Skip to content

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

Ask for a sign-in's verification code only after the password (#780)

David McKaybb62c6530ea0
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fa905f66..1b5bf4fe 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,7 +8,7 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
## Unreleased
-**Before upgrading.** Four things change for an existing deployment:
+**Before upgrading.** Five things change for an existing deployment:
- A hosted computer's browser is now headed by default. It uses a little more memory than headless
did; set `COMPUTER_BROWSER_MODE=headless` (Helm: `computers.browserMode: headless`) to keep the old
behaviour.
@@ -28,6 +28,21 @@ Newest first. `Unreleased` is what is on `main` and not yet tagged.
comes back on their next conversation with that Bot (one they turned off and kept stays off).
`OPENBOT_MEMORY_SOURCE_DEFAULTS=false` and `OPENBOT_PROACTIVE_DEFAULTS=false` (Helm: `config.memory.*`)
prevent it.
+- Migration `0056_sign_in_code_step` widens the check on `sign_in_requests.status` to allow
+ `code_required` (below). A server and a computer must be upgraded together: an older computer has
+ no `/sign-in/code`.
+
+### A sign-in's verification code is asked for after the password
+
+The private sign-in form used to ask for a username, a password and "a verification code, if the
+site asks for one" all at once, so a person had to guess whether a code was coming and type one
+before the site had sent it. Now the form asks only for the username and password. If the site,
+once it has the password, shows a one-time-code field, the request waits in a new `code_required`
+state and the form asks for the code the site just sent, on its own. A wrong code keeps asking; a
+code nobody enters expires with the request, and the person can still take over the browser or
+cancel. The Bot is told only how it ended, never the code, and a saved login still never stores one.
+The step is audited as `computer.sign_in_code_requested`, and a failed code as
+`computer.sign_in_failed` with `step: "code"`.
### A licence token from a store reaches the server
diff --git a/agent-computer/src/authorisation.ts b/agent-computer/src/authorisation.ts
index 0bd8a1bd..ddf51b04 100644
--- a/agent-computer/src/authorisation.ts
+++ b/agent-computer/src/authorisation.ts
@@ -75,6 +75,7 @@ const ACTING_PATHS = new Set([
"/files/write",
// Typing a person's login into the page. Refused while they hold the wheel, like any other typing.
"/sign-in/fill",
+ "/sign-in/code",
]);
export function actsOnTheComputer(pathname: string): boolean {
diff --git a/agent-computer/src/index.ts b/agent-computer/src/index.ts
index 01ce9a2f..e05165ac 100644
--- a/agent-computer/src/index.ts
+++ b/agent-computer/src/index.ts
@@ -51,7 +51,12 @@ import {
} from "./secret-masking";
import { type BotSession, createSessions } from "./sessions";
import { createShell } from "./shell";
-import { fillSignIn, parseSignInFill } from "./sign-in";
+import {
+ fillSignIn,
+ fillSignInCode,
+ parseSignInCode,
+ parseSignInFill,
+} from "./sign-in";
import { startVirtualDisplay } from "./virtual-display";
import { applyWebBotAuthPush } from "./web-bot-auth";
import {
@@ -958,6 +963,21 @@ serve<StreamData>({
return json(result);
}
+ /**
+ * The verification code a site asked for after the password, from the same private form.
+ *
+ * Handled exactly as the login above: read once, typed by `fillSignInCode` into the page that is
+ * waiting for it, and dropped.
+ */
+ if (url.pathname === "/sign-in/code" && request.method === "POST") {
+ const input = parseSignInCode(await request.json().catch(() => null));
+ if (typeof input === "string") return json({ error: input }, 400);
+ const target = await currentPage(botId);
+ const result = await fillSignInCode(target, input);
+ if (result.submitted) session.snapshotId += 1;
+ return json(result);
+ }
+
if (
["/control/take", "/control/release", "/control/cancel"].includes(
url.pathname,
diff --git a/agent-computer/src/sign-in.ts b/agent-computer/src/sign-in.ts
index 9641017b..a2ca5837 100644
--- a/agent-computer/src/sign-in.ts
+++ b/agent-computer/src/sign-in.ts
@@ -3,8 +3,13 @@
*
* The private sign-in form posts a username and password to the server, the server posts them here,
* and this types them. The Bot is never involved: it does not pick the fields, it does not see the
- * values, and what comes back says only whether a form was submitted and whether a password field is
- * still showing.
+ * values, and what comes back says only whether a form was submitted, whether a password field is
+ * still showing, and whether the site went on to ask for a verification code.
+ *
+ * A verification code is never asked for up front. It comes after the password, and only when the
+ * site, having accepted the password, shows a one-time-code field: `fillSignIn` reports that and
+ * stops, the person is asked for the code the site just sent, and `fillSignInCode` types it into the
+ * page that is still waiting for it.
*
* Three refusals, before anything is typed:
* - the page must be on the exact origin the person was asked to sign in to, so a login cannot be
@@ -23,12 +28,24 @@ export type SignInFillInput = {
origin: string;
username?: string;
password: string;
- code?: string;
};
export type SignInFillResult = {
submitted: boolean;
passwordFieldVisible: boolean;
+ /** The site accepted the password and is now showing a one-time-code field, on this origin. */
+ codeRequested: boolean;
+ url: string;
+ error?: string;
+};
+
+export type SignInCodeInput = { origin: string; code: string };
+
+export type SignInCodeResult = {
+ submitted: boolean;
+ /** Whether a code field is still showing after submitting: the plainest sign the code was refused. */
+ codeFieldVisible: boolean;
+ passwordFieldVisible: boolean;
url: string;
error?: string;
};
@@ -58,16 +75,27 @@ export function parseSignInFill(body: unknown): SignInFillInput | string {
return "A sign-in needs a password.";
if (input.username !== undefined && typeof input.username !== "string")
return "The username must be text.";
- if (input.code !== undefined && typeof input.code !== "string")
- return "The code must be text.";
+ // A `code` is not read: one is only ever typed after the site asks for it, by `fillSignInCode`.
return {
origin: originOfUrl(input.origin),
password: input.password,
...(input.username ? { username: input.username } : {}),
- ...(input.code ? { code: input.code } : {}),
};
}
+/** Parse the verification-code body, the same way. */
+export function parseSignInCode(body: unknown): SignInCodeInput | string {
+ if (!body || typeof body !== "object") return "A sign-in needs a JSON body.";
+ const input = body as Record<string, unknown>;
+ if (typeof input.origin !== "string" || !originOfUrl(input.origin))
+ return "A sign-in names the website's origin.";
+ if (typeof input.code !== "string" || !input.code.trim())
+ return "A verification code is required.";
+ if (input.code.length > 64)
+ return "A verification code is at most 64 characters.";
+ return { origin: originOfUrl(input.origin), code: input.code.trim() };
+}
+
/**
* Find the login fields on the page and mark them for the locators below.
*
@@ -123,23 +151,39 @@ function markLoginFields(attribute: string) {
return { username: Boolean(username), password: Boolean(password) };
}
-/** Find a one-time-code field. Runs in the page. */
+/**
+ * Find a one-time-code field. Runs in the page.
+ *
+ * The site's own `autocomplete="one-time-code"` first; otherwise a visible text-like field whose name,
+ * id or label reads as a verification code. Any earlier mark is cleared, so a field that has gone
+ * away is never typed into.
+ */
function markCodeField(attribute: string) {
+ for (const node of document.querySelectorAll(`[${attribute}="code"]`))
+ node.removeAttribute(attribute);
const inputs = [
...document.querySelectorAll<HTMLInputElement>("input"),
].filter((input) => {
const box = input.getBoundingClientRect();
+ const style = getComputedStyle(input);
return (
box.width > 0 &&
box.height > 0 &&
+ style.visibility !== "hidden" &&
+ style.display !== "none" &&
!input.disabled &&
- input.type !== "hidden"
+ !input.readOnly &&
+ ["text", "tel", "number", "password", ""].includes(input.type)
);
});
const code =
inputs.find((input) => /one-time-code/.test(input.autocomplete)) ??
- inputs.find((input) =>
- /code|otp|totp|2fa|mfa|verif|token/i.test(`${input.name} ${input.id}`),
+ inputs.find(
+ (input) =>
+ input.type !== "password" &&
+ /code|otp|totp|2fa|mfa|verif|passcode/i.test(
+ `${input.name} ${input.id} ${input.getAttribute("aria-label") ?? ""}`,
+ ),
);
if (code) code.setAttribute(attribute, "code");
return Boolean(code);
@@ -188,8 +232,13 @@ async function settle(page: Page) {
.catch(() => undefined);
}
+/** A password field still showing, other than a one-time-code field a site drew as one. */
async function passwordVisible(page: Page) {
- return (await page.locator("input[type=password]:visible").count()) > 0;
+ return (
+ (await page
+ .locator(`input[type=password]:visible:not([${LOGIN_ATTRIBUTE}="code"])`)
+ .count()) > 0
+ );
}
async function typeSecret(field: Locator, value: string) {
@@ -204,6 +253,7 @@ export async function fillSignIn(
const answer = (error: string, submitted = false): SignInFillResult => ({
submitted,
passwordFieldVisible: false,
+ codeRequested: false,
url: page.url(),
error,
});
@@ -246,30 +296,70 @@ export async function fillSignIn(
await typeSecret(passwordField, input.password);
await submitFrom(page, passwordField);
await settle(page);
- if (input.code) {
- if (originOfUrl(page.url()) !== input.origin)
- return answer(
- `The sign-in moved to ${originOfUrl(page.url()) || "another page"} before the code was asked for. Take over the browser to finish.`,
- true,
- );
- let hasCode = await page.evaluate(markCodeField, LOGIN_ATTRIBUTE);
- if (!hasCode) {
- await page.waitForTimeout(2_000);
- hasCode = await page.evaluate(markCodeField, LOGIN_ATTRIBUTE);
- }
- if (hasCode) {
- const codeField = page.locator(`[${LOGIN_ATTRIBUTE}="code"]`);
- await typeSecret(codeField, input.code);
- await submitFrom(page, codeField);
- await settle(page);
- }
+ // A password field still showing is a refused login; the server says so. Only past that is a
+ // code field the site asking for a second step. The code field is looked for first, so one a
+ // site draws as a password input is not mistaken for the login's own, and is then given a
+ // moment to appear.
+ let codeRequested = await page.evaluate(markCodeField, LOGIN_ATTRIBUTE);
+ const refused = await passwordVisible(page);
+ if (!codeRequested && !refused) {
+ await page.waitForTimeout(2_000);
+ codeRequested = await page.evaluate(markCodeField, LOGIN_ATTRIBUTE);
}
+ if (codeRequested && originOfUrl(page.url()) !== input.origin)
+ return answer(
+ `The sign-in moved to ${originOfUrl(page.url()) || "another page"} to ask for a verification code. Take over the browser to finish signing in there.`,
+ true,
+ );
return {
submitted: true,
- passwordFieldVisible: await passwordVisible(page),
+ passwordFieldVisible: codeRequested ? false : refused,
+ codeRequested,
url: page.url(),
};
} catch {
return answer("The login could not be typed into the page.");
}
}
+
+/**
+ * Type the verification code a site asked for into the page that is waiting for it.
+ *
+ * Only after `fillSignIn` reported `codeRequested`, and with the same refusals: the page must still
+ * be on the origin the person was asked to sign in to, and must still be showing a code field.
+ */
+export async function fillSignInCode(
+ page: Page,
+ input: SignInCodeInput,
+): Promise<SignInCodeResult> {
+ const answer = (error: string, submitted = false): SignInCodeResult => ({
+ submitted,
+ codeFieldVisible: false,
+ passwordFieldVisible: false,
+ url: page.url(),
+ error,
+ });
+ if (originOfUrl(page.url()) !== input.origin)
+ return answer(
+ `The Bot's browser is not on ${input.origin} any more. Take over the browser to finish signing in.`,
+ );
+ try {
+ if (!(await page.evaluate(markCodeField, LOGIN_ATTRIBUTE)))
+ return answer("The site is not asking for a verification code any more.");
+ const codeField = page.locator(`[${LOGIN_ATTRIBUTE}="code"]`);
+ await typeSecret(codeField, input.code);
+ await submitFrom(page, codeField);
+ await settle(page);
+ const codeFieldVisible =
+ originOfUrl(page.url()) === input.origin &&
+ (await page.evaluate(markCodeField, LOGIN_ATTRIBUTE));
+ return {
+ submitted: true,
+ codeFieldVisible,
+ passwordFieldVisible: await passwordVisible(page),
+ url: page.url(),
+ };
+ } catch {
+ return answer("The verification code could not be typed into the page.");
+ }
+}
diff --git a/agent-computer/tests/authorisation.test.ts b/agent-computer/tests/authorisation.test.ts
index 02927ebc..873ad4aa 100644
--- a/agent-computer/tests/authorisation.test.ts
+++ b/agent-computer/tests/authorisation.test.ts
@@ -120,6 +120,8 @@ describe("what the wheel stops while a person is driving", () => {
"/scroll",
"/exec",
"/files/write",
+ "/sign-in/fill",
+ "/sign-in/code",
]) {
expect(actsOnTheComputer(path)).toBeTrue();
}
diff --git a/agent-computer/tests/sign-in.test.ts b/agent-computer/tests/sign-in.test.ts
index f2f45456..6f24af29 100644
--- a/agent-computer/tests/sign-in.test.ts
+++ b/agent-computer/tests/sign-in.test.ts
@@ -7,7 +7,13 @@ import {
SECRET_ATTRIBUTE,
sensitiveRefs,
} from "../src/secret-masking";
-import { fillSignIn, originOfUrl, parseSignInFill } from "../src/sign-in";
+import {
+ fillSignIn,
+ fillSignInCode,
+ originOfUrl,
+ parseSignInCode,
+ parseSignInFill,
+} from "../src/sign-in";
/**
* The computer's half of the private sign-in, against a real Chromium and a real login page served
@@ -22,6 +28,7 @@ import { fillSignIn, originOfUrl, parseSignInFill } from "../src/sign-in";
*/
const asked = process.env.OPENBOT_COMPUTER_BROWSER === "1";
const PASSWORD = "hunter2-not-for-the-model";
+const CODE = "482913";
let browser: Browser;
let server: ReturnType<typeof Bun.serve>;
let origin = "";
@@ -57,6 +64,40 @@ beforeAll(async () => {
return page(`<form method="post" action="/session">
<input name="email" type="email" value="${url.searchParams.get("username") ?? ""}">
<input name="password" type="password"></form>`);
+ // A site that asks for a one-time code only once the password is accepted, the way MFA works.
+ if (url.pathname === "/mfa-login")
+ return page(`<form method="post" action="/mfa-session">
+ <label>Email <input name="email" type="email"></label>
+ <label>Password <input name="password" type="password"></label>
+ <button>Sign in</button></form>`);
+ if (url.pathname === "/mfa-session" && request.method === "POST") {
+ const form = await request.formData();
+ return form.get("password") === PASSWORD
+ ? Response.redirect(`${origin}/mfa-code`, 303)
+ : Response.redirect(`${origin}/mfa-login`, 303);
+ }
+ if (url.pathname === "/mfa-code")
+ return page(`<p>We sent a code to your phone.</p>
+ <form method="post" action="/mfa-verify">
+ <label>Verification code <input name="otp" autocomplete="one-time-code" inputmode="numeric"></label>
+ <button>Verify</button></form>`);
+ // The same, with the code field drawn as a password input, as some sites do.
+ if (url.pathname === "/masked-login")
+ return page(`<form method="post" action="/masked-session">
+ <input name="email" type="email"><input name="password" type="password">
+ <button>Sign in</button></form>`);
+ if (url.pathname === "/masked-session" && request.method === "POST")
+ return page(`<form method="post" action="/mfa-verify">
+ <input name="otp" type="password" autocomplete="one-time-code">
+ <button>Verify</button></form>`);
+ if (url.pathname === "/mfa-verify" && request.method === "POST") {
+ const form = await request.formData();
+ return form.get("otp") === CODE
+ ? Response.redirect(`${origin}/home`, 303)
+ : page(`<p>That code is not right.</p>
+ <form method="post" action="/mfa-verify">
+ <input name="otp" autocomplete="one-time-code"><button>Verify</button></form>`);
+ }
if (url.pathname === "/home") return page("<h1>Welcome back</h1>");
return new Response("not found", { status: 404 });
},
@@ -94,6 +135,23 @@ describe("parsing what the server sends", () => {
});
expect(originOfUrl("about:blank")).toBe("");
});
+
+ test("a code is never part of the login, and comes on its own once the site asks", () => {
+ // Sent with the password by an older client: dropped, so it can never be typed early.
+ expect(parseSignInFill({ origin, password: PASSWORD, code: CODE })).toEqual(
+ { origin, password: PASSWORD },
+ );
+ expect(parseSignInCode({ origin, code: "" })).toBe(
+ "A verification code is required.",
+ );
+ expect(parseSignInCode({ origin: "nope", code: CODE })).toBe(
+ "A sign-in names the website's origin.",
+ );
+ expect(parseSignInCode({ origin: `${origin}/x`, code: CODE })).toEqual({
+ origin,
+ code: CODE,
+ });
+ });
});
describe.skipIf(!asked)("typing a login", () => {
@@ -107,6 +165,7 @@ describe.skipIf(!asked)("typing a login", () => {
expect(result).toEqual({
submitted: true,
passwordFieldVisible: false,
+ codeRequested: false,
url: `${origin}/home`,
});
expect(JSON.stringify(result)).not.toContain(PASSWORD);
@@ -154,6 +213,90 @@ describe.skipIf(!asked)("typing a login", () => {
});
});
+describe.skipIf(!asked)(
+ "a site that asks for a code after the password",
+ () => {
+ test("stops at the code page and says so, then types the code it is given and finishes", async () => {
+ const tab = await open("/mfa-login");
+ const login = await fillSignIn(tab, {
+ origin,
+ username: "[email protected]",
+ password: PASSWORD,
+ });
+ // The password went in and the site moved on to ask for a code. Nothing was guessed at it.
+ expect(login).toEqual({
+ submitted: true,
+ passwordFieldVisible: false,
+ codeRequested: true,
+ url: `${origin}/mfa-code`,
+ });
+ expect(await tab.locator("input[name=otp]").inputValue()).toBe("");
+
+ const finished = await fillSignInCode(tab, { origin, code: CODE });
+ expect(finished).toEqual({
+ submitted: true,
+ codeFieldVisible: false,
+ passwordFieldVisible: false,
+ url: `${origin}/home`,
+ });
+ expect(JSON.stringify([login, finished])).not.toContain(PASSWORD);
+ expect(JSON.stringify([login, finished])).not.toContain(CODE);
+ await tab.close();
+ });
+
+ test("a code field drawn as a password input is the code step, not a refused login", async () => {
+ const tab = await open("/masked-login");
+ const login = await fillSignIn(tab, {
+ origin,
+ username: "[email protected]",
+ password: PASSWORD,
+ });
+ expect(login).toMatchObject({
+ submitted: true,
+ passwordFieldVisible: false,
+ codeRequested: true,
+ });
+ const finished = await fillSignInCode(tab, { origin, code: CODE });
+ expect(finished.url).toBe(`${origin}/home`);
+ await tab.close();
+ });
+
+ test("a code the site refuses leaves its code field showing, which is the failure signal", async () => {
+ const tab = await open("/mfa-login");
+ await fillSignIn(tab, {
+ origin,
+ username: "[email protected]",
+ password: PASSWORD,
+ });
+ const refused = await fillSignInCode(tab, { origin, code: "000000" });
+ expect(refused).toMatchObject({
+ submitted: true,
+ codeFieldVisible: true,
+ });
+ // And the right one still finishes from there.
+ const finished = await fillSignInCode(tab, { origin, code: CODE });
+ expect(finished).toMatchObject({ codeFieldVisible: false });
+ expect(finished.url).toBe(`${origin}/home`);
+ await tab.close();
+ });
+
+ test("types no code when the page is not asking for one, or is on another origin", async () => {
+ const tab = await open("/home");
+ expect(await fillSignInCode(tab, { origin, code: CODE })).toMatchObject({
+ submitted: false,
+ error: "The site is not asking for a verification code any more.",
+ });
+ const elsewhere = await fillSignInCode(tab, {
+ origin: "https://example.com",
+ code: CODE,
+ });
+ expect(elsewhere.submitted).toBe(false);
+ expect(elsewhere.error).toContain("not on https://example.com");
+ await tab.close();
+ });
+ },
+);
+
describe.skipIf(!asked)("secrets typed into the page are not read back", () => {
test("the aria snapshot shows a password's value, and the masked snapshot does not", async () => {
const tab = await browser.newPage();
diff --git a/app/src/components/passwords/sign-in-form.tsx b/app/src/components/passwords/sign-in-form.tsx
index 01597ac4..6eb73a1c 100644
--- a/app/src/components/passwords/sign-in-form.tsx
+++ b/app/src/components/passwords/sign-in-form.tsx
@@ -1,4 +1,9 @@
-import { IconKey, IconLock, IconPointer } from "@tabler/icons-react";
+import {
+ IconKey,
+ IconLock,
+ IconPointer,
+ IconShieldCheck,
+} from "@tabler/icons-react";
import { useMutation, useQuery } from "@tanstack/react-query";
import { Link } from "@tanstack/react-router";
import { useId, useState } from "react";
@@ -19,6 +24,7 @@ import {
cancelSignInMutationOptions,
confirmSavedLoginMutationOptions,
finishSignInMutationOptions,
+ submitSignInCodeMutationOptions,
submitSignInMutationOptions,
takeOverSignInMutationOptions,
} from "@/lib/passwords/mutations";
@@ -37,6 +43,10 @@ import { queryClient } from "@/query-client";
* component's state until it is sent and is cleared the moment it is.
*
* Four answers: type a login, confirm a saved one, take over the browser, or decline.
+ *
+ * A verification code is never asked for here up front. If the site, once it has the password, sends
+ * one, the server reports `code_required` and this form asks for that code alone, then sends it on
+ * its own, cleared from state the same way.
*/
export function SignInForm({ requestId }: { requestId: string }) {
const request = useQuery({
@@ -48,6 +58,7 @@ export function SignInForm({ requestId }: { requestId: string }) {
: 3_000,
});
const submit = useMutation(submitSignInMutationOptions(queryClient));
+ const submitCode = useMutation(submitSignInCodeMutationOptions(queryClient));
const confirmSaved = useMutation(
confirmSavedLoginMutationOptions(queryClient),
);
@@ -70,11 +81,13 @@ export function SignInForm({ requestId }: { requestId: string }) {
const data = request.data;
const busy =
submit.isPending ||
+ submitCode.isPending ||
confirmSaved.isPending ||
takeOver.isPending ||
finish.isPending ||
cancel.isPending;
const failure =
+ submitCode.error ??
submit.error ??
confirmSaved.error ??
takeOver.error ??
@@ -90,6 +103,73 @@ export function SignInForm({ requestId }: { requestId: string }) {
</PageSection>
);
+ if (data.status === "code_required")
+ return (
+ <PageSection
+ title="Enter the verification code"
+ description="The site sent a verification code. Enter it to finish signing in."
+ >
+ <form
+ className="flex flex-col gap-3"
+ autoComplete="off"
+ onSubmit={(event) => {
+ event.preventDefault();
+ const value = code.trim();
+ if (!value) return;
+ submitCode.mutate(
+ { id: requestId, code: value },
+ // Cleared whatever happened: a code is good once, and a wrong one is retyped.
+ { onSettled: () => setCode("") },
+ );
+ }}
+ >
+ <label className="flex flex-col gap-1 text-sm" htmlFor={`${id}-code`}>
+ Verification code
+ <Input
+ id={`${id}-code`}
+ autoComplete="one-time-code"
+ inputMode="numeric"
+ name="code"
+ required
+ autoFocus
+ value={code}
+ onChange={(event) => setCode(event.target.value)}
+ />
+ </label>
+ {failure || data.outcome ? (
+ <p className="text-destructive text-sm" role="alert">
+ {failure?.message ?? data.outcome}
+ </p>
+ ) : null}
+ <div className="flex flex-wrap gap-2">
+ <Button size="sm" type="submit" disabled={busy || !code.trim()}>
+ <IconShieldCheck />
+ {submitCode.isPending ? "Checking…" : "Finish signing in"}
+ </Button>
+ <Button
+ size="sm"
+ type="button"
+ variant="outline"
+ disabled={busy}
+ onClick={() => takeOver.mutate(requestId)}
+ >
+ <IconPointer />
+ Take over to finish
+ </Button>
+ <Button
+ size="sm"
+ type="button"
+ variant="ghost"
+ disabled={busy}
+ onClick={() => cancel.mutate(requestId)}
+ >
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </PageSection>
+ );
+
if (data.status === "taken_over")
return (
<PageSection
@@ -159,14 +239,10 @@ export function SignInForm({ requestId }: { requestId: string }) {
size="sm"
disabled={busy}
onClick={() =>
- confirmSaved.mutate(
- {
- id: requestId,
- loginId: login.id,
- ...(code ? { code } : {}),
- },
- { onSettled: () => setCode("") },
- )
+ confirmSaved.mutate({
+ id: requestId,
+ loginId: login.id,
+ })
}
>
Confirm and sign in
@@ -194,16 +270,12 @@ export function SignInForm({ requestId }: { requestId: string }) {
input: {
...(username ? { username } : {}),
password,
- ...(code ? { code } : {}),
save,
},
},
{
// Cleared whatever happened: a failed attempt is retyped, never kept.
- onSettled: () => {
- setPassword("");
- setCode("");
- },
+ onSettled: () => setPassword(""),
},
);
}}
@@ -236,18 +308,6 @@ export function SignInForm({ requestId }: { requestId: string }) {
onChange={(event) => setPassword(event.target.value)}
/>
</label>
- <label className="flex flex-col gap-1 text-sm" htmlFor={`${id}-code`}>
- Verification code, if the site asks for one
- <Input
- id={`${id}-code`}
- autoComplete="one-time-code"
- inputMode="numeric"
- name="code"
- type="password"
- value={code}
- onChange={(event) => setCode(event.target.value)}
- />
- </label>
{data.passwordManager ? (
<label
className="flex items-center gap-2 text-sm"
diff --git a/app/src/lib/passwords/mutations.ts b/app/src/lib/passwords/mutations.ts
index a2b87894..07bda979 100644
--- a/app/src/lib/passwords/mutations.ts
+++ b/app/src/lib/passwords/mutations.ts
@@ -7,6 +7,10 @@ const FALLBACK = "The sign-in could not be completed";
const invalidate = (queryClient: QueryClient) =>
queryClient.invalidateQueries({ queryKey: passwordKeys.all });
+/** The request as the answer left it, shown at once rather than at the next poll. */
+const show = (queryClient: QueryClient) => (request: SignInRequest) =>
+ queryClient.setQueryData(passwordKeys.signIn(request.id), request);
+
const path = (id: string, action: string) =>
`/api/sign-in-requests/${encodeURIComponent(id)}/${action}`;
@@ -18,11 +22,15 @@ async function post(id: string, action: string, body?: unknown) {
}).then((response) => response.json())) as SignInRequest;
}
-/** The credential goes in the request body and nowhere else: not state, not the cache, not a log. */
+/**
+ * The credential goes in the request body and nowhere else: not state, not the cache, not a log.
+ *
+ * No verification code: one is asked for only after the site has the password, and only if the site
+ * then asks (the request is `code_required`). See `submitSignInCodeMutationOptions`.
+ */
export type SignInSubmission = {
username?: string;
password: string;
- code?: string;
save?: boolean;
};
@@ -30,6 +38,17 @@ export function submitSignInMutationOptions(queryClient: QueryClient) {
return mutationOptions({
mutationFn: (variables: { id: string; input: SignInSubmission }) =>
post(variables.id, "submit", variables.input),
+ onSuccess: show(queryClient),
+ onSettled: () => invalidate(queryClient),
+ });
+}
+
+/** The verification code the site sent, once the request is `code_required`. The code and nothing else. */
+export function submitSignInCodeMutationOptions(queryClient: QueryClient) {
+ return mutationOptions({
+ mutationFn: (variables: { id: string; code: string }) =>
+ post(variables.id, "code", { code: variables.code }),
+ onSuccess: show(queryClient),
onSettled: () => invalidate(queryClient),
});
}
@@ -37,11 +56,9 @@ export function submitSignInMutationOptions(queryClient: QueryClient) {
/** Choosing a saved login in the form is the owner's confirmation to use it for this sign-in. */
export function confirmSavedLoginMutationOptions(queryClient: QueryClient) {
return mutationOptions({
- mutationFn: (variables: { id: string; loginId: string; code?: string }) =>
- post(variables.id, "use-saved", {
- loginId: variables.loginId,
- ...(variables.code ? { code: variables.code } : {}),
- }),
+ mutationFn: (variables: { id: string; loginId: string }) =>
+ post(variables.id, "use-saved", { loginId: variables.loginId }),
+ onSuccess: show(queryClient),
onSettled: () => invalidate(queryClient),
});
}
diff --git a/app/src/lib/passwords/queries.ts b/app/src/lib/passwords/queries.ts
index 35f07dd4..1439b95c 100644
--- a/app/src/lib/passwords/queries.ts
+++ b/app/src/lib/passwords/queries.ts
@@ -10,6 +10,8 @@ import { client } from "@/lib/client";
export type SignInStatus =
| "pending"
| "filling"
+ /** The site took the password and sent a verification code; the form asks for only that now. */
+ | "code_required"
| "taken_over"
| "signed_in"
| "failed"
diff --git a/app/tests/sign-in-code-after-password.test.tsx b/app/tests/sign-in-code-after-password.test.tsx
new file mode 100644
index 00000000..472dd326
--- /dev/null
+++ b/app/tests/sign-in-code-after-password.test.tsx
@@ -0,0 +1,130 @@
+import { afterAll, afterEach, beforeAll, expect, test } from "bun:test";
+import { GlobalRegistrator } from "@happy-dom/global-registrator";
+import { QueryClientProvider } from "@tanstack/react-query";
+import { cleanup, render, waitFor } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { SignInForm } from "@/components/passwords/sign-in-form";
+import { queryClient } from "@/query-client";
+import { settleReactWork } from "./settle-react-work";
+
+/**
+ * "All MFA codes are after the fact, none are during or before."
+ *
+ * The private sign-in form, rendered for real against a server that behaves like the passwords
+ * routes: it asks for a username and password and nothing else, and only once the server says the
+ * site sent a code (`code_required`) does it ask for that code, on its own, and send it on its own.
+ */
+
+beforeAll(() => GlobalRegistrator.register());
+afterEach(() => {
+ cleanup();
+ queryClient.clear();
+});
+afterAll(async () => {
+ await settleReactWork();
+ GlobalRegistrator.unregister();
+});
+
+const originalFetch = global.fetch;
+afterEach(() => {
+ global.fetch = originalFetch;
+});
+
+const PASSWORD = "correct-horse-battery-staple";
+const CODE = "731904";
+const ID = "request-mfa";
+
+function serving() {
+ const state = {
+ id: ID,
+ botId: "default",
+ origin: "https://portal.example",
+ reason: null,
+ status: "pending",
+ method: null as string | null,
+ outcome: null as string | null,
+ threadId: null,
+ toolCallId: null,
+ controlRequestId: null,
+ createdAt: "2026-10-12T10:00:00Z",
+ expiresAt: "2026-10-12T10:15:00Z",
+ resolvedAt: null,
+ fillingUntil: null,
+ passwordManager: true,
+ savedLogins: [],
+ };
+ const posted: { path: string; body: Record<string, unknown> }[] = [];
+ global.fetch = Object.assign(
+ async (input: RequestInfo | URL, init?: RequestInit) => {
+ const path = new URL(String(input), "http://127.0.0.1").pathname;
+ if (init?.method === "POST") {
+ const body = JSON.parse(String(init.body ?? "{}"));
+ posted.push({ path, body });
+ if (path.endsWith("/submit")) {
+ state.status = "code_required";
+ state.method = "typed";
+ } else if (path.endsWith("/code") && body.code === CODE) {
+ state.status = "signed_in";
+ state.outcome = "Signed in to https://portal.example.";
+ } else if (path.endsWith("/code")) {
+ state.outcome =
+ "The site did not accept that code. Check it, or ask the site for a new one, and try again.";
+ return Response.json({ error: state.outcome }, { status: 409 });
+ }
+ return Response.json(state);
+ }
+ if (path === `/api/sign-in-requests/${ID}`) return Response.json(state);
+ return Response.json({ error: "Not found" }, { status: 404 });
+ },
+ { preconnect: originalFetch.preconnect },
+ );
+ return { state, posted };
+}
+
+test("asks for the login first, and for the code only once the site has sent one", async () => {
+ const server = serving();
+ const user = userEvent.setup({ document });
+ const tree = render(
+ <QueryClientProvider client={queryClient}>
+ <SignInForm requestId={ID} />
+ </QueryClientProvider>,
+ );
+ const password = await tree.findByLabelText("Password");
+ expect(tree.getByLabelText("Username or email")).toBeDefined();
+ // Nothing about a code before the site has asked for one.
+ expect(tree.queryByLabelText(/code/i)).toBeNull();
+ expect(tree.queryByText(/verification code/i)).toBeNull();
+
+ await user.type(
+ tree.getByLabelText("Username or email"),
+ );
+ await user.type(password, PASSWORD);
+ await user.click(tree.getByRole("button", { name: /^Sign in$/ }));
+
+ await tree.findByText(
+ "The site sent a verification code. Enter it to finish signing in.",
+ );
+ // The login form is gone, and its password with it; one field is left: the code.
+ expect(tree.queryByLabelText("Password")).toBeNull();
+ const code = tree.getByLabelText("Verification code");
+ expect(server.posted[0]?.path).toBe(`/api/sign-in-requests/${ID}/submit`);
+ expect(server.posted[0]?.body).not.toHaveProperty("code");
+
+ // A wrong code says so and keeps asking.
+ await user.type(code, "000000");
+ await user.click(tree.getByRole("button", { name: /Finish signing in/ }));
+ await tree.findAllByText(/did not accept that code/);
+ expect(tree.getByLabelText("Verification code")).toBeDefined();
+
+ await user.type(tree.getByLabelText("Verification code"), CODE);
+ await user.click(tree.getByRole("button", { name: /Finish signing in/ }));
+ await tree.findByText("Signed in");
+ await waitFor(() => expect(server.posted).toHaveLength(3));
+ expect(server.posted.slice(1).map((post) => post.path)).toEqual([
+ `/api/sign-in-requests/${ID}/code`,
+ `/api/sign-in-requests/${ID}/code`,
+ ]);
+ // The code step carries the code and nothing else: no password is sent twice.
+ expect(server.posted[2]?.body).toEqual({ code: CODE });
+});
diff --git a/server/drizzle/0056_sign_in_code_step.sql b/server/drizzle/0056_sign_in_code_step.sql
new file mode 100644
index 00000000..6ffd2d46
--- /dev/null
+++ b/server/drizzle/0056_sign_in_code_step.sql
@@ -0,0 +1,2 @@
+ALTER TABLE "sign_in_requests" DROP CONSTRAINT "sign_in_requests_status_check";--> statement-breakpoint
+ALTER TABLE "sign_in_requests" ADD CONSTRAINT "sign_in_requests_status_check" CHECK ("sign_in_requests"."status" IN ('pending', 'filling', 'code_required', 'taken_over', 'signed_in', 'failed', 'cancelled', 'expired'));
\ No newline at end of file
diff --git a/server/drizzle/meta/0056_snapshot.json b/server/drizzle/meta/0056_snapshot.json
new file mode 100644
index 00000000..09950185
--- /dev/null
+++ b/server/drizzle/meta/0056_snapshot.json
@@ -0,0 +1,9863 @@
+{
+ "id": "1e95338a-aa54-4146-9f37-32111c369e75",
+ "prevId": "d319c213-0cdb-4fe0-aa1b-813c9dbcf3c4",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.accounts": {
+ "name": "accounts",
+ "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
+ },
+ "issuer": {
+ "name": "issuer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "accounts_provider_account_idx": {
+ "name": "accounts_provider_account_idx",
+ "columns": [
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "account_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "accounts_user_id_users_id_fk": {
+ "name": "accounts_user_id_users_id_fk",
+ "tableFrom": "accounts",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agents": {
+ "name": "agents",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "agent_type",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "configuration": {
+ "name": "configuration",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "package_id": {
+ "name": "package_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "override": {
+ "name": "override",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agents_package_id_deployment_packages_id_fk": {
+ "name": "agents_package_id_deployment_packages_id_fk",
+ "tableFrom": "agents",
+ "tableTo": "deployment_packages",
+ "columnsFrom": [
+ "package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.attachments": {
+ "name": "attachments",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by": {
+ "name": "uploaded_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mime_type": {
+ "name": "mime_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bytes": {
+ "name": "bytes",
+ "type": "bytea",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "attached_at": {
+ "name": "attached_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "upload_group": {
+ "name": "upload_group",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "attachments_channel_idx": {
+ "name": "attachments_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "attachments_uploaded_by_idx": {
+ "name": "attachments_uploaded_by_idx",
+ "columns": [
+ {
+ "expression": "uploaded_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "attachments_upload_group_idx": {
+ "name": "attachments_upload_group_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "uploaded_by",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "upload_group",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"attachments\".\"attached_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "attachments_staged_idx": {
+ "name": "attachments_staged_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"attachments\".\"attached_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "attachments_channel_id_channels_id_fk": {
+ "name": "attachments_channel_id_channels_id_fk",
+ "tableFrom": "attachments",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "attachments_uploaded_by_users_id_fk": {
+ "name": "attachments_uploaded_by_users_id_fk",
+ "tableFrom": "attachments",
+ "tableTo": "users",
+ "columnsFrom": [
+ "uploaded_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.audit_events": {
+ "name": "audit_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiator_kind": {
+ "name": "initiator_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'person'"
+ },
+ "initiator_id": {
+ "name": "initiator_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_type": {
+ "name": "target_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_id": {
+ "name": "target_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "audit_events_created_at_idx": {
+ "name": "audit_events_created_at_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_events_type_time_idx": {
+ "name": "audit_events_type_time_idx",
+ "columns": [
+ {
+ "expression": "event_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_events_actor_time_idx": {
+ "name": "audit_events_actor_time_idx",
+ "columns": [
+ {
+ "expression": "actor_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_events_target_time_idx": {
+ "name": "audit_events_target_time_idx",
+ "columns": [
+ {
+ "expression": "target_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "target_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "audit_events_initiator_time_idx": {
+ "name": "audit_events_initiator_time_idx",
+ "columns": [
+ {
+ "expression": "initiator_kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_agents": {
+ "name": "channel_agents",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "channel_agents_channel_id_channels_id_fk": {
+ "name": "channel_agents_channel_id_channels_id_fk",
+ "tableFrom": "channel_agents",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_agents_agent_id_agents_id_fk": {
+ "name": "channel_agents_agent_id_agents_id_fk",
+ "tableFrom": "channel_agents",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "channel_agents_channel_id_agent_id_pk": {
+ "name": "channel_agents_channel_id_agent_id_pk",
+ "columns": [
+ "channel_id",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channel_memberships": {
+ "name": "channel_memberships",
+ "schema": "",
+ "columns": {
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_read_at": {
+ "name": "last_read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "channel_memberships_channel_id_channels_id_fk": {
+ "name": "channel_memberships_channel_id_channels_id_fk",
+ "tableFrom": "channel_memberships",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "channel_memberships_user_id_users_id_fk": {
+ "name": "channel_memberships_user_id_users_id_fk",
+ "tableFrom": "channel_memberships",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "channel_memberships_channel_id_user_id_pk": {
+ "name": "channel_memberships_channel_id_user_id_pk",
+ "columns": [
+ "channel_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.channels": {
+ "name": "channels",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "suggested_prompts": {
+ "name": "suggested_prompts",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "allowed_groups": {
+ "name": "allowed_groups",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "package_id": {
+ "name": "package_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "override": {
+ "name": "override",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary_at": {
+ "name": "summary_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message": {
+ "name": "last_message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_source_id": {
+ "name": "last_message_source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_at": {
+ "name": "last_message_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_message_agent_id": {
+ "name": "last_message_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "channels_recent_activity_idx": {
+ "name": "channels_recent_activity_idx",
+ "columns": [
+ {
+ "expression": "COALESCE(\"last_message_at\", \"created_at\") DESC",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "channels_awaiting_summary_idx": {
+ "name": "channels_awaiting_summary_idx",
+ "columns": [
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"channels\".\"summary\" is null and \"channels\".\"deleted_at\" is null",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "channels_package_id_deployment_packages_id_fk": {
+ "name": "channels_package_id_deployment_packages_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "deployment_packages",
+ "columnsFrom": [
+ "package_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "channels_last_message_agent_id_agents_id_fk": {
+ "name": "channels_last_message_agent_id_agents_id_fk",
+ "tableFrom": "channels",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "last_message_agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.credentials": {
+ "name": "credentials",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "kind": {
+ "name": "kind",
+ "type": "credential_kind",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_value": {
+ "name": "encrypted_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key_id": {
+ "name": "key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "credentials_active_key_idx": {
+ "name": "credentials_active_key_idx",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "key_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"credentials\".\"revoked_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.deployment_packages": {
+ "name": "deployment_packages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "tenant_id": {
+ "name": "tenant_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_path": {
+ "name": "source_path",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "checksum": {
+ "name": "checksum",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "loaded_at": {
+ "name": "loaded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "deployment_packages_tenant_id_unique": {
+ "name": "deployment_packages_tenant_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "tenant_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.intelligence_channel_mappings": {
+ "name": "intelligence_channel_mappings",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "intelligence_channel_mappings_thread_idx": {
+ "name": "intelligence_channel_mappings_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "intelligence_channel_mappings_user_id_users_id_fk": {
+ "name": "intelligence_channel_mappings_user_id_users_id_fk",
+ "tableFrom": "intelligence_channel_mappings",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "intelligence_channel_mappings_channel_id_channels_id_fk": {
+ "name": "intelligence_channel_mappings_channel_id_channels_id_fk",
+ "tableFrom": "intelligence_channel_mappings",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "intelligence_channel_mappings_user_id_channel_id_pk": {
+ "name": "intelligence_channel_mappings_user_id_channel_id_pk",
+ "columns": [
+ "user_id",
+ "channel_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.revoked_access": {
+ "name": "revoked_access",
+ "schema": "",
+ "columns": {
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "revoked_by": {
+ "name": "revoked_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sessions": {
+ "name": "sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sessions_user_id_users_id_fk": {
+ "name": "sessions_user_id_users_id_fk",
+ "tableFrom": "sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "sessions_token_unique": {
+ "name": "sessions_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sso_providers": {
+ "name": "sso_providers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issuer": {
+ "name": "issuer",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "oidc_config": {
+ "name": "oidc_config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "saml_config": {
+ "name": "saml_config",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "organization_id": {
+ "name": "organization_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "sso_providers_user_id_users_id_fk": {
+ "name": "sso_providers_user_id_users_id_fk",
+ "tableFrom": "sso_providers",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "sso_providers_provider_id_unique": {
+ "name": "sso_providers_provider_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "provider_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_instructions": {
+ "name": "user_instructions",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_instructions_user_id_users_id_fk": {
+ "name": "user_instructions_user_id_users_id_fk",
+ "tableFrom": "user_instructions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_roles": {
+ "name": "user_roles",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "role",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_roles_user_id_users_id_fk": {
+ "name": "user_roles_user_id_users_id_fk",
+ "tableFrom": "user_roles",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "user_roles_user_id_role_pk": {
+ "name": "user_roles_user_id_role_pk",
+ "columns": [
+ "user_id",
+ "role"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.users": {
+ "name": "users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "preferences": {
+ "name": "preferences",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "groups": {
+ "name": "groups",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "onboarding_step": {
+ "name": "onboarding_step",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "onboarding_completed_at": {
+ "name": "onboarding_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_signed_in_at": {
+ "name": "last_signed_in_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "users_email_unique": {
+ "name": "users_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verifications": {
+ "name": "verifications",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.action_policy": {
+ "name": "action_policy",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deny": {
+ "name": "deny",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allow": {
+ "name": "allow",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.computer_page_frame": {
+ "name": "computer_page_frame",
+ "schema": "",
+ "columns": {
+ "computer_id": {
+ "name": "computer_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "frame": {
+ "name": "frame",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "captured_at": {
+ "name": "captured_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "computer_page_frame_captured_idx": {
+ "name": "computer_page_frame_captured_idx",
+ "columns": [
+ {
+ "expression": "captured_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "computer_page_frame_computer_id_tool_call_id_pk": {
+ "name": "computer_page_frame_computer_id_tool_call_id_pk",
+ "columns": [
+ "computer_id",
+ "tool_call_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.computer_snapshot": {
+ "name": "computer_snapshot",
+ "schema": "",
+ "columns": {
+ "computer_id": {
+ "name": "computer_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "snapshot_id": {
+ "name": "snapshot_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "elements": {
+ "name": "elements",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "taken_at": {
+ "name": "taken_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "session": {
+ "name": "session",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_preferences": {
+ "name": "agent_preferences",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "hidden_at": {
+ "name": "hidden_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pinned_at": {
+ "name": "pinned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agent_preferences_user_id_users_id_fk": {
+ "name": "agent_preferences_user_id_users_id_fk",
+ "tableFrom": "agent_preferences",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_preferences_agent_id_agents_id_fk": {
+ "name": "agent_preferences_agent_id_agents_id_fk",
+ "tableFrom": "agent_preferences",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_preferences_user_id_agent_id_pk": {
+ "name": "agent_preferences_user_id_agent_id_pk",
+ "columns": [
+ "user_id",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_profiles": {
+ "name": "agent_profiles",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role_description": {
+ "name": "role_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "avatar_seed": {
+ "name": "avatar_seed",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "visibility": {
+ "name": "visibility",
+ "type": "agent_visibility",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "callback_token_hash": {
+ "name": "callback_token_hash",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "callback_token_issued_at": {
+ "name": "callback_token_issued_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_profiles_visibility_deleted_idx": {
+ "name": "agent_profiles_visibility_deleted_idx",
+ "columns": [
+ {
+ "expression": "visibility",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "deleted_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_profiles_agent_id_agents_id_fk": {
+ "name": "agent_profiles_agent_id_agents_id_fk",
+ "tableFrom": "agent_profiles",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_profiles_owner_user_id_users_id_fk": {
+ "name": "agent_profiles_owner_user_id_users_id_fk",
+ "tableFrom": "agent_profiles",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.routine_runs": {
+ "name": "routine_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "routine_id": {
+ "name": "routine_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "routine_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waiting": {
+ "name": "waiting",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'schedule'"
+ }
+ },
+ "indexes": {
+ "routine_runs_by_routine_idx": {
+ "name": "routine_runs_by_routine_idx",
+ "columns": [
+ {
+ "expression": "routine_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "routine_runs_routine_id_routines_id_fk": {
+ "name": "routine_runs_routine_id_routines_id_fk",
+ "tableFrom": "routine_runs",
+ "tableTo": "routines",
+ "columnsFrom": [
+ "routine_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.routine_sweeps": {
+ "name": "routine_sweeps",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "swept_at": {
+ "name": "swept_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "owner": {
+ "name": "owner",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.routines": {
+ "name": "routines",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instruction": {
+ "name": "instruction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled_at": {
+ "name": "enabled_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "routines_due_idx": {
+ "name": "routines_due_idx",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "routines_by_owner_idx": {
+ "name": "routines_by_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "routines_owner_user_id_users_id_fk": {
+ "name": "routines_owner_user_id_users_id_fk",
+ "tableFrom": "routines",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "routines_agent_id_agents_id_fk": {
+ "name": "routines_agent_id_agents_id_fk",
+ "tableFrom": "routines",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.component_exclusions": {
+ "name": "component_exclusions",
+ "schema": "",
+ "columns": {
+ "component_name": {
+ "name": "component_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "withheld_by": {
+ "name": "withheld_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "component_exclusions_component_name_components_name_fk": {
+ "name": "component_exclusions_component_name_components_name_fk",
+ "tableFrom": "component_exclusions",
+ "tableTo": "components",
+ "columnsFrom": [
+ "component_name"
+ ],
+ "columnsTo": [
+ "name"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "component_exclusions_agent_id_agents_id_fk": {
+ "name": "component_exclusions_agent_id_agents_id_fk",
+ "tableFrom": "component_exclusions",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "component_exclusions_component_name_agent_id_pk": {
+ "name": "component_exclusions_component_name_agent_id_pk",
+ "columns": [
+ "component_name",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.component_functions": {
+ "name": "component_functions",
+ "schema": "",
+ "columns": {
+ "component_name": {
+ "name": "component_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "function_name": {
+ "name": "function_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_by": {
+ "name": "granted_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "component_functions_component_name_components_name_fk": {
+ "name": "component_functions_component_name_components_name_fk",
+ "tableFrom": "component_functions",
+ "tableTo": "components",
+ "columnsFrom": [
+ "component_name"
+ ],
+ "columnsTo": [
+ "name"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "component_functions_component_name_function_name_pk": {
+ "name": "component_functions_component_name_function_name_pk",
+ "columns": [
+ "component_name",
+ "function_name"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.components": {
+ "name": "components",
+ "schema": "",
+ "columns": {
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft_description": {
+ "name": "draft_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_description": {
+ "name": "published_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published": {
+ "name": "published",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.brokered_connections": {
+ "name": "brokered_connections",
+ "schema": "",
+ "columns": {
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app": {
+ "name": "app",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "holder": {
+ "name": "holder",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vendor_user_id": {
+ "name": "vendor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_by": {
+ "name": "connected_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "verified": {
+ "name": "verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "verified_at": {
+ "name": "verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "probe_action": {
+ "name": "probe_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "brokered_connections_person_idx": {
+ "name": "brokered_connections_person_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "app",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"brokered_connections\".\"holder\" = 'person'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brokered_connections_deployment_idx": {
+ "name": "brokered_connections_deployment_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "app",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"brokered_connections\".\"holder\" = 'deployment'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "brokered_connections_user_idx": {
+ "name": "brokered_connections_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "brokered_connections_holder_check": {
+ "name": "brokered_connections_holder_check",
+ "value": "(\"brokered_connections\".\"holder\" = 'person' AND \"brokered_connections\".\"user_id\" IS NOT NULL) OR (\"brokered_connections\".\"holder\" = 'deployment' AND \"brokered_connections\".\"user_id\" IS NULL)"
+ },
+ "brokered_connections_provider_check": {
+ "name": "brokered_connections_provider_check",
+ "value": "\"brokered_connections\".\"provider\" IN ('composio')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.composio_connections": {
+ "name": "composio_connections",
+ "schema": "",
+ "columns": {
+ "toolkit": {
+ "name": "toolkit",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "verified": {
+ "name": "verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "verified_at": {
+ "name": "verified_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "probe_action": {
+ "name": "probe_action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "composio_connections_user_idx": {
+ "name": "composio_connections_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "composio_connections_toolkit_user_id_pk": {
+ "name": "composio_connections_toolkit_user_id_pk",
+ "columns": [
+ "toolkit",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_servers": {
+ "name": "mcp_servers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "logo": {
+ "name": "logo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "vendor": {
+ "name": "vendor",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provenance": {
+ "name": "provenance",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'first-party'"
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_scheme": {
+ "name": "auth_scheme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "account_mode": {
+ "name": "account_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "shared_vendor_user_id": {
+ "name": "shared_vendor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools_refreshed_at": {
+ "name": "tools_refreshed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "added_by": {
+ "name": "added_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "mcp_servers_credential_id_credentials_id_fk": {
+ "name": "mcp_servers_credential_id_credentials_id_fk",
+ "tableFrom": "mcp_servers",
+ "tableTo": "credentials",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "mcp_servers_account_mode_check": {
+ "name": "mcp_servers_account_mode_check",
+ "value": "\"mcp_servers\".\"account_mode\" IS NULL OR \"mcp_servers\".\"account_mode\" IN ('personal', 'shared')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.mcp_tools": {
+ "name": "mcp_tools",
+ "schema": "",
+ "columns": {
+ "server_id": {
+ "name": "server_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,
+ "default": "''"
+ },
+ "input_schema": {
+ "name": "input_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "effect": {
+ "name": "effect",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "destructive": {
+ "name": "destructive",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "version": {
+ "name": "version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "mcp_tools_server_id_mcp_servers_id_fk": {
+ "name": "mcp_tools_server_id_mcp_servers_id_fk",
+ "tableFrom": "mcp_tools",
+ "tableTo": "mcp_servers",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "mcp_tools_server_id_name_pk": {
+ "name": "mcp_tools_server_id_name_pk",
+ "columns": [
+ "server_id",
+ "name"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.mcp_user_credentials": {
+ "name": "mcp_user_credentials",
+ "schema": "",
+ "columns": {
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connected_at": {
+ "name": "connected_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "mcp_user_credentials_user_idx": {
+ "name": "mcp_user_credentials_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "mcp_user_credentials_server_id_mcp_servers_id_fk": {
+ "name": "mcp_user_credentials_server_id_mcp_servers_id_fk",
+ "tableFrom": "mcp_user_credentials",
+ "tableTo": "mcp_servers",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_user_credentials_user_id_users_id_fk": {
+ "name": "mcp_user_credentials_user_id_users_id_fk",
+ "tableFrom": "mcp_user_credentials",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "mcp_user_credentials_credential_id_credentials_id_fk": {
+ "name": "mcp_user_credentials_credential_id_credentials_id_fk",
+ "tableFrom": "mcp_user_credentials",
+ "tableTo": "credentials",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "mcp_user_credentials_server_id_user_id_pk": {
+ "name": "mcp_user_credentials_server_id_user_id_pk",
+ "columns": [
+ "server_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.plugin_grants": {
+ "name": "plugin_grants",
+ "schema": "",
+ "columns": {
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ref": {
+ "name": "ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "granted_by": {
+ "name": "granted_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "plugin_grants_agent_idx": {
+ "name": "plugin_grants_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "plugin_grants_agent_id_agents_id_fk": {
+ "name": "plugin_grants_agent_id_agents_id_fk",
+ "tableFrom": "plugin_grants",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "plugin_grants_kind_ref_agent_id_pk": {
+ "name": "plugin_grants_kind_ref_agent_id_pk",
+ "columns": [
+ "kind",
+ "ref",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sandboxed_components": {
+ "name": "sandboxed_components",
+ "schema": "",
+ "columns": {
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft_description": {
+ "name": "draft_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_html": {
+ "name": "draft_html",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_css": {
+ "name": "draft_css",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_js_functions": {
+ "name": "draft_js_functions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "draft_argument_schema": {
+ "name": "draft_argument_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "published_description": {
+ "name": "published_description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_html": {
+ "name": "published_html",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_css": {
+ "name": "published_css",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_js_functions": {
+ "name": "published_js_functions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "published_argument_schema": {
+ "name": "published_argument_schema",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "sample_arguments": {
+ "name": "sample_arguments",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "revision": {
+ "name": "revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "published": {
+ "name": "published",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authored_by": {
+ "name": "authored_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.skill_tools": {
+ "name": "skill_tools",
+ "schema": "",
+ "columns": {
+ "skill_id": {
+ "name": "skill_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ref": {
+ "name": "ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "declared_by": {
+ "name": "declared_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "skill_tools_ref_idx": {
+ "name": "skill_tools_ref_idx",
+ "columns": [
+ {
+ "expression": "ref",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "skill_tools_skill_id_skills_id_fk": {
+ "name": "skill_tools_skill_id_skills_id_fk",
+ "tableFrom": "skill_tools",
+ "tableTo": "skills",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "skill_tools_skill_id_ref_pk": {
+ "name": "skill_tools_skill_id_ref_pk",
+ "columns": [
+ "skill_id",
+ "ref"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.skills": {
+ "name": "skills",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'yours'"
+ },
+ "installed_by": {
+ "name": "installed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "skills_slug_key": {
+ "name": "skills_slug_key",
+ "columns": [
+ {
+ "expression": "slug",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "skills_owner_idx": {
+ "name": "skills_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "skills_owner_user_id_users_id_fk": {
+ "name": "skills_owner_user_id_users_id_fk",
+ "tableFrom": "skills",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.work_items": {
+ "name": "work_items",
+ "schema": "",
+ "columns": {
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "run_at": {
+ "name": "run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "claimed_by": {
+ "name": "claimed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "lease_until": {
+ "name": "lease_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "work_items_claimable_idx": {
+ "name": "work_items_claimable_idx",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "work_items_kind_key_pk": {
+ "name": "work_items_kind_key_pk",
+ "columns": [
+ "kind",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.voice_sessions": {
+ "name": "voice_sessions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "anchor_message_id": {
+ "name": "anchor_message_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ended_at": {
+ "name": "ended_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "duration_seconds": {
+ "name": "duration_seconds",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transcript": {
+ "name": "transcript",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "summary": {
+ "name": "summary",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "summary_status": {
+ "name": "summary_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'failed'"
+ }
+ },
+ "indexes": {
+ "voice_sessions_channel_started_idx": {
+ "name": "voice_sessions_channel_started_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "started_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "voice_sessions_channel_id_channels_id_fk": {
+ "name": "voice_sessions_channel_id_channels_id_fk",
+ "tableFrom": "voice_sessions",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "voice_sessions_user_id_users_id_fk": {
+ "name": "voice_sessions_user_id_users_id_fk",
+ "tableFrom": "voice_sessions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "voice_sessions_duration_check": {
+ "name": "voice_sessions_duration_check",
+ "value": "\"voice_sessions\".\"duration_seconds\" >= 0"
+ },
+ "voice_sessions_summary_check": {
+ "name": "voice_sessions_summary_check",
+ "value": "(\"voice_sessions\".\"summary_status\" = 'ready' AND \"voice_sessions\".\"summary\" IS NOT NULL) OR (\"voice_sessions\".\"summary_status\" = 'failed' AND \"voice_sessions\".\"summary\" IS NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.learning_settings": {
+ "name": "learning_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "settings": {
+ "name": "settings",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.learning_thread_bindings": {
+ "name": "learning_thread_bindings",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "container_id": {
+ "name": "container_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "learning_thread_bindings_user_id_thread_id_pk": {
+ "name": "learning_thread_bindings_user_id_thread_id_pk",
+ "columns": [
+ "user_id",
+ "thread_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.responsibilities": {
+ "name": "responsibilities",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "instruction": {
+ "name": "instruction",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "success_criteria": {
+ "name": "success_criteria",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "responsibility_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "progress": {
+ "name": "progress",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "last_result": {
+ "name": "last_result",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subscriptions": {
+ "name": "subscriptions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "responsibilities_owner_status_idx": {
+ "name": "responsibilities_owner_status_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "responsibilities_owner_user_id_users_id_fk": {
+ "name": "responsibilities_owner_user_id_users_id_fk",
+ "tableFrom": "responsibilities",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "responsibilities_agent_id_agents_id_fk": {
+ "name": "responsibilities_agent_id_agents_id_fk",
+ "tableFrom": "responsibilities",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.responsibility_events": {
+ "name": "responsibility_events",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "responsibility_events_source_id_idx": {
+ "name": "responsibility_events_source_id_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "responsibility_events_owner_user_id_users_id_fk": {
+ "name": "responsibility_events_owner_user_id_users_id_fk",
+ "tableFrom": "responsibility_events",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.responsibility_runs": {
+ "name": "responsibility_runs",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "responsibility_id": {
+ "name": "responsibility_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "responsibility_run_status",
+ "typeSchema": "public",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "reply_text": {
+ "name": "reply_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "waiting": {
+ "name": "waiting",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation": {
+ "name": "continuation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "responsibility_runs_event_idx": {
+ "name": "responsibility_runs_event_idx",
+ "columns": [
+ {
+ "expression": "responsibility_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "event_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "responsibility_runs_status_idx": {
+ "name": "responsibility_runs_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "responsibility_runs_responsibility_id_responsibilities_id_fk": {
+ "name": "responsibility_runs_responsibility_id_responsibilities_id_fk",
+ "tableFrom": "responsibility_runs",
+ "tableTo": "responsibilities",
+ "columnsFrom": [
+ "responsibility_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "responsibility_runs_event_id_responsibility_events_id_fk": {
+ "name": "responsibility_runs_event_id_responsibility_events_id_fk",
+ "tableFrom": "responsibility_runs",
+ "tableTo": "responsibility_events",
+ "columnsFrom": [
+ "event_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.responsibility_source_bindings": {
+ "name": "responsibility_source_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "responsibility_source_bindings_owner_idx": {
+ "name": "responsibility_source_bindings_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "responsibility_source_bindings_owner_user_id_users_id_fk": {
+ "name": "responsibility_source_bindings_owner_user_id_users_id_fk",
+ "tableFrom": "responsibility_source_bindings",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "responsibility_source_bindings_credential_id_credentials_id_fk": {
+ "name": "responsibility_source_bindings_credential_id_credentials_id_fk",
+ "tableFrom": "responsibility_source_bindings",
+ "tableTo": "credentials",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.responsibility_triggers": {
+ "name": "responsibility_triggers",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "responsibility_id": {
+ "name": "responsibility_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "responsibility_triggers_owner_idx": {
+ "name": "responsibility_triggers_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "responsibility_triggers_responsibility_idx": {
+ "name": "responsibility_triggers_responsibility_idx",
+ "columns": [
+ {
+ "expression": "responsibility_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "responsibility_triggers_kind_idx": {
+ "name": "responsibility_triggers_kind_idx",
+ "columns": [
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "responsibility_triggers_owner_user_id_users_id_fk": {
+ "name": "responsibility_triggers_owner_user_id_users_id_fk",
+ "tableFrom": "responsibility_triggers",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "responsibility_triggers_responsibility_id_responsibilities_id_fk": {
+ "name": "responsibility_triggers_responsibility_id_responsibilities_id_fk",
+ "tableFrom": "responsibility_triggers",
+ "tableTo": "responsibilities",
+ "columnsFrom": [
+ "responsibility_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "responsibility_triggers_credential_id_credentials_id_fk": {
+ "name": "responsibility_triggers_credential_id_credentials_id_fk",
+ "tableFrom": "responsibility_triggers",
+ "tableTo": "credentials",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.approval_preferences": {
+ "name": "approval_preferences",
+ "schema": "",
+ "columns": {
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "auto_review": {
+ "name": "auto_review",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "host_commands": {
+ "name": "host_commands",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'ask'"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "approval_preferences_owner_user_id_users_id_fk": {
+ "name": "approval_preferences_owner_user_id_users_id_fk",
+ "tableFrom": "approval_preferences",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "approval_preferences_host_commands_check": {
+ "name": "approval_preferences_host_commands_check",
+ "value": "\"approval_preferences\".\"host_commands\" IN ('ask', 'allow', 'never')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.approval_requests": {
+ "name": "approval_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action_digest": {
+ "name": "action_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "action": {
+ "name": "action",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "decision": {
+ "name": "decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "result": {
+ "name": "result",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "decided_at": {
+ "name": "decided_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "completed_at": {
+ "name": "completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "approval_requests_action_idx": {
+ "name": "approval_requests_action_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "tool_call_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "approval_requests_inbox_idx": {
+ "name": "approval_requests_inbox_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "approval_requests_owner_user_id_users_id_fk": {
+ "name": "approval_requests_owner_user_id_users_id_fk",
+ "tableFrom": "approval_requests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "approval_status_check": {
+ "name": "approval_status_check",
+ "value": "\"approval_requests\".\"status\" IN ('pending', 'approved', 'denied', 'consumed', 'completed')"
+ },
+ "approval_decision_check": {
+ "name": "approval_decision_check",
+ "value": "\"approval_requests\".\"decision\" IN ('allow_once', 'allow_always', 'deny', 'handled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.approval_rules": {
+ "name": "approval_rules",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bot_id": {
+ "name": "bot_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_ref": {
+ "name": "tool_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effect": {
+ "name": "effect",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "behaviour": {
+ "name": "behaviour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'allow'"
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "approval_rules_owner_idx": {
+ "name": "approval_rules_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "approval_rules_owner_user_id_users_id_fk": {
+ "name": "approval_rules_owner_user_id_users_id_fk",
+ "tableFrom": "approval_rules",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "approval_rules_behaviour_check": {
+ "name": "approval_rules_behaviour_check",
+ "value": "\"approval_rules\".\"behaviour\" IN ('allow', 'pre_approved', 'ask', 'hand_off')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.approval_team_rules": {
+ "name": "approval_team_rules",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "bot_id": {
+ "name": "bot_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_ref": {
+ "name": "tool_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "effect": {
+ "name": "effect",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "behaviour": {
+ "name": "behaviour",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by": {
+ "name": "created_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revoked_at": {
+ "name": "revoked_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "approval_team_rules_created_by_users_id_fk": {
+ "name": "approval_team_rules_created_by_users_id_fk",
+ "tableFrom": "approval_team_rules",
+ "tableTo": "users",
+ "columnsFrom": [
+ "created_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "approval_team_rules_behaviour_check": {
+ "name": "approval_team_rules_behaviour_check",
+ "value": "\"approval_team_rules\".\"behaviour\" IN ('allow', 'pre_approved', 'ask', 'hand_off')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.approval_team_settings": {
+ "name": "approval_team_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "enforce_auto_review": {
+ "name": "enforce_auto_review",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "custom_rules_enabled": {
+ "name": "custom_rules_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "host_commands_cap": {
+ "name": "host_commands_cap",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'allow'"
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "approval_team_settings_updated_by_users_id_fk": {
+ "name": "approval_team_settings_updated_by_users_id_fk",
+ "tableFrom": "approval_team_settings",
+ "tableTo": "users",
+ "columnsFrom": [
+ "updated_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "approval_team_settings_host_commands_cap_check": {
+ "name": "approval_team_settings_host_commands_cap_check",
+ "value": "\"approval_team_settings\".\"host_commands_cap\" IN ('ask', 'allow', 'never')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.memory_sources": {
+ "name": "memory_sources",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_ref": {
+ "name": "tool_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "args": {
+ "name": "args",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "sync_status": {
+ "name": "sync_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "sync_error": {
+ "name": "sync_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_sync_at": {
+ "name": "last_sync_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "next_sync_at": {
+ "name": "next_sync_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "memory_sources_owner_idx": {
+ "name": "memory_sources_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "memory_sources_due_idx": {
+ "name": "memory_sources_due_idx",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_sync_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "memory_sources_owner_user_id_users_id_fk": {
+ "name": "memory_sources_owner_user_id_users_id_fk",
+ "tableFrom": "memory_sources",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "memory_sources_agent_id_agents_id_fk": {
+ "name": "memory_sources_agent_id_agents_id_fk",
+ "tableFrom": "memory_sources",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.personal_memories": {
+ "name": "personal_memories",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "import_digest": {
+ "name": "import_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provenance": {
+ "name": "provenance",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "review_state": {
+ "name": "review_state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unreviewed'"
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "formed_by": {
+ "name": "formed_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'person'"
+ },
+ "formed_by_agent_id": {
+ "name": "formed_by_agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_app": {
+ "name": "source_app",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_ref": {
+ "name": "source_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_link": {
+ "name": "source_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "observed_at": {
+ "name": "observed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intelligence_memory_id": {
+ "name": "intelligence_memory_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "intelligence_digest": {
+ "name": "intelligence_digest",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "personal_memories_owner_idx": {
+ "name": "personal_memories_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "personal_memories_intelligence_idx": {
+ "name": "personal_memories_intelligence_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "intelligence_memory_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "personal_memories_formed_idx": {
+ "name": "personal_memories_formed_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "formed_by_agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "personal_memories_import_idx": {
+ "name": "personal_memories_import_idx",
+ "columns": [
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "personal_memories_formed_digest_idx": {
+ "name": "personal_memories_formed_digest_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "import_digest",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"personal_memories\".\"formed_by\" = 'bot'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "personal_memories_owner_user_id_users_id_fk": {
+ "name": "personal_memories_owner_user_id_users_id_fk",
+ "tableFrom": "personal_memories",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "personal_memories_source_id_memory_sources_id_fk": {
+ "name": "personal_memories_source_id_memory_sources_id_fk",
+ "tableFrom": "personal_memories",
+ "tableTo": "memory_sources",
+ "columnsFrom": [
+ "source_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "personal_memories_formed_by_agent_id_agents_id_fk": {
+ "name": "personal_memories_formed_by_agent_id_agents_id_fk",
+ "tableFrom": "personal_memories",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "formed_by_agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.default_opt_outs": {
+ "name": "default_opt_outs",
+ "schema": "",
+ "columns": {
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "feature": {
+ "name": "feature",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "default_opt_outs_owner_user_id_users_id_fk": {
+ "name": "default_opt_outs_owner_user_id_users_id_fk",
+ "tableFrom": "default_opt_outs",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "default_opt_outs_agent_id_agents_id_fk": {
+ "name": "default_opt_outs_agent_id_agents_id_fk",
+ "tableFrom": "default_opt_outs",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "default_opt_outs_owner_user_id_agent_id_feature_scope_pk": {
+ "name": "default_opt_outs_owner_user_id_agent_id_feature_scope_pk",
+ "columns": [
+ "owner_user_id",
+ "agent_id",
+ "feature",
+ "scope"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "default_opt_outs_feature_check": {
+ "name": "default_opt_outs_feature_check",
+ "value": "\"default_opt_outs\".\"feature\" IN ('memory_source', 'proactive_research')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.proactive_settings": {
+ "name": "proactive_settings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "focus": {
+ "name": "focus",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "interval_minutes": {
+ "name": "interval_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 240
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_status": {
+ "name": "last_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'idle'"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "proactive_settings_owner_agent_idx": {
+ "name": "proactive_settings_owner_agent_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "proactive_settings_due_idx": {
+ "name": "proactive_settings_due_idx",
+ "columns": [
+ {
+ "expression": "enabled",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "proactive_settings_owner_user_id_users_id_fk": {
+ "name": "proactive_settings_owner_user_id_users_id_fk",
+ "tableFrom": "proactive_settings",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "proactive_settings_agent_id_agents_id_fk": {
+ "name": "proactive_settings_agent_id_agents_id_fk",
+ "tableFrom": "proactive_settings",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "proactive_settings_interval_check": {
+ "name": "proactive_settings_interval_check",
+ "value": "\"proactive_settings\".\"interval_minutes\" >= 60 AND \"proactive_settings\".\"interval_minutes\" <= 1440"
+ },
+ "proactive_settings_status_check": {
+ "name": "proactive_settings_status_check",
+ "value": "\"proactive_settings\".\"last_status\" IN ('idle', 'running', 'succeeded', 'error')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.proactive_suggestions": {
+ "name": "proactive_suggestions",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "setting_id": {
+ "name": "setting_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "detail": {
+ "name": "detail",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_app": {
+ "name": "source_app",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_ref": {
+ "name": "source_ref",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_link": {
+ "name": "source_link",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'open'"
+ },
+ "delivered_at": {
+ "name": "delivered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "proactive_suggestions_owner_idx": {
+ "name": "proactive_suggestions_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "proactive_suggestions_run_idx": {
+ "name": "proactive_suggestions_run_idx",
+ "columns": [
+ {
+ "expression": "run_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "proactive_suggestions_owner_user_id_users_id_fk": {
+ "name": "proactive_suggestions_owner_user_id_users_id_fk",
+ "tableFrom": "proactive_suggestions",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "proactive_suggestions_agent_id_agents_id_fk": {
+ "name": "proactive_suggestions_agent_id_agents_id_fk",
+ "tableFrom": "proactive_suggestions",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "proactive_suggestions_setting_id_proactive_settings_id_fk": {
+ "name": "proactive_suggestions_setting_id_proactive_settings_id_fk",
+ "tableFrom": "proactive_suggestions",
+ "tableTo": "proactive_settings",
+ "columnsFrom": [
+ "setting_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "proactive_suggestions_status_check": {
+ "name": "proactive_suggestions_status_check",
+ "value": "\"proactive_suggestions\".\"status\" IN ('open', 'dismissed', 'started')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.demonstrations": {
+ "name": "demonstrations",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bot_id": {
+ "name": "bot_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'recording'"
+ },
+ "actions": {
+ "name": "actions",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "draft": {
+ "name": "draft",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "skill_slug": {
+ "name": "skill_slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "demonstrations_owner_idx": {
+ "name": "demonstrations_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "demonstrations_active_bot_idx": {
+ "name": "demonstrations_active_bot_idx",
+ "columns": [
+ {
+ "expression": "bot_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"demonstrations\".\"status\" = 'recording'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "demonstrations_owner_user_id_users_id_fk": {
+ "name": "demonstrations_owner_user_id_users_id_fk",
+ "tableFrom": "demonstrations",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "demonstrations_bot_id_agents_id_fk": {
+ "name": "demonstrations_bot_id_agents_id_fk",
+ "tableFrom": "demonstrations",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "bot_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.delivery_bindings": {
+ "name": "delivery_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "identity": {
+ "name": "identity",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "realm": {
+ "name": "realm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "mention_id": {
+ "name": "mention_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "opted_out_at": {
+ "name": "opted_out_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "delivery_binding_identity_idx": {
+ "name": "delivery_binding_identity_idx",
+ "columns": [
+ {
+ "expression": "transport",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "realm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "identity",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "delivery_bindings_owner_idx": {
+ "name": "delivery_bindings_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "delivery_bindings_owner_user_id_users_id_fk": {
+ "name": "delivery_bindings_owner_user_id_users_id_fk",
+ "tableFrom": "delivery_bindings",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_bindings_channel_id_channels_id_fk": {
+ "name": "delivery_bindings_channel_id_channels_id_fk",
+ "tableFrom": "delivery_bindings",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_bindings_agent_id_agents_id_fk": {
+ "name": "delivery_bindings_agent_id_agents_id_fk",
+ "tableFrom": "delivery_bindings",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.delivery_challenges": {
+ "name": "delivery_challenges",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "address": {
+ "name": "address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "consumed_at": {
+ "name": "consumed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "delivery_challenges_owner_user_id_users_id_fk": {
+ "name": "delivery_challenges_owner_user_id_users_id_fk",
+ "tableFrom": "delivery_challenges",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_challenges_channel_id_channels_id_fk": {
+ "name": "delivery_challenges_channel_id_channels_id_fk",
+ "tableFrom": "delivery_challenges",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_challenges_agent_id_agents_id_fk": {
+ "name": "delivery_challenges_agent_id_agents_id_fk",
+ "tableFrom": "delivery_challenges",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.delivery_inbox": {
+ "name": "delivery_inbox",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "binding_id": {
+ "name": "binding_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "realm": {
+ "name": "realm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "delivery_inbox_dedupe_idx": {
+ "name": "delivery_inbox_dedupe_idx",
+ "columns": [
+ {
+ "expression": "source",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "realm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "external_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "delivery_inbox_owner_idx": {
+ "name": "delivery_inbox_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "delivery_inbox_owner_user_id_users_id_fk": {
+ "name": "delivery_inbox_owner_user_id_users_id_fk",
+ "tableFrom": "delivery_inbox",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_inbox_channel_id_channels_id_fk": {
+ "name": "delivery_inbox_channel_id_channels_id_fk",
+ "tableFrom": "delivery_inbox",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_inbox_agent_id_agents_id_fk": {
+ "name": "delivery_inbox_agent_id_agents_id_fk",
+ "tableFrom": "delivery_inbox",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.delivery_outbox": {
+ "name": "delivery_outbox",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "dedupe_key": {
+ "name": "dedupe_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "binding_id": {
+ "name": "binding_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "device_id": {
+ "name": "device_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "transport": {
+ "name": "transport",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "request_id": {
+ "name": "request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'queued'"
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error": {
+ "name": "error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "delivery_outbox_owner_idx": {
+ "name": "delivery_outbox_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "delivery_outbox_provider_idx": {
+ "name": "delivery_outbox_provider_idx",
+ "columns": [
+ {
+ "expression": "transport",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "delivery_outbox_owner_user_id_users_id_fk": {
+ "name": "delivery_outbox_owner_user_id_users_id_fk",
+ "tableFrom": "delivery_outbox",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_outbox_channel_id_channels_id_fk": {
+ "name": "delivery_outbox_channel_id_channels_id_fk",
+ "tableFrom": "delivery_outbox",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "delivery_outbox_agent_id_agents_id_fk": {
+ "name": "delivery_outbox_agent_id_agents_id_fk",
+ "tableFrom": "delivery_outbox",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "delivery_outbox_dedupe_key_unique": {
+ "name": "delivery_outbox_dedupe_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "dedupe_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.push_devices": {
+ "name": "push_devices",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "platform": {
+ "name": "platform",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "push_devices_owner_idx": {
+ "name": "push_devices_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "push_devices_owner_user_id_users_id_fk": {
+ "name": "push_devices_owner_user_id_users_id_fk",
+ "tableFrom": "push_devices",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "push_devices_token_unique": {
+ "name": "push_devices_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.group_bot_threads": {
+ "name": "group_bot_threads",
+ "schema": "",
+ "columns": {
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "group_bot_threads_thread_idx": {
+ "name": "group_bot_threads_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "group_bot_threads_owner_user_id_users_id_fk": {
+ "name": "group_bot_threads_owner_user_id_users_id_fk",
+ "tableFrom": "group_bot_threads",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "group_bot_threads_channel_id_channels_id_fk": {
+ "name": "group_bot_threads_channel_id_channels_id_fk",
+ "tableFrom": "group_bot_threads",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "group_bot_threads_owner_user_id_channel_id_agent_id_pk": {
+ "name": "group_bot_threads_owner_user_id_channel_id_agent_id_pk",
+ "columns": [
+ "owner_user_id",
+ "channel_id",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.group_messages": {
+ "name": "group_messages",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "channel_id": {
+ "name": "channel_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "text": {
+ "name": "text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'completed'"
+ },
+ "details": {
+ "name": "details",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "group_messages_channel_idx": {
+ "name": "group_messages_channel_idx",
+ "columns": [
+ {
+ "expression": "channel_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "group_messages_channel_id_channels_id_fk": {
+ "name": "group_messages_channel_id_channels_id_fk",
+ "tableFrom": "group_messages",
+ "tableTo": "channels",
+ "columnsFrom": [
+ "channel_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "group_messages_owner_user_id_users_id_fk": {
+ "name": "group_messages_owner_user_id_users_id_fk",
+ "tableFrom": "group_messages",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "group_messages_status_check": {
+ "name": "group_messages_status_check",
+ "value": "\"group_messages\".\"status\" IN ('queued', 'running', 'waiting', 'completed', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.action_records": {
+ "name": "action_records",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "surface": {
+ "name": "surface",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bot_id": {
+ "name": "bot_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_name": {
+ "name": "tool_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "command": {
+ "name": "command",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "action_records_created_idx": {
+ "name": "action_records_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "action_records_bot_idx": {
+ "name": "action_records_bot_idx",
+ "columns": [
+ {
+ "expression": "bot_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "action_records_surface_check": {
+ "name": "action_records_surface_check",
+ "value": "\"action_records\".\"surface\" IN ('cloud', 'local')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.capability_settings": {
+ "name": "capability_settings",
+ "schema": "",
+ "columns": {
+ "scope_kind": {
+ "name": "scope_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "capability": {
+ "name": "capability",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allowed": {
+ "name": "allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "capability_settings_scope_kind_scope_id_capability_pk": {
+ "name": "capability_settings_scope_kind_scope_id_capability_pk",
+ "columns": [
+ "scope_kind",
+ "scope_id",
+ "capability"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "capability_settings_scope_kind_check": {
+ "name": "capability_settings_scope_kind_check",
+ "value": "\"capability_settings\".\"scope_kind\" IN ('organization', 'role', 'group')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.enterprise_settings": {
+ "name": "enterprise_settings",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_usage": {
+ "name": "model_usage",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "run_id": {
+ "name": "run_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "allowed": {
+ "name": "allowed",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "model_usage_created_idx": {
+ "name": "model_usage_created_idx",
+ "columns": [
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "model_usage_model_idx": {
+ "name": "model_usage_model_idx",
+ "columns": [
+ {
+ "expression": "model",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "model_usage_source_check": {
+ "name": "model_usage_source_check",
+ "value": "\"model_usage\".\"source\" IN ('configured', 'observed', 'unknown')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.network_policies": {
+ "name": "network_policies",
+ "schema": "",
+ "columns": {
+ "scope_kind": {
+ "name": "scope_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scope_id": {
+ "name": "scope_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "mode": {
+ "name": "mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rules": {
+ "name": "rules",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{\"entries\":[]}'::jsonb"
+ },
+ "locked": {
+ "name": "locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "updated_by": {
+ "name": "updated_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "network_policies_scope_kind_scope_id_pk": {
+ "name": "network_policies_scope_kind_scope_id_pk",
+ "columns": [
+ "scope_kind",
+ "scope_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "network_policies_scope_kind_check": {
+ "name": "network_policies_scope_kind_check",
+ "value": "\"network_policies\".\"scope_kind\" IN ('organization', 'group')"
+ },
+ "network_policies_mode_check": {
+ "name": "network_policies_mode_check",
+ "value": "\"network_policies\".\"mode\" IN ('allow_all', 'defaults_plus_allowlist', 'allowlist_only')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_connection_bindings": {
+ "name": "scim_connection_bindings",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_key": {
+ "name": "connection_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provisioning_domain_id": {
+ "name": "provisioning_domain_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decommissioned_at": {
+ "name": "decommissioned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decommission_status": {
+ "name": "decommission_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "decommission_cursor_user_id": {
+ "name": "decommission_cursor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decommission_reconciled_user_count": {
+ "name": "decommission_reconciled_user_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "decommission_batch_count": {
+ "name": "decommission_batch_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "decommission_revision": {
+ "name": "decommission_revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "decommission_completed_at": {
+ "name": "decommission_completed_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decommission_lease_id": {
+ "name": "decommission_lease_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decommission_lease_expires_at": {
+ "name": "decommission_lease_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "scim_connection_bindings_connection_idx": {
+ "name": "scim_connection_bindings_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_connection_bindings_connection_key_unique": {
+ "name": "scim_connection_bindings_connection_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_group_members": {
+ "name": "scim_group_members",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scim_user_id": {
+ "name": "scim_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "membership_key": {
+ "name": "membership_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_group_members_connection_idx": {
+ "name": "scim_group_members_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_group_members_group_idx": {
+ "name": "scim_group_members_group_idx",
+ "columns": [
+ {
+ "expression": "group_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_group_members_scim_user_idx": {
+ "name": "scim_group_members_scim_user_idx",
+ "columns": [
+ {
+ "expression": "scim_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_members_group_id_scim_groups_id_fk": {
+ "name": "scim_group_members_group_id_scim_groups_id_fk",
+ "tableFrom": "scim_group_members",
+ "tableTo": "scim_groups",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_members_scim_user_id_scim_users_id_fk": {
+ "name": "scim_group_members_scim_user_id_scim_users_id_fk",
+ "tableFrom": "scim_group_members",
+ "tableTo": "scim_users",
+ "columnsFrom": [
+ "scim_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_members_membership_key_unique": {
+ "name": "scim_group_members_membership_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "membership_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_groups": {
+ "name": "scim_groups",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provisioning_domain_id": {
+ "name": "provisioning_domain_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revision": {
+ "name": "revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name_key": {
+ "name": "display_name_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_id_key": {
+ "name": "external_id_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "order_key": {
+ "name": "order_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_groups_connection_idx": {
+ "name": "scim_groups_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_groups_domain_idx": {
+ "name": "scim_groups_domain_idx",
+ "columns": [
+ {
+ "expression": "provisioning_domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_groups_display_name_key_unique": {
+ "name": "scim_groups_display_name_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "display_name_key"
+ ]
+ },
+ "scim_groups_external_id_key_unique": {
+ "name": "scim_groups_external_id_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "external_id_key"
+ ]
+ },
+ "scim_groups_order_key_unique": {
+ "name": "scim_groups_order_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "order_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_identity_tombstones": {
+ "name": "scim_identity_tombstones",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provisioning_domain_id": {
+ "name": "provisioning_domain_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id_key": {
+ "name": "external_id_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "profile": {
+ "name": "profile",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "deleted_at": {
+ "name": "deleted_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_identity_tombstones_connection_idx": {
+ "name": "scim_identity_tombstones_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_identity_tombstones_domain_idx": {
+ "name": "scim_identity_tombstones_domain_idx",
+ "columns": [
+ {
+ "expression": "provisioning_domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_identity_tombstones_user_idx": {
+ "name": "scim_identity_tombstones_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_identity_tombstones_user_id_users_id_fk": {
+ "name": "scim_identity_tombstones_user_id_users_id_fk",
+ "tableFrom": "scim_identity_tombstones",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_identity_tombstones_external_id_key_unique": {
+ "name": "scim_identity_tombstones_external_id_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "external_id_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_projection_grants": {
+ "name": "scim_projection_grants",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provisioning_domain_id": {
+ "name": "provisioning_domain_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "scim_user_id": {
+ "name": "scim_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_kind": {
+ "name": "source_kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_value": {
+ "name": "source_value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "grant_key": {
+ "name": "grant_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_projection_grants_connection_idx": {
+ "name": "scim_projection_grants_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_projection_grants_domain_idx": {
+ "name": "scim_projection_grants_domain_idx",
+ "columns": [
+ {
+ "expression": "provisioning_domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_projection_grants_scim_user_idx": {
+ "name": "scim_projection_grants_scim_user_idx",
+ "columns": [
+ {
+ "expression": "scim_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_projection_grants_user_idx": {
+ "name": "scim_projection_grants_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_projection_grants_scim_user_id_scim_users_id_fk": {
+ "name": "scim_projection_grants_scim_user_id_scim_users_id_fk",
+ "tableFrom": "scim_projection_grants",
+ "tableTo": "scim_users",
+ "columnsFrom": [
+ "scim_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_projection_grants_user_id_users_id_fk": {
+ "name": "scim_projection_grants_user_id_users_id_fk",
+ "tableFrom": "scim_projection_grants",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_projection_grants_grant_key_unique": {
+ "name": "scim_projection_grants_grant_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "grant_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_subjects": {
+ "name": "scim_subjects",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "profile_source_id": {
+ "name": "profile_source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "revision": {
+ "name": "revision",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_subjects_profile_source_idx": {
+ "name": "scim_subjects_profile_source_idx",
+ "columns": [
+ {
+ "expression": "profile_source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_subjects_user_id_users_id_fk": {
+ "name": "scim_subjects_user_id_users_id_fk",
+ "tableFrom": "scim_subjects",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_subjects_user_id_unique": {
+ "name": "scim_subjects_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_users": {
+ "name": "scim_users",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provisioning_domain_id": {
+ "name": "provisioning_domain_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_user_key": {
+ "name": "connection_user_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_name": {
+ "name": "user_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_name_key": {
+ "name": "user_name_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "primary_email": {
+ "name": "primary_email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "work_email_value_index": {
+ "name": "work_email_value_index",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_value_index": {
+ "name": "email_value_index",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "formatted_name": {
+ "name": "formatted_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "given_name": {
+ "name": "given_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "family_name": {
+ "name": "family_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "serialized_emails": {
+ "name": "serialized_emails",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "serialized_attributes": {
+ "name": "serialized_attributes",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "external_id_key": {
+ "name": "external_id_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "order_key": {
+ "name": "order_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_users_connection_idx": {
+ "name": "scim_users_connection_idx",
+ "columns": [
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_users_domain_idx": {
+ "name": "scim_users_domain_idx",
+ "columns": [
+ {
+ "expression": "provisioning_domain_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_users_user_idx": {
+ "name": "scim_users_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_users_user_id_users_id_fk": {
+ "name": "scim_users_user_id_users_id_fk",
+ "tableFrom": "scim_users",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_users_connection_user_key_unique": {
+ "name": "scim_users_connection_user_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "connection_user_key"
+ ]
+ },
+ "scim_users_user_name_key_unique": {
+ "name": "scim_users_user_name_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_name_key"
+ ]
+ },
+ "scim_users_external_id_key_unique": {
+ "name": "scim_users_external_id_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "external_id_key"
+ ]
+ },
+ "scim_users_order_key_unique": {
+ "name": "scim_users_order_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "order_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.bot_lifecycle": {
+ "name": "bot_lifecycle",
+ "schema": "",
+ "columns": {
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "paused_at": {
+ "name": "paused_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "notify": {
+ "name": "notify",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'all'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "bot_lifecycle_owner_user_id_users_id_fk": {
+ "name": "bot_lifecycle_owner_user_id_users_id_fk",
+ "tableFrom": "bot_lifecycle",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "bot_lifecycle_agent_id_agents_id_fk": {
+ "name": "bot_lifecycle_agent_id_agents_id_fk",
+ "tableFrom": "bot_lifecycle",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "bot_lifecycle_owner_user_id_agent_id_pk": {
+ "name": "bot_lifecycle_owner_user_id_agent_id_pk",
+ "columns": [
+ "owner_user_id",
+ "agent_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.update_routing_preferences": {
+ "name": "update_routing_preferences",
+ "schema": "",
+ "columns": {
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "update_routing_preferences_owner_user_id_users_id_fk": {
+ "name": "update_routing_preferences_owner_user_id_users_id_fk",
+ "tableFrom": "update_routing_preferences",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "update_routing_preferences_owner_user_id_kind_pk": {
+ "name": "update_routing_preferences_owner_user_id_kind_pk",
+ "columns": [
+ "owner_user_id",
+ "kind"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.saved_logins": {
+ "name": "saved_logins",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "encrypted_password": {
+ "name": "encrypted_password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_used_at": {
+ "name": "last_used_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "saved_logins_owner_origin_username_idx": {
+ "name": "saved_logins_owner_origin_username_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "origin",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "username",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "saved_logins_owner_idx": {
+ "name": "saved_logins_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "saved_logins_owner_user_id_users_id_fk": {
+ "name": "saved_logins_owner_user_id_users_id_fk",
+ "tableFrom": "saved_logins",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.sign_in_requests": {
+ "name": "sign_in_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "bot_id": {
+ "name": "bot_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "origin": {
+ "name": "origin",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "method": {
+ "name": "method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "outcome": {
+ "name": "outcome",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tool_call_id": {
+ "name": "tool_call_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "control_request_id": {
+ "name": "control_request_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "continuation": {
+ "name": "continuation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "filling_until": {
+ "name": "filling_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "sign_in_requests_owner_idx": {
+ "name": "sign_in_requests_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "sign_in_requests_owner_user_id_users_id_fk": {
+ "name": "sign_in_requests_owner_user_id_users_id_fk",
+ "tableFrom": "sign_in_requests",
+ "tableTo": "users",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "sign_in_requests_status_check": {
+ "name": "sign_in_requests_status_check",
+ "value": "\"sign_in_requests\".\"status\" IN ('pending', 'filling', 'code_required', 'taken_over', 'signed_in', 'failed', 'cancelled', 'expired')"
+ },
+ "sign_in_requests_method_check": {
+ "name": "sign_in_requests_method_check",
+ "value": "\"sign_in_requests\".\"method\" IS NULL OR \"sign_in_requests\".\"method\" IN ('typed', 'saved', 'takeover')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_bot_assignments": {
+ "name": "team_bot_assignments",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_name": {
+ "name": "group_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assigned_by": {
+ "name": "assigned_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "assigned_at": {
+ "name": "assigned_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_bot_assignments_agent_id_agents_id_fk": {
+ "name": "team_bot_assignments_agent_id_agents_id_fk",
+ "tableFrom": "team_bot_assignments",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_bot_assignments_assigned_by_users_id_fk": {
+ "name": "team_bot_assignments_assigned_by_users_id_fk",
+ "tableFrom": "team_bot_assignments",
+ "tableTo": "users",
+ "columnsFrom": [
+ "assigned_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_bot_assignments_agent_id_group_name_pk": {
+ "name": "team_bot_assignments_agent_id_group_name_pk",
+ "columns": [
+ "agent_id",
+ "group_name"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_bot_audience": {
+ "name": "team_bot_audience",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_bot_audience_agent_id_agents_id_fk": {
+ "name": "team_bot_audience_agent_id_agents_id_fk",
+ "tableFrom": "team_bot_audience",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_bot_audience_agent_id_kind_value_pk": {
+ "name": "team_bot_audience_agent_id_kind_value_pk",
+ "columns": [
+ "agent_id",
+ "kind",
+ "value"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "team_bot_audience_kind_check": {
+ "name": "team_bot_audience_kind_check",
+ "value": "\"team_bot_audience\".\"kind\" IN ('user', 'group')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_bot_consent_defaults": {
+ "name": "team_bot_consent_defaults",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_bot_consent_defaults_user_id_users_id_fk": {
+ "name": "team_bot_consent_defaults_user_id_users_id_fk",
+ "tableFrom": "team_bot_consent_defaults",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_bot_consent_defaults_user_id_server_id_pk": {
+ "name": "team_bot_consent_defaults_user_id_server_id_pk",
+ "columns": [
+ "user_id",
+ "server_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_bot_consents": {
+ "name": "team_bot_consents",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "decision": {
+ "name": "decision",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_bot_consents_user_id_users_id_fk": {
+ "name": "team_bot_consents_user_id_users_id_fk",
+ "tableFrom": "team_bot_consents",
+ "tableTo": "users",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_bot_consents_agent_id_agents_id_fk": {
+ "name": "team_bot_consents_agent_id_agents_id_fk",
+ "tableFrom": "team_bot_consents",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_bot_consents_user_id_agent_id_server_id_pk": {
+ "name": "team_bot_consents_user_id_agent_id_server_id_pk",
+ "columns": [
+ "user_id",
+ "agent_id",
+ "server_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "team_bot_consents_decision_check": {
+ "name": "team_bot_consents_decision_check",
+ "value": "\"team_bot_consents\".\"decision\" IN ('always', 'once')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_bot_publications": {
+ "name": "team_bot_publications",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "published_by": {
+ "name": "published_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "audience": {
+ "name": "audience",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "published_at": {
+ "name": "published_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_bot_publications_agent_id_agents_id_fk": {
+ "name": "team_bot_publications_agent_id_agents_id_fk",
+ "tableFrom": "team_bot_publications",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_bot_publications_published_by_users_id_fk": {
+ "name": "team_bot_publications_published_by_users_id_fk",
+ "tableFrom": "team_bot_publications",
+ "tableTo": "users",
+ "columnsFrom": [
+ "published_by"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "team_bot_publications_audience_check": {
+ "name": "team_bot_publications_audience_check",
+ "value": "\"team_bot_publications\".\"audience\" IN ('team', 'people')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_use_approval_members": {
+ "name": "shared_use_approval_members",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "shared_use_approval_members_approval_fk": {
+ "name": "shared_use_approval_members_approval_fk",
+ "tableFrom": "shared_use_approval_members",
+ "tableTo": "shared_use_approvals",
+ "columnsFrom": [
+ "agent_id",
+ "server_id"
+ ],
+ "columnsTo": [
+ "agent_id",
+ "server_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_use_approval_members_agent_id_server_id_kind_value_pk": {
+ "name": "shared_use_approval_members_agent_id_server_id_kind_value_pk",
+ "columns": [
+ "agent_id",
+ "server_id",
+ "kind",
+ "value"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_use_approval_members_kind_check": {
+ "name": "shared_use_approval_members_kind_check",
+ "value": "\"shared_use_approval_members\".\"kind\" IN ('user', 'group')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_use_approvals": {
+ "name": "shared_use_approvals",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "audience": {
+ "name": "audience",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "outside_input": {
+ "name": "outside_input",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_by": {
+ "name": "approved_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "approved_at": {
+ "name": "approved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "shared_use_approvals_agent_id_agents_id_fk": {
+ "name": "shared_use_approvals_agent_id_agents_id_fk",
+ "tableFrom": "shared_use_approvals",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_use_approvals_server_id_mcp_servers_id_fk": {
+ "name": "shared_use_approvals_server_id_mcp_servers_id_fk",
+ "tableFrom": "shared_use_approvals",
+ "tableTo": "mcp_servers",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "shared_use_approvals_agent_id_server_id_pk": {
+ "name": "shared_use_approvals_agent_id_server_id_pk",
+ "columns": [
+ "agent_id",
+ "server_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_use_approvals_audience_check": {
+ "name": "shared_use_approvals_audience_check",
+ "value": "\"shared_use_approvals\".\"audience\" IN ('owner', 'people', 'team')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.shared_use_requests": {
+ "name": "shared_use_requests",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "server_id": {
+ "name": "server_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_audience": {
+ "name": "proposed_audience",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_outside_input": {
+ "name": "proposed_outside_input",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "proposed_members": {
+ "name": "proposed_members",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "reason": {
+ "name": "reason",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "requested_by": {
+ "name": "requested_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "decided_by": {
+ "name": "decided_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "decided_at": {
+ "name": "decided_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "shared_use_requests_pending_idx": {
+ "name": "shared_use_requests_pending_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "server_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"shared_use_requests\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "shared_use_requests_status_idx": {
+ "name": "shared_use_requests_status_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "shared_use_requests_agent_id_agents_id_fk": {
+ "name": "shared_use_requests_agent_id_agents_id_fk",
+ "tableFrom": "shared_use_requests",
+ "tableTo": "agents",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "shared_use_requests_server_id_mcp_servers_id_fk": {
+ "name": "shared_use_requests_server_id_mcp_servers_id_fk",
+ "tableFrom": "shared_use_requests",
+ "tableTo": "mcp_servers",
+ "columnsFrom": [
+ "server_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "shared_use_requests_audience_check": {
+ "name": "shared_use_requests_audience_check",
+ "value": "\"shared_use_requests\".\"proposed_audience\" IN ('owner', 'people', 'team')"
+ },
+ "shared_use_requests_reason_check": {
+ "name": "shared_use_requests_reason_check",
+ "value": "\"shared_use_requests\".\"reason\" IN ('publish', 'trigger', 'grant', 'refused_call')"
+ },
+ "shared_use_requests_status_check": {
+ "name": "shared_use_requests_status_check",
+ "value": "\"shared_use_requests\".\"status\" IN ('pending', 'approved', 'declined', 'superseded')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.identity_link_challenges": {
+ "name": "identity_link_challenges",
+ "schema": "",
+ "columns": {
+ "token_hash": {
+ "name": "token_hash",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "identity_link_challenges_expiry_idx": {
+ "name": "identity_link_challenges_expiry_idx",
+ "columns": [
+ {
+ "expression": "expires_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "identity_link_challenges_user_provider_idx": {
+ "name": "identity_link_challenges_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.identity_links": {
+ "name": "identity_links",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "realm": {
+ "name": "realm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subject": {
+ "name": "subject",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "handle": {
+ "name": "handle",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "verified_by": {
+ "name": "verified_by",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "identity_links_identity_idx": {
+ "name": "identity_links_identity_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "realm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "subject",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "identity_links_user_realm_idx": {
+ "name": "identity_links_user_realm_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "realm",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "identity_links_credential_idx": {
+ "name": "identity_links_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"identity_links\".\"credential_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "identity_links_credential_id_credentials_id_fk": {
+ "name": "identity_links_credential_id_credentials_id_fk",
+ "tableFrom": "identity_links",
+ "tableTo": "credentials",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "identity_links_verified_by_check": {
+ "name": "identity_links_verified_by_check",
+ "value": "\"identity_links\".\"verified_by\" IN ('challenge', 'oauth')"
+ },
+ "identity_links_status_check": {
+ "name": "identity_links_status_check",
+ "value": "\"identity_links\".\"status\" IN ('active', 'needs_reconnect')"
+ }
+ },
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {
+ "public.agent_type": {
+ "name": "agent_type",
+ "schema": "public",
+ "values": [
+ "built_in",
+ "remote_ag_ui",
+ "remote_mastra"
+ ]
+ },
+ "public.credential_kind": {
+ "name": "credential_kind",
+ "schema": "public",
+ "values": [
+ "model",
+ "connector",
+ "agent",
+ "mcp",
+ "mcp_oauth_client",
+ "mcp_user_token"
+ ]
+ },
+ "public.role": {
+ "name": "role",
+ "schema": "public",
+ "values": [
+ "admin",
+ "user"
+ ]
+ },
+ "public.agent_visibility": {
+ "name": "agent_visibility",
+ "schema": "public",
+ "values": [
+ "public",
+ "private"
+ ]
+ },
+ "public.routine_run_status": {
+ "name": "routine_run_status",
+ "schema": "public",
+ "values": [
+ "succeeded",
+ "failed",
+ "skipped",
+ "waiting"
+ ]
+ },
+ "public.responsibility_run_status": {
+ "name": "responsibility_run_status",
+ "schema": "public",
+ "values": [
+ "queued",
+ "running",
+ "waiting",
+ "succeeded",
+ "failed",
+ "skipped"
+ ]
+ },
+ "public.responsibility_status": {
+ "name": "responsibility_status",
+ "schema": "public",
+ "values": [
+ "active",
+ "paused",
+ "completed"
+ ]
+ }
+ },
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/server/drizzle/meta/_journal.json b/server/drizzle/meta/_journal.json
index a11adacc..70e4dfa6 100644
--- a/server/drizzle/meta/_journal.json
+++ b/server/drizzle/meta/_journal.json
@@ -393,6 +393,13 @@
"when": 1791841282662,
"tag": "0055_default_opt_outs",
"breakpoints": true
+ },
+ {
+ "idx": 56,
+ "version": "7",
+ "when": 1791866936937,
+ "tag": "0056_sign_in_code_step",
+ "breakpoints": true
}
]
}
\ No newline at end of file
diff --git a/server/src/audit.ts b/server/src/audit.ts
index 1e9ae871..8c2ffab3 100644
--- a/server/src/audit.ts
+++ b/server/src/audit.ts
@@ -268,6 +268,8 @@ export const auditEventTypes = [
// A Bot asking its owner to sign it in to a website, and how that ended. Never the username, the
// password or a code: the row says which site, which request and whether a saved login was used.
"computer.sign_in_requested",
+ // The site accepted the password and asked for a verification code. Whether one was asked, never it.
+ "computer.sign_in_code_requested",
"computer.sign_in_completed",
"computer.sign_in_failed",
"computer.sign_in_cancelled",
diff --git a/server/src/computer/gateway.ts b/server/src/computer/gateway.ts
index 20465301..4cb9812b 100644
--- a/server/src/computer/gateway.ts
+++ b/server/src/computer/gateway.ts
@@ -77,6 +77,8 @@ import type {
ScrollInput,
SecretRequest,
SecretResult,
+ SignInCodeInput,
+ SignInCodeResult,
SignInFillInput,
SignInFillResult,
SnapshotElement,
@@ -246,6 +248,12 @@ export interface ComputerGateway {
input: SignInFillInput,
signal?: AbortSignal,
): Promise<SignInFillResult>;
+ /** Type the verification code a site asked for after the password. See passwords/service.ts. */
+ signInCode(
+ botId: string,
+ input: SignInCodeInput,
+ signal?: AbortSignal,
+ ): Promise<SignInCodeResult>;
humanInput(botId: string, input: HumanInput): Promise<HumanInputResult>;
computers(): Promise<{
isolation: "per-bot" | "shared";
@@ -950,6 +958,17 @@ export function createComputerGateway(
);
},
+ /** The code a site asked for once the password was in, on the same path and terms as the login. */
+ signInCode(botId: string, input: SignInCodeInput, signal?: AbortSignal) {
+ return post<SignInCodeResult>(
+ botId,
+ "/sign-in/code",
+ input,
+ signal,
+ SIGN_IN_BACKSTOP_MS,
+ );
+ },
+
async supplySecret(botId: string, actor: ActionActor, text: string) {
const result = await post<SecretResult>(botId, "/human/secret", { text });
await writeControlEvent(auditStore, "computer.secret_supplied", {
@@ -1439,7 +1458,7 @@ async function writeControlEvent(
const PAGE_FIELDS = ["title", "text"] as const;
const SNAPSHOT_FIELDS = ["title", "elements"] as const;
-/** A two-step login can take two page loads and a code; this outlasts the computer's own waits. */
+/** A two-step login can take two page loads and a wait for a code field; this outlasts the computer's own waits. */
const SIGN_IN_BACKSTOP_MS = 75_000;
export function hostOf(url: string): string {
diff --git a/server/src/computer/schema.ts b/server/src/computer/schema.ts
index e5af3a24..7c0272fd 100644
--- a/server/src/computer/schema.ts
+++ b/server/src/computer/schema.ts
@@ -327,8 +327,6 @@ export type SignInFillInput = {
origin: string;
username?: string;
password: string;
- /** A one-time code the person entered alongside, typed if the site asks for one. */
- code?: string;
};
/** What the computer reports. No field here ever carries a credential. */
@@ -336,6 +334,23 @@ export type SignInFillResult = {
submitted: boolean;
/** Whether the page still shows a password field after submitting: the plainest sign of a failure. */
passwordFieldVisible: boolean;
+ /**
+ * The site accepted the password and now shows a one-time-code field. Never known before the
+ * password is in: a code is only ever asked for after the fact, and then sent with `SignInCodeInput`.
+ */
+ codeRequested: boolean;
+ url: string;
+ error?: string;
+};
+
+/** The verification code a site asked for, typed into the page that is waiting for it. */
+export type SignInCodeInput = { origin: string; code: string };
+
+export type SignInCodeResult = {
+ submitted: boolean;
+ /** Whether a code field still shows after submitting: the plainest sign the code was refused. */
+ codeFieldVisible: boolean;
+ passwordFieldVisible: boolean;
url: string;
error?: string;
};
diff --git a/server/src/db/schema/passwords.ts b/server/src/db/schema/passwords.ts
index 0105b3fd..f9ed8820 100644
--- a/server/src/db/schema/passwords.ts
+++ b/server/src/db/schema/passwords.ts
@@ -87,7 +87,7 @@ export const signInRequests = pgTable(
index("sign_in_requests_owner_idx").on(t.ownerUserId, t.status),
check(
"sign_in_requests_status_check",
- sql`${t.status} IN ('pending', 'filling', 'taken_over', 'signed_in', 'failed', 'cancelled', 'expired')`,
+ sql`${t.status} IN ('pending', 'filling', 'code_required', 'taken_over', 'signed_in', 'failed', 'cancelled', 'expired')`,
),
check(
"sign_in_requests_method_check",
diff --git a/server/src/passwords/routes.ts b/server/src/passwords/routes.ts
index 4c906619..b2f99831 100644
--- a/server/src/passwords/routes.ts
+++ b/server/src/passwords/routes.ts
@@ -111,13 +111,26 @@ export function createSignInRoutes(
{
username: field(body, "username", { max: 512 }),
password: field(body, "password", { required: true }) as string,
- code: field(body, "code", { max: 64 }),
+ // No `code`: one is asked for only after the site has the password. See `/:id/code`.
save: body?.save === true,
},
),
);
});
+ /** The verification code a site asked for, once the request is `code_required`. */
+ routes.post("/:id/code", async (context) => {
+ const body = await readBody(context.req.raw);
+ return context.json(
+ await service.submitCode(
+ context.var.actor.id,
+ context.req.param("id"),
+ actorOf(context),
+ { code: field(body, "code", { required: true, max: 64 }) as string },
+ ),
+ );
+ });
+
routes.post("/:id/use-saved", async (context) => {
const body = await readBody(context.req.raw);
return context.json(
@@ -130,7 +143,6 @@ export function createSignInRoutes(
required: true,
max: 200,
}) as string,
- code: field(body, "code", { max: 64 }),
},
),
);
diff --git a/server/src/passwords/service.ts b/server/src/passwords/service.ts
index 62aec4e5..3cc349ce 100644
--- a/server/src/passwords/service.ts
+++ b/server/src/passwords/service.ts
@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto";
import { type AuditStore, recordAuditEvent } from "../audit";
import type { ActionActor, ComputerGateway } from "../computer/gateway";
-import type { SignInFillResult } from "../computer/schema";
+import type { SignInCodeResult, SignInFillResult } from "../computer/schema";
import { decryptSecret, encryptSecret } from "../credentials";
import {
originOf,
@@ -21,14 +21,19 @@ import {
* Bot learns a request id, the person is sent to a form that is not part of the conversation, and the
* turn waits. The form answers one of four ways:
*
- * - typed: a username and password (and a code, when the site asks) go from the form to this
- * service to the Bot's computer, which types them into the page itself;
+ * - typed: a username and password go from the form to this service to the Bot's computer, which
+ * types them into the page itself;
* - saved: the person picks one of their saved logins for exactly this site. Choosing it in the form
* IS the confirmation Dot requires for using a saved login on a new sign-in: nothing here fills a
* saved login without that request from its owner;
* - takeover: the person takes the Bot's browser and signs in by hand;
* - cancel.
*
+ * A verification code is never asked for up front. When the site, having taken the password, shows a
+ * one-time-code field, the request moves to `code_required` and the form asks for the code the site
+ * just sent; `submitCode` has the computer type it into the page that is waiting. A wrong code keeps
+ * the request there, and an unanswered one expires like any other request.
+ *
* Whatever happens, the Bot is told the outcome and never the credential. The audit rows say which
* site, which request and how it was answered; they carry no username, password or code.
*/
@@ -36,7 +41,7 @@ export type SignInService = ReturnType<typeof createSignInService>;
export type SignInServiceDependencies = {
store: PasswordStore;
- gateway: Pick<ComputerGateway, "signIn" | "requestHelp">;
+ gateway: Pick<ComputerGateway, "signIn" | "signInCode" | "requestHelp">;
/** The deployment's KEY_ENCRYPTION_KEY, the same one `credentials.ts` encrypts under. */
encryptionKey: string;
auditStore?: AuditStore;
@@ -57,7 +62,11 @@ export type SignInServiceDependencies = {
};
const DEFAULT_TTL_MS = 15 * 60_000;
-const OPEN: readonly SignInStatus[] = ["pending", "taken_over"];
+const OPEN: readonly SignInStatus[] = [
+ "pending",
+ "code_required",
+ "taken_over",
+];
/**
* How long one attempt may hold a request in `filling`. Past the computer's own sign-in backstop
* (75s), so a live attempt is never reopened under itself; a server that died mid-fill leaves the
@@ -123,6 +132,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
async function audit(
eventType:
| "computer.sign_in_requested"
+ | "computer.sign_in_code_requested"
| "computer.sign_in_completed"
| "computer.sign_in_failed"
| "computer.sign_in_cancelled"
@@ -154,10 +164,15 @@ export function createSignInService(deps: SignInServiceDependencies) {
request.fillingUntil !== null &&
request.fillingUntil <= new Date()
) {
+ // `method` is set once the site has taken the password, so an attempt abandoned while typing
+ // the code goes back to asking for the code, not for the whole login again.
+ const codeStep = request.method !== null;
const reopened = await store.transition(owner, id, ["filling"], {
- status: "pending",
+ status: codeStep ? "code_required" : "pending",
fillingUntil: null,
- outcome: "The last sign-in attempt did not finish. Try again.",
+ outcome: codeStep
+ ? "The last attempt to enter the code did not finish. Try again."
+ : "The last sign-in attempt did not finish. Try again.",
});
if (reopened) return load(owner, id);
return (await store.request(owner, id)) ?? request;
@@ -165,7 +180,10 @@ export function createSignInService(deps: SignInServiceDependencies) {
if (OPEN.includes(request.status) && request.expiresAt <= new Date()) {
const expired = await store.transition(owner, id, OPEN, {
status: "expired",
- outcome: `Nobody signed in to ${request.origin} before the request expired. Do not ask for the login another way.`,
+ outcome:
+ request.status === "code_required"
+ ? `Nobody entered the verification code for ${request.origin} before the request expired. Do not ask for the login or the code another way.`
+ : `Nobody signed in to ${request.origin} before the request expired. Do not ask for the login another way.`,
resolvedAt: new Date(),
});
if (expired) {
@@ -215,6 +233,142 @@ export function createSignInService(deps: SignInServiceDependencies) {
};
}
+ /**
+ * Save a typed login the site has accepted. Never a code: a verification code is good once.
+ *
+ * Called after the request has already moved on, so a save that fails is reported with `whenFailed`
+ * and a 409, and never leaves the request stuck.
+ */
+ async function saveTyped(
+ actor: ActionActor,
+ owner: string,
+ id: string,
+ origin: string,
+ username: string,
+ password: string,
+ whenFailed: string,
+ ) {
+ try {
+ const saved = await store.saveLogin({
+ ownerUserId: owner,
+ origin,
+ username,
+ encryptedPassword: await encryptSecret(deps.encryptionKey, password),
+ });
+ await audit("password.saved", actor, "password", saved.id, {
+ site: origin,
+ login: saved.id,
+ });
+ } catch (error) {
+ console.error(
+ JSON.stringify({
+ type: "password-save-failed",
+ request: id,
+ error: error instanceof Error ? error.name : "UnknownError",
+ }),
+ );
+ throw new SignInRefusedError(whenFailed, 409);
+ }
+ }
+
+ /**
+ * Type the verification code a site asked for, and record how it went.
+ *
+ * Only from `code_required`. The code lives in this function's arguments and the one request to
+ * the computer, as a password does in `fill`.
+ */
+ async function enterCode(
+ owner: string,
+ id: string,
+ actor: ActionActor,
+ code: string,
+ ): Promise<SignInRequestRecord> {
+ const request = await load(owner, id);
+ if (request.status !== "code_required")
+ throw new SignInRefusedError(
+ request.status === "filling"
+ ? "This sign-in is already being entered."
+ : request.status === "pending" || request.status === "taken_over"
+ ? "The site is not asking for a verification code."
+ : "This sign-in request is no longer open.",
+ 409,
+ );
+ const claimed = await store.transition(owner, id, ["code_required"], {
+ status: "filling",
+ fillingUntil: new Date(Date.now() + FILLING_LEASE_MS),
+ });
+ if (!claimed)
+ throw new SignInRefusedError(
+ "This sign-in is already being entered.",
+ 409,
+ );
+ let result: SignInCodeResult | undefined;
+ let failure: string | undefined;
+ // Where a failure leaves the request: asking for the code again, unless the site fell back to
+ // its login page, when only the whole login again can help.
+ let back: "code_required" | "pending" = "code_required";
+ try {
+ result = await gateway.signInCode(claimed.botId, {
+ origin: claimed.origin,
+ code,
+ });
+ if (result.error) failure = scrub(result.error, [code]);
+ else if (!result.submitted)
+ failure = "The verification code could not be submitted.";
+ else if (result.passwordFieldVisible) {
+ back = "pending";
+ failure =
+ "The site went back to its sign-in page, so the code did not finish signing in. Enter the login again.";
+ } else if (result.codeFieldVisible)
+ failure =
+ "The site did not accept that code. Check it, or ask the site for a new one, and try again.";
+ } catch (error) {
+ failure = scrub(
+ error instanceof Error
+ ? error.message
+ : "The Bot's computer did not respond.",
+ [code],
+ );
+ }
+ if (failure) {
+ const reopened = await store.transition(owner, id, ["filling"], {
+ status: back,
+ fillingUntil: null,
+ outcome: failure,
+ ...(back === "pending" ? { method: null } : {}),
+ });
+ await audit("computer.sign_in_failed", actor, "computer", claimed.botId, {
+ bot: claimed.botId,
+ request: id,
+ site: claimed.origin,
+ ...(claimed.method ? { method: claimed.method } : {}),
+ step: "code",
+ failure,
+ });
+ throw new SignInRefusedError(failure, reopened ? 409 : 400);
+ }
+ const page = result?.url ? scrub(result.url, [code]) : undefined;
+ const done = await store.transition(owner, id, ["filling"], {
+ status: "signed_in",
+ fillingUntil: null,
+ outcome: `Signed in to ${claimed.origin}${page ? `; the page is now ${page}` : ""}.`,
+ resolvedAt: new Date(),
+ });
+ if (!done)
+ throw new Error(
+ "The sign-in request changed while it was being entered.",
+ );
+ await audit("computer.sign_in_completed", actor, "computer", done.botId, {
+ bot: done.botId,
+ request: id,
+ site: done.origin,
+ ...(done.method ? { method: done.method } : {}),
+ verificationCode: true,
+ });
+ await resolved(done);
+ return done;
+ }
+
/**
* Type a login into the Bot's browser, and record how it went.
*
@@ -225,7 +379,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
owner: string,
id: string,
actor: ActionActor,
- credential: { username?: string; password: string; code?: string },
+ credential: { username?: string; password: string },
method: "typed" | "saved",
extra: { loginId?: string; save?: boolean },
): Promise<SignInRequestRecord> {
@@ -255,7 +409,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
"This sign-in is already being entered.",
409,
);
- const secrets = [credential.password, credential.username, credential.code];
+ const secrets = [credential.password, credential.username];
let result: SignInFillResult | undefined;
let failure: string | undefined;
try {
@@ -263,7 +417,6 @@ export function createSignInService(deps: SignInServiceDependencies) {
origin: claimed.origin,
...(credential.username ? { username: credential.username } : {}),
password: credential.password,
- ...(credential.code ? { code: credential.code } : {}),
});
if (result.error) failure = scrub(result.error, secrets);
else if (!result.submitted)
@@ -292,6 +445,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
request: id,
site: claimed.origin,
method,
+ step: "login",
...(extra.loginId ? { savedLogin: extra.loginId } : {}),
failure,
});
@@ -299,6 +453,48 @@ export function createSignInService(deps: SignInServiceDependencies) {
}
if (method === "saved" && extra.loginId)
await store.touchLogin(owner, extra.loginId);
+ if (result?.codeRequested) {
+ /*
+ * The site took the password and sent a code. Nothing is final and the Bot is told nothing: the
+ * request waits for the person to enter the code the site just sent. `method` is recorded now,
+ * which is also how an abandoned code attempt knows to reopen at the code step.
+ */
+ const waiting = await store.transition(owner, id, ["filling"], {
+ status: "code_required",
+ method,
+ fillingUntil: null,
+ outcome: null,
+ });
+ if (!waiting)
+ throw new Error(
+ "The sign-in request changed while it was being entered.",
+ );
+ await audit(
+ "computer.sign_in_code_requested",
+ actor,
+ "computer",
+ waiting.botId,
+ {
+ bot: waiting.botId,
+ request: id,
+ site: waiting.origin,
+ method,
+ ...(extra.loginId ? { savedLogin: extra.loginId } : {}),
+ },
+ );
+ // The password was accepted, so it is saved now, while it is still in hand. Never the code.
+ if (saving && credential.username)
+ await saveTyped(
+ actor,
+ owner,
+ id,
+ waiting.origin,
+ credential.username,
+ credential.password,
+ "The site accepted the password, but the login could not be saved. Enter the code to finish, then save it again from Passwords.",
+ );
+ return waiting;
+ }
/*
* Signed in is recorded, and the Bot told, BEFORE the optional save. The site accepted the login
* either way; a save that fails afterwards must not leave the request stuck in `filling` with the
@@ -323,36 +519,16 @@ export function createSignInService(deps: SignInServiceDependencies) {
...(extra.loginId ? { savedLogin: extra.loginId } : {}),
});
await resolved(done);
- if (saving && credential.username) {
- try {
- const saved = await store.saveLogin({
- ownerUserId: owner,
- origin: claimed.origin,
- username: credential.username,
- encryptedPassword: await encryptSecret(
- deps.encryptionKey,
- credential.password,
- ),
- });
- await audit("password.saved", actor, "password", saved.id, {
- site: claimed.origin,
- login: saved.id,
- });
- } catch (error) {
- console.error(
- JSON.stringify({
- type: "password-save-failed",
- request: id,
- error: error instanceof Error ? error.name : "UnknownError",
- }),
- );
- throw new SignInRefusedError(
- "You are signed in, but the login could not be saved. Save it again from Passwords.",
- // The request has moved on (it is signed in); only the optional save did not happen.
- 409,
- );
- }
- }
+ if (saving && credential.username)
+ await saveTyped(
+ actor,
+ owner,
+ id,
+ claimed.origin,
+ credential.username,
+ credential.password,
+ "You are signed in, but the login could not be saved. Save it again from Passwords.",
+ );
return done;
}
@@ -428,7 +604,6 @@ export function createSignInService(deps: SignInServiceDependencies) {
input: {
username?: string;
password: string;
- code?: string;
save?: boolean;
},
) {
@@ -441,12 +616,27 @@ export function createSignInService(deps: SignInServiceDependencies) {
);
},
+ /** The verification code the site sent, once the request is `code_required`. */
+ async submitCode(
+ owner: string,
+ id: string,
+ actor: ActionActor,
+ input: { code: string },
+ ) {
+ const code = input.code?.trim();
+ if (!code)
+ throw new SignInRefusedError(
+ "Enter the verification code the site sent.",
+ );
+ return view(await enterCode(owner, id, actor, code));
+ },
+
/** The person confirming one of their saved logins for this sign-in. */
async useSaved(
owner: string,
id: string,
actor: ActionActor,
- input: { loginId: string; code?: string },
+ input: { loginId: string },
) {
if (!(await managerOn(owner)))
throw new SignInRefusedError(
@@ -470,11 +660,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
owner,
id,
actor,
- {
- username: login.username,
- password,
- ...(input.code ? { code: input.code } : {}),
- },
+ { username: login.username, password },
"saved",
{ loginId: login.id },
),
@@ -484,7 +670,9 @@ export function createSignInService(deps: SignInServiceDependencies) {
/** Sign in by hand instead: hand the person the Bot's browser. */
async takeOver(owner: string, id: string, actor: ActionActor) {
const request = await load(owner, id);
- if (request.status !== "pending")
+ // From the code step too: a person may rather type the code into the site themselves.
+ const from: readonly SignInStatus[] = ["pending", "code_required"];
+ if (!from.includes(request.status))
throw new SignInRefusedError(
"This sign-in request is no longer open.",
409,
@@ -495,7 +683,7 @@ export function createSignInService(deps: SignInServiceDependencies) {
`Sign in to ${request.origin}${request.reason ? `: ${request.reason}` : ""}`,
request.toolCallId ?? undefined,
);
- const next = await store.transition(owner, id, ["pending"], {
+ const next = await store.transition(owner, id, from, {
status: "taken_over",
controlRequestId: state.request?.id ?? null,
});
diff --git a/server/src/passwords/store.ts b/server/src/passwords/store.ts
index 44cd65a1..522b5066 100644
--- a/server/src/passwords/store.ts
+++ b/server/src/passwords/store.ts
@@ -52,7 +52,11 @@ export function createPasswordStore(database: Database): PasswordStore {
.where(
and(
eq(signInRequests.ownerUserId, ownerUserId),
- inArray(signInRequests.status, ["pending", "taken_over"]),
+ inArray(signInRequests.status, [
+ "pending",
+ "code_required",
+ "taken_over",
+ ]),
sql`${signInRequests.expiresAt} > now()`,
),
)
@@ -165,7 +169,7 @@ export function createMemoryPasswordStore(): PasswordStore & {
return [...requests.values()].filter(
(row) =>
row.ownerUserId === ownerUserId &&
- (row.status === "pending" || row.status === "taken_over") &&
+ ["pending", "code_required", "taken_over"].includes(row.status) &&
row.expiresAt > new Date(),
);
},
diff --git a/server/src/passwords/types.ts b/server/src/passwords/types.ts
index 05d0a284..d5bc1a4a 100644
--- a/server/src/passwords/types.ts
+++ b/server/src/passwords/types.ts
@@ -10,6 +10,8 @@
export type SignInStatus =
| "pending"
| "filling"
+ /** The site accepted the password and sent a verification code; the form now asks for only that. */
+ | "code_required"
| "taken_over"
| "signed_in"
| "failed"
diff --git a/server/tests/passwords-sign-in.test.ts b/server/tests/passwords-sign-in.test.ts
index 2fe603ef..f99a9fd3 100644
--- a/server/tests/passwords-sign-in.test.ts
+++ b/server/tests/passwords-sign-in.test.ts
@@ -16,7 +16,12 @@ import {
createHeadlessComputerTools,
HeadlessToolSuspension,
} from "../src/computer/headless-tools";
-import type { SignInFillInput, SignInFillResult } from "../src/computer/schema";
+import type {
+ SignInCodeInput,
+ SignInCodeResult,
+ SignInFillInput,
+ SignInFillResult,
+} from "../src/computer/schema";
import {
createPasswordRoutes,
createSignInRoutes,
@@ -43,19 +48,38 @@ const USERNAME = "[email protected]";
const CODE = "918273";
const KEY = Buffer.alloc(32, 7).toString("base64");
-function fakeGateway(result: Partial<SignInFillResult> = {}) {
+function fakeGateway(
+ result: Partial<SignInFillResult> = {},
+ /** What each code typed in answers, in order; the last one repeats. */
+ codeResults: Partial<SignInCodeResult>[] = [{}],
+) {
const fills: SignInFillInput[] = [];
+ const codes: SignInCodeInput[] = [];
const helps: string[] = [];
- const gateway: Pick<ComputerGateway, "signIn" | "requestHelp"> = {
+ const gateway: Pick<
+ ComputerGateway,
+ "signIn" | "signInCode" | "requestHelp"
+ > = {
async signIn(_botId, input) {
fills.push(input);
return {
submitted: true,
passwordFieldVisible: false,
+ codeRequested: false,
url: "https://example.com/home",
...result,
};
},
+ async signInCode(_botId, input) {
+ codes.push(input);
+ return {
+ submitted: true,
+ codeFieldVisible: false,
+ passwordFieldVisible: false,
+ url: "https://example.com/home",
+ ...(codeResults[codes.length - 1] ?? codeResults.at(-1)),
+ };
+ },
async requestHelp(_botId, _actor, reason) {
helps.push(reason);
return {
@@ -64,7 +88,7 @@ function fakeGateway(result: Partial<SignInFillResult> = {}) {
} as unknown as Awaited<ReturnType<ComputerGateway["requestHelp"]>>;
},
};
- return { gateway, fills, helps };
+ return { gateway, fills, codes, helps };
}
function audit() {
@@ -74,10 +98,14 @@ function audit() {
}
function setup(
- options: { manager?: boolean; fill?: Partial<SignInFillResult> } = {},
+ options: {
+ manager?: boolean;
+ fill?: Partial<SignInFillResult>;
+ code?: Partial<SignInCodeResult>[];
+ } = {},
) {
const store = createMemoryPasswordStore();
- const computer = fakeGateway(options.fill);
+ const computer = fakeGateway(options.fill, options.code);
const trail = audit();
const resolved: SignInRequestRecord[] = [];
const service = createSignInService({
@@ -128,7 +156,6 @@ describe("a sign-in request answered with a typed login", () => {
const view = await service.submit("owner", request.id, actor, {
username: USERNAME,
password: PASSWORD,
- code: CODE,
save: true,
});
expect(view.status).toBe("signed_in");
@@ -137,9 +164,10 @@ describe("a sign-in request answered with a typed login", () => {
origin: "https://example.com",
username: USERNAME,
password: PASSWORD,
- code: CODE,
},
]);
+ // A site that never asked for a code is never sent one.
+ expect(computer.codes).toEqual([]);
const done = resolved[0];
if (!done) throw new Error("not resolved");
const toolResult = signInToolResult(done);
@@ -410,7 +438,6 @@ describe("the routes", () => {
post(`/api/sign-in-requests/${id}/submit`, {
username: USERNAME,
password: PASSWORD,
- code: CODE,
save: true,
}),
);
@@ -443,6 +470,263 @@ describe("the routes", () => {
});
});
+/**
+ * "All MFA codes are after the fact, none are during or before." The form asks for a username and
+ * password only. A site that then shows a one-time-code field moves the request to `code_required`,
+ * the person is asked for the code the site just sent, and only that is typed in.
+ */
+describe("a site that asks for a verification code after the password", () => {
+ async function asked(options: Parameters<typeof setup>[0] = {}) {
+ const context = setup({
+ ...options,
+ fill: {
+ codeRequested: true,
+ url: "https://example.com/mfa",
+ ...options.fill,
+ },
+ });
+ const request = await context.service.request({
+ ownerUserId: "owner",
+ botId: "bot",
+ site: "example.com",
+ actor,
+ });
+ return { ...context, request };
+ }
+
+ test("submit the login, then the code: code_required, then signed in, and the Bot told once", async () => {
+ const { service, computer, trail, store, resolved, request } =
+ await asked();
+ const waiting = await service.submit("owner", request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ save: true,
+ });
+ expect(waiting.status).toBe("code_required");
+ expect(waiting.outcome).toBeNull();
+ // Nothing final yet: the Bot is still waiting, and has been told nothing.
+ expect(resolved).toEqual([]);
+ expect(computer.codes).toEqual([]);
+ // The site accepted the password, so it is saved now, and never with a code.
+ const [saved] = await store.logins("owner");
+ expect(saved?.username).toBe(USERNAME);
+
+ const done = await service.submitCode("owner", request.id, actor, {
+ code: CODE,
+ });
+ expect(done.status).toBe("signed_in");
+ expect(done.method).toBe("typed");
+ expect(computer.codes).toEqual([
+ { origin: "https://example.com", code: CODE },
+ ]);
+ expect(resolved.map((row) => row.status)).toEqual(["signed_in"]);
+ const toolResult = signInToolResult(resolved[0] as SignInRequestRecord);
+ expect(toolResult).toMatchObject({ ok: true, signedIn: true });
+ expect(trail.rows.map((row) => row.eventType)).toEqual([
+ "computer.sign_in_requested",
+ "computer.sign_in_code_requested",
+ "password.saved",
+ "computer.sign_in_completed",
+ ]);
+ expectNoCredential(
+ everything(
+ waiting,
+ done,
+ toolResult,
+ trail.rows,
+ [...store.requests.values()],
+ [...store.saved.values()],
+ ),
+ );
+ expect(everything(trail.rows, toolResult)).not.toContain(USERNAME);
+ });
+
+ test("a wrong code keeps asking for the code, and the right one then finishes", async () => {
+ const { service, trail, resolved, request } = await asked({
+ code: [{ codeFieldVisible: true, url: "https://example.com/mfa" }, {}],
+ });
+ await service.submit("owner", request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ });
+ const wrong = await service
+ .submitCode("owner", request.id, actor, { code: CODE })
+ .catch((error: Error) => error);
+ expect(wrong).toBeInstanceOf(Error);
+ expect((wrong as Error).message).toMatch(/did not accept that code/);
+ const after = await service.get("owner", request.id);
+ expect(after.status).toBe("code_required");
+ expect(after.outcome).toMatch(/did not accept that code/);
+ expect(resolved).toEqual([]);
+ const failed = trail.rows.find(
+ (row) => row.eventType === "computer.sign_in_failed",
+ );
+ expect(failed?.payload).toMatchObject({ step: "code" });
+ expect(
+ (await service.submitCode("owner", request.id, actor, { code: CODE }))
+ .status,
+ ).toBe("signed_in");
+ expect(resolved).toHaveLength(1);
+ expectNoCredential(everything(trail.rows, wrong));
+ });
+
+ test("a request waiting on its code expires, and the Bot is told why, never the code", async () => {
+ const { service, store, resolved, request } = await asked();
+ await service.submit("owner", request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ });
+ const row = store.requests.get(request.id);
+ if (!row) throw new Error("missing");
+ row.expiresAt = new Date(Date.now() - 1_000);
+ const view = await service.get("owner", request.id);
+ expect(view.status).toBe("expired");
+ expect(view.outcome).toMatch(/verification code/);
+ await expect(
+ service.submitCode("owner", request.id, actor, { code: CODE }),
+ ).rejects.toThrow(/no longer open/);
+ expect(resolved.map((done) => done.status)).toEqual(["expired"]);
+ expect(signInToolResult(resolved[0] as SignInRequestRecord).ok).toBe(false);
+ });
+
+ test("a code is refused until the site has asked for one", async () => {
+ const { service, computer } = setup();
+ const request = await service.request({
+ ownerUserId: "owner",
+ botId: "bot",
+ site: "example.com",
+ actor,
+ });
+ await expect(
+ service.submitCode("owner", request.id, actor, { code: CODE }),
+ ).rejects.toThrow(/not asking for a verification code/);
+ expect(computer.codes).toEqual([]);
+ });
+
+ test("a site that falls back to its login page reopens the login form", async () => {
+ const { service, request } = await asked({
+ code: [{ passwordFieldVisible: true, url: "https://example.com/login" }],
+ });
+ await service.submit("owner", request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ });
+ await expect(
+ service.submitCode("owner", request.id, actor, { code: CODE }),
+ ).rejects.toThrow(/sign-in page/);
+ expect((await service.get("owner", request.id)).status).toBe("pending");
+ });
+
+ test("a saved login stops for the code the same way, and the code is never stored", async () => {
+ const context = await asked();
+ await context.service.submit("owner", context.request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ save: true,
+ });
+ await context.service.submitCode("owner", context.request.id, actor, {
+ code: CODE,
+ });
+ const [login] = await context.store.logins("owner");
+ if (!login) throw new Error("not saved");
+ const next = await context.service.request({
+ ownerUserId: "owner",
+ botId: "bot",
+ site: "example.com",
+ actor,
+ });
+ const waiting = await context.service.useSaved("owner", next.id, actor, {
+ loginId: login.id,
+ });
+ expect(waiting.status).toBe("code_required");
+ expect(waiting.method).toBe("saved");
+ const done = await context.service.submitCode("owner", next.id, actor, {
+ code: CODE,
+ });
+ expect(done).toMatchObject({ status: "signed_in", method: "saved" });
+ expectNoCredential(everything([...context.store.saved.values()]));
+ });
+
+ test("taking over or cancelling still works while the code is awaited", async () => {
+ const first = await asked();
+ await first.service.submit("owner", first.request.id, actor, {
+ password: PASSWORD,
+ });
+ expect(
+ (await first.service.takeOver("owner", first.request.id, actor)).status,
+ ).toBe("taken_over");
+ const second = await asked();
+ await second.service.submit("owner", second.request.id, actor, {
+ password: PASSWORD,
+ });
+ expect(
+ (await second.service.cancel("owner", second.request.id, actor)).status,
+ ).toBe("cancelled");
+ });
+
+ test("an abandoned code attempt reopens to the code step, not the login", async () => {
+ const { service, store, request } = await asked();
+ await service.submit("owner", request.id, actor, {
+ username: USERNAME,
+ password: PASSWORD,
+ });
+ await store.transition("owner", request.id, ["code_required"], {
+ status: "filling",
+ fillingUntil: new Date(Date.now() - 1_000),
+ });
+ expect((await service.get("owner", request.id)).status).toBe(
+ "code_required",
+ );
+ });
+
+ test("the routes take the login and then the code, and answer with neither", async () => {
+ const context = await asked();
+ const requireUser = async (
+ c: { set: (key: "actor", value: AppVariables["actor"]) => void },
+ next: () => Promise<void>,
+ ) => {
+ c.set("actor", {
+ id: "owner",
+ email: "[email protected]",
+ } as AppVariables["actor"]);
+ await next();
+ };
+ const server = new Hono<{ Variables: AppVariables }>().route(
+ "/api/sign-in-requests",
+ createSignInRoutes(
+ context.service,
+ requireUser as never,
+ async () => true,
+ ),
+ );
+ const post = (path: string, body: unknown) =>
+ server.fetch(
+ new Request(`http://127.0.0.1/api/sign-in-requests${path}`, {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify(body),
+ }),
+ );
+ const id = context.request.id;
+ // A code sent with the login, by an older form, is not read: it would be typed before the site asked.
+ const login = await post(`/${id}/submit`, {
+ username: USERNAME,
+ password: PASSWORD,
+ code: CODE,
+ });
+ expect(login.status).toBe(200);
+ const loginBody = await login.text();
+ expect(JSON.parse(loginBody).status).toBe("code_required");
+ expect(context.computer.fills[0]).not.toHaveProperty("code");
+ expect((await post(`/${id}/code`, {})).status).toBe(400);
+ const code = await post(`/${id}/code`, { code: CODE });
+ expect(code.status).toBe(200);
+ const codeBody = await code.text();
+ expect(JSON.parse(codeBody).status).toBe("signed_in");
+ expectNoCredential(loginBody + codeBody);
+ });
+});
+
/*
* The whole path an unattended Bot takes, through the real headless middleware and turn runner:
* the Bot asks, the turn pauses, the person answers in the form, and the turn resumes. Every AG-UI
diff --git a/server/tests/passwords-store.integration.test.ts b/server/tests/passwords-store.integration.test.ts
index 5f68547c..cd7e25eb 100644
--- a/server/tests/passwords-store.integration.test.ts
+++ b/server/tests/passwords-store.integration.test.ts
@@ -33,9 +33,13 @@ const service = createSignInService({
return {
submitted: true,
passwordFieldVisible: false,
+ codeRequested: false,
url: "https://example.com/",
};
},
+ signInCode: async () => {
+ throw new Error("not used");
+ },
requestHelp: async () => {
throw new Error("not used");
},
@@ -103,3 +107,60 @@ test("a request and a saved login are their owner's alone, and only the envelope
(await service.deleteLogin(owner, rows[0]?.id ?? "", actor)).deleted,
).toBe(true);
});
+
+/**
+ * A site that asks for a verification code after the password. `code_required` is a status the
+ * table's check constraint must accept (migration 0056), and an open request the person still sees.
+ */
+test("a request waiting on its verification code is stored, listed, and then signed in", async () => {
+ const codes: string[] = [];
+ const mfa = createSignInService({
+ store,
+ encryptionKey: Buffer.alloc(32, 3).toString("base64"),
+ gateway: {
+ signIn: async () => ({
+ submitted: true,
+ passwordFieldVisible: false,
+ codeRequested: true,
+ url: "https://example.com/mfa",
+ }),
+ signInCode: async (_botId, input) => {
+ codes.push(input.code);
+ return {
+ submitted: true,
+ codeFieldVisible: false,
+ passwordFieldVisible: false,
+ url: "https://example.com/",
+ };
+ },
+ requestHelp: async () => {
+ throw new Error("not used");
+ },
+ },
+ });
+ const request = await mfa.request({
+ ownerUserId: owner,
+ botId: `${prefix}-bot`,
+ site: "https://example.com/login",
+ actor,
+ });
+ const waiting = await mfa.submit(owner, request.id, actor, {
+ username: "alice",
+ password: PASSWORD,
+ });
+ expect(waiting.status).toBe("code_required");
+ expect((await mfa.pending(owner)).map((row) => row.status)).toContain(
+ "code_required",
+ );
+ const done = await mfa.submitCode(owner, request.id, actor, {
+ code: "551234",
+ });
+ expect(done.status).toBe("signed_in");
+ expect(codes).toEqual(["551234"]);
+ const [stored] = await database
+ .select()
+ .from(signInRequests)
+ .where(inArray(signInRequests.id, [request.id]));
+ expect(JSON.stringify(stored)).not.toContain("551234");
+ expect(JSON.stringify(stored)).not.toContain(PASSWORD);
+});