From 32820093d6ceee7597d656663889c3f5d53601f7 Mon Sep 17 00:00:00 2001 From: baekjosh <352828215+baekjosh@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:02:19 -0800 Subject: [PATCH 1/4] feat(canvas): resize the Pages and Layers split - Drag the edge between the Pages list and the Layers tree, or focus it and use the arrow keys (10px a press); Home and End take it to its limits. - Store the split per browser as a percentage of the rail height. CSS and JS both clamp it, so Pages keeps its heading and one row and Layers keeps room for a few rows at any window height. - Until the split is dragged, the Pages list keeps its 30vh cap. - Replace PagesPanel's unused fill prop with the split props. - Tests: clamp, key and storage rules as unit tests; headless Chromium drives a real mouse drag, keyboard steps and a reload. --- src/components/LayersPanel.tsx | 5 ++- src/components/PagesPanel.tsx | 72 ++++++++++++++++++++++++++++-- src/lib/i18n/en/panels.ts | 1 + src/lib/i18n/pt-BR/panels.ts | 1 + src/lib/pagesSplit.ts | 77 ++++++++++++++++++++++++++++++++ tests/canvasPageFixture.ts | 24 +++++++--- tests/fixtures/canvasPage.html | 12 ++++- tests/pagesSplit.test.ts | 45 +++++++++++++++++++ tests/pagesSplitBrowser.test.ts | 78 +++++++++++++++++++++++++++++++++ 9 files changed, 302 insertions(+), 13 deletions(-) create mode 100644 src/lib/pagesSplit.ts create mode 100644 tests/pagesSplit.test.ts create mode 100644 tests/pagesSplitBrowser.test.ts diff --git a/src/components/LayersPanel.tsx b/src/components/LayersPanel.tsx index 45d6dfa1d..16400f5ef 100644 --- a/src/components/LayersPanel.tsx +++ b/src/components/LayersPanel.tsx @@ -14,6 +14,7 @@ import type { ComponentDef } from '../../shared/components' import { canEditOpenCanvas, pickedSelectors, useStore } from '../lib/store' import { currentPageCanvas, usePageCanvas } from '../lib/pages' import { PagesPanel, sectionHeading } from './PagesPanel' +import { usePagesPct } from '../lib/pagesSplit' import { getIdentity } from '../lib/identity' import { deleteFramesTracked } from '../lib/history' import { api } from '../lib/api' @@ -258,6 +259,8 @@ export function LayersPanel({ const setLayersOpen = useStore((s) => s.setLayersOpen) const t = useT() const [query, setQuery] = useState('') + /* the Pages section's share of the rail, once dragged; kept across reloads */ + const [pagesPct, setPagesPct] = usePagesPct() const [expanded, setExpanded] = useState>(() => new Set()) /* the row being dragged and where it would land; the pointer handlers are bound to the window for the length of the press, so they read the rows @@ -581,7 +584,7 @@ export function LayersPanel({ <> {/* Figma's order: the pages at the top, the frames of the active page under them, the search at the bottom within thumb's reach */} - +
{t('panels.layersTitle')} diff --git a/src/components/PagesPanel.tsx b/src/components/PagesPanel.tsx index 7532990b6..b1f7ba846 100644 --- a/src/components/PagesPanel.tsx +++ b/src/components/PagesPanel.tsx @@ -8,6 +8,7 @@ import { ApiError } from '../lib/api' import { Button } from './ui/button' import { PageIcon, PlusIcon } from './ui/icons' import { cn } from '../lib/utils' +import { clampPagesPx, pagesHeightCss, pagesPctOf, pagesPxAfterKey } from '../lib/pagesSplit' import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuItem } from './ui/context-menu' import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './ui/select' import { useT } from '@/lib/i18n' @@ -18,7 +19,15 @@ import { useT } from '@/lib/i18n' export const sectionHeading = 'text-[11px] font-normal text-ink-faint' const sectionBtn = 'size-5 rounded-[5px] text-ink-faint hover:bg-paper-deep hover:text-ink' -export function PagesPanel({ fill = false }: { fill?: boolean }) { +export function PagesPanel({ + pagesPct = null, + onPagesPctChange, +}: { + /** the section's share of the rail's height once dragged; null keeps its own height */ + pagesPct?: number | null + /** given in the Layers rail: the section's bottom edge is the handle that sets the share */ + onPagesPctChange?: (pct: number) => void +}) { const canvas = useStore((s) => s.canvas) const activePageId = useStore((s) => s.activePageId) const selectedIds = useStore((s) => s.selectedIds) @@ -301,14 +310,20 @@ export function PagesPanel({ fill = false }: { fill?: boolean }) { ) return ( -
+
{t('panels.pagesTitle')} {!readOnly && addPage}
-
{list}
+
+ {list} +
{!readOnly && selectedIds.length > 0 && pages.length > 1 && ( /* the canvas shortcuts listen on window: ⌫ would delete the frames being moved and typed letters would switch tools, so the picker's @@ -331,6 +346,57 @@ export function PagesPanel({ fill = false }: { fill?: boolean }) {
)} + {onPagesPctChange && }
) } + +/** The Pages section's bottom edge: dragged, or moved with the arrow keys, Home and End. Each step measures the + * section and its rail again, so it starts from what is on screen. The browser releases the pointer's capture + * when the drag ends, which resets the drag. */ +function PagesSplitHandle({ onChange }: { onChange: (pct: number) => void }) { + const t = useT() + const drag = useRef<{ y: number; pagesPx: number; railPx: number } | null>(null) + return ( +
{ + if (e.button !== 0) return + e.preventDefault() + e.stopPropagation() + drag.current = { y: e.clientY, ...measurePages(e.currentTarget) } + e.currentTarget.setPointerCapture(e.pointerId) + }} + onPointerMove={(e) => { + const start = drag.current + if (!start) return + e.stopPropagation() + const px = clampPagesPx(start.pagesPx + e.clientY - start.y, start.railPx) + onChange(pagesPctOf(px, start.railPx)) + }} + onLostPointerCapture={() => { + drag.current = null + }} + onKeyDown={(e) => { + const { pagesPx, railPx } = measurePages(e.currentTarget) + const px = pagesPxAfterKey(e.key, pagesPx, railPx) + if (px === undefined) return + e.preventDefault() + e.stopPropagation() + onChange(pagesPctOf(px, railPx)) + }} + /> + ) +} + +/** The Pages section and the rail it sits in, both in px. */ +function measurePages(handle: HTMLElement) { + const pages = handle.closest('[data-slot="pages-panel"]')! + const rail = handle.closest('[data-slot="panel"]')! + return { pagesPx: pages.getBoundingClientRect().height, railPx: rail.getBoundingClientRect().height } +} diff --git a/src/lib/i18n/en/panels.ts b/src/lib/i18n/en/panels.ts index 201156cf6..aaaea0e9e 100644 --- a/src/lib/i18n/en/panels.ts +++ b/src/lib/i18n/en/panels.ts @@ -35,6 +35,7 @@ export const panels = { pagesMoveFailed: 'Could not move all selected frames to the page', pagesSaveFailed: 'Could not save pages', pagesDuplicateFailed: 'Could not duplicate the page', + pagesResize: 'Resize pages', memoryIntro: 'Memory is how this canvas remembers your taste — and how every agent designs with it.', memoryReferences: 'References', diff --git a/src/lib/i18n/pt-BR/panels.ts b/src/lib/i18n/pt-BR/panels.ts index 81e026422..b93acec8d 100644 --- a/src/lib/i18n/pt-BR/panels.ts +++ b/src/lib/i18n/pt-BR/panels.ts @@ -35,6 +35,7 @@ export const panels: Catalog['panels'] = { pagesMoveFailed: 'Não foi possível mover todos os frames selecionados para a página', pagesSaveFailed: 'Não foi possível salvar as páginas', pagesDuplicateFailed: 'Não foi possível duplicar a página', + pagesResize: 'Redimensionar páginas', memoryIntro: 'A Memória é como este canvas lembra do seu gosto — e como cada agente cria designs com ele.', memoryReferences: 'Referências', diff --git a/src/lib/pagesSplit.ts b/src/lib/pagesSplit.ts new file mode 100644 index 000000000..b2958548a --- /dev/null +++ b/src/lib/pagesSplit.ts @@ -0,0 +1,77 @@ +/* The split between the Pages list and the Layers tree in the canvas rail. + It is kept as a percentage of the rail's height, so one split fits any + window. `pagesHeightCss` clamps it again in CSS, so a window that shrinks + below the size the split was dragged in still shows both lists. */ +import { useEffect, useState } from 'react' + +/** the least the Pages section gets: its heading and one row */ +export const PAGES_MIN_PX = 54 +/** what the Layers tree always keeps: the rail's header, the Layers heading + * and search footer, and room for a few rows */ +export const LAYERS_MIN_PX = 240 +/** how far one arrow press moves the split */ +export const PAGES_KEY_STEP_PX = 10 + +const STORAGE_KEY = 'doop:layers-pages-split' + +/** a Pages height, held between its minimum and the room the Layers tree keeps */ +export function clampPagesPx(px: number, railPx: number): number { + const max = Math.max(PAGES_MIN_PX, railPx - LAYERS_MIN_PX) + return Math.min(max, Math.max(PAGES_MIN_PX, px)) +} + +/** a Pages height as a percentage of the rail */ +export function pagesPctOf(px: number, railPx: number): number { + return (px / railPx) * 100 +} + +/** the CSS height of the Pages section for a stored percentage, with the limits `clampPagesPx` applies */ +export function pagesHeightCss(pct: number): string { + return `clamp(${PAGES_MIN_PX}px, ${pct}%, calc(100% - ${LAYERS_MIN_PX}px))` +} + +/** the Pages height an arrow key, Home or End asks for; undefined for any other key. + * Home and End clamp infinity, so they stop at the same limits as a drag. */ +export function pagesPxAfterKey(key: string, pagesPx: number, railPx: number): number | undefined { + switch (key) { + case 'ArrowUp': + return clampPagesPx(pagesPx - PAGES_KEY_STEP_PX, railPx) + case 'ArrowDown': + return clampPagesPx(pagesPx + PAGES_KEY_STEP_PX, railPx) + case 'Home': + return clampPagesPx(-Infinity, railPx) + case 'End': + return clampPagesPx(Infinity, railPx) + default: + return undefined + } +} + +/** a stored split, or null when it is missing or not a percentage of the rail */ +export function readPagesPct(raw: string | null): number | null { + if (raw === null) return null + const pct = Number(raw) + return Number.isFinite(pct) && pct > 0 && pct < 100 ? pct : null +} + +/** The split as the user last left it, kept per browser; null until it is dragged. */ +export function usePagesPct(): [number | null, (pct: number | null) => void] { + const [pct, setPct] = useState(readStoredPct) + useEffect(() => { + try { + if (pct === null) localStorage.removeItem(STORAGE_KEY) + else localStorage.setItem(STORAGE_KEY, String(pct)) + } catch { + /* the split still works when it cannot be saved */ + } + }, [pct]) + return [pct, setPct] +} + +function readStoredPct(): number | null { + try { + return readPagesPct(localStorage.getItem(STORAGE_KEY)) + } catch { + return null + } +} diff --git a/tests/canvasPageFixture.ts b/tests/canvasPageFixture.ts index af459bb18..6ceea1763 100644 --- a/tests/canvasPageFixture.ts +++ b/tests/canvasPageFixture.ts @@ -1,10 +1,10 @@ import type { Page } from 'puppeteer-core' -import type { Frame } from '../shared/types' +import type { CanvasPageInfo, Frame } from '../shared/types' import { fixtureUrl } from './browser' declare global { interface Window { - canvasPageHarness: { seed: (frames: Frame[]) => void } + canvasPageHarness: { seed: (frames: Frame[], pages?: CanvasPageInfo[]) => void } } } @@ -18,11 +18,16 @@ export function canvasFrame(frame: Pick { +export async function openCanvasPage( + page: Page, + frames: Frame[], + search = '', + pages?: CanvasPageInfo[], +): Promise { await prepareCanvasPage(page) - await showCanvasPage(page, frames, search) + await showCanvasPage(page, frames, search, pages) } /** The stubs alone, for a test that has something to do before the page loads. */ @@ -51,9 +56,14 @@ export async function prepareCanvasPage(page: Page): Promise { } /** Load the fixture, or load it again, on a prepared page. */ -export async function showCanvasPage(page: Page, frames: Frame[], search = ''): Promise { +export async function showCanvasPage( + page: Page, + frames: Frame[], + search = '', + pages?: CanvasPageInfo[], +): Promise { await page.goto(fixtureUrl(`canvasPage.html${search}`)) await page.waitForFunction(() => !!window.canvasPageHarness && !!document.querySelector('.stage')) - await page.evaluate((frames) => window.canvasPageHarness.seed(frames), frames) + await page.evaluate((frames, pages) => window.canvasPageHarness.seed(frames, pages), frames, pages) await page.waitForSelector('[data-frame-title]') } diff --git a/tests/fixtures/canvasPage.html b/tests/fixtures/canvasPage.html index 5cddd03f1..3bccdaddd 100644 --- a/tests/fixtures/canvasPage.html +++ b/tests/fixtures/canvasPage.html @@ -16,8 +16,16 @@ /* the canvas page as an editor has it open, with all its chrome; the test hands it the canvas the room would have sent */ window.canvasPageHarness = { - seed: (frames) => - useStore.getState().setCanvas({ id: 'c', name: 'Canvas', frames, role: 'edit', createdAt: 0, updatedAt: 0 }), + seed: (frames, pages) => + useStore.getState().setCanvas({ + id: 'c', + name: 'Canvas', + frames, + pages, + role: 'edit', + createdAt: 0, + updatedAt: 0, + }), } createRoot(document.getElementById('root')).render( React.createElement(TooltipProvider, null, React.createElement(CanvasPage, { canvasId: 'c' })), diff --git a/tests/pagesSplit.test.ts b/tests/pagesSplit.test.ts new file mode 100644 index 000000000..f4f0b6a6e --- /dev/null +++ b/tests/pagesSplit.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it } from 'vitest' +import { LAYERS_MIN_PX, PAGES_MIN_PX, clampPagesPx, pagesPxAfterKey, readPagesPct } from '../src/lib/pagesSplit' + +describe('clampPagesPx', () => { + it('holds the Pages section between its minimum and the room the Layers tree keeps', () => { + expect(clampPagesPx(-500, 800)).toBe(PAGES_MIN_PX) + expect(clampPagesPx(10_000, 800)).toBe(800 - LAYERS_MIN_PX) + expect(clampPagesPx(300, 800)).toBe(300) + }) + + it('keeps one row of Pages in a rail too short to hold both lists', () => { + expect(clampPagesPx(400, 200)).toBe(PAGES_MIN_PX) + }) +}) + +describe('pagesPxAfterKey', () => { + it('moves the split one step per arrow press and stops at its limits', () => { + expect(pagesPxAfterKey('ArrowDown', 300, 800)).toBe(310) + expect(pagesPxAfterKey('ArrowUp', 300, 800)).toBe(290) + expect(pagesPxAfterKey('ArrowUp', PAGES_MIN_PX, 800)).toBe(PAGES_MIN_PX) + }) + + it('takes Home and End to the two limits', () => { + expect(pagesPxAfterKey('Home', 300, 800)).toBe(PAGES_MIN_PX) + expect(pagesPxAfterKey('End', 300, 800)).toBe(800 - LAYERS_MIN_PX) + }) + + it('leaves every other key to the page', () => { + expect(pagesPxAfterKey('a', 300, 800)).toBeUndefined() + }) +}) + +describe('readPagesPct', () => { + it('keeps a stored split', () => { + expect(readPagesPct('37.5')).toBe(37.5) + }) + + it('drops anything that is not a split of the rail, so a bad value falls back to the default', () => { + expect(readPagesPct(null)).toBeNull() + expect(readPagesPct('')).toBeNull() + expect(readPagesPct('tall')).toBeNull() + expect(readPagesPct('0')).toBeNull() + expect(readPagesPct('100')).toBeNull() + }) +}) diff --git a/tests/pagesSplitBrowser.test.ts b/tests/pagesSplitBrowser.test.ts new file mode 100644 index 000000000..6416bb7f6 --- /dev/null +++ b/tests/pagesSplitBrowser.test.ts @@ -0,0 +1,78 @@ +import type { Page } from 'puppeteer-core' +import { beforeEach, describe, expect, it } from 'vitest' +import { findBrowserPath } from '../server/screenshot' +import { LAYERS_MIN_PX, PAGES_MIN_PX } from '../src/lib/pagesSplit' +import { pagePerTest } from './browser' +import { canvasFrame, openCanvasPage, showCanvasPage } from './canvasPageFixture' + +/* enough pages to reach the Pages list's 30vh cap in an 800px window */ +const PAGES = Array.from({ length: 12 }, (_, i) => ({ id: `p${i + 1}`, name: `Page ${i + 1}` })) +const FRAMES = [canvasFrame({ id: 'f1', name: 'Home', x: 0, y: 0, width: 100, height: 100 })] + +describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { + const pages = pagePerTest() + let page: Page + + beforeEach(async () => { + page = await pages.open() + await page.setViewport({ width: 1280, height: 800 }) + await openCanvasPage(page, FRAMES, '', PAGES) + }) + + /** the Pages section, the Layers tree and the rail they share, in px */ + const sizes = () => + page.evaluate(() => { + const pagesEl = document.querySelector('[data-slot="pages-panel"]')! + const rail = pagesEl.closest('[data-slot="panel"]')! + const tree = rail.querySelector('[role="tree"]')! + return { + pages: pagesEl.getBoundingClientRect().height, + tree: tree.getBoundingClientRect().height, + rail: rail.getBoundingClientRect().height, + } + }) + + /** press the split and drag it `dy` px, in steps the way a hand moves */ + async function dragSplit(dy: number) { + const box = await (await page.$('[data-slot="pages-split"]'))!.boundingBox() + const x = box!.x + box!.width / 2 + const y = box!.y + box!.height / 2 + await page.mouse.move(x, y) + await page.mouse.down() + await page.mouse.move(x, y + dy, { steps: 8 }) + await page.mouse.up() + } + + it('dragging the split up gives the Layers tree the room the Pages list gives up', async () => { + const before = await sizes() + await dragSplit(-120) + const after = await sizes() + expect(before.pages - after.pages).toBeCloseTo(120, 0) + expect(after.tree - before.tree).toBeCloseTo(120, 0) + }) + + it('stops the split where the Layers tree keeps its minimum room', async () => { + await dragSplit(2000) + const { pages: pagesPx, rail } = await sizes() + expect(pagesPx).toBeCloseTo(rail - LAYERS_MIN_PX, 0) + }) + + it('moves the split 10px an arrow press, and Home and End take it to its limits', async () => { + const start = await sizes() + await (await page.$('[data-slot="pages-split"]'))!.focus() + await page.keyboard.press('ArrowUp') + expect((await sizes()).pages).toBeCloseTo(start.pages - 10, 0) + await page.keyboard.press('Home') + expect((await sizes()).pages).toBeCloseTo(PAGES_MIN_PX, 0) + await page.keyboard.press('End') + const end = await sizes() + expect(end.pages).toBeCloseTo(end.rail - LAYERS_MIN_PX, 0) + }) + + it('keeps the split when the page loads again', async () => { + await dragSplit(-120) + const dragged = await sizes() + await showCanvasPage(page, FRAMES, '', PAGES) + expect((await sizes()).pages).toBeCloseTo(dragged.pages, 0) + }) +}) From e5bb2080bbc4f3c33ad8fc35164d9f0bfca695b3 Mon Sep 17 00:00:00 2001 From: baekjosh <352828215+baekjosh@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:05:45 -0800 Subject: [PATCH 2/4] fix(canvas): keep a page row and the move picker inside Pages - At 54px, a selected frame's move picker (40px) left the Pages list no room for its 27px row, so the first row was clipped. - The minimum is now 101px: heading 30 + row 27 + list padding 4 + picker 40. - The browser test selects a frame, presses Home, and checks that the first row and the picker sit inside their Pages section. - The unit test is renamed to name the minimum, not one row. --- src/lib/pagesSplit.ts | 5 +++-- tests/pagesSplit.test.ts | 2 +- tests/pagesSplitBrowser.test.ts | 23 +++++++++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/lib/pagesSplit.ts b/src/lib/pagesSplit.ts index b2958548a..b7b92c405 100644 --- a/src/lib/pagesSplit.ts +++ b/src/lib/pagesSplit.ts @@ -4,8 +4,9 @@ below the size the split was dragged in still shows both lists. */ import { useEffect, useState } from 'react' -/** the least the Pages section gets: its heading and one row */ -export const PAGES_MIN_PX = 54 +/** the least the Pages section gets, so its heading, one page row and the move picker + * (30 + 27 + 4 + 40px) all fit; PagesPanel's classes set those sizes */ +export const PAGES_MIN_PX = 101 /** what the Layers tree always keeps: the rail's header, the Layers heading * and search footer, and room for a few rows */ export const LAYERS_MIN_PX = 240 diff --git a/tests/pagesSplit.test.ts b/tests/pagesSplit.test.ts index f4f0b6a6e..cd350ce43 100644 --- a/tests/pagesSplit.test.ts +++ b/tests/pagesSplit.test.ts @@ -8,7 +8,7 @@ describe('clampPagesPx', () => { expect(clampPagesPx(300, 800)).toBe(300) }) - it('keeps one row of Pages in a rail too short to hold both lists', () => { + it('keeps the Pages minimum in a rail too short to hold both lists', () => { expect(clampPagesPx(400, 200)).toBe(PAGES_MIN_PX) }) }) diff --git a/tests/pagesSplitBrowser.test.ts b/tests/pagesSplitBrowser.test.ts index 6416bb7f6..6d9eeea3e 100644 --- a/tests/pagesSplitBrowser.test.ts +++ b/tests/pagesSplitBrowser.test.ts @@ -75,4 +75,27 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { await showCanvasPage(page, FRAMES, '', PAGES) expect((await sizes()).pages).toBeCloseTo(dragged.pages, 0) }) + + it('keeps one page row and the move picker inside the Pages section while a frame is selected', async () => { + await page.click('[role="treeitem"][data-row-key="f1"]') + await page.waitForSelector('[data-slot="pages-panel"] [data-slot="select-trigger"]') + await (await page.$('[data-slot="pages-split"]'))!.focus() + await page.keyboard.press('Home') + const fit = await page.evaluate(() => { + const edges = (el: Element) => { + const { top, bottom, height } = el.getBoundingClientRect() + return { top, bottom, height } + } + const pagesEl = document.querySelector('[data-slot="pages-panel"]')! + const row = pagesEl.querySelector('[data-page-id]')! + return { + pages: edges(pagesEl), + list: edges(row.parentElement!), + row: edges(row), + picker: edges(pagesEl.querySelector('[data-slot="select-trigger"]')!), + } + }) + expect(fit.row.bottom).toBeLessThanOrEqual(fit.list.bottom + 0.5) + expect(fit.picker.bottom).toBeLessThanOrEqual(fit.pages.bottom + 0.5) + }) }) From 56c860aeb583763b03063a3468408c303c3beb01 Mon Sep 17 00:00:00 2001 From: baekjosh <352828215+baekjosh@users.noreply.github.com> Date: Mon, 16 Nov 2026 17:26:57 -0800 Subject: [PATCH 3/4] fix(pages): finish compact Pages and Layers resizing - Merge current upstream and preserve the richer canvas fixture contract. - Keep sparse page lists compact and draw a full-width panel-color divider. - Account for the move picker in the minimum and report live separator values. - Cover sparse lists, dragging, keyboard limits, persistence, and selection changes. --- .context/DESIGN.md | 5 +- .context/RELEASE.md | 5 + .context/TECHSTACK.md | 312 +- .context/specs/INDEX.md | 4 + .context/specs/components.md | 136 +- .context/specs/frame-approval.md | 17 +- .context/specs/workspace-component-library.md | 259 + .context/specs/workspaces-billing.md | 4 +- .env.example | 57 + .github/workflows/android.yml | 51 + .prettierignore | 4 + .release-please-manifest.json | 4 +- CHANGELOG.md | 125 + README.md | 25 +- android/.gitignore | 7 + android/README.md | 120 + android/app/build.gradle.kts | 69 + android/app/proguard-rules.pro | 1 + .../design/doop/android/AndroidFlowTest.kt | 319 ++ .../design/doop/android/BlitzRenderTest.kt | 87 + android/app/src/debug/AndroidManifest.xml | 3 + .../debug/res/xml/debug_network_security.xml | 6 + android/app/src/main/AndroidManifest.xml | 27 + .../app/src/main/assets/HankenGrotesk-OFL.txt | 94 + android/app/src/main/assets/Inter-OFL.txt | 93 + .../app/src/main/assets/Lucide-LICENSE.txt | 43 + android/app/src/main/assets/SelectionDOM.js | 81 + android/app/src/main/cpp/blitz_jni.c | 76 + .../design/doop/android/AgentFollowService.kt | 65 + .../main/java/design/doop/android/AppModel.kt | 118 + .../design/doop/android/BlitzCanvasView.kt | 211 + .../java/design/doop/android/BlitzNative.kt | 38 + .../java/design/doop/android/CanvasModel.kt | 267 + .../java/design/doop/android/CanvasScreen.kt | 225 + .../java/design/doop/android/DoopClient.kt | 107 + .../java/design/doop/android/DoopIcons.kt | 44 + .../java/design/doop/android/DoopTheme.kt | 89 + .../java/design/doop/android/MainActivity.kt | 241 + .../main/java/design/doop/android/Models.kt | 124 + .../design/doop/android/SelectionActions.kt | 103 + .../src/main/res/drawable-nodpi/app_mark.png | Bin 0 -> 12868 bytes .../app/src/main/res/drawable/apple_mark.xml | 1 + .../app/src/main/res/drawable/doop_logo.xml | 8 + .../app/src/main/res/drawable/google_mark.xml | 6 + .../src/main/res/drawable/microsoft_mark.xml | 6 + .../app/src/main/res/font/hanken_grotesk.ttf | Bin 0 -> 132892 bytes android/app/src/main/res/font/inter.ttf | Bin 0 -> 876576 bytes android/app/src/main/res/values/styles.xml | 8 + .../main/res/xml/data_extraction_rules.xml | 17 + android/app/src/main/res/xml/export_paths.xml | 1 + .../java/design/doop/android/ModelTest.kt | 71 + android/build.gradle.kts | 4 + android/gradle.properties | 4 + android/gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 45457 bytes .../gradle/wrapper/gradle-wrapper.properties | 8 + android/gradlew | 248 + android/gradlew.bat | 93 + android/scripts/build-native.py | 36 + android/settings.gradle.kts | 7 + bun.lock | 19 + desktop/CHANGELOG.md | 13 + desktop/package.json | 2 +- desktop/src-tauri-chromium/Cargo.toml | 2 +- desktop/src-tauri-chromium/tauri.conf.json | 2 +- desktop/src-tauri/Cargo.toml | 2 +- desktop/src-tauri/src/claude.rs | 2 +- desktop/src-tauri/tauri.conf.json | 2 +- ios/BlitzKit/rust/Cargo.lock | 39 +- ios/BlitzKit/rust/Cargo.toml | 48 +- ios/BlitzKit/rust/src/lib.rs | 175 +- ios/BlitzKit/rust/tests/imported_pages.rs | 144 + ios/Doop.xcodeproj/project.pbxproj | 8 +- ios/Doop/CanvasModel.swift | 4 +- ios/Doop/ContentView.swift | 32 +- ios/Doop/Core/Models.swift | 68 +- ios/Doop/NativeCanvasView.swift | 101 +- ios/README.md | 11 + ios/Tests/ServerAddressTests.swift | 29 +- package.json | 3 +- public/doop-sync.js | 25 +- server/accountDeletion.ts | 4 + server/actions.ts | 1127 +++- server/assets.ts | 34 +- server/automations.ts | 17 +- server/canvasFaces.ts | 30 + server/canvasFontUpload.ts | 50 + server/componentActions.ts | 1251 +++- server/componentCss.ts | 178 +- server/componentEngine.ts | 406 +- server/componentLibrary.ts | 427 ++ server/componentPreview.ts | 20 +- server/componentTools.ts | 511 +- server/componentUsage.ts | 92 + server/components.ts | 172 +- server/customAgentRoutes.ts | 149 + server/customAgents.ts | 325 ++ .../db/migrations/0053_library_components.sql | 17 + .../0054_library_publish_policy.sql | 1 + .../0055_library_nested_sources.sql | 1 + server/db/migrations/0056_work_replies.sql | 2 + server/db/migrations/0057_custom_agents.sql | 30 + .../migrations/0058_component_soft_delete.sql | 3 + .../0059_workspace_seats_bought.sql | 1 + server/db/migrations/meta/0053_snapshot.json | 4755 ++++++++++++++++ server/db/migrations/meta/0054_snapshot.json | 4761 ++++++++++++++++ server/db/migrations/meta/0055_snapshot.json | 4767 ++++++++++++++++ server/db/migrations/meta/0056_snapshot.json | 4779 ++++++++++++++++ server/db/migrations/meta/0057_snapshot.json | 4981 ++++++++++++++++ server/db/migrations/meta/0058_snapshot.json | 5000 ++++++++++++++++ server/db/migrations/meta/0059_snapshot.json | 5007 +++++++++++++++++ server/db/migrations/meta/_journal.json | 49 + server/db/persist.ts | 221 +- server/db/schema.ts | 90 + server/entitlements.ts | 56 + server/env.ts | 41 +- server/existingStyle.ts | 119 + server/featureEvents.ts | 35 + server/fontRoutes.ts | 5 +- server/fonts.ts | 62 +- server/guide.ts | 557 +- server/hostedCopies.ts | 143 + server/icoImage.ts | 116 + server/iconProxy.ts | 95 + server/imageDescriptions.ts | 5 +- server/imageGen.ts | 75 +- server/imageSearch.ts | 100 +- server/importer.ts | 12 +- server/index.ts | 518 +- server/inlineData.ts | 88 + server/journal.ts | 355 ++ server/layerExport.ts | 86 + server/mcp.ts | 421 +- server/parse5Select.ts | 157 + server/pdfExport.ts | 4 +- server/photoProxy.ts | 100 + server/previews.ts | 16 +- server/propagation.ts | 385 ++ server/publicUrl.ts | 17 +- server/renderBrowser.ts | 594 ++ server/renderLimits.ts | 16 + server/resident.ts | 475 +- server/reuseNotes.ts | 229 + server/screenshot.ts | 326 +- server/seed.ts | 4 + server/stallWatchdog.ts | 213 + server/stallWatcher.mjs | 93 + server/storage.ts | 3 +- server/store.ts | 304 +- server/thumbs.ts | 2 + server/toolLoads.ts | 15 +- server/workBudget.ts | 215 + server/workspaces.ts | 137 +- shared/agentBrand.ts | 53 + shared/agents.ts | 64 +- shared/asciiSearch.ts | 31 + shared/automations.ts | 36 +- shared/billing.ts | 67 +- shared/components.ts | 84 +- shared/customAgents.ts | 191 + shared/designTokens.ts | 8 +- shared/imageDescriptions.ts | 2 + shared/modelMenu.ts | 63 +- shared/pages.ts | 29 + shared/types.ts | 44 + src/App.tsx | 9 +- src/components/ActivityPanel.tsx | 121 +- src/components/AgentChat.tsx | 99 + src/components/AgentIcon.tsx | 76 +- src/components/AppRail.tsx | 64 +- src/components/AutomateShell.tsx | 5 +- src/components/CanvasSearchModal.tsx | 18 +- src/components/CodePanel.tsx | 52 - src/components/CommentPopovers.tsx | 16 +- src/components/ComponentImport.tsx | 267 + src/components/ComponentSection.tsx | 182 +- src/components/ComponentThumb.tsx | 95 + src/components/ComponentsPanel.tsx | 480 +- src/components/ConnectModal.tsx | 6 +- src/components/Cursors.tsx | 2 +- src/components/CustomAgents.tsx | 428 ++ src/components/DashShell.tsx | 24 +- src/components/DesktopTabs.tsx | 23 +- src/components/ElementContextMenu.tsx | 26 +- src/components/ElementMove.tsx | 95 +- src/components/ElementPanel.tsx | 156 +- src/components/ExportModal.tsx | 4 +- src/components/ExportOptions.tsx | 12 +- src/components/FlexLayoutControls.tsx | 4 + src/components/FollowFrame.tsx | 2 +- src/components/FontLibrary.tsx | 21 +- src/components/FrameApproval.tsx | 7 +- src/components/FrameContextMenu.tsx | 10 +- src/components/FrameExportModal.tsx | 3 + src/components/FrameView.tsx | 224 +- src/components/GhostFrames.tsx | 2 +- src/components/HomeHero.tsx | 155 +- src/components/ImageDescriptionsCard.tsx | 51 +- src/components/ImageFill.tsx | 180 +- src/components/ImageModelCard.tsx | 91 +- src/components/Inspector.tsx | 17 +- src/components/InteractionsPanel.tsx | 6 +- src/components/LayerExportSection.tsx | 52 + src/components/LayersPanel.tsx | 90 +- src/components/LibrarySection.tsx | 525 ++ src/components/LibraryUpdateEverywhere.tsx | 83 + src/components/MainMenu.tsx | 2 +- src/components/NativeAppPromo.tsx | 217 + src/components/Onboarding.tsx | 6 +- src/components/PagesPanel.tsx | 90 +- src/components/PeerAvatars.tsx | 6 +- src/components/PlanCards.tsx | 180 + src/components/PlanSettings.tsx | 110 + src/components/PromptBar.tsx | 14 +- src/components/PrototypePlayer.tsx | 6 + src/components/SeatStepper.tsx | 64 + src/components/Stage.tsx | 11 +- src/components/UpgradeHost.tsx | 12 + src/components/WorkingNow.tsx | 2 +- src/components/WorkspaceLibraries.tsx | 103 + src/components/WorkspaceModals.tsx | 347 +- src/components/ui/avatar.tsx | 7 +- src/components/ui/brand-mark.tsx | 55 +- src/components/ui/button.tsx | 3 + src/components/ui/icons.tsx | 57 +- src/components/ui/input.tsx | 3 + src/components/ui/panel.tsx | 31 +- src/components/ui/property-field.tsx | 107 +- src/components/ui/select.tsx | 3 + src/hooks/use-roster.ts | 31 + src/hooks/use-value-slide.ts | 172 + src/lib/actions/edits.ts | 231 +- src/lib/actions/registry.ts | 16 + src/lib/agentChat.ts | 64 + src/lib/agentsSplit.ts | 36 + src/lib/api.ts | 154 +- src/lib/components.ts | 108 +- src/lib/composerFlight.ts | 20 + src/lib/desktop.ts | 51 + src/lib/drawing.ts | 26 +- src/lib/drawingMove.ts | 33 +- src/lib/exportEvents.ts | 24 + src/lib/frameBleed.ts | 21 + src/lib/frameBridge.ts | 53 +- src/lib/frameClipboard.ts | 9 + src/lib/frameDropRuntime.ts | 108 +- src/lib/frameReplay.ts | 12 +- src/lib/frameRuntime.ts | 397 +- src/lib/groupLayout.ts | 172 + src/lib/homePrompt.ts | 15 +- src/lib/i18n/en/actions.ts | 1 + src/lib/i18n/en/agents.ts | 57 + src/lib/i18n/en/components.ts | 96 +- src/lib/i18n/en/home.ts | 20 +- src/lib/i18n/en/index.ts | 4 + src/lib/i18n/en/inspector.ts | 8 +- src/lib/i18n/en/models.ts | 12 +- src/lib/i18n/en/panels.ts | 10 +- src/lib/i18n/en/plans.ts | 114 + src/lib/i18n/en/rail.ts | 2 + src/lib/i18n/en/settings.ts | 21 +- src/lib/i18n/en/shell.ts | 12 +- src/lib/i18n/en/stage.ts | 2 +- src/lib/i18n/en/workspace.ts | 32 +- src/lib/i18n/pt-BR/actions.ts | 1 + src/lib/i18n/pt-BR/agents.ts | 59 + src/lib/i18n/pt-BR/components.ts | 99 +- src/lib/i18n/pt-BR/home.ts | 20 +- src/lib/i18n/pt-BR/index.ts | 4 + src/lib/i18n/pt-BR/inspector.ts | 8 +- src/lib/i18n/pt-BR/models.ts | 13 +- src/lib/i18n/pt-BR/panels.ts | 10 +- src/lib/i18n/pt-BR/plans.ts | 109 + src/lib/i18n/pt-BR/rail.ts | 2 + src/lib/i18n/pt-BR/settings.ts | 21 +- src/lib/i18n/pt-BR/shell.ts | 10 +- src/lib/i18n/pt-BR/stage.ts | 2 +- src/lib/i18n/pt-BR/workspace.ts | 33 +- src/lib/layerEdits.ts | 6 +- src/lib/layers.ts | 148 +- src/lib/library.ts | 116 + src/lib/libraryResume.ts | 167 + src/lib/me.ts | 27 +- src/lib/nativeApp.ts | 74 + src/lib/pageLink.ts | 53 + src/lib/pageUrl.ts | 48 + src/lib/pagesSplit.ts | 47 +- src/lib/planFeatures.ts | 124 + src/lib/prototype.ts | 2 + src/lib/store.ts | 15 +- src/lib/upgrade.ts | 84 + src/lib/ws.ts | 6 + src/pages/AutomationEditor.tsx | 15 +- src/pages/Automations.tsx | 4 +- src/pages/CanvasPage.tsx | 38 +- src/pages/Home.tsx | 18 +- src/pages/Settings.tsx | 60 +- src/pages/Workspace.tsx | 120 +- src/stories/Button.stories.tsx | 2 + src/stories/Fields.stories.tsx | 25 +- src/stories/Shell.stories.tsx | 18 + src/styles.css | 12 + tests/accountDeletion.test.ts | 4 +- tests/accountMenu.test.tsx | 2 +- tests/agentBrand.test.ts | 45 + tests/agentChat.test.ts | 136 + tests/appMenu.test.ts | 2 + tests/automations.test.ts | 18 +- tests/backgrounds.test.ts | 8 +- tests/billing.test.ts | 53 +- tests/canvasPageFixture.ts | 22 +- tests/commentThreadStackBrowser.test.ts | 123 + tests/componentCssAncestors.test.ts | 167 + tests/componentDrops.test.ts | 158 + tests/componentHollow.test.ts | 218 + tests/componentImport.test.tsx | 153 + tests/componentPartKeys.test.ts | 130 + tests/componentPersistOrder.test.ts | 143 + tests/componentSectionDeleted.test.tsx | 131 + tests/componentSoftDelete.test.ts | 599 ++ tests/componentSoftDeleteRoutes.test.ts | 129 + tests/componentTableParts.test.ts | 135 + tests/componentTools.test.ts | 321 +- tests/componentUnicode.test.ts | 76 + tests/componentUsage.test.ts | 187 + tests/components.test.ts | 19 +- tests/componentsBehind.test.ts | 73 + tests/componentsBrowser.test.ts | 119 + tests/componentsCatchUp.test.ts | 99 + tests/componentsEdgeCases.test.ts | 35 +- tests/composerFlight.test.ts | 54 + tests/customAgentScopes.test.ts | 42 + tests/customAgents.test.ts | 209 + tests/customAgentsHttp.test.ts | 263 + tests/designTokenWrites.test.ts | 51 + tests/desktopTabShortcuts.test.ts | 72 + tests/drawingMove.test.ts | 2 +- tests/drawingMoveBrowser.test.ts | 4 +- tests/drawingReorderBrowser.test.ts | 69 + tests/drawingShapesBrowser.test.ts | 88 +- tests/elementPanelBrowser.test.ts | 65 +- tests/env.test.ts | 26 + tests/existingStyle.test.ts | 98 + tests/faviconLogos.test.ts | 77 + tests/featureEvents.test.ts | 45 + tests/fixtures/canvasPage.html | 15 +- tests/fixtures/frameReplay.html | 4 +- tests/fixtures/syncCss.html | 30 + tests/fixtures/syncCss/sheet.css | 36 + tests/fontFrameWrites.test.ts | 16 +- tests/frameApproval.test.ts | 30 + tests/frameReplay.test.ts | 15 +- tests/frameRuntimeBody.test.ts | 16 + tests/groupDrawnBrowser.test.ts | 350 ++ tests/groupLayout.test.ts | 94 + tests/harness.ts | 24 +- tests/homePrompt.test.ts | 15 +- tests/icoFixture.ts | 53 + tests/icoImage.test.ts | 51 + tests/iconProxy.test.ts | 141 + tests/imageDescriptionsCard.test.tsx | 31 +- tests/imageDescriptionsHttp.test.ts | 6 +- tests/imageGen.test.ts | 82 + tests/imagePaste.test.ts | 4 +- tests/importer.test.ts | 5 + tests/inlineData.test.ts | 360 ++ tests/inspiration.test.ts | 11 + tests/instanceLayerName.test.ts | 87 + tests/journal.test.ts | 396 ++ tests/layerExport.test.ts | 161 + tests/layerExportHttp.test.ts | 52 + tests/layerExportSection.test.tsx | 77 + tests/layerParents.test.ts | 5 +- tests/layersDragAcross.test.tsx | 2 + tests/layersEye.test.tsx | 6 +- tests/layersKeys.test.tsx | 7 +- tests/layersMove.test.ts | 39 +- tests/layersRename.test.tsx | 6 +- tests/layersStack.test.tsx | 3 + tests/lazyFrameHtmlHttp.test.ts | 16 + tests/libraryDeletedComponents.test.ts | 237 + tests/libraryDrop.test.ts | 123 + tests/libraryPlan.test.ts | 158 + tests/libraryResume.test.ts | 129 + tests/librarySection.test.tsx | 369 ++ tests/libraryTools.test.ts | 422 ++ tests/libraryUpdateEverywhere.test.ts | 201 + tests/linearIntegration.test.ts | 8 +- tests/mcpInstructions.test.ts | 67 + tests/nativeApp.test.ts | 84 + tests/pageCanvasBrowser.test.ts | 142 + tests/pageLink.test.ts | 173 + tests/pagesSplit.test.ts | 47 +- tests/pagesSplitBrowser.test.ts | 208 +- tests/paletteFocus.test.tsx | 40 + tests/pdfExport.test.ts | 34 +- tests/photoProxy.test.ts | 104 + tests/planLimits.test.ts | 132 + tests/propagation.test.ts | 356 ++ tests/publicUrl.test.ts | 47 + tests/renderBrowser.test.ts | 399 ++ tests/residentApproval.test.ts | 98 + tests/residentPageTools.test.ts | 1 + tests/residentTokenWork.test.ts | 1 + tests/reuseNotes.test.ts | 277 + tests/serverListen.test.ts | 50 + tests/stallWatchdog.test.ts | 154 + tests/standalonePanelBrowser.test.ts | 52 + tests/storeJournal.test.ts | 265 + tests/syncCssBrowser.test.ts | 32 + tests/tokenComponentGuidance.test.ts | 75 + tests/upgradeModal.test.tsx | 134 + tests/valueSlide.test.tsx | 165 + tests/vectorPaintBrowser.test.ts | 226 + tests/workBudget.test.ts | 191 + tests/workBudgetCommit.test.ts | 906 +++ tests/workBudgetHttp.test.ts | 63 + tests/workReplyPersist.test.ts | 105 + tests/workspaceLibraries.test.tsx | 108 + tests/workspaceLibrary.test.ts | 320 ++ tests/writeBoundaryHttp.test.ts | 213 + 420 files changed, 70810 insertions(+), 2844 deletions(-) create mode 100644 .context/specs/workspace-component-library.md create mode 100644 .github/workflows/android.yml create mode 100644 android/.gitignore create mode 100644 android/README.md create mode 100644 android/app/build.gradle.kts create mode 100644 android/app/proguard-rules.pro create mode 100644 android/app/src/androidTest/java/design/doop/android/AndroidFlowTest.kt create mode 100644 android/app/src/androidTest/java/design/doop/android/BlitzRenderTest.kt create mode 100644 android/app/src/debug/AndroidManifest.xml create mode 100644 android/app/src/debug/res/xml/debug_network_security.xml create mode 100644 android/app/src/main/AndroidManifest.xml create mode 100644 android/app/src/main/assets/HankenGrotesk-OFL.txt create mode 100644 android/app/src/main/assets/Inter-OFL.txt create mode 100644 android/app/src/main/assets/Lucide-LICENSE.txt create mode 100644 android/app/src/main/assets/SelectionDOM.js create mode 100644 android/app/src/main/cpp/blitz_jni.c create mode 100644 android/app/src/main/java/design/doop/android/AgentFollowService.kt create mode 100644 android/app/src/main/java/design/doop/android/AppModel.kt create mode 100644 android/app/src/main/java/design/doop/android/BlitzCanvasView.kt create mode 100644 android/app/src/main/java/design/doop/android/BlitzNative.kt create mode 100644 android/app/src/main/java/design/doop/android/CanvasModel.kt create mode 100644 android/app/src/main/java/design/doop/android/CanvasScreen.kt create mode 100644 android/app/src/main/java/design/doop/android/DoopClient.kt create mode 100644 android/app/src/main/java/design/doop/android/DoopIcons.kt create mode 100644 android/app/src/main/java/design/doop/android/DoopTheme.kt create mode 100644 android/app/src/main/java/design/doop/android/MainActivity.kt create mode 100644 android/app/src/main/java/design/doop/android/Models.kt create mode 100644 android/app/src/main/java/design/doop/android/SelectionActions.kt create mode 100644 android/app/src/main/res/drawable-nodpi/app_mark.png create mode 100644 android/app/src/main/res/drawable/apple_mark.xml create mode 100644 android/app/src/main/res/drawable/doop_logo.xml create mode 100644 android/app/src/main/res/drawable/google_mark.xml create mode 100644 android/app/src/main/res/drawable/microsoft_mark.xml create mode 100644 android/app/src/main/res/font/hanken_grotesk.ttf create mode 100644 android/app/src/main/res/font/inter.ttf create mode 100644 android/app/src/main/res/values/styles.xml create mode 100644 android/app/src/main/res/xml/data_extraction_rules.xml create mode 100644 android/app/src/main/res/xml/export_paths.xml create mode 100644 android/app/src/test/java/design/doop/android/ModelTest.kt create mode 100644 android/build.gradle.kts create mode 100644 android/gradle.properties create mode 100644 android/gradle/wrapper/gradle-wrapper.jar create mode 100644 android/gradle/wrapper/gradle-wrapper.properties create mode 100755 android/gradlew create mode 100644 android/gradlew.bat create mode 100644 android/scripts/build-native.py create mode 100644 android/settings.gradle.kts create mode 100644 ios/BlitzKit/rust/tests/imported_pages.rs create mode 100644 server/canvasFaces.ts create mode 100644 server/canvasFontUpload.ts create mode 100644 server/componentLibrary.ts create mode 100644 server/componentUsage.ts create mode 100644 server/customAgentRoutes.ts create mode 100644 server/customAgents.ts create mode 100644 server/db/migrations/0053_library_components.sql create mode 100644 server/db/migrations/0054_library_publish_policy.sql create mode 100644 server/db/migrations/0055_library_nested_sources.sql create mode 100644 server/db/migrations/0056_work_replies.sql create mode 100644 server/db/migrations/0057_custom_agents.sql create mode 100644 server/db/migrations/0058_component_soft_delete.sql create mode 100644 server/db/migrations/0059_workspace_seats_bought.sql create mode 100644 server/db/migrations/meta/0053_snapshot.json create mode 100644 server/db/migrations/meta/0054_snapshot.json create mode 100644 server/db/migrations/meta/0055_snapshot.json create mode 100644 server/db/migrations/meta/0056_snapshot.json create mode 100644 server/db/migrations/meta/0057_snapshot.json create mode 100644 server/db/migrations/meta/0058_snapshot.json create mode 100644 server/db/migrations/meta/0059_snapshot.json create mode 100644 server/entitlements.ts create mode 100644 server/existingStyle.ts create mode 100644 server/featureEvents.ts create mode 100644 server/hostedCopies.ts create mode 100644 server/icoImage.ts create mode 100644 server/iconProxy.ts create mode 100644 server/inlineData.ts create mode 100644 server/journal.ts create mode 100644 server/layerExport.ts create mode 100644 server/parse5Select.ts create mode 100644 server/photoProxy.ts create mode 100644 server/propagation.ts create mode 100644 server/renderBrowser.ts create mode 100644 server/renderLimits.ts create mode 100644 server/reuseNotes.ts create mode 100644 server/stallWatchdog.ts create mode 100644 server/stallWatcher.mjs create mode 100644 server/workBudget.ts create mode 100644 shared/agentBrand.ts create mode 100644 shared/asciiSearch.ts create mode 100644 shared/customAgents.ts create mode 100644 src/components/AgentChat.tsx delete mode 100644 src/components/CodePanel.tsx create mode 100644 src/components/ComponentImport.tsx create mode 100644 src/components/ComponentThumb.tsx create mode 100644 src/components/CustomAgents.tsx create mode 100644 src/components/LayerExportSection.tsx create mode 100644 src/components/LibrarySection.tsx create mode 100644 src/components/LibraryUpdateEverywhere.tsx create mode 100644 src/components/NativeAppPromo.tsx create mode 100644 src/components/PlanCards.tsx create mode 100644 src/components/PlanSettings.tsx create mode 100644 src/components/SeatStepper.tsx create mode 100644 src/components/UpgradeHost.tsx create mode 100644 src/components/WorkspaceLibraries.tsx create mode 100644 src/hooks/use-roster.ts create mode 100644 src/hooks/use-value-slide.ts create mode 100644 src/lib/agentChat.ts create mode 100644 src/lib/agentsSplit.ts create mode 100644 src/lib/composerFlight.ts create mode 100644 src/lib/exportEvents.ts create mode 100644 src/lib/frameBleed.ts create mode 100644 src/lib/groupLayout.ts create mode 100644 src/lib/i18n/en/agents.ts create mode 100644 src/lib/i18n/en/plans.ts create mode 100644 src/lib/i18n/pt-BR/agents.ts create mode 100644 src/lib/i18n/pt-BR/plans.ts create mode 100644 src/lib/library.ts create mode 100644 src/lib/libraryResume.ts create mode 100644 src/lib/nativeApp.ts create mode 100644 src/lib/pageLink.ts create mode 100644 src/lib/pageUrl.ts create mode 100644 src/lib/planFeatures.ts create mode 100644 src/lib/upgrade.ts create mode 100644 tests/agentBrand.test.ts create mode 100644 tests/agentChat.test.ts create mode 100644 tests/commentThreadStackBrowser.test.ts create mode 100644 tests/componentCssAncestors.test.ts create mode 100644 tests/componentDrops.test.ts create mode 100644 tests/componentHollow.test.ts create mode 100644 tests/componentImport.test.tsx create mode 100644 tests/componentPartKeys.test.ts create mode 100644 tests/componentPersistOrder.test.ts create mode 100644 tests/componentSectionDeleted.test.tsx create mode 100644 tests/componentSoftDelete.test.ts create mode 100644 tests/componentSoftDeleteRoutes.test.ts create mode 100644 tests/componentTableParts.test.ts create mode 100644 tests/componentUnicode.test.ts create mode 100644 tests/componentUsage.test.ts create mode 100644 tests/componentsBehind.test.ts create mode 100644 tests/componentsCatchUp.test.ts create mode 100644 tests/composerFlight.test.ts create mode 100644 tests/customAgentScopes.test.ts create mode 100644 tests/customAgents.test.ts create mode 100644 tests/customAgentsHttp.test.ts create mode 100644 tests/desktopTabShortcuts.test.ts create mode 100644 tests/existingStyle.test.ts create mode 100644 tests/faviconLogos.test.ts create mode 100644 tests/featureEvents.test.ts create mode 100644 tests/fixtures/syncCss.html create mode 100644 tests/fixtures/syncCss/sheet.css create mode 100644 tests/groupDrawnBrowser.test.ts create mode 100644 tests/groupLayout.test.ts create mode 100644 tests/icoFixture.ts create mode 100644 tests/icoImage.test.ts create mode 100644 tests/iconProxy.test.ts create mode 100644 tests/inlineData.test.ts create mode 100644 tests/instanceLayerName.test.ts create mode 100644 tests/journal.test.ts create mode 100644 tests/layerExport.test.ts create mode 100644 tests/layerExportHttp.test.ts create mode 100644 tests/layerExportSection.test.tsx create mode 100644 tests/libraryDeletedComponents.test.ts create mode 100644 tests/libraryDrop.test.ts create mode 100644 tests/libraryPlan.test.ts create mode 100644 tests/libraryResume.test.ts create mode 100644 tests/librarySection.test.tsx create mode 100644 tests/libraryTools.test.ts create mode 100644 tests/libraryUpdateEverywhere.test.ts create mode 100644 tests/mcpInstructions.test.ts create mode 100644 tests/nativeApp.test.ts create mode 100644 tests/pageLink.test.ts create mode 100644 tests/paletteFocus.test.tsx create mode 100644 tests/photoProxy.test.ts create mode 100644 tests/planLimits.test.ts create mode 100644 tests/propagation.test.ts create mode 100644 tests/renderBrowser.test.ts create mode 100644 tests/residentApproval.test.ts create mode 100644 tests/reuseNotes.test.ts create mode 100644 tests/serverListen.test.ts create mode 100644 tests/stallWatchdog.test.ts create mode 100644 tests/standalonePanelBrowser.test.ts create mode 100644 tests/storeJournal.test.ts create mode 100644 tests/syncCssBrowser.test.ts create mode 100644 tests/tokenComponentGuidance.test.ts create mode 100644 tests/upgradeModal.test.tsx create mode 100644 tests/valueSlide.test.tsx create mode 100644 tests/vectorPaintBrowser.test.ts create mode 100644 tests/workBudget.test.ts create mode 100644 tests/workBudgetCommit.test.ts create mode 100644 tests/workBudgetHttp.test.ts create mode 100644 tests/workReplyPersist.test.ts create mode 100644 tests/workspaceLibraries.test.tsx create mode 100644 tests/workspaceLibrary.test.ts create mode 100644 tests/writeBoundaryHttp.test.ts diff --git a/.context/DESIGN.md b/.context/DESIGN.md index d8d976091..9d22e6dba 100644 --- a/.context/DESIGN.md +++ b/.context/DESIGN.md @@ -111,7 +111,8 @@ stock Tailwind type sizes and radii, `leading-[…]` / `tracking-[…]`, weights and hex colours; only the not-yet-migrated editor chrome, listed in `LEGACY_CHROME`, is exempt). Each has a story. -- `Button` - the ring button, one black `primary` per screen (`size="bar"` is the 32px header +- `Button` - the ring button, one black `primary` per screen (`variant="brand"` is the accent + fill for the one action a live signal asks for, such as unpublished library changes; `size="bar"` is the 32px header and toolbar action with a leading glyph: Import, New canvas; `size="inline"` is a boxless text action at the caption step, `bare` in a selection bar, `link` in a card or callout); `IconButton` - a glyph in a quiet square (sm 24px / md 32px / lg 34px, `round` for row actions, @@ -187,7 +188,7 @@ density="rail"` (the group caption with its chevron) and `DashNavItem density="r disc), `tone="ink"` (the account's own face: initials on an ink disc, no collar), `initials()` (the one first-and-last-letter rule), `BrandMark` - every third-party logo (``; figma, github, canva, photoshop, meta, claude, openai, cursor, gemini, google, apple, microsoft, slack, linear, openrouter, - deepseek, kimi); + deepseek, kimi, grok, opencode, pi); `AppIcon` is a model provider, import source or export format as doop.design's "Works with" row draws it: the brand tile (23% corners, inset edge and soft drop) with its glyph at 56% (`claude`, `claude-code`, `openai`, `gemini`, `openrouter`, `deepseek`, `kimi`, `seedream`, `codex`, `cursor`, `mcp`, `headless`, `github`, `figma`, `photoshop`, `canva`, `website`, `live-app`, `pdf`, `png`, `svg`, diff --git a/.context/RELEASE.md b/.context/RELEASE.md index c86b9ca8d..2e052b7a7 100644 --- a/.context/RELEASE.md +++ b/.context/RELEASE.md @@ -98,6 +98,11 @@ in `.github/actions/setup-desktop`: `server.rs`, `serverSettings.test.tsx`. - The shell tells the page its platform via `window.__DOOP_DESKTOP_PLATFORM__` (read in `src/lib/shell.ts`); only macOS gets the overlay title bar / traffic-light inset. +- Tab shortcuts (`TAB_SHORTCUTS` / `tabShortcutTarget` in `src/lib/desktop.ts`), shell only: ⌘1 + (Ctrl+1 elsewhere) opens Home and ⌘2…⌘9 the open canvas tabs in strip order, as in Figma's + desktop app; ⌘, (Ctrl+,) opens Settings (`SETTINGS_SHORTCUT`, `shellShortcutTarget`); read + by physical key, from text fields and frames too. Web-only, no desktop release needed. + Tests: `desktopTabShortcuts.test.ts`. - Desktop app version is tracked separately from the root `package.json` and bumped by release-please (see above); after the release PR merges, tag as `desktop-vX.Y.Z`. - The macOS app is the Chromium (CEF) build in `desktop/src-tauri-chromium`; Windows and Linux diff --git a/.context/TECHSTACK.md b/.context/TECHSTACK.md index 94b589e74..b9bbd82e1 100644 --- a/.context/TECHSTACK.md +++ b/.context/TECHSTACK.md @@ -35,6 +35,21 @@ back to frame details if nothing carries the id. Browser regressions in `tests/pageCanvasBrowser.test.ts` cover initial loading, cross-page links, stamping on copy, clipboard round trips, history and script-created or script-removed elements. +- Page links are `/c/?page=` (`src/lib/pageLink.ts`, pure). `openingPageId` is + the one rule for the page a canvas URL opens: the page of the frame it links, else the page it + names, else the default (the first page; on a library canvas its components page, see Workspace + component libraries). A frame or page that is not on the canvas counts as not named. The store's + `setCanvas` applies it when a canvas is first opened, so the first paint is that page; a rejoin + keeps the page the person is on. `followPageInUrl` (`src/lib/pageUrl.ts`, mounted by + `CanvasPage`) then keeps the address bar on the open page with `history.replaceState`, as + `?pane=` does on the Workspace page, so Back leaves the canvas rather than walking page + switches: `pageSearch` drops `page` on the default page, leaves a frame link on the open page + alone, drops a frame, element or comment link to another page, and keeps every other parameter. + A history entry that names a page opens it. The URL is this browser's view: a remote page-list + change moves nobody, except off a deleted page. "Copy link to page" is in the page row's menu + (`PagesPanel.tsx`, viewers too; the link always names its page). Agents get the form in the MCP + instructions, the guide's Pages bullet and the resident kickoff. Tests: `pageLink.test.ts`, the + "pages in the URL" cases in `tests/pageCanvasBrowser.test.ts`. - Radix UI primitives (`@radix-ui/react-*`, ^1.x-2.x) + shadcn 4.19.0 - accessible UI primitives generated into `src/components/ui`. - `@anthropic-ai/sdk` 0.115.0 and `@modelcontextprotocol/sdk` 1.12.0 - power the built-in Doop @@ -46,6 +61,21 @@ something matches; six-hour in-memory cache for the free plan's 1,000 requests a day. Every result credits One Page Love and the authors with the entry's link (their terms). Tests: `inspiration.test.ts`. +- Icons and stock photos from Doop's origin (`server/hostedCopies.ts`, `server/iconProxy.ts`, + `server/photoProxy.ts`): `search_icons` hands out `/icons/iconify//.svg` and `search_images` + `/photos/pexels/.jpeg?w=&h=` (the provider in the path, so another source can sit beside it), which the server fetches from Iconify or Pexels the first time + anything loads them and keeps in the bucket (`iconify/` and `pexels/.`) + and a small in-memory LRU. Only each source's known options pass (Iconify `color`, `width`, + `height`, `rotate`, `flip`, `box`; Pexels `w`, `h`, `dpr`, `fit`, an unsized photo getting the + 940x650 search size, never the original), redirects are refused, and source fetches are capped + (icons 16 running and 64 waiting, photos 8 and 32; past that a 503 with `Retry-After`). Served + like an `/a/` asset (nosniff, open CORS, a script-free CSP on SVG; photos immutable). Hotlinks to + `api.iconify.design` rendered blank in screenshots on and off, since the hosted renderer fetched + them itself; the renderer (`loadFrameInto`) also points a frame's existing Iconify and Pexels + hotlinks at Doop before loading it; `hostedIconSvg` and `hostedPhoto` read both in-process, + since a private `BETTER_AUTH_URL` is refused by `fetchRemote`. Pexels' licence + allows rehosting; arbitrary hotlinked images are never copied. Tests: `iconProxy.test.ts`, + `photoProxy.test.ts`. - Where frame CSS goes (`FRAME_STYLES` in `server/guide.ts`): agents are asked to style an element in its own `style` attribute, which is what the editor reads and writes, and to keep a ` + diff --git a/android/app/src/main/res/xml/data_extraction_rules.xml b/android/app/src/main/res/xml/data_extraction_rules.xml new file mode 100644 index 000000000..0c651904e --- /dev/null +++ b/android/app/src/main/res/xml/data_extraction_rules.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/android/app/src/main/res/xml/export_paths.xml b/android/app/src/main/res/xml/export_paths.xml new file mode 100644 index 000000000..7287de421 --- /dev/null +++ b/android/app/src/main/res/xml/export_paths.xml @@ -0,0 +1 @@ + diff --git a/android/app/src/test/java/design/doop/android/ModelTest.kt b/android/app/src/test/java/design/doop/android/ModelTest.kt new file mode 100644 index 000000000..f3db53282 --- /dev/null +++ b/android/app/src/test/java/design/doop/android/ModelTest.kt @@ -0,0 +1,71 @@ +package design.doop.android + +import org.json.JSONObject +import org.junit.Assert.* +import org.junit.Test +import java.net.URI + +class ModelTest { + @Test fun fittingTallBoardsKeepsAllFramesInsideTheViewport() { + val scale=canvasFitScale(1400f,40000f,900f,1400f,2.625f) + assertEquals(.035f,scale,.00001f) + assertTrue(40000f*scale<=1400f && 1400f*scale<=900f) + assertEquals(10.5f,canvasFitScale(1f,1f,900f,1400f,2.625f),.00001f) + } + + @Test fun serverAddressRejectsCredentialsPathsAndInsecureRemoteHosts() { + for(value in listOf("http://doop.design","https://user:pass@doop.design","https://doop.design/path","https://doop.design?token=x","https://doop.design/#x")) + assertTrue(value,runCatching {ServerAddress.parse(value,true)}.isFailure) + assertEquals("https://doop.design",ServerAddress.parse(" https://DOOP.design/ ").origin) + assertTrue(runCatching {ServerAddress.parse("http://10.0.2.2:3109")}.isFailure) + assertEquals("http://10.0.2.2:3109",ServerAddress.parse("http://10.0.2.2:3109",true).origin) + assertTrue(runCatching {ServerAddress.parse("https://doop.design").api("//evil.test/api")}.isFailure) + } + @Test fun authCallbacksRequireMatchingFreshChallengeAndCannotReplayAmbiguousQueries() { + val a=AuthAttempt("abc","https://doop.design",1000) + assertEquals("hello+world",a.token(URI("doop://auth?challenge=abc&token=hello%2Bworld"),2000)) + for(link in listOf("doop://auth?challenge=wrong&token=x","https://auth?challenge=abc&token=x","doop://auth?challenge=abc&token=","doop://auth?challenge=abc&token=a&token=b")) assertNull(a.token(URI(link),2000)) + assertNull(a.token(URI("doop://auth?challenge=abc&token=x"),601001)) + assertNull(a.token(URI("doop://auth?challenge=abc&token=x"),999)) + val generated=AuthAttempt.create("https://doop.design") + assertTrue(generated.challenge.matches(Regex("[0-9a-f]{32}"))) + } + @Test fun legacyPagesAndFrameDimensionsAreValidated() { + val board=Board.parse(JSONObject("""{"id":"c","name":"Canvas","frames":[{"id":"f","width":100,"height":200,"html":""}]}""")) + assertEquals("c:page1",board.pageOf(board.frames.first())) + assertTrue(runCatching {Frame.parse(JSONObject("""{"id":"f","width":100000,"height":200}"""))}.isFailure) + } + @Test fun modelPickerUsesEnabledDefaultAccountAndItsOwnMenu() { + val view=JSONObject("""{"default":"openai-key","accounts":[ + {"kind":"anthropic-key","enabled":true,"model":"unrelated"}, + {"kind":"openai-key","enabled":true,"model":"fast"}], + "menus":{"openai-key":[{"id":"fast","name":"Fast model"},{"id":"careful","name":"Careful model"}]}}""") + val selected=AccountModelSelection.parse(view)!! + assertEquals("openai-key",selected.kind) + assertEquals("Fast model",selected.label) + assertEquals(listOf("fast","careful"),selected.options.map {it.getString("id")}) + view.getJSONArray("accounts").getJSONObject(1).put("enabled",false) + assertNull(AccountModelSelection.parse(view)) + view.put("default","claude-local") + assertNull(AccountModelSelection.parse(view)) + assertNull(AccountModelSelection.parse(JSONObject("""{"accounts":[],"menus":{}}"""))) + } + @Test fun frameRoundTripRetainsVersionAndLayoutWithoutReusingVersionOnCreate() { + val frame=Frame.parse(JSONObject("""{"id":"f","canvasId":"c","name":"Rotated","width":100,"height":200, + "updatedAt":1780000000123,"z":42.5,"rotation":-33.5,"pageId":"p","hidden":true,"locked":true}""")) + assertEquals(1780000000123L,frame.updatedAt) + assertEquals(42.5,frame.body().getDouble("z"),0.0) + assertEquals(-33.5,frame.body().getDouble("rotation"),0.0) + assertEquals(frame,Frame.parse(frame.json())) + assertFalse(frame.body().has("updatedAt")) + assertFalse(frame.body().has("expectedUpdatedAt")) + } + @Test fun snappingIsScreenSpaceAndIncludesCenters() { + val f=Frame("f","c","A",0f,0f,100f,200f,"") + val other=f.copy(id="g",x=300f,y=400f) + assertEquals(200f,snapFrame(f,205f,0f,listOf(other),1f).x) + assertEquals(205f,snapFrame(f,205f,0f,listOf(other),2f).x) + assertEquals(300f,snapFrame(f,302f,0f,listOf(other),1f).guideX) + assertEquals(302f,snapFrame(f,302f,0f,listOf(other.copy(hidden=true)),1f).x) + } +} diff --git a/android/build.gradle.kts b/android/build.gradle.kts new file mode 100644 index 000000000..9378b4ee8 --- /dev/null +++ b/android/build.gradle.kts @@ -0,0 +1,4 @@ +plugins { + id("com.android.application") version "9.0.1" apply false + id("org.jetbrains.kotlin.plugin.compose") version "2.2.10" apply false +} diff --git a/android/gradle.properties b/android/gradle.properties new file mode 100644 index 000000000..f86c37500 --- /dev/null +++ b/android/gradle.properties @@ -0,0 +1,4 @@ +org.gradle.jvmargs=-Xmx3g -Dfile.encoding=UTF-8 +org.gradle.workers.max=4 +android.useAndroidX=true +kotlin.code.style=official diff --git a/android/gradle/wrapper/gradle-wrapper.jar b/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..8bdaf60c75ab801e22807dde59e12a8735a34077 GIT binary patch literal 45457 zcma&NW0YlEwk;ePwr$(aux;D69T}N{9ky*d!_2U4+qUuIRNZ#Jck8}7U+vcB{`IjNZqX3eq5;s6ddAkU&5{L|^Ow`ym2B0m+K02+~Q)i807X3X94qi>j)C0e$=H zm31v`=T&y}ACuKx7G~yWSYncG=NFB>O2);i9EmJ(9jSamq?Crj$g~1l3m-4M7;BWn zau2S&sSA0b0Rhg>6YlVLQa;D#)1yw+eGs~36Q$}5?avIRne3TQZXb<^e}?T69w<9~ zUmx1cG0uZ?Kd;Brd$$>r>&MrY*3$t^PWF1+J+G_xmpHW=>mly$<>~wHH+Bt3mzN7W zhR)g{_veH6>*KxLJ~~s{9HZm!UeC86d_>42NRqd$ev8zSMq4kt)q*>8kJ8p|^wuKx zq2Is_HJPoQ_apSoT?zJj7vXBp!xejBc^7F|zU0rhy%Ub*Dy#jJs!>1?CmJ-gulPVX zKit>RVmjL=G?>jytf^U@mfnC*1-7EVag@%ROu*#kA+)Rxq?MGK0v-dp^kM?nyMngb z_poL>GLThB7xAO*I7&?4^Nj`<@O@>&0M-QxIi zD@n}s%CYI4Be19C$lAb9Bbm6!R{&A;=yh=#fnFyb`s7S5W3?arZf?$khCwkGN!+GY~GT8-`!6pFr zbFBVEF`kAgtecfjJ`flN2Z!$$8}6hV>Tu;+rN%$X^t8fI>tXQnRn^$UhXO8Gu zt$~QON8`doV&{h}=2!}+xJKrNPcIQid?WuHUC-i%P^F(^z#XB`&&`xTK&L+i8a3a@ zkV-Jy;AnyQ`N=&KONV_^-0WJA{b|c#_l=v!19U@hS~M-*ix16$r01GN3#naZ|DxY2 z76nbjbOnFcx4bKbEoH~^=EikiZ)_*kOb>nW6>_vjf-UCf0uUy~QBb7~WfVO6qN@ns zz=XEG0s5Yp`mlmUad)8!(QDgIzY=OK%_hhPStbyYYd|~zDIc3J4 zy9y%wZOW>}eG4&&;Z>vj&Mjg+>4gL! z(@oCTFf-I^54t=*4AhKRoE-0Ky=qg3XK2Mu!Bmw@z>y(|a#(6PcfbVTw-dUqyx4x4 z3O#+hW1ANwSv-U+9otHE#U9T>(nWx>^7RO_aI>${jvfZQ{mUwiaxHau!H z0Nc}ucJu+bKux?l!dQ2QA(r@(5KZl(Or=U!=2K*8?D=ZT-IAcAX!5OI3w@`sF@$($ zbDk0p&3X0P%B0aKdijO|s})70K&mk1DC|P##b=k@fcJ|lo@JNWRUc>KL?6dJpvtSUK zxR|w8Bo6K&y~Bd}gvuz*3z z@sPJr{(!?mi@okhudaM{t3gp9TJ!|@j4eO1C&=@h#|QLCUKLaKVL z!lls$%N&ZG7yO#jK?U>bJ+^F@K#A4d&Jz4boGmptagnK!Qu{Ob>%+60xRYK>iffd_ z>6%0K)p!VwP$^@Apm%NrS6TpKJwj_Q=k~?4=_*NIe~eh_QtRaqX4t-rJAGYdB{pGq zSXX)-dR8mQ)X|;8@_=J6Dk7MfMp;x)^aZeCtScHs12t3vL+p-6!qhPkOM1OYQ z8YXW5tWp)Th(+$m7SnV_hNGKAP`JF4URkkNc@YV9}FK$9k zR&qgi$Cj#4bC1VK%#U)f%(+oQJ+EqvV{uAq1YG0riLvGxW@)m;*ayU-BSW61COFy0 z(-l>GJqYl;*x1PnRZ(p3Lm}* zlkpWyCoYtg9pAZ5RU^%w=vN{3Y<6WImxj(*SCcJsFj?o6CZ~>cWW^foliM#qN#We{ zwsL!u1$rzC1#4~bILZm*a!T{^kCci$XOJADm)P;y^%x5)#G#_!2uNp^S;cE`*ASCn;}H7pP^RRA z6lfXK(r4dy<_}R|(7%Lyo>QFP#s31E8zsYA${gSUykUV@?lyDNF=KhTeF^*lu7C*{ zBCIjy;bIE;9inJ$IT8_jL%)Q{7itmncYlkf2`lHl(gTwD%LmEPo^gskydVxMd~Do` zO8EzF!yn!r|BEgPjhW#>g(unY#n}=#4J;3FD2ThN5LpO0tI2~pqICaFAGT%%;3Xx$ z>~Ng(64xH-RV^Rj4=A_q1Ee8kcF}8HN{5kjYX0ADh}jq{q18x(pV!23pVsK5S}{M#p8|+LvfKx|_3;9{+6cu7%5o-+R@z>TlTft#kcJ`s2-j zUe4dgpInZU!<}aTGuwgdWJZ#8TPiV9QW<-o!ibBn&)?!ZDomECehvT7GSCRyF#VN2&5GShch9*}4p;8TX~cW*<#( zv-HmU7&+YUWO__NN3UbTFJ&^#3vxW4U9q5=&ORa+2M$4rskA4xV$rFSEYBGy55b{z z!)$_fYXiY?-GWDhGZXgTw}#ilrw=BiN(DGO*W7Vw(} zjUexksYLt_Nq?pl_nVa@c1W#edQKbT>VSN1NK?DulHkFpI-LXl7{;dl@z0#v?x%U& z8k8M1X6%TwR4BQ_eEWJASvMTy?@fQubBU__A_US567I-~;_VcX^NJ-E(ZPR^NASj1 zVP!LIf8QKtcdeH#w6ak50At)e={eF_Ns6J2Iko6dn8Qwa6!NQHZMGsD zhzWeSFK<{hJV*!cIHxjgR+e#lkUHCss-j)$g zF}DyS531TUXKPPIoePo{yH%qEr-dLMOhv^sC&@9YI~uvl?rBp^A-57{aH_wLg0&a|UxKLlYZQ24fpb24Qjil`4OCyt0<1eu>5i1Acv zaZtQRF)Q;?Aw3idg;8Yg9Cb#)03?pQ@O*bCloG zC^|TnJl`GXN*8iI;Ql&_QIY0ik}rqB;cNZ-qagp=qmci9eScHsRXG$zRNdf4SleJ} z7||<#PCW~0>3u8PP=-DjNhD(^(B0AFF+(oKOiQyO5#v4nI|v_D5@c2;zE`}DK!%;H zUn|IZ6P;rl*5`E(srr6@-hpae!jW=-G zC<*R?RLwL;#+hxN4fJ!oP4fX`vC3&)o!#l4y@MrmbmL{t;VP%7tMA-&vju_L zhtHbOL4`O;h*5^e3F{b9(mDwY6JwL8w`oi28xOyj`pVo!75hngQDNg7^D$h4t&1p2 ziWD_!ap3GM(S)?@UwWk=Szym^eDxSx3NaR}+l1~(@0car6tfP#sZRTb~w!WAS{+|SgUN3Tv`J4OMf z9ta_f>-`!`I@KA=CXj_J>CE7T`yGmej0}61sE(%nZa1WC_tV6odiysHA5gzfWN-`uXF46mhJGLpvNTBmx$!i zF67bAz~E|P{L6t1B+K|Cutp&h$fDjyq9JFy$7c_tB(Q$sR)#iMQH3{Og1AyD^lyQwX6#B|*ecl{-_;*B>~WSFInaRE_q6 zpK#uCprrCb`MU^AGddA#SS{P7-OS9h%+1`~9v-s^{s8faWNpt*Pmk_ECjt(wrpr{C_xdAqR(@!ERTSs@F%^DkE@No}wqol~pS^e7>ksF_NhL0?6R4g`P- zk8lMrVir~b(KY+hk5LQngwm`ZQT5t1^7AzHB2My6o)_ejR0{VxU<*r-Gld`l6tfA` zKoj%x9=>Ce|1R|1*aC}|F0R32^KMLAHN}MA<8NNaZ^j?HKxSwxz`N2hK8lEb{jE0& zg4G_6F@#NyDN?=i@=)eidKhlg!nQoA{`PgaH{;t|M#5z}a`u?^gy{5L~I2smLR z*4RmNxHqf9>D>sXSemHK!h4uPwMRb+W`6F>Q6j@isZ>-F=)B2*sTCD9A^jjUy)hjAw71B&$u}R(^R; zY9H3k8$|ounk>)EOi_;JAKV8U8ICSD@NrqB!&=)Ah_5hzp?L9Sw@c>>#f_kUhhm=p z1jRz8X7)~|VwO(MF3PS(|CL++1n|KT3*dhGjg!t_vR|8Yg($ z+$S$K=J`K6eG#^(J54=4&X#+7Car=_aeAuC>dHE+%v9HFu>r%ry|rwkrO-XPhR_#K zS{2Unv!_CvS7}Mb6IIT$D4Gq5v$Pvi5nbYB+1Yc&RY;3;XDihlvhhIG6AhAHsBYsm zK@MgSzs~y|+f|j-lsXKT0(%E2SkEb)p+|EkV5w8=F^!r1&0#0^tGhf9yPZ)iLJ^ zIXOg)HW_Vt{|r0W(`NmMLF$?3ZQpq+^OtjR-DaVLHpz%1+GZ7QGFA?(BIqBlVQ;)k zu)oO|KG&++gD9oL7aK4Zwjwi~5jqk6+w%{T$1`2>3Znh=OFg|kZ z>1cn>CZ>P|iQO%-Pic8wE9c*e%=3qNYKJ+z1{2=QHHFe=u3rqCWNhV_N*qzneN8A5 zj`1Ir7-5`33rjDmyIGvTx4K3qsks(I(;Kgmn%p#p3K zn8r9H8kQu+n@D$<#RZtmp$*T4B&QvT{K&qx(?>t@mX%3Lh}sr?gI#vNi=vV5d(D<=Cp5-y!a{~&y|Uz*PU{qe zI7g}mt!txT)U(q<+Xg_sSY%1wVHy;Dv3uze zJ>BIdSB2a|aK+?o63lR8QZhhP)KyQvV`J3)5q^j1-G}fq=E4&){*&hiam>ssYm!ya z#PsY0F}vT#twY1mXkGYmdd%_Uh12x0*6lN-HS-&5XWbJ^%su)-vffvKZ%rvLHVA<; zJP=h13;x?$v30`T)M)htph`=if#r#O5iC^ZHeXc6J8gewn zL!49!)>3I-q6XOZRG0=zjyQc`tl|RFCR}f-sNtc)I^~?Vv2t7tZZHvgU2Mfc9$LqG z!(iz&xb=q#4otDBO4p)KtEq}8NaIVcL3&pbvm@0Kk-~C@y3I{K61VDF_=}c`VN)3P z+{nBy^;=1N`A=xH$01dPesY_na*zrcnssA}Ix60C=sWg9EY=2>-yH&iqhhm28qq9Z z;}znS4ktr40Lf~G@6D5QxW&?q^R|=1+h!1%G4LhQs54c2Wo~4% zCA||d==lv2bP=9%hd0Dw_a$cz9kk)(Vo}NpSPx!vnV*0Bh9$CYP~ia#lEoLRJ8D#5 zSJS?}ABn1LX>8(Mfg&eefX*c0I5bf4<`gCy6VC{e>$&BbwFSJ0CgVa;0-U7=F81R+ zUmzz&c;H|%G&mSQ0K16Vosh?sjJW(Gp+1Yw+Yf4qOi|BFVbMrdO6~-U8Hr|L@LHeZ z0ALmXHsVm137&xnt#yYF$H%&AU!lf{W436Wq87nC16b%)p?r z70Wua59%7Quak50G7m3lOjtvcS>5}YL_~?Pti_pfAfQ!OxkX$arHRg|VrNx>R_Xyi z`N|Y7KV`z3(ZB2wT9{Dl8mtl zg^UOBv~k>Z(E)O>Z;~Z)W&4FhzwiPjUHE9&T#nlM)@hvAZL>cha-< zQ8_RL#P1?&2Qhk#c9fK9+xM#AneqzE-g(>chLp_Q2Xh$=MAsW z2ScEKr+YOD*R~mzy{bOJjs;X2y1}DVFZi7d_df^~((5a2%p%^4cf>vM_4Sn@@ssVJ z9ChGhs zbanJ+h74)3tWOviXI|v!=HU2mE%3Th$Mpx&lEeGFEBWRy8ogJY`BCXj@7s~bjrOY! z4nIU5S>_NrpN}|waZBC)$6ST8x91U2n?FGV8lS{&LFhHbuHU?SVU{p7yFSP_f#Eyh zJhI@o9lAeEwbZYC=~<(FZ$sJx^6j@gtl{yTOAz`Gj!Ab^y})eG&`Qt2cXdog2^~oOH^K@oHcE(L;wu2QiMv zJuGdhNd+H{t#Tjd<$PknMSfbI>L1YIdZ+uFf*Z=BEM)UPG3oDFe@8roB0h(*XAqRc zoxw`wQD@^nxGFxQXN9@GpkLqd?9@(_ZRS@EFRCO8J5{iuNAQO=!Lo5cCsPtt4=1qZN8z`EA2{ge@SjTyhiJE%ttk{~`SEl%5>s=9E~dUW0uws>&~3PwXJ!f>ShhP~U9dLvE8ElNt3g(6-d zdgtD;rgd^>1URef?*=8BkE&+HmzXD-4w61(p6o~Oxm`XexcHmnR*B~5a|u-Qz$2lf zXc$p91T~E4psJxhf^rdR!b_XmNv*?}!PK9@-asDTaen;p{Rxsa=1E}4kZ*}yQPoT0 zvM}t!CpJvk<`m~^$^1C^o1yM(BzY-Wz2q7C^+wfg-?}1bF?5Hk?S{^#U%wX4&lv0j zkNb)byI+nql(&65xV?_L<0tj!KMHX8Hmh2(udEG>@OPQ}KPtdwEuEb$?acp~yT1&r z|7YU<(v!0as6Xff5^XbKQIR&MpjSE)pmub+ECMZzn7c!|hnm_Rl&H_oXWU2!h7hhf zo&-@cLkZr#eNgUN9>b=QLE1V^b`($EX3RQIyg#45A^=G!jMY`qJ z8qjZ$*-V|?y0=zIM>!2q!Gi*t4J5Otr^OT3XzQ_GjATc(*eM zqllux#QtHhc>YtnswBNiS^t(dTDn|RYSI%i%-|sv1wh&|9jfeyx|IHowW)6uZWR<%n8I}6NidBm zJ>P7#5m`gnXLu;?7jQZ!PwA80d|AS*+mtrU6z+lzms6^vc4)6Zf+$l+Lk3AsEK7`_ zQ9LsS!2o#-pK+V`g#3hC$6*Z~PD%cwtOT8;7K3O=gHdC=WLK-i_DjPO#WN__#YLX|Akw3LnqUJUw8&7pUR;K zqJ98?rKMXE(tnmT`#080w%l1bGno7wXHQbl?QFU=GoK@d!Ov=IgsdHd-iIs4ahcgSj(L@F96=LKZ zeb5cJOVlcKBudawbz~AYk@!^p+E=dT^UhPE`96Q5J~cT-8^tp`J43nLbFD*Nf!w;6 zs>V!5#;?bwYflf0HtFvX_6_jh4GEpa0_s8UUe02@%$w^ym&%wI5_APD?9S4r9O@4m zq^Z5Br8#K)y@z*fo08@XCs;wKBydn+60ks4Z>_+PFD+PVTGNPFPg-V-|``!0l|XrTyUYA@mY?#bJYvD>jX&$o9VAbo?>?#Z^c+Y4Dl zXU9k`s74Sb$OYh7^B|SAVVz*jEW&GWG^cP<_!hW+#Qp|4791Od=HJcesFo?$#0eWD z8!Ib_>H1WQE}shsQiUNk!uWOyAzX>r(-N7;+(O333_ES7*^6z4{`p&O*q8xk{0xy@ zB&9LkW_B}_Y&?pXP-OYNJfqEWUVAPBk)pTP^;f+75Wa(W>^UO_*J05f1k{ zd-}j!4m@q#CaC6mLsQHD1&7{tJ*}LtE{g9LB>sIT7)l^ucm8&+L0=g1E_6#KHfS>A_Z?;pFP96*nX=1&ejZ+XvZ=ML`@oVu>s^WIjn^SY}n zboeP%`O9|dhzvnw%?wAsCw*lvVcv%bmO5M4cas>b%FHd;A6Z%Ej%;jgPuvL$nk=VQ=$-OTwslYg zJQtDS)|qkIs%)K$+r*_NTke8%Rv&w^v;|Ajh5QXaVh}ugccP}3E^(oGC5VO*4`&Q0 z&)z$6i_aKI*CqVBglCxo#9>eOkDD!voCJRFkNolvA2N&SAp^4<8{Y;#Kr5740 za|G`dYGE!9NGU3Ge6C)YByb6Wy#}EN`Ao#R!$LQ&SM#hifEvZp>1PAX{CSLqD4IuO z4#N4AjMj5t2|!yTMrl5r)`_{V6DlqVeTwo|tq4MHLZdZc5;=v9*ibc;IGYh+G|~PB zx2}BAv6p$}?7YpvhqHu7L;~)~Oe^Y)O(G(PJQB<&2AhwMw!(2#AHhjSsBYUd8MDeM z+UXXyV@@cQ`w}mJ2PGs>=jHE{%i44QsPPh(=yorg>jHic+K+S*q3{th6Ik^j=@%xo zXfa9L_<|xTL@UZ?4H`$vt9MOF`|*z&)!mECiuenMW`Eo2VE#|2>2ET7th6+VAmU(o zq$Fz^TUB*@a<}kr6I>r;6`l%8NWtVtkE?}Q<<$BIm*6Z(1EhDtA29O%5d1$0q#C&f zFhFrrss{hOsISjYGDOP*)j&zZUf9`xvR8G)gwxE$HtmKsezo`{Ta~V5u+J&Tg+{bh zhLlNbdzJNF6m$wZNblWNbP6>dTWhngsu=J{);9D|PPJ96aqM4Lc?&6H-J1W15uIpQ ziO{&pEc2}-cqw+)w$`p(k(_yRpmbp-Xcd`*;Y$X=o(v2K+ISW)B1(ZnkV`g4rHQ=s z+J?F9&(||&86pi}snC07Lxi1ja>6kvnut;|Ql3fD)%k+ASe^S|lN69+Ek3UwsSx=2EH)t}K>~ z`Mz-SSVH29@DWyl`ChuGAkG>J;>8ZmLhm>uEmUvLqar~vK3lS;4s<{+ehMsFXM(l- zRt=HT>h9G)JS*&(dbXrM&z;)66C=o{=+^}ciyt8|@e$Y}IREAyd_!2|CqTg=eu}yG z@sI9T;Tjix*%v)c{4G84|0j@8wX^Iig_JsPU|T%(J&KtJ>V zsAR+dcmyT5k&&G{!)VXN`oRS{n;3qd`BgAE9r?%AHy_Gf8>$&X$=>YD7M911?<{qX zkJ;IOfY$nHdy@kKk_+X%g3`T(v|jS;>`pz`?>fqMZ>Fvbx1W=8nvtuve&y`JBfvU~ zr+5pF!`$`TUVsx3^<)48&+XT92U0DS|^X6FwSa-8yviRkZ*@Wu|c*lX!m?8&$0~4T!DB0@)n}ey+ew}T1U>|fH3=W5I!=nfoNs~OkzTY7^x^G&h>M7ewZqmZ=EL0}3#ikWg+(wuoA{7hm|7eJz zNz78l-K81tP16rai+fvXtspOhN-%*RY3IzMX6~8k9oFlXWgICx9dp;`)?Toz`fxV@&m8< z{lzWJG_Y(N1nOox>yG^uDr}kDX_f`lMbtxfP`VD@l$HR*B(sDeE(+T831V-3d3$+% zDKzKnK_W(gLwAK{Saa2}zaV?1QmcuhDu$)#;*4gU(l&rgNXB^WcMuuTki*rt>|M)D zoI;l$FTWIUp}euuZjDidpVw6AS-3dal2TJJaVMGj#CROWr|;^?q>PAo2k^u-27t~v zCv10IL~E)o*|QgdM!GJTaT&|A?oW)m9qk2{=y*7qb@BIAlYgDIe)k(qVH@)#xx6%7 z@)l%aJwz5Joc84Q2jRp71d;=a@NkjSdMyN%L6OevML^(L0_msbef>ewImS=+DgrTk z4ON%Y$mYgcZ^44O*;ctP>_7=}=pslsu>~<-bw=C(jeQ-X`kUo^BS&JDHy%#L32Cj_ zXRzDCfCXKXxGSW9yOGMMOYqPKnU zTF6gDj47!7PoL%z?*{1eyc2IVF*RXX?mj1RS}++hZg_%b@6&PdO)VzvmkXxJ*O7H} z6I7XmJqwX3<>z%M@W|GD%(X|VOZ7A+=@~MxMt8zhDw`yz?V>H%C0&VY+ZZ>9AoDVZeO1c~z$r~!H zA`N_9p`X?z>jm!-leBjW1R13_i2(0&aEY2$l_+-n#powuRO;n2Fr#%jp{+3@`h$c< zcFMr;18Z`UN#spXv+3Ks_V_tSZ1!FY7H(tdAk!v}SkoL9RPYSD3O5w>A3%>7J+C-R zZfDmu=9<1w1CV8rCMEm{qyErCUaA3Q zRYYw_z!W7UDEK)8DF}la9`}8z*?N32-6c-Bwx^Jf#Muwc67sVW24 zJ4nab%>_EM8wPhL=MAN)xx1tozAl zmhXN;*-X%)s>(L=Q@vm$qmuScku>PV(W_x-6E?SFRjSk)A1xVqnml_92fbj0m};UC zcV}lRW-r*wY106|sshV`n#RN{)D9=!>XVH0vMh>od=9!1(U+sWF%#B|eeaKI9RpaW z8Ol_wAJX%j0h5fkvF)WMZ1}?#R(n-OT0CtwsL)|qk;*(!a)5a5ku2nCR9=E*iOZ`9 zy4>LHKt-BgHL@R9CBSG!v4wK zvjF8DORRva)@>nshE~VM@i2c$PKw?3nz(6-iVde;-S~~7R<5r2t$0U8k2_<5C0!$j zQg#lsRYtI#Q1YRs(-%(;F-K7oY~!m&zhuU4LL}>jbLC>B`tk8onRRcmIm{{0cpkD|o@Ixu#x9Wm5J)3oFkbfi62BX8IX1}VTe#{C(d@H|#gy5#Sa#t>sH@8v1h8XFgNGs?)tyF_S^ueJX_-1%+LR`1X@C zS3Oc)o)!8Z9!u9d!35YD^!aXtH;IMNzPp`NS|EcdaQw~<;z`lmkg zE|tQRF7!S!UCsbag%XlQZXmzAOSs= zIUjgY2jcN9`xA6mzG{m|Zw=3kZC4@XY=Bj%k8%D&iadvne$pYNfZI$^2BAB|-MnZW zU4U?*qE3`ZDx-bH})>wz~)a z_SWM!E=-BS#wdrfh;EfPNOS*9!;*+wp-zDthj<>P0a2n?$xfe;YmX~5a;(mNV5nKx zYR86%WtAPsOMIg&*o9uUfD!v&4(mpS6P`bFohPP<&^fZzfA|SvVzPQgbtwwM>IO>Z z75ejU$1_SB1tn!Y-9tajZ~F=Fa~{cnj%Y|$;%z6fJV1XC0080f)Pj|87j142q6`i>#)BCIi+x&jAH9|H#iMvS~?w;&E`y zoarJ)+5HWmZ{&OqlzbdQU=SE3GKmnQq zI{h6f$C@}Mbqf#JDsJyi&7M0O2ORXtEB`#cZ;#AcB zkao0`&|iH8XKvZ_RH|VaK@tAGKMq9x{sdd%p-o`!cJzmd&hb86N!KKxp($2G?#(#BJn5%hF0(^`= z2qRg5?82({w-HyjbffI>eqUXavp&|D8(I6zMOfM}0;h%*D_Dr@+%TaWpIEQX3*$vQ z8_)wkNMDi{rW`L+`yN^J*Gt(l7PExu3_hrntgbW0s}7m~1K=(mFymoU87#{|t*fJ?w8&>Uh zcS$Ny$HNRbT!UCFldTSp2*;%EoW+yhJD8<3FUt8@XSBeJM2dSEz+5}BWmBvdYK(OA zlm`nDDsjKED{$v*jl(&)H7-+*#jWI)W|_X)!em1qpjS_CBbAiyMt;tx*+0P%*m&v< zxV9rlslu8#cS!of#^1O$(ds8aviMFiT`6W+FzMHW{YS+SieJ^?TQb%NT&pasw^kbc znd`=%(bebvrNx3#7vq@vAX-G`4|>cY0svIXopH02{v;GZ{wJM#psz4!m8(IZu<)9D zqR~U7@cz-6H{724_*}-DWwE8Sk+dYBb*O-=c z+wdchFcm6$$^Z0_qGnv0P`)h1=D$_eg8!2-|7Y;o*c)4ax!Me0*EVcioh{wI#!qcb z1&xhOotXMrlo7P6{+C8m;E#4*=8(2y!r0d<6 zKi$d2X;O*zS(&Xiz_?|`ympxITf|&M%^WHp=694g6W@k+BL_T1JtSYX0OZ}o%?Pzu zJ{%P8A$uq?4F!NWGtq>_GLK3*c6dIcGH)??L`9Av&0k$A*14ED9!e9z_SZd3OH6ER zg%5^)3^gw;4DFw(RC;~r`bPJOR}H}?2n60=g4ESUTud$bkBLPyI#4#Ye{5x3@Yw<* z;P5Up>Yn(QdP#momCf=kOzZYzg9E330=67WOPbCMm2-T1%8{=or9L8+HGL{%83lri zODB;Y|LS`@mn#Wmez7t6-x`a2{}U9hE|xY7|BVcFCqoAZQzsEi=dYHB z(bqG3J5?teVSBqTj{aiqe<9}}CEc$HdsJSMp#I;4(EXRy_k|Y8X#5hwkqAaIGKARF zX?$|UO{>3-FU;IlFi80O^t+WMNw4So2nsg}^T1`-Ox&C%Gn_AZ-49Nir=2oYX6 z`uVke@L5PVh)YsvAgFMZfKi{DuSgWnlAaag{RN6t6oLm6{4)H~4xg#Xfcq-e@ALk& z@UP4;uCe(Yjg4jaJZ4pu*+*?4#+XCi%sTrqaT*jNY7|WQ!oR;S8nt)cI27W$Sz!94 z01zoTW`C*P3E?1@6thPe(QpIue$A54gp#C7pmfwRj}GxIw$!!qQetn`nvuwIvMBQ; zfF8K-D~O4aJKmLbNRN1?AZsWY&rp?iy`LP^3KT0UcGNy=Z@7qVM(#5u#Du#w>a&Bs z@f#zU{wk&5n!YF%D11S9*CyaI8%^oX=vq$Ei9cL1&kvv9|8vZD;Mhs1&slm`$A%ED zvz6SQ8aty~`IYp2Xd~G$z%Jf4zwVPKkCtqObrnc2gHKj^jg&-NH|xdNK_;+2d4ZXw zN9j)`jcp7y65&6P@}LsD_OLSi(#GW#hC*qF5KpmeXuQDNS%ZYpuW<;JI<>P6ln!p@ z>KPAM>8^cX|2!n@tV=P)f2Euv?!}UM`^RJ~nTT@W>KC2{{}xXS{}WH{|3najkiEUj z7l;fUWDPCtzQ$?(f)6RvzW~Tqan$bXibe%dv}**BqY!d4J?`1iX`-iy8nPo$s4^mQ z5+@=3xuZAl#KoDF*%>bJ4UrEB2EE8m7sQn!r7Z-ggig`?yy`p~3;&NFukc$`_>?}a z?LMo2LV^n>m!fv^HKKRrDn|2|zk?~S6i|xOHt%K(*TGWkq3{~|9+(G3M-L=;U-YRa zp{kIXZ8P!koE;BN2A;nBx!={yg4v=-xGOMC#~MA07zfR)yZtSF_2W^pDLcXg->*WD zY7Sz5%<_k+lbS^`y)=vX|KaN!gEMQob|(`%nP6huwr$%^?%0^vwr$(CZQD*Jc5?E( zb-q9E`OfoWSJ$rUs$ILfSFg3Mb*-!Ozgaz^%7ZkX@=3km0G;?+e?FQT_l5A9vKr<> z_CoemDo@6YIyl57l*gnJ^7+8xLW5oEGzjLv2P8vj*Q%O1^KOfrsC6eHvk{+$BMLGu z%goP8UY?J7Lj=@jcI$4{m2Sw?1E%_0C7M$lj}w{E#hM4%3QX|;tH6>RJf-TI_1A0w z@KcTEFx(@uitbo?UMMqUaSgt=n`Bu*;$4@cbg9JIS})3#2T;B7S

Z?HZkSa`=MM?n)?|XcM)@e1qmzJ$_4K^?-``~Oi&38`2}sjmP?kK z$yT)K(UU3fJID@~3R;)fU%k%9*4f>oq`y>#t90$(y*sZTzWcW$H=Xv|%^u^?2*n)Csx;35O0v7Nab-REgxDZNf5`cI69k$` zx(&pP6zVxlK5Apn5hAhui}b)(IwZD}D?&)_{_yTL7QgTxL|_X!o@A`)P#!%t9al+# zLD(Rr+?HHJEOl545~m1)cwawqY>cf~9hu-L`crI^5p~-9Mgp9{U5V&dJSwolnl_CM zwAMM1Tl$D@>v?LN2PLe0IZrQL1M zcA%i@Lc)URretFJhtw7IaZXYC6#8slg|*HfUF2Z5{3R_tw)YQ94=dprT`SFAvHB+7 z)-Hd1yE8LB1S+4H7iy$5XruPxq6pc_V)+VO{seA8^`o5{T5s<8bJ`>I3&m%R4cm1S z`hoNk%_=KU2;+#$Y!x7L%|;!Nxbu~TKw?zSP(?H0_b8Qqj4EPrb@~IE`~^#~C%D9k zvJ=ERh`xLgUwvusQbo6S=I5T+?lITYsVyeCCwT9R>DwQa&$e(PxF<}RpLD9Vm2vV# zI#M%ksVNFG1U?;QR{Kx2sf>@y$7sop6SOnBC4sv8S0-`gEt0eHJ{`QSW(_06Uwg*~ zIw}1dZ9c=K$a$N?;j`s3>)AqC$`ld?bOs^^stmYmsWA$XEVhUtGlx&OyziN1~2 z)s5fD(d@gq7htIGX!GCxKT=8aAOHW&DAP=$MpZ)SpeEZhk83}K) z0(Uv)+&pE?|4)D2PX4r6gOGHDY}$8FSg$3eDb*nEVmkFQ#lFpcH~IPeatiH3nPTkP z*xDN7l}r2GM9jwSsl=*!547nRPCS0pb;uE#myTqV+=se>bU=#e)f2}wCp%f-cIrh`FHA$2`monVy?qvJ~o2B6I7IE28bCY4=c#^){*essLG zXUH50W&SWmi{RIG9G^p;PohSPtC}djjXSoC)kyA8`o+L}SjE{i?%;Vh=h;QC{s`T7 zLmmHCr8F}#^O8_~lR)^clv$mMe`e*{MW#Sxd`rDckCnFBo9sC*vw2)dA9Q3lUi*Fy zgDsLt`xt|7G=O6+ms=`_FpD4}37uvelFLc^?snyNUNxbdSj2+Mpv<67NR{(mdtSDNJ3gSD@>gX_7S5 zCD)JP5Hnv!llc-9fwG=4@?=%qu~(4j>YXtgz%gZ#+A9i^H!_R!MxWlFsH(ClP3dU} za&`m(cM0xebj&S170&KLU%39I+XVWOJ_1XpF^ip}3|y()Fn5P@$pP5rvtiEK6w&+w z7uqIxZUj$#qN|<_LFhE@@SAdBy8)xTu>>`xC>VYU@d}E)^sb9k0}YKr=B8-5M?3}d z7&LqQWQ`a&=ihhANxe3^YT>yj&72x#X4NXRTc#+sk;K z=VUp#I(YIRO`g7#;5))p=y=MQ54JWeS(A^$qt>Y#unGRT$0BG=rI(tr>YqSxNm+-x z6n;-y8B>#FnhZX#mhVOT30baJ{47E^j-I6EOp;am;FvTlYRR2_?CjCWY+ypoUD-2S zqnFH6FS+q$H$^7>>(nd^WE+?Zn#@HU3#t|&=JnEDgIU+;CgS+krs+Y8vMo6U zHVkPoReZ-Di3z!xdBu#aW1f{8sC)etjN90`2|Y@{2=Os`(XLL9+ z1$_PE$GgTQrVx`^sx=Y(_y-SvquMF5<`9C=vM52+e+-r=g?D z+E|97MyoaK5M^n1(mnWeBpgtMs8fXOu4Q$89C5q4@YY0H{N47VANA1}M2e zspor6LdndC=kEvxs3YrPGbc;`q}|zeg`f;t3-8na)dGdZ9&d(n{|%mNaHaKJOA~@8 zgP?nkzV-=ULb)L3r`p)vj4<702a5h~Y%byo4)lh?rtu1YXYOY+qyTwzs!59I zL}XLe=q$e<+Wm7tvB$n88#a9LzBkgHhfT<&i#%e*y|}@I z!N~_)vodngB7%CI2pJT*{GX|cI5y>ZBN)}mezK~fFv@$*L`84rb0)V=PvQ2KN}3lTpT@$>a=CP?kcC0S_^PZ#Vd9#CF4 zP&`6{Y!hd^qmL!zr#F~FB0yag-V;qrmW9Jnq~-l>Sg$b%%TpO}{Q+*Pd-@n2suVh_ zSYP->P@# z&gQ^f{?}m(u5B9xqo63pUvDsJDQJi5B~ak+J{tX8$oL!_{Dh zL@=XFzWb+83H3wPbTic+osVp&~UoW3SqK0#P6+BKbOzK65tz)-@AW#g}Ew+pE3@ zVbdJkJ}EM@-Ghxp_4a)|asEk* z5)mMI&EK~BI^aaTMRl)oPJRH^Ld{;1FC&#pS`gh;l3Y;DF*`pR%OSz8U@B@zJxPNX zwyP_&8GsQ7^eYyUO3FEE|9~I~X8;{WTN=DJW0$2OH=3-!KZG=X6TH?>URr(A0l@+d zj^B9G-ACel;yYGZc}G`w9sR$Mo{tzE7&%XKuW$|u7DM<6_z}L>I{o`(=!*1 z{5?1p3F^aBONr6Ws!6@G?XRxJxXt_6b}2%Bp=0Iv5ngnpU^P+?(?O0hKwAK z*|wAisG&8&Td1XY+6qI~-5&+4DE2p|Dj8@do;!40o)F)QuoeUY;*I&QZ0*4?u)$s`VTkNl1WG`}g@J_i zjjmv4L%g&>@U9_|l>8^CN}`@4<D2aMN&?XXD-HNnsVM`irjv$ z^YVNUx3r1{-o6waQfDp=OG^P+vd;qEvd{UUYc;gF0UwaeacXkw32He^qyoYHjZeFS zo(#C9#&NEdFRcFrj7Q{CJgbmDejNS!H%aF6?;|KJQn_*Ps3pkq9yE~G{0wIS*mo0XIEYH zzIiJ>rbmD;sGXt#jlx7AXSGGcjty)5z5lTGp|M#5DCl0q0|~pNQ%1dP!-1>_7^BA~ zwu+uumJmTCcd)r|Hc)uWm7S!+Dw4;E|5+bwPb4i17Ued>NklnnsG+A{T-&}0=sLM- zY;sA9v@YH>b9#c$Vg{j@+>UULBX=jtu~N^%Y#BB5)pB|$?0Mf7msMD<7eACoP1(XY zPO^h5Brvhn$%(0JSo3KFwEPV&dz8(P41o=mo7G~A*P6wLJ@-#|_A z7>k~4&lbqyP1!la!qmhFBfIfT?nIHQ0j2WlohXk^sZ`?8-vwEwV0~uu{RDE^0yfl$ znua{^`VTZ)-h#ch_6^e2{VPaE@o&55|3dx$z_b6gbqduXJ(Lz(zq&ZbJ6qA4Ac4RT zhJO4KBLN!t;h(eW(?cZJw^swf8lP@tWMZ8GD)zg)siA3!2EJYI(j>WI$=pK!mo!Ry z?q&YkTIbTTr<>=}+N8C_EAR0XQL2&O{nNAXb?33iwo8{M``rUHJgnk z8KgZzZLFf|(O6oeugsm<;5m~4N$2Jm5#dph*@TgXC2_k&d%TG0LPY=Fw)=gf(hy9QmY*D6jCAiq44 zo-k2C+?3*+Wu7xm1w*LEAl`Vsq(sYPUMw|MiXrW)92>rVOAse5Pmx^OSi{y%EwPAE zx|csvE{U3c{vA>@;>xcjdCW15pE31F3aoIBsz@OQRvi%_MMfgar2j3Ob`9e@gLQk# zlzznEHgr|Ols%f*a+B-0klD`czi@RWGPPpR1tE@GB|nwe`td1OwG#OjGlTH zfT#^r?%3Ocp^U0F8Kekck6-Vg2gWs|sD_DTJ%2TR<5H3a$}B4ZYpP=p)oAoHxr8I! z1SYJ~v-iP&mNm{ra7!KP^KVpkER>-HFvq*>eG4J#kz1|eu;=~u2|>}TE_5nv2=d!0 z3P~?@blSo^uumuEt{lBsGcx{_IXPO8s01+7DP^yt&>k;<5(NRrF|To2h7hTWBFQ_A z+;?Q$o5L|LlIB>PH(4j)j3`JIb1xA_C@HRFnPnlg{zGO|-RO7Xn}!*2U=Z2V?{5Al z9+iL+n^_T~6Uu{law`R&fFadSVi}da8G>|>D<{(#vi{OU;}1ZnfXy8=etC7)Ae<2S zAlI`&=HkNiHhT0|tQztSLNsRR6v8bmf&$6CI|7b8V4kyJ{=pG#h{1sVeC28&Ho%Fh zwo_FIS}ST-2OF6jNQ$(pjrq)P)@sie#tigN1zSclxJLb-O9V|trp^G8<1rpsj8@+$ z2y27iiM>H8kfd%AMlK|9C>Lkvfs9iSk>k2}tCFlqF~Z_>-uWVQDd$5{3sM%2$du9; z*ukNSo}~@w@DPF)_vS^VaZ)7Mk&8ijX2hNhKom$#PM%bzSA-s$ z0O!broj`!Nuk)Qcp3(>dL|5om#XMx2RUSDMDY9#1|+~fxwP}1I4iYy4j$CGx3jD&eKhf%z`Jn z7mD!y6`nVq%&Q#5yqG`|+e~1$Zkgu!O(~~pWSDTw2^va3u!DOMVRQ8ycq)sk&H%vb z;$a`3gp74~I@swI!ILOkzVK3G&SdTcVe~RzN<+z`u(BY=yuwez{#T3a_83)8>2!X?`^02zVjqx-fN+tW`zCqH^XG>#Ies$qxa!n4*FF0m zxgJlPPYl*q4ylX;DVu3G*I6T&JyWvs`A(*u0+62=+ylt2!u)6LJ=Qe1rA$OWcNCmH zLu7PwMDY#rYQA1!!ONNcz~I^uMvi6N&Lo4dD&HF?1Su5}COTZ-jwR)-zLq=6@bN}X zSP(-MY`TOJ@1O`bLPphMMSWm+YL{Ger>cA$KT~)DuTl+H)!2Lf`c+lZ0ipxd>KfKn zIv;;eEmz(_(nwW24a+>v{K}$)A?=tp+?>zAmfL{}@0r|1>iFQfJ5C*6dKdijK=j16 zQpl4gl93ttF5@d<9e2LoZ~cqkH)aFMgt(el_)#OG4R4Hnqm(@D*Uj>2ZuUCy)o-yy z_J|&S-@o5#2IMcL(}qWF3EL<4n(`cygenA)G%Ssi7k4w)LafelpV5FvS9uJES+(Ml z?rzZ={vYrB#mB-Hd#ID{KS5dKl-|Wh_~v+Lvq3|<@w^MD-RA{q!$gkUUNIvAaex5y z)jIGW{#U=#UWyku7FIAB=TES8>L%Y9*h2N`#Gghie+a?>$CRNth?ORq)!Tde24f5K zKh>cz5oLC;ry*tHIEQEL>8L=zsjG7+(~LUN5K1pT`_Z-4Z}k^m%&H%g3*^e(FDCC{ zBh~eqx%bY?qqu_2qa+9A+oS&yFw^3nLRsN#?FcZvt?*dZhRC_a%Jd{qou(p5AG_Q6 ziOJMu8D~kJ7xEkG(69$Dl3t1J592=Olom%;13uZvYDda08YwzqFlND-;YodmA!SL) z!AOSI=(uCnG#Yo&BgrH(muUemmhQW7?}IHfxI~T`44wuLGFOMdKreQO!a=Z-LkH{T z@h;`A_l2Pp>Xg#`Vo@-?WJn-0((RR4uKM6P2*^-qprHgQhMzSd32@ho>%fFMbp9Y$ zx-#!r8gEu;VZN(fDbP7he+Nu7^o3<+pT!<<>m;m z=FC$N)wx)asxb_KLs}Z^;x*hQM}wQGr((&=%+=#jW^j|Gjn$(qqXwt-o-|>kL!?=T zh0*?m<^>S*F}kPiq@)Cp+^fnKi2)%<-Tw4K3oHwmI-}h}Kc^+%1P!D8aWp!hB@-ZT zybHrRdeYlYulEj>Bk zEIi|PU0eGg&~kWQ{q)gw%~bFT0`Q%k5S|tt!JIZXVXX=>er!7R^w>zeQ%M-(C|eOQG>5i|}i3}X#?aqAg~b1t{-fqwKd(&CyA zmyy)et*E}+q_lEqgbClewiJ=u@bFX}LKe)5o26K9fS;R`!er~a?lUCKf60`4Zq7{2q$L?k?IrAdcDu+ z4A0QJBUiGx&$TBASI2ASM_Wj{?fjv=CORO3GZz;1X*AYY`anM zI`M6C%8OUFSc$tKjiFJ|V74Yj-lK&Epi7F^Gp*rLeDTokfW#o6sl33W^~4V|edbS1 zhx%1PTdnI!C96iYqSA=qu6;p&Dd%)Skjjw0fyl>3k@O?I@x5|>2_7G#_Yc2*1>=^# z|H43bJDx$SS2!vkaMG!;VRGMbY{eJhT%FR{(a+RXDbd4OT?DRoE(`NhiVI6MsUCsT z1gc^~Nv>i;cIm2~_SYOfFpkUvV)(iINXEep;i4>&8@N#|h+_;DgzLqh3I#lzhn>cN zjm;m6U{+JXR2Mi)=~WxM&t9~WShlyA$Pnu+VIW2#;0)4J*C!{1W|y1TP{Q;!tldR< zI7aoH&cMm*apW}~BabBT;`fQ1-9q|!?6nTzmhiIo6fGQlcP{pu)kJh- zUK&Ei9lArSO6ep_SN$Lt_01|Y#@Ksznl@f<+%ku1F|k#Gcwa`(^M<2%M3FAZVb99?Ez4d9O)rqM< zCbYsdZlSo{X#nKqiRA$}XG}1Tw@)D|jGKo1ITqmvE4;ovYH{NAk{h8*Ysh@=nZFiF zmDF`@4do#UDKKM*@wDbwoO@tPx4aExhPF_dvlR&dB5>)W=wG6Pil zq{eBzw%Ov!?D+%8&(uK`m7JV7pqNp-krMd>ECQypq&?p#_3wy){eW{(2q}ij{6bfmyE+-ZO z)G4OtI;ga9;EVyKF6v3kO1RdQV+!*>tV-ditH-=;`n|2T zu(vYR*BJSBsjzFl1Oy#DpL=|pfEY4NM;y5Yly__T*Eg^3Mb_()pHwn)mAsh!7Yz-Z zY`hBLDXS4F^{>x=oOphq|LMo;G!C(b2hS9A6lJqb+e$2af}7C>zW2p{m18@Bdd>iL zoEE$nFUnaz_6p${cMO|;(c1f9nm5G5R;p)m4dcC1?1YD=2Mi&20=4{nu>AV#R^d%A zsmm_RlT#`;g~an9mo#O1dYV)2{mgUWEqb*a@^Ok;ckj;uqy{%*YB^({d{^V)P9VvP zC^qbK&lq~}TWm^RF8d4zbo~bJuw zFV!!}b^4BlJ0>5S3Q>;u*BLC&G6Fa5V|~w&bRZ*-YU>df6%qAvK?%Qf+#=M-+JqLw&w*l4{v7XTstY4j z26z69U#SVzSbY9HBXyD;%P$#vVU7G*Yb-*fy)Qpx?;ed;-P24>-L6U+OAC9Jj63kg zlY`G2+5tg1szc#*9ga3%f9H9~!(^QjECetX-PlacTR+^g8L<#VRovPGvsT)ln3lr= zm5WO@!NDuw+d4MY;K4WJg3B|Sp|WdumpFJO>I2tz$72s4^uXljWseYSAd+vGfjutO z-x~Qlct+BnlI+Iun)fOklxPH?30i&j9R$6g5^f&(x7bIom|FLKq9CUE);w2G>}vye zxWvEaXhx8|~2j)({Rq>0J9}lzdE`yhQ(l$z! z;x%d%_u?^4vlES_>JaIjJBN|N8z5}@l1#PG_@{mh`oWXQOI41_kPG}R_pV+jd^PU) zEor^SHo`VMul*80-K$0mSk|FiI+tHdWt-hzt~S>6!2-!R&rdL_^gGGUzkPe zEZkUKU=EY(5Ex)zeTA4-{Bkbn!Gm?nuaI4jLE%X;zMZ7bwn4FXz(?az;9(Uv;38U6 zi)}rA3xAcD2&6BY<~Pj9Q1~4Dyjs&!$)hyHiiTI@%qXd~+>> zW}$_puSSJ^uWv$jtWakn}}@eX6_LGz|7M#$!3yjY ztS{>HmQ%-8u0@|ig{kzD&CNK~-dIK5e{;@uWOs8$r>J7^c2P~Pwx%QVX0e8~oXK0J zM4HCNK?%t6?v~#;eP#t@tM$@SXRt;(b&kU7uDzlzUuu;+LQ5g%=FqpJPGrX8HJ8CS zITK|(fjhs3@CR}H4@)EjL@J zV_HPexOQ!@k&kvsQG)n;7lZaUh>{87l4NS_=Y-O9Ul3CaKG8iy+xD=QXZSr57a-hb z7jz3Ts-NVsMI783OPEdlE|e&a2;l^h@e>oYMh5@=Lte-9A+20|?!9>Djl~{XkAo>0p9`n&nfWGdGAfT-mSYW z1cvG>GT9dRJdcm7M_AG9JX5AqTCdJ6MRqR3p?+FvMxp(oB-6MZ`lRzSAj%N(1#8@_ zDnIIo9Rtv12(Eo}k_#FILhaZQ`yRD^Vn5tm+IK@hZO>s=t5`@p1#k?Umz2y*R64CF zGM-v&*k}zZ%Xm<_?1=g~<*&3KAy;_^QfccIp~CS7NW24Tn|mSDxb%pvvi}S}(~`2# z3I|kD@||l@lAW06K2%*gHd4x9YKeXWpwU%!ozYcJ+KJeX!s6b94j!Qyy7>S!wb?{qaMa`rpbU1phn0EpF}L zsBdZc|Im#iRiQmJjZwb5#n;`_O{$Zu$I zMXqbfu0yVmt!!Y`Fzl}QV7HUSOPib#da4i@vM$0u2FEYytsvrbR#ui9lrMkZ(AVVJ zMVl^Wi_fSRsEXLA_#rdaG%r(@UCw#o7*yBN)%22b)VSNyng6Lxk|2;XK3Qb=C_<`F zN##8MLHz-s%&O6JE~@P1=iHpj8go@4sC7*AWe99tuf$f7?2~wC&RA^UjB*2`K!%$y zSDzMd7}!vvN|#wDuP%%nuGk8&>N)7eRxtqdMXHD1W%hP7tYW{W>^DJp`3WS>3}i+$ z_li?4AlEj`r=!SPiIc+NNUZ9NCrMv&G0BdQHBO&S7d48aB)LfGi@D%5CC1%)1hVcJ zB~=yNC}LBn(K?cHkPmAX$5^M7JSnNkcc!X!0kD&^F$cJmRP(SJ`9b7}b)o$rj=BZ- zC;BX3IG94%Qz&(V$)7O~v|!=jd-yU1(6wd1u;*$z4DDe6+BFLhz>+8?59?d2Ngxck zm92yR!jk@MP@>>9FtAY2L+Z|MaSp{MnL-;fm}W3~fg!9TRr3;S@ysLf@#<)keHDRO zsJI1tP`g3PNL`2(8hK3!4;r|E-ZQbU0e-9u{(@du`4wjGj|A!QB&9w~?OI1r}M? zw)6tvsknfPfmNijZ;3VZX&HM6=|&W zy6GIe3a?_(pRxdUc==do9?C&v7+6cgIoL4)Ka^bOG9`l;S|QmVzjv%)3^PDi@=-cp z=!R0bU<@_;#*D}e1m@0!%k=VPtyRAkWYW(VFl|eu0LteWH7eDB%P|uF7BQ-|D4`n; z)UpuY1)*s32UwW756>!OoAq#5GAtfrjo*^7YUv^(eiySE?!TQzKxzqXE@jM_bq3Zq zg#1orE*Zd5ZWEpDXW9$=NzuadNSO*NW)ZJ@IDuU`w}j_FRE4-QS*rD4mPVQPH(jGg z+-Ye?3%G%=DT5U1b+TnNHHv(nz-S?3!M4hXtEB@J4WK%%p zkv=Bb`1DHmgUdYo>3kwB(T>Ba#DKv%cLp2h4r8v}p=Np}wL!&PB5J-w4V4REM{kMD z${oSuAw9?*yo3?tNp~X5WF@B^P<6L0HtIW0H7^`R8~9zAXgREH`6H{ntGu$aQ;oNq zig;pB^@KMHNoJcEb0f1fz+!M6sy?hQjof-QoxJgBM`!k^T~cykcmi^s_@1B9 z)t1)Y-ZsV9iA&FDrVoF=L7U#4&inXk{3+Xm9A|R<=ErgxPW~Fq zqu-~x0dIBlR+5_}`IK^*5l3f5$&K@l?J{)_d_*459pvsF*e*#+2guls(cid4!N%DG zl3(2`az#5!^@HNRe3O4(_5nc+){q?ENQG2|uKW0U0$aJ5SQ6hg>G4OyN6os76y%u8qNNHi;}XnRNwpsfn^!6Qt(-4tE`uxaDZ`hQp#aFX373|F?vjEiSEkV>K)cTBG+UL#wDj0_ zM9$H&-86zP=9=5_Q7d3onkqKNr4PAlF<>U^^yYAAEso|Ak~p$3NNZ$~4&kE9Nj^As zQPoo!m*uZ;z1~;#g(?zFECJ$O2@EBy<;F)fnQxOKvH`MojG5T?7thbe%F@JyN^k1K zn3H*%Ymoim)ePf)xhl2%$T)vq3P=4ty%NK)@}po&7Q^~o3l))Zm4<75Y!fFihsXJc z9?vecovF^nYfJVg#W~R3T1*PK{+^YFgb*7}Up2U#)oNyzkfJ#$)PkFxrq_{Ai?0zk zWnjq_ixF~Hs7YS9Y6H&8&k0#2cAj~!Vv4{wCM zi2f1FjQf+F@=BOB)pD|T41a4AEz+8hnH<#_PT#H|Vwm7iQ0-Tw()WMN za0eI-{B2G{sZ7+L+^k@BA)G;mOFWE$O+2nS|DzPSGZ)ede(9%+8kqu4W^wTn!yZPN z7u!Qu0u}K5(0euRZ$7=kn9DZ+llruq5A_l) zOK~wof7_^8Yeh@Qd*=P!gM)lh`Z@7^M?k8Z?t$$vMAuBG>4p56Dt!R$p{)y>QG}it zGG;Ei```7ewXrbGo6Z=!AJNQ!GP8l13m7|FIQTFZTpIg#kpZkl1wj)s1eySXjAAWy zfl;;@{QQ;Qnb$@LY8_Z&7 z6+d98F?z2Zo)sS)z$YoL(zzF>Ey8u#S_%n7)XUX1Pu(>e8gEUU1S;J=EH(#`cWi1+ zoL$5TN+?#NM8=4E7HOk)bf5MXvEo%he5QcB%_5YQ$cu_j)Pd^@5hi}d%nG}x9xXtD-JMQxr;KkC=r_dS-t`lf zF&CS?Lk~>U^!)Y0LZqNVJq+*_#F7W~!UkvZfQhzvW`q;^X&iv~ zEDDGIQ&(S;#Hb(Ej4j+#D#sDS_uHehlY0kZsQpktc?;O z22W1b%wNcdfNza<1M2{*mAkM<{}@(w`VuQ<^lG|iYSuWBD#lYK9+jsdA+&#;Y@=zXLVr840Nq_t5))#7}2s9pK* zg42zd{EY|#sIVMDhg9>t6_Y#O>JoG<{GO&OzTa;iA9&&^6=5MT21f6$7o@nS=w;R) znkgu*7Y{UNPu7B9&B&~q+N@@+%&cO0N`TZ-qQ|@f@e0g2BI+9xO$}NzMOzEbSSJ@v z1uNp(S z-dioXc$5YyA6-My@gW~1GH($Q?;GCHfk{ej-{Q^{iTFs1^Sa67RNd5y{cjX1tG+$& zbGrUte{U1{^Z_qpzW$-V!pJz$dQZrL5i(1MKU`%^= z^)i;xua4w)evDBrFVm)Id5SbXMx2u7M5Df<2L4B`wy4-Y+Wec#b^QJO|J9xF{x#M8 zuLUer`%ZL^m3gy?U&dI+`kgNZ+?bl3H%8)&k84*-=aMfADh&@$xr&IS|4{3$v&K3q zZTn&f{N(#L6<-BZYNs4 zB*Kl*@_IhGXI^_8zfXT^XNmjJ@5E~H*wFf<&er?p7suz85)$-Hqz@C zGMFg1NKs;otNViu)r-u{SOLcqwqc7$poPvm(-^ag1m71}HL#cj5t4Hw(W?*fi4GSH z9962NZ>p^ECPqVc$N}phy>N8rQsWWm%%rc5B4XLATFEtffX&TM2%|8S2Lh_q; zCytXua84HBnSybW-}(j z3Zwv4CaK)jC!{oUvdsFRXK&Sx@t)yGm(h65$!WZ!-jL52no}NX6=E<=H!aZ74h_&> zZ+~c@k!@}Cs84l{u+)%kg4fq~pOeTK3S4)gX~FKJw4t9ba!Ai{_gkKQYQvafZIyKq zX|r4xgC(l%JgmW!tvR&yNt$6uME({M`uNIi7HFiPEQo_UMRkl~12&4c& z^se;dbZWKu7>dLMg`IZq%@b@ME?|@{&xEIZEU(omKNUY? z`JszxNghuO-VA;MrZKEC0|Gi0tz3c#M?aO?WGLy64LkG4T%|PBIt_?bl{C=L@9e;A zia!35TZI7<`R8hr06xF62*rNH5T3N0v^acg+;ENvrLYo|B4!c^eILcn#+lxDZR!%l zjL6!6h9zo)<5GrSPth7+R(rLAW?HF4uu$glo?w1U-y}CR@%v+wSAlsgIXn>e%bc{FE;j@R0AoNIWf#*@BSngZ)HmNqkB z)cs3yN%_PT4f*K+Y1wFl)be=1iq+bb1G-}b|72|gJ|lMt`tf~0Jk}zMbS0+M-Mq}R z>Bv}-W6J%}j#dIz`Z0}zD(DGKn`R;E8A`)$a6qDfr(c@iHKZcCVY_nJEDpcUddGH* z*ct2$&)RelhmV}@jGXY>3Y~vp;b*l9M+hO}&x`e~q*heO8GVkvvJTwyxFetJC8VnhjR`5*+qHEDUNp16g`~$TbdliLLd}AFf}U+Oda1JXwwseRFbj?DN96;VSX~z?JxJSuA^BF}262%Z0)nv<6teKK`F zfm9^HsblS~?Xrb1_~^=5=PD!QH$Y1hD_&qe1HTQnese8N#&C(|Q)CvtAu6{{0Q%ut8ESVdn&& z4y%nsCs!$(#9d{iVjXDR##3UyoMNeY@_W^%qyuZ^K3Oa4(^!tDXOUS?b2P)yRtJ8j zSX}@qGBj+gKf;|6Kb&rq`!}S*cSu-3&S>=pM$eEB{K>PP~I}N|uGE|`3U#{Q6v^kO4nIsaq zfPld}c|4tVPI4!=!ETCNW+LjcbmEoxm0RZ%ieV0`(nVlWKClZW5^>f&h79-~CF(%+ zv|KL(^xQ7$#a}&BSGr9zf{xJ(cCfq>UR*>^-Ou_pmknCt6Y--~!duL{k2D{yLMl__ z!KeMRRg&EsD2s|cmy?xgK&XcGIKeos`&UEVhBTw;mqy|8DlP1M7PYS2z{YmTJ;n!h znPe(Qu?c7+xZz!Tm1AnE8|;&tf7fW$2dArX7ck1Jd(S1+91YB8bjISRZ`UL*?vb{b zMp*!Xq7VaLc0Ogqj5qmop8NREQ{9_iC$;tviZlubGLy1jLlIFBxAymMr@SDLAcx+) z5YRkl$bW**X)W0JzWNcLx9>fTqJj00ipY6Ua?mUlsgQrVVgpmaheE;RgA5U_+WsPh z9+X|PU4zFyNxZ2?Q+V`Mo{xH~(m}OMRZa<&$nCl7o4x`^^|V4?aPz8#KwFm=8T6_} z8=P_4$_rD2a%7}}HT6VQ>ZGKW=QF7zI-2=6oBNZR$HVn|gq`>l$HZ`48lkM7%R$>MS& zghR`WZ9Xrd_6FaDedH6_aKVJhYev*2)UQ>!CRH3PQ_d9nXlO;c z9PeqiKD@aGz^|mvD-tV<{BjfA;)B+76!*+`$CZOJ=#)}>{?!9fAg(Xngbh||n=q*C zU0mGP`NxHn$uY#@)gN<0xr)%Ue80U{-`^FX1~Q@^>WbLraiB|c#4v$5HX)0z!oA#jOXPyWg! z8EC}SBmG7j3T&zCenPLYA{kN(3l62pu}91KOWZl? zg~>T4gQ%1y3AYa^J|>ba$7F5KlVx}_&*~me*q-SYLBCXZFU=U8mHQD4K!?;B61NoX z?VS41SS&jHyhmB~+bC=w0a06V``ZXCkC~}oM9pM{$hU~-s_elYPmT1L!%B`?*<+?( zFQ@TP%y+QL`_&Y0A3679pe5~iL=z)$b)k!oSbJRyw+K};SGAvvE=|<~*aiwJc?uE@2?7a1i9|3=^N%*9smt3ZIhjY>gIsr{Q2rX(NovZ7I1n^V{ z#~(1ze-%`C>fM`^hCV**9BA-04lNuu&3=reevNOMwmX(A{yh`^c8%0mjAKMj{Th05 zXrM(zILwyL-Pcdw^(=gj(ZLVMA95zlzmLa^skb8tQq%8SV&4vp?S>L3+P4^tp`$xA zr38jBw0ItR`VbO5vB1`<3d})}aorkIU1z3*ifYN&Lpp)}|}QJS60th_v-EEkAM zyOREuj!Ou|pVeZEWg;$Hf!x;xAmFu7gB^UR$=L0BuZ~thLC@#moJ(@@wejR|`t_K@ zuQ{XmpAWz%o&~2dk!SIGR$EmpZY)@+r^gvX26%)y>1u2bt~JUPTQzQu&_tB)|{19)&n$m5Fhw0A-8S1^%XpAD%`#a z_ModVxsM|x!m3N1vRt_XEL`O-+J3cMsM1l*dbjT&S0c@}Xxl3I&AeMNT97G3c6%3C zbrZS?2EAKcEq@@Pw?r%eh0YM6z0>&Qe#n+e9hEHK?fzig3v5S#O2IxVLu;a>~c~ZfHVbgLox%_tg)bsC8Rl35P=Jhl+Y=w6zb$ z;*uO%i^U z^mp_QggBILLF$AyjPD41Z0SFdbDj&z&xjq~X|OoM7bCuBfma1CEd!4RKGqPR)K)e}+7^JfFUI_fy63cMyq#&)Z*#w18{S zhC@f9U5k#2S2`d$-)cEoH-eAz{2Qh>YF1Xa)E$rWd52N-@{#lrw3lRqr)z?BGThgO z-Mn>X=RPHQ)#9h{3ciF)<>s{uf_&XdKb&kC!a373l2OCu&y8&n#P%$7YwAVJ_lD-G zX7tgMEV8}dY^mz`R6_0tQ5Eu@CdSOyaI63Vb*mR+rCzxgsjCXLSHOmzt0tA zGoA0Cp&l>rtO@^uQayrkoe#d2@}|?SlQl9W{fmcxY(0*y zHTZ6>FL;$8FEzbb;M(o%mBe-X?o<0+1dH?ZVjcf8)Kyqb07*a zLfP1blbt)=W)TN}4M#dUnt8Gdr4p$QRA<0W)JhWLK3-g82Q~2Drmx4J z;6m4re%igus136VL}MDI-V;WmSfs4guF_(7ifNl#M~Yx5HB!UF)>*-KDQl0U?u4UXV2I*qMhEfsxb%87fi+W;mW5{h?o8!52}VUs*Fpo#aSuXk(Ug z>r>xC#&2<9Uwmao@iJQ|{Vr__?eRT2NB$OcoXQ-jZ{t|?Uy{7q$nU-i|&-R6fHPWJDgHZ69iVbK#Ab@2@y zPD*Gj=hib?PWr8NGf;g$o5I!*n>94Z!IfqRm zLvM>Gx$Y*rEL3Z-+lS42=cnEfXR)h1z`h8a+I%E_ss%qXsrgIV%qv9d|KT>fV5=3e zw>P#ju>2naGc{=6!)9TeHq$S9Pk|>$UCEl}H}lE@;0(jbNT9TXUXyss>al>S4DuGi zVCy;Qt=a2`iu2;TvrIkh2NTvNV}0)qun~9y1yEQMdOf#V#3(e(C?+--8bCsJu={Q1z5qNJIk&yW>ZnVm;A=fL~29lvXQ*4j(SLau?P zi8LC7&**O!6B6=vfY%M;!p2L2tQ+w3Y!am{b?14E`h4kN$1L0XqT5=y=DW8GI_yi% zlIWsjmf0{l#|ei>)>&IM4>jXH)?>!fK?pfWIQn9gT9N(z&w3SvjlD|u*6T@oNQRF6 zU5Uo~SA}ml5f8mvxzX>BGL}c2#AT^6Lo-TM5XluWoqBRin$tiyRQK0wJ!Ro+7S!-K z=S95p-(#IDKOZsRd{l65N(Xae`wOa4Dg9?g|Jx97N-7OfHG(rN#k=yNGW0K$Tia5J zMMX1+!ulc1%8e*FNRV8jL|OSL-_9Nv6O=CH>Ty(W@sm`j=NFa1F3tT$?wM1}GZekB z6F_VLMCSd7(b9T%IqUMo$w9sM5wOA7l8xW<(1w0T=S}MB+9X5UT|+nemtm_;!|bxX z_bnOKN+F30ehJ$459k@=69yTz^_)-hNE4XMv$~_%vlH_y^`P1pLxYF6#_IZyteO`9wpuS> z#%Vyg5mMDt?}j!0}MoBX|9PS0#B zSVo6xLVjujMN57}IVc#A{VB*_yx;#mgM4~yT6wO;Qtm8MV6DX?u(JS~JFA~PvEl%9 z2XI}c>OzPoPn_IoyXa2v}BA(M+sWq=_~L0rZ_yR17I5c^m4;?2&KdCc)3lCs!M|0OzH@(PbG8T6w%N zKzR>%SLxL_C6~r3=xm9VG8<9yLHV6rJOjFHPaNdQHHflp><44l>&;)&7s)4lX%-er znWCv8eJJe1KAi_t1p%c4`bgxD2(1v)jm(gvQLp2K-=04oaIJu{F7SIu8&)gyw7x>+ zbzYF7KXg;T71w!-=C0DjcnF^JP$^o_N>*BAjtH!^HD6t1o?(O7IrmcodeQVDD<*+j zN)JdgB6v^iiJ1q`bZ(^WvN{v@sDqG$M9L`-UV!3q&sWZUnQ{&tAkpX(nZ_L#rMs}>p7l0fU5I5IzArncQi6TWjP#1B=QZ|Uqm-3{)YPn=XFqHW-~Fb z^!0CvIdelQbgcac9;By79%T`uvNhg9tS><pLzXePP=JZzcO@?5GRAdF4)sY*)YGP* zyioMa3=HRQz(v}+cqXc0%2*Q%CQi%e2~$a9r+X*u3J8w^Shg#%4I&?!$})y@ zzg8tQ6_-`|TBa_2v$D;Q(pFutj7@yos0W$&__9$|Yn3DFe*)k{g^|JIV4bqI@2%-4kpb_p? zQ4}qQcA>R6ihbxnVa{c;f7Y)VPV&mRY-*^qm~u3HB>8lf3P&&#GhQk8uIYYgwrugY zei>mp`YdC*R^Cxuv@d0V?$~d*=m-X?1Fqd9@*IM^wQ_^-nQEuc0!OqMr#TeT=8W`JbjjXc-Dh3NhnTj8e82yP;V_B<7LIejij+B{W1ViaJ_)+q?$BaLJpxt_4@&(?rWC3NC-_Z9Sg4JJWc( zX!Y34j67vCMHKB=JcJ1|#UI^D^mn(i=A5rf-iV7y4bR5HhC=I`rFPZv4F>q+h?l34 z4(?KYwZYHwkPG%kK7$A&M#=lpIn3Qo<>s6UFy|J$Zca-s(oM7??dkuKh?f5b2`m57 zJhs4BTcVVmwsswlX?#70uQb*k1Fi3q4+9`V+ikSk{L3K=-5HgN0JekQ=J~549Nd*+H%5+fi6aJuR=K zyD3xW{X$PL7&iR)=wumlTq2gY{LdrngAaPC;Qw_xLfVE0c0Z>y918TQpL!q@?`8{L!el18Qxiki3WZONF=eK$N3)p>36EW)I@Y z7QxbWW_9_7a*`VS&5~4-9!~&g8M+*U9{I2Bz`@TJ@E(YL$l+%<=?FyR#&e&v?Y@@G zqFF`J*v;l$&(A=s`na2>4ExKnxr`|OD+Xd-b4?6xl4mQ94xuk!-$l8*%+1zQU{)!= zTooUhjC0SNBh!&Ne}Q=1%`_r=Vu1c8RuE!|(g4BQGcd5AbpLbvKv_Z~Y`l!mr!sCc zDBupoc{W@U(6KWqW@xV_`;J0~+WDx|t^WeMri#=q0U5ZN7@@FAv<1!hP6!IYX z>UjbhaEv2Fk<6C0M^@J`lH#LgKJ(`?6z5=uH+ImggSQaZtvh52WTK+EBN~-op#EQKYW`$yBmq z4wgLTJPn3;mtbs0m0RO&+EG>?rb*ZECE0#eeSOFL!2YQ$w}cae>sun`<=}m!=go!v zO2jn<0tNh4E-4)ZA(ixh5nIUuXF-qYl>0I_1)K%EAw`D7~la$=gc@6g{iWF=>i_76?Mc zh#l9h7))<|EY=sK!E|54;c!b;Zp}HLd5*-w^6^whxB98v`*P>cj!Nfu1R%@bcp{cb zUZ24(fUXn3d&oc{6H%u(@4&_O?#HO(qd^YH=V`WJ=u*u6Zie8mE^r_Oz zDw`DaXeq4G#m@EK5+p40Xe!Lr!-jTQLCV3?R1|3#`%45h8#WSA!XoLDMS7=t!SluZ4H56;G z6C9D(B6>k^ur_DGfJ@Y-=3$5HkrI zO+3P>R@$6QZ#ATUI3$)xRBEL#5IKs}yhf&fK;ANA#Qj~G zdE|k|`puh$%dyE4R0$7dZd)M*#e7s%*PKPyrS;d%&S(d{_Ktq^!Hpi&bxZx`?9pEw z%sPjo&adHm95F7Z1{RdY#*a!&LcBZVRe{qhn8d{pOUJ{fOu`_kFg7ZVeRYZ(!ezNktT5{Ab z4BZI$vS0$vm3t9q`ECjDK;pmS{8ZTKs`Js~PYv2|=VkDv{Dtt)cLU@9%K6_KqtqfM zaE*e$f$Xm=;IAURNUXw8g%=?jzG2}10ZA5qXzAaJ@eh)yv5B=ETyVwC-a*CD;GgRJ z4J1~zMUey?4iVlS0zW|F-~0nenLiN3S0)l!T2}D%;<}Z9DzeVgcB+MSj;f$KY;uP%UR#f`0u*@6U@tk@jO3N?Fjq< z{cUUhjrr$rmo>qE?52zKe+>6iP5P_tcUfxsLSy{9*)shB(w`UUveNH`a`kr$VEF@} zKh&|lTD;4;m_H6C&)9#D`kRh;S(NTa=Ve^~xe_0~x$6h8Q@B_qu#ee=(lkI9@F6$0m=z@H=4&h%Q{htM>uHs(Sr@2ry`fgLA zKj8lVXdGPyy)2J%A${}Rm_a{){wHnlM?yGPQ7#KO{8*(_l0QZHuV};nO?c%h?qwSL z3wem|w*2tdxW5&PxC(Wd0QG_w|GPbw|0UFK`u$~U%!`QKcME;=Q@?*erh4_>FP~1n zAldwG9h$$u_$RFK6Uxo20GHqJzc}Rl-EwVz3h4n z;3~%DwD84i>)-8#&#y3k)3BG5cNaP3?t4q}F%yfv?*yEiC>sSo}$f>nh0QNZXH1N)-Q7kbk=2uL9OrF)nXrE@F1y%_8Yn c82=K%QXLKFx%@O{wJjEi6Y56o#$)Bpeg literal 0 HcmV?d00001 diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..8fe023903 --- /dev/null +++ b/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,8 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806 +networkTimeout=60000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/android/gradlew b/android/gradlew new file mode 100755 index 000000000..61b77d7f3 --- /dev/null +++ b/android/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat new file mode 100644 index 000000000..bd8a8c055 --- /dev/null +++ b/android/gradlew.bat @@ -0,0 +1,93 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/android/scripts/build-native.py b/android/scripts/build-native.py new file mode 100644 index 000000000..c3d263082 --- /dev/null +++ b/android/scripts/build-native.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +"""Build the shared iOS/Android Blitz engine and its small Android JNI adapter.""" +import os +from pathlib import Path +import platform +import shutil +import subprocess + +root = Path(__file__).resolve().parents[2] +sdk = Path(os.environ.get("ANDROID_HOME", str(Path.home() / "Library/Android/sdk"))) +ndk = sdk / "ndk/30.0.16248370" +host = "darwin-x86_64" if platform.system() == "Darwin" else "linux-x86_64" +toolchain = ndk / "toolchains/llvm/prebuilt" / host +if not toolchain.exists(): + raise SystemExit(f"Install NDK 30.0.16248370 in {sdk} first") +# cargo-ndk's panic reporter prints its environment. Pass build-related variables only. +env = {k: v for k, v in os.environ.items() if k in { + "HOME", "PATH", "TMPDIR", "CARGO_HOME", "RUSTUP_HOME", "JAVA_HOME", "ANDROID_HOME" +}} +env.update(ANDROID_HOME=str(sdk), ANDROID_NDK_HOME=str(ndk), CARGO_BUILD_JOBS="4") +env["PATH"] = str(Path.home() / ".cargo/bin") + os.pathsep + env.get("PATH", "") +crate = root / "ios/BlitzKit/rust" +subprocess.run(["cargo", "ndk", "-t", "arm64-v8a", "-P", "26", "build", "--release", "--locked"], + cwd=crate, env=env, check=True) +out = root / "android/app/build/native/jniLibs/arm64-v8a" +out.mkdir(parents=True, exist_ok=True) +subprocess.run([str(toolchain / "bin/aarch64-linux-android26-clang"), "-shared", "-fPIC", "-O2", + "-Wl,-z,max-page-size=16384", "-Wl,--gc-sections", "-Wl,-soname,libdoop_android.so", + "-Wl,--exclude-libs,ALL", "-I" + str(root / "ios/BlitzKit/include"), + str(root / "android/app/src/main/cpp/blitz_jni.c"), + str(crate / "target/aarch64-linux-android/release/libdoopblitz.a"), + "-lc++_shared", "-llog", "-landroid", "-ljnigraphics", "-ldl", "-lm", "-o", str(out / "libdoop_android.so")], + env=env, check=True) +shutil.copy2(toolchain / "sysroot/usr/lib/aarch64-linux-android/libc++_shared.so", out) +subprocess.run([str(toolchain / "bin/llvm-strip"), "--strip-unneeded", str(out / "libdoop_android.so")], check=True) +print("Android Blitz renderer:", out) diff --git a/android/settings.gradle.kts b/android/settings.gradle.kts new file mode 100644 index 000000000..bb666de6e --- /dev/null +++ b/android/settings.gradle.kts @@ -0,0 +1,7 @@ +pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } } +dependencyResolutionManagement { + repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) + repositories { google(); mavenCentral() } +} +rootProject.name = "Doop" +include(":app") diff --git a/bun.lock b/bun.lock index 5f305e6b3..2cdae9a66 100644 --- a/bun.lock +++ b/bun.lock @@ -26,6 +26,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", + "css-select": "5.1.0", "drizzle-orm": "^0.45.2", "envalid": "8.2.0", "express": "^4.19.2", @@ -931,6 +932,8 @@ "body-parser": ["body-parser@1.20.6", "", { "dependencies": { "bytes": "~3.1.2", "content-type": "~1.0.5", "debug": "2.6.9", "depd": "2.0.0", "destroy": "~1.2.0", "http-errors": "~2.0.1", "iconv-lite": "~0.4.24", "on-finished": "~2.4.1", "qs": "~6.15.1", "raw-body": "~2.5.3", "type-is": "~1.6.18", "unpipe": "~1.0.0" } }, "sha512-p5tAzS57i5MV9fZFDj9LeIiTZEufbSe2eDozP+ElheSUq1m74CRq1jI4mYNDdVs9vQztXFLuk/Gd6BWTdwRJ5g=="], + "boolbase": ["boolbase@1.0.0", "", {}, "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww=="], + "bowser": ["bowser@2.14.1", "", {}, "sha512-tzPjzCxygAKWFOJP011oxFHs57HzIhOEracIgAePE4pqB3LikALKnSzUyU4MGs9/iCEUuHlAJTjTc5M+u7YEGg=="], "brace-expansion": ["brace-expansion@5.0.9", "", { "dependencies": { "balanced-match": "^4.0.2" } }, "sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg=="], @@ -1019,6 +1022,10 @@ "cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="], + "css-select": ["css-select@5.1.0", "", { "dependencies": { "boolbase": "^1.0.0", "css-what": "^6.1.0", "domhandler": "^5.0.2", "domutils": "^3.0.1", "nth-check": "^2.0.1" } }, "sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg=="], + + "css-what": ["css-what@6.2.2", "", {}, "sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA=="], + "css.escape": ["css.escape@1.5.1", "", {}, "sha512-YUifsXXuknHlUsmlgyY0PKzgPOr7/FjCePfHNt0jxm83wHZi44VDMQ7/fGNkjY3/jV1MC+1CmZbaHzugyeRtpg=="], "cssesc": ["cssesc@3.0.0", "", { "bin": { "cssesc": "bin/cssesc" } }, "sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg=="], @@ -1065,8 +1072,16 @@ "dom-accessibility-api": ["dom-accessibility-api@0.5.16", "", {}, "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg=="], + "dom-serializer": ["dom-serializer@2.0.0", "", { "dependencies": { "domelementtype": "^2.3.0", "domhandler": "^5.0.2", "entities": "^4.2.0" } }, "sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg=="], + + "domelementtype": ["domelementtype@2.3.0", "", {}, "sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw=="], + + "domhandler": ["domhandler@5.0.3", "", { "dependencies": { "domelementtype": "^2.3.0" } }, "sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w=="], + "dompurify": ["dompurify@3.4.14", "", { "optionalDependencies": { "@types/trusted-types": "^2.0.7" } }, "sha512-dVoH9z+MY+C9IilgGCk3YfFqjLi3fChm2OiKJMzh6axrJ5qwxqWaZamgmHrpv22CN/KdbZJuGEGgfQoL00LTdg=="], + "domutils": ["domutils@3.2.2", "", { "dependencies": { "dom-serializer": "^2.0.0", "domelementtype": "^2.3.0", "domhandler": "^5.0.3" } }, "sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw=="], + "dot-prop": ["dot-prop@6.0.1", "", { "dependencies": { "is-obj": "^2.0.0" } }, "sha512-tE7ztYzXHIeyvc7N+hR3oi7FIbf/NIjVP9hmAt3yMXzrQ072/fpjGLx2GxNxGxUl5V73MEqYzioOMoVhGMJ5cA=="], "dotenv": ["dotenv@17.4.2", "", {}, "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw=="], @@ -1441,6 +1456,8 @@ "npm-run-path": ["npm-run-path@6.0.0", "", { "dependencies": { "path-key": "^4.0.0", "unicorn-magic": "^0.3.0" } }, "sha512-9qny7Z9DsQU8Ou39ERsPU4OZQlSTP47ShQzuKZ6PRXpYLtIFgl/DEBYEXKlvcEa+9tHVcK8CF81Y2V72qaZhWA=="], + "nth-check": ["nth-check@2.1.1", "", { "dependencies": { "boolbase": "^1.0.0" } }, "sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w=="], + "object-assign": ["object-assign@4.1.1", "", {}, "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg=="], "object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="], @@ -1983,6 +2000,8 @@ "cosmiconfig-typescript-loader/jiti": ["jiti@2.6.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ=="], + "dom-serializer/entities": ["entities@4.5.0", "", {}, "sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw=="], + "dot-prop/is-obj": ["is-obj@2.0.0", "", {}, "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w=="], "drizzle-kit/esbuild": ["esbuild@0.25.12", "", { "optionalDependencies": { "@esbuild/aix-ppc64": "0.25.12", "@esbuild/android-arm": "0.25.12", "@esbuild/android-arm64": "0.25.12", "@esbuild/android-x64": "0.25.12", "@esbuild/darwin-arm64": "0.25.12", "@esbuild/darwin-x64": "0.25.12", "@esbuild/freebsd-arm64": "0.25.12", "@esbuild/freebsd-x64": "0.25.12", "@esbuild/linux-arm": "0.25.12", "@esbuild/linux-arm64": "0.25.12", "@esbuild/linux-ia32": "0.25.12", "@esbuild/linux-loong64": "0.25.12", "@esbuild/linux-mips64el": "0.25.12", "@esbuild/linux-ppc64": "0.25.12", "@esbuild/linux-riscv64": "0.25.12", "@esbuild/linux-s390x": "0.25.12", "@esbuild/linux-x64": "0.25.12", "@esbuild/netbsd-arm64": "0.25.12", "@esbuild/netbsd-x64": "0.25.12", "@esbuild/openbsd-arm64": "0.25.12", "@esbuild/openbsd-x64": "0.25.12", "@esbuild/openharmony-arm64": "0.25.12", "@esbuild/sunos-x64": "0.25.12", "@esbuild/win32-arm64": "0.25.12", "@esbuild/win32-ia32": "0.25.12", "@esbuild/win32-x64": "0.25.12" }, "bin": { "esbuild": "bin/esbuild" } }, "sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg=="], diff --git a/desktop/CHANGELOG.md b/desktop/CHANGELOG.md index c771130d0..fceebf2d3 100644 --- a/desktop/CHANGELOG.md +++ b/desktop/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## [0.14.0](https://github.com/kgoedecke/doop/compare/desktop-v0.13.0...desktop-v0.14.0) (2026-11-16) + + +### Features + +* **canvas:** action registry with ⌘K palette, main menu and editor shortcuts ([#448](https://github.com/kgoedecke/doop/issues/448)) ([1970798](https://github.com/kgoedecke/doop/commit/1970798b4f13c65c90654116d1dcf0ae634856c0)) +* **desktop:** choose the Doop server from the sign-in screen ([#452](https://github.com/kgoedecke/doop/issues/452)) ([f98867a](https://github.com/kgoedecke/doop/commit/f98867a0917c36fcb2e1139b2f984a3ef9b4f0da)) + + +### Bug Fixes + +* **agent:** raise the resident step limit and finish runs whose work is done ([#517](https://github.com/kgoedecke/doop/issues/517)) ([e17dc2b](https://github.com/kgoedecke/doop/commit/e17dc2b940fb49e18a330cec96008112f2af5233)) + ## [0.13.0](https://github.com/kgoedecke/doop/compare/desktop-v0.12.0...desktop-v0.13.0) (2026-11-08) diff --git a/desktop/package.json b/desktop/package.json index d5d0cf25e..870d0c1a4 100644 --- a/desktop/package.json +++ b/desktop/package.json @@ -1,7 +1,7 @@ { "name": "doop-desktop", "private": true, - "version": "0.13.0", + "version": "0.14.0", "scripts": { "tauri": "tauri", "dev": "tauri dev", diff --git a/desktop/src-tauri-chromium/Cargo.toml b/desktop/src-tauri-chromium/Cargo.toml index 8a761cbde..ae97dd432 100644 --- a/desktop/src-tauri-chromium/Cargo.toml +++ b/desktop/src-tauri-chromium/Cargo.toml @@ -11,7 +11,7 @@ # shared dependencies below in step with ../src-tauri. [package] name = "doop-desktop-chromium" -version = "0.13.0" +version = "0.14.0" description = "Desktop shell for doop on Chromium (CEF) — the same thin shell over the hosted app" edition = "2021" build = "../src-tauri/build.rs" diff --git a/desktop/src-tauri-chromium/tauri.conf.json b/desktop/src-tauri-chromium/tauri.conf.json index c9636406a..8c82827e4 100644 --- a/desktop/src-tauri-chromium/tauri.conf.json +++ b/desktop/src-tauri-chromium/tauri.conf.json @@ -2,7 +2,7 @@ "$schema": "https://schema.tauri.app/config/2", "productName": "doop", "mainBinaryName": "doop-desktop", - "version": "0.13.0", + "version": "0.14.0", "identifier": "design.doop.desktop", "build": { "devUrl": "http://localhost:4300", diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml index cb01e54a9..990338fc6 100644 --- a/desktop/src-tauri/Cargo.toml +++ b/desktop/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "doop-desktop" -version = "0.13.0" +version = "0.14.0" description = "Desktop shell for doop — a thin webview over the hosted app" edition = "2021" diff --git a/desktop/src-tauri/src/claude.rs b/desktop/src-tauri/src/claude.rs index 7b591ad4b..8e3d78468 100644 --- a/desktop/src-tauri/src/claude.rs +++ b/desktop/src-tauri/src/claude.rs @@ -765,7 +765,7 @@ fn run_cli(app: &AppHandle, job: &Value, cancel: Arc) -> Result 1_000_000 { return Err("Task is too large".into()); } - let turns = job["maxTurns"].as_u64().unwrap_or(24).clamp(1, 40); + let turns = job["maxTurns"].as_u64().unwrap_or(60).clamp(1, 80); let dir = directory(app)?.join(id); std::fs::create_dir_all(&dir).map_err(|e| e.to_string())?; let config = dir.join("mcp.json"); diff --git a/desktop/src-tauri/tauri.conf.json b/desktop/src-tauri/tauri.conf.json index 539302044..339361afa 100644 --- a/desktop/src-tauri/tauri.conf.json +++ b/desktop/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "doop", - "version": "0.13.0", + "version": "0.14.0", "identifier": "design.doop.desktop", "build": { "devUrl": "http://localhost:4300", diff --git a/ios/BlitzKit/rust/Cargo.lock b/ios/BlitzKit/rust/Cargo.lock index 1636a7c25..37c81396f 100644 --- a/ios/BlitzKit/rust/Cargo.lock +++ b/ios/BlitzKit/rust/Cargo.lock @@ -232,7 +232,7 @@ dependencies = [ [[package]] name = "blitz-dom" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "accesskit", "anyrender", @@ -243,7 +243,7 @@ dependencies = [ "color", "cssparser", "cursor-icon", - "debug_timer 0.1.3 (git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb)", + "debug_timer 0.1.3 (git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe)", "euclid", "html-escape", "image", @@ -277,7 +277,7 @@ dependencies = [ [[package]] name = "blitz-html" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "blitz-dom", "blitz-traits", @@ -288,7 +288,7 @@ dependencies = [ [[package]] name = "blitz-net" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "blitz-traits", "data-url", @@ -304,7 +304,7 @@ dependencies = [ [[package]] name = "blitz-paint" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "anyrender", "anyrender_svg", @@ -327,7 +327,7 @@ dependencies = [ [[package]] name = "blitz-traits" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "atomic_refcell", "bitflags 2.13.2", @@ -756,7 +756,7 @@ checksum = "da220af51a1a335e9a930beaaef53d261e41ea9eecfb3d973a3ddae1a7284b9c" [[package]] name = "debug_timer" version = "0.1.3" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" [[package]] name = "deranged" @@ -865,6 +865,7 @@ dependencies = [ "skia-safe", "taffy", "tokio", + "url", ] [[package]] @@ -2877,7 +2878,7 @@ dependencies = [ [[package]] name = "selectors" version = "0.41.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "bitflags 2.13.2", "cssparser", @@ -2965,7 +2966,7 @@ dependencies = [ [[package]] name = "servo_arc" version = "0.5.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "serde", "stable_deref_trait", @@ -3211,7 +3212,7 @@ dependencies = [ [[package]] name = "stylo" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "app_units", "arrayvec", @@ -3267,7 +3268,7 @@ dependencies = [ [[package]] name = "stylo_atoms" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "string_cache", "string_cache_codegen", @@ -3276,7 +3277,7 @@ dependencies = [ [[package]] name = "stylo_derive" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "darling", "proc-macro2", @@ -3288,7 +3289,7 @@ dependencies = [ [[package]] name = "stylo_dom" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "bitflags 2.13.2", "stylo_malloc_size_of", @@ -3297,7 +3298,7 @@ dependencies = [ [[package]] name = "stylo_malloc_size_of" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "app_units", "cssparser", @@ -3315,7 +3316,7 @@ dependencies = [ [[package]] name = "stylo_static_prefs" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "toml", ] @@ -3323,7 +3324,7 @@ dependencies = [ [[package]] name = "stylo_taffy" version = "0.3.0-beta.2" -source = "git+https://github.com/kgoedecke/blitz?rev=98827022abbcf9623487df590f18a815ee8c5bfb#98827022abbcf9623487df590f18a815ee8c5bfb" +source = "git+https://github.com/kgoedecke/blitz?rev=3cbca256ee8863a030e9e37a8be1001975e2bdfe#3cbca256ee8863a030e9e37a8be1001975e2bdfe" dependencies = [ "bitflags 2.13.2", "stylo", @@ -3334,7 +3335,7 @@ dependencies = [ [[package]] name = "stylo_traits" version = "0.22.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "app_units", "bitflags 2.13.2", @@ -3589,7 +3590,7 @@ checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" [[package]] name = "to_shmem" version = "0.6.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "cssparser", "servo_arc", @@ -3602,7 +3603,7 @@ dependencies = [ [[package]] name = "to_shmem_derive" version = "0.2.0" -source = "git+https://github.com/kgoedecke/stylo?rev=f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70#f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" +source = "git+https://github.com/kgoedecke/stylo?rev=f247bcfd8e380832e02c9c2b69d83bd5ee59bb43#f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" dependencies = [ "darling", "proc-macro2", diff --git a/ios/BlitzKit/rust/Cargo.toml b/ios/BlitzKit/rust/Cargo.toml index e74b6a106..bb5f564c8 100644 --- a/ios/BlitzKit/rust/Cargo.toml +++ b/ios/BlitzKit/rust/Cargo.toml @@ -10,15 +10,15 @@ crate-type = ["staticlib", "rlib"] [dependencies] # Blitz from the `doop` branch of kgoedecke/blitz: DioxusLabs/blitz at 0f60502 plus our -# rendering fixes (inline SVG, web fonts, placeholders, filters), each also sent upstream. +# rendering fixes (inline SVG, web fonts, placeholders, filters, opt-in prefers-reduced-motion), +# each also sent upstream. # Update by rebasing that branch and bumping the rev here. -blitz-dom = { git = "https://github.com/kgoedecke/blitz", rev = "98827022abbcf9623487df590f18a815ee8c5bfb", default-features = false, features = ["default"] } +blitz-dom = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false, features = ["default"] } # Same taffy as the pinned Blitz workspace: the bridge re-rounds layout on the device-pixel grid. taffy = { git = "https://github.com/DioxusLabs/taffy", rev = "49152ca29664f9687c714c7732d88ff07d62110a", default-features = false, features = ["std", "content_size"] } -blitz-html = { git = "https://github.com/kgoedecke/blitz", rev = "98827022abbcf9623487df590f18a815ee8c5bfb", default-features = false } -blitz-paint = { git = "https://github.com/kgoedecke/blitz", rev = "98827022abbcf9623487df590f18a815ee8c5bfb", default-features = false, features = ["svg"] } -blitz-net = { git = "https://github.com/kgoedecke/blitz", rev = "98827022abbcf9623487df590f18a815ee8c5bfb", default-features = false, features = ["cache"] } -blitz-traits = { git = "https://github.com/kgoedecke/blitz", rev = "98827022abbcf9623487df590f18a815ee8c5bfb", default-features = false } +blitz-html = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false } +blitz-paint = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false, features = ["svg"] } +blitz-traits = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false } # Same parley revision as the pinned Blitz commit, for one shared font context. parley = { git = "https://github.com/linebender/parley", rev = "718dcb721941fd8e72128833122d31f5a4e80504", default-features = false, features = ["std", "system"] } anyrender = "0.14" @@ -32,27 +32,39 @@ tokio = { version = "1", features = ["rt-multi-thread"] } # unification; a standalone crate has to turn them on or PNGs paint blank. image = { version = "0.25", default-features = false, features = ["png", "jpeg", "gif", "webp", "bmp", "ico"] } serde_json = "1" +# Resolves a frame's own ``; the version Blitz already uses. +url = "2" + +# Android has no desktop home directory. Blitz's optional disk-cache constructor +# panics there; documents still retain downloaded resources in memory. Keep the +# existing disk cache on Apple targets, without changing their feature set. +[target.'cfg(not(target_os = "android"))'.dependencies] +blitz-net = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false, features = ["cache"] } + +[target.'cfg(target_os = "android")'.dependencies] +blitz-net = { git = "https://github.com/kgoedecke/blitz", rev = "3cbca256ee8863a030e9e37a8be1001975e2bdfe", default-features = false } # Local fixes; see the header of each vendored Cargo.toml. # Stylo (the `stylo` crates below) from the `doop` branch of kgoedecke/stylo: 0.22.0 with -# `background-clip: text` and `-webkit-text-fill-color` parsed in Servo builds. +# `background-clip: text` and `-webkit-text-fill-color` parsed in Servo builds, and the +# `prefers-reduced-motion` media feature. # anyrender from the `doop` branch of kgoedecke/anyrender: the published 0.14 / anyrender_skia # 0.12 commit plus the variable-font fix (DioxusLabs/anyrender#128). Both crates come from the # fork so that blitz-paint and the Skia backend share one `anyrender`. [patch.crates-io] anyrender = { git = "https://github.com/kgoedecke/anyrender", rev = "229216b1c86c13b8ba00eaf8d274d42f4ce91d80" } anyrender_skia = { git = "https://github.com/kgoedecke/anyrender", rev = "229216b1c86c13b8ba00eaf8d274d42f4ce91d80" } -stylo = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_traits = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_atoms = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_dom = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_static_prefs = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_derive = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -stylo_malloc_size_of = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -selectors = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -servo_arc = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -to_shmem = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } -to_shmem_derive = { git = "https://github.com/kgoedecke/stylo", rev = "f31ec9fb0fa83b3b79cfce08016f3cb8cc777c70" } +stylo = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_traits = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_atoms = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_dom = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_static_prefs = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_derive = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +stylo_malloc_size_of = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +selectors = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +servo_arc = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +to_shmem = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } +to_shmem_derive = { git = "https://github.com/kgoedecke/stylo", rev = "f247bcfd8e380832e02c9c2b69d83bd5ee59bb43" } [features] default = ["skia"] diff --git a/ios/BlitzKit/rust/src/lib.rs b/ios/BlitzKit/rust/src/lib.rs index 0a8f85c89..6a5095ac4 100644 --- a/ios/BlitzKit/rust/src/lib.rs +++ b/ios/BlitzKit/rust/src/lib.rs @@ -18,7 +18,7 @@ use blitz_traits::NodeId; use blitz_html::HtmlDocument; use blitz_net::Provider; use blitz_paint::{paint_scene, paint_scene_region}; -use blitz_traits::net::NetWaker; +use blitz_traits::net::{NetHandler, NetProvider, NetWaker, Request}; use blitz_traits::shell::{ColorScheme, Viewport}; use peniko::Fill; use peniko::kurbo::{Affine, Rect}; @@ -54,8 +54,12 @@ fn base_font_context() -> FontContext { /// System families that carry the symbols pages use as text (★ ✓ → ● ⌘ ✦), first match wins. /// System Font and Apple Symbols come first, as WebKit's cascade picks them; a family the /// device lacks is skipped. +#[cfg(not(target_os = "android"))] const SYMBOL_FAMILIES: &[&str] = &["System Font", "Apple Symbols", "Hiragino Sans", "Menlo", "Zapf Dingbats", "STIX Two Math"]; +#[cfg(target_os = "android")] +const SYMBOL_FAMILIES: &[&str] = + &["Noto Sans Symbols", "Noto Sans Symbols 2", "Noto Sans Math", "Noto Color Emoji"]; /// Fontique finds a fallback per script from one sample letter, and symbols belong to no /// script of their own: a ★ in a Latin run only gets the Latin fallback (Helvetica), and a @@ -96,26 +100,100 @@ impl NetWaker for Waker { pub struct Doc { document: HtmlDocument, net: Arc, + /// The URL the frame is served from (the Doop server's origin). The document's own + /// `` is resolved against it on every parse, so it is kept rather than the result. base_url: String, width: u32, height: u32, scale: f32, } +type Fetch = (usize, Request, Box); + +/// The document's network provider. It holds the fetches a parse starts (images, linked +/// stylesheets) until the document's base URL is known, since Blitz starts them while it +/// parses, before a `` can be read; once released it passes every fetch (fonts and +/// images found later by stylesheets) straight to `net`. +struct HeldFetches { + net: Arc, + held: Mutex>>, +} + +impl NetProvider for HeldFetches { + fn fetch(&self, doc_id: usize, request: Request, handler: Box) { + let mut held = self.held.lock().unwrap(); + match held.as_mut() { + Some(fetches) => fetches.push((doc_id, request, handler)), + None => { + drop(held); + self.net.fetch(doc_id, request, handler); + } + } + } +} + +impl HeldFetches { + fn new(net: &Arc) -> Self { + Self { net: Arc::clone(net), held: Mutex::new(Some(Vec::new())) } + } + + fn release(&self) { + let fetches = self.held.lock().unwrap().take().unwrap_or_default(); + for (doc_id, request, handler) in fetches { + self.net.fetch(doc_id, request, handler); + } + } +} + +/// The base URL a browser gives a document served from `fallback`: the first `` with an +/// `href`, resolved against `fallback`, else `fallback` itself. Only http(s) results count: a +/// `javascript:`, `data:` or `file:` base (or one that does not parse) leaves `fallback`, so a +/// frame cannot point its relative URLs at the device's files. +fn document_base_url(document: &BaseDocument, fallback: &url::Url) -> url::Url { + let href = document + .query_selector("base[href]") + .ok() + .flatten() + .and_then(|id| document.get_node(id)) + .and_then(|node| node.attr(local_name!("href"))); + href.and_then(|href| fallback.join(href).ok()) + .filter(|url| matches!(url.scheme(), "http" | "https")) + .unwrap_or_else(|| fallback.clone()) +} + +fn parse(html: &str, base_url: &str, net: Arc, width: u32, height: u32, scale: f32) -> HtmlDocument { + HtmlDocument::from_html( + html, + DocumentConfig { + base_url: Some(base_url.to_string()), + net_provider: Some(net), + viewport: Some(viewport(width, height, scale)), + font_ctx: Some(base_font_context()), + ..Default::default() + }, + ) +} + impl Doc { fn new(html: &str, base_url: &str, width: u32, height: u32, scale: f32) -> Self { let _guard = runtime().enter(); let net = Arc::new(Provider::new(Some(Arc::new(Waker) as Arc))); - let mut document = HtmlDocument::from_html( - html, - DocumentConfig { - base_url: Some(base_url.to_string()), - net_provider: Some(Arc::clone(&net) as _), - viewport: Some(viewport(width, height, scale)), - font_ctx: Some(base_font_context()), - ..Default::default() - }, - ); + // Parse against the server origin with the fetches held. An imported page carries + // `` for its `/img/x.png` paths; when its base differs, parse + // again against it and drop the held fetches (they point at the Doop server), as a + // browser resolves every URL against the document's base. + let held = Arc::new(HeldFetches::new(&net)); + let mut document = parse(html, base_url, Arc::clone(&held) as _, width, height, scale); + let own_base = url::Url::parse(base_url).ok().and_then(|fallback| { + Some(document_base_url(document.as_ref(), &fallback)).filter(|resolved| *resolved != fallback) + }); + match own_base { + Some(resolved) => { + drop(document); + document = parse(html, resolved.as_str(), Arc::clone(&net) as _, width, height, scale); + } + None => held.release(), + } // Icon sprites: inline SVG is drawn from standalone markup, so `` references are // expanded into clones that inherit from the `` site, as a browser's shadow tree does. document.as_mut().expand_svg_use_elements(); @@ -132,12 +210,18 @@ impl Doc { } fn viewport(width: u32, height: u32, scale: f32) -> Viewport { - Viewport::new( + let mut viewport = Viewport::new( (width as f32 * scale).round().max(1.0) as u32, (height as f32 * scale).round().max(1.0) as u32, scale, ColorScheme::Light, - ) + ); + // Frames are mostly painted as still pictures at time 0 (playback runs only for large + // frames on screen), and pages hide content until an entry animation has run: `opacity: 0` + // plus a `forwards` fade-in, sometimes frozen at `animation-duration: 0s`, which Stylo never + // starts. Matching `prefers-reduced-motion: reduce` takes the fallback such pages ship. + viewport.reduced_motion = true; + viewport } unsafe fn cstr<'a>(ptr: *const c_char) -> &'a str { @@ -192,7 +276,8 @@ pub extern "C" fn doopblitz_doc_id(doc: *const Doc) -> usize { } /// Replace the document with a fresh parse of `html` (streamed agent chunks, -/// collaborator edits). Keeps size, scale and base URL. +/// collaborator edits). Keeps size, scale and the server URL; the new HTML's own +/// ``, if any, is resolved against it again. #[unsafe(no_mangle)] pub extern "C" fn doopblitz_doc_set_html(doc: *mut Doc, html: *const c_char) { let doc = unsafe { &mut *doc }; @@ -690,3 +775,65 @@ fn selector_path(base: &BaseDocument, id: NodeId) -> String { parts.reverse(); parts.join(" > ") } + +#[cfg(test)] +mod tests { + use super::*; + + const SERVER: &str = "https://doop.design/"; + + fn base_of(head: &str) -> String { + let html = format!("{head}

x

"); + Doc::new(&html, SERVER, 100, 100, 1.0).base().base_url().to_string() + } + + #[test] + fn an_absolute_base_href_wins_over_the_server() { + assert_eq!(base_of(""), "https://www.useterse.ai/"); + assert_eq!(base_of(""), "http://example.com/a/b"); + } + + #[test] + fn a_relative_base_href_resolves_against_the_server() { + assert_eq!(base_of(""), "https://doop.design/site/"); + assert_eq!(base_of(""), "https://cdn.example.com/x/"); + assert_eq!(base_of(""), "https://www.useterse.ai/"); + } + + #[test] + fn without_a_base_href_the_server_stays() { + assert_eq!(base_of(""), SERVER); + assert_eq!(base_of(""), SERVER); + } + + #[test] + fn a_base_that_is_not_http_keeps_the_server() { + for href in ["javascript:alert(1)", "data:text/html,x", "file:///etc/", "about:blank", "http://[::1"] { + assert_eq!(base_of(&format!("")), SERVER, "{href}"); + } + } + + #[test] + fn the_first_base_with_an_href_wins() { + let head = ""; + assert_eq!(base_of(head), "https://first.example/"); + // A first href that is refused is not passed over for a later one, as in browsers. + assert_eq!(base_of(""), SERVER); + } + + #[test] + fn replacing_the_html_reads_its_base_again() { + let mut doc = Doc::new("

plain

", SERVER, 100, 100, 1.0); + let set = |doc: &mut Doc, html: &str| { + let html = CString::new(html).unwrap(); + doopblitz_doc_set_html(doc, html.as_ptr()); + doc.base().base_url().to_string() + }; + assert_eq!(doc.base().base_url().as_str(), SERVER); + assert_eq!(set(&mut doc, "

x

"), "https://a.example/"); + assert_eq!(set(&mut doc, "

x

"), "https://b.example/"); + // The server URL is kept, not the last base: a base that goes away no longer applies. + assert_eq!(set(&mut doc, "

x

"), SERVER); + assert_eq!(set(&mut doc, "

x

"), "https://doop.design/relative/"); + } +} diff --git a/ios/BlitzKit/rust/tests/imported_pages.rs b/ios/BlitzKit/rust/tests/imported_pages.rs new file mode 100644 index 000000000..686a0478a --- /dev/null +++ b/ios/BlitzKit/rust/tests/imported_pages.rs @@ -0,0 +1,144 @@ +//! Pages imported from a website: their images resolve against the page's own ``, and +//! content that fades in with an entry animation shows through the page's reduced-motion fallback. +use doopblitz::*; +use std::ffi::CString; +use std::io::{BufRead, BufReader, Cursor, Write}; +use std::net::TcpListener; +use std::time::{Duration, Instant}; + +const RED: [u8; 3] = [255, 0, 0]; +const BLUE: [u8; 3] = [0, 0, 255]; + +fn png(rgb: [u8; 3]) -> Vec { + let image = image::RgbaImage::from_pixel(8, 8, image::Rgba([rgb[0], rgb[1], rgb[2], 255])); + let mut bytes = Cursor::new(Vec::new()); + image.write_to(&mut bytes, image::ImageFormat::Png).unwrap(); + bytes.into_inner() +} + +/// A local stand-in for both servers: `/site/` is the imported website, where the image is +/// red; `/doop/` is the Doop server, which (like the real one) answers a path it does not +/// know with its own HTML page, and here has a blue image so a wrong resolution shows. +fn serve() -> u16 { + let listener = TcpListener::bind("127.0.0.1:0").unwrap(); + let port = listener.local_addr().unwrap().port(); + let (red, blue) = (png(RED), png(BLUE)); + std::thread::spawn(move || { + for stream in listener.incoming() { + let Ok(mut stream) = stream else { continue }; + let mut request_line = String::new(); + let mut reader = BufReader::new(stream.try_clone().unwrap()); + if reader.read_line(&mut request_line).is_err() { + continue; + } + loop { + let mut header = String::new(); + if reader.read_line(&mut header).map_or(true, |n| n == 0) || header == "\r\n" { + break; + } + } + let path = request_line.split_whitespace().nth(1).unwrap_or("/"); + let (kind, body) = match path { + "/site/actors/swatch.png" => ("image/png", red.clone()), + "/doop/actors/swatch.png" => ("image/png", blue.clone()), + _ => ("text/html", b"Doop".to_vec()), + }; + let head = format!( + "HTTP/1.1 200 OK\r\nContent-Type: {kind}\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", + body.len() + ); + let _ = stream.write_all(head.as_bytes()).and_then(|_| stream.write_all(&body)); + } + }); + port +} + +/// Paint `html` served from `base_url` until nothing is loading; the RGB at CSS point (x, y). +fn pixel_after_loading(html: &str, base_url: &str, x: usize, y: usize) -> [u8; 3] { + let html = CString::new(html).unwrap(); + let base = CString::new(base_url).unwrap(); + let doc = doopblitz_doc_new(html.as_ptr(), base.as_ptr(), 100, 100, 1.0); + let deadline = Instant::now() + Duration::from_secs(10); + let (mut w, mut h, mut len) = (0, 0, 0); + loop { + doopblitz_buffer_free(doopblitz_doc_render(doc, &mut w, &mut h, &mut len), len); + if !doopblitz_doc_loading(doc) || Instant::now() > deadline { + break; + } + std::thread::sleep(Duration::from_millis(10)); + } + // A fetch can land between the paint and the check; paint once more to take it in. + let buf = doopblitz_doc_render(doc, &mut w, &mut h, &mut len); + let pixels = unsafe { std::slice::from_raw_parts(buf, len) }.to_vec(); + doopblitz_buffer_free(buf, len); + doopblitz_doc_free(doc); + let i = (y * w as usize + x) * 4; + [pixels[i], pixels[i + 1], pixels[i + 2]] +} + +fn swatch_page(head: &str) -> String { + format!( + "{head}\ + " + ) +} + +#[test] +fn images_resolve_against_the_pages_own_base() { + let port = serve(); + let doop = format!("http://127.0.0.1:{port}/doop/"); + let site = format!("http://127.0.0.1:{port}/site/"); + assert_eq!(pixel_after_loading(&swatch_page(&format!("")), &doop, 50, 50), RED); + // A relative href resolves against the server URL first. + assert_eq!(pixel_after_loading(&swatch_page(""), &doop, 50, 50), RED); + // No base, or one that is not http(s): the server URL stays the base. + assert_eq!(pixel_after_loading(&swatch_page(""), &doop, 50, 50), BLUE); + assert_eq!(pixel_after_loading(&swatch_page(""), &doop, 50, 50), BLUE); + // Resources requested after the parse (a CSS background, fetched once styles resolve) go + // to the same base, with or without a ``. + let background = |head: &str| { + format!( + "{head}
" + ) + }; + assert_eq!(pixel_after_loading(&background(&format!("")), &doop, 50, 50), RED); + assert_eq!(pixel_after_loading(&background(""), &doop, 50, 50), BLUE); +} + +/// One black 100×100 box with `css` applied to `.a`, painted at time 0. +fn box_at_time_zero(css: &str) -> u8 { + let html = format!( + "\ +
" + ); + let html = CString::new(html).unwrap(); + let base = CString::new("https://doop.design/").unwrap(); + let doc = doopblitz_doc_new(html.as_ptr(), base.as_ptr(), 100, 100, 1.0); + let (mut w, mut h, mut len) = (0, 0, 0); + let buf = doopblitz_doc_render_at(doc, 0.0, &mut w, &mut h, &mut len); + let value = unsafe { std::slice::from_raw_parts(buf, len) }[(50 * w as usize + 50) * 4]; + doopblitz_buffer_free(buf, len); + doopblitz_doc_free(doc); + value +} + +#[test] +fn frames_match_prefers_reduced_motion_reduce() { + assert_eq!(box_at_time_zero("@media (prefers-reduced-motion: reduce) { .a { opacity: 0 } }"), 255); + assert_eq!(box_at_time_zero("@media (prefers-reduced-motion) { .a { opacity: 0 } }"), 255); + assert_eq!(box_at_time_zero("@media (prefers-reduced-motion: no-preference) { .a { opacity: 0 } }"), 0); + assert_eq!(box_at_time_zero("@media not (prefers-reduced-motion: reduce) { .a { opacity: 0 } }"), 0); +} + +#[test] +fn an_entry_animation_with_a_reduced_motion_fallback_shows_its_content() { + // As on the imported Terse landing page: content waits at `opacity: 0` for a `forwards` + // fade-in, which the capture froze at `animation-duration: 0s` (Stylo never starts a + // zero-length animation, so its end state never applied), and the page's reduced-motion + // block turns animations off and shows the content. + let page = ".a { opacity: 0; animation: 0.7s cubic-bezier(0.2, 0.7, 0.2, 1) 0s 1 normal forwards running rise }\ + * { animation-duration: 0s !important; animation-delay: 0s !important }\ + @media (prefers-reduced-motion: reduce) { * { animation: none !important } .a { opacity: 1 } }"; + assert_eq!(box_at_time_zero(page), 0); +} diff --git a/ios/Doop.xcodeproj/project.pbxproj b/ios/Doop.xcodeproj/project.pbxproj index 761848d28..8925b5c96 100644 --- a/ios/Doop.xcodeproj/project.pbxproj +++ b/ios/Doop.xcodeproj/project.pbxproj @@ -413,7 +413,7 @@ Metal, ); SWIFT_OBJC_BRIDGING_HEADER = BlitzKit/include/doopblitz.h; - MARKETING_VERSION = 0.1.2; + MARKETING_VERSION = 0.1.3; PRODUCT_BUNDLE_IDENTIFIER = design.doop.ios; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -469,7 +469,7 @@ Metal, ); SWIFT_OBJC_BRIDGING_HEADER = BlitzKit/include/doopblitz.h; - MARKETING_VERSION = 0.1.2; + MARKETING_VERSION = 0.1.3; PRODUCT_BUNDLE_IDENTIFIER = design.doop.ios; PRODUCT_NAME = "$(TARGET_NAME)"; SUPPORTED_PLATFORMS = "iphoneos iphonesimulator"; @@ -491,7 +491,7 @@ INFOPLIST_FILE = DoopActivity/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Doop Agent Status"; IPHONEOS_DEPLOYMENT_TARGET = 16.2; - MARKETING_VERSION = 0.1.2; + MARKETING_VERSION = 0.1.3; PRODUCT_BUNDLE_IDENTIFIER = design.doop.ios.activity; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -513,7 +513,7 @@ INFOPLIST_FILE = DoopActivity/Info.plist; INFOPLIST_KEY_CFBundleDisplayName = "Doop Agent Status"; IPHONEOS_DEPLOYMENT_TARGET = 16.2; - MARKETING_VERSION = 0.1.2; + MARKETING_VERSION = 0.1.3; PRODUCT_BUNDLE_IDENTIFIER = design.doop.ios.activity; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; diff --git a/ios/Doop/CanvasModel.swift b/ios/Doop/CanvasModel.swift index 04011ccf9..2e11b4255 100644 --- a/ios/Doop/CanvasModel.swift +++ b/ios/Doop/CanvasModel.swift @@ -347,8 +347,8 @@ final class CanvasModel: ObservableObject { return PromptScope(scope: CardScope(frameId: frame.id), label: frame.name, frameName: frame.name) } - func queue(_ prompt: String, scope: CardScope? = nil, assignment: AgentAssignment = .automatic) async throws { - let request = CardQueueRequest(title: prompt, scope: scope, assignment: assignment) + func queue(_ prompt: String, scope: CardScope? = nil, assignment: AgentAssignment = .automatic, runner: RunnerPick? = nil) async throws { + let request = CardQueueRequest(title: prompt, scope: scope, assignment: assignment, runner: runner) _ = try await client.data("/api/canvases/\(id)/cards", method: "POST", body: request.body) } diff --git a/ios/Doop/ContentView.swift b/ios/Doop/ContentView.swift index e0279d561..f6b6c2229 100644 --- a/ios/Doop/ContentView.swift +++ b/ios/Doop/ContentView.swift @@ -191,8 +191,6 @@ private struct LibraryView: View { @State private var deleting: CanvasSummary? @State private var renaming: CanvasSummary? @State private var busy = false - /// A Live Activity tapped before the library loaded; opened after the first reload. - @State private var pendingLink: (canvasID: String, serverOrigin: String)? #if DEBUG /// `.task` restarts every time the library reappears, so `-openCanvas` must fire only once. @State private var openedLaunchCanvas = false @@ -219,14 +217,12 @@ private struct LibraryView: View { .font(.custom("HankenGrotesk-Regular_Light", size: 34, relativeTo: .largeTitle)) Text("Pick up an idea. Or start something new.").foregroundStyle(.secondary) }.padding(.top, 12) - // The count sits beside the scope it counts, not at the far edge. HStack(spacing: 4) { Picker("Workspace", selection: $workspace) { Text("All canvases").tag("all") Text("Personal").tag("personal") ForEach(app.workspaces) { Text($0.name).tag($0.id) } }.pickerStyle(.menu) - Text("\(filtered.count) \(filtered.count == 1 ? "canvas" : "canvases")").font(.caption).foregroundStyle(.secondary) Spacer(minLength: 0) } if let error = app.error { Text(error).foregroundStyle(.red).font(.callout) } @@ -274,7 +270,6 @@ private struct LibraryView: View { .refreshable { await app.reload() } .task { await app.reload() - if let link = pendingLink { pendingLink = nil; open(link) } #if DEBUG // -openCanvas jumps straight to a canvas (simulator automation). if !openedLaunchCanvas, path.isEmpty, let id = UserDefaults.standard.string(forKey: "openCanvas"), let canvas = app.canvases.first(where: { $0.id == id }) { @@ -284,10 +279,16 @@ private struct LibraryView: View { #endif } - .navigationDestination(for: CanvasSummary.self) { canvas in NativeCanvasView(summary: canvas, client: app.client, currentUser: app.user) } + // `.id` gives each canvas its own view: replacing the open canvas (a Live Activity tap) + // would otherwise reuse the destination and keep the old canvas's `@StateObject` model. + .navigationDestination(for: CanvasSummary.self) { canvas in + NativeCanvasView(summary: canvas, client: app.client, currentUser: app.user).id(canvas.id) + } .onOpenURL { url in + // `open` reloads the list when the canvas is not in it yet, so a link that + // arrives before the first load, or into an empty library, still opens. guard let link = CanvasLink.parse(url) else { return } - if app.canvases.isEmpty { pendingLink = link } else { open(link) } + open(link) } .alert("New canvas", isPresented: $creating) { TextField("Canvas name", text: $title) @@ -338,10 +339,14 @@ private struct LibraryView: View { /// Opens the canvas a Live Activity links to, if it lives on this app's server. private func open(_ link: (canvasID: String, serverOrigin: String)) { - guard link.serverOrigin == app.client.server.origin.absoluteString, - let canvas = app.canvases.first(where: { $0.id == link.canvasID }) else { return } - showingAgents = false - path = [canvas] + guard link.serverOrigin == app.client.server.origin.absoluteString else { return } + Task { + // A canvas made since the last reload (an agent's new canvas) is not listed yet. + if !app.canvases.contains(where: { $0.id == link.canvasID }) { await app.reload() } + guard let canvas = app.canvases.first(where: { $0.id == link.canvasID }) else { return } + showingAgents = false + path = [canvas] + } } private func create() { @@ -387,8 +392,11 @@ private struct CanvasCard: View { if let frameID = canvas.previewFrameId { GeometryReader { geometry in AsyncImage(url: origin.appendingPathComponent("i/\(frameID).jpg").appending(queryItems: [URLQueryItem(name: "preview", value: "")])) { image in + // `clipped()` hides the overflow but does not shrink the hit area: a tall + // page filled to the card's width reached over the cards above it. image.resizable().scaledToFill() .frame(width: geometry.size.width, height: geometry.size.height).clipped() + .allowsHitTesting(false) } placeholder: { placeholder.frame(width: geometry.size.width, height: geometry.size.height) } @@ -408,6 +416,8 @@ private struct CanvasCard: View { .background(Color(uiColor: .secondarySystemGroupedBackground), in: RoundedRectangle(cornerRadius: 20)) .clipShape(RoundedRectangle(cornerRadius: 20)) .overlay(RoundedRectangle(cornerRadius: 20).strokeBorder(.primary.opacity(0.06))) + // Taps and the long-press preview are the card as drawn, never anything spilling past it. + .contentShape([.interaction, .contextMenuPreview], RoundedRectangle(cornerRadius: 20)) } private var placeholder: some View { Image(systemName: "square.stack.3d.up").font(.system(size: 42, weight: .ultraLight)).foregroundStyle(.tertiary) } } diff --git a/ios/Doop/Core/Models.swift b/ios/Doop/Core/Models.swift index 2c3f7f5f7..2e40b0ed4 100644 --- a/ios/Doop/Core/Models.swift +++ b/ios/Doop/Core/Models.swift @@ -80,20 +80,57 @@ public struct AgentModelOption: Decodable, Identifiable { public let blurb: String? } -/// Uses the same server-owned menu and account preference as desktop. -public struct AgentModelAccount: Decodable { - public let connected: Bool - public let kind: String? - public let model: String? - public let menus: [String: [AgentModelOption]]? - - public var options: [AgentModelOption] { - guard connected, let kind else { return [] } - return menus?[kind] ?? [] +/// One connection a task may run on, as `GET /api/agent-runners` lists it +/// (`AgentRunner` in shared/agentRunner.ts): every provider that is connected and on. +public struct AgentRunner: Decodable, Identifiable { + public let provider: String + /// "ChatGPT", "Claude Plan", "OpenAI"… + public let name: String + /// What the connection runs on when a pick names no model. + public let model: String + public let effort: String? + public let models: [AgentModelOption] + public let efforts: [AgentModelOption]? + public var id: String { provider } + + public func modelName(_ id: String) -> String { models.first { $0.id == id }?.name ?? id } +} + +public struct AgentRunners: Decodable { + public let runners: [AgentRunner] + /// What work without a pick runs on: the Settings default. + public let `default`: String? + + /// The stored pick resolved against what is connected now, as the web + /// composer's `resolveRunnerPick` does: a pick naming a connection that is + /// gone falls back to the default, then to the first connection. + public func resolve(_ stored: RunnerPick?) -> (runner: AgentRunner, pick: RunnerPick)? { + guard let runner = runners.first(where: { $0.provider == stored?.provider }) + ?? runners.first(where: { $0.provider == self.default }) ?? runners.first else { return nil } + let same = stored?.provider == runner.provider + let model = same ? stored?.model ?? runner.model : runner.model + let effort = same && runner.efforts?.contains(where: { $0.id == stored?.effort }) == true ? stored?.effort : runner.effort + return (runner, RunnerPick(provider: runner.provider, model: model, effort: effort)) } - public var label: String { - guard connected else { return "Auto" } - return options.first { $0.id == model }?.name ?? model ?? "Auto" +} + +/// What a card asks to run on: the `runner` field of `POST /api/canvases/:id/cards`. +public struct RunnerPick: Codable, Equatable { + public var provider: String + public var model: String? + public var effort: String? + + public init(provider: String, model: String? = nil, effort: String? = nil) { + self.provider = provider + self.model = model + self.effort = effort + } + + public var body: [String: Any] { + var body: [String: Any] = ["provider": provider] + if let model { body["model"] = model } + if let effort { body["effort"] = effort } + return body } } @@ -235,17 +272,20 @@ public struct CardQueueRequest { public var title: String public var scope: CardScope? public var assignment: AgentAssignment + public var runner: RunnerPick? - public init(title: String, scope: CardScope?, assignment: AgentAssignment = .automatic) { + public init(title: String, scope: CardScope?, assignment: AgentAssignment = .automatic, runner: RunnerPick? = nil) { self.title = title self.scope = scope self.assignment = assignment + self.runner = runner } public var body: [String: Any] { var body: [String: Any] = ["title": title] if let scope { body["scope"] = scope.body } if let agentIDs = assignment.agentIDs { body["agents"] = agentIDs } + if let runner { body["runner"] = runner.body } return body } } diff --git a/ios/Doop/NativeCanvasView.swift b/ios/Doop/NativeCanvasView.swift index 880fd2bdf..996a0e813 100644 --- a/ios/Doop/NativeCanvasView.swift +++ b/ios/Doop/NativeCanvasView.swift @@ -8,10 +8,12 @@ struct NativeCanvasView: View { @State private var sheet: Panel? @State private var prompt = "" @State private var agentAssignment = AgentAssignment.automatic - @State private var modelAccount: AgentModelAccount? + /// The connections a task may run on (`GET /api/agent-runners`). + @State private var runners: AgentRunners? + /// This phone's pick, sent with every task as the card's `runner`, as the web composer does. + @State private var storedPick: RunnerPick? = Self.loadPick() @State private var modelPickerOpen = false @State private var loadingModels = false - @State private var changingModel = false @State private var modelError: String? @State private var contextReferences: [PromptContextReference] = [] @State private var contextPickerOpen = false @@ -215,7 +217,7 @@ struct NativeCanvasView: View { } private var canSend: Bool { - !sending && !changingModel && model.connected && !prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty + !sending && model.connected && !prompt.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } private var hasComposerContext: Bool { @@ -275,18 +277,18 @@ struct NativeCanvasView: View { if modelPickerOpen { Task { await loadModels() } } } label: { HStack(spacing: 6) { - ComposerBrandMark(name: modelAccount?.kind == "anthropic-key" ? "claude" : "chatgpt", color: ComposerColors.muted) + ComposerBrandMark(name: runnerBrand, color: ComposerColors.muted) .frame(width: 14, height: 14) - Text(modelAccount?.label ?? "Auto") + Text(runnerLabel) .font(.subheadline) .lineLimit(1).minimumScaleFactor(0.8) } .foregroundStyle(ComposerColors.muted).padding(.horizontal, 8).frame(minHeight: 44) .contentShape(Rectangle()) } - .buttonStyle(.plain).disabled(sending || changingModel) + .buttonStyle(.plain).disabled(sending) .accessibilityLabel("Choose model") - .accessibilityValue(modelAccount?.label ?? "Auto") + .accessibilityValue(runnerLabel) .accessibilityIdentifier("canvas.modelPicker") Button(action: sendPrompt) { Group { @@ -441,44 +443,47 @@ struct NativeCanvasView: View { }.padding(.leading, 12) ScrollView { VStack(alignment: .leading, spacing: 4) { - if loadingModels || changingModel { - ProgressView(changingModel ? "Saving model…" : "Loading models…") - .padding(12).frame(maxWidth: .infinity) + if loadingModels && runners == nil { + ProgressView("Loading models…").padding(12).frame(maxWidth: .infinity) } if let modelError { Text(modelError).font(.callout).foregroundStyle(.secondary).padding(.horizontal, 12) Button("Retry") { Task { await loadModels() } }.padding(12) } - if let account = modelAccount, !loadingModels { - if account.options.isEmpty { - Text(account.connected ? "No models are available for this account." : - "Auto uses the server’s model. Connect a model account to choose your own.") - .font(.callout).foregroundStyle(.secondary).padding(12) + if let runners, runners.runners.isEmpty { + Text("Auto uses the server’s model. Connect a model account to choose your own.") + .font(.callout).foregroundStyle(.secondary).padding(12) + } + ForEach(runners?.runners ?? []) { runner in + if (runners?.runners.count ?? 0) > 1 { + Text(runner.name).font(.caption).foregroundStyle(.secondary) + .padding(.horizontal, 12).padding(.top, 8) } - ForEach(account.options) { option in - Button { Task { await chooseModel(option.id) } } label: { + ForEach(runner.models) { option in + let chosen = resolved?.pick.provider == runner.provider && resolved?.pick.model == option.id + Button { choose(option.id, on: runner) } label: { HStack(spacing: 12) { VStack(alignment: .leading, spacing: 3) { Text(option.name).font(.body) - if let blurb = option.blurb { + if let blurb = option.blurb, !blurb.isEmpty { Text(blurb).font(.caption).foregroundStyle(.secondary) .multilineTextAlignment(.leading) } } Spacer(minLength: 0) - if option.id == account.model { Image(systemName: "checkmark").font(.callout).foregroundStyle(ComposerColors.action) } + if chosen { Image(systemName: "checkmark").font(.callout).foregroundStyle(ComposerColors.action) } } .padding(12).frame(minHeight: 48).contentShape(Rectangle()) } - .buttonStyle(.plain).disabled(changingModel) - .accessibilityLabel("Use " + option.name) - .accessibilityAddTraits(option.id == account.model ? [.isSelected] : []) + .buttonStyle(.plain) + .accessibilityLabel("Use " + option.name + " on " + runner.name) + .accessibilityAddTraits(chosen ? [.isSelected] : []) } } } - }.frame(height: modelAccount?.options.isEmpty == false ? 240 : 100) + }.frame(height: runners?.runners.isEmpty == false ? 240 : 100) Divider().padding(.horizontal, 12) - Link(modelAccount?.connected == true ? "Model settings…" : "Connect a model…", + Link(runners?.runners.isEmpty == false ? "Model settings…" : "Connect a model…", destination: modelSettingsURL) .font(.callout).padding(12).frame(minHeight: 44) } @@ -493,26 +498,37 @@ struct NativeCanvasView: View { } private func loadModels() async { - guard !loadingModels, !changingModel else { return } + guard !loadingModels else { return } loadingModels = true defer { loadingModels = false } do { - modelAccount = try await model.client.get("/api/model-account") + runners = try await model.client.get("/api/agent-runners") modelError = nil } catch { modelError = error.localizedDescription } } - private func chooseModel(_ id: String) async { - guard !changingModel, modelAccount?.options.contains(where: { $0.id == id }) == true else { return } - if id == modelAccount?.model { modelPickerOpen = false; return } - changingModel = true - defer { changingModel = false } - do { - let data = try await model.client.data("/api/model-account", method: "PATCH", body: ["model": id]) - modelAccount = try JSONDecoder().decode(AgentModelAccount.self, from: data) - modelError = nil - modelPickerOpen = false - } catch { modelError = error.localizedDescription } + /// The pick this phone sends, against what is connected now; nil runs on the server's default. + private var resolved: (runner: AgentRunner, pick: RunnerPick)? { runners?.resolve(storedPick) } + private var runnerLabel: String { + guard let resolved else { return "Auto" } + return resolved.runner.modelName(resolved.pick.model ?? resolved.runner.model) + } + private var runnerBrand: String { + guard let resolved else { return "doop" } + return resolved.runner.provider.contains("anthropic") || resolved.runner.provider.contains("claude") + ? "claude" : resolved.runner.name + " " + (resolved.pick.model ?? "") + } + + private func choose(_ modelID: String, on runner: AgentRunner) { + let effort = resolved?.pick.provider == runner.provider ? resolved?.pick.effort : runner.effort + storedPick = RunnerPick(provider: runner.provider, model: modelID, effort: effort) + if let data = try? JSONEncoder().encode(storedPick) { UserDefaults.standard.set(data, forKey: Self.pickKey) } + modelPickerOpen = false + } + + private static let pickKey = "agentRunnerPick" + private static func loadPick() -> RunnerPick? { + UserDefaults.standard.data(forKey: pickKey).flatMap { try? JSONDecoder().decode(RunnerPick.self, from: $0) } } private var mentionQuery: String? { PromptContextReference.mentionQuery(in: prompt) } @@ -711,8 +727,17 @@ struct NativeCanvasView: View { let assignment = agentAssignment let title = PromptContextReference.taskTitle(value, references: contextReferences) Task { + // A saved pick is only honoured once the runner list is known: without it the task + // would go out with no runner and quietly run on the server's default instead. + if storedPick != nil && runners == nil { await loadModels() } + if storedPick != nil && runners == nil { + model.error = "Couldn’t load your models, so the task wasn’t sent. Try again." + sending = false + return + } + let runner = resolved?.pick do { - try await model.queue(title, scope: scope, assignment: assignment) + try await model.queue(title, scope: scope, assignment: assignment, runner: runner) prompt = "" contextReferences = [] agentAssignment = .automatic diff --git a/ios/README.md b/ios/README.md index 7e0286902..6b167a168 100644 --- a/ios/README.md +++ b/ios/README.md @@ -213,6 +213,17 @@ rectangle. Repeating tiles use an image brush; a weak-keyed, 16 MiB cache per pa thread reuses them across paints without retaining documents. Individual textures are capped at 4 megapixels / 4096 px per side. `rust/tests/svg_background.rs` checks repetition, filtered noise, and full-frame versus region rendering. + +Frames imported from a website keep the site's ``, and their paths +(`/img/logo.svg`) are relative to it. Blitz takes its base URL from the embedder and +starts image and stylesheet fetches while it parses, so `Doc::new` parses with the +fetches held, reads the first `` (resolved against the server origin, http(s) +only), and parses again against it when it differs; otherwise the held fetches go out. +Every document also matches `prefers-reduced-motion: reduce` (`Viewport::reduced_motion` +in the Blitz fork, the media feature in the Stylo fork), so content a page hides until an +entry animation has run shows through the page's own reduced-motion fallback; frames are +mostly painted as still pictures at time 0. A page without such a fallback still paints +its pre-animation state there. `rust/tests/imported_pages.rs` covers both. As with gradients, spaced backgrounds requiring more than 500 explicit tile draws are skipped to keep painting bounded; repeat/round use a single brush fill. diff --git a/ios/Tests/ServerAddressTests.swift b/ios/Tests/ServerAddressTests.swift index f6e58c13b..d5f75d3a5 100644 --- a/ios/Tests/ServerAddressTests.swift +++ b/ios/Tests/ServerAddressTests.swift @@ -15,7 +15,7 @@ struct ServerAddressChecks { checks.testCardAgentAssignmentBody() checks.testPromptContext() try checks.testContextPeople() - try checks.testAgentModelMenu() + try checks.testAgentRunners() try checks.testAgentActivityStates() FrameSnappingChecks.run() try FrameWorkersChecks.run() @@ -102,16 +102,23 @@ struct ServerAddressChecks { checkTrue(JSONSerialization.isValidJSONObject(["title": "Make it bolder", "scope": element])) } - func testAgentModelMenu() throws { - let connected = try JSONDecoder().decode(AgentModelAccount.self, from: Data(#"{"connected":true,"kind":"chatgpt","model":"model-b","menus":{"chatgpt":[{"id":"model-a","name":"Model A"},{"id":"model-b","name":"Model B","blurb":"Everyday model"}],"anthropic-key":[{"id":"other","name":"Other"}]}}"#.utf8)) - checkEqual(connected.options.map(\.id), ["model-a", "model-b"]) - checkEqual(connected.label, "Model B") - let disconnected = try JSONDecoder().decode(AgentModelAccount.self, from: Data(#"{"connected":false}"#.utf8)) - checkEqual(disconnected.options.count, 0) - checkEqual(disconnected.label, "Auto") - let olderServer = try JSONDecoder().decode(AgentModelAccount.self, from: Data(#"{"connected":true,"kind":"chatgpt","model":"custom"}"#.utf8)) - checkEqual(olderServer.options.count, 0) - checkEqual(olderServer.label, "custom") + func testAgentRunners() throws { + let json = #"{"runners":[{"provider":"chatgpt","name":"ChatGPT","model":"model-b","effort":"medium","models":[{"id":"model-a","name":"Model A","blurb":""},{"id":"model-b","name":"Model B","blurb":"Everyday model"}],"efforts":[{"id":"low","name":"Low","blurb":""},{"id":"medium","name":"Medium","blurb":""}]},{"provider":"anthropic-key","name":"Claude","model":"other","models":[{"id":"other","name":"Other","blurb":""}]}],"default":"anthropic-key"}"# + let runners = try JSONDecoder().decode(AgentRunners.self, from: Data(json.utf8)) + checkEqual(runners.runners.map(\.provider), ["chatgpt", "anthropic-key"]) + // No pick: the Settings default, on its configured model. + checkEqual(runners.resolve(nil)?.pick, RunnerPick(provider: "anthropic-key", model: "other")) + // A pick on a connected provider keeps its model and a known effort. + checkEqual(runners.resolve(RunnerPick(provider: "chatgpt", model: "model-a", effort: "low"))?.pick, + RunnerPick(provider: "chatgpt", model: "model-a", effort: "low")) + // An effort the provider does not offer falls back to the connection's own. + checkEqual(runners.resolve(RunnerPick(provider: "chatgpt", model: "model-a", effort: "max"))?.pick.effort, "medium") + // A pick naming a connection that is gone runs on the default. + checkEqual(runners.resolve(RunnerPick(provider: "gemini-key", model: "x"))?.pick.provider, "anthropic-key") + checkNil(try JSONDecoder().decode(AgentRunners.self, from: Data(#"{"runners":[]}"#.utf8)).resolve(nil), "Nothing connected: Auto") + let body = CardQueueRequest(title: "Go", scope: nil, runner: RunnerPick(provider: "chatgpt", model: "model-a")).body + checkEqual((body["runner"] as? [String: Any])?["provider"] as? String, "chatgpt") + checkNil(CardQueueRequest(title: "Go", scope: nil).body["runner"], "No pick sends no runner") } func testPromptContext() { diff --git a/package.json b/package.json index d60e8d9aa..a115f3ffc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "doop", - "version": "0.14.0", + "version": "0.15.0", "private": true, "type": "module", "packageManager": "bun@1.3.10", @@ -53,6 +53,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "cmdk": "^1.1.1", + "css-select": "5.1.0", "drizzle-orm": "^0.45.2", "envalid": "8.2.0", "express": "^4.19.2", diff --git a/public/doop-sync.js b/public/doop-sync.js index 5b1b71c79..181fbcbad 100644 --- a/public/doop-sync.js +++ b/public/doop-sync.js @@ -87,6 +87,29 @@ return page.length > 280 ? page.slice(0, 280) : page } + /* A sheet's url()s are relative to the sheet, not the page: a bundler's + /_next/static/css/a.css points at ../media/font.woff2. Resolve them while + the sheet is still known; once its rules join the snapshot's ' + const styleAt = lastIndexOfAscii(html, ' { + reveal.held = false + }) broadcast(frame.canvasId, { type: 'frame:streaming', frameId: frame.id, active: true, actor }) } function finishReveal(frameId: string) { const r = reveals.get(frameId) if (!r) return - reveals.delete(frameId) + dropKey(reveals, frameId) const frame = store.getFrame(frameId) if (!frame) return broadcast(frame.canvasId, { type: 'frame:streaming', frameId, active: false, actor: r.actor }) @@ -1656,7 +1895,10 @@ function finishReveal(frameId: string) { function finishStream(frameId: string, logDone: boolean) { const s = streams.get(frameId) if (!s) return - streams.delete(frameId) + dropKey(streams, frameId) + dropKey(streamIssues, frameId) + /* background work that waited for this stream (a detach-all) takes its turn now */ + afterCommit(() => propagation.resumeFrame(frameId)) const current = store.getFrame(frameId) if (!current) return /* a stream that ends without its done chunk (the agent went idle, or a @@ -1664,8 +1906,8 @@ function finishStream(frameId: string, logDone: boolean) { a finished one already has them, and this is then a no-op */ let renamed = current.html for (const rename of pendingRenames.get(frameId) ?? []) renamed = applyRename(renamed, rename) - pendingRenames.delete(frameId) - const html = withLibraryFaces(current.canvasId, renamed) + dropKey(pendingRenames, frameId) + const html = withCanvasFaces(current.canvasId, renamed) /* compare the HTML, not the objects: updateFrame edits the frame in place */ const htmlChanged = html !== current.html const frame = htmlChanged ? store.updateFrame(frameId, { html }, s.actor.name)! : current @@ -1685,6 +1927,7 @@ function finishStream(frameId: string, logDone: boolean) { setInterval(() => { const now = Date.now() for (const [frameId, r] of reveals) { + if (r.held) continue const frame = store.getFrame(frameId) if (!frame) { reveals.delete(frameId) @@ -1712,26 +1955,43 @@ setInterval(() => { /** An agent that died mid-stream never sends the last chunk, so its work is settled here: a * component change skipped while it streamed, the stylesheets, a main written in the stream. */ export function expireIdleStreams(now = Date.now()) { - for (const [frameId, s] of streams) { + /* a copy: a settling that is undone puts its stream back into the map */ + for (const [frameId, s] of [...streams]) { if (now - s.lastActivity <= STREAM_IDLE_MS) continue - const before = store.getFrame(frameId) - const prepared = before ? prepareWrite(before.canvasId, frameId, before.html, before.html, s.actor.name) : undefined - if (before && prepared && prepared.html !== before.html) { - const prior = priorState(before) - const frame = store.updateFrame(frameId, { html: prepared.html }, s.actor.name)! - noteHtmlChange(prior, s.actor, true) - /* viewers get it healed, like every chunk, so a script cut off mid-way never runs */ - broadcast(frame.canvasId, { - type: 'frame:updated', - frame: { ...frame, html: healPartialHtml(frame.html) }, - actor: s.actor, - }) + const canvasId = store.getFrame(frameId)?.canvasId + try { + runOperation(`settle stream of frame ${frameId}`, canvasId, () => settleIdleStream(frameId, s)) + } catch (error) { + if (!(error instanceof WorkBudgetError)) throw error + /* it runs on a timer, where nothing would catch a refusal: a frame over the work + budget stays as its stream left it (the settling is undone as one), the stream + still closes, and the frame's next write settles it */ + console.error(`[streams] ${error.message}`) + runOperation(`close stream of frame ${frameId}`, canvasId, () => finishStream(frameId, false)) } - finishStream(frameId, false) - if (before && prepared?.changed.length) propagateComponents(before.canvasId, prepared.changed, s.actor, frameId) } } +/** The settling pass of a stream nobody closed, and its close: one operation, so a refusal + * part of the way leaves the frame, its components and the room as they were. */ +function settleIdleStream(frameId: string, s: StreamState) { + const before = store.getFrame(frameId) + const prepared = before ? prepareWrite(before.canvasId, before.id, before.html, before.html, s.actor.name) : undefined + if (before && prepared && prepared.html !== before.html) { + const prior = priorState(before) + const frame = store.updateFrame(frameId, { html: prepared.html }, s.actor.name)! + noteHtmlChange(prior, s.actor, true) + /* viewers get it healed, like every chunk, so a script cut off mid-way never runs */ + broadcast(frame.canvasId, { + type: 'frame:updated', + frame: { ...frame, html: healPartialHtml(frame.html) }, + actor: s.actor, + }) + } + finishStream(frameId, false) + if (before && prepared?.changed.length) propagateFromFrameWrite(before.canvasId, prepared.changed, s.actor, frameId) +} + /** A deleted frame held a component's main: the component points at another * frame carrying the marker if there is one, else at no main, so the catalog * never hands out a frame that is gone. */ @@ -1752,27 +2012,112 @@ function releaseMains(canvasId: string, frameId: string, actor: Actor) { /* ------------------------------------------------------------------ */ const componentIssues = new Map() +/** What a stream's chunks had to say about the uses they expanded, held for its done chunk. */ +const streamIssues = new Map() /** What the last write to this frame had to say about its components; reading clears it. */ export function takeComponentIssues(frameId: string): ComponentIssue[] { const issues = componentIssues.get(frameId) ?? [] - componentIssues.delete(frameId) + dropKey(componentIssues, frameId) return issues } -function prepareWrite(canvasId: string, frameId: string, html: string, priorHtml: string, by: string) { +/** What the last write to this frame had to say about its components, left for whoever takes them. */ +export function peekComponentIssues(frameId: string): readonly ComponentIssue[] { + return componentIssues.get(frameId) ?? [] +} + +/** Something found out about a frame's last write after it landed: heard with the rest. */ +export function addComponentIssue(frameId: string, issue: ComponentIssue) { + setKey(componentIssues, frameId, [...(componentIssues.get(frameId) ?? []), issue]) +} + +function prepareWrite( + canvasId: string, + frameId: string, + html: string, + priorHtml: string, + by: string, + carried: ComponentIssue[] = [], +) { const canvas = store.getCanvas(canvasId) if (!canvas) return { html, changed: [] as ComponentDef[] } const prepared = prepareFrameHtml(canvas, frameId, html, by, priorHtml) - if (prepared.issues.length) componentIssues.set(frameId, prepared.issues) - else componentIssues.delete(frameId) + const issues = dedupeIssues([...carried, ...prepared.issues]) + if (issues.length) setKey(componentIssues, frameId, issues) + else dropKey(componentIssues, frameId) /* no new revision, so no propagation either: only "Go to main" needs to hear of it */ for (const def of prepared.moved) broadcastComponent(canvasId, def, resolveActor({ name: by, kind: 'user' })) + announceAdopted(canvasId, prepared.adopted, resolveActor({ name: by, kind: 'user' }), true) /* faces after the components: an expanded may name a library family */ - return { ...prepared, html: withLibraryFaces(canvasId, prepared.html) } + return { ...prepared, html: withCanvasFaces(canvasId, prepared.html) } +} + +/** Components a canvas just took up from its workspace library: the room gets + * the definitions, and the canvas the library's tokens they name and it lacks + * (an existing token of the same name is left alone). Inside a frame write the + * token pass waits for that write to land, since adding tokens restyles frames. */ +export function announceAdopted(canvasId: string, adopted: ComponentDef[], actor: Actor, withinWrite = false) { + if (!adopted.length) return + for (const def of adopted) broadcastComponent(canvasId, def, actor) + const names = adopted.map((def) => `“${def.name}”`).join(', ') + logComponent(canvasId, actor, `added ${names} from the workspace library`) + const carry = () => carryLibraryTokens(canvasId, adopted, actor) + if (!withinWrite) return carry() + /* once the write has landed and been sent, as work of its own */ + if (inTransaction()) postCommit(carry) + else queueMicrotask(carry) +} + +/** Create the library's tokens these linked components name and the canvas + * lacks: on first use, and again when a pulled update starts naming new ones. */ +export function carryLibraryTokens(canvasId: string, adopted: ComponentDef[], actor: Actor) { + const have = new Set(store.getTokens(canvasId).map((token) => token.name)) + const missing = new Map() + for (const def of adopted) { + if (!def.source) continue + const used = tokensUsedBy(`${def.template}\n${def.css}`, store.getTokens(def.source.canvasId)) + for (const token of used) if (!have.has(token.name)) missing.set(token.name, token) + } + if (!missing.size || !store.getCanvas(canvasId)) return + const inputs = aliasesLast([...missing.values()]).map(({ name, type, value, themes, description }) => ({ + name, + type, + value, + ...(themes ? { themes } : {}), + ...(description ? { description } : {}), + })) + createTokens(canvasId, inputs, actor) +} + +/** Tokens ordered so each comes after the ones its values read: an alias is + * refused while what it points at does not exist yet. */ +function aliasesLast(tokens: DesignToken[]): DesignToken[] { + const placed = new Set() + const ordered: DesignToken[] = [] + const names = new Set(tokens.map((token) => token.name)) + const reads = (token: DesignToken) => + [token.value, ...Object.values(token.themes ?? {})].flatMap(referencedTokens).filter((name) => names.has(name)) + let waiting = tokens + while (waiting.length) { + const ready = waiting.filter((token) => reads(token).every((name) => placed.has(name))) + /* a cycle cannot be ordered: hand the rest over and let each be refused on its own */ + const next = ready.length ? ready : waiting + for (const token of next) { + placed.add(token.name) + ordered.push(token) + } + waiting = waiting.filter((token) => !placed.has(token.name)) + } + return ordered } /** A component's own line in the activity feed. */ +/** A component that is no longer on the canvas at all (an import taken back): not a soft delete. */ +export function broadcastComponentGone(canvasId: string, id: string, actor: Actor) { + broadcast(canvasId, { type: 'component', id, component: null, actor }) +} + export function logComponent(canvasId: string, actor: Actor, line: string) { logActivity(canvasId, actor, line) touch(canvasId, actor) @@ -1782,90 +2127,228 @@ export function broadcastComponent(canvasId: string, component: ComponentDef, ac broadcast(canvasId, { type: 'component', id: component.id, component, actor }) } -export function broadcastComponentDeleted(canvasId: string, id: string, actor: Actor) { - broadcast(canvasId, { type: 'component', id, component: null, actor }) +/** A library published or withdrew something: every canvas of its workspace hears, + * the library canvas included (its own panel shows what is still unpublished). */ +export function broadcastLibrary(library: Pick, actor: Actor) { + for (const canvas of store.allCanvases()) { + if (canvas.id === library.id || (library.workspaceId && canvas.workspaceId === library.workspaceId)) + broadcast(canvas.id, { type: 'library', actor }) + } +} + +/** A canvas moved between a workspace and its owner's personal space (or got + * an owner): its team is now another scope's, so its room hears the new one. */ +export function announceTeam(canvasId: string) { + const canvas = store.getCanvas(canvasId) + if (canvas) broadcast(canvas.id, { type: 'team', team: teamOfCanvas(canvas) }) } -export interface PropagationReport { - components: string[] - frames: { id: string; name: string; approvalLost: boolean }[] +/** A workspace's (or a person's own) custom agents changed: every canvas + * that takes its agents from there gets the new list, so its mention picker + * and its automation steps offer what the team now has. */ +export function broadcastCustomAgents(scope: { workspaceId: string } | { ownerId: string }) { + for (const canvas of store.allCanvases()) { + const hears = + 'workspaceId' in scope + ? canvas.workspaceId === scope.workspaceId + : !canvas.workspaceId && canvas.ownerId === scope.ownerId + if (hears) broadcast(canvas.id, { type: 'team', team: teamOfCanvas(canvas) }) + } } -/** A main changed: bring every frame using it up to date, and tell the room. Frames - * mid-stream catch up when their stream ends, since prepareFrameHtml upgrades instances. */ -export function propagateComponents( +export type PropagationReport = propagation.DrainReport + +/** Propagation an operation still open has asked for: it enters the queue at the commit. */ +const propagationAsked = new Map() + +/** Is this component waiting to be carried to frames of the canvas: in the queue, or asked + * for by the operation in progress and queued when it commits? */ +export function propagationPending(canvasId: string, componentId: string): boolean { + return propagationAsked.has(`${canvasId}:${componentId}`) || propagation.isPending(canvasId, 'propagate', componentId) +} + +/** A frame write that changed a main. Every other frame using it is brought up to date in + * the background (server/propagation.ts); with DOOP_DEFER_COMPONENT_PROPAGATION each + * catches up on its own next write instead (prepareFrameHtml upgrades instances). */ +function propagateFromFrameWrite(canvasId: string, changed: ComponentDef[], actor: Actor, originFrameId: string) { + if (env.DOOP_DEFER_COMPONENT_PROPAGATION) { + for (const def of changed) broadcast(canvasId, { type: 'component', id: def.id, component: def, actor }) + return + } + queuePropagation(canvasId, changed, actor, originFrameId) +} + +/** A main changed: tell the room now, and queue every frame using it to be brought up to + * date, one per tick. Returns at once; nothing is read or rewritten here. `originFrameId` + * is the frame whose write this came from, which already has the change. */ +export function queuePropagation(canvasId: string, changed: ComponentDef[], actor: Actor, originFrameId?: string) { + for (const def of changed) broadcast(canvasId, { type: 'component', id: def.id, component: def, actor }) + /* nothing follows a deleted component: its instances keep the markup they have */ + const followed = changed.filter((def) => !isDeleted(def)).map((def) => def.id) + const others = store.getCanvas(canvasId)?.frames.some((frame) => frame.id !== originFrameId) ?? false + const asked = others ? followed.map((id) => `${canvasId}:${id}`) : [] + for (const key of asked) setKey(propagationAsked, key, true) + /* queued with the commit: a refused write has asked for nothing */ + afterCommit(() => { + for (const key of asked) propagationAsked.delete(key) + propagation.enqueue('propagate', canvasId, followed, actor, { exceptFrameId: originFrameId }) + }) +} + +/** One frame's turn in the queue: what the synchronous sweep did per frame. History is filed + * and the room sees frame:updated; sign-off stands, since the frame itself was not edited. + * A frame mid-stream catches up when its stream ends. */ +function propagateIntoFrame( canvasId: string, - changed: ComponentDef[], + frameId: string, + componentIds: string[], actor: Actor, - originFrameId?: string, -): PropagationReport { - const report: PropagationReport = { components: [], frames: [] } - const queue = [...changed] - const seen = new Set() - const touched = new Map() - for (let def = queue.shift(); def; def = queue.shift()) { - if (seen.has(def.id)) continue - seen.add(def.id) - report.components.push(def.name) - broadcast(canvasId, { type: 'component', id: def.id, component: def, actor }) - const canvas = store.getCanvas(canvasId) - if (!canvas) break - for (const frame of [...canvas.frames]) { - if (frame.id === originFrameId && !seen.has(`origin:${frame.id}`)) { - seen.add(`origin:${frame.id}`) - continue - } - /* a one-shot reveal is only playback of what is already stored, so it updates like any frame */ - if (streams.has(frame.id) || !referencesComponent(frame.html, def.id)) continue - const prepared = prepareFrameHtml(canvas, frame.id, frame.html, actor.name, frame.html) - queue.push(...prepared.changed) - /* the ordinary write's font pass too: a main that took up a library family - brings its face along to every frame it reaches */ - const html = withLibraryFaces(canvasId, prepared.html) - if (html === frame.html) continue - const prior = priorState(frame) - const wasApproved = frame.approval?.status === 'ready_for_dev' - const updated = store.updateFrame(frame.id, { html }, actor.name) - if (!updated) continue - noteHtmlChange(prior, actor, true) - broadcast(canvasId, { type: 'frame:updated', frame: updated, actor }) - touched.set(frame.id, { - id: frame.id, - name: frame.name, - approvalLost: wasApproved || !!touched.get(frame.id)?.approvalLost, +): propagation.FrameOutcome { + const canvas = store.getCanvas(canvasId) + const frame = store.getFrame(frameId) + if (!canvas || !frame || frame.canvasId !== canvasId) return {} + /* a one-shot reveal is only playback of what is already stored, so it updates like any frame */ + const followed = componentIds.filter((id) => !isDeleted(canvas.components?.find((def) => def.id === id))) + if (streams.has(frame.id) || !followed.some((id) => referencesComponent(frame.html, id))) return {} + const stamp = frame.updatedAt + const prepared = prepareFrameHtml(canvas, frame.id, frame.html, actor.name, frame.html) + /* a main in this frame that is built from what changed: its own instances are next */ + if (prepared.changed.length) queuePropagation(canvasId, prepared.changed, actor) + /* the ordinary write's font pass too: a main that took up a library family + brings its face along to every frame it reaches */ + const html = withCanvasFaces(canvasId, prepared.html) + const latest = store.getFrame(frameId) + if (!latest) return {} + /* written underneath the preparation: what was prepared is of an older frame */ + if (latest.updatedAt !== stamp) return { requeue: true } + if (html === latest.html) return {} + const prior = priorState(latest) + /* a component it uses changed, not the frame: sign-off stands (decided 2026-11-12) */ + const updated = store.updateFrame(latest.id, { html }, actor.name, { annotation: true }) + if (!updated) return {} + noteHtmlChange(prior, actor, true) + broadcast(canvasId, { type: 'frame:updated', frame: updated, actor }) + return { touched: { id: updated.id, name: updated.name, approvalLost: false } } +} + +function propagationDrained(canvasId: string, report: PropagationReport, actor: Actor) { + if (!report.frames.length) return + const names = report.components.flatMap((id) => { + const def = store.getComponents(canvasId).find((candidate) => candidate.id === id) + return def ? [`“${def.name}”`] : [] + }) + const lost = report.frames.filter((frame) => frame.approvalLost).length + const count = report.frames.length + logActivity( + canvasId, + actor, + `updated ${names.join(', ')} in ${count} frame${count === 1 ? '' : 's'}${ + lost ? `; ${lost} approved frame${lost === 1 ? '' : 's'} now need${lost === 1 ? 's' : ''} review` : '' + }`, + ) + touch(canvasId, actor) +} + +propagation.registerFrameTask('propagate', { frame: propagateIntoFrame, drained: propagationDrained }) + +/** + * Bring instances left on an older revision up to their component: the frames a propagation + * never reached, since the queue lives in memory and a restart mid-drain drops it. Queued as + * an ordinary propagation per canvas, in the name of whoever last changed the component. + */ +export async function catchUpComponentsBehind(): Promise<{ components: number; canvases: number }> { + /* propagation switched off: frames follow on their own next write, by choice */ + if (env.DOOP_DEFER_COMPONENT_PROPAGATION) return { components: 0, canvases: 0 } + const behind = await persist.componentsBehind() + const byCanvas = new Map>() + for (const { canvasId, componentId } of behind) + byCanvas.set(canvasId, (byCanvas.get(canvasId) ?? new Set()).add(componentId)) + let components = 0 + let canvases = 0 + for (const [canvasId, ids] of byCanvas) { + const defs = store.getComponents(canvasId).filter((def) => ids.has(def.id) && !isDeleted(def)) + if (!defs.length) continue + components += defs.length + canvases += 1 + for (const def of defs) { + const actor = resolveActor({ name: def.updatedBy, kind: 'user' }) + transaction(() => queuePropagation(canvasId, [def], actor)) + } + /* one canvas at a time: a queued canvas is loaded and held until it drains, so queueing + them all at once would hold every one of them in memory together */ + await propagation.whenCanvasIdle(canvasId) + } + return { components, canvases } +} + +/** + * Give hollow definitions their markup back from their mains, as the next write of each main + * would: rows that lost it when an older write landed last, before writes to a component row + * were queued (2026-11-11). One canvas at a time, after boot; nothing to do once every + * definition is whole. Instances need no update (they were rendered from what the main + * holds), and the main's frame is written only when the pass marked it up (part keys), as an + * annotation that leaves sign-off standing. + */ +export async function healHollowComponents(): Promise<{ + healed: number + noMain: number + failed: number +}> { + const counts = { healed: 0, noMain: 0, failed: 0 } + const hollowOn = (canvas: Canvas) => + (canvas.components ?? []).filter((def) => isHollow(def) && !isDeleted(def) && !def.source?.library) + for (const listed of store.allCanvases()) { + const waiting = hollowOn(listed).length + if (!waiting) continue + try { + await store.withCanvas(listed.id, async (canvas) => { + if (canvas) healCanvas(canvas, counts) }) + } catch (err) { + /* this canvas could not be read: the rest still get theirs, and the next boot tries again */ + counts.failed += waiting + console.error(`[components] healing hollow definitions on ${listed.id}: the canvas did not load`, err) } } - report.frames = [...touched.values()] - if (report.frames.length) { - const lost = report.frames.filter((frame) => frame.approvalLost).length - const count = report.frames.length - logActivity( - canvasId, - actor, - `updated ${report.components.map((name) => `“${name}”`).join(', ')} in ${count} frame${count === 1 ? '' : 's'}${ - lost ? `; ${lost} approved frame${lost === 1 ? '' : 's'} now need${lost === 1 ? 's' : ''} review` : '' - }`, - ) - touch(canvasId, actor) + return counts +} + +function healCanvas(canvas: Canvas, counts: { healed: number; noMain: number; failed: number }) { + const byFrame = new Map>() + for (const def of canvas.components ?? []) { + if (!isHollow(def) || isDeleted(def) || def.source?.library) continue + const main = canvas.frames.find((frame) => frame.html.includes(`${COMPONENT_ATTR}="${def.id}"`)) + if (!main) { + counts.noMain++ + continue + } + byFrame.set(main, (byFrame.get(main) ?? new Set()).add(def.id)) + } + for (const [frame, ids] of byFrame) { + try { + transaction(() => healFromMain(canvas, frame, ids)) + } catch (err) { + console.error(`[components] healing ${[...ids].join(', ')} from frame ${frame.id} failed:`, err) + } + for (const id of ids) { + if (isHollow(store.getComponents(canvas.id).find((def) => def.id === id))) counts.failed++ + else counts.healed++ + } } - return report } -/** A finished document with the @font-face rules for the canvas's library - * fonts it uses (shared/fonts.ts) and the stylesheet link for the hosted - * fonts it names (shared/webFonts.ts), so naming a family is all it takes. */ -function withLibraryFaces(canvasId: string, html: string): string { - const canvas = store.getCanvas(canvasId) - if (!canvas) return html - const library = fontsForCanvas(canvas) - /* tokens first: a family named only through a font token is then in the - document for the font scan to find */ - const withTokens = withTokenBlock(html, canvas.tokens ?? [], canvas.tokenThemes ?? []) - return withWebFontLinks(withFontFaces(withTokens, library), library) +/** The definitions only: the frame is written just where a main needed part keys, as an + * annotation, since nothing in it looks different. */ +function healFromMain(canvas: Canvas, frame: Frame, ids: ReadonlySet) { + const actor = resolveActor({ name: frame.updatedBy, kind: 'user' }) + const { html, saved } = rederiveFromMains(canvas, frame.id, ids, actor.name) + for (const def of saved) broadcastComponent(canvas.id, def, actor) + if (html === frame.html) return + const next = store.updateFrame(frame.id, { html }, frame.updatedBy, { annotation: true }) + if (next) broadcast(canvas.id, { type: 'frame:updated', frame: next, actor }) } -export function appendFrameHtml( +export const appendFrameHtml = atomic(function appendFrameHtml( frameId: string, chunk: string, actor: Actor, @@ -1875,36 +2358,54 @@ export function appendFrameHtml( if (!before) return undefined const starting = opts.start || !streams.has(frameId) + /* read now: the store updates `before` in place below */ + const base = before.html /* an agent that escapes its opening chunk escapes the whole stream, so latch the verdict there: a chunk mid-design can hold a legitimate `<` (a code sample) and must never be sniffed on its own */ const escaped = starting ? looksEscapedHtml(chunk) : (streams.get(frameId)?.escaped ?? false) const piece = escaped ? decodeEscapedHtml(chunk) : chunk const canvas = store.getCanvas(before.canvasId) - const expanded = canvas ? prepareChunk(canvas, piece, opts.start ? '' : before.html) : piece + /* the chunk's own pass can take up a library component, and the last chunk's whole-frame + pass below can still be refused (the work budget): the write boundary undoes it then */ + const chunked = canvas + ? prepareChunk(canvas, piece, opts.start ? '' : before.html, actor.name) + : { html: piece, issues: [], adopted: [] } + const expanded = chunked.html + const carried = [...(starting ? [] : (streamIssues.get(frameId) ?? [])), ...chunked.issues] /* the last chunk settles the whole document: a split across chunks, the component stylesheets, a main written in the stream, the - faces of the library fonts it names */ + faces of the library fonts it names. Until then each chunk gets the + canvas's tokens and fonts, so a mid-stream screenshot shows them. A + token renamed mid-stream waits for the stream to close (pendingRenames): + until then the block stays as written, under the names the frame uses. */ const joined = opts.start ? expanded : before.html + expanded const prepared = opts.done - ? prepareWrite(before.canvasId, frameId, joined, before.html, actor.name) - : { html: joined, changed: [] as ComponentDef[] } + ? prepareWrite(before.canvasId, before.id, joined, before.html, actor.name, carried) + : { + html: pendingRenames.has(frameId) ? joined : withCanvasFacesMidStream(before.canvasId, joined), + changed: [] as ComponentDef[], + } const html = prepared.html + if (opts.done) dropKey(streamIssues, frameId) + else setKey(streamIssues, frameId, carried) const prior = priorState(before) const frame = store.updateFrame(frameId, { html }, actor.name)! /* the opening chunk replaces the design; every later one extends this burst */ noteHtmlChange(prior, actor, !starting) + announceAdopted(before.canvasId, chunked.adopted, actor, true) if (starting) { finishReveal(frameId) /* a live stream overrides any one-shot playback in flight */ - streams.set(frameId, { actor, escaped, lastActivity: Date.now() }) + setKey(streams, frameId, { actor, escaped, lastActivity: Date.now(), base, tail: '' }) broadcast(frame.canvasId, { type: 'frame:streaming', frameId, active: true, actor }) logActivity(frame.canvasId, actor, `is designing “${frame.name}” live…`, frameId) autoTask(frame.canvasId, actor, `Designing “${frame.name}”`, frameId) } - const s = streams.get(frameId)! + const s = edit(streams.get(frameId)!) s.lastActivity = Date.now() s.escaped = escaped + s.tail = (s.tail + piece).slice(-STREAM_TAIL_CHARS) /* the chunk renders the moment it arrives — viewers see the agent's real progress */ broadcast(frame.canvasId, { @@ -1914,22 +2415,26 @@ export function appendFrameHtml( }) if (opts.done) { finishStream(frameId, true) - if (prepared.changed.length) propagateComponents(frame.canvasId, prepared.changed, actor, frameId) + if (prepared.changed.length) propagateFromFrameWrite(frame.canvasId, prepared.changed, actor, frameId) } touch(frame.canvasId, actor, frameId) return frame -} +}) /* ------------------------------------------------------------------ */ -export function setCanvasPages(canvasId: string, pages: import('../shared/types.ts').CanvasPageInfo[], actor: Actor) { +export const setCanvasPages = atomic(function setCanvasPages( + canvasId: string, + pages: import('../shared/types.ts').CanvasPageInfo[], + actor: Actor, +) { const saved = store.setPages(canvasId, pages) const next = saved?.pages ?? pages broadcast(canvasId, { type: 'canvas:pages', pages: next, actor }) for (const guide of saved?.dropped ?? []) broadcast(canvasId, { type: 'guide', id: guide.id, guide: null, actor }) return next -} +}) /** Add one page at the end of the canvas, named `name`, with a fresh id; peers * get the page list. Returns the new page and the whole list. */ @@ -1977,14 +2482,14 @@ export async function duplicatePage(canvasId: string, pageId: string, actor: Act for (const guide of copy.guides) broadcast(canvasId, { type: 'guide', id: guide.id, guide, actor }) for (const frame of copy.frames) { broadcast(canvasId, { type: 'frame:created', frame, actor }) - emitCanvasEvent(canvasId, { type: 'frame.created', frame, actor }) + emitEvent(canvasId, { type: 'frame.created', frame, actor }) } logActivity(canvasId, actor, `duplicated page “${copy.source.name}” as “${copy.page.name}”`) touch(canvasId, actor) return copy } -export function createFrame( +export const createFrame = atomic(function createFrame( canvasId: string, input: { name: string @@ -2010,8 +2515,8 @@ export function createFrame( const frame = store.createFrame(canvasId, input, actor.name) if (!frame) return undefined const createIssues = takeComponentIssues('') - if (createIssues.length) componentIssues.set(frame.id, createIssues) - bursts.set(frame.id, { actor, lastAt: frame.createdAt }) + if (createIssues.length) setKey(componentIssues, frame.id, createIssues) + setKey(bursts, frame.id, { actor, lastAt: frame.createdAt }) if (actor.kind === 'agent' && frame.html.length > 0) { /* agent one-shot creation still plays back as a reveal */ broadcast(canvasId, { type: 'frame:created', frame: { ...frame, html: '' }, actor }) @@ -2022,15 +2527,15 @@ export function createFrame( } logActivity(canvasId, actor, `created frame “${frame.name}”`, frame.id) touch(canvasId, actor, frame.id) - emitCanvasEvent(canvasId, { type: 'frame.created', frame, actor }) + emitEvent(canvasId, { type: 'frame.created', frame, actor }) return frame -} +}) /** `replace` marks a deliberate whole-document write (set_frame_html): it * always opens a history burst, even when the new document keeps most of * the old one's wrapper — only the reveal-or-morph choice stays similarity * based. Without it a write is judged by how much it changed. */ -export function updateFrame( +export const updateFrame = atomic(function updateFrame( frameId: string, patch: Partial< Pick @@ -2066,7 +2571,7 @@ export function updateFrame( const openReveal = reveals.get(frameId) if (openReveal) { /* new content mid-playback: rewind to the divergence and re-arm the deadline */ - openReveal.actor = actor + edit(openReveal).actor = actor openReveal.shown = Math.min(openReveal.shown, prefix) openReveal.deadline = Date.now() + revealDuration(frame.html.length - openReveal.shown) trackTaskFrame(frame.canvasId, actor, frameId) @@ -2099,33 +2604,40 @@ export function updateFrame( logActivity(frame.canvasId, actor, `${frame.locked ? 'locked' : 'unlocked'} “${frame.name}”`, frame.id) } - if (changedComponents.length) propagateComponents(frame.canvasId, changedComponents, actor, frameId) + if (changedComponents.length) propagateFromFrameWrite(frame.canvasId, changedComponents, actor, frameId) touch(frame.canvasId, actor, frame.id) return frame -} +}) /** Several frames' places in the stack at once (the Layers panel renumbering * a page, or undoing that): every frame is checked before any is written, * so the order changes whole or not at all. Undefined when a frame is * gone or on another canvas. Not a design edit: no activity line. */ -export function restackFrames(canvasId: string, writes: StackWrite[], actor: Actor): Frame[] | undefined { +export const restackFrames = atomic(function restackFrames( + canvasId: string, + writes: StackWrite[], + actor: Actor, +): Frame[] | undefined { if (writes.some((w) => store.getFrame(w.id)?.canvasId !== canvasId)) return undefined const frames = writes.map((w) => store.updateFrame(w.id, { z: w.z }, actor.name)!) for (const frame of frames) broadcast(canvasId, { type: 'frame:updated', frame, actor }) touch(canvasId, actor, frames[0]?.id) return frames -} +}) -/** Sign-off is a human action, separate from ordinary frame editing. */ -export function setFrameApproval( +/** Sign-off is a human action, separate from ordinary frame editing. An agent may set it + * for the person it works for: the approval stays theirs (`approvedBy`), with the agent + * recorded as `approvedVia` and as the actor of the broadcast and activity line. */ +export const setFrameApproval = atomic(function setFrameApproval( frameId: string, ready: boolean, user: { id: string; name: string }, + agent?: Actor, ): Frame | undefined { const current = store.getFrame(frameId) if (!current) return undefined if (ready && current.approval?.status === 'ready_for_dev') return current - const actor = resolveActor({ name: user.name, kind: 'user' }) + const actor = agent ?? resolveActor({ name: user.name, kind: 'user' }) const approval = ready ? { status: 'ready_for_dev' as const, @@ -2133,17 +2645,41 @@ export function setFrameApproval( approvedByUserId: user.id, approvedAt: Math.max(Date.now(), current.updatedAt + 1), approvedFrameUpdatedAt: current.updatedAt, + ...(agent ? { approvedVia: agent.name } : {}), } : null - const frame = store.updateFrame(frameId, { approval }, user.name)! + const frame = store.updateFrame(frameId, { approval }, actor.name)! broadcast(frame.canvasId, { type: 'frame:updated', frame, actor }) logActivity( frame.canvasId, actor, - ready ? `marked “${frame.name}” ready for dev` : `moved “${frame.name}” back to draft`, + ready + ? `marked “${frame.name}” ready for dev${agent ? ` for ${user.name}` : ''}` + : `moved “${frame.name}” back to draft`, frameId, ) return frame +}) + +/** An agent's approval request, shared by the MCP tool and the resident agent. */ +export function agentSetFrameApproval( + frameId: string, + status: 'ready_for_dev' | 'draft', + user: { id: string; name: string }, + agent: Actor, +): { ok: true; frame: Frame } | { ok: false; error: string } { + const current = store.getFrame(frameId) + if (!current) return { ok: false, error: `no frame with id ${frameId}` } + if (status === 'ready_for_dev' && isFrameStreaming(frameId)) + return { ok: false, error: 'the design is still streaming — wait for it to finish before approving it' } + const frame = setFrameApproval(frameId, status === 'ready_for_dev', user, agent) + return frame ? { ok: true, frame } : { ok: false, error: `no frame with id ${frameId}` } +} + +/** An agent is appending to this frame right now. A one-shot reveal does not count: it is + * only playback of what is already stored, so background work may rewrite the frame. */ +export function isFrameMidStream(frameId: string): boolean { + return streams.has(frameId) } export function isFrameStreaming(frameId: string): boolean { @@ -2159,40 +2695,41 @@ export function isCanvasStreaming(canvasId: string): boolean { return false } -export function deleteFrame(frameId: string, actor: Actor): Frame | undefined { +export const deleteFrame = atomic(function deleteFrame(frameId: string, actor: Actor): Frame | undefined { /* close any live stream or playback while the frame still exists, so their auto “Designing…” tasks end with it */ finishStream(frameId, false) finishReveal(frameId) const frame = store.deleteFrame(frameId) if (!frame) return undefined - unsavedStamps.delete(frameId) - bursts.delete(frameId) - thumbs.purge(frameId) + dropKey(unsavedStamps, frameId) + dropKey(bursts, frameId) + afterCommit(() => thumbs.purge(frameId)) broadcast(frame.canvasId, { type: 'frame:deleted', frameId, actor }) releaseMains(frame.canvasId, frameId, actor) logActivity(frame.canvasId, actor, `deleted frame “${frame.name}”`, frame.id) touch(frame.canvasId, actor, null) return frame -} +}) /** Remove a canvas with everything attached to it; viewers are told to leave. */ -export function deleteCanvas(canvasId: string): boolean { +export const deleteCanvas = atomic(function deleteCanvas(canvasId: string): boolean { const c = store.deleteCanvas(canvasId) + forgetLibrary(canvasId) if (!c) return false for (const f of c.frames) { - thumbs.purge(f.id) - bursts.delete(f.id) + afterCommit(() => thumbs.purge(f.id)) + dropKey(bursts, f.id) } broadcast(canvasId, { type: 'canvas:deleted' }) - taskLog.delete(canvasId) - feedbackLog.delete(canvasId) - commentLog.delete(canvasId) - activityLog.delete(canvasId) - decisionLog.delete(canvasId) - proposalLog.delete(canvasId) + dropKey(taskLog, canvasId) + dropKey(feedbackLog, canvasId) + dropKey(commentLog, canvasId) + dropKey(activityLog, canvasId) + dropKey(decisionLog, canvasId) + dropKey(proposalLog, canvasId) return true -} +}) export function renameCanvas(canvasId: string, name: string, actor: Actor) { const canvas = store.renameCanvas(canvasId, name) @@ -2231,7 +2768,7 @@ export function guidelineSummary(doc: GuidelineDoc): string { /** Upsert (or, with empty markdown, delete) a design doc. Returns the doc, * null for a deletion, undefined when the canvas is missing; throws on * invalid input with a message meant for the caller's error channel. */ -export function setGuideline( +export const setGuideline = atomic(function setGuideline( canvasId: string, name: string, markdown: string, @@ -2251,7 +2788,7 @@ export function setGuideline( if (!clean) { const existing = store.getGuidelines(canvasId).find((d) => d.name === slug) if (!store.deleteGuideline(canvasId, slug)) return store.getCanvas(canvasId) ? null : undefined - persist.saveGuidelineVersion(canvasId, slug, '', actor.name, Date.now()) + stored.saveGuidelineVersion(canvasId, slug, '', actor.name, Date.now()) broadcast(canvasId, { type: 'guidelines', name: slug, doc: null, actor }) logActivity(canvasId, actor, `deleted the design guide “${existing ? guidelineTitle(existing) : slug}”`) touch(canvasId, actor) @@ -2263,12 +2800,12 @@ export function setGuideline( throw new Error(`this canvas already has ${MAX_GUIDELINE_DOCS} design guides — delete one first`) const doc = store.setGuideline(canvasId, slug, clean, actor.name, pos, cleanTitle) if (!doc) return undefined - persist.saveGuidelineVersion(canvasId, slug, clean, actor.name, doc.updatedAt) + stored.saveGuidelineVersion(canvasId, slug, clean, actor.name, doc.updatedAt) broadcast(canvasId, { type: 'guidelines', name: slug, doc, actor }) logActivity(canvasId, actor, `updated the design guide “${guidelineTitle(doc)}”`) touch(canvasId, actor) return doc -} +}) /** Patch design-guide metadata (card position, display title) without touching * the content: no version snapshot, position changes make no activity noise. */ @@ -2420,21 +2957,21 @@ function restyleTokenFrames(canvasId: string, actor: Actor, rename?: TokenRename for (const frame of [...canvas.frames]) { /* an open append stream gets its block, and any rename, with its done chunk */ if (streams.has(frame.id)) { - if (rename) pendingRenames.set(frame.id, [...(pendingRenames.get(frame.id) ?? []), rename]) + if (rename) setKey(pendingRenames, frame.id, [...(pendingRenames.get(frame.id) ?? []), rename]) continue } let html = frame.html if (rename) html = applyRename(html, rename) - html = withLibraryFaces(canvasId, html) + html = withCanvasFaces(canvasId, html) if (html === frame.html) continue const prevHtml = frame.html const updated = store.updateFrame(frame.id, { html }, actor.name, { annotation: true }) if (!updated) continue - thumbs.purge(frame.id) + afterCommit(() => thumbs.purge(frame.id)) const openReveal = reveals.get(frame.id) if (openReveal) { /* mid-playback: rewind to where the documents diverge, as a rewrite does */ - openReveal.shown = Math.min(openReveal.shown, sharedSpan(prevHtml, updated.html).prefix) + edit(openReveal).shown = Math.min(openReveal.shown, sharedSpan(prevHtml, updated.html).prefix) openReveal.deadline = Date.now() + revealDuration(updated.html.length - openReveal.shown) } else broadcast(canvasId, { type: 'frame:updated', frame: updated, actor }) changed++ @@ -2457,7 +2994,11 @@ function tokenSummary(results: TokenResult[], verb: string): string { /** Add tokens; one result per entry, errors in-band so a batch with one bad * entry still lands the rest. Returns undefined when the canvas is missing. */ -export function createTokens(canvasId: string, inputs: unknown[], actor: Actor): TokenResult[] | undefined { +export const createTokens = atomic(function createTokens( + canvasId: string, + inputs: unknown[], + actor: Actor, +): TokenResult[] | undefined { const canvas = store.getCanvas(canvasId) if (!canvas) return undefined const results: TokenResult[] = [] @@ -2545,11 +3086,15 @@ export function createTokens(canvasId: string, inputs: unknown[], actor: Actor): touch(canvasId, actor) } return results -} +}) /** Change, rename or delete tokens by name, in order; one result per entry. * Every frame naming a changed token is restyled before this returns. */ -export function setTokens(canvasId: string, edits: TokenEdit[], actor: Actor): TokenResult[] | undefined { +export const setTokens = atomic(function setTokens( + canvasId: string, + edits: TokenEdit[], + actor: Actor, +): TokenResult[] | undefined { if (!store.getCanvas(canvasId)) return undefined const results: TokenResult[] = [] const renames: TokenRename[] = [] @@ -2675,12 +3220,12 @@ export function setTokens(canvasId: string, edits: TokenEdit[], actor: Actor): T touch(canvasId, actor) } return results -} +}) /** Replace the canvas's token themes (order included): a theme that leaves * takes its values with it, and every frame is restyled. Throws on bad * input with a message for the caller's error channel. */ -export function setTokenThemes( +export const setTokenThemes = atomic(function setTokenThemes( canvasId: string, themes: unknown, actor: Actor, @@ -2730,7 +3275,7 @@ export function setTokenThemes( ) touch(canvasId, actor) return names -} +}) /* ------------------------------------------------------------------ */ /* Design memory: pinned reference frames (exemplars), captured */ @@ -2767,16 +3312,17 @@ function captureDecision( ...(input.agentName ? { agentName: input.agentName } : {}), at: Date.now(), } - const list = decisionLog.get(canvasId) ?? [] - list.unshift(decision) - if (list.length > 100) list.length = 100 - decisionLog.set(canvasId, list) - persist.saveDecision(canvasId, decision) + prepend(decisionLog, canvasId, decision) + stored.saveDecision(canvasId, decision) broadcast(canvasId, { type: 'decision', decision }) /* generalize the raw words into a preference, then maybe propose a rule (both no-ops without an API key). Dynamic import: distill depends on this module. */ - import('./distill.ts').then((d) => d.onDecision(canvasId, decision.id)).catch(() => {}) + afterCommit(() => + detached(() => { + import('./distill.ts').then((d) => d.onDecision(canvasId, decision.id)).catch(() => {}) + }), + ) return decision } @@ -2785,8 +3331,8 @@ function captureDecision( export function setDecisionSummary(canvasId: string, id: string, summary: string) { const decision = getDecisions(canvasId).find((d) => d.id === id) if (!decision) return - decision.summary = summary - persist.saveDecision(canvasId, decision) + edit(decision).summary = summary + stored.saveDecision(canvasId, decision) broadcast(canvasId, { type: 'decision', decision }) } @@ -2849,8 +3395,8 @@ export function markDecisionsDistilled(canvasId: string, ids: string[]) { const now = Date.now() for (const d of getDecisions(canvasId)) { if (ids.includes(d.id)) { - d.distilledAt = now - persist.saveDecision(canvasId, d) + edit(d).distilledAt = now + stored.saveDecision(canvasId, d) } } } @@ -2870,18 +3416,15 @@ export function addProposal( at: Date.now(), status: 'pending', } - const list = proposalLog.get(canvasId) ?? [] - list.unshift(proposal) - if (list.length > 100) list.length = 100 - proposalLog.set(canvasId, list) - persist.saveProposal(canvasId, proposal) + prepend(proposalLog, canvasId, proposal) + stored.saveProposal(canvasId, proposal) broadcast(canvasId, { type: 'proposal', proposal }) return proposal } /** A human accepted (rule lands in the guide, versioned like any edit) or * dismissed a proposal. */ -export function resolveProposal( +export const resolveProposal = atomic(function resolveProposal( canvasId: string, proposalId: string, accept: boolean, @@ -2896,11 +3439,11 @@ export function resolveProposal( : `# ${proposal.guideTitle ?? guidelineTitle({ name: proposal.guideName })}\n\n${proposal.rule}` setGuideline(canvasId, proposal.guideName, markdown, actor, undefined, guide ? undefined : proposal.guideTitle) } - proposal.status = accept ? 'accepted' : 'dismissed' + edit(proposal).status = accept ? 'accepted' : 'dismissed' proposal.resolvedBy = actor.name proposal.resolvedAt = Date.now() - persist.saveProposal(canvasId, proposal) + stored.saveProposal(canvasId, proposal) broadcast(canvasId, { type: 'proposal', proposal }) if (accept) logActivity(canvasId, actor, `accepted a Memory rule into “${proposal.guideName}”`) return proposal -} +}) diff --git a/server/assets.ts b/server/assets.ts index a5f4362a2..6b06d5306 100644 --- a/server/assets.ts +++ b/server/assets.ts @@ -6,6 +6,7 @@ import * as t from './db/schema.ts' import * as storage from './storage.ts' import type { FrameImage } from '../shared/imageDescriptions.ts' import { emitCanvasEvent } from './events.ts' +import { FREE_UPLOAD_BYTES } from '../shared/billing.ts' /** * Uploaded assets (images, and the files of font libraries): bytes in object storage (server/storage.ts), one @@ -18,7 +19,8 @@ import { emitCanvasEvent } from './events.ts' * some day, asset_refs is the ledger to build it on. */ -export const MAX_ASSET_BYTES = 5 * 1024 * 1024 +/** The default cap: imports, generated images and Free uploads. */ +export const MAX_ASSET_BYTES = FREE_UPLOAD_BYTES const MIME_EXT = { 'image/png': 'png', @@ -60,12 +62,19 @@ interface UploadTicket { canvasId: string ownerId?: string uploadedBy: string + /** what the curl brings: an image for upload_asset (the default), a font file for upload_font */ + kind?: 'asset' | 'font' expiresAt: number inFlight: boolean } const tickets = new Map() -export function createUploadTicket(meta: { canvasId: string; ownerId?: string; uploadedBy: string }): { +export function createUploadTicket(meta: { + canvasId: string + ownerId?: string + uploadedBy: string + kind?: 'asset' | 'font' +}): { token: string expiresAt: number } { @@ -108,13 +117,18 @@ export interface AssetMeta { size: number } +/** `limit` is the uploader's cap where a person uploads (entitlements.ts + * uploadLimit); imports and generated images keep the default. */ export async function createAsset( buf: Buffer, meta: { canvasId?: string; ownerId?: string; uploadedBy: string }, + limit: { bytes: number; message: (bytes: number) => string } = { + bytes: MAX_ASSET_BYTES, + message: (bytes) => `file is ${(bytes / 1024 / 1024).toFixed(1)} MB — the limit is 5 MB`, + }, ): Promise { if (buf.length === 0) throw new Error('empty file') - if (buf.length > MAX_ASSET_BYTES) - throw new Error(`file is ${(buf.length / 1024 / 1024).toFixed(1)} MB — the limit is 5 MB`) + if (buf.length > limit.bytes) throw new Error(limit.message(buf.length)) const mime = sniffMime(buf) if (!mime) throw new Error('unsupported file type — png, jpg, webp, gif and svg are accepted') return storeAsset(buf, { mime, ext: MIME_EXT[mime] }, meta) @@ -212,9 +226,11 @@ export async function getAsset(id: string, signal?: AbortSignal): Promise<{ meta } /** Fetch a remote image through the SSRF guard, validating every redirect - * hop, with a hard size cap enforced while streaming. */ -export async function fetchRemote(rawUrl: string): Promise { + * hop, with a hard size cap enforced while streaming. A caller that only + * reads a small file (a favicon) may pass a tighter cap than the store's. */ +export async function fetchRemote(rawUrl: string, maxBytes: number = MAX_ASSET_BYTES): Promise { const { fetchPinnedPublicUrl, parsePublicHttpUrl } = await import('./publicUrl.ts') + const tooBig = new Error(`file exceeds the ${Math.round(maxBytes / 1024 / 1024)} MB limit`) let url = parsePublicHttpUrl(rawUrl) for (let hop = 0; hop < 4; hop++) { const res = await fetchPinnedPublicUrl(url, { @@ -229,7 +245,7 @@ export async function fetchRemote(rawUrl: string): Promise { continue } if (!res.ok) throw new Error(`fetch failed: HTTP ${res.status}`) - if (Number(res.headers.get('content-length') || 0) > MAX_ASSET_BYTES) throw new Error('file exceeds the 5 MB limit') + if (Number(res.headers.get('content-length') || 0) > maxBytes) throw tooBig if (!res.body) throw new Error('empty response') const chunks: Uint8Array[] = [] let total = 0 @@ -238,9 +254,9 @@ export async function fetchRemote(rawUrl: string): Promise { const { done, value } = await reader.read() if (done) break total += value.byteLength - if (total > MAX_ASSET_BYTES) { + if (total > maxBytes) { await reader.cancel() - throw new Error('file exceeds the 5 MB limit') + throw tooBig } chunks.push(value) } diff --git a/server/automations.ts b/server/automations.ts index 359842e8d..2d8609610 100644 --- a/server/automations.ts +++ b/server/automations.ts @@ -10,14 +10,17 @@ import * as meta from './meta.ts' import { AutomationPullError, extensions } from './extensions.ts' import { hasDurableCanvasAccess } from './access.ts' import { getUserName, isBanned } from './auth.ts' -import { roleName } from '../shared/agents.ts' +import { normalizePipeline, roleName } from '../shared/agents.ts' +import { rosterFor } from './customAgents.ts' import type { AgentTask } from '../shared/types.ts' import { env } from './env.ts' import { MAX_NAME, + automationQueuedBy, incompleteReason, nextRunAt, normalizeSchedule, + narrowStepRoles, normalizeSteps, normalizeTrigger, type ApprovedSource, @@ -167,7 +170,7 @@ function parseInput( else { const parsed = normalizeSteps(body.steps) if (typeof parsed === 'string') return parsed - steps = parsed + steps = narrowStepRoles(parsed, (canvasId) => rosterFor(store.getCanvas(canvasId))) } const bad = checkCanvases(ownerId, steps) if (bad) return bad @@ -370,15 +373,17 @@ async function queueAgent( '', ].join('\n') : '' + /* a custom agent deleted since the step was saved hands it to the default */ + const pipeline = normalizePipeline(step.roles, rosterFor(store.getCanvas(step.canvasId))).slice(0, 1) const card: AgentTask = { id: nanoid(8), agentName: '', color: '#0177d3', status: `${sourceBrief}${earlierResults}${step.prompt}`, startedAt: Date.now(), - queuedBy: `Automation · ${row.name}`, + queuedBy: automationQueuedBy(row.name), queuedByUserId: row.ownerId, - pipeline: step.roles, + pipeline, stage: 0, } state.taskId = card.id @@ -405,7 +410,7 @@ async function queueAgent( startedAt: card.startedAt, queuedBy: card.queuedBy, queuedByUserId: row.ownerId, - pipeline: step.roles.join(','), + pipeline: pipeline.join(','), stage: 0, }) }) @@ -480,7 +485,7 @@ export async function advanceRun(id: string): Promise { return } state.summaries.push( - `Completed ${step.type === 'agent' ? step.title || roleName(step.roles[0]) : 'design task'}`, + `Completed ${step.type === 'agent' ? step.title || roleName(step.roles[0], rosterFor(store.getCanvas(step.canvasId))) : 'design task'}`, ) for (const frameId of (task.frameIds ?? '').split(',').filter(Boolean)) { if (store.getFrame(frameId)?.canvasId === step.canvasId && state.links.length < 30) diff --git a/server/canvasFaces.ts b/server/canvasFaces.ts new file mode 100644 index 000000000..e15a4e348 --- /dev/null +++ b/server/canvasFaces.ts @@ -0,0 +1,30 @@ +import { withTokenBlock } from '../shared/designTokens.ts' +import { withFontFaces } from '../shared/fonts.ts' +import { withWebFontLinks } from '../shared/webFonts.ts' +import { fontsForCanvas } from './fonts.ts' +import { store } from './store.ts' + +/** A document with what the canvas supplies to every frame: the values of the + * design tokens it names (shared/designTokens.ts), the @font-face rules for the + * library fonts it uses (shared/fonts.ts) and the stylesheet link for the hosted + * fonts it names (shared/webFonts.ts), so naming a token or a family is all it takes. */ +export function withCanvasFaces(canvasId: string, html: string): string { + const canvas = store.getCanvas(canvasId) + if (!canvas) return html + const library = fontsForCanvas(canvas) + /* tokens first: a family named only through a font token is then in the + document for the font scan to find */ + const withTokens = withTokenBlock(html, canvas.tokens ?? [], canvas.tokenThemes ?? []) + return withWebFontLinks(withFontFaces(withTokens, library), library) +} + +/** A complete `` or `` tag: before one has arrived, the place a block + * would go can still be a half-written tag (`]*>/i + +/** The same for a document still streaming in, once its top is settled, so a + * screenshot of the first section already shows the canvas's tokens and fonts. + * Each pass replaces the blocks the last one wrote, so chunks never stack them. */ +export function withCanvasFacesMidStream(canvasId: string, html: string): string { + return SETTLED_TOP.test(html) ? withCanvasFaces(canvasId, html) : html +} diff --git a/server/canvasFontUpload.ts b/server/canvasFontUpload.ts new file mode 100644 index 000000000..c8e137405 --- /dev/null +++ b/server/canvasFontUpload.ts @@ -0,0 +1,50 @@ +import { addFont, canUseScope, FontInputError } from './fonts.ts' +import { store } from './store.ts' +import type { CustomFont, FontScope } from '../shared/fonts.ts' + +/** + * An agent adding a font file to the library a canvas designs with + * (upload_font over MCP, its curl ticket, and the resident's upload_font): + * the canvas's workspace library, or its owner's own for a personal canvas. + * The font is then used by family name and Doop writes the @font-face, the + * way an uploaded library font always is, instead of the file riding inside + * the frame as base64. + */ + +/** The library a canvas's fonts live in, if this person may add to it. */ +function scopeFor(canvasId: string, userId: string): FontScope { + const canvas = store.getCanvas(canvasId) + if (!canvas) throw new FontInputError('canvas not found') + if (canvas.workspaceId) { + const scope = { workspaceId: canvas.workspaceId } + if (!canUseScope(scope, userId)) + throw new FontInputError("only members of this canvas's workspace can add to its font library") + return scope + } + if (canvas.ownerId !== userId) + throw new FontInputError( + "this personal canvas uses its owner's font library, which only they can add to: ask them to upload the font in Settings → Fonts", + ) + return { personal: true } +} + +export async function addCanvasFont( + canvasId: string, + user: { id: string; name: string }, + buf: Buffer, + fileName: string, +): Promise { + return addFont(scopeFor(canvasId, user.id), user, buf, fileName) +} + +/** What an agent is told once its font is in the library. */ +export function uploadedFontResult(font: CustomFont) { + return { + ok: true, + family: font.family, + weight: font.weight, + style: font.style, + css: `font-family: "${font.family}", sans-serif;`, + note: `Added to this canvas's font library. Name the family in CSS (${`font-family: "${font.family}"`}) and Doop writes the @font-face into the frame; never inline the file. Upload each weight and style you use as its own file.`, + } +} diff --git a/server/componentActions.ts b/server/componentActions.ts index 550e46fb0..ac85afe61 100644 --- a/server/componentActions.ts +++ b/server/componentActions.ts @@ -1,9 +1,10 @@ -import { parse, parseFragment, serializeOuter, type DefaultTreeAdapterTypes as Tree } from 'parse5' -import { canvasPages } from '../shared/pages.ts' +import { serializeOuter, type DefaultTreeAdapterTypes as Tree } from 'parse5' +import { canvasPages, COMPONENTS_PAGE } from '../shared/pages.ts' import { BIND_ATTR, COMPONENT_ATTR, INSTANCE_ATTR, + OVERRIDES_ATTR, MAX_COMPONENTS, MAX_COMPONENT_DESCRIPTION, MAX_COMPONENT_NAME, @@ -13,20 +14,24 @@ import { SLOT_ATTR, SOURCE_CSS_ATTR, USE_TAG, + activeComponents, componentSignature, + isDeleted, isPropName, type ComponentCode, type ComponentDef, type ComponentProp, type InstanceOverrides, + type LibraryComponent, type PartOverride, } from '../shared/components.ts' -import { ELEMENT_ID_ATTR, elementIdSelector } from '../shared/elementId.ts' +import { ELEMENT_ID_ATTR } from '../shared/elementId.ts' import type { Actor, Canvas, Frame } from '../shared/types.ts' import { decodeQuotes, familyKey, fontFaceRule, usesFamily, type CustomFont } from '../shared/fonts.ts' import { fontsForCanvas } from './fonts.ts' import * as actions from './actions.ts' -import { blankComponent, bumpRevision, contextFor, referencesComponent } from './components.ts' +import { blankComponent, bumpRevision, contextFor, referencesComponent, withinRevision } from './components.ts' +import { unmatchedSelectors } from './componentCss.ts' import { alignParts, attrOf, @@ -41,6 +46,11 @@ import { kidsOf, measureTree, parseTemplateRoot, + fitsIn, + isTableContext, + isTablePart, + rootFragment, + tableScaffold, partsOf, readInstance, renderInstance, @@ -51,8 +61,30 @@ import { useMarkup, withDetachedCss, } from './componentEngine.ts' +import { + adoptFromLibrary, + findInLibraries, + isLibrary, + LibraryAdoptError, + libraryBlock, + libraryChanges, + librariesForCanvas, + originOf, + publishable, + publishedOn, + publishLibrary as writeLibrary, + snapshotClosure, + unpublishLibrary as dropLibrary, + type LibraryChangeEntry, +} from './componentLibrary.ts' +import { env } from './env.ts' import { resolveElement } from './elementIds.ts' +import * as propagation from './propagation.ts' +import { optional, parse, parseFragment, usage as workUsage, WorkBudgetError } from './workBudget.ts' +import { afterCommit, atomic, checkpoint, transaction } from './journal.ts' +import { usageByComponent, usageOf, type ComponentUsage } from './componentUsage.ts' import { store } from './store.ts' +import { mayPublishLibrary } from './workspaces.ts' /** * What a person or an agent can do with components. Each operation ends in an @@ -64,22 +96,47 @@ import { store } from './store.ts' export class ComponentError extends Error {} -type Element = Tree.Element +/** A library action on a canvas that may not have one: personal, or in a + * workspace whose plan lapsed. Routes turn it into the upgrade prompt. */ +export class LibraryPlanError extends ComponentError { + constructor( + message: string, + /** the workspace that needs a plan; undefined when the canvas is in none */ + readonly workspaceId?: string, + ) { + super(message) + } +} -const COMPONENTS_PAGE = 'Components' +/** Publishing where the workspace keeps it to its owner and admins. REST answers 403. */ +export class LibraryPublisherError extends ComponentError {} + +type Element = Tree.Element function fail(message: string): never { throw new ComponentError(message) } +/** A component in use, by id or name. A deleted one is not found here: see findDeletedComponent. */ export function findComponent(canvasId: string, ref: string): ComponentDef | undefined { - return contextFor(canvasId).find(ref) + const def = contextFor(canvasId).find(ref) + return isDeleted(def) ? undefined : def +} + +/** A soft-deleted component, by id or name (a name an active component has means that one). */ +export function findDeletedComponent(canvasId: string, ref: string): ComponentDef | undefined { + const def = contextFor(canvasId).find(ref) + return isDeleted(def) ? def : undefined } function requireComponent(canvasId: string, ref: string): ComponentDef { - const def = findComponent(canvasId, ref) - if (def) return def - const names = store.getComponents(canvasId).map((candidate) => candidate.name) + const def = contextFor(canvasId).find(ref) + if (def && !isDeleted(def)) return def + if (def) + fail( + `“${def.name}” was deleted from this canvas. Its instances keep their look but no longer follow it. Restore it first (restore_component) to use or change it.`, + ) + const names = activeComponents(store.getComponents(canvasId)).map((candidate) => candidate.name) fail(`no component “${ref}” on this canvas${names.length ? ` — it has: ${names.join(', ')}` : ''}`) } @@ -92,21 +149,22 @@ function requireFrame(canvasId: string, frameId: string): Frame { function validName(name: string, canvasId: string, except?: string): string { const clean = name.replace(/["<>]/g, '').trim().slice(0, MAX_COMPONENT_NAME) if (!clean) fail('a component needs a name') - const taken = store - .getComponents(canvasId) - .some((def) => def.id !== except && def.name.toLowerCase() === clean.toLowerCase()) + /* a deleted component does not hold its name: restoring it finds another if it must */ + const taken = activeComponents(store.getComponents(canvasId)).some( + (def) => def.id !== except && def.name.toLowerCase() === clean.toLowerCase(), + ) if (taken) fail(`this canvas already has a component named “${clean}” — update it, or pick another name`) return clean } /** The name itself when no component here has it, else " (library)", * " (library 2)", … so two imports of a shared name stay apart. */ -export function freeName(canvasId: string, name: string): string { - const names = new Set(store.getComponents(canvasId).map((def) => def.name.toLowerCase())) +export function freeName(canvasId: string, name: string, label = 'library'): string { + const names = new Set(activeComponents(store.getComponents(canvasId)).map((def) => def.name.toLowerCase())) if (!names.has(name.toLowerCase())) return name for (let n = 1; ; n++) { /* the suffix always fits: a name at the limit is shortened to make room, then checked */ - const suffix = n === 1 ? ' (library)' : ` (library ${n})` + const suffix = n === 1 ? ` (${label})` : ` (${label} ${n})` const candidate = `${name.slice(0, MAX_COMPONENT_NAME - suffix.length).trimEnd()}${suffix}` if (!names.has(candidate.toLowerCase())) return candidate } @@ -186,23 +244,9 @@ export function validProps(props: unknown): ComponentProp[] { /* Reading */ /* ------------------------------------------------------------------ */ -export interface ComponentUsage { - instances: number - frames: { id: string; name: string; instances: number; approved: boolean }[] -} - -export function usageOf(canvas: Canvas, id: string): ComponentUsage { - const marker = ` ${INSTANCE_ATTR}="${id}"` - const frames = canvas.frames.flatMap((frame) => { - const instances = frame.html.split(marker).length - 1 - return instances - ? [{ id: frame.id, name: frame.name, instances, approved: frame.approval?.status === 'ready_for_dev' }] - : [] - }) - return { instances: frames.reduce((total, frame) => total + frame.instances, 0), frames } -} +export { usageOf, type ComponentUsage } -export function usageExample(def: ComponentDef): string { +export function usageExample(def: Pick): string { const props = def.props .filter((prop) => prop.type !== 'boolean') .slice(0, 4) @@ -212,24 +256,83 @@ export function usageExample(def: ComponentDef): string { return `<${USE_TAG} component="${def.name}"${props}>${slots}` } +/** The catalog of a canvas (or of some of its components): usage for all of them comes from + * one pass over the canvas's frames, not one per component (server/componentUsage.ts). */ +export function catalog( + canvas: Canvas, + defs: ComponentDef[] = activeComponents(canvas.components), + usage = usageByComponent(canvas), +) { + return defs.map((def) => catalogEntry(canvas, def, usage.get(def.id) ?? { instances: 0, frames: [] })) +} + +/** Deleted components something on the canvas still shows: their instances keep their look + * and follow nothing, until the component is restored or they are detached. */ +export function deletedComponentsInUse(canvas: Canvas, usage = usageByComponent(canvas)) { + return (canvas.components ?? []).flatMap((def) => { + const used = isDeleted(def) ? usage.get(def.id) : undefined + return used?.instances + ? [ + { + id: def.id, + name: def.name, + instances: used.instances, + frames: used.frames.length, + deleted_by: def.deletedBy ?? '', + deleted_at: new Date(def.deletedAt ?? def.updatedAt).toISOString(), + }, + ] + : [] + }) +} + /** The one-line catalog entry: little to read, enough to use the component without another call. */ -export function catalogEntry(canvas: Canvas, def: ComponentDef) { +export function catalogEntry(canvas: Canvas, def: ComponentDef, usage = usageOf(canvas, def.id)) { + return { + id: def.id, + name: def.name, + signature: componentSignature(def), + ...(def.description ? { description: def.description } : {}), + usage: usageExample(def), + instances: usage.instances, + ...(def.source?.library ? libraryLink(def) : def.mainFrameId ? {} : { main_missing: true }), + ...(def.code ? { code: def.code } : {}), + ...updateAvailable(canvas, def), + } +} + +/** A component on another canvas, as something to import: what it is and how to + * use it. Not how often it is used there: counting reads that canvas's frame + * HTML, which is loaded per canvas and is not this caller's to load. */ +export function importableEntry(def: ComponentDef) { return { id: def.id, name: def.name, signature: componentSignature(def), ...(def.description ? { description: def.description } : {}), usage: usageExample(def), - instances: usageOf(canvas, def.id).instances, - ...(def.mainFrameId ? {} : { main_missing: true }), ...(def.code ? { code: def.code } : {}), - ...updateAvailable(def), } } -function updateAvailable(def: ComponentDef) { +/** Where a linked component is changed: its library canvas, not here. */ +function libraryLink(def: ComponentDef) { + const canvasId = def.source!.canvasId + return { + library: { + canvas_id: canvasId, + name: store.getCanvas(canvasId)?.name ?? canvasId, + /* the publication this follows; `rev` beside it counts changes on this canvas */ + rev: def.source!.rev, + }, + } +} + +function updateAvailable(canvas: Canvas, def: ComponentDef) { if (!def.source) return {} - const origin = store.getComponents(def.source.canvasId).find((candidate) => candidate.id === def.source?.componentId) + const origin = def.source.library + ? originOf(canvas, def) + : store.getComponents(def.source.canvasId).find((candidate) => candidate.id === def.source?.componentId) return origin && origin.rev > def.source.rev ? { library_update_available: { from_rev: def.source.rev, to_rev: origin.rev, canvas_id: def.source.canvasId } } : {} @@ -244,8 +347,9 @@ export function componentDetail(canvas: Canvas, def: ComponentDef) { ...(info.isSlot ? { slot: attrOf(info.el, SLOT_ATTR) } : {}), ...(info.isUse ? { component: attrOf(info.el, 'component') } : {}), })) + const usage = usageOf(canvas, def.id) return { - ...catalogEntry(canvas, def), + ...catalogEntry(canvas, def, usage), rev: def.rev, props: def.props, slots: def.slots, @@ -255,7 +359,7 @@ export function componentDetail(canvas: Canvas, def: ComponentDef) { parts, main_frame_id: def.mainFrameId, main_image_url: def.mainFrameId ? `/i/${def.mainFrameId}.png?scale=2` : null, - usage_by_frame: usageOf(canvas, def.id).frames, + usage_by_frame: usage.frames, versions: def.history.map((entry) => ({ rev: entry.rev, saved_at: entry.savedAt, saved_by: entry.savedBy })), updated_by: def.updatedBy, updated_at: new Date(def.updatedAt).toISOString(), @@ -279,6 +383,8 @@ export function instancesIn(frame: Frame) { { instance_id: state.instanceId, component: def?.name ?? id, + /* its component was deleted: it keeps its look, follows nothing and takes no props */ + ...(isDeleted(def) ? { component_deleted: true } : {}), component_id: id, props: state.overrides.props ?? {}, overridden_parts: Object.keys(state.overrides.parts ?? {}), @@ -297,7 +403,7 @@ export interface CreateFromElement { props?: ComponentProp[] code?: ComponentCode frameId: string - /** a data-doop-id, or a selector from find_component_candidates */ + /** a data-doop-id, or an element path */ element: string autoProps?: boolean /** also turn every other element of the same shape on the canvas into an instance */ @@ -307,15 +413,29 @@ export interface CreateFromElement { export interface CreateResult { component: ComponentDef converted: { frameId: string; instances: number }[] + /** props named for the author, from what each element is: worth a look, and a rename */ + inferred: string[] + /** replace_matching ran out of work budget part of the way: the component is made and + * `converted` lists what was linked, but frames after those were not looked at */ + matching_stopped?: true } function checkCapacity(canvasId: string) { - if (store.getComponents(canvasId).length >= MAX_COMPONENTS) + if (activeComponents(store.getComponents(canvasId)).length >= MAX_COMPONENTS) fail(`a canvas holds at most ${MAX_COMPONENTS} components`) } -function selectorFor(element: string): string { - return /^[a-z0-9]{6}$/.test(element) ? elementIdSelector(element) : element +/** An element named by its data-doop-id, whatever wrote it (Doop stamps six characters, an + * agent may write "me3-tabbar"), else by an element path (`body > main > section:nth-of-type(2)`). + * Only the six-character form was tried as an id, so an agent's own ids found nothing. */ +function findElement(doc: Tree.Document, element: string): Element | undefined { + const stack: Tree.ChildNode[] = [...doc.childNodes] + for (let node = stack.pop(); node; node = stack.pop()) { + if (!isElement(node)) continue + if (attrOf(node, ELEMENT_ID_ATTR) === element) return node + stack.push(...node.childNodes) + } + return resolveElement(doc, element) } function withinInstance(el: Element): boolean { @@ -329,7 +449,11 @@ function withinInstance(el: Element): boolean { return false } -export function createComponentFromElement(canvasId: string, input: CreateFromElement, actor: Actor): CreateResult { +export const createComponentFromElement = atomic(function createComponentFromElement( + canvasId: string, + input: CreateFromElement, + actor: Actor, +): CreateResult { checkCapacity(canvasId) const name = validName(input.name, canvasId) const props = validProps(input.props) @@ -344,34 +468,41 @@ export function createComponentFromElement(canvasId: string, input: CreateFromEl const shape = shapeOf(el) const def = blankComponent({ name, description: clip(input.description), props, code: input.code, by: actor.name }) - store.saveComponent(canvasId, def) - try { + /* one unit: a write that fails leaves no main-less component holding the name */ + const inferred = transaction(() => { + store.saveComponent(canvasId, def) setAttr(el, COMPONENT_ATTR, def.id) stampParts(el) - if (input.autoProps !== false && !hasBindings(el)) inferBindings(el) + const bound = input.autoProps !== false && !hasBindings(el) ? inferBindings(el) : [] const html = splice(frame.html, [{ start: located.start, end: located.end, text: serializeOuter(el) }]) actions.updateFrame(frame.id, { html }, actor) - } catch (error) { - /* a write that failed leaves no main-less component holding the name */ - store.deleteComponent(canvasId, def.id) - throw error - } + actions.logComponent(canvasId, actor, `made “${requireComponent(canvasId, def.id).name}” a component`) + return bound + }) const saved = requireComponent(canvasId, def.id) - const converted = input.replaceMatching ? convertMatching(canvasId, shape, saved, actor) : [] - actions.logComponent(canvasId, actor, `made “${saved.name}” a component`) - return { component: requireComponent(canvasId, def.id), converted } -} + const matching = input.replaceMatching + ? convertMatching(canvasId, shape, saved, actor) + : { converted: [], stopped: false } + return { + component: requireComponent(canvasId, def.id), + converted: matching.converted, + inferred, + ...(matching.stopped ? { matching_stopped: true as const } : {}), + } +}) const clip = (text: string | undefined) => text?.slice(0, MAX_COMPONENT_DESCRIPTION) function hasBindings(el: Element): boolean { + /* on a it binds nothing, so it is no sign the author named their props */ + if (el.tagName === USE_TAG) return false if (attrOf(el, BIND_ATTR) !== undefined) return true return kidsOf(el).some(hasBindings) } function locate(html: string, element: string) { const doc = parse(html, { sourceCodeLocationInfo: true }) - const el = resolveElement(doc, selectorFor(element)) + const el = findElement(doc, element) const location = el?.sourceCodeLocation return el && location ? { el, start: location.startOffset, end: location.endOffset } : undefined } @@ -386,7 +517,7 @@ ${rawCss} -${root} +${tableScaffold(root)(root)} ` } @@ -403,7 +534,7 @@ function componentsPageId(canvasId: string, actor: Actor): string { } function singleRoot(html: string): Element { - const roots = kidsOf(parseFragment(html.trim())).filter((el) => el.tagName !== 'style' && el.tagName !== 'script') + const roots = kidsOf(rootFragment(html.trim())).filter((el) => el.tagName !== 'style' && el.tagName !== 'script') if (roots.length === 1) return roots[0]! const wrapper = kidsOf(parseFragment(`
${html.trim()}
`))[0] if (!wrapper) fail('html must hold an element') @@ -423,7 +554,11 @@ export interface CreateFromHtml { } /** A new design with nowhere to live yet: its main goes on the Components page, as a frame of its own. */ -export function createComponentFromHtml(canvasId: string, input: CreateFromHtml, actor: Actor): ComponentDef { +export const createComponentFromHtml = atomic(function createComponentFromHtml( + canvasId: string, + input: CreateFromHtml, + actor: Actor, +): CreateResult { checkCapacity(canvasId) const name = validName(input.name, canvasId) const def = blankComponent({ @@ -433,18 +568,39 @@ export function createComponentFromHtml(canvasId: string, input: CreateFromHtml, code: input.code, by: actor.name, }) + /* nothing of a create that fails stays: the definition, the Components page it may have + made and the main's frame are undone together (the unit this function is) */ store.saveComponent(canvasId, def) - try { - const root = singleRoot(input.html) - if (input.autoProps !== false && !hasBindings(root)) inferBindings(root) - setAttr(root, COMPONENT_ATTR, def.id) - writeNewMain(canvasId, def, serializeOuter(root), input.css ?? '', actor, input.width, input.height) - } catch (error) { - store.deleteComponent(canvasId, def.id) - throw error - } + const root = singleRoot(input.html) + const inferred = input.autoProps !== false && !hasBindings(root) ? inferBindings(root) : [] + setAttr(root, COMPONENT_ATTR, def.id) + writeNewMain(canvasId, def, serializeOuter(root), input.css ?? '', actor, input.width, input.height) + const component = requireComponent(canvasId, def.id) + /* the component is made: a note that cannot be worked out within budget is left out */ + if (input.css) optional(() => reportCssNotKept(component, input.css!)) actions.logComponent(canvasId, actor, `created component “${name}”`) - return requireComponent(canvasId, def.id) + return { component, converted: [], inferred } +}) + +const MAX_SELECTORS_NAMED = 8 + +/** Rules handed over as a component's CSS that it did not keep: said in the result of the call + * that passed them, since the main's frame still shows them and nothing else would. */ +function reportCssNotKept(def: ComponentDef, css: string) { + const frame = def.mainFrameId ? store.getFrame(def.mainFrameId) : undefined + const main = frame + ? findMarked(frame.html, COMPONENT_ATTR).find((found) => attrOf(found.el, COMPONENT_ATTR) === def.id) + : undefined + if (!frame || !main) return + const variants = def.props.filter((prop) => prop.type === 'enum').map((prop) => `data-${prop.name}`) + const selectors = unmatchedSelectors(css, main.el, variants) + if (!selectors.length) return + const more = selectors.length - MAX_SELECTORS_NAMED + const named = `${selectors.slice(0, MAX_SELECTORS_NAMED).join(', ')}${more > 0 ? ` and ${more} more` : ''}` + actions.addComponentIssue(frame.id, { + code: 'css_not_kept', + message: `these CSS rules name nothing in “${def.name}” and were not kept: ${named}. A component keeps the rules for its own elements. To restyle a component nested in it, start the selector at one of its own elements (.card .btn), which applies inside this component only; to restyle that component everywhere, update_component it instead.`, + }) } function writeNewMain( @@ -456,11 +612,15 @@ function writeNewMain( width = 480, height = 240, ): Frame { - const pageId = componentsPageId(canvasId, actor) - const frame = actions.createFrame(canvasId, { name: def.name, pageId, width, height, html: '' }, actor) - if (!frame) fail('canvas not found') - actions.updateFrame(frame.id, { html: mainFrameDoc(def, root, rawCss) }, actor) - return store.getFrame(frame.id) ?? frame + /* one unit: when the main cannot be written, its empty frame (and a Components page made + for it) does not stay behind */ + return transaction(() => { + const pageId = componentsPageId(canvasId, actor) + const frame = actions.createFrame(canvasId, { name: def.name, pageId, width, height, html: '' }, actor) + if (!frame) fail('canvas not found') + actions.updateFrame(frame.id, { html: mainFrameDoc(def, root, rawCss) }, actor) + return store.getFrame(frame.id) ?? frame + }) } /* ------------------------------------------------------------------ */ @@ -491,15 +651,51 @@ export interface UpdateResult { frames: { id: string; name: string; instances: number; approved: boolean }[] approvals_affected: number overrides_orphaned: { frame_id: string; instance_id: string; parts: string[] }[] + /** frames with overridden instances that were not examined, because reading them all + * would have used up the operation's work budget: overrides_orphaned may be missing some */ + overrides_unchecked_frames?: number } -} - -function orphanedOverrides(canvas: Canvas, def: ComponentDef, template: string) { + /** How the change reaches the instances in `impact.frames` (absent in a dry run): + * `queued` rewrites them in the background, a frame per tick; `deferred` means the + * server has propagation switched off and each frame follows on its own next write; + * `none` means nothing instances render from changed. */ + propagation?: { status: 'queued' | 'deferred' | 'none'; frames: number } +} + +function propagationOf(canvasId: string, before: ComponentDef, impact: UpdateResult['impact']) { + const after = requireComponent(canvasId, before.id) + const frames = impact.frames.filter((frame) => frame.id !== after.mainFrameId).length + if (actions.propagationPending(canvasId, before.id)) return { status: 'queued' as const, frames } + const moved = after.rev !== before.rev && env.DOOP_DEFER_COMPONENT_PROPAGATION + return moved ? { status: 'deferred' as const, frames } : { status: 'none' as const, frames: 0 } +} + +/** The share of an operation's parse budget the impact report may use: the write it + * precedes needs the rest. */ +const IMPACT_BUDGET_SHARE = 0.25 + +/** Instances whose overrides name a part the new template no longer has. Only frames that + * can hold one are parsed: frames using the component (from the usage index, no scan) whose + * instances either carry an overrides marker or fill a slot / nest a component at a part the + * new template drops. A plain restyle of a component with no overridden instance parses nothing. */ +function orphanedOverrides(canvas: Canvas, def: ComponentDef, template: string, frames: ComponentUsage['frames']) { const keys = new Set(partsOf(template).keys()) + /* content read from the DOM rather than the marker (readInstance): held by every instance */ + const structuralGone = [...partsOf(def.template).entries()].some( + ([key, info]) => (info.isSlot || info.isUse) && !keys.has(key), + ) const ctx = contextFor(canvas.id) const orphaned: UpdateResult['impact']['overrides_orphaned'] = [] - for (const frame of canvas.frames) { - if (!referencesComponent(frame.html, def.id)) continue + const limit = env.DOOP_WORK_BUDGET_PARSE_MB * 1024 * 1024 * IMPACT_BUDGET_SHARE + const spentBefore = workUsage().parsedBytes + let unchecked = 0 + for (const used of frames) { + const frame = store.getFrame(used.id) + if (!frame || (!structuralGone && !frame.html.includes(OVERRIDES_ATTR))) continue + if (limit && workUsage().parsedBytes - spentBefore + frame.html.length > limit) { + unchecked += 1 + continue + } for (const found of findMarked(frame.html, INSTANCE_ATTR)) { if (attrOf(found.el, INSTANCE_ATTR) !== def.id) continue const state = readInstance(found.el, def, ctx) @@ -507,7 +703,7 @@ function orphanedOverrides(canvas: Canvas, def: ComponentDef, template: string) if (state && parts.length) orphaned.push({ frame_id: frame.id, instance_id: state.instanceId, parts }) } } - return orphaned + return { orphaned, unchecked } } /** A rewrite of the main: old element keys carried over wherever tag and place line up, @@ -522,17 +718,31 @@ function alignedRoot(html: string, def: ComponentDef): Element { function nextHtml(def: ComponentDef, input: UpdateInput): string | undefined { if (input.find !== undefined) { const count = def.template.split(input.find).length - 1 - if (count === 0) fail('find text is not in the template — read it with get_component') + if (count === 0) + fail( + def.rawCss.includes(input.find) + ? 'find text is in the CSS, and find + replace works on the template only — pass the whole changed stylesheet as css (get_component returns the current one)' + : 'find text is not in the template — read it with get_component. find + replace works on the template markup only; CSS is replaced whole through css', + ) if (count > 1) fail(`find text occurs ${count} times — include more context so it matches once`) return def.template.replace(input.find, input.replace ?? '') } return input.html } -export function updateComponent(canvasId: string, ref: string, input: UpdateInput, actor: Actor): UpdateResult { +export const updateComponent = atomic(function updateComponent( + canvasId: string, + ref: string, + input: UpdateInput, + actor: Actor, +): UpdateResult { const canvas = store.getCanvas(canvasId) if (!canvas) fail('canvas not found') const def = requireComponent(canvasId, ref) + if (def.source?.library && !input.dryRun) + fail( + `“${def.name}” comes from the workspace library on canvas ${def.source.canvasId}: change it there and publish, then sync_component here. For one instance that must differ, use update_instances.`, + ) if (input.expectedRev !== undefined && input.expectedRev !== def.rev) fail( `component “${def.name}” is at revision ${def.rev}, not ${input.expectedRev} — someone changed it; read it again`, @@ -540,16 +750,24 @@ export function updateComponent(canvasId: string, ref: string, input: UpdateInpu const html = nextHtml(def, input) const nextRoot = html !== undefined ? alignedRoot(html, def) : undefined const usage = usageOf(canvas, def.id) + const overrides = nextRoot + ? orphanedOverrides(canvas, def, stampedTemplate(nextRoot), usage.frames) + : { orphaned: [], unchecked: 0 } const impact: UpdateResult['impact'] = { instances: usage.instances, frames: usage.frames, approvals_affected: usage.frames.filter((frame) => frame.approved).length, - overrides_orphaned: nextRoot ? orphanedOverrides(canvas, def, stampedTemplate(nextRoot)) : [], + overrides_orphaned: overrides.orphaned, + ...(overrides.unchecked ? { overrides_unchecked_frames: overrides.unchecked } : {}), } if (input.dryRun) return { component: def, dry_run: true, impact } const nextProps = input.props !== undefined ? validProps(input.props) : undefined const propsChanged = nextProps !== undefined && JSON.stringify(nextProps) !== JSON.stringify(def.props) + /* this function is one unit (server/journal.ts): a refusal anywhere in it, the work budget + included, undoes the name, props and revision saved below along with the main's write */ + const writesMain = nextRoot !== undefined || input.css !== undefined || input.props !== undefined + const root = writesMain ? (nextRoot ?? alignedRoot(def.template, def)) : undefined const meta: ComponentDef = { ...(propsChanged ? bumpRevision(def, actor.name) : def), ...(input.name !== undefined ? { name: validName(input.name, canvasId, def.id) } : {}), @@ -563,26 +781,38 @@ export function updateComponent(canvasId: string, ref: string, input: UpdateInpu else if (input.code !== undefined) meta.code = input.code store.saveComponent(canvasId, meta) - if (nextRoot || input.css !== undefined || input.props !== undefined) { - const root = nextRoot ?? alignedRoot(def.template, def) - writeMain(canvasId, meta, root, input.css, actor, input.head ? def.head : undefined) + if (root) { + const write = () => writeMain(canvasId, meta, root, input.css, actor, input.head ? def.head : undefined) + /* the props above opened a revision: the main's write is the rest of it, not another */ + if (propsChanged) withinRevision(canvasId, def.id, write) + else write() } else actions.broadcastComponent(canvasId, requireComponent(canvasId, def.id), actor) /* new defaults change what instances render even when the main's markup did not move */ - if (propsChanged) actions.propagateComponents(canvasId, [requireComponent(canvasId, def.id)], actor) + if (propsChanged) actions.queuePropagation(canvasId, [requireComponent(canvasId, def.id)], actor) if (input.name !== undefined && def.mainFrameId && store.getFrame(def.mainFrameId)?.name === def.name) { actions.updateFrame(def.mainFrameId, { name: meta.name }, actor) } + /* the update has landed: a note that cannot be worked out within budget is left out, + never turned into a refusal of what is already done */ + if (input.css) optional(() => reportCssNotKept(requireComponent(canvasId, def.id), input.css!)) actions.logComponent(canvasId, actor, `updated component “${meta.name}”`) - return { component: requireComponent(canvasId, def.id), dry_run: false, impact } -} + return { + component: requireComponent(canvasId, def.id), + dry_run: false, + impact, + propagation: propagationOf(canvasId, def, impact), + } +}) function stampedTemplate(root: Element): string { - const clone = kidsOf(parseFragment(serializeOuter(root)))[0]! + const clone = kidsOf(rootFragment(serializeOuter(root)))[0]! stampParts(clone) return serializeOuter(clone) } /** Put new markup in the main's place, or give the component a new main if it lost it. */ +const leadingTagOf = (markup: string) => /<([a-z][\w-]*)/i.exec(markup)?.[1]?.toLowerCase() ?? 'element' + function writeMain( canvasId: string, def: ComponentDef, @@ -600,7 +830,19 @@ function writeMain( writeNewMain(canvasId, def, rendered, css ?? def.rawCss, actor) return } - let html = splice(frame.html, [{ start: located.start, end: located.end, text: rendered }]) + /* a main that becomes a table part gets a table around it where it stands; one that stops being + one cannot stay in the row that holds it */ + const parent = located.el.parentNode && 'tagName' in located.el.parentNode ? located.el.parentNode.tagName : 'body' + let text = rendered + if (!fitsIn(rendered, parent)) { + /* outside any table a new table can go where the main stood; inside one it would break it */ + if (isTablePart(rendered) && !isTableContext(parent)) text = tableScaffold(rendered)(rendered) + else + fail( + `the main of “${def.name}” sits inside a <${parent}>, which cannot hold a <${leadingTagOf(rendered)}>: keep a root a <${parent}> can hold (it is a <${located.el.tagName}> now), or move the main out of the table first`, + ) + } + let html = splice(frame.html, [{ start: located.start, end: located.end, text }]) if (css !== undefined) html = withSourceCss(html, def.id, css) if (replacedHead) html = withHeadTags(html, replacedHead, def.head) actions.updateFrame(frame.id, { html }, actor) @@ -660,7 +902,7 @@ function useFor(def: ComponentDef, props: Record | undefined, in return useMarkup(def.name, state, def, undefined) } -export function insertInstance( +export const insertInstance = atomic(function insertInstance( canvasId: string, input: InsertInput, actor: Actor, @@ -673,9 +915,10 @@ export function insertInstance( const before = new Set(instanceIds(frame.html)) const next = actions.updateFrame(frame.id, { html }, actor) if (!next) fail('frame not found') - const instanceId = instanceIds(next.html).find((id) => !before.has(id)) ?? '' + /* the instance is placed: if its id cannot be read back within budget, get_frame has it */ + const instanceId = optional(() => instanceIds(next.html).find((id) => !before.has(id))) ?? '' return { frame: next, instanceId } -} +}) function instanceIds(html: string): string[] { return findMarked(html, INSTANCE_ATTR).flatMap((found) => attrOf(found.el, ELEMENT_ID_ATTR) ?? []) @@ -684,7 +927,7 @@ function instanceIds(html: string): string[] { function insertAt(html: string, markup: string, target: string | undefined, position: InstancePosition): string { if (target) { const doc = parse(html, { sourceCodeLocationInfo: true }) - const el = resolveElement(doc, selectorFor(target)) + const el = findElement(doc, target) const location = el?.sourceCodeLocation if (!location) fail(`no element “${target}” in this frame — use a data-doop-id from get_frame`) if (position === 'before') @@ -739,7 +982,7 @@ function applyChange(state: InstanceOverrides, change: InstanceChange): Instance } /** One frame write however many instances change, so the whole batch is one undo step. */ -export function changeInstances( +export const changeInstances = atomic(function changeInstances( canvasId: string, frameId: string, changes: InstanceChange[], @@ -768,6 +1011,10 @@ export function changeInstances( continue } if (!def) continue + if (isDeleted(def)) + fail( + `“${def.name}” was deleted, so this instance no longer follows anything and cannot take props or overrides. Restore the component (restore_component), or detach the instance and edit it as plain markup.`, + ) const state = readInstance(located.el, ctx.atRev(def.id, Number(attrOf(located.el, REV_ATTR))) ?? def, ctx) if (!state) continue validateProps(def, change.props) @@ -783,7 +1030,7 @@ export function changeInstances( const next = html !== frame.html ? actions.updateFrame(frame.id, { html }, actor) : frame if (!next) fail('frame not found') return { frame: next, missing: changes.map((change) => change.instanceId).filter((id) => !seen.has(id)) } -} +}) /** Every instance of one component in this markup, cut loose with its look. */ function detachAll(html: string, def: ComponentDef): { html: string; count: number } { @@ -811,39 +1058,157 @@ function validateProps(def: ComponentDef, props: Record | undefi } } -/** Remove a component; every instance keeps its look as plain markup, and its main stays too. */ -export function deleteComponent(canvasId: string, ref: string, actor: Actor) { +export interface DetachQueued { + /** false when nothing on the canvas uses the component */ + queued: boolean + instances: number + frames: number +} + +/** + * Delete a component, softly: the definition is kept and marked deleted, and NO frame is + * written. Its instances keep the markup they have, byte for byte, and stop following + * anything; new uses are refused; a component built from it keeps rendering as it did. The + * main's markup stays where it is, frozen (an edit to it is an edit to that frame only). + * restoreComponent undoes it. Cutting the instances loose is its own act: detachAllInstances. + */ +export const deleteComponent = atomic(function deleteComponent(canvasId: string, ref: string, actor: Actor) { const canvas = store.getCanvas(canvasId) if (!canvas) fail('canvas not found') + const already = findDeletedComponent(canvasId, ref) + if (already) fail(`“${already.name}” is already deleted — restore_component brings it back`) const def = requireComponent(canvasId, ref) - const dependents = store - .getComponents(canvasId) - .filter((other) => other.id !== def.id && /component="([^"]+)"/.test(other.template)) - .filter((other) => - [...other.template.matchAll(/component="([^"]+)"/g)].some((m) => m[1] === def.id || m[1] === def.name), - ) - if (dependents.length) + const usage = usageOf(canvas, def.id) + const deleted: ComponentDef = { ...def, status: 'deleted', deletedAt: Date.now(), deletedBy: actor.name } + store.saveComponent(canvasId, deleted) + actions.broadcastComponent(canvasId, deleted, actor) + const kept = usage.instances + actions.logComponent( + canvasId, + actor, + `deleted component “${def.name}”${kept ? `; ${kept} instance${kept === 1 ? ' keeps its' : 's keep their'} look` : ''}`, + ) + return { deleted: def.name, component_id: def.id, instances_kept: kept, frames: usage.frames.length } +}) + +export interface RestoreResult { + component: ComponentDef + /** `kept`: its main was still on the canvas; `written`: a new main was made from the + * definition; `none`: it comes from a workspace library and has no main here */ + main: 'kept' | 'written' | 'none' +} + +/** Bring a deleted component back. Its instances were never changed, so they follow it again + * as they are. The main is the markup that still carries its marker if any does (edits made + * to it while the component was deleted become a new revision, like any edit of a main); + * otherwise a main is written from the kept definition. */ +export const restoreComponent = atomic(function restoreComponent( + canvasId: string, + ref: string, + actor: Actor, +): RestoreResult { + const canvas = store.getCanvas(canvasId) + if (!canvas) fail('canvas not found') + const def = findDeletedComponent(canvasId, ref) + if (!def) { + const active = findComponent(canvasId, ref) fail( - `“${def.name}” is used inside ${dependents.map((other) => `“${other.name}”`).join(', ')} — remove it there first`, + active + ? `“${active.name}” is not deleted, so there is nothing to restore` + : `no deleted component “${ref}” on this canvas`, ) - /* gone from the store first, so these writes treat its main as plain markup */ - store.deleteComponent(canvasId, def.id) - let detached = 0 - for (const frame of [...canvas.frames]) { - if (!referencesComponent(frame.html, def.id)) continue - const cut = detachAll(frame.html, def) - detached += cut.count - actions.updateFrame(frame.id, { html: cut.html }, actor) } - actions.broadcastComponentDeleted(canvasId, def.id, actor) + checkCapacity(canvasId) + const marker = `${COMPONENT_ATTR}="${def.id}"` + const remembered = def.mainFrameId ? store.getFrame(def.mainFrameId) : undefined + const home = [remembered, ...canvas.frames].find((frame) => frame?.html.includes(marker)) + const { status: _status, deletedAt: _deletedAt, deletedBy: _deletedBy, ...kept } = def + const active: ComponentDef = { + ...kept, + /* its name may have been given to another component since */ + name: freeName(canvasId, def.name, 'restored'), + mainFrameId: home?.id ?? null, + updatedAt: Date.now(), + updatedBy: actor.name, + } + /* one unit: when no main can be written (the work budget) it stays deleted, not half back */ + store.saveComponent(canvasId, active) + let main: RestoreResult['main'] = 'none' + if (active.source?.library) main = 'none' + else if (home) { + /* an ordinary write of the frame as it is: the main is read again, so what it holds + now and the definition agree, and a difference reaches the instances */ + actions.updateFrame(home.id, { html: home.html }, actor) + main = 'kept' + } else { + writeMain(canvasId, active, alignedRoot(active.template, active), undefined, actor) + main = 'written' + } + const component = requireComponent(canvasId, def.id) + actions.broadcastComponent(canvasId, component, actor) + actions.logComponent(canvasId, actor, `restored component “${component.name}”`) + return { component, main } +}) + +/** Cut every instance of a component loose, keeping its look: plain markup, no longer linked. + * Runs in the background queue, a frame per tick (server/propagation.ts), so it returns + * what it queued, not what it did. For a deleted component this is how its leftovers stop + * being instances; for one in use it leaves the component with none. */ +export function detachAllInstances(canvasId: string, ref: string, actor: Actor): DetachQueued { + const canvas = store.getCanvas(canvasId) + if (!canvas) fail('canvas not found') + const def = findDeletedComponent(canvasId, ref) ?? requireComponent(canvasId, ref) + const usage = usageOf(canvas, def.id) + /* queued with the commit of the operation that asked */ + if (usage.instances) afterCommit(() => propagation.enqueue('detach', canvasId, [def.id], actor)) + return { queued: usage.instances > 0, instances: usage.instances, frames: usage.frames.length } +} + +/** One frame's turn in the detach queue: an ordinary write, so history is filed, sign-off on + * an approved frame goes back to review and the room sees it. */ +function detachInFrame( + canvasId: string, + frameId: string, + componentIds: string[], + actor: Actor, +): propagation.FrameOutcome { + const frame = store.getFrame(frameId) + if (!frame || frame.canvasId !== canvasId) return {} + /* a frame an agent is streaming into is not rewritten under it. The request is kept until + the stream closes (actions.finishStream resumes it), not dropped and not retried meanwhile */ + if (actions.isFrameMidStream(frameId)) return { defer: true } + let html = frame.html + let count = 0 + for (const id of componentIds) { + const def = store.getComponents(canvasId).find((candidate) => candidate.id === id) + if (!def || !referencesComponent(html, id)) continue + const cut = detachAll(html, def) + html = cut.html + count += cut.count + } + if (!count) return {} + const wasApproved = frame.approval?.status === 'ready_for_dev' + const updated = actions.updateFrame(frame.id, { html }, actor) + if (!updated) return {} + return { count, touched: { id: updated.id, name: updated.name, approvalLost: wasApproved } } +} + +function detachDrained(canvasId: string, report: propagation.DrainReport, actor: Actor) { + if (!report.count) return + const names = report.components.flatMap((id) => { + const def = store.getComponents(canvasId).find((candidate) => candidate.id === id) + return def ? [`“${def.name}”`] : [] + }) + const frames = report.frames.length actions.logComponent( canvasId, actor, - `deleted component “${def.name}”; ${detached} instance${detached === 1 ? '' : 's'} kept as plain markup`, + `detached ${report.count} instance${report.count === 1 ? '' : 's'} of ${names.join(', ')} in ${frames} frame${frames === 1 ? '' : 's'}; ${report.count === 1 ? 'it keeps its' : 'they keep their'} look as plain markup`, ) - return { deleted: def.name, instances_detached: detached } } +propagation.registerFrameTask('detach', { frame: detachInFrame, drained: detachDrained }) + /* ------------------------------------------------------------------ */ /* Finding what should be a component */ /* ------------------------------------------------------------------ */ @@ -934,18 +1299,21 @@ function suggestedName(el: Element): string { } /** Repeated structures on a canvas, largest payoff first: what an agent or a person - * should turn into components, typically in a canvas that grew without any. */ -export function findComponentCandidates(canvas: Canvas, limit = 12) { + * should turn into components, typically in a canvas that grew without any. Groups + * under `minOccurrences`, or spread over fewer than `minFrames` frames, never hide the + * repeats inside them. */ +export function findComponentCandidates(canvas: Canvas, limit = 12, minOccurrences = 2, minFrames = 1) { const { shapes, sizes } = collectShapes(canvas) const groups = [...shapes] - .filter(([, occurrences]) => occurrences.length >= 2) + .filter(([, occurrences]) => occurrences.length >= minOccurrences) .map(([shape, occurrences]) => ({ shape, occurrences, size: sizes.get(occurrences[0]!.el) ?? 1 })) .sort((a, b) => b.size * b.occurrences.length - a.size * a.occurrences.length) const covered = new Set() const candidates: ReturnType[] = [] for (const group of groups) { const fresh = group.occurrences.filter((occurrence) => !covered.has(occurrence.el)) - if (fresh.length < 2) continue + if (fresh.length < minOccurrences) continue + if (new Set(fresh.map((occurrence) => occurrence.frame.id)).size < minFrames) continue /* everything inside a repeated block is repeated as well: the block is the finding */ for (const occurrence of fresh) markCovered(occurrence.el, covered) candidates.push(describeCandidate(group.shape, fresh, group.size)) @@ -977,9 +1345,32 @@ function describeCandidate(shape: string, occurrences: Occurrence[], size: numbe function convertMatching(canvasId: string, shape: string | undefined, def: ComponentDef, actor: Actor) { const canvas = store.getCanvas(canvasId) - const template = parseTemplateRoot(def.template) - if (!canvas || !template || !shape) return [] const converted: CreateResult['converted'] = [] + if (!canvas || !shape) return { converted, stopped: false } + /* a sub-commit: the component is made and stays, whatever becomes of the matching */ + checkpoint() + try { + const template = parseTemplateRoot(def.template) + if (!template) return { converted, stopped: false } + convertFrames(canvas, shape, template, def, actor, converted) + } catch (error) { + /* the component exists and the frames so far are linked (each was sub-committed as it + was done): out of budget, the rest is left for another call rather than reported as + a change that never happened */ + if (!(error instanceof WorkBudgetError)) throw error + return { converted, stopped: true } + } + return { converted, stopped: false } +} + +function convertFrames( + canvas: Canvas, + shape: string, + template: Element, + def: ComponentDef, + actor: Actor, + converted: CreateResult['converted'], +) { for (const frame of [...canvas.frames]) { /* a locked frame is not to be edited, however good the reason */ if (frame.demo || frame.locked) continue @@ -1005,8 +1396,9 @@ function convertMatching(canvasId: string, shape: string | undefined, def: Compo /* the next prepare diffs each against the template: differing words become props */ actions.updateFrame(frame.id, { html: splice(frame.html, edits) }, actor) converted.push({ frameId: frame.id, instances: edits.length }) + /* a sub-commit per frame: one that is linked stays linked if a later one is refused */ + checkpoint() } - return converted } function keyLike(el: Element, template: Element) { @@ -1031,7 +1423,7 @@ function newId(): string { /** Elements on a frame that look exactly like an existing component but are not instances of it. */ export function lookalikesIn(frame: Frame): { component: string; occurrences: number; usage: string }[] { - const defs = store.getComponents(frame.canvasId).filter((def) => def.template) + const defs = activeComponents(store.getComponents(frame.canvasId)).filter((def) => def.template) if (!defs.length) return [] const shapes = new Map( defs.flatMap((def) => { @@ -1073,14 +1465,50 @@ export function importComponent( ref: string, actor: Actor, ): ComponentDef { + const target = store.getCanvas(targetCanvasId) + if (!target) fail('canvas not found') + const shared = librariesForCanvas(target).find((library) => library.canvasId === sourceCanvasId) + if (shared) return useLibraryComponent(target, sourceCanvasId, ref, actor) const origin = findComponent(sourceCanvasId, ref) if (!origin) fail(`no component “${ref}” on canvas ${sourceCanvasId}`) refuseSiblings(targetCanvasId, sourceCanvasId, origin) - const ctxIds = new Set() - importDependencies(targetCanvasId, sourceCanvasId, origin, actor, ctxIds) + const progress: ImportProgress = { seen: new Set(), pending: [], kept: [] } + try { + /* one unit: what is not sub-committed below is undone when the import is refused */ + transaction(() => importDependencies(targetCanvasId, sourceCanvasId, origin, actor, progress)) + } catch (error) { + throw afterImportRefusal(progress, error) + } return requireComponent(targetCanvasId, origin.id) } +/** What an import has done so far, so a refusal part of the way can be told truly. */ +interface ImportProgress { + seen: Set + /** what it has done since its last sub-commit: undone if it is refused now */ + pending: string[] + /** what its sub-commits have made permanent */ + kept: string[] +} + +/** A component already here was brought up to date: a complete update, which stays whatever + * happens next. The sub-commit keeps everything done before it too (the components this + * import made on the way are what the update is built from), so a refusal later leaves a + * consistent prefix, and running the import again continues from it. */ +function keepImportProgress(progress: ImportProgress) { + progress.kept.push(...progress.pending) + progress.pending = [] + checkpoint() +} + +/** An import of several components ran out of work budget. What it had sub-committed stays, + * and the error says so; everything after that was undone by its write boundary, so an + * import that only makes new components lands whole or not at all. */ +function afterImportRefusal(progress: ImportProgress, error: unknown): unknown { + if (!(error instanceof WorkBudgetError) || !progress.kept.length) return error + return error.afterPartialWork(progress.kept.join(', ')) +} + /** A canvas and its copies share component ids. The same id here, not pulled from this library, * is this canvas's own component: importing over it would replace its main and every instance. * Checked for the whole set before anything is written, so a refusal leaves nothing half imported. */ @@ -1097,7 +1525,7 @@ function refuseSiblings(targetCanvasId: string, sourceCanvasId: string, origin: `this canvas already has its own component “${existing.name}” (${existing.id}), shared with canvas ${sourceCanvasId} because one was copied from the other; importing would replace it, so edit it here instead`, ) for (const match of def.template.matchAll(/component="([^"]+)"/g)) { - const dependency = findComponent(sourceCanvasId, match[1]!) + const dependency = contextFor(sourceCanvasId).find(match[1]!) if (dependency) stack.push(dependency) } } @@ -1108,19 +1536,43 @@ function importDependencies( sourceCanvasId: string, origin: ComponentDef, actor: Actor, - seen: Set, + progress: ImportProgress, ): boolean { - if (seen.has(origin.id)) return false - seen.add(origin.id) + if (progress.seen.has(origin.id)) return false + progress.seen.add(origin.id) let changed = false for (const match of origin.template.matchAll(/component="([^"]+)"/g)) { - const dependency = findComponent(sourceCanvasId, match[1]!) - if (dependency && importDependencies(targetCanvasId, sourceCanvasId, dependency, actor, seen)) changed = true + /* deleted ones too: a component built from a deleted one still renders it, frozen */ + const dependency = contextFor(sourceCanvasId).find(match[1]!) + if (dependency && importDependencies(targetCanvasId, sourceCanvasId, dependency, actor, progress)) changed = true } const existing = store.getComponents(targetCanvasId).find((def) => def.id === origin.id) + if (!existing && isDeleted(origin)) { + /* deleted at its source: copied as it stands, still deleted and with no main, so it is + there for what is built from it to render and not to be used by itself */ + const now = Date.now() + const frozen: ComponentDef = { + ...origin, + rawCss: importedCss(targetCanvasId, sourceCanvasId, origin), + mainFrameId: null, + history: [], + source: { canvasId: sourceCanvasId, componentId: origin.id, rev: origin.rev }, + createdAt: now, + updatedAt: now, + updatedBy: actor.name, + } + store.saveComponent(targetCanvasId, frozen) + progress.pending.push(`“${frozen.name}” imported`) + actions.broadcastComponent(targetCanvasId, frozen, actor) + return true + } if (existing) { + /* deleted here: frozen, whatever its origin has become */ + if (isDeleted(existing)) return changed if (existing.source?.canvasId === sourceCanvasId && existing.source.rev === origin.rev) return changed pullFrom(targetCanvasId, existing, origin, sourceCanvasId, actor) + progress.pending.push(`“${existing.name}” updated`) + keepImportProgress(progress) return true } checkCapacity(targetCanvasId) @@ -1133,9 +1585,10 @@ function importDependencies( source: { canvasId: sourceCanvasId, componentId: origin.id, rev: origin.rev }, by: actor.name, }) - store.saveComponent(targetCanvasId, { ...def, head: origin.head }) const root = parseTemplateRoot(origin.template) if (!root) fail(`component “${origin.name}” has no markup`) + store.saveComponent(targetCanvasId, { ...def, head: origin.head }) + progress.pending.push(`“${def.name}” imported`) setAttr(root, COMPONENT_ATTR, def.id) writeNewMain( targetCanvasId, @@ -1178,10 +1631,532 @@ function pullFrom( export function syncComponent(canvasId: string, ref: string, actor: Actor, canRead: (canvasId: string) => boolean) { const def = requireComponent(canvasId, ref) if (!def.source) fail(`“${def.name}” was not imported from a library`) + if (def.source.library) { + const { component, updated } = pullFromLibrary(canvasId, def, actor) + return { component, updated } + } if (!canRead(def.source.canvasId)) fail('this account cannot read that library canvas') const origin = findComponent(def.source.canvasId, def.source.componentId) if (!origin) fail('its library no longer has this component') /* the whole tree: a nested component can move without this one moving, and this one can start using new ones */ - const updated = importDependencies(canvasId, def.source.canvasId, origin, actor, new Set()) + const progress: ImportProgress = { seen: new Set(), pending: [], kept: [] } + const source = def.source.canvasId + let updated: boolean + try { + updated = transaction(() => importDependencies(canvasId, source, origin, actor, progress)) + } catch (error) { + throw afterImportRefusal(progress, error) + } return { component: requireComponent(canvasId, def.id), updated } } + +/* ------------------------------------------------------------------ */ +/* Workspace libraries: published once, used on every canvas there. */ +/* Spec: .context/specs/workspace-component-library.md. */ +/* ------------------------------------------------------------------ */ + +function requireLibraryPlan(canvas: Canvas, doing: string) { + const block = libraryBlock(canvas) + if (!block) return + if (block.reason === 'no_workspace') + throw new LibraryPlanError( + `${doing} needs this canvas to be in a workspace: shared component libraries are part of the Team plan. Tell the person, who can move the canvas into a workspace from Home.`, + ) + throw new LibraryPlanError( + `${doing} needs this canvas's workspace to be on the Team plan. Tell the person, who can upgrade it from the workspace's billing page.`, + block.workspaceId, + ) +} + +/** Whether the workspace's publish setting lets this person publish from the + * canvas (true where there is no workspace: the plan check speaks there). */ +export function mayPublishFrom(canvas: Pick, userId: string | undefined): boolean { + return !canvas.workspaceId || mayPublishLibrary(canvas.workspaceId, userId) +} + +/** The one gate on who publishes and withdraws: REST, MCP and the resident + * agent all reach the library through the two functions that call it. */ +function requireLibraryPublisher(canvas: Canvas, userId: string | undefined) { + if (mayPublishFrom(canvas, userId)) return + throw new LibraryPublisherError( + "Publishing to this workspace's library is limited to its owner and admins. One of them can publish this, or change who may publish in the workspace's General settings.", + ) +} + +/** A published component as the catalog lists it, ready to use by name. */ +export function libraryEntry(snapshot: LibraryComponent) { + return { + id: snapshot.id, + name: snapshot.name, + signature: componentSignature(snapshot), + ...(snapshot.description ? { description: snapshot.description } : {}), + usage: usageExample(snapshot), + /* the publication's version: what a preview of it is keyed by */ + rev: snapshot.rev, + ...(snapshot.code ? { code: snapshot.code } : {}), + } +} + +/** What the canvas's workspace libraries publish that it does not use yet. */ +export function libraryCatalog(canvas: Canvas) { + const linked = new Set( + (canvas.components ?? []).flatMap((def) => (def.source?.library ? [`${def.source.canvasId}:${def.id}`] : [])), + ) + return librariesForCanvas(canvas).flatMap((library) => { + const components = library.components.filter((entry) => !linked.has(`${entry.canvasId}:${entry.id}`)) + return components.length + ? [{ canvas_id: library.canvasId, canvas_name: library.name, components: components.map(libraryEntry) }] + : [] + }) +} + +/** Take a published component up on this canvas (a no-op when it already is). */ +export const useLibraryComponent = atomic(function useLibraryComponent( + canvas: Canvas, + libraryCanvasId: string, + ref: string, + actor: Actor, +): ComponentDef { + requireLibraryPlan(canvas, 'Using a library component') + const snapshot = findInLibraries(canvas, ref).find((entry) => entry.canvasId === libraryCanvasId) + if (!snapshot) { + const names = publishedOn(libraryCanvasId).map((entry) => entry.name) + fail( + `that library does not publish “${ref}”${names.length ? ` — it publishes: ${names.join(', ')}` : ''}. Its owner may need to publish it first.`, + ) + } + try { + actions.announceAdopted(canvas.id, adoptFromLibrary(canvas.id, snapshot, actor.name), actor) + } catch (error) { + if (error instanceof LibraryAdoptError) fail(error.message) + throw error + } + return requireComponent(canvas.id, snapshot.id) +}) + +/** A linked definition takes its library's published state: a new revision here, + * carried to every instance like any change to a main. */ +function relink(canvasId: string, def: ComponentDef, snapshot: LibraryComponent, actor: Actor): ComponentDef { + const bumped = bumpRevision(def, actor.name) + const next: ComponentDef = { + ...bumped, + /* a link's revision is the publication it shows, so a frame's markers and the + library agree on the number; never below the next local one, for links + made before the two were kept together */ + rev: Math.max(bumped.rev, snapshot.rev), + description: snapshot.description, + template: snapshot.template, + css: snapshot.css, + rawCss: snapshot.rawCss, + head: snapshot.head, + props: snapshot.props, + slots: snapshot.slots, + source: { canvasId: snapshot.canvasId, componentId: snapshot.id, rev: snapshot.rev, library: true }, + } + if (snapshot.code) next.code = snapshot.code + else delete next.code + store.saveComponent(canvasId, next) + return next +} + +/** `quiet` leaves the activity line to the caller (updateLibraryConsumers writes one per canvas). */ +const pullFromLibrary = atomic(function pullFromLibrary( + canvasId: string, + def: ComponentDef, + actor: Actor, + quiet: boolean = false, +) { + const canvas = store.getCanvas(canvasId) + if (!canvas) fail('canvas not found') + const origin = originOf(canvas, def) + if (!origin) fail(`its library no longer publishes “${def.name}”; it stays as it is here`) + /* the whole tree: a nested component can move without this one moving, and this one can start using new ones */ + const closure = snapshotClosure(origin) + /* all of it fits, or none of it is written: a pull refused half way would leave + some definitions on the new publication and their instances on the old one */ + const before = store.getComponents(canvasId) + let missing = 0 + for (const snapshot of closure) { + const local = before.find((candidate) => candidate.id === snapshot.id) + if (!local) missing += 1 + else if (!local.source?.library || local.source.canvasId !== snapshot.canvasId) + fail( + `this update is built from “${snapshot.name}”, and this canvas has a component of its own under that id (“${local.name}”, ${local.id}; one canvas was copied from the other), so nothing was changed. Rename is not enough: detach or delete that component here first, or keep the version this canvas has.`, + ) + } + if (before.length + missing > MAX_COMPONENTS) + fail( + `this update needs ${missing} more component${missing === 1 ? '' : 's'}, and a canvas holds at most ${MAX_COMPONENTS}; nothing was changed`, + ) + const changed: ComponentDef[] = [] + const added: ComponentDef[] = [] + for (const snapshot of closure) { + const local = store.getComponents(canvasId).find((candidate) => candidate.id === snapshot.id) + if (!local) { + try { + added.push(...adoptFromLibrary(canvasId, snapshot, actor.name)) + } catch (error) { + if (error instanceof LibraryAdoptError) fail(error.message) + throw error + } + } else if ( + /* a component this canvas deleted is frozen at the design it had: a pull of what is + built from it (or of anything else) leaves its template, CSS and revision alone */ + !isDeleted(local) && + local.source?.library && + local.source.canvasId === snapshot.canvasId && + local.source.rev < snapshot.rev + ) + changed.push(relink(canvasId, local, snapshot, actor)) + } + actions.announceAdopted(canvasId, added, actor) + let frames: actions.PropagationReport['frames'] = [] + if (changed.length) { + /* before the instances are rewritten, so each frame's token block has what the new CSS names */ + actions.carryLibraryTokens(canvasId, changed, actor) + frames = framesUsing( + canvas, + changed.map((entry) => entry.id), + ) + actions.queuePropagation(canvasId, changed, actor) + if (!quiet) + actions.logComponent( + canvasId, + actor, + `updated ${changed.map((entry) => `“${entry.name}”`).join(', ')} from the workspace library`, + ) + } + return { + component: requireComponent(canvasId, def.id), + updated: changed.length > 0 || added.length > 0, + /* what moved, for a caller reporting on it */ + changed: changed.map((entry) => entry.name), + /* the frames queued to follow: they are rewritten in the background, one per tick */ + frames, + } +}) + +/** The frames holding an instance of any of these components: what a change to them is + * queued for. Following a component keeps a frame's sign-off. */ +function framesUsing(canvas: Canvas, componentIds: string[]): actions.PropagationReport['frames'] { + const frames = new Map() + for (const id of componentIds) + for (const frame of usageOf(canvas, id).frames) + frames.set(frame.id, { id: frame.id, name: frame.name, approvalLost: false }) + return [...frames.values()] +} + +export interface LibraryStatus { + /** whether this canvas has published anything */ + library: boolean + changes: LibraryChangeEntry[] + published_at?: number + published_by?: string +} + +/** A canvas as a library: what it has published and what publishing now would change. */ +export function libraryStatus(canvas: Canvas): LibraryStatus { + const snapshots = publishedOn(canvas.id) + const latest = snapshots.reduce( + (newest, entry) => (!newest || entry.publishedAt > newest.publishedAt ? entry : newest), + undefined, + ) + return { + library: isLibrary(canvas.id), + changes: libraryChanges(canvas), + ...(latest ? { published_at: latest.publishedAt, published_by: latest.publishedBy } : {}), + } +} + +/** The workspace's canvases using what this library publishes, and which of their + * links are behind its latest publication: where a publish still has to be pulled. */ +export function libraryConsumers(canvas: Canvas) { + if (!canvas.workspaceId) return [] + const snapshots = publishedOn(canvas.id) + return store.allCanvases().flatMap((other) => { + if (other.id === canvas.id || other.workspaceId !== canvas.workspaceId) return [] + const linked = activeComponents(other.components).filter( + (def) => def.source?.library && def.source.canvasId === canvas.id, + ) + if (!linked.length) return [] + const behind = linked.filter((def) => { + const snapshot = snapshots.find((entry) => entry.id === def.source?.componentId) + return !!snapshot && snapshot.rev > (def.source?.rev ?? 0) + }) + return [ + { + canvas_id: other.id, + canvas_name: other.name, + components: linked.map((def) => def.name), + ...(behind.length ? { update_waiting: behind.map((def) => def.name) } : {}), + }, + ] + }) +} + +/** The linked components on a canvas whose library has published something newer. */ +export function waitingLibraryUpdates(canvas: Canvas): ComponentDef[] { + return activeComponents(canvas.components).filter((def) => { + const origin = originOf(canvas, def) + return !!origin && !!def.source && origin.rev > def.source.rev + }) +} + +/** Publish this canvas's components to its workspace: all of them, or the ones named + * (each with what it is built from). Other canvases see an update and pull it when they choose. + * `publisherId` is the account acting (the agent's person, for an agent), checked against the + * workspace's publish setting; a dry run is checked too, so an agent hears the refusal first. */ +export const publishToLibrary = atomic(function publishToLibrary( + canvasId: string, + refs: readonly string[] | undefined, + actor: Actor, + publisherId: string | undefined, + dryRun: boolean = false, +) { + const canvas = store.getCanvas(canvasId) + if (!canvas) fail('canvas not found') + requireLibraryPlan(canvas, 'Publishing a library') + requireLibraryPublisher(canvas, publisherId) + const ids = refs?.map((ref) => { + const def = requireComponent(canvasId, ref) + if (def.source?.library) + fail(`“${def.name}” comes from another library and is published there, not from this canvas`) + if (!publishable(def)) fail(`“${def.name}” has no design yet, so there is nothing to publish`) + return def.id + }) + if (!ids && !(canvas.components ?? []).some(publishable) && !isLibrary(canvasId)) + fail('this canvas has no components of its own to publish — make one with create_component first') + const result = writeLibrary(canvas, ids, actor.name, dryRun) + if (!dryRun && (result.published.length || result.removed.length)) { + const count = result.published.length + actions.logComponent( + canvasId, + actor, + count + ? `published ${count} component${count === 1 ? '' : 's'} to the workspace library` + : 'removed components from the workspace library', + ) + actions.broadcastLibrary(canvas, actor) + } + return { dry_run: dryRun, ...result, library: libraryStatus(canvas) } +}) + +/** Stop offering this canvas's components to the workspace. Nothing changes on canvases using them. */ +export const unpublishFromLibrary = atomic(function unpublishFromLibrary( + canvasId: string, + refs: readonly string[] | undefined, + actor: Actor, + publisherId: string | undefined, +) { + const canvas = store.getCanvas(canvasId) + if (!canvas) fail('canvas not found') + requireLibraryPublisher(canvas, publisherId) + const ids = refs?.map( + (ref) => publishedOn(canvasId).find((entry) => entry.id === ref || entry.name === ref)?.id ?? ref, + ) + const gone = dropLibrary(canvasId, ids) + if (gone.length) { + actions.logComponent( + canvasId, + actor, + `stopped sharing ${gone.length} component${gone.length === 1 ? '' : 's'} with the workspace`, + ) + actions.broadcastLibrary(canvas, actor) + } + return { unpublished: gone.map((entry) => ({ id: entry.id, name: entry.name })), library: libraryStatus(canvas) } +}) + +/* ---- update everywhere: the one way a publication is pushed ---- */ + +export interface LibraryUpdateOptions { + /** report what would change and change nothing */ + dryRun?: boolean + /** may the acting account change that canvas? one it may not is skipped and reported */ + canEdit: (canvasId: string) => boolean + /** may it open that canvas? one it may not is reported without its id and name */ + canRead: (canvasId: string) => boolean + /** who is acting: where a workspace keeps publishing to its owner and admins, + * sending a library's changes to every canvas is theirs too */ + publisherId: string | undefined +} + +export interface LibraryConsumerUpdate { + canvas_id: string + canvas_name: string + /** the linked components brought up to the publication */ + updated: string[] + /** frames rewritten; in a dry run, the frames holding an instance of what would update */ + frames_changed: number + /** always 0: a frame following its components keeps its sign-off (2026-11-12). Kept so + * readers of the report do not break */ + approvals_withdrawn: number +} + +export interface LibrarySkippedConsumer { + /** absent for a canvas the account cannot open */ + canvas_id?: string + canvas_name?: string + reason: 'no_edit_access' | 'failed' + message: string +} + +export interface LibraryUpdateReport { + dry_run: boolean + library: { canvas_id: string; canvas_name: string } + canvases: LibraryConsumerUpdate[] + skipped: LibrarySkippedConsumer[] +} + +/** The links on a canvas that pulling this library's publication would move: the ones + * behind it and, as pullFromLibrary walks them, whatever they are built from that is behind too. */ +function staleLinks(canvas: Canvas, libraryCanvasId: string): ComponentDef[] { + const stale = new Map() + for (const def of waitingLibraryUpdates(canvas)) { + const origin = def.source?.canvasId === libraryCanvasId ? originOf(canvas, def) : undefined + if (!origin) continue + for (const snapshot of snapshotClosure(origin)) { + const local = (canvas.components ?? []).find((candidate) => candidate.id === snapshot.id) + if ( + local && + !isDeleted(local) && + local.source?.library && + local.source.canvasId === snapshot.canvasId && + local.source.rev < snapshot.rev + ) + stale.set(local.id, local) + } + } + return [...stale.values()] +} + +function previewConsumerUpdate(canvas: Canvas, libraryCanvasId: string): LibraryConsumerUpdate | undefined { + const stale = staleLinks(canvas, libraryCanvasId) + if (!stale.length) return undefined + const frames = new Map() + for (const def of stale) for (const frame of usageOf(canvas, def.id).frames) frames.set(frame.id, false) + return { + canvas_id: canvas.id, + canvas_name: canvas.name, + updated: stale.map((def) => def.name), + frames_changed: frames.size, + approvals_withdrawn: [...frames.values()].filter(Boolean).length, + } +} + +/** Pull the library's publication into one loaded canvas. A refusal part of the way + * leaves what was already pulled in place, so both halves are returned. */ +function pullIntoConsumer(canvas: Canvas, library: Canvas, actor: Actor) { + const updated = new Set() + const frames = new Map() + let refusal: string | undefined + try { + for (const def of waitingLibraryUpdates(canvas)) { + if (def.source?.canvasId !== library.id) continue + const pulled = pullFromLibrary(canvas.id, def, actor, true) + for (const name of pulled.changed) updated.add(name) + for (const frame of pulled.frames) frames.set(frame.id, frame.approvalLost || frames.get(frame.id) === true) + } + } catch (error) { + if (!(error instanceof ComponentError)) throw error + refusal = error.message + } + if (updated.size) + actions.logComponent( + canvas.id, + actor, + `updated ${[...updated].map((name) => `“${name}”`).join(', ')} from the workspace library “${library.name}”, which was updated on every canvas using it`, + ) + const update: LibraryConsumerUpdate | undefined = updated.size + ? { + canvas_id: canvas.id, + canvas_name: canvas.name, + updated: [...updated], + frames_changed: frames.size, + approvals_withdrawn: [...frames.values()].filter(Boolean).length, + } + : undefined + return { update, refusal } +} + +/** Bring every canvas of the workspace that uses this library up to its latest + * publication, in one step. Publishing never does this: it is its own act, by someone + * who may edit each canvas it changes, and it reports canvas by canvas what it did. + * Each pull is the ordinary one (pullFromLibrary): history is filed, approved frames + * keep their sign-off and the canvas's room is told. + * + * Frame HTML is loaded per canvas (store.load), and a pull reads and rewrites the + * consumer's frames, so each consumer is loaded and held while it is worked on: one + * at a time, so a workspace of many canvases is never all in memory for this. */ +export async function updateLibraryConsumers( + libraryCanvasId: string, + actor: Actor, + options: LibraryUpdateOptions, +): Promise { + const library = store.getCanvas(libraryCanvasId) + if (!library) fail('canvas not found') + requireLibraryPlan(library, 'Updating the canvases that use a library') + requireLibraryPublisher(library, options.publisherId) + if (!isLibrary(library.id)) + fail('this canvas has not published a library, so no canvas follows it — publish_library comes first') + const report: LibraryUpdateReport = { + dry_run: options.dryRun === true, + library: { canvas_id: library.id, canvas_name: library.name }, + canvases: [], + skipped: [], + } + for (const consumer of libraryConsumers(library)) { + if (!consumer.update_waiting) continue + const named = options.canRead(consumer.canvas_id) + ? { canvas_id: consumer.canvas_id, canvas_name: consumer.canvas_name } + : {} + if (!options.canEdit(consumer.canvas_id)) { + report.skipped.push({ + ...named, + reason: 'no_edit_access', + message: 'this account may not edit that canvas; someone who can has to pull the update there', + }) + continue + } + const canvas = await store.load(consumer.canvas_id) + /* deleted, or moved out of the workspace, while an earlier canvas was being read */ + if (!canvas) continue + const release = store.hold(canvas.id) + try { + if (report.dry_run) { + const preview = previewConsumerUpdate(canvas, library.id) + if (preview) report.canvases.push(preview) + continue + } + const { update, refusal } = pullIntoConsumer(canvas, library, actor) + /* a sub-commit per canvas: its pull is sent and its frames enter the queue now, before + the wait below (which would otherwise wait on a queue nothing has reached yet), and + a canvas that is done stays done if a later one is refused */ + checkpoint() + if (update) { + /* the pull only queued its frames: wait here, canvas held, for what it really changed. + The wait blocks nothing (the queue works a frame per tick), and keeps the canvases + this walks through in memory one at a time. */ + const drained = (await propagation.whenCanvasIdle(canvas.id)).propagate + report.canvases.push({ + ...update, + frames_changed: drained?.frames.length ?? 0, + approvals_withdrawn: drained?.frames.filter((frame) => frame.approvalLost).length ?? 0, + }) + } + if (refusal) report.skipped.push({ ...named, reason: 'failed', message: refusal }) + } finally { + release() + } + } + if (!report.dry_run && report.canvases.length) { + const count = report.canvases.length + actions.logComponent( + library.id, + actor, + `updated ${count} canvas${count === 1 ? '' : 'es'} to this library’s latest publication`, + ) + /* the library's own panel counts who is behind: it reads again */ + actions.broadcastLibrary(library, actor) + } + return report +} diff --git a/server/componentCss.ts b/server/componentCss.ts index de2d60a14..a01104a3a 100644 --- a/server/componentCss.ts +++ b/server/componentCss.ts @@ -1,4 +1,6 @@ -import { parse, serializeOuter, type DefaultTreeAdapterTypes as Tree } from 'parse5' +import { serializeOuter, type DefaultTreeAdapterTypes as Tree } from 'parse5' +import { parse } from './workBudget.ts' +import { elementIs } from './parse5Select.ts' import { CSS_ATTR, DETACHED_CSS_ATTR, HEAD_ATTR, INSTANCE_ATTR } from '../shared/components.ts' import { TOKEN_BLOCK_ATTR } from '../shared/designTokens.ts' import { FONT_BLOCK_ATTR } from '../shared/fonts.ts' @@ -239,16 +241,44 @@ function compoundMatches(compound: string, tokens: Tokens): boolean { ) } +/** What a main is made of: its own elements, and apart from them the components nested in it; + * and the elements it sits in, nearest first. */ +interface SubtreeTokens { + own: Tokens + nested: Tokens + ancestors: Element[] +} + +/** A selected subtree: the selector as far as it concerns it, and a condition on the document + * it keeps (a theme), to be written before the scope. */ +interface Relevant { + selector: string + prefix: string +} + /** The selector as far as it concerns the subtree: compounds naming ancestors outside it are cut off. - * Null when its subject is not in the subtree at all. */ -function relevantSelector(selector: string, tokens: Tokens): string | null { + * Null when its subject is not in the subtree at all. A subject inside a nested component counts + * only when the selector reaches it from one of the main's own elements (`.plan .btn`): that is + * this component restyling what it holds, where a bare `.btn` is the nested component's business. */ +function relevantSelector(selector: string, { own, nested, ancestors }: SubtreeTokens): Relevant | null { const compounds = compoundsOf(selector) - const last = compounds[compounds.length - 1] - if (!last || !compoundMatches(last.compound, tokens)) return null + if (!compounds.length) return null + const isOwn = (index: number) => compoundMatches(compounds[index]!.compound, own) + const isNested = (index: number) => compoundMatches(compounds[index]!.compound, nested) let first = compounds.length - 1 - while (first > 0 && compoundMatches(compounds[first - 1]!.compound, tokens)) first-- - return compounds - .slice(first) + if (!isOwn(first)) { + if (!isNested(first)) return null + while (first > 0 && !isOwn(first - 1) && isNested(first - 1)) first-- + if (first === 0 || !isOwn(first - 1)) return null + } + while (first > 0 && isOwn(first - 1)) first-- + const prefix = keptAncestors(compounds, first, ancestors) + if (prefix === null) return null + return { selector: joinCompounds(compounds.slice(first)), prefix } +} + +function joinCompounds(pieces: { compound: string; combinator: string }[]): string { + return pieces .map((piece, index) => { if (index === 0) return piece.compound return piece.combinator === ' ' ? ` ${piece.compound}` : ` ${piece.combinator} ${piece.compound}` @@ -256,11 +286,62 @@ function relevantSelector(selector: string, tokens: Tokens): string | null { .join('') } +/** + * The compounds before `first` name what the main sits in: the rule is how the main looks + * there, and they are cut, when its ancestors meet them (matched by css-select, values and all; + * `>` asks it of the main's parent). When they do not (`.login__card h2` for a main outside any + * card) the rule is someone else's: null. A theme condition that does not hold now, wherever + * it sits (`html.dark .bar`, `.shell [data-doop-theme="dark"] .bar`), stays as the rule's + * condition when the rest holds; the rest is cut: the prefix returned. A sibling (`+`, `~`) is + * not checked, as it never was. + */ +function keptAncestors( + compounds: { compound: string; combinator: string }[], + first: number, + ancestors: Element[], +): string | null { + if (first === 0) return '' + const joiner = compounds[first]!.combinator + if (joiner === '+' || joiner === '~') return '' + const candidates = joiner === '>' ? ancestors.slice(0, 1) : ancestors + const meets = (pieces: { compound: string; combinator: string }[]) => + candidates.some((el) => elementIs(el, joinCompounds(pieces))) + const named = compounds.slice(0, first) + if (meets(named)) return '' + const themeless = named.map((piece) => ({ ...piece, compound: withoutTheme(piece.compound) })) + const themes = named.flatMap((piece, index) => (piece.compound !== themeless[index]!.compound ? [index] : [])) + if (!themes.length || !meets(themeless)) return null + /* only the theme stays a condition: the wrappers around it are where the main sits, cut like + any. Two themes side by side keep how they were joined (`>` stays `>`) */ + return themes + .map((at, index) => { + const compound = named[at]!.compound + if (index === 0) return compound + const joiner = themes[index - 1] === at - 1 ? named[at]!.combinator : ' ' + return joiner === ' ' ? ` ${compound}` : ` ${joiner} ${compound}` + }) + .join('') +} + +/* a theme is a state the document or a part of it switches into: what the main shows now is + one of its themes, so a condition on another one is kept, not tested */ +const THEME_ATTRIBUTE = /\[\s*data-doop-theme\b(?:[^\]"']|"[^"]*"|'[^']*')*\]/gi +const DOCUMENT_ROOT = /^(?::root|html|body)(?![\w-])/i + +function withoutTheme(compound: string): string { + const bare = compound.replace(THEME_ATTRIBUTE, '') + const root = DOCUMENT_ROOT.exec(bare)?.[0] + /* html.dark, :root[data-mode]: the document is always there, its classes are a theme too */ + if (root) return root + return bare || '*' +} + /** A selector scoped to the instance root: at or below it, its pseudo-classes left in place. */ -export function scopeSelector(selector: string, scope: string): string { +export function scopeSelector(selector: string, scope: string, prefix = ''): string { const where = `:where(${scope})` const lead = /^(\*|[a-zA-Z][\w-]*)?((?:[.#](?:[\w\u0080-\uffff-]|\\.)+|\[[^\]]*\])*)/.exec(selector)?.[0] ?? '' - return `${where} ${selector}, ${lead}${where}${selector.slice(lead.length)}` + const before = prefix ? `${prefix} ` : '' + return `${before}${where} ${selector}, ${before}${lead}${where}${selector.slice(lead.length)}` } function isDocumentSelector(selector: string): boolean { @@ -284,23 +365,62 @@ function walkElements(node: Tree.ParentNode, visit: (el: Element) => void) { } } -function tokensOf(root: Element, skip: (el: Element) => boolean): Tokens { - const tokens: Tokens = { tags: new Set(), classes: new Set(), ids: new Set(), attrs: new Set() } - const add = (el: Element) => { - tokens.tags.add(el.tagName.toLowerCase()) - for (const attr of el.attrs) { - tokens.attrs.add(attr.name.toLowerCase()) - if (attr.name === 'class') for (const name of attr.value.split(/\s+/)) if (name) tokens.classes.add(name) - if (attr.name === 'id') tokens.ids.add(attr.value) - } +const noTokens = (): Tokens => ({ tags: new Set(), classes: new Set(), ids: new Set(), attrs: new Set() }) + +/** `isNested` marks the root of a nested instance: it and everything below it are that component's. */ +function addTokens(el: Element, tokens: Tokens) { + tokens.tags.add(el.tagName.toLowerCase()) + for (const attr of el.attrs) { + tokens.attrs.add(attr.name.toLowerCase()) + if (attr.name === 'class') for (const name of attr.value.split(/\s+/)) if (name) tokens.classes.add(name) + if (attr.name === 'id') tokens.ids.add(attr.value) } - const stack: Element[] = [root] +} + +function tokensOf(root: Element, isNested: (el: Element) => boolean): Omit { + const own = noTokens() + const nested = noTokens() + const add = addTokens + const stack: { el: Element; inside: boolean }[] = [{ el: root, inside: false }] for (let next = stack.pop(); next; next = stack.pop()) { - if (next !== root && skip(next)) continue - add(next) - for (const child of next.childNodes) if ('tagName' in child) stack.push(child) + const inside = next.inside || (next.el !== root && isNested(next.el)) + add(next.el, inside ? nested : own) + for (const child of next.el.childNodes) if ('tagName' in child) stack.push({ el: child, inside }) } - return tokens + return { own, nested } +} + +const isInstanceRoot = (el: Element) => el.attrs.some((attr) => attr.name === INSTANCE_ATTR) + +function mainTokens(root: Element, variantAttrs: string[]): SubtreeTokens { + const tokens = tokensOf(root, isInstanceRoot) + for (const name of variantAttrs) tokens.own.attrs.add(name) + return { ...tokens, ancestors: ancestorsOf(root) } +} + +/** Each element the main sits in, nearest first: what an ancestor compound may name. */ +function ancestorsOf(root: Element): Element[] { + const chain: Element[] = [] + for (let node = root.parentNode; node && 'tagName' in node; node = node.parentNode) chain.push(node) + return chain +} + +/** The selectors in a stylesheet written for one component that name nothing in it, so that + * `extractComponentCss` leaves their rules behind: what its author should hear about. */ +export function unmatchedSelectors(sheet: string, root: Element, variantAttrs: string[] = []): string[] { + const tokens = mainTokens(root, variantAttrs) + const unmatched: string[] = [] + const visit = (list: CssNode[]) => { + for (const node of list) { + if (node.kind === 'group') visit(node.nodes) + if (node.kind !== 'rule') continue + for (const selector of splitTopLevel(node.selector, ',')) { + if (selector && !isDocumentSelector(selector) && !relevantSelector(selector, tokens)) unmatched.push(selector) + } + } + } + visit(parseCss(sheet)) + return [...new Set(unmatched)] } const usedFonts = (css: string) => @@ -362,9 +482,7 @@ export function extractComponentCss( variantAttrs: string[] = [], ): ExtractedCss { const scope = `[${INSTANCE_ATTR}="${componentId}"]` - const nested = (el: Element) => el.attrs.some((attr) => attr.name === INSTANCE_ATTR) - const tokens = tokensOf(root, nested) - for (const name of variantAttrs) tokens.attrs.add(name) + const tokens = mainTokens(root, variantAttrs) const nodes = parseCss(sheet) const customProps = new Map() const inherited: string[] = [] @@ -380,7 +498,7 @@ export function extractComponentCss( } collectDocumentRules(nodes) - const keptRules = (list: CssNode[], write: (selector: string) => string): string[] => + const keptRules = (list: CssNode[], write: (relevant: Relevant) => string): string[] => list.flatMap((node) => { if (node.kind === 'group') { const inner = keptRules(node.nodes, write) @@ -394,8 +512,8 @@ export function extractComponentCss( }) return selectors.length ? [`${selectors.join(', ')} {${node.body}}`] : [] }) - const rules = keptRules(nodes, (selector) => scopeSelector(selector, scope)) - const rawRules = keptRules(nodes, (selector) => selector) + const rules = keptRules(nodes, ({ selector, prefix }) => scopeSelector(selector, scope, prefix)) + const rawRules = keptRules(nodes, ({ selector, prefix }) => (prefix ? `${prefix} ${selector}` : selector)) const ruleText = rules.join('\n') /* inherited and custom properties land on the instance root, so its text diff --git a/server/componentEngine.ts b/server/componentEngine.ts index 4763a8ef2..329ea5fd5 100644 --- a/server/componentEngine.ts +++ b/server/componentEngine.ts @@ -1,5 +1,13 @@ import { createHash } from 'node:crypto' -import { parse, parseFragment, serialize, serializeOuter, type DefaultTreeAdapterTypes as Tree } from 'parse5' +import { indexOfAscii } from '../shared/asciiSearch.ts' +import { + defaultTreeAdapter, + html as parse5Html, + serialize, + serializeOuter, + type DefaultTreeAdapterTypes as Tree, +} from 'parse5' +import { parse, parseFragment } from './workBudget.ts' import { BIND_ATTR, COMPONENT_ATTR, @@ -19,6 +27,8 @@ import { SLOT_SUGGEST_ATTR, USE_TAG, conditionHolds, + isDeleted, + isHollow, isPropName, parseBindings, parseCondition, @@ -94,14 +104,109 @@ function directText(el: Element): string { .trim() } -function setChildrenFromHtml(el: Element, html: string) { - const fragment = parseFragment(html) +function setChildrenFromHtml(el: Element, markup: string) { + const fragment = fragmentIn(markup, el.tagName) el.childNodes = fragment.childNodes for (const child of el.childNodes) child.parentNode = el } export function parseTemplateRoot(template: string): Element | undefined { - return elementKids(parseFragment(template))[0] + return elementKids(rootFragment(template))[0] +} + +/* where a table part can stand: the HTML parser drops a anywhere but in a row */ +const TABLE_PARENT: Record = { + td: 'tr', + th: 'tr', + tr: 'tbody', + tbody: 'table', + thead: 'table', + tfoot: 'table', + caption: 'table', + colgroup: 'table', + col: 'colgroup', +} + +const contextElements = new Map() + +function contextElement(tag: string): Element { + let el = contextElements.get(tag) + if (!el) { + el = defaultTreeAdapter.createElement(tag, parse5Html.NS.HTML, []) as Element + contextElements.set(tag, el) + } + return el +} + +/** Markup parsed as the content of a `parentTag`: a row's cells stay cells. */ +export function fragmentIn(markup: string, parentTag: string | undefined) { + const parent = parentTag?.toLowerCase() + return parent && TABLE_CONTEXTS.has(parent) ? parseInContext(contextElement(parent), markup) : parseFragment(markup) +} + +/* parse5's other form of parseFragment: the markup read as the content of `context` */ +const parseInContext = parseFragment as unknown as (context: Element, markup: string) => Tree.DocumentFragment + +const TABLE_CONTEXTS = new Set(['table', 'tbody', 'thead', 'tfoot', 'tr', 'colgroup']) + +/** The first element's tag, past any leading whitespace and comments. */ +function leadingTag(markup: string): string | undefined { + return /^(?:\s|)*<([a-z][\w-]*)/i.exec(markup)?.[1]?.toLowerCase() +} + +/** Can this markup's root stand where `parentTag` holds it? A table part only in its own table + * context; anything else nowhere a table part must be (the parser moves it out of a row). */ +export function fitsIn(markup: string, parentTag: string): boolean { + const tag = leadingTag(markup) + const parent = parentTag.toLowerCase() + if (tag && TABLE_PARENT[tag]) return ALLOWED_PARENTS[tag]?.has(parent) ?? false + return !TABLE_CONTEXTS.has(parent) +} + +/* every parent a table part may stand in: a row in any section of a table, or straight in one */ +const ALLOWED_PARENTS: Record> = { + td: new Set(['tr']), + th: new Set(['tr']), + tr: new Set(['tbody', 'thead', 'tfoot', 'table']), + tbody: new Set(['table']), + thead: new Set(['table']), + tfoot: new Set(['table']), + caption: new Set(['table']), + colgroup: new Set(['table']), + col: new Set(['colgroup', 'table']), +} + +/** Is `tag` an element whose children the parser keeps to table parts? */ +export function isTableContext(tag: string): boolean { + return TABLE_CONTEXTS.has(tag.toLowerCase()) +} + +/** Is this markup's root a table part (a cell, a row, a section of a table)? */ +export function isTablePart(markup: string): boolean { + const tag = leadingTag(markup) + return !!tag && !!TABLE_PARENT[tag] +} + +/** One element's markup parsed where it can stand: a table part inside what holds it. */ +export function rootFragment(markup: string) { + const tag = leadingTag(markup) + return fragmentIn(markup, tag ? TABLE_PARENT[tag] : undefined) +} + +/** What a table part needs around it to be a page's markup at all, for a main of its own. */ +export function tableScaffold(markup: string): (inner: string) => string { + const tag = leadingTag(markup) + const chain: string[] = [] + for (let parent = tag && TABLE_PARENT[tag]; parent; parent = TABLE_PARENT[parent]) chain.unshift(parent) + if (!tag || !TABLE_PARENT[tag]) return (inner) => inner + if (chain[0] !== 'table') chain.unshift('table') + return (inner) => + chain.map((t) => `<${t}>`).join('') + + inner + + [...chain] + .reverse() + .map((t) => ``) + .join('') } const JSON_OBJECT = (value: string | undefined): Record => { @@ -144,6 +249,8 @@ interface RenderOptions { shallow?: boolean /** the instance being rendered: what a nested instance's id is derived from */ ownerId?: string + /** a whole write: nothing more is coming, so an unclosed in slot or override content is placed too */ + final?: boolean } /** A nested instance has no place of its own to keep an id: the template owns its markup, and the @@ -164,7 +271,7 @@ function applyBindings(el: Element, def: Revision, overrides: InstanceOverrides) const raw = attrOf(el, BIND_ATTR) if (raw === undefined) return setAttr(el, BIND_ATTR, null) - for (const { target, prop } of parseBindings(raw)) { + for (const { target, prop } of parseBindings(raw, el.tagName)) { const value = overrides.props?.[prop] if (value === undefined) continue if (target === null) setText(el, value) @@ -241,7 +348,7 @@ function renderPart( setAttr(el, SLOT_SUGGEST_ATTR, null) if (part) applyPartOverride(el, part) const isSlot = attrOf(el, SLOT_ATTR) !== undefined - const content = (html: string) => expandUses(html, options.ctx, [], options.depth) + const content = (html: string) => expandUses(html, options.ctx, [], options.depth, { final: options.final }) if (part?.html !== undefined) { setChildrenFromHtml(el, options.shallow ? part.html : content(part.html)) return @@ -324,7 +431,13 @@ export function renderInstance( return undefined } const root = parseTemplateRoot(revision.template) - if (!root) return undefined + if (!root) { + options.ctx.issues.push({ + code: 'empty_template', + message: `component “${revision.name}” has no markup in its main, so its instance rendered nothing. Give it markup with update_component html.`, + }) + return undefined + } const id = instanceId || newElementId() const inner: RenderOptions = { ...options, stack: [...options.stack, revision.id], depth: depth + 1, ownerId: id } const key = attrOf(root, PART_ATTR) @@ -369,7 +482,7 @@ function clean(overrides: InstanceOverrides): InstanceOverrides { /** The compact markup of a node list: instances collapse to ``, the rest serializes as it stands. */ function compactChildren(el: ParentNode, ctx: EngineContext): string { - const clone = parseFragment(serialize(el)) + const clone = fragmentIn(serialize(el), isElement(el) ? el.tagName : undefined) compactInTree(clone, ctx) return serialize(clone) } @@ -423,7 +536,7 @@ export function partsOf(template: string): Map { isSlot: attrOf(el, SLOT_ATTR) !== undefined, isUse: el.tagName === USE_TAG, } - for (const { target, prop } of parseBindings(attrOf(el, BIND_ATTR) ?? '')) { + for (const { target, prop } of parseBindings(attrOf(el, BIND_ATTR) ?? '', el.tagName)) { if (target === null) info.textProp = prop else if (target.startsWith('style.')) info.styleProps.set(target.slice('style.'.length), prop) else if (target.startsWith('--')) info.styleProps.set(target, prop) @@ -523,7 +636,7 @@ function diffAttrs( } function canonicalInner(el: Element): string { - const clone = parseFragment(serialize(el)) + const clone = fragmentIn(serialize(el), el.tagName) const strip = (node: ParentNode) => { for (const child of node.childNodes) { if (!isElement(child)) continue @@ -764,6 +877,7 @@ export function useTagFor( inTemplate = false, byId = false, reconcile = false, + withId = false, ): string { const marker = readMarker(el) if (!marker) return serializeOuter(el) @@ -771,7 +885,7 @@ export function useTagFor( const revision = ctx.atRev(marker.componentId, marker.rev) ?? def const state = (reconcile ? reconcileInstance(el, ctx) : undefined) ?? readInstance(el, revision, ctx) ?? marker const ref = byId ? marker.componentId : (def?.name ?? marker.componentId) - return useMarkup(ref, state, revision, inTemplate ? attrOf(el, PART_ATTR) : undefined) + return useMarkup(ref, state, revision, inTemplate ? attrOf(el, PART_ATTR) : undefined, withId) } export function useMarkup( @@ -779,6 +893,8 @@ export function useMarkup( state: InstanceState, def: Revision | undefined, part: string | undefined, + /** with a part: the element id too. A frame's copy of a main keeps both; a stored template never an id */ + withId = false, ): string { const rest: Record = {} const slotChildren: string[] = [] @@ -793,13 +909,24 @@ export function useMarkup( } let tag = `<${USE_TAG}${attrText('component', name)}` if (part) tag += attrText(PART_ATTR, part) - else if (isElementId(state.instanceId)) tag += attrText('id', state.instanceId) + if ((!part || withId) && isElementId(state.instanceId)) tag += attrText('id', state.instanceId) for (const [prop, value] of Object.entries(state.overrides.props ?? {}).sort(([a], [b]) => a.localeCompare(b))) tag += attrText(prop, value) if (Object.keys(rest).length) tag += attrText('overrides', stableJson(rest)) return `${tag}>${slotChildren.join('')}` } +/* Attributes that mean something on a template's own element and nothing on a ``: the + nested instance is written out in the main, so one of these would only ride along as an + attribute override on its root. Each says what to write instead. */ +const TEMPLATE_ONLY_ATTRS: Record = { + [BIND_ATTR]: + 'a component cannot pass its props on to a component inside it. Give that one fixed values (label="…"), or put an element with data-doop-slot there and let each instance supply its own ', + [IF_ATTR]: 'put it on an element wrapped around the ', + [SLOT_ATTR]: 'put it on an element wrapped around the , which is then the slot’s default content', + [SLOT_SUGGEST_ATTR]: 'it belongs on the element that carries data-doop-slot', +} + /** Build an instance's overrides from a ``'s attributes, reporting what does not fit. */ export function stateFromUseAttrs(use: Element, def: Revision, ctx: EngineContext): InstanceState { const props: Record = {} @@ -818,6 +945,14 @@ export function stateFromUseAttrs(use: Element, def: Revision, ctx: EngineContex for (const attr of use.attrs) { const name = attr.name if (name === 'component' || name === 'id' || name === PART_ATTR || name === ELEMENT_ID_ATTR) continue + const instead = TEMPLATE_ONLY_ATTRS[name] + if (instead) { + ctx.issues.push({ + code: 'ignored_attribute', + message: `${name} on <${USE_TAG} component="${def.name}"> does nothing and was dropped: ${instead}.`, + }) + continue + } if (name === 'overrides') { parts = { ...parts, ...asPartRecord(JSON_OBJECT(attr.value)) } continue @@ -928,18 +1063,21 @@ interface UseSpan { openEnd: number closeStart: number selfClosing: boolean + /** read leniently: an open tag whose end never came, taken as empty */ + unclosed?: boolean } -function nextUse(html: string, from: number, opaque: [number, number][]): UseSpan | undefined { - const lower = html.toLowerCase() +/** The next complete `` from `from`. `lenient` (a whole write, nothing more to come) + * takes an open tag whose end never came as empty, so the ones after it still expand. */ +function nextUse(html: string, from: number, opaque: [number, number][], lenient = false): UseSpan | undefined { const open = `<${USE_TAG}` const close = `]/.test(following) && !opaque.some(([a, b]) => at >= a && at < b)) break - start = lower.indexOf(open, at + 1) + start = indexOfAscii(html, open, at + 1) } if (start === -1) return undefined const openEnd = tagEnd(html, start) @@ -950,9 +1088,12 @@ function nextUse(html: string, from: number, opaque: [number, number][]): UseSpa let depth = 1 let cursor = openEnd + 1 while (depth > 0) { - const nextOpen = lower.indexOf(open, cursor) - const nextClose = lower.indexOf(close, cursor) - if (nextClose === -1) return undefined + const nextOpen = indexOfAscii(html, open, cursor) + const nextClose = indexOfAscii(html, close, cursor) + if (nextClose === -1) + return lenient + ? { start, end: openEnd + 1, openEnd, closeStart: openEnd + 1, selfClosing: true, unclosed: true } + : undefined if (nextOpen !== -1 && nextOpen < nextClose) { const innerEnd = tagEnd(html, nextOpen) if (innerEnd === -1) return undefined @@ -970,37 +1111,72 @@ function nextUse(html: string, from: number, opaque: [number, number][]): UseSpa } /** Every complete `` in the HTML, written out in full. One still missing - * its end (mid-stream) stays as it is until a later pass. */ -export function expandUses(html: string, ctx: EngineContext, stack: string[] = [], depth = 0): string { - if (!html.toLowerCase().includes(`<${USE_TAG}`)) return html + * its end (mid-stream) stays as it is until a later pass; on a whole write (`final`) + * nothing more is coming, so it is taken as empty and reported. */ +export function expandUses( + html: string, + ctx: EngineContext, + stack: string[] = [], + depth = 0, + { final = false }: { final?: boolean } = {}, +): string { + if (indexOfAscii(html, `<${USE_TAG}`) === -1) return html const opaque = opaqueRanges(html) let out = '' let cursor = 0 - for (let span = nextUse(html, 0, opaque); span; span = nextUse(html, cursor, opaque)) { + for (let span = nextUse(html, 0, opaque, final); span; span = nextUse(html, cursor, opaque, final)) { out += html.slice(cursor, span.start) - out += expandOne(html, span, ctx, stack, depth) + if (span.unclosed) { + const ref = /\bcomponent\s*=\s*["']([^"']*)["']/i.exec(html.slice(span.start, span.openEnd))?.[1] ?? '' + ctx.issues.push({ + code: 'unclosed_use', + message: `<${USE_TAG} component="${ref}"> was never closed with , so it was placed with no slot content. Close every <${USE_TAG}>, or write it self-closing.`, + }) + } + out += expandOne(html, span, ctx, stack, depth, final) cursor = span.end } return out + html.slice(cursor) } -function expandOne(html: string, span: UseSpan, ctx: EngineContext, stack: string[], depth: number): string { +function expandOne( + html: string, + span: UseSpan, + ctx: EngineContext, + stack: string[], + depth: number, + final: boolean, +): string { const openTag = html.slice(span.start, span.openEnd + 1).replace(/\/>$/, '>') const inner = span.selfClosing ? '' : html.slice(span.openEnd + 1, span.closeStart) const use = elementKids(parseFragment(`${openTag}${inner}`))[0] - if (!use) return '' + if (!use) { + ctx.issues.push({ code: 'unknown_component', message: `a <${USE_TAG}> could not be read, so it was left out` }) + return '' + } const ref = attrOf(use, 'component') ?? '' const def = ctx.find(ref) if (!def) { ctx.issues.push({ code: 'unknown_component', message: `no component “${ref}” on this canvas` }) return '' } + /* a deleted component takes no new use. One a template already holds (it wears its part + key) is not new: a component built from a deleted one keeps rendering as it did */ + if (isDeleted(def) && attrOf(use, PART_ATTR) === undefined) { + ctx.issues.push({ + code: 'deleted_component', + message: `“${def.name}” was deleted from this canvas, so it was not placed. Restore it (restore_component) to use it again, or use another component.`, + }) + return '' + } const state = stateFromUseAttrs(use, def, ctx) - const root = renderInstance(def, def, state.overrides, state.instanceId, { ctx, stack, depth }) + const root = renderInstance(def, def, state.overrides, state.instanceId, { ctx, stack, depth, final }) if (!root) return '' - /* a template read back by update_component keeps the nested instance's key, and its overrides with it */ - const part = attrOf(use, PART_ATTR) - if (part) setAttr(root, PART_ATTR, part) + /* a template read back by update_component keeps the nested instance's key, and its overrides + with it. One that names none gets no key from the component it renders: that is the + component's own root key, the same for every use of it, so a second keyless use in a main + took the key of the first (agent reports, 2026-11-11). The main gives it one of its own */ + setAttr(root, PART_ATTR, attrOf(use, PART_ATTR) ?? null) return serializeOuter(root) } @@ -1091,9 +1267,22 @@ export function splice(html: string, edits: { start: number; end: number; text: * What agents read: a screen of 40 buttons costs 40 lines rather than 40 subtrees. */ export function compactDocument(html: string, ctx: EngineContext): string { if (!html.includes(INSTANCE_ATTR) && !html.includes(CSS_ATTR)) return html - const instances = findInstancesEverywhere(html) - const edits = instances.map((found) => ({ start: found.start, end: found.end, text: useTagFor(found.el, ctx) })) - return stripComponentHead(splice(html, edits)) + /* an instance of a deleted component stays written out: as it would be a new + use of it when the frame is written back, and those are refused. One of a hollow + component too, with its stylesheet: written back as it would render nothing */ + const hollow = hollowIds(html, ctx) + const instances = findInstancesEverywhere(html).filter( + (found) => !isDeleted(ctx.find(attrOf(found.el, INSTANCE_ATTR) ?? '')) && !holdsHollow(found.el, ctx), + ) + /* one inside a main keeps the key the main gave it (its place there, which the main's + instances' overrides name) and its element id (what comments and links name): saved back + without them, it would get new ones */ + const edits = instances.map((found) => ({ + start: found.start, + end: found.end, + text: insideMain(found.el) ? useTagFor(found.el, ctx, true, false, false, true) : useTagFor(found.el, ctx), + })) + return stripComponentHead(splice(html, edits), hollow) } /** Outermost instances, also those below a main: the main itself is not an instance. */ @@ -1101,10 +1290,37 @@ export function findInstancesEverywhere(html: string): Located[] { return findMarked(html, INSTANCE_ATTR) } -/** Everything a component put in the head: its stylesheet, and the links and scripts it brought. */ -export function stripComponentHead(html: string): string { +function insideMain(el: Element): boolean { + for (let node = el.parentNode; node && isElement(node); node = node.parentNode) + if (attrOf(node, COMPONENT_ATTR) !== undefined) return true + return false +} + +/** Is this instance, or one nested anywhere inside it, of a hollow component? Rendered again + * (or read back as ) it would lose that instance, so it is left as written. */ +export function holdsHollow(el: Element, ctx: EngineContext): boolean { + const stack: Element[] = [el] + for (let node = stack.pop(); node; node = stack.pop()) { + const id = attrOf(node, INSTANCE_ATTR) + if (id !== undefined && isHollow(ctx.find(id))) return true + stack.push(...elementKids(node)) + } + return false +} + +/** The hollow components this document has instances of. */ +function hollowIds(html: string, ctx: EngineContext): Set { + return new Set([...usedComponentIds(html)].filter((id) => isHollow(ctx.find(id)))) +} + +/** Everything a component put in the head: its stylesheet, and the links and scripts it brought. + * The stylesheets of the components in `keep` stay. */ +export function stripComponentHead(html: string, keep: ReadonlySet = new Set()): string { return html - .replace(new RegExp(`]*\\b${CSS_ATTR}="[^"]*"[^>]*>[\\s\\S]*?\\n?`, 'gi'), '') + .replace( + new RegExp(`]*\\b${CSS_ATTR}="([^"]*)"[^>]*>[\\s\\S]*?\\n?`, 'gi'), + (block, id: string) => (keep.has(id) ? block : ''), + ) .replace(new RegExp(`]*\\s${HEAD_ATTR}(?:="[^"]*")?[\\s>][^>]*>[\\s\\S]*?\\n?`, 'gi'), '') .replace(new RegExp(`]*\\s${HEAD_ATTR}(?:="[^"]*")?[\\s>/][^>]*>\\n?`, 'gi'), '') } @@ -1125,7 +1341,8 @@ export function usedComponentIds(html: string): Set { /** Put exactly the component stylesheets this document needs into its head. */ export function syncComponentHead(html: string, defs: ComponentDef[]): string { - const stripped = stripComponentHead(html) + /* a hollow component has no stylesheet to put back: its instances keep the one they have */ + const stripped = stripComponentHead(html, new Set(defs.filter(isHollow).map((def) => def.id))) const blocks: string[] = [] for (const def of defs) { /* a tag the frame has of its own, or one another component already brought, is not repeated */ @@ -1196,7 +1413,7 @@ export function stampParts(root: Element): boolean { /** The main's markup as a template: no main marker, no element ids (each instance * gets its own), nested instances compact. */ export function templateFromMain(main: Element, ctx: EngineContext): string { - const clone = elementKids(parseFragment(serializeOuter(main)))[0] + const clone = elementKids(rootFragment(serializeOuter(main)))[0] if (!clone) return '' setAttr(clone, COMPONENT_ATTR, null) const walk = (node: Element) => { @@ -1218,17 +1435,52 @@ function compactKeepingParts(node: Element, ctx: EngineContext) { /** Carry the old keys onto a rewritten template, element by element where tag and * place line up, so an agent resending a main does not orphan every override. */ export function alignParts(next: Element, previous: Element | undefined) { + const written = new Set() + const stack: Element[] = [next] + for (let el = stack.pop(); el; el = stack.pop()) { + const key = attrOf(el, PART_ATTR) + if (key) written.add(key) + stack.push(...elementKids(el)) + } + alignWith(next, previous, written) +} + +/** + * A child that names a key is matched to the old child with that key, never by place. One + * that names none takes the place of an old child that nothing claimed: inserting a keyless + * element before a keyed one used to hand it that one's key (overrides and all) and re-key + * the owner as a duplicate (agent reports, 2026-11-11). `written` holds every key the new + * markup names, and the keys handed out so far: none of them is handed out again. + */ +function alignWith(next: Element, previous: Element | undefined, written: Set) { if (!previous || next.tagName !== previous.tagName) return if (!attrOf(next, PART_ATTR)) { const key = attrOf(previous, PART_ATTR) - if (key) setAttr(next, PART_ATTR, key) + if (key && !written.has(key)) { + setAttr(next, PART_ATTR, key) + written.add(key) + } } const oldKids = elementKids(previous) + const oldByKey = new Map() + for (const kid of oldKids) { + const key = attrOf(kid, PART_ATTR) + if (key) oldByKey.set(key, kid) + } + const free = oldKids.filter((kid) => { + const key = attrOf(kid, PART_ATTR) + return !key || !written.has(key) + }) const seenOfTag = new Map() for (const kid of elementKids(next)) { + const key = attrOf(kid, PART_ATTR) + if (key) { + alignWith(kid, oldByKey.get(key), written) + continue + } const index = seenOfTag.get(kid.tagName) ?? 0 seenOfTag.set(kid.tagName, index + 1) - alignParts(kid, oldKids.filter((candidate) => candidate.tagName === kid.tagName)[index]) + alignWith(kid, free.filter((candidate) => candidate.tagName === kid.tagName)[index], written) } } @@ -1256,7 +1508,7 @@ export function derivePropsAndSlots( stack.push(...elementKids(el).reverse()) } for (const el of order) { - for (const { target, prop } of parseBindings(attrOf(el, BIND_ATTR) ?? '')) { + for (const { target, prop } of parseBindings(attrOf(el, BIND_ATTR) ?? '', el.tagName)) { if (props.has(prop)) continue const known = declaredOf(declared, prop) const type = target === 'src' ? 'image' : target === 'href' ? 'link' : 'text' @@ -1295,16 +1547,61 @@ export function derivePropsAndSlots( const descriptionOf = (prop: ComponentProp | undefined) => (prop?.description ? { description: prop.description } : {}) +/* what an element's text is called when nothing on it says: by what the element is */ +const ROLE_NAMES: Record = { + h1: 'title', + h2: 'title', + h3: 'title', + h4: 'title', + h5: 'title', + h6: 'title', + button: 'label', + a: 'label', + label: 'label', + summary: 'label', + li: 'item', + figcaption: 'caption', + caption: 'caption', + small: 'caption', + blockquote: 'quote', + time: 'date', + th: 'heading', + td: 'cell', +} + +/* a utility class says how an element looks, not what it is: `text-sm`, `mt-2`, `md:flex` */ +const UTILITY_CLASS = + /[:[\]/.]|^-|^(flex|grid|block|inline|hidden|relative|absolute|truncate|uppercase|italic|underline|antialiased)$|^(text|font|bg|border|rounded|shadow|leading|tracking|p|px|py|pt|pb|pl|pr|m|mx|my|mt|mb|ml|mr|w|h|min|max|gap|flex|grid|inline|items|justify|opacity|whitespace)-/ + +/** The name an element gives itself: its `data-name`, else its last class that is not a utility. */ +function ownPropName(el: Element): string | undefined { + const classes = (attrOf(el, 'class') ?? '').split(/\s+/).filter((name) => name && !UTILITY_CLASS.test(name)) + const raw = attrOf(el, 'data-name') ?? classes.at(-1) ?? '' + const name = raw && raw.length < 30 ? toPropName(raw) : 'value' + return name === 'value' ? undefined : name +} + +/** The nearest element, from this one up to the main, whose tag says what its text is. */ +function roleName(el: Element, root: Element): string { + for (let node: Element | undefined = el; node;) { + const role = ROLE_NAMES[node.tagName] + if (role) return role + if (node === root) break + const parent: ParentNode | null = node.parentNode + node = parent && isElement(parent) ? parent : undefined + } + return el === root ? 'label' : 'text' +} + /** Name what a component would most likely vary: leaf text, image sources, link targets. - * Written onto the main as ordinary bindings, so a person or agent can see and change them. */ -export function inferBindings(root: Element, limit = 12): number { + * Written onto the main as ordinary bindings, so a person or agent can see and change them. + * Returns the prop names it made up, in template order. */ +export function inferBindings(root: Element, limit = 12): string[] { const used = new Set() let count = 0 - const nameFor = (el: Element, fallback: string) => { - const name = attrOf(el, 'data-name') ?? attrOf(el, 'class')?.split(/\s+/).at(-1) ?? '' - const base = toPropName(name && name.length < 30 ? name : fallback) - let candidate = base === 'value' ? fallback : base - for (let n = 2; used.has(candidate); n++) candidate = `${base === 'value' ? fallback : base}-${n}` + const take = (base: string) => { + let candidate = base + for (let n = 2; used.has(candidate); n++) candidate = `${base}-${n}` used.add(candidate) return candidate } @@ -1312,22 +1609,25 @@ export function inferBindings(root: Element, limit = 12): number { const order: Element[] = [] for (let el = stack.pop(); el; el = stack.pop()) { if (el.tagName === 'style' || el.tagName === 'script' || el.tagName === 'svg') continue - if (attrOf(el, INSTANCE_ATTR)) continue + /* a nested component, written out or still ``: its content is its own */ + if (attrOf(el, INSTANCE_ATTR) || el.tagName === USE_TAG) continue order.push(el) stack.push(...elementKids(el).reverse()) } for (const el of order) { if (count >= limit || attrOf(el, BIND_ATTR) !== undefined || attrOf(el, SLOT_ATTR) !== undefined) continue const bindings: string[] = [] - if (el.tagName === 'img' && attrOf(el, 'src')) bindings.push(`src:${nameFor(el, 'image')}`) - if (el.tagName === 'a' && attrOf(el, 'href')) bindings.push(`href:${nameFor(el, 'link')}`) - if (elementKids(el).length === 0 && directText(el)) bindings.push(nameFor(el, el === root ? 'label' : 'text')) + const own = ownPropName(el) + if (el.tagName === 'img' && attrOf(el, 'src')) bindings.push(`src:${take(own ?? 'image')}`) + /* a link's target is named beside its text: `cta-link` next to `cta` */ + if (el.tagName === 'a' && attrOf(el, 'href')) bindings.push(`href:${take(own ? `${own}-link` : 'link')}`) + if (elementKids(el).length === 0 && directText(el)) bindings.push(take(own ?? roleName(el, root))) if (bindings.length) { setAttr(el, BIND_ATTR, bindings.join(',')) count += bindings.length } } - return count + return [...used] } /* ------------------------------------------------------------------ */ diff --git a/server/componentLibrary.ts b/server/componentLibrary.ts new file mode 100644 index 000000000..b2903d496 --- /dev/null +++ b/server/componentLibrary.ts @@ -0,0 +1,427 @@ +import { + MAX_COMPONENTS, + MAX_COMPONENT_NAME, + stableJson, + isDeleted, + type ComponentDef, + type LibraryChange, + type LibraryComponent, +} from '../shared/components.ts' +import type { Canvas } from '../shared/types.ts' +import { libraryLandingPageId } from '../shared/pages.ts' +import * as persist from './db/persist.ts' +import { afterCommit, recordUndo } from './journal.ts' +import { store } from './store.ts' +import { getWorkspace, isActive } from './workspaces.ts' + +/** + * Workspace component libraries: what each library canvas has published, and + * how a canvas in the same workspace takes a published component up. A canvas + * is a library while it has published snapshots; it serves the workspace it is + * in. Mirrored in memory like components, since frame writes read it. + * Spec: .context/specs/workspace-component-library.md. + */ + +const published = new Map() + +/** Replace a canvas's publication (none = it publishes nothing). Journaled like every store + * write (server/journal.ts): undone with the operation, its rows written at the commit. */ +function setPublished(canvasId: string, next: LibraryComponent[]) { + const before = published.get(canvasId) + if (next.length) published.set(canvasId, next) + else published.delete(canvasId) + recordUndo(() => { + if (published.get(canvasId) !== (next.length ? next : undefined)) return + if (before) published.set(canvasId, before) + else published.delete(canvasId) + }) +} + +export async function hydrateLibraries(): Promise { + published.clear() + for (const snapshot of await persist.loadLibraryComponents()) { + const list = published.get(snapshot.canvasId) + if (list) list.push(snapshot) + else published.set(snapshot.canvasId, [snapshot]) + } +} + +/** What a canvas has published, whether or not anyone may use it right now. */ +export function publishedOn(canvasId: string): LibraryComponent[] { + return published.get(canvasId) ?? [] +} + +export function isLibrary(canvasId: string): boolean { + return publishedOn(canvasId).length > 0 +} + +/** Where a library canvas opens: see `libraryLandingPageId`. Reads frame + * metadata only, so it needs no frame HTML loaded. */ +export function landingPageOf(canvas: Canvas): string | undefined { + const snapshots = publishedOn(canvas.id) + if (!snapshots.length) return undefined + return libraryLandingPageId( + canvas, + snapshots.map((snapshot) => snapshot.id), + ) +} + +/** Why a canvas cannot publish or use a library, or null when it can: libraries + * belong to a workspace whose plan is live (every workspace, with billing off). */ +export function libraryBlock( + canvas: Pick, +): { reason: 'no_workspace' } | { reason: 'plan_required'; workspaceId: string } | null { + if (!canvas.workspaceId) return { reason: 'no_workspace' } + const workspace = getWorkspace(canvas.workspaceId) + if (!workspace) return { reason: 'no_workspace' } + return isActive(workspace) ? null : { reason: 'plan_required', workspaceId: workspace.id } +} + +export interface Library { + canvasId: string + name: string + components: LibraryComponent[] +} + +/** The libraries a canvas designs with: every other canvas of its workspace + * that has published. It goes by the canvas, like fonts, so a guest editing a + * workspace canvas has its library too. */ +export function librariesForCanvas(canvas: Pick): Library[] { + if (libraryBlock(canvas)) return [] + const libraries: Library[] = [] + for (const [canvasId, components] of published) { + if (canvasId === canvas.id || !components.length) continue + const source = store.getCanvas(canvasId) + if (!source || source.workspaceId !== canvas.workspaceId) continue + /* a component its library has deleted is published only as what others are built from + (see `publication`): it comes along with them, and is not offered on its own */ + const offered = components.filter((entry) => !isDeleted(source.components?.find((def) => def.id === entry.id))) + if (offered.length) libraries.push({ canvasId, name: source.name, components: offered }) + } + return libraries.sort((a, b) => a.name.localeCompare(b.name)) +} + +/** Every library of a workspace, for its settings page. */ +export function librariesOfWorkspace(workspaceId: string): Library[] { + return librariesForCanvas({ id: '', workspaceId }) +} + +function matches(snapshot: LibraryComponent, ref: string): boolean { + return snapshot.id === ref || snapshot.name.toLowerCase() === ref.trim().toLowerCase() +} + +/** Published components a canvas could use under this name or id, across its libraries. */ +export function findInLibraries(canvas: Pick, ref: string): LibraryComponent[] { + return librariesForCanvas(canvas).flatMap((library) => library.components.filter((entry) => matches(entry, ref))) +} + +export function publishedSnapshot(canvasId: string, componentId: string): LibraryComponent | undefined { + return publishedOn(canvasId).find((entry) => entry.id === componentId) +} + +/** The snapshot a linked definition follows, while its library still serves this canvas. */ +export function originOf(canvas: Pick, def: ComponentDef): LibraryComponent | undefined { + if (!def.source?.library) return undefined + const source = store.getCanvas(def.source.canvasId) + if (!source || source.workspaceId !== canvas.workspaceId || !canvas.workspaceId) return undefined + return publishedSnapshot(def.source.canvasId, def.source.componentId) +} + +/* ------------------------------------------------------------------ */ +/* Publishing */ +/* ------------------------------------------------------------------ */ + +function nestedRefs(template: string): string[] { + return [...template.matchAll(/component="([^"]+)"/g)].map((match) => match[1]!) +} + +/** Which other library each nested component of a definition is linked to, on its canvas today. */ +function nestedSources(canvasId: string, def: ComponentDef): Record | undefined { + const defs = store.getComponents(canvasId) + const sources: Record = {} + for (const ref of nestedRefs(def.template)) { + const nested = defs.find((candidate) => candidate.id === ref || candidate.name === ref) + if (nested?.source?.library) sources[nested.id] = nested.source.canvasId + } + return Object.keys(sources).length ? sources : undefined +} + +function sameAsPublished(canvasId: string, def: ComponentDef, snapshot: LibraryComponent): boolean { + return ( + stableJson(nestedSources(canvasId, def) ?? {}) === stableJson(snapshot.nested ?? {}) && + def.name === snapshot.name && + def.description === snapshot.description && + def.template === snapshot.template && + def.css === snapshot.css && + JSON.stringify(def.head) === JSON.stringify(snapshot.head) && + JSON.stringify(def.props) === JSON.stringify(snapshot.props) && + JSON.stringify(def.slots) === JSON.stringify(snapshot.slots) && + JSON.stringify(def.code ?? null) === JSON.stringify(snapshot.code ?? null) + ) +} + +/** The canvas's own component, with a design to show. */ +function ownDesign(def: ComponentDef): boolean { + return !def.source?.library && def.rev > 0 && !!def.template +} + +/** A component a library canvas can publish: its own, with a design to show, and in use. */ +export function publishable(def: ComponentDef): boolean { + return ownDesign(def) && !isDeleted(def) +} + +/** Everything a publication of this canvas holds: the components it can publish, and the + * deleted ones those are built from. A deleted component is frozen, not gone: a published + * Card that nests a deleted Button still renders that Button, so a canvas using the Card + * needs the Button's snapshot too. It rides along as a dependency only (never offered on + * its own, see `librariesForCanvas`), and leaves the publication when nothing in use is + * built from it any more. */ +function publication(canvas: Canvas): ComponentDef[] { + const inUse = (canvas.components ?? []).filter(publishable) + const frozen = withDependencies( + canvas, + inUse.map((def) => def.id), + ).filter((def) => isDeleted(def) && ownDesign(def)) + return [...inUse, ...frozen] +} + +export interface LibraryChangeEntry { + id: string + name: string + change: LibraryChange +} + +/** What publishing this canvas now would do, component by component. */ +export function libraryChanges(canvas: Canvas): LibraryChangeEntry[] { + const snapshots = publishedOn(canvas.id) + const local = publication(canvas) + const entries: LibraryChangeEntry[] = local.map((def) => { + const snapshot = snapshots.find((entry) => entry.id === def.id) + const change: LibraryChange = !snapshot + ? 'new' + : sameAsPublished(canvas.id, def, snapshot) + ? 'unchanged' + : 'changed' + return { id: def.id, name: def.name, change } + }) + for (const snapshot of snapshots) { + if (!local.some((def) => def.id === snapshot.id)) + entries.push({ id: snapshot.id, name: snapshot.name, change: 'removed' }) + } + return entries +} + +/** The chosen components and everything they are built from, by id. */ +function withDependencies(canvas: Canvas, ids: readonly string[]): ComponentDef[] { + const defs = canvas.components ?? [] + const seen = new Map() + const stack = [...ids] + for (let ref = stack.pop(); ref; ref = stack.pop()) { + const def = defs.find((candidate) => candidate.id === ref || candidate.name === ref) + if (!def || seen.has(def.id)) continue + seen.set(def.id, def) + stack.push(...nestedRefs(def.template)) + } + return [...seen.values()] +} + +/** `previous` is what was published before: a publication's `rev` only ever + * rises, since a change that leaves the canvas's own revision alone (a + * description, the code mapping, head tags) must still reach the canvases + * using it, and they tell an update by a higher `rev`. */ +function snapshotOf( + canvasId: string, + def: ComponentDef, + by: string, + at: number, + previous: LibraryComponent | undefined, +): LibraryComponent { + return { + canvasId, + id: def.id, + name: def.name, + description: def.description, + template: def.template, + css: def.css, + rawCss: def.rawCss, + head: def.head, + props: def.props, + slots: def.slots, + ...(def.code ? { code: def.code } : {}), + ...(nestedSources(canvasId, def) ? { nested: nestedSources(canvasId, def) } : {}), + rev: previous ? Math.max(def.rev, previous.rev + 1) : def.rev, + publishedAt: at, + publishedBy: by, + } +} + +export interface PublishResult { + published: LibraryChangeEntry[] + removed: LibraryChangeEntry[] +} + +/** Publish the chosen components (all publishable ones when none are named), + * each with what it is built from. A published component the canvas no longer + * has stops being offered. Entitlement is the caller's check. */ +export function publishLibrary( + canvas: Canvas, + ids: readonly string[] | undefined, + by: string, + dryRun = false, +): PublishResult { + const all = publication(canvas) + /* the chosen ones and what they are built from, deleted dependencies included */ + const chosen = withDependencies(canvas, ids ?? all.map((def) => def.id)).filter((def) => all.includes(def)) + const before = publishedOn(canvas.id) + const changes = libraryChanges(canvas) + const changeOf = (id: string) => changes.find((entry) => entry.id === id) + const result: PublishResult = { + published: chosen.flatMap((def) => { + const entry = changeOf(def.id) + return entry && entry.change !== 'unchanged' ? [entry] : [] + }), + removed: changes.filter((entry) => entry.change === 'removed'), + } + if (dryRun) return result + const at = Date.now() + const next = before.filter((entry) => !result.removed.some((gone) => gone.id === entry.id)) + for (const def of chosen) { + if (changeOf(def.id)?.change === 'unchanged') continue + const index = next.findIndex((entry) => entry.id === def.id) + const snapshot = snapshotOf(canvas.id, def, by, at, next[index]) + if (index === -1) next.push(snapshot) + else next[index] = snapshot + afterCommit(() => persist.saveLibraryComponent(snapshot)) + } + for (const gone of result.removed) afterCommit(() => persist.deleteLibraryComponent(canvas.id, gone.id)) + next.sort((a, b) => a.name.localeCompare(b.name)) + setPublished(canvas.id, next) + return result +} + +/** Stop offering some published components, or the whole library. Canvases + * already using them keep their definition and every instance. */ +export function unpublishLibrary(canvasId: string, ids?: readonly string[]): LibraryComponent[] { + const before = publishedOn(canvasId) + const gone = ids ? before.filter((entry) => ids.includes(entry.id)) : before + for (const entry of gone) afterCommit(() => persist.deleteLibraryComponent(canvasId, entry.id)) + const kept = before.filter((entry) => !gone.includes(entry)) + setPublished(canvasId, kept) + return gone +} + +/** The canvas is gone: so is what it published, here as in the database (where + * the rows go with the canvas's own). Not a withdrawal anyone is told about. */ +export function forgetLibrary(canvasId: string) { + setPublished(canvasId, []) +} + +/* ------------------------------------------------------------------ */ +/* Using */ +/* ------------------------------------------------------------------ */ + +export class LibraryAdoptError extends Error {} + +function freeLibraryName(name: string, taken: Set): string { + if (!taken.has(name.toLowerCase())) return name + for (let n = 1; ; n++) { + const suffix = n === 1 ? ' (library)' : ` (library ${n})` + const candidate = `${name.slice(0, MAX_COMPONENT_NAME - suffix.length).trimEnd()}${suffix}` + if (!taken.has(candidate.toLowerCase())) return candidate + } +} + +/** A snapshot read as a definition, for rendering it where no canvas holds it yet. */ +export function snapshotAsDef(snapshot: LibraryComponent): ComponentDef { + return linkedDef(snapshot, snapshot.name, snapshot.publishedBy) +} + +function linkedDef(snapshot: LibraryComponent, name: string, by: string): ComponentDef { + const now = Date.now() + return { + id: snapshot.id, + name, + description: snapshot.description, + template: snapshot.template, + css: snapshot.css, + rawCss: snapshot.rawCss, + head: snapshot.head, + props: snapshot.props, + slots: snapshot.slots, + /* the publication's own number: a linked definition changes only by taking a + newer publication, so one count serves both and instance markers read true */ + rev: snapshot.rev, + mainFrameId: null, + history: [], + ...(snapshot.code ? { code: snapshot.code } : {}), + source: { canvasId: snapshot.canvasId, componentId: snapshot.id, rev: snapshot.rev, library: true }, + createdAt: now, + updatedAt: now, + updatedBy: by, + } +} + +/** A nested component its own library does not publish: a library can be built + * out of another's components (a Plan card around the design system's Button). + * The publication recorded which library each of those came from, and that is + * the one resolved against. An id alone would not do, since a copied canvas + * shares ids and two libraries can publish different designs under one; nor + * would the library canvas's link as it is today, which can have moved since. */ +function publishedElsewhere(entry: LibraryComponent, ref: string): LibraryComponent | undefined { + const from = entry.nested?.[ref] + if (!from) return undefined + const source = store.getCanvas(from) + if (!source || source.workspaceId !== store.getCanvas(entry.canvasId)?.workspaceId) return undefined + return publishedSnapshot(from, ref) +} + +/** The snapshot and every published component it is built from, dependencies first. */ +export function snapshotClosure(snapshot: LibraryComponent): LibraryComponent[] { + const seen = new Map() + const visit = (entry: LibraryComponent) => { + if (seen.has(entry.id)) return + seen.set(entry.id, entry) + for (const ref of nestedRefs(entry.template)) { + const nested = + publishedOn(entry.canvasId).find((candidate) => matches(candidate, ref)) ?? publishedElsewhere(entry, ref) + if (nested) visit(nested) + } + } + visit(snapshot) + return [...seen.values()].reverse() +} + +/** Add a published component to a canvas as a linked definition with no main + * of its own, along with what it is built from. Returns the definitions that + * were added; ones the canvas already links are left as they are, since an + * update is pulled on request. Throws before writing anything when an id here + * belongs to the canvas's own component (a copied canvas shares ids). */ +export function adoptFromLibrary(canvasId: string, snapshot: LibraryComponent, by: string): ComponentDef[] { + const local = store.getComponents(canvasId) + const wanted = snapshotClosure(snapshot) + const missing = wanted.filter((entry) => { + const existing = local.find((def) => def.id === entry.id) + if (existing && existing.source?.canvasId !== entry.canvasId) + throw new LibraryAdoptError( + `this canvas already has its own component “${existing.name}” (${existing.id}), shared with the library because one canvas was copied from the other; edit it here instead`, + ) + return !existing + }) + if (local.length + missing.length > MAX_COMPONENTS) + throw new LibraryAdoptError(`a canvas holds at most ${MAX_COMPONENTS} components`) + const taken = new Set(local.map((def) => def.name.toLowerCase())) + const added: ComponentDef[] = [] + for (const entry of missing) { + const linked = linkedDef(entry, freeLibraryName(entry.name, taken), by) + /* one its library has deleted comes only as what another is built from: it is deleted + here too, so it renders inside that component and is not there to be used by itself */ + const origin = store.getComponents(entry.canvasId).find((candidate) => candidate.id === entry.id) + const def: ComponentDef = isDeleted(origin) + ? { ...linked, status: 'deleted', deletedAt: origin?.deletedAt ?? Date.now(), deletedBy: origin?.deletedBy ?? by } + : linked + if (!isDeleted(def)) taken.add(def.name.toLowerCase()) + store.saveComponent(canvasId, def) + added.push(def) + } + return added +} diff --git a/server/componentPreview.ts b/server/componentPreview.ts index 0a88b5a13..219f0e0aa 100644 --- a/server/componentPreview.ts +++ b/server/componentPreview.ts @@ -1,6 +1,7 @@ import { serializeOuter } from 'parse5' import { CSS_ATTR, type ComponentDef, type InstanceOverrides } from '../shared/components.ts' import type { Frame } from '../shared/types.ts' +import { withCanvasFaces } from './canvasFaces.ts' import { contextFor } from './components.ts' import { renderInstance } from './componentEngine.ts' @@ -41,12 +42,20 @@ const label = (combo: Record) => const escapeHtml = (text: string) => text.replace(/&/g, '&').replace(/ { const overrides: InstanceOverrides = Object.keys(combo).length ? { props: combo } : {} const root = renderInstance(def, def, overrides, '', { ctx, stack: [] }) @@ -56,12 +65,17 @@ export function previewDocument( }) const columns = Math.min(combos.length, 3) const rows = Math.ceil(combos.length / columns) - const html = `${stylesFor(canvasId, def)}
${cells.join('')}
` +
${cells.join('')}
`, + ) return { html, width: SHEET_WIDTH, height: rows * CELL_HEIGHT, variants: combos.length } } diff --git a/server/componentTools.ts b/server/componentTools.ts index bfb5e1771..983339104 100644 --- a/server/componentTools.ts +++ b/server/componentTools.ts @@ -1,7 +1,8 @@ import { z } from 'zod' -import { PROP_TYPES, USE_TAG, type ComponentDef } from '../shared/components.ts' +import { activeComponents, PROP_TYPES, USE_TAG, type ComponentDef } from '../shared/components.ts' import type { Actor, Canvas, Frame } from '../shared/types.ts' import { + catalog, catalogEntry, changeInstances, componentDetail, @@ -9,19 +10,34 @@ import { createComponentFromElement, createComponentFromHtml, deleteComponent, + detachAllInstances, findComponent, - findComponentCandidates, + findDeletedComponent, + importableEntry, importComponent, insertInstance, instancesIn, + libraryCatalog, + libraryConsumers, lookalikesIn, + publishToLibrary, + restoreComponent, restoreComponentVersion, syncComponent, + unpublishFromLibrary, updateComponent, + updateLibraryConsumers, usageExample, usageOf, + waitingLibraryUpdates, } from './componentActions.ts' +import { isLibrary, librariesForCanvas } from './componentLibrary.ts' import * as actions from './actions.ts' +import { componentReuseNotes, componentSystemNotes, frameReuseNotes } from './reuseNotes.ts' +import { store } from './store.ts' +import { inlineDataRefusal, type Surface } from './inlineData.ts' +import { optional, WorkBudgetError } from './workBudget.ts' +import { transaction } from './journal.ts' /** * The component tools every agent gets, over MCP (server/mcp.ts) or in the server @@ -53,8 +69,14 @@ export interface ToolContext { actor: Actor /** may this account read that other canvas? a library is only imported from one it can */ canRead: (canvasId: string) => boolean + /** may this account change that other canvas? update_library_everywhere writes only where it can */ + canEdit: (canvasId: string) => boolean /** canvases this account can read, for the library listing */ readableCanvases: () => Canvas[] + /** the account acting: the person an agent works for. Publishing is checked against it */ + userId: string | undefined + /** which agent is calling, for the tools a refusal may point it at */ + surface?: Surface } export type ToolResult = { data: unknown; note?: string; frames?: Frame[] } @@ -66,13 +88,44 @@ interface ComponentTool { readOnly: boolean destructive?: boolean shape: z.ZodRawShape - run(input: Record, context: ToolContext): ToolResult + /** a promise only where the tool has to load other canvases (update_library_everywhere) */ + run(input: Record, context: ToolContext): ToolResult | Promise } +/** The components a new main names in a that resolved to nothing, by the name it gave. */ +function missingNested(def: ComponentDef): string[] { + if (!def.mainFrameId) return [] + const refs = actions + .peekComponentIssues(def.mainFrameId) + .filter((issue) => issue.code === 'unknown_component') + .map((issue) => /“([^”]*)”/.exec(issue.message)?.[1] ?? '') + return [...new Set(refs)] +} + +/** One create_components call: a canvas's starting kit, not its whole library. */ +export const MAX_BATCH_COMPONENTS = 12 + const COMPONENT_REF = z.string().describe('Component name or id') const FRAME_ID = z.string().describe('Frame id from get_canvas') +const LIBRARY_NOTE = + 'This canvas is a workspace library: other canvases keep the last published version until you publish_library here (when the human wants the change shared) and each pulls it with sync_component (or, when the human asks for it everywhere, update_library_everywhere here).' const IMPACT_NOTE = - 'Check one affected frame with get_frame_screenshot. Sign-off on approved frames that changed is withdrawn, as with any edit.' + 'Check one affected frame with get_frame_screenshot. Approved frames keep their sign-off: following a component is not an edit of the frame.' + +/** Whether the instances have the change yet: said, because the call returns before they do. */ +function propagationNote(result: { propagation?: { status: string; frames: number } }): string[] { + const { status, frames } = result.propagation ?? { status: 'none', frames: 0 } + const count = `${frames} frame${frames === 1 ? '' : 's'}` + if (status === 'queued') + return [ + `Instances are updating in the background: queued for ${count} (impact.frames). get_frame and get_frame_screenshot wait a moment for it; on a large canvas the last frames can take longer.`, + ] + if (status === 'deferred') + return [ + `This server has component propagation switched off for now: the ${count} in impact.frames keep the previous revision until each is next written.`, + ] + return [] +} function summary(canvas: Canvas, def: ComponentDef) { return catalogEntry(canvas, def) @@ -88,12 +141,20 @@ function outcomeFrames(context: ToolContext, def: ComponentDef, extra: string[] const asProps = (value: unknown) => value as Record | undefined +const inferredProps = (names: string[]) => (names.length ? { inferred_props: names } : {}) + +/** Names the server made up are the ones worth a second look, while nothing uses them yet. */ +function inferredNote(names: string[]): string { + if (!names.length) return '' + return ` Props inferred from the markup: ${names.join(', ')}. To name one yourself, write data-doop-prop on its element (now: update_component with find + replace on the template, before instances set it); pass props to give one a type or description.` +} + export const COMPONENT_TOOLS: ComponentTool[] = [ { name: 'list_components', title: 'List components', description: - 'List the reusable components on a canvas: each name, its props and slots as a one-line signature, a ready-to-paste and how often it is used. Check this BEFORE writing markup: anything on this list must be used through , never redrawn. With libraries=true, also lists components on other canvases this account can read, ready for import_component.', + "List the reusable components on a canvas: each name, its props and slots as a one-line signature, a ready-to-paste and how often it is used. Check this BEFORE writing markup: anything on this list must be used through , never redrawn. workspace_libraries lists what the canvas's workspace has published and this canvas does not use yet: write with that name and it is added, linked to its library. With libraries=true, also lists components on other canvases this account can read, ready for import_component.", readOnly: true, shape: { query: z.string().optional().describe('Only components whose name or description contains this'), @@ -103,25 +164,37 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ const wanted = typeof query === 'string' ? query.toLowerCase() : '' const matches = (def: ComponentDef) => !wanted || def.name.toLowerCase().includes(wanted) || def.description.toLowerCase().includes(wanted) - const components = (canvas.components ?? []).filter(matches).map((def) => summary(canvas, def)) + const components = catalog(canvas, activeComponents(canvas.components).filter(matches)) + const shared = libraryCatalog(canvas) + .map((library) => ({ + ...library, + components: library.components.filter( + (entry) => + !wanted || + entry.name.toLowerCase().includes(wanted) || + (entry.description ?? '').toLowerCase().includes(wanted), + ), + })) + .filter((library) => library.components.length) return { data: { components, + ...(shared.length ? { workspace_libraries: shared } : {}), ...(libraries ? { libraries: readableCanvases() - .filter((other) => other.id !== canvas.id && other.components?.length) + .filter((other) => other.id !== canvas.id && activeComponents(other.components).length) .map((other) => ({ canvas_id: other.id, canvas_name: other.name, - components: (other.components ?? []).filter(matches).map((def) => summary(other, def)), + components: activeComponents(other.components).filter(matches).map(importableEntry), })), } : {}), - ...(components.length + ...(components.length || shared.length ? {} : { - note: 'No components match. If a block repeats, find_component_candidates shows what is worth making one.', + note: 'No components match. If a block repeats, make it one with create_component.', }), }, } @@ -144,13 +217,13 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ name: 'create_component', title: 'Create a component', description: - 'Make a reusable component, one of two ways. From an element already in a frame (frame_id + element: a data-doop-id, or the element of a find_component_candidates result): that element stays where it is and becomes the main; pass replace_matching=true to turn every other element of the same shape on the canvas into a linked instance in one go, differing text and links becoming props. From new markup (html + css): the main lands on the canvas\'s Components page. Unless the markup already says otherwise, leaf text, image sources and link targets become props; mark your own with data-doop-prop="label" (text), data-doop-prop="href:link,--accent:accent" (attributes, custom properties), data-doop-if="tone=ghost" or "show-icon" (conditional elements), data-doop-slot="actions" (content each instance supplies, add data-doop-slot-suggest="Button"). An enum prop in props sets data- on the root, so variants are plain CSS: .btn[data-tone="ghost"] { … }. Give it a description saying when to use it: it is how the next agent knows.', + 'Make a reusable component from new markup (html + css) or from an element already in a frame (frame_id + element). From markup, the main lands on the canvas\'s Components page and no instance is placed anywhere: to use it, write in a frame\'s HTML or call insert_instance. From an element (its data-doop-id from get_frame), that element stays where it is and becomes the main; pass replace_matching=true to turn every other element of the same shape on the canvas into a linked instance in one go, differing text and links becoming props. Unless the markup already says otherwise, leaf text, image sources and link targets become props, named after what each element is (title, label, image, link, text) or its class; the result lists them. Name your own with data-doop-prop="label" (text), data-doop-prop="src:photo" (an image; on an a bare name binds its src too), data-doop-prop="href:link,--accent:accent" (attributes, custom properties), data-doop-if="tone=ghost" or "show-icon" (conditional elements), data-doop-slot="actions" (content each instance supplies, add data-doop-slot-suggest="Button"). An enum prop in props sets data- on the root, so variants are plain CSS: .btn[data-tone="ghost"] { … }. Give it a description saying when to use it: it is how the next agent knows.', readOnly: false, shape: { name: z.string().describe('Short and unique, e.g. "Button", "Pricing Card"'), description: z.string().optional().describe('When to use this. Later agents choose by it'), frame_id: z.string().optional().describe('With element: make this existing element the main'), - element: z.string().optional().describe('A data-doop-id, or the element from find_component_candidates'), + element: z.string().optional().describe("The element's data-doop-id from get_frame"), replace_matching: z .boolean() .optional() @@ -172,7 +245,7 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ autoProps: input.auto_props as boolean | undefined, } if (typeof input.html === 'string') { - const def = createComponentFromHtml( + const { component: def, inferred } = createComponentFromHtml( canvas.id, { ...shared, @@ -184,14 +257,22 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ actor, ) return { - data: { ok: true, component: summary(canvas, def), main_frame_id: def.mainFrameId }, - note: `Use it with ${usageExample(def)}. Call get_frame_screenshot on main_frame_id, and resize that frame to fit with update_frame.`, + data: { + ok: true, + component: summary(canvas, def), + main_frame_id: def.mainFrameId, + ...inferredProps(inferred), + }, + note: [ + `The main is frame main_frame_id on the Components page. No instance was placed: to use it, write ${usageExample(def)} in a frame's HTML, or call insert_instance. Call get_frame_screenshot on main_frame_id, and resize that frame to fit with update_frame.${inferredNote(inferred)}`, + ...(optional(() => componentReuseNotes(canvas, def, shared.autoProps)) ?? []), + ].join('\n'), frames: outcomeFrames({ canvas } as ToolContext, def), } } if (typeof input.frame_id !== 'string' || typeof input.element !== 'string') throw new ComponentError('pass html, or frame_id with element') - const { component, converted } = createComponentFromElement( + const { component, converted, inferred, matching_stopped } = createComponentFromElement( canvas.id, { ...shared, @@ -207,8 +288,18 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ component: summary(canvas, component), main_frame_id: component.mainFrameId, converted, + ...(matching_stopped ? { matching_stopped } : {}), + ...inferredProps(inferred), }, - note: `Use it with ${usageExample(component)}.`, + note: [ + `Use it with ${usageExample(component)}.${inferredNote(inferred)}`, + ...(matching_stopped + ? [ + 'replace_matching stopped part of the way (the work budget for one call): the frames in `converted` are linked, later frames were not looked at and their copies stay plain markup.', + ] + : []), + ...(optional(() => componentReuseNotes(canvas, component, shared.autoProps)) ?? []), + ].join('\n'), frames: outcomeFrames( { canvas } as ToolContext, component, @@ -217,11 +308,109 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ } }, }, + { + name: 'create_components', + title: 'Create several components', + description: `Make up to ${MAX_BATCH_COMPONENTS} components from new markup in one call: the way to set up a canvas's component system (the primitives and patterns its screens are built from) before the first screen. Each entry takes what create_component takes from html: name, description, html (one root element), css, width, height, props, auto_props, code. Entries are made in order, so a later one can an earlier one: list primitives first (Button, Input, Badge), then what is built from them (Card, NavItem, Sidebar). Each entry stands alone: one that is refused is reported with its reason and the others are still made. The mains land on the Components page and no instance is placed anywhere; use them with in frame HTML. To make a component from an element already in a frame, use create_component.`, + readOnly: false, + shape: { + components: z + .array( + z.object({ + name: z.string().describe('Short and unique, e.g. "Button"'), + description: z.string().optional().describe('When to use this. Later agents choose by it'), + html: z.string().describe('Markup, one root element'), + css: z.string().optional().describe('The rules it needs, unscoped; they get scoped for you'), + width: z.number().optional().describe('The main frame width, default 480'), + height: z.number().optional().describe('The main frame height, default 240'), + props: z.array(propSchema).optional().describe('Enum props, and metadata for bound ones'), + auto_props: z.boolean().optional().describe('false = do not infer props'), + code: codeSchema.optional(), + }), + ) + .min(1) + .max(MAX_BATCH_COMPONENTS) + .describe('In dependency order: a component another one nests comes first'), + }, + run(input, { canvas, actor }) { + const entries = (Array.isArray(input.components) ? input.components : []) as Record[] + if (!entries.length) throw new ComponentError('pass at least one component') + if (entries.length > MAX_BATCH_COMPONENTS) + throw new ComponentError(`at most ${MAX_BATCH_COMPONENTS} components per call; send the rest in another call`) + const made: ComponentDef[] = [] + const refused: string[] = [] + const notes: string[] = [] + const results = entries.map((entry, index) => { + const name = String(entry.name ?? '') + try { + /* each entry is its own unit: a refused one leaves nothing behind and the rest go on */ + const { component: def, inferred } = transaction(() => { + const created = createComponentFromHtml( + canvas.id, + { + name, + description: entry.description as string | undefined, + props: entry.props as never, + code: entry.code as never, + autoProps: entry.auto_props as boolean | undefined, + html: String(entry.html ?? ''), + css: entry.css as string | undefined, + width: entry.width as number | undefined, + height: entry.height as number | undefined, + }, + actor, + ) + /* a naming nothing renders as nothing: saved, the entry would lose that part for + good, so it is refused (undone with this unit) and can be sent again once that one exists */ + const missing = missingNested(created.component) + if (missing.length) + throw new ComponentError( + `it nests ${missing.map((ref) => (ref ? `“${ref}”` : 'a that could not be read')).join(', ')}, which ${missing.length === 1 ? 'is' : 'are'} not a component on this canvas${refused.length ? ' (an entry this call refused, or one never made)' : ''}; nothing was made for it`, + ) + return created + }) + made.push(def) + notes.push( + ...(optional(() => componentReuseNotes(canvas, def, entry.auto_props as boolean | undefined)) ?? []), + ) + return { + index, + ok: true as const, + component: summary(canvas, def), + main_frame_id: def.mainFrameId, + ...inferredProps(inferred), + } + } catch (error) { + /* a refusal is this entry's; a spent work budget refuses the whole call (runComponentTool) */ + if (!(error instanceof ComponentError)) throw error + refused.push(name) + return { index, ok: false as const, name, error: error.message } + } + }) + const failed = results.filter((result) => !result.ok) + const usage = made.map((def) => usageExample(def)).join('\n') + return { + data: { ok: failed.length === 0, created: made.length, failed: failed.length, results }, + note: [ + made.length + ? `Made ${made.length} component${made.length === 1 ? '' : 's'} on the Components page. No instance was placed: compose screens from them with\n${usage}\nCall get_frame_screenshot on a main_frame_id or two, and resize a main to fit with update_frame. Props each one inferred are in its inferred_props.` + : 'Nothing was made.', + ...(failed.length + ? [ + `${failed.length} entr${failed.length === 1 ? 'y was' : 'ies were'} refused (see results): fix ${failed.length === 1 ? 'it' : 'them'} and send ${failed.length === 1 ? 'it' : 'them'} again. An entry that nests a refused one is refused too.`, + ] + : []), + ...notes, + ].join('\n'), + frames: made.flatMap((def) => outcomeFrames({ canvas } as ToolContext, def)), + } + }, + }, { name: 'update_component', title: 'Update a component', description: - "Change a component's main; every instance on the canvas follows at once, keeping its props and overrides, so this is how a sweeping design change is one call rather than one edit per screen. Small changes: find + replace on the template (from get_component). Rewrites: html, keeping data-doop-part attributes where you can so overrides stay attached. The result reports the impact: which frames changed, which approved frames lost sign-off, which overrides no longer have an element to apply to. Pass dry_run=true to read that report first, which you should for a component with many instances. A changed main is one undo-able revision: restore_component_version goes back.", + "Change a component's main; every instance on the canvas follows in the background within moments, keeping its props and overrides, so this is how a sweeping design change is one call rather than one edit per screen. Small changes to the markup: find + replace on the template (from get_component). CSS is not searched: to change a style, pass the whole stylesheet as css. Rewrites: html, keeping data-doop-part attributes where you can so overrides stay attached. The result reports the impact: which frames hold instances and are queued to follow (propagation), how many of them are approved (they keep their sign-off), which overrides no longer have an element to apply to. Pass dry_run=true to read that report first, which you should for a component with many instances. A changed main is one undo-able revision: restore_component_version goes back.", readOnly: false, destructive: true, shape: { @@ -240,7 +429,7 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ expected_rev: z.number().optional().describe('Refuse if the component has moved past this revision'), dry_run: z.boolean().optional().describe('Report the impact and change nothing'), }, - run(input, { canvas, actor }) { + run(input, { canvas, actor, canRead }) { const result = updateComponent( canvas.id, String(input.component), @@ -257,11 +446,32 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ }, actor, ) + /* on a library canvas the impact above counts this canvas alone: say who else follows it */ + const shared = isLibrary(canvas.id) + ? libraryConsumers(canvas).filter((consumer) => canRead(consumer.canvas_id)) + : [] return { - data: { ok: true, ...result, component: summary(canvas, result.component), rev: result.component.rev }, + data: { + ok: true, + ...result, + component: summary(canvas, result.component), + rev: result.component.rev, + ...(shared.length ? { library_used_by: shared } : {}), + }, ...(result.dry_run - ? {} - : { note: IMPACT_NOTE, frames: outcomeFrames({ canvas } as ToolContext, result.component) }), + ? shared.length + ? { + note: 'The impact counts this canvas only. It is a workspace library: the canvases in library_used_by get this change once it is published (publish_library) and each pulls it (sync_component).', + } + : {} + : { + note: [ + ...propagationNote(result), + isLibrary(canvas.id) ? `${IMPACT_NOTE} ${LIBRARY_NOTE}` : IMPACT_NOTE, + ...(optional(() => componentReuseNotes(canvas, result.component)) ?? []), + ].join('\n'), + frames: outcomeFrames({ canvas } as ToolContext, result.component), + }), } }, }, @@ -341,52 +551,83 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ })), actor, ) + /* the change is in: reading the instances back is a courtesy the budget may not cover */ + const instances = optional(() => instancesIn(frame)) return { - data: { ok: true, instances: instancesIn(frame), ...(missing.length ? { not_found: missing } : {}) }, + data: { ok: true, ...(instances ? { instances } : {}), ...(missing.length ? { not_found: missing } : {}) }, + ...(instances ? {} : { note: 'The change was applied. Call get_frame to read the instances back.' }), frames: [frame], } }, }, { - name: 'find_component_candidates', - title: 'Find what should be a component', + name: 'delete_component', + title: 'Delete a component', description: - "Scan a canvas for repeated structures that are not components yet, biggest payoff first: how often each appears, in how many frames, and an example element. On a canvas that grew without components, this is step one. Then call create_component with the example's frame_id and element and replace_matching=true.", - readOnly: true, - shape: { limit: z.number().min(1).max(30).optional() }, - run({ limit }, { canvas }) { - const candidates = findComponentCandidates(canvas, typeof limit === 'number' ? limit : 12) - return { data: { candidates, ...(candidates.length ? {} : { note: 'Nothing repeats on this canvas.' }) } } + 'Delete a component. Nothing changes in any design and no frame is rewritten: its instances keep exactly the markup they have and simply stop following it, its main stays in its frame as ordinary markup, and a component built from it keeps rendering as it did. It leaves the catalog, of it is refused, and get_canvas lists it under deletedComponents while instances of it remain. restore_component brings it back with every instance linked again. Pass detach_instances=true only when the human wants the leftovers to be plain markup for good: that rewrites every frame using it, in the background, and cannot be restored (it also works on a component that is already deleted).', + readOnly: false, + destructive: true, + shape: { + component: COMPONENT_REF, + detach_instances: z + .boolean() + .optional() + .describe('Also turn every instance into plain markup, in the background. Not undone by restore_component'), + }, + run({ component, detach_instances }, { canvas, actor }) { + const ref = String(component) + const pending = findDeletedComponent(canvas.id, ref) + /* detaching what an earlier delete left behind is the same call again */ + const result = + pending && detach_instances === true + ? { deleted: pending.name, component_id: pending.id, already_deleted: true } + : deleteComponent(canvas.id, ref, actor) + const detach = detach_instances === true ? detachAllInstances(canvas.id, result.component_id, actor) : undefined + const touched = detach?.queued ? usageOf(canvas, result.component_id).frames.map((frame) => frame.id) : [] + return { + data: { ok: true, ...result, ...(detach ? { detach } : {}) }, + note: detach + ? detach.queued + ? `Detaching ${detach.instances} instance${detach.instances === 1 ? '' : 's'} in ${detach.frames} frame${detach.frames === 1 ? '' : 's'} in the background, a frame at a time: they become plain markup that keeps its look. This is not undone by restore_component.` + : 'Nothing on the canvas uses it, so there was nothing to detach.' + : 'No frame was changed: its instances look the same and no longer follow it. restore_component brings it back; delete_component with detach_instances=true turns what is left into plain markup.', + frames: canvas.frames.filter((frame) => touched.includes(frame.id)), + } }, }, { - name: 'delete_component', - title: 'Delete a component', + name: 'restore_component', + title: 'Restore a deleted component', description: - 'Delete a component. Nothing disappears from any design: instances stay exactly as they look, as plain markup no longer linked, and the main stays in its frame. Refused while another component is built from it.', + 'Bring back a component that delete_component removed (get_canvas lists those still in use under deletedComponents). Its instances were never changed, so they are linked again as they are, and it is back in the catalog. Its main is the markup that still carries it; if that is gone, a new main is written on the Components page from the kept definition. If its name was given to another component meanwhile it comes back as “ (restored)”. Instances that were detached stay plain markup.', readOnly: false, - destructive: true, - shape: { component: COMPONENT_REF }, + shape: { component: COMPONENT_REF.describe('Name or id of the deleted component') }, run({ component }, { canvas, actor }) { - /* read before the delete: afterwards nothing marks these frames */ - const def = findComponent(canvas.id, String(component)) - const touched = def ? outcomeFrames({ canvas } as ToolContext, def).map((frame) => frame.id) : [] - const result = deleteComponent(canvas.id, String(component), actor) - return { data: { ok: true, ...result }, frames: canvas.frames.filter((frame) => touched.includes(frame.id)) } + const { component: def, main } = restoreComponent(canvas.id, String(component), actor) + return { + data: { ok: true, component: summary(canvas, def), main, main_frame_id: def.mainFrameId }, + note: + main === 'written' + ? 'Its old main was gone, so a new one was written on the Components page (main_frame_id).' + : 'Its instances follow it again.', + frames: outcomeFrames({ canvas } as ToolContext, def), + } }, }, { name: 'restore_component_version', title: 'Restore a component revision', description: - 'Put a component back to an earlier revision (listed by get_component) and carry that to every instance, keeping their props and overrides. It is a new revision, so this can be undone too.', + 'Put a component back to an earlier revision (listed by get_component) and carry that to every instance in the background, keeping their props and overrides. It is a new revision, so this can be undone too.', readOnly: false, destructive: true, shape: { component: COMPONENT_REF, rev: z.number() }, run({ component, rev }, { canvas, actor }) { const result = restoreComponentVersion(canvas.id, String(component), Number(rev), actor) + const note = propagationNote(result).join('\n') return { data: { ok: true, ...result, component: summary(canvas, result.component), rev: result.component.rev }, + ...(note ? { note } : {}), frames: outcomeFrames({ canvas } as ToolContext, result.component), } }, @@ -395,7 +636,7 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ name: 'import_component', title: 'Import a component from a library', description: - 'Copy a component, and whatever it is built from, from another canvas this account can read (see list_components with libraries=true). It stays linked to its origin: a later change there shows up as library_update_available and arrives only when sync_component pulls it, so a library never changes this canvas unasked.', + 'Add a component, and whatever it is built from, from another canvas. From a workspace library (list_components → workspace_libraries) it is linked to what that library published and has no main here: change it on the library canvas. Writing with its name does the same without this call; use this when two libraries publish the same name. From any other canvas this account can read (list_components with libraries=true) it is copied with a main of its own. Either way a later change at the origin shows up as library_update_available and arrives only when sync_component pulls it, so publishing alone never changes this canvas.', readOnly: false, shape: { source_canvas_id: z.string().describe('The library canvas'), @@ -403,7 +644,9 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ }, run({ source_canvas_id, component }, { canvas, actor, canRead }) { const source = String(source_canvas_id) - if (!canRead(source)) throw new ComponentError('this account cannot read that canvas') + /* a workspace library goes by the canvas, like its fonts: whoever may edit here may use it */ + const shared = librariesForCanvas(canvas).some((library) => library.canvasId === source) + if (!shared && !canRead(source)) throw new ComponentError('this account cannot read that canvas') const def = importComponent(canvas.id, source, String(component), actor) return { data: { ok: true, component: summary(canvas, def) }, note: `Use it with ${usageExample(def)}.` } }, @@ -412,11 +655,29 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ name: 'sync_component', title: 'Pull a library update', description: - "Bring an imported component up to its library's current revision, carrying it to every instance here. Local instance overrides are kept; edits made to the local main are replaced.", + "Bring an imported component up to what its library last published (or, for a copy from another canvas, that canvas's current revision), carrying it to every instance here. Without component, pulls every workspace-library update waiting on this canvas in one call. Instance overrides are kept; edits made to a copied main are replaced. Approved frames keep their sign-off. It works on one canvas: after publish_library, call it on each canvas listed in that result's used_by, or use update_library_everywhere on the library canvas when the human wants every canvas updated at once.", readOnly: false, destructive: true, - shape: { component: COMPONENT_REF }, + shape: { + component: COMPONENT_REF.optional().describe('Component name or id; omit for every waiting library update'), + }, run({ component }, { canvas, actor, canRead }) { + if (component === undefined || component === '') { + const waiting = waitingLibraryUpdates(canvas) + const frames = new Map() + const updated: string[] = [] + for (const def of waiting) { + const result = syncComponent(canvas.id, def.id, actor, canRead) + if (!result.updated) continue + updated.push(result.component.name) + for (const frame of outcomeFrames({ canvas } as ToolContext, result.component)) frames.set(frame.id, frame) + } + return { + data: { ok: true, updated: updated.length > 0, components: updated }, + ...(waiting.length ? {} : { note: 'No workspace-library update is waiting on this canvas.' }), + frames: [...frames.values()], + } + } const result = syncComponent(canvas.id, String(component), actor, canRead) return { data: { ok: true, updated: result.updated, component: summary(canvas, result.component) }, @@ -424,33 +685,177 @@ export const COMPONENT_TOOLS: ComponentTool[] = [ } }, }, + { + name: 'publish_library', + title: 'Publish components to the workspace library', + description: + "Share this canvas's components with every canvas in its workspace. Publishing snapshots them: other canvases use the published state, never work in progress, and a canvas already using one sees library_update_available and pulls it when it chooses, so publishing changes no other canvas by itself. The result's used_by lists the canvases using this library and which components each still has to pull (sync_component there, or update_library_everywhere when the human asks for the change on every canvas). Without components, everything this canvas owns is published; with them, only those (each with what it is built from). dry_run=true lists what would be published or removed. unpublish=true stops sharing instead (the named components, or all); canvases using them keep their definition and every instance. Publish when the human asks for it in any words (make this available to the team, share it with our other canvases), not on your own initiative: it is how a team's design system reaches their other canvases. Needs a canvas in a workspace on the Team plan, and a workspace can keep publishing to its owner and admins; when it is refused for either reason, tell the human rather than working around it.", + readOnly: false, + shape: { + components: z.array(z.string()).optional().describe('Component names or ids; omit for all'), + dry_run: z.boolean().optional().describe('Report what would change and publish nothing'), + unpublish: z.boolean().optional().describe('Stop sharing instead of publishing'), + }, + run({ components, dry_run, unpublish }, { canvas, actor, canRead, userId }) { + const refs = Array.isArray(components) && components.length ? components.map(String) : undefined + /* other canvases by name: only the ones this account can open */ + const usedBy = () => libraryConsumers(canvas).filter((consumer) => canRead(consumer.canvas_id)) + if (unpublish === true) { + const result = unpublishFromLibrary(canvas.id, refs, actor, userId) + return { data: { ok: true, unpublished: result.unpublished, is_library: result.library.library } } + } + const result = publishToLibrary(canvas.id, refs, actor, userId, dry_run === true) + const unpublished = result.library.changes.filter((entry) => entry.change !== 'unchanged') + return { + data: { + ok: true, + dry_run: result.dry_run, + published: result.published, + removed: result.removed, + /* whether this canvas shares anything with its workspace right now */ + is_library: result.library.library, + ...(result.dry_run ? {} : { still_unpublished: unpublished.map((entry) => entry.name) }), + used_by: usedBy(), + }, + note: result.dry_run + ? 'Dry run: nothing was published. `published` and `removed` are what a real call would do.' + : 'Published. Canvases in used_by with update_waiting keep the previous version until sync_component is called on each. Only when the human asks for the change everywhere: update_library_everywhere.', + } + }, + }, + { + name: 'update_library_everywhere', + title: 'Update every canvas using this library', + description: + "Pull this library canvas's latest publication into every canvas of the workspace that uses it, in one call: what sync_component does on one canvas, done on all of them. Use it ONLY when the human asks for the change everywhere / across all canvases, never as a follow-up to publish_library on your own initiative: it changes other people's canvases (approved frames keep their sign-off). Run it with dry_run=true first and tell the human what it would touch. It applies what is published, so publish_library comes first (its used_by shows which canvases are waiting). The result reports per canvas which components were updated, how many frames changed (approvals_withdrawn is always 0: approved frames keep their sign-off); skipped lists canvases this account may not edit, or where the pull was refused, and each of those still needs sync_component by someone who can. Relay the report to the human.", + readOnly: false, + destructive: true, + shape: { + dry_run: z.boolean().optional().describe('Report what would change on each canvas and change nothing'), + }, + async run({ dry_run }, { canvas, actor, canEdit, canRead, userId }) { + const report = await updateLibraryConsumers(canvas.id, actor, { + dryRun: dry_run === true, + canEdit, + canRead, + publisherId: userId, + }) + const count = report.canvases.length + return { + data: { ok: true, ...report }, + note: + count + report.skipped.length === 0 + ? 'Every canvas using this library already has its latest publication. Changes made here since then reach nobody until publish_library.' + : report.dry_run + ? 'Dry run: nothing was changed. frames_changed counts the frames holding an instance of what would update; approved frames keep their sign-off. Tell the human before running it for real.' + : `Updated ${count} canvas${count === 1 ? '' : 'es'}. Tell the human which canvases changed${report.skipped.length ? ', and which were skipped and why' : ''}.`, + } + }, + }, ] export const COMPONENT_TOOL_NAMES = COMPONENT_TOOLS.map((tool) => tool.name) +/** Every string a call submits (markup, css, find/replace, prop values), for the base64 check. */ +function submittedText(value: unknown): string { + if (typeof value === 'string') return value + if (Array.isArray(value)) return value.map(submittedText).join('\n') + if (value && typeof value === 'object') return Object.values(value).map(submittedText).join('\n') + return '' +} + +/** What the call's targets already hold: the component (its stored template, styles and head, and + * its main frame) and the frame it writes to. Carrying those over is not a new upload. */ +function currentMarkup(input: Record, context: ToolContext): string { + const parts: string[] = [] + const html = (frameId: unknown) => { + if (typeof frameId !== 'string') return + try { + const frame = store.getFrame(frameId) + if (frame?.canvasId === context.canvas.id) parts.push(frame.html) + } catch { + /* not loaded: nothing to compare against */ + } + } + if (typeof input.component === 'string') { + const def = findComponent(context.canvas.id, input.component) + if (def) { + parts.push(def.template, def.css, def.rawCss, ...def.head) + html(def.mainFrameId) + } + } + html(input.frame_id) + return parts.join('\n') +} + /** Run a tool's handler, turning a ComponentError into a message the agent can act on. */ -export function runComponentTool( +export async function runComponentTool( name: string, input: Record, context: ToolContext, -): { ok: true; result: ToolResult } | { ok: false; error: string } { +): Promise<{ ok: true; result: ToolResult } | { ok: false; error: string }> { const tool = COMPONENT_TOOLS.find((candidate) => candidate.name === name) if (!tool) return { ok: false, error: `unknown tool ${name}` } + const inline = inlineDataRefusal(submittedText(input), currentMarkup(input, context), context.surface) + if (inline) return { ok: false, error: inline } try { - return { ok: true, result: tool.run(input, context) } + /* one unit (server/journal.ts): a refusal comes back as this call's error, not as a + throw out of the operation, so what the tool had changed is undone here. Awaited + inside, so an async tool's ComponentError is caught like any other */ + return { ok: true, result: await transaction(() => tool.run(input, context)) } } catch (error) { - if (error instanceof ComponentError) return { ok: false, error: error.message } + if (error instanceof ComponentError || error instanceof WorkBudgetError) return { ok: false, error: error.message } throw error } } -/** What an agent should hear after writing a frame: what could not be done, and components it redrew by hand. */ -export function componentWriteNotes(frame: Frame): string[] { +/** The usage event a library tool call counts as, if it did something: MCP and + * the resident agent report it on the person the agent works for. */ +export function libraryFeatureEvent(name: string, input: Record, data: unknown): string | undefined { + const result = (data ?? {}) as { updated?: boolean; component?: { library?: unknown }; components?: string[] } + if (name === 'publish_library') + return input.dry_run === true || input.unpublish === true ? undefined : 'library_published' + if (name === 'sync_component') + return result.updated && result.component?.library ? 'library_update_pulled' : undefined + if (name === 'import_component') return result.component?.library ? 'library_component_used' : undefined + if (name === 'update_library_everywhere') return input.dry_run === true ? undefined : 'library_updated_everywhere' + return undefined +} + +/** What an agent should hear after writing a frame: what could not be done, and components it redrew by hand. + * `review` is a whole-frame write (create, replace, a finished stream), which also hears what it should + * have reused: blocks repeated by hand and colours the canvas has as tokens. */ +export function componentWriteNotes(frame: Frame, { review = false }: { review?: boolean } = {}): string[] { const notes = actions.takeComponentIssues(frame.id).map((issue) => `COMPONENT: ${issue.message}`) - for (const lookalike of lookalikesIn(frame)) { + const canvas = review ? store.getCanvas(frame.canvasId) : undefined + if (canvas) notes.push(...(optional(() => frameReuseNotes(canvas, frame)) ?? [])) + /* said after a write that has landed: when the budget is spent, the note is simply not made */ + for (const lookalike of optional(() => lookalikesIn(frame)) ?? []) { notes.push( `COMPONENT: ${lookalike.occurrences} element${lookalike.occurrences === 1 ? '' : 's'} in this frame match${lookalike.occurrences === 1 ? 'es' : ''} “${lookalike.component}” but ${lookalike.occurrences === 1 ? 'is' : 'are'} not linked to it, so ${lookalike.occurrences === 1 ? 'it' : 'they'} will not follow changes. Use ${lookalike.usage} instead.`, ) } return notes } + +/** Frames whose stream has already heard the component-system note: said once, not per chunk. */ +const toldThisStream = new Set() +const SYSTEM_NOTE = 'COMPONENT SYSTEM:' + +/** The notes one chunk of a stream hears. Mid-stream, only the component-system note, the first + * time the screen's markup shows it is being drawn without components (the agent can still change + * course); the last chunk hears the whole review, without that note again. */ +export function streamChunkNotes(frame: Frame, { start, done }: { start?: boolean; done?: boolean }): string[] { + if (start) toldThisStream.delete(frame.id) + const told = toldThisStream.has(frame.id) + if (done) { + toldThisStream.delete(frame.id) + const notes = componentWriteNotes(frame, { review: true }) + return told ? notes.filter((note) => !note.startsWith(SYSTEM_NOTE)) : notes + } + if (told) return [] + const canvas = store.getCanvas(frame.canvasId) + const notes = canvas ? (optional(() => componentSystemNotes(canvas, frame)) ?? []) : [] + if (notes.length) toldThisStream.add(frame.id) + return notes +} diff --git a/server/componentUsage.ts b/server/componentUsage.ts new file mode 100644 index 000000000..0890c035d --- /dev/null +++ b/server/componentUsage.ts @@ -0,0 +1,92 @@ +import { INSTANCE_ATTR } from '../shared/components.ts' +import type { Canvas, Frame } from '../shared/types.ts' + +/** + * Where every component of a canvas is used, from ONE pass over its frames. + * The catalog in get_canvas used to split every frame's HTML once per + * component: components × canvas bytes on each read. Here a frame's HTML is + * scanned once for all instance markers (a string scan, never a parse) and the + * counts are kept until that frame is written again: every frame write moves + * the frame's `updatedAt`, which is what a kept count is checked against. So a + * read after one frame changed scans that one frame, and a read after nothing + * changed scans none. + * + * Only counts are kept, never HTML, so the cache holds nothing a dropped canvas + * (store.evictIdle) would need back, and a canvas that is deleted takes its + * entry along (the cache is keyed weakly by the canvas). + */ + +export interface ComponentUsage { + instances: number + frames: { id: string; name: string; instances: number; approved: boolean }[] +} + +interface FrameCounts { + /** the frame's updatedAt when it was scanned */ + stamp: number + counts: Map +} + +const scanned = new WeakMap>() + +/* the leading space: an element's attribute, not a selector in a stylesheet */ +const MARKER = ` ${INSTANCE_ATTR}="` + +const tally = { passes: 0, framesScanned: 0 } + +/** How often the index walked a canvas, and how many frames it had to read: what tests count. */ +export function usageScans(): { passes: number; framesScanned: number } { + return { ...tally } +} + +/** Instance markers in one document, counted per component id. */ +function countMarkers(html: string): Map { + const counts = new Map() + for (let at = html.indexOf(MARKER); at !== -1; at = html.indexOf(MARKER, at + MARKER.length)) { + const from = at + MARKER.length + const to = html.indexOf('"', from) + if (to === -1) break + const id = html.slice(from, to) + counts.set(id, (counts.get(id) ?? 0) + 1) + } + return counts +} + +function countsOf(kept: Map, frame: Frame): Map { + const known = kept.get(frame.id) + if (known?.stamp === frame.updatedAt) return known.counts + tally.framesScanned += 1 + const counts = countMarkers(frame.html) + kept.set(frame.id, { stamp: frame.updatedAt, counts }) + return counts +} + +/** Usage of every component used anywhere on the canvas, by component id. One pass. */ +export function usageByComponent(canvas: Canvas): Map { + tally.passes += 1 + let kept = scanned.get(canvas) + if (!kept) scanned.set(canvas, (kept = new Map())) + const usage = new Map() + const present = new Set() + for (const frame of canvas.frames) { + present.add(frame.id) + for (const [id, instances] of countsOf(kept, frame)) { + let entry = usage.get(id) + if (!entry) usage.set(id, (entry = { instances: 0, frames: [] })) + entry.instances += instances + /* name and sign-off are read now, not kept: a rename or an approval is not a design write */ + entry.frames.push({ + id: frame.id, + name: frame.name, + instances, + approved: frame.approval?.status === 'ready_for_dev', + }) + } + } + for (const frameId of kept.keys()) if (!present.has(frameId)) kept.delete(frameId) + return usage +} + +export function usageOf(canvas: Canvas, id: string): ComponentUsage { + return usageByComponent(canvas).get(id) ?? { instances: 0, frames: [] } +} diff --git a/server/components.ts b/server/components.ts index 9f6aec78c..1e44931f4 100644 --- a/server/components.ts +++ b/server/components.ts @@ -7,9 +7,11 @@ import { INSTANCE_ATTR, MAX_COMPONENT_HISTORY, OVERRIDES_ATTR, + PART_ATTR, PROPS_ATTR, REV_ATTR, USE_TAG, + isDeleted, type ComponentDef, type ComponentIssue, type ComponentProp, @@ -20,6 +22,7 @@ import { derivePropsAndSlots, expandUses, findMarked, + holdsHollow, renderInstance, reconcileInstance, setAttr, @@ -30,7 +33,9 @@ import { usedComponentIds, type EngineContext, } from './componentEngine.ts' +import { adoptFromLibrary, findInLibraries, LibraryAdoptError } from './componentLibrary.ts' import { store } from './store.ts' +import { noteCanvas } from './workBudget.ts' import type { Canvas } from '../shared/types.ts' /** @@ -47,12 +52,26 @@ export function newComponentId(): string { return `c${componentSuffix()}` } -export function contextFor(canvasId: string): EngineContext { +/** A write may take up a component its workspace library publishes, the first + * time something names it: `added` collects the definitions that joined the canvas. */ +export interface LibraryAdoption { + by: string + added: ComponentDef[] +} + +export function contextFor(canvasId: string, adoption?: LibraryAdoption): EngineContext { const defs = () => store.getComponents(canvasId) - const find = (ref: string) => { + const issues: ComponentIssue[] = [] + /* an id is exact, deleted or not: markup already on the canvas points at it. A name means + the component in use; a deleted one answers to its name only when nothing else has it, + so that asking for it says "deleted" rather than "unknown" */ + const local = (ref: string) => { const wanted = ref.trim().toLowerCase() - return defs().find((def) => def.id === ref) ?? defs().find((def) => def.name.toLowerCase() === wanted) + const named = defs().filter((def) => def.name.toLowerCase() === wanted) + return defs().find((def) => def.id === ref) ?? named.find((def) => !isDeleted(def)) ?? named[0] } + const find = (ref: string) => + local(ref) ?? (adoption && ref ? fromLibrary(canvasId, ref, adoption, issues) : undefined) return { find, atRev(id, rev) { @@ -62,8 +81,41 @@ export function contextFor(canvasId: string): EngineContext { const snapshot = def.history.find((entry) => entry.rev === rev) return snapshot ? { id, name: def.name, rev, template: snapshot.template, props: snapshot.props } : undefined }, - issues: [], + issues, + } +} + +/** Nothing on the canvas has this name: its workspace library may. A local + * component always wins the name, so this is reached only for a new one. */ +function fromLibrary( + canvasId: string, + ref: string, + adoption: LibraryAdoption, + issues: ComponentIssue[], +): ComponentDef | undefined { + const canvas = store.getCanvas(canvasId) + if (!canvas) return undefined + const candidates = findInLibraries(canvas, ref) + const [snapshot] = candidates + if (!snapshot) return undefined + if (candidates.length > 1) { + const where = candidates.map( + (entry) => `${store.getCanvas(entry.canvasId)?.name ?? entry.canvasId} (${entry.canvasId})`, + ) + issues.push({ + code: 'library_ambiguous', + message: `“${ref}” is published by more than one library: ${where.join(', ')}. Call import_component with the source_canvas_id you mean, then use it.`, + }) + return undefined + } + try { + adoption.added.push(...adoptFromLibrary(canvasId, snapshot, adoption.by)) + } catch (error) { + if (!(error instanceof LibraryAdoptError)) throw error + issues.push({ code: 'unknown_component', message: error.message }) + return undefined } + return store.getComponents(canvasId).find((def) => def.id === snapshot.id) } export function referencesComponent(html: string, id: string): boolean { @@ -129,15 +181,47 @@ export function bumpRevision(def: ComponentDef, by: string): ComponentDef { return { ...def, history, rev: def.rev + 1, updatedAt: Date.now(), updatedBy: by } } -function prepareMains(canvas: Canvas, frameId: string, html: string, by: string, ctx: EngineContext) { +/* Revisions update_component has opened and whose main is still to be written. That write is + the rest of the same change, so it fills the open revision instead of adding one: the kept + snapshot stays the state instances were rendered from. Every write is sync, so an entry + never outlives its update. */ +const openRevisions = new Set() + +const revisionKey = (canvasId: string, id: string) => `${canvasId}:${id}` + +/** Run a main's write as part of the revision `bumpRevision` just opened for this component. */ +export function withinRevision(canvasId: string, id: string, write: () => T): T { + const key = revisionKey(canvasId, id) + openRevisions.add(key) + try { + return write() + } finally { + openRevisions.delete(key) + } +} + +/** `only`: the mains to look at, every other one left as it is (a repair of those definitions). */ +function prepareMains( + canvas: Canvas, + frameId: string, + html: string, + by: string, + ctx: EngineContext, + only?: ReadonlySet, +) { const changed: ComponentDef[] = [] const moved: ComponentDef[] = [] const claimed = new Set() const edits: { start: number; end: number; text: string }[] = [] - const sheet = () => frameStylesheets(html) - const headTags = () => frameHeadTags(html) + /* each parses the whole frame, so once per call, not once per main: a frame + holding hundreds of mains re-parsed itself hundreds of times per propagation */ + let sheetCache: string | undefined + let headCache: string[] | undefined + const sheet = () => (sheetCache ??= frameStylesheets(html)) + const headTags = () => [...(headCache ??= frameHeadTags(html))] for (const found of findMarked(html, COMPONENT_ATTR)) { const id = attrOf(found.el, COMPONENT_ATTR) ?? '' + if (only && !only.has(id)) continue const def = store.getComponents(canvas.id).find((candidate) => candidate.id === id) if (!def) { /* pasted from a canvas that does not have this component: plain markup here */ @@ -149,12 +233,17 @@ function prepareMains(canvas: Canvas, frameId: string, html: string, by: string, }) continue } + /* frozen: the main of a deleted component is markup of this frame alone. An edit to it + (an old client's save, a paste) changes neither the definition nor its status */ + if (isDeleted(def)) continue const mainElsewhere = def.mainFrameId !== null && def.mainFrameId !== frameId && !!store.getFrame(def.mainFrameId)?.html.includes(`${COMPONENT_ATTR}="${id}"`) - if (claimed.has(id) || mainElsewhere || !frameId) { - /* a copy of a main is an instance, the way copying a Figma main is */ + if (claimed.has(id) || mainElsewhere || !frameId || def.source?.library) { + /* a copy of a main is an instance, the way copying a Figma main is; and a + library component's main lives on its library canvas, so one pasted + here (it has no main of its own to be "elsewhere") is an instance too */ const rendered = renderInstance(def, def, {}, '', { ctx, stack: [] }) if (rendered) edits.push({ start: found.start, end: found.end, text: serializeOuter(rendered) }) continue @@ -183,7 +272,7 @@ function prepareMains(canvas: Canvas, frameId: string, html: string, by: string, if (same && def.mainFrameId === frameId) continue /* a main coming back with the same content is not a new revision */ const next: ComponentDef = - same || def.rev === 0 + same || def.rev === 0 || openRevisions.has(revisionKey(canvas.id, id)) ? { ...def, rev: def.rev || 1, updatedAt: Date.now(), updatedBy: by } : bumpRevision(def, by) const saved = { ...next, template, css, rawCss, head, props, slots, mainFrameId: frameId } @@ -192,8 +281,8 @@ function prepareMains(canvas: Canvas, frameId: string, html: string, by: string, else moved.push(saved) } /* a main this frame held and no longer does: the component lives on without one */ - for (const def of store.getComponents(canvas.id)) { - if (def.mainFrameId !== frameId || !frameId || claimed.has(def.id)) continue + for (const def of only ? [] : store.getComponents(canvas.id)) { + if (def.mainFrameId !== frameId || !frameId || claimed.has(def.id) || isDeleted(def)) continue if (html.includes(`${COMPONENT_ATTR}="${def.id}"`)) continue const saved = { ...def, mainFrameId: null, updatedAt: Date.now(), updatedBy: by } store.saveComponent(canvas.id, saved) @@ -202,6 +291,23 @@ function prepareMains(canvas: Canvas, frameId: string, html: string, by: string, return { html: edits.length ? splice(html, edits) : html, changed, moved } } +/** + * Re-derive these definitions from their mains in this frame, as a write of the frame would, + * and nothing else: no other main is looked at and no instance is rendered again. `html` is + * the frame as the pass would leave it; it differs only where a main needed part keys. + */ +export function rederiveFromMains( + canvas: Canvas, + frameId: string, + ids: ReadonlySet, + by: string, +): { html: string; saved: ComponentDef[] } { + const frame = store.getFrame(frameId) + if (!frame) return { html: '', saved: [] } + const mains = prepareMains(canvas, frameId, frame.html, by, contextFor(canvas.id), ids) + return { html: mains.html, saved: [...mains.changed, ...mains.moved] } +} + function prepareInstances(html: string, ctx: EngineContext) { const edits: { start: number; end: number; text: string }[] = [] for (const found of findMarked(html, INSTANCE_ATTR)) { @@ -213,11 +319,17 @@ function prepareInstances(html: string, ctx: EngineContext) { edits.push({ start: found.start, end: found.end, text: serializeOuter(found.el) }) continue } + /* its component was deleted: the instance keeps the markup it has, untouched. So does one + holding an instance of a hollow component: rendered again, that instance would be lost */ + if (isDeleted(def) || holdsHollow(found.el, ctx)) continue const before = serializeOuter(found.el) const state = reconcileInstance(found.el, ctx) if (!state) continue - const rendered = renderInstance(def, def, state.overrides, state.instanceId, { ctx, stack: [] }) + /* only a whole write gets here: nothing more is coming for the content it holds */ + const rendered = renderInstance(def, def, state.overrides, state.instanceId, { ctx, stack: [], final: true }) if (!rendered) continue + /* the key it has is its place in what holds it (a main), not the component's own root key */ + setAttr(rendered, PART_ATTR, attrOf(found.el, PART_ATTR) ?? null) const after = serializeOuter(rendered) if (after !== before) edits.push({ start: found.start, end: found.end, text: after }) } @@ -231,6 +343,8 @@ export interface PreparedHtml { changed: ComponentDef[] /** components whose main only moved (here, or out of this frame): the room needs the new location */ moved: ComponentDef[] + /** components this write took up from the workspace library: the room needs them, and their tokens */ + adopted: ComponentDef[] } export function prepareFrameHtml( @@ -243,11 +357,13 @@ export function prepareFrameHtml( if (!touchesComponents(incoming)) { const lost = frameId && priorHtml.includes(`${COMPONENT_ATTR}="`) const moved = lost ? prepareMains(canvas, frameId, incoming, by, contextFor(canvas.id)).moved : [] - return { html: incoming, issues: removedInstanceIssues(priorHtml, incoming), changed: [], moved } + return { html: incoming, issues: removedInstanceIssues(priorHtml, incoming), changed: [], moved, adopted: [] } } - const ctx = contextFor(canvas.id) + const adoption: LibraryAdoption = { by, added: [] } + const ctx = contextFor(canvas.id, adoption) + noteCanvas(canvas.id) try { - const expanded = expandUses(incoming, ctx) + const expanded = expandUses(incoming, ctx, [], 0, { final: true }) const mains = prepareMains(canvas, frameId, expanded, by, ctx) const instances = prepareInstances(mains.html, ctx) const html = syncComponentHead(instances, closureOf(usedComponentIds(instances), canvas.id)) @@ -256,15 +372,20 @@ export function prepareFrameHtml( issues: dedupeIssues([...ctx.issues, ...removedInstanceIssues(priorHtml, html)]), changed: mains.changed, moved: mains.moved, + adopted: adoption.added, } } catch (error) { - /* markup nested past the call stack: the write itself still has to land */ + /* out of budget part of the way: the operation's write boundary (server/journal.ts) + undoes a main folded into its definition and a component taken up from the library, + so neither outlives the frame write that is now not happening. + Markup nested past the call stack: the write itself still has to land */ if (!(error instanceof RangeError)) throw error return { html: incoming, issues: [{ code: 'too_deep', message: 'this markup is nested too deeply for its components to be updated' }], changed: [], moved: [], + adopted: adoption.added, } } } @@ -286,7 +407,7 @@ function removedInstanceIssues(prior: string, next: string): ComponentIssue[] { ] } -function dedupeIssues(issues: ComponentIssue[]): ComponentIssue[] { +export function dedupeIssues(issues: ComponentIssue[]): ComponentIssue[] { const seen = new Set() return issues.filter((issue) => { if (seen.has(issue.message)) return false @@ -298,14 +419,21 @@ function dedupeIssues(issues: ComponentIssue[]): ComponentIssue[] { /** One chunk of a live stream: components render as they arrive, each stylesheet * once and in place, since the head may already have gone by. The last chunk's * full pass moves them where they belong. */ -export function prepareChunk(canvas: Canvas, chunk: string, soFar: string): string { - if (!chunk.toLowerCase().includes(`<${USE_TAG}`)) return chunk - const ctx = contextFor(canvas.id) +export function prepareChunk( + canvas: Canvas, + chunk: string, + soFar: string, + by: string, +): { html: string; issues: ComponentIssue[]; adopted: ComponentDef[] } { + if (!chunk.toLowerCase().includes(`<${USE_TAG}`)) return { html: chunk, issues: [], adopted: [] } + const adoption: LibraryAdoption = { by, added: [] } + const ctx = contextFor(canvas.id, adoption) const expanded = expandUses(chunk, ctx) const styles = closureOf(usedComponentIds(expanded), canvas.id) .filter((def) => def.css.trim() && !soFar.includes(`${CSS_ATTR}="${def.id}"`)) .map((def) => ``) - return `${styles.join('\n')}${expanded}` + /* a use expanded here is gone by the last chunk's pass: what it had to say is said now */ + return { html: `${styles.join('\n')}${expanded}`, issues: ctx.issues, adopted: adoption.added } } /** A blank component, before its main has been written: the first prepare fills it in. */ diff --git a/server/customAgentRoutes.ts b/server/customAgentRoutes.ts new file mode 100644 index 000000000..6c53eb859 --- /dev/null +++ b/server/customAgentRoutes.ts @@ -0,0 +1,149 @@ +import { Router, type Request, type Response } from 'express' +import { + parseBuiltInAgentPatch, + parseCustomAgentInput, + parseCustomAgentPatch, + type AgentScope, +} from '../shared/customAgents.ts' +import { + AgentInputError, + createCustomAgent, + deleteCustomAgent, + listBuiltInAgents, + listCustomAgents, + resetBuiltInAgent, + updateBuiltInAgent, + updateCustomAgent, +} from './customAgents.ts' +import { isWorkspaceMember } from './workspaces.ts' +import { broadcastCustomAgents } from './actions.ts' +import { captureFeature } from './featureEvents.ts' + +/** /api/agents: the custom agents Settings and Workspace manage, and under + * /api/agents/builtin the same team's changes to the built-in agents. `?workspace=` + * names a workspace's (members only); without it they are the signed-in + * person's own, used on their personal canvases. The /api session gate + * upstream means impersonating admins can look but not change anything. */ +export const customAgentsRouter = Router() + +/** Whether a person may read and change a scope's agents. */ +function canUseAgentScope(scope: AgentScope, userId: string): boolean { + return 'personal' in scope || isWorkspaceMember(scope.workspaceId, userId) +} + +function scopeOf(req: Request, res: Response): AgentScope | null { + const workspace = req.query.workspace + const scope: AgentScope = typeof workspace === 'string' && workspace ? { workspaceId: workspace } : { personal: true } + if (canUseAgentScope(scope, req.user!.id)) return scope + res.status(403).json({ error: 'you are not a member of this workspace' }) + return null +} + +function announce(scope: AgentScope, userId: string) { + broadcastCustomAgents('workspaceId' in scope ? scope : { ownerId: userId }) +} + +function failed(res: Response, e: unknown, what: string) { + if (e instanceof AgentInputError) res.status(400).json({ error: e.message }) + else { + console.error(`[agents] ${what} failed`, e) + res.status(500).json({ error: `the agent could not be ${what === 'delete' ? 'removed' : 'saved'} — try again` }) + } +} + +customAgentsRouter.get('/', (req, res) => { + const scope = scopeOf(req, res) + if (scope) res.json(listCustomAgents(scope, req.user!.id)) +}) + +customAgentsRouter.post('/', async (req, res) => { + const scope = scopeOf(req, res) + if (!scope) return + const input = parseCustomAgentInput(req.body) + if (!input.ok) return res.status(400).json({ error: input.error }) + const userId = req.user!.id + try { + const agent = await createCustomAgent(scope, userId, input.value, () => canUseAgentScope(scope, userId)) + announce(scope, userId) + captureFeature(userId, 'custom_agent_created', 'ui', { + scope: 'workspaceId' in scope ? 'workspace' : 'personal', + reviewer: input.value.reviewer, + }) + res.json(agent) + } catch (e) { + failed(res, e, 'create') + } +}) + +customAgentsRouter.patch('/:handle', async (req, res) => { + const scope = scopeOf(req, res) + if (!scope) return + const patch = parseCustomAgentPatch(req.body) + if (!patch.ok) return res.status(400).json({ error: patch.error }) + const userId = req.user!.id + try { + const agent = await updateCustomAgent(scope, userId, req.params.handle, patch.value, () => + canUseAgentScope(scope, userId), + ) + if (!agent) return res.status(404).json({ error: 'agent not found' }) + announce(scope, userId) + res.json(agent) + } catch (e) { + failed(res, e, 'update') + } +}) + +customAgentsRouter.delete('/:handle', async (req, res) => { + const scope = scopeOf(req, res) + if (!scope) return + const userId = req.user!.id + try { + if (!(await deleteCustomAgent(scope, userId, req.params.handle, () => canUseAgentScope(scope, userId)))) + return res.status(404).json({ error: 'agent not found' }) + announce(scope, userId) + res.json({ ok: true }) + } catch (e) { + failed(res, e, 'delete') + } +}) + +/* the built-in agents as this team has them: on or off, and edited */ +customAgentsRouter.get('/builtin', (req, res) => { + const scope = scopeOf(req, res) + if (scope) res.json(listBuiltInAgents(scope, req.user!.id)) +}) + +customAgentsRouter.patch('/builtin/:id', async (req, res) => { + const scope = scopeOf(req, res) + if (!scope) return + const patch = parseBuiltInAgentPatch(req.params.id, req.body) + if (!patch.ok) return res.status(400).json({ error: patch.error }) + const userId = req.user!.id + try { + const agent = await updateBuiltInAgent(scope, userId, req.params.id, patch.value, () => + canUseAgentScope(scope, userId), + ) + if (!agent) return res.status(404).json({ error: 'agent not found' }) + announce(scope, userId) + if (patch.value.disabled !== undefined) + captureFeature(userId, 'builtin_agent_toggled', 'ui', { role: req.params.id, enabled: !patch.value.disabled }) + res.json(agent) + } catch (e) { + failed(res, e, 'update') + } +}) + +/* undo the team's edits to a built-in agent; on or off stays */ +customAgentsRouter.delete('/builtin/:id', async (req, res) => { + const scope = scopeOf(req, res) + if (!scope) return + const userId = req.user!.id + try { + const agent = await resetBuiltInAgent(scope, userId, req.params.id, () => canUseAgentScope(scope, userId)) + if (!agent) return res.status(404).json({ error: 'agent not found' }) + announce(scope, userId) + res.json(agent) + } catch (e) { + failed(res, e, 'update') + } +}) diff --git a/server/customAgents.ts b/server/customAgents.ts new file mode 100644 index 000000000..d5c9b36bf --- /dev/null +++ b/server/customAgents.ts @@ -0,0 +1,325 @@ +import { nanoid } from 'nanoid' +import { and, eq } from 'drizzle-orm' +import { db } from './db/index.ts' +import * as t from './db/schema.ts' +import { AGENT_ROLES, type AgentRole, type Roster } from '../shared/agents.ts' +import { + MAX_CUSTOM_AGENTS, + type AgentScope, + type BuiltInAgent, + type BuiltInAgentPatch, + type CustomAgent, + type CustomAgentInput, + type CustomAgentPatch, +} from '../shared/customAgents.ts' + +/** + * Custom agents (shared/customAgents.ts) and each team's changes to the + * built-in ones (`agent_overrides`). Read on every comment, card and + * resident run, so the whole table is mirrored in memory at boot and kept + * current by the writes below; the database is written before the mirror. + * + * Who may change a scope is the caller's question (server/customAgentRoutes.ts + * asks workspace membership). Writes take it as `allowed` and ask again once + * their turn in the scope's queue comes, since membership can end meanwhile; + * this module stays free of the store, which persist.ts imports it beside. + */ + +type AgentRow = typeof t.customAgents.$inferSelect +type OverrideRow = typeof t.agentOverrides.$inferSelect + +const rows = new Map() +/** by `overrideKey(scope, roleId)` */ +const overrides = new Map() + +function overrideKey(scope: string, roleId: string): string { + return `${scope}\n${roleId}` +} + +export class AgentInputError extends Error {} + +export async function hydrateCustomAgents(): Promise { + const [all, changed] = await Promise.all([db.select().from(t.customAgents), db.select().from(t.agentOverrides)]) + rows.clear() + for (const row of all) rows.set(row.id, row) + overrides.clear() + for (const row of changed) overrides.set(overrideKey(row.scope, row.roleId), row) +} + +/** A built-in agent with one team's changes applied. */ +function withOverride(role: AgentRole, row: OverrideRow | undefined): AgentRole { + if (!row) return role + return { + ...role, + ...(row.color ? { color: row.color } : {}), + ...(row.blurb ? { blurb: row.blurb } : {}), + ...(row.brief ? { brief: row.brief, briefByTeam: true } : {}), + ...(row.reviewer !== null ? { reviewer: row.reviewer } : {}), + } +} + +function builtInsIn(key: string): BuiltInAgent[] { + return AGENT_ROLES.map((role) => { + const row = overrides.get(overrideKey(key, role.id)) + const edited = !!row && (!!row.color || !!row.blurb || !!row.brief || row.reviewer !== null) + return { ...withOverride(role, row), enabled: !row?.disabled, edited } + }) +} + +/** The built-in team as one scope has it, switched-off agents included. */ +export function listBuiltInAgents(scope: AgentScope, userId: string): BuiltInAgent[] { + return builtInsIn(scopeKey(scope, userId)) +} + +function scopeKey(scope: AgentScope, userId: string): string { + return 'workspaceId' in scope ? `ws:${scope.workspaceId}` : `user:${userId}` +} + +function toAgent(row: AgentRow): CustomAgent { + return { + id: row.handle, + name: row.name, + color: row.color, + blurb: row.blurb, + brief: row.brief, + ...(row.reviewer ? { reviewer: true } : {}), + custom: true, + createdAt: row.createdAt, + } +} + +function rowsIn(key: string): AgentRow[] { + return [...rows.values()].filter((row) => row.scope === key).sort((a, b) => a.createdAt - b.createdAt) +} + +export function listCustomAgents(scope: AgentScope, userId: string): CustomAgent[] { + return rowsIn(scopeKey(scope, userId)).map(toAgent) +} + +/** The scope a canvas takes its agents from: its workspace's, or its owner's. */ +function canvasScopeKey(canvas: { workspaceId?: string | null; ownerId?: string | null }): string | undefined { + if (canvas.workspaceId) return `ws:${canvas.workspaceId}` + return canvas.ownerId ? `user:${canvas.ownerId}` : undefined +} + +export function customAgentsForCanvas(canvas: { workspaceId?: string | null; ownerId?: string | null }): CustomAgent[] { + const key = canvasScopeKey(canvas) + return key ? rowsIn(key).map(toAgent) : [] +} + +/** A canvas's team as its viewers get it (the canvas GET, the room): + * everything the mention picker and the marks need, but no instructions, + * which stay with the people who manage the agents (anyone with a view link + * would read them otherwise). */ +export function teamOfCanvas(canvas: { workspaceId?: string | null; ownerId?: string | null }): AgentRole[] { + return rosterFor(canvas).map(({ briefByTeam: _briefByTeam, ...role }) => ({ ...role, brief: '' })) +} + +/** The team a canvas's work is addressed with: the built-in agents its team + * has on (with its changes), then its custom agents. The built-in team as it + * ships for a canvas that is gone or has no owner. */ +export function rosterFor(canvas: { workspaceId?: string | null; ownerId?: string | null } | undefined): Roster { + const key = canvas && canvasScopeKey(canvas) + if (!key) return AGENT_ROLES + const builtIns = builtInsIn(key) + .filter((role) => role.enabled) + .map(({ enabled: _enabled, edited: _edited, ...role }) => role) + return [...builtIns, ...rowsIn(key).map(toAgent)] +} + +const scopeChains = new Map>() + +/** Run a scope's writes one after another, so two creations racing for one + * handle are checked one at a time. */ +function inScopeOrder(key: string, work: () => Promise): Promise { + const next = (scopeChains.get(key) ?? Promise.resolve()).then(work, work) + const settled = next.catch(() => {}) + scopeChains.set(key, settled) + void settled.then(() => { + if (scopeChains.get(key) === settled) scopeChains.delete(key) + }) + return next +} + +export async function createCustomAgent( + scope: AgentScope, + userId: string, + input: CustomAgentInput, + allowed: () => boolean, +): Promise { + const key = scopeKey(scope, userId) + return inScopeOrder(key, async () => { + /* checked in the queue: the person may have left the workspace meanwhile */ + if (!allowed()) throw new AgentInputError('this workspace no longer exists or you left it') + const existing = rowsIn(key) + if (existing.length >= MAX_CUSTOM_AGENTS) + throw new AgentInputError(`a team has room for ${MAX_CUSTOM_AGENTS} custom agents — remove one first`) + if (existing.some((r) => r.handle === input.handle)) + throw new AgentInputError(`@${input.handle} is already taken here`) + if (existing.some((r) => r.name.toLowerCase() === input.name.toLowerCase())) + throw new AgentInputError(`${input.name} is already on the team`) + const now = Date.now() + const row: AgentRow = { + id: nanoid(10), + scope: key, + handle: input.handle, + name: input.name, + color: input.color, + blurb: input.blurb, + brief: input.brief, + reviewer: input.reviewer, + createdBy: userId, + createdAt: now, + updatedAt: now, + } + await db.insert(t.customAgents).values(row) + rows.set(row.id, row) + return toAgent(row) + }) +} + +function findRow(key: string, handle: string): AgentRow | undefined { + for (const row of rows.values()) if (row.scope === key && row.handle === handle) return row + return undefined +} + +export async function updateCustomAgent( + scope: AgentScope, + userId: string, + handle: string, + patch: CustomAgentPatch, + allowed: () => boolean, +): Promise { + const key = scopeKey(scope, userId) + return inScopeOrder(key, async () => { + const row = findRow(key, handle) + if (!row || !allowed()) return undefined + const next: AgentRow = { ...row, ...patch, updatedAt: Date.now() } + await db + .update(t.customAgents) + .set({ + color: next.color, + blurb: next.blurb, + brief: next.brief, + reviewer: next.reviewer, + updatedAt: next.updatedAt, + }) + .where(eq(t.customAgents.id, row.id)) + rows.set(row.id, next) + return toAgent(next) + }) +} + +/** Remove an agent. Work still waiting on it goes to the default agent + * (`roleName` falls back), and its finished work keeps its name. */ +export async function deleteCustomAgent( + scope: AgentScope, + userId: string, + handle: string, + allowed: () => boolean, +): Promise { + const key = scopeKey(scope, userId) + return inScopeOrder(key, async () => { + const row = findRow(key, handle) + if (!row || !allowed()) return false + await db.delete(t.customAgents).where(eq(t.customAgents.id, row.id)) + rows.delete(row.id) + return true + }) +} + +/** Change a built-in agent for one scope. Fields left out keep their current + * value; a row that ends up changing nothing is removed. */ +export async function updateBuiltInAgent( + scope: AgentScope, + userId: string, + roleId: string, + patch: BuiltInAgentPatch, + allowed: () => boolean, +): Promise { + const key = scopeKey(scope, userId) + const stock = AGENT_ROLES.find((role) => role.id === roleId) + if (!stock) return undefined + return inScopeOrder(key, async () => { + if (!allowed()) throw new AgentInputError('this workspace no longer exists or you left it') + const current = overrides.get(overrideKey(key, roleId)) + /* a value equal to how the agent ships is stored as no change, so + "Reset" and an edit back to the original read the same */ + const differs = (value: T | undefined, shipped: T | undefined, kept: T | null): T | null => + value === undefined ? kept : value === shipped ? null : value + const next: OverrideRow = { + scope: key, + roleId, + disabled: patch.disabled ?? current?.disabled ?? false, + color: differs(patch.color, stock.color.toUpperCase(), current?.color ?? null), + blurb: differs(patch.blurb, stock.blurb, current?.blurb ?? null), + brief: differs(patch.brief, stock.brief, current?.brief ?? null), + reviewer: differs(patch.reviewer, stock.reviewer ?? false, current?.reviewer ?? null), + updatedBy: userId, + updatedAt: Date.now(), + } + await writeOverride(next) + return builtInsIn(key).find((role) => role.id === roleId) + }) +} + +/** Undo a team's edits to a built-in agent; whether it is on stays as it is. */ +export async function resetBuiltInAgent( + scope: AgentScope, + userId: string, + roleId: string, + allowed: () => boolean, +): Promise { + const key = scopeKey(scope, userId) + if (!AGENT_ROLES.some((role) => role.id === roleId)) return undefined + return inScopeOrder(key, async () => { + if (!allowed()) throw new AgentInputError('this workspace no longer exists or you left it') + const disabled = overrides.get(overrideKey(key, roleId))?.disabled ?? false + await writeOverride({ + scope: key, + roleId, + disabled, + color: null, + blurb: null, + brief: null, + reviewer: null, + updatedBy: userId, + updatedAt: Date.now(), + }) + return builtInsIn(key).find((role) => role.id === roleId) + }) +} + +async function writeOverride(row: OverrideRow): Promise { + const unchanged = !row.disabled && !row.color && !row.blurb && !row.brief && row.reviewer === null + if (unchanged) return removeOverride(row.scope, row.roleId) + await db + .insert(t.agentOverrides) + .values(row) + .onConflictDoUpdate({ target: [t.agentOverrides.scope, t.agentOverrides.roleId], set: row }) + overrides.set(overrideKey(row.scope, row.roleId), row) +} + +async function removeOverride(scope: string, roleId: string): Promise { + await db.delete(t.agentOverrides).where(and(eq(t.agentOverrides.scope, scope), eq(t.agentOverrides.roleId, roleId))) + overrides.delete(overrideKey(scope, roleId)) +} + +/** Drop a deleted workspace's agents. */ +export async function dropWorkspaceAgents(workspaceId: string): Promise { + await dropScope(`ws:${workspaceId}`) +} + +/** Drop a deleted account's own agents. */ +export async function dropPersonalAgents(userId: string): Promise { + await dropScope(`user:${userId}`) +} + +async function dropScope(key: string): Promise { + await inScopeOrder(key, async () => { + await db.delete(t.customAgents).where(eq(t.customAgents.scope, key)) + await db.delete(t.agentOverrides).where(eq(t.agentOverrides.scope, key)) + for (const [id, row] of rows) if (row.scope === key) rows.delete(id) + for (const [id, row] of overrides) if (row.scope === key) overrides.delete(id) + }) +} diff --git a/server/db/migrations/0053_library_components.sql b/server/db/migrations/0053_library_components.sql new file mode 100644 index 000000000..92edbdc00 --- /dev/null +++ b/server/db/migrations/0053_library_components.sql @@ -0,0 +1,17 @@ +CREATE TABLE "library_components" ( + "canvas_id" text NOT NULL, + "id" text NOT NULL, + "name" text NOT NULL, + "description" text NOT NULL, + "template" text NOT NULL, + "css" text NOT NULL, + "raw_css" text NOT NULL, + "head" jsonb NOT NULL, + "props" jsonb NOT NULL, + "slots" jsonb NOT NULL, + "code" jsonb, + "rev" integer NOT NULL, + "published_at" bigint NOT NULL, + "published_by" text NOT NULL, + CONSTRAINT "library_components_canvas_id_id_pk" PRIMARY KEY("canvas_id","id") +); diff --git a/server/db/migrations/0054_library_publish_policy.sql b/server/db/migrations/0054_library_publish_policy.sql new file mode 100644 index 000000000..a7b8ad796 --- /dev/null +++ b/server/db/migrations/0054_library_publish_policy.sql @@ -0,0 +1 @@ +ALTER TABLE "workspaces" ADD COLUMN "library_publish" text; \ No newline at end of file diff --git a/server/db/migrations/0055_library_nested_sources.sql b/server/db/migrations/0055_library_nested_sources.sql new file mode 100644 index 000000000..12b0e309f --- /dev/null +++ b/server/db/migrations/0055_library_nested_sources.sql @@ -0,0 +1 @@ +ALTER TABLE "library_components" ADD COLUMN "nested" jsonb; \ No newline at end of file diff --git a/server/db/migrations/0056_work_replies.sql b/server/db/migrations/0056_work_replies.sql new file mode 100644 index 000000000..b88bd69a4 --- /dev/null +++ b/server/db/migrations/0056_work_replies.sql @@ -0,0 +1,2 @@ +ALTER TABLE "feedback" ADD COLUMN "reply" text;--> statement-breakpoint +ALTER TABLE "tasks" ADD COLUMN "reply" text; \ No newline at end of file diff --git a/server/db/migrations/0057_custom_agents.sql b/server/db/migrations/0057_custom_agents.sql new file mode 100644 index 000000000..42abd123b --- /dev/null +++ b/server/db/migrations/0057_custom_agents.sql @@ -0,0 +1,30 @@ +CREATE TABLE "agent_overrides" ( + "scope" text NOT NULL, + "role_id" text NOT NULL, + "disabled" boolean DEFAULT false NOT NULL, + "color" text, + "blurb" text, + "brief" text, + "reviewer" boolean, + "updated_by" text NOT NULL, + "updated_at" bigint NOT NULL, + CONSTRAINT "agent_overrides_scope_role_id_pk" PRIMARY KEY("scope","role_id") +); +--> statement-breakpoint +CREATE TABLE "custom_agents" ( + "id" text PRIMARY KEY NOT NULL, + "scope" text NOT NULL, + "handle" text NOT NULL, + "name" text NOT NULL, + "color" text NOT NULL, + "blurb" text NOT NULL, + "brief" text NOT NULL, + "reviewer" boolean DEFAULT false NOT NULL, + "created_by" text NOT NULL, + "created_at" bigint NOT NULL, + "updated_at" bigint NOT NULL +); +--> statement-breakpoint +ALTER TABLE "feedback" ADD COLUMN "claimed_by_resident" boolean;--> statement-breakpoint +CREATE UNIQUE INDEX "custom_agents_scope_handle_idx" ON "custom_agents" USING btree ("scope","handle");--> statement-breakpoint +CREATE UNIQUE INDEX "custom_agents_scope_name_idx" ON "custom_agents" USING btree ("scope","name"); \ No newline at end of file diff --git a/server/db/migrations/0058_component_soft_delete.sql b/server/db/migrations/0058_component_soft_delete.sql new file mode 100644 index 000000000..5bb290c46 --- /dev/null +++ b/server/db/migrations/0058_component_soft_delete.sql @@ -0,0 +1,3 @@ +ALTER TABLE "components" ADD COLUMN "status" text DEFAULT 'active' NOT NULL;--> statement-breakpoint +ALTER TABLE "components" ADD COLUMN "deleted_at" bigint;--> statement-breakpoint +ALTER TABLE "components" ADD COLUMN "deleted_by" text; \ No newline at end of file diff --git a/server/db/migrations/0059_workspace_seats_bought.sql b/server/db/migrations/0059_workspace_seats_bought.sql new file mode 100644 index 000000000..d17f68d29 --- /dev/null +++ b/server/db/migrations/0059_workspace_seats_bought.sql @@ -0,0 +1 @@ +ALTER TABLE "workspaces" ADD COLUMN "seats_bought" integer DEFAULT 1 NOT NULL; \ No newline at end of file diff --git a/server/db/migrations/meta/0053_snapshot.json b/server/db/migrations/meta/0053_snapshot.json new file mode 100644 index 000000000..16bed23fa --- /dev/null +++ b/server/db/migrations/meta/0053_snapshot.json @@ -0,0 +1,4755 @@ +{ + "id": "ea4926d8-80a5-4579-9c32-2ff5a5932435", + "prevId": "313297c1-0d2e-48c7-a896-4d2f07d14551", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0054_snapshot.json b/server/db/migrations/meta/0054_snapshot.json new file mode 100644 index 000000000..02d3c2a33 --- /dev/null +++ b/server/db/migrations/meta/0054_snapshot.json @@ -0,0 +1,4761 @@ +{ + "id": "88dabd62-6be7-4282-bfbc-ff23c9ada6ed", + "prevId": "ea4926d8-80a5-4579-9c32-2ff5a5932435", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0055_snapshot.json b/server/db/migrations/meta/0055_snapshot.json new file mode 100644 index 000000000..c9c6ef30d --- /dev/null +++ b/server/db/migrations/meta/0055_snapshot.json @@ -0,0 +1,4767 @@ +{ + "id": "58b524eb-757d-437a-b7fa-d2a37a436c16", + "prevId": "88dabd62-6be7-4282-bfbc-ff23c9ada6ed", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nested": { + "name": "nested", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0056_snapshot.json b/server/db/migrations/meta/0056_snapshot.json new file mode 100644 index 000000000..87081b161 --- /dev/null +++ b/server/db/migrations/meta/0056_snapshot.json @@ -0,0 +1,4779 @@ +{ + "id": "d464cfab-9f9a-47a9-af94-1b69d5c06a53", + "prevId": "58b524eb-757d-437a-b7fa-d2a37a436c16", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nested": { + "name": "nested", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0057_snapshot.json b/server/db/migrations/meta/0057_snapshot.json new file mode 100644 index 000000000..54a646d1c --- /dev/null +++ b/server/db/migrations/meta/0057_snapshot.json @@ -0,0 +1,4981 @@ +{ + "id": "5c6d5327-d707-46a3-b1f3-c9860294f893", + "prevId": "d464cfab-9f9a-47a9-af94-1b69d5c06a53", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_overrides": { + "name": "agent_overrides", + "schema": "", + "columns": { + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "agent_overrides_scope_role_id_pk": { + "name": "agent_overrides_scope_role_id_pk", + "columns": ["scope", "role_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.custom_agents": { + "name": "custom_agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "custom_agents_scope_handle_idx": { + "name": "custom_agents_scope_handle_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "custom_agents_scope_name_idx": { + "name": "custom_agents_scope_name_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by_resident": { + "name": "claimed_by_resident", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nested": { + "name": "nested", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0058_snapshot.json b/server/db/migrations/meta/0058_snapshot.json new file mode 100644 index 000000000..b5b885d15 --- /dev/null +++ b/server/db/migrations/meta/0058_snapshot.json @@ -0,0 +1,5000 @@ +{ + "id": "4feda452-6efc-4d76-aaa3-6ba4dc1a0f34", + "prevId": "5c6d5327-d707-46a3-b1f3-c9860294f893", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_overrides": { + "name": "agent_overrides", + "schema": "", + "columns": { + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "agent_overrides_scope_role_id_pk": { + "name": "agent_overrides_scope_role_id_pk", + "columns": ["scope", "role_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "deleted_at": { + "name": "deleted_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.custom_agents": { + "name": "custom_agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "custom_agents_scope_handle_idx": { + "name": "custom_agents_scope_handle_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "custom_agents_scope_name_idx": { + "name": "custom_agents_scope_name_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by_resident": { + "name": "claimed_by_resident", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nested": { + "name": "nested", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/0059_snapshot.json b/server/db/migrations/meta/0059_snapshot.json new file mode 100644 index 000000000..3c6abfe56 --- /dev/null +++ b/server/db/migrations/meta/0059_snapshot.json @@ -0,0 +1,5007 @@ +{ + "id": "1180ab66-a1b3-4550-970e-f586cac2f865", + "prevId": "4feda452-6efc-4d76-aaa3-6ba4dc1a0f34", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.activity": { + "name": "activity", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_name": { + "name": "actor_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "actor_color": { + "name": "actor_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "activity_canvas_idx": { + "name": "activity_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_defaults": { + "name": "agent_defaults", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_feedback": { + "name": "agent_feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tool": { + "name": "tool", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client": { + "name": "client", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_feedback_at_idx": { + "name": "agent_feedback_at_idx", + "columns": [ + { + "expression": "at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_keys": { + "name": "agent_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret_hash": { + "name": "secret_hash", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "agent_keys_user_idx": { + "name": "agent_keys_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "agent_keys_hash_idx": { + "name": "agent_keys_hash_idx", + "columns": [ + { + "expression": "secret_hash", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.agent_overrides": { + "name": "agent_overrides", + "schema": "", + "columns": { + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "agent_overrides_scope_role_id_pk": { + "name": "agent_overrides_scope_role_id_pk", + "columns": ["scope", "role_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.asset_refs": { + "name": "asset_refs", + "schema": "", + "columns": { + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "asset_refs_frame_idx": { + "name": "asset_refs_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "asset_refs_asset_id_frame_id_pk": { + "name": "asset_refs_asset_id_frame_id_pk", + "columns": ["asset_id", "frame_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.assets": { + "name": "assets", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "described_at": { + "name": "described_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "described_by": { + "name": "described_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_attempts": { + "name": "describe_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "describe_payer_id": { + "name": "describe_payer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "describe_provider": { + "name": "describe_provider", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "assets_canvas_idx": { + "name": "assets_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_approvals": { + "name": "automation_approvals", + "schema": "", + "columns": { + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "approved_at": { + "name": "approved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automation_approvals_event_idx": { + "name": "automation_approvals_event_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "approved_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automation_runs": { + "name": "automation_runs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "automation_id": { + "name": "automation_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "state": { + "name": "state", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "lease_until": { + "name": "lease_until", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "automation_runs_automation_idx": { + "name": "automation_runs_automation_idx", + "columns": [ + { + "expression": "automation_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.automations": { + "name": "automations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "schedule": { + "name": "schedule", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "trigger": { + "name": "trigger", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'{\"type\":\"schedule\"}'::jsonb" + }, + "approval_since": { + "name": "approval_since", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "steps": { + "name": "steps", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "next_run_at": { + "name": "next_run_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "automations_owner_idx": { + "name": "automations_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "automations_next_run_idx": { + "name": "automations_next_run_idx", + "columns": [ + { + "expression": "next_run_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.backgrounds": { + "name": "backgrounds", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "tone": { + "name": "tone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "avg_color": { + "name": "avg_color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "palette": { + "name": "palette", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "tags": { + "name": "tags", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "text_zone": { + "name": "text_zone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvas_members": { + "name": "canvas_members", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "canvas_members_canvas_id_user_id_pk": { + "name": "canvas_members_canvas_id_user_id_pk", + "columns": ["canvas_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.canvases": { + "name": "canvases", + "schema": "", + "columns": { + "pages": { + "name": "pages", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "guides": { + "name": "guides", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "token_themes": { + "name": "token_themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "link_access": { + "name": "link_access", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "copy_count": { + "name": "copy_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_id": { + "name": "element_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "element_origin": { + "name": "element_origin", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "selector": { + "name": "selector", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "snippet": { + "name": "snippet", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "for_agent": { + "name": "for_agent", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "parent_id": { + "name": "parent_id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "comments_canvas_idx": { + "name": "comments_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.components": { + "name": "components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "main_frame_id": { + "name": "main_frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "history": { + "name": "history", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "deleted_at": { + "name": "deleted_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "components_canvas_id_id_pk": { + "name": "components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.custom_agents": { + "name": "custom_agents", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "handle": { + "name": "handle", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "blurb": { + "name": "blurb", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "brief": { + "name": "brief", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "reviewer": { + "name": "reviewer", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "custom_agents_scope_handle_idx": { + "name": "custom_agents_scope_handle_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "handle", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "custom_agents_scope_name_idx": { + "name": "custom_agents_scope_name_idx", + "columns": [ + { + "expression": "scope", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.decisions": { + "name": "decisions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "distilled_at": { + "name": "distilled_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "decisions_canvas_idx": { + "name": "decisions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.design_tokens": { + "name": "design_tokens", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "themes": { + "name": "themes", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "order": { + "name": "order", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "design_tokens_canvas_id_name_pk": { + "name": "design_tokens_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.feedback": { + "name": "feedback", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "target_agent": { + "name": "target_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "from_name": { + "name": "from_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_user_id": { + "name": "from_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "delivered_at": { + "name": "delivered_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "claimed_by": { + "name": "claimed_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_by_resident": { + "name": "claimed_by_resident", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "completed_at": { + "name": "completed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "feedback_canvas_idx": { + "name": "feedback_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.fonts": { + "name": "fonts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "family": { + "name": "family", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "weight": { + "name": "weight", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "style": { + "name": "style", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "asset_id": { + "name": "asset_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ext": { + "name": "ext", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "file_name": { + "name": "file_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_by": { + "name": "uploaded_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "fonts_workspace_idx": { + "name": "fonts_workspace_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "fonts_owner_idx": { + "name": "fonts_owner_idx", + "columns": [ + { + "expression": "owner_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frame_versions": { + "name": "frame_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_by_kind": { + "name": "saved_by_kind", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frame_versions_frame_idx": { + "name": "frame_versions_frame_idx", + "columns": [ + { + "expression": "frame_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "frame_versions_canvas_idx": { + "name": "frame_versions_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.frames": { + "name": "frames", + "schema": "", + "columns": { + "page_id": { + "name": "page_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "demo": { + "name": "demo", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "hidden": { + "name": "hidden", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "locked": { + "name": "locked", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "z": { + "name": "z", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "rotation": { + "name": "rotation", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "approval": { + "name": "approval", + "type": "jsonb", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "frames_canvas_idx": { + "name": "frames_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.github_connections": { + "name": "github_connections", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "repo": { + "name": "repo", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "installation_id": { + "name": "installation_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "deploy_url": { + "name": "deploy_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_synced_at": { + "name": "last_synced_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "github_connections_canvas_idx": { + "name": "github_connections_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guideline_versions": { + "name": "guideline_versions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "saved_at": { + "name": "saved_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "saved_by": { + "name": "saved_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "guideline_versions_doc_idx": { + "name": "guideline_versions_doc_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.guidelines": { + "name": "guidelines", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "markdown": { + "name": "markdown", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "guidelines_canvas_id_name_pk": { + "name": "guidelines_canvas_id_name_pk", + "columns": ["canvas_id", "name"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_description_prefs": { + "name": "image_description_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'account'" + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.image_prefs": { + "name": "image_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.instance_settings": { + "name": "instance_settings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "email_password_signup": { + "name": "email_password_signup", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "sso_auto_redirect": { + "name": "sso_auto_redirect", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "default_workspace_id": { + "name": "default_workspace_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_by": { + "name": "updated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.integrations": { + "name": "integrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "account_name": { + "name": "account_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "accounts": { + "name": "accounts", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "integrations_user_provider_idx": { + "name": "integrations_user_provider_idx", + "columns": [ + { + "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": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.library_components": { + "name": "library_components", + "schema": "", + "columns": { + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "template": { + "name": "template", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "css": { + "name": "css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "raw_css": { + "name": "raw_css", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "head": { + "name": "head", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "props": { + "name": "props", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "slots": { + "name": "slots", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "code": { + "name": "code", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "nested": { + "name": "nested", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "rev": { + "name": "rev", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "published_at": { + "name": "published_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "published_by": { + "name": "published_by", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "library_components_canvas_id_id_pk": { + "name": "library_components_canvas_id_id_pk", + "columns": ["canvas_id", "id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_installations": { + "name": "linear_installations", + "schema": "", + "columns": { + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "app_user_id": { + "name": "app_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "linear_installations_user_id_unique": { + "name": "linear_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_oauth_states": { + "name": "linear_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "verifier": { + "name": "verifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.linear_sessions": { + "name": "linear_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "issue_id": { + "name": "issue_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_id": { + "name": "ack_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "result_id": { + "name": "result_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "linear_sessions_status_idx": { + "name": "linear_sessions_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.live_activities": { + "name": "live_activities", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_payload": { + "name": "last_payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_timestamp": { + "name": "last_timestamp", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "live_activities_token_unique": { + "name": "live_activities_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.live_activity_starters": { + "name": "live_activity_starters", + "schema": "", + "columns": { + "token": { + "name": "token", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.local_agent_preferences": { + "name": "local_agent_preferences", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'default'" + }, + "effort": { + "name": "effort", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_proposals": { + "name": "memory_proposals", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_name": { + "name": "guide_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "guide_title": { + "name": "guide_title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rule": { + "name": "rule", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "rationale": { + "name": "rationale", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "based_on": { + "name": "based_on", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "at": { + "name": "at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "resolved_by": { + "name": "resolved_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "memory_proposals_canvas_idx": { + "name": "memory_proposals_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.memory_references": { + "name": "memory_references", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "frame_id": { + "name": "frame_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "html": { + "name": "html", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "pinned_by": { + "name": "pinned_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "pinned_at": { + "name": "pinned_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "memory_references_canvas_idx": { + "name": "memory_references_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.model_accounts": { + "name": "model_accounts", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "api_key": { + "name": "api_key", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom": { + "name": "custom", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "model_accounts_user_id_kind_pk": { + "name": "model_accounts_user_id_kind_pk", + "columns": ["user_id", "kind"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notification_prefs": { + "name": "notification_prefs", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "comment_emails": { + "name": "comment_emails", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.resident_usage": { + "name": "resident_usage", + "schema": "", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "used": { + "name": "used", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_installations": { + "name": "slack_installations", + "schema": "", + "columns": { + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_user_id": { + "name": "bot_user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "bot_token": { + "name": "bot_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "connected_at": { + "name": "connected_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "slack_installations_user_id_unique": { + "name": "slack_installations_user_id_unique", + "nullsNotDistinct": false, + "columns": ["user_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_oauth_states": { + "name": "slack_oauth_states", + "schema": "", + "columns": { + "hash": { + "name": "hash", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.slack_sessions": { + "name": "slack_sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "thread_ts": { + "name": "thread_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "requester_id": { + "name": "requester_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_url": { + "name": "response_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "follow_up": { + "name": "follow_up", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ack_ts": { + "name": "ack_ts", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "bigint", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "acknowledged": { + "name": "acknowledged", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "linked": { + "name": "linked", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "reported": { + "name": "reported", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "slack_sessions_status_idx": { + "name": "slack_sessions_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "slack_sessions_thread_idx": { + "name": "slack_sessions_thread_idx", + "columns": [ + { + "expression": "team_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "thread_ts", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_edges": { + "name": "sync_edges", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "from_page": { + "name": "from_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "count": { + "name": "count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "sync_edges_key_id_from_page_to_page_pk": { + "name": "sync_edges_key_id_from_page_to_page_pk", + "columns": ["key_id", "from_page", "to_page"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_keys": { + "name": "sync_keys", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_used_at": { + "name": "last_used_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_keys_canvas_idx": { + "name": "sync_keys_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "sync_keys_secret_idx": { + "name": "sync_keys_secret_idx", + "columns": [ + { + "expression": "secret", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.sync_links": { + "name": "sync_links", + "schema": "", + "columns": { + "key_id": { + "name": "key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "page": { + "name": "page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "to_page": { + "name": "to_page", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "x": { + "name": "x", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "y": { + "name": "y", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "width": { + "name": "width", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "height": { + "name": "height", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "sync_links_page_idx": { + "name": "sync_links_page_idx", + "columns": [ + { + "expression": "key_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "page", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "canvas_id": { + "name": "canvas_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner": { + "name": "owner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "started_at": { + "name": "started_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "ended_at": { + "name": "ended_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "auto": { + "name": "auto", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "queued_by": { + "name": "queued_by", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failed_at": { + "name": "failed_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "failure_reason": { + "name": "failure_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "pipeline": { + "name": "pipeline", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "queued_by_user_id": { + "name": "queued_by_user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "frame_ids": { + "name": "frame_ids", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "runner": { + "name": "runner", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reply": { + "name": "reply", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "tasks_canvas_idx": { + "name": "tasks_canvas_idx", + "columns": [ + { + "expression": "canvas_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.webhooks": { + "name": "webhooks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "events": { + "name": "events", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "last_status": { + "name": "last_status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_at": { + "name": "last_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + } + }, + "indexes": { + "webhooks_user_idx": { + "name": "webhooks_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_invites": { + "name": "workspace_invites", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "invited_by": { + "name": "invited_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_invites_workspace_email_idx": { + "name": "workspace_invites_workspace_email_idx", + "columns": [ + { + "expression": "workspace_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "workspace_invites_email_idx": { + "name": "workspace_invites_email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspace_members": { + "name": "workspace_members", + "schema": "", + "columns": { + "workspace_id": { + "name": "workspace_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_by": { + "name": "added_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "added_at": { + "name": "added_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "workspace_members_user_idx": { + "name": "workspace_members_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "workspace_members_workspace_id_user_id_pk": { + "name": "workspace_members_workspace_id_user_id_pk", + "columns": ["workspace_id", "user_id"] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.workspaces": { + "name": "workspaces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "owner_id": { + "name": "owner_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'inactive'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "seats": { + "name": "seats", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 0 + }, + "seats_bought": { + "name": "seats_bought", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "current_period_end": { + "name": "current_period_end", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "cancel_at_period_end": { + "name": "cancel_at_period_end", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "billing_event_at": { + "name": "billing_event_at", + "type": "bigint", + "primaryKey": false, + "notNull": false + }, + "library_publish": { + "name": "library_publish", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "bigint", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "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", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "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.oauth_access_token": { + "name": "oauth_access_token", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_access_token_access_token_unique": { + "name": "oauth_access_token_access_token_unique", + "nullsNotDistinct": false, + "columns": ["access_token"] + }, + "oauth_access_token_refresh_token_unique": { + "name": "oauth_access_token_refresh_token_unique", + "nullsNotDistinct": false, + "columns": ["refresh_token"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_application": { + "name": "oauth_application", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "client_secret": { + "name": "client_secret", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "redirect_urls": { + "name": "redirect_urls", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "disabled": { + "name": "disabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "oauth_application_client_id_unique": { + "name": "oauth_application_client_id_unique", + "nullsNotDistinct": false, + "columns": ["client_id"] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.oauth_consent": { + "name": "oauth_consent", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "scopes": { + "name": "scopes", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "consent_given": { + "name": "consent_given", + "type": "boolean", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "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", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "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 + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "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": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": ["token"] + } + }, + "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", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + }, + "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", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/server/db/migrations/meta/_journal.json b/server/db/migrations/meta/_journal.json index 0b0ebe1c3..97af13d43 100644 --- a/server/db/migrations/meta/_journal.json +++ b/server/db/migrations/meta/_journal.json @@ -365,6 +365,55 @@ "when": 1794352711304, "tag": "0052_components", "breakpoints": true + }, + { + "idx": 53, + "version": "7", + "when": 1794364584915, + "tag": "0053_library_components", + "breakpoints": true + }, + { + "idx": 54, + "version": "7", + "when": 1794369628411, + "tag": "0054_library_publish_policy", + "breakpoints": true + }, + { + "idx": 55, + "version": "7", + "when": 1794371994196, + "tag": "0055_library_nested_sources", + "breakpoints": true + }, + { + "idx": 56, + "version": "7", + "when": 1794387792095, + "tag": "0056_work_replies", + "breakpoints": true + }, + { + "idx": 57, + "version": "7", + "when": 1794391031591, + "tag": "0057_custom_agents", + "breakpoints": true + }, + { + "idx": 58, + "version": "7", + "when": 1794449184067, + "tag": "0058_component_soft_delete", + "breakpoints": true + }, + { + "idx": 59, + "version": "7", + "when": 1794783638191, + "tag": "0059_workspace_seats_bought", + "breakpoints": true } ] } diff --git a/server/db/persist.ts b/server/db/persist.ts index 55fd58d0d..2db93b1e6 100644 --- a/server/db/persist.ts +++ b/server/db/persist.ts @@ -5,10 +5,10 @@ import { and, desc, eq, inArray, sql } from 'drizzle-orm' import { db } from './index.ts' import * as t from './schema.ts' import { extractAssetIds } from '../assets.ts' -import { roleByAgentName } from '../../shared/agents.ts' +import { AGENT_ROLES, roleByAgentName } from '../../shared/agents.ts' import { isCommunityCategory } from '../../shared/types.ts' import { storedLinkAccess } from '../../shared/canvasRole.ts' -import type { ComponentDef } from '../../shared/components.ts' +import type { ComponentDef, LibraryComponent } from '../../shared/components.ts' import type { DesignToken, TokenType } from '../../shared/designTokens.ts' import { parseRunnerPick } from '../../shared/agentRunner.ts' import { byStack } from '../../shared/frameStack.ts' @@ -154,7 +154,6 @@ export function deleteMember(canvasId: string, userId: string) { ) } -/* Single-shot writes (one save per explicit edit) — no debounce needed. */ function componentRow(canvasId: string, def: ComponentDef) { return { canvasId, @@ -172,16 +171,105 @@ function componentRow(canvasId: string, def: ComponentDef) { code: def.code ?? null, source: def.source ?? null, history: def.history, + status: def.status ?? ('active' as const), + deletedAt: def.deletedAt ?? null, + deletedBy: def.deletedBy ?? null, createdAt: def.createdAt, updatedAt: def.updatedAt, updatedBy: def.updatedBy, } } +/* + * Writes to one component row go one at a time, and only the latest state waits: a create + * saves a blank definition and then the filled one, and on a pooled connection two + * fire-and-forget upserts land in either order. The blank one landing last left a hollow + * row that the next boot loaded as the component (2026-11-11: 236 definitions, 7%). A write + * that fails is retried while nothing newer waits, and logged when it gives up. + */ +interface RowQueue { + next: (() => Promise) | undefined + drained: Promise +} + +const componentWrites = new Map() + +/** How long to wait before each retry of a failed component write. */ +export const COMPONENT_WRITE_RETRIES_MS = [500, 5_000, 30_000] + +/* a retry waiting out its delay: shutdown cuts the wait short, so the write gets its last try */ +const retryWaits = new Set<() => void>() +let draining = false + +const pause = (ms: number) => + draining + ? Promise.resolve() + : new Promise((resolve) => { + const wake = () => { + clearTimeout(timer) + retryWaits.delete(wake) + resolve() + } + const timer = setTimeout(wake, ms) + retryWaits.add(wake) + }) + +function queueComponentWrite(canvasId: string, id: string, write: () => Promise) { + const key = `${canvasId}\0${id}` + const queued = componentWrites.get(key) + if (queued) { + queued.next = write + return + } + const queue: RowQueue = { next: write, drained: Promise.resolve() } + componentWrites.set(key, queue) + queue.drained = drainComponentWrites(key, queue) +} + +async function drainComponentWrites(key: string, queue: RowQueue) { + try { + for (let write = queue.next; write; write = queue.next) { + queue.next = undefined + await writeWithRetries(key, write, queue) + } + } finally { + componentWrites.delete(key) + } +} + +async function writeWithRetries(key: string, write: () => Promise, queue: RowQueue) { + for (let attempt = 0; ; attempt++) { + try { + await write() + return + } catch (error) { + /* a newer state is waiting: it replaces this one, so this one need not land */ + if (queue.next) return + const wait = COMPONENT_WRITE_RETRIES_MS[attempt] + if (wait === undefined) { + console.error(`[db] component write failed for good: ${key.replace('\0', '/')}`, error) + return + } + console.error(`[db] component write failed, retrying in ${wait}ms: ${key.replace('\0', '/')}`, error) + await pause(wait) + if (queue.next) return + } + } +} + +/** Every queued component write, settled: what a canvas delete waits for (so a queued save + * cannot put a row back afterwards), and what a test awaits. */ +export function pendingComponentWrites(canvasId?: string): Promise { + const prefix = canvasId === undefined ? '' : `${canvasId}\0` + return Promise.allSettled( + [...componentWrites].filter(([key]) => key.startsWith(prefix)).map(([, queue]) => queue.drained), + ) +} + export function saveComponent(canvasId: string, def: ComponentDef) { const row = componentRow(canvasId, def) const { canvasId: _canvasId, id: _id, createdAt: _createdAt, ...set } = row - swallow( + queueComponentWrite(canvasId, def.id, () => db .insert(t.components) .values(row) @@ -189,8 +277,51 @@ export function saveComponent(canvasId: string, def: ComponentDef) { ) } +/** + * The components with an instance stored at an older revision than the component: the + * frames a propagation never reached (the queue lives in memory, so a restart mid-drain + * drops it; the kill switch of 2026-11-11 deferred it). Read in the database, where matching + * every frame's HTML costs the server nothing. + */ +export async function componentsBehind(): Promise<{ canvasId: string; componentId: string }[]> { + const result = await db.execute(sql` + select distinct c.canvas_id as "canvasId", c.id as "componentId" + from components c + join frames f on f.canvas_id = c.canvas_id + and position('data-doop-instance="' || c.id || '"' in f.html) > 0 + cross join lateral regexp_matches(f.html, 'data-doop-instance="' || c.id || '" data-doop-rev="(\\d+)"', 'g') as m + where coalesce(c.status, 'active') = 'active' and c.rev > 1 and m[1]::int < c.rev`) + return (result as unknown as { rows: { canvasId: string; componentId: string }[] }).rows +} + export function deleteComponent(canvasId: string, id: string) { - swallow(db.delete(t.components).where(and(eq(t.components.canvasId, canvasId), eq(t.components.id, id)))) + queueComponentWrite(canvasId, id, () => + db.delete(t.components).where(and(eq(t.components.canvasId, canvasId), eq(t.components.id, id))), + ) +} + +export function saveLibraryComponent(snapshot: LibraryComponent) { + const row = { ...snapshot, code: snapshot.code ?? null, nested: snapshot.nested ?? null } + const { canvasId: _canvasId, id: _id, ...set } = row + swallow( + db + .insert(t.libraryComponents) + .values(row) + .onConflictDoUpdate({ target: [t.libraryComponents.canvasId, t.libraryComponents.id], set }), + ) +} + +export function deleteLibraryComponent(canvasId: string, id: string) { + swallow( + db + .delete(t.libraryComponents) + .where(and(eq(t.libraryComponents.canvasId, canvasId), eq(t.libraryComponents.id, id))), + ) +} + +export async function loadLibraryComponents(): Promise { + const rows = await db.select().from(t.libraryComponents).orderBy(t.libraryComponents.name) + return rows.map(({ code, nested, ...row }) => ({ ...row, ...(code ? { code } : {}), ...(nested ? { nested } : {}) })) } export function saveGuideline(canvasId: string, doc: GuidelineDoc) { @@ -723,12 +854,21 @@ export function deleteCanvas(canvasId: string) { ) .then(() => db.delete(t.frames).where(eq(t.frames.canvasId, canvasId))), ) - swallow(db.delete(t.tasks).where(eq(t.tasks.canvasId, canvasId))) - swallow(db.delete(t.feedback).where(eq(t.feedback.canvasId, canvasId))) + /* a queued task or feedback write (a run's reply, then its completion) + would otherwise re-insert its row after the delete */ + swallow(pendingRowWrites(taskWrites, canvasId).then(() => db.delete(t.tasks).where(eq(t.tasks.canvasId, canvasId)))) + swallow( + pendingRowWrites(feedbackWrites, canvasId).then(() => + db.delete(t.feedback).where(eq(t.feedback.canvasId, canvasId)), + ), + ) swallow(db.delete(t.comments).where(eq(t.comments.canvasId, canvasId))) swallow(db.delete(t.activity).where(eq(t.activity.canvasId, canvasId))) swallow(db.delete(t.guidelines).where(eq(t.guidelines.canvasId, canvasId))) - swallow(db.delete(t.components).where(eq(t.components.canvasId, canvasId))) + swallow( + pendingComponentWrites(canvasId).then(() => db.delete(t.components).where(eq(t.components.canvasId, canvasId))), + ) + swallow(db.delete(t.libraryComponents).where(eq(t.libraryComponents.canvasId, canvasId))) swallow(db.delete(t.guidelineVersions).where(eq(t.guidelineVersions.canvasId, canvasId))) swallow( pendingTokenWrites(canvasId).then(() => db.delete(t.designTokens).where(eq(t.designTokens.canvasId, canvasId))), @@ -797,7 +937,26 @@ function repoCardFields(kind: string | null, payload: string | null): Pick>() +/* queued writes per row id, with the canvas each belongs to, so deleting a + canvas can wait for its rows' writes instead of having one land after */ +interface QueuedWrite { + canvasId: string + write: Promise +} + +/** Chain `write` after the row's earlier writes, in order. */ +function queueRowWrite(queue: Map, id: string, canvasId: string, write: () => Promise) { + const queued = (queue.get(id)?.write ?? Promise.resolve()).then(write, write) + queue.set(id, { canvasId, write: queued }) + swallow(queued.finally(() => queue.get(id)?.write === queued && queue.delete(id))) +} + +/** Settles once every write queued so far for this canvas's rows has. */ +function pendingRowWrites(queue: Map, canvasId: string): Promise { + return Promise.allSettled([...queue.values()].filter((q) => q.canvasId === canvasId).map((q) => q.write)) +} + +const taskWrites = new Map() export function saveTask(canvasId: string, task: AgentTask) { const row = { @@ -823,6 +982,7 @@ export function saveTask(canvasId: string, task: AgentTask) { scope: task.scope ? JSON.stringify(task.scope) : null, frameIds: task.frameIds?.join(',') ?? null, runner: task.runner ? JSON.stringify(task.runner) : null, + reply: task.reply ?? null, } const write = () => db @@ -841,13 +1001,17 @@ export function saveTask(canvasId: string, task: AgentTask) { pipeline: row.pipeline, stage: row.stage, frameIds: row.frameIds, + reply: row.reply, }, }) - const queued = (taskWrites.get(task.id) ?? Promise.resolve()).then(write, write) - taskWrites.set(task.id, queued) - swallow(queued.finally(() => taskWrites.get(task.id) === queued && taskWrites.delete(task.id))) + queueRowWrite(taskWrites, task.id, canvasId, write) } +/* One feedback row is often saved twice in a row (its reply, then its + completion), and each write carries the whole state. Without an order the + older write can land last and undo the newer one, so writes per row queue. */ +const feedbackWrites = new Map() + export function saveFeedback(fb: TaskFeedback) { const row = { id: fb.id, @@ -861,12 +1025,14 @@ export function saveFeedback(fb: TaskFeedback) { at: fb.at, deliveredAt: fb.deliveredAt ?? null, claimedBy: fb.claimedBy ?? null, + claimedByResident: fb.claimedByResident ?? null, completedAt: fb.completedAt ?? null, failedAt: fb.failedAt ?? null, failureReason: fb.failureReason ?? null, runner: fb.runner ? JSON.stringify(fb.runner) : null, + reply: fb.reply ?? null, } - swallow( + const write = () => db .insert(t.feedback) .values(row) @@ -875,12 +1041,14 @@ export function saveFeedback(fb: TaskFeedback) { set: { deliveredAt: row.deliveredAt, claimedBy: row.claimedBy, + claimedByResident: row.claimedByResident, completedAt: row.completedAt, failedAt: row.failedAt, failureReason: row.failureReason, + reply: row.reply, }, - }), - ) + }) + queueRowWrite(feedbackWrites, fb.id, fb.canvasId, write) } export function saveComment(c: ElementComment) { @@ -975,6 +1143,9 @@ export async function flush(getFrame: (id: string) => Frame | undefined): Promis }), ) await pendingVersionWrites(() => true) + draining = true + for (const wake of [...retryWaits]) wake() + await pendingComponentWrites() } /* ------------------------------------------------------------------ */ @@ -1083,8 +1254,13 @@ export async function hydrate(): Promise { for (const row of componentRows) { const c = byId.get(row.canvasId) if (!c) continue - const { canvasId: _canvasId, code, source, ...def } = row - ;(c.components ??= []).push({ ...def, ...(code ? { code } : {}), ...(source ? { source } : {}) }) + const { canvasId: _canvasId, code, source, status, deletedAt, deletedBy, ...def } = row + ;(c.components ??= []).push({ + ...def, + ...(code ? { code } : {}), + ...(source ? { source } : {}), + ...(status === 'deleted' ? { status, deletedAt: deletedAt ?? def.updatedAt, deletedBy: deletedBy ?? '' } : {}), + }) } for (const g of guidelineRows) { const c = byId.get(g.canvasId) @@ -1156,6 +1332,7 @@ export async function hydrate(): Promise { ...scopeField(row.scope), ...(row.frameIds ? { frameIds: row.frameIds.split(',').filter(Boolean) } : {}), ...runnerField(row.runner), + ...(row.reply != null ? { reply: row.reply } : {}), }) tasks.set(row.canvasId, list) } @@ -1164,10 +1341,12 @@ export async function hydrate(): Promise { for (const row of feedbackRows) { const list = feedback.get(row.canvasId) ?? [] if (list.length >= LOG_CAP) continue - /* only resident agents run in-process; feedback claimed by an outside MCP - agent may still be in flight elsewhere, so it is left alone */ + /* only resident runs are in-process; feedback claimed by an outside MCP + agent may still be in flight elsewhere, so it is left alone. The claim + records which it was, since a custom agent may share an outside agent's + name; a claim from before that record could only be a built-in's */ const interrupted = - roleByAgentName(row.claimedBy ?? undefined) != null && + (row.claimedByResident ?? roleByAgentName(row.claimedBy ?? undefined, AGENT_ROLES) != null) && row.deliveredAt != null && row.completedAt == null && row.failedAt == null @@ -1187,9 +1366,11 @@ export async function hydrate(): Promise { at: row.at, ...(row.deliveredAt != null ? { deliveredAt: row.deliveredAt } : {}), ...(row.claimedBy != null ? { claimedBy: row.claimedBy } : {}), + ...(row.claimedByResident != null ? { claimedByResident: row.claimedByResident } : {}), ...(row.completedAt != null ? { completedAt: row.completedAt } : {}), ...(failedAt !== undefined ? { failedAt } : {}), ...(failureReason !== undefined ? { failureReason } : {}), + ...(row.reply != null ? { reply: row.reply } : {}), }) feedback.set(row.canvasId, list) } diff --git a/server/db/schema.ts b/server/db/schema.ts index d225c6af1..30faa5406 100644 --- a/server/db/schema.ts +++ b/server/db/schema.ts @@ -110,6 +110,9 @@ export const workspaces = pgTable('workspaces', { interval: text('interval'), /** the paid seat count Stripe is billing for */ seats: integer('seats').notNull().default(0), + /** the seats the owner chose to pay for: the billed quantity is this or + * the member count, whichever is larger, so invites fill bought seats first */ + seatsBought: integer('seats_bought').notNull().default(1), stripeCustomerId: text('stripe_customer_id'), stripeSubscriptionId: text('stripe_subscription_id'), /** epoch ms the current billing period ends (= the next renewal) */ @@ -118,6 +121,9 @@ export const workspaces = pgTable('workspaces', { /** Stripe's `created` of the last subscription event applied (epoch s) — * an older event arriving late must not roll the mirror back */ billingEventAt: bigint('billing_event_at', { mode: 'number' }), + /** who may publish to the workspace's component library: 'admins' (owner and + * admins only); null is everyone who can edit the library canvas */ + libraryPublish: text('library_publish'), createdAt: bigint('created_at', { mode: 'number' }).notNull(), updatedAt: bigint('updated_at', { mode: 'number' }).notNull(), }) @@ -362,6 +368,8 @@ export const tasks = pgTable( frameIds: text('frame_ids'), /** JSON RunnerPick: the connection and model the composer picked for a card */ runner: text('runner'), + /** a card's agent answer: the latest run's closing words */ + reply: text('reply'), }, (t) => [index('tasks_canvas_idx').on(t.canvasId)], ) @@ -380,11 +388,17 @@ export const feedback = pgTable( at: bigint('at', { mode: 'number' }).notNull(), deliveredAt: bigint('delivered_at', { mode: 'number' }), claimedBy: text('claimed_by'), + /** the claim came from a resident run (in-process), not an outside agent + * that happens to share a resident's name; null on claims made before + * custom agents, when only built-in names were resident */ + claimedByResident: boolean('claimed_by_resident'), completedAt: bigint('completed_at', { mode: 'number' }), failedAt: bigint('failed_at', { mode: 'number' }), failureReason: text('failure_reason'), /** JSON RunnerPick of the task it answers, kept from when it was left */ runner: text('runner'), + /** the closing words of the run that handled it */ + reply: text('reply'), }, (t) => [index('feedback_canvas_idx').on(t.canvasId)], ) @@ -494,6 +508,50 @@ export const fonts = pgTable( (t) => [index('fonts_workspace_idx').on(t.workspaceId), index('fonts_owner_idx').on(t.ownerId)], ) +/** Custom agents (shared/customAgents.ts): specialists a workspace or a + * person adds to the built-in team. `scope` is 'ws:' or + * 'user:'; a handle is unique within it. */ +export const customAgents = pgTable( + 'custom_agents', + { + id: text('id').primaryKey(), + scope: text('scope').notNull(), + handle: text('handle').notNull(), + name: text('name').notNull(), + color: text('color').notNull(), + blurb: text('blurb').notNull(), + brief: text('brief').notNull(), + reviewer: boolean('reviewer').notNull().default(false), + createdBy: text('created_by').notNull(), + createdAt: bigint('created_at', { mode: 'number' }).notNull(), + updatedAt: bigint('updated_at', { mode: 'number' }).notNull(), + }, + (t) => [ + uniqueIndex('custom_agents_scope_handle_idx').on(t.scope, t.handle), + uniqueIndex('custom_agents_scope_name_idx').on(t.scope, t.name), + ], +) + +/** A workspace's or a person's changes to one built-in agent + * (shared/agents.ts): switched off, or its colour, one-liner, instructions or + * reviewer flag replaced. A null field keeps the built-in value; no row is + * the built-in agent as it ships. `scope` as in `custom_agents`. */ +export const agentOverrides = pgTable( + 'agent_overrides', + { + scope: text('scope').notNull(), + roleId: text('role_id').notNull(), + disabled: boolean('disabled').notNull().default(false), + color: text('color'), + blurb: text('blurb'), + brief: text('brief'), + reviewer: boolean('reviewer'), + updatedBy: text('updated_by').notNull(), + updatedAt: bigint('updated_at', { mode: 'number' }).notNull(), + }, + (t) => [primaryKey({ columns: [t.scope, t.roleId] })], +) + /** Named design docs per canvas (brand rules, style recipes) — markdown * written mostly for agents. Small and cold-path; hydrated with the canvas. */ export const guidelines = pgTable( @@ -535,6 +593,11 @@ export const components = pgTable( code: jsonb('code').$type(), source: jsonb('source').$type>(), history: jsonb('history').$type().notNull(), + /** 'deleted' is a soft delete: the row stays, so instances keep what they were + * rendered from and the component can be restored */ + status: text('status').$type<'active' | 'deleted'>().notNull().default('active'), + deletedAt: bigint('deleted_at', { mode: 'number' }), + deletedBy: text('deleted_by'), createdAt: bigint('created_at', { mode: 'number' }).notNull(), updatedAt: bigint('updated_at', { mode: 'number' }).notNull(), updatedBy: text('updated_by').notNull(), @@ -542,6 +605,33 @@ export const components = pgTable( (t) => [primaryKey({ columns: [t.canvasId, t.id] })], ) +/** What a workspace library has published: one snapshot per component of a + * library canvas. A canvas is a library while it has rows here, and serves the + * workspace it is in at that moment (read from the canvas, not stored). Small + * and read on frame writes, so mirrored in memory (server/componentLibrary.ts). */ +export const libraryComponents = pgTable( + 'library_components', + { + canvasId: text('canvas_id').notNull(), + id: text('id').notNull(), + name: text('name').notNull(), + description: text('description').notNull(), + template: text('template').notNull(), + css: text('css').notNull(), + rawCss: text('raw_css').notNull(), + head: jsonb('head').$type().notNull(), + props: jsonb('props').$type().notNull(), + slots: jsonb('slots').$type().notNull(), + code: jsonb('code').$type(), + /** nested components from other libraries: component id → library canvas id */ + nested: jsonb('nested').$type>(), + rev: integer('rev').notNull(), + publishedAt: bigint('published_at', { mode: 'number' }).notNull(), + publishedBy: text('published_by').notNull(), + }, + (t) => [primaryKey({ columns: [t.canvasId, t.id] })], +) + /** Append-only history of guideline docs: one snapshot per save, an empty * markdown marks a deletion. Capped per doc at write time; read on demand * (cold path — no in-memory mirror). */ diff --git a/server/entitlements.ts b/server/entitlements.ts new file mode 100644 index 000000000..6c20e34ef --- /dev/null +++ b/server/entitlements.ts @@ -0,0 +1,56 @@ +import { FREE_UPLOAD_BYTES, PRO_UPLOAD_BYTES } from '../shared/billing.ts' +import type { FontScope } from '../shared/fonts.ts' +import { billingEnabled } from './billing.ts' +import { store } from './store.ts' +import { getWorkspace, isActive, planFor } from './workspaces.ts' + +/** + * What the Pro plan adds beyond a shared workspace: bigger uploads and an + * unlimited font library. Pro is a workspace subscription, so a perk applies + * where the work happens in a paid workspace, and to anyone who belongs to + * one, on their personal canvases too. A server without billing gives + * everyone everything, as it does workspaces. + */ + +/** Whether a person is on Pro: a member of a live paid workspace. */ +export function isProUser(userId: string | undefined): boolean { + if (!billingEnabled()) return true + return !!userId && planFor(userId) === 'team' +} + +function isProWorkspace(workspaceId: string | null | undefined): boolean { + if (!workspaceId) return false + const workspace = getWorkspace(workspaceId) + return !!workspace && isActive(workspace) +} + +/** The largest image a person may upload to a canvas. */ +export function uploadLimit(input: { canvasId?: string; userId?: string }): number { + if (isProUser(input.userId)) return PRO_UPLOAD_BYTES + const canvas = input.canvasId ? store.getCanvas(input.canvasId) : undefined + return isProWorkspace(canvas?.workspaceId) ? PRO_UPLOAD_BYTES : FREE_UPLOAD_BYTES +} + +/** Whether a font library may grow past the Free plan's families. */ +export function unlimitedFonts(scope: FontScope, userId: string): boolean { + if (!billingEnabled()) return true + return 'workspaceId' in scope ? isProWorkspace(scope.workspaceId) : isProUser(userId) +} + +const MB = 1024 * 1024 + +/** What follows a Free limit in a refusal: what Pro allows. */ +function proNote(limit: number): string { + return limit < PRO_UPLOAD_BYTES ? ` on the Free plan; Pro uploads up to ${PRO_UPLOAD_BYTES / MB} MB` : '' +} + +/** The cap createAsset applies to one person's upload, and its refusals: + * `message` for a file of known size, `exceeded` for a stream cut short. */ +export function uploadCap(input: { canvasId?: string; userId?: string }) { + const bytes = uploadLimit(input) + return { + bytes, + message: (size: number) => `file is ${(size / MB).toFixed(1)} MB — the limit is ${bytes / MB} MB${proNote(bytes)}`, + exceeded: `file exceeds the ${bytes / MB} MB limit${proNote(bytes)}`, + } +} diff --git a/server/env.ts b/server/env.ts index 26b4d2d6e..67b849882 100644 --- a/server/env.ts +++ b/server/env.ts @@ -105,6 +105,7 @@ const nonNegativeInt = int(0) const schema = { NODE_ENV: str({ choices: ['development', 'test', 'production'], default: 'development' }), PORT: port({ default: 4400 }), + HOST: str({ default: undefined }), /* the interface language for anyone who has not picked one in Settings */ DEFAULT_LOCALE: str({ choices: LOCALES, default: FALLBACK_LOCALE }), /* unset = embedded Postgres (PGlite) under ./data/pg */ @@ -160,6 +161,26 @@ const schema = { AZURE_OPENAI_API_VERSION: str({ default: undefined }), AZURE_OPENAI_REASONING_EFFORT: str({ default: undefined }), RESIDENT_TASK_LIMIT: nonNegativeInt({ default: 0 }), + /* incident kill switch: a frame write stops pushing a changed main into every + other frame synchronously (each catches up on its own next write) */ + DOOP_DEFER_COMPONENT_PROPAGATION: bool({ default: false }), + /* what one operation (a request, a tool call, one frame of the propagation queue) may + hand the component engine's HTML parser, and how long it may spend in it + (server/workBudget.ts); 0 lifts a limit */ + DOOP_WORK_BUDGET_PARSE_MB: nonNegativeInt({ default: 96 }), + DOOP_WORK_BUDGET_MS: nonNegativeInt({ default: 2000 }), + /* what a store write outside any write boundary does (server/journal.ts): nothing, a + logged line per kind of write, or a thrown error. Unset: 'warn' in development, 'off' + in production and under test (the integration harness sets 'throw'). */ + DOOP_WRITE_BOUNDARY: str({ choices: ['', 'off', 'warn', 'throw'], default: '' }), + /* the stall watchdog (server/stallWatchdog.ts): a watcher thread logs the operations in + flight once the event loop has not answered for STALL_LOG_MS, and ends the process + (for the supervisor to restart it) after STALL_EXIT_MS; an operation that took + SLOW_OP_LOG_MS is logged when it finishes. 0 switches one off. The exit is off + outside production, where a debugger's breakpoint looks exactly like a stall. */ + STALL_LOG_MS: nonNegativeInt({ default: 5000 }), + STALL_EXIT_MS: nonNegativeInt({ default: 60_000, devDefault: 0 }), + SLOW_OP_LOG_MS: nonNegativeInt({ default: 2000 }), DOOP_AGENT_MODEL: str({ default: 'claude-opus-5' }), DOOP_DISTILL_MODEL: str({ default: 'claude-haiku-4-5-20251001' }), DOOP_AGENT_OPENAI_MODEL: str({ default: 'gpt-5.6-terra' }), @@ -186,6 +207,7 @@ const schema = { CHATGPT_CODEX_CLIENT_VERSION: str({ default: '0.163.0' }), CHATGPT_ORIGINATOR: str({ default: 'codex_cli_rs' }), OPENAI_RESPONSES_URL: str({ default: 'https://api.openai.com/v1/responses' }), + OPENAI_IMAGES_URL: str({ default: 'https://api.openai.com/v1/images/generations' }), OPENAI_MODELS_URL: str({ default: 'https://api.openai.com/v1/models' }), OPENROUTER_CHAT_URL: str({ default: 'https://openrouter.ai/api/v1/chat/completions' }), GEMINI_OPENAI_CHAT_URL: str({ @@ -255,6 +277,16 @@ const schema = { /* ---------------------------------------------------- screenshots */ CHROME_PATH: str({ default: undefined }), CHROME_NO_SANDBOX: bool({ default: false }), + /* pages the shared Chromium renders at once (renderBrowser.ts) */ + RENDER_CONCURRENCY: nonNegativeInt({ default: 4 }), + /* a remote Chrome over the DevTools protocol instead of the local one + (Cloudflare Browser Run, browserless, a renderer service) */ + REMOTE_BROWSER_URL: str({ default: undefined }), + REMOTE_BROWSER_TOKEN: str({ default: undefined }), + /* the remote browser cannot reach this server's private network (a hosted + provider such as Cloudflare): it may fetch public URLs itself instead of + through the DNS-pinned proxy. Never set it for a self-hosted renderer */ + REMOTE_BROWSER_ISOLATED: bool({ default: false }), /* ------------------------------------------------------ analytics */ POSTHOG_KEY: str({ default: undefined }), @@ -325,7 +357,14 @@ function parse() { something other than production; doop treats an unset NODE_ENV as development (bun run dev, the test harness), so say so */ source.NODE_ENV ??= 'development' - return cleanEnv(source, schema, { reporter }) + const parsed = cleanEnv(source, schema, { reporter }) + /* the stall line names what is in flight before the process is ended: a log threshold + above the exit threshold would be a line nobody gets to read first */ + if (parsed.STALL_LOG_MS > 0 && parsed.STALL_EXIT_MS > 0 && parsed.STALL_LOG_MS > parsed.STALL_EXIT_MS) + throw new Error( + `Invalid environment configuration:\n STALL_LOG_MS: ${parsed.STALL_LOG_MS} is greater than STALL_EXIT_MS (${parsed.STALL_EXIT_MS}); the log threshold must come first`, + ) + return parsed } export type Env = ReturnType diff --git a/server/existingStyle.ts b/server/existingStyle.ts new file mode 100644 index 000000000..07bc14de3 --- /dev/null +++ b/server/existingStyle.ts @@ -0,0 +1,119 @@ +import { canvasPages, COMPONENTS_PAGE, framePageId } from '../shared/pages.ts' +import type { Canvas } from '../shared/types.ts' +import { authoredCss, hexesIn } from './reuseNotes.ts' + +/** + * What an agent should know before adding to a canvas that already has a look: the colours + * and fonts its frames share. Without it an agent asked + * for "one more page" copies hex values and redraws the nav by hand, and the canvas ends up + * with seven copies of a header instead of a component and a set of tokens. + */ + +/** Below this many frames there is no established style to read, only a first frame. */ +const MIN_FRAMES = 2 +const MAX_COLOURS = 8 +const MAX_FONTS = 4 + +export interface ExistingStyle { + frames: number + /** most shared first; only filled when the canvas has no tokens */ + colours: { value: string; frames: number }[] + fonts: { family: string; frames: number }[] +} + +const GENERIC_FONTS = new Set([ + 'serif', + 'sans-serif', + 'monospace', + 'cursive', + 'fantasy', + 'system-ui', + 'ui-sans-serif', + 'ui-serif', + 'ui-monospace', + 'inherit', + 'initial', + 'unset', + '-apple-system', + 'blinkmacsystemfont', +]) + +/** The first named family of each font-family declaration, `var(--…)` and generics left out. */ +function fontsIn(css: string): Set { + const found = new Set() + for (const match of css.matchAll(/font-family\s*:\s*([^;}]+)/gi)) { + const first = (match[1] ?? '') + .split(',')[0] + ?.trim() + .replace(/^['"]|['"]$/g, '') + if (!first || first.startsWith('var(') || GENERIC_FONTS.has(first.toLowerCase())) continue + found.add(first) + } + return found +} + +/** How many frames name each value, most first. */ +function tally(perFrame: Set[], limit: number): { value: string; frames: number }[] { + const counts = new Map() + for (const values of perFrame) for (const value of values) counts.set(value, (counts.get(value) ?? 0) + 1) + return [...counts] + .map(([value, frames]) => ({ value, frames })) + .sort((a, b) => b.frames - a.frames) + .slice(0, limit) +} + +/** The established style of a canvas, or null when it has fewer than two of the user's frames. */ +export function existingStyle(canvas: Canvas): ExistingStyle | null { + /* the Components page holds the library's mains, not screens in the canvas's style */ + const library = new Set( + canvasPages(canvas) + .filter((page) => page.name === COMPONENTS_PAGE) + .map((page) => page.id), + ) + const frames = canvas.frames.filter((frame) => !frame.demo && !library.has(framePageId(canvas, frame))) + if (frames.length < MIN_FRAMES) return null + /* with tokens the palette is already named: nothing to read off the frames */ + if ((canvas.tokens ?? []).length) return { frames: frames.length, colours: [], fonts: [] } + const css = frames.map((frame) => authoredCss(frame.html)) + const colours = tally( + css.map( + ({ sheets, inline }) => + new Set([ + ...sheets.flatMap((sheet) => [...hexesIn(sheet, { sheet: true })]), + ...inline.flatMap((style) => [...hexesIn(style, { sheet: false })]), + ]), + ), + MAX_COLOURS, + ) + const fonts = tally( + css.map(({ sheets, inline }) => new Set([...sheets, ...inline].flatMap((block) => [...fontsIn(block)]))), + MAX_FONTS, + ).map(({ value, frames }) => ({ family: value, frames })) + return { frames: frames.length, colours, fonts } +} + +/** What to do with it, in the words both get_canvas and the resident kickoff use. */ +export function existingStyleBrief(style: ExistingStyle, { tokens }: { tokens: boolean }): string { + const lines = [ + `This canvas already has a style: ${style.frames} frames set it. New work follows it rather than a fresh brief.`, + ] + if (!tokens) { + const colours = style.colours.map((colour) => `${colour.value} (${colour.frames} frames)`).join(', ') + const fonts = style.fonts.map((font) => `${font.family} (${font.frames} frames)`).join(', ') + lines.push( + 'It has no design tokens yet. Before your first new frame, read its values off the existing frames' + + (colours + ? ` (shared colours: ${colours}` + (fonts ? `; fonts: ${fonts})` : ')') + : fonts + ? ` (fonts: ${fonts})` + : '') + + ' and get_frame on a page or two for type sizes, radii and spacing, then create them with create_tokens by role ' + + 'and write var(--name) in what you add.', + ) + } + lines.push( + 'Do not rewrite the existing frames to use new tokens or components (no replace_matching) unless the human asked: ' + + 'when you finish, offer to bring them onto the same tokens and components.', + ) + return lines.join(' ') +} diff --git a/server/featureEvents.ts b/server/featureEvents.ts new file mode 100644 index 000000000..cfff8200a --- /dev/null +++ b/server/featureEvents.ts @@ -0,0 +1,35 @@ +import type { TokenResult } from '../shared/designTokens.ts' +import { capture } from './analytics.ts' + +/** Where a feature was used from: the app, an MCP agent, the resident Doop + * Agent, or an automation step. Features agents can reach report from the + * server, so the count includes the work done on a person's behalf. */ +export type FeatureVia = 'ui' | 'mcp' | 'resident' | 'automation' + +/** One use of a product feature, on the person it belongs to: the one + * signed in, the one who connected the agent, or the one who asked the + * resident agent. With no such person there is no one to count it on. */ +export function captureFeature( + userId: string | undefined, + event: string, + via: FeatureVia, + properties: Record = {}, +) { + if (!userId) return + capture(userId, event, { ...properties, via }) +} + +/** A token write as one `tokens_changed`, counted by outcome; a write where + * every token failed is not a use. */ +export function captureTokenResults( + userId: string | undefined, + canvasId: string, + via: FeatureVia, + results: TokenResult[] | undefined, +) { + if (!results) return + const counts = { created: 0, updated: 0, deleted: 0 } + for (const r of results) if (r.result !== 'error') counts[r.result]++ + if (!counts.created && !counts.updated && !counts.deleted) return + captureFeature(userId, 'tokens_changed', via, { canvas_id: canvasId, ...counts }) +} diff --git a/server/fontRoutes.ts b/server/fontRoutes.ts index 021f8c882..161323d6b 100644 --- a/server/fontRoutes.ts +++ b/server/fontRoutes.ts @@ -1,6 +1,6 @@ import express, { Router, type Request, type Response } from 'express' import { MAX_FONT_BYTES, type FontScope } from '../shared/fonts.ts' -import { FontInputError, addFont, canUseScope, deleteFont, listFonts } from './fonts.ts' +import { FontInputError, FontLimitError, addFont, canUseScope, deleteFont, listFonts } from './fonts.ts' /** /api/fonts: the font libraries Settings and Workspace manage. `?workspace=` * names a workspace's library (members only); without it the library is the @@ -36,7 +36,8 @@ fontsRouter.post('/', express.raw({ type: () => true, limit: MAX_FONT_BYTES + 10 const font = await addFont(scope, req.user!, Buffer.isBuffer(req.body) ? req.body : Buffer.alloc(0), fileName) res.json(font) } catch (e) { - if (e instanceof FontInputError) res.status(400).json({ error: e.message }) + if (e instanceof FontLimitError) res.status(402).json({ error: e.message, upgrade: 'fonts' }) + else if (e instanceof FontInputError) res.status(400).json({ error: e.message }) else { console.error('[fonts] upload failed', e) res.status(500).json({ error: 'the font could not be saved — try again' }) diff --git a/server/fonts.ts b/server/fonts.ts index 90479e849..31a8f1a3c 100644 --- a/server/fonts.ts +++ b/server/fonts.ts @@ -6,6 +6,8 @@ import { env } from './env.ts' import { storeAsset } from './assets.ts' import { readFontFile } from './fontFile.ts' import { isWorkspaceMember } from './workspaces.ts' +import { unlimitedFonts } from './entitlements.ts' +import { FREE_FONT_FAMILIES } from '../shared/billing.ts' import { MAX_FONT_BYTES, type CustomFont, type FontFormat, type FontScope, type FontStyle } from '../shared/fonts.ts' /** @@ -20,6 +22,23 @@ const rows = new Map() export class FontInputError extends Error {} +/** A Free library already holds its families; the route answers 402 so the + * page can offer Pro. */ +export class FontLimitError extends FontInputError {} + +/** Refuse a family a Free library has no room for. A face of a family the + * library already has is always welcome, so a family stays complete. */ +function checkFamilyRoom(scope: FontScope, userId: string, family: string): void { + if (unlimitedFonts(scope, userId)) return + const families = new Set( + [...rows.values()].filter((r) => inScope(r, scope, userId)).map((r) => r.family.toLowerCase()), + ) + if (families.has(family.toLowerCase()) || families.size < FREE_FONT_FAMILIES) return + throw new FontLimitError( + `the Free plan holds ${FREE_FONT_FAMILIES} font families and this library has ${families.size}: upgrade to Pro for unlimited fonts, or remove a family first`, + ) +} + export async function hydrateFonts(): Promise { const all = await db.select().from(t.fonts) rows.clear() @@ -80,28 +99,35 @@ export async function addFont( } catch (e) { throw new FontInputError(e instanceof Error ? e.message : 'the font file could not be read') } - const asset = await storeAsset(buf, info, { ownerId: user.id, uploadedBy: user.name }) - const row: FontRow = { - id: nanoid(10), - workspaceId: 'workspaceId' in scope ? scope.workspaceId : null, - ownerId: user.id, - family: info.family, - weight: info.weight, - style: info.style, - format: info.format, - assetId: asset.id, - ext: asset.ext, - fileName: fileName.replace(/[^\w.\- ]+/g, '').slice(0, 120) || `font.${asset.ext}`, - size: buf.length, - uploadedBy: user.id, - createdAt: Date.now(), - } + /* a quick refusal before anything waits in the queue */ + checkFamilyRoom(scope, user.id, info.family) + const cleanName = fileName.replace(/[^\w.\- ]+/g, '').slice(0, 120) /* find-and-replace runs one at a time per library: two uploads of the same - face racing would otherwise each miss the other's row and both stay */ + face racing would otherwise each miss the other's row and both stay. The + file is stored inside the queue, after the checks, so a refused upload + leaves nothing behind. */ return inLibraryOrder(scope, user.id, async () => { /* checked again in the queue: the workspace may have been deleted, or the - uploader removed from it, while the file was being stored */ + uploader removed from it, while earlier uploads ran */ if (!canUseScope(scope, user.id)) throw new FontInputError('this workspace no longer exists or you left it') + /* again in the queue: two new families uploaded at once both passed the first look */ + checkFamilyRoom(scope, user.id, info.family) + const asset = await storeAsset(buf, info, { ownerId: user.id, uploadedBy: user.name }) + const row: FontRow = { + id: nanoid(10), + workspaceId: 'workspaceId' in scope ? scope.workspaceId : null, + ownerId: user.id, + family: info.family, + weight: info.weight, + style: info.style, + format: info.format, + assetId: asset.id, + ext: asset.ext, + fileName: cleanName || `font.${asset.ext}`, + size: buf.length, + uploadedBy: user.id, + createdAt: Date.now(), + } const replaced = [...rows.values()].filter( (r) => inScope(r, scope, user.id) && diff --git a/server/guide.ts b/server/guide.ts index 2d8b67f99..5787118c6 100644 --- a/server/guide.ts +++ b/server/guide.ts @@ -1,12 +1,62 @@ /** - * The deep playbook agents load via get_guide — kept out of the initialize - * instructions so the handshake stays small (same pattern paper.design uses). + * The playbook agents load via get_guide, kept out of the initialize instructions so the + * handshake stays small (Claude Code cuts server instructions at 4,096 characters). + * As Paper and pen.dev do it: one main guide every agent loads first ("doop-instructions"), + * and topics an agent loads only when its task needs one, so every session does not pay + * for the whole playbook. */ import { AGENT_ROLES } from '../shared/agents.ts' import { MAX_DECISION_CHARS } from '../shared/designDecisions.ts' -export const GUIDE_TOPICS = ['doop-instructions'] as const +export const GUIDE_TOPICS = [ + 'doop-instructions', + 'images', + 'components', + 'prototypes', + 'redesigns', + 'comments-and-agents', + 'export', + 'imported-frames', +] as const + +export type GuideTopic = (typeof GUIDE_TOPICS)[number] + +/** What each topic covers: listed in get_guide's description and at the end of the main guide. */ +export const GUIDE_TOPIC_SUMMARIES: Record = { + 'doop-instructions': 'the main guide: load it first, before any other Doop tool', + images: 'photos, backgrounds, icons, logos, generated images and uploads in full', + components: 'nesting, variants, overrides, deleting, other canvases and workspace libraries', + prototypes: 'wiring screens into a clickable flow', + redesigns: 'redesigning an existing site or page: import, audit, two directions', + 'comments-and-agents': "comment threads, and the built-in Doop Agent's roles", + export: 'images and PDF of a frame or one element', + 'imported-frames': 'frames imported from a GitHub repo or synced from a live app', +} + +/** The check a frame-writing tool's description asks for, at the moment the HTML is written: + * MCP's create_frame, append_frame_html and set_frame_html and the resident's matching tools. */ +export const COMPOSE_CHECK = + "Before you send the HTML, check it against the canvas's component system: is anything here a part of the system you are redrawing (use ), or a reusable piece the system should gain (create it first)? One-off layout stays plain HTML." + +/** The must-do list at the top of the guide and the resident prompt: how a canvas is set up + * before its screens, said first so it is not buried under streaming and images. */ +export const SYSTEM_FIRST = `Set up the system, then compose. Work the way a designer sets up a Figma file: + +1. **Tokens first.** The brief's colours, type, radii and spacing become the canvas's tokens + (create_tokens) before the first frame; frames use them as var(--…). +2. **A component system before screens.** Sketch the few primitives a product like this is + built from (a Button with its variants, inputs, a tag or badge) and the patterns it leans on + (nav, a card, a list row), and make them components with create_components, on the tokens. + A button that appears once is still the system's Button. Then compose every screen from + them with , and grow the system as you go: a reusable piece a screen needs is + added to the system, not drawn inline. One-off layout (a hero's composition, section + wrappers, the page grid) stays plain HTML. Ask what a designer would put on the + Components page. +3. **Themes are tokens.** Dark mode, or any other theme, is set_token_themes and + data-doop-theme on the frame, never a copied frame with its colours changed. + +On a canvas that already has tokens and components, use them: get_canvas lists both.` /** The taste doctrine every design surface shares. The MCP guide serves it to * external agents and the resident system prompt embeds it verbatim, so the @@ -63,16 +113,31 @@ brief. It is part of the deliverable, not private scratch work: hero device → one-line direction. NAME the one exemplar you are following and say why it won — or state that none fit and the brief derives from the design-quality principles alone. -3. **Post it.** Summarize in set_status ("Designing grocery landing — candlelit mood, - after Oatside") and persist the brief as separate save_decision calls so humans - and later agents see what you committed to. Each call holds one decision and its - rationale, at most ${MAX_DECISION_CHARS} characters. Split by topic (exemplar, palette, typography, - layout), keeping the reason for each choice with that choice; do not split sentences - into arbitrary chunks or discard rationale to squeeze the whole brief into one call. - -Skip the brief only when the canvas already dictates the style — established frames, -style guides or pinned references — or when the human handed you a complete design -system. Then those are the brief; follow them.` +3. **Make it the canvas's tokens.** Before your first frame, create the brief's values + with create_tokens: the palette by role (--color-ground, --color-ink, --color-accent…), + font families, the type scale, radii and spacing. Frames and components then use them + as var(--…), and a change to a token restyles every frame that names it. The tokens + are where the values live; nothing else holds them. + **Then set up the component system on them.** Name the primitives and patterns the + design is built from, the way a designer starts a Figma file's Components page (a Button + with its variants, inputs, a badge; the nav, a card, a list row), and create them in one + create_components call, primitives first so the patterns can them. The first + frame is composed from these. +4. **Post it.** Summarize in set_status ("Designing grocery landing — candlelit mood, + after Oatside") and record the choices that need a reason with save_decision: the + exemplar you followed and why it won, why this mood, why this accent. A decision is + the why, not a copy of the values. Each call holds one decision and its rationale, at + most ${MAX_DECISION_CHARS} characters; do not split sentences into arbitrary chunks or drop the + rationale to squeeze several decisions into one call. + +Skip the brief only when the canvas already dictates the style — tokens (get_tokens), +established frames, style guides or pinned references — or when the human handed you a +complete design system. Then those are the brief; follow them, and if a value you need +has no token yet, add one with create_tokens rather than writing it into a frame. Frames +with no tokens behind them are a brief too: get_canvas's existingStyle lists the colours +and fonts they share, so create those as tokens before your first new frame instead of +copying hex values from page to page. Leave the existing frames as they are unless asked, +and offer to move them onto the tokens when you finish.` /** How to wire a clickable prototype — shared by the MCP guide and the resident agents' system prompt. */ export const PROTOTYPES = `When a human asks for a clickable prototype or a flow, wire the screens with data attributes on @@ -105,8 +170,13 @@ export const FRAME_STYLES = `- Style an element on the element itself: style=" editor, which reads and writes that attribute, so a style written there is one they can change, move and copy without surprises. A stylesheet rule can outrank their edit, or stop matching the moment they group or reorder layers. -- A `, + 'gi', +) + +/** The CSS the author wrote: their ${body}` + +function setup() { + const canvas = store.createCanvas('hollow', 'owner-hollow') + const def = blankComponent({ name: 'Button', by: 'Tester' }) + store.saveComponent(canvas.id, def) + const main = actions.createFrame(canvas.id, { name: 'Button main', html: '' }, actor)! + actions.updateFrame( + main.id, + { + html: doc( + ``, + '.btn { padding: 8px; background: teal }', + ), + }, + actor, + ) + const page = actions.createFrame(canvas.id, { name: 'Page', html: '' }, actor)! + actions.updateFrame(page.id, { html: doc('

text

') }, actor) + const filled = store.getComponents(canvas.id).find((d) => d.id === def.id)! + /* the row a boot loads after the blank write landed last */ + store.saveComponent(canvas.id, { + ...filled, + template: '', + css: '', + rawCss: '', + props: [], + slots: [], + rev: 0, + mainFrameId: null, + history: [], + }) + return { canvas, def, main, page } +} + +const html = (id: string) => store.getFrame(id)!.html + +describe('a hollow component', () => { + it('reads back to an agent with its instances written out and their stylesheet', () => { + const { def, page } = setup() + const compact = compactFrameHtml(store.getFrame(page.id)!) + expect(compact).not.toContain(' { + const { def, page } = setup() + const compact = compactFrameHtml(store.getFrame(page.id)!) + actions.updateFrame(page.id, { html: compact.replace('

text

', '

edited

') }, actor) + expect(html(page.id)).toContain('edited') + expect(html(page.id)).toContain(`${INSTANCE_ATTR}="${def.id}"`) + expect(html(page.id)).toContain('Go') + expect(html(page.id)).toMatch(new RegExp(`${CSS_ATTR}="${def.id}"[^>]*>[^<]*background: teal`)) + }) + + it('keeps the stylesheet of its instances through a whole write of their frame', () => { + const { def, page } = setup() + actions.updateFrame(page.id, { html: html(page.id).replace('

text

', '

moved

') }, actor) + expect(html(page.id)).toMatch(new RegExp(`${CSS_ATTR}="${def.id}"[^>]*>[^<]*background: teal`)) + }) + + it('gets its markup back from the next write of its main', () => { + const { canvas, def, main } = setup() + actions.updateFrame(main.id, { html: html(main.id).replace('Buy', 'Buy now') }, actor) + const healed = store.getComponents(canvas.id).find((d) => d.id === def.id)! + expect(healed.template).toContain('Buy now') + expect(healed.mainFrameId).toBe(main.id) + expect(healed.rev).toBeGreaterThan(0) + }) +}) + +describe('healing hollow components after boot', () => { + it('gives each its markup back from its main and leaves its instances as they are', async () => { + const { canvas, def, main, page } = setup() + const pageBefore = html(page.id) + const mainBefore = html(main.id) + const { healed, failed } = await actions.healHollowComponents() + expect(healed).toBeGreaterThanOrEqual(1) + expect(failed).toBe(0) + const now = store.getComponents(canvas.id).find((d) => d.id === def.id)! + expect(now.template).toContain('Buy') + expect(now.css).toContain('teal') + expect(now.mainFrameId).toBe(main.id) + expect(html(page.id)).toBe(pageBefore) + expect(html(main.id)).toBe(mainBefore) + }) + + it('counts one whose main is gone, and leaves it be', async () => { + const { canvas, def, main } = setup() + actions.updateFrame(main.id, { html: doc('

no main any more

') }, actor) + const result = await actions.healHollowComponents() + expect(result.noMain).toBeGreaterThanOrEqual(1) + expect(store.getComponents(canvas.id).find((d) => d.id === def.id)!.template).toBe('') + }) +}) + +/** A Card whose main nests a Button, a page using the Card, and a frame holding another + * component's main beside a Card. Then the Button and the Badge lose their markup. */ +function nested() { + const { canvas, def: button, main: buttonMain } = setup() + /* a write of its main gives the Button its markup back, so the Card and its instances render it */ + actions.updateFrame(buttonMain.id, { html: `${html(buttonMain.id)} ` }, actor) + const card = blankComponent({ name: 'Card', by: 'Tester' }) + store.saveComponent(canvas.id, card) + const cardMain = actions.createFrame(canvas.id, { name: 'Card main', html: '' }, actor)! + actions.updateFrame( + cardMain.id, + { + html: doc( + `

Title

`, + '.card { border: 1px solid }', + ), + }, + actor, + ) + const badge = blankComponent({ name: 'Badge', by: 'Tester' }) + store.saveComponent(canvas.id, badge) + const mixed = actions.createFrame(canvas.id, { name: 'Mixed', html: '' }, actor)! + actions.updateFrame( + mixed.id, + { + html: doc( + `New

text

`, + '.badge { color: red }', + ), + }, + actor, + ) + expect(html(mixed.id)).toContain('Inside') + for (const id of [button.id, badge.id]) { + const now = store.getComponents(canvas.id).find((d) => d.id === id)! + store.saveComponent(canvas.id, { + ...now, + template: '', + css: '', + rawCss: '', + rev: 0, + mainFrameId: null, + history: [], + }) + } + return { canvas, button, badge, card, mixed } +} + +describe('an instance holding one of a hollow component', () => { + it('reads back written out, so writing it back keeps the nested instance', () => { + const { mixed } = nested() + const compact = compactFrameHtml(store.getFrame(mixed.id)!) + expect(compact).not.toContain('component="Card"') + actions.updateFrame(mixed.id, { html: compact.replace('

text

', '

edited

') }, actor) + expect(html(mixed.id)).toContain('edited') + expect(html(mixed.id)).toContain('Inside') + }) + + it('keeps the nested instance through a whole write of its frame', () => { + const { mixed } = nested() + actions.updateFrame(mixed.id, { html: html(mixed.id).replace('

text

', '

moved

') }, actor) + expect(html(mixed.id)).toContain('Inside') + }) + + it('is left as it is when the frame it shares with a hollow main is healed', async () => { + const { canvas, badge, mixed } = nested() + const before = html(mixed.id) + await actions.healHollowComponents() + expect(store.getComponents(canvas.id).find((d) => d.id === badge.id)!.template).toContain('New') + expect(html(mixed.id)).toBe(before) + }) +}) + +describe('healing, when a canvas does not load', () => { + it('counts its definitions as failed and goes on with the other canvases', async () => { + const broken = setup() + const fine = setup() + const load = store.withCanvas.bind(store) + const spy = vi + .spyOn(store, 'withCanvas') + .mockImplementation((id, work) => + id === broken.canvas.id ? Promise.reject(new Error('read failed')) : load(id, work), + ) + vi.spyOn(console, 'error').mockImplementation(() => {}) + const result = await actions.healHollowComponents() + expect(result.failed).toBeGreaterThanOrEqual(1) + expect(store.getComponents(fine.canvas.id).find((d) => d.id === fine.def.id)!.template).toContain('Buy') + spy.mockRestore() + }) +}) diff --git a/tests/componentImport.test.tsx b/tests/componentImport.test.tsx new file mode 100644 index 000000000..a611583ed --- /dev/null +++ b/tests/componentImport.test.tsx @@ -0,0 +1,153 @@ +// @vitest-environment happy-dom +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, expect, it, vi } from 'vitest' +import type { ComponentLibrary } from '../src/lib/api' + +const mocks = vi.hoisted(() => ({ + importComponent: vi.fn(), + componentPreview: vi.fn(), + notices: [] as string[], + components: [] as { id: string; status?: 'deleted' }[], +})) +vi.mock('../src/lib/api', () => ({ + api: { importComponent: mocks.importComponent, componentPreview: mocks.componentPreview }, +})) +vi.mock('../src/lib/store', () => { + const state = { + get canvas() { + return { id: 'here', components: mocks.components } + }, + pushNotice: (text: string) => mocks.notices.push(text), + } + const useStore = Object.assign((select: (s: typeof state) => unknown) => select(state), { getState: () => state }) + return { useStore } +}) +import { ImportCanvasList, ImportComponentsModal } from '../src/components/ComponentImport' +;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +/* Importing from another canvas: the panel lists canvases like Home, with a way + back, and a canvas opens a modal to pick its components. */ + +let root: Root +let container: HTMLDivElement +const button = (label: string) => + Array.from(document.querySelectorAll('button')).find((b) => b.textContent?.trim() === label) +const entry = (id: string, name: string) => ({ id, name, signature: `${id}:1`, instances: 0 }) + +const landing: ComponentLibrary = { + id: 'landing', + name: 'UI v2 landing', + updatedAt: Date.now() - 3_600_000, + previewFrameId: 'f1', + components: [entry('cover', 'Blog Cover'), entry('canva', 'Tile Canva'), entry('claude', 'Tile Claude Code')], +} +const empty: ComponentLibrary = { id: 'posts', name: 'X Posts', updatedAt: Date.now(), components: [] } + +beforeEach(() => { + container = document.createElement('div') + document.body.append(container) + root = createRoot(container) + mocks.notices.length = 0 + mocks.components = [] + mocks.importComponent.mockReset().mockResolvedValue({}) + mocks.componentPreview.mockReset().mockReturnValue(new Promise(() => {})) +}) +afterEach(() => { + act(() => root.unmount()) + container.remove() + document.body.innerHTML = '' +}) + +it('lists canvases one per row, greys one with no components, and goes back', () => { + const onBack = vi.fn() + const onPick = vi.fn() + act(() => root.render()) + + const tiles = document.querySelectorAll('[data-import-canvas]') + expect([...tiles].map((tile) => tile.dataset.importCanvas)).toEqual(['UI v2 landing', 'X Posts']) + expect(tiles[0]!.textContent).toContain('3') + expect(tiles[1]!.disabled).toBe(true) + expect(tiles[1]!.textContent).toContain('No components') + + act(() => tiles[0]!.click()) + expect(onPick).toHaveBeenCalledWith(landing) + act(() => button('Components')!.click()) + expect(onBack).toHaveBeenCalled() +}) + +it('filters canvases by name', () => { + act(() => root.render( {}} onPick={() => {}} />)) + const search = document.querySelector('input[aria-label="Search canvases"]')! + act(() => { + const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')!.set! + set.call(search, 'posts') + search.dispatchEvent(new Event('input', { bubbles: true })) + }) + const names = [...document.querySelectorAll('[data-import-canvas]')].map((t) => t.dataset.importCanvas) + expect(names).toEqual(['X Posts']) +}) + +it('imports the picked components, skipping the ones already here', async () => { + mocks.components = [{ id: 'claude' }] + const onDone = vi.fn() + act(() => root.render( {}} onDone={onDone} />)) + /* the one already here has no checkbox and says so */ + const cell = (name: string) => document.querySelector(`[data-import-component="${name}"]`)! + expect(cell('Tile Claude Code').querySelector('input')).toBeNull() + expect(cell('Tile Claude Code').textContent).toContain('Already on this canvas') + + act(() => button('Select all')!.click()) + expect(button('Import 2 components')).toBeDefined() + await act(async () => button('Import 2 components')!.click()) + + expect(mocks.importComponent.mock.calls).toEqual([ + ['here', 'landing', 'cover'], + ['here', 'landing', 'canva'], + ]) + expect(mocks.notices).toEqual(['2 components imported']) + expect(onDone).toHaveBeenCalled() +}) + +it('keeps the modal open and says why when an import fails', async () => { + mocks.importComponent.mockRejectedValue(new Error('no component “Blog Cover” on canvas landing')) + const onDone = vi.fn() + act(() => root.render( {}} onDone={onDone} />)) + act(() => document.querySelector('[data-import-component="Blog Cover"] input')!.click()) + await act(async () => button('Import 1 component')!.click()) + expect(mocks.notices).toEqual(['no component “Blog Cover” on canvas landing']) + expect(onDone).not.toHaveBeenCalled() + expect(button('Import 1 component')).toBeDefined() +}) + +it('closing goes back to the canvas list', () => { + const onBack = vi.fn() + act(() => root.render( {}} />)) + act(() => button('Back to canvases')!.click()) + expect(onBack).toHaveBeenCalled() +}) + +it('cannot be closed while an import runs', async () => { + let finish = () => {} + mocks.importComponent.mockReturnValue(new Promise((resolve) => (finish = resolve))) + const onBack = vi.fn() + act(() => root.render( {}} />)) + act(() => document.querySelector('[data-import-component="Blog Cover"] input')!.click()) + act(() => button('Import 1 component')!.click()) + expect(button('Importing…')).toBeDefined() + expect(document.querySelector('[aria-label="Close"]')).toBeNull() + act(() => document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))) + expect(onBack).not.toHaveBeenCalled() + await act(async () => finish()) +}) + +it('stops counting a picked component once it has arrived', () => { + act(() => root.render( {}} onDone={() => {}} />)) + act(() => document.querySelector('[data-import-component="Blog Cover"] input')!.click()) + expect(button('Import 1 component')).toBeDefined() + /* it lands here (an earlier, partly failed run brought it), still ticked */ + mocks.components = [{ id: 'cover' }] + act(() => root.render( {}} onDone={() => {}} />)) + expect(button('Import')!.disabled).toBe(true) + expect(document.body.textContent).not.toContain('1 selected') +}) diff --git a/tests/componentPartKeys.test.ts b/tests/componentPartKeys.test.ts new file mode 100644 index 000000000..df0594bc8 --- /dev/null +++ b/tests/componentPartKeys.test.ts @@ -0,0 +1,130 @@ +import { describe, expect, it, vi } from 'vitest' + +vi.mock('../server/db/persist.ts', () => ({ + saveCanvas: () => {}, + saveFrame: () => {}, + saveFrameNow: async () => {}, + saveActivity: () => {}, + saveFrameVersion: () => {}, + saveTask: () => {}, + saveComponent: () => {}, + deleteComponent: () => {}, +})) + +import * as actions from '../server/actions.ts' +import { compactFrameHtml, createComponentFromHtml, updateComponent } from '../server/componentActions.ts' +import { store } from '../server/store.ts' +import { INSTANCE_ATTR, PART_ATTR } from '../shared/components.ts' +import type { Actor } from '../shared/types.ts' + +/* + * A part key is how an instance's overrides find their element. Agent reports (2026-11-11): + * inserting a keyless element before a keyed one moved the keyed one's key, and the + * overrides with it, onto the new element, with nothing in the impact report. + */ +const actor = { name: 'Tester', kind: 'agent', color: '#000', clientId: 'x' } as unknown as Actor + +/** The key on the element whose `label` (a ``) or text is `label`. */ +function keyOf(template: string, label: string): string | undefined { + const tag = new RegExp(`<[^>]*\\blabel="${label}"[^>]*>|<[^>]*>${label}<`).exec(template)?.[0] ?? '' + return new RegExp(`${PART_ATTR}="([a-z]+)"`).exec(tag)?.[1] +} + +function footer() { + const canvas = store.createCanvas('parts', 'owner-parts') + createComponentFromHtml( + canvas.id, + { name: 'Button', html: '' }, + actor, + ) + const def = createComponentFromHtml( + canvas.id, + { name: 'Step Footer', html: '
' }, + actor, + ).component + return { canvas, def } +} + +describe('a nested instance added to a main', () => { + it('in front of a keyed one leaves that one its key', () => { + const { canvas, def } = footer() + const skip = keyOf(def.template, 'Skip')! + const sent = def.template.replace('
{ + const { canvas, def } = footer() + const sent = def.template.replace( + '
', + '
', + ) + const after = updateComponent(canvas.id, 'Step Footer', { html: sent }, actor).component + const keys = ['Skip', 'Next', 'Done'].map((label) => keyOf(after.template, label)) + expect(new Set(keys).size).toBe(3) + /* the main's frame carries the same keys as the template */ + const main = store.getFrame(after.mainFrameId!)!.html + const nested = [...main.matchAll(new RegExp(`]*${INSTANCE_ATTR}[^>]*>`, 'g'))].map( + ([tag]) => new RegExp(`${PART_ATTR}="([a-z]+)"`).exec(tag)?.[1], + ) + expect(nested).toEqual(keys) + }) +}) + +describe('a keyless element added to a main', () => { + it('in front of a keyed sibling of the same tag leaves the sibling its key', () => { + const canvas = store.createCanvas('list', 'owner-parts') + const def = createComponentFromHtml( + canvas.id, + { name: 'List', html: '
  • Second
', autoProps: false }, + actor, + ).component + const second = keyOf(def.template, 'Second')! + const sent = def.template.replace(/
  • First
  • { + const canvas = store.createCanvas('resend', 'owner-parts') + const def = createComponentFromHtml( + canvas.id, + { name: 'Pair', html: '

    Title

    Body

    ', autoProps: false }, + actor, + ).component + const sent = '

    New title

    New body

    ' + const after = updateComponent(canvas.id, 'Pair', { html: sent }, actor).component + expect(keyOf(after.template, 'New title')).toBe(keyOf(def.template, 'Title')) + expect(keyOf(after.template, 'New body')).toBe(keyOf(def.template, 'Body')) + }) +}) + +describe('a main read back in short form and saved', () => { + it('keeps the keys of the instances nested in it, so nothing about the component changes', () => { + const { canvas, def } = footer() + const main = store.getFrame(def.mainFrameId!)! + const compact = compactFrameHtml(main) + expect(compact).toContain(`${PART_ATTR}="${keyOf(def.template, 'Skip')}"`) + actions.updateFrame(main.id, { html: compact }, actor) + const after = store.getComponents(canvas.id).find((d) => d.id === def.id)! + expect(after.template).toBe(def.template) + expect(after.rev).toBe(def.rev) + }) + + it('keeps the element ids of the instances nested in it, so comments and links still find them', () => { + const { def } = footer() + const main = store.getFrame(def.mainFrameId!)! + const ids = () => + [...store.getFrame(main.id)!.html.matchAll(new RegExp(`]*${INSTANCE_ATTR}[^>]*>`, 'g'))].map( + ([tag]) => /data-doop-id="([^"]+)"/.exec(tag)?.[1], + ) + const before = ids() + expect(before[0]).toBeDefined() + actions.updateFrame(main.id, { html: compactFrameHtml(main) }, actor) + expect(ids()).toEqual(before) + }) +}) diff --git a/tests/componentPersistOrder.test.ts b/tests/componentPersistOrder.test.ts new file mode 100644 index 000000000..9c54523c4 --- /dev/null +++ b/tests/componentPersistOrder.test.ts @@ -0,0 +1,143 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { ComponentDef } from '../shared/components.ts' + +/* + * A pooled database: each write lands when its own connection finishes, so two writes sent + * back to back can land in either order. `landed` is the row as the database ends up with it. + * A create saves a blank definition and then the filled one; before writes to a component + * row were queued, the blank one could land last (2026-11-11: 236 hollow definitions). + */ +const pool = vi.hoisted(() => ({ + landed: new Map(), + delays: [] as number[], + failures: 0, + sent: 0, +})) + +vi.mock('../server/db/index.ts', () => { + const send = (land: () => void) => { + const delay = pool.delays.shift() ?? 0 + pool.sent++ + return new Promise((resolve, reject) => + setTimeout(() => { + if (pool.failures > 0) { + pool.failures-- + reject(new Error('connection reset')) + return + } + land() + resolve() + }, delay), + ) + } + const db = { + insert: () => ({ + values: (row: { id: string }) => ({ + onConflictDoUpdate: () => send(() => pool.landed.set(row.id, row)), + }), + }), + delete: () => ({ where: () => send(() => pool.landed.clear()) }), + } + return { db } +}) + +const persist = await import('../server/db/persist.ts') + +const def = (patch: Partial): ComponentDef => ({ + id: 'cmp-1', + name: 'Button', + description: '', + template: '', + css: '', + rawCss: '', + head: [], + props: [], + slots: [], + rev: 0, + mainFrameId: null, + history: [], + createdAt: 1, + updatedAt: 1, + updatedBy: 'Ada', + ...patch, +}) + +const blank = def({}) +const filled = def({ template: '', rev: 1, mainFrameId: 'frame-1', updatedAt: 2 }) + +const stored = () => pool.landed.get('cmp-1') as { template: string; rev: number } | undefined + +beforeEach(() => { + pool.landed.clear() + pool.delays.length = 0 + pool.failures = 0 + pool.sent = 0 +}) + +afterEach(() => { + vi.useRealTimers() + vi.restoreAllMocks() +}) + +describe('writes to one component row', () => { + it('land in the order they were made, even when the first is slow', async () => { + pool.delays.push(30, 0) + persist.saveComponent('canvas-1', blank) + persist.saveComponent('canvas-1', filled) + await persist.pendingComponentWrites() + expect(stored()?.template).toBe('') + expect(stored()?.rev).toBe(1) + }) + + it('send only the latest of the states that waited behind a write in flight', async () => { + pool.delays.push(20) + persist.saveComponent('canvas-1', blank) + persist.saveComponent('canvas-1', def({ rev: 1, template: 'one' })) + persist.saveComponent('canvas-1', filled) + await persist.pendingComponentWrites() + expect(pool.sent).toBe(2) + expect(stored()?.template).toBe('') + }) + + it('keep a delete after the save it follows', async () => { + pool.delays.push(20) + persist.saveComponent('canvas-1', filled) + persist.deleteComponent('canvas-1', 'cmp-1') + await persist.pendingComponentWrites() + expect(stored()).toBeUndefined() + }) + + it('retry a write that failed, and say so', async () => { + const logged = vi.spyOn(console, 'error').mockImplementation(() => {}) + vi.useFakeTimers() + pool.failures = 1 + persist.saveComponent('canvas-1', filled) + await vi.runAllTimersAsync() + await persist.pendingComponentWrites() + expect(stored()?.rev).toBe(1) + expect(logged).toHaveBeenCalledWith(expect.stringContaining('retrying'), expect.any(Error)) + }) + + it('give a failed write up for a newer state rather than retry it', async () => { + vi.spyOn(console, 'error').mockImplementation(() => {}) + pool.failures = 1 + pool.delays.push(20) + persist.saveComponent('canvas-1', blank) + persist.saveComponent('canvas-1', filled) + await persist.pendingComponentWrites() + expect(pool.sent).toBe(2) + expect(stored()?.template).toBe('') + }) + + /* last: a drained module stays drained */ + it('reach the database at shutdown, a retry waiting out its delay included', async () => { + vi.spyOn(console, 'error').mockImplementation(() => {}) + pool.failures = 1 + persist.saveComponent('canvas-1', filled) + await vi.waitFor(() => expect(pool.sent).toBe(1)) + const started = Date.now() + await persist.flush(() => undefined) + expect(Date.now() - started).toBeLessThan(400) + expect(stored()?.rev).toBe(1) + }) +}) diff --git a/tests/componentSectionDeleted.test.tsx b/tests/componentSectionDeleted.test.tsx new file mode 100644 index 000000000..9abf2bdbb --- /dev/null +++ b/tests/componentSectionDeleted.test.tsx @@ -0,0 +1,131 @@ +// @vitest-environment happy-dom +import { act } from 'react' +import { createRoot, type Root } from 'react-dom/client' +import { afterEach, beforeEach, expect, it, vi } from 'vitest' +import type { ComponentDef } from '../shared/components' +import type { Frame } from '../shared/types' + +const mocks = vi.hoisted(() => ({ + undeleteComponent: vi.fn(), + changeInstances: vi.fn(), + notices: [] as string[], + components: [] as unknown[], + frames: [] as unknown[], + canEdit: true, +})) +vi.mock('../src/lib/api', () => ({ + api: { undeleteComponent: mocks.undeleteComponent, changeInstances: mocks.changeInstances }, + errorMessage: (_error: unknown, fallback: string) => fallback, +})) +vi.mock('../src/lib/history', () => ({ recordCreate: () => {}, recordUpdate: () => {}, recordUpdates: () => {} })) +vi.mock('../src/lib/store', () => { + const state = { + get canvas() { + return { id: 'canvas1', components: mocks.components, frames: mocks.frames } + }, + pushNotice: (text: string) => mocks.notices.push(text), + setComponentLocal: () => {}, + upsertFrame: () => {}, + setSelectedElement: () => {}, + } + const useStore = Object.assign((select: (s: typeof state) => unknown) => select(state), { getState: () => state }) + return { useStore, canEditOpenCanvas: () => mocks.canEdit, pickedSelectors: () => [] } +}) +import { ComponentSection } from '../src/components/ComponentSection' +;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true + +/* The Design panel on an instance whose component was deleted: it says so, and offers the + two ways out (restore the component, detach this instance) instead of its props. */ + +let root: Root +let container: HTMLDivElement + +const def = (over: Partial = {}): ComponentDef => ({ + id: 'cbutton', + name: 'Button', + description: '', + template: '', + css: '', + rawCss: '', + head: [], + props: [{ name: 'label', type: 'text' }], + slots: [], + rev: 1, + mainFrameId: 'main1', + history: [], + createdAt: 1, + updatedAt: 1, + updatedBy: 'Tester', + ...over, +}) + +const frame = { + id: 'frame1', + canvasId: 'canvas1', + name: 'Page', + html: '', +} as unknown as Frame + +const button = (label: string) => + Array.from(document.querySelectorAll('button')).find((b) => b.textContent?.trim() === label) + +function render() { + act(() => root.render()) +} + +beforeEach(() => { + container = document.createElement('div') + document.body.append(container) + root = createRoot(container) + mocks.frames = [frame] + mocks.canEdit = true + mocks.notices.length = 0 + mocks.undeleteComponent.mockReset() + mocks.changeInstances.mockReset() +}) + +afterEach(() => { + act(() => root.unmount()) + container.remove() +}) + +it('shows an instance of a component in use with its props', () => { + mocks.components = [def()] + render() + expect(container.textContent).toContain('Button') + expect(container.textContent).not.toContain('Main component deleted') + expect(container.querySelector('[data-slot="deleted-component"]')).toBeNull() + expect(container.textContent).toContain('label') +}) + +it('says the main component was deleted, and offers Restore and Detach instead of props', async () => { + mocks.components = [def({ status: 'deleted', deletedAt: 5, deletedBy: 'Tester' })] + mocks.undeleteComponent.mockResolvedValue({ component: def(), main: 'kept' }) + mocks.changeInstances.mockResolvedValue({ frame, missing: [] }) + render() + expect(container.querySelector('[data-slot="deleted-component"]')).not.toBeNull() + expect(container.textContent).toContain('Main component deleted') + expect(container.querySelectorAll('input, textarea')).toHaveLength(0) + + await act(async () => { + button('Restore component')!.click() + await Promise.resolve() + }) + expect(mocks.undeleteComponent).toHaveBeenCalledWith('canvas1', 'cbutton') + expect(mocks.notices).toEqual(['“Button” restored']) + + await act(async () => { + button('Detach')!.click() + await Promise.resolve() + }) + expect(mocks.changeInstances).toHaveBeenCalledWith('frame1', [{ instanceId: 'inst01', detach: true }]) +}) + +it('offers nothing to someone who can only look', () => { + mocks.components = [def({ status: 'deleted', deletedAt: 5, deletedBy: 'Tester' })] + mocks.canEdit = false + render() + expect(container.textContent).toContain('Main component deleted') + expect(button('Restore component')).toBeUndefined() + expect(button('Detach')).toBeUndefined() +}) diff --git a/tests/componentSoftDelete.test.ts b/tests/componentSoftDelete.test.ts new file mode 100644 index 000000000..96641c8fb --- /dev/null +++ b/tests/componentSoftDelete.test.ts @@ -0,0 +1,599 @@ +import { Client } from '@modelcontextprotocol/sdk/client/index.js' +import { InMemoryTransport } from '@modelcontextprotocol/sdk/inMemory.js' +import { afterEach, describe, expect, it, vi } from 'vitest' + +vi.mock('../server/db/persist.ts', () => ({ + saveCanvas: () => {}, + saveFrame: () => {}, + saveFrameNow: async () => {}, + saveActivity: () => {}, + saveFrameVersion: () => {}, + saveTask: () => {}, + saveComponent: () => {}, + deleteComponent: () => {}, + deleteFrame: () => {}, + saveFeedback: () => {}, + saveComment: () => {}, + saveDecision: () => {}, + saveProposal: () => {}, +})) + +import { buildMcpServer } from '../server/mcp.ts' +import { execTool, RESIDENT_TOOL_NAMES } from '../server/resident.ts' +import { store } from '../server/store.ts' +import * as actions from '../server/actions.ts' +import * as propagation from '../server/propagation.ts' +import { blankComponent } from '../server/components.ts' +import { + catalog, + changeInstances, + compactFrameHtml, + ComponentError, + deleteComponent, + deletedComponentsInUse, + detachAllInstances, + importComponent, + insertInstance, + restoreComponent, + syncComponent, + updateComponent, +} from '../server/componentActions.ts' +import { COMPONENT_ATTR, INSTANCE_ATTR } from '../shared/components.ts' +import { DEFAULT_ROLE_ID, roleName } from '../shared/agents.ts' +import type { Actor } from '../shared/types.ts' + +const OWNER = 'owner-soft-delete' +const actor = { name: 'Tester', kind: 'user', color: '#000', clientId: 'x' } as unknown as Actor + +const doc = (body: string, css = '') => + `${body}` + +const framed = (id: string) => store.getFrame(id)!.html +const current = (canvasId: string, id: string) => store.getComponents(canvasId).find((d) => d.id === id)! + +/** A Button, a Card built from it, and pages using each. */ +function setup(pages = 6) { + const canvas = store.createCanvas('soft delete test', OWNER) + const button = blankComponent({ name: 'Button', by: 'Tester' }) + store.saveComponent(canvas.id, button) + const buttonMain = actions.createFrame(canvas.id, { name: 'Button main', html: '' }, actor)! + actions.updateFrame( + buttonMain.id, + { + html: doc( + ``, + '.btn { padding: 8px; background: teal }', + ), + }, + actor, + ) + const card = blankComponent({ name: 'Card', by: 'Tester' }) + store.saveComponent(canvas.id, card) + const cardMain = actions.createFrame(canvas.id, { name: 'Card main', html: '' }, actor)! + actions.updateFrame( + cardMain.id, + { + html: doc( + `

    Title

    `, + '.card { border: 1px solid }', + ), + }, + actor, + ) + const frames = Array.from({ length: pages }, (_, index) => { + const frame = actions.createFrame(canvas.id, { name: `Page ${index}`, html: '' }, actor)! + const body = + index % 2 === 0 + ? `

    text ${index}

    ` + : `` + actions.updateFrame(frame.id, { html: doc(body) }, actor) + return frame + }) + return { canvas, button, buttonMain, card, cardMain, frames } +} + +const allHtml = (canvasId: string) => + Object.fromEntries(store.getCanvas(canvasId)!.frames.map((frame) => [frame.id, frame.html])) + +afterEach(async () => { + vi.restoreAllMocks() + await propagation.whenIdle() +}) + +describe('deleting a component', () => { + it('writes no frame, keeps every instance byte for byte, and keeps the definition', async () => { + const { canvas, button } = setup() + await propagation.whenIdle() + const before = allHtml(canvas.id) + const frameWrites = vi.spyOn(store, 'updateFrame') + + const result = deleteComponent(canvas.id, 'Button', actor) + + expect(frameWrites).not.toHaveBeenCalled() + await propagation.whenIdle() + expect(frameWrites).not.toHaveBeenCalled() + expect(allHtml(canvas.id)).toEqual(before) + const kept = current(canvas.id, button.id) + expect(kept.status).toBe('deleted') + expect(kept.deletedBy).toBe('Tester') + expect(kept.deletedAt).toBeGreaterThan(0) + expect(kept.template).toContain('btn') + /* 3 pages use it directly, 3 through a Card, and the Card's main holds one */ + expect(result).toMatchObject({ deleted: 'Button', instances_kept: 7, frames: 7 }) + expect(catalog(canvas).map((entry) => entry.name)).toEqual(['Card']) + expect(deletedComponentsInUse(canvas)).toMatchObject([{ id: button.id, name: 'Button', instances: 7 }]) + }) + + it('is refused twice, and names what can be done instead', () => { + const { canvas } = setup(2) + deleteComponent(canvas.id, 'Button', actor) + expect(() => deleteComponent(canvas.id, 'Button', actor)).toThrow(/already deleted/) + expect(() => updateComponent(canvas.id, 'Button', { description: 'x' }, actor)).toThrow(/was deleted.*restore/i) + }) + + it('leaves its instances out of everything that follows a main', async () => { + const { canvas, button, buttonMain, frames } = setup() + await propagation.whenIdle() + deleteComponent(canvas.id, 'Button', actor) + const definition = current(canvas.id, button.id) + const before = allHtml(canvas.id) + + /* an old client saves the deleted main, changed: only that frame takes it */ + const edited = framed(buttonMain.id).replace('class="btn"', 'class="btn stale-edit"') + actions.updateFrame(buttonMain.id, { html: edited }, actor) + expect(framed(buttonMain.id)).toContain('btn stale-edit') + expect(framed(buttonMain.id)).toContain(`${COMPONENT_ATTR}="${button.id}"`) + expect(propagation.pendingFrames(canvas.id)).toBe(0) + await propagation.whenIdle() + + expect(current(canvas.id, button.id)).toBe(definition) + expect(current(canvas.id, button.id).status).toBe('deleted') + for (const frame of frames) expect(framed(frame.id)).toBe(before[frame.id]) + + /* and a frame holding an instance saves unchanged, its stylesheet still in the head */ + const page = frames[0]! + actions.updateFrame(page.id, { html: framed(page.id) }, actor) + expect(framed(page.id)).toBe(before[page.id]) + expect(framed(page.id)).toContain(`data-doop-component-css="${button.id}"`) + }) + + it('does not come back when its main reappears in another frame', () => { + const { canvas, button, buttonMain } = setup(2) + const main = //.exec(framed(buttonMain.id))![0] + deleteComponent(canvas.id, 'Button', actor) + const definition = current(canvas.id, button.id) + const fresh = actions.createFrame(canvas.id, { name: 'Pasted', html: '' }, actor)! + actions.updateFrame(fresh.id, { html: doc(`${main.replace('Buy', 'Sell')}

    pasted

    `) }, actor) + expect(current(canvas.id, button.id)).toBe(definition) + expect(framed(fresh.id)).toContain('Sell') + expect(framed(fresh.id)).toContain(`${COMPONENT_ATTR}="${button.id}"`) + expect(actions.takeComponentIssues(fresh.id)).toEqual([]) + }) + + it('refuses a new use, in markup and through insert_instance', () => { + const { canvas, frames } = setup(2) + deleteComponent(canvas.id, 'Button', actor) + const page = frames[0]! + actions.updateFrame( + page.id, + { html: doc(`

    kept

    `) }, + actor, + ) + expect(framed(page.id)).toContain('

    kept

    ') + expect(framed(page.id)).not.toContain('New') + const issues = actions.takeComponentIssues(page.id) + expect(issues.map((issue) => issue.code)).toContain('deleted_component') + expect(issues.find((issue) => issue.code === 'deleted_component')!.message).toMatch( + /“Button” was deleted.*restore/i, + ) + + expect(() => insertInstance(canvas.id, { frameId: page.id, component: 'Button' }, actor)).toThrow(ComponentError) + expect(() => insertInstance(canvas.id, { frameId: page.id, component: 'Button' }, actor)).toThrow(/was deleted/) + }) + + it('reads back as full markup, so writing a frame back never asks for it again', () => { + const { canvas, frames } = setup(2) + const page = frames[0]! + expect(compactFrameHtml(store.getFrame(page.id)!)).toContain(' { + const { canvas, cardMain, frames } = setup() + await propagation.whenIdle() + const before = allHtml(canvas.id) + expect(() => deleteComponent(canvas.id, 'Button', actor)).not.toThrow() + expect(allHtml(canvas.id)).toEqual(before) + + /* the Card changes: its instances follow, each still holding the Button it was drawn with */ + actions.updateFrame(cardMain.id, { html: framed(cardMain.id).replace('class="card"', 'class="card wide"') }, actor) + await propagation.whenIdle() + const cardPage = frames[1]! + expect(framed(cardPage.id)).toContain('card wide') + expect(framed(cardPage.id)).toContain('Inside') + expect(framed(cardPage.id)).toContain('class="btn"') + expect(framed(cardMain.id)).toContain('Inside') + /* a new Card can still be placed, Button and all */ + actions.updateFrame(frames[0]!.id, { html: doc(``) }, actor) + expect(framed(frames[0]!.id)).toContain('Fresh') + expect(framed(frames[0]!.id)).toContain('Inside') + expect(actions.takeComponentIssues(frames[0]!.id)).toEqual([]) + }) + + it('still lets one instance be detached, and refuses to change one', () => { + const { canvas, frames } = setup(2) + const page = frames[0]! + const instanceId = /data-doop-id="([^"]+)"/.exec(framed(page.id))![1]! + deleteComponent(canvas.id, 'Button', actor) + expect(() => changeInstances(canvas.id, page.id, [{ instanceId, props: { label: 'x' } }], actor)).toThrow( + /was deleted/, + ) + changeInstances(canvas.id, page.id, [{ instanceId, detach: true }], actor) + expect(framed(page.id)).not.toContain(` ${INSTANCE_ATTR}="`) + expect(framed(page.id)).toContain('data-doop-detached-from') + expect(framed(page.id)).toContain('Go 0') + }) +}) + +describe('importing a component built from a deleted one', () => { + it('copies the deleted dependency, still deleted, so the imported component is whole', async () => { + const source = setup(0) + await propagation.whenIdle() + deleteComponent(source.canvas.id, 'Button', actor) + const target = store.createCanvas('personal target', OWNER) + + const card = importComponent(target.id, source.canvas.id, 'Card', actor) + await propagation.whenIdle() + + const defs = store.getComponents(target.id) + const button = defs.find((def) => def.id === source.button.id) + expect(button).toMatchObject({ status: 'deleted', name: 'Button', mainFrameId: null }) + expect(button!.template).toBe(current(source.canvas.id, source.button.id).template) + expect(button!.css).toBe(current(source.canvas.id, source.button.id).css) + expect(catalog(target).map((entry) => entry.name)).toEqual(['Card']) + /* the Card's own main, and a new instance of it, hold the button */ + expect(card.template).toContain(`component="${source.button.id}"`) + expect(framed(card.mainFrameId!)).toContain('Inside') + expect(framed(card.mainFrameId!)).toContain('class="btn"') + const page = actions.createFrame(target.id, { name: 'Page', html: '' }, actor)! + actions.updateFrame(page.id, { html: doc('') }, actor) + expect(framed(page.id)).toContain('Mine') + expect(framed(page.id)).toContain('Inside') + expect(framed(page.id)).toContain(`data-doop-component-css="${source.button.id}"`) + expect(actions.takeComponentIssues(page.id)).toEqual([]) + /* and it is not there to be used by itself */ + expect(() => insertInstance(target.id, { frameId: page.id, component: 'Button' }, actor)).toThrow(/was deleted/) + }) + + it('leaves a dependency this canvas already has, deleted or not, as it is on a later sync', async () => { + const source = setup(0) + await propagation.whenIdle() + const target = store.createCanvas('personal target', OWNER) + importComponent(target.id, source.canvas.id, 'Card', actor) + await propagation.whenIdle() + const mine = current(target.id, source.button.id) + expect(mine.status ?? 'active').toBe('active') + /* the source deletes its Button, then changes the Card */ + deleteComponent(source.canvas.id, 'Button', actor) + updateComponent(source.canvas.id, 'Card', { find: 'class="card"', replace: 'class="card v2"' }, actor) + await propagation.whenIdle() + + const synced = syncComponent(target.id, 'Card', actor, () => true) + await propagation.whenIdle() + expect(synced.updated).toBe(true) + expect(current(target.id, source.card.id).template).toContain('card v2') + expect(current(target.id, source.button.id)).toBe(mine) + }) +}) + +describe('restoring a component', () => { + it('round-trips: active again on its surviving main, and instances follow it again', async () => { + const { canvas, button, buttonMain, frames } = setup() + await propagation.whenIdle() + const before = allHtml(canvas.id) + const frameCount = canvas.frames.length + deleteComponent(canvas.id, 'Button', actor) + + const restored = restoreComponent(canvas.id, 'Button', actor) + await propagation.whenIdle() + + expect(restored.component.id).toBe(button.id) + expect(restored.main).toBe('kept') + const def = current(canvas.id, button.id) + expect(def.status ?? 'active').toBe('active') + expect(def.deletedAt).toBeUndefined() + expect(def.mainFrameId).toBe(buttonMain.id) + expect(def.rev).toBe(1) + expect(canvas.frames).toHaveLength(frameCount) + expect(allHtml(canvas.id)).toEqual(before) + expect( + catalog(canvas) + .map((entry) => entry.name) + .sort(), + ).toEqual(['Button', 'Card']) + expect(deletedComponentsInUse(canvas)).toEqual([]) + + actions.updateFrame( + buttonMain.id, + { html: framed(buttonMain.id).replace('class="btn"', 'class="btn again"') }, + actor, + ) + await propagation.whenIdle() + expect(framed(frames[0]!.id)).toContain('btn again') + expect(framed(frames[1]!.id)).toContain('btn again') + }) + + it('writes a main from the kept definition when the old one is gone', async () => { + const { canvas, button, buttonMain, frames } = setup(2) + await propagation.whenIdle() + deleteComponent(canvas.id, 'Button', actor) + actions.deleteFrame(buttonMain.id, actor) + const before = framed(frames[0]!.id) + + const restored = restoreComponent(canvas.id, button.id, actor) + await propagation.whenIdle() + + expect(restored.main).toBe('written') + const def = current(canvas.id, button.id) + expect(def.mainFrameId).not.toBeNull() + expect(def.mainFrameId).not.toBe(buttonMain.id) + expect(framed(def.mainFrameId!)).toContain(`${COMPONENT_ATTR}="${button.id}"`) + expect(framed(def.mainFrameId!)).toContain('Buy') + expect(def.template).toContain('btn') + expect(framed(frames[0]!.id)).toBe(before) + }) + + it('takes edits made to its main while it was deleted as a new revision', async () => { + const { canvas, button, buttonMain, frames } = setup(2) + await propagation.whenIdle() + deleteComponent(canvas.id, 'Button', actor) + actions.updateFrame( + buttonMain.id, + { html: framed(buttonMain.id).replace('class="btn"', 'class="btn late"') }, + actor, + ) + expect(current(canvas.id, button.id).rev).toBe(1) + + restoreComponent(canvas.id, 'Button', actor) + expect(current(canvas.id, button.id).rev).toBe(2) + await propagation.whenIdle() + expect(framed(frames[0]!.id)).toContain('btn late') + }) + + it('takes another name when its own was given away meanwhile', () => { + const { canvas, button } = setup(2) + deleteComponent(canvas.id, 'Button', actor) + const replacement = blankComponent({ name: 'Button', by: 'Tester' }) + store.saveComponent(canvas.id, replacement) + const restored = restoreComponent(canvas.id, button.id, actor) + expect(restored.component.name).toBe('Button (restored)') + expect(() => restoreComponent(canvas.id, button.id, actor)).toThrow(/not deleted/) + }) +}) + +describe('detaching every instance', () => { + it('runs through the queue, a frame per tick, and leaves plain markup', async () => { + const { canvas, button, frames } = setup() + await propagation.whenIdle() + deleteComponent(canvas.id, 'Button', actor) + const before = allHtml(canvas.id) + let turn = 0 + const immediate = globalThis.setImmediate + vi.spyOn(globalThis, 'setImmediate').mockImplementation(((run: () => void) => + immediate(() => { + turn += 1 + run() + })) as typeof setImmediate) + const perTurn = new Map() + vi.spyOn(store, 'updateFrame').mockImplementation(function (this: typeof store, ...args) { + perTurn.set(turn, (perTurn.get(turn) ?? 0) + 1) + return Object.getPrototypeOf(store).updateFrame.apply(store, args) + }) + + const queued = detachAllInstances(canvas.id, 'Button', actor) + + expect(queued).toMatchObject({ queued: true, instances: 7, frames: 7 }) + expect(allHtml(canvas.id)).toEqual(before) + expect(perTurn.size).toBe(0) + + await propagation.whenIdle() + expect(Math.max(...perTurn.values())).toBe(1) + const direct = framed(frames[0]!.id) + expect(direct).not.toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(direct).toContain(`data-doop-detached-from="${button.id}.`) + expect(direct).toContain('Go 0') + expect(deletedComponentsInUse(canvas)).toEqual([]) + const line = actions.getActivity(canvas.id).find((item) => item.message.startsWith('detached')) + expect(line?.message).toContain('“Button”') + }) + + it('waits for a frame an agent is streaming into, without spinning, and detaches it when the stream closes', async () => { + const { canvas, button, frames } = setup(4) + await propagation.whenIdle() + const agent = actions.resolveActor({ name: 'Streamer', kind: 'agent' }) + const streaming = frames[0]! + actions.appendFrameHtml( + streaming.id, + '', + agent, + { start: true }, + ) + expect(actions.isFrameMidStream(streaming.id)).toBe(true) + expect(framed(streaming.id)).toContain(` ${INSTANCE_ATTR}="${button.id}"`) + + let visits = 0 + const immediate = globalThis.setImmediate + vi.spyOn(globalThis, 'setImmediate').mockImplementation(((run: () => void) => + immediate(() => { + visits += 1 + run() + })) as typeof setImmediate) + detachAllInstances(canvas.id, 'Button', actor) + await propagation.whenIdle() + + /* everything else is done, the queue is empty, and the request is kept, not dropped */ + expect(framed(frames[2]!.id)).not.toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(framed(streaming.id)).toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(propagation.pendingFrames(canvas.id)).toBe(0) + expect(propagation.deferredFrames()).toContain(streaming.id) + const settled = visits + await new Promise((resolve) => setTimeout(resolve, 60)) + expect(visits).toBeLessThanOrEqual(settled + 1) + expect(visits).toBeLessThan(60) + + actions.appendFrameHtml(streaming.id, '

    last

    ', agent, { done: true }) + await propagation.whenIdle() + expect(framed(streaming.id)).not.toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(framed(streaming.id)).toContain(`data-doop-detached-from="${button.id}.`) + expect(framed(streaming.id)).toContain('Streamed') + expect(propagation.deferredFrames()).toEqual([]) + expect(deletedComponentsInUse(canvas)).toEqual([]) + }) + + it('detaches a frame whose stream was abandoned, when the idle stream is closed', async () => { + const { canvas, button, frames } = setup(2) + await propagation.whenIdle() + const agent = actions.resolveActor({ name: 'Streamer', kind: 'agent' }) + const streaming = frames[0]! + actions.appendFrameHtml( + streaming.id, + '', + agent, + { start: true }, + ) + detachAllInstances(canvas.id, 'Button', actor) + await propagation.whenIdle() + expect(framed(streaming.id)).toContain(` ${INSTANCE_ATTR}="${button.id}"`) + + actions.expireIdleStreams(Date.now() + 60 * 60_000) + await propagation.whenIdle() + expect(framed(streaming.id)).not.toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(framed(streaming.id)).toContain('Left') + expect(propagation.deferredFrames()).toEqual([]) + }) + + it('works on a component that is not deleted, which then has no instances', async () => { + const { canvas, button, frames } = setup(2) + await propagation.whenIdle() + detachAllInstances(canvas.id, 'Button', actor) + await propagation.whenIdle() + expect(framed(frames[0]!.id)).not.toContain(` ${INSTANCE_ATTR}="${button.id}"`) + expect(current(canvas.id, button.id).status ?? 'active').toBe('active') + expect(catalog(canvas).find((entry) => entry.name === 'Button')!.instances).toBe(0) + }) +}) + +describe('agents', () => { + type ToolResponse = { content: { type: string; text?: string }[]; isError?: boolean } + + async function connect() { + const [clientSide, serverSide] = InMemoryTransport.createLinkedPair() + await buildMcpServer('Owner', OWNER).connect(serverSide) + const client = new Client({ name: 'soft-delete-test', version: '0' }) + await client.connect(clientSide) + const call = async (name: string, args: Record) => { + const response = (await client.callTool({ name, arguments: { agent_name: 'Tester', ...args } })) as ToolResponse + const text = response.content.map((block) => block.text ?? '').join('\n') + // eslint-disable-next-line typescript/no-explicit-any + let data: any + try { + data = JSON.parse(response.content[0]?.text ?? '') + } catch { + data = undefined + } + return { data, text, isError: !!response.isError } + } + return { client, call } + } + + it('delete, see what is left, and restore over MCP', async () => { + const { canvas, button, frames } = setup() + await propagation.whenIdle() + const before = allHtml(canvas.id) + const { client, call } = await connect() + + const deleted = await call('delete_component', { canvas_id: canvas.id, component: 'Button' }) + expect(deleted.isError).toBe(false) + expect(deleted.data).toMatchObject({ ok: true, deleted: 'Button', instances_kept: 7 }) + expect(deleted.text).toContain('restore_component') + expect(allHtml(canvas.id)).toEqual(before) + + const listed = await call('get_canvas', { canvas_id: canvas.id }) + expect(listed.data.components.map((entry: { name: string }) => entry.name)).toEqual(['Card']) + expect(listed.data.deletedComponents).toMatchObject([{ id: button.id, name: 'Button', instances: 7 }]) + + const frame = await call('get_frame', { frame_id: frames[0]!.id }) + expect(frame.text).not.toContain(' entry.name).sort()).toEqual(['Button', 'Card']) + expect(again.data.deletedComponents).toBeUndefined() + expect(allHtml(canvas.id)).toEqual(before) + await client.close() + }) + + it('detach everything on request over MCP, in the background', async () => { + const { canvas, button, frames } = setup() + await propagation.whenIdle() + const { client, call } = await connect() + const deleted = await call('delete_component', { + canvas_id: canvas.id, + component: 'Button', + detach_instances: true, + }) + expect(deleted.isError).toBe(false) + expect(deleted.data.detach).toMatchObject({ queued: true, frames: 7 }) + await propagation.whenIdle() + expect(framed(frames[0]!.id)).toContain(`data-doop-detached-from="${button.id}.`) + await client.close() + }) + + it('gives the resident agent the same tools, with the same result', async () => { + expect(RESIDENT_TOOL_NAMES).toContain('delete_component') + expect(RESIDENT_TOOL_NAMES).toContain('restore_component') + const { canvas, button } = setup() + await propagation.whenIdle() + const before = allHtml(canvas.id) + const resident = actions.resolveActor({ name: roleName(DEFAULT_ROLE_ID), kind: 'agent' }) + const runState = { + mutatedFrames: new Set(), + sourceFrames: new Set(), + verificationFrames: new Set(), + verifiedFrames: new Set(), + seenVerified: new Set(), + rewriteDrafts: new Map(), + vision: false, + imagesGenerated: 0, + repliedThreads: new Set(), + awaitingThreads: new Set(), + tokenWrites: 0, + arrangeWrites: 0, + } + const call = (name: string, input: unknown) => ({ type: 'tool_use' as const, id: 't1', name, input }) + + const deleted = await execTool(call('delete_component', { component: 'Button' }), canvas.id, resident, runState) + expect(deleted.is_error).toBeUndefined() + expect(String(deleted.content)).toContain('"instances_kept":7') + expect(current(canvas.id, button.id).status).toBe('deleted') + expect(allHtml(canvas.id)).toEqual(before) + + const restored = await execTool(call('restore_component', { component: 'Button' }), canvas.id, resident, runState) + expect(restored.is_error).toBeUndefined() + expect(current(canvas.id, button.id).status ?? 'active').toBe('active') + expect(allHtml(canvas.id)).toEqual(before) + }) +}) diff --git a/tests/componentSoftDeleteRoutes.test.ts b/tests/componentSoftDeleteRoutes.test.ts new file mode 100644 index 000000000..05fc9f8d0 --- /dev/null +++ b/tests/componentSoftDeleteRoutes.test.ts @@ -0,0 +1,129 @@ +import { rmSync } from 'node:fs' +import { afterAll, beforeAll, describe, expect, it } from 'vitest' +import { Client, startServer, type Server } from './harness' + +/* The real server and database: the soft-delete migration, the REST routes, and a deleted + component still deleted (and still restorable) after a restart. */ + +const doc = (body: string) => + `${body}` + +interface CanvasBody { + frames: { id: string; html: string }[] + components: { id: string; name: string; status?: string; deletedBy?: string }[] +} + +describe('soft-deleting a component over REST', () => { + let server: Server + let owner: Client + let stranger: Client + let canvasId: string + let mainFrameId: string + let pageId: string + let componentId: string + + const canvas = async (client = owner) => (await (await client.get(`/api/canvases/${canvasId}`)).json()) as CanvasBody + const pageHtml = async () => (await canvas()).frames.find((frame) => frame.id === pageId)!.html + const listed = async () => + (await (await owner.get(`/api/canvases/${canvasId}/components`)).json()) as { id: string; instances: number }[] + + /** Wait for the background queue: the page no longer holds an instance marker. */ + async function untilDetached() { + for (let attempt = 0; attempt < 100; attempt++) { + const html = await pageHtml() + if (!html.includes(' data-doop-instance="')) return html + await new Promise((resolve) => setTimeout(resolve, 50)) + } + throw new Error('the instances were never detached') + } + + beforeAll(async () => { + server = await startServer() + owner = await new Client(server).signUp('owner@softdelete.test', 'Owner') + stranger = await new Client(server).signUp('stranger@softdelete.test', 'Stranger') + canvasId = ((await (await owner.post('/api/canvases', { name: 'Soft delete' })).json()) as { id: string }).id + const main = (await ( + await owner.post(`/api/canvases/${canvasId}/frames`, { + name: 'Main', + html: doc('One'), + }) + ).json()) as { id: string } + mainFrameId = main.id + const made = await owner.post(`/api/canvases/${canvasId}/components`, { + name: 'Tag', + frameId: mainFrameId, + element: 'tagone', + }) + componentId = ((await made.json()) as { component: { id: string } }).component.id + const page = (await ( + await owner.post(`/api/canvases/${canvasId}/frames`, { + name: 'Page', + html: doc(''), + }) + ).json()) as { id: string } + pageId = page.id + }, 60_000) + + /* background writes can still be landing when the tests end: the data directory goes + only once the server has exited, or the removal races its shutdown flush */ + afterAll(async () => { + if (!server) return + server.stop({ keepData: true }) + await server.stopped + rmSync(server.dataDir, { recursive: true, force: true }) + }) + + it('deletes without writing a frame, and keeps the definition', async () => { + const before = await pageHtml() + expect(await listed()).toMatchObject([{ id: componentId, instances: 2 }]) + expect((await stranger.delete(`/api/canvases/${canvasId}/components/${componentId}`)).status).toBe(403) + + const res = await owner.delete(`/api/canvases/${canvasId}/components/${componentId}`) + expect(res.status).toBe(200) + expect(await res.json()).toMatchObject({ deleted: 'Tag', instances_kept: 2, frames: 1 }) + expect(await pageHtml()).toBe(before) + expect(await listed()).toEqual([]) + expect((await canvas()).components).toMatchObject([{ id: componentId, status: 'deleted', deletedBy: 'Owner' }]) + + const again = await owner.delete(`/api/canvases/${canvasId}/components/${componentId}`) + expect(again.status).toBe(400) + expect(((await again.json()) as { error: string }).error).toContain('already deleted') + /* a new use is refused: the frame is saved without it */ + const use = await owner.post(`/api/frames/${pageId}/instances`, { component: 'Tag' }) + expect(use.status).toBe(400) + expect(((await use.json()) as { error: string }).error).toContain('was deleted') + }) + + it('is still deleted after a restart, and comes back on its main', async () => { + const before = await pageHtml() + server.stop({ keepData: true }) + await server.stopped + server = await startServer({}, server.dataDir) + const cookies = owner.cookies + owner = new Client(server) + owner.cookies = cookies + + expect((await canvas()).components).toMatchObject([{ id: componentId, status: 'deleted' }]) + expect(await listed()).toEqual([]) + expect(await pageHtml()).toBe(before) + + const missing = await owner.post(`/api/canvases/${canvasId}/components/nope/undelete`, {}) + expect(missing.status).toBe(400) + const restored = await owner.post(`/api/canvases/${canvasId}/components/${componentId}/undelete`, {}) + expect(restored.status).toBe(200) + expect(await restored.json()).toMatchObject({ main: 'kept', component: { id: componentId, mainFrameId } }) + expect(await listed()).toMatchObject([{ id: componentId, instances: 2 }]) + expect((await canvas()).components[0]!.status).toBeUndefined() + expect(await pageHtml()).toBe(before) + }, 60_000) + + it('detaches every instance in the background when asked', async () => { + const res = await owner.post(`/api/canvases/${canvasId}/components/${componentId}/detach-instances`, {}) + expect(res.status).toBe(200) + expect(await res.json()).toEqual({ queued: true, instances: 2, frames: 1 }) + const html = await untilDetached() + expect(html).toContain('data-doop-detached-from') + expect(html.match(/>One ({ + saveCanvas: () => {}, + saveFrame: () => {}, + saveFrameNow: async () => {}, + saveActivity: () => {}, + saveFrameVersion: () => {}, + saveTask: () => {}, + saveComponent: () => {}, + deleteComponent: () => {}, +})) + +import * as actions from '../server/actions.ts' +import * as propagation from '../server/propagation.ts' +import { compactFrameHtml, createComponentFromHtml, updateComponent } from '../server/componentActions.ts' +import { blankComponent } from '../server/components.ts' +import { store } from '../server/store.ts' +import { INSTANCE_ATTR } from '../shared/components.ts' +import type { Actor } from '../shared/types.ts' + +/* + * A component whose root is a table part (a cell, a row) made from markup. Agent report + * (2026-11-11): create_component said ok and stored an empty definition, since a parsed + * on its own, outside a table, is dropped by the HTML parser. + */ +const actor = { name: 'Tester', kind: 'agent', color: '#000', clientId: 'x' } as unknown as Actor +const doc = (body: string) => `${body}` + +describe('a component made from a table part', () => { + it('keeps a cell, renders it inside a row, and reads back in short form', async () => { + const canvas = store.createCanvas('cells', 'owner-cells') + const { component } = createComponentFromHtml( + canvas.id, + { + name: 'Cell', + html: 'x', + css: '.cell { padding: 4px }', + props: [{ name: 'tone', type: 'enum', options: ['plain', 'loud'], default: 'plain' }], + }, + actor, + ) + expect(component.template).toMatch(/^]*data-doop-component/) + + const page = actions.createFrame( + canvas.id, + { + name: 'Grid', + html: doc( + '
    ', + ), + }, + actor, + )! + const html = store.getFrame(page.id)!.html + expect(html).toMatch(new RegExp(`]*${INSTANCE_ATTR}="${component.id}"[^>]*>`)) + expect(html).toContain('>A<') + expect(compactFrameHtml(store.getFrame(page.id)!)).toContain('A<') + }) + + it('keeps a row with its cells', () => { + const canvas = store.createCanvas('rows', 'owner-rows') + const { component } = createComponentFromHtml( + canvas.id, + { name: 'Row', html: 'NameValue' }, + actor, + ) + expect(component.template).toMatch(/^]*>]*>/) + expect(component.template).toContain('Value') + }) + + it('finds the table part behind a leading comment', () => { + const canvas = store.createCanvas('commented', 'owner-cells') + const { component } = createComponentFromHtml( + canvas.id, + { name: 'Note cell', html: 'Value' }, + actor, + ) + expect(component.template).toMatch(/^ { + const canvas = store.createCanvas('becomes', 'owner-cells') + createComponentFromHtml(canvas.id, { name: 'Becomes', html: '
    Value
    ' }, actor) + const { component } = updateComponent(canvas.id, 'Becomes', { html: 'Value' }, actor) + expect(component.template).toMatch(/^]*class="now"/) + expect(store.getFrame(component.mainFrameId!)!.html).toMatch(/]*data-doop-component/) + }) + + it('refuses to turn a main that sits in a row into something a row cannot hold', () => { + const canvas = store.createCanvas('stays', 'owner-cells') + createComponentFromHtml(canvas.id, { name: 'Stays', html: 'Value' }, actor) + expect(() => updateComponent(canvas.id, 'Stays', { html: '
    Value
    ' }, actor)).toThrow(/sits inside a /) + }) + + it('leaves a header row where it is when only its CSS changes', () => { + const canvas = store.createCanvas('header', 'owner-cells') + const def = createComponentFromHtml(canvas.id, { name: 'Shell', html: '
    x
    ' }, actor).component + const main = store.getFrame(def.mainFrameId!)! + const head = blankComponent({ name: 'Head row', by: 'Tester' }) + store.saveComponent(canvas.id, head) + actions.updateFrame( + main.id, + { + html: main.html.replace( + '', + `
    Name
    a
    `, + ), + }, + actor, + ) + updateComponent(canvas.id, 'Head row', { css: '.h { font-weight: 600 }' }, actor) + const html = store.getFrame(main.id)!.html + expect(html).toMatch(/]*data-doop-component[^>]*>]*>Name<\/th><\/tr><\/thead>/) + expect(html.match(//g)).toHaveLength(1) + }) + + it('refuses to turn a cell into a row where it stands, rather than nesting a table in the row', () => { + const canvas = store.createCanvas('cell-to-row', 'owner-cells') + const def = createComponentFromHtml(canvas.id, { name: 'Cell2', html: '' }, actor).component + const before = store.getFrame(def.mainFrameId!)!.html + expect(() => updateComponent(canvas.id, 'Cell2', { html: '' }, actor)).toThrow( + /sits inside a , which cannot hold a /, + ) + expect(store.getFrame(def.mainFrameId!)!.html).toBe(before) + }) +}) diff --git a/tests/componentTools.test.ts b/tests/componentTools.test.ts index 3ce440a61..0c986b0cc 100644 --- a/tests/componentTools.test.ts +++ b/tests/componentTools.test.ts @@ -14,7 +14,11 @@ vi.mock('../server/db/persist.ts', () => ({ import { buildMcpServer } from '../server/mcp.ts' import { store } from '../server/store.ts' +import * as propagation from '../server/propagation.ts' import { takeComponentIssues } from '../server/actions.ts' +import { findComponent } from '../server/componentActions.ts' +import { previewDocument } from '../server/componentPreview.ts' +import { activeComponents } from '../shared/components.ts' const OWNER = 'owner-1' const AGENT = { agent_name: 'Tester' } @@ -33,6 +37,8 @@ async function call( // eslint-disable-next-line typescript/no-explicit-any ): Promise<{ data: any; text: string; isError: boolean }> { const response = (await client.callTool({ name, arguments: { ...AGENT, ...args } })) as ToolResponse + /* instances follow a changed main in the background: tests read the settled canvas */ + await propagation.whenIdle() const texts = response.content.flatMap((block) => (block.type === 'text' ? [block.text ?? ''] : [])) let data: unknown try { @@ -95,6 +101,26 @@ describe('an agent working with components', () => { expect(listed.data.note).toContain('doop-use') }) + it('previews every variant for an agent, and only the default for the panel', async () => { + const canvas = newCanvas() + const { data: created } = await call('create_component', { + canvas_id: canvas.id, + name: 'Button', + html: BUTTON, + css: CSS, + props: [{ name: 'tone', type: 'enum', options: ['solid', 'ghost'], default: 'ghost' }], + }) + const def = findComponent(canvas.id, created.component.id)! + const sheet = previewDocument(canvas.id, def) + expect(sheet.variants).toBe(2) + expect(sheet.html).toContain('tone=solid') + const card = previewDocument(canvas.id, def, 'default') + expect(card.variants).toBe(1) + expect(card.html).not.toContain('
    ') + expect(card.html).toContain('data-tone="ghost"') + expect(card.html).not.toContain('data-tone="solid"') + }) + it('reads a screen back in short form, at a fraction of the size, and can edit it', async () => { const canvas = newCanvas() await button(canvas.id) @@ -189,7 +215,8 @@ describe('an agent working with components', () => { for (const id of [a, b, created.main_frame_id]) expect(store.getFrame(id)!.html).toContain('btn big') expect(store.getFrame(a)!.html).toContain('Keep A') expect(store.getFrame(b)!.html).toContain('Keep B') - expect(store.getFrame(a)!.approval?.status).toBe('needs_review') + /* the frame follows the component and keeps its sign-off */ + expect(store.getFrame(a)!.approval?.status).toBe('ready_for_dev') const back = await call('restore_component_version', { canvas_id: canvas.id, component: 'Button', rev: 1 }) expect(back.isError).toBe(false) @@ -228,24 +255,17 @@ describe('an agent working with components', () => { it('turns repeated markup into linked instances, differences becoming props', async () => { const canvas = newCanvas() - const card = (title: string) => - `

    ${title}

    Copy for ${title}

    ` - const a = await framed(canvas.id, `${card('One')}${card('Two')}`, 'A') + const card = (title: string, id = '') => + `

    ${title}

    Copy for ${title}

    ` + /* an id an agent wrote itself, not one Doop stamped */ + const a = await framed(canvas.id, `${card('One', 'card-one')}${card('Two')}`, 'A') const b = await framed(canvas.id, card('Three'), 'B') - const found = await call('find_component_candidates', { canvas_id: canvas.id }) - const top = found.data.candidates[0] - expect(top.occurrences).toBe(3) - expect(top.frames).toBe(2) - expect(top.suggested_name).toBe('Card') - /* the block is the finding, not each thing inside it */ - expect(found.data.candidates).toHaveLength(1) - const made = await call('create_component', { canvas_id: canvas.id, - name: top.suggested_name, - frame_id: top.example.frame_id, - element: top.example.element, + name: 'Card', + frame_id: a, + element: 'card-one', replace_matching: true, }) expect(made.isError).toBe(false) @@ -268,7 +288,6 @@ describe('an agent working with components', () => { expect(store.getFrame(a)!.html.match(/card v2/g)!.length).toBeGreaterThanOrEqual(2) expect(store.getFrame(b)!.html).toContain('card v2') expect(store.getFrame(b)!.html).toContain('Three') - expect((await call('find_component_candidates', { canvas_id: canvas.id })).data.candidates).toEqual([]) }) it('places instances and changes several in one write', async () => { @@ -343,12 +362,24 @@ describe('an agent working with components', () => { const canvas = newCanvas() await button(canvas.id) const frameId = await framed(canvas.id, '') + const before = store.getFrame(frameId)!.html const result = await call('delete_component', { canvas_id: canvas.id, component: 'Button' }) - expect(result.data.instances_detached).toBe(1) + expect(result.data.instances_kept).toBe(1) + /* a soft delete: no frame is written, the instance is as it was, the definition is kept */ + expect(store.getFrame(frameId)!.html).toBe(before) + expect(store.getComponents(canvas.id).map((def) => def.status)).toEqual(['deleted']) + expect((await call('list_components', { canvas_id: canvas.id })).data.components).toEqual([]) + + /* cutting the instances loose is asked for, and happens in the background */ + const detached = await call('delete_component', { + canvas_id: canvas.id, + component: 'Button', + detach_instances: true, + }) + expect(detached.data.detach).toMatchObject({ queued: true, instances: 1 }) const html = store.getFrame(frameId)!.html expect(html).toContain('Stays') expect(html).not.toContain('data-doop-instance') - expect(store.getComponents(canvas.id)).toEqual([]) }) it('imports from a library and pulls updates only on request', async () => { @@ -386,6 +417,173 @@ describe('an agent working with components', () => { ).toBeUndefined() }) + it('is told that template attributes on a do nothing, and no override is stored for them', async () => { + const canvas = newCanvas() + await button(canvas.id) + const made = await call('create_component', { + canvas_id: canvas.id, + name: 'Card', + html: '

    Pro

    ', + }) + expect(made.isError).toBe(false) + expect(made.text).toContain('COMPONENT: data-doop-prop on ') + expect(made.text).toContain('data-doop-slot') + expect(made.text).toContain('COMPONENT: data-doop-if on ') + const card = findComponent(canvas.id, 'Card')! + expect(card.props.map((prop) => prop.name)).toEqual(['title']) + expect(card.template).not.toContain('overrides=') + expect(card.template).not.toContain('label:cta') + expect(store.getFrame(made.data.main_frame_id)!.html).not.toContain('label:cta') + expect(store.getFrame(made.data.main_frame_id)!.html).not.toContain('show-cta') + + /* a binding that binds nothing does not stand in for the component's own props */ + const tier = await call('create_component', { + canvas_id: canvas.id, + name: 'Tier', + html: '

    Pro

    Buy
    ', + }) + expect(tier.data.inferred_props).toEqual(['title']) + expect(tier.text.match(/COMPONENT: data-doop-prop/g)).toHaveLength(1) + expect(findComponent(canvas.id, 'Tier')!.template).not.toContain('overrides=') + + /* the same in a frame, where it is not nested in anything */ + const placed = await call('create_frame', { + canvas_id: canvas.id, + name: 'Screen', + html: '', + }) + expect(placed.text).toContain('COMPONENT: data-doop-prop on ') + const html = store.getFrame(placed.data.frame.id)!.html + expect(html).not.toContain('data-doop-prop') + /* prototype wiring on an instance is the instance's own, and stays */ + expect(html).toContain('data-doop-on="click"') + }) + + it('keeps css that restyles a nested component from this one, and names the rules it did not keep', async () => { + const canvas = newCanvas() + await button(canvas.id) + const made = await call('create_component', { + canvas_id: canvas.id, + name: 'Plan', + html: '

    Pro

    ', + css: '.plan { padding: 8px } .plan .btn { width: 100% } .plan > .btn .label { color: red } .btn .label { color: blue } .nope { color: green }', + }) + expect(made.isError).toBe(false) + const plan = () => findComponent(canvas.id, 'Plan')! + expect(plan().rawCss).toContain('.plan .btn { width: 100% }') + expect(plan().rawCss).toContain('.plan > .btn .label { color: red }') + /* scoped to this component's instances, so it reaches the Button inside a Plan and no other */ + expect(plan().css).toContain(`.plan:where([data-doop-instance="${plan().id}"]) .btn { width: 100% }`) + expect(plan().rawCss).not.toContain('color: blue') + expect(plan().rawCss).not.toContain('.nope') + expect(made.text).toContain('COMPONENT: these CSS rules name nothing in “Plan”') + expect(made.text).toContain('.btn .label, .nope') + expect(made.text).not.toContain('.plan .btn,') + + const frameId = await framed( + canvas.id, + '', + ) + expect(store.getFrame(frameId)!.html).toContain(`.plan:where([data-doop-instance="${plan().id}"]) .btn`) + + const updated = await call('update_component', { + canvas_id: canvas.id, + component: 'Plan', + css: '.plan .btn { width: auto } .label { font-weight: 600 }', + }) + expect(updated.isError).toBe(false) + expect(plan().rawCss).toContain('.plan .btn { width: auto }') + expect(updated.text).toContain('were not kept: .label.') + expect(store.getFrame(frameId)!.html).toContain('width: auto') + + const clean = await call('update_component', { + canvas_id: canvas.id, + component: 'Plan', + css: '.plan .btn { width: 50% }', + }) + expect(clean.text).not.toContain('were not kept') + }) + + it('names inferred props after what each element is, and lists them in the result', async () => { + const canvas = newCanvas() + const made = await call('create_component', { + canvas_id: canvas.id, + name: 'Offer', + html: '

    Pro

    For teams

    Billed yearly

    Buy
    ', + }) + expect(made.isError).toBe(false) + expect(made.data.component.signature).toBe( + 'Offer(image: image, title: text, text: text, text-2: text, link: link, label: text)', + ) + expect(made.data.inferred_props).toEqual(['image', 'title', 'text', 'text-2', 'link', 'label']) + expect(made.text).toContain('Props inferred from the markup: image, title, text, text-2, link, label') + expect(made.text).toContain('data-doop-prop') + + /* names an author wrote are never touched, and nothing is listed as inferred */ + const own = await call('create_component', { + canvas_id: canvas.id, + name: 'Named', + html: '

    Pro

    Fixed copy

    ', + }) + expect(own.data.component.signature).toBe('Named(headline: text)') + expect(own.data.inferred_props).toBeUndefined() + expect(own.text).not.toContain('Props inferred') + }) + + it('says where a component made from markup went, and how to use it', async () => { + const canvas = newCanvas() + const created = await call('create_component', { canvas_id: canvas.id, name: 'Button', html: BUTTON, css: CSS }) + expect(created.text).toContain('Components page') + expect(created.text).toContain('No instance was placed') + expect(created.text).toContain(' tool.name === 'create_component')!.description! + const opening = description.split('. ').slice(0, 2).join('. ') + expect(opening).toContain('Components page') + expect(opening).toContain(' { + const canvas = newCanvas() + await button(canvas.id) + const frameId = await framed(canvas.id, '') + const before = findComponent(canvas.id, 'Button')! + expect(before.rev).toBe(1) + + const both = await call('update_component', { + canvas_id: canvas.id, + component: 'Button', + html: '', + props: [{ name: 'tone', type: 'enum', options: ['ghost', 'solid'] }], + }) + expect(both.data.rev).toBe(2) + const after = findComponent(canvas.id, 'Button')! + expect(after.history.map((entry) => entry.rev)).toEqual([1]) + /* the kept revision is what instances were rendered from: the old markup with the old props */ + expect(after.history[0]!.template).toBe(before.template) + expect(after.history[0]!.props).toEqual(before.props) + const html = store.getFrame(frameId)!.html + expect(html).toContain('btn wide') + expect(html).toContain('data-doop-rev="2"') + /* an instance that set nothing follows the new default */ + expect(html).toContain('data-tone="ghost"') + + const propsOnly = await call('update_component', { + canvas_id: canvas.id, + component: 'Button', + props: [{ name: 'tone', type: 'enum', options: ['solid', 'ghost', 'outline'] }], + }) + expect(propsOnly.data.rev).toBe(3) + expect(store.getFrame(frameId)!.html).toContain('data-tone="solid"') + + const back = await call('restore_component_version', { canvas_id: canvas.id, component: 'Button', rev: 1 }) + expect(back.data.rev).toBe(4) + expect(findComponent(canvas.id, 'Button')!.history.map((entry) => entry.rev)).toEqual([1, 2, 3]) + expect(store.getFrame(frameId)!.html).not.toContain('btn wide') + }) + it('cannot reach a canvas it cannot read', async () => { const other = store.createCanvas('Private', 'somebody-else') const canvas = newCanvas() @@ -399,3 +597,90 @@ describe('an agent working with components', () => { expect(imported.text).toContain('cannot read') }) }) + +describe('setting up a component system in one call', () => { + const kit = (canvasId: string, components: Record[]) => + call('create_components', { canvas_id: canvasId, components }) + + it('makes a kit in order, so a pattern can nest the primitive listed before it', async () => { + const canvas = newCanvas() + const made = await kit(canvas.id, [ + { name: 'Button', html: BUTTON, css: CSS, props: [{ name: 'tone', type: 'enum', options: ['solid', 'ghost'] }] }, + { name: 'Badge', html: 'New', css: '.badge { padding: 2px 6px }' }, + { + name: 'Card', + html: '

    Title

    ', + css: '.card { padding: 16px }', + }, + ]) + expect(made.isError).toBe(false) + expect(made.data).toMatchObject({ ok: true, created: 3, failed: 0 }) + expect(made.data.results.map((result: { component: { name: string } }) => result.component.name)).toEqual([ + 'Button', + 'Badge', + 'Card', + ]) + expect(made.text).toContain(' store.getFrame(result.main_frame_id)!) + const page = canvasNow.pages?.find((candidate) => candidate.name === 'Components') + expect(mains.every((main: { pageId?: string }) => main.pageId === page?.id)).toBe(true) + /* the card's main renders the nested ones as linked instances */ + const card = mains[2] + for (const nested of ['Badge', 'Button']) + expect(card.html).toMatch(new RegExp(`<[a-z]+[^>]*data-doop-instance="${findComponent(canvas.id, nested)!.id}"`)) + /* and the mains do not sit on top of each other */ + const boxes = mains.map((main: { x: number; y: number }) => `${main.x},${main.y}`) + expect(new Set(boxes).size).toBe(3) + }) + + it('reports a refused entry and still makes the others', async () => { + const canvas = newCanvas() + await button(canvas.id) + const made = await kit(canvas.id, [ + { name: 'Button', html: BUTTON, css: CSS }, + { name: 'Badge', html: 'New' }, + ]) + expect(made.isError).toBe(false) + expect(made.data).toMatchObject({ ok: false, created: 1, failed: 1 }) + expect(made.data.results[0]).toMatchObject({ index: 0, ok: false, name: 'Button' }) + expect(made.data.results[0].error).toBeTruthy() + expect(made.data.results[1]).toMatchObject({ index: 1, ok: true }) + expect(made.text).toContain('1 entry was refused') + const names = activeComponents(store.getCanvas(canvas.id)!.components).map((def) => def.name) + expect(names.sort()).toEqual(['Badge', 'Button']) + }) + + it('refuses an entry that nests a refused one, rather than saving it without that part', async () => { + const canvas = newCanvas() + const made = await kit(canvas.id, [ + /* an enum with no options is refused */ + { name: 'Button', html: BUTTON, css: CSS, props: [{ name: 'tone', type: 'enum' }] }, + { name: 'Card', html: '

    Title

    ' }, + { name: 'Badge', html: 'New' }, + ]) + expect(made.data).toMatchObject({ ok: false, created: 1, failed: 2 }) + expect(made.data.results[1]).toMatchObject({ ok: false, name: 'Card' }) + expect(made.data.results[1].error).toContain('it nests “Button”') + expect(made.data.results[2]).toMatchObject({ ok: true }) + expect(activeComponents(store.getCanvas(canvas.id)!.components).map((def) => def.name)).toEqual(['Badge']) + /* nothing of the refused card is left on the Components page */ + expect(store.getCanvas(canvas.id)!.frames.map((frame) => frame.name)).toEqual(['Badge']) + /* sent again in order once fixed, both are made, the card holding its button */ + const again = await kit(canvas.id, [ + { name: 'Button', html: BUTTON, css: CSS }, + { name: 'Card', html: '

    Title

    ' }, + ]) + expect(again.data).toMatchObject({ ok: true, created: 2 }) + const card = store.getFrame(again.data.results[1].main_frame_id)! + expect(card.html).toContain(`data-doop-instance="${findComponent(canvas.id, 'Button')!.id}"`) + }) + + it('takes at most twelve at a time', async () => { + const canvas = newCanvas() + const many = Array.from({ length: 13 }, (_, index) => ({ name: `Part${index}`, html: `${index}` })) + const refused = await kit(canvas.id, many) + expect(refused.isError).toBe(true) + expect(activeComponents(store.getCanvas(canvas.id)!.components)).toEqual([]) + }) +}) diff --git a/tests/componentUnicode.test.ts b/tests/componentUnicode.test.ts new file mode 100644 index 000000000..40d325903 --- /dev/null +++ b/tests/componentUnicode.test.ts @@ -0,0 +1,76 @@ +import { describe, expect, it, vi } from 'vitest' + +vi.mock('../server/db/persist.ts', () => ({ + saveCanvas: () => {}, + saveFrame: () => {}, + saveFrameNow: async () => {}, + saveActivity: () => {}, + saveFrameVersion: () => {}, + saveTask: () => {}, + saveComponent: () => {}, + deleteComponent: () => {}, +})) + +import * as actions from '../server/actions.ts' +import { healPartialHtml } from '../server/actions.ts' +import { blankComponent } from '../server/components.ts' +import { store } from '../server/store.ts' +import { indexOfAscii, lastIndexOfAscii } from '../shared/asciiSearch.ts' +import { COMPONENT_ATTR, INSTANCE_ATTR, USE_TAG } from '../shared/components.ts' +import type { Actor } from '../shared/types.ts' + +/* "İ" (U+0130) lowercases to two code units: offsets found in a lowercased copy of a frame + pointed one character past every match after it (agent reports, 2026-11-11, Turkish UI) */ +const actor = { name: 'Tester', kind: 'user', color: '#000', clientId: 'x' } as unknown as Actor +const doc = (body: string) => `${body}` + +function canvasWithButton() { + const canvas = store.createCanvas('unicode', 'owner-unicode') + const def = blankComponent({ name: 'Buton', by: 'Tester' }) + store.saveComponent(canvas.id, def) + const main = actions.createFrame(canvas.id, { name: 'Buton main', html: '' }, actor)! + actions.updateFrame( + main.id, + { html: doc(``) }, + actor, + ) + return { canvas, def } +} + +describe('a frame with a Turkish capital dotted I', () => { + it('expands every , those after the character included', () => { + const { canvas, def } = canvasWithButton() + const page = actions.createFrame(canvas.id, { name: 'Sayfa', html: '' }, actor)! + actions.updateFrame( + page.id, + { + html: doc( + '

    İş bulma

    ' + + '', + ), + }, + actor, + ) + const html = store.getFrame(page.id)!.html + expect(html).not.toContain(`<${USE_TAG}`) + expect(html.split(`${INSTANCE_ATTR}="${def.id}"`)).toHaveLength(4) + expect(html).toContain('İş emrini aç') + expect(html).toContain('İptal') + expect(html).not.toContain('<') + }) + + it('drops a half-written script at its start when streaming', () => { + expect(healPartialHtml('

    İstanbul

    + + diff --git a/tests/fixtures/syncCss/sheet.css b/tests/fixtures/syncCss/sheet.css new file mode 100644 index 000000000..7519a231d --- /dev/null +++ b/tests/fixtures/syncCss/sheet.css @@ -0,0 +1,36 @@ +/* Both url()s are relative to this file, as a bundler writes them + (Next.js: /_next/static/css/a.css pointing at ../media/font.woff2). */ +@font-face { + font-family: 'Sync Probe'; + src: url('../fonts/nunito-sans-bold-italic.woff2') format('woff2'); +} +body { + font-family: 'Sync Probe', serif; + background-image: url('../raster/blue.svg'); +} +/* A quoted url() may hold a ")", and a string that only reads like a url() + is text, not a reference. */ +.probe-paren { + background-image: url('../raster/banner (1).svg'); +} +.probe-string::before { + content: 'url(icon.svg)'; +} +/* A custom property keeps its value as written, quotes or none. */ +:root { + --probe-bare: url(../raster/bare.svg); + --probe-single: url('../raster/single.svg'); +} +/* Left as they are: an empty url(), a data: url and an in-document + reference. Rewritten: a custom property's URL( in capitals, and a url + whose query keeps a backslash, which must stay escaped. */ +:root { + --probe-upper: URL(../raster/upper.svg); +} +.probe-kept { + background-image: url(''), url('data:image/svg+xml,%3Csvg%2F%3E'); + mask-image: url('#probe-mask'); +} +.probe-escape { + background-image: url('../raster/q.svg?a\\b'); +} diff --git a/tests/fontFrameWrites.test.ts b/tests/fontFrameWrites.test.ts index 6eb931b3d..60fa5c3b4 100644 --- a/tests/fontFrameWrites.test.ts +++ b/tests/fontFrameWrites.test.ts @@ -43,6 +43,8 @@ const { store } = await import('../server/store.ts') const agent: Actor = { name: 'Claude', kind: 'agent', color: '#e5533c' } const DESIGN = `

    Hi

    ` +/* a stream with no head or body tag yet: nothing can be placed until it ends */ +const FRAGMENT = `

    Hi

    ` /* what open canvases are sent: the frame HTML each frame:updated carried */ const sent: { frameId: string; html: string }[] = [] @@ -91,19 +93,23 @@ describe('library faces on frame writes', () => { expect(store.getFrame(frame.id)!.html).toContain('family=Space+Grotesk:') }) - it('adds them with the done chunk of a stream, not before', () => { + it('adds them from the first chunk of a stream once its head is in, once', () => { const canvasId = store.createCanvas('fonts', 'kevin').id const frame = actions.createFrame(canvasId, { name: 'Hero' }, agent)! + sent.length = 0 actions.appendFrameHtml(frame.id, DESIGN, agent, { start: true }) - expect(store.getFrame(frame.id)!.html).not.toContain(BRAND.url) - actions.appendFrameHtml(frame.id, '', agent, { done: true }) + /* a mid-stream screenshot renders the store; viewers render what they are sent */ expect(store.getFrame(frame.id)!.html).toContain(BRAND.url) + expect(sent.at(-1)?.html).toContain(BRAND.url) + actions.appendFrameHtml(frame.id, '', agent, { done: true }) + expect(store.getFrame(frame.id)!.html.split(BRAND.url)).toHaveLength(2) }) it('adds them when an unfinished stream goes idle', () => { const canvasId = store.createCanvas('fonts', 'kevin').id const frame = actions.createFrame(canvasId, { name: 'Hero' }, agent)! - actions.appendFrameHtml(frame.id, DESIGN, agent, { start: true }) + actions.appendFrameHtml(frame.id, FRAGMENT, agent, { start: true }) + expect(store.getFrame(frame.id)!.html).not.toContain(BRAND.url) sent.length = 0 vi.advanceTimersByTime(31_000) expect(store.getFrame(frame.id)!.html).toContain(BRAND.url) @@ -114,7 +120,7 @@ describe('library faces on frame writes', () => { it('never sends viewers a script the stream left unfinished', () => { const canvasId = store.createCanvas('fonts', 'kevin').id const frame = actions.createFrame(canvasId, { name: 'Hero' }, agent)! - actions.appendFrameHtml(frame.id, `${DESIGN} diff --git a/tests/pagesRename.test.tsx b/tests/pagesRename.test.tsx index 8a830a9f2..7d1089a45 100644 --- a/tests/pagesRename.test.tsx +++ b/tests/pagesRename.test.tsx @@ -94,7 +94,13 @@ describe('PagesPanel rename', () => { container = document.createElement('div') document.body.appendChild(container) root = createRoot(container) - act(() => root.render()) + act(() => + root.render( +
    + +
    , + ), + ) }) afterEach(() => { diff --git a/tests/pagesSplitBrowser.test.ts b/tests/pagesSplitBrowser.test.ts index 5553d01eb..4a0e14169 100644 --- a/tests/pagesSplitBrowser.test.ts +++ b/tests/pagesSplitBrowser.test.ts @@ -76,11 +76,16 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { await page.mouse.up() } - /** the split a long list took to its largest, as a person leaves it, then the page loaded on `canvas` */ - async function reloadAfterLargestSplit(frames: typeof FRAMES, canvas: Parameters[3]) { + /** Leave a large split on the current canvas, then open a different canvas. */ + async function openAnotherCanvas(frames: typeof FRAMES, canvas: Parameters[3]) { await focusSplit() await page.keyboard.press('End') - await showCanvasPage(page, frames, '', canvas) + await showCanvasPage( + page, + frames.map((frame) => ({ ...frame, canvasId: 'small' })), + '?fixtureCanvasId=small', + canvas, + ) } /** the edges of a section's parts, for what must stay inside it */ @@ -135,6 +140,22 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { expect((await sizes()).pages).toBeCloseTo(dragged.pages, 0) }) + it('drags past the last page row and still leaves a visible Layers row at the bottom', async () => { + await showCanvasPage(page, FRAMES, '', { pages: PAGES.slice(0, 12) }) + const before = await fit() + await dragSplit(500) + const after = await sizes() + expect(after.pages).toBeGreaterThanOrEqual(after.rail - 150) + expect((await fit()).pages.bottom - before.lastRow.bottom).toBeGreaterThan(100) + const rowVisible = await page.$eval(FRAME_ROW, (row) => { + const tree = row.closest('[role="tree"]')! + return row.getBoundingClientRect().bottom <= tree.getBoundingClientRect().bottom + }) + expect(rowVisible).toBe(true) + await showCanvasPage(page, FRAMES, '', { pages: PAGES.slice(0, 12) }) + expect((await sizes()).pages).toBeCloseTo(after.pages, 0) + }) + it('reports where the split is and the range it can move in, as the keys, a drag and the window move it', async () => { const start = await liveSeparator() expect(start.min).toBe(pagesMinPx(false)) @@ -184,7 +205,7 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { expect(withPicker.picker!.bottom).toBeLessThanOrEqual(withPicker.pages.bottom + 0.5) }) - describe('with few pages after a large split was saved', () => { + describe('on another canvas after a large split was saved', () => { /** the divider as the section draws it, the panel's own outline color, and the room under it */ const divider = () => page.evaluate(() => { @@ -209,7 +230,7 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { }) it('sizes a single page to its row on an empty canvas, with a full-width divider in the panel outline color', async () => { - await reloadAfterLargestSplit([], { pages: [PAGES[0]!] }) + await openAnotherCanvas([], { pages: [PAGES[0]!] }) const section = await fit() /* the list's bottom padding and the divider are all that is left under the row */ expect(section.pages.bottom - section.firstRow.bottom).toBeLessThanOrEqual(6) @@ -227,7 +248,7 @@ describe.skipIf(!findBrowserPath())('the Pages and Layers split', () => { }) it('grows by the move picker while a frame is selected, keeping the row and the picker inside', async () => { - await reloadAfterLargestSplit(FRAMES, { pages: PAGES.slice(0, 2) }) + await openAnotherCanvas(FRAMES, { pages: PAGES.slice(0, 2) }) const before = await fit() expect(before.picker).toBeNull() expect(before.pages.bottom - before.lastRow.bottom).toBeLessThanOrEqual(6)
    Value
    Value