From 54693f8c650a12d49ac9e2579e5373adad059f10 Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Tue, 24 Nov 2026 12:54:23 +0000 Subject: [PATCH 1/6] =?UTF-8?q?PEP-253:=20=D0=BF=D0=BB=D0=B0=D0=BD=20?= =?UTF-8?q?=E2=80=94=20=D0=BA=D0=BB=D1=8E=D1=87=D0=B8=20=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B8=D1=81=D0=BE=D0=B2=20=D0=B8=D0=B7=20=D1=81=D0=B5?= =?UTF-8?q?=D0=BA=D1=80=D0=B5=D1=82=D0=BE=D0=B2=20=D0=B2=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- .../pep-253-secrets-to-access-hub/design.md | 38 +++++++ .../pep-253-secrets-to-access-hub/proposal.md | 23 ++++ .../specs/project-secrets/spec.md | 100 ++++++++++++++++++ .../pep-253-secrets-to-access-hub/tasks.md | 14 +++ 4 files changed, 175 insertions(+) create mode 100644 openspec/changes/pep-253-secrets-to-access-hub/design.md create mode 100644 openspec/changes/pep-253-secrets-to-access-hub/proposal.md create mode 100644 openspec/changes/pep-253-secrets-to-access-hub/specs/project-secrets/spec.md create mode 100644 openspec/changes/pep-253-secrets-to-access-hub/tasks.md diff --git a/openspec/changes/pep-253-secrets-to-access-hub/design.md b/openspec/changes/pep-253-secrets-to-access-hub/design.md new file mode 100644 index 00000000..a999f466 --- /dev/null +++ b/openspec/changes/pep-253-secrets-to-access-hub/design.md @@ -0,0 +1,38 @@ +## Решения + +**Кому идёт секрет — колонка, а не префикс имени.** `project_secrets.agent_env` (boolean, по умолчанию 1 — +существующие строки ведут себя как раньше). Новый секрет из ядра (`setProjectSecret`) — `agent_env = 0`, +если не передано `agent: true`; замена значения «кому» не меняет. Старое правило PEP-112 +(`ANTHROPIC_*`, `CLAUDE_*`, `OPENCODE_*` — только продукту) остаётся поверх колонки. + +**Настройка проекта — строка `settings` `project.agent-secrets:` `{on}`**, без миграции. Нет строки — +вкл. (так живут существующие проекты). `provisionProject` (веб, MCP, CLI — один путь) пишет `{on:false}`. +`core.createProject` не трогаем: прямые вызовы в тестах остаются «как раньше». +`projectSecretEnv(…, "agent")` при выкл. отдаёт пустое окружение; выкатка (`"deploy"`) и маскировка +по-прежнему видят все секреты. + +**Угадывание сервиса** — `core/secret-services.ts`, чистые правила: префиксы имени и формат значения +(`sk_test_`, `sk-ant-`, `ghp_`, `xoxb-`, `SG.`, `re_`, токен Telegram…). Только карточки каталога без своего +адреса (`baseEditable`) и с подходящей формой ключа (Twilio — «sid:token»): иначе одной кнопкой +подключение не создать. Вебхук-секреты (`whsec_`, `*_WEBHOOK_SECRET`), DSN, адреса — не ключи сервиса. +Значение используется только для проверки префикса и в отчёт не попадает. + +**Переезд** — `secretToConnection(db, userId, projectId, name)`: владелец подключения — тот, кто нажал +(подключения принадлежат пользователю, PEP-234); имя — карточка каталога, при совпадении — «<Сервис> · KEY». +Разрешение — весь проект, `read=auto`, `write=auto` («агент мог всё» → «чтение и запись, сразу»). +Секрет: `agent_env = 0`, `connection_id` = подключение. Событие `secret_to_connection`. Секрет не удаляется. + +**Отчёт** — `secretsAgentReport(db, {projectIds?})`: строки «секрет, кому, сервис, уже подключение». +Суперадмин — раздел на `/secrets` и CLI; владелец — пометки в своём списке секретов. Разовое сообщение +владельцам — `peppa secrets agent-report --notify` (runner `notifySecretsReport`, обсуждение проекта от FORGE, +отметка `secrets.report:` — повторно не шлёт). На живой системе запуск просим суперадмина: +агент в контейнере живую базу не видит. + +**Подсказка при вводе** — клиентский остров `SecretNameHint` получает от сервера пары «префикс → сервис» +(`secretNameHints()`), чтобы не тянуть ядро в браузер. + +## Риски +- Существующий проект, где агент реально пользовался ключом из env: после переезда ключа агент получит + отказ и должен звать `call_connection` — правило в RULES.md и текст `list_secrets` это говорят. +- Шлюз работает только из изолированного контейнера (PEP-234); на «none» агент без ключа останется без + доступа — это и есть цель. diff --git a/openspec/changes/pep-253-secrets-to-access-hub/proposal.md b/openspec/changes/pep-253-secrets-to-access-hub/proposal.md new file mode 100644 index 00000000..262a5a86 --- /dev/null +++ b/openspec/changes/pep-253-secrets-to-access-hub/proposal.md @@ -0,0 +1,23 @@ +## Why +Секреты проекта (PEP-54) раннер кладёт каждому агенту в окружение: агент может прочитать ключ, напечатать +его или унести. Access Hub (PEP-234/249) уже даёт агенту внешний сервис без ключа, но пока ключи +сервисов лежат и в секретах проекта, защита только на бумаге. + +## What Changes +- У секрета появляется «кому»: **только продукту** (выкатка, как раньше) или **агенту и продукту** + (агент видит ключ). Новый секрет по умолчанию — только продукту; существующие — как были (агенту). +- Настройка проекта «Агенты получают секреты в окружение»: новые проекты — выкл., существующие — вкл. + (как сейчас), владелец меняет в «⋯ Настройки проекта → Секреты». Выкл. — агенту не уходит ни один секрет. +- Угадывание сервиса каталога по имени и формату значения (`STRIPE_*`/`sk_test_…`, `OPENAI_API_KEY`/`sk-…`, + `GITHUB_TOKEN`/`ghp_…`…), значение не печатается. +- «Сделать подключением» одной кнопкой: подключение из каталога с этим ключом, разрешение проекту + «чтение и запись — сразу», секрет становится «только продукту»; ничего не удаляется. +- Ревизия: отчёт суперадмину (раздел «Секреты», CLI `peppa secrets agent-report`) и владельцам (пометки + в списке секретов, одно сообщение в обсуждение проекта по `--notify`). +- Подсказка при добавлении секрета с именем сервиса из каталога: «агенту лучше дать подключение». +- Правило агентам в `template/RULES.md`: ключ внешнего сервиса — через подключение / запрос доступа. + +## Impact +- БД: миграция `project_secrets.agent_env`, `project_secrets.connection_id`. +- core: `secrets.ts`, новый `secret-services.ts`; runner: `provisionProject`, отчёт владельцам; web: панель секретов, + `/secrets`; MCP `list_secrets`; CLI; `template/RULES.md`. diff --git a/openspec/changes/pep-253-secrets-to-access-hub/specs/project-secrets/spec.md b/openspec/changes/pep-253-secrets-to-access-hub/specs/project-secrets/spec.md new file mode 100644 index 00000000..18cf03cc --- /dev/null +++ b/openspec/changes/pep-253-secrets-to-access-hub/specs/project-secrets/spec.md @@ -0,0 +1,100 @@ +## MODIFIED Requirements + +### Requirement: Секреты в окружении сессии агента +Раннер SHALL выдавать сессии агента как переменные окружения только секреты проекта с пометкой +«агенту и продукту» и только если у проекта включена настройка «Агенты получают секреты в окружение». +Значения не попадают в аргументы tmux и в файлы, остающиеся на диске. Каждая выдача пишется в журнал +сессии событием `secrets_issued` со списком имён. + +#### Scenario: Агент получает секрет +- **GIVEN** у проекта PAY включена настройка «Агенты получают секреты в окружение» +- **AND** секрет `STRIPE_TEST_KEY` = `sk_test_123456` с пометкой «агенту и продукту» +- **WHEN** PM переводит стори PAY-3 в «В работе» +- **THEN** в процессе агента `STRIPE_TEST_KEY` = `sk_test_123456`, в журнале сессии событие `secrets_issued` с именами `["STRIPE_TEST_KEY"]`, файла `secrets.env` в каталоге запуска нет + +#### Scenario: Секрет только продукту +- **GIVEN** у проекта PAY секрет `MAPS_KEY` с пометкой «только продукту» +- **WHEN** запускается сессия агента PAY и выкатывается версия для проверки +- **THEN** в окружении агента `MAPS_KEY` нет, а продукт получает `MAPS_KEY` + +#### Scenario: Настройка выключена +- **GIVEN** у проекта PAY выключена настройка «Агенты получают секреты в окружение» +- **AND** секрет `STRIPE_TEST_KEY` с пометкой «агенту и продукту» +- **WHEN** запускается сессия агента PAY +- **THEN** в окружении агента секретов проекта нет, события `secrets_issued` нет + +#### Scenario: Секретов нет +- **GIVEN** у проекта PAY нет секретов +- **WHEN** запускается сессия агента +- **THEN** сессия стартует как раньше, события `secrets_issued` нет + +## ADDED Requirements + +### Requirement: Кому идёт секрет +Секрет проекта SHALL иметь пометку «только продукту» или «агенту и продукту». Новый секрет сохраняется +«только продукту», если владелец не выбрал иное; замена значения пометку не меняет; секреты, заведённые +до этой стори, остаются «агенту и продукту». Владелец и участники проекта SHALL менять пометку в списке +секретов. Выкатка продукта получает все секреты проекта независимо от пометки. + +#### Scenario: Новый секрет по умолчанию +- **GIVEN** PM — владелец проекта PAY +- **WHEN** PM сохраняет секрет `MAPS_KEY`, не меняя выбор «Кому» +- **THEN** в списке у `MAPS_KEY` написано «только продукту» + +#### Scenario: Замена значения +- **GIVEN** секрет `STRIPE_TEST_KEY` с пометкой «агенту и продукту» +- **WHEN** PM сохраняет новое значение `STRIPE_TEST_KEY` +- **THEN** пометка остаётся «агенту и продукту» + +### Requirement: Настройка «Агенты получают секреты в окружение» +Проект SHALL иметь настройку «Агенты получают секреты в окружение», которую видит и меняет владелец. +Новые проекты создаются с выключенной настройкой; у проектов, созданных раньше, она включена. + +#### Scenario: Новый проект +- **GIVEN** PM создаёт проект SHOP +- **WHEN** PM открывает «⋯ Настройки проекта → Секреты» +- **THEN** настройка «Агенты получают секреты в окружение» выключена + +#### Scenario: Старый проект +- **GIVEN** проект PAY создан до этой стори и настройку никто не менял +- **WHEN** запускается сессия агента PAY с секретом «агенту и продукту» +- **THEN** агент получает этот секрет, как раньше + +### Requirement: Ключ сервиса из каталога становится подключением +Для секрета, в котором по имени или формату значения узнаётся сервис каталога подключений, FORGE SHALL +показывать пометку «это ключ <Сервис> — агенту лучше дать подключение» и кнопку «Сделать подключением». +Кнопка создаёт подключение этого сервиса с тем же ключом, разрешение проекту «чтение и запись — сразу» и +делает секрет «только продукту». Секрет не удаляется. Значение секрета нигде не показывается. + +#### Scenario: Переезд ключа Stripe +- **GIVEN** в проекте PAY секрет `STRIPE_SECRET_KEY` = `sk_test_abc123` «агенту и продукту» +- **WHEN** владелец нажимает «Сделать подключением» +- **THEN** у владельца есть подключение «Stripe» с разрешением проекту PAY на чтение и запись сразу +- **AND** у секрета пометка «только продукту» и «стал подключением «Stripe»» +- **AND** агент PAY не получает `STRIPE_SECRET_KEY` в окружение, а выкатка продукта получает + +#### Scenario: Секрет не похож на ключ сервиса +- **GIVEN** секрет `FEATURE_FLAGS` = `beta,new-ui` +- **WHEN** владелец открывает список секретов +- **THEN** у `FEATURE_FLAGS` нет кнопки «Сделать подключением» + +#### Scenario: Подсказка при вводе +- **GIVEN** владелец добавляет секрет +- **WHEN** он вводит имя `OPENAI_API_KEY` +- **THEN** под полем видно «Это ключ OpenAI — агенту лучше дать подключение» + +### Requirement: Ревизия секретов +FORGE SHALL строить отчёт по секретам проектов: имя, кому идёт, узнанный сервис, стал ли подключением — +без значений. Суперадмин видит отчёт по всем проектам в разделе «Секреты» и в CLI +`peppa secrets agent-report`; с `--notify` владелец каждого проекта с ключами сервисов, которые ещё +уходят агентам, получает одно сообщение в обсуждении проекта (повторно не шлётся). + +#### Scenario: Отчёт суперадмину +- **GIVEN** в проекте PAY секрет `GITHUB_TOKEN` = `ghp_…` «агенту и продукту» +- **WHEN** суперадмин открывает раздел «Секреты» +- **THEN** в отчёте строка PAY · `GITHUB_TOKEN` · GitHub · «агенту», значения ключа нет + +#### Scenario: Сообщение владельцу один раз +- **GIVEN** владельцу проекта PAY уже отправлено сообщение о ключах сервисов +- **WHEN** суперадмин снова запускает `peppa secrets agent-report --notify` +- **THEN** нового сообщения в обсуждении PAY нет diff --git a/openspec/changes/pep-253-secrets-to-access-hub/tasks.md b/openspec/changes/pep-253-secrets-to-access-hub/tasks.md new file mode 100644 index 00000000..1adbc4a0 --- /dev/null +++ b/openspec/changes/pep-253-secrets-to-access-hub/tasks.md @@ -0,0 +1,14 @@ +## 1. Данные и ядро +- [ ] 1.1 Схема и миграция: `project_secrets.agent_env`, `project_secrets.connection_id` +- [ ] 1.2 `secrets.ts`: «кому» у секрета, настройка проекта, `projectSecretEnv` учитывает обе, `setSecretAudience` +- [ ] 1.3 `secret-services.ts`: угадывание сервиса, подсказки для веба, `secretsAgentReport`, `secretToConnection` +- [ ] 1.4 `provisionProject`: новым проектам настройка выкл. + +## 2. Каналы +- [ ] 2.1 Веб: список секретов (кому, сервис, «Сделать подключением», переключатель), форма с выбором и подсказкой, настройка проекта; `/secrets` — отчёт +- [ ] 2.2 MCP `list_secrets` агента; CLI `peppa secrets agent-report [--notify]`, runner `notifySecretsReport` +- [ ] 2.3 Переводы en/kk, словарь, «Помощь», `template/RULES.md` + +## 3. Тесты и завершение +- [ ] 3.1 Тест `secrets-access-hub.test.ts`; регрессия `secrets.test.ts`, `deploy.test.ts`, `access-hub*.test.ts` +- [ ] 3.2 lint, typecheck; память; archive; PR From e8a651a3b8526c3c516653ff0295afb64679c0cb Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Tue, 24 Nov 2026 12:58:15 +0000 Subject: [PATCH 2/6] =?UTF-8?q?PEP-253:=20=D1=81=D0=B5=D0=BA=D1=80=D0=B5?= =?UTF-8?q?=D1=82=20=C2=AB=D1=82=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B4=D1=83=D0=BA=D1=82=D1=83=C2=BB=20/=20=C2=AB?= =?UTF-8?q?=D0=B0=D0=B3=D0=B5=D0=BD=D1=82=D1=83=C2=BB,=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0,=20=D1=83=D0=B3=D0=B0=D0=B4=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8?= =?UTF-8?q?=D1=81=D0=B0,=20=D0=BF=D0=B5=D1=80=D0=B5=D0=B5=D0=B7=D0=B4=20?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5,=20=D0=BE=D1=82=D1=87=D1=91=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- packages/core/src/index.ts | 1 + packages/core/src/secret-services.ts | 185 + packages/core/src/secrets.ts | 55 +- .../db/migrations/0031_secrets_agent_env.sql | 2 + .../db/migrations/meta/0031_snapshot.json | 5295 +++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + packages/db/src/schema.ts | 5 + packages/runner/src/index.ts | 1 + packages/runner/src/provision.ts | 4 +- packages/runner/src/secrets-report.ts | 33 + 10 files changed, 5578 insertions(+), 10 deletions(-) create mode 100644 packages/core/src/secret-services.ts create mode 100644 packages/db/migrations/0031_secrets_agent_env.sql create mode 100644 packages/db/migrations/meta/0031_snapshot.json create mode 100644 packages/runner/src/secrets-report.ts diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 6b547a7b..0dc327fa 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -85,6 +85,7 @@ export * from "./budgets.ts"; export * from "./analytics.ts"; export * from "./audit.ts"; export * from "./secrets.ts"; +export * from "./secret-services.ts"; export * from "./product-needs.ts"; export * from "./product-review.ts"; export * from "./secrets-audit.ts"; diff --git a/packages/core/src/secret-services.ts b/packages/core/src/secret-services.ts new file mode 100644 index 00000000..2dcd2edf --- /dev/null +++ b/packages/core/src/secret-services.ts @@ -0,0 +1,185 @@ +// PEP-253: project secrets that are keys of Access Hub catalog services (PEP-249). An agent should +// reach such a service through the gateway (PEP-234) and never hold the key, so FORGE recognises +// them, reports them and moves them to a connection with one button. The value is looked at only +// for its prefix — it is never printed, logged or returned. +import { m as tr } from "@peppa/shared/i18n"; +import { connections, projects, projectSecrets, type Db } from "@peppa/db"; +import { and, asc, eq, inArray, isNull } from "drizzle-orm"; +import { logEvent } from "./audit.ts"; +import { catalogService, type CatalogService } from "./connection-catalog.ts"; +import { createConnection, grantConnection } from "./connections.ts"; +import { decrypt } from "./crypto.ts"; +import { PeppaError } from "./errors.ts"; +import { agentSecretsEnabled, productOnlySecret } from "./secrets.ts"; +import { setSetting } from "./settings.ts"; +import { projectForUser } from "./users.ts"; + +interface ServiceRule { + service: string; + /** Name prefixes (also exact names). */ + names: string[]; + /** Value prefixes / shapes that identify the service even under another name. */ + values?: RegExp[]; +} + +// Order matters: Anthropic's `sk-ant-` before OpenAI's `sk-`. +const RULES: ServiceRule[] = [ + { service: "stripe", names: ["STRIPE_"], values: [/^(sk|rk)_(test|live)_[A-Za-z0-9]{8,}$/] }, + { service: "anthropic", names: ["ANTHROPIC_API_KEY"], values: [/^sk-ant-[A-Za-z0-9_-]{8,}$/] }, + { service: "openai", names: ["OPENAI_"], values: [/^sk-(proj-)?[A-Za-z0-9_-]{16,}$/] }, + { service: "github", names: ["GITHUB_", "GH_TOKEN"], values: [/^(ghp|gho|ghu|ghs)_[A-Za-z0-9]{20,}$/, /^github_pat_[A-Za-z0-9_]{20,}$/] }, + { service: "slack", names: ["SLACK_"], values: [/^xox[bpa]-[A-Za-z0-9-]{10,}$/] }, + { service: "sendgrid", names: ["SENDGRID_"], values: [/^SG\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}$/] }, + { service: "resend", names: ["RESEND_"], values: [/^re_[A-Za-z0-9_]{16,}$/] }, + { service: "telegram", names: ["TELEGRAM_BOT_TOKEN", "TG_BOT_TOKEN", "BOT_TOKEN"], values: [/^\d{6,12}:[A-Za-z0-9_-]{30,}$/] }, + { service: "notion", names: ["NOTION_"], values: [/^(secret|ntn)_[A-Za-z0-9]{20,}$/] }, + { service: "airtable", names: ["AIRTABLE_"], values: [/^pat[A-Za-z0-9]{10,}\.[A-Za-z0-9]{20,}$/] }, + { service: "cloudflare", names: ["CLOUDFLARE_API_TOKEN", "CF_API_TOKEN"] }, + { service: "sentry", names: ["SENTRY_AUTH_TOKEN"], values: [/^sntrys_[A-Za-z0-9_=-]{20,}$/] }, + { service: "twilio", names: ["TWILIO_"] }, + { service: "kaspi", names: ["KASPI_"] }, + { service: "2gis", names: ["DGIS_", "TWOGIS_", "GIS2_"] }, + { service: "google-sheets", names: ["GOOGLE_SHEETS_", "SHEETS_API_KEY"] }, + { service: "google-drive", names: ["GOOGLE_DRIVE_"] }, + { service: "google-calendar", names: ["GOOGLE_CALENDAR_"] }, +]; + +/** Names that sit under a service prefix but are not an API key of it (webhook signing, DSN, ids, addresses). */ +const NOT_A_KEY = /(WEBHOOK|SIGNING|_DSN$|_URL$|_HOST$|_ID$|_PUBLISHABLE|_PUBLIC|_ORG$|_PROJECT$|_ENDPOINT$|_REGION$|_CHAT_ID$|_USERNAME$)/; +const NOT_A_KEY_VALUE = /^(whsec_|pk_(test|live)_|https?:\/\/)/; + +function usable(card: CatalogService | null): card is CatalogService { + // One button can't make a connection that needs the user's own address. + return !!card && !card.baseEditable; +} + +const nameMatches = (name: string, rule: ServiceRule) => rule.names.some((p) => (p.endsWith("_") ? name.startsWith(p) : name === p)); + +/** + * The catalog service a secret is a key of, or null. By name first, then by the value's shape. + * A value that clearly isn't a key (webhook secret, publishable key, address) is never a match. + */ +export function guessSecretService(name: string, value?: string | null): CatalogService | null { + const v = value?.trim() ?? ""; + if (v && NOT_A_KEY_VALUE.test(v)) return null; + if (NOT_A_KEY.test(name)) return null; + const byValue = v ? RULES.find((r) => r.values?.some((re) => re.test(v))) : undefined; + if (byValue) return usable(catalogService(byValue.service)) ? catalogService(byValue.service) : null; + const byName = RULES.find((r) => nameMatches(name, r)); + if (!byName) return null; + const card = catalogService(byName.service); + if (!usable(card)) return null; + // Basic auth needs «login:password» in one value — a lone token can't become such a connection. + if (card.auth === "basic" && v && !/^[^:]+:.+$/.test(v)) return null; + return card; +} + +/** For the web form's live hint (no core in the browser): name prefix → service name. */ +export function secretNameHints(): Array<{ prefix: string; exact: boolean; service: string }> { + return RULES.flatMap((r) => { + const card = catalogService(r.service); + return usable(card) ? r.names.map((p) => ({ prefix: p, exact: !p.endsWith("_"), service: card.name })) : []; + }); +} + +export interface SecretReportRow { + projectId: number; + projectKey: string; + ownerId: number | null; + name: string; + /** Marked «агенту и продукту». */ + agentEnv: boolean; + /** The project's agents get secrets at all (PEP-253 setting). */ + agentsGetSecrets: boolean; + /** Reaches agents' env right now. */ + inAgentEnv: boolean; + serviceId: string | null; + serviceName: string | null; + connectionId: number | null; + connectionName: string | null; + unreadable: boolean; +} + +/** + * Every project secret (live projects; `projectIds` narrows) with where it goes and the service + * it is a key of. No values. + */ +export async function secretsAgentReport(db: Db, o: { projectIds?: number[] } = {}): Promise { + if (o.projectIds && !o.projectIds.length) return []; + const rows = await db + .select({ s: projectSecrets, key: projects.key, ownerId: projects.ownerId, connectionName: connections.name }) + .from(projectSecrets) + .innerJoin(projects, eq(projects.id, projectSecrets.projectId)) + .leftJoin(connections, eq(connections.id, projectSecrets.connectionId)) + .where(and(isNull(projects.deletedAt), o.projectIds ? inArray(projects.id, o.projectIds) : undefined)) + .orderBy(asc(projects.key), asc(projectSecrets.name)); + const enabled = new Map(); + const out: SecretReportRow[] = []; + for (const r of rows) { + if (!enabled.has(r.s.projectId)) enabled.set(r.s.projectId, await agentSecretsEnabled(db, r.s.projectId)); + let value: string | null = null; + let unreadable = false; + try { + value = decrypt(r.s.valueEnc); + } catch { + unreadable = true; + } + const card = guessSecretService(r.s.name, value); + const agentsGetSecrets = enabled.get(r.s.projectId)!; + out.push({ + projectId: r.s.projectId, + projectKey: r.key, + ownerId: r.ownerId, + name: r.s.name, + agentEnv: r.s.agentEnv, + agentsGetSecrets, + inAgentEnv: agentsGetSecrets && r.s.agentEnv && !productOnlySecret(r.s.name), + serviceId: card?.id ?? null, + serviceName: card?.name ?? null, + connectionId: r.s.connectionId, + connectionName: r.connectionName ?? null, + unreadable, + }); + } + return out; +} + +/** A secret the owner should move: a service key that still reaches agents and isn't a connection yet. */ +export const shouldMove = (r: SecretReportRow) => !!r.serviceId && r.inAgentEnv && !r.connectionId && !r.unreadable; + +/** + * «Сделать подключением»: a connection of the recognised catalog service with the secret's key, + * owned by the person who pressed; a grant to the whole project with reading and writing at once + * (an agent with the key in env could do anything); the secret stays, but only for the product. + */ +export async function secretToConnection(db: Db, userId: number, projectId: number, name: string): Promise<{ connectionId: number; connectionName: string }> { + const project = await projectForUser(db, userId, projectId); + const [s] = await db.select().from(projectSecrets).where(and(eq(projectSecrets.projectId, projectId), eq(projectSecrets.name, name))); + if (!s) throw new PeppaError(tr("Секрета {name} нет", { name })); + if (s.connectionId) throw new PeppaError(tr("Этот ключ уже стал подключением")); + let value: string; + try { + value = decrypt(s.valueEnc); + } catch { + throw new PeppaError(tr("Значение секрета не читается — сохраните его заново")); + } + const card = guessSecretService(name, value); + if (!card) throw new PeppaError(tr("Не удалось понять, ключ какого сервиса в секрете {name}", { name })); + const mine = await db.select({ name: connections.name }).from(connections).where(eq(connections.ownerId, userId)); + const taken = new Set(mine.map((c) => c.name)); + let connName = card.name; + if (taken.has(connName)) connName = `${card.name} · ${project.key}`; + for (let i = 2; taken.has(connName); i++) connName = `${card.name} · ${project.key} ${i}`; + const conn = await createConnection(db, userId, { catalogId: card.id, name: connName, secret: value.trim() }); + await grantConnection(db, userId, conn.id, { projectId, agentId: null, readMode: "auto", writeMode: "auto" }); + await db.update(projectSecrets).set({ agentEnv: false, connectionId: conn.id, updatedBy: userId, updatedAt: new Date() }).where(eq(projectSecrets.id, s.id)); + await logEvent(db, { projectId, type: "secret_to_connection", payload: { name, connectionId: conn.id, service: card.id } }); + return { connectionId: conn.id, connectionName: conn.name }; +} + +/** `settings` key: the owner of the project was told about service keys in secrets (once). */ +export const secretsReportNoticeKey = (projectId: number) => `secrets.report:${projectId}`; + +export async function markSecretsReportNoticed(db: Db, projectId: number, names: string[]): Promise { + await setSetting(db, secretsReportNoticeKey(projectId), { at: Date.now(), names }); +} diff --git a/packages/core/src/secrets.ts b/packages/core/src/secrets.ts index b3dc8160..91a70bcc 100644 --- a/packages/core/src/secrets.ts +++ b/packages/core/src/secrets.ts @@ -1,4 +1,5 @@ -// PEP-54: a project's secrets for its agents. Values are AES-256-GCM encrypted with +// PEP-54: a project's secrets for its agents. +// PEP-253: and/or only for the deployed product (`agent_env`); keys of catalog services move to Access Hub. Values are AES-256-GCM encrypted with // PEPPA_SECRET, never shown after saving, handed to agent sessions as env by the runner // and masked in the web terminal and agent steps. import { m as tr } from "@peppa/shared/i18n"; @@ -7,7 +8,7 @@ import { and, asc, eq, inArray } from "drizzle-orm"; import { logEvent } from "./audit.ts"; import { decrypt, encrypt } from "./crypto.ts"; import { PeppaError } from "./errors.ts"; -import { setSetting } from "./settings.ts"; +import { getSetting, setSetting } from "./settings.ts"; import { projectForUser } from "./users.ts"; export const SECRET_NAME_RE = /^[A-Z][A-Z0-9_]{0,63}$/; @@ -26,6 +27,23 @@ const RESERVED_PREFIX = ["PEPPA_", "LD_", "DYLD_", "TMUX"]; */ const PRODUCT_ONLY_PREFIX = ["CLAUDE_", "ANTHROPIC_", "OPENCODE_"]; export const productOnlySecret = (name: string) => PRODUCT_ONLY_PREFIX.some((p) => name.startsWith(p)); +/** + * PEP-253: «Агенты получают секреты в окружение». No row = on (projects made before PEP-253 work + * as they did); `provisionProject` writes off for every new project. + */ +export const agentSecretsKey = (projectId: number) => `project.agent-secrets:${projectId}`; + +export async function agentSecretsEnabled(db: Db, projectId: number): Promise { + return (await getSetting<{ on?: boolean }>(db, agentSecretsKey(projectId)))?.on !== false; +} + +/** Owner and members; the change applies from the next agent start. */ +export async function setAgentSecretsEnabled(db: Db, userId: number | null, projectId: number, on: boolean): Promise { + if (userId != null) await projectForUser(db, userId, projectId); + await setSetting(db, agentSecretsKey(projectId), { on, at: Date.now() }); + if (userId != null) await logEvent(db, { projectId, type: "agent_secrets_setting", payload: { on } }); +} + /** `settings` key: when the project's secrets last changed and deployed versions need a restart. */ export const secretsChangedKey = (projectId: number) => `product.redeploy:${projectId}`; @@ -41,12 +59,16 @@ export interface ProjectSecretView { updatedAt: Date; updatedBy: string | null; lastUsedAt: Date | null; + /** PEP-253: also into agents' env (else only to the deployed product). */ + agentEnv: boolean; + /** PEP-253: the Access Hub connection the key moved to. */ + connectionId: number | null; } /** Secrets of a project without values (web, MCP). */ export async function listProjectSecrets(db: Db, projectId: number): Promise { const rows = await db - .select({ id: projectSecrets.id, name: projectSecrets.name, updatedAt: projectSecrets.updatedAt, updatedBy: users.login, lastUsedAt: projectSecrets.lastUsedAt }) + .select({ id: projectSecrets.id, name: projectSecrets.name, updatedAt: projectSecrets.updatedAt, updatedBy: users.login, lastUsedAt: projectSecrets.lastUsedAt, agentEnv: projectSecrets.agentEnv, connectionId: projectSecrets.connectionId }) .from(projectSecrets) .leftJoin(users, eq(users.id, projectSecrets.updatedBy)) .where(eq(projectSecrets.projectId, projectId)) @@ -54,8 +76,12 @@ export async function listProjectSecrets(db: Db, projectId: number): Promise { +/** + * Creates or replaces a secret; owner and members of the project only. PEP-253: a new secret goes + * only to the deployed product unless `agent: true`; replacing a value keeps where it goes unless + * `agent` is given. + */ +export async function setProjectSecret(db: Db, userId: number, projectId: number, name: string, value: string, o: { agent?: boolean } = {}): Promise { await projectForUser(db, userId, projectId); name = name.trim(); const err = secretNameError(name); @@ -65,13 +91,21 @@ export async function setProjectSecret(db: Db, userId: number, projectId: number if (Buffer.byteLength(value) > SECRET_MAX_BYTES) throw new PeppaError(tr("Значение секрета больше 16 КБ")); const valueEnc = encrypt(value); const [existing] = await db.select({ id: projectSecrets.id }).from(projectSecrets).where(and(eq(projectSecrets.projectId, projectId), eq(projectSecrets.name, name))); - if (existing) await db.update(projectSecrets).set({ valueEnc, updatedBy: userId, updatedAt: new Date() }).where(eq(projectSecrets.id, existing.id)); - else await db.insert(projectSecrets).values({ projectId, name, valueEnc, createdBy: userId, updatedBy: userId }); - await logEvent(db, { projectId, type: "secret_set", payload: { name, replaced: !!existing } }); + if (existing) await db.update(projectSecrets).set({ valueEnc, updatedBy: userId, updatedAt: new Date(), ...(o.agent != null ? { agentEnv: o.agent } : {}) }).where(eq(projectSecrets.id, existing.id)); + else await db.insert(projectSecrets).values({ projectId, name, valueEnc, createdBy: userId, updatedBy: userId, agentEnv: o.agent ?? false }); + await logEvent(db, { projectId, type: "secret_set", payload: { name, replaced: !!existing, ...(o.agent != null ? { agent: o.agent } : {}) } }); await setSetting(db, secretsChangedKey(projectId), { at: Date.now() }); return (await listProjectSecrets(db, projectId)).find((s) => s.name === name)!; } +/** PEP-253: «только продукту» (false) or «агенту и продукту» (true); owner and members. */ +export async function setSecretAudience(db: Db, userId: number, projectId: number, name: string, agent: boolean): Promise { + await projectForUser(db, userId, projectId); + const done = await db.update(projectSecrets).set({ agentEnv: agent, updatedBy: userId, updatedAt: new Date() }).where(and(eq(projectSecrets.projectId, projectId), eq(projectSecrets.name, name))).returning({ id: projectSecrets.id }); + if (!done.length) throw new PeppaError(tr("Секрета {name} нет", { name })); + await logEvent(db, { projectId, type: "secret_audience", payload: { name, agent } }); +} + export async function deleteProjectSecret(db: Db, userId: number, projectId: number, name: string): Promise { await projectForUser(db, userId, projectId); const gone = await db.delete(projectSecrets).where(and(eq(projectSecrets.projectId, projectId), eq(projectSecrets.name, name))).returning({ id: projectSecrets.id }); @@ -84,13 +118,16 @@ export async function deleteProjectSecret(db: Db, userId: number, projectId: num * name → value for an agent session or for a deploy of the product (runner only). Unreadable * values (wrong key) are skipped and reported, so one broken secret never blocks a session. * PEP-112: product-only names (ANTHROPIC_*, …) are left out of agent sessions. + * PEP-253: an agent gets only secrets marked «агенту и продукту», and none at all when the + * project's «Агенты получают секреты в окружение» is off. A deploy gets every secret. */ export async function projectSecretEnv(db: Db, projectId: number, target: "agent" | "deploy" = "agent"): Promise<{ env: Record; unreadable: string[] }> { + if (target === "agent" && !(await agentSecretsEnabled(db, projectId))) return { env: {}, unreadable: [] }; const rows = await db.select().from(projectSecrets).where(eq(projectSecrets.projectId, projectId)).orderBy(asc(projectSecrets.name)); const env: Record = {}; const unreadable: string[] = []; for (const r of rows) { - if (target === "agent" && productOnlySecret(r.name)) continue; + if (target === "agent" && (productOnlySecret(r.name) || !r.agentEnv)) continue; try { env[r.name] = decrypt(r.valueEnc); } catch { diff --git a/packages/db/migrations/0031_secrets_agent_env.sql b/packages/db/migrations/0031_secrets_agent_env.sql new file mode 100644 index 00000000..3093c0b2 --- /dev/null +++ b/packages/db/migrations/0031_secrets_agent_env.sql @@ -0,0 +1,2 @@ +ALTER TABLE `project_secrets` ADD `agent_env` integer DEFAULT true NOT NULL;--> statement-breakpoint +ALTER TABLE `project_secrets` ADD `connection_id` integer REFERENCES connections(id); \ No newline at end of file diff --git a/packages/db/migrations/meta/0031_snapshot.json b/packages/db/migrations/meta/0031_snapshot.json new file mode 100644 index 00000000..8e3b8997 --- /dev/null +++ b/packages/db/migrations/meta/0031_snapshot.json @@ -0,0 +1,5295 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "9cf50dea-f14f-432b-a35a-af13076a2fca", + "prevId": "1ad8db33-759f-4508-9ebd-50d0f75742c5", + "tables": { + "agents": { + "name": "agents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "character": { + "name": "character", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "disabled_at": { + "name": "disabled_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "agents_name_unique": { + "name": "agents_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "attachments": { + "name": "attachments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "chat_message_id": { + "name": "chat_message_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "event_id": { + "name": "event_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "file": { + "name": "file", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime": { + "name": "mime", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "attachments_task": { + "name": "attachments_task", + "columns": [ + "task_id" + ], + "isUnique": false + }, + "attachments_message": { + "name": "attachments_message", + "columns": [ + "chat_message_id" + ], + "isUnique": false + }, + "attachments_event": { + "name": "attachments_event", + "columns": [ + "event_id" + ], + "isUnique": false + }, + "attachments_project": { + "name": "attachments_project", + "columns": [ + "project_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "attachments_project_id_projects_id_fk": { + "name": "attachments_project_id_projects_id_fk", + "tableFrom": "attachments", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "attachments_user_id_users_id_fk": { + "name": "attachments_user_id_users_id_fk", + "tableFrom": "attachments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "attachments_task_id_tasks_id_fk": { + "name": "attachments_task_id_tasks_id_fk", + "tableFrom": "attachments", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "attachments_chat_message_id_chat_messages_id_fk": { + "name": "attachments_chat_message_id_chat_messages_id_fk", + "tableFrom": "attachments", + "tableTo": "chat_messages", + "columnsFrom": [ + "chat_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "attachments_event_id_events_id_fk": { + "name": "attachments_event_id_events_id_fk", + "tableFrom": "attachments", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "chat_messages": { + "name": "chat_messages", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "chat_id": { + "name": "chat_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "thread_key": { + "name": "thread_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "thread_title": { + "name": "thread_title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "important": { + "name": "important", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "author_kind": { + "name": "author_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'system'" + }, + "author_user_id": { + "name": "author_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "author_login": { + "name": "author_login", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "via": { + "name": "via", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "question_id": { + "name": "question_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_chat_id": { + "name": "tg_chat_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_message_id": { + "name": "tg_message_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "chat_messages_dedupe_key_unique": { + "name": "chat_messages_dedupe_key_unique", + "columns": [ + "dedupe_key" + ], + "isUnique": true + }, + "chat_messages_chat": { + "name": "chat_messages_chat", + "columns": [ + "chat_id", + "id" + ], + "isUnique": false + }, + "chat_messages_thread": { + "name": "chat_messages_thread", + "columns": [ + "chat_id", + "thread_key", + "id" + ], + "isUnique": false + }, + "chat_messages_created_at": { + "name": "chat_messages_created_at", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "chat_messages_tg": { + "name": "chat_messages_tg", + "columns": [ + "tg_chat_id", + "tg_message_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "chat_messages_chat_id_chats_id_fk": { + "name": "chat_messages_chat_id_chats_id_fk", + "tableFrom": "chat_messages", + "tableTo": "chats", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chat_messages_author_user_id_users_id_fk": { + "name": "chat_messages_author_user_id_users_id_fk", + "tableFrom": "chat_messages", + "tableTo": "users", + "columnsFrom": [ + "author_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chat_messages_question_id_questions_id_fk": { + "name": "chat_messages_question_id_questions_id_fk", + "tableFrom": "chat_messages", + "tableTo": "questions", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chat_messages_task_id_tasks_id_fk": { + "name": "chat_messages_task_id_tasks_id_fk", + "tableFrom": "chat_messages", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "chats": { + "name": "chats", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_chat_id": { + "name": "tg_chat_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_title": { + "name": "tg_title", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_linked_at": { + "name": "tg_linked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_linked_by": { + "name": "tg_linked_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tg_bot_user_id": { + "name": "tg_bot_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "chats_user_id_unique": { + "name": "chats_user_id_unique", + "columns": [ + "user_id" + ], + "isUnique": true + }, + "chats_project_id_unique": { + "name": "chats_project_id_unique", + "columns": [ + "project_id" + ], + "isUnique": true + }, + "chats_tg_chat_id_unique": { + "name": "chats_tg_chat_id_unique", + "columns": [ + "tg_chat_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "chats_user_id_users_id_fk": { + "name": "chats_user_id_users_id_fk", + "tableFrom": "chats", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chats_project_id_projects_id_fk": { + "name": "chats_project_id_projects_id_fk", + "tableFrom": "chats", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "chats_tg_linked_by_users_id_fk": { + "name": "chats_tg_linked_by_users_id_fk", + "tableFrom": "chats", + "tableTo": "users", + "columnsFrom": [ + "tg_linked_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "chats_tg_bot_user_id_users_id_fk": { + "name": "chats_tg_bot_user_id_users_id_fk", + "tableFrom": "chats", + "tableTo": "users", + "columnsFrom": [ + "tg_bot_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "check_runs": { + "name": "check_runs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "branch": { + "name": "branch", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check": { + "name": "check", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "run_url": { + "name": "run_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "log_tail": { + "name": "log_tail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_sec": { + "name": "duration_sec", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'report'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "check_runs_project_sha_check": { + "name": "check_runs_project_sha_check", + "columns": [ + "project_id", + "sha", + "check" + ], + "isUnique": true + }, + "check_runs_task_sha": { + "name": "check_runs_task_sha", + "columns": [ + "task_id", + "sha" + ], + "isUnique": false + }, + "check_runs_updated": { + "name": "check_runs_updated", + "columns": [ + "updated_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "check_runs_project_id_projects_id_fk": { + "name": "check_runs_project_id_projects_id_fk", + "tableFrom": "check_runs", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "check_runs_task_id_tasks_id_fk": { + "name": "check_runs_task_id_tasks_id_fk", + "tableFrom": "check_runs", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "code_reviews": { + "name": "code_reviews", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "state": { + "name": "state", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "verdict": { + "name": "verdict", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "findings": { + "name": "findings", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "code_reviews_project_id_projects_id_fk": { + "name": "code_reviews_project_id_projects_id_fk", + "tableFrom": "code_reviews", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "code_reviews_task_id_tasks_id_fk": { + "name": "code_reviews_task_id_tasks_id_fk", + "tableFrom": "code_reviews", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "connection_grants": { + "name": "connection_grants", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "connection_id": { + "name": "connection_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "operations": { + "name": "operations", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "read_mode": { + "name": "read_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'off'" + }, + "write_mode": { + "name": "write_mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'off'" + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "connection_grants_project": { + "name": "connection_grants_project", + "columns": [ + "project_id" + ], + "isUnique": false + }, + "connection_grants_connection": { + "name": "connection_grants_connection", + "columns": [ + "connection_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "connection_grants_connection_id_connections_id_fk": { + "name": "connection_grants_connection_id_connections_id_fk", + "tableFrom": "connection_grants", + "tableTo": "connections", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "connection_grants_project_id_projects_id_fk": { + "name": "connection_grants_project_id_projects_id_fk", + "tableFrom": "connection_grants", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "connection_grants_agent_id_agents_id_fk": { + "name": "connection_grants_agent_id_agents_id_fk", + "tableFrom": "connection_grants", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "connection_grants_created_by_users_id_fk": { + "name": "connection_grants_created_by_users_id_fk", + "tableFrom": "connection_grants", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "connection_log": { + "name": "connection_log", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "owner_id": { + "name": "owner_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connection_id": { + "name": "connection_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "connection_name": { + "name": "connection_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_name": { + "name": "agent_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "path": { + "name": "path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status_code": { + "name": "status_code", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'call'" + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "project_key": { + "name": "project_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "prev_hash": { + "name": "prev_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "hash": { + "name": "hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "connection_log_owner": { + "name": "connection_log_owner", + "columns": [ + "owner_id", + "id" + ], + "isUnique": false + }, + "connection_log_session_created": { + "name": "connection_log_session_created", + "columns": [ + "session_id", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "connection_log_owner_id_users_id_fk": { + "name": "connection_log_owner_id_users_id_fk", + "tableFrom": "connection_log", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "connection_log_connection_id_connections_id_fk": { + "name": "connection_log_connection_id_connections_id_fk", + "tableFrom": "connection_log", + "tableTo": "connections", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "connection_log_project_id_projects_id_fk": { + "name": "connection_log_project_id_projects_id_fk", + "tableFrom": "connection_log", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "connection_log_session_id_sessions_id_fk": { + "name": "connection_log_session_id_sessions_id_fk", + "tableFrom": "connection_log", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "connection_log_agent_id_agents_id_fk": { + "name": "connection_log_agent_id_agents_id_fk", + "tableFrom": "connection_log", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "connections": { + "name": "connections", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "owner_id": { + "name": "owner_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_kind": { + "name": "auth_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'bearer'" + }, + "auth_header": { + "name": "auth_header", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "catalog_id": { + "name": "catalog_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_status": { + "name": "check_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "checked_at": { + "name": "checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "check_alerted_at": { + "name": "check_alerted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dek_enc": { + "name": "dek_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'active'" + }, + "revoked_at": { + "name": "revoked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "connections_owner_name": { + "name": "connections_owner_name", + "columns": [ + "owner_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "connections_owner_id_users_id_fk": { + "name": "connections_owner_id_users_id_fk", + "tableFrom": "connections", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "error_sources": { + "name": "error_sources", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bugsink_project_id": { + "name": "bugsink_project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "dsn": { + "name": "dsn", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "error_sources_bugsink_project_id_unique": { + "name": "error_sources_bugsink_project_id_unique", + "columns": [ + "bugsink_project_id" + ], + "isUnique": true + }, + "error_sources_project_kind": { + "name": "error_sources_project_kind", + "columns": [ + "project_id", + "kind" + ], + "isUnique": true + } + }, + "foreignKeys": { + "error_sources_project_id_projects_id_fk": { + "name": "error_sources_project_id_projects_id_fk", + "tableFrom": "error_sources", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "events": { + "name": "events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_kind": { + "name": "actor_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_user_id": { + "name": "actor_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_channel": { + "name": "actor_channel", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor_client_id": { + "name": "actor_client_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "events_created_at": { + "name": "events_created_at", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "events_session_type": { + "name": "events_session_type", + "columns": [ + "session_id", + "type" + ], + "isUnique": false + }, + "events_type_created": { + "name": "events_type_created", + "columns": [ + "type", + "created_at" + ], + "isUnique": false + }, + "events_project_created": { + "name": "events_project_created", + "columns": [ + "project_id", + "created_at" + ], + "isUnique": false + }, + "events_task_type": { + "name": "events_task_type", + "columns": [ + "task_id", + "type" + ], + "isUnique": false + } + }, + "foreignKeys": { + "events_project_id_projects_id_fk": { + "name": "events_project_id_projects_id_fk", + "tableFrom": "events", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "events_task_id_tasks_id_fk": { + "name": "events_task_id_tasks_id_fk", + "tableFrom": "events", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "events_session_id_sessions_id_fk": { + "name": "events_session_id_sessions_id_fk", + "tableFrom": "events", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "events_actor_user_id_users_id_fk": { + "name": "events_actor_user_id_users_id_fk", + "tableFrom": "events", + "tableTo": "users", + "columnsFrom": [ + "actor_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "feedback": { + "name": "feedback", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "via": { + "name": "via", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "context": { + "name": "context", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'{}'" + }, + "screenshots": { + "name": "screenshots", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'received'" + }, + "analysis": { + "name": "analysis", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "analysis_error": { + "name": "analysis_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "analysis_started_at": { + "name": "analysis_started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "option_index": { + "name": "option_index", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reject_reason": { + "name": "reject_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "decided_by": { + "name": "decided_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "decided_at": { + "name": "decided_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "feedback_user": { + "name": "feedback_user", + "columns": [ + "user_id", + "created_at" + ], + "isUnique": false + }, + "feedback_status": { + "name": "feedback_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "feedback_user_id_users_id_fk": { + "name": "feedback_user_id_users_id_fk", + "tableFrom": "feedback", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "feedback_task_id_tasks_id_fk": { + "name": "feedback_task_id_tasks_id_fk", + "tableFrom": "feedback", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "feedback_decided_by_users_id_fk": { + "name": "feedback_decided_by_users_id_fk", + "tableFrom": "feedback", + "tableTo": "users", + "columnsFrom": [ + "decided_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "goals": { + "name": "goals", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'open'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "goals_project_id_projects_id_fk": { + "name": "goals_project_id_projects_id_fk", + "tableFrom": "goals", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "incident_settings": { + "name": "incident_settings", + "columns": { + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "hook_secret": { + "name": "hook_secret", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "policy": { + "name": "policy", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'backlog'" + }, + "triage_prompt": { + "name": "triage_prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "environments": { + "name": "environments", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[\"prod\",\"production\"]'" + }, + "daily_limit": { + "name": "daily_limit", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 5 + }, + "ignore_pattern": { + "name": "ignore_pattern", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "goal_id": { + "name": "goal_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "webhook_auto": { + "name": "webhook_auto", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "incident_settings_hook_secret_unique": { + "name": "incident_settings_hook_secret_unique", + "columns": [ + "hook_secret" + ], + "isUnique": true + } + }, + "foreignKeys": { + "incident_settings_project_id_projects_id_fk": { + "name": "incident_settings_project_id_projects_id_fk", + "tableFrom": "incident_settings", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incident_settings_goal_id_goals_id_fk": { + "name": "incident_settings_goal_id_goals_id_fk", + "tableFrom": "incident_settings", + "tableTo": "goals", + "columnsFrom": [ + "goal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "incidents": { + "name": "incidents", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "bugsink_issue_id": { + "name": "bugsink_issue_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "friendly_id": { + "name": "friendly_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "culprit": { + "name": "culprit", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "environment": { + "name": "environment", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "first_release": { + "name": "first_release", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_release": { + "name": "last_release", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "events": { + "name": "events", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "first_seen": { + "name": "first_seen", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "last_seen": { + "name": "last_seen", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "stack": { + "name": "stack", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'new'" + }, + "decision": { + "name": "decision", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "decided_by": { + "name": "decided_by", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "decision_reason": { + "name": "decision_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "task_created_at": { + "name": "task_created_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "resolved_release": { + "name": "resolved_release", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "resolved_at": { + "name": "resolved_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "regressions": { + "name": "regressions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "incidents_bugsink_issue_id_unique": { + "name": "incidents_bugsink_issue_id_unique", + "columns": [ + "bugsink_issue_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "incidents_project_id_projects_id_fk": { + "name": "incidents_project_id_projects_id_fk", + "tableFrom": "incidents", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "incidents_task_id_tasks_id_fk": { + "name": "incidents_task_id_tasks_id_fk", + "tableFrom": "incidents", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_clients": { + "name": "oauth_clients", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "redirect_uris": { + "name": "redirect_uris", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_codes": { + "name": "oauth_codes", + "columns": { + "code_hash": { + "name": "code_hash", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "redirect_uri": { + "name": "redirect_uri", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "code_challenge": { + "name": "code_challenge", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "used_at": { + "name": "used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "oauth_codes_client_id_oauth_clients_id_fk": { + "name": "oauth_codes_client_id_oauth_clients_id_fk", + "tableFrom": "oauth_codes", + "tableTo": "oauth_clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_codes_user_id_users_id_fk": { + "name": "oauth_codes_user_id_users_id_fk", + "tableFrom": "oauth_codes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "oauth_tokens": { + "name": "oauth_tokens", + "columns": { + "token_hash": { + "name": "token_hash", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "client_id": { + "name": "client_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "revoked_at": { + "name": "revoked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "oauth_tokens_client_id_oauth_clients_id_fk": { + "name": "oauth_tokens_client_id_oauth_clients_id_fk", + "tableFrom": "oauth_tokens", + "tableTo": "oauth_clients", + "columnsFrom": [ + "client_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "oauth_tokens_user_id_users_id_fk": { + "name": "oauth_tokens_user_id_users_id_fk", + "tableFrom": "oauth_tokens", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_invites": { + "name": "project_invites", + "columns": { + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "login": { + "name": "login", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "invited_by": { + "name": "invited_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "project_invites_project_id_projects_id_fk": { + "name": "project_invites_project_id_projects_id_fk", + "tableFrom": "project_invites", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_invites_invited_by_users_id_fk": { + "name": "project_invites_invited_by_users_id_fk", + "tableFrom": "project_invites", + "tableTo": "users", + "columnsFrom": [ + "invited_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_invites_project_id_login_pk": { + "columns": [ + "project_id", + "login" + ], + "name": "project_invites_project_id_login_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_members": { + "name": "project_members", + "columns": { + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "added_by": { + "name": "added_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "project_members_project_id_projects_id_fk": { + "name": "project_members_project_id_projects_id_fk", + "tableFrom": "project_members", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_members_user_id_users_id_fk": { + "name": "project_members_user_id_users_id_fk", + "tableFrom": "project_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_members_added_by_users_id_fk": { + "name": "project_members_added_by_users_id_fk", + "tableFrom": "project_members", + "tableTo": "users", + "columnsFrom": [ + "added_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "project_members_project_id_user_id_pk": { + "columns": [ + "project_id", + "user_id" + ], + "name": "project_members_project_id_user_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_secrets": { + "name": "project_secrets", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "value_enc": { + "name": "value_enc", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_by": { + "name": "updated_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "last_used_at": { + "name": "last_used_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_env": { + "name": "agent_env", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "connection_id": { + "name": "connection_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "project_secrets_project_name": { + "name": "project_secrets_project_name", + "columns": [ + "project_id", + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "project_secrets_project_id_projects_id_fk": { + "name": "project_secrets_project_id_projects_id_fk", + "tableFrom": "project_secrets", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_secrets_created_by_users_id_fk": { + "name": "project_secrets_created_by_users_id_fk", + "tableFrom": "project_secrets", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "project_secrets_updated_by_users_id_fk": { + "name": "project_secrets_updated_by_users_id_fk", + "tableFrom": "project_secrets", + "tableTo": "users", + "columnsFrom": [ + "updated_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "project_secrets_connection_id_connections_id_fk": { + "name": "project_secrets_connection_id_connections_id_fk", + "tableFrom": "project_secrets", + "tableTo": "connections", + "columnsFrom": [ + "connection_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gitea_owner": { + "name": "gitea_owner", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "gitea_repo": { + "name": "gitea_repo", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "default_branch": { + "name": "default_branch", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'main'" + }, + "workspace_path": { + "name": "workspace_path", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "next_task_number": { + "name": "next_task_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "subscription_pool_id": { + "name": "subscription_pool_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_at": { + "name": "deleted_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "deleted_by": { + "name": "deleted_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "projects_slug_unique": { + "name": "projects_slug_unique", + "columns": [ + "slug" + ], + "isUnique": true + }, + "projects_key_unique": { + "name": "projects_key_unique", + "columns": [ + "key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "projects_owner_id_users_id_fk": { + "name": "projects_owner_id_users_id_fk", + "tableFrom": "projects", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "projects_subscription_pool_id_subscription_pools_id_fk": { + "name": "projects_subscription_pool_id_subscription_pools_id_fk", + "tableFrom": "projects", + "tableTo": "subscription_pools", + "columnsFrom": [ + "subscription_pool_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "projects_deleted_by_users_id_fk": { + "name": "projects_deleted_by_users_id_fk", + "tableFrom": "projects", + "tableTo": "users", + "columnsFrom": [ + "deleted_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_outbox": { + "name": "push_outbox", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subscription_id": { + "name": "subscription_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "urgency": { + "name": "urgency", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'normal'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "sent_at": { + "name": "sent_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "push_outbox_dedupe_key_unique": { + "name": "push_outbox_dedupe_key_unique", + "columns": [ + "dedupe_key" + ], + "isUnique": true + }, + "push_outbox_status_created": { + "name": "push_outbox_status_created", + "columns": [ + "status", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "push_outbox_subscription_id_push_subscriptions_id_fk": { + "name": "push_outbox_subscription_id_push_subscriptions_id_fk", + "tableFrom": "push_outbox", + "tableTo": "push_subscriptions", + "columnsFrom": [ + "subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_subscriptions": { + "name": "push_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "last_ok_at": { + "name": "last_ok_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "columns": [ + "endpoint" + ], + "isUnique": true + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "questions": { + "name": "questions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "session_id": { + "name": "session_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "options": { + "name": "options", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "msg_type": { + "name": "msg_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "default_option": { + "name": "default_option", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "answer": { + "name": "answer", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "answered_via": { + "name": "answered_via", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_message_id": { + "name": "telegram_message_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "awaiting_hook": { + "name": "awaiting_hook", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "reminders": { + "name": "reminders", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "answered_at": { + "name": "answered_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "questions_project_answered": { + "name": "questions_project_answered", + "columns": [ + "project_id", + "answered_at" + ], + "isUnique": false + }, + "questions_task": { + "name": "questions_task", + "columns": [ + "task_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "questions_project_id_projects_id_fk": { + "name": "questions_project_id_projects_id_fk", + "tableFrom": "questions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "questions_task_id_tasks_id_fk": { + "name": "questions_task_id_tasks_id_fk", + "tableFrom": "questions", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "questions_session_id_sessions_id_fk": { + "name": "questions_session_id_sessions_id_fk", + "tableFrom": "questions", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "releases": { + "name": "releases", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "env": { + "name": "env", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sha": { + "name": "sha", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "previous_sha": { + "name": "previous_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host": { + "name": "host", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_number": { + "name": "pr_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tasks": { + "name": "tasks", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'deploying'" + }, + "deployed_by": { + "name": "deployed_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'ci'" + }, + "reason": { + "name": "reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "run_url": { + "name": "run_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "log_tail": { + "name": "log_tail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "screenshots": { + "name": "screenshots", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "releases_project_id_projects_id_fk": { + "name": "releases_project_id_projects_id_fk", + "tableFrom": "releases", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "review_settings": { + "name": "review_settings", + "columns": { + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "enabled": { + "name": "enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "max_iterations": { + "name": "max_iterations", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 2 + }, + "rules": { + "name": "rules", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "review_settings_project_id_projects_id_fk": { + "name": "review_settings_project_id_projects_id_fk", + "tableFrom": "review_settings", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runner_commands": { + "name": "runner_commands", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "payload": { + "name": "payload", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'queued'" + }, + "result": { + "name": "result", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error_kind": { + "name": "error_kind", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "actor": { + "name": "actor", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host": { + "name": "host", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "finished_at": { + "name": "finished_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "runner_commands_status_idx": { + "name": "runner_commands_status_idx", + "columns": [ + "status", + "id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runner_hosts": { + "name": "runner_hosts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ssh_target": { + "name": "ssh_target", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ssh_port": { + "name": "ssh_port", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 22 + }, + "workdir": { + "name": "workdir", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'peppa'" + }, + "peppa_url": { + "name": "peppa_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'unknown'" + }, + "info": { + "name": "info", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "runner_hosts_name_unique": { + "name": "runner_hosts_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "runner_tasks": { + "name": "runner_tasks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "session_id": { + "name": "session_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "front": { + "name": "front", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "started_at": { + "name": "started_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ended_at": { + "name": "ended_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "runner_tasks_session_idx": { + "name": "runner_tasks_session_idx", + "columns": [ + "session_id", + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "runner_tasks_session_id_sessions_id_fk": { + "name": "runner_tasks_session_id_sessions_id_fk", + "tableFrom": "runner_tasks", + "tableTo": "sessions", + "columnsFrom": [ + "session_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "runner_tasks_task_id_tasks_id_fk": { + "name": "runner_tasks_task_id_tasks_id_fk", + "tableFrom": "runner_tasks", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sessions": { + "name": "sessions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "tmux_name": { + "name": "tmux_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'claude'" + }, + "subscription_id": { + "name": "subscription_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claude_session_id": { + "name": "claude_session_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "generation": { + "name": "generation", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "auto_nudges": { + "name": "auto_nudges", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "resume_at": { + "name": "resume_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "limit_probe_min": { + "name": "limit_probe_min", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "limit_resumes": { + "name": "limit_resumes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "limit_resumes_day": { + "name": "limit_resumes_day", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "limit_resumed_at": { + "name": "limit_resumed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "rotate_reason": { + "name": "rotate_reason", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "workspace_path": { + "name": "workspace_path", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "host_id": { + "name": "host_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "container": { + "name": "container", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "agent_id": { + "name": "agent_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "usage": { + "name": "usage", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "watch_state": { + "name": "watch_state", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'starting'" + }, + "last_activity_at": { + "name": "last_activity_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "ended_at": { + "name": "ended_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "sessions_tmux_name_unique": { + "name": "sessions_tmux_name_unique", + "columns": [ + "tmux_name" + ], + "isUnique": true + }, + "sessions_task_status": { + "name": "sessions_task_status", + "columns": [ + "task_id", + "status" + ], + "isUnique": false + }, + "sessions_status": { + "name": "sessions_status", + "columns": [ + "status" + ], + "isUnique": false + } + }, + "foreignKeys": { + "sessions_project_id_projects_id_fk": { + "name": "sessions_project_id_projects_id_fk", + "tableFrom": "sessions", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "sessions_task_id_tasks_id_fk": { + "name": "sessions_task_id_tasks_id_fk", + "tableFrom": "sessions", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "sessions_subscription_id_subscriptions_id_fk": { + "name": "sessions_subscription_id_subscriptions_id_fk", + "tableFrom": "sessions", + "tableTo": "subscriptions", + "columnsFrom": [ + "subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "sessions_host_id_runner_hosts_id_fk": { + "name": "sessions_host_id_runner_hosts_id_fk", + "tableFrom": "sessions", + "tableTo": "runner_hosts", + "columnsFrom": [ + "host_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "sessions_agent_id_agents_id_fk": { + "name": "sessions_agent_id_agents_id_fk", + "tableFrom": "sessions", + "tableTo": "agents", + "columnsFrom": [ + "agent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "subscription_pool_members": { + "name": "subscription_pool_members", + "columns": { + "pool_id": { + "name": "pool_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "subscription_id": { + "name": "subscription_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "subscription_pool_members_pool_id_subscription_pools_id_fk": { + "name": "subscription_pool_members_pool_id_subscription_pools_id_fk", + "tableFrom": "subscription_pool_members", + "tableTo": "subscription_pools", + "columnsFrom": [ + "pool_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "subscription_pool_members_subscription_id_subscriptions_id_fk": { + "name": "subscription_pool_members_subscription_id_subscriptions_id_fk", + "tableFrom": "subscription_pool_members", + "tableTo": "subscriptions", + "columnsFrom": [ + "subscription_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "subscription_pool_members_pool_id_subscription_id_pk": { + "columns": [ + "pool_id", + "subscription_id" + ], + "name": "subscription_pool_members_pool_id_subscription_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "subscription_pools": { + "name": "subscription_pools", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "subscription_pools_name_unique": { + "name": "subscription_pools_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": { + "subscription_pools_created_by_users_id_fk": { + "name": "subscription_pools_created_by_users_id_fk", + "tableFrom": "subscription_pools", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "subscriptions": { + "name": "subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth_kind": { + "name": "auth_kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "secret_enc": { + "name": "secret_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "key_provider": { + "name": "key_provider", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "limited_until": { + "name": "limited_until", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "last_error": { + "name": "last_error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "checked_at": { + "name": "checked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "activated_at": { + "name": "activated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": {}, + "foreignKeys": { + "subscriptions_created_by_users_id_fk": { + "name": "subscriptions_created_by_users_id_fk", + "tableFrom": "subscriptions", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "task_deps": { + "name": "task_deps", + "columns": { + "task_id": { + "name": "task_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "blocked_by_id": { + "name": "blocked_by_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "task_deps_blocked_by": { + "name": "task_deps_blocked_by", + "columns": [ + "blocked_by_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "task_deps_task_id_tasks_id_fk": { + "name": "task_deps_task_id_tasks_id_fk", + "tableFrom": "task_deps", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "task_deps_blocked_by_id_tasks_id_fk": { + "name": "task_deps_blocked_by_id_tasks_id_fk", + "tableFrom": "task_deps", + "tableTo": "tasks", + "columnsFrom": [ + "blocked_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "task_deps_task_id_blocked_by_id_pk": { + "columns": [ + "task_id", + "blocked_by_id" + ], + "name": "task_deps_task_id_blocked_by_id_pk" + } + }, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tasks": { + "name": "tasks", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "goal_id": { + "name": "goal_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "number": { + "name": "number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'backlog'" + }, + "openspec_change": { + "name": "openspec_change", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "pr_url": { + "name": "pr_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "ci_attempts": { + "name": "ci_attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "ci_failed_sha": { + "name": "ci_failed_sha", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gitea_issue": { + "name": "gitea_issue", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "position": { + "name": "position", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "origin": { + "name": "origin", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'human'" + }, + "proposed": { + "name": "proposed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "tasks_project_number": { + "name": "tasks_project_number", + "columns": [ + "project_id", + "number" + ], + "isUnique": true + }, + "tasks_project_issue": { + "name": "tasks_project_issue", + "columns": [ + "project_id", + "gitea_issue" + ], + "isUnique": true + }, + "tasks_project_status_pos": { + "name": "tasks_project_status_pos", + "columns": [ + "project_id", + "status", + "position" + ], + "isUnique": false + } + }, + "foreignKeys": { + "tasks_project_id_projects_id_fk": { + "name": "tasks_project_id_projects_id_fk", + "tableFrom": "tasks", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "tasks_goal_id_goals_id_fk": { + "name": "tasks_goal_id_goals_id_fk", + "tableFrom": "tasks", + "tableTo": "goals", + "columnsFrom": [ + "goal_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "telegram_outbox": { + "name": "telegram_outbox", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "method": { + "name": "method", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "params": { + "name": "params", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "question_id": { + "name": "question_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "chat_message_id": { + "name": "chat_message_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "attempts": { + "name": "attempts", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "next_attempt_at": { + "name": "next_attempt_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "telegram_message_id": { + "name": "telegram_message_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "error": { + "name": "error", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "sent_at": { + "name": "sent_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "telegram_outbox_dedupe_key_unique": { + "name": "telegram_outbox_dedupe_key_unique", + "columns": [ + "dedupe_key" + ], + "isUnique": true + }, + "telegram_outbox_status_created": { + "name": "telegram_outbox_status_created", + "columns": [ + "status", + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "telegram_outbox_question_id_questions_id_fk": { + "name": "telegram_outbox_question_id_questions_id_fk", + "tableFrom": "telegram_outbox", + "tableTo": "questions", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "telegram_outbox_chat_message_id_chat_messages_id_fk": { + "name": "telegram_outbox_chat_message_id_chat_messages_id_fk", + "tableFrom": "telegram_outbox", + "tableTo": "chat_messages", + "columnsFrom": [ + "chat_message_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "telegram_updates": { + "name": "telegram_updates", + "columns": { + "update_id": { + "name": "update_id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + } + }, + "indexes": { + "telegram_updates_created": { + "name": "telegram_updates_created", + "columns": [ + "created_at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "gitea_id": { + "name": "gitea_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "login": { + "name": "login", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "access_token_enc": { + "name": "access_token_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "refresh_token_enc": { + "name": "refresh_token_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "token_expires_at": { + "name": "token_expires_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claude_token_enc": { + "name": "claude_token_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "claude_token_set_at": { + "name": "claude_token_set_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_chat_id": { + "name": "telegram_chat_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_user_id": { + "name": "telegram_user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_username": { + "name": "telegram_username", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_paired_at": { + "name": "telegram_paired_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_bot_token_enc": { + "name": "telegram_bot_token_enc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "telegram_bot_username": { + "name": "telegram_bot_username", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "egov_iin": { + "name": "egov_iin", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "egov_linked_at": { + "name": "egov_linked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_sub": { + "name": "google_sub", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_email": { + "name": "google_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "google_linked_at": { + "name": "google_linked_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "password_set_at": { + "name": "password_set_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "disabled_at": { + "name": "disabled_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(cast(unixepoch('subsec') * 1000 as integer))" + }, + "last_login_at": { + "name": "last_login_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "users_gitea_id_unique": { + "name": "users_gitea_id_unique", + "columns": [ + "gitea_id" + ], + "isUnique": true + }, + "users_login_unique": { + "name": "users_login_unique", + "columns": [ + "login" + ], + "isUnique": true + }, + "users_telegram_chat_id_unique": { + "name": "users_telegram_chat_id_unique", + "columns": [ + "telegram_chat_id" + ], + "isUnique": true + }, + "users_egov_iin_unique": { + "name": "users_egov_iin_unique", + "columns": [ + "egov_iin" + ], + "isUnique": true + }, + "users_google_sub_unique": { + "name": "users_google_sub_unique", + "columns": [ + "google_sub" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index b7d35a85..876bc1d9 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -218,6 +218,13 @@ "when": 1795512094088, "tag": "0030_access_hub_journal", "breakpoints": true + }, + { + "idx": 31, + "version": "6", + "when": 1795524871580, + "tag": "0031_secrets_agent_env", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index 3483bc51..6c3900be 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -660,6 +660,11 @@ export const projectSecrets = sqliteTable( updatedAt: updatedAt(), // Last time a session got it in its env. lastUsedAt: integer("last_used_at", { mode: "timestamp_ms" }), + // PEP-253: also into agent sessions' env (1) or only to the deployed product (0). Rows made + // before PEP-253 keep 1; new ones are 0 unless the owner chose otherwise. + agentEnv: integer("agent_env", { mode: "boolean" }).notNull().default(true), + // PEP-253: the Access Hub connection this key moved to («Сделать подключением»). + connectionId: integer("connection_id").references((): AnySQLiteColumn => connections.id, { onDelete: "set null" }), }, (t) => [uniqueIndex("project_secrets_project_name").on(t.projectId, t.name)], ); diff --git a/packages/runner/src/index.ts b/packages/runner/src/index.ts index da27aca1..fa0e8a31 100644 --- a/packages/runner/src/index.ts +++ b/packages/runner/src/index.ts @@ -82,3 +82,4 @@ export * from "./edge-dns.ts"; export * from "./workspace-paths.ts"; export * from "./codex-trust.ts"; export * from "./codex-screen.ts"; +export * from "./secrets-report.ts"; diff --git a/packages/runner/src/provision.ts b/packages/runner/src/provision.ts index 1c9884bf..a4b5b4c6 100644 --- a/packages/runner/src/provision.ts +++ b/packages/runner/src/provision.ts @@ -5,7 +5,7 @@ import { m } from "@peppa/shared/i18n"; import { cpSync, existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync, mkdirSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { createProject, NEW_PROJECT_AUTONOMY, NEW_PROJECT_PUBLISH, setPublishMode, logEvent, ownPool, setAutonomy, setIntakeSettings, setProjectPool, giteaForBot, giteaForUser, isLocalUser, PeppaError, type GiteaClient, type Project, type User } from "@peppa/core"; +import { createProject, setAgentSecretsEnabled, NEW_PROJECT_AUTONOMY, NEW_PROJECT_PUBLISH, setPublishMode, logEvent, ownPool, setAutonomy, setIntakeSettings, setProjectPool, giteaForBot, giteaForUser, isLocalUser, PeppaError, type GiteaClient, type Project, type User } from "@peppa/core"; import { projects, type Db } from "@peppa/db"; import { loadEnv } from "@peppa/shared"; import { eq, or } from "drizzle-orm"; @@ -178,6 +178,8 @@ export async function provisionProject(db: Db, o: ProvisionOptions): Promise`), in the project's discussion from FORGE — it reaches the +// owner and members like any message there. Paused projects are skipped (and asked again later). +import { m as tr, asIs } from "@peppa/shared/i18n"; +import { ensureProjectChat, getProject, getSetting, isProjectPaused, markSecretsReportNoticed, secretsAgentReport, secretsReportNoticeKey, shouldMove } from "@peppa/core"; +import type { Db } from "@peppa/db"; +import { sayInDiscussion } from "./analyst-chat.ts"; + +export function secretsReportText(items: Array<{ name: string; serviceName: string }>, link: string): string { + const list = items.map((i) => `• ${asIs(i.name)} — ${asIs(i.serviceName)}`).join("\n"); + return `${tr("Агенты проекта видят ключи внешних сервисов: {n}. Безопаснее сделать их подключениями — агент будет работать с сервисом, не видя ключа, а продукт получит ключ как раньше.", { n: items.length })}\n${list}\n${tr("Откройте «⋯ Настройки проекта → Секреты» и нажмите «Сделать подключением» у каждого ключа: {link}", { link })}`; +} + +export async function notifySecretsReport(db: Db, o: { log?: (m: string) => void } = {}): Promise> { + const rows = (await secretsAgentReport(db)).filter(shouldMove); + const byProject = new Map(); + for (const r of rows) byProject.set(r.projectId, [...(byProject.get(r.projectId) ?? []), r]); + const sent: Array<{ projectKey: string; names: string[] }> = []; + for (const [projectId, items] of byProject) { + if (await getSetting(db, secretsReportNoticeKey(projectId))) continue; + if (await isProjectPaused(db, projectId)) continue; + const project = await getProject(db, items[0]!.projectKey); + const chat = await ensureProjectChat(db, projectId); + const link = `${process.env.PEPPA_WEB_URL ?? ""}/p/${project.key}`; + await sayInDiscussion(db, project, chat.id, secretsReportText(items.map((i) => ({ name: i.name, serviceName: i.serviceName! })), link), null); + const names = items.map((i) => i.name); + await markSecretsReportNoticed(db, projectId, names); + o.log?.(`${project.key}: ${names.join(", ")}`); + sent.push({ projectKey: project.key, names }); + } + return sent; +} From ce706efb18da1691d281cc7d30aefccd7f3e43bc Mon Sep 17 00:00:00 2001 From: peppa-bot Date: Tue, 24 Nov 2026 13:01:12 +0000 Subject: [PATCH 3/6] =?UTF-8?q?PEP-253:=20=D0=B2=D0=B5=D0=B1=20=E2=80=94?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D1=83=20=D0=B8=D0=B4=D1=91=D1=82=20=D1=81?= =?UTF-8?q?=D0=B5=D0=BA=D1=80=D0=B5=D1=82,=20=C2=AB=D0=A1=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=B0=D1=82=D1=8C=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=D0=BC=C2=BB,=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B0=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0,=20=D0=BE=D1=82=D1=87=D1=91=D1=82=20?= =?UTF-8?q?=D1=81=D1=83=D0=BF=D0=B5=D1=80=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD?= =?UTF-8?q?=D1=83;=20MCP,=20CLI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- apps/web/app/(app)/actions.ts | 30 +++++- apps/web/app/(app)/p/[key]/page.tsx | 16 ++- apps/web/app/(app)/secrets/page.tsx | 28 +++++- apps/web/components/ProjectSecrets.tsx | 134 +++++++++++++++++++------ apps/web/components/SecretNameHint.tsx | 34 +++++++ packages/cli/src/index.ts | 21 +++- packages/mcp/src/agent.ts | 11 +- packages/mcp/src/manager.ts | 2 +- 8 files changed, 237 insertions(+), 39 deletions(-) create mode 100644 apps/web/components/SecretNameHint.tsx diff --git a/apps/web/app/(app)/actions.ts b/apps/web/app/(app)/actions.ts index 7d83c314..5b26f836 100644 --- a/apps/web/app/(app)/actions.ts +++ b/apps/web/app/(app)/actions.ts @@ -55,6 +55,9 @@ import { setTaskBudget, type Budget, setProjectSecret, + setSecretAudience, + secretToConnection, + setAgentSecretsEnabled, setNeedDone, removeNeed, deleteProjectSecret, @@ -801,7 +804,32 @@ export async function saveProjectSecretAction(f: FormData) { const user = asWebActor(await requireUser()); await attempt(f, async () => { // The value is taken as is (no trim): keys may legitimately end with spaces/newlines. - await setProjectSecret(db, user.id, Number(str(f, "projectId")), str(f, "name"), String(f.get("value") ?? "")); + // PEP-253: «Кому» — only the product by default. + await setProjectSecret(db, user.id, Number(str(f, "projectId")), str(f, "name"), String(f.get("value") ?? ""), { agent: str(f, "audience") === "agent" }); + }); +} + +// PEP-253: «только продукту» ⇄ «агенту и продукту». +export async function setSecretAudienceAction(f: FormData) { + const user = asWebActor(await requireUser()); + await attempt(f, async () => { + await setSecretAudience(db, user.id, Number(str(f, "projectId")), str(f, "name"), str(f, "audience") === "agent"); + }); +} + +// PEP-253: «Сделать подключением» — a catalog connection with the secret's key, granted to the project. +export async function secretToConnectionAction(f: FormData) { + const user = asWebActor(await requireUser()); + await attempt(f, async () => { + await secretToConnection(db, user.id, Number(str(f, "projectId")), str(f, "name")); + }); +} + +// PEP-253: «Агенты получают секреты в окружение». +export async function setAgentSecretsAction(f: FormData) { + const user = asWebActor(await requireUser()); + await attempt(f, async () => { + await setAgentSecretsEnabled(db, user.id, Number(str(f, "projectId")), str(f, "on") === "1"); }); } diff --git a/apps/web/app/(app)/p/[key]/page.tsx b/apps/web/app/(app)/p/[key]/page.tsx index 294477c0..89badd39 100644 --- a/apps/web/app/(app)/p/[key]/page.tsx +++ b/apps/web/app/(app)/p/[key]/page.tsx @@ -5,7 +5,7 @@ import { PublishPanel } from "@/components/PublishPanel"; import { notFound } from "next/navigation"; import { ExternalLink, Plus, Rocket, SquareTerminal } from "lucide-react"; import { columnOf, currentReleases, peekRepo, isPlatform, listReleases, bugsinkWebhookBase, openPulls, platformReleaseCandidate, platformReleaseOffers, ownPendingLogins, readAgentsMd, repoOverview, type Release, sharedRequest, subscriptionRequestOffer } from "@peppa/runner"; -import { getProjectPause, getPublishMode, poolSubscriptions, PRODUCT_PROJECT_TABS, userProjectIds, projectProduct, discussionUnread, ensureProjectChat, listHosts, DEFAULT_RUNNER_SETTINGS, DEFAULT_AGENT_SETTINGS, getProjectAgentSettings, getSystemAgentSettings, getProjectRunnerSettings, getSystemRunnerSettings, blockedLabel, blockersMap, epicProgress, progressLabel, taskProgress, getProjectBudget, listJournal, listProjectSecrets, projectMetrics, type ActorChannel, type ActorKind, getAutonomy, getIncidentSettings, getReviewSettings, isSuperadmin, listEpics, listErrorSources, listIncidents, listMembers, listPools, listSpecs, taskAgentNames, getIntakeSettings, intakePendingTasks, projectAgentWarning, taskHoldReasons, memoryStats, readMemory, projectPool, sharedPool, ownPool, poolOverview, repoAudience, repoVisibilityLabel } from "@peppa/core"; +import { getProjectPause, getPublishMode, poolSubscriptions, PRODUCT_PROJECT_TABS, userProjectIds, projectProduct, discussionUnread, ensureProjectChat, listHosts, DEFAULT_RUNNER_SETTINGS, DEFAULT_AGENT_SETTINGS, getProjectAgentSettings, getSystemAgentSettings, getProjectRunnerSettings, getSystemRunnerSettings, blockedLabel, blockersMap, epicProgress, progressLabel, taskProgress, getProjectBudget, listJournal, listProjectSecrets, agentSecretsEnabled, secretsAgentReport, secretNameHints, projectMetrics, type ActorChannel, type ActorKind, getAutonomy, getIncidentSettings, getReviewSettings, isSuperadmin, listEpics, listErrorSources, listIncidents, listMembers, listPools, listSpecs, taskAgentNames, getIntakeSettings, intakePendingTasks, projectAgentWarning, taskHoldReasons, memoryStats, readMemory, projectPool, sharedPool, ownPool, poolOverview, repoAudience, repoVisibilityLabel } from "@peppa/core"; import { productNeeds, lastProductReview } from "@peppa/core"; import { LiveRefresh } from "@/components/LiveRefresh"; import { PanelSection } from "@/components/ActivityAside"; @@ -132,6 +132,8 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr const [pool, pools, autonomy, shared] = await Promise.all([projectPool(db, p.id), superadmin ? listPools(db) : Promise.resolve([]), getAutonomy(db, p.id), sharedPool(db)]); // PEP-10/27: runner settings of the project over the system ones. const [runnerOwn, runnerSystem, secrets, runnerHosts] = await Promise.all([getProjectRunnerSettings(db, p.id), getSystemRunnerSettings(db), listProjectSecrets(db, p.id), listHosts(db, { enabled: true })]); + // PEP-253: where secrets go and which of them are keys of catalog services. + const [agentSecrets, secretReport] = await Promise.all([agentSecretsEnabled(db, p.id), secretsAgentReport(db, { projectIds: [p.id] })]); // PEP-41: agent provider/model of the project over the platform's. const [agentOwn, agentSystem] = await Promise.all([getProjectAgentSettings(db, p.id), getSystemAgentSettings(db)]); // PEP-31: the project's pool has no working subscription — agents won't start. @@ -290,11 +292,17 @@ export default async function ProjectPage({ params, searchParams }: { params: Pr - {engineer && ( - + [r.name, { serviceName: r.serviceName, connectionName: r.connectionName }]))} + hints={secretNameHints()} + engineer={engineer} + /> - )} {engineer && ( diff --git a/apps/web/app/(app)/secrets/page.tsx b/apps/web/app/(app)/secrets/page.tsx index 76f7b7e4..b8fa1895 100644 --- a/apps/web/app/(app)/secrets/page.tsx +++ b/apps/web/app/(app)/secrets/page.tsx @@ -1,6 +1,6 @@ import { notFound } from "next/navigation"; import { ShieldCheck } from "lucide-react"; -import { isSuperadmin, secretsAudit, type PlatformSecretRow } from "@peppa/core"; +import { isSuperadmin, secretsAudit, secretsAgentReport, type PlatformSecretRow } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { Disclosure, Empty, Flash, Notice, PageHeader, Section } from "@/components/common"; import { Badge } from "@/components/ui/badge"; @@ -56,6 +56,8 @@ export default async function Secrets({ searchParams }: { searchParams: Promise< if (!(await isSuperadmin(db, user))) notFound(); const q = await searchParams; const a = await secretsAudit(db); + // PEP-253: service keys in project secrets, those still reaching agents first. + const keys = (await secretsAgentReport(db)).filter((r) => r.serviceId).sort((x, y) => Number(y.inAgentEnv && !y.connectionId) - Number(x.inAgentEnv && !x.connectionId)); const enc = a.encryption; // The link sits inside the sentence: split the translated text around {link}. const reissue = t("Перевыпуск — в {link}: «Переподключить» запускает новый вход, старый токен Claude отзывается в claude.ai → Settings → Claude Code.").split("{link}"); @@ -202,6 +204,30 @@ export default async function Secrets({ searchParams }: { searchParams: Promise< )} + +
+

+ {t("Секреты, в которых узнан ключ сервиса из каталога подключений. Пока ключ уходит агентам, агент может его прочитать; владелец переносит его кнопкой «Сделать подключением» в настройках проекта. Сообщить владельцам один раз: peppa secrets agent-report --notify.")} +

+ {keys.length === 0 ? ( + {t("Ключей сервисов в секретах проектов нет.")} + ) : ( +
    + {keys.map((r) => ( +
  • + + {r.projectKey} + + {r.name} + {r.serviceName} + + {r.connectionName ? t("стал подключением «{name}»", { name: r.connectionName }) : r.inAgentEnv ? t("уходит агентам") : t("только продукту")} + +
  • + ))} +
+ )} +
); diff --git a/apps/web/components/ProjectSecrets.tsx b/apps/web/components/ProjectSecrets.tsx index 4bedbece..39d7b70c 100644 --- a/apps/web/components/ProjectSecrets.tsx +++ b/apps/web/components/ProjectSecrets.tsx @@ -3,9 +3,10 @@ import type { ProjectSecretView } from "@peppa/core"; import { Hidden } from "@/components/cards"; import { ago } from "@/components/common"; import { Button } from "@/components/ui/button"; -import { Input, Textarea } from "@/components/ui/input"; +import { Textarea } from "@/components/ui/input"; +import { SecretNameHint } from "@/components/SecretNameHint"; import { getT } from "@/lib/i18n"; -import { deleteProjectSecretAction, saveProjectSecretAction } from "@/app/(app)/actions"; +import { deleteProjectSecretAction, saveProjectSecretAction, secretToConnectionAction, setAgentSecretsAction, setSecretAudienceAction } from "@/app/(app)/actions"; import { Fragment, type ReactNode } from "react"; /** A translated sentence with {name} placeholders replaced by inline elements. */ @@ -13,44 +14,121 @@ function rich(text: string, parts: Record): ReactNode { return text.split(/\{(\w+)\}/).map((piece, i) => {i % 2 ? (parts[piece] ?? `{${piece}}`) : piece}); } -/** PEP-54: the project's secrets for agents and (PEP-112) for the deployed product — names only; values are write-only. */ -export async function ProjectSecretsPanel({ projectId, secrets, back }: { projectId: number; secrets: ProjectSecretView[]; back: string }) { +/** + * PEP-54: the project's secrets for agents and (PEP-112) for the deployed product — names only; values are write-only. + * PEP-253: where each secret goes (only the product / also agents), the project setting «Агенты получают секреты + * в окружение», and keys of catalog services with «Сделать подключением». + */ +export async function ProjectSecretsPanel({ + projectId, + secrets, + back, + agentsEnabled, + services, + hints, + engineer, +}: { + projectId: number; + secrets: ProjectSecretView[]; + back: string; + agentsEnabled: boolean; + /** secret name → the recognised catalog service and the connection it became. */ + services: Map; + hints: Array<{ prefix: string; exact: boolean; service: string }>; + engineer: boolean; +}) { const t = await getT(); return (
+
+ + + {t("Агенты получают секреты в окружение")}: {agentsEnabled ? t("да") : t("нет")} + + + {agentsEnabled + ? t("Агент видит ключи с пометкой «агенту и продукту» и может их напечатать или унести. Внешние сервисы безопаснее давать подключениями.") + : t("Агенты не получают ни одного секрета; продукт получает все. Внешние сервисы агентам — через подключения.")} + + + {secrets.length > 0 && (
    - {secrets.map((s) => ( -
  • - - {s.name} - - {t("изменён {ago}", { ago: ago(s.updatedAt, t) })} - {s.updatedBy ? ` · ${s.updatedBy}` : ""} · {s.lastUsedAt ? t("выдан агенту {ago}", { ago: ago(s.lastUsedAt, t) }) : t("агентам ещё не выдавался")} - - -
    - - - -
  • - ))} + {secrets.map((s) => { + const svc = services.get(s.name); + const toAgent = s.agentEnv && agentsEnabled; + const canMove = !!svc?.serviceName && !s.connectionId; + return ( +
  • +
    + + {s.name} + + {s.agentEnv ? t("агенту и продукту") : t("только продукту")} + {s.agentEnv && !agentsEnabled ? ` (${t("агентам секреты не выдаются")})` : ""} + {" · "} + {t("изменён {ago}", { ago: ago(s.updatedAt, t) })} + {s.updatedBy ? ` · ${s.updatedBy}` : ""} + {toAgent ? ` · ${s.lastUsedAt ? t("выдан агенту {ago}", { ago: ago(s.lastUsedAt, t) }) : t("агентам ещё не выдавался")}` : ""} + + +
    + + + +
    + {svc?.connectionName && {t("Стал подключением «{name}»: агент работает с сервисом, не видя ключа.", { name: svc.connectionName })}} + {canMove && ( + + {toAgent + ? t("Это ключ {service}, и агент его видит. Сделайте подключение: агент будет работать с сервисом, не видя ключа, продукт получит ключ как раньше.", { service: svc!.serviceName! }) + : t("Это ключ {service}. Агенту его можно дать подключением — ключ он не увидит.", { service: svc!.serviceName! })} + + )} +
    + {canMove && ( +
    + + + + )} +
    + + + +
    +
  • + ); + })}
)}
- +