Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

feat: send an external agent's tasks to an invocation URL (#620)

Croffbc5e8dd788a1
diff --git a/.env.example b/.env.example
index 410e71d9..4a73d3a1 100644
--- a/.env.example
+++ b/.env.example
@@ -138,6 +138,10 @@ APP_ENCRYPTION_KEY=
# AGENT_CHAT_STREAM_POLL_MS=300 # how often an open stream looks for new events
# AGENT_CHAT_HISTORY_MESSAGES=20 # thread messages sent to the runner as context
+# ── External agents with an invocation URL (apps/api): the api sends their tasks to it ──
+# AGENT_INVOCATION_POLL_INTERVAL_MS=1000 # how often to look for tasks to send
+# AGENT_INVOCATION_TIMEOUT_MS=15000 # wait for the endpoint's answer. With no answer, the task stays leased
+
# From address for outbound email. Required for Resend (verified sender); for SMTP
# defaults to the SMTP username. NOTIFICATIONS_EMAIL_FROM is read as a fallback.
# EMAIL_FROM=Its a Plan <[email protected]>
diff --git a/README.md b/README.md
index 5fc21a0b..edb1b383 100644
--- a/README.md
+++ b/README.md
@@ -160,6 +160,7 @@ needed. Run it again later to restart the instance; the data stays.
- [Deploy on Kubernetes](docs/helm.md) — Helm chart for any Kubernetes cluster
- [Local development](docs/development.md) — running the apps on the host, and the tests
- [Coding agent setup](docs/runner.md) — the config for each CLI that `@itsaplan/runner` runs
+- [Agent endpoint](docs/agent-endpoint.md) — the instance sends an external agent's tasks to a URL that you run, such as an AWS Lambda function
## Built with
diff --git a/apps/api/src/background.ts b/apps/api/src/background.ts
index f258a5da..efb58ab7 100644
--- a/apps/api/src/background.ts
+++ b/apps/api/src/background.ts
@@ -1,6 +1,7 @@
import { intEnv } from '#shared/lib';
import { agentRunConfig } from '#modules/agents/core/run-queue';
import { processAgentRuns } from '#modules/agents/core/run-poller';
+import { agentInvocationConfig, dispatchInvocations } from '#modules/agents/invocation/service';
import { pruneAgentTraces } from '#modules/agents/core/runtime/trace-retention';
import { sweepStaleIssues } from '#modules/issues/auto-archive';
@@ -15,6 +16,9 @@ import { sweepStaleIssues } from '#modules/issues/auto-archive';
// back for that long.
export function startBackgroundJobs(): void {
startLoop('agent-runs', processAgentRuns, agentRunConfig.pollIntervalMs);
+ // An external agent with an invocation URL is sent its work from a loop of its own, so
+ // a slow endpoint holds back neither the runs of internal agents nor the other way.
+ startLoop('agent-invocations', sendInvocations, agentInvocationConfig.pollIntervalMs);
// Archiving is not time-sensitive, so the sweep runs far less often than the queue
// is drained.
startLoop('auto-archive', autoArchive, () => intEnv('AUTO_ARCHIVE_INTERVAL_MS', 3_600_000));
@@ -26,6 +30,14 @@ async function autoArchive(): Promise<void> {
if (archived > 0) console.log(`[background] auto-archived ${archived} stale issues`);
}
+// Not awaited: the next tick does not wait for a slow endpoint, so the other agents are
+// sent their work meanwhile.
+async function sendInvocations(): Promise<void> {
+ void dispatchInvocations().catch((error: unknown) =>
+ console.error('[background] agent-invocations failed:', error),
+ );
+}
+
async function pruneTraces(): Promise<void> {
const deleted = await pruneAgentTraces();
if (deleted > 0) console.log(`[background] pruned ${deleted} agent trace spans`);
diff --git a/apps/api/src/modules/agents/chat/index.ts b/apps/api/src/modules/agents/chat/index.ts
index fdf5fdf1..499572dd 100644
--- a/apps/api/src/modules/agents/chat/index.ts
+++ b/apps/api/src/modules/agents/chat/index.ts
@@ -173,13 +173,14 @@ export const agentChatRoutes = new Elysia({ name: 'agent-chat', detail: { tags:
.post('/agent-chats/claim', async ({ agent }) => ({ message: await claimNextMessage(agent) }), {
runnerAgent: true,
- response: { 200: ClaimChatResponse, ...errors(401, 403) },
+ response: { 200: ClaimChatResponse, ...errors(401, 403, 409) },
detail: {
summary: 'Claim the next chat message',
description:
"Take the calling agent's next chat message to answer. The call waits for one " +
'and returns message: null when none arrives. It is leased: report events, ' +
- 'heartbeats, or a result, otherwise it is handed out again.',
+ 'heartbeats, or a result, otherwise it is handed out again. 409 for an agent ' +
+ 'with an invocation URL, whose messages are sent to that URL.',
},
})
diff --git a/apps/api/src/modules/agents/chat/service.ts b/apps/api/src/modules/agents/chat/service.ts
index f59cb36a..fa17fe88 100644
--- a/apps/api/src/modules/agents/chat/service.ts
+++ b/apps/api/src/modules/agents/chat/service.ts
@@ -17,7 +17,7 @@ import { attachmentPreamble, chartPreamble, projectsPreamble } from '../core/pro
import { peoplePreamble, type Person } from '../core/prompt/run-context';
import type { ChatMessagePage, ChatPart, ChatThreadPage } from '../model';
import { newChatThreadId } from '../core/runtime/thread-ids';
-import { touchRunner, type RunnerAgent } from '../runner/service';
+import { assertRunnerDrained, touchRunner, type RunnerAgent } from '../runner/service';
import type { AgUiEventBody, ChatMessageStatus } from './model';
// Chat with an external agent. The answer is produced by a runner on the operator's
@@ -421,6 +421,7 @@ async function expireExhausted(agentId: number): Promise<void> {
// when none turns up in time. Waiting instead of polling is what makes an answer start
// the moment it is sent.
export async function claimNextMessage(agent: RunnerAgent): Promise<ClaimedChat | null> {
+ assertRunnerDrained(agent);
await touchRunner(agent.id);
await expireExhausted(agent.id);
const deadline = Date.now() + agentChatConfig.claimWaitMs();
@@ -432,6 +433,13 @@ export async function claimNextMessage(agent: RunnerAgent): Promise<ClaimedChat
}
}
+// The agent's next due answer without waiting for one, for an agent whose answers are
+// sent to its invocation URL rather than claimed.
+export async function takeNextMessage(agent: RunnerAgent): Promise<ClaimedChat | null> {
+ await expireExhausted(agent.id);
+ return claimMessage(agent);
+}
+
// Takes the agent's next due answer, or null when it has none. Claiming clears whatever
// a previous attempt produced: the answer is generated again from the start, and the
// browser would otherwise read the abandoned half twice.
diff --git a/apps/api/src/modules/agents/core/__tests__/unit/tools.test.ts b/apps/api/src/modules/agents/core/__tests__/unit/tools.test.ts
index 7c7b6a74..4a944793 100644
--- a/apps/api/src/modules/agents/core/__tests__/unit/tools.test.ts
+++ b/apps/api/src/modules/agents/core/__tests__/unit/tools.test.ts
@@ -101,6 +101,9 @@ describe('normalizeToolKeys', () => {
'update_ai_agent',
'delete_ai_agent',
'regenerate_ai_agent_key',
+ 'get_ai_agent_invocation_secret',
+ 'rotate_ai_agent_invocation_secret',
+ 'test_ai_agent_invocation',
'run_ai_agent',
];
expect(normalizeToolKeys(management)).toEqual([]);
diff --git a/apps/api/src/modules/agents/core/model.ts b/apps/api/src/modules/agents/core/model.ts
index 3ef769c3..4cfd238e 100644
--- a/apps/api/src/modules/agents/core/model.ts
+++ b/apps/api/src/modules/agents/core/model.ts
@@ -112,6 +112,18 @@ const configFields = {
"'team' any member's.",
}),
),
+ invocationUrl: t.Optional(
+ t.Nullable(
+ t.String({
+ minLength: 1,
+ maxLength: 2048,
+ description:
+ "HTTPS URL an external agent's runs and chat messages are POSTed to, signed with " +
+ 'its invocation secret, instead of being claimed by a runner. Null puts the agent ' +
+ 'back on a runner. Ignored for an internal agent.',
+ }),
+ ),
+ ),
};
// An agent DTO (AiAgentRow from the service).
@@ -144,6 +156,7 @@ export const AiAgentResponse = t.Object({
ownerUserId: t.Nullable(t.String()),
runnerScope: t.Union([t.Literal('owner'), t.Literal('team')]),
lastSeenAt: t.Nullable(t.String()),
+ invocationUrl: t.Nullable(t.String()),
createdAt: t.String(),
apiKeyStart: t.Nullable(t.String()),
modelProvider: t.Nullable(t.String()),
diff --git a/apps/api/src/modules/agents/core/service.ts b/apps/api/src/modules/agents/core/service.ts
index 23432038..33765732 100644
--- a/apps/api/src/modules/agents/core/service.ts
+++ b/apps/api/src/modules/agents/core/service.ts
@@ -27,6 +27,8 @@ import { runsTeam, type TeamStanding } from '#modules/teams/service';
import { projectRefSql } from '#modules/teams/ref';
import { getDefaultRoleId } from '#modules/roles/service';
import { deleteAccount } from '#shared/account-deletion';
+import { assertPublicHttpUrl } from '#shared/net';
+import { ensureInvocationSecret } from '../invocation/secret';
// Data access for AI agents. Each agent is backed by a hidden bot user
// (ai_agent.user_id -> user.id): that user is what a work item is assigned to,
@@ -114,6 +116,9 @@ export interface AiAgentRow {
// When a runner last polled for this agent, which is what presence is derived
// from. Null until a runner connects.
lastSeenAt: string | null;
+ // Where an external agent's work is sent instead of being claimed by a runner, or
+ // null when a runner drains it.
+ invocationUrl: string | null;
createdAt: string;
// The agent's current API key, for display only — the secret is never returned
// after creation. start is the key's leading characters kept for identification.
@@ -153,6 +158,7 @@ function mapAgent(row: {
ownerUserId: string | null;
runnerScope: string;
lastSeenAt: Date | null;
+ invocationUrl: string | null;
createdAt: Date;
apiKeyStart: string | null;
modelProvider: string | null;
@@ -184,6 +190,7 @@ function mapAgent(row: {
ownerUserId: row.ownerUserId,
runnerScope: row.runnerScope as RunnerScope,
lastSeenAt: row.lastSeenAt ? iso(row.lastSeenAt) : null,
+ invocationUrl: row.invocationUrl,
createdAt: iso(row.createdAt),
apiKeyStart: row.apiKeyStart,
modelProvider: row.modelProvider,
@@ -223,6 +230,7 @@ const agentColumns = {
ownerUserId: aiAgent.ownerUserId,
runnerScope: aiAgent.runnerScope,
lastSeenAt: aiAgent.lastSeenAt,
+ invocationUrl: aiAgent.invocationUrl,
createdAt: aiAgent.createdAt,
apiKeyStart: apikey.start,
modelProvider: integrationCredential.integrationKey,
@@ -540,6 +548,8 @@ export interface NewAgentInput {
projectIds?: number[];
// External-agent runner scope (default: any member's runs).
runnerScope?: RunnerScope;
+ // Where an external agent's work is sent; omitted or null for one a runner drains.
+ invocationUrl?: string | null;
// The member creating the agent, who owns its runner.
ownerUserId?: string | null;
}
@@ -596,8 +606,10 @@ export async function createAgent(
const userId = crypto.randomUUID();
const email = `${userId}@agents.local`;
const isInternal = input.kind === 'internal';
+ const invocationUrl = isInternal ? null : (input.invocationUrl ?? null);
await assertUsernameFree(teamId, input.username);
if (isInternal) await assertModelCredential(teamId, input.modelCredentialId);
+ if (invocationUrl) await assertPublicHttpUrl(invocationUrl);
const projectIds = await resolveTeamProjectIds(teamId, input.projectIds ?? []);
// An agent joins a project the way a person accepting an invite does: on the team's
// default role, changed per project from the project's member list afterwards.
@@ -629,6 +641,7 @@ export async function createAgent(
delegationDelaySec: input.delegationDelaySec,
ownerUserId: input.ownerUserId ?? null,
runnerScope: input.runnerScope ?? 'team',
+ invocationUrl,
})
.returning({ id: aiAgent.id });
// The agent belongs to the team's member list like a person does, on a standing
@@ -649,6 +662,7 @@ export async function createAgent(
if (input.fieldTriggers?.length) {
await setFieldTriggers(agentId, projectIds, input.fieldTriggers);
}
+ if (invocationUrl) await ensureInvocationSecret(agentId);
// Issued outside the transaction: better-auth writes the key through its own
// connection, so it cannot join this one.
@@ -787,6 +801,7 @@ export interface AgentPatch {
fieldTriggers?: FieldTrigger[];
delegationDelaySec?: number;
runnerScope?: RunnerScope;
+ invocationUrl?: string | null;
}
export async function updateAgent(
@@ -799,6 +814,9 @@ export async function updateAgent(
const agent = await getAgentById(id, teamId);
if (!agent) return null;
await assertModelCredential(teamId, patch.modelCredentialId);
+ // Only an external agent is sent its work; an internal one runs here.
+ const invocationUrl = agent.kind === 'external' ? patch.invocationUrl : undefined;
+ if (invocationUrl) await assertPublicHttpUrl(invocationUrl);
// The display name lives on the bot user.
if (patch.name !== undefined) {
@@ -828,6 +846,7 @@ export async function updateAgent(
set.runnerScope = patch.runnerScope;
if (patch.runnerScope === 'owner') set.ownerUserId = actorUserId;
}
+ if (invocationUrl !== undefined) set.invocationUrl = invocationUrl;
if (Object.keys(set).length > 0) {
try {
await db
@@ -848,6 +867,7 @@ export async function updateAgent(
if (patch.fieldTriggers !== undefined) {
await setFieldTriggers(id, projectIds, patch.fieldTriggers);
}
+ if (invocationUrl) await ensureInvocationSecret(id);
return getAgentById(id, teamId);
}
diff --git a/apps/api/src/modules/agents/invocation/__tests__/integration/agent-invocation.test.ts b/apps/api/src/modules/agents/invocation/__tests__/integration/agent-invocation.test.ts
new file mode 100644
index 00000000..2e16a7dc
--- /dev/null
+++ b/apps/api/src/modules/agents/invocation/__tests__/integration/agent-invocation.test.ts
@@ -0,0 +1,338 @@
+import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
+import { createHmac } from 'node:crypto';
+import { apiKeyApi, authedApi, type Api, createProject } from '#tests/helpers/app';
+import { signUpTestUser } from '#tests/helpers/auth';
+import { resetDb } from '#tests/helpers/db';
+import { addProjectMember } from '#tests/helpers/members';
+import { createAgent, teamOf } from '#tests/helpers/agents';
+import { dispatchInvocations } from '#modules/agents/invocation/service';
+
+// An external agent with an invocation URL is sent its runs and chat messages instead of
+// a runner claiming them. The endpoint is a server on localhost, which the SSRF guard
+// refuses under NODE_ENV=test, so each case runs as development, the way the git
+// provider tests reach theirs.
+
+interface Received {
+ event: string;
+ signature: string;
+ body: string;
+ json: {
+ event: string;
+ agent: { id: number; username: string };
+ run?: { id: number; prompt: string };
+ message?: { id: number; prompt: string };
+ };
+}
+
+function fakeEndpoint(respond: () => Response | Promise<Response> = () => new Response('ok')) {
+ const received: Received[] = [];
+ const server = Bun.serve({
+ port: 0,
+ async fetch(req) {
+ const body = await req.text();
+ received.push({
+ event: req.headers.get('x-itsaplan-event') ?? '',
+ signature: req.headers.get('x-itsaplan-signature') ?? '',
+ body,
+ json: JSON.parse(body),
+ });
+ return respond();
+ },
+ });
+ return { url: `http://127.0.0.1:${server.port}/agent`, received, stop: () => server.stop(true) };
+}
+
+// What a receiver does with the header: recompute the HMAC over the bytes it got.
+function signedWith(secret: string, item: Received): boolean {
+ const [t, v1] = item.signature.split(',').map((part) => part.split('=')[1]);
+ return createHmac('sha256', secret).update(`${t}.${item.body}`).digest('hex') === v1;
+}
+
+async function setup(invocationUrl?: string) {
+ const owner = await signUpTestUser({ name: 'Owner' });
+ const asOwner = authedApi(owner.cookie);
+ await createProject(asOwner, { key: 'MKT', name: 'Marketing' });
+ const view = await asOwner.projects({ projectKey: 'MKT' }).get();
+ const created = await createAgent(asOwner, 'MKT', {
+ name: 'Cloud Bot',
+ username: 'cloud',
+ kind: 'external',
+ triggerOnMention: true,
+ invocationUrl,
+ });
+ return {
+ asOwner,
+ teamId: await teamOf(asOwner, 'MKT'),
+ columnId: view.data!.columns[0].id,
+ agent: created.data!.agent,
+ asAgent: apiKeyApi(created.data!.apiKey!),
+ };
+}
+
+function agentOf(api: Api, teamId: number, agentId: number) {
+ return api.teams({ teamId })['ai-agents']({ agentId });
+}
+
+function chatOf(api: Api, agentId: number) {
+ return api.projects({ projectKey: 'MKT' })['ai-agents']({ agentId });
+}
+
+async function queueRun(asOwner: Api, columnId: number) {
+ const issue = (
+ await asOwner.projects({ projectKey: 'MKT' }).issues.post({ columnId, title: 'Landing page' })
+ ).data!;
+ await asOwner.issues({ issueId: issue.id }).comments.post({ body: 'please review @cloud' });
+ return issue;
+}
+
+async function lastRun(asOwner: Api, teamId: number, agentId: number) {
+ return (await agentOf(asOwner, teamId, agentId).runs.get({ query: {} })).data!.items[0];
+}
+
+const ENV_KEYS = ['NODE_ENV', 'AGENT_RUN_MAX_ATTEMPTS', 'AGENT_INVOCATION_TIMEOUT_MS'] as const;
+
+describe('agent invocation', () => {
+ const environment = Object.fromEntries(ENV_KEYS.map((key) => [key, process.env[key]]));
+ let endpoint: ReturnType<typeof fakeEndpoint> | null = null;
+
+ beforeEach(async () => {
+ await resetDb();
+ process.env.NODE_ENV = 'development';
+ });
+
+ afterEach(async () => {
+ await endpoint?.stop();
+ endpoint = null;
+ for (const key of ENV_KEYS) {
+ if (environment[key] === undefined) delete process.env[key];
+ else process.env[key] = environment[key];
+ }
+ });
+
+ it('issues a signing secret with the first URL and keeps it when the URL changes', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, teamId, agent } = await setup(endpoint.url);
+ expect(agent.invocationUrl).toBe(endpoint.url);
+
+ const first = await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get();
+ expect(first.status).toBe(200);
+ expect(first.data!.secret).toStartWith('whsec_');
+
+ const moved = `${endpoint.url}/v2`;
+ const patched = await agentOf(asOwner, teamId, agent.id).patch({ invocationUrl: moved });
+ expect(patched.data!.invocationUrl).toBe(moved);
+ const second = await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get();
+ expect(second.data!.secret).toBe(first.data!.secret);
+ });
+
+ it('rotates the secret', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, teamId, agent } = await setup(endpoint.url);
+ const before = (await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get()).data!;
+
+ const rotated = await agentOf(asOwner, teamId, agent.id)['invocation-secret'].post();
+ expect(rotated.status).toBe(200);
+ expect(rotated.data!.secret).not.toBe(before.secret!);
+ const after = (await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get()).data!;
+ expect(after.secret).toBe(rotated.data!.secret);
+ });
+
+ it('has no URL and no secret for an agent a runner drains', async () => {
+ const { asOwner, teamId, agent } = await setup();
+ expect(agent.invocationUrl).toBeNull();
+ const res = await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get();
+ expect(res.data!.secret).toBeNull();
+ });
+
+ it('refuses a URL that points to a private address', async () => {
+ const { asOwner, teamId, agent } = await setup();
+ process.env.NODE_ENV = 'test';
+ for (const invocationUrl of ['http://127.0.0.1:9/agent', 'https://10.0.0.1/agent']) {
+ const res = await agentOf(asOwner, teamId, agent.id).patch({ invocationUrl });
+ expect(res.status).toBe(400);
+ }
+ });
+
+ it('ignores a URL on an internal agent and refuses its invocation routes', async () => {
+ const { asOwner, teamId } = await setup();
+ const created = await createAgent(asOwner, 'MKT', {
+ name: 'Inside',
+ username: 'inside',
+ kind: 'internal',
+ invocationUrl: 'https://agents.example.com/run',
+ });
+ expect(created.data!.agent.invocationUrl).toBeNull();
+ const res = await agentOf(asOwner, teamId, created.data!.agent.id)['invocation-secret'].get();
+ expect(res.status).toBe(400);
+ });
+
+ it('keeps the secret and the test to members who may edit agents', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, teamId, agent } = await setup(endpoint.url);
+ const asMember = await addProjectMember(asOwner, 'MKT');
+
+ expect((await agentOf(asMember, teamId, agent.id).get()).data!.invocationUrl).toBe(
+ endpoint.url,
+ );
+ expect((await agentOf(asMember, teamId, agent.id)['invocation-secret'].get()).status).toBe(403);
+ expect((await agentOf(asMember, teamId, agent.id)['invocation-secret'].post()).status).toBe(
+ 403,
+ );
+ expect((await agentOf(asMember, teamId, agent.id)['invocation-test'].post()).status).toBe(403);
+ });
+
+ it('sends a test ping the endpoint can verify', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, teamId, agent } = await setup(endpoint.url);
+ const { secret } = (await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get()).data!;
+
+ const res = await agentOf(asOwner, teamId, agent.id)['invocation-test'].post();
+ expect(res.status).toBe(200);
+ expect(res.data).toMatchObject({ ok: true, status: 200, responseBody: 'ok', error: null });
+ expect(endpoint.received).toHaveLength(1);
+ expect(endpoint.received[0]).toMatchObject({
+ event: 'ping',
+ json: { event: 'ping', agent: { id: agent.id, username: 'cloud' } },
+ });
+ expect(signedWith(secret!, endpoint.received[0])).toBe(true);
+ });
+
+ it('reports how an endpoint refused the ping', async () => {
+ endpoint = fakeEndpoint(() => new Response('bad signature', { status: 401 }));
+ const { asOwner, teamId, agent } = await setup(endpoint.url);
+
+ const res = await agentOf(asOwner, teamId, agent.id)['invocation-test'].post();
+ expect(res.data).toMatchObject({
+ ok: false,
+ timedOut: false,
+ status: 401,
+ responseBody: 'bad signature',
+ error: 'The endpoint answered 401',
+ });
+ });
+
+ it('refuses a test for an agent with no URL', async () => {
+ const { asOwner, teamId, agent } = await setup();
+ expect((await agentOf(asOwner, teamId, agent.id)['invocation-test'].post()).status).toBe(400);
+ });
+
+ it('sends a queued run, which the endpoint finishes with the agent key', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, asAgent, teamId, columnId, agent } = await setup(endpoint.url);
+ const { secret } = (await agentOf(asOwner, teamId, agent.id)['invocation-secret'].get()).data!;
+ const issue = await queueRun(asOwner, columnId);
+
+ await dispatchInvocations();
+ expect(endpoint.received).toHaveLength(1);
+ const sent = endpoint.received[0];
+ expect(sent.event).toBe('agent.run');
+ expect(sent.json.run).toMatchObject({ trigger: 'mention', issueId: issue.id, attempts: 1 });
+ expect(sent.json.run!.prompt).toContain('please review');
+ expect(signedWith(secret!, sent)).toBe(true);
+
+ // Leased: the next pass sends nothing while the endpoint works on it.
+ await dispatchInvocations();
+ expect(endpoint.received).toHaveLength(1);
+
+ const done = await asAgent['agent-runs']({ runId: sent.json.run!.id }).result.post({
+ status: 'success',
+ output: 'Opened PR #12',
+ });
+ expect(done.status).toBe(204);
+ expect(await lastRun(asOwner, teamId, agent.id)).toMatchObject({
+ status: 'success',
+ output: 'Opened PR #12',
+ });
+ });
+
+ it('puts a run the endpoint refused back for a retry', async () => {
+ endpoint = fakeEndpoint(() => new Response('down', { status: 500 }));
+ const { asOwner, teamId, columnId, agent } = await setup(endpoint.url);
+ await queueRun(asOwner, columnId);
+
+ await dispatchInvocations();
+ expect(await lastRun(asOwner, teamId, agent.id)).toMatchObject({
+ status: 'pending',
+ attempts: 1,
+ lastError: 'The endpoint answered 500',
+ });
+ });
+
+ it('fails a run the endpoint refused on its last attempt', async () => {
+ process.env.AGENT_RUN_MAX_ATTEMPTS = '1';
+ endpoint = fakeEndpoint(() => new Response('down', { status: 500 }));
+ const { asOwner, teamId, columnId, agent } = await setup(endpoint.url);
+ const issue = await queueRun(asOwner, columnId);
+
+ await dispatchInvocations();
+ expect(await lastRun(asOwner, teamId, agent.id)).toMatchObject({
+ status: 'failed',
+ lastError: 'The endpoint answered 500',
+ });
+ const feed = await asOwner.issues({ issueId: issue.id }).feed.get({ query: {} });
+ expect(feed.data!.items).toContainEqual(
+ expect.objectContaining({
+ action: 'agent_finished',
+ payload: { subject: { value: 'failed' } },
+ }),
+ );
+ });
+
+ it('leaves a run under its lease when the endpoint does not answer in time', async () => {
+ process.env.AGENT_INVOCATION_TIMEOUT_MS = '100';
+ endpoint = fakeEndpoint(() => new Promise<Response>(() => {}));
+ const { asOwner, teamId, columnId, agent } = await setup(endpoint.url);
+ await queueRun(asOwner, columnId);
+
+ await dispatchInvocations();
+ await dispatchInvocations();
+ expect(endpoint.received).toHaveLength(1);
+ expect(await lastRun(asOwner, teamId, agent.id)).toMatchObject({
+ status: 'pending',
+ attempts: 1,
+ lastError: null,
+ });
+ });
+
+ it('sends a chat message, and the endpoint reports the answer back', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, asAgent, agent } = await setup(endpoint.url);
+ const { messageId } = (await chatOf(asOwner, agent.id).chat.post({ prompt: 'Status?' })).data!;
+
+ await dispatchInvocations();
+ const sent = endpoint.received[0];
+ expect(sent.event).toBe('agent.chat');
+ expect(sent.json.message).toMatchObject({ id: messageId, attempts: 1 });
+ expect(sent.json.message!.prompt).toContain('Status?');
+
+ await asAgent['agent-chats']({ messageId }).events.post({
+ events: [{ type: 'TEXT_MESSAGE_CONTENT', messageId: 'm1', delta: 'All green.' }],
+ });
+ await asAgent['agent-chats']({ messageId }).result.post({ status: 'success' });
+ const events = await chatOf(asOwner, agent.id).chat({ messageId }).events.get({ query: {} });
+ expect(events.data!.status).toBe('success');
+ expect(events.data!.items.map((item) => item.event)).toContainEqual(
+ expect.objectContaining({ delta: 'All green.' }),
+ );
+ });
+
+ it('fails a chat answer the endpoint refused', async () => {
+ endpoint = fakeEndpoint(() => new Response('busy', { status: 503 }));
+ const { asOwner, agent } = await setup(endpoint.url);
+ const { messageId } = (await chatOf(asOwner, agent.id).chat.post({ prompt: 'Status?' })).data!;
+
+ await dispatchInvocations();
+ const events = await chatOf(asOwner, agent.id).chat({ messageId }).events.get({ query: {} });
+ expect(events.data).toMatchObject({ status: 'failed', error: 'The endpoint answered 503' });
+ });
+
+ it('refuses a runner claim while the agent has a URL', async () => {
+ endpoint = fakeEndpoint();
+ const { asOwner, asAgent, teamId, agent } = await setup(endpoint.url);
+ expect((await asAgent['agent-runs'].claim.post()).status).toBe(409);
+ expect((await asAgent['agent-chats'].claim.post()).status).toBe(409);
+
+ await agentOf(asOwner, teamId, agent.id).patch({ invocationUrl: null });
+ expect((await asAgent['agent-runs'].claim.post()).status).toBe(200);
+ });
+});
diff --git a/apps/api/src/modules/agents/invocation/index.ts b/apps/api/src/modules/agents/invocation/index.ts
new file mode 100644
index 00000000..abd59fa1
--- /dev/null
+++ b/apps/api/src/modules/agents/invocation/index.ts
@@ -0,0 +1,98 @@
+import { Elysia } from 'elysia';
+import { guards } from '#shared/guards';
+import { authContext } from '#shared/auth-context';
+import type { TeamMembership } from '#shared/access';
+import { HttpError } from '#shared/lib';
+import { commonErrors } from '#shared/responses';
+import { mcpTool } from '#mcp/generate';
+import { agentScopeOf, getAgentById } from '../core/service';
+import {
+ agentParams,
+ InvocationSecretResponse,
+ InvocationTestResponse,
+ RotatedInvocationSecretResponse,
+} from './model';
+import { readInvocationSecret, rotateInvocationSecret } from './secret';
+import { testInvocation } from './service';
+
+// The external agent the path addresses, scoped the way the agent routes scope it.
+async function requireExternalAgent(agentId: number, membership: TeamMembership) {
+ const agent = await getAgentById(agentId, membership.teamId, agentScopeOf(membership));
+ if (!agent) throw new HttpError(404, 'Agent not found');
+ if (agent.kind !== 'external') {
+ throw new HttpError(400, 'Only an external agent is sent its work');
+ }
+ return agent;
+}
+
+// What is needed to set up the endpoint at an external agent's invocation URL. Each
+// route requires `edit` on the agents: the secret lets its holder sign work for the
+// agent, and whoever may edit the agent can already point its URL anywhere.
+export const agentInvocationRoutes = new Elysia({
+ name: 'agent-invocation',
+ detail: { tags: ['AI Agents'] },
+})
+ .use(authContext)
+ .use(guards)
+
+ .get(
+ '/teams/:teamId/ai-agents/:agentId/invocation-secret',
+ async ({ params, membership }) => {
+ await requireExternalAgent(params.agentId, membership);
+ return { secret: await readInvocationSecret(params.agentId) };
+ },
+ {
+ params: agentParams,
+ teamPermission: ['ai_agents', 'edit'],
+ response: { 200: InvocationSecretResponse, ...commonErrors },
+ detail: {
+ summary: 'Read the invocation secret',
+ description:
+ 'The key the requests sent to the invocation URL are signed with, in the ' +
+ 'X-Itsaplan-Signature header.',
+ ...mcpTool('get_ai_agent_invocation_secret'),
+ },
+ },
+ )
+
+ .post(
+ '/teams/:teamId/ai-agents/:agentId/invocation-secret',
+ async ({ params, membership }) => {
+ await requireExternalAgent(params.agentId, membership);
+ return { secret: await rotateInvocationSecret(params.agentId) };
+ },
+ {
+ params: agentParams,
+ teamPermission: ['ai_agents', 'edit'],
+ response: { 200: RotatedInvocationSecretResponse, ...commonErrors },
+ detail: {
+ summary: 'Rotate the invocation secret',
+ description:
+ 'Issue a new signing key. The next request is signed with it, so the endpoint ' +
+ 'has to be given it first.',
+ // The endpoint keeps verifying with the old key until it is given the new one.
+ ...mcpTool('rotate_ai_agent_invocation_secret', { destructiveHint: true }),
+ },
+ },
+ )
+
+ .post(
+ '/teams/:teamId/ai-agents/:agentId/invocation-test',
+ async ({ params, membership }) => {
+ const outcome = await testInvocation(await requireExternalAgent(params.agentId, membership));
+ if (!outcome) throw new HttpError(400, 'The agent has no invocation URL');
+ return outcome;
+ },
+ {
+ params: agentParams,
+ teamPermission: ['ai_agents', 'edit'],
+ response: { 200: InvocationTestResponse, ...commonErrors },
+ detail: {
+ summary: 'Send a test request',
+ description:
+ "Send a signed ping to the agent's invocation URL and report how the endpoint " +
+ 'answered.',
+ ...mcpTool('test_ai_agent_invocation'),
+ },
+ },
+ );
diff --git a/apps/api/src/modules/agents/invocation/model.ts b/apps/api/src/modules/agents/invocation/model.ts
new file mode 100644
index 00000000..6bf79985
--- /dev/null
+++ b/apps/api/src/modules/agents/invocation/model.ts
@@ -0,0 +1,21 @@
+import { t } from 'elysia';
+
+export { agentParams } from '../model';
+
+export const InvocationSecretResponse = t.Object({
+ secret: t.Nullable(
+ t.String({ description: 'Null while the agent has never had an invocation URL.' }),
+ ),
+});
+
+export const RotatedInvocationSecretResponse = t.Object({ secret: t.String() });
+
+// InvocationOutcome from the service.
+export const InvocationTestResponse = t.Object({
+ ok: t.Boolean({ description: 'The endpoint answered 2xx.' }),
+ timedOut: t.Boolean(),
+ status: t.Nullable(t.Number({ description: 'HTTP status, null when none arrived.' })),
+ error: t.Nullable(t.String()),
+ responseBody: t.Nullable(t.String({ description: 'The start of what the endpoint answered.' })),
+ durationMs: t.Number(),
+});
diff --git a/apps/api/src/modules/agents/invocation/secret.ts b/apps/api/src/modules/agents/invocation/secret.ts
new file mode 100644
index 00000000..509b7d0d
--- /dev/null
+++ b/apps/api/src/modules/agents/invocation/secret.ts
@@ -0,0 +1,48 @@
+import { db, aiAgent } from '@repo/db';
+import { and, eq, isNull } from 'drizzle-orm';
+import { decryptSecret, encryptSecret } from '@repo/crypto';
+import { generateSecret } from '#modules/webhooks/service';
+
+// The key an external agent's invocations are signed with. It is issued with the
+// agent's first invocation URL and read back to sign every request, so it is kept
+// encrypted rather than hashed.
+
+function encryptedColumns(secret: string) {
+ const enc = encryptSecret(secret);
+ return {
+ invocationSecretCiphertext: enc.ciphertext,
+ invocationSecretIv: enc.iv,
+ invocationSecretAuthTag: enc.authTag,
+ };
+}
+
+// Issues a secret for an agent that has none and leaves one already issued as it is, so
+// saving the URL again does not break the receiver that verifies with it.
+export async function ensureInvocationSecret(agentId: number): Promise<void> {
+ await db
+ .update(aiAgent)
+ .set(encryptedColumns(generateSecret()))
+ .where(and(eq(aiAgent.id, agentId), isNull(aiAgent.invocationSecretCiphertext)));
+}
+
+// Replaces the secret and returns the new one. Requests signed before take the old one,
+// so the receiver has to be given the new value before the next request arrives.
+export async function rotateInvocationSecret(agentId: number): Promise<string> {
+ const secret = generateSecret();
+ await db.update(aiAgent).set(encryptedColumns(secret)).where(eq(aiAgent.id, agentId));
+ return secret;
+}
+
+export async function readInvocationSecret(agentId: number): Promise<string | null> {
+ const rows = await db
+ .select({
+ ciphertext: aiAgent.invocationSecretCiphertext,
+ iv: aiAgent.invocationSecretIv,
+ authTag: aiAgent.invocationSecretAuthTag,
+ })
+ .from(aiAgent)
+ .where(eq(aiAgent.id, agentId));
+ const row = rows[0];
+ if (!row?.ciphertext || !row.iv || !row.authTag) return null;
+ return decryptSecret({ ciphertext: row.ciphertext, iv: row.iv, authTag: row.authTag });
+}
diff --git a/apps/api/src/modules/agents/invocation/service.ts b/apps/api/src/modules/agents/invocation/service.ts
new file mode 100644
index 00000000..60651119
--- /dev/null
+++ b/apps/api/src/modules/agents/invocation/service.ts
@@ -0,0 +1,227 @@
+import { db, aiAgent, agentChatMessage, agentRun } from '@repo/db';
+import { and, eq, inArray, isNotNull, lte, or, sql, exists } from 'drizzle-orm';
+import { signPayload } from '@repo/crypto';
+import { pinnedFetch } from '@repo/net';
+import { intEnv } from '#shared/lib';
+import {
+ agentRunConfig,
+ markRunFailed,
+ runRetryDelayMs,
+ scheduleRunRetry,
+} from '../core/run-queue';
+import { recordAgentRunFinished } from '../core/run-activity';
+import { getRunnerAgent, takeNextRun, type RunnerAgent, type RunnerRun } from '../runner/service';
+import { finishMessage, takeNextMessage, type ClaimedChat } from '../chat/service';
+import { readInvocationSecret } from './secret';
+
+// Sends an external agent its work when it has an invocation URL. The work is claimed
+// with the runner's own claims, so a run sent here is framed, leased and admitted the
+// same way, and the endpoint reports progress and the result through the runner routes
+// with the agent's API key. The request only hands the work over: a 2xx means the
+// endpoint took it.
+
+export const agentInvocationConfig = {
+ pollIntervalMs: () => intEnv('AGENT_INVOCATION_POLL_INTERVAL_MS', 1000),
+ timeoutMs: () => intEnv('AGENT_INVOCATION_TIMEOUT_MS', 15_000),
+};
+
+type InvocationEvent = 'agent.run' | 'agent.chat' | 'ping';
+
+// The receiver's response body, cut to what the test result shows.
+const MAX_RESPONSE_CHARS = 2000;
+
+export interface InvocationOutcome {
+ ok: boolean;
+ // No answer in time. The endpoint may still be working on the request, so the work
+ // stays under its lease instead of being sent again at once.
+ timedOut: boolean;
+ status: number | null;
+ error: string | null;
+ responseBody: string | null;
+ durationMs: number;
+}
+
+interface Target {
+ url: string;
+ secret: string;
+}
+
+async function targetOf(agent: {
+ id: number;
+ invocationUrl: string | null;
+}): Promise<Target | null> {
+ if (!agent.invocationUrl) return null;
+ const secret = await readInvocationSecret(agent.id);
+ return secret ? { url: agent.invocationUrl, secret } : null;
+}
+
+async function invoke(
+ target: Target,
+ event: InvocationEvent,
+ agent: { id: number; username: string },
+ data: Record<string, unknown>,
+): Promise<InvocationOutcome> {
+ const body = JSON.stringify({
+ event,
+ agent: { id: agent.id, username: agent.username },
+ apiUrl: (process.env.API_URL ?? '').replace(/\/+$/, '') || null,
+ ...data,
+ });
+ const timeoutMs = agentInvocationConfig.timeoutMs();
+ const signal = AbortSignal.timeout(timeoutMs);
+ const started = Date.now();
+ try {
+ const res = await pinnedFetch(target.url, {
+ method: 'POST',
+ signal,
+ headers: {
+ 'Content-Type': 'application/json',
+ 'User-Agent': 'itsaplan-agents/1',
+ 'X-Itsaplan-Event': event,
+ 'X-Itsaplan-Signature': signPayload(target.secret, Math.floor(started / 1000), body),
+ },
+ body,
+ maxBytes: MAX_RESPONSE_CHARS * 4,
+ truncateBody: true,
+ });
+ const text = (await res.text().catch(() => '')).slice(0, MAX_RESPONSE_CHARS);
+ const ok = res.status >= 200 && res.status < 300;
+ return {
+ ok,
+ timedOut: false,
+ status: res.status,
+ error: ok ? null : `The endpoint answered ${res.status}`,
+ responseBody: text || null,
+ durationMs: Date.now() - started,
+ };
+ } catch (err) {
+ const timedOut = signal.aborted;
+ let error: string;
+ if (timedOut) error = `No answer within ${Math.round(timeoutMs / 1000)}s`;
+ else error = err instanceof Error ? err.message : String(err);
+ return {
+ ok: false,
+ timedOut,
+ status: null,
+ error,
+ responseBody: null,
+ durationMs: Date.now() - started,
+ };
+ }
+}
+
+// Sends a ping, so whoever sets the URL up sees whether the endpoint answers and
+// accepts the signature before real work goes there. Null when the agent has no URL.
+export async function testInvocation(agent: {
+ id: number;
+ username: string;
+ invocationUrl: string | null;
+}): Promise<InvocationOutcome | null> {
+ const target = await targetOf(agent);
+ if (!target) return null;
+ return invoke(target, 'ping', agent, {});
+}
+
+// The bot users of the agents with an invocation URL that have a run or a chat answer
+// due. The secret is issued with the URL, so an agent without one is left out rather
+// than sent unsigned requests.
+async function agentsWithDueWork(): Promise<string[]> {
+ const dueRun = db
+ .select({ id: agentRun.id })
+ .from(agentRun)
+ .where(
+ and(
+ eq(agentRun.agentId, aiAgent.id),
+ eq(agentRun.status, 'pending'),
+ lte(agentRun.nextAttemptAt, sql`now()`),
+ ),
+ );
+ const dueAnswer = db
+ .select({ id: agentChatMessage.id })
+ .from(agentChatMessage)
+ .where(
+ and(
+ eq(agentChatMessage.agentId, aiAgent.id),
+ eq(agentChatMessage.role, 'assistant'),
+ inArray(agentChatMessage.status, ['pending', 'streaming']),
+ lte(agentChatMessage.nextAttemptAt, sql`now()`),
+ ),
+ );
+ const rows = await db
+ .select({ userId: aiAgent.userId })
+ .from(aiAgent)
+ .where(
+ and(
+ eq(aiAgent.kind, 'external'),
+ isNotNull(aiAgent.invocationUrl),
+ isNotNull(aiAgent.invocationSecretCiphertext),
+ or(exists(dueRun), exists(dueAnswer)),
+ ),
+ );
+ return rows.map((row) => row.userId);
+}
+
+// Claims up to a batch of items one at a time, so the requests for them can be sent
+// together.
+async function takeBatch<T>(take: () => Promise<T | null>): Promise<T[]> {
+ const items: T[] = [];
+ for (let i = 0; i < agentRunConfig.batchSize(); i++) {
+ const item = await take();
+ if (!item) break;
+ items.push(item);
+ }
+ return items;
+}
+
+// A run the endpoint refused is retried like a failed attempt of an internal agent's
+// run, and the last refusal fails it.
+async function sendRun(agent: RunnerAgent, target: Target, run: RunnerRun): Promise<void> {
+ const outcome = await invoke(target, 'agent.run', agent, { run });
+ if (outcome.ok || outcome.timedOut) return;
+ const error = outcome.error ?? 'The endpoint refused the run';
+ if (run.attempts < agentRunConfig.maxAttempts()) {
+ await scheduleRunRetry(run.id, runRetryDelayMs(run.attempts), error);
+ return;
+ }
+ await recordAgentRunFinished({ issueId: run.issueId, agentUserId: agent.userId }, 'failed');
+ await markRunFailed(run.id, error);
+}
+
+// A person is waiting for the answer, so a refusal fails it at once instead of after
+// the retries a run gets.
+async function sendChat(agent: RunnerAgent, target: Target, message: ClaimedChat): Promise<void> {
+ const outcome = await invoke(target, 'agent.chat', agent, { message });
+ if (outcome.ok || outcome.timedOut) return;
+ await finishMessage(agent.id, message.id, { status: 'failed', error: outcome.error });
+}
+
+async function dispatchAgent(userId: string): Promise<void> {
+ const agent = await getRunnerAgent(userId);
+ if (!agent) return;
+ const target = await targetOf(agent);
+ if (!target) return;
+ const runs = await takeBatch(() => takeNextRun(agent));
+ const messages = await takeBatch(() => takeNextMessage(agent));
+ await Promise.all([
+ ...runs.map((run) => sendRun(agent, target, run)),
+ ...messages.map((message) => sendChat(agent, target, message)),
+ ]);
+}
+
+// The bot users of the agents whose requests are still out. A pass skips them, so an
+// agent is not sent a second batch while its endpoint is still answering the first.
+const dispatching = new Set<string>();
+
+export async function dispatchInvocations(): Promise<void> {
+ const userIds = (await agentsWithDueWork()).filter((userId) => !dispatching.has(userId));
+ await Promise.all(
+ userIds.map(async (userId) => {
+ dispatching.add(userId);
+ try {
+ await dispatchAgent(userId);
+ } finally {
+ dispatching.delete(userId);
+ }
+ }),
+ );
+}
diff --git a/apps/api/src/modules/agents/runner/index.ts b/apps/api/src/modules/agents/runner/index.ts
index 36738fa7..570a1a01 100644
--- a/apps/api/src/modules/agents/runner/index.ts
+++ b/apps/api/src/modules/agents/runner/index.ts
@@ -16,12 +16,13 @@ export const agentRunnerRoutes = new Elysia({
.post('/agent-runs/claim', async ({ agent }) => ({ run: await claimRunnerRun(agent) }), {
runnerAgent: true,
- response: { 200: ClaimResponse, ...errors(401, 403) },
+ response: { 200: ClaimResponse, ...errors(401, 403, 409) },
detail: {
summary: 'Claim the next run',
description:
"Take the calling agent's next queued run, or run: null when it has none. It is " +
- 'leased: report a result or send heartbeats, otherwise it is handed out again.',
+ 'leased: report a result or send heartbeats, otherwise it is handed out again. ' +
+ '409 for an agent with an invocation URL, whose runs are sent to that URL.',
},
})
diff --git a/apps/api/src/modules/agents/runner/service.ts b/apps/api/src/modules/agents/runner/service.ts
index 3ce22400..e890aa3a 100644
--- a/apps/api/src/modules/agents/runner/service.ts
+++ b/apps/api/src/modules/agents/runner/service.ts
@@ -1,5 +1,6 @@
import { db, aiAgent, agentRun, project, projectMember } from '@repo/db';
import { and, eq, sql } from 'drizzle-orm';
+import { HttpError } from '#shared/lib';
import { type ContextUsage } from '../chat-usage';
import {
agentRunConfig,
@@ -49,6 +50,8 @@ export interface RunnerAgent {
// A chat names all of them in the system prompt; a run names the one it works in.
projects: RunnerProject[];
instructions: string | null;
+ // Set when the agent is sent its work rather than drained by a runner.
+ invocationUrl: string | null;
}
// The agent whose bot user is the caller, or null when the caller is not an agent.
@@ -63,6 +66,7 @@ export async function getRunnerAgent(userId: string): Promise<RunnerAgent | null
userId: aiAgent.userId,
username: aiAgent.username,
instructions: aiAgent.instructions,
+ invocationUrl: aiAgent.invocationUrl,
})
.from(aiAgent)
.where(eq(aiAgent.userId, userId))
@@ -138,12 +142,26 @@ async function expireExhaustedRuns(agent: RunnerAgent): Promise<void> {
await recordAgentRunFinished({ ...row, agentUserId: agent.userId }, 'failed');
}
-// Claims the agent's next due run, or null when it has none. FOR UPDATE SKIP LOCKED
-// keeps two runners on the same key from taking the same run.
+// An agent with an invocation URL is sent its work, so a runner that claims as well
+// would take tasks the endpoint is meant to get. The endpoint reports through the runner
+// routes too; only the claims are refused.
+export function assertRunnerDrained(agent: RunnerAgent): void {
+ if (agent.invocationUrl) {
+ throw new HttpError(409, 'This agent receives its work at its invocation URL');
+ }
+}
+
export async function claimRunnerRun(agent: RunnerAgent): Promise<RunnerRun | null> {
+ assertRunnerDrained(agent);
+ await touchRunner(agent.id);
+ return takeNextRun(agent);
+}
+
+// Claims the agent's next due run, or null when it has none. FOR UPDATE SKIP LOCKED
+// keeps two claims on the same agent from taking the same run.
+export async function takeNextRun(agent: RunnerAgent): Promise<RunnerRun | null> {
const agentId = agent.id;
await expireExhaustedRuns(agent);
- await touchRunner(agentId);
const rows = await db.execute(sql`
UPDATE agent_run r
SET attempts = r.attempts + 1,
diff --git a/apps/api/src/planner.ts b/apps/api/src/planner.ts
index dc631fe5..31d7d489 100644
--- a/apps/api/src/planner.ts
+++ b/apps/api/src/planner.ts
@@ -40,6 +40,7 @@ import { agentScheduleRoutes } from './modules/agents/schedules';
import { modelPriceRoutes } from './modules/agents/prices';
import { agentRunnerRoutes } from './modules/agents/runner';
import { agentChatRoutes } from './modules/agents/chat';
+import { agentInvocationRoutes } from './modules/agents/invocation';
import { notificationRoutes } from './modules/notifications';
import { notificationSettingsRoutes } from './modules/notification-settings';
import { notificationPreferenceRoutes } from './modules/notification-preferences';
@@ -100,6 +101,7 @@ export const planner = new Elysia({ name: 'planner' })
.use(modelPriceRoutes)
.use(agentRunnerRoutes)
.use(agentChatRoutes)
+ .use(agentInvocationRoutes)
.use(dashboardRoutes)
.use(noteBoardRoutes)
.use(documentRoutes)
diff --git a/apps/web/messages/ar/teams.json b/apps/web/messages/ar/teams.json
index 15fe57f6..1986852b 100644
--- a/apps/web/messages/ar/teams.json
+++ b/apps/web/messages/ar/teams.json
@@ -410,8 +410,46 @@
"runDelay": "استنى قبل ما تبدأ",
"runDelayHint": "الوقت اللي تفضل فيه تعدّل على المهمة قبل ما الوكيل يبدأ. صفر يعني يبدأ على طول.",
"minutes": "دقيقة",
- "runner": "المنفّذ (runner)",
- "runnerHint": "العملية اللي على جهازك واللي بتنفّذ مهام الوكيل ده",
+ "connection": "الاتصال",
+ "connectionHint": "الوكيل بيستلم مهامه إزاي",
+ "deliveryRunner": "المنفّذ",
+ "deliveryRunnerHint": "جهازك بيطلب المهام",
+ "deliveryUrl": "نقطة الاستقبال",
+ "deliveryUrlHint": "الرابط بتاعك بيستقبل المهام",
+ "invocationUrl": "رابط نقطة الاستقبال",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "بيستقبل كل مهمة ورسالة شات كطلب POST موقّع.",
+ "invocationUnsaved": "احفظ علشان المهام تتبعت على الرابط ده.",
+ "invocationSecretOnSave": "احفظ الرابط عشان تاخد سرّ التوقيع.",
+ "invocationSecret": "سرّ التوقيع",
+ "invocationSecretHint": "استخدمه عشان تتأكد من الهيدر X-Itsaplan-Signature.",
+ "invocationSecretRotated": "سرّ التوقيع اتولّد من جديد",
+ "invocationRotate": "إعادة توليد السرّ",
+ "invocationRotateTitle": "إعادة توليد سرّ التوقيع؟",
+ "invocationRotateMessage": "الطلبات بتاعة <v>{name}</v> هتستخدم السرّ الجديد على طول. حدّث نقطة الاستقبال، وإلا هترفض المهام الجاية.",
+ "invocationTest": "طلب تجريبي",
+ "invocationTestHint": "بيبعت ping موقّع على الرابط المحفوظ.",
+ "invocationTestSend": "ابعت تجربة",
+ "invocationTestSending": "بيتبعت…",
+ "invocationTestOk": "ردّ بـ {status} في {ms} ms",
+ "invocationTestRefused": "ردّ بـ {status}. المتوقع 2xx.",
+ "invocationTestTimeout": "مفيش رد في الوقت المناسب. رد الأول، وبعدين اشتغل.",
+ "invocationTestUnreachable": "مقدرناش نوصل لنقطة الاستقبال",
+ "invocationHelpOpen": "إزاي تعمل نقطة الاستقبال",
+ "invocationHelpTitle": "إزاي تستلم المهام على رابط",
+ "invocationHelpVerify": "اتأكد من التوقيع",
+ "invocationHelpVerifyHint": "HMAC-SHA256 للتوقيت ونقطة والـ body الخام، والمفتاح هو سرّ التوقيع. ارفض أي طلب أقدم من خمس دقايق.",
+ "invocationHelpAccept": "ردّ بـ 2xx على طول",
+ "invocationHelpAcceptHint": "اشتغل بعد ما ترد. لو رديت بأي حالة تانية، المهمة هتتبعت تاني بعدين، ورسالة الشات هتفشل على طول.",
+ "invocationHelpPayload": "اقرا المهمة",
+ "invocationHelpPayloadHint": "حقل event بيقول إيه اللي وصل: مهمة، رسالة شات، أو ping تجريبي.",
+ "invocationHelpTabRun": "مهمة",
+ "invocationHelpTabChat": "رسالة شات",
+ "invocationHelpTabPing": "ping تجريبي",
+ "invocationHelpReport": "ابعت النتيجة بمفتاح الوكيل",
+ "invocationHelpReportHint": "وانت شغّال ابعت heartbeat كل 5 دقايق على الأقل. وبعدين ابعت النتيجة. ممكن تبعت رد الشات على أجزاء.",
+ "invocationHelpTest": "ابعت طلب تجريبي",
+ "invocationHelpTestHint": "قسم الاتصال هيوريك نقطة الاستقبال ردّت إزاي.",
"runnerWayCli": "أداة المنفّذ (runner CLI)",
"runnerWayCliHint": "حزمة npm بتاعتنا. وجّهها على وكيل برمجة، وهي بتسأل على المهام وترجّع النتيجة. محتاجة ملف إعدادات فيه مفتاح الوكيل.",
"runnerWayApi": "كودك إنت",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "بتاعك إنت",
"runnerHelpPiAdapter": "بي يقرأ .mcp.json عن طريق إضافة. ثبّتها مرة واحدة: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "اتأكد إنه متوصّل",
- "runnerHelpCheckHint": "قسم المنفّذ هيبان فيه «شغّال».",
+ "runnerHelpCheckHint": "قسم الاتصال هيبان فيه «شغّال».",
"runnerOnline": "المنفّذ شغّال",
"runnerOffline": "المنفّذ مش شغّال",
"runnerNever": "مفيش منفّذ لسه",
@@ -442,6 +480,8 @@
"runnerStateOffline": "مش شغّال",
"runnerStateNone": "مش متوصّل",
"runnerSeen": "آخر ظهور من {time}",
+ "runnerStateUrl": "نقطة استقبال",
+ "runnerUrl": "بيستلم المهام على رابطه",
"actions": "الإجراءات",
"actionsHint": "اللي الوكيل يقدر يعمله في المشروع",
"searchActions": "بحث في الإجراءات",
diff --git a/apps/web/messages/en/teams.json b/apps/web/messages/en/teams.json
index 2a6889ad..51a29197 100644
--- a/apps/web/messages/en/teams.json
+++ b/apps/web/messages/en/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Wait before starting",
"runDelayHint": "Time to keep editing the issue before the agent starts. 0 starts at once.",
"minutes": "min",
- "runner": "Runner",
- "runnerHint": "The process on your machine that executes this agent's tasks",
+ "connection": "Connection",
+ "connectionHint": "How the agent gets its tasks",
+ "deliveryRunner": "Runner",
+ "deliveryRunnerHint": "Your machine asks for tasks",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "Your URL receives the tasks",
+ "invocationUrl": "Endpoint URL",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Gets each task and chat message as a signed POST request.",
+ "invocationUnsaved": "Save to send tasks to this URL.",
+ "invocationSecretOnSave": "Save the URL to get the signing secret.",
+ "invocationSecret": "Signing secret",
+ "invocationSecretHint": "Use it to check the X-Itsaplan-Signature header.",
+ "invocationSecretRotated": "Signing secret regenerated",
+ "invocationRotate": "Regenerate secret",
+ "invocationRotateTitle": "Regenerate the signing secret?",
+ "invocationRotateMessage": "Requests for <v>{name}</v> switch to the new secret right away. Update your endpoint, or it will refuse the next tasks.",
+ "invocationTest": "Test request",
+ "invocationTestHint": "Sends a signed ping to the saved URL.",
+ "invocationTestSend": "Send test",
+ "invocationTestSending": "Sending…",
+ "invocationTestOk": "Answered {status} in {ms} ms",
+ "invocationTestRefused": "Answered {status}. Expected 2xx.",
+ "invocationTestTimeout": "No answer in time. Answer first, then do the work.",
+ "invocationTestUnreachable": "Couldn't reach the endpoint",
+ "invocationHelpOpen": "How to build the endpoint",
+ "invocationHelpTitle": "How to receive tasks at a URL",
+ "invocationHelpVerify": "Check the signature",
+ "invocationHelpVerifyHint": "HMAC-SHA256 of the timestamp, a dot and the raw body, keyed with the signing secret. Refuse requests older than five minutes.",
+ "invocationHelpAccept": "Answer 2xx right away",
+ "invocationHelpAcceptHint": "Do the work after you answer. With any other status, a task comes again later, and a chat message fails at once.",
+ "invocationHelpPayload": "Read the task",
+ "invocationHelpPayloadHint": "The event field says what arrived: a task, a chat message, or a test ping.",
+ "invocationHelpTabRun": "Task",
+ "invocationHelpTabChat": "Chat message",
+ "invocationHelpTabPing": "Test ping",
+ "invocationHelpReport": "Send the result with the agent's key",
+ "invocationHelpReportHint": "While you work, send a heartbeat at least every 5 minutes. Then send the result. You can send a chat answer in parts.",
+ "invocationHelpTest": "Send a test request",
+ "invocationHelpTestHint": "The Connection section shows how your endpoint answered.",
"runnerWayCli": "Runner CLI",
"runnerWayCliHint": "Our npm package. Point it at a coding agent, it polls for tasks and reports back. Needs a config file with the agent's key.",
"runnerWayApi": "Your own code",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Your own",
"runnerHelpPiAdapter": "Pi reads .mcp.json through an extension. Install it once: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Check it is connected",
- "runnerHelpCheckHint": "The Runner section shows Online.",
+ "runnerHelpCheckHint": "The Connection section shows Online.",
"runnerOnline": "Runner online",
"runnerOffline": "Runner offline",
"runnerNever": "No runner yet",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Offline",
"runnerStateNone": "Not connected",
"runnerSeen": "Last seen {time} ago",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Gets tasks at its URL",
"actions": "Actions",
"actionsHint": "What the agent can do in the project",
"searchActions": "Search actions",
diff --git a/apps/web/messages/es-ES/teams.json b/apps/web/messages/es-ES/teams.json
index bfdd1197..1705e539 100644
--- a/apps/web/messages/es-ES/teams.json
+++ b/apps/web/messages/es-ES/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Esperar antes de empezar",
"runDelayHint": "Tiempo para seguir editando el ticket antes de que el agente empiece. 0 empieza de inmediato.",
"minutes": "min",
- "runner": "Ejecutor",
- "runnerHint": "El proceso en tu máquina que ejecuta las tareas de este agente",
+ "connection": "Conexión",
+ "connectionHint": "Cómo recibe el agente sus tareas",
+ "deliveryRunner": "Ejecutor",
+ "deliveryRunnerHint": "Tu máquina pide las tareas",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "Tu URL recibe las tareas",
+ "invocationUrl": "URL del endpoint",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Recibe cada tarea y mensaje de chat como un POST firmado.",
+ "invocationUnsaved": "Guarda para enviar las tareas a esta URL.",
+ "invocationSecretOnSave": "Guarda la URL para obtener el secreto de firma.",
+ "invocationSecret": "Secreto de firma",
+ "invocationSecretHint": "Úsalo para comprobar la cabecera X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Secreto de firma regenerado",
+ "invocationRotate": "Regenerar el secreto",
+ "invocationRotateTitle": "¿Regenerar el secreto de firma?",
+ "invocationRotateMessage": "Las solicitudes para <v>{name}</v> pasan al secreto nuevo de inmediato. Actualiza tu endpoint o rechazará las próximas tareas.",
+ "invocationTest": "Solicitud de prueba",
+ "invocationTestHint": "Envía un ping firmado a la URL guardada.",
+ "invocationTestSend": "Enviar prueba",
+ "invocationTestSending": "Enviando…",
+ "invocationTestOk": "Respondió {status} en {ms} ms",
+ "invocationTestRefused": "Respondió {status}. Se esperaba 2xx.",
+ "invocationTestTimeout": "Sin respuesta a tiempo. Responde primero y luego haz el trabajo.",
+ "invocationTestUnreachable": "No se pudo contactar con el endpoint",
+ "invocationHelpOpen": "Cómo crear el endpoint",
+ "invocationHelpTitle": "Cómo recibir tareas en una URL",
+ "invocationHelpVerify": "Comprueba la firma",
+ "invocationHelpVerifyHint": "HMAC-SHA256 de la marca de tiempo, un punto y el cuerpo sin procesar, con el secreto de firma como clave. Rechaza las solicitudes de hace más de cinco minutos.",
+ "invocationHelpAccept": "Responde 2xx enseguida",
+ "invocationHelpAcceptHint": "Trabaja después de responder. Con cualquier otro estado, la tarea vuelve más tarde y un mensaje de chat falla al instante.",
+ "invocationHelpPayload": "Lee la tarea",
+ "invocationHelpPayloadHint": "El campo event indica qué llegó: una tarea, un mensaje de chat o un ping de prueba.",
+ "invocationHelpTabRun": "Tarea",
+ "invocationHelpTabChat": "Mensaje de chat",
+ "invocationHelpTabPing": "Ping de prueba",
+ "invocationHelpReport": "Envía el resultado con la clave del agente",
+ "invocationHelpReportHint": "Mientras trabajas, envía un heartbeat al menos cada 5 minutos. Luego envía el resultado. Puedes enviar una respuesta de chat por partes.",
+ "invocationHelpTest": "Envía una solicitud de prueba",
+ "invocationHelpTestHint": "La sección Conexión muestra cómo respondió tu endpoint.",
"runnerWayCli": "CLI del ejecutor",
"runnerWayCliHint": "Nuestro paquete de npm. Apúntalo a un agente de codificación, sondea tareas y informa de vuelta. Necesita un fichero de configuración con la clave del agente.",
"runnerWayApi": "Tu propio código",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "El tuyo propio",
"runnerHelpPiAdapter": "Pi lee .mcp.json mediante una extensión. Instálala una vez: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Comprobar que está conectado",
- "runnerHelpCheckHint": "La sección Ejecutor muestra En línea.",
+ "runnerHelpCheckHint": "La sección Conexión muestra En línea.",
"runnerOnline": "Ejecutor en línea",
"runnerOffline": "Ejecutor fuera de línea",
"runnerNever": "Todavía no hay ejecutor",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Fuera de línea",
"runnerStateNone": "No conectado",
"runnerSeen": "Última ves visto hace {time}",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Recibe tareas en su URL",
"actions": "Acciones",
"actionsHint": "Lo que el agente puede hacer en el proyecto",
"searchActions": "Buscar acciones",
diff --git a/apps/web/messages/fa/teams.json b/apps/web/messages/fa/teams.json
index b243f325..f25e9c77 100644
--- a/apps/web/messages/fa/teams.json
+++ b/apps/web/messages/fa/teams.json
@@ -410,8 +410,46 @@
"runDelay": "انتظار قبل از شروع",
"runDelayHint": "زمانی که می‌توانید تسک را ویرایش کنید تا ایجنت شروع کند. ۰ یعنی بلافاصله شروع می‌شود.",
"minutes": "دقیقه",
- "runner": "رانر",
- "runnerHint": "فرایندی روی دستگاه شما که وظیفه‌های این ایجنت را اجرا می‌کند",
+ "connection": "اتصال",
+ "connectionHint": "ایجنت وظیفه‌هایش را چطور دریافت می‌کند",
+ "deliveryRunner": "رانر",
+ "deliveryRunnerHint": "دستگاه شما وظیفه‌ها را درخواست می‌کند",
+ "deliveryUrl": "اندپوینت",
+ "deliveryUrlHint": "URL شما وظیفه‌ها را دریافت می‌کند",
+ "invocationUrl": "URL اندپوینت",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "هر وظیفه و پیام چت را به‌صورت درخواست POST امضاشده دریافت می‌کند.",
+ "invocationUnsaved": "ذخیره کنید تا وظیفه‌ها به این URL ارسال شوند.",
+ "invocationSecretOnSave": "URL را ذخیره کنید تا راز امضا را بگیرید.",
+ "invocationSecret": "راز امضا",
+ "invocationSecretHint": "سرایند X-Itsaplan-Signature را با آن بررسی کنید.",
+ "invocationSecretRotated": "راز امضا بازتولید شد",
+ "invocationRotate": "بازتولید راز",
+ "invocationRotateTitle": "راز امضا بازتولید شود؟",
+ "invocationRotateMessage": "درخواست‌های <v>{name}</v> بی‌درنگ از راز جدید استفاده می‌کنند. اندپوینت خود را به‌روز کنید، وگرنه وظیفه‌های بعدی را رد می‌کند.",
+ "invocationTest": "درخواست آزمایشی",
+ "invocationTestHint": "یک ping امضاشده به URL ذخیره‌شده می‌فرستد.",
+ "invocationTestSend": "ارسال آزمایش",
+ "invocationTestSending": "در حال ارسال…",
+ "invocationTestOk": "پاسخ {status} در {ms} میلی‌ثانیه",
+ "invocationTestRefused": "پاسخ {status}. انتظار می‌رفت 2xx باشد.",
+ "invocationTestTimeout": "پاسخی به‌موقع نرسید. اول پاسخ دهید، بعد کار را انجام دهید.",
+ "invocationTestUnreachable": "دسترسی به اندپوینت ممکن نشد",
+ "invocationHelpOpen": "ساخت اندپوینت",
+ "invocationHelpTitle": "دریافت وظیفه‌ها روی یک URL",
+ "invocationHelpVerify": "امضا را بررسی کنید",
+ "invocationHelpVerifyHint": "HMAC-SHA256 از برچسب زمان، یک نقطه و بدنهٔ خام، با راز امضا به‌عنوان کلید. درخواست‌های قدیمی‌تر از پنج دقیقه را رد کنید.",
+ "invocationHelpAccept": "فوراً با 2xx پاسخ دهید",
+ "invocationHelpAcceptHint": "بعد از پاسخ کار را انجام دهید. با هر وضعیت دیگری، وظیفه بعداً دوباره ارسال می‌شود و پیام چت بی‌درنگ ناموفق می‌شود.",
+ "invocationHelpPayload": "وظیفه را بخوانید",
+ "invocationHelpPayloadHint": "فیلد event می‌گوید چه رسیده: وظیفه، پیام چت یا ping آزمایشی.",
+ "invocationHelpTabRun": "وظیفه",
+ "invocationHelpTabChat": "پیام چت",
+ "invocationHelpTabPing": "ping آزمایشی",
+ "invocationHelpReport": "نتیجه را با کلید ایجنت بفرستید",
+ "invocationHelpReportHint": "در حین کار دست‌کم هر ۵ دقیقه یک heartbeat بفرستید. سپس نتیجه را بفرستید. پاسخ چت را می‌توان تکه‌تکه فرستاد.",
+ "invocationHelpTest": "یک درخواست آزمایشی بفرستید",
+ "invocationHelpTestHint": "بخش اتصال نشان می‌دهد اندپوینت شما چه پاسخی داد.",
"runnerWayCli": "CLI رانر",
"runnerWayCliHint": "پکیج npm ما. آن را به یک ایجنت کدنویسی وصل کنید؛ هر چند وقت یک‌بار صف وظیفه‌ها را بررسی می‌کند و نتیجه را برمی‌گرداند. به یک فایل پیکربندی با کلید ایجنت نیاز دارد.",
"runnerWayApi": "کد خودتان",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "خودتان",
"runnerHelpPiAdapter": "Pi فایل .mcp.json را از طریق یک افزونه می‌خواند. یک بار نصبش کنید: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "بررسی اتصال",
- "runnerHelpCheckHint": "بخش رانر وضعیت «آنلاین» را نشان می‌دهد.",
+ "runnerHelpCheckHint": "بخش اتصال وضعیت «آنلاین» را نشان می‌دهد.",
"runnerOnline": "رانر آنلاین",
"runnerOffline": "رانر آفلاین",
"runnerNever": "هنوز رانری نیست",
@@ -442,6 +480,8 @@
"runnerStateOffline": "آفلاین",
"runnerStateNone": "متصل نیست",
"runnerSeen": "آخرین بازدید {time} پیش",
+ "runnerStateUrl": "اندپوینت",
+ "runnerUrl": "وظیفه‌ها را روی URL خود دریافت می‌کند",
"actions": "اکشن‌ها",
"actionsHint": "کارهایی که ایجنت می‌تواند در پروژه انجام دهد",
"searchActions": "جستجوی اکشن‌ها",
diff --git a/apps/web/messages/fr/teams.json b/apps/web/messages/fr/teams.json
index 8f72fdb4..7726db31 100644
--- a/apps/web/messages/fr/teams.json
+++ b/apps/web/messages/fr/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Attendre avant de démarrer",
"runDelayHint": "Le temps laissé pour continuer à modifier le ticket avant que l'agent démarre. 0 démarre immédiatement.",
"minutes": "min",
- "runner": "Runner",
- "runnerHint": "Le processus sur votre machine qui exécute les tâches de cet agent",
+ "connection": "Connexion",
+ "connectionHint": "Comment l'agent reçoit ses tâches",
+ "deliveryRunner": "Runner",
+ "deliveryRunnerHint": "Votre machine demande les tâches",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "Votre URL reçoit les tâches",
+ "invocationUrl": "URL de l'endpoint",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Reçoit chaque tâche et chaque message de chat en POST signé.",
+ "invocationUnsaved": "Enregistrez pour envoyer les tâches à cette URL.",
+ "invocationSecretOnSave": "Enregistrez l'URL pour obtenir le secret de signature.",
+ "invocationSecret": "Secret de signature",
+ "invocationSecretHint": "Utilisez-le pour vérifier l'en-tête X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Secret de signature régénéré",
+ "invocationRotate": "Régénérer le secret",
+ "invocationRotateTitle": "Régénérer le secret de signature ?",
+ "invocationRotateMessage": "Les requêtes pour <v>{name}</v> passent tout de suite au nouveau secret. Mettez à jour votre endpoint, sinon il refusera les prochaines tâches.",
+ "invocationTest": "Requête de test",
+ "invocationTestHint": "Envoie un ping signé à l'URL enregistrée.",
+ "invocationTestSend": "Envoyer un test",
+ "invocationTestSending": "Envoi…",
+ "invocationTestOk": "Réponse {status} en {ms} ms",
+ "invocationTestRefused": "Réponse {status}. 2xx attendu.",
+ "invocationTestTimeout": "Pas de réponse à temps. Répondez d'abord, puis faites le travail.",
+ "invocationTestUnreachable": "Impossible de joindre l'endpoint",
+ "invocationHelpOpen": "Comment créer l'endpoint",
+ "invocationHelpTitle": "Recevoir les tâches sur une URL",
+ "invocationHelpVerify": "Vérifiez la signature",
+ "invocationHelpVerifyHint": "HMAC-SHA256 de l'horodatage, d'un point et du corps brut, avec le secret de signature comme clé. Refusez les requêtes de plus de cinq minutes.",
+ "invocationHelpAccept": "Répondez 2xx tout de suite",
+ "invocationHelpAcceptHint": "Travaillez après avoir répondu. Avec tout autre statut, une tâche revient plus tard et un message de chat échoue aussitôt.",
+ "invocationHelpPayload": "Lisez la tâche",
+ "invocationHelpPayloadHint": "Le champ event indique ce qui arrive : une tâche, un message de chat ou un ping de test.",
+ "invocationHelpTabRun": "Tâche",
+ "invocationHelpTabChat": "Message de chat",
+ "invocationHelpTabPing": "Ping de test",
+ "invocationHelpReport": "Envoyez le résultat avec la clé de l'agent",
+ "invocationHelpReportHint": "Pendant le travail, envoyez un heartbeat au moins toutes les 5 minutes. Puis envoyez le résultat. Vous pouvez envoyer une réponse de chat en plusieurs parties.",
+ "invocationHelpTest": "Envoyez une requête de test",
+ "invocationHelpTestHint": "La section Connexion montre comment votre endpoint a répondu.",
"runnerWayCli": "CLI du runner",
"runnerWayCliHint": "Notre paquet npm. Faites-le pointer vers un agent de code : il interroge les tâches et rend compte. Nécessite un fichier de configuration contenant la clé de l'agent.",
"runnerWayApi": "Votre propre code",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Le vôtre",
"runnerHelpPiAdapter": "Pi lit .mcp.json via une extension. Installez-la une fois : pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Vérifiez qu'il est connecté",
- "runnerHelpCheckHint": "La section Runner affiche En ligne.",
+ "runnerHelpCheckHint": "La section Connexion affiche En ligne.",
"runnerOnline": "Runner en ligne",
"runnerOffline": "Runner hors ligne",
"runnerNever": "Aucun runner pour l'instant",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Hors ligne",
"runnerStateNone": "Non connecté",
"runnerSeen": "Vu il y a {time}",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Reçoit les tâches sur son URL",
"actions": "Actions",
"actionsHint": "Ce que l'agent peut faire dans le projet",
"searchActions": "Rechercher une action",
diff --git a/apps/web/messages/id/teams.json b/apps/web/messages/id/teams.json
index db7a3d49..e49930a1 100644
--- a/apps/web/messages/id/teams.json
+++ b/apps/web/messages/id/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Tunggu sebelum memulai",
"runDelayHint": "Waktu untuk terus mengedit issue sebelum agen dimulai. 0 langsung memulai.",
"minutes": "mnt",
- "runner": "Runner",
- "runnerHint": "Proses di komputer Anda yang menjalankan tugas agen ini",
+ "connection": "Koneksi",
+ "connectionHint": "Cara agen menerima tugasnya",
+ "deliveryRunner": "Runner",
+ "deliveryRunnerHint": "Komputer Anda meminta tugas",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "URL Anda menerima tugas",
+ "invocationUrl": "URL endpoint",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Menerima setiap tugas dan pesan chat sebagai POST yang ditandatangani.",
+ "invocationUnsaved": "Simpan agar tugas dikirim ke URL ini.",
+ "invocationSecretOnSave": "Simpan URL untuk mendapatkan rahasia tanda tangan.",
+ "invocationSecret": "Rahasia tanda tangan",
+ "invocationSecretHint": "Gunakan untuk memeriksa header X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Rahasia tanda tangan dibuat ulang",
+ "invocationRotate": "Buat ulang rahasia",
+ "invocationRotateTitle": "Buat ulang rahasia tanda tangan?",
+ "invocationRotateMessage": "Permintaan untuk <v>{name}</v> langsung memakai rahasia baru. Perbarui endpoint Anda, atau endpoint akan menolak tugas berikutnya.",
+ "invocationTest": "Permintaan uji",
+ "invocationTestHint": "Mengirim ping bertanda tangan ke URL yang disimpan.",
+ "invocationTestSend": "Kirim uji",
+ "invocationTestSending": "Mengirim…",
+ "invocationTestOk": "Menjawab {status} dalam {ms} ms",
+ "invocationTestRefused": "Menjawab {status}. Seharusnya 2xx.",
+ "invocationTestTimeout": "Tidak ada jawaban tepat waktu. Jawab dulu, lalu kerjakan tugasnya.",
+ "invocationTestUnreachable": "Tidak dapat menghubungi endpoint",
+ "invocationHelpOpen": "Cara membuat endpoint",
+ "invocationHelpTitle": "Cara menerima tugas di URL",
+ "invocationHelpVerify": "Periksa tanda tangan",
+ "invocationHelpVerifyHint": "HMAC-SHA256 dari stempel waktu, titik, dan body mentah, dengan rahasia tanda tangan sebagai kunci. Tolak permintaan yang lebih lama dari lima menit.",
+ "invocationHelpAccept": "Segera jawab 2xx",
+ "invocationHelpAcceptHint": "Kerjakan setelah Anda menjawab. Dengan status lain, tugas dikirim lagi nanti dan pesan chat langsung gagal.",
+ "invocationHelpPayload": "Baca tugasnya",
+ "invocationHelpPayloadHint": "Kolom event menyebutkan apa yang tiba: tugas, pesan chat, atau ping uji.",
+ "invocationHelpTabRun": "Tugas",
+ "invocationHelpTabChat": "Pesan chat",
+ "invocationHelpTabPing": "Ping uji",
+ "invocationHelpReport": "Kirim hasil dengan kunci agen",
+ "invocationHelpReportHint": "Selama bekerja, kirim heartbeat setidaknya setiap 5 menit. Lalu kirim hasilnya. Jawaban chat bisa dikirim bertahap.",
+ "invocationHelpTest": "Kirim permintaan uji",
+ "invocationHelpTestHint": "Bagian Koneksi menampilkan jawaban endpoint Anda.",
"runnerWayCli": "CLI Runner",
"runnerWayCliHint": "Paket npm kami. Hubungkan ke agen coding; paket ini akan memeriksa tugas secara berkala dan melaporkan hasilnya. Memerlukan file konfigurasi dengan kunci agen.",
"runnerWayApi": "Kode Anda sendiri",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Milik Anda sendiri",
"runnerHelpPiAdapter": "Pi membaca .mcp.json melalui ekstensi. Pasang sekali: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Periksa apakah terhubung",
- "runnerHelpCheckHint": "Bagian Runner menampilkan Online.",
+ "runnerHelpCheckHint": "Bagian Koneksi menampilkan Online.",
"runnerOnline": "Runner online",
"runnerOffline": "Runner offline",
"runnerNever": "Belum ada runner",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Offline",
"runnerStateNone": "Tidak terhubung",
"runnerSeen": "Terakhir terlihat {time} lalu",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Menerima tugas di URL-nya",
"actions": "Tindakan",
"actionsHint": "Apa yang dapat dilakukan agen dalam proyek",
"searchActions": "Cari tindakan",
diff --git a/apps/web/messages/ko/teams.json b/apps/web/messages/ko/teams.json
index e159f8a8..a0ae41aa 100644
--- a/apps/web/messages/ko/teams.json
+++ b/apps/web/messages/ko/teams.json
@@ -410,8 +410,46 @@
"runDelay": "실행 전 대기",
"runDelayHint": "AI 에이전트가 실행되기 전에 이슈를 계속 편집할 수 있는 대기 시간입니다. 0이면 즉시 실행됩니다.",
"minutes": "분",
- "runner": "러너",
- "runnerHint": "이 AI 에이전트의 작업을 실행하는 머신의 프로세스",
+ "connection": "연결",
+ "connectionHint": "AI 에이전트가 작업을 받는 방식",
+ "deliveryRunner": "러너",
+ "deliveryRunnerHint": "내 머신이 작업을 요청합니다",
+ "deliveryUrl": "엔드포인트",
+ "deliveryUrlHint": "내 URL이 작업을 받습니다",
+ "invocationUrl": "엔드포인트 URL",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "모든 작업과 채팅 메시지를 서명된 POST 요청으로 받습니다.",
+ "invocationUnsaved": "저장해야 이 URL로 작업이 전송됩니다.",
+ "invocationSecretOnSave": "URL을 저장해 서명 시크릿을 받으세요.",
+ "invocationSecret": "서명 시크릿",
+ "invocationSecretHint": "이 값으로 X-Itsaplan-Signature 헤더를 확인하세요.",
+ "invocationSecretRotated": "서명 시크릿을 다시 생성했습니다",
+ "invocationRotate": "시크릿 다시 생성",
+ "invocationRotateTitle": "서명 시크릿을 다시 생성할까요?",
+ "invocationRotateMessage": "<v>{name}</v>에 대한 요청은 바로 새 시크릿을 사용합니다. 엔드포인트를 업데이트하지 않으면 다음 작업을 거부합니다.",
+ "invocationTest": "테스트 요청",
+ "invocationTestHint": "저장된 URL로 서명된 ping을 보냅니다.",
+ "invocationTestSend": "테스트 보내기",
+ "invocationTestSending": "보내는 중…",
+ "invocationTestOk": "{ms}ms 만에 {status} 응답",
+ "invocationTestRefused": "{status} 응답. 2xx가 필요합니다.",
+ "invocationTestTimeout": "제시간에 응답이 없습니다. 먼저 응답하고 나서 작업하세요.",
+ "invocationTestUnreachable": "엔드포인트에 연결할 수 없습니다",
+ "invocationHelpOpen": "엔드포인트 만드는 방법",
+ "invocationHelpTitle": "URL로 작업을 받는 방법",
+ "invocationHelpVerify": "서명 확인",
+ "invocationHelpVerifyHint": "타임스탬프, 점, 원본 본문을 서명 시크릿으로 HMAC-SHA256 처리한 값입니다. 5분보다 오래된 요청은 거부하세요.",
+ "invocationHelpAccept": "바로 2xx로 응답",
+ "invocationHelpAcceptHint": "응답한 뒤에 작업하세요. 다른 상태로 응답하면 작업은 나중에 다시 전송되고, 채팅 메시지는 바로 실패합니다.",
+ "invocationHelpPayload": "작업 읽기",
+ "invocationHelpPayloadHint": "event 필드에 작업, 채팅 메시지, 테스트 ping 중 무엇인지 나옵니다.",
+ "invocationHelpTabRun": "작업",
+ "invocationHelpTabChat": "채팅 메시지",
+ "invocationHelpTabPing": "테스트 ping",
+ "invocationHelpReport": "AI 에이전트 키로 결과 보내기",
+ "invocationHelpReportHint": "작업 중에는 최소 5분마다 heartbeat를 보내세요. 그다음 결과를 보내세요. 채팅 답변은 나눠서 보낼 수 있습니다.",
+ "invocationHelpTest": "테스트 요청 보내기",
+ "invocationHelpTestHint": "연결 섹션에서 엔드포인트의 응답을 확인할 수 있습니다.",
"runnerWayCli": "Runner CLI",
"runnerWayCliHint": "npm 패키지를 사용합니다. 코딩 에이전트와 연결하면 작업을 주기적으로 확인하고 결과를 전송합니다. AI 에이전트 키가 포함된 설정 파일이 필요합니다.",
"runnerWayApi": "직접 구현",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "직접 설정",
"runnerHelpPiAdapter": "Pi는 확장을 통해 .mcp.json을 읽습니다. 한 번만 설치하세요: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "연결 확인",
- "runnerHelpCheckHint": "러너 섹션에 온라인으로 표시되는지 확인하세요.",
+ "runnerHelpCheckHint": "연결 섹션에 온라인으로 표시되는지 확인하세요.",
"runnerOnline": "러너 온라인",
"runnerOffline": "러너 오프라인",
"runnerNever": "아직 연결된 러너 없음",
@@ -442,6 +480,8 @@
"runnerStateOffline": "오프라인",
"runnerStateNone": "연결되지 않음",
"runnerSeen": "마지막 연결: {time} 전",
+ "runnerStateUrl": "엔드포인트",
+ "runnerUrl": "URL로 작업을 받습니다",
"actions": "작업 권한",
"actionsHint": "AI 에이전트가 프로젝트에서 수행할 수 있는 작업",
"searchActions": "작업 권한 검색",
diff --git a/apps/web/messages/pt-BR/teams.json b/apps/web/messages/pt-BR/teams.json
index 09f94dee..ed0c1795 100644
--- a/apps/web/messages/pt-BR/teams.json
+++ b/apps/web/messages/pt-BR/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Esperar antes de começar",
"runDelayHint": "Tempo para continuar editando a issue antes do agente começar. 0 começa na hora.",
"minutes": "min",
- "runner": "Runner",
- "runnerHint": "O processo na sua máquina que executa as tarefas deste agente",
+ "connection": "Conexão",
+ "connectionHint": "Como o agente recebe as tarefas",
+ "deliveryRunner": "Runner",
+ "deliveryRunnerHint": "Sua máquina pede as tarefas",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "Sua URL recebe as tarefas",
+ "invocationUrl": "URL do endpoint",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Recebe cada tarefa e mensagem de chat como um POST assinado.",
+ "invocationUnsaved": "Salve para enviar as tarefas a esta URL.",
+ "invocationSecretOnSave": "Salve a URL para obter o segredo de assinatura.",
+ "invocationSecret": "Segredo de assinatura",
+ "invocationSecretHint": "Use-o para conferir o cabeçalho X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Segredo de assinatura regenerado",
+ "invocationRotate": "Regenerar segredo",
+ "invocationRotateTitle": "Regenerar o segredo de assinatura?",
+ "invocationRotateMessage": "As requisições para <v>{name}</v> passam a usar o novo segredo na hora. Atualize seu endpoint, ou ele vai recusar as próximas tarefas.",
+ "invocationTest": "Requisição de teste",
+ "invocationTestHint": "Envia um ping assinado para a URL salva.",
+ "invocationTestSend": "Enviar teste",
+ "invocationTestSending": "Enviando…",
+ "invocationTestOk": "Respondeu {status} em {ms} ms",
+ "invocationTestRefused": "Respondeu {status}. Esperado 2xx.",
+ "invocationTestTimeout": "Sem resposta a tempo. Responda primeiro e depois faça o trabalho.",
+ "invocationTestUnreachable": "Não foi possível alcançar o endpoint",
+ "invocationHelpOpen": "Como montar o endpoint",
+ "invocationHelpTitle": "Como receber tarefas em uma URL",
+ "invocationHelpVerify": "Confira a assinatura",
+ "invocationHelpVerifyHint": "HMAC-SHA256 do timestamp, um ponto e o corpo bruto, com o segredo de assinatura como chave. Recuse requisições com mais de cinco minutos.",
+ "invocationHelpAccept": "Responda 2xx na hora",
+ "invocationHelpAcceptHint": "Trabalhe depois de responder. Com qualquer outro status, a tarefa volta mais tarde e uma mensagem de chat falha na hora.",
+ "invocationHelpPayload": "Leia a tarefa",
+ "invocationHelpPayloadHint": "O campo event diz o que chegou: uma tarefa, uma mensagem de chat ou um ping de teste.",
+ "invocationHelpTabRun": "Tarefa",
+ "invocationHelpTabChat": "Mensagem de chat",
+ "invocationHelpTabPing": "Ping de teste",
+ "invocationHelpReport": "Envie o resultado com a chave do agente",
+ "invocationHelpReportHint": "Enquanto trabalha, envie um heartbeat pelo menos a cada 5 minutos. Depois envie o resultado. Você pode enviar uma resposta de chat em partes.",
+ "invocationHelpTest": "Envie uma requisição de teste",
+ "invocationHelpTestHint": "A seção Conexão mostra como o seu endpoint respondeu.",
"runnerWayCli": "CLI do runner",
"runnerWayCliHint": "Nosso pacote npm. Aponte-o para um agente de código, ele busca tarefas e reporta de volta. Precisa de um arquivo de configuração com a chave do agente.",
"runnerWayApi": "Seu próprio código",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "O seu",
"runnerHelpPiAdapter": "O Pi lê o .mcp.json por meio de uma extensão. Instale-a uma vez: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Verificar se está conectado",
- "runnerHelpCheckHint": "A seção Runner mostra Online.",
+ "runnerHelpCheckHint": "A seção Conexão mostra Online.",
"runnerOnline": "Runner online",
"runnerOffline": "Runner offline",
"runnerNever": "Nenhum runner ainda",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Offline",
"runnerStateNone": "Não conectado",
"runnerSeen": "Visto há {time}",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Recebe tarefas na sua URL",
"actions": "Ações",
"actionsHint": "O que o agente pode fazer no projeto",
"searchActions": "Buscar ações",
diff --git a/apps/web/messages/ru/teams.json b/apps/web/messages/ru/teams.json
index ea692262..4dfe660f 100644
--- a/apps/web/messages/ru/teams.json
+++ b/apps/web/messages/ru/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Пауза перед стартом",
"runDelayHint": "Время дописать задачу до старта агента. 0 — запуск сразу.",
"minutes": "мин",
- "runner": "Раннер",
- "runnerHint": "Процесс на вашей машине, который выполняет задачи этого агента",
+ "connection": "Подключение",
+ "connectionHint": "Как агент получает задачи",
+ "deliveryRunner": "Раннер",
+ "deliveryRunnerHint": "Ваша машина запрашивает задачи",
+ "deliveryUrl": "Эндпоинт",
+ "deliveryUrlHint": "Задачи приходят на ваш URL",
+ "invocationUrl": "URL эндпоинта",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Каждая задача и сообщение чата приходят сюда подписанным POST-запросом.",
+ "invocationUnsaved": "Сохраните, чтобы задачи шли на этот URL.",
+ "invocationSecretOnSave": "Сохраните URL, чтобы получить секрет подписи.",
+ "invocationSecret": "Секрет подписи",
+ "invocationSecretHint": "Проверяйте им заголовок X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Секрет подписи перевыпущен",
+ "invocationRotate": "Перевыпустить секрет",
+ "invocationRotateTitle": "Перевыпустить секрет подписи?",
+ "invocationRotateMessage": "Запросы для <v>{name}</v> сразу перейдут на новый секрет. Обновите его в эндпоинте, иначе он отклонит следующие задачи.",
+ "invocationTest": "Тестовый запрос",
+ "invocationTestHint": "Отправляет подписанный ping на сохранённый URL.",
+ "invocationTestSend": "Отправить тест",
+ "invocationTestSending": "Отправка…",
+ "invocationTestOk": "Ответ {status} за {ms} мс",
+ "invocationTestRefused": "Ответ {status}. Ожидался 2xx.",
+ "invocationTestTimeout": "Эндпоинт не ответил вовремя. Отвечайте сразу, а работу делайте потом.",
+ "invocationTestUnreachable": "Не удалось связаться с эндпоинтом",
+ "invocationHelpOpen": "Как сделать эндпоинт",
+ "invocationHelpTitle": "Как получать задачи по URL",
+ "invocationHelpVerify": "Проверьте подпись",
+ "invocationHelpVerifyHint": "HMAC-SHA256 от метки времени, точки и сырого тела запроса с секретом подписи в качестве ключа. Отклоняйте запросы старше пяти минут.",
+ "invocationHelpAccept": "Сразу ответьте 2xx",
+ "invocationHelpAcceptHint": "Работайте после ответа. При любом другом статусе задача придёт снова позже, а сообщение чата сразу завершится ошибкой.",
+ "invocationHelpPayload": "Прочитайте задачу",
+ "invocationHelpPayloadHint": "Поле event говорит, что пришло: задача, сообщение чата или тестовый ping.",
+ "invocationHelpTabRun": "Задача",
+ "invocationHelpTabChat": "Сообщение чата",
+ "invocationHelpTabPing": "Тестовый ping",
+ "invocationHelpReport": "Отправьте результат с ключом агента",
+ "invocationHelpReportHint": "Во время работы шлите heartbeat хотя бы раз в 5 минут. Потом отправьте результат. Ответ в чат можно слать частями.",
+ "invocationHelpTest": "Отправьте тестовый запрос",
+ "invocationHelpTestHint": "В секции «Подключение» будет видно, как ответил эндпоинт.",
"runnerWayCli": "Раннер CLI",
"runnerWayCliHint": "Наш npm-пакет. Указываете ему кодинг-агента — он забирает задачи и возвращает результат. Нужен файл конфигурации с ключом агента.",
"runnerWayApi": "Свой код",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Своя команда",
"runnerHelpPiAdapter": "Pi читает .mcp.json через расширение. Установите его один раз: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Проверьте связь",
- "runnerHelpCheckHint": "В секции «Раннер» появится «На связи».",
+ "runnerHelpCheckHint": "В секции «Подключение» появится «На связи».",
"runnerOnline": "Раннер на связи",
"runnerOffline": "Раннер офлайн",
"runnerNever": "Раннер не подключён",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Офлайн",
"runnerStateNone": "Не подключён",
"runnerSeen": "Был на связи {time} назад",
+ "runnerStateUrl": "Эндпоинт",
+ "runnerUrl": "Получает задачи по URL",
"actions": "Действия",
"actionsHint": "Что агент может делать в проекте",
"searchActions": "Поиск действий",
diff --git a/apps/web/messages/tr/teams.json b/apps/web/messages/tr/teams.json
index 2a616070..b4aa078a 100644
--- a/apps/web/messages/tr/teams.json
+++ b/apps/web/messages/tr/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Başlamadan önce bekle",
"runDelayHint": "Ajan başlamadan önce işi düzenlemeye devam etme süresi. 0 hemen başlatır.",
"minutes": "dk",
- "runner": "Runner",
- "runnerHint": "Makinenizde bu ajanın görevlerini yürüten işlem (process)",
+ "connection": "Bağlantı",
+ "connectionHint": "Ajanın görevleri nasıl aldığı",
+ "deliveryRunner": "Runner",
+ "deliveryRunnerHint": "Makineniz görevleri ister",
+ "deliveryUrl": "Endpoint",
+ "deliveryUrlHint": "Görevleri URL'niz alır",
+ "invocationUrl": "Endpoint URL'si",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Her görevi ve sohbet mesajını imzalı bir POST isteği olarak alır.",
+ "invocationUnsaved": "Görevleri bu URL'ye göndermek için kaydedin.",
+ "invocationSecretOnSave": "İmza gizli anahtarını almak için URL'yi kaydedin.",
+ "invocationSecret": "İmza gizli anahtarı",
+ "invocationSecretHint": "X-Itsaplan-Signature başlığını bununla kontrol edin.",
+ "invocationSecretRotated": "İmza gizli anahtarı yeniden oluşturuldu",
+ "invocationRotate": "Gizli anahtarı yeniden oluştur",
+ "invocationRotateTitle": "İmza gizli anahtarı yeniden oluşturulsun mu?",
+ "invocationRotateMessage": "<v>{name}</v> için istekler hemen yeni anahtara geçer. Endpoint'inizi güncelleyin, yoksa sonraki görevleri reddeder.",
+ "invocationTest": "Test isteği",
+ "invocationTestHint": "Kayıtlı URL'ye imzalı bir ping gönderir.",
+ "invocationTestSend": "Test gönder",
+ "invocationTestSending": "Gönderiliyor…",
+ "invocationTestOk": "{ms} ms içinde {status} yanıtı verdi",
+ "invocationTestRefused": "{status} yanıtı verdi. 2xx bekleniyordu.",
+ "invocationTestTimeout": "Zamanında yanıt gelmedi. Önce yanıt verin, işi sonra yapın.",
+ "invocationTestUnreachable": "Endpoint'e ulaşılamadı",
+ "invocationHelpOpen": "Endpoint nasıl oluşturulur",
+ "invocationHelpTitle": "Görevler bir URL'de nasıl alınır",
+ "invocationHelpVerify": "İmzayı kontrol edin",
+ "invocationHelpVerifyHint": "Zaman damgası, bir nokta ve ham gövdenin HMAC-SHA256 değeri. Anahtar, imza gizli anahtarıdır. Beş dakikadan eski istekleri reddedin.",
+ "invocationHelpAccept": "Hemen 2xx ile yanıt verin",
+ "invocationHelpAcceptHint": "İşi yanıt verdikten sonra yapın. Başka bir durum kodunda görev daha sonra yeniden gelir, sohbet mesajı ise hemen başarısız olur.",
+ "invocationHelpPayload": "Görevi okuyun",
+ "invocationHelpPayloadHint": "event alanı neyin geldiğini söyler: bir görev, bir sohbet mesajı veya bir test pingi.",
+ "invocationHelpTabRun": "Görev",
+ "invocationHelpTabChat": "Sohbet mesajı",
+ "invocationHelpTabPing": "Test pingi",
+ "invocationHelpReport": "Sonucu ajanın anahtarıyla gönderin",
+ "invocationHelpReportHint": "Çalışırken en az 5 dakikada bir heartbeat gönderin. Sonra sonucu gönderin. Sohbet yanıtını parça parça gönderebilirsiniz.",
+ "invocationHelpTest": "Test isteği gönderin",
+ "invocationHelpTestHint": "Bağlantı bölümü endpoint'inizin nasıl yanıt verdiğini gösterir.",
"runnerWayCli": "Runner CLI",
"runnerWayCliHint": "npm paketimiz. Bir kodlama ajanına yönlendirin; görevleri sorgular ve sonucu bildirir. Ajan anahtarını içeren bir yapılandırma dosyası gerektirir.",
"runnerWayApi": "Kendi kodunuz",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Kendinize ait",
"runnerHelpPiAdapter": "Pi, .mcp.json dosyasını bir uzantı üzerinden okur. Bir kez kurun: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Bağlandığını kontrol edin",
- "runnerHelpCheckHint": "Runner bölümü Çevrimiçi (Online) gösterir.",
+ "runnerHelpCheckHint": "Bağlantı bölümü Çevrimiçi (Online) gösterir.",
"runnerOnline": "Runner çevrimiçi",
"runnerOffline": "Runner çevrimdışı",
"runnerNever": "Henüz runner yok",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Çevrimdışı",
"runnerStateNone": "Bağlı değil",
"runnerSeen": "Son görülme: {time} önce",
+ "runnerStateUrl": "Endpoint",
+ "runnerUrl": "Görevleri kendi URL'sinde alır",
"actions": "Eylemler",
"actionsHint": "Ajanın projede yapabileceği işlemler",
"searchActions": "Eylemleri ara",
diff --git a/apps/web/messages/uk/teams.json b/apps/web/messages/uk/teams.json
index 2510620d..1f5fcf6e 100644
--- a/apps/web/messages/uk/teams.json
+++ b/apps/web/messages/uk/teams.json
@@ -410,8 +410,46 @@
"runDelay": "Пауза перед стартом",
"runDelayHint": "Час дописати задачу до старту агента. 0 — запуск одразу.",
"minutes": "хв",
- "runner": "Раннер",
- "runnerHint": "Процес на вашій машині, який виконує завдання цього агента",
+ "connection": "Підключення",
+ "connectionHint": "Як агент отримує завдання",
+ "deliveryRunner": "Раннер",
+ "deliveryRunnerHint": "Ваша машина запитує завдання",
+ "deliveryUrl": "Ендпоінт",
+ "deliveryUrlHint": "Завдання приходять на ваш URL",
+ "invocationUrl": "URL ендпоінта",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "Кожне завдання й повідомлення чату приходять сюди підписаним POST-запитом.",
+ "invocationUnsaved": "Збережіть, щоб завдання йшли на цей URL.",
+ "invocationSecretOnSave": "Збережіть URL, щоб отримати секрет підпису.",
+ "invocationSecret": "Секрет підпису",
+ "invocationSecretHint": "Перевіряйте ним заголовок X-Itsaplan-Signature.",
+ "invocationSecretRotated": "Секрет підпису перегенеровано",
+ "invocationRotate": "Перегенерувати секрет",
+ "invocationRotateTitle": "Перегенерувати секрет підпису?",
+ "invocationRotateMessage": "Запити для <v>{name}</v> одразу перейдуть на новий секрет. Оновіть його в ендпоінті, інакше він відхилить наступні завдання.",
+ "invocationTest": "Тестовий запит",
+ "invocationTestHint": "Надсилає підписаний ping на збережений URL.",
+ "invocationTestSend": "Надіслати тест",
+ "invocationTestSending": "Надсилання…",
+ "invocationTestOk": "Відповідь {status} за {ms} мс",
+ "invocationTestRefused": "Відповідь {status}. Очікувався 2xx.",
+ "invocationTestTimeout": "Ендпоінт не відповів вчасно. Відповідайте одразу, а роботу робіть потім.",
+ "invocationTestUnreachable": "Не вдалося зв'язатися з ендпоінтом",
+ "invocationHelpOpen": "Як зробити ендпоінт",
+ "invocationHelpTitle": "Як отримувати завдання за URL",
+ "invocationHelpVerify": "Перевірте підпис",
+ "invocationHelpVerifyHint": "HMAC-SHA256 від мітки часу, крапки й сирого тіла запиту з секретом підпису як ключем. Відхиляйте запити, старші за п'ять хвилин.",
+ "invocationHelpAccept": "Одразу відповідайте 2xx",
+ "invocationHelpAcceptHint": "Працюйте після відповіді. За будь-якого іншого статусу завдання прийде знову пізніше, а повідомлення чату одразу завершиться помилкою.",
+ "invocationHelpPayload": "Прочитайте завдання",
+ "invocationHelpPayloadHint": "Поле event каже, що прийшло: завдання, повідомлення чату чи тестовий ping.",
+ "invocationHelpTabRun": "Завдання",
+ "invocationHelpTabChat": "Повідомлення чату",
+ "invocationHelpTabPing": "Тестовий ping",
+ "invocationHelpReport": "Надішліть результат із ключем агента",
+ "invocationHelpReportHint": "Під час роботи надсилайте heartbeat щонайменше раз на 5 хвилин. Потім надішліть результат. Відповідь у чат можна надсилати частинами.",
+ "invocationHelpTest": "Надішліть тестовий запит",
+ "invocationHelpTestHint": "У секції «Підключення» буде видно, як відповів ендпоінт.",
"runnerWayCli": "Раннер CLI",
"runnerWayCliHint": "Наш npm-пакет. Указуєте йому кодинг-агента — він забирає задачі та повертає результат. Потрібен файл конфігурації з ключем агента.",
"runnerWayApi": "Власний код",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "Своя команда",
"runnerHelpPiAdapter": "Pi читає .mcp.json через розширення. Встановіть його один раз: pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "Перевірте зв'язок",
- "runnerHelpCheckHint": "У секції «Раннер» з'явиться «На зв'язку».",
+ "runnerHelpCheckHint": "У секції «Підключення» з'явиться «На зв'язку».",
"runnerOnline": "Раннер на зв'язку",
"runnerOffline": "Раннер офлайн",
"runnerNever": "Раннер не підключено",
@@ -442,6 +480,8 @@
"runnerStateOffline": "Офлайн",
"runnerStateNone": "Не підключено",
"runnerSeen": "Востаннє на зв'язку {time} тому",
+ "runnerStateUrl": "Ендпоінт",
+ "runnerUrl": "Отримує завдання за URL",
"actions": "Дії",
"actionsHint": "Що агент може робити в проєкті",
"searchActions": "Пошук дій",
diff --git a/apps/web/messages/zh-CN/teams.json b/apps/web/messages/zh-CN/teams.json
index d4a22519..0b2ee7da 100644
--- a/apps/web/messages/zh-CN/teams.json
+++ b/apps/web/messages/zh-CN/teams.json
@@ -410,8 +410,46 @@
"runDelay": "启动前等待",
"runDelayHint": "代理启动前继续编辑事项的时间。0 表示立即开始。",
"minutes": "分钟",
- "runner": "运行器",
- "runnerHint": "在你的机器上执行该智能体任务的进程",
+ "connection": "连接",
+ "connectionHint": "智能体如何接收任务",
+ "deliveryRunner": "运行器",
+ "deliveryRunnerHint": "你的机器请求任务",
+ "deliveryUrl": "端点",
+ "deliveryUrlHint": "你的 URL 接收任务",
+ "invocationUrl": "端点 URL",
+ "invocationUrlPlaceholder": "https://example.com/agent",
+ "invocationUrlHint": "以签名的 POST 请求接收每个任务和聊天消息。",
+ "invocationUnsaved": "保存后任务才会发送到这个 URL。",
+ "invocationSecretOnSave": "保存 URL 以获取签名密钥。",
+ "invocationSecret": "签名密钥",
+ "invocationSecretHint": "用它校验 X-Itsaplan-Signature 请求头。",
+ "invocationSecretRotated": "签名密钥已重新生成",
+ "invocationRotate": "重新生成密钥",
+ "invocationRotateTitle": "重新生成签名密钥?",
+ "invocationRotateMessage": "发给 <v>{name}</v> 的请求会立即改用新密钥签名。请更新你的端点,否则它会拒绝后续任务。",
+ "invocationTest": "测试请求",
+ "invocationTestHint": "向已保存的 URL 发送一个签名的 ping。",
+ "invocationTestSend": "发送测试",
+ "invocationTestSending": "发送中…",
+ "invocationTestOk": "{ms} 毫秒内返回 {status}",
+ "invocationTestRefused": "返回 {status},应为 2xx。",
+ "invocationTestTimeout": "未在规定时间内响应。请先响应,再开始工作。",
+ "invocationTestUnreachable": "无法连接到端点",
+ "invocationHelpOpen": "如何搭建端点",
+ "invocationHelpTitle": "如何通过 URL 接收任务",
+ "invocationHelpVerify": "校验签名",
+ "invocationHelpVerifyHint": "以签名密钥为键,对时间戳、一个点和原始请求体做 HMAC-SHA256。拒绝超过五分钟的请求。",
+ "invocationHelpAccept": "立即返回 2xx",
+ "invocationHelpAcceptHint": "响应之后再开始工作。返回其他状态时,任务稍后会重新发送,聊天消息会立即失败。",
+ "invocationHelpPayload": "读取任务",
+ "invocationHelpPayloadHint": "event 字段说明收到的是什么:任务、聊天消息或测试 ping。",
+ "invocationHelpTabRun": "任务",
+ "invocationHelpTabChat": "聊天消息",
+ "invocationHelpTabPing": "测试 ping",
+ "invocationHelpReport": "用智能体密钥发送结果",
+ "invocationHelpReportHint": "工作期间至少每 5 分钟发送一次 heartbeat,然后发送结果。聊天回复可以分段发送。",
+ "invocationHelpTest": "发送测试请求",
+ "invocationHelpTestHint": "“连接”一节会显示端点的响应。",
"runnerWayCli": "Runner CLI",
"runnerWayCliHint": "我们的 npm 包。指向一个编码智能体,它会领取任务并回传结果。需要一个包含智能体密钥的配置文件。",
"runnerWayApi": "你自己的代码",
@@ -434,7 +472,7 @@
"runnerHelpTabCustom": "自定义",
"runnerHelpPiAdapter": "Pi 通过扩展读取 .mcp.json。安装一次即可:pi install npm:pi-mcp-adapter",
"runnerHelpCheck": "确认已连接",
- "runnerHelpCheckHint": "“运行器”一节会显示“在线”。",
+ "runnerHelpCheckHint": "“连接”一节会显示“在线”。",
"runnerOnline": "运行器在线",
"runnerOffline": "运行器离线",
"runnerNever": "尚未连接运行器",
@@ -442,6 +480,8 @@
"runnerStateOffline": "离线",
"runnerStateNone": "未连接",
"runnerSeen": "{time} 前在线",
+ "runnerStateUrl": "端点",
+ "runnerUrl": "通过 URL 接收任务",
"actions": "操作",
"actionsHint": "代理在项目中可以执行的操作",
"searchActions": "搜索操作",
diff --git a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx
index 9b4f077d..a24fb2e6 100644
--- a/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx
+++ b/apps/web/src/components/common/agent-chat/AgentChatPanel.tsx
@@ -78,8 +78,9 @@ export function AgentChatPanel({
const fileInputRef = useRef<HTMLInputElement>(null);
// An external agent answers on its runner, so with none polling the message would sit
// in the queue with nothing to take it. The composer says so instead of accepting it.
- // A message typed while the agent is answering is not refused — it waits its turn.
- const runnerOffline = agent.kind === 'external' && !isRunnerOnline(agent);
+ // A message typed while the agent is answering is not refused — it waits its turn. An
+ // agent with an endpoint is sent the message, so nothing has to be online.
+ const runnerOffline = agent.kind === 'external' && !agent.invocationUrl && !isRunnerOnline(agent);
const canSend = input.trim().length > 0 && !runnerOffline;
function submit() {
diff --git a/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx b/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx
index 6ce32818..d5839168 100644
--- a/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx
+++ b/apps/web/src/components/common/agent-chat/AgentRunnerStatus.tsx
@@ -1,4 +1,4 @@
-import { Radio } from 'lucide-react';
+import { Radio, Webhook } from 'lucide-react';
import { useTranslations } from 'next-intl';
import type { AiAgent } from '@/lib/api/endpoints/agents';
import { cn } from '@/lib/utils';
@@ -7,8 +7,9 @@ import { isRunnerOnline } from './runnerOnline';
// Whether an external agent's runner is connected right now. The agent has no runner
// until someone starts one, so "never connected" is a normal state and reads
-// differently from "went offline". `compact` drops to the bare state for places that
-// already say what it is about, such as a section header.
+// differently from "went offline". An agent whose tasks are sent to its endpoint has no
+// runner to be connected, and says so instead. `compact` drops to the bare state for
+// places that already say what it is about, such as a section header.
//
// The strings sit in the settings namespace, where the runner is set up; the chat shows
// the same three states rather than wording its own.
@@ -24,6 +25,15 @@ export function AgentRunnerStatus({
const lastSeen = agent?.lastSeenAt ?? null;
const online = isRunnerOnline(agent);
+ if (agent?.invocationUrl) {
+ return (
+ <span className="inline-flex items-center gap-1.5 text-xs text-muted-foreground">
+ <Webhook className="size-3 shrink-0" />
+ {compact ? t('runnerStateUrl') : t('runnerUrl')}
+ </span>
+ );
+ }
+
let label: string;
if (online) label = compact ? t('runnerStateOnline') : t('runnerOnline');
else if (lastSeen) label = compact ? t('runnerStateOffline') : t('runnerOffline');
diff --git a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
index 22af06e9..4b62cea7 100644
--- a/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
+++ b/apps/web/src/features/settings/components/schedules/SettingsScheduleDialog.tsx
@@ -139,7 +139,9 @@ export function SettingsScheduleDialog({
</SettingsScheduleField>
</div>
- {selectedAgent?.kind === 'external' && <SettingsScheduleRunnerHint agent={selectedAgent} />}
+ {selectedAgent?.kind === 'external' && !selectedAgent.invocationUrl && (
+ <SettingsScheduleRunnerHint agent={selectedAgent} />
+ )}
{!initial && <SettingsScheduleTypeField value={type} onChange={setType} />}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentConnectionSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentConnectionSection.tsx
new file mode 100644
index 00000000..03a3871e
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentConnectionSection.tsx
@@ -0,0 +1,57 @@
+import { Cable, Terminal, Webhook } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import type { AiAgent } from '@/lib/api/endpoints/agents';
+import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';
+import type { AgentFormValue } from '../../utils/agentForm';
+import { AgentFormSection } from './AgentFormSection';
+import { AgentOptionCards } from './AgentOptionCards';
+import { AgentRunnerWays } from './AgentRunnerWays';
+import AgentInvocationPanel from './AgentInvocationPanel';
+
+// How an external agent gets its tasks: a runner takes them, or they are sent to the
+// agent's endpoint. Who may give it tasks is an access question and lives in the Access
+// section.
+export default function AgentConnectionSection({
+ agent,
+ value,
+ onChange,
+ ...section
+}: {
+ // The saved agent, for its presence and its saved URL. Null while creating.
+ agent: AiAgent | null;
+ value: AgentFormValue;
+ onChange: (patch: Partial<AgentFormValue>) => void;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
+ const t = useTranslations('teams.agents');
+
+ return (
+ <AgentFormSection
+ {...section}
+ icon={Cable}
+ title={t('connection')}
+ hint={t('connectionHint')}
+ headerRight={<AgentRunnerStatus agent={agent} compact />}
+ >
+ <AgentOptionCards
+ options={[
+ {
+ value: 'runner',
+ icon: Terminal,
+ label: t('deliveryRunner'),
+ hint: t('deliveryRunnerHint'),
+ },
+ { value: 'url', icon: Webhook, label: t('deliveryUrl'), hint: t('deliveryUrlHint') },
+ ]}
+ value={value.delivery}
+ onChange={(delivery) => onChange({ delivery })}
+ />
+ {value.delivery === 'runner' ? (
+ <AgentRunnerWays />
+ ) : (
+ <AgentInvocationPanel agent={agent} value={value} onChange={onChange} />
+ )}
+ </AgentFormSection>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentInvocationHelpSheet.tsx b/apps/web/src/features/teams/components/ai-agents/AgentInvocationHelpSheet.tsx
new file mode 100644
index 00000000..93c2dbc9
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentInvocationHelpSheet.tsx
@@ -0,0 +1,143 @@
+import { HelpCircle } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { API_URL } from '@/lib/api/core/client';
+import { Button } from '@/components/ui/button';
+import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger } from '@/components/ui/sheet';
+import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
+import { AgentRunnerCodeBlock } from './AgentRunnerCodeBlock';
+import { AgentRunnerHelpStep } from './AgentRunnerHelpStep';
+
+// How to build the endpoint an external agent's tasks are sent to. The snippets are
+// Node, the runtime most functions (AWS Lambda, Azure Functions, Cloudflare Workers)
+// are written in.
+
+const VERIFY = `import { createHmac, timingSafeEqual } from 'node:crypto';
+
+// header: the X-Itsaplan-Signature value; rawBody: the body exactly as it arrived.
+function verify(secret, header, rawBody) {
+ const { t, v1 } = Object.fromEntries(header.split(',').map((part) => part.split('=')));
+ if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
+ const expected = createHmac('sha256', secret).update(\`\${t}.\${rawBody}\`).digest('hex');
+ return v1?.length === expected.length && timingSafeEqual(Buffer.from(v1), Buffer.from(expected));
+}`;
+
+const AGENT = `"agent": { "id": 12, "username": "cloud-bot" },
+ "apiUrl": "${API_URL}"`;
+
+const PAYLOADS = [
+ {
+ id: 'run',
+ label: 'invocationHelpTabRun',
+ code: `{
+ "event": "agent.run",
+ ${AGENT},
+ "run": {
+ "id": 345,
+ "trigger": "status",
+ "prompt": "The task, framed with what started it",
+ "systemPrompt": "The project, the people, and the agent's instructions",
+ "attempts": 1,
+ "issueId": 678,
+ "issueIdentifier": "MKT-42"
+ }
+}`,
+ },
+ {
+ id: 'chat',
+ label: 'invocationHelpTabChat',
+ code: `{
+ "event": "agent.chat",
+ ${AGENT},
+ "message": {
+ "id": 901,
+ "threadId": "chat:12:...",
+ "prompt": "The person's message, after the earlier turns",
+ "systemPrompt": "The projects, the person, and the agent's instructions",
+ "attempts": 1,
+ "sessionId": null
+ }
+}`,
+ },
+ {
+ id: 'ping',
+ label: 'invocationHelpTabPing',
+ code: `{
+ "event": "ping",
+ ${AGENT}
+}`,
+ },
+] as const;
+
+const REPORT = `const api = (path, body = {}) =>
+ fetch(\`${API_URL}\${path}\`, {
+ method: 'POST',
+ headers: { 'x-api-key': process.env.ITSAPLAN_API_KEY, 'content-type': 'application/json' },
+ body: JSON.stringify(body),
+ });
+
+// A task: a heartbeat at least every 5 minutes while you work, then the result.
+await api(\`/agent-runs/\${payload.run.id}/heartbeat\`);
+await api(\`/agent-runs/\${payload.run.id}/result\`, { status: 'success', output: 'Opened PR #12' });
+
+// A chat message: the answer as it is written, then the end of it.
+await api(\`/agent-chats/\${payload.message.id}/events\`, {
+ events: [{ type: 'TEXT_MESSAGE_CONTENT', messageId: 'm1', delta: 'Done, PR #12 is open.' }],
+});
+await api(\`/agent-chats/\${payload.message.id}/result\`, { status: 'success' });`;
+
+export function AgentInvocationHelpSheet() {
+ const t = useTranslations('teams.agents');
+
+ return (
+ <Sheet>
+ <SheetTrigger asChild>
+ <Button type="button" variant="outline" size="sm" className="gap-1.5">
+ <HelpCircle className="size-4" />
+ {t('invocationHelpOpen')}
+ </Button>
+ </SheetTrigger>
+ <SheetContent side="bottom" className="flex h-dvh flex-col">
+ <SheetHeader>
+ <SheetTitle>{t('invocationHelpTitle')}</SheetTitle>
+ </SheetHeader>
+ <div className="mx-auto w-full max-w-[720px] flex-1 space-y-6 overflow-y-auto px-4 pb-8">
+ <AgentRunnerHelpStep n={1} title={t('invocationHelpVerify')}>
+ <p className="text-xs text-muted-foreground">{t('invocationHelpVerifyHint')}</p>
+ <AgentRunnerCodeBlock code={VERIFY} />
+ </AgentRunnerHelpStep>
+
+ <AgentRunnerHelpStep n={2} title={t('invocationHelpAccept')}>
+ <p className="text-xs text-muted-foreground">{t('invocationHelpAcceptHint')}</p>
+ </AgentRunnerHelpStep>
+
+ <AgentRunnerHelpStep n={3} title={t('invocationHelpPayload')}>
+ <p className="text-xs text-muted-foreground">{t('invocationHelpPayloadHint')}</p>
+ <Tabs defaultValue="run">
+ <TabsList variant="line">
+ {PAYLOADS.map((p) => (
+ <TabsTrigger key={p.id} value={p.id}>
+ {t(p.label)}
+ </TabsTrigger>
+ ))}
+ </TabsList>
+ {PAYLOADS.map((p) => (
+ <TabsContent key={p.id} value={p.id} className="pt-3">
+ <AgentRunnerCodeBlock code={p.code} />
+ </TabsContent>
+ ))}
+ </Tabs>
+ </AgentRunnerHelpStep>
+
+ <AgentRunnerHelpStep n={4} title={t('invocationHelpReport')}>
+ <p className="text-xs text-muted-foreground">{t('invocationHelpReportHint')}</p>
+ <AgentRunnerCodeBlock code={REPORT} />
+ </AgentRunnerHelpStep>
+
+ <AgentRunnerHelpStep n={5} title={t('invocationHelpTest')}>
+ <p className="text-xs text-muted-foreground">{t('invocationHelpTestHint')}</p>
+ </AgentRunnerHelpStep>
+ </div>
+ </SheetContent>
+ </Sheet>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentInvocationPanel.tsx b/apps/web/src/features/teams/components/ai-agents/AgentInvocationPanel.tsx
new file mode 100644
index 00000000..bdc300c0
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentInvocationPanel.tsx
@@ -0,0 +1,62 @@
+import { useTranslations } from 'next-intl';
+import type { AiAgent } from '@/lib/api/endpoints/agents';
+import { Input } from '@/components/ui/input';
+import { useAgentCan } from '../../context/agentSection';
+import type { AgentFormValue } from '../../utils/agentForm';
+import AgentInvocationSecret from './AgentInvocationSecret';
+import AgentInvocationTest from './AgentInvocationTest';
+import { AgentInvocationHelpSheet } from './AgentInvocationHelpSheet';
+
+// The endpoint an external agent's tasks are sent to. The secret and the test act on
+// what the server holds, so they appear once a URL is saved and keep addressing that
+// one while an edit to it is unsaved.
+export default function AgentInvocationPanel({
+ agent,
+ value,
+ onChange,
+}: {
+ agent: AiAgent | null;
+ value: AgentFormValue;
+ onChange: (patch: Partial<AgentFormValue>) => void;
+}) {
+ const t = useTranslations('teams.agents');
+ const can = useAgentCan();
+ const saved = agent?.invocationUrl ?? null;
+ const edited = saved !== null && value.invocationUrl.trim() !== saved;
+
+ return (
+ <div className="space-y-5">
+ <div className="space-y-1.5">
+ <label htmlFor="agent-invocation-url" className="text-sm font-medium">
+ {t('invocationUrl')}
+ </label>
+ <Input
+ id="agent-invocation-url"
+ type="url"
+ inputMode="url"
+ dir="ltr"
+ autoComplete="off"
+ placeholder={t('invocationUrlPlaceholder')}
+ value={value.invocationUrl}
+ onChange={(e) => onChange({ invocationUrl: e.target.value })}
+ />
+ <p className="text-xs text-muted-foreground">
+ {edited ? t('invocationUnsaved') : t('invocationUrlHint')}
+ </p>
+ </div>
+
+ {!agent || !saved ? (
+ <p className="text-xs text-muted-foreground">{t('invocationSecretOnSave')}</p>
+ ) : (
+ can('edit') && (
+ <>
+ <AgentInvocationSecret agent={agent} />
+ <AgentInvocationTest agentId={agent.id} />
+ </>
+ )
+ )}
+
+ <AgentInvocationHelpSheet />
+ </div>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentInvocationSecret.tsx b/apps/web/src/features/teams/components/ai-agents/AgentInvocationSecret.tsx
new file mode 100644
index 00000000..e8adce8d
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentInvocationSecret.tsx
@@ -0,0 +1,64 @@
+import { useState } from 'react';
+import { RefreshCw } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import type { AiAgent } from '@/lib/api/endpoints/agents';
+import { useInvocationSecretQuery, useRotateInvocationSecret } from '@/services/aiAgents.service';
+import { Button } from '@/components/ui/button';
+import { Skeleton } from '@/components/ui/skeleton';
+import ConfirmDialog from '@/components/common/overlay/ConfirmDialog';
+import { useAgentSection } from '../../context/agentSection';
+import AgentKeyValue from './AgentKeyValue';
+
+// The key the endpoint checks every request against. Unlike the API key it is kept
+// readable, because the server signs each request with it.
+export default function AgentInvocationSecret({ agent }: { agent: AiAgent }) {
+ const t = useTranslations('teams.agents');
+ const { teamId } = useAgentSection();
+ const secret = useInvocationSecretQuery(teamId, agent.id).data?.secret ?? null;
+ const rotate = useRotateInvocationSecret(teamId);
+ const [confirming, setConfirming] = useState(false);
+
+ return (
+ <div className="space-y-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <div className="min-w-0">
+ <span className="block text-sm font-medium">{t('invocationSecret')}</span>
+ <span className="block text-xs text-muted-foreground">{t('invocationSecretHint')}</span>
+ </div>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="gap-1.5"
+ disabled={rotate.isPending}
+ onClick={() => setConfirming(true)}
+ >
+ <RefreshCw className="size-3.5" />
+ {t('invocationRotate')}
+ </Button>
+ </div>
+ <div className="rounded-md bg-muted/50 p-1.5">
+ {secret ? <AgentKeyValue apiKey={secret} /> : <Skeleton className="h-8 w-full" />}
+ </div>
+
+ {confirming && (
+ <ConfirmDialog
+ title={t('invocationRotateTitle')}
+ confirmLabel={t('invocationRotate')}
+ onClose={() => setConfirming(false)}
+ onConfirm={async () => {
+ await rotate.mutateAsync(agent.id);
+ setConfirming(false);
+ }}
+ >
+ <p className="text-sm text-muted-foreground">
+ {t.rich('invocationRotateMessage', {
+ name: agent.name,
+ v: (chunks) => <span className="font-medium">{chunks}</span>,
+ })}
+ </p>
+ </ConfirmDialog>
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentInvocationTest.tsx b/apps/web/src/features/teams/components/ai-agents/AgentInvocationTest.tsx
new file mode 100644
index 00000000..6c7a4313
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentInvocationTest.tsx
@@ -0,0 +1,71 @@
+import { CircleCheck, CircleX, Send } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import type { InvocationTestResult } from '@/lib/api/endpoints/agents';
+import { useTestInvocation } from '@/services/aiAgents.service';
+import { Button } from '@/components/ui/button';
+import { useAgentSection } from '../../context/agentSection';
+
+// Sends a signed ping to the saved URL and shows how the endpoint answered: whether it
+// is reachable and whether it accepts the signature.
+export default function AgentInvocationTest({ agentId }: { agentId: number }) {
+ const t = useTranslations('teams.agents');
+ const { teamId } = useAgentSection();
+ const test = useTestInvocation(teamId);
+ const result = test.data;
+
+ function summary(r: InvocationTestResult): string {
+ if (r.ok) return t('invocationTestOk', { status: r.status ?? 0, ms: r.durationMs });
+ if (r.timedOut) return t('invocationTestTimeout');
+ if (r.status !== null) return t('invocationTestRefused', { status: r.status });
+ return t('invocationTestUnreachable');
+ }
+
+ return (
+ <div className="space-y-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <div className="min-w-0">
+ <span className="block text-sm font-medium">{t('invocationTest')}</span>
+ <span className="block text-xs text-muted-foreground">{t('invocationTestHint')}</span>
+ </div>
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ className="gap-1.5"
+ disabled={test.isPending}
+ onClick={() => test.mutate(agentId)}
+ >
+ <Send className="size-3.5" />
+ {test.isPending ? t('invocationTestSending') : t('invocationTestSend')}
+ </Button>
+ </div>
+
+ {result && !test.isPending && (
+ <div className="space-y-1.5 rounded-md bg-muted/50 px-3 py-2" aria-live="polite">
+ <p className="flex items-center gap-1.5 text-xs">
+ {result.ok ? (
+ <CircleCheck className="size-3.5 shrink-0 text-emerald-500" />
+ ) : (
+ <CircleX className="size-3.5 shrink-0 text-destructive" />
+ )}
+ <span className="font-medium">{summary(result)}</span>
+ {/* The transport's own words, for the cases the summary cannot name. */}
+ {!result.ok && result.status === null && !result.timedOut && result.error && (
+ <span className="min-w-0 truncate text-muted-foreground" dir="ltr">
+ {result.error}
+ </span>
+ )}
+ </p>
+ {result.responseBody && (
+ <pre
+ dir="ltr"
+ className="max-h-32 overflow-auto rounded bg-background/60 px-2 py-1.5 text-start font-mono text-xs whitespace-pre-wrap text-muted-foreground"
+ >
+ {result.responseBody}
+ </pre>
+ )}
+ </div>
+ )}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentOptionCards.tsx b/apps/web/src/features/teams/components/ai-agents/AgentOptionCards.tsx
new file mode 100644
index 00000000..1d3ef38d
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentOptionCards.tsx
@@ -0,0 +1,47 @@
+import type { LucideIcon } from 'lucide-react';
+
+interface AgentOption<T extends string> {
+ value: T;
+ icon: LucideIcon;
+ label: string;
+ hint: string;
+}
+
+// A choice between two options shown side by side, each with an icon, a name and a
+// one-line hint: the kind of a new agent, and how an external one gets its tasks.
+export function AgentOptionCards<T extends string>({
+ options,
+ value,
+ onChange,
+}: {
+ options: AgentOption<T>[];
+ value: T;
+ onChange: (value: T) => void;
+}) {
+ return (
+ <div className="grid grid-cols-2 gap-2">
+ {options.map((option) => {
+ const Icon = option.icon;
+ return (
+ <button
+ key={option.value}
+ type="button"
+ aria-pressed={value === option.value}
+ onClick={() => onChange(option.value)}
+ className={`flex items-start gap-2.5 rounded-md px-3 py-2 text-start text-sm transition-colors ${
+ value === option.value
+ ? 'bg-secondary ring-1 ring-foreground/15'
+ : 'bg-muted/50 hover:bg-accent/60'
+ }`}
+ >
+ <Icon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
+ <span className="min-w-0">
+ <span className="font-medium">{option.label}</span>
+ <span className="block text-xs text-muted-foreground">{option.hint}</span>
+ </span>
+ </button>
+ );
+ })}
+ </div>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx b/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx
deleted file mode 100644
index 00d17175..00000000
--- a/apps/web/src/features/teams/components/ai-agents/AgentRunnerSection.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { Code2, Package, Terminal } from 'lucide-react';
-import { useTranslations } from 'next-intl';
-import type { AiAgent } from '@/lib/api/endpoints/agents';
-import { AgentRunnerStatus } from '@/components/common/agent-chat/AgentRunnerStatus';
-import { AgentFormSection } from './AgentFormSection';
-import { AgentRunnerCodeBlock } from './AgentRunnerCodeBlock';
-import { AgentRunnerHelpSheet, RUN_COMMAND } from './AgentRunnerHelpSheet';
-
-// The Runner section of an external agent: whether its runner is connected right
-// now, and how to start one. Who may give the agent work is an access question and
-// lives in the Access section, so nothing here is a setting.
-export default function AgentRunnerSection({
- agent,
- ...section
-}: {
- // The saved agent, for its presence. Null while creating: no key exists yet, so the
- // state reads as not connected.
- agent: AiAgent | null;
- open: boolean;
- onOpenChange: (open: boolean) => void;
-}) {
- const t = useTranslations('teams.agents');
-
- return (
- <AgentFormSection
- {...section}
- icon={Terminal}
- title={t('runner')}
- hint={t('runnerHint')}
- // Presence belongs in the header: it is the section's state at a glance, and it
- // stays visible while the section is collapsed.
- headerRight={<AgentRunnerStatus agent={agent} compact />}
- >
- <div className="space-y-3">
- <div className="space-y-2 rounded-md border p-3">
- <p className="flex items-center gap-1.5 text-sm font-medium">
- <Package className="size-4 text-muted-foreground" />
- {t('runnerWayCli')}
- </p>
- <p className="text-xs text-muted-foreground">{t('runnerWayCliHint')}</p>
- <AgentRunnerCodeBlock code={RUN_COMMAND} />
- <AgentRunnerHelpSheet />
- </div>
-
- <div className="space-y-2 rounded-md border p-3">
- <p className="flex items-center gap-1.5 text-sm font-medium">
- <Code2 className="size-4 text-muted-foreground" />
- {t('runnerWayApi')}
- </p>
- <p className="text-xs text-muted-foreground">{t('runnerWayApiHint')}</p>
- </div>
- </div>
- </AgentFormSection>
- );
-}
diff --git a/apps/web/src/features/teams/components/ai-agents/AgentRunnerWays.tsx b/apps/web/src/features/teams/components/ai-agents/AgentRunnerWays.tsx
new file mode 100644
index 00000000..238c4cf0
--- /dev/null
+++ b/apps/web/src/features/teams/components/ai-agents/AgentRunnerWays.tsx
@@ -0,0 +1,32 @@
+import { Code2, Package } from 'lucide-react';
+import { useTranslations } from 'next-intl';
+import { AgentRunnerCodeBlock } from './AgentRunnerCodeBlock';
+import { AgentRunnerHelpSheet, RUN_COMMAND } from './AgentRunnerHelpSheet';
+
+// The two ways to run something that takes an external agent's tasks: the runner CLI,
+// or code of one's own against the runner routes.
+export function AgentRunnerWays() {
+ const t = useTranslations('teams.agents');
+
+ return (
+ <div className="space-y-3">
+ <div className="space-y-2 rounded-md border p-3">
+ <p className="flex items-center gap-1.5 text-sm font-medium">
+ <Package className="size-4 text-muted-foreground" />
+ {t('runnerWayCli')}
+ </p>
+ <p className="text-xs text-muted-foreground">{t('runnerWayCliHint')}</p>
+ <AgentRunnerCodeBlock code={RUN_COMMAND} />
+ <AgentRunnerHelpSheet />
+ </div>
+
+ <div className="space-y-2 rounded-md border p-3">
+ <p className="flex items-center gap-1.5 text-sm font-medium">
+ <Code2 className="size-4 text-muted-foreground" />
+ {t('runnerWayApi')}
+ </p>
+ <p className="text-xs text-muted-foreground">{t('runnerWayApiHint')}</p>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx
index 58b3fc90..3fc4722b 100644
--- a/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx
+++ b/apps/web/src/features/teams/components/ai-agents/TeamAiAgentFields.tsx
@@ -26,7 +26,8 @@ import AgentModelSection from './AgentModelSection';
import AgentActionsSection from './AgentActionsSection';
import AgentTriggersSection from './AgentTriggersSection';
import { AgentInstructionsField } from './AgentInstructionsField';
-import AgentRunnerSection from './AgentRunnerSection';
+import AgentConnectionSection from './AgentConnectionSection';
+import { AgentOptionCards } from './AgentOptionCards';
import { useTranslations } from 'next-intl';
// Which sections open when an existing agent is opened for editing, so the form reads
@@ -119,31 +120,16 @@ export default function TeamAiAgentFields({
{!kindLocked && (
<div className="space-y-1.5">
<span className="text-sm font-medium">{t('kind')}</span>
- <div className="grid grid-cols-2 gap-2">
- {(['external', 'internal'] as const).map((k) => {
- const KindIcon = AGENT_KIND_ICON[k];
- return (
- <button
- key={k}
- type="button"
- onClick={() => onChange({ kind: k })}
- className={`flex items-start gap-2.5 rounded-md px-3 py-2 text-start text-sm transition-colors ${
- value.kind === k
- ? 'bg-secondary ring-1 ring-foreground/15'
- : 'bg-muted/50 hover:bg-accent/60'
- }`}
- >
- <KindIcon className="mt-0.5 size-4 shrink-0 text-muted-foreground" />
- <span className="min-w-0">
- <span className="font-medium">{t(`kindLabel.${k}`)}</span>
- <span className="block text-xs text-muted-foreground">
- {t(`kindHint.${k}`)}
- </span>
- </span>
- </button>
- );
- })}
- </div>
+ <AgentOptionCards
+ options={(['external', 'internal'] as const).map((k) => ({
+ value: k,
+ icon: AGENT_KIND_ICON[k],
+ label: t(`kindLabel.${k}`),
+ hint: t(`kindHint.${k}`),
+ }))}
+ value={value.kind}
+ onChange={(kind) => onChange({ kind })}
+ />
</div>
)}
@@ -211,8 +197,14 @@ export default function TeamAiAgentFields({
/>
);
- const runnerSection = (
- <AgentRunnerSection key="runner" {...sectionProps('runner')} agent={agent} />
+ const connectionSection = (
+ <AgentConnectionSection
+ key="connection"
+ {...sectionProps('connection')}
+ agent={agent}
+ value={value}
+ onChange={onChange}
+ />
);
const modelSection = (
@@ -380,7 +372,7 @@ export default function TeamAiAgentFields({
tokenSection,
accessSection,
triggersSection,
- runnerSection,
+ connectionSection,
]
: [
basicsSection,
diff --git a/apps/web/src/features/teams/utils/agentForm.ts b/apps/web/src/features/teams/utils/agentForm.ts
index 6dacc6ad..645188e8 100644
--- a/apps/web/src/features/teams/utils/agentForm.ts
+++ b/apps/web/src/features/teams/utils/agentForm.ts
@@ -35,14 +35,21 @@ export interface AgentFormValue {
// else, so an agent with none authenticates and sees no project.
projectIds: number[];
runnerScope: 'owner' | 'team';
+ // How an external agent gets its tasks: taken by a runner, or sent to its URL.
+ delivery: AgentDelivery;
+ invocationUrl: string;
}
+export type AgentDelivery = 'runner' | 'url';
+
export interface FormFieldTrigger {
fieldId: number;
delayMin: string;
}
const USERNAME_PATTERN = /^[a-zA-Z0-9._-]+$/;
+// Only the shape is checked here; the server refuses an address it will not send to.
+const URL_PATTERN = /^https?:\/\/\S+$/;
// Suggests a mention handle from the agent's name: non-Latin scripts are
// transliterated, the result is lowercased, every run of characters the handle can't
@@ -56,11 +63,17 @@ export function suggestUsername(name: string): string {
.slice(0, 64);
}
-// Whether the form holds a submittable value: a non-empty name and a username
-// matching the server rules (1-64 chars, [a-zA-Z0-9._-]).
+// Whether the form holds a submittable value: a non-empty name, a username matching
+// the server rules (1-64 chars, [a-zA-Z0-9._-]), and a URL when the tasks are sent to one.
export function isAgentFormValid(v: AgentFormValue): boolean {
const username = v.username.trim();
- return v.name.trim().length > 0 && username.length <= 64 && USERNAME_PATTERN.test(username);
+ const sendsToUrl = v.kind === 'external' && v.delivery === 'url';
+ return (
+ v.name.trim().length > 0 &&
+ username.length <= 64 &&
+ USERNAME_PATTERN.test(username) &&
+ (!sendsToUrl || URL_PATTERN.test(v.invocationUrl.trim()))
+ );
}
// The form's starting value, from an existing agent when editing or blank defaults
@@ -88,6 +101,8 @@ export function initialAgentValue(agent?: AiAgent): AgentFormValue {
delegationDelayMin: String(Math.round((agent?.delegationDelaySec ?? 120) / 60)),
projectIds: (agent?.projects ?? []).map((project) => project.id),
runnerScope: agent?.runnerScope ?? 'team',
+ delivery: agent?.invocationUrl ? 'url' : 'runner',
+ invocationUrl: agent?.invocationUrl ?? '',
};
}
@@ -102,8 +117,8 @@ function parseNum(s: string): number | null {
// The kind-specific config, shared by the create input and edit patch. Both kinds
// carry their projects, their run triggers, and their instructions; an external agent
-// adds the scope of the runs its runner receives, an internal one the model/tools
-// config.
+// adds the scope of the runs it receives and where they are sent, an internal one the
+// model/tools config.
function configFields(v: AgentFormValue) {
const common = {
projectIds: v.projectIds,
@@ -117,7 +132,11 @@ function configFields(v: AgentFormValue) {
delegationDelaySec: delaySecFromMinutes(v.delegationDelayMin),
};
if (v.kind === 'external') {
- return { ...common, runnerScope: v.runnerScope };
+ return {
+ ...common,
+ runnerScope: v.runnerScope,
+ invocationUrl: v.delivery === 'url' ? v.invocationUrl.trim() : null,
+ };
}
return {
...common,
diff --git a/apps/web/src/lib/api/endpoints/agents.ts b/apps/web/src/lib/api/endpoints/agents.ts
index 8bc3fba3..45e568f3 100644
--- a/apps/web/src/lib/api/endpoints/agents.ts
+++ b/apps/web/src/lib/api/endpoints/agents.ts
@@ -64,6 +64,9 @@ export interface AiAgent {
runnerScope: 'owner' | 'team';
// When the agent's runner last polled, or null while none ever has.
lastSeenAt: string | null;
+ // Where an external agent's tasks and chat messages are sent instead of being taken
+ // by a runner; null when a runner takes them.
+ invocationUrl: string | null;
createdAt: string;
apiKeyStart: string | null;
// The integration key of the model credential (the provider, e.g. "openai"), or
@@ -141,6 +144,7 @@ export interface NewAiAgentInput {
delegationDelaySec?: number;
projectIds?: number[];
runnerScope?: 'owner' | 'team';
+ invocationUrl?: string | null;
}
export interface AiAgentPatch {
@@ -161,6 +165,7 @@ export interface AiAgentPatch {
delegationDelaySec?: number;
projectIds?: number[];
runnerScope?: 'owner' | 'team';
+ invocationUrl?: string | null;
}
// One event of a streamed agent run (mirrors the API's AgentRunEvent). `text` is a
@@ -206,6 +211,32 @@ export const regenerateAiAgentKey = (teamId: number, agentId: number) =>
method: 'POST',
});
+// How the endpoint at the invocation URL answered a test ping. `status` is null when no
+// answer arrived.
+export interface InvocationTestResult {
+ ok: boolean;
+ timedOut: boolean;
+ status: number | null;
+ error: string | null;
+ responseBody: string | null;
+ durationMs: number;
+}
+
+// The key the requests to an external agent's invocation URL are signed with. Null
+// until the agent first gets a URL.
+export const getInvocationSecret = (teamId: number, agentId: number) =>
+ request<{ secret: string | null }>(`/teams/${teamId}/ai-agents/${agentId}/invocation-secret`);
+
+export const rotateInvocationSecret = (teamId: number, agentId: number) =>
+ request<{ secret: string }>(`/teams/${teamId}/ai-agents/${agentId}/invocation-secret`, {
+ method: 'POST',
+ });
+
+export const testInvocation = (teamId: number, agentId: number) =>
+ request<InvocationTestResult>(`/teams/${teamId}/ai-agents/${agentId}/invocation-test`, {
+ method: 'POST',
+ });
+
export const deleteAiAgent = (teamId: number, agentId: number) =>
request<void>(`/teams/${teamId}/ai-agents/${agentId}`, { method: 'DELETE' });
diff --git a/apps/web/src/services/aiAgents.service.ts b/apps/web/src/services/aiAgents.service.ts
index c51bc406..d535fb30 100644
--- a/apps/web/src/services/aiAgents.service.ts
+++ b/apps/web/src/services/aiAgents.service.ts
@@ -31,6 +31,9 @@ import {
updateAiAgent,
regenerateAiAgentKey,
deleteAiAgent,
+ getInvocationSecret,
+ rotateInvocationSecret,
+ testInvocation,
} from '@/lib/api/endpoints/agents';
import { qk } from '@/services/queryKeys';
@@ -275,6 +278,33 @@ export function useRegenerateAiAgentKey(teamId: number | null) {
});
}
+// The key an external agent's invocations are signed with, which only a member who may
+// edit the agent reads. A save that sets the first URL issues it, and saving refetches
+// every agent query, this one included.
+export function useInvocationSecretQuery(teamId: number | null, agentId: number | null) {
+ return useQuery({
+ queryKey: qk.invocationSecret(teamId ?? 0, agentId ?? 0),
+ queryFn: () => getInvocationSecret(teamId!, agentId!),
+ enabled: teamId != null && agentId != null,
+ });
+}
+
+export function useRotateInvocationSecret(teamId: number | null) {
+ const t = useTranslations('teams.agents');
+ const qc = useQueryClient();
+ return useMutation({
+ mutationFn: (agentId: number) => rotateInvocationSecret(teamId!, agentId),
+ onSuccess: (res, agentId) => {
+ toast.success(t('invocationSecretRotated'));
+ if (teamId != null) qc.setQueryData(qk.invocationSecret(teamId, agentId), res);
+ },
+ });
+}
+
+export function useTestInvocation(teamId: number | null) {
+ return useMutation({ mutationFn: (agentId: number) => testInvocation(teamId!, agentId) });
+}
+
export function useDeleteAiAgent(teamId: number | null) {
const invalidate = useAgentInvalidator(teamId);
return useMutation({
diff --git a/apps/web/src/services/queryKeys.ts b/apps/web/src/services/queryKeys.ts
index 01ce2987..a1a97b3a 100644
--- a/apps/web/src/services/queryKeys.ts
+++ b/apps/web/src/services/queryKeys.ts
@@ -161,6 +161,8 @@ export const qk = {
['aiAgents', teamId, agentId, 'skills'] as const,
// An agent's triggered run history (the runs sidebar).
agentRuns: (teamId: number, agentId: number) => ['aiAgents', teamId, agentId, 'runs'] as const,
+ invocationSecret: (teamId: number, agentId: number) =>
+ ['aiAgents', teamId, agentId, 'invocationSecret'] as const,
agentSchedules: (projectKey: string) => ['agentSchedules', projectKey] as const,
// One page of them: the window scopes the entry.
agentSchedulePage: (projectKey: string, params: unknown) =>
diff --git a/apps/worker/src/__tests__/unit/delivery.test.ts b/apps/worker/src/__tests__/unit/delivery.test.ts
new file mode 100644
index 00000000..4184810f
--- /dev/null
+++ b/apps/worker/src/__tests__/unit/delivery.test.ts
@@ -0,0 +1,12 @@
+import { describe, it, expect } from 'bun:test';
+import { isRetryableStatus } from '../../delivery';
+
+describe('isRetryableStatus', () => {
+ it('retries 408, 429, and 5xx', () => {
+ for (const s of [408, 429, 500, 502, 503]) expect(isRetryableStatus(s)).toBe(true);
+ });
+
+ it('does not retry other 4xx', () => {
+ for (const s of [400, 401, 403, 404, 410, 422]) expect(isRetryableStatus(s)).toBe(false);
+ });
+});
diff --git a/apps/worker/src/delivery.ts b/apps/worker/src/delivery.ts
index f636c088..54a1b377 100644
--- a/apps/worker/src/delivery.ts
+++ b/apps/worker/src/delivery.ts
@@ -1,5 +1,5 @@
import { pinnedFetch, UrlNotAllowedError } from '@repo/net';
-import { signPayload } from './signature';
+import { signPayload } from '@repo/crypto';
export interface DeliverInput {
url: string;
diff --git a/apps/worker/src/signature.ts b/apps/worker/src/signature.ts
deleted file mode 100644
index 5c653c57..00000000
--- a/apps/worker/src/signature.ts
+++ /dev/null
@@ -1,10 +0,0 @@
-import { createHmac } from 'node:crypto';
-
-// HMAC-SHA256 over `${timestamp}.${body}` with the webhook's secret, formatted as
-// the X-Itsaplan-Signature header value (`t=<ts>,v1=<hex>`). The timestamp lets
-// the receiver reject replays; the receiver recomputes the HMAC over the exact
-// bytes it received and compares in constant time.
-export function signPayload(secret: string, timestampSeconds: number, body: string): string {
- const digest = createHmac('sha256', secret).update(`${timestampSeconds}.${body}`).digest('hex');
- return `t=${timestampSeconds},v1=${digest}`;
-}
diff --git a/docs/agent-endpoint.md b/docs/agent-endpoint.md
new file mode 100644
index 00000000..caf89c6b
--- /dev/null
+++ b/docs/agent-endpoint.md
@@ -0,0 +1,183 @@
+# Agent endpoint
+
+An external agent gets its tasks in one of two ways:
+
+- A runner on your machine asks the instance for the tasks. See [Coding agent setup](runner.md).
+- The instance sends the tasks to an endpoint that you run: an AWS Lambda function URL, an
+ Azure Function, a Cloudflare Worker, or any other HTTPS server.
+
+This page describes the endpoint.
+
+The endpoint gets the same tasks as a runner: delegations, mentions, field and status
+triggers, schedules, manual runs, and chat messages. Each task has the same prompt and
+system prompt. The endpoint sends the result through the same routes as a runner.
+
+## Set it up
+
+1. Create an external agent. Copy its API key.
+2. In the agent's Connection section, select Endpoint. Enter the URL and save.
+3. Copy the signing secret below the URL.
+4. Click Send test. The section shows the status code of the answer and the start of its
+ body.
+
+The URL must use HTTPS and resolve to a public address. To use a private host, add it to
+`SSRF_ALLOWED_HOSTS` on the instance. That host must also use HTTPS.
+
+When `NODE_ENV` on the instance is not `production` or `test`, the instance also accepts
+`http://` and private addresses, for example `http://localhost:4000`. Use this to test a
+local server before you deploy the function.
+
+While the agent has a URL, the runner claim routes (`POST /agent-runs/claim`,
+`POST /agent-chats/claim`) answer 409. To connect a runner again, clear the URL.
+
+## Requests
+
+The instance sends each task as one `POST` request with a JSON body and these headers:
+
+| Header | Value |
+| ---------------------- | ---------------------------------------- |
+| `Content-Type` | `application/json` |
+| `X-Itsaplan-Event` | `agent.run`, `agent.chat` or `ping` |
+| `X-Itsaplan-Signature` | `t=<unix seconds>,v1=<hex HMAC-SHA256>` |
+
+The body of an `agent.run` request:
+
+```json
+{
+ "event": "agent.run",
+ "agent": { "id": 12, "username": "cloud-bot" },
+ "apiUrl": "https://api.example.com",
+ "run": {
+ "id": 345,
+ "trigger": "status",
+ "prompt": "The task, framed with what started it",
+ "systemPrompt": "The project, the people, and the agent's instructions",
+ "attempts": 1,
+ "issueId": 678,
+ "issueIdentifier": "MKT-42"
+ }
+}
+```
+
+`apiUrl` is the `API_URL` of the instance, or `null` if `API_URL` is not set. An
+`agent.chat` request has `message` instead of `run`:
+
+```json
+{
+ "id": 901,
+ "threadId": "chat:12:...",
+ "prompt": "The person's message, after the earlier turns",
+ "systemPrompt": "The projects, the person, and the agent's instructions",
+ "attempts": 1,
+ "sessionId": null
+}
+```
+
+A `ping` request has only `event`, `agent` and `apiUrl`. Send test sends a `ping`.
+
+### Verify the signature
+
+The signature is an HMAC-SHA256 of `<t>.<raw body>`. The key is the signing secret.
+Calculate it on the raw body, before you parse the JSON:
+
+```js
+import { createHmac, timingSafeEqual } from 'node:crypto';
+
+function verify(secret, header, rawBody) {
+ const { t, v1 } = Object.fromEntries(header.split(',').map((part) => part.split('=')));
+ if (Math.abs(Date.now() / 1000 - Number(t)) > 300) return false;
+ const expected = createHmac('sha256', secret).update(`${t}.${rawBody}`).digest('hex');
+ const given = Buffer.from(v1 ?? '');
+ const wanted = Buffer.from(expected);
+ return given.length === wanted.length && timingSafeEqual(given, wanted);
+}
+```
+
+Project webhooks use the same signature, with the secret of the webhook.
+
+### Answer
+
+The status code of the answer tells the instance what to do with the task:
+
+- **2xx.** The endpoint accepted the task. The instance leases the task for
+ `AGENT_RUN_LEASE_SECONDS` (chat: `AGENT_CHAT_LEASE_SECONDS`), 300 seconds by default.
+ A heartbeat extends the lease. The result closes the task. If the lease ends before the
+ result, the instance sends the task again. It sends a task at most
+ `AGENT_RUN_MAX_ATTEMPTS` times (chat: `AGENT_CHAT_MAX_ATTEMPTS`), 3 by default.
+- **Other status code, or a connection error.** The instance sends a run again after a
+ delay. The first delay is up to 30 seconds. Each next delay is longer, up to 30 minutes.
+ After the last attempt, the run fails. A chat message fails immediately, because a
+ person waits for the answer.
+- **No answer in `AGENT_INVOCATION_TIMEOUT_MS`** (15 seconds by default). The instance
+ treats the task as accepted and keeps it leased. Thus an endpoint that does the work
+ before it answers does not get the same task again while the lease lasts.
+
+The instance does not use the body of the answer. Only Send test shows it. The result of
+a task comes only through the routes below.
+
+### Send the result
+
+Call the API at `apiUrl`. Put the agent's API key in the `x-api-key` header:
+
+| Route | Body |
+| ---------------------------------------- | -------------------------------------------------------- |
+| `POST /agent-runs/:runId/heartbeat` | none |
+| `POST /agent-runs/:runId/result` | `{ "status": "success" \| "failed", "output", "error" }` |
+| `POST /agent-chats/:messageId/events` | `{ "events": [AG-UI events], "sessionId" }` |
+| `POST /agent-chats/:messageId/heartbeat` | none |
+| `POST /agent-chats/:messageId/result` | `{ "status": "success" \| "failed", "error" }` |
+
+A chat answer is a sequence of AG-UI events. Send a `TEXT_MESSAGE_CONTENT` event with a
+`delta` for each part of the text. Send the tool call events for each tool that the agent
+uses. When the person stops the answer, the events, heartbeat and result routes of that
+answer return `{ "canceled": true }`. Then stop the work on that answer.
+
+The agent reads and changes issues with the same key, through the REST API or the MCP
+server at `<apiUrl>/mcp`.
+
+## With the runner
+
+With `listen`, `@itsaplan/runner` is the endpoint. It receives the tasks on a port and
+runs them with a coding agent CLI, the same as when it polls. See
+[Receiving tasks on a port](https://github.com/croffasia/itsaplan/blob/main/packages/runner/README.md#receiving-tasks-on-a-port).
+
+## Example: AWS Lambda
+
+A Node.js handler for a Lambda function URL. Set `ITSAPLAN_API_KEY` and
+`ITSAPLAN_SIGNING_SECRET` in the environment of the function:
+
+```js
+import { createHmac, timingSafeEqual } from 'node:crypto';
+
+const api = (base, path, body = {}) =>
+ fetch(`${base}${path}`, {
+ method: 'POST',
+ headers: { 'x-api-key': process.env.ITSAPLAN_API_KEY, 'content-type': 'application/json' },
+ body: JSON.stringify(body),
+ });
+
+export const handler = async (event) => {
+ const raw = event.isBase64Encoded ? Buffer.from(event.body, 'base64').toString() : event.body;
+ const signature = event.headers['x-itsaplan-signature'] ?? '';
+ if (!verify(process.env.ITSAPLAN_SIGNING_SECRET, signature, raw)) {
+ return { statusCode: 401, body: 'bad signature' };
+ }
+ const payload = JSON.parse(raw);
+ if (payload.event === 'agent.run') {
+ const output = await doTheWork(payload.run); // your agent: a model call, a pull request
+ await api(payload.apiUrl, `/agent-runs/${payload.run.id}/result`, {
+ status: 'success',
+ output,
+ });
+ }
+ return { statusCode: 200, body: 'ok' };
+};
+```
+
+`verify` is the function from [Verify the signature](#verify-the-signature). A function URL
+keeps the request open until the handler returns. Thus this handler answers after the
+work. The instance stops the wait after 15 seconds and keeps the task leased. For work
+longer than the lease, do one of these:
+
+- Send heartbeats.
+- Invoke a second function asynchronously with the task, and answer immediately.
diff --git a/docs/runner.md b/docs/runner.md
index b68df863..5261c4e0 100644
--- a/docs/runner.md
+++ b/docs/runner.md
@@ -13,6 +13,9 @@ This page holds both files for each preset, and the notes that apply to that CLI
runner's own settings are in its
[README](https://github.com/croffasia/itsaplan/blob/main/packages/runner/README.md).
+The instance can also send the tasks to an endpoint that you run. See
+[Agent endpoint](agent-endpoint.md).
+
Enable MCP for the project first, in Settings, MCP Server. It is off by default.
## Claude Code
diff --git a/packages/crypto/package.json b/packages/crypto/package.json
index 82257824..93fcb0fd 100644
--- a/packages/crypto/package.json
+++ b/packages/crypto/package.json
@@ -8,7 +8,8 @@
},
"scripts": {
"lint": "eslint .",
- "typecheck": "tsc --noEmit"
+ "typecheck": "tsc --noEmit",
+ "test": "bun test"
},
"devDependencies": {
"@repo/eslint-config": "workspace:*",
diff --git a/apps/worker/src/__tests__/unit/signature.test.ts b/packages/crypto/src/__tests__/sign.test.ts
similarity index 63%
rename from apps/worker/src/__tests__/unit/signature.test.ts
rename to packages/crypto/src/__tests__/sign.test.ts
index 0952b5ea..1d66a192 100644
--- a/apps/worker/src/__tests__/unit/signature.test.ts
+++ b/packages/crypto/src/__tests__/sign.test.ts
@@ -1,7 +1,6 @@
import { describe, it, expect } from 'bun:test';
import { createHmac } from 'node:crypto';
-import { signPayload } from '../../signature';
-import { isRetryableStatus } from '../../delivery';
+import { signPayload } from '../index';
describe('signPayload', () => {
it('produces t=<ts>,v1=<hmac> over `${ts}.${body}`', () => {
@@ -20,13 +19,3 @@ describe('signPayload', () => {
expect(signPayload('a', 1, '{}')).not.toBe(signPayload('b', 1, '{}'));
});
});
-
-describe('isRetryableStatus', () => {
- it('retries 408, 429, and 5xx', () => {
- for (const s of [408, 429, 500, 502, 503]) expect(isRetryableStatus(s)).toBe(true);
- });
-
- it('does not retry other 4xx', () => {
- for (const s of [400, 401, 403, 404, 410, 422]) expect(isRetryableStatus(s)).toBe(false);
- });
-});
diff --git a/packages/crypto/src/index.ts b/packages/crypto/src/index.ts
index 8c1cf4b2..fe3e5d79 100644
--- a/packages/crypto/src/index.ts
+++ b/packages/crypto/src/index.ts
@@ -1,4 +1,4 @@
-import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'node:crypto';
+import { createCipheriv, createDecipheriv, createHash, createHmac, randomBytes } from 'node:crypto';
// Symmetric encryption for secrets stored at rest (provider API keys). AES-256-GCM
// with a per-value random IV; the auth tag is kept alongside so decryption is
@@ -53,3 +53,13 @@ export function decryptSecret(enc: EncryptedSecret): string {
]);
return plaintext.toString('utf8');
}
+
+// HMAC-SHA256 over `${timestamp}.${body}`, formatted as the X-Itsaplan-Signature header
+// value (`t=<ts>,v1=<hex>`). It signs every request this instance sends to a URL someone
+// configured: a webhook delivery and an agent invocation. The timestamp lets the
+// receiver reject replays; the receiver recomputes the HMAC over the exact bytes it
+// received and compares in constant time.
+export function signPayload(secret: string, timestampSeconds: number, body: string): string {
+ const digest = createHmac('sha256', secret).update(`${timestampSeconds}.${body}`).digest('hex');
+ return `t=${timestampSeconds},v1=${digest}`;
+}
diff --git a/packages/db/drizzle/0151_agent_invocation_url.sql b/packages/db/drizzle/0151_agent_invocation_url.sql
new file mode 100644
index 00000000..57daaf37
--- /dev/null
+++ b/packages/db/drizzle/0151_agent_invocation_url.sql
@@ -0,0 +1,4 @@
+ALTER TABLE "ai_agent" ADD COLUMN "invocation_url" text;--> statement-breakpoint
+ALTER TABLE "ai_agent" ADD COLUMN "invocation_secret_ciphertext" text;--> statement-breakpoint
+ALTER TABLE "ai_agent" ADD COLUMN "invocation_secret_iv" text;--> statement-breakpoint
+ALTER TABLE "ai_agent" ADD COLUMN "invocation_secret_auth_tag" text;
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/0151_snapshot.json b/packages/db/drizzle/meta/0151_snapshot.json
new file mode 100644
index 00000000..d5985fde
--- /dev/null
+++ b/packages/db/drizzle/meta/0151_snapshot.json
@@ -0,0 +1,12403 @@
+{
+ "id": "17a18039-6e6c-432b-86df-fafcf1d9c744",
+ "prevId": "2e4b7f25-0a5a-4548-bd8a-cb97fce4b45d",
+ "version": "7",
+ "dialect": "postgresql",
+ "tables": {
+ "public.account": {
+ "name": "account",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "account_id": {
+ "name": "account_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider_id": {
+ "name": "provider_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "access_token_expires_at": {
+ "name": "access_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_expires_at": {
+ "name": "refresh_token_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "account_userId_idx": {
+ "name": "account_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "account_user_id_user_id_fk": {
+ "name": "account_user_id_user_id_fk",
+ "tableFrom": "account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.apikey": {
+ "name": "apikey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "config_id": {
+ "name": "config_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'default'"
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start": {
+ "name": "start",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prefix": {
+ "name": "prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "refill_interval": {
+ "name": "refill_interval",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refill_amount": {
+ "name": "refill_amount",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_refill_at": {
+ "name": "last_refill_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enabled": {
+ "name": "enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_enabled": {
+ "name": "rate_limit_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ },
+ "rate_limit_time_window": {
+ "name": "rate_limit_time_window",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1000
+ },
+ "rate_limit_max": {
+ "name": "rate_limit_max",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 100
+ },
+ "request_count": {
+ "name": "request_count",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 0
+ },
+ "remaining": {
+ "name": "remaining",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_request": {
+ "name": "last_request",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "permissions": {
+ "name": "permissions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "apikey_configId_idx": {
+ "name": "apikey_configId_idx",
+ "columns": [
+ {
+ "expression": "config_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_referenceId_idx": {
+ "name": "apikey_referenceId_idx",
+ "columns": [
+ {
+ "expression": "reference_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "apikey_key_idx": {
+ "name": "apikey_key_idx",
+ "columns": [
+ {
+ "expression": "key",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.jwks": {
+ "name": "jwks",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "private_key": {
+ "name": "private_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "alg": {
+ "name": "alg",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "crv": {
+ "name": "crv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_access_token": {
+ "name": "oauth_access_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_id": {
+ "name": "refresh_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthAccessToken_clientId_idx": {
+ "name": "oauthAccessToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_sessionId_idx": {
+ "name": "oauthAccessToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_userId_idx": {
+ "name": "oauthAccessToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_authorizationCodeId_idx": {
+ "name": "oauthAccessToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthAccessToken_refreshId_idx": {
+ "name": "oauthAccessToken_refreshId_idx",
+ "columns": [
+ {
+ "expression": "refresh_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_access_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_access_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_session_id_session_id_fk": {
+ "name": "oauth_access_token_session_id_session_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_user_id_user_id_fk": {
+ "name": "oauth_access_token_user_id_user_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_access_token_refresh_id_oauth_refresh_token_id_fk": {
+ "name": "oauth_access_token_refresh_id_oauth_refresh_token_id_fk",
+ "tableFrom": "oauth_access_token",
+ "tableTo": "oauth_refresh_token",
+ "columnsFrom": [
+ "refresh_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_access_token_token_unique": {
+ "name": "oauth_access_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client": {
+ "name": "oauth_client",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_secret": {
+ "name": "client_secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_discovery_id": {
+ "name": "client_discovery_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "skip_consent": {
+ "name": "skip_consent",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "enable_end_session": {
+ "name": "enable_end_session",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "subject_type": {
+ "name": "subject_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "client_credentials_scopes": {
+ "name": "client_credentials_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'{}'"
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "uri": {
+ "name": "uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "contacts": {
+ "name": "contacts",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tos": {
+ "name": "tos",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy": {
+ "name": "policy",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_id": {
+ "name": "software_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_version": {
+ "name": "software_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "software_statement": {
+ "name": "software_statement",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "redirect_uris": {
+ "name": "redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "post_logout_redirect_uris": {
+ "name": "post_logout_redirect_uris",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_uri": {
+ "name": "backchannel_logout_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "backchannel_logout_session_required": {
+ "name": "backchannel_logout_session_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "token_endpoint_auth_method": {
+ "name": "token_endpoint_auth_method",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "application_type": {
+ "name": "application_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks": {
+ "name": "jwks",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "jwks_uri": {
+ "name": "jwks_uri",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "grant_types": {
+ "name": "grant_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_types": {
+ "name": "response_types",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "require_pkce": {
+ "name": "require_pkce",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens": {
+ "name": "dpop_bound_access_tokens",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClient_userId_idx": {
+ "name": "oauthClient_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_user_id_user_id_fk": {
+ "name": "oauth_client_user_id_user_id_fk",
+ "tableFrom": "oauth_client",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_client_client_id_unique": {
+ "name": "oauth_client_client_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "client_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client_assertion": {
+ "name": "oauth_client_assertion",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_client_resource": {
+ "name": "oauth_client_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "resource_id": {
+ "name": "resource_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "oauthClientResource_clientId_resourceId_uidx": {
+ "name": "oauthClientResource_clientId_resourceId_uidx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_clientId_idx": {
+ "name": "oauthClientResource_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthClientResource_resourceId_idx": {
+ "name": "oauthClientResource_resourceId_idx",
+ "columns": [
+ {
+ "expression": "resource_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_client_resource_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_client_resource_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_client_resource_resource_id_oauth_resource_identifier_fk": {
+ "name": "oauth_client_resource_resource_id_oauth_resource_identifier_fk",
+ "tableFrom": "oauth_client_resource",
+ "tableTo": "oauth_resource",
+ "columnsFrom": [
+ "resource_id"
+ ],
+ "columnsTo": [
+ "identifier"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_consent": {
+ "name": "oauth_consent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthConsent_clientId_idx": {
+ "name": "oauthConsent_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthConsent_userId_idx": {
+ "name": "oauthConsent_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_consent_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_consent_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_consent_user_id_user_id_fk": {
+ "name": "oauth_consent_user_id_user_id_fk",
+ "tableFrom": "oauth_consent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_refresh_token": {
+ "name": "oauth_refresh_token",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "session_id": {
+ "name": "session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reference_id": {
+ "name": "reference_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "authorization_code_id": {
+ "name": "authorization_code_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "resources": {
+ "name": "resources",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "requested_user_info_claims": {
+ "name": "requested_user_info_claims",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "revoked": {
+ "name": "revoked",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotated_at": {
+ "name": "rotated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_response": {
+ "name": "rotation_replay_response",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "rotation_replay_expires_at": {
+ "name": "rotation_replay_expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "auth_time": {
+ "name": "auth_time",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "confirmation": {
+ "name": "confirmation",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "oauthRefreshToken_clientId_idx": {
+ "name": "oauthRefreshToken_clientId_idx",
+ "columns": [
+ {
+ "expression": "client_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_sessionId_idx": {
+ "name": "oauthRefreshToken_sessionId_idx",
+ "columns": [
+ {
+ "expression": "session_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_userId_idx": {
+ "name": "oauthRefreshToken_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "oauthRefreshToken_authorizationCodeId_idx": {
+ "name": "oauthRefreshToken_authorizationCodeId_idx",
+ "columns": [
+ {
+ "expression": "authorization_code_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "oauth_refresh_token_client_id_oauth_client_client_id_fk": {
+ "name": "oauth_refresh_token_client_id_oauth_client_client_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "oauth_client",
+ "columnsFrom": [
+ "client_id"
+ ],
+ "columnsTo": [
+ "client_id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_session_id_session_id_fk": {
+ "name": "oauth_refresh_token_session_id_session_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "session",
+ "columnsFrom": [
+ "session_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "oauth_refresh_token_user_id_user_id_fk": {
+ "name": "oauth_refresh_token_user_id_user_id_fk",
+ "tableFrom": "oauth_refresh_token",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_refresh_token_token_unique": {
+ "name": "oauth_refresh_token_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.oauth_resource": {
+ "name": "oauth_resource",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "access_token_ttl": {
+ "name": "access_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "refresh_token_ttl": {
+ "name": "refresh_token_ttl",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_algorithm": {
+ "name": "signing_algorithm",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "signing_key_id": {
+ "name": "signing_key_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "allowed_scopes": {
+ "name": "allowed_scopes",
+ "type": "text[]",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "custom_claims": {
+ "name": "custom_claims",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "dpop_bound_access_tokens_required": {
+ "name": "dpop_bound_access_tokens_required",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "disabled": {
+ "name": "disabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "policy_version": {
+ "name": "policy_version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false,
+ "default": 1
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "oauth_resource_identifier_unique": {
+ "name": "oauth_resource_identifier_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "identifier"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.passkey": {
+ "name": "passkey",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "public_key": {
+ "name": "public_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "counter": {
+ "name": "counter",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "device_type": {
+ "name": "device_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "backed_up": {
+ "name": "backed_up",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "transports": {
+ "name": "transports",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "aaguid": {
+ "name": "aaguid",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "passkey_userId_idx": {
+ "name": "passkey_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "passkey_credentialID_idx": {
+ "name": "passkey_credentialID_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "passkey_user_id_user_id_fk": {
+ "name": "passkey_user_id_user_id_fk",
+ "tableFrom": "passkey",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.session": {
+ "name": "session",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ip_address": {
+ "name": "ip_address",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_agent": {
+ "name": "user_agent",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "session_userId_idx": {
+ "name": "session_userId_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "session_user_id_user_id_fk": {
+ "name": "session_user_id_user_id_fk",
+ "tableFrom": "session",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "session_token_unique": {
+ "name": "session_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user": {
+ "name": "user",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_verified": {
+ "name": "email_verified",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "image": {
+ "name": "image",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_username": {
+ "name": "display_username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "default": "'user'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false,
+ "default": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_email_unique": {
+ "name": "user_email_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "email"
+ ]
+ },
+ "user_username_unique": {
+ "name": "user_username_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "username"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.verification": {
+ "name": "verification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "identifier": {
+ "name": "identifier",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "expires_at": {
+ "name": "expires_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "verification_identifier_idx": {
+ "name": "verification_identifier_idx",
+ "columns": [
+ {
+ "expression": "identifier",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_event": {
+ "name": "agent_chat_event",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "bigserial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "message_id": {
+ "name": "message_id",
+ "type": "integer",
+ "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": {
+ "agent_chat_event_message_idx": {
+ "name": "agent_chat_event_message_idx",
+ "columns": [
+ {
+ "expression": "message_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_event_message_id_agent_chat_message_id_fk": {
+ "name": "agent_chat_event_message_id_agent_chat_message_id_fk",
+ "tableFrom": "agent_chat_event",
+ "tableTo": "agent_chat_message",
+ "columnsFrom": [
+ "message_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_favorite": {
+ "name": "agent_chat_favorite",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "agent_chat_favorite_user_id_user_id_fk": {
+ "name": "agent_chat_favorite_user_id_user_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_favorite_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_favorite_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_favorite",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_chat_favorite_user_id_thread_id_pk": {
+ "name": "agent_chat_favorite_user_id_thread_id_pk",
+ "columns": [
+ "user_id",
+ "thread_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_message": {
+ "name": "agent_chat_message",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "finished_at": {
+ "name": "finished_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_message_thread_idx": {
+ "name": "agent_chat_message_thread_idx",
+ "columns": [
+ {
+ "expression": "thread_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_chat_message_due_idx": {
+ "name": "agent_chat_message_due_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming')",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_message_thread_id_agent_chat_thread_id_fk": {
+ "name": "agent_chat_message_thread_id_agent_chat_thread_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "agent_chat_thread",
+ "columnsFrom": [
+ "thread_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_message_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_message_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_message",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_chat_message_role_check": {
+ "name": "agent_chat_message_role_check",
+ "value": "\"agent_chat_message\".\"role\" IN ('user', 'assistant')"
+ },
+ "agent_chat_message_status_check": {
+ "name": "agent_chat_message_status_check",
+ "value": "\"agent_chat_message\".\"status\" IN ('pending', 'streaming', 'success', 'failed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_thread": {
+ "name": "agent_chat_thread",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cli_session_id": {
+ "name": "cli_session_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_thread_agent_user_idx": {
+ "name": "agent_chat_thread_agent_user_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_thread_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_thread_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_chat_thread_user_id_user_id_fk": {
+ "name": "agent_chat_thread_user_id_user_id_fk",
+ "tableFrom": "agent_chat_thread",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_chat_usage": {
+ "name": "agent_chat_usage",
+ "schema": "",
+ "columns": {
+ "thread_id": {
+ "name": "thread_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_chat_usage_agent_idx": {
+ "name": "agent_chat_usage_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_chat_usage_agent_id_ai_agent_id_fk": {
+ "name": "agent_chat_usage_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_chat_usage",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_field_trigger": {
+ "name": "agent_field_trigger",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ }
+ },
+ "indexes": {
+ "agent_field_trigger_field_idx": {
+ "name": "agent_field_trigger_field_idx",
+ "columns": [
+ {
+ "expression": "field_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_field_trigger_agent_id_ai_agent_id_fk": {
+ "name": "agent_field_trigger_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_field_trigger_field_id_custom_field_id_fk": {
+ "name": "agent_field_trigger_field_id_custom_field_id_fk",
+ "tableFrom": "agent_field_trigger",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_field_trigger_agent_id_field_id_pk": {
+ "name": "agent_field_trigger_agent_id_field_id_pk",
+ "columns": [
+ "agent_id",
+ "field_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_field_trigger_delay_check": {
+ "name": "agent_field_trigger_delay_check",
+ "value": "\"agent_field_trigger\".\"delay_sec\" >= 0 AND \"agent_field_trigger\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_run": {
+ "name": "agent_run",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "schedule_id": {
+ "name": "schedule_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger": {
+ "name": "trigger",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'delegation'"
+ },
+ "scheduled_for": {
+ "name": "scheduled_for",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output": {
+ "name": "output",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "input_tokens": {
+ "name": "input_tokens",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "output_tokens": {
+ "name": "output_tokens",
+ "type": "integer",
+ "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": {
+ "agent_run_schedule_fire_uq": {
+ "name": "agent_run_schedule_fire_uq",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "scheduled_for",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_due_idx": {
+ "name": "agent_run_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_schedule_idx": {
+ "name": "agent_run_schedule_idx",
+ "columns": [
+ {
+ "expression": "schedule_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_run_project_idx": {
+ "name": "agent_run_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_run_agent_id_ai_agent_id_fk": {
+ "name": "agent_run_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_project_id_project_id_fk": {
+ "name": "agent_run_project_id_project_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_issue_id_issue_id_fk": {
+ "name": "agent_run_issue_id_issue_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_schedule_id_agent_schedule_id_fk": {
+ "name": "agent_run_schedule_id_agent_schedule_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "agent_schedule",
+ "columnsFrom": [
+ "schedule_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_run_source_activity_id_issue_activity_id_fk": {
+ "name": "agent_run_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "agent_run",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "agent_run_status_check": {
+ "name": "agent_run_status_check",
+ "value": "\"agent_run\".\"status\" IN ('pending', 'success', 'failed', 'canceled')"
+ },
+ "agent_run_trigger_check": {
+ "name": "agent_run_trigger_check",
+ "value": "\"agent_run\".\"trigger\" IN ('mention', 'delegation', 'field', 'schedule', 'manual', 'status', 'event')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_schedule": {
+ "name": "agent_schedule",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "prompt": {
+ "name": "prompt",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'cron'"
+ },
+ "cron": {
+ "name": "cron",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'active'"
+ },
+ "next_run_at": {
+ "name": "next_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delay_sec": {
+ "name": "delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "options": {
+ "name": "options",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "last_run_at": {
+ "name": "last_run_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_schedule_due_idx": {
+ "name": "agent_schedule_due_idx",
+ "columns": [
+ {
+ "expression": "status",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "next_run_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_agent_idx": {
+ "name": "agent_schedule_agent_idx",
+ "columns": [
+ {
+ "expression": "agent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_project_idx": {
+ "name": "agent_schedule_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_schedule_column_idx": {
+ "name": "agent_schedule_column_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_schedule_agent_id_ai_agent_id_fk": {
+ "name": "agent_schedule_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_project_id_project_id_fk": {
+ "name": "agent_schedule_project_id_project_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_schedule_column_id_project_column_id_fk": {
+ "name": "agent_schedule_column_id_project_column_id_fk",
+ "tableFrom": "agent_schedule",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_schedule_project_id_agent_id_name_unique": {
+ "name": "agent_schedule_project_id_agent_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "agent_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_schedule_status_check": {
+ "name": "agent_schedule_status_check",
+ "value": "\"agent_schedule\".\"status\" IN ('active', 'paused')"
+ },
+ "agent_schedule_type_check": {
+ "name": "agent_schedule_type_check",
+ "value": "(\"agent_schedule\".\"type\" = 'cron' AND \"agent_schedule\".\"cron\" IS NOT NULL AND \"agent_schedule\".\"next_run_at\" IS NOT NULL AND \"agent_schedule\".\"column_id\" IS NULL)\n OR (\"agent_schedule\".\"type\" = 'status' AND \"agent_schedule\".\"column_id\" IS NOT NULL AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL)\n OR (\"agent_schedule\".\"type\" NOT IN ('cron', 'status') AND \"agent_schedule\".\"cron\" IS NULL AND \"agent_schedule\".\"next_run_at\" IS NULL AND \"agent_schedule\".\"column_id\" IS NULL)"
+ },
+ "agent_schedule_delay_check": {
+ "name": "agent_schedule_delay_check",
+ "value": "\"agent_schedule\".\"delay_sec\" >= 0 AND \"agent_schedule\".\"delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill": {
+ "name": "agent_skill",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_url": {
+ "name": "source_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_prefix": {
+ "name": "s3_prefix",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "files": {
+ "name": "files",
+ "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": {
+ "agent_skill_team_idx": {
+ "name": "agent_skill_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_team_id_team_id_fk": {
+ "name": "agent_skill_team_id_team_id_fk",
+ "tableFrom": "agent_skill",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_skill_team_id_name_unique": {
+ "name": "agent_skill_team_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "agent_skill_source_check": {
+ "name": "agent_skill_source_check",
+ "value": "\"agent_skill\".\"source\" IN ('upload', 'inline', 'github')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.agent_skill_link": {
+ "name": "agent_skill_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "skill_id": {
+ "name": "skill_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_skill_link_skill_idx": {
+ "name": "agent_skill_link_skill_idx",
+ "columns": [
+ {
+ "expression": "skill_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_skill_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_skill_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_skill_link_skill_id_agent_skill_id_fk": {
+ "name": "agent_skill_link_skill_id_agent_skill_id_fk",
+ "tableFrom": "agent_skill_link",
+ "tableTo": "agent_skill",
+ "columnsFrom": [
+ "skill_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_skill_link_agent_id_skill_id_pk": {
+ "name": "agent_skill_link_agent_id_skill_id_pk",
+ "columns": [
+ "agent_id",
+ "skill_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool": {
+ "name": "agent_tool",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "tool_key": {
+ "name": "tool_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "credential_id": {
+ "name": "credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "agent_tool_team_idx": {
+ "name": "agent_tool_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "agent_tool_credential_idx": {
+ "name": "agent_tool_credential_idx",
+ "columns": [
+ {
+ "expression": "credential_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_team_id_team_id_fk": {
+ "name": "agent_tool_team_id_team_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_credential_id_integration_credential_id_fk": {
+ "name": "agent_tool_credential_id_integration_credential_id_fk",
+ "tableFrom": "agent_tool",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "agent_tool_team_id_tool_key_credential_id_unique": {
+ "name": "agent_tool_team_id_tool_key_credential_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "tool_key",
+ "credential_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.agent_tool_link": {
+ "name": "agent_tool_link",
+ "schema": "",
+ "columns": {
+ "agent_id": {
+ "name": "agent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "agent_tool_id": {
+ "name": "agent_tool_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "agent_tool_link_tool_idx": {
+ "name": "agent_tool_link_tool_idx",
+ "columns": [
+ {
+ "expression": "agent_tool_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "agent_tool_link_agent_id_ai_agent_id_fk": {
+ "name": "agent_tool_link_agent_id_ai_agent_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "ai_agent",
+ "columnsFrom": [
+ "agent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "agent_tool_link_agent_tool_id_agent_tool_id_fk": {
+ "name": "agent_tool_link_agent_tool_id_agent_tool_id_fk",
+ "tableFrom": "agent_tool_link",
+ "tableTo": "agent_tool",
+ "columnsFrom": [
+ "agent_tool_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "agent_tool_link_agent_id_agent_tool_id_pk": {
+ "name": "agent_tool_link_agent_id_agent_tool_id_pk",
+ "columns": [
+ "agent_id",
+ "agent_tool_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.ai_agent": {
+ "name": "ai_agent",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model_credential_id": {
+ "name": "model_credential_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "instructions": {
+ "name": "instructions",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "tools": {
+ "name": "tools",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "temperature": {
+ "name": "temperature",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "reasoning_effort": {
+ "name": "reasoning_effort",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "max_steps": {
+ "name": "max_steps",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "trigger_on_mention": {
+ "name": "trigger_on_mention",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "trigger_on_assign": {
+ "name": "trigger_on_assign",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "delegation_delay_sec": {
+ "name": "delegation_delay_sec",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 120
+ },
+ "api_key_ciphertext": {
+ "name": "api_key_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_iv": {
+ "name": "api_key_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "api_key_auth_tag": {
+ "name": "api_key_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "memory_enabled": {
+ "name": "memory_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "memory_last_messages": {
+ "name": "memory_last_messages",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "runner_scope": {
+ "name": "runner_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'team'"
+ },
+ "last_seen_at": {
+ "name": "last_seen_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_url": {
+ "name": "invocation_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_ciphertext": {
+ "name": "invocation_secret_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_iv": {
+ "name": "invocation_secret_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "invocation_secret_auth_tag": {
+ "name": "invocation_secret_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "ai_agent_team_username_uq": {
+ "name": "ai_agent_team_username_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(\"username\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "ai_agent_team_idx": {
+ "name": "ai_agent_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "ai_agent_team_id_team_id_fk": {
+ "name": "ai_agent_team_id_team_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_user_id_user_id_fk": {
+ "name": "ai_agent_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "ai_agent_model_credential_id_integration_credential_id_fk": {
+ "name": "ai_agent_model_credential_id_integration_credential_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "integration_credential",
+ "columnsFrom": [
+ "model_credential_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "ai_agent_owner_user_id_user_id_fk": {
+ "name": "ai_agent_owner_user_id_user_id_fk",
+ "tableFrom": "ai_agent",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "ai_agent_user_id_unique": {
+ "name": "ai_agent_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "ai_agent_kind_check": {
+ "name": "ai_agent_kind_check",
+ "value": "\"ai_agent\".\"kind\" IN ('external', 'internal')"
+ },
+ "ai_agent_runner_scope_check": {
+ "name": "ai_agent_runner_scope_check",
+ "value": "\"ai_agent\".\"runner_scope\" IN ('owner', 'team')"
+ },
+ "ai_agent_reasoning_effort_check": {
+ "name": "ai_agent_reasoning_effort_check",
+ "value": "\"ai_agent\".\"reasoning_effort\" IN ('low', 'medium', 'high')"
+ },
+ "ai_agent_delegation_delay_check": {
+ "name": "ai_agent_delegation_delay_check",
+ "value": "\"ai_agent\".\"delegation_delay_sec\" >= 0 AND \"ai_agent\".\"delegation_delay_sec\" <= 86400"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.app_secret": {
+ "name": "app_secret",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "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.app_setting": {
+ "name": "app_setting",
+ "schema": "",
+ "columns": {
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "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.chat_attachment": {
+ "name": "chat_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "chat_attachment_project_idx": {
+ "name": "chat_attachment_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "chat_attachment_project_id_project_id_fk": {
+ "name": "chat_attachment_project_id_project_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "chat_attachment_uploaded_by_user_id_user_id_fk": {
+ "name": "chat_attachment_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "chat_attachment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "chat_attachment_public_id_unique": {
+ "name": "chat_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.custom_field": {
+ "name": "custom_field",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_type_id": {
+ "name": "issue_type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_type": {
+ "name": "field_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "member_scope": {
+ "name": "member_scope",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "show_in_body": {
+ "name": "show_in_body",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_project_id_project_id_fk": {
+ "name": "custom_field_project_id_project_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "custom_field_issue_type_id_issue_type_id_fk": {
+ "name": "custom_field_issue_type_id_issue_type_id_fk",
+ "tableFrom": "custom_field",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "issue_type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "custom_field_field_type_check": {
+ "name": "custom_field_field_type_check",
+ "value": "\"custom_field\".\"field_type\" IN ('text', 'markdown', 'url', 'number', 'boolean', 'date', 'datetime', 'datetime_range', 'select', 'multi_select', 'member')"
+ },
+ "custom_field_member_scope_check": {
+ "name": "custom_field_member_scope_check",
+ "value": "(\"custom_field\".\"field_type\" = 'member') = (\"custom_field\".\"member_scope\" IS NOT NULL) AND (\"custom_field\".\"member_scope\" IS NULL OR \"custom_field\".\"member_scope\" IN ('all', 'humans', 'agents'))"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.custom_field_option": {
+ "name": "custom_field_option",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "custom_field_option_field_id_custom_field_id_fk": {
+ "name": "custom_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "custom_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "custom_field_option_field_id_value_unique": {
+ "name": "custom_field_option_field_id_value_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "field_id",
+ "value"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.cycle": {
+ "name": "cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "goal": {
+ "name": "goal",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "end_date": {
+ "name": "end_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "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": {
+ "cycle_project_idx": {
+ "name": "cycle_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "start_date",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "cycle_project_id_project_id_fk": {
+ "name": "cycle_project_id_project_id_fk",
+ "tableFrom": "cycle",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "cycle_dates_check": {
+ "name": "cycle_dates_check",
+ "value": "\"cycle\".\"end_date\" >= \"cycle\".\"start_date\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.document_asset": {
+ "name": "document_asset",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "uploaded_by_user_id": {
+ "name": "uploaded_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_asset_document_idx": {
+ "name": "document_asset_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_asset_document_id_project_document_id_fk": {
+ "name": "document_asset_document_id_project_document_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_asset_uploaded_by_user_id_user_id_fk": {
+ "name": "document_asset_uploaded_by_user_id_user_id_fk",
+ "tableFrom": "document_asset",
+ "tableTo": "user",
+ "columnsFrom": [
+ "uploaded_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "document_asset_public_id_unique": {
+ "name": "document_asset_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_collaboration": {
+ "name": "document_collaboration",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "epoch": {
+ "name": "epoch",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_collaboration_document_id_project_document_id_fk": {
+ "name": "document_collaboration_document_id_project_document_id_fk",
+ "tableFrom": "document_collaboration",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_comment": {
+ "name": "document_comment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "author_id": {
+ "name": "author_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "quote": {
+ "name": "quote",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "selection_from": {
+ "name": "selection_from",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "selection_to": {
+ "name": "selection_to",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "orphaned": {
+ "name": "orphaned",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "resolved_at": {
+ "name": "resolved_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "document_comment_document_idx": {
+ "name": "document_comment_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "created_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "document_comment_document_id_project_document_id_fk": {
+ "name": "document_comment_document_id_project_document_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_parent_id_document_comment_id_fk": {
+ "name": "document_comment_parent_id_document_comment_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "document_comment",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "document_comment_author_id_user_id_fk": {
+ "name": "document_comment_author_id_user_id_fk",
+ "tableFrom": "document_comment",
+ "tableTo": "user",
+ "columnsFrom": [
+ "author_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.document_step": {
+ "name": "document_step",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "client_id": {
+ "name": "client_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "step": {
+ "name": "step",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "document_step_document_id_project_document_id_fk": {
+ "name": "document_step_document_id_project_document_id_fk",
+ "tableFrom": "document_step",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "document_step_document_id_version_pk": {
+ "name": "document_step_document_id_version_pk",
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_managed_repository": {
+ "name": "git_managed_repository",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "connection_id": {
+ "name": "connection_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "full_name": {
+ "name": "full_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "web_url": {
+ "name": "web_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "webhook_external_id": {
+ "name": "webhook_external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'connected'"
+ },
+ "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": {
+ "git_managed_repository_project_connection_idx": {
+ "name": "git_managed_repository_project_connection_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "connection_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_managed_repository_project_id_project_id_fk": {
+ "name": "git_managed_repository_project_id_project_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "git_managed_repository_connection_id_git_provider_connection_id_fk": {
+ "name": "git_managed_repository_connection_id_git_provider_connection_id_fk",
+ "tableFrom": "git_managed_repository",
+ "tableTo": "git_provider_connection",
+ "columnsFrom": [
+ "connection_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "git_managed_repository_project_connection_external_unique": {
+ "name": "git_managed_repository_project_connection_external_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "connection_id",
+ "external_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.git_provider_connection": {
+ "name": "git_provider_connection",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "base_url": {
+ "name": "base_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "account_login": {
+ "name": "account_login",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "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": {
+ "git_provider_connection_team_idx": {
+ "name": "git_provider_connection_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "git_provider_connection_team_id_team_id_fk": {
+ "name": "git_provider_connection_team_id_team_id_fk",
+ "tableFrom": "git_provider_connection",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.import_job": {
+ "name": "import_job",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "phase": {
+ "name": "phase",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'discover'"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "config": {
+ "name": "config",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "cursor": {
+ "name": "cursor",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "credential_ciphertext": {
+ "name": "credential_ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_iv": {
+ "name": "credential_iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "credential_auth_tag": {
+ "name": "credential_auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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": {
+ "import_job_project_idx": {
+ "name": "import_job_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_job_due_idx": {
+ "name": "import_job_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"import_job\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_job_project_id_project_id_fk": {
+ "name": "import_job_project_id_project_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "import_job_created_by_user_id_user_id_fk": {
+ "name": "import_job_created_by_user_id_user_id_fk",
+ "tableFrom": "import_job",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_job_source_check": {
+ "name": "import_job_source_check",
+ "value": "\"import_job\".\"source\" IN ('plane', 'linear')"
+ },
+ "import_job_phase_check": {
+ "name": "import_job_phase_check",
+ "value": "\"import_job\".\"phase\" IN ('discover', 'create', 'link', 'rewrite', 'attachments', 'done')"
+ },
+ "import_job_status_check": {
+ "name": "import_job_status_check",
+ "value": "\"import_job\".\"status\" IN ('pending', 'running', 'paused', 'completed', 'failed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.import_record": {
+ "name": "import_record",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "import_job_id": {
+ "name": "import_job_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_entity_type": {
+ "name": "source_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_display_id": {
+ "name": "source_display_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_entity_type": {
+ "name": "local_entity_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "local_id": {
+ "name": "local_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "import_record_job_source_uq": {
+ "name": "import_record_job_source_uq",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_local_idx": {
+ "name": "import_record_job_local_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "local_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "import_record_job_display_idx": {
+ "name": "import_record_job_display_idx",
+ "columns": [
+ {
+ "expression": "import_job_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_entity_type",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "source_display_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "import_record_import_job_id_import_job_id_fk": {
+ "name": "import_record_import_job_id_import_job_id_fk",
+ "tableFrom": "import_record",
+ "tableTo": "import_job",
+ "columnsFrom": [
+ "import_job_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "import_record_source_entity_type_check": {
+ "name": "import_record_source_entity_type_check",
+ "value": "\"import_record\".\"source_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"
+ },
+ "import_record_local_entity_type_check": {
+ "name": "import_record_local_entity_type_check",
+ "value": "\"import_record\".\"local_entity_type\" IS NULL OR \"import_record\".\"local_entity_type\" IN ('issue', 'comment', 'label', 'state', 'cycle', 'attachment')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative": {
+ "name": "initiative",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'planned'"
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_date": {
+ "name": "target_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_project_idx": {
+ "name": "initiative_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_project_id_project_id_fk": {
+ "name": "initiative_project_id_project_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_owner_user_id_user_id_fk": {
+ "name": "initiative_owner_user_id_user_id_fk",
+ "tableFrom": "initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "initiative_status_check": {
+ "name": "initiative_status_check",
+ "value": "\"initiative\".\"status\" IN ('proposed', 'planned', 'active', 'completed', 'canceled')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.initiative_attachment": {
+ "name": "initiative_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "initiative_attachment_initiative_idx": {
+ "name": "initiative_attachment_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "initiative_attachment_initiative_id_initiative_id_fk": {
+ "name": "initiative_attachment_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_attachment",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "initiative_attachment_public_id_unique": {
+ "name": "initiative_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.initiative_label": {
+ "name": "initiative_label",
+ "schema": "",
+ "columns": {
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "initiative_label_initiative_id_initiative_id_fk": {
+ "name": "initiative_label_initiative_id_initiative_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "initiative_label_label_id_label_id_fk": {
+ "name": "initiative_label_label_id_label_id_fk",
+ "tableFrom": "initiative_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "initiative_label_initiative_id_label_id_pk": {
+ "name": "initiative_label_initiative_id_label_id_pk",
+ "columns": [
+ "initiative_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.integration_credential": {
+ "name": "integration_credential",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "integration_key": {
+ "name": "integration_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label": {
+ "name": "label",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "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": {
+ "integration_credential_team_idx": {
+ "name": "integration_credential_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "integration_credential_team_id_team_id_fk": {
+ "name": "integration_credential_team_id_team_id_fk",
+ "tableFrom": "integration_credential",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue": {
+ "name": "issue",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "delegate_user_id": {
+ "name": "delegate_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_points": {
+ "name": "estimate_points",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "estimate_minutes": {
+ "name": "estimate_minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "start_date": {
+ "name": "start_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "due_date": {
+ "name": "due_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_extended": {
+ "name": "share_extended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_project_active_idx": {
+ "name": "issue_project_active_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"archived_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_project_title_idx": {
+ "name": "issue_project_title_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "lower(btrim(\"title\"))",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_parent_idx": {
+ "name": "issue_parent_idx",
+ "columns": [
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"parent_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_idx": {
+ "name": "issue_cycle_idx",
+ "columns": [
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue\".\"cycle_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_project_id_project_id_fk": {
+ "name": "issue_project_id_project_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_type_id_issue_type_id_fk": {
+ "name": "issue_type_id_issue_type_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_initiative_id_initiative_id_fk": {
+ "name": "issue_initiative_id_initiative_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_id_cycle_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "cycle",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_column_id_project_column_id_fk": {
+ "name": "issue_column_id_project_column_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ },
+ "issue_parent_id_issue_id_fk": {
+ "name": "issue_parent_id_issue_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_assignee_user_id_user_id_fk": {
+ "name": "issue_assignee_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "assignee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_delegate_user_id_user_id_fk": {
+ "name": "issue_delegate_user_id_user_id_fk",
+ "tableFrom": "issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "delegate_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_share_token_unique": {
+ "name": "issue_share_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "share_token"
+ ]
+ },
+ "issue_project_id_sequence_number_unique": {
+ "name": "issue_project_id_sequence_number_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "issue_estimate_points_check": {
+ "name": "issue_estimate_points_check",
+ "value": "\"issue\".\"estimate_points\" >= 0"
+ },
+ "issue_estimate_minutes_check": {
+ "name": "issue_estimate_minutes_check",
+ "value": "\"issue\".\"estimate_minutes\" >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_activity": {
+ "name": "issue_activity",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "reply_to_id": {
+ "name": "reply_to_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "body": {
+ "name": "body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "action": {
+ "name": "action",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "edited_at": {
+ "name": "edited_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": {
+ "issue_activity_issue_idx": {
+ "name": "issue_activity_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_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": {}
+ },
+ "issue_activity_reply_idx": {
+ "name": "issue_activity_reply_idx",
+ "columns": [
+ {
+ "expression": "reply_to_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_activity_initiative_idx": {
+ "name": "issue_activity_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_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": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_activity_issue_id_issue_id_fk": {
+ "name": "issue_activity_issue_id_issue_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_initiative_id_initiative_id_fk": {
+ "name": "issue_activity_initiative_id_initiative_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_reply_to_id_issue_activity_id_fk": {
+ "name": "issue_activity_reply_to_id_issue_activity_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "reply_to_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_activity_actor_user_id_user_id_fk": {
+ "name": "issue_activity_actor_user_id_user_id_fk",
+ "tableFrom": "issue_activity",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_activity_kind_check": {
+ "name": "issue_activity_kind_check",
+ "value": "\"issue_activity\".\"kind\" IN ('comment', 'activity')"
+ },
+ "issue_activity_owner_check": {
+ "name": "issue_activity_owner_check",
+ "value": "(\"issue_activity\".\"issue_id\" IS NOT NULL) <> (\"issue_activity\".\"initiative_id\" IS NOT NULL)"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_attachment": {
+ "name": "issue_attachment",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "s3_key": {
+ "name": "s3_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "filename": {
+ "name": "filename",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_type": {
+ "name": "content_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "size_bytes": {
+ "name": "size_bytes",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_attachment_issue_idx": {
+ "name": "issue_attachment_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_attachment_issue_id_issue_id_fk": {
+ "name": "issue_attachment_issue_id_issue_id_fk",
+ "tableFrom": "issue_attachment",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_attachment_public_id_unique": {
+ "name": "issue_attachment_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist": {
+ "name": "issue_checklist",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_issue_idx": {
+ "name": "issue_checklist_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_issue_id_issue_id_fk": {
+ "name": "issue_checklist_issue_id_issue_id_fk",
+ "tableFrom": "issue_checklist",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_checklist_item": {
+ "name": "issue_checklist_item",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "checklist_id": {
+ "name": "checklist_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "done": {
+ "name": "done",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_checklist_item_checklist_idx": {
+ "name": "issue_checklist_item_checklist_idx",
+ "columns": [
+ {
+ "expression": "checklist_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_checklist_item_checklist_id_issue_checklist_id_fk": {
+ "name": "issue_checklist_item_checklist_id_issue_checklist_id_fk",
+ "tableFrom": "issue_checklist_item",
+ "tableTo": "issue_checklist",
+ "columnsFrom": [
+ "checklist_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_cycle": {
+ "name": "issue_cycle",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cycle_id": {
+ "name": "cycle_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "entered_at": {
+ "name": "entered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "left_at": {
+ "name": "left_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "issue_cycle_issue_idx": {
+ "name": "issue_cycle_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_cycle_idx": {
+ "name": "issue_cycle_cycle_idx",
+ "columns": [
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_cycle_open_idx": {
+ "name": "issue_cycle_open_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "cycle_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"issue_cycle\".\"left_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_cycle_issue_id_issue_id_fk": {
+ "name": "issue_cycle_issue_id_issue_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_cycle_cycle_id_cycle_id_fk": {
+ "name": "issue_cycle_cycle_id_cycle_id_fk",
+ "tableFrom": "issue_cycle",
+ "tableTo": "cycle",
+ "columnsFrom": [
+ "cycle_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_development_check": {
+ "name": "issue_development_check",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "development_link_id": {
+ "name": "development_link_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "app_id": {
+ "name": "app_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_development_check_link_sha_idx": {
+ "name": "issue_development_check_link_sha_idx",
+ "columns": [
+ {
+ "expression": "development_link_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_development_check_development_link_id_issue_development_link_id_fk": {
+ "name": "issue_development_check_development_link_id_issue_development_link_id_fk",
+ "tableFrom": "issue_development_check",
+ "tableTo": "issue_development_link",
+ "columnsFrom": [
+ "development_link_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_development_check_development_link_id_app_id_name_unique": {
+ "name": "issue_development_check_development_link_id_app_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "development_link_id",
+ "app_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_development_link": {
+ "name": "issue_development_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "repository": {
+ "name": "repository",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pull_request'"
+ },
+ "external_key": {
+ "name": "external_key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "number": {
+ "name": "number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state": {
+ "name": "state",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "draft": {
+ "name": "draft",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "source_branch": {
+ "name": "source_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "target_branch": {
+ "name": "target_branch",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "head_sha": {
+ "name": "head_sha",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pipeline_status": {
+ "name": "pipeline_status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "pipeline_url": {
+ "name": "pipeline_url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_development_link_issue_idx": {
+ "name": "issue_development_link_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_development_link_pr_idx": {
+ "name": "issue_development_link_pr_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repository",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "number",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_development_link_sha_idx": {
+ "name": "issue_development_link_sha_idx",
+ "columns": [
+ {
+ "expression": "provider",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "repository",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "head_sha",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_development_link_issue_id_issue_id_fk": {
+ "name": "issue_development_link_issue_id_issue_id_fk",
+ "tableFrom": "issue_development_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_development_link_issue_id_provider_repository_external_key_unique": {
+ "name": "issue_development_link_issue_id_provider_repository_external_key_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "provider",
+ "repository",
+ "external_key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_option": {
+ "name": "issue_field_option",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "option_id": {
+ "name": "option_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_option_issue_id_issue_id_fk": {
+ "name": "issue_field_option_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_field_id_custom_field_id_fk": {
+ "name": "issue_field_option_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_option_option_id_custom_field_option_id_fk": {
+ "name": "issue_field_option_option_id_custom_field_option_id_fk",
+ "tableFrom": "issue_field_option",
+ "tableTo": "custom_field_option",
+ "columnsFrom": [
+ "option_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_field_option_issue_id_field_id_option_id_pk": {
+ "name": "issue_field_option_issue_id_field_id_option_id_pk",
+ "columns": [
+ "issue_id",
+ "field_id",
+ "option_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_field_value": {
+ "name": "issue_field_value",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "field_id": {
+ "name": "field_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value_text": {
+ "name": "value_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_number": {
+ "name": "value_number",
+ "type": "numeric",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_bool": {
+ "name": "value_bool",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_date": {
+ "name": "value_date",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime": {
+ "name": "value_datetime",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_datetime_end": {
+ "name": "value_datetime_end",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "value_user_id": {
+ "name": "value_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_field_value_issue_id_issue_id_fk": {
+ "name": "issue_field_value_issue_id_issue_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_field_id_custom_field_id_fk": {
+ "name": "issue_field_value_field_id_custom_field_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "custom_field",
+ "columnsFrom": [
+ "field_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_field_value_value_user_id_user_id_fk": {
+ "name": "issue_field_value_value_user_id_user_id_fk",
+ "tableFrom": "issue_field_value",
+ "tableTo": "user",
+ "columnsFrom": [
+ "value_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_field_value_issue_id_field_id_unique": {
+ "name": "issue_field_value_issue_id_field_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "issue_id",
+ "field_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_import": {
+ "name": "issue_import",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "public_id": {
+ "name": "public_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "attachment_id": {
+ "name": "attachment_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'mapped'"
+ },
+ "mapping": {
+ "name": "mapping",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "error_text": {
+ "name": "error_text",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_import_project_idx": {
+ "name": "issue_import_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_import_project_id_project_id_fk": {
+ "name": "issue_import_project_id_project_id_fk",
+ "tableFrom": "issue_import",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_import_attachment_id_chat_attachment_id_fk": {
+ "name": "issue_import_attachment_id_chat_attachment_id_fk",
+ "tableFrom": "issue_import",
+ "tableTo": "chat_attachment",
+ "columnsFrom": [
+ "attachment_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_import_public_id_unique": {
+ "name": "issue_import_public_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "public_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_key_alias": {
+ "name": "issue_key_alias",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "sequence_number": {
+ "name": "sequence_number",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "issue_key_alias_issue_idx": {
+ "name": "issue_key_alias_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_key_alias_project_id_project_id_fk": {
+ "name": "issue_key_alias_project_id_project_id_fk",
+ "tableFrom": "issue_key_alias",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_key_alias_issue_id_issue_id_fk": {
+ "name": "issue_key_alias_issue_id_issue_id_fk",
+ "tableFrom": "issue_key_alias",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_key_alias_project_id_sequence_number_pk": {
+ "name": "issue_key_alias_project_id_sequence_number_pk",
+ "columns": [
+ "project_id",
+ "sequence_number"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_label": {
+ "name": "issue_label",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_label_issue_id_issue_id_fk": {
+ "name": "issue_label_issue_id_issue_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_label_label_id_label_id_fk": {
+ "name": "issue_label_label_id_label_id_fk",
+ "tableFrom": "issue_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_label_issue_id_label_id_pk": {
+ "name": "issue_label_issue_id_label_id_pk",
+ "columns": [
+ "issue_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_link": {
+ "name": "issue_link",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "source_issue_id": {
+ "name": "source_issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "target_issue_id": {
+ "name": "target_issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "kind": {
+ "name": "kind",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_link_pair_kind_idx": {
+ "name": "issue_link_pair_kind_idx",
+ "columns": [
+ {
+ "expression": "least(\"source_issue_id\", \"target_issue_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "greatest(\"source_issue_id\", \"target_issue_id\")",
+ "asc": true,
+ "isExpression": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "kind",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_link_source_idx": {
+ "name": "issue_link_source_idx",
+ "columns": [
+ {
+ "expression": "source_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_link_target_idx": {
+ "name": "issue_link_target_idx",
+ "columns": [
+ {
+ "expression": "target_issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_link_source_issue_id_issue_id_fk": {
+ "name": "issue_link_source_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "source_issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_link_target_issue_id_issue_id_fk": {
+ "name": "issue_link_target_issue_id_issue_id_fk",
+ "tableFrom": "issue_link",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "target_issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_link_kind_check": {
+ "name": "issue_link_kind_check",
+ "value": "\"issue_link\".\"kind\" IN ('blocks', 'relates', 'duplicates')"
+ },
+ "issue_link_self_check": {
+ "name": "issue_link_self_check",
+ "value": "\"issue_link\".\"source_issue_id\" <> \"issue_link\".\"target_issue_id\""
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.issue_status": {
+ "name": "issue_status",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_name": {
+ "name": "column_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "entered_at": {
+ "name": "entered_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "left_at": {
+ "name": "left_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "issue_status_issue_idx": {
+ "name": "issue_status_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "entered_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_status_column_idx": {
+ "name": "issue_status_column_idx",
+ "columns": [
+ {
+ "expression": "column_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"issue_status\".\"column_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "issue_status_open_idx": {
+ "name": "issue_status_open_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"issue_status\".\"left_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_status_issue_id_issue_id_fk": {
+ "name": "issue_status_issue_id_issue_id_fk",
+ "tableFrom": "issue_status",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_status_column_id_project_column_id_fk": {
+ "name": "issue_status_column_id_project_column_id_fk",
+ "tableFrom": "issue_status",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_template": {
+ "name": "issue_template",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "title_template": {
+ "name": "title_template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "description_template": {
+ "name": "description_template",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "type_id": {
+ "name": "type_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "column_id": {
+ "name": "column_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "priority": {
+ "name": "priority",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "assignee_user_id": {
+ "name": "assignee_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_template_project_id_project_id_fk": {
+ "name": "issue_template_project_id_project_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_template_type_id_issue_type_id_fk": {
+ "name": "issue_template_type_id_issue_type_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "issue_type",
+ "columnsFrom": [
+ "type_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_template_column_id_project_column_id_fk": {
+ "name": "issue_template_column_id_project_column_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "project_column",
+ "columnsFrom": [
+ "column_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "issue_template_assignee_user_id_user_id_fk": {
+ "name": "issue_template_assignee_user_id_user_id_fk",
+ "tableFrom": "issue_template",
+ "tableTo": "user",
+ "columnsFrom": [
+ "assignee_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_template_project_id_name_unique": {
+ "name": "issue_template_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_template_label": {
+ "name": "issue_template_label",
+ "schema": "",
+ "columns": {
+ "template_id": {
+ "name": "template_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "label_id": {
+ "name": "label_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_template_label_template_id_issue_template_id_fk": {
+ "name": "issue_template_label_template_id_issue_template_id_fk",
+ "tableFrom": "issue_template_label",
+ "tableTo": "issue_template",
+ "columnsFrom": [
+ "template_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_template_label_label_id_label_id_fk": {
+ "name": "issue_template_label_label_id_label_id_fk",
+ "tableFrom": "issue_template_label",
+ "tableTo": "label",
+ "columnsFrom": [
+ "label_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_template_label_template_id_label_id_pk": {
+ "name": "issue_template_label_template_id_label_id_pk",
+ "columns": [
+ "template_id",
+ "label_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_type": {
+ "name": "issue_type",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "issue_type_project_id_project_id_fk": {
+ "name": "issue_type_project_id_project_id_fk",
+ "tableFrom": "issue_type",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "issue_type_project_id_name_unique": {
+ "name": "issue_type_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_watcher": {
+ "name": "issue_watcher",
+ "schema": "",
+ "columns": {
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "subscribed": {
+ "name": "subscribed",
+ "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": {},
+ "foreignKeys": {
+ "issue_watcher_issue_id_issue_id_fk": {
+ "name": "issue_watcher_issue_id_issue_id_fk",
+ "tableFrom": "issue_watcher",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_watcher_user_id_user_id_fk": {
+ "name": "issue_watcher_user_id_user_id_fk",
+ "tableFrom": "issue_watcher",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "issue_watcher_issue_id_user_id_pk": {
+ "name": "issue_watcher_issue_id_user_id_pk",
+ "columns": [
+ "issue_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.issue_worklog": {
+ "name": "issue_worklog",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "minutes": {
+ "name": "minutes",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "spent_on": {
+ "name": "spent_on",
+ "type": "date",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "note": {
+ "name": "note",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "issue_worklog_issue_idx": {
+ "name": "issue_worklog_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "spent_on",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "issue_worklog_issue_id_issue_id_fk": {
+ "name": "issue_worklog_issue_id_issue_id_fk",
+ "tableFrom": "issue_worklog",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "issue_worklog_user_id_user_id_fk": {
+ "name": "issue_worklog_user_id_user_id_fk",
+ "tableFrom": "issue_worklog",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "issue_worklog_minutes_check": {
+ "name": "issue_worklog_minutes_check",
+ "value": "\"issue_worklog\".\"minutes\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.label": {
+ "name": "label",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_project_id_project_id_fk": {
+ "name": "label_project_id_project_id_fk",
+ "tableFrom": "label",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "label_group_id_label_group_id_fk": {
+ "name": "label_group_id_label_group_id_fk",
+ "tableFrom": "label",
+ "tableTo": "label_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_project_id_name_unique": {
+ "name": "label_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.label_group": {
+ "name": "label_group",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "label_group_project_id_project_id_fk": {
+ "name": "label_group_project_id_project_id_fk",
+ "tableFrom": "label_group",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "label_group_project_id_name_unique": {
+ "name": "label_group_project_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.model_price": {
+ "name": "model_price",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "model": {
+ "name": "model",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "input": {
+ "name": "input",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "output": {
+ "name": "output",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "cache_read": {
+ "name": "cache_read",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "cache_write": {
+ "name": "cache_write",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "model_price_workspace_id_workspace_id_fk": {
+ "name": "model_price_workspace_id_workspace_id_fk",
+ "tableFrom": "model_price",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "model_price_workspace_id_provider_model_unique": {
+ "name": "model_price_workspace_id_provider_model_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "provider",
+ "model"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "model_price_rates_check": {
+ "name": "model_price_rates_check",
+ "value": "\"model_price\".\"input\" >= 0 AND \"model_price\".\"output\" >= 0 AND coalesce(\"model_price\".\"cache_read\", 0) >= 0 AND coalesce(\"model_price\".\"cache_write\", 0) >= 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.note_board": {
+ "name": "note_board",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "canvas": {
+ "name": "canvas",
+ "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": {
+ "note_board_project_idx": {
+ "name": "note_board_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "updated_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "note_board_project_id_project_id_fk": {
+ "name": "note_board_project_id_project_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_owner_user_id_user_id_fk": {
+ "name": "note_board_owner_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_created_by_user_id_user_id_fk": {
+ "name": "note_board_created_by_user_id_user_id_fk",
+ "tableFrom": "note_board",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.note_board_member": {
+ "name": "note_board_member",
+ "schema": "",
+ "columns": {
+ "board_id": {
+ "name": "board_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "note_board_member_user_idx": {
+ "name": "note_board_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "note_board_member_board_id_note_board_id_fk": {
+ "name": "note_board_member_board_id_note_board_id_fk",
+ "tableFrom": "note_board_member",
+ "tableTo": "note_board",
+ "columnsFrom": [
+ "board_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "note_board_member_user_id_user_id_fk": {
+ "name": "note_board_member_user_id_user_id_fk",
+ "tableFrom": "note_board_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "note_board_member_board_id_user_id_pk": {
+ "name": "note_board_member_board_id_user_id_pk",
+ "columns": [
+ "board_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.notification": {
+ "name": "notification",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "source_activity_id": {
+ "name": "source_activity_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "type": {
+ "name": "type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "actor_user_id": {
+ "name": "actor_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "actor_name": {
+ "name": "actor_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "read_at": {
+ "name": "read_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "snoozed_until": {
+ "name": "snoozed_until",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "notification_user_idx": {
+ "name": "notification_user_idx",
+ "columns": [
+ {
+ "expression": "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": {}
+ },
+ "notification_user_unread_idx": {
+ "name": "notification_user_unread_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": false,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification\".\"read_at\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_user_id_user_id_fk": {
+ "name": "notification_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_project_id_project_id_fk": {
+ "name": "notification_project_id_project_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_issue_id_issue_id_fk": {
+ "name": "notification_issue_id_issue_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "notification_source_activity_id_issue_activity_id_fk": {
+ "name": "notification_source_activity_id_issue_activity_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "issue_activity",
+ "columnsFrom": [
+ "source_activity_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "notification_actor_user_id_user_id_fk": {
+ "name": "notification_actor_user_id_user_id_fk",
+ "tableFrom": "notification",
+ "tableTo": "user",
+ "columnsFrom": [
+ "actor_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_type_check": {
+ "name": "notification_type_check",
+ "value": "\"notification\".\"type\" IN ('assigned', 'mentioned', 'commented', 'state_changed')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.notification_delivery": {
+ "name": "notification_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "channel": {
+ "name": "channel",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "recipient": {
+ "name": "recipient",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "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()"
+ }
+ },
+ "indexes": {
+ "notification_delivery_due_idx": {
+ "name": "notification_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"notification_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "notification_delivery_project_id_project_id_fk": {
+ "name": "notification_delivery_project_id_project_id_fk",
+ "tableFrom": "notification_delivery",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "notification_delivery_channel_check": {
+ "name": "notification_delivery_channel_check",
+ "value": "\"notification_delivery\".\"channel\" IN ('email', 'telegram')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project": {
+ "name": "project",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "next_sequence": {
+ "name": "next_sequence",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "initiatives_enabled": {
+ "name": "initiatives_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "dashboards_enabled": {
+ "name": "dashboards_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "documents_enabled": {
+ "name": "documents_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "notes_enabled": {
+ "name": "notes_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "cycles_enabled": {
+ "name": "cycles_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "subtasks_enabled": {
+ "name": "subtasks_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "checklists_enabled": {
+ "name": "checklists_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_enabled": {
+ "name": "issue_stats_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "points_estimate_enabled": {
+ "name": "points_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_estimate_enabled": {
+ "name": "time_estimate_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "time_logging_enabled": {
+ "name": "time_logging_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_team_id_team_id_fk": {
+ "name": "project_team_id_team_id_fk",
+ "tableFrom": "project",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_team_key_uq": {
+ "name": "project_team_key_uq",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "key"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_action": {
+ "name": "project_action",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "condition": {
+ "name": "condition",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "effect": {
+ "name": "effect",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_action_project_idx": {
+ "name": "project_action_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_action_project_id_project_id_fk": {
+ "name": "project_action_project_id_project_id_fk",
+ "tableFrom": "project_action",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_column": {
+ "name": "project_column",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "state_type": {
+ "name": "state_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'unstarted'"
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'#6b7280'"
+ },
+ "position": {
+ "name": "position",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "wip_limit": {
+ "name": "wip_limit",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "wip_mode": {
+ "name": "wip_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'soft'"
+ },
+ "auto_assign_user_id": {
+ "name": "auto_assign_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_column_project_id_project_id_fk": {
+ "name": "project_column_project_id_project_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_column_auto_assign_user_id_user_id_fk": {
+ "name": "project_column_auto_assign_user_id_user_id_fk",
+ "tableFrom": "project_column",
+ "tableTo": "user",
+ "columnsFrom": [
+ "auto_assign_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_column_project_id_position_unique": {
+ "name": "project_column_project_id_position_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "project_id",
+ "position"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "project_column_state_type_check": {
+ "name": "project_column_state_type_check",
+ "value": "\"project_column\".\"state_type\" IN ('backlog', 'unstarted', 'started', 'completed', 'canceled')"
+ },
+ "project_column_wip_mode_check": {
+ "name": "project_column_wip_mode_check",
+ "value": "\"project_column\".\"wip_mode\" IN ('soft', 'hard')"
+ },
+ "project_column_wip_limit_check": {
+ "name": "project_column_wip_limit_check",
+ "value": "\"project_column\".\"wip_limit\" IS NULL OR \"project_column\".\"wip_limit\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_dashboard": {
+ "name": "project_dashboard",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "layout": {
+ "name": "layout",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_dashboard_project_idx": {
+ "name": "project_dashboard_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_dashboard_project_id_project_id_fk": {
+ "name": "project_dashboard_project_id_project_id_fk",
+ "tableFrom": "project_dashboard",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document": {
+ "name": "project_document",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "archived_by_ancestor_id": {
+ "name": "archived_by_ancestor_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 1
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "updated_by_user_id": {
+ "name": "updated_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_project_tree_idx": {
+ "name": "project_document_project_tree_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "parent_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_owner_idx": {
+ "name": "project_document_owner_idx",
+ "columns": [
+ {
+ "expression": "owner_user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "project_document_project_archive_idx": {
+ "name": "project_document_project_archive_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "archived_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_project_id_project_id_fk": {
+ "name": "project_document_project_id_project_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_parent_id_project_document_id_fk": {
+ "name": "project_document_parent_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "parent_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_archived_by_ancestor_id_project_document_id_fk": {
+ "name": "project_document_archived_by_ancestor_id_project_document_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "archived_by_ancestor_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_owner_user_id_user_id_fk": {
+ "name": "project_document_owner_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_created_by_user_id_user_id_fk": {
+ "name": "project_document_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_updated_by_user_id_user_id_fk": {
+ "name": "project_document_updated_by_user_id_user_id_fk",
+ "tableFrom": "project_document",
+ "tableTo": "user",
+ "columnsFrom": [
+ "updated_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_document_version_check": {
+ "name": "project_document_version_check",
+ "value": "\"project_document\".\"version\" > 0"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_document_initiative": {
+ "name": "project_document_initiative",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "initiative_id": {
+ "name": "initiative_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_initiative_initiative_idx": {
+ "name": "project_document_initiative_initiative_idx",
+ "columns": [
+ {
+ "expression": "initiative_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_initiative_document_id_project_document_id_fk": {
+ "name": "project_document_initiative_document_id_project_document_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_initiative_id_initiative_id_fk": {
+ "name": "project_document_initiative_initiative_id_initiative_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "initiative",
+ "columnsFrom": [
+ "initiative_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_initiative_created_by_user_id_user_id_fk": {
+ "name": "project_document_initiative_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_initiative",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_initiative_document_id_initiative_id_pk": {
+ "name": "project_document_initiative_document_id_initiative_id_pk",
+ "columns": [
+ "document_id",
+ "initiative_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_issue": {
+ "name": "project_document_issue",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "issue_id": {
+ "name": "issue_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_issue_issue_idx": {
+ "name": "project_document_issue_issue_idx",
+ "columns": [
+ {
+ "expression": "issue_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_issue_document_id_project_document_id_fk": {
+ "name": "project_document_issue_document_id_project_document_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_issue_id_issue_id_fk": {
+ "name": "project_document_issue_issue_id_issue_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "issue",
+ "columnsFrom": [
+ "issue_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_issue_created_by_user_id_user_id_fk": {
+ "name": "project_document_issue_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_issue",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_issue_document_id_issue_id_pk": {
+ "name": "project_document_issue_document_id_issue_id_pk",
+ "columns": [
+ "document_id",
+ "issue_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_preference": {
+ "name": "project_document_preference",
+ "schema": "",
+ "columns": {
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_preference_user_idx": {
+ "name": "project_document_preference_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_preference_document_id_project_document_id_fk": {
+ "name": "project_document_preference_document_id_project_document_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_preference_user_id_user_id_fk": {
+ "name": "project_document_preference_user_id_user_id_fk",
+ "tableFrom": "project_document_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_document_preference_document_id_user_id_pk": {
+ "name": "project_document_preference_document_id_user_id_pk",
+ "columns": [
+ "document_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_document_revision": {
+ "name": "project_document_revision",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "document_id": {
+ "name": "document_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "version": {
+ "name": "version",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "parent_id": {
+ "name": "parent_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "title": {
+ "name": "title",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "content_json": {
+ "name": "content_json",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "full_width": {
+ "name": "full_width",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_private": {
+ "name": "is_private",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_locked": {
+ "name": "is_locked",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "archived_at": {
+ "name": "archived_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "owner_user_id": {
+ "name": "owner_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_by_user_id": {
+ "name": "created_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_document_revision_document_idx": {
+ "name": "project_document_revision_document_idx",
+ "columns": [
+ {
+ "expression": "document_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "version",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_document_revision_document_id_project_document_id_fk": {
+ "name": "project_document_revision_document_id_project_document_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "project_document",
+ "columnsFrom": [
+ "document_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_owner_user_id_user_id_fk": {
+ "name": "project_document_revision_owner_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "owner_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "project_document_revision_created_by_user_id_user_id_fk": {
+ "name": "project_document_revision_created_by_user_id_user_id_fk",
+ "tableFrom": "project_document_revision",
+ "tableTo": "user",
+ "columnsFrom": [
+ "created_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_document_revision_document_version_unique": {
+ "name": "project_document_revision_document_version_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "document_id",
+ "version"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_member": {
+ "name": "project_member",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "description": {
+ "name": "description",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "''"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invite'"
+ },
+ "is_favorite": {
+ "name": "is_favorite",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "is_hidden": {
+ "name": "is_hidden",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_member_user_idx": {
+ "name": "project_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_member_project_id_project_id_fk": {
+ "name": "project_member_project_id_project_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_user_id_user_id_fk": {
+ "name": "project_member_user_id_user_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_member_role_id_team_role_id_fk": {
+ "name": "project_member_role_id_team_role_id_fk",
+ "tableFrom": "project_member",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_member_project_id_user_id_pk": {
+ "name": "project_member_project_id_user_id_pk",
+ "columns": [
+ "project_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "project_member_role_check": {
+ "name": "project_member_role_check",
+ "value": "\"project_member\".\"role\" IN ('owner', 'member')"
+ },
+ "project_member_source_check": {
+ "name": "project_member_source_check",
+ "value": "\"project_member\".\"source\" IN ('invite', 'scim')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.project_setting": {
+ "name": "project_setting",
+ "schema": "",
+ "columns": {
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "key": {
+ "name": "key",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "value": {
+ "name": "value",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_setting_project_id_project_id_fk": {
+ "name": "project_setting_project_id_project_id_fk",
+ "tableFrom": "project_setting",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_setting_project_id_key_pk": {
+ "name": "project_setting_project_id_key_pk",
+ "columns": [
+ "project_id",
+ "key"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_view": {
+ "name": "project_view",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "icon": {
+ "name": "icon",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "filters": {
+ "name": "filters",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "display": {
+ "name": "display",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "position": {
+ "name": "position",
+ "type": "double precision",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "share_token": {
+ "name": "share_token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "share_extended": {
+ "name": "share_extended",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "project_view_project_idx": {
+ "name": "project_view_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "position",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "project_view_project_id_project_id_fk": {
+ "name": "project_view_project_id_project_id_fk",
+ "tableFrom": "project_view",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "project_view_share_token_unique": {
+ "name": "project_view_share_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "share_token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.project_view_favorite": {
+ "name": "project_view_favorite",
+ "schema": "",
+ "columns": {
+ "view_id": {
+ "name": "view_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "project_view_favorite_view_id_project_view_id_fk": {
+ "name": "project_view_favorite_view_id_project_view_id_fk",
+ "tableFrom": "project_view_favorite",
+ "tableTo": "project_view",
+ "columnsFrom": [
+ "view_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "project_view_favorite_user_id_user_id_fk": {
+ "name": "project_view_favorite_user_id_user_id_fk",
+ "tableFrom": "project_view_favorite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "project_view_favorite_view_id_user_id_pk": {
+ "name": "project_view_favorite_view_id_user_id_pk",
+ "columns": [
+ "view_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.revision": {
+ "name": "revision",
+ "schema": "",
+ "columns": {
+ "scope": {
+ "name": "scope",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "rev": {
+ "name": "rev",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "revision_project_idx": {
+ "name": "revision_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team": {
+ "name": "team",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "slug": {
+ "name": "slug",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "mcp_enabled": {
+ "name": "mcp_enabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "default_agent_ids": {
+ "name": "default_agent_ids",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "team_workspace_idx": {
+ "name": "team_workspace_idx",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_workspace_id_workspace_id_fk": {
+ "name": "team_workspace_id_workspace_id_fk",
+ "tableFrom": "team",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_slug_unique": {
+ "name": "team_slug_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "slug"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_invite": {
+ "name": "team_invite",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "token": {
+ "name": "token",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "email": {
+ "name": "email",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "team_role": {
+ "name": "team_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "project_role": {
+ "name": "project_role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "invited_by_user_id": {
+ "name": "invited_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "accepted_by_user_id": {
+ "name": "accepted_by_user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "responded_at": {
+ "name": "responded_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ }
+ },
+ "indexes": {
+ "team_invite_team_pending_uq": {
+ "name": "team_invite_team_pending_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_project_pending_uq": {
+ "name": "team_invite_project_pending_uq",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ },
+ {
+ "expression": "email",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_invite\".\"status\" = 'pending' AND \"team_invite\".\"project_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_team_idx": {
+ "name": "team_invite_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_invite_project_idx": {
+ "name": "team_invite_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_invite_team_id_team_id_fk": {
+ "name": "team_invite_team_id_team_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_invite_project_id_project_id_fk": {
+ "name": "team_invite_project_id_project_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_invite_role_id_team_role_id_fk": {
+ "name": "team_invite_role_id_team_role_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "team_invite_invited_by_user_id_user_id_fk": {
+ "name": "team_invite_invited_by_user_id_user_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "invited_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ },
+ "team_invite_accepted_by_user_id_user_id_fk": {
+ "name": "team_invite_accepted_by_user_id_user_id_fk",
+ "tableFrom": "team_invite",
+ "tableTo": "user",
+ "columnsFrom": [
+ "accepted_by_user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_invite_token_unique": {
+ "name": "team_invite_token_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "team_invite_team_role_check": {
+ "name": "team_invite_team_role_check",
+ "value": "\"team_invite\".\"team_role\" IN ('owner', 'manager', 'member')"
+ },
+ "team_invite_project_role_check": {
+ "name": "team_invite_project_role_check",
+ "value": "(\"team_invite\".\"project_id\" IS NULL AND \"team_invite\".\"project_role\" IS NULL)\n OR (\"team_invite\".\"project_id\" IS NOT NULL AND \"team_invite\".\"project_role\" IN ('owner', 'member'))"
+ },
+ "team_invite_status_check": {
+ "name": "team_invite_status_check",
+ "value": "\"team_invite\".\"status\" IN ('pending', 'accepted', 'rejected')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_member": {
+ "name": "team_member",
+ "schema": "",
+ "columns": {
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "source": {
+ "name": "source",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'invite'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "team_member_user_idx": {
+ "name": "team_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_member_team_id_team_id_fk": {
+ "name": "team_member_team_id_team_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "team_member_user_id_user_id_fk": {
+ "name": "team_member_user_id_user_id_fk",
+ "tableFrom": "team_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "team_member_team_id_user_id_pk": {
+ "name": "team_member_team_id_user_id_pk",
+ "columns": [
+ "team_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "team_member_role_check": {
+ "name": "team_member_role_check",
+ "value": "\"team_member\".\"role\" IN ('owner', 'manager', 'member', 'agent')"
+ },
+ "team_member_source_check": {
+ "name": "team_member_source_check",
+ "value": "\"team_member\".\"source\" IN ('invite', 'scim')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.team_notification_setting": {
+ "name": "team_notification_setting",
+ "schema": "",
+ "columns": {
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "ciphertext": {
+ "name": "ciphertext",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "iv": {
+ "name": "iv",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "auth_tag": {
+ "name": "auth_tag",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "redacted": {
+ "name": "redacted",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "team_notification_setting_team_id_team_id_fk": {
+ "name": "team_notification_setting_team_id_team_id_fk",
+ "tableFrom": "team_notification_setting",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.team_role": {
+ "name": "team_role",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "team_id": {
+ "name": "team_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "is_default": {
+ "name": "is_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "permissions": {
+ "name": "permissions",
+ "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": {
+ "team_role_default_uq": {
+ "name": "team_role_default_uq",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"team_role\".\"is_default\"",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "team_role_team_idx": {
+ "name": "team_role_team_idx",
+ "columns": [
+ {
+ "expression": "team_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "team_role_team_id_team_id_fk": {
+ "name": "team_role_team_id_team_id_fk",
+ "tableFrom": "team_role",
+ "tableTo": "team",
+ "columnsFrom": [
+ "team_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "team_role_team_id_name_unique": {
+ "name": "team_role_team_id_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "team_id",
+ "name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_notification_preference": {
+ "name": "user_notification_preference",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "email_events": {
+ "name": "email_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "telegram_events": {
+ "name": "telegram_events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'{}'::jsonb"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_notification_preference_user_id_user_id_fk": {
+ "name": "user_notification_preference_user_id_user_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_notification_preference_project_id_project_id_fk": {
+ "name": "user_notification_preference_project_id_project_id_fk",
+ "tableFrom": "user_notification_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "user_notification_pref_user_project_unique": {
+ "name": "user_notification_pref_user_project_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "user_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.user_preference": {
+ "name": "user_preference",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "timezone": {
+ "name": "timezone",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'UTC'"
+ },
+ "locale": {
+ "name": "locale",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'en'"
+ },
+ "theme": {
+ "name": "theme",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'system'"
+ },
+ "issue_open_mode": {
+ "name": "issue_open_mode",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'panel'"
+ },
+ "start_page": {
+ "name": "start_page",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'work-items'"
+ },
+ "show_chat_by_default": {
+ "name": "show_chat_by_default",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": false
+ },
+ "issue_stats_open": {
+ "name": "issue_stats_open",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "issue_stats_view": {
+ "name": "issue_stats_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'compact'"
+ },
+ "issue_activity_view": {
+ "name": "issue_activity_view",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'flat'"
+ },
+ "auto_watch": {
+ "name": "auto_watch",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "hotkeys": {
+ "name": "hotkeys",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "last_project_id": {
+ "name": "last_project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "seen_version": {
+ "name": "seen_version",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "user_preference_user_id_user_id_fk": {
+ "name": "user_preference_user_id_user_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "user_preference_last_project_id_project_id_fk": {
+ "name": "user_preference_last_project_id_project_id_fk",
+ "tableFrom": "user_preference",
+ "tableTo": "project",
+ "columnsFrom": [
+ "last_project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "user_preference_theme_check": {
+ "name": "user_preference_theme_check",
+ "value": "\"user_preference\".\"theme\" IN ('light', 'dark', 'system')"
+ },
+ "user_preference_issue_open_mode_check": {
+ "name": "user_preference_issue_open_mode_check",
+ "value": "\"user_preference\".\"issue_open_mode\" IN ('panel', 'page')"
+ },
+ "user_preference_start_page_check": {
+ "name": "user_preference_start_page_check",
+ "value": "\"user_preference\".\"start_page\" IN ('inbox', 'dashboard', 'work-items', 'initiatives')"
+ },
+ "user_preference_issue_stats_view_check": {
+ "name": "user_preference_issue_stats_view_check",
+ "value": "\"user_preference\".\"issue_stats_view\" IN ('compact', 'timeline')"
+ },
+ "user_preference_issue_activity_view_check": {
+ "name": "user_preference_issue_activity_view_check",
+ "value": "\"user_preference\".\"issue_activity_view\" IN ('flat', 'grouped')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.user_telegram_account": {
+ "name": "user_telegram_account",
+ "schema": "",
+ "columns": {
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "chat_id": {
+ "name": "chat_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "username": {
+ "name": "username",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "first_name": {
+ "name": "first_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code": {
+ "name": "link_code",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "link_code_expires_at": {
+ "name": "link_code_expires_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "linked_at": {
+ "name": "linked_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": {
+ "user_telegram_account_chat_id_unique": {
+ "name": "user_telegram_account_chat_id_unique",
+ "columns": [
+ {
+ "expression": "chat_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"chat_id\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "user_telegram_account_link_code_unique": {
+ "name": "user_telegram_account_link_code_unique",
+ "columns": [
+ {
+ "expression": "link_code",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"user_telegram_account\".\"link_code\" IS NOT NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "user_telegram_account_user_id_user_id_fk": {
+ "name": "user_telegram_account_user_id_user_id_fk",
+ "tableFrom": "user_telegram_account",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook": {
+ "name": "webhook",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "url": {
+ "name": "url",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "secret": {
+ "name": "secret",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "events": {
+ "name": "events",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'[]'::jsonb"
+ },
+ "is_active": {
+ "name": "is_active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "default": true
+ },
+ "consecutive_failures": {
+ "name": "consecutive_failures",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_project_idx": {
+ "name": "webhook_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_project_id_project_id_fk": {
+ "name": "webhook_project_id_project_id_fk",
+ "tableFrom": "webhook",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.webhook_delivery": {
+ "name": "webhook_delivery",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "webhook_id": {
+ "name": "webhook_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_id": {
+ "name": "event_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "event_type": {
+ "name": "event_type",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "payload": {
+ "name": "payload",
+ "type": "jsonb",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "status": {
+ "name": "status",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'pending'"
+ },
+ "attempts": {
+ "name": "attempts",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true,
+ "default": 0
+ },
+ "next_attempt_at": {
+ "name": "next_attempt_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "last_error": {
+ "name": "last_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_status": {
+ "name": "response_status",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "response_body": {
+ "name": "response_body",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "webhook_delivery_due_idx": {
+ "name": "webhook_delivery_due_idx",
+ "columns": [
+ {
+ "expression": "next_attempt_at",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "where": "\"webhook_delivery\".\"status\" = 'pending'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "webhook_delivery_webhook_idx": {
+ "name": "webhook_delivery_webhook_idx",
+ "columns": [
+ {
+ "expression": "webhook_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "webhook_delivery_webhook_id_webhook_id_fk": {
+ "name": "webhook_delivery_webhook_id_webhook_id_fk",
+ "tableFrom": "webhook_delivery",
+ "tableTo": "webhook",
+ "columnsFrom": [
+ "webhook_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.workspace": {
+ "name": "workspace",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "name": {
+ "name": "name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "color": {
+ "name": "color",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "team_creation": {
+ "name": "team_creation",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'owner'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "workspace_team_creation_check": {
+ "name": "workspace_team_creation_check",
+ "value": "\"workspace\".\"team_creation\" IN ('owner', 'managers', 'members')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.workspace_manager": {
+ "name": "workspace_manager",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'admin'"
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "workspace_manager_owner_uq": {
+ "name": "workspace_manager_owner_uq",
+ "columns": [
+ {
+ "expression": "workspace_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"workspace_manager\".\"role\" = 'owner'",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "workspace_manager_user_idx": {
+ "name": "workspace_manager_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "workspace_manager_workspace_id_workspace_id_fk": {
+ "name": "workspace_manager_workspace_id_workspace_id_fk",
+ "tableFrom": "workspace_manager",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "workspace_manager_user_id_user_id_fk": {
+ "name": "workspace_manager_user_id_user_id_fk",
+ "tableFrom": "workspace_manager",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "workspace_manager_workspace_id_user_id_pk": {
+ "name": "workspace_manager_workspace_id_user_id_pk",
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {
+ "workspace_manager_role_check": {
+ "name": "workspace_manager_role_check",
+ "value": "\"workspace_manager\".\"role\" IN ('owner', 'admin')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_group": {
+ "name": "scim_group",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "uuid",
+ "primaryKey": true,
+ "notNull": true,
+ "default": "gen_random_uuid()"
+ },
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "display_name": {
+ "name": "display_name",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_group_instance_display_name_uq": {
+ "name": "scim_group_instance_display_name_uq",
+ "columns": [
+ {
+ "expression": "display_name",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"scim_group\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_workspace_id_workspace_id_fk": {
+ "name": "scim_group_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_group",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_workspace_id_display_name_unique": {
+ "name": "scim_group_workspace_id_display_name_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "display_name"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_group_mapping": {
+ "name": "scim_group_mapping",
+ "schema": "",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "serial",
+ "primaryKey": true,
+ "notNull": true
+ },
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "project_id": {
+ "name": "project_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "role": {
+ "name": "role",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "'member'"
+ },
+ "role_id": {
+ "name": "role_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp with time zone",
+ "primaryKey": false,
+ "notNull": true,
+ "default": "now()"
+ }
+ },
+ "indexes": {
+ "scim_group_mapping_project_idx": {
+ "name": "scim_group_mapping_project_idx",
+ "columns": [
+ {
+ "expression": "project_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_mapping_group_id_scim_group_id_fk": {
+ "name": "scim_group_mapping_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_project_id_project_id_fk": {
+ "name": "scim_group_mapping_project_id_project_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "project",
+ "columnsFrom": [
+ "project_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_mapping_role_id_team_role_id_fk": {
+ "name": "scim_group_mapping_role_id_team_role_id_fk",
+ "tableFrom": "scim_group_mapping",
+ "tableTo": "team_role",
+ "columnsFrom": [
+ "role_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "set null",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_group_mapping_group_id_project_id_unique": {
+ "name": "scim_group_mapping_group_id_project_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "group_id",
+ "project_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {
+ "scim_group_mapping_role_check": {
+ "name": "scim_group_mapping_role_check",
+ "value": "\"scim_group_mapping\".\"role\" IN ('owner', 'member')"
+ }
+ },
+ "isRLSEnabled": false
+ },
+ "public.scim_group_member": {
+ "name": "scim_group_member",
+ "schema": "",
+ "columns": {
+ "group_id": {
+ "name": "group_id",
+ "type": "uuid",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ }
+ },
+ "indexes": {
+ "scim_group_member_user_idx": {
+ "name": "scim_group_member_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_group_member_group_id_scim_group_id_fk": {
+ "name": "scim_group_member_group_id_scim_group_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "scim_group",
+ "columnsFrom": [
+ "group_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_group_member_user_id_user_id_fk": {
+ "name": "scim_group_member_user_id_user_id_fk",
+ "tableFrom": "scim_group_member",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "scim_group_member_group_id_user_id_pk": {
+ "name": "scim_group_member_group_id_user_id_pk",
+ "columns": [
+ "group_id",
+ "user_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ },
+ "public.scim_user": {
+ "name": "scim_user",
+ "schema": "",
+ "columns": {
+ "workspace_id": {
+ "name": "workspace_id",
+ "type": "integer",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "user_id": {
+ "name": "user_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true
+ },
+ "external_id": {
+ "name": "external_id",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false
+ },
+ "active": {
+ "name": "active",
+ "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": {
+ "scim_user_instance_user_uq": {
+ "name": "scim_user_instance_user_uq",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": true,
+ "where": "\"scim_user\".\"workspace_id\" IS NULL",
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ },
+ "scim_user_user_idx": {
+ "name": "scim_user_user_idx",
+ "columns": [
+ {
+ "expression": "user_id",
+ "isExpression": false,
+ "asc": true,
+ "nulls": "last"
+ }
+ ],
+ "isUnique": false,
+ "concurrently": false,
+ "method": "btree",
+ "with": {}
+ }
+ },
+ "foreignKeys": {
+ "scim_user_workspace_id_workspace_id_fk": {
+ "name": "scim_user_workspace_id_workspace_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "workspace",
+ "columnsFrom": [
+ "workspace_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ },
+ "scim_user_user_id_user_id_fk": {
+ "name": "scim_user_user_id_user_id_fk",
+ "tableFrom": "scim_user",
+ "tableTo": "user",
+ "columnsFrom": [
+ "user_id"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {},
+ "uniqueConstraints": {
+ "scim_user_workspace_id_user_id_unique": {
+ "name": "scim_user_workspace_id_user_id_unique",
+ "nullsNotDistinct": false,
+ "columns": [
+ "workspace_id",
+ "user_id"
+ ]
+ }
+ },
+ "policies": {},
+ "checkConstraints": {},
+ "isRLSEnabled": false
+ }
+ },
+ "enums": {},
+ "schemas": {},
+ "sequences": {},
+ "roles": {},
+ "policies": {},
+ "views": {},
+ "_meta": {
+ "columns": {},
+ "schemas": {},
+ "tables": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/db/drizzle/meta/_journal.json b/packages/db/drizzle/meta/_journal.json
index bccd276c..113f0c40 100644
--- a/packages/db/drizzle/meta/_journal.json
+++ b/packages/db/drizzle/meta/_journal.json
@@ -1058,6 +1058,13 @@
"when": 1792098421237,
"tag": "0150_workspace_per_owner",
"breakpoints": true
+ },
+ {
+ "idx": 151,
+ "version": "7",
+ "when": 1792447270678,
+ "tag": "0151_agent_invocation_url",
+ "breakpoints": true
}
]
-}
+}
\ No newline at end of file
diff --git a/packages/db/src/schema/app.ts b/packages/db/src/schema/app.ts
index c9912f5e..6b537eb2 100644
--- a/packages/db/src/schema/app.ts
+++ b/packages/db/src/schema/app.ts
@@ -563,6 +563,16 @@ export const aiAgent = pgTable(
// Last time a runner claimed work or sent a heartbeat for this agent, which is
// what the UI shows as its presence. NULL for an agent no runner ever polled.
lastSeenAt: timestamp('last_seen_at', { withTimezone: true }),
+ // Where an external agent receives its work instead of from a runner: each of its
+ // runs and chat answers is POSTed here, and the endpoint reports back through the
+ // routes a runner uses. NULL for an agent a runner drains, and for an internal one.
+ invocationUrl: text('invocation_url'),
+ // The key those requests are signed with, encrypted at rest like the API key above
+ // because every request reads it back. It outlives a cleared URL, so pointing the
+ // agent at a URL again needs no change on the receiving side.
+ invocationSecretCiphertext: text('invocation_secret_ciphertext'),
+ invocationSecretIv: text('invocation_secret_iv'),
+ invocationSecretAuthTag: text('invocation_secret_auth_tag'),
createdAt: timestamp('created_at', { withTimezone: true }).notNull().defaultNow(),
},
(t) => [
diff --git a/packages/runner/README.md b/packages/runner/README.md
index f30b6038..5e621ddc 100644
--- a/packages/runner/README.md
+++ b/packages/runner/README.md
@@ -11,6 +11,8 @@ This package runs such agents on your own machine — one, or several at once.
Pi, and Oh My Pi (`omp`). Each preset sets the unattended flags and the session resume.
- Runs your own `command` instead, if you prefer. The command takes the task on stdin.
- Answers the agent's chat. Sends the text and the tool calls while the CLI prints them.
+- Receives the tasks on a port instead of polling, for an agent whose Connection is
+ Endpoint. See [Receiving tasks on a port](#receiving-tasks-on-a-port).
## Quick start
@@ -149,6 +151,86 @@ options describe every agent at once; an entry has priority over them.
An agent whose key the instance refuses stops on its own, and the others keep working.
+## Receiving tasks on a port
+
+By default the runner polls the instance for tasks. With `listen`, the instance sends each
+task to the runner when the task is created. The runner then does not poll.
+
+Use `listen` for a runner on a server that the instance can reach. On a laptop behind a
+router, use polling. Polling needs no setup, and the chat is equally fast with it: a chat
+claim waits on the server until a message comes.
+
+**1.** In the agent's settings, open Connection and select Endpoint. Enter the public
+HTTPS address of the runner's port (see [Reaching the port](#reaching-the-port)), and
+save. Copy the signing secret.
+
+**2.** Add `listen` and `signingSecret` to `itsaplan-runner.json`:
+
+```json
+{
+ "url": "https://plan.example.com",
+ "apiKey": "the agent's key",
+ "agent": "claude",
+ "listen": 4000,
+ "signingSecret": "whsec_…"
+}
+```
+
+**3.** Start the runner. It logs `listening on port 4000`. In the agent's settings, click
+Send test. The result must be `200`.
+
+The runner answers each task immediately. Then it runs the task as it runs a polled task,
+with the same command, heartbeats and result. The rules for a request:
+
+- The runner accepts only a `POST` request signed with the secret of one of its agents.
+- It refuses a request whose signature time is more than five minutes from its clock.
+- If the instance sends a task again while the task runs, the runner does not start it a
+ second time.
+
+Several agents can use one port. The runner identifies the agent by the secret, so each
+agent needs its own `signingSecret`. Put the agents in `agents`:
+
+```json
+{
+ "url": "https://plan.example.com",
+ "agent": "claude",
+ "listen": 4000,
+ "agents": [
+ { "apiKey": "the first agent's key", "signingSecret": "whsec_first…" },
+ { "apiKey": "the second agent's key", "signingSecret": "whsec_second…" }
+ ]
+}
+```
+
+In the same file, the runner polls for each agent that has no `listen`.
+
+### Reaching the port
+
+The runner serves plain HTTP. In production, the instance requires HTTPS. Put a tunnel or a
+reverse proxy in front of the port:
+
+- **Reverse proxy** on a server with a domain. Caddy gets the certificate automatically:
+
+ ```
+ runner.example.com {
+ reverse_proxy localhost:4000
+ }
+ ```
+
+- **Cloudflare Tunnel.** `cloudflared tunnel --url http://localhost:4000` prints a
+ `trycloudflare.com` address. The address changes each time the tunnel starts, and then
+ you must change the agent's URL too. A named tunnel on your own domain keeps the same
+ address.
+- **ngrok.** `ngrok http 4000`. A static domain in your ngrok account keeps the same
+ address.
+- **Tailscale Funnel.** `tailscale funnel 4000` publishes the port at the machine's
+ `ts.net` address.
+
+On a private network without a tunnel, add the runner's host to `SSRF_ALLOWED_HOSTS` on
+the instance. That host must also use HTTPS. When `NODE_ENV` on the instance is not
+`production` or `test`, the instance also accepts `http://` and private addresses, for
+example `http://localhost:4000`.
+
## Settings
The runner reads `./itsaplan-runner.json`. For a different file, give the path as an
@@ -176,6 +258,8 @@ priority over both. An `agents` entry has priority over all three, for the field
| `pollIntervalMs` | `ITSAPLAN_POLL_INTERVAL_MS` | `3000` | Wait after an empty queue. Minimum 1000 |
| `timeoutMs` | `ITSAPLAN_TIMEOUT_MS` | `1800000` | Time before the runner stops a task |
| `outputFormat` | `ITSAPLAN_OUTPUT_FORMAT` | the preset's | How the runner reads a chat answer |
+| `listen` | `ITSAPLAN_LISTEN` | — | Port that receives the tasks. The runner does not poll for the agent |
+| `signingSecret` | `ITSAPLAN_SIGNING_SECRET` | — | The agent's signing secret. Required with `listen` |
Set `agent` or `command`. With the environment you need no file at all:
@@ -265,7 +349,7 @@ Without a session the server sends the last 20 messages of the conversation as p
- **Node 20 or later.**
- **An It's a Plan instance 0.10.0 or later.** The chat needs 0.11.0. An older instance
- gives the runner only the queued runs.
+ gives the runner only the queued runs. `listen` needs 1.6.0.
- **An external agent in your project.** The runner authenticates with its API key.
- **The coding agent, installed and signed in on the same machine.** The runner starts the
CLI as you, but it cannot sign in for you.
diff --git a/packages/runner/package.json b/packages/runner/package.json
index 1c7abf38..81aad60f 100644
--- a/packages/runner/package.json
+++ b/packages/runner/package.json
@@ -1,6 +1,6 @@
{
"name": "@itsaplan/runner",
- "version": "0.5.3",
+ "version": "0.6.0",
"description": "Runs an Itsaplan external agent's queued tasks and answers its chat on your own machine",
"keywords": [
"itsaplan",
diff --git a/packages/runner/src/__tests__/config.test.ts b/packages/runner/src/__tests__/config.test.ts
index 9e4d92a9..98237010 100644
--- a/packages/runner/src/__tests__/config.test.ts
+++ b/packages/runner/src/__tests__/config.test.ts
@@ -126,3 +126,52 @@ describe('several agents', () => {
).rejects.toThrow('each with its own apiKey');
});
});
+
+describe('listen', () => {
+ it('reads the port and the secret, from the file or the environment', async () => {
+ const [config] = await load({
+ ...base,
+ apiKey: 'key-a',
+ listen: 4000,
+ signingSecret: 'whsec_a',
+ });
+ expect(config).toMatchObject({ listen: 4000, signingSecret: 'whsec_a' });
+
+ process.env.ITSAPLAN_LISTEN = '4100';
+ process.env.ITSAPLAN_SIGNING_SECRET = 'whsec_env';
+ const [fromEnv] = await load({ ...base, apiKey: 'key-a' });
+ expect(fromEnv).toMatchObject({ listen: 4100, signingSecret: 'whsec_env' });
+ });
+
+ it('leaves an agent without listen to the polling', async () => {
+ const [config] = await load({ ...base, apiKey: 'key-a' });
+ expect(config.listen).toBeUndefined();
+ });
+
+ it('refuses listen without a secret, and a port that is not one', async () => {
+ await expect(load({ ...base, apiKey: 'key-a', listen: 4000 })).rejects.toThrow(
+ 'signingSecret is required',
+ );
+ for (const listen of [0, 70000, 'abc', 40.5]) {
+ await expect(
+ load({ ...base, apiKey: 'key-a', listen, signingSecret: 'whsec_a' }),
+ ).rejects.toThrow('listen must be a port');
+ }
+ });
+
+ it('needs a secret of its own for each agent on a port', async () => {
+ await expect(
+ load({ ...base, apiKeys: ['key-a', 'key-b'], listen: 4000, signingSecret: 'whsec_shared' }),
+ ).rejects.toThrow('its own signingSecret');
+
+ const configs = await load({
+ ...base,
+ listen: 4000,
+ agents: [
+ { apiKey: 'key-a', signingSecret: 'whsec_a' },
+ { apiKey: 'key-b', signingSecret: 'whsec_b' },
+ ],
+ });
+ expect(configs.map((config) => config.signingSecret)).toEqual(['whsec_a', 'whsec_b']);
+ });
+});
diff --git a/packages/runner/src/__tests__/listen.test.ts b/packages/runner/src/__tests__/listen.test.ts
new file mode 100644
index 00000000..ce27aa28
--- /dev/null
+++ b/packages/runner/src/__tests__/listen.test.ts
@@ -0,0 +1,163 @@
+import { describe, it, expect, afterEach } from 'bun:test';
+import { createHmac } from 'node:crypto';
+import type { ChatMessage, Run } from '../client';
+import { startListener, verifySignature, type ListenAgent, type Listener } from '../listen';
+
+// The runner as an endpoint: a request is taken only when one of the configured agents
+// signed it, and it then runs as that agent's task, within its concurrency, once.
+
+function sign(secret: string, body: string, t = Math.floor(Date.now() / 1000)): string {
+ return `t=${t},v1=${createHmac('sha256', secret).update(`${t}.${body}`).digest('hex')}`;
+}
+
+const run = (id: number): Run => ({
+ id,
+ trigger: 'mention',
+ prompt: 'p',
+ systemPrompt: 's',
+ issueId: 1,
+ issueIdentifier: 'MKT-1',
+});
+
+const message: ChatMessage = {
+ id: 7,
+ threadId: 't',
+ prompt: 'p',
+ systemPrompt: 's',
+ sessionId: null,
+};
+
+describe('verifySignature', () => {
+ const body = '{"event":"ping"}';
+
+ it('accepts the signature of the exact body', () => {
+ expect(verifySignature('s1', sign('s1', body), body)).toBe(true);
+ });
+
+ it('refuses another secret, another body, and a malformed header', () => {
+ expect(verifySignature('s2', sign('s1', body), body)).toBe(false);
+ expect(verifySignature('s1', sign('s1', body), `${body} `)).toBe(false);
+ expect(verifySignature('s1', 'v1=abc', body)).toBe(false);
+ expect(verifySignature('s1', '', body)).toBe(false);
+ const t = Math.floor(Date.now() / 1000);
+ expect(verifySignature('s1', `t=${t},v1=${'é'.repeat(64)}`, body)).toBe(false);
+ });
+
+ it('refuses a request signed more than five minutes away from now', () => {
+ const t = 1_700_000_000;
+ expect(verifySignature('s1', sign('s1', body, t), body, t + 299)).toBe(true);
+ expect(verifySignature('s1', sign('s1', body, t), body, t + 301)).toBe(false);
+ });
+});
+
+describe('startListener', () => {
+ let listener: Listener | null = null;
+
+ afterEach(async () => {
+ await listener?.close();
+ listener = null;
+ });
+
+ function agent(secret: string, overrides: Partial<ListenAgent> = {}) {
+ const seen = { runs: [] as Run[], chats: [] as ChatMessage[] };
+ const value: ListenAgent = {
+ secret,
+ concurrency: 1,
+ run: async (r) => void seen.runs.push(r),
+ chat: async (m) => void seen.chats.push(m),
+ ...overrides,
+ };
+ return { value, seen };
+ }
+
+ async function post(body: string, secret: string | null, method = 'POST') {
+ const headers: Record<string, string> = { 'content-type': 'application/json' };
+ if (secret) headers['x-itsaplan-signature'] = sign(secret, body);
+ return fetch(`http://127.0.0.1:${listener!.port}/agent`, {
+ method,
+ headers,
+ body: method === 'POST' ? body : undefined,
+ });
+ }
+
+ it('hands a task to the agent whose secret signed it', async () => {
+ const first = agent('secret-a');
+ const second = agent('secret-b');
+ listener = await startListener(0, [first.value, second.value], () => {});
+
+ const res = await post(JSON.stringify({ event: 'agent.run', run: run(1) }), 'secret-b');
+ expect(res.status).toBe(200);
+ await post(JSON.stringify({ event: 'agent.chat', message }), 'secret-a');
+ await Bun.sleep(10);
+
+ expect(second.seen.runs.map((r) => r.id)).toEqual([1]);
+ expect(first.seen.runs).toEqual([]);
+ expect(first.seen.chats.map((m) => m.id)).toEqual([7]);
+ });
+
+ it('answers a ping and starts nothing', async () => {
+ const only = agent('secret-a');
+ listener = await startListener(0, [only.value], () => {});
+ expect((await post('{"event":"ping"}', 'secret-a')).status).toBe(200);
+ expect(only.seen.runs).toEqual([]);
+ });
+
+ it('refuses an unsigned request, a foreign secret, another method, and an unknown event', async () => {
+ const only = agent('secret-a');
+ listener = await startListener(0, [only.value], () => {});
+ const body = JSON.stringify({ event: 'agent.run', run: run(1) });
+
+ expect((await post(body, null)).status).toBe(401);
+ expect((await post(body, 'secret-x')).status).toBe(401);
+ expect((await post('', null, 'GET')).status).toBe(405);
+ expect((await post('{"event":"agent.later"}', 'secret-a')).status).toBe(400);
+ expect(only.seen.runs).toEqual([]);
+ });
+
+ it('refuses a body larger than a task can be', async () => {
+ listener = await startListener(0, [agent('secret-a').value], () => {});
+ const huge = JSON.stringify({ event: 'ping', pad: 'x'.repeat(6 * 1024 * 1024) });
+ const res = await post(huge, 'secret-a').catch(() => null);
+ // The server answers 413 and drops the connection, which a client may see as either.
+ expect(res === null || res.status === 413).toBe(true);
+ });
+
+ it('runs the tasks one at a time at concurrency 1, and a task sent again only once', async () => {
+ const started: number[] = [];
+ let finishFirst!: () => void;
+ const firstDone = new Promise<void>((resolve) => (finishFirst = resolve));
+ const only = agent('secret-a', {
+ run: async (r) => {
+ started.push(r.id);
+ if (r.id === 1) await firstDone;
+ },
+ });
+ listener = await startListener(0, [only.value], () => {});
+
+ await post(JSON.stringify({ event: 'agent.run', run: run(1) }), 'secret-a');
+ await post(JSON.stringify({ event: 'agent.run', run: run(1) }), 'secret-a');
+ await post(JSON.stringify({ event: 'agent.run', run: run(2) }), 'secret-a');
+ await Bun.sleep(10);
+ expect(started).toEqual([1]);
+
+ finishFirst();
+ await Bun.sleep(10);
+ expect(started).toEqual([1, 2]);
+ });
+
+ it('waits for the tasks in flight when it closes', async () => {
+ let finished = false;
+ const only = agent('secret-a', {
+ run: async () => {
+ await Bun.sleep(50);
+ finished = true;
+ },
+ });
+ listener = await startListener(0, [only.value], () => {});
+ await post(JSON.stringify({ event: 'agent.run', run: run(1) }), 'secret-a');
+
+ await listener.close();
+ listener = null;
+ expect(finished).toBe(true);
+ });
+});
diff --git a/packages/runner/src/cli.ts b/packages/runner/src/cli.ts
index c5d08841..1476e412 100755
--- a/packages/runner/src/cli.ts
+++ b/packages/runner/src/cli.ts
@@ -1,112 +1,35 @@
#!/usr/bin/env node
import { setTimeout as sleep } from 'node:timers/promises';
-import { UsageReader } from './agui';
-import { answer } from './chat';
import { Client, RequestError, type ChatMessage, type Run } from './client';
import { loadConfig, type RunnerConfig } from './config';
-import { execute } from './execute';
+import { startListener } from './listen';
+import { handleChat, handleRun, type Log } from './tasks';
// The runner holds no state — the queue is the server's — so stopping it mid-task only
// means that task's lease expires and another runner picks it up.
//
// Two feeds are drained side by side per agent: triggered runs, polled, and chat
// messages, claimed by a call that waits on the server for one. A config that lists
-// several agents runs that pair for each of them, in the one process.
+// several agents runs that pair for each of them, in the one process. An agent with
+// `listen` is not polled: the instance sends it its tasks on that port instead.
-const HEARTBEAT_MS = 60_000;
const ERROR_BACKOFF_MS = 5_000;
-type Log = (message: string) => void;
-
function prefixOf(name: string): string {
return name ? `[itsaplan-runner ${name}]` : '[itsaplan-runner]';
}
-function log(message: string): void {
- console.log(`${prefixOf('')} ${message}`);
-}
-
-// A task can take much longer than the server's lease; without this it would be handed
-// out again mid-flight.
-async function withHeartbeat<T>(log: Log, beat: () => Promise<void>, work: Promise<T>): Promise<T> {
- const timer = setInterval(() => {
- beat().catch((err) => log(`heartbeat failed: ${String(err)}`));
- }, HEARTBEAT_MS);
- try {
- return await work;
- } finally {
- clearInterval(timer);
- }
+function logFor(name: string): Log {
+ const prefix = prefixOf(name);
+ return (message) => console.log(`${prefix} ${message}`);
}
-function taskOf(run: Run) {
- return {
- prompt: run.prompt,
- systemPrompt: run.systemPrompt,
- env: {
- ITSAPLAN_RUN_ID: String(run.id),
- ITSAPLAN_TRIGGER: run.trigger,
- ITSAPLAN_SYSTEM_PROMPT: run.systemPrompt,
- ITSAPLAN_ISSUE: run.issueIdentifier ?? '',
- ITSAPLAN_ISSUE_ID: run.issueId == null ? '' : String(run.issueId),
- },
- };
-}
+const log = logFor('');
-async function handle(config: RunnerConfig, client: Client, log: Log, run: Run): Promise<void> {
- const label = run.issueIdentifier ?? `run ${run.id}`;
- log(`${label}: started (${run.trigger})`);
- try {
- // Read as the command writes, not off the outcome: only the tail of the output is
- // kept, and the line carrying the counts can fall outside it.
- const usage = new UsageReader(config.outputFormat);
- const outcome = await withHeartbeat(
- log,
- () => client.heartbeat(run.id),
- execute(config, taskOf(run), { onData: (chunk) => usage.write(chunk) }),
- );
- usage.end();
- await client.report(run.id, { ...outcome, usage: usage.value() });
- log(`${label}: ${outcome.status}${outcome.error ? ` — ${outcome.error}` : ''}`);
- } catch (err) {
- // The command itself never throws here; this is the runner failing to run or
- // report it. Reporting the failure keeps the run from being retried blindly.
- const message = err instanceof Error ? err.message : String(err);
- log(`${label}: runner error — ${message}`);
- await client.report(run.id, { status: 'failed', error: message }).catch(() => {});
- }
-}
-
-// The stop the member pressed comes back on whichever call the runner was making: the
-// events report while the command writes, the heartbeat while it is silent. Both abort
-// the same controller, which kills the command.
-async function handleChat(
- config: RunnerConfig,
- client: Client,
- log: Log,
- message: ChatMessage,
-): Promise<void> {
- log(`chat ${message.id}: answering`);
- const stop = new AbortController();
- try {
- await withHeartbeat(
- log,
- async () => {
- if (await client.chatHeartbeat(message.id)) stop.abort();
- },
- answer(config, client, message, stop),
- );
- } catch (err) {
- // Without a reported failure the chat waits for an answer that is no longer coming.
- // A stopped answer is already closed, so nothing is reported for it.
- if (!stop.signal.aborted) {
- const text = err instanceof Error ? err.message : String(err);
- log(`chat ${message.id}: runner error — ${text}`);
- await client.chatResult(message.id, { status: 'failed', error: text }).catch(() => {});
- return;
- }
- }
- log(`chat ${message.id}: ${stop.signal.aborted ? 'stopped' : 'answered'}`);
+interface State {
+ stopping: boolean;
+ // Settles when the runner is asked to stop, for what waits on that rather than polls.
+ stopped: Promise<void>;
}
// Both feeds are drained the same way; they differ in what asking for work means — a poll
@@ -174,12 +97,11 @@ function parseArgv(argv: string[]): { configPath?: string; agent?: string; args:
return parsed;
}
-// Everything one agent needs: the two feeds, until the runner is stopped or the server
-// refuses its key.
-async function serve(state: { stopping: boolean }, config: RunnerConfig): Promise<void> {
+// Everything one polled agent needs: the two feeds, until the runner is stopped or the
+// server refuses its key.
+async function poll(state: State, config: RunnerConfig): Promise<void> {
const client = new Client(config);
- const prefix = prefixOf(config.name);
- const log: Log = (message) => console.log(`${prefix} ${message}`);
+ const log = logFor(config.name);
log(
`running ${config.agent ?? 'the configured command'}, polling ${config.url} every ` +
`${config.pollIntervalMs}ms, up to ${config.concurrency} at once`,
@@ -191,7 +113,7 @@ async function serve(state: { stopping: boolean }, config: RunnerConfig): Promis
log,
config.concurrency,
() => client.claim(),
- (run) => handle(config, client, log, run),
+ (run) => handleRun(config, client, log, run),
async () => {
await sleep(config.pollIntervalMs);
return true;
@@ -222,12 +144,60 @@ async function serve(state: { stopping: boolean }, config: RunnerConfig): Promis
]);
}
+// The agents that listen on one port share its server, which tells them apart by the
+// secret each request is signed with.
+async function listenOn(state: State, port: number, configs: RunnerConfig[]): Promise<void> {
+ const listener = await startListener(
+ port,
+ configs.map((config) => {
+ const client = new Client(config);
+ const log = logFor(config.name);
+ log(
+ `running ${config.agent ?? 'the configured command'} for the tasks ${config.url} ` +
+ `sends to port ${port}, up to ${config.concurrency} at once`,
+ );
+ return {
+ secret: config.signingSecret!,
+ concurrency: config.concurrency,
+ run: (run: Run) => handleRun(config, client, log, run),
+ chat: (message: ChatMessage) => handleChat(config, client, log, message),
+ };
+ }),
+ log,
+ );
+ log(`listening on port ${listener.port}`);
+ await state.stopped;
+ await listener.close();
+}
+
+function byPort(configs: RunnerConfig[]): Map<number, RunnerConfig[]> {
+ const ports = new Map<number, RunnerConfig[]>();
+ for (const config of configs) {
+ if (config.listen === undefined) continue;
+ ports.set(config.listen, [...(ports.get(config.listen) ?? []), config]);
+ }
+ return ports;
+}
+
+// Whether the work ended without an error, which is logged under the agent's name.
+function settle(name: string, work: Promise<void>): Promise<boolean> {
+ return work.then(
+ () => true,
+ (err: unknown) => {
+ const message = err instanceof Error ? err.message : String(err);
+ console.error(`${prefixOf(name)} stopped — ${message}`);
+ return false;
+ },
+ );
+}
+
async function main(): Promise<void> {
const cli = parseArgv(process.argv.slice(2));
const configPath =
cli.configPath ?? process.env.ITSAPLAN_RUNNER_CONFIG ?? './itsaplan-runner.json';
const configs = await loadConfig(configPath, { agent: cli.agent, args: cli.args });
- const state = { stopping: false };
+ let stop!: () => void;
+ const state: State = { stopping: false, stopped: new Promise((resolve) => (stop = resolve)) };
for (const signal of ['SIGINT', 'SIGTERM'] as const) {
process.on(signal, () => {
@@ -239,24 +209,22 @@ async function main(): Promise<void> {
process.exit(1);
}
state.stopping = true;
+ stop();
log('stopping — finishing the tasks in flight, press again to quit now');
});
}
// One agent's key being refused says nothing about the others, so it does not take them
- // down with it; the runner still exits non-zero once they are all finished.
- const served = await Promise.all(
- configs.map((config) =>
- serve(state, config).then(
- () => true,
- (err: unknown) => {
- const message = err instanceof Error ? err.message : String(err);
- console.error(`${prefixOf(config.name)} stopped — ${message}`);
- return false;
- },
- ),
+ // down with it; the runner still exits non-zero once they are all finished. A port that
+ // cannot be opened stops the agents on it the same way.
+ const served = await Promise.all([
+ ...configs
+ .filter((config) => config.listen === undefined)
+ .map((config) => settle(config.name, poll(state, config))),
+ ...[...byPort(configs)].map(([port, listening]) =>
+ settle(listening.length === 1 ? listening[0]!.name : '', listenOn(state, port, listening)),
),
- );
+ ]);
if (served.includes(false)) process.exit(1);
}
diff --git a/packages/runner/src/config.ts b/packages/runner/src/config.ts
index 47763abd..39a5f186 100644
--- a/packages/runner/src/config.ts
+++ b/packages/runner/src/config.ts
@@ -28,6 +28,12 @@ export interface RunnerConfig {
concurrency: number;
// How often to ask for work when the queue was empty.
pollIntervalMs: number;
+ // The port the instance sends this agent's tasks to, for an agent whose Connection is an
+ // endpoint. Such an agent is not polled.
+ listen?: number;
+ // The agent's signing secret, which proves a request on that port came from the
+ // instance. Required with `listen`.
+ signingSecret?: string;
// How long one task may take before it is killed and reported as failed.
timeoutMs: number;
// How the output is read when the command answers a chat message. 'text' takes whatever
@@ -95,6 +101,15 @@ function agentFrom(value: unknown): PresetName | undefined {
return name;
}
+function portFrom(value: unknown): number | undefined {
+ if (value === undefined || value === '') return undefined;
+ const port = intFrom(value, 0);
+ if (!Number.isInteger(port) || port < 1 || port > 65535) {
+ throw new Error('listen must be a port number from 1 to 65535');
+ }
+ return port;
+}
+
function argsFrom(value: unknown): string[] {
if (value === undefined) return [];
if (!Array.isArray(value) || value.some((item) => typeof item !== 'string')) {
@@ -191,6 +206,11 @@ function nameOf(entry: Fields, index: number, total: number): string {
function configFrom(fields: Fields, name: string, extraArgs: string[]): RunnerConfig {
const agent = agentFrom(fields.agent);
const command = textOf(fields.command);
+ const listen = portFrom(fields.listen);
+ const signingSecret = textOf(fields.signingSecret);
+ if (listen !== undefined && !signingSecret) {
+ throw new Error('signingSecret is required with listen — copy it from the agent settings');
+ }
if (!agent && !command) {
throw new Error(
`set either agent (one of ${PRESET_NAMES.join(', ')}) or command in the config file or the environment`,
@@ -212,9 +232,28 @@ function configFrom(fields: Fields, name: string, extraArgs: string[]): RunnerCo
),
timeoutMs: intFrom(fields.timeoutMs, DEFAULTS.timeoutMs),
outputFormat: outputFormatFrom(fields.outputFormat, presetOf({ agent, command })),
+ listen,
+ signingSecret,
};
}
+// The agents on one port are told apart by the secret a request is signed with, so two of
+// them sharing one would make a request belong to both. The instance issues every agent a
+// secret of its own, so this refuses `apiKeys` given one shared `signingSecret`.
+function assertSecretsApart(configs: RunnerConfig[]): void {
+ const seen = new Set<string>();
+ for (const config of configs) {
+ if (config.listen === undefined) continue;
+ const key = `${config.listen} ${config.signingSecret}`;
+ if (seen.has(key)) {
+ throw new Error(
+ 'each agent on a listen port needs its own signingSecret — list them in agents',
+ );
+ }
+ seen.add(key);
+ }
+}
+
// Whatever the environment and the command line said, which is what the file's shared
// fields are read through. An agent entry then wins over all three: it is the only place
// that can describe one agent among several.
@@ -230,6 +269,8 @@ function sharedFields(file: Fields, overrides: ConfigOverrides): Fields {
pollIntervalMs: env.ITSAPLAN_POLL_INTERVAL_MS,
timeoutMs: env.ITSAPLAN_TIMEOUT_MS,
outputFormat: env.ITSAPLAN_OUTPUT_FORMAT,
+ listen: env.ITSAPLAN_LISTEN,
+ signingSecret: env.ITSAPLAN_SIGNING_SECRET,
};
// A variable that is not set says nothing about the field, so it must not overwrite it.
for (const [field, value] of Object.entries(outside)) {
@@ -249,7 +290,9 @@ export async function loadConfig(
throw new Error('no agents configured — apiKeys and agents cannot be empty');
}
const shared = sharedFields(file, overrides);
- return entries.map((entry, index) =>
+ const configs = entries.map((entry, index) =>
configFrom(merge(shared, entry), nameOf(entry, index, entries.length), overrides.args ?? []),
);
+ assertSecretsApart(configs);
+ return configs;
}
diff --git a/packages/runner/src/listen.ts b/packages/runner/src/listen.ts
new file mode 100644
index 00000000..63c59004
--- /dev/null
+++ b/packages/runner/src/listen.ts
@@ -0,0 +1,188 @@
+import { createHmac, timingSafeEqual } from 'node:crypto';
+import { createServer, type IncomingMessage } from 'node:http';
+import type { ChatMessage, Run } from './client';
+import type { Log } from './tasks';
+
+// The runner as the endpoint an agent's tasks are sent to: one HTTP server per port, for
+// every agent configured on it. A request is the instance's only when it is signed with one
+// of those agents' secrets, and the secret it is signed with is also what says which agent
+// it is for. TLS is left to the tunnel or the reverse proxy in front of the port.
+//
+// The answer goes out as soon as the task is queued: it only tells the instance that the
+// runner took the task. The task then runs and reports exactly as a claimed one does.
+
+// How far a request's timestamp may be from the clock here, so that a captured request
+// cannot be sent again later.
+const SIGNATURE_TOLERANCE_S = 300;
+// A task is a prompt and its context; a body far larger than that is not one.
+const MAX_BODY_BYTES = 5 * 1024 * 1024;
+
+// The header is `t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<body>">`.
+export function verifySignature(
+ secret: string,
+ header: string,
+ body: string,
+ nowSeconds = Date.now() / 1000,
+): boolean {
+ const fields = new Map(
+ header.split(',').map((part) => {
+ const at = part.indexOf('=');
+ return [part.slice(0, at).trim(), part.slice(at + 1).trim()] as const;
+ }),
+ );
+ const t = fields.get('t');
+ const v1 = fields.get('v1');
+ if (!t || !v1 || !Number.isFinite(Number(t))) return false;
+ if (Math.abs(nowSeconds - Number(t)) > SIGNATURE_TOLERANCE_S) return false;
+ const expected = createHmac('sha256', secret).update(`${t}.${body}`).digest('hex');
+ // Bytes, not characters: a header of non-ASCII characters is longer in bytes, and
+ // timingSafeEqual throws on buffers of different lengths.
+ const given = Buffer.from(v1);
+ const wanted = Buffer.from(expected);
+ return given.length === wanted.length && timingSafeEqual(given, wanted);
+}
+
+export interface ListenAgent {
+ secret: string;
+ // Tasks at once, per feed, the same as for a polled agent.
+ concurrency: number;
+ run: (run: Run) => Promise<void>;
+ chat: (message: ChatMessage) => Promise<void>;
+}
+
+export interface Listener {
+ port: number;
+ // Stops taking requests and resolves once the tasks already taken are finished.
+ close: () => Promise<void>;
+}
+
+// One feed of one agent: at most `limit` tasks at a time, the rest in the order they came.
+// The instance sends a task again when its lease runs out, so a task already held here is
+// not started a second time.
+function feed<T extends { id: number }>(
+ limit: number,
+ work: (item: T) => Promise<void>,
+ inFlight: Set<Promise<void>>,
+): (item: T) => void {
+ let active = 0;
+ const waiting: (() => void)[] = [];
+ const held = new Set<number>();
+ const acquire = () => {
+ if (active < limit) {
+ active++;
+ return Promise.resolve();
+ }
+ return new Promise<void>((resolve) => waiting.push(resolve));
+ };
+ // A waiting task takes the slot over, so a request that arrives meanwhile cannot take it
+ // as well.
+ const release = () => {
+ const next = waiting.shift();
+ if (next) next();
+ else active--;
+ };
+ return (item) => {
+ if (held.has(item.id)) return;
+ held.add(item.id);
+ const task = acquire()
+ .then(() => work(item))
+ .finally(() => {
+ held.delete(item.id);
+ release();
+ });
+ inFlight.add(task);
+ void task.finally(() => inFlight.delete(task)).catch(() => {});
+ };
+}
+
+class TooLargeError extends Error {}
+
+function readBody(req: IncomingMessage): Promise<string> {
+ return new Promise((resolve, reject) => {
+ const chunks: Buffer[] = [];
+ let size = 0;
+ req.on('data', (chunk: Buffer) => {
+ size += chunk.length;
+ if (size > MAX_BODY_BYTES) {
+ reject(new TooLargeError());
+ req.destroy();
+ return;
+ }
+ chunks.push(chunk);
+ });
+ req.on('end', () => resolve(Buffer.concat(chunks).toString('utf8')));
+ req.on('error', reject);
+ });
+}
+
+interface Payload {
+ event?: string;
+ run?: Run;
+ message?: ChatMessage;
+}
+
+export function startListener(port: number, agents: ListenAgent[], log: Log): Promise<Listener> {
+ const inFlight = new Set<Promise<void>>();
+ const served = agents.map((agent) => ({
+ secret: agent.secret,
+ run: feed(agent.concurrency, agent.run, inFlight),
+ chat: feed(agent.concurrency, agent.chat, inFlight),
+ }));
+
+ // Every path is answered the same way, so a proxy that adds a prefix needs no setting.
+ const server = createServer((req, res) => {
+ if (req.method !== 'POST') {
+ res.writeHead(405, { allow: 'POST' }).end();
+ return;
+ }
+ readBody(req).then(
+ (body) => {
+ const header = req.headers['x-itsaplan-signature'];
+ const agent =
+ typeof header === 'string'
+ ? served.find((candidate) => verifySignature(candidate.secret, header, body))
+ : undefined;
+ if (!agent) {
+ log('refused a request that no configured agent signed');
+ res.writeHead(401).end('bad signature');
+ return;
+ }
+ let payload: Payload;
+ try {
+ payload = JSON.parse(body) as Payload;
+ } catch {
+ res.writeHead(400).end('body is not JSON');
+ return;
+ }
+ if (payload.event === 'agent.run' && payload.run) agent.run(payload.run);
+ else if (payload.event === 'agent.chat' && payload.message) agent.chat(payload.message);
+ else if (payload.event !== 'ping') {
+ res.writeHead(400).end(`unknown event ${String(payload.event)}`);
+ return;
+ }
+ res.writeHead(200).end('ok');
+ },
+ (err: unknown) => {
+ res.writeHead(err instanceof TooLargeError ? 413 : 400).end();
+ },
+ );
+ });
+
+ return new Promise((resolve, reject) => {
+ server.once('error', reject);
+ server.listen(port, () => {
+ server.off('error', reject);
+ const address = server.address();
+ resolve({
+ port: typeof address === 'object' && address ? address.port : port,
+ close: async () => {
+ await new Promise<void>((done) => {
+ server.close(() => done());
+ server.closeIdleConnections();
+ });
+ await Promise.allSettled([...inFlight]);
+ },
+ });
+ });
+ });
+}
diff --git a/packages/runner/src/tasks.ts b/packages/runner/src/tasks.ts
new file mode 100644
index 00000000..03e607ff
--- /dev/null
+++ b/packages/runner/src/tasks.ts
@@ -0,0 +1,100 @@
+import { UsageReader } from './agui';
+import { answer } from './chat';
+import type { ChatMessage, Client, Run } from './client';
+import type { RunnerConfig } from './config';
+import { execute } from './execute';
+
+// One task of either feed, from the moment the runner holds it to its reported result. A
+// task is the same whether the runner claimed it or the instance sent it.
+
+const HEARTBEAT_MS = 60_000;
+
+export type Log = (message: string) => void;
+
+// A task can take much longer than the server's lease; without this it would be handed
+// out again mid-flight.
+async function withHeartbeat<T>(log: Log, beat: () => Promise<void>, work: Promise<T>): Promise<T> {
+ const timer = setInterval(() => {
+ beat().catch((err) => log(`heartbeat failed: ${String(err)}`));
+ }, HEARTBEAT_MS);
+ try {
+ return await work;
+ } finally {
+ clearInterval(timer);
+ }
+}
+
+function taskOf(run: Run) {
+ return {
+ prompt: run.prompt,
+ systemPrompt: run.systemPrompt,
+ env: {
+ ITSAPLAN_RUN_ID: String(run.id),
+ ITSAPLAN_TRIGGER: run.trigger,
+ ITSAPLAN_SYSTEM_PROMPT: run.systemPrompt,
+ ITSAPLAN_ISSUE: run.issueIdentifier ?? '',
+ ITSAPLAN_ISSUE_ID: run.issueId == null ? '' : String(run.issueId),
+ },
+ };
+}
+
+export async function handleRun(
+ config: RunnerConfig,
+ client: Client,
+ log: Log,
+ run: Run,
+): Promise<void> {
+ const label = run.issueIdentifier ?? `run ${run.id}`;
+ log(`${label}: started (${run.trigger})`);
+ try {
+ // Read as the command writes, not off the outcome: only the tail of the output is
+ // kept, and the line carrying the counts can fall outside it.
+ const usage = new UsageReader(config.outputFormat);
+ const outcome = await withHeartbeat(
+ log,
+ () => client.heartbeat(run.id),
+ execute(config, taskOf(run), { onData: (chunk) => usage.write(chunk) }),
+ );
+ usage.end();
+ await client.report(run.id, { ...outcome, usage: usage.value() });
+ log(`${label}: ${outcome.status}${outcome.error ? ` — ${outcome.error}` : ''}`);
+ } catch (err) {
+ // The command itself never throws here; this is the runner failing to run or
+ // report it. Reporting the failure keeps the run from being retried blindly.
+ const message = err instanceof Error ? err.message : String(err);
+ log(`${label}: runner error — ${message}`);
+ await client.report(run.id, { status: 'failed', error: message }).catch(() => {});
+ }
+}
+
+// The stop the member pressed comes back on whichever call the runner was making: the
+// events report while the command writes, the heartbeat while it is silent. Both abort
+// the same controller, which kills the command.
+export async function handleChat(
+ config: RunnerConfig,
+ client: Client,
+ log: Log,
+ message: ChatMessage,
+): Promise<void> {
+ log(`chat ${message.id}: answering`);
+ const stop = new AbortController();
+ try {
+ await withHeartbeat(
+ log,
+ async () => {
+ if (await client.chatHeartbeat(message.id)) stop.abort();
+ },
+ answer(config, client, message, stop),
+ );
+ } catch (err) {
+ // Without a reported failure the chat waits for an answer that is no longer coming.
+ // A stopped answer is already closed, so nothing is reported for it.
+ if (!stop.signal.aborted) {
+ const text = err instanceof Error ? err.message : String(err);
+ log(`chat ${message.id}: runner error — ${text}`);
+ await client.chatResult(message.id, { status: 'failed', error: text }).catch(() => {});
+ return;
+ }
+ }
+ log(`chat ${message.id}: ${stop.signal.aborted ? 'stopped' : 'answered'}`);
+}