# Technical Documentation: n8n-io/n8n

> ℹ️ **Provenance:** Multi-Tier Ingestion · [CodeWiki Reference](https://codewiki.google/github.com/n8n-io/n8n)

### Overview (README.md)

# n8n – The Platform for AI Agents and Workflow Automation

Fair-code platform to build and deploy AI agents and workflows. Combine a visual canvas with custom code, run it self-hosted or in the [cloud](https://app.n8n.cloud/login), and connect to 1500+ integrations. AI automation you can trust with real work, from prototype to production.



## Key Capabilities

- **AI-Native Automation Platform**: Build and operationalize AI workflows and multi-step agents using your own data, models, and tools
- **Model Flexibility, No Lock-In**: Connect to OpenAI, Anthropic, Google, or open-source models and switch providers without changing your architecture
- **From Prototype to Production**: Design multi-step AI workflows with logic, tool use, human approvals, and full observability
- **Code When You Need It**: Combine visual building with JavaScript, Python, and npm packages for advanced AI workflows
- **Enterprise-Ready AI**: Self-host or deploy securely with role-based access, audit trails, and support for sensitive data
- **Leverage What Already Exists**: 1500+ integrations and 9,000+ workflow [templates](https://n8n.io/workflows) to connect AI with your existing systems

## Quick Start

Try n8n instantly with our install script (requires [Docker](https://www.docker.com/)):

```sh
curl -fsSL https://get.n8n.io | sh
```

Or deploy manually with [Docker](https://docs.n8n.io/hosting/installation/docker/):

```
docker volume create n8n_data
docker run -it --rm --name n8n -p 5678:5678 -v n8n_data:/home/node/.n8n docker.n8n.io/n8nio/n8n
```

Access the editor at http://localhost:5678

## Resources

- 📚 [Documentation](https://docs.n8n.io)
- 🔧 [1500+ Integrations](https://n8n.io/integrations)
- 💡 [Example Workflows](https://n8n.io/workflows)
- 🤖 [AI & LangChain Guide](https://docs.n8n.io/advanced-ai/)
- 👥 [Community Forum](https://community.n8n.io)
- 📖 [Community Tutorials](https://community.n8n.io/c/tutorials/28)

## Support

Need help? Our community forum is the place to get support and connect with other users:
[community.n8n.io](https://community.n8n.io)

## License

n8n is [fair-code](https://faircode.io) distributed under the [Sustainable Use License](https://github.com/n8n-io/n8n/blob/master/LICENSE.md) and [n8n Enterprise License](https://github.com/n8n-io/n8n/blob/master/LICENSE_EE.md).

- **Source Available**: Always visible source code
- **Self-Hostable**: Deploy anywhere
- **Extensible**: Add your own nodes and functionality

[Enterprise Licenses](mailto:license@n8n.io) available for additional features and support.

Additional information about the license model can be found in the [docs](https://docs.n8n.io/sustainable-use-license/).

## Contributing

Found a bug 🐛 or have a feature idea ✨? Check our [Contributing Guide](https://github.com/n8n-io/n8n/blob/master/CONTRIBUTING.md) for a setup guide & best practices.

## Join the Team

Want to shape the future of automation? Check out our [job posts](https://n8n.io/careers) and join our team!

## What does n8n mean?

**Short answer:** It means "nodemation" and is pronounced as n-eight-n.

**Long answer:** "I get that question quite often (more often than I expected) so I decided it is probably best to answer it here. While looking for a good name for the project with a free domain I realized very quickly that all the good ones I could think of were already taken. So, in the end, I chose nodemation. 'node-' in the sense that it uses a Node-View and that it uses Node.js and '-mation' for 'automation' which is what the project is supposed to help with. However, I did not like how long the name was and I could not imagine writing something that long every time in the CLI. That is when I then ended up on 'n8n'." - **Jan Oberhauser, Founder and CEO, n8n.io**

---

### Adr README (`docs/adr/README.md`)

# Architecture Decision Records

An Architecture Decision Record (ADR) is a short, dated record of one
important technical decision: the context, the decision, the alternatives,
and the consequences.

The company process is defined in the Notion page
[Engineering Technical Decisions][process] and its sub-page
[Architecture Decision Records][adr-page].
This README applies that process to this repository and records the
conventions that the reviews of the first records settled.

## When to write an ADR

Write an ADR when the reason for a decision can matter in the future. The
test from the company process: if an engineer challenges this choice in 12
months, will the original context and alternatives help them?

Write one record for each decision. The test: can this decision be reversed on
its own? If yes, it gets its own file. Do not put two independent decisions
into one record.

Do not write an ADR for an implementation detail, a refactor, or a choice that
follows an existing decision.

## Location

Store a record in the package where the implementation lives, in its
`docs/adr/` directory. For example, a record about engine v2 goes in
`packages/@n8n/engine/docs/adr/`. A record that concerns the whole repository
goes in the root `docs/adr/`, next to this README. CI rejects any other
location.

## File name

The file name follows from the title and the date:

```text
ADR-YYYYMMDD-<title in kebab-case>.md
```

The title is the H1 of the record. It states the decision, not the topic:
"Use PostgreSQL advisory locks", not "Database locking". The date is the date
of the decision, and it matches the `Date` field. CI checks both.

Do not rename a record after it is merged. Links depend on the file name.
Refer to a record by its full file name, for example
`ADR-20260828-obtain-trigger-output-before-creating-the-execution`, not by a
number. CI checks that every record ID a record mentions names a file.

## Template

Copy [`docs/ADR_TEMPLATE.md`](../ADR_TEMPLATE.md) from the repository root.
It is the one template, and CI checks every record against its structure.

The header has three required fields, `Date`, `Status`, and `Decision Owner`,
in that order, and three optional fields, `Source`, `Supersedes`, and
`Superseded by`. Omit an optional field that has no value. `Source` names
where the decision came from: a ticket, an RFC, or an incident. The body
names none of these. The `RFC` field under `Links` holds the link to the RFC.

## Status

Use one of three values:

- **Active.** The decision stands.
- **Superseded.** A newer record replaced the decision. Link to it in
  `Superseded by`.
- **Deprecated.** The decision no longer applies and no record replaces it.

There is no Draft or Proposed status. The pull request holds that state while
the record is written and checked.

The status says whether the decision stands. It does not say whether the code
exists. Implementation progress belongs nowhere in the record.

## What goes where

**Context.** The problem and the constraints. State the world as it is, in
the present tense: "In engine v1, `putExecutionToWait` sleeps in the process
for a time wait under 65 seconds." Do not date a fact ("at the date of this
record"), do not narrate history ("core has since decided"), and do not phase
work ("the shim's part lands later"). The record is dated once, in its header.
Aim for fewer than 150 words.

**Decision.** What we decided, and the main reason. State the behaviour the
decision guarantees, in the present tense and the active voice: "A wait fires
at its deadline and not before it. A wait fires once, however many replicas
run." Describe the mechanism only when the mechanism is the decision. A sweep
that sleeps until the next deadline is how the engine fires waits today; the
guarantee is what the record decides. Do not write implementation state here.
A sentence such as "the engine does not do this yet" goes stale exactly where
a reader takes the text as the current contract.

**Alternatives Considered.** Each option we did not select, and why. Lead with
the reason: "We rejected it for two reasons." An option that reads as an equal
choice leaves the reader to guess why it lost. Use the conditional mood for
what an alternative would do: "This option would need a column." The
indicative mood ("this option needs a column") reads as a description of
shipped code.

**Consequences.** What follows from the decision: benefits, trade-offs,
constraints, and operational effects. A constraint on the mechanism belongs
here: "One statement must read the step rows and write the status." How the
code meets the constraint today, and the order in which the work lands, do
not. This is the one section that may grow after the record is merged. A
consequence that the team learned later belongs here. A changed decision does
not.

**Links.** Exactly three fields, each on one line: `RFC`, `Documentation`, and
`Related ADRs`. Write `-` when a field has no value. Name related records by
full file name. There is no `Tickets` field.

## Changing a decision

A merged record is history. Do not edit its Context, Decision, or Alternatives
to reflect a later change. Write a new record instead.

Therefore a change to the Context, the Decision, or the Alternatives rides the
pull request that merges the record. In a stack, the change belongs in the
first pull request that carries the record, not in the follow-up that
implements it. A decision can merge before its code. That is normal, and not a
reason to move or edit the record.

When a new decision replaces an old one:

1. Write a new record. Explain the new context.
2. Set `Supersedes` in the new record and `Superseded by` in the old one.
3. Set the old record's status to `Superseded`.

When a decision no longer applies and nothing replaces it, set its status to
`Deprecated`.

## Style

- Write in ASD-STE100 Simplified Technical English, as `AGENTS.md` requires:
  short sentences, the active voice, one idea for each sentence.
- Wrap paragraph lines at 100 columns. CI enforces it. The `Links` fields
  are exempt and stay on one line each.
- Do not reference a ticket in the body. Every sentence must stand without
  the ID: "Send-and-wait nodes need credentials to send their message." The
  `Source` field is the one place for a ticket.
- Use plain words. "Nothing moves a step from `waiting` to `completed` in one
  step" beats "No component completes a waiting step directly".
- Keep the record short. A reader should understand the decision in a few
  minutes without the pull request or the design document.
- Use a Mermaid diagram when a picture says it better than prose.

## Checked by CI

The `adr-conventions` rule of `@n8n/code-health` runs in the Static Analysis
check of every pull request. For every `ADR-*.md` file it checks:

- a `docs/adr` directory at the repository root or at a package root;
- a file name that matches the H1 and the `Date` field;
- the header fields, their order, and one blank line between them;
- a `Decision Owner` from the allowed list in
  `packages/quality/policy/code-health/src/index.ts`;
- a full file name in `Supersedes` and `Superseded by`;
- exactly the five sections, in order, each with content;
- the three `Links` fields, one line each;
- paragraph lines of at most 100 characters outside `Links`;
- that every record ID the record mentions is a full ID that names a file in
  this repository. A date alone, `ADR-20260902`, is rejected.

Run it locally:

```bash
pnpm --filter=@n8n/code-health check --rule=adr-conventions --ignore-baseline
```

## Process

1. The decision is made: in an RFC, a design review, a team discussion, or a
   pull request.
2. The Decision Owner, or a delegate, writes the record.
3. Open a pull request. The review checks that the record is accurate and
   clear. It does not reopen the decision.
4. Merge. The record is `Active`.
5. Implementation pull requests link to the record they implement.

[process]: https://app.notion.com/p/n8n/3bd5b6e0c94f804bac20ecc31500ce37
[adr-page]: https://app.notion.com/p/n8n/3bf5b6e0c94f8046b204c4b50533ec8b

---

### Generated Postgres Schema README (`docs/generated/postgres-schema/README.md`)

# n8n database schema (PostgreSQL)

## Description

Auto-generated from the PostgreSQL migrations in @n8n/db. Do not edit by hand.

## Tables

| Name | Columns | Comment | Type |
| ---- | ------- | ------- | ---- |
| [public.activity_event](public.activity_event.md) | 11 |  | BASE TABLE |
| [public.agent_background_job](public.agent_background_job.md) | 23 |  | BASE TABLE |
| [public.agent_budget_applied_call](public.agent_budget_applied_call.md) | 2 |  | BASE TABLE |
| [public.agent_budget_spend](public.agent_budget_spend.md) | 4 |  | BASE TABLE |
| [public.agent_channel_status](public.agent_channel_status.md) | 11 |  | BASE TABLE |
| [public.agent_chat_attachments](public.agent_chat_attachments.md) | 12 |  | BASE TABLE |
| [public.agent_chat_subscriptions](public.agent_chat_subscriptions.md) | 6 |  | BASE TABLE |
| [public.agent_checkpoints](public.agent_checkpoints.md) | 7 |  | BASE TABLE |
| [public.agent_credential_dependency](public.agent_credential_dependency.md) | 3 |  | BASE TABLE |
| [public.agent_eval_dataset](public.agent_eval_dataset.md) | 10 |  | BASE TABLE |
| [public.agent_eval_rating](public.agent_eval_rating.md) | 8 |  | BASE TABLE |
| [public.agent_eval_result](public.agent_eval_result.md) | 16 |  | BASE TABLE |
| [public.agent_eval_run](public.agent_eval_run.md) | 14 |  | BASE TABLE |
| [public.agent_execution](public.agent_execution.md) | 25 |  | BASE TABLE |
| [public.agent_execution_message_links](public.agent_execution_message_links.md) | 5 |  | BASE TABLE |
| [public.agent_execution_threads](public.agent_execution_threads.md) | 20 |  | BASE TABLE |
| [public.agent_files](public.agent_files.md) | 10 |  | BASE TABLE |
| [public.agent_history](public.agent_history.md) | 9 |  | BASE TABLE |
| [public.agent_message_queue](public.agent_message_queue.md) | 10 |  | BASE TABLE |
| [public.agent_plan](public.agent_plan.md) | 8 |  | BASE TABLE |
| [public.agent_plan_history](public.agent_plan_history.md) | 6 |  | BASE TABLE |
| [public.agent_skill_dependency](public.agent_skill_dependency.md) | 4 |  | BASE TABLE |
| [public.agent_task_definition](public.agent_task_definition.md) | 8 |  | BASE TABLE |
| [public.agent_task_run_lock](public.agent_task_run_lock.md) | 6 |  | BASE TABLE |
| [public.agent_task_snapshot](public.agent_task_snapshot.md) | 9 |  | BASE TABLE |
| [public.agent_thread_grants](public.agent_thread_grants.md) | 4 |  | BASE TABLE |
| [public.agent_version_skill_dependency](public.agent_version_skill_dependency.md) | 4 |  | BASE TABLE |
| [public.agent_workflow_dependency](public.agent_workflow_dependency.md) | 3 |  | BASE TABLE |
| [public.agents](public.agents.md) | 15 |  | BASE TABLE |
| [public.agents_memory_entries](public.agents_memory_entries.md) | 13 |  | BASE TABLE |
| [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) | 14 |  | BASE TABLE |
| [public.agents_memory_entry_locks](public.agents_memory_entry_locks.md) | 6 |  | BASE TABLE |
| [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) | 10 |  | BASE TABLE |
| [public.agents_messages](public.agents_messages.md) | 12 |  | BASE TABLE |
| [public.agents_observation_cursors](public.agents_observation_cursors.md) | 6 |  | BASE TABLE |
| [public.agents_observation_locks](public.agents_observation_locks.md) | 7 |  | BASE TABLE |
| [public.agents_observations](public.agents_observations.md) | 11 |  | BASE TABLE |
| [public.agents_resources](public.agents_resources.md) | 4 |  | BASE TABLE |
| [public.agents_threads](public.agents_threads.md) | 6 |  | BASE TABLE |
| [public.ai_builder_temporary_workflow](public.ai_builder_temporary_workflow.md) | 4 |  | BASE TABLE |
| [public.ai_preference](public.ai_preference.md) | 8 |  | BASE TABLE |
| [public.annotation_tag_entity](public.annotation_tag_entity.md) | 4 |  | BASE TABLE |
| [public.app](public.app.md) | 9 |  | BASE TABLE |
| [public.app_artifact](public.app_artifact.md) | 8 |  | BASE TABLE |
| [public.app_version](public.app_version.md) | 10 |  | BASE TABLE |
| [public.auth_identity](public.auth_identity.md) | 5 |  | BASE TABLE |
| [public.auth_provider_sync_history](public.auth_provider_sync_history.md) | 11 |  | BASE TABLE |
| [public.binary_data](public.binary_data.md) | 9 |  | BASE TABLE |
| [public.chat_hub_agent_tools](public.chat_hub_agent_tools.md) | 2 |  | BASE TABLE |
| [public.chat_hub_agents](public.chat_hub_agents.md) | 13 |  | BASE TABLE |
| [public.chat_hub_messages](public.chat_hub_messages.md) | 17 |  | BASE TABLE |
| [public.chat_hub_session_tools](public.chat_hub_session_tools.md) | 2 |  | BASE TABLE |
| [public.chat_hub_sessions](public.chat_hub_sessions.md) | 13 |  | BASE TABLE |
| [public.chat_hub_tools](public.chat_hub_tools.md) | 9 |  | BASE TABLE |
| [public.credential_dependency](public.credential_dependency.md) | 5 |  | BASE TABLE |
| [public.credentials_entity](public.credentials_entity.md) | 14 |  | BASE TABLE |
| [public.data_table](public.data_table.md) | 5 |  | BASE TABLE |
| [public.data_table_column](public.data_table_column.md) | 7 |  | BASE TABLE |
| [public.deployment_key](public.deployment_key.md) | 7 |  | BASE TABLE |
| [public.dynamic_credential_entry](public.dynamic_credential_entry.md) | 6 |  | BASE TABLE |
| [public.dynamic_credential_resolver](public.dynamic_credential_resolver.md) | 6 |  | BASE TABLE |
| [public.dynamic_credential_user_entry](public.dynamic_credential_user_entry.md) | 6 |  | BASE TABLE |
| [public.evaluation_collection](public.evaluation_collection.md) | 9 |  | BASE TABLE |
| [public.evaluation_config](public.evaluation_config.md) | 12 |  | BASE TABLE |
| [public.event_destinations](public.event_destinations.md) | 4 |  | BASE TABLE |
| [public.execution_annotation_tags](public.execution_annotation_tags.md) | 2 |  | BASE TABLE |
| [public.execution_annotations](public.execution_annotations.md) | 6 |  | BASE TABLE |
| [public.execution_data](public.execution_data.md) | 4 |  | BASE TABLE |
| [public.execution_entity](public.execution_entity.md) | 19 |  | BASE TABLE |
| [public.execution_metadata](public.execution_metadata.md) | 4 |  | BASE TABLE |
| [public.folder](public.folder.md) | 6 |  | BASE TABLE |
| [public.folder_tag](public.folder_tag.md) | 2 |  | BASE TABLE |
| [public.idempotency_key](public.idempotency_key.md) | 9 |  | BASE TABLE |
| [public.insights_by_period](public.insights_by_period.md) | 6 |  | BASE TABLE |
| [public.insights_metadata](public.insights_metadata.md) | 5 |  | BASE TABLE |
| [public.insights_raw](public.insights_raw.md) | 5 |  | BASE TABLE |
| [public.installed_nodes](public.installed_nodes.md) | 4 |  | BASE TABLE |
| [public.installed_packages](public.installed_packages.md) | 6 |  | BASE TABLE |
| [public.instance_ai_checkpoints](public.instance_ai_checkpoints.md) | 9 |  | BASE TABLE |
| [public.instance_ai_events](public.instance_ai_events.md) | 7 |  | BASE TABLE |
| [public.instance_ai_iteration_logs](public.instance_ai_iteration_logs.md) | 6 |  | BASE TABLE |
| [public.instance_ai_mcp_registry_connections](public.instance_ai_mcp_registry_connections.md) | 7 |  | BASE TABLE |
| [public.instance_ai_messages](public.instance_ai_messages.md) | 8 |  | BASE TABLE |
| [public.instance_ai_observation_cursors](public.instance_ai_observation_cursors.md) | 5 |  | BASE TABLE |
| [public.instance_ai_observation_locks](public.instance_ai_observation_locks.md) | 6 |  | BASE TABLE |
| [public.instance_ai_observational_memory](public.instance_ai_observational_memory.md) | 32 |  | BASE TABLE |
| [public.instance_ai_observations](public.instance_ai_observations.md) | 10 |  | BASE TABLE |
| [public.instance_ai_pending_confirmations](public.instance_ai_pending_confirmations.md) | 12 |  | BASE TABLE |
| [public.instance_ai_resources](public.instance_ai_resources.md) | 5 |  | BASE TABLE |
| [public.instance_ai_thread_grants](public.instance_ai_thread_grants.md) | 5 |  | BASE TABLE |
| [public.instance_ai_thread_tabs](public.instance_ai_thread_tabs.md) | 5 |  | BASE TABLE |
| [public.instance_ai_threads](public.instance_ai_threads.md) | 7 |  | BASE TABLE |
| [public.instance_ai_workflow_snapshots](public.instance_ai_workflow_snapshots.md) | 7 |  | BASE TABLE |
| [public.instance_credential_assignment](public.instance_credential_assignment.md) | 4 |  | BASE TABLE |
| [public.instance_monitoring_report](public.instance_monitoring_report.md) | 10 |  | BASE TABLE |
| [public.instance_version_history](public.instance_version_history.md) | 5 |  | BASE TABLE |
| [public.invalid_auth_token](public.invalid_auth_token.md) | 2 |  | BASE TABLE |
| [public.mcp_registry_server](public.mcp_registry_server.md) | 7 |  | BASE TABLE |
| [public.migration_finding](public.migration_finding.md) | 10 |  | BASE TABLE |
| [public.migration_finding_sync](public.migration_finding_sync.md) | 3 |  | BASE TABLE |
| [public.migration_workflow_owner](public.migration_workflow_owner.md) | 7 |  | BASE TABLE |
| [public.oauth_access_tokens](public.oauth_access_tokens.md) | 3 |  | BASE TABLE |
| [public.oauth_authorization_codes](public.oauth_authorization_codes.md) | 13 |  | BASE TABLE |
| [public.oauth_clients](public.oauth_clients.md) | 10 |  | BASE TABLE |
| [public.oauth_refresh_tokens](public.oauth_refresh_tokens.md) | 8 |  | BASE TABLE |
| [public.oauth_user_consents](public.oauth_user_consents.md) | 5 |  | BASE TABLE |
| [public.poller_state](public.poller_state.md) | 7 |  | BASE TABLE |
| [public.processed_data](public.processed_data.md) | 5 |  | BASE TABLE |
| [public.project](public.project.md) | 9 |  | BASE TABLE |
| [public.project_pool_settings](public.project_pool_settings.md) | 4 |  | BASE TABLE |
| [public.project_relation](public.project_relation.md) | 5 |  | BASE TABLE |
| [public.project_secrets_provider_access](public.project_secrets_provider_access.md) | 5 |  | BASE TABLE |
| [public.promotion_environment](public.promotion_environment.md) | 9 |  | BASE TABLE |
| [public.promotion_environment_project](public.promotion_environment_project.md) | 5 |  | BASE TABLE |
| [public.promotion_provider](public.promotion_provider.md) | 8 |  | BASE TABLE |
| [public.promotion_review](public.promotion_review.md) | 10 |  | BASE TABLE |
| [public.promotion_run](public.promotion_run.md) | 8 |  | BASE TABLE |
| [public.role](public.role.md) | 7 |  | BASE TABLE |
| [public.role_mapping_rule](public.role_mapping_rule.md) | 7 |  | BASE TABLE |
| [public.role_mapping_rule_project](public.role_mapping_rule_project.md) | 2 |  | BASE TABLE |
| [public.role_scope](public.role_scope.md) | 2 |  | BASE TABLE |
| [public.scheduled_job](public.scheduled_job.md) | 25 |  | BASE TABLE |
| [public.scheduled_task](public.scheduled_task.md) | 19 |  | BASE TABLE |
| [public.scope](public.scope.md) | 3 |  | BASE TABLE |
| [public.secrets_provider_connection](public.secrets_provider_connection.md) | 7 |  | BASE TABLE |
| [public.self_healing_investigation](public.self_healing_investigation.md) | 12 |  | BASE TABLE |
| [public.self_healing_result](public.self_healing_result.md) | 15 |  | BASE TABLE |
| [public.settings](public.settings.md) | 3 |  | BASE TABLE |
| [public.shared_credentials](public.shared_credentials.md) | 5 |  | BASE TABLE |
| [public.shared_workflow](public.shared_workflow.md) | 5 |  | BASE TABLE |
| [public.skill](public.skill.md) | 8 |  | BASE TABLE |
| [public.skill_file](public.skill_file.md) | 5 |  | BASE TABLE |
| [public.skill_version](public.skill_version.md) | 11 |  | BASE TABLE |
| [public.tag_entity](public.tag_entity.md) | 4 |  | BASE TABLE |
| [public.test_case_execution](public.test_case_execution.md) | 14 |  | BASE TABLE |
| [public.test_run](public.test_run.md) | 16 |  | BASE TABLE |
| [public.token_exchange_jti](public.token_exchange_jti.md) | 3 |  | BASE TABLE |
| [public.trusted_key](public.trusted_key.md) | 4 |  | BASE TABLE |
| [public.trusted_key_source](public.trusted_key_source.md) | 8 |  | BASE TABLE |
| [public.trusted_source](public.trusted_source.md) | 15 |  | BASE TABLE |
| [public.trusted_source_identity](public.trusted_source_identity.md) | 8 |  | BASE TABLE |
| [public.type_availability_policy](public.type_availability_policy.md) | 7 |  | BASE TABLE |
| [public.type_availability_policy_attachment](public.type_availability_policy_attachment.md) | 6 |  | BASE TABLE |
| [public.type_availability_policy_scope](public.type_availability_policy_scope.md) | 8 |  | BASE TABLE |
| [public.user](public.user.md) | 15 |  | BASE TABLE |
| [public.user_api_keys](public.user_api_keys.md) | 9 |  | BASE TABLE |
| [public.user_favorites](public.user_favorites.md) | 4 |  | BASE TABLE |
| [public.variables](public.variables.md) | 5 |  | BASE TABLE |
| [public.webhook_entity](public.webhook_entity.md) | 6 |  | BASE TABLE |
| [public.workflow_builder_session](public.workflow_builder_session.md) | 9 |  | BASE TABLE |
| [public.workflow_dependency](public.workflow_dependency.md) | 9 |  | BASE TABLE |
| [public.workflow_entity](public.workflow_entity.md) | 20 |  | BASE TABLE |
| [public.workflow_history](public.workflow_history.md) | 11 |  | BASE TABLE |
| [public.workflow_publication_outbox](public.workflow_publication_outbox.md) | 8 |  | BASE TABLE |
| [public.workflow_publication_retry_state](public.workflow_publication_retry_state.md) | 4 |  | BASE TABLE |
| [public.workflow_publication_trigger_status](public.workflow_publication_trigger_status.md) | 8 |  | BASE TABLE |
| [public.workflow_publish_history](public.workflow_publish_history.md) | 6 |  | BASE TABLE |
| [public.workflow_published_version](public.workflow_published_version.md) | 4 |  | BASE TABLE |
| [public.workflow_review_activity](public.workflow_review_activity.md) | 7 |  | BASE TABLE |
| [public.workflow_review_activity_comment](public.workflow_review_activity_comment.md) | 8 |  | BASE TABLE |
| [public.workflow_review_request](public.workflow_review_request.md) | 12 |  | BASE TABLE |
| [public.workflow_review_request_authors](public.workflow_review_request_authors.md) | 2 |  | BASE TABLE |
| [public.workflow_review_request_reviewers](public.workflow_review_request_reviewers.md) | 2 |  | BASE TABLE |
| [public.workflow_review_request_workflow](public.workflow_review_request_workflow.md) | 5 |  | BASE TABLE |
| [public.workflow_statistics](public.workflow_statistics.md) | 7 |  | BASE TABLE |
| [public.workflow_statistics_delta](public.workflow_statistics_delta.md) | 6 |  | BASE TABLE |
| [public.workflow_suggestion](public.workflow_suggestion.md) | 16 |  | BASE TABLE |
| [public.workflow_suggestion_activity](public.workflow_suggestion_activity.md) | 7 |  | BASE TABLE |
| [public.workflows_tags](public.workflows_tags.md) | 2 |  | BASE TABLE |

## Stored procedures and functions

| Name | ReturnType | Arguments | Type |
| ---- | ------- | ------- | ---- |
| public.increment_workflow_version | trigger |  | FUNCTION |
| public.prevent_deployment_key_delete | trigger |  | FUNCTION |
| public.uuid_generate_v1 | uuid |  | FUNCTION |
| public.uuid_generate_v1mc | uuid |  | FUNCTION |
| public.uuid_generate_v3 | uuid | namespace uuid, name text | FUNCTION |
| public.uuid_generate_v4 | uuid |  | FUNCTION |
| public.uuid_generate_v5 | uuid | namespace uuid, name text | FUNCTION |
| public.uuid_nil | uuid |  | FUNCTION |
| public.uuid_ns_dns | uuid |  | FUNCTION |
| public.uuid_ns_oid | uuid |  | FUNCTION |
| public.uuid_ns_url | uuid |  | FUNCTION |
| public.uuid_ns_x500 | uuid |  | FUNCTION |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Sqlite Schema README (`docs/generated/sqlite-schema/README.md`)

# n8n database schema (SQLite)

## Description

Auto-generated from the SQLite migrations in @n8n/db. Do not edit by hand.

## Tables

| Name | Columns | Comment | Type |
| ---- | ------- | ------- | ---- |
| [activity_event](activity_event.md) | 11 |  | table |
| [agent_background_job](agent_background_job.md) | 23 |  | table |
| [agent_budget_applied_call](agent_budget_applied_call.md) | 2 |  | table |
| [agent_budget_spend](agent_budget_spend.md) | 4 |  | table |
| [agent_channel_status](agent_channel_status.md) | 11 |  | table |
| [agent_chat_attachments](agent_chat_attachments.md) | 12 |  | table |
| [agent_chat_subscriptions](agent_chat_subscriptions.md) | 6 |  | table |
| [agent_checkpoints](agent_checkpoints.md) | 7 |  | table |
| [agent_credential_dependency](agent_credential_dependency.md) | 3 |  | table |
| [agent_eval_dataset](agent_eval_dataset.md) | 10 |  | table |
| [agent_eval_rating](agent_eval_rating.md) | 8 |  | table |
| [agent_eval_result](agent_eval_result.md) | 16 |  | table |
| [agent_eval_run](agent_eval_run.md) | 14 |  | table |
| [agent_execution](agent_execution.md) | 25 |  | table |
| [agent_execution_message_links](agent_execution_message_links.md) | 5 |  | table |
| [agent_execution_threads](agent_execution_threads.md) | 20 |  | table |
| [agent_files](agent_files.md) | 10 |  | table |
| [agent_history](agent_history.md) | 9 |  | table |
| [agent_message_queue](agent_message_queue.md) | 10 |  | table |
| [agent_plan](agent_plan.md) | 8 |  | table |
| [agent_plan_history](agent_plan_history.md) | 6 |  | table |
| [agent_skill_dependency](agent_skill_dependency.md) | 4 |  | table |
| [agent_task_definition](agent_task_definition.md) | 8 |  | table |
| [agent_task_run_lock](agent_task_run_lock.md) | 6 |  | table |
| [agent_task_snapshot](agent_task_snapshot.md) | 9 |  | table |
| [agent_thread_grants](agent_thread_grants.md) | 4 |  | table |
| [agent_version_skill_dependency](agent_version_skill_dependency.md) | 4 |  | table |
| [agent_workflow_dependency](agent_workflow_dependency.md) | 3 |  | table |
| [agents](agents.md) | 15 |  | table |
| [agents_memory_entries](agents_memory_entries.md) | 13 |  | table |
| [agents_memory_entry_candidates](agents_memory_entry_candidates.md) | 14 |  | table |
| [agents_memory_entry_locks](agents_memory_entry_locks.md) | 6 |  | table |
| [agents_memory_entry_sources](agents_memory_entry_sources.md) | 10 |  | table |
| [agents_messages](agents_messages.md) | 12 |  | table |
| [agents_observation_cursors](agents_observation_cursors.md) | 6 |  | table |
| [agents_observation_locks](agents_observation_locks.md) | 7 |  | table |
| [agents_observations](agents_observations.md) | 11 |  | table |
| [agents_resources](agents_resources.md) | 4 |  | table |
| [agents_threads](agents_threads.md) | 6 |  | table |
| [ai_builder_temporary_workflow](ai_builder_temporary_workflow.md) | 4 |  | table |
| [ai_preference](ai_preference.md) | 8 |  | table |
| [annotation_tag_entity](annotation_tag_entity.md) | 4 |  | table |
| [app](app.md) | 9 |  | table |
| [app_artifact](app_artifact.md) | 8 |  | table |
| [app_version](app_version.md) | 10 |  | table |
| [auth_identity](auth_identity.md) | 5 |  | table |
| [auth_provider_sync_history](auth_provider_sync_history.md) | 11 |  | table |
| [binary_data](binary_data.md) | 9 |  | table |
| [chat_hub_agent_tools](chat_hub_agent_tools.md) | 2 |  | table |
| [chat_hub_agents](chat_hub_agents.md) | 13 |  | table |
| [chat_hub_messages](chat_hub_messages.md) | 17 |  | table |
| [chat_hub_session_tools](chat_hub_session_tools.md) | 2 |  | table |
| [chat_hub_sessions](chat_hub_sessions.md) | 13 |  | table |
| [chat_hub_tools](chat_hub_tools.md) | 9 |  | table |
| [credential_dependency](credential_dependency.md) | 5 |  | table |
| [credentials_entity](credentials_entity.md) | 14 |  | table |
| [data_table](data_table.md) | 5 |  | table |
| [data_table_column](data_table_column.md) | 7 |  | table |
| [deployment_key](deployment_key.md) | 7 |  | table |
| [dynamic_credential_entry](dynamic_credential_entry.md) | 6 |  | table |
| [dynamic_credential_resolver](dynamic_credential_resolver.md) | 6 |  | table |
| [dynamic_credential_user_entry](dynamic_credential_user_entry.md) | 6 |  | table |
| [evaluation_collection](evaluation_collection.md) | 9 |  | table |
| [evaluation_config](evaluation_config.md) | 12 |  | table |
| [event_destinations](event_destinations.md) | 4 |  | table |
| [execution_annotation_tags](execution_annotation_tags.md) | 2 |  | table |
| [execution_annotations](execution_annotations.md) | 6 |  | table |
| [execution_data](execution_data.md) | 4 |  | table |
| [execution_entity](execution_entity.md) | 19 |  | table |
| [execution_metadata](execution_metadata.md) | 4 |  | table |
| [folder](folder.md) | 6 |  | table |
| [folder_tag](folder_tag.md) | 2 |  | table |
| [idempotency_key](idempotency_key.md) | 9 |  | table |
| [insights_by_period](insights_by_period.md) | 6 |  | table |
| [insights_metadata](insights_metadata.md) | 5 |  | table |
| [insights_raw](insights_raw.md) | 5 |  | table |
| [installed_nodes](installed_nodes.md) | 4 |  | table |
| [installed_packages](installed_packages.md) | 6 |  | table |
| [instance_ai_checkpoints](instance_ai_checkpoints.md) | 9 |  | table |
| [instance_ai_events](instance_ai_events.md) | 7 |  | table |
| [instance_ai_iteration_logs](instance_ai_iteration_logs.md) | 6 |  | table |
| [instance_ai_mcp_registry_connections](instance_ai_mcp_registry_connections.md) | 7 |  | table |
| [instance_ai_messages](instance_ai_messages.md) | 8 |  | table |
| [instance_ai_observation_cursors](instance_ai_observation_cursors.md) | 5 |  | table |
| [instance_ai_observation_locks](instance_ai_observation_locks.md) | 6 |  | table |
| [instance_ai_observational_memory](instance_ai_observational_memory.md) | 32 |  | table |
| [instance_ai_observations](instance_ai_observations.md) | 10 |  | table |
| [instance_ai_pending_confirmations](instance_ai_pending_confirmations.md) | 12 |  | table |
| [instance_ai_resources](instance_ai_resources.md) | 5 |  | table |
| [instance_ai_thread_grants](instance_ai_thread_grants.md) | 5 |  | table |
| [instance_ai_thread_tabs](instance_ai_thread_tabs.md) | 5 |  | table |
| [instance_ai_threads](instance_ai_threads.md) | 7 |  | table |
| [instance_ai_workflow_snapshots](instance_ai_workflow_snapshots.md) | 7 |  | table |
| [instance_credential_assignment](instance_credential_assignment.md) | 4 |  | table |
| [instance_monitoring_report](instance_monitoring_report.md) | 10 |  | table |
| [instance_version_history](instance_version_history.md) | 5 |  | table |
| [invalid_auth_token](invalid_auth_token.md) | 2 |  | table |
| [mcp_registry_server](mcp_registry_server.md) | 7 |  | table |
| [migration_finding](migration_finding.md) | 10 |  | table |
| [migration_finding_sync](migration_finding_sync.md) | 3 |  | table |
| [migration_workflow_owner](migration_workflow_owner.md) | 7 |  | table |
| [oauth_access_tokens](oauth_access_tokens.md) | 3 |  | table |
| [oauth_authorization_codes](oauth_authorization_codes.md) | 13 |  | table |
| [oauth_clients](oauth_clients.md) | 10 |  | table |
| [oauth_refresh_tokens](oauth_refresh_tokens.md) | 8 |  | table |
| [oauth_user_consents](oauth_user_consents.md) | 5 |  | table |
| [poller_state](poller_state.md) | 7 |  | table |
| [processed_data](processed_data.md) | 5 |  | table |
| [project](project.md) | 9 |  | table |
| [project_pool_settings](project_pool_settings.md) | 4 |  | table |
| [project_relation](project_relation.md) | 5 |  | table |
| [project_secrets_provider_access](project_secrets_provider_access.md) | 5 |  | table |
| [promotion_environment](promotion_environment.md) | 9 |  | table |
| [promotion_environment_project](promotion_environment_project.md) | 5 |  | table |
| [promotion_provider](promotion_provider.md) | 8 |  | table |
| [promotion_review](promotion_review.md) | 10 |  | table |
| [promotion_run](promotion_run.md) | 8 |  | table |
| [role](role.md) | 7 |  | table |
| [role_mapping_rule](role_mapping_rule.md) | 7 |  | table |
| [role_mapping_rule_project](role_mapping_rule_project.md) | 2 |  | table |
| [role_scope](role_scope.md) | 2 |  | table |
| [scheduled_job](scheduled_job.md) | 25 |  | table |
| [scheduled_task](scheduled_task.md) | 19 |  | table |
| [scope](scope.md) | 3 |  | table |
| [secrets_provider_connection](secrets_provider_connection.md) | 7 |  | table |
| [self_healing_investigation](self_healing_investigation.md) | 12 |  | table |
| [self_healing_result](self_healing_result.md) | 15 |  | table |
| [settings](settings.md) | 3 |  | table |
| [shared_credentials](shared_credentials.md) | 5 |  | table |
| [shared_workflow](shared_workflow.md) | 5 |  | table |
| [skill](skill.md) | 8 |  | table |
| [skill_file](skill_file.md) | 5 |  | table |
| [skill_version](skill_version.md) | 11 |  | table |
| [tag_entity](tag_entity.md) | 4 |  | table |
| [test_case_execution](test_case_execution.md) | 16 |  | table |
| [test_run](test_run.md) | 16 |  | table |
| [token_exchange_jti](token_exchange_jti.md) | 3 |  | table |
| [trusted_key](trusted_key.md) | 4 |  | table |
| [trusted_key_source](trusted_key_source.md) | 8 |  | table |
| [trusted_source](trusted_source.md) | 15 |  | table |
| [trusted_source_identity](trusted_source_identity.md) | 8 |  | table |
| [type_availability_policy](type_availability_policy.md) | 7 |  | table |
| [type_availability_policy_attachment](type_availability_policy_attachment.md) | 6 |  | table |
| [type_availability_policy_scope](type_availability_policy_scope.md) | 8 |  | table |
| [user](user.md) | 15 |  | table |
| [user_api_keys](user_api_keys.md) | 9 |  | table |
| [user_favorites](user_favorites.md) | 4 |  | table |
| [variables](variables.md) | 5 |  | table |
| [webhook_entity](webhook_entity.md) | 6 |  | table |
| [workflow_builder_session](workflow_builder_session.md) | 9 |  | table |
| [workflow_dependency](workflow_dependency.md) | 9 |  | table |
| [workflow_entity](workflow_entity.md) | 20 |  | table |
| [workflow_history](workflow_history.md) | 11 |  | table |
| [workflow_publication_outbox](workflow_publication_outbox.md) | 8 |  | table |
| [workflow_publication_retry_state](workflow_publication_retry_state.md) | 4 |  | table |
| [workflow_publication_trigger_status](workflow_publication_trigger_status.md) | 8 |  | table |
| [workflow_publish_history](workflow_publish_history.md) | 6 |  | table |
| [workflow_published_version](workflow_published_version.md) | 4 |  | table |
| [workflow_review_activity](workflow_review_activity.md) | 7 |  | table |
| [workflow_review_activity_comment](workflow_review_activity_comment.md) | 8 |  | table |
| [workflow_review_request](workflow_review_request.md) | 12 |  | table |
| [workflow_review_request_authors](workflow_review_request_authors.md) | 2 |  | table |
| [workflow_review_request_reviewers](workflow_review_request_reviewers.md) | 2 |  | table |
| [workflow_review_request_workflow](workflow_review_request_workflow.md) | 5 |  | table |
| [workflow_statistics](workflow_statistics.md) | 7 |  | table |
| [workflow_suggestion](workflow_suggestion.md) | 16 |  | table |
| [workflow_suggestion_activity](workflow_suggestion_activity.md) | 7 |  | table |
| [workflows_tags](workflows_tags.md) | 2 |  | table |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Packages @N8n Cli Docs Getting Started (`packages/@n8n/cli/docs/getting-started.md`)

# Getting Started

## Installation

```bash
# Use directly with npx (zero install)
npx @n8n/cli workflow list

# Or install globally
npm install @n8n/cli
```

## Configuration

The CLI needs two things: your n8n instance URL and an API key.

### Option 1: Config file (recommended)

```bash
n8n-cli config set-url https://my-n8n.app.n8n.cloud
n8n-cli config set-api-key n8n_api_xxxxx

# Verify
n8n-cli config show
```

Configuration is saved to `~/.n8n-cli/config.json` with restricted file permissions (`0600`).

### Option 2: Environment variables

```bash
export N8N_URL=https://my-n8n.app.n8n.cloud
export N8N_API_KEY=n8n_api_xxxxx
```

### Option 3: Inline flags

```bash
n8n-cli --url=https://my-n8n.app.n8n.cloud --api-key=n8n_api_xxxxx workflow list
```

### Resolution order

The CLI resolves configuration in this priority order:

1. Command-line flags (`--url`, `--api-key`)
2. Environment variables (`N8N_URL`, `N8N_API_KEY`)
3. Config file (`~/.n8n-cli/config.json`)

## Your first commands

```bash
# List all workflows
n8n-cli workflow list

# Get a specific workflow as JSON
n8n-cli workflow get 1234 --format=json

# List failed executions
n8n-cli execution list --status=error --limit=5

# Create a tag
n8n-cli tag create --name=production
```

## Output formats

Every command supports three output formats:

| Format | Flag | Use case |
|--------|------|----------|
| Table | `--format=table` (default) | Human-readable terminal display |
| JSON | `--format=json` | Piping to `jq`, programmatic use |
| ID-only | `--format=id-only` | Piping to `xargs`, scripting |

```bash
# Human reads a table
n8n-cli workflow list

# AI agent or script gets JSON
n8n-cli workflow list --format=json | jq '.[] | select(.active) | .id'

# Pipe IDs to deactivate all workflows
n8n-cli workflow list --format=id-only | xargs -I{} n8n-cli workflow deactivate {}
```

## AI agent skills

The CLI ships with a skill that teaches AI coding agents how to use `n8n-cli`.

```bash
# Claude Code (installs to .claude/skills/n8n-cli/ in the current project)
n8n-cli skill install

# Claude Code (global — installs to ~/.claude/skills/n8n-cli/)
n8n-cli skill install --global

# Cursor (appends to .cursorrules)
n8n-cli skill install --target=cursor

# Windsurf (appends to .windsurfrules)
n8n-cli skill install --target=windsurf
```

Then use `/n8n-cli` in Claude Code to load the skill.

## Getting help

Every command has built-in help:

```bash
n8n-cli --help
n8n-cli workflow --help
n8n-cli workflow list --help
```

---

### Packages @N8n Cli Docs Index (`packages/@n8n/cli/docs/index.md`)

---
layout: home

hero:
  name: n8n CLI
  text: Manage n8n from the terminal
  tagline: A lightweight client CLI for workflows, executions, credentials, and more.
  actions:
    - theme: brand
      text: Get Started
      link: /getting-started
    - theme: alt
      text: Command Reference
      link: /commands/workflow

features:
  - title: Zero Dependencies
    details: Uses native Node.js fetch — no HTTP libraries, no server stack. Installs in seconds.
  - title: AI Agent Friendly
    details: Designed for Claude Code, Cursor, and other AI coding agents. Self-documenting with --help at every level.
  - title: Pipe Everything
    details: JSON, table, and ID-only output formats. Pipe to jq, grep, xargs — compose with the Unix toolchain.
  - title: Scriptable
    details: Meaningful exit codes, errors on stderr, data on stdout. Built for CI/CD pipelines.
---

---

### Packages Frontend @N8n I18n Docs README (`packages/frontend/@n8n/i18n/docs/README.md`)

# i18n in n8n

## Scope

n8n allows for internalization of the majority of UI text:

- base text, e.g. menu display items in the left-hand sidebar menu,
- node text, e.g. parameter display names and placeholders in the node view,
- credential text, e.g. parameter display names and placeholders in the credential modal,
- header text, e.g. node display names and descriptions at various spots.

Currently, n8n does _not_ allow for internalization of:

- messages from outside the `editor-ui` package, e.g. `No active database connection`,
- strings in certain Vue components, e.g. date time picker
- node subtitles, e.g. `create: user` or `getAll: post` below the node name on the canvas,
- new version notification contents in the updates panel, e.g. `Includes node enhancements`, and
- options that rely on `loadOptionsMethod`.

Pending functionality:

- Search in nodes panel by translated node name
- UI responsiveness to differently sized strings
- Locale-aware number formatting

## Locale identifiers

A **locale identifier** is a language code compatible with the [`Accept-Language` header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language), e.g. `de` (German), `es` (Spanish), `ja` (Japanese). Regional variants of locale identifiers, such as `-AT` in `de-AT`, are _not_ supported. For a list of all locale identifiers, see [column 639-1 in this table](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes).

By default, n8n runs in the `en` (English) locale. To have run it in a different locale, set the `N8N_DEFAULT_LOCALE` environment variable to a locale identifier. When running in a non-`en` locale, n8n will display UI strings for the selected locale and fall back to `en` for any untranslated strings.

```
export N8N_DEFAULT_LOCALE=de
pnpm start
```

Output:

```
Initializing n8n process
n8n ready on 0.0.0.0, port 5678
Version: 0.156.0
Locale: de

Editor is now accessible via:
http://localhost:5678/

Press "o" to open in Browser.
```

## Base text

Base text is rendered with no dependencies, i.e. base text is fixed and does not change in any circumstances. Base text is supplied by the user in one file per locale in the `/frontend/@n8n/i18n` package.

### Locating base text

The base text file for each locale is located at `/packages/frontend/@n8n/i18n/src/locales/` and is named `{localeIdentifier}.json`. Keys in the base text file can be Vue component dirs, Vue component names, and references to symbols in those Vue components. These keys are added by the team as the UI is modified or expanded.

```json
{
	"nodeCreator.categoryNames.analytics": "🇩🇪 Analytics",
	"nodeCreator.categoryNames.communication": "🇩🇪 Communication",
	"nodeCreator.categoryNames.coreNodes": "🇩🇪 Core Nodes"
}
```

### Translating base text

1. Select a new locale identifier, e.g. `de`, copy the `en` JSON base text file with a new name:

```
cp ./packages/frontend/@n8n/i18n/src/locales/en.json ./packages/frontend/@n8n/i18n/src/locales/de.json
```

2. Find in the UI a string to translate, and search for it in the newly created base text file. Alternatively, find in `/frontend/editor-ui` a call to `i18n.baseText(key)`, e.g. `i18n.baseText('workflowActivator.deactivateWorkflow')`, and take note of the key and find it in the newly created base text file.

> **Note**: If you cannot find a string in the new base text file, either it does not belong to base text (i.e., the string might be part of header text, credential text, or node text), or the string might belong to the backend, where i18n is currently unsupported.

3. Translate the string value - do not change the key. In the examples below, a string starting with 🇩🇪 stands for a string translated from English into German.

As an optional final step, remove any untranslated strings from the new base text file. Untranslated strings in the new base text file will trigger a fallback to the `en` base text file.

> For information about **interpolation** and **reusable base text**, refer to the [Addendum](./ADDENDUM.md).

## Dynamic text

Dynamic text relies on data specific to each node and credential:

- `headerText` and `nodeText` in the **node translation file**
- `credText` in the **credential translation file**

### Locating dynamic text

#### Locating the credential translation file

A credential translation file is placed at `/nodes-base/credentials/translations/{localeIdentifier}`

```
credentials
	└── translations
		└── de
			├── githubApi.json
			└── githubOAuth2Api.json
```

Every credential must have its own credential translation file.

The name of the credential translation file must be sourced from the credential's `description.name` property:

```ts
export class GithubApi implements ICredentialType {
	name = 'githubApi'; // to use for credential translation file
	displayName = 'Github API';
	documentationUrl = 'github';
	properties: INodeProperties[] = [
```

#### Locating the node translation file

A node translation file is placed at `/nodes-base/nodes/{node}/translations/{localeIdentifier}`

```
GitHub
	├── GitHub.node.ts
	├── GitHubTrigger.node.ts
	└── translations
		└── de
			├── github.json
			└── githubTrigger.json
```

Every node must have its own node translation file.

> For information about nodes in **versioned dirs** and **grouping dirs**, refer to the [Addendum](./ADDENDUM.md).

The name of the node translation file must be sourced from the node's `description.name` property:

```ts
export class Github implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'GitHub',
		name: 'github', // to use for node translation file name
		icon: 'file:github.svg',
		group: ['input'],
```

### Translating dynamic text

#### Translating the credential translation file

> **Note**: All translation keys are optional. Missing translation values trigger a fallback to the `en` locale strings.

A credential translation file, e.g. `githubApi.json` is an object containing keys that match the credential parameter names:

```ts
export class GithubApi implements ICredentialType {
	name = 'githubApi';
	displayName = 'Github API';
	documentationUrl = 'github';
	properties: INodeProperties[] = [
		{
			displayName: 'Github Server',
			name: 'server', // key to use in translation
			type: 'string',
			default: 'https://api.github.com',
			description: 'The server to connect to. Only has to be set if Github Enterprise is used.',
		},
		{
			displayName: 'User',
			name: 'user', // key to use in translation
			type: 'string',
			default: '',
		},
		{
			displayName: 'Access Token',
			name: 'accessToken', // key to use in translation
			type: 'string',
			default: '',
		},
	];
}
```

The object for each node credential parameter allows for the keys `displayName`, `description`, and `placeholder`.

```json
{
	"server.displayName": "🇩🇪 Github Server",
	"server.description": "🇩🇪 The server to connect to. Only has to be set if Github Enterprise is used.",
	"user.placeholder": "🇩🇪 Hans",
	"accessToken.placeholder": "🇩🇪 123"
}
```

<p align="center">
	<img src="img/cred.png">
</p>

Only existing parameters are translatable. If a credential parameter does not have a description in the English original, adding a translation for that non-existing parameter will not result in the translation being displayed - the parameter will need to be added in the English original first.

#### Translating the node translation file

> **Note**: All keys are optional. Missing translations trigger a fallback to the `en` locale strings.

Each node translation file is an object that allows for two keys, `header` and `nodeView`, which are the _sections_ of each node translation.

The `header` section points to an object that may contain only two keys, `displayName` and `description`, matching the node's `description.displayName` and `description.description`.

```ts
export class Github implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'GitHub', // key to use in translation
		description: 'Consume GitHub API', // key to use in translation
		name: 'github',
		icon: 'file:github.svg',
		group: ['input'],
		version: 1,
```

```json
{
	"header": {
		"displayName": "🇩🇪 GitHub",
		"description": "🇩🇪 Consume GitHub API"
	}
}
```

Header text is used wherever the node's display name and description are needed:

<p align="center">
		<img src="img/header1.png" width="400">
		<img src="img/header2.png" width="200">
		<img src="img/header3.png" width="400">
</p>

<p align="center">
		<img src="img/header4.png" width="400">
		<img src="img/header5.png" width="500">
</p>

In turn, the `nodeView` section points to an object containing translation keys that match the node's operational parameters, found in the `*.node.ts` and also found in `*Description.ts` files in the same dir.

```ts
export class Github implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'GitHub',
		name: 'github',
		properties: [
			{
				displayName: 'Resource',
				name: 'resource', // key to use in translation
				type: 'options',
				options: [],
				default: 'issue',
				description: 'The resource to operate on.',
			},
```

```json
{
	"nodeView.resource.displayName": "🇩🇪 Resource"
}
```

A node parameter allows for different translation keys depending on parameter type.

#### `string`, `number` and `boolean` parameters

Allowed keys: `displayName`, `description`, `placeholder`

```ts
{
	displayName: 'Repository Owner',
	name: 'owner', // key to use in translation
	type: 'string',
	required: true,
	placeholder: 'n8n-io',
	description: 'Owner of the repository.',
},
```

```json
{
	"nodeView.owner.displayName": "🇩🇪 Repository Owner",
	"nodeView.owner.placeholder": "🇩🇪 n8n-io",
	"nodeView.owner.description": "🇩🇪 Owner of the repository"
}
```

<p align="center">
	<img src="img/node1.png" width="400">
</p>

#### `options` parameter

Allowed keys: `displayName`, `description`, `placeholder`

Allowed subkeys: `options.{optionName}.displayName` and `options.{optionName}.description`.

```js
{
	displayName: 'Resource',
	name: 'resource',
	type: 'options',
	options: [
		{
			name: 'File',
			value: 'file', // key to use in translation
		},
		{
			name: 'Issue',
			value: 'issue', // key to use in translation
		},
	],
	default: 'issue',
	description: 'Resource to operate on',
},
```

```json
{
	"nodeView.resource.displayName": "🇩🇪 Resource",
	"nodeView.resource.description": "🇩🇪 Resource to operate on",
	"nodeView.resource.options.file.name": "🇩🇪 File",
	"nodeView.resource.options.issue.name": "🇩🇪 Issue"
}
```

<p align="center">
	<img src="img/node2.png" width="400">
</p>

For nodes whose credentials may be used in the HTTP Request node, an additional option `Custom API Call` is injected into the `Resource` and `Operation` parameters. Use the `__CUSTOM_API_CALL__` key to translate this additional option.

```json
{
	"nodeView.resource.options.file.name": "🇩🇪 File",
	"nodeView.resource.options.issue.name": "🇩🇪 Issue",
	"nodeView.resource.options.__CUSTOM_API_CALL__.name": "🇩🇪 Custom API Call"
}
```

#### `collection` and `fixedCollection` parameters

Allowed keys: `displayName`, `description`, `placeholder`, `multipleValueButtonText`

Example of `collection` parameter:

```js
{
	displayName: 'Labels',
	name: 'labels', // key to use in translation
	type: 'collection',
	typeOptions: {
		multipleValues: true,
		multipleValueButtonText: 'Add Label',
	},
	displayOptions: {
		show: {
			operation: [
				'create',
			],
			resource: [
				'issue',
			],
		},
	},
	default: { 'label': '' },
	options: [
		{
			displayName: 'Label',
			name: 'label', // key to use in translation
			type: 'string',
			default: '',
			description: 'Label to add to issue',
		},
	],
},
```

```json
{
	"nodeView.labels.displayName": "🇩🇪 Labels",
	"nodeView.labels.multipleValueButtonText": "🇩🇪 Add Label",
	"nodeView.labels.options.label.displayName": "🇩🇪 Label",
	"nodeView.labels.options.label.description": "🇩🇪 Label to add to issue",
	"nodeView.labels.options.label.placeholder": "🇩🇪 Some placeholder"
}
```

Example of `fixedCollection` parameter:

```js
{
	displayName: 'Additional Parameters',
	name: 'additionalParameters',
	placeholder: 'Add Parameter',
	description: 'Additional fields to add.',
	type: 'fixedCollection',
	default: {},
	displayOptions: {
		show: {
			operation: [
				'create',
				'delete',
				'edit',
			],
			resource: [
				'file',
			],
		},
	},
	options: [
		{
			name: 'author',
			displayName: 'Author',
			values: [
				{
					displayName: 'Name',
					name: 'name',
					type: 'string',
					default: '',
					description: 'Name of the author of the commit',
					placeholder: 'John',
				},
				{
					displayName: 'Email',
					name: 'email',
					type: 'string',
					default: '',
					description: 'Email of the author of the commit',
					placeholder: 'john@email.com',
				},
			],
		},
	],
}
```

```json
{
	"nodeView.additionalParameters.displayName": "🇩🇪 Additional Parameters",
	"nodeView.additionalParameters.placeholder": "🇩🇪 Add Field",
	"nodeView.additionalParameters.options.author.displayName": "🇩🇪 Author",
	"nodeView.additionalParameters.options.author.values.name.displayName": "🇩🇪 Name",
	"nodeView.additionalParameters.options.author.values.name.description": "🇩🇪 Name of the author of the commit",
	"nodeView.additionalParameters.options.author.values.name.placeholder": "🇩🇪 Jan",
	"nodeView.additionalParameters.options.author.values.email.displayName": "🇩🇪 Email",
	"nodeView.additionalParameters.options.author.values.email.description": "🇩🇪 Email of the author of the commit",
	"nodeView.additionalParameters.options.author.values.email.placeholder": "🇩🇪 jan@n8n.io"
}
```

<p align="center">
		<img src="img/node4.png" width="400">
</p>

> For information on **reusable dynamic text**, refer to the [Addendum](./ADDENDUM.md).

# Building translations

## Base text

When translating a base text file at `/packages/frontend/@n8n/i18n/src/locales/{localeIdentifier}.json`:

1. Open a terminal:

```sh
export N8N_DEFAULT_LOCALE=de
pnpm start
```

2. Open another terminal:

```sh
export N8N_DEFAULT_LOCALE=de
cd packages/frontend/editor-ui
pnpm dev
```

Changing the base text file will trigger a rebuild of the client at `http://localhost:8080`.

## Dynamic text

When translating a dynamic text file at `/packages/nodes-base/nodes/{node}/translations/{localeIdentifier}/{node}.json`,

1. Open a terminal:

```sh
export N8N_DEFAULT_LOCALE=de
pnpm start
```

2. Open another terminal:

```sh
export N8N_DEFAULT_LOCALE=de
cd packages/nodes-base
pnpm n8n-generate-translations
pnpm watch
```

After changing the dynamic text file:

1. Stop and restart the first terminal.
2. Refresh the browser at `http://localhost:5678`

If a `headerText` section was changed, re-run `pnpm n8n-generate-translations` in `/nodes-base`.

> **Note**: To translate base and dynamic text simultaneously, run three terminals following the steps from both sections (first terminal running only once) and browse `http://localhost:8080`.

---

### ADR TEMPLATE (`docs/ADR_TEMPLATE.md`)

# <Decision title>

Date: YYYY-MM-DD

Status: 

Decision Owner: 

Source: 

Supersedes: 

Superseded by: 

## Context



## Decision



## Alternatives Considered



## Consequences



## Links

RFC: 

Documentation: 

Related ADRs:

---

### Db (`docs/db.md`)

# Database

n8n persists its state in a relational database, accessed through TypeORM. The
schema supports both SQLite (the default) and PostgreSQL, and is defined by the
**migrations** in `@n8n/db` rather than the entities (entities run with
`synchronize: false`).

## Schema reference

Auto-generated documentation of the schema, one set per supported database:

- [SQLite](./generated/sqlite-schema/README.md)
- [PostgreSQL](./generated/postgres-schema/README.md)

Each set lists every table with its columns, types, defaults, indexes, and
foreign keys, plus a Mermaid ER diagram of the relationships. The two differ
where the column types do (e.g. `datetime` vs `timestamptz`, `text`/`simple-json`
vs `json`/`jsonb`, `boolean` representation).

### How it's generated

The generator spins up an empty database, runs the full `@n8n/db` migration set
against it, and points [tbls](https://github.com/k1LoW/tbls) at the result.
SQLite uses a throwaway file; PostgreSQL uses a throwaway testcontainer, so
**Docker is required**.

```bash
# Regenerate both (requires Docker; tbls locally via `brew install tbls`)
pnpm db:schema:docs

# Verify the committed docs match the current migrations
pnpm db:schema:check
```

The schema reference is **auto-generated — do not edit by hand.** CI fails when
a migration changes the schema but the docs weren't regenerated; when that
happens, run `pnpm db:schema:docs` and commit the result.

---

### Generated Postgres Schema Public.Activity Event (`docs/generated/postgres-schema/public.activity_event.md`)

# public.activity_event

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| action | varchar(64) |  | false |  |  | What happened, as a verb: created, saved, published, unpublished, deleted, archived, unarchived, version-updated |
| category | varchar(32) |  | false |  |  | Kind of happening, not kind of resource — see ActivityEventCategory in @n8n/db. The unit a reader caps and collapses by: workflow, credential. Executions are absent on purpose; execution_entity already records and indexes them |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| data | json |  | true |  |  | Minimal detail that makes an entry meaningful unexpanded (a save node delta, and whether the assistant or the user changed it). Size-capped on write; no user ids |
| id | integer |  | false |  |  |  |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) | The access boundary; every read filters on it, so an entry without a project could never be shown and is not worth writing |
| resourceId | varchar(36) |  | true |  |  | Id of the resource, for fetching the full record. No FK: entries outlive it |
| resourceName | text |  | true |  |  | Name at the time of the entry, denormalised so a row reads without a join and survives the resource being deleted. Truncated on write |
| resourceType | varchar(32) |  | true |  |  | What `resourceId` points at; see ActivityResourceType in @n8n/db. NULL when an entry is about the instance rather than a resource |
| typeVersion | integer | 1 | false |  |  | Schema version of `data` for this category/action pair |
| userId | uuid |  | true |  | [public.user](public.user.md) | Who acted. Never NULL on insert — every event carries a user. Goes NULL when that user is deleted |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_29654477f37189453b353d3f46a | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE SET NULL |
| FK_6bf94d5542661d2e1b9e0c41436 | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_c2c1e9fdda754a6bf7f664d7e04 | PRIMARY KEY | PRIMARY KEY (id) |
| activity_event_action_not_null | n | NOT NULL action |
| activity_event_category_not_null | n | NOT NULL category |
| activity_event_createdAt_not_null | n | NOT NULL "createdAt" |
| activity_event_id_not_null | n | NOT NULL id |
| activity_event_projectId_not_null | n | NOT NULL "projectId" |
| activity_event_typeVersion_not_null | n | NOT NULL "typeVersion" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_activity_event_project | CREATE INDEX "IDX_activity_event_project" ON public.activity_event USING btree ("projectId", id) |
| IDX_activity_event_resource | CREATE INDEX "IDX_activity_event_resource" ON public.activity_event USING btree ("resourceId", id) |
| IDX_activity_event_user | CREATE INDEX "IDX_activity_event_user" ON public.activity_event USING btree ("userId", id) |
| PK_c2c1e9fdda754a6bf7f664d7e04 | CREATE UNIQUE INDEX "PK_c2c1e9fdda754a6bf7f664d7e04" ON public.activity_event USING btree (id) |

## Relations

```mermaid
erDiagram

"public.activity_event" }o--|| "public.project" : "FOREIGN KEY (#quot;projectId#quot;) REFERENCES project(id) ON DELETE CASCADE"
"public.activity_event" }o--o| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE SET NULL"

"public.activity_event" {
  varchar_64_ action
  varchar_32_ category
  timestamp_3__with_time_zone createdAt
  json data
  integer id
  varchar_36_ projectId FK
  varchar_36_ resourceId
  text resourceName
  varchar_32_ resourceType
  integer typeVersion
  uuid userId FK
}
"public.project" {
  timestamp_3__with_time_zone createdAt
  uuid creatorId FK
  json customTelemetryTags
  varchar_512_ description
  json icon
  varchar_36_ id
  varchar_255_ name
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Background Job (`docs/generated/postgres-schema/public.agent_background_job.md`)

# public.agent_background_job

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| childExecutionId | varchar(36) |  | true |  |  | Workflow jobs only |
| childThreadId | varchar(128) |  | true |  |  | Sub-agent jobs only; minted at dispatch, links to agent_execution_threads |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| error | text |  | true |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| kind | varchar(16) |  | false |  |  | What the job tracks: a detached sub-agent run or a workflow execution |
| notifiedAt | timestamp(3) with time zone |  | true |  |  | Time when the parent received the latest result or approval request |
| parentAgentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| parentPrincipalHash | varchar(64) |  | false |  |  | Sandbox principal hash of the parent agent run |
| parentResourceId | varchar(255) |  | false |  |  | Memory resource of the parent agent run |
| parentThreadId | varchar(128) |  | false |  |  |  |
| pauseRequestId | uuid |  | true |  |  | Groups jobs stopped by one user request |
| planId | uuid |  | true |  | [public.agent_plan](public.agent_plan.md) | Plan that owns this work |
| planTaskId | uuid |  | true |  |  | Task ID in the saved plan document |
| result | text |  | true |  |  | Final answer of a settled sub-agent job |
| settledAt | timestamp(3) with time zone |  | true |  |  |  |
| sourceExecutionId | varchar(36) |  | true |  | [public.agent_execution](public.agent_execution.md) | Execution that dispatched this job |
| status | varchar(16) |  | false |  |  | running: child works; suspended: child awaits approval; paused: user stopped the child; completed, failed, cancelled: terminal |
| subAgentId | varchar(36) |  | true |  |  | Sub-agent jobs only |
| timeoutAt | timestamp(3) with time zone |  | true |  |  | When reconciliation fails the job as timed out; NULL means no timeout |
| title | varchar(255) |  | false |  |  | Task name or workflow name, echoed in status-check listings |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | true |  |  | Workflow jobs only; scopes cancellation |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_background_job_kind | CHECK | CHECK (((kind)::text = ANY ((ARRAY['subagent'::character varying, 'workflow'::character varying])::text[]))) |
| CHK_agent_background_job_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['running'::character varying, 'suspended'::character varying, 'paused'::character varying, 'completed'::character varying, 'failed'::character varying, 'cancelled'::character varying])::text[]))) |
| FK_4db3b7ebea4ed4f69649982018c | FOREIGN KEY | FOREIGN KEY ("sourceExecutionId") REFERENCES agent_execution(id) ON DELETE SET NULL |
| FK_ce131bff629d89015893e350e9c | FOREIGN KEY | FOREIGN KEY ("planId") REFERENCES agent_plan(id) ON DELETE SET NULL |
| FK_d46c6f00730c2ef8bcb6ee24b67 | FOREIGN KEY | FOREIGN KEY ("parentAgentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_6e0db58281aa2b4c956dc0d58e9 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_background_job_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_background_job_id_not_null | n | NOT NULL id |
| agent_background_job_kind_not_null | n | NOT NULL kind |
| agent_background_job_parentAgentId_not_null | n | NOT NULL "parentAgentId" |
| agent_background_job_parentPrincipalHash_not_null | n | NOT NULL "parentPrincipalHash" |
| agent_background_job_parentResourceId_not_null | n | NOT NULL "parentResourceId" |
| agent_background_job_parentThreadId_not_null | n | NOT NULL "parentThreadId" |
| agent_background_job_status_not_null | n | NOT NULL status |
| agent_background_job_title_not_null | n | NOT NULL title |
| agent_background_job_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_93d62baabe9858816b5adafb44 | CREATE INDEX "IDX_93d62baabe9858816b5adafb44" ON public.agent_background_job USING btree ("parentThreadId", status) |
| IDX_agent_background_job_childExecutionId | CREATE UNIQUE INDEX "IDX_agent_background_job_childExecutionId" ON public.agent_background_job USING btree ("childExecutionId") WHERE ("childExecutionId" IS NOT NULL) |
| IDX_agent_background_job_parentThreadId | CREATE INDEX "IDX_agent_background_job_parentThreadId" ON public.agent_background_job USING btree ("parentThreadId") WHERE (((status)::text <> 'running'::text) AND ("notifiedAt" IS NULL)) |
| IDX_agent_background_job_planId_planTaskId | CREATE INDEX "IDX_agent_background_job_planId_planTaskId" ON public.agent_background_job USING btree ("planId", "planTaskId") |
| IDX_agent_background_job_sourceExecutionId | CREATE INDEX "IDX_agent_background_job_sourceExecutionId" ON public.agent_background_job USING btree ("sourceExecutionId") |
| IDX_agent_background_job_timeoutAt | CREATE INDEX "IDX_agent_background_job_timeoutAt" ON public.agent_background_job USING btree ("timeoutAt") WHERE ((status)::text = ANY ((ARRAY['running'::character varying, 'suspended'::character varying])::text[])) |
| IDX_d46c6f00730c2ef8bcb6ee24b6 | CREATE INDEX "IDX_d46c6f00730c2ef8bcb6ee24b6" ON public.agent_background_job USING btree ("parentAgentId") |
| IDX_e43e630272995a93dfeb94ab3e | CREATE INDEX "IDX_e43e630272995a93dfeb94ab3e" ON public.agent_background_job USING btree ("settledAt") |
| PK_6e0db58281aa2b4c956dc0d58e9 | CREATE UNIQUE INDEX "PK_6e0db58281aa2b4c956dc0d58e9" ON public.agent_background_job USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Budget Applied Call (`docs/generated/postgres-schema/public.agent_budget_applied_call.md`)

# public.agent_budget_applied_call

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| callId | uuid |  | false |  |  | Model call id. A second insert of the same id does not add spend. |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  | Time this call id was stored. A later prune can delete old rows. |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_0d91039b74f93ae1bdfc485e2ba | PRIMARY KEY | PRIMARY KEY ("callId") |
| agent_budget_applied_call_callId_not_null | n | NOT NULL "callId" |
| agent_budget_applied_call_createdAt_not_null | n | NOT NULL "createdAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_0d91039b74f93ae1bdfc485e2ba | CREATE UNIQUE INDEX "PK_0d91039b74f93ae1bdfc485e2ba" ON public.agent_budget_applied_call USING btree ("callId") |

## Relations

```mermaid
erDiagram


"public.agent_budget_applied_call" {
  uuid callId
  timestamp_3__with_time_zone createdAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Budget Spend (`docs/generated/postgres-schema/public.agent_budget_spend.md`)

# public.agent_budget_spend

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| key | varchar(128) |  | false |  |  | Session key is the root thread id. Month key is {agentId}:{YYYY-MM}. |
| totalUsd | double precision | 0 | false |  |  | Running USD estimate for this ledger key. A check rejects a negative total. |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_budget_spend_total_usd_non_negative | CHECK | CHECK (("totalUsd" >= (0)::double precision)) |
| PK_ca88e3ef81cc367fc55807e582c | PRIMARY KEY | PRIMARY KEY (key) |
| agent_budget_spend_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_budget_spend_key_not_null | n | NOT NULL key |
| agent_budget_spend_totalUsd_not_null | n | NOT NULL "totalUsd" |
| agent_budget_spend_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_ca88e3ef81cc367fc55807e582c | CREATE UNIQUE INDEX "PK_ca88e3ef81cc367fc55807e582c" ON public.agent_budget_spend USING btree (key) |

## Relations

```mermaid
erDiagram


"public.agent_budget_spend" {
  timestamp_3__with_time_zone createdAt
  varchar_128_ key
  double_precision totalUsd
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Channel Status (`docs/generated/postgres-schema/public.agent_channel_status.md`)

# public.agent_channel_status

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this channel |
| attempts | integer | 0 | false |  |  | Consecutive failed startup attempts by this process, reset on success |
| backoffUntil | timestamp(3) with time zone |  | true |  |  | Earliest this process should retry; null when there is nothing to retry |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | false |  |  | Credential connection that backs this channel; no FK so a failure is still recordable after the credential is deleted |
| errorMessage | text |  | true |  |  | Why this process could not start the channel; null once it succeeds |
| expiresAt | timestamp(3) with time zone |  | true |  |  | When this row stops counting unless its owner refreshes it; null never expires |
| hostId | varchar(128) |  | false |  |  | Process that observed this; the only writer of this row |
| integrationType | varchar(64) |  | false |  |  | Chat integration platform for this channel |
| status | varchar(16) |  | false |  |  | What this process last observed: connected or error |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_channel_status_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['connected'::character varying, 'error'::character varying])::text[]))) |
| FK_7a723e6aad04d88057dea6a21f4 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_4e1ca943734d575679a56f4da90 | PRIMARY KEY | PRIMARY KEY ("agentId", "integrationType", "credentialId", "hostId") |
| agent_channel_status_agentId_not_null | n | NOT NULL "agentId" |
| agent_channel_status_attempts_not_null | n | NOT NULL attempts |
| agent_channel_status_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_channel_status_credentialId_not_null | n | NOT NULL "credentialId" |
| agent_channel_status_hostId_not_null | n | NOT NULL "hostId" |
| agent_channel_status_integrationType_not_null | n | NOT NULL "integrationType" |
| agent_channel_status_status_not_null | n | NOT NULL status |
| agent_channel_status_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a7c67724df9ef3d12f6da773c1 | CREATE INDEX "IDX_a7c67724df9ef3d12f6da773c1" ON public.agent_channel_status USING btree ("expiresAt") |
| IDX_c75ec632fe0b5b1905edb9cd7f | CREATE INDEX "IDX_c75ec632fe0b5b1905edb9cd7f" ON public.agent_channel_status USING btree ("hostId") |
| PK_4e1ca943734d575679a56f4da90 | CREATE UNIQUE INDEX "PK_4e1ca943734d575679a56f4da90" ON public.agent_channel_status USING btree ("agentId", "integrationType", "credentialId", "hostId") |

## Relations

```mermaid
erDiagram

"public.agent_channel_status" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_channel_status" {
  varchar_36_ agentId FK
  integer attempts
  timestamp_3__with_time_zone backoffUntil
  timestamp_3__with_time_zone createdAt
  varchar_36_ credentialId
  text errorMessage
  timestamp_3__with_time_zone expiresAt
  varchar_128_ hostId
  varchar_64_ integrationType
  varchar_16_ status
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Chat Attachments (`docs/generated/postgres-schema/public.agent_chat_attachments.md`)

# public.agent_chat_attachments

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | true |  | [public.agents](public.agents.md) | Agent the attachment was sent to, when persisted (null for inline agents) |
| binaryDataId | text |  | false |  |  | Opaque BinaryDataService reference (mode-prefixed, e.g. "filesystem-v2:\<uuid\>"); not an FK to binary_data, which only has rows in DB storage mode |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| fileName | varchar(255) |  | false |  |  |  |
| fileSizeBytes | integer |  | false |  |  | Uploaded file size in bytes |
| id | varchar(16) |  | false |  |  | Application-generated n8n nano ID |
| mimeType | varchar(255) |  | false |  |  |  |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) | Project owning the conversation; authorization scope for downloads |
| resourceId | varchar(255) |  | true |  |  | Per-user scope within the thread (platform user), when known |
| source | varchar(32) |  | false |  |  | Surface the file arrived from, e.g. "chat", "slack", "telegram" |
| threadId | varchar(128) |  | false |  |  | Conversation thread the file belongs to |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_41c246c30af3d2108d93e15dd5e | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_5c048535b2132b40dfed2e640e5 | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_9c1250f77b41d1a0e71a3f1414a | PRIMARY KEY | PRIMARY KEY (id) |
| agent_chat_attachments_binaryDataId_not_null | n | NOT NULL "binaryDataId" |
| agent_chat_attachments_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_chat_attachments_fileName_not_null | n | NOT NULL "fileName" |
| agent_chat_attachments_fileSizeBytes_not_null | n | NOT NULL "fileSizeBytes" |
| agent_chat_attachments_id_not_null | n | NOT NULL id |
| agent_chat_attachments_mimeType_not_null | n | NOT NULL "mimeType" |
| agent_chat_attachments_projectId_not_null | n | NOT NULL "projectId" |
| agent_chat_attachments_source_not_null | n | NOT NULL source |
| agent_chat_attachments_threadId_not_null | n | NOT NULL "threadId" |
| agent_chat_attachments_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_6806b43c8a0d11460f0c2552eb | CREATE INDEX "IDX_6806b43c8a0d11460f0c2552eb" ON public.agent_chat_attachments USING btree ("projectId", "threadId") |
| IDX_7e9556f25f995653997be3322b | CREATE INDEX "IDX_7e9556f25f995653997be3322b" ON public.agent_chat_attachments USING btree ("agentId", "threadId") |
| PK_9c1250f77b41d1a0e71a3f1414a | CREATE UNIQUE INDEX "PK_9c1250f77b41d1a0e71a3f1414a" ON public.agent_chat_attachments USING btree (id) |

## Relations

```mermaid
erDiagram

"public.agent_chat_attachments" }o--o| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agent_chat_attachments" }o--|| "public.project" : "FOREIGN KEY (#quot;projectId#quot;) REFERENCES project(id) ON DELETE CASCADE"

"public.agent_chat_attachments" {
  varchar_36_ agentId FK
  text binaryDataId
  timestamp_3__with_time_zone createdAt
  varchar_255_ fileName
  integer fileSizeBytes
  varchar_16_ id
  varchar_255_ mimeType
  varchar_36_ projectId FK
  varchar_255_ resourceId
  varchar_32_ source
  varchar_128_ threadId
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.project" {
  timestamp_3__with_time_zone createdAt
  uuid creatorId FK
  json customTelemetryTags
  varchar_512_ description
  json icon
  varchar_36_ id
  varchar_255_ name
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Chat Subscriptions (`docs/generated/postgres-schema/public.agent_chat_subscriptions.md`)

# public.agent_chat_subscriptions

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this subscription |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(255) |  | false |  |  | Credential connection that owns this subscription |
| integrationType | varchar(64) |  | false |  |  | Chat integration platform for this subscription |
| threadId | varchar(255) |  | false |  |  | Platform thread ID the agent is subscribed to |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_chat_subscriptions_integrationType | CHECK | CHECK ((("integrationType")::text = ANY ((ARRAY['telegram'::character varying, 'slack'::character varying, 'linear'::character varying, 'discord'::character varying, 'teams'::character varying, 'whatsapp'::character varying])::text[]))) |
| FK_e79153bd179c011e779d5016796 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_76598cf91038bee1f3ac94c94bc | PRIMARY KEY | PRIMARY KEY ("agentId", "integrationType", "credentialId", "threadId") |
| agent_chat_subscriptions_agentId_not_null | n | NOT NULL "agentId" |
| agent_chat_subscriptions_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_chat_subscriptions_credentialId_not_null | n | NOT NULL "credentialId" |
| agent_chat_subscriptions_integrationType_not_null | n | NOT NULL "integrationType" |
| agent_chat_subscriptions_threadId_not_null | n | NOT NULL "threadId" |
| agent_chat_subscriptions_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_76598cf91038bee1f3ac94c94bc | CREATE UNIQUE INDEX "PK_76598cf91038bee1f3ac94c94bc" ON public.agent_chat_subscriptions USING btree ("agentId", "integrationType", "credentialId", "threadId") |

## Relations

```mermaid
erDiagram

"public.agent_chat_subscriptions" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_chat_subscriptions" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  varchar_255_ credentialId
  varchar_64_ integrationType
  varchar_255_ threadId
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Checkpoints (`docs/generated/postgres-schema/public.agent_checkpoints.md`)

# public.agent_checkpoints

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(255) |  | true |  | [public.agents](public.agents.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| expired | boolean | false | false |  |  |  |
| runId | varchar(255) |  | false |  |  |  |
| state | text |  | true |  |  |  |
| threadId | text |  | true |  |  | SDK thread key from checkpoint state. Execution history is optional. |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_5e31c210f896d539964bf99fe32 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_50a27cbafa6806c9b162304b5fd | PRIMARY KEY | PRIMARY KEY ("runId") |
| agent_checkpoints_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_checkpoints_expired_not_null | n | NOT NULL expired |
| agent_checkpoints_runId_not_null | n | NOT NULL "runId" |
| agent_checkpoints_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_5e31c210f896d539964bf99fe3 | CREATE INDEX "IDX_5e31c210f896d539964bf99fe3" ON public.agent_checkpoints USING btree ("agentId") |
| IDX_agent_checkpoints_thread | CREATE INDEX "IDX_agent_checkpoints_thread" ON public.agent_checkpoints USING btree ("agentId", "threadId", expired, "updatedAt") |
| IDX_agent_checkpoints_threadId | CREATE INDEX "IDX_agent_checkpoints_threadId" ON public.agent_checkpoints USING btree ("threadId") |
| PK_50a27cbafa6806c9b162304b5fd | CREATE UNIQUE INDEX "PK_50a27cbafa6806c9b162304b5fd" ON public.agent_checkpoints USING btree ("runId") |

## Relations

```mermaid
erDiagram

"public.agent_checkpoints" }o--o| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_checkpoints" {
  varchar_255_ agentId FK
  timestamp_3__with_time_zone createdAt
  boolean expired
  varchar_255_ runId
  text state
  text threadId
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Credential Dependency (`docs/generated/postgres-schema/public.agent_credential_dependency.md`)

# public.agent_credential_dependency

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | false |  | [public.credentials_entity](public.credentials_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_6a6948884969cb4204a1975578b | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_fec7ee37062350d6a4a2979327d | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE CASCADE |
| PK_546f5d9cfaf5ea78efcc6f5d0a2 | PRIMARY KEY | PRIMARY KEY ("agentId", "credentialId") |
| agent_credential_dependency_agentId_not_null | n | NOT NULL "agentId" |
| agent_credential_dependency_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_credential_dependency_credentialId_not_null | n | NOT NULL "credentialId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_fec7ee37062350d6a4a2979327 | CREATE INDEX "IDX_fec7ee37062350d6a4a2979327" ON public.agent_credential_dependency USING btree ("credentialId") |
| PK_546f5d9cfaf5ea78efcc6f5d0a2 | CREATE UNIQUE INDEX "PK_546f5d9cfaf5ea78efcc6f5d0a2" ON public.agent_credential_dependency USING btree ("agentId", "credentialId") |

## Relations

```mermaid
erDiagram

"public.agent_credential_dependency" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agent_credential_dependency" }o--|| "public.credentials_entity" : "FOREIGN KEY (#quot;credentialId#quot;) REFERENCES credentials_entity(id) ON DELETE CASCADE"

"public.agent_credential_dependency" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  varchar_36_ credentialId FK
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.credentials_entity" {
  timestamp_3__with_time_zone createdAt
  text data
  text description
  varchar_36_ id
  boolean isGlobal
  boolean isManaged
  boolean isResolvable
  varchar_128_ name
  timestamp_3__with_time_zone pendingAuthorizationExpiresAt
  boolean resolvableAllowFallback
  varchar_16_ resolverId FK
  varchar_128_ type
  timestamp_3__with_time_zone updatedAt
  varchar_16_ usageScope
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Eval Dataset (`docs/generated/postgres-schema/public.agent_eval_dataset.md`)

# public.agent_eval_dataset

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| columnMapping | json |  | true |  |  | Maps dataset columns onto input / expectedOutput / criteria roles |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| createdById | uuid |  | true |  | [public.user](public.user.md) |  |
| datasetRef | json |  | false |  |  | Pointer into the dataset backend (e.g. { dataTableId }); shape varies by datasetSource |
| datasetSource | varchar(32) |  | false |  |  | Dataset backend the cases are read from |
| description | text |  | true |  |  |  |
| id | varchar(36) |  | false | [public.agent_eval_run](public.agent_eval_run.md) |  |  |
| name | varchar(128) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_eval_dataset_datasetSource | CHECK | CHECK ((("datasetSource")::text = ANY ((ARRAY['data_table'::character varying, 'google_sheets'::character varying])::text[]))) |
| FK_9d3a6fd750f7746de453cf4d5ed | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_eda9e5fa5558d3f16bc2f6c21b6 | FOREIGN KEY | FOREIGN KEY ("createdById") REFERENCES "user"(id) ON DELETE SET NULL |
| PK_ac887efbb3580a577f1442cfa89 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_eval_dataset_agentId_not_null | n | NOT NULL "agentId" |
| agent_eval_dataset_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_eval_dataset_datasetRef_not_null | n | NOT NULL "datasetRef" |
| agent_eval_dataset_datasetSource_not_null | n | NOT NULL "datasetSource" |
| agent_eval_dataset_id_not_null | n | NOT NULL id |
| agent_eval_dataset_name_not_null | n | NOT NULL name |
| agent_eval_dataset_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_9d3a6fd750f7746de453cf4d5e | CREATE INDEX "IDX_9d3a6fd750f7746de453cf4d5e" ON public.agent_eval_dataset USING btree ("agentId") |
| PK_ac887efbb3580a577f1442cfa89 | CREATE UNIQUE INDEX "PK_ac887efbb3580a577f1442cfa89" ON public.agent_eval_dataset USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Eval Rating (`docs/generated/postgres-schema/public.agent_eval_rating.md`)

# public.agent_eval_rating

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| comment | text |  | true |  |  |  |
| correction | json |  | true |  |  | Optional corrected/edited output supplied by the rater |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| ratedById | uuid |  | true |  | [public.user](public.user.md) |  |
| resultId | varchar(36) |  | false |  | [public.agent_eval_result](public.agent_eval_result.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| vote | varchar(8) |  | false |  |  | Human feedback direction |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_eval_rating_vote | CHECK | CHECK (((vote)::text = ANY ((ARRAY['up'::character varying, 'down'::character varying])::text[]))) |
| FK_9cadae6591c64498f1b58a2cef3 | FOREIGN KEY | FOREIGN KEY ("resultId") REFERENCES agent_eval_result(id) ON DELETE CASCADE |
| FK_e06a7408573a3e152e673977d2c | FOREIGN KEY | FOREIGN KEY ("ratedById") REFERENCES "user"(id) ON DELETE SET NULL |
| PK_04b7709a435e0c07520ceb37393 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_eval_rating_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_eval_rating_id_not_null | n | NOT NULL id |
| agent_eval_rating_resultId_not_null | n | NOT NULL "resultId" |
| agent_eval_rating_updatedAt_not_null | n | NOT NULL "updatedAt" |
| agent_eval_rating_vote_not_null | n | NOT NULL vote |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_9cadae6591c64498f1b58a2cef | CREATE INDEX "IDX_9cadae6591c64498f1b58a2cef" ON public.agent_eval_rating USING btree ("resultId") |
| PK_04b7709a435e0c07520ceb37393 | CREATE UNIQUE INDEX "PK_04b7709a435e0c07520ceb37393" ON public.agent_eval_rating USING btree (id) |

## Relations

```mermaid
erDiagram

"public.agent_eval_rating" }o--o| "public.user" : "FOREIGN KEY (#quot;ratedById#quot;) REFERENCES #quot;user#quot;(id) ON DELETE SET NULL"
"public.agent_eval_rating" }o--|| "public.agent_eval_result" : "FOREIGN KEY (#quot;resultId#quot;) REFERENCES agent_eval_result(id) ON DELETE CASCADE"

"public.agent_eval_rating" {
  text comment
  json correction
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  uuid ratedById FK
  varchar_36_ resultId FK
  timestamp_3__with_time_zone updatedAt
  varchar_8_ vote
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
"public.agent_eval_result" {
  timestamp_3__with_time_zone completedAt
  timestamp_3__with_time_zone createdAt
  varchar_255_ errorCode
  json errorDetails
  varchar_36_ id
  json input
  json metrics
  json output
  timestamp_3__with_time_zone runAt
  varchar_36_ runId FK
  integer runIndex
  varchar_255_ sourceRowId
  varchar status
  json toolCalls
  timestamp_3__with_time_zone updatedAt
  json verdict
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Eval Result (`docs/generated/postgres-schema/public.agent_eval_result.md`)

# public.agent_eval_result

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| completedAt | timestamp(3) with time zone |  | true |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| errorCode | varchar(255) |  | true |  |  |  |
| errorDetails | json |  | true |  |  |  |
| id | varchar(36) |  | false | [public.agent_eval_rating](public.agent_eval_rating.md) |  |  |
| input | json |  | true |  |  | Snapshot of the case input actually run (row may later change) |
| metrics | json |  | true |  |  | Per-case judge scores |
| output | json |  | true |  |  | Agent output for this case |
| runAt | timestamp(3) with time zone |  | true |  |  |  |
| runId | varchar(36) |  | false |  | [public.agent_eval_run](public.agent_eval_run.md) |  |
| runIndex | integer |  | true |  |  | Order of this case within the run |
| sourceRowId | varchar(255) |  | true |  |  | Origin dataset row id; loose pointer, rows are external and mutable |
| status | varchar |  | false |  |  | Per-case lifecycle |
| toolCalls | json |  | true |  |  | Tool-call timeline captured during the run |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| verdict | json |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_eval_result_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['new'::character varying, 'running'::character varying, 'success'::character varying, 'error'::character varying, 'cancelled'::character varying])::text[]))) |
| FK_40a2d1248a6d984f442de2fac1b | FOREIGN KEY | FOREIGN KEY ("runId") REFERENCES agent_eval_run(id) ON DELETE CASCADE |
| PK_d40a22dc56dc200313c1f0e41ac | PRIMARY KEY | PRIMARY KEY (id) |
| agent_eval_result_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_eval_result_id_not_null | n | NOT NULL id |
| agent_eval_result_runId_not_null | n | NOT NULL "runId" |
| agent_eval_result_status_not_null | n | NOT NULL status |
| agent_eval_result_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_40a2d1248a6d984f442de2fac1 | CREATE INDEX "IDX_40a2d1248a6d984f442de2fac1" ON public.agent_eval_result USING btree ("runId") |
| PK_d40a22dc56dc200313c1f0e41ac | CREATE UNIQUE INDEX "PK_d40a22dc56dc200313c1f0e41ac" ON public.agent_eval_result USING btree (id) |

## Relations

```mermaid
erDiagram

"public.agent_eval_rating" }o--|| "public.agent_eval_result" : "FOREIGN KEY (#quot;resultId#quot;) REFERENCES agent_eval_result(id) ON DELETE CASCADE"
"public.agent_eval_result" }o--|| "public.agent_eval_run" : "FOREIGN KEY (#quot;runId#quot;) REFERENCES agent_eval_run(id) ON DELETE CASCADE"

"public.agent_eval_result" {
  timestamp_3__with_time_zone completedAt
  timestamp_3__with_time_zone createdAt
  varchar_255_ errorCode
  json errorDetails
  varchar_36_ id
  json input
  json metrics
  json output
  timestamp_3__with_time_zone runAt
  varchar_36_ runId FK
  integer runIndex
  varchar_255_ sourceRowId
  varchar status
  json toolCalls
  timestamp_3__with_time_zone updatedAt
  json verdict
}
"public.agent_eval_rating" {
  text comment
  json correction
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  uuid ratedById FK
  varchar_36_ resultId FK
  timestamp_3__with_time_zone updatedAt
  varchar_8_ vote
}
"public.agent_eval_run" {
  varchar_36_ agentVersionId
  boolean cancelRequested
  timestamp_3__with_time_zone completedAt
  timestamp_3__with_time_zone createdAt
  uuid createdById FK
  varchar_36_ datasetId FK
  varchar_255_ errorCode
  json errorDetails
  varchar_36_ id
  json metrics
  timestamp_3__with_time_zone runAt
  varchar_255_ runningInstanceId
  varchar status
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Eval Run (`docs/generated/postgres-schema/public.agent_eval_run.md`)

# public.agent_eval_run

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentVersionId | varchar(36) |  | true |  |  | Published agent version under test (agent_history.versionId); loose pointer, no FK so runs survive history pruning. The agent itself comes from the dataset. |
| cancelRequested | boolean | false | false |  |  | Fallback cancellation flag polled by the running main |
| completedAt | timestamp(3) with time zone |  | true |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| createdById | uuid |  | true |  | [public.user](public.user.md) |  |
| datasetId | varchar(36) |  | false |  | [public.agent_eval_dataset](public.agent_eval_dataset.md) |  |
| errorCode | varchar(255) |  | true |  |  |  |
| errorDetails | json |  | true |  |  |  |
| id | varchar(36) |  | false | [public.agent_eval_result](public.agent_eval_result.md) |  |  |
| metrics | json |  | true |  |  | Aggregated run-level scores |
| runAt | timestamp(3) with time zone |  | true |  |  |  |
| runningInstanceId | varchar(255) |  | true |  |  | Main instance executing this run; used to coordinate cancellation |
| status | varchar |  | false |  |  | Run lifecycle |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_eval_run_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['new'::character varying, 'running'::character varying, 'completed'::character varying, 'error'::character varying, 'cancelled'::character varying])::text[]))) |
| FK_39ca447735d378e365f4227abff | FOREIGN KEY | FOREIGN KEY ("datasetId") REFERENCES agent_eval_dataset(id) ON DELETE CASCADE |
| FK_54ee897f442cc7393a6d6165334 | FOREIGN KEY | FOREIGN KEY ("createdById") REFERENCES "user"(id) ON DELETE SET NULL |
| PK_280832ca3f1b43663cc0e25e77f | PRIMARY KEY | PRIMARY KEY (id) |
| agent_eval_run_cancelRequested_not_null | n | NOT NULL "cancelRequested" |
| agent_eval_run_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_eval_run_datasetId_not_null | n | NOT NULL "datasetId" |
| agent_eval_run_id_not_null | n | NOT NULL id |
| agent_eval_run_status_not_null | n | NOT NULL status |
| agent_eval_run_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_39ca447735d378e365f4227abf | CREATE INDEX "IDX_39ca447735d378e365f4227abf" ON public.agent_eval_run USING btree ("datasetId") |
| PK_280832ca3f1b43663cc0e25e77f | CREATE UNIQUE INDEX "PK_280832ca3f1b43663cc0e25e77f" ON public.agent_eval_run USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Execution (`docs/generated/postgres-schema/public.agent_execution.md`)

# public.agent_execution

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| acceptsSteering | boolean | false | false |  |  | Accept input until the runtime closes admission |
| attachments | json |  | true |  |  | Metadata of files attached to the user turn ({id, fileName, mimeType, sizeBytes}[]); bytes live in BinaryDataService |
| author | json |  | true |  |  | Chat platform user who wrote the turn as {id, name}; null for runs outside chat integrations |
| cacheReadTokens | integer |  | true |  |  | Input tokens read from the provider prompt cache. A subset of promptTokens, not added to it |
| cacheWriteTokens | integer |  | true |  |  | Input tokens written to the provider prompt cache. A subset of promptTokens, not added to it |
| completionTokens | integer |  | true |  |  |  |
| cost | double precision |  | true |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| duration | integer | 0 | false |  |  |  |
| error | text |  | true |  |  |  |
| failureSummary | json |  | true |  |  | Execution failure projection as {count, latest} for session list queries |
| finishReason | varchar(32) |  | true |  |  | Why the run ended, e.g. stop or guardrail. Null for older runs. |
| guardrailCode | varchar(64) |  | true |  |  | Code of the guardrail that stopped the run, e.g. budget.session. |
| hitlStatus | varchar(16) |  | true |  |  |  |
| id | varchar(36) |  | false | [public.agent_background_job](public.agent_background_job.md) [public.agent_execution](public.agent_execution.md) [public.agent_execution_message_links](public.agent_execution_message_links.md) [public.agent_message_queue](public.agent_message_queue.md) |  |  |
| model | varchar(255) |  | true |  |  |  |
| parentExecutionId | varchar(36) |  | true |  | [public.agent_execution](public.agent_execution.md) | Execution of the parent turn that delegated this run. Null for a top-level turn |
| promptTokens | integer |  | true |  |  |  |
| source | varchar(32) |  | true |  |  |  |
| startedAt | timestamp(3) with time zone |  | true |  |  |  |
| status | varchar(16) |  | false |  |  |  |
| stoppedAt | timestamp(3) with time zone |  | true |  |  |  |
| storedAt | varchar(2) | 'db'::character varying | false |  |  |  |
| threadId | varchar(128) |  | false |  | [public.agent_execution_threads](public.agent_execution_threads.md) |  |
| timeline | json |  | true |  |  |  |
| totalTokens | integer |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userMessage | text |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_execution_hitlStatus | CHECK | CHECK ((("hitlStatus")::text = ANY ((ARRAY['suspended'::character varying, 'resumed'::character varying])::text[]))) |
| CHK_agent_execution_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['running'::character varying, 'success'::character varying, 'error'::character varying, 'cancelled'::character varying, 'interrupted'::character varying])::text[]))) |
| CHK_agent_execution_storedAt | CHECK | CHECK ((("storedAt")::text = ANY ((ARRAY['db'::character varying, 'fs'::character varying, 's3'::character varying, 'az'::character varying])::text[]))) |
| FK_add2432fb6034cc18b6af299dce | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agent_execution_threads(id) ON DELETE CASCADE |
| FK_agent_execution_parentExecutionId | FOREIGN KEY | FOREIGN KEY ("parentExecutionId") REFERENCES agent_execution(id) ON DELETE SET NULL |
| PK_ba438acc8532addc12d1ef17049 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_execution_acceptsSteering_not_null | n | NOT NULL "acceptsSteering" |
| agent_execution_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_execution_duration_not_null | n | NOT NULL duration |
| agent_execution_id_not_null | n | NOT NULL id |
| agent_execution_status_not_null | n | NOT NULL status |
| agent_execution_storedAt_not_null | n | NOT NULL "storedAt" |
| agent_execution_threadId_not_null | n | NOT NULL "threadId" |
| agent_execution_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_63d3c3a68b9cebf05f967f0b1c | CREATE INDEX "IDX_63d3c3a68b9cebf05f967f0b1c" ON public.agent_execution USING btree ("threadId", "createdAt") |
| IDX_agent_execution_parentExecutionId | CREATE INDEX "IDX_agent_execution_parentExecutionId" ON public.agent_execution USING btree ("parentExecutionId") |
| IDX_agent_execution_status | CREATE INDEX "IDX_agent_execution_status" ON public.agent_execution USING btree (status) WHERE ((status)::text = 'running'::text) |
| PK_ba438acc8532addc12d1ef17049 | CREATE UNIQUE INDEX "PK_ba438acc8532addc12d1ef17049" ON public.agent_execution USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Execution Message Links (`docs/generated/postgres-schema/public.agent_execution_message_links.md`)

# public.agent_execution_message_links

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| direction | varchar(6) |  | false |  |  | Input consumed by the execution or output written by it |
| executionId | varchar(36) |  | false |  | [public.agent_execution](public.agent_execution.md) | Execution that consumed or wrote the message |
| messageId | varchar(36) |  | false |  | [public.agents_messages](public.agents_messages.md) | Canonical conversation message ID |
| position | integer |  | false |  |  | Input message IDs in consumption order. Steering can add messages to the same execution. |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_execution_message_links_direction | CHECK | CHECK (((direction)::text = ANY ((ARRAY['input'::character varying, 'output'::character varying])::text[]))) |
| FK_be7d0a2fd1360c9fa09baf84f60 | FOREIGN KEY | FOREIGN KEY ("messageId") REFERENCES agents_messages(id) ON DELETE CASCADE |
| FK_e78f470a036d01f9e395d53bb59 | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES agent_execution(id) ON DELETE CASCADE |
| PK_cf07f3f98aad61dbb08fac1cdb9 | PRIMARY KEY | PRIMARY KEY ("executionId", "messageId") |
| agent_execution_message_links_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_execution_message_links_direction_not_null | n | NOT NULL direction |
| agent_execution_message_links_executionId_not_null | n | NOT NULL "executionId" |
| agent_execution_message_links_messageId_not_null | n | NOT NULL "messageId" |
| agent_execution_message_links_position_not_null | n | NOT NULL "position" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_10fe500ee8877351841799369b | CREATE UNIQUE INDEX "IDX_10fe500ee8877351841799369b" ON public.agent_execution_message_links USING btree ("executionId", direction, "position") |
| IDX_be7d0a2fd1360c9fa09baf84f6 | CREATE INDEX "IDX_be7d0a2fd1360c9fa09baf84f6" ON public.agent_execution_message_links USING btree ("messageId") |
| PK_cf07f3f98aad61dbb08fac1cdb9 | CREATE UNIQUE INDEX "PK_cf07f3f98aad61dbb08fac1cdb9" ON public.agent_execution_message_links USING btree ("executionId", "messageId") |

## Relations

```mermaid
erDiagram

"public.agent_execution_message_links" }o--|| "public.agent_execution" : "FOREIGN KEY (#quot;executionId#quot;) REFERENCES agent_execution(id) ON DELETE CASCADE"
"public.agent_execution_message_links" }o--|| "public.agents_messages" : "FOREIGN KEY (#quot;messageId#quot;) REFERENCES agents_messages(id) ON DELETE CASCADE"

"public.agent_execution_message_links" {
  timestamp_3__with_time_zone createdAt
  varchar_6_ direction
  varchar_36_ executionId FK
  varchar_36_ messageId FK
  integer position
}
"public.agent_execution" {
  boolean acceptsSteering
  json attachments
  json author
  integer completionTokens
  double_precision cost
  timestamp_3__with_time_zone createdAt
  integer duration
  text error
  json failureSummary
  varchar_32_ finishReason
  varchar_64_ guardrailCode
  varchar_16_ hitlStatus
  varchar_36_ id
  varchar_255_ model
  integer promptTokens
  varchar_32_ source
  timestamp_3__with_time_zone startedAt
  varchar_16_ status
  timestamp_3__with_time_zone stoppedAt
  varchar_2_ storedAt
  varchar_128_ threadId FK
  json timeline
  integer totalTokens
  timestamp_3__with_time_zone updatedAt
  text userMessage
}
"public.agents_messages" {
  json author
  json content
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json modelContent
  timestamp_3__with_time_zone modelContextAt
  json origin
  varchar_255_ resourceId
  varchar_36_ role
  varchar_255_ threadId FK
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Execution Threads (`docs/generated/postgres-schema/public.agent_execution_threads.md`)

# public.agent_execution_threads

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| accessScope | varchar(16) | 'user'::character varying | false |  |  | user: private session; project: shared integration, workflow, or task session |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| agentName | varchar(255) |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| emoji | varchar(8) |  | true |  |  |  |
| id | varchar(128) |  | false | [public.agent_execution](public.agent_execution.md) [public.agent_message_queue](public.agent_message_queue.md) [public.agent_plan](public.agent_plan.md) [public.agent_thread_grants](public.agent_thread_grants.md) |  |  |
| ownerId | uuid |  | true |  | [public.user](public.user.md) | User who started this private session |
| parentAgentId | varchar(36) |  | true |  |  | Saved agent id of the parent that delegated this subagent run. |
| parentThreadId | varchar(128) |  | true |  |  | Parent session thread id that delegated this subagent run. |
| projectId | varchar(255) |  | false |  | [public.project](public.project.md) |  |
| sessionNumber | integer | 0 | false |  |  |  |
| taskId | varchar(32) |  | true |  |  | Published task ID that triggered this session; not an FK because published runs can outlive draft task definition rows |
| taskStop | json |  | true |  |  | Latest task stop boundary and unresolved stop errors |
| taskVersionId | varchar(36) |  | true |  | [public.agent_history](public.agent_history.md) | Published agent_history version that supplied the task snapshot |
| title | varchar(255) |  | true |  |  |  |
| totalCompletionTokens | integer | 0 | false |  |  |  |
| totalCost | double precision | 0 | false |  |  |  |
| totalDuration | integer | 0 | false |  |  |  |
| totalPromptTokens | integer | 0 | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_execution_threads_accessScope | CHECK | CHECK ((("accessScope")::text = ANY ((ARRAY['user'::character varying, 'project'::character varying])::text[]))) |
| FK_0468a9dc35597314e641d4722aa | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_0e2f8bf92a7a9c88b89670f701c | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| FK_agent_execution_threads_owner | FOREIGN KEY | FOREIGN KEY ("ownerId") REFERENCES "user"(id) ON DELETE SET NULL |
| FK_f00b52d74fe11838e1fe086deea | FOREIGN KEY | FOREIGN KEY ("taskVersionId") REFERENCES agent_history("versionId") ON DELETE SET NULL |
| PK_22373dbf6ba6929d8ac50093309 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_execution_threads_accessScope_not_null | n | NOT NULL "accessScope" |
| agent_execution_threads_agentId_not_null | n | NOT NULL "agentId" |
| agent_execution_threads_agentName_not_null | n | NOT NULL "agentName" |
| agent_execution_threads_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_execution_threads_id_not_null | n | NOT NULL id |
| agent_execution_threads_projectId_not_null | n | NOT NULL "projectId" |
| agent_execution_threads_sessionNumber_not_null | n | NOT NULL "sessionNumber" |
| agent_execution_threads_totalCompletionTokens_not_null | n | NOT NULL "totalCompletionTokens" |
| agent_execution_threads_totalCost_not_null | n | NOT NULL "totalCost" |
| agent_execution_threads_totalDuration_not_null | n | NOT NULL "totalDuration" |
| agent_execution_threads_totalPromptTokens_not_null | n | NOT NULL "totalPromptTokens" |
| agent_execution_threads_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_0468a9dc35597314e641d4722a | CREATE INDEX "IDX_0468a9dc35597314e641d4722a" ON public.agent_execution_threads USING btree ("agentId") |
| IDX_0e2f8bf92a7a9c88b89670f701 | CREATE INDEX "IDX_0e2f8bf92a7a9c88b89670f701" ON public.agent_execution_threads USING btree ("projectId") |
| IDX_agent_execution_threads_ownerId | CREATE INDEX "IDX_agent_execution_threads_ownerId" ON public.agent_execution_threads USING btree ("ownerId") |
| IDX_agent_execution_threads_taskVersionId | CREATE INDEX "IDX_agent_execution_threads_taskVersionId" ON public.agent_execution_threads USING btree ("taskVersionId") |
| PK_22373dbf6ba6929d8ac50093309 | CREATE UNIQUE INDEX "PK_22373dbf6ba6929d8ac50093309" ON public.agent_execution_threads USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Files (`docs/generated/postgres-schema/public.agent_files.md`)

# public.agent_files

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this uploaded file |
| binaryDataId | text |  | true |  |  | Opaque BinaryDataService reference (mode-prefixed, e.g. "filesystem-v2:\<uuid\>"); not an FK to binary_data, which only has rows in DB storage mode |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| fileName | varchar(255) |  | false |  |  |  |
| fileSizeBytes | integer |  | false |  |  | Uploaded file size in bytes |
| id | varchar(16) |  | false |  |  | Application-generated n8n nano ID |
| mimeType | varchar(255) |  | false |  |  |  |
| storageKey | text |  | false |  |  | Key addressing the bytes within storedAt: a binary_data.fileId for db, a byte-store key otherwise. Not a foreign key |
| storedAt | varchar(2) | 'db'::character varying | false |  |  | Where the file bytes live: 'db' (binary_data table), or a blob-storage backend ('fs', 's3', 'az') |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_files_storedAt | CHECK | CHECK ((("storedAt")::text = ANY ((ARRAY['db'::character varying, 'fs'::character varying, 's3'::character varying, 'az'::character varying])::text[]))) |
| FK_aca4514cb500494b64356c2e164 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_692920e59217af7d124cd95106f | PRIMARY KEY | PRIMARY KEY (id) |
| agent_files_agentId_not_null | n | NOT NULL "agentId" |
| agent_files_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_files_fileName_not_null | n | NOT NULL "fileName" |
| agent_files_fileSizeBytes_not_null | n | NOT NULL "fileSizeBytes" |
| agent_files_id_not_null | n | NOT NULL id |
| agent_files_mimeType_not_null | n | NOT NULL "mimeType" |
| agent_files_storageKey_not_null | n | NOT NULL "storageKey" |
| agent_files_storedAt_not_null | n | NOT NULL "storedAt" |
| agent_files_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_45dafc48fe2ce95eac30fc8ffd | CREATE INDEX "IDX_45dafc48fe2ce95eac30fc8ffd" ON public.agent_files USING btree ("agentId", "createdAt") |
| IDX_agent_files_agentId_binaryDataId | CREATE UNIQUE INDEX "IDX_agent_files_agentId_binaryDataId" ON public.agent_files USING btree ("agentId", "binaryDataId") |
| IDX_agent_files_agentId_fileName | CREATE UNIQUE INDEX "IDX_agent_files_agentId_fileName" ON public.agent_files USING btree ("agentId", "fileName") |
| PK_692920e59217af7d124cd95106f | CREATE UNIQUE INDEX "PK_692920e59217af7d124cd95106f" ON public.agent_files USING btree (id) |

## Relations

```mermaid
erDiagram

"public.agent_files" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_files" {
  varchar_36_ agentId FK
  text binaryDataId
  timestamp_3__with_time_zone createdAt
  varchar_255_ fileName
  integer fileSizeBytes
  varchar_16_ id
  varchar_255_ mimeType
  text storageKey
  varchar_2_ storedAt
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent History (`docs/generated/postgres-schema/public.agent_history.md`)

# public.agent_history

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| author | varchar(255) |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| publishedById | uuid |  | true |  | [public.user](public.user.md) |  |
| schema | json |  | true |  |  | Frozen snapshot of the published AgentJsonConfig |
| skills | json |  | true |  |  | Frozen map of `skillId → AgentSkill` at publish time |
| tools | json |  | true |  |  | Frozen map of `toolId → { code, descriptor }` at publish time |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| versionId | varchar(36) |  | false | [public.agent_execution_threads](public.agent_execution_threads.md) [public.agent_task_snapshot](public.agent_task_snapshot.md) [public.agent_version_skill_dependency](public.agent_version_skill_dependency.md) [public.agents](public.agents.md) |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_8771675f44c58fb40e0feb9ee35 | FOREIGN KEY | FOREIGN KEY ("publishedById") REFERENCES "user"(id) ON DELETE SET NULL |
| FK_87cd5a8da20304b089ea2f83fec | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_65ffcfe7a8e112fb826311fb092 | PRIMARY KEY | PRIMARY KEY ("versionId") |
| agent_history_agentId_not_null | n | NOT NULL "agentId" |
| agent_history_author_not_null | n | NOT NULL author |
| agent_history_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_history_updatedAt_not_null | n | NOT NULL "updatedAt" |
| agent_history_versionId_not_null | n | NOT NULL "versionId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_87cd5a8da20304b089ea2f83fe | CREATE INDEX "IDX_87cd5a8da20304b089ea2f83fe" ON public.agent_history USING btree ("agentId") |
| PK_65ffcfe7a8e112fb826311fb092 | CREATE UNIQUE INDEX "PK_65ffcfe7a8e112fb826311fb092" ON public.agent_history USING btree ("versionId") |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Message Queue (`docs/generated/postgres-schema/public.agent_message_queue.md`)

# public.agent_message_queue

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| executionId | varchar(36) |  | true |  | [public.agent_execution](public.agent_execution.md) | Current execution; NULL means pending |
| id | bigint |  | false |  |  | Acceptance order; IDs are not reused |
| messageId | varchar(36) |  | false |  | [public.agents_messages](public.agents_messages.md) | Canonical input created when the queue accepts it |
| payload | json |  | false |  |  | Dispatch, authorization, and reply context. Input is stored on the message |
| position | integer | 0 | false |  |  | Pending turn order within the session |
| steeringExecutionId | varchar(36) |  | true |  | [public.agent_execution](public.agent_execution.md) | Execution reserved to consume this input |
| steeringOrder | integer |  | true |  |  | Acceptance order among outstanding steers |
| threadId | varchar(128) |  | false |  | [public.agent_execution_threads](public.agent_execution_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_message_queue_steering_pair | CHECK | CHECK ((("steeringExecutionId" IS NULL) = ("steeringOrder" IS NULL))) |
| FK_2349d84b4f2a660fc264f38fef3 | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES agent_execution(id) |
| FK_a74f9154a59430986112d70cb16 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agent_execution_threads(id) ON DELETE CASCADE |
| FK_agent_message_queue_messageId | FOREIGN KEY | FOREIGN KEY ("messageId") REFERENCES agents_messages(id) ON DELETE CASCADE |
| FK_eff54787927c2968dc24495c911 | FOREIGN KEY | FOREIGN KEY ("steeringExecutionId") REFERENCES agent_execution(id) |
| PK_733d8c959a6057f04f4da5ab721 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_message_queue_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_message_queue_id_not_null | n | NOT NULL id |
| agent_message_queue_messageId_not_null | n | NOT NULL "messageId" |
| agent_message_queue_payload_not_null | n | NOT NULL payload |
| agent_message_queue_position_not_null | n | NOT NULL "position" |
| agent_message_queue_threadId_not_null | n | NOT NULL "threadId" |
| agent_message_queue_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_2349d84b4f2a660fc264f38fef | CREATE INDEX "IDX_2349d84b4f2a660fc264f38fef" ON public.agent_message_queue USING btree ("executionId") |
| IDX_agent_message_queue_messageId | CREATE UNIQUE INDEX "IDX_agent_message_queue_messageId" ON public.agent_message_queue USING btree ("messageId") |
| IDX_agent_message_queue_steeringExecutionId_steeringOrder | CREATE UNIQUE INDEX "IDX_agent_message_queue_steeringExecutionId_steeringOrder" ON public.agent_message_queue USING btree ("steeringExecutionId", "steeringOrder") WHERE ("steeringExecutionId" IS NOT NULL) |
| IDX_agent_message_queue_threadId | CREATE UNIQUE INDEX "IDX_agent_message_queue_threadId" ON public.agent_message_queue USING btree ("threadId") WHERE ("executionId" IS NOT NULL) |
| IDX_agent_message_queue_threadId_position | CREATE INDEX "IDX_agent_message_queue_threadId_position" ON public.agent_message_queue USING btree ("threadId", "position") |
| PK_733d8c959a6057f04f4da5ab721 | CREATE UNIQUE INDEX "PK_733d8c959a6057f04f4da5ab721" ON public.agent_message_queue USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Plan (`docs/generated/postgres-schema/public.agent_plan.md`)

# public.agent_plan

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| closedAt | timestamp(3) with time zone |  | true |  |  | NULL while the plan is active |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| data | json |  | false |  |  | Opaque plan document |
| formatVersion | integer |  | false |  |  | Version of the plan JSON format |
| id | uuid |  | false | [public.agent_background_job](public.agent_background_job.md) [public.agent_plan_history](public.agent_plan_history.md) |  | Plan ID generated by the caller |
| revision | integer | 1 | false |  |  | Current document revision |
| threadId | varchar(128) |  | false |  | [public.agent_execution_threads](public.agent_execution_threads.md) | Session that owns the plan |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_plan_format_version | CHECK | CHECK (("formatVersion" > 0)) |
| CHK_agent_plan_revision | CHECK | CHECK ((revision > 0)) |
| FK_a72ec0a4fc0c1d6aa1d7a177e32 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agent_execution_threads(id) ON DELETE CASCADE |
| PK_c2b705709b763e796e29b1f6282 | PRIMARY KEY | PRIMARY KEY (id) |
| agent_plan_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_plan_data_not_null | n | NOT NULL data |
| agent_plan_formatVersion_not_null | n | NOT NULL "formatVersion" |
| agent_plan_id_not_null | n | NOT NULL id |
| agent_plan_revision_not_null | n | NOT NULL revision |
| agent_plan_threadId_not_null | n | NOT NULL "threadId" |
| agent_plan_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a72ec0a4fc0c1d6aa1d7a177e3 | CREATE INDEX "IDX_a72ec0a4fc0c1d6aa1d7a177e3" ON public.agent_plan USING btree ("threadId") |
| IDX_agent_plan_threadId | CREATE UNIQUE INDEX "IDX_agent_plan_threadId" ON public.agent_plan USING btree ("threadId") WHERE ("closedAt" IS NULL) |
| PK_c2b705709b763e796e29b1f6282 | CREATE UNIQUE INDEX "PK_c2b705709b763e796e29b1f6282" ON public.agent_plan USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Plan History (`docs/generated/postgres-schema/public.agent_plan_history.md`)

# public.agent_plan_history

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| closedAt | timestamp(3) with time zone |  | true |  |  | Plan closure time at this revision |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| data | json |  | false |  |  | Complete plan document after this change |
| formatVersion | integer |  | false |  |  | Version of the snapshot JSON format |
| planId | uuid |  | false |  | [public.agent_plan](public.agent_plan.md) | Plan that owns this snapshot |
| revision | integer |  | false |  |  | Document revision captured by this snapshot |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agent_plan_history_format_version | CHECK | CHECK (("formatVersion" > 0)) |
| CHK_agent_plan_history_revision | CHECK | CHECK ((revision > 0)) |
| FK_ff6ebe6c2b329aba472095b4a5d | FOREIGN KEY | FOREIGN KEY ("planId") REFERENCES agent_plan(id) ON DELETE CASCADE |
| PK_a643cfc7a42df9e579ab05a7950 | PRIMARY KEY | PRIMARY KEY ("planId", revision) |
| agent_plan_history_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_plan_history_data_not_null | n | NOT NULL data |
| agent_plan_history_formatVersion_not_null | n | NOT NULL "formatVersion" |
| agent_plan_history_planId_not_null | n | NOT NULL "planId" |
| agent_plan_history_revision_not_null | n | NOT NULL revision |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_a643cfc7a42df9e579ab05a7950 | CREATE UNIQUE INDEX "PK_a643cfc7a42df9e579ab05a7950" ON public.agent_plan_history USING btree ("planId", revision) |

## Relations

```mermaid
erDiagram

"public.agent_plan_history" }o--|| "public.agent_plan" : "FOREIGN KEY (#quot;planId#quot;) REFERENCES agent_plan(id) ON DELETE CASCADE"

"public.agent_plan_history" {
  timestamp_3__with_time_zone closedAt
  timestamp_3__with_time_zone createdAt
  json data
  integer formatVersion
  uuid planId FK
  integer revision
}
"public.agent_plan" {
  timestamp_3__with_time_zone closedAt
  timestamp_3__with_time_zone createdAt
  json data
  integer formatVersion
  uuid id
  integer revision
  varchar_128_ threadId FK
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Skill Dependency (`docs/generated/postgres-schema/public.agent_skill_dependency.md`)

# public.agent_skill_dependency

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| skillId | varchar(36) |  | false |  | [public.skill](public.skill.md) |  |
| skillVersionId | uuid |  | true |  | [public.skill_version](public.skill_version.md) | Set when the agent draft pins a saved version. NULL = follows the latest saved version |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_068f21aefba31ae621482f396dc | FOREIGN KEY | FOREIGN KEY ("skillId") REFERENCES skill(id) ON DELETE CASCADE |
| FK_72325bb13511a51847c53fcb377 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_7676571bd6f41d9e32f0d066fe9 | FOREIGN KEY | FOREIGN KEY ("skillVersionId") REFERENCES skill_version(id) |
| PK_18a54f60491d3e2aa2200b70f4a | PRIMARY KEY | PRIMARY KEY ("agentId", "skillId") |
| agent_skill_dependency_agentId_not_null | n | NOT NULL "agentId" |
| agent_skill_dependency_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_skill_dependency_skillId_not_null | n | NOT NULL "skillId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_068f21aefba31ae621482f396d | CREATE INDEX "IDX_068f21aefba31ae621482f396d" ON public.agent_skill_dependency USING btree ("skillId") |
| PK_18a54f60491d3e2aa2200b70f4a | CREATE UNIQUE INDEX "PK_18a54f60491d3e2aa2200b70f4a" ON public.agent_skill_dependency USING btree ("agentId", "skillId") |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Task Definition (`docs/generated/postgres-schema/public.agent_task_definition.md`)

# public.agent_task_definition

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Owning agent; task definitions are deleted when the agent is deleted |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| cronExpression | varchar(128) |  | false |  |  | Cron schedule evaluated using the instance timezone |
| id | varchar(32) |  | false |  |  | Application-generated task ID referenced from agent JSON config |
| name | varchar(128) |  | false |  |  |  |
| objective | text |  | false |  |  | User-authored instruction sent to the agent when this task runs |
| timezone | varchar(64) |  | true |  |  | IANA timezone the cron is evaluated in; null falls back to the instance timezone |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_f45d0535a2ed59b6c2dd6da98a0 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_1756c11c637903e97629a7a784a | PRIMARY KEY | PRIMARY KEY (id) |
| agent_task_definition_agentId_not_null | n | NOT NULL "agentId" |
| agent_task_definition_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_task_definition_cronExpression_not_null | n | NOT NULL "cronExpression" |
| agent_task_definition_id_not_null | n | NOT NULL id |
| agent_task_definition_name_not_null | n | NOT NULL name |
| agent_task_definition_objective_not_null | n | NOT NULL objective |
| agent_task_definition_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_f45d0535a2ed59b6c2dd6da98a | CREATE INDEX "IDX_f45d0535a2ed59b6c2dd6da98a" ON public.agent_task_definition USING btree ("agentId") |
| PK_1756c11c637903e97629a7a784a | CREATE UNIQUE INDEX "PK_1756c11c637903e97629a7a784a" ON public.agent_task_definition USING btree (id) |

## Relations

```mermaid
erDiagram

"public.agent_task_definition" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_task_definition" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  varchar_128_ cronExpression
  varchar_32_ id
  varchar_128_ name
  text objective
  varchar_64_ timezone
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Task Run Lock (`docs/generated/postgres-schema/public.agent_task_run_lock.md`)

# public.agent_task_run_lock

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Published agent whose scheduled task run is locked |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| heldUntil | timestamp(3) with time zone |  | false |  |  | Time after which another main can claim this task run lock |
| holderId | uuid |  | false |  |  | Ephemeral lock owner token generated by the running main |
| taskId | varchar(32) |  | false |  |  | Published task ID whose scheduled run is locked |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_b57a2862ae869aab24e54cefd48 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_f593adaf7230e964d3c25deda64 | PRIMARY KEY | PRIMARY KEY ("agentId", "taskId") |
| agent_task_run_lock_agentId_not_null | n | NOT NULL "agentId" |
| agent_task_run_lock_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_task_run_lock_heldUntil_not_null | n | NOT NULL "heldUntil" |
| agent_task_run_lock_holderId_not_null | n | NOT NULL "holderId" |
| agent_task_run_lock_taskId_not_null | n | NOT NULL "taskId" |
| agent_task_run_lock_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_f593adaf7230e964d3c25deda64 | CREATE UNIQUE INDEX "PK_f593adaf7230e964d3c25deda64" ON public.agent_task_run_lock USING btree ("agentId", "taskId") |

## Relations

```mermaid
erDiagram

"public.agent_task_run_lock" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"

"public.agent_task_run_lock" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone heldUntil
  uuid holderId
  varchar_32_ taskId
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Task Snapshot (`docs/generated/postgres-schema/public.agent_task_snapshot.md`)

# public.agent_task_snapshot

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| cronExpression | varchar(128) |  | false |  |  | Cron schedule evaluated using the instance timezone |
| enabled | boolean |  | false |  |  | Published enabled state for this task at publish time |
| name | varchar(128) |  | false |  |  |  |
| objective | text |  | false |  |  | User-authored instruction sent to the agent when this task runs |
| taskId | varchar(32) |  | false |  |  | Stable task ID referenced from the published agent JSON config |
| timezone | varchar(64) |  | true |  |  | IANA timezone the cron is evaluated in; null falls back to the instance timezone |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| versionId | varchar(36) |  | false |  | [public.agent_history](public.agent_history.md) | Published agent_history version this task snapshot belongs to |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1acedce6690392ef1611cca8b88 | FOREIGN KEY | FOREIGN KEY ("versionId") REFERENCES agent_history("versionId") ON DELETE CASCADE |
| PK_2142a8bcda2360c3c5e34f82640 | PRIMARY KEY | PRIMARY KEY ("versionId", "taskId") |
| agent_task_snapshot_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_task_snapshot_cronExpression_not_null | n | NOT NULL "cronExpression" |
| agent_task_snapshot_enabled_not_null | n | NOT NULL enabled |
| agent_task_snapshot_name_not_null | n | NOT NULL name |
| agent_task_snapshot_objective_not_null | n | NOT NULL objective |
| agent_task_snapshot_taskId_not_null | n | NOT NULL "taskId" |
| agent_task_snapshot_updatedAt_not_null | n | NOT NULL "updatedAt" |
| agent_task_snapshot_versionId_not_null | n | NOT NULL "versionId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_2142a8bcda2360c3c5e34f82640 | CREATE UNIQUE INDEX "PK_2142a8bcda2360c3c5e34f82640" ON public.agent_task_snapshot USING btree ("versionId", "taskId") |

## Relations

```mermaid
erDiagram

"public.agent_task_snapshot" }o--|| "public.agent_history" : "FOREIGN KEY (#quot;versionId#quot;) REFERENCES agent_history(#quot;versionId#quot;) ON DELETE CASCADE"

"public.agent_task_snapshot" {
  timestamp_3__with_time_zone createdAt
  varchar_128_ cronExpression
  boolean enabled
  varchar_128_ name
  text objective
  varchar_32_ taskId
  varchar_64_ timezone
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId FK
}
"public.agent_history" {
  varchar_36_ agentId FK
  varchar_255_ author
  timestamp_3__with_time_zone createdAt
  uuid publishedById FK
  json schema
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Thread Grants (`docs/generated/postgres-schema/public.agent_thread_grants.md`)

# public.agent_thread_grants

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| grantKey | varchar(512) |  | false |  |  | JSON tuple: [tool, toolName] or [integration_action, connectionId, action] |
| threadId | varchar(128) |  | false |  | [public.agent_execution_threads](public.agent_execution_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_10aad4b5b51d34aae8da90fd5cb | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agent_execution_threads(id) ON DELETE CASCADE |
| PK_18777b98ed446901dd7453424ce | PRIMARY KEY | PRIMARY KEY ("threadId", "grantKey") |
| agent_thread_grants_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_thread_grants_grantKey_not_null | n | NOT NULL "grantKey" |
| agent_thread_grants_threadId_not_null | n | NOT NULL "threadId" |
| agent_thread_grants_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_18777b98ed446901dd7453424ce | CREATE UNIQUE INDEX "PK_18777b98ed446901dd7453424ce" ON public.agent_thread_grants USING btree ("threadId", "grantKey") |

## Relations

```mermaid
erDiagram

"public.agent_thread_grants" }o--|| "public.agent_execution_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES agent_execution_threads(id) ON DELETE CASCADE"

"public.agent_thread_grants" {
  timestamp_3__with_time_zone createdAt
  varchar_512_ grantKey
  varchar_128_ threadId FK
  timestamp_3__with_time_zone updatedAt
}
"public.agent_execution_threads" {
  varchar_16_ accessScope
  varchar_36_ agentId FK
  varchar_255_ agentName
  timestamp_3__with_time_zone createdAt
  varchar_8_ emoji
  varchar_128_ id
  uuid ownerId FK
  varchar_36_ parentAgentId
  varchar_128_ parentThreadId
  varchar_255_ projectId FK
  integer sessionNumber
  varchar_32_ taskId
  json taskStop
  varchar_36_ taskVersionId FK
  varchar_255_ title
  integer totalCompletionTokens
  double_precision totalCost
  integer totalDuration
  integer totalPromptTokens
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Version Skill Dependency (`docs/generated/postgres-schema/public.agent_version_skill_dependency.md`)

# public.agent_version_skill_dependency

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentVersionId | varchar(36) |  | false |  | [public.agent_history](public.agent_history.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| skillId | varchar(36) |  | false |  | [public.skill](public.skill.md) |  |
| skillVersionId | uuid |  | false |  | [public.skill_version](public.skill_version.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_97472baf9196d914d9cd9de6201 | FOREIGN KEY | FOREIGN KEY ("agentVersionId") REFERENCES agent_history("versionId") ON DELETE CASCADE |
| FK_c494292243a7e510acd0331c3d1 | FOREIGN KEY | FOREIGN KEY ("skillId") REFERENCES skill(id) ON DELETE CASCADE |
| FK_df63badfd7d3f2aa622ece471c4 | FOREIGN KEY | FOREIGN KEY ("skillVersionId") REFERENCES skill_version(id) |
| PK_df0a2577371b94f3c7008d81822 | PRIMARY KEY | PRIMARY KEY ("agentVersionId", "skillId") |
| agent_version_skill_dependency_agentVersionId_not_null | n | NOT NULL "agentVersionId" |
| agent_version_skill_dependency_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_version_skill_dependency_skillId_not_null | n | NOT NULL "skillId" |
| agent_version_skill_dependency_skillVersionId_not_null | n | NOT NULL "skillVersionId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_c494292243a7e510acd0331c3d | CREATE INDEX "IDX_c494292243a7e510acd0331c3d" ON public.agent_version_skill_dependency USING btree ("skillId") |
| IDX_df63badfd7d3f2aa622ece471c | CREATE INDEX "IDX_df63badfd7d3f2aa622ece471c" ON public.agent_version_skill_dependency USING btree ("skillVersionId") |
| PK_df0a2577371b94f3c7008d81822 | CREATE UNIQUE INDEX "PK_df0a2577371b94f3c7008d81822" ON public.agent_version_skill_dependency USING btree ("agentVersionId", "skillId") |

## Relations

```mermaid
erDiagram

"public.agent_version_skill_dependency" }o--|| "public.agent_history" : "FOREIGN KEY (#quot;agentVersionId#quot;) REFERENCES agent_history(#quot;versionId#quot;) ON DELETE CASCADE"
"public.agent_version_skill_dependency" }o--|| "public.skill" : "FOREIGN KEY (#quot;skillId#quot;) REFERENCES skill(id) ON DELETE CASCADE"
"public.agent_version_skill_dependency" }o--|| "public.skill_version" : "FOREIGN KEY (#quot;skillVersionId#quot;) REFERENCES skill_version(id)"

"public.agent_version_skill_dependency" {
  varchar_36_ agentVersionId FK
  timestamp_3__with_time_zone createdAt
  varchar_36_ skillId FK
  uuid skillVersionId FK
}
"public.agent_history" {
  varchar_36_ agentId FK
  varchar_255_ author
  timestamp_3__with_time_zone createdAt
  uuid publishedById FK
  json schema
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.skill" {
  varchar_36_ agentId FK
  boolean availableToAssistant
  timestamp_3__with_time_zone createdAt
  uuid createdById FK
  varchar_36_ id
  varchar_36_ projectId FK
  varchar_16_ source
  timestamp_3__with_time_zone updatedAt
}
"public.skill_version" {
  varchar_64_ contentHash
  timestamp_3__with_time_zone createdAt
  uuid createdById FK
  varchar_1024_ description
  json frontmatter
  uuid id
  text instructions
  varchar_128_ name
  varchar_36_ skillId FK
  timestamp_3__with_time_zone updatedAt
  integer version
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agent Workflow Dependency (`docs/generated/postgres-schema/public.agent_workflow_dependency.md`)

# public.agent_workflow_dependency

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | false |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_a2694df196a66064edbdbe38b94 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE CASCADE |
| FK_e5511a5e9eab71b7e516bdc04e9 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_4b9cb5e8db0dd16bb843b76465a | PRIMARY KEY | PRIMARY KEY ("agentId", "workflowId") |
| agent_workflow_dependency_agentId_not_null | n | NOT NULL "agentId" |
| agent_workflow_dependency_createdAt_not_null | n | NOT NULL "createdAt" |
| agent_workflow_dependency_workflowId_not_null | n | NOT NULL "workflowId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a2694df196a66064edbdbe38b9 | CREATE INDEX "IDX_a2694df196a66064edbdbe38b9" ON public.agent_workflow_dependency USING btree ("workflowId") |
| PK_4b9cb5e8db0dd16bb843b76465a | CREATE UNIQUE INDEX "PK_4b9cb5e8db0dd16bb843b76465a" ON public.agent_workflow_dependency USING btree ("agentId", "workflowId") |

## Relations

```mermaid
erDiagram

"public.agent_workflow_dependency" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agent_workflow_dependency" }o--|| "public.workflow_entity" : "FOREIGN KEY (#quot;workflowId#quot;) REFERENCES workflow_entity(id) ON DELETE CASCADE"

"public.agent_workflow_dependency" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  varchar_36_ workflowId FK
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.workflow_entity" {
  boolean active
  varchar_36_ activeVersionId FK
  json connections
  timestamp_3__with_time_zone createdAt
  text description
  varchar_36_ id
  boolean isArchived
  json meta
  varchar_128_ name
  json nodeGroups
  json nodes
  varchar_36_ parentFolderId FK
  json pinData
  json settings
  varchar sourceWorkflowId
  json staticData
  integer triggerCount
  timestamp_3__with_time_zone updatedAt
  integer versionCounter
  character_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents (`docs/generated/postgres-schema/public.agents.md`)

# public.agents

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| activeVersionId | varchar(36) |  | true |  | [public.agent_history](public.agent_history.md) |  |
| availableInMCP | boolean | false | false |  |  | Whether MCP clients granted agent scopes may operate on this agent |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.agent_background_job](public.agent_background_job.md) [public.agent_channel_status](public.agent_channel_status.md) [public.agent_chat_attachments](public.agent_chat_attachments.md) [public.agent_chat_subscriptions](public.agent_chat_subscriptions.md) [public.agent_checkpoints](public.agent_checkpoints.md) [public.agent_credential_dependency](public.agent_credential_dependency.md) [public.agent_eval_dataset](public.agent_eval_dataset.md) [public.agent_execution_threads](public.agent_execution_threads.md) [public.agent_files](public.agent_files.md) [public.agent_history](public.agent_history.md) [public.agent_skill_dependency](public.agent_skill_dependency.md) [public.agent_task_definition](public.agent_task_definition.md) [public.agent_task_run_lock](public.agent_task_run_lock.md) [public.agent_workflow_dependency](public.agent_workflow_dependency.md) [public.agents_memory_entries](public.agents_memory_entries.md) [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) [public.agents_memory_entry_locks](public.agents_memory_entry_locks.md) [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) [public.agents_observation_cursors](public.agents_observation_cursors.md) [public.agents_observation_locks](public.agents_observation_locks.md) [public.agents_observations](public.agents_observations.md) [public.skill](public.skill.md) |  |  |
| integrations | json | '[]'::json | false |  |  |  |
| name | varchar(128) |  | false |  |  |  |
| projectId | varchar(255) |  | true |  | [public.project](public.project.md) |  |
| revision | integer | 0 | false |  |  |  |
| schema | json |  | true |  |  |  |
| scope | varchar(16) | 'project'::character varying | false |  |  | project: belongs to projectId; instance: code-defined, belongs to no project (projectId is null) |
| setupCompletedAt | timestamp(3) with time zone |  | true |  |  | When this agent first reached a complete, publishable setup |
| skills | json | '{}'::json | false |  |  |  |
| tools | json | '{}'::json | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| versionId | varchar(36) |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_scope | CHECK | CHECK (((scope)::text = ANY ((ARRAY['project'::character varying, 'instance'::character varying])::text[]))) |
| CHK_agents_scope_project | CHECK | CHECK ((((scope)::text = 'instance'::text) = ("projectId" IS NULL))) |
| FK_940597dfe9753375309ce6aeea0 | FOREIGN KEY | FOREIGN KEY ("activeVersionId") REFERENCES agent_history("versionId") ON DELETE SET NULL |
| FK_a30d560207c4071d98aa03c179c | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_9c653f28ae19c5884d5baf6a1d9 | PRIMARY KEY | PRIMARY KEY (id) |
| agents_availableInMCP_not_null | n | NOT NULL "availableInMCP" |
| agents_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_id_not_null | n | NOT NULL id |
| agents_integrations_not_null | n | NOT NULL integrations |
| agents_name_not_null | n | NOT NULL name |
| agents_revision_not_null | n | NOT NULL revision |
| agents_scope_not_null | n | NOT NULL scope |
| agents_skills_not_null | n | NOT NULL skills |
| agents_tools_not_null | n | NOT NULL tools |
| agents_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a30d560207c4071d98aa03c179 | CREATE INDEX "IDX_a30d560207c4071d98aa03c179" ON public.agents USING btree ("projectId") |
| IDX_agents_projectId | CREATE INDEX "IDX_agents_projectId" ON public.agents USING btree ("projectId") |
| PK_9c653f28ae19c5884d5baf6a1d9 | CREATE UNIQUE INDEX "PK_9c653f28ae19c5884d5baf6a1d9" ON public.agents USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Memory Entries (`docs/generated/postgres-schema/public.agents_memory_entries.md`)

# public.agents_memory_entries

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this episodic memory entry |
| content | text |  | false |  |  |  |
| contentHash | varchar(64) |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| embedding | json |  | true |  |  | Embedding vector for episodic recall |
| embeddingModel | varchar(128) |  | true |  |  | Embedding model used to produce embedding |
| id | varchar(36) |  | false | [public.agents_memory_entries](public.agents_memory_entries.md) [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) |  |  |
| lastSeenAt | timestamp(3) with time zone |  | false |  |  | Last time equivalent content was observed; updatedAt tracks row mutation time |
| metadata | json |  | true |  |  | Optional system metadata for ranking and debugging |
| resourceId | varchar(255) |  | false |  | [public.agents_resources](public.agents_resources.md) | agents_resources.id partition used for episodic recall scope |
| status | varchar(16) |  | false |  |  |  |
| supersededBy | varchar(36) |  | true |  | [public.agents_memory_entries](public.agents_memory_entries.md) | Self-reference to replacement memory entry |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_memory_entries_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'superseded'::character varying, 'dropped'::character varying])::text[]))) |
| FK_0edf1226b77ddc525eae4938079 | FOREIGN KEY | FOREIGN KEY ("supersededBy") REFERENCES agents_memory_entries(id) |
| FK_1443a75e59adbfb796071d66393 | FOREIGN KEY | FOREIGN KEY ("resourceId") REFERENCES agents_resources(id) ON DELETE CASCADE |
| FK_28e981fb675e9b44ce02f0ec1dd | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_bfbc45dc88f66fae4e4b4a15fec | PRIMARY KEY | PRIMARY KEY (id) |
| agents_memory_entries_agentId_not_null | n | NOT NULL "agentId" |
| agents_memory_entries_contentHash_not_null | n | NOT NULL "contentHash" |
| agents_memory_entries_content_not_null | n | NOT NULL content |
| agents_memory_entries_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_memory_entries_id_not_null | n | NOT NULL id |
| agents_memory_entries_lastSeenAt_not_null | n | NOT NULL "lastSeenAt" |
| agents_memory_entries_resourceId_not_null | n | NOT NULL "resourceId" |
| agents_memory_entries_status_not_null | n | NOT NULL status |
| agents_memory_entries_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_0edf1226b77ddc525eae493807 | CREATE INDEX "IDX_0edf1226b77ddc525eae493807" ON public.agents_memory_entries USING btree ("supersededBy") |
| IDX_1443a75e59adbfb796071d6639 | CREATE INDEX "IDX_1443a75e59adbfb796071d6639" ON public.agents_memory_entries USING btree ("resourceId") |
| IDX_a03e04e94bea8439dd166d4b52 | CREATE UNIQUE INDEX "IDX_a03e04e94bea8439dd166d4b52" ON public.agents_memory_entries USING btree ("agentId", "resourceId", "contentHash") |
| IDX_aff2807b31eccbafe59d0474f0 | CREATE INDEX "IDX_aff2807b31eccbafe59d0474f0" ON public.agents_memory_entries USING btree ("agentId", "resourceId", status, "createdAt", id) |
| PK_bfbc45dc88f66fae4e4b4a15fec | CREATE UNIQUE INDEX "PK_bfbc45dc88f66fae4e4b4a15fec" ON public.agents_memory_entries USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Memory Entry Candidates (`docs/generated/postgres-schema/public.agents_memory_entry_candidates.md`)

# public.agents_memory_entry_candidates

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this episodic memory capture candidate |
| attemptCount | smallint | 0 | false |  |  | Number of failed processing attempts |
| content | text |  | false |  |  | Agent-proposed durable memory content |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| evidenceText | text |  | false |  |  | Redacted exact evidence from the source message |
| id | varchar(36) |  | false | [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) |  |  |
| kind | varchar(32) |  | false |  |  | Reason the agent flagged this candidate; see EpisodicMemoryCaptureKind in @n8n/agents |
| resourceId | varchar(255) |  | false |  | [public.agents_resources](public.agents_resources.md) | Resource scope for the eventual episodic memory entry |
| runId | varchar(255) |  | false |  |  | Agent run that issued the memory capture tool call |
| sourceMessageId | varchar(36) |  | true |  | [public.agents_messages](public.agents_messages.md) | Persisted message that contains the exact source evidence |
| status | varchar(16) | 'pending'::character varying | false |  |  | Candidate processing state |
| threadId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) | Conversation thread where the agent flagged this candidate |
| toolCallId | varchar(255) |  | false |  |  | Model tool-call ID used to make enqueue replay-safe |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_memory_entry_candidates_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['pending'::character varying, 'completed'::character varying, 'failed'::character varying])::text[]))) |
| FK_5123f71435736664d2676084a85 | FOREIGN KEY | FOREIGN KEY ("resourceId") REFERENCES agents_resources(id) ON DELETE CASCADE |
| FK_ac7ada75df7cc8ced228921d5a9 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| FK_b3d0f5fe54565580bc1f5febb6e | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_f1857f6716aa258393dd6f33243 | FOREIGN KEY | FOREIGN KEY ("sourceMessageId") REFERENCES agents_messages(id) ON DELETE SET NULL |
| PK_d5c36484cafd23222df4c564159 | PRIMARY KEY | PRIMARY KEY (id) |
| agents_memory_entry_candidates_agentId_not_null | n | NOT NULL "agentId" |
| agents_memory_entry_candidates_attemptCount_not_null | n | NOT NULL "attemptCount" |
| agents_memory_entry_candidates_content_not_null | n | NOT NULL content |
| agents_memory_entry_candidates_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_memory_entry_candidates_evidenceText_not_null | n | NOT NULL "evidenceText" |
| agents_memory_entry_candidates_id_not_null | n | NOT NULL id |
| agents_memory_entry_candidates_kind_not_null | n | NOT NULL kind |
| agents_memory_entry_candidates_resourceId_not_null | n | NOT NULL "resourceId" |
| agents_memory_entry_candidates_runId_not_null | n | NOT NULL "runId" |
| agents_memory_entry_candidates_status_not_null | n | NOT NULL status |
| agents_memory_entry_candidates_threadId_not_null | n | NOT NULL "threadId" |
| agents_memory_entry_candidates_toolCallId_not_null | n | NOT NULL "toolCallId" |
| agents_memory_entry_candidates_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_5123f71435736664d2676084a8 | CREATE INDEX "IDX_5123f71435736664d2676084a8" ON public.agents_memory_entry_candidates USING btree ("resourceId") |
| IDX_6dc22e132cf1a34e5bca672b99 | CREATE INDEX "IDX_6dc22e132cf1a34e5bca672b99" ON public.agents_memory_entry_candidates USING btree ("agentId", "resourceId", status, "createdAt", id) |
| IDX_ac7ada75df7cc8ced228921d5a | CREATE INDEX "IDX_ac7ada75df7cc8ced228921d5a" ON public.agents_memory_entry_candidates USING btree ("threadId") |
| IDX_e3e49861a5452db63b036a2561 | CREATE UNIQUE INDEX "IDX_e3e49861a5452db63b036a2561" ON public.agents_memory_entry_candidates USING btree ("agentId", "runId", "toolCallId") |
| IDX_f1857f6716aa258393dd6f3324 | CREATE INDEX "IDX_f1857f6716aa258393dd6f3324" ON public.agents_memory_entry_candidates USING btree ("sourceMessageId") |
| PK_d5c36484cafd23222df4c564159 | CREATE UNIQUE INDEX "PK_d5c36484cafd23222df4c564159" ON public.agents_memory_entry_candidates USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Memory Entry Locks (`docs/generated/postgres-schema/public.agents_memory_entry_locks.md`)

# public.agents_memory_entry_locks

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this lock |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| heldUntil | timestamp(3) with time zone |  | false |  |  |  |
| holderId | varchar(64) |  | false |  |  | Ephemeral background-task lock owner token |
| resourceId | varchar(255) |  | false |  | [public.agents_resources](public.agents_resources.md) | agents_resources.id partition locked for episodic indexing |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_0ccf6d9ea6f44fa1c264fc2f795 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_9594c0983cfee1c8ff49b05848b | FOREIGN KEY | FOREIGN KEY ("resourceId") REFERENCES agents_resources(id) ON DELETE CASCADE |
| PK_a8e0f570d04a174292bea104ae6 | PRIMARY KEY | PRIMARY KEY ("agentId", "resourceId") |
| agents_memory_entry_locks_agentId_not_null | n | NOT NULL "agentId" |
| agents_memory_entry_locks_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_memory_entry_locks_heldUntil_not_null | n | NOT NULL "heldUntil" |
| agents_memory_entry_locks_holderId_not_null | n | NOT NULL "holderId" |
| agents_memory_entry_locks_resourceId_not_null | n | NOT NULL "resourceId" |
| agents_memory_entry_locks_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_9594c0983cfee1c8ff49b05848 | CREATE INDEX "IDX_9594c0983cfee1c8ff49b05848" ON public.agents_memory_entry_locks USING btree ("resourceId") |
| PK_a8e0f570d04a174292bea104ae6 | CREATE UNIQUE INDEX "PK_a8e0f570d04a174292bea104ae6" ON public.agents_memory_entry_locks USING btree ("agentId", "resourceId") |

## Relations

```mermaid
erDiagram

"public.agents_memory_entry_locks" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agents_memory_entry_locks" }o--|| "public.agents_resources" : "FOREIGN KEY (#quot;resourceId#quot;) REFERENCES agents_resources(id) ON DELETE CASCADE"

"public.agents_memory_entry_locks" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone heldUntil
  varchar_64_ holderId
  varchar_255_ resourceId FK
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.agents_resources" {
  timestamp_3__with_time_zone createdAt
  varchar_255_ id
  text metadata
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Memory Entry Sources (`docs/generated/postgres-schema/public.agents_memory_entry_sources.md`)

# public.agents_memory_entry_sources

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns the linked episodic memory entry source |
| candidateId | varchar(36) |  | true |  | [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) | Capture candidate used as source evidence |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| evidenceHash | varchar(64) |  | false |  |  | Bounded hash used to deduplicate exact evidence links |
| evidenceText | text |  | false |  |  | Exact source evidence text, not recall scope |
| id | varchar(36) |  | false |  |  |  |
| memoryEntryId | varchar(36) |  | false |  | [public.agents_memory_entries](public.agents_memory_entries.md) | Episodic memory entry linked to this source evidence |
| observationId | varchar(36) |  | true |  | [public.agents_observations](public.agents_observations.md) | Observation-log row used as source evidence |
| threadId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) | Source conversation thread for this evidence |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_memory_entry_sources_exactly_one_source | CHECK | CHECK (((("observationId" IS NOT NULL) AND ("candidateId" IS NULL)) OR (("observationId" IS NULL) AND ("candidateId" IS NOT NULL)))) |
| FK_451d387a182fa8dd8002dfc3a77 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| FK_4706f6223313959b7437a2b48df | FOREIGN KEY | FOREIGN KEY ("memoryEntryId") REFERENCES agents_memory_entries(id) ON DELETE CASCADE |
| FK_87640d646b020c3be8e16cd0fa6 | FOREIGN KEY | FOREIGN KEY ("candidateId") REFERENCES agents_memory_entry_candidates(id) ON DELETE CASCADE |
| FK_c38e8a57a36b880e39a52ada2e8 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_cb7c15d22fd068a0806aa57fc03 | FOREIGN KEY | FOREIGN KEY ("observationId") REFERENCES agents_observations(id) ON DELETE CASCADE |
| PK_278f05e98e74baaaa93f52b4bab | PRIMARY KEY | PRIMARY KEY (id) |
| agents_memory_entry_sources_agentId_not_null | n | NOT NULL "agentId" |
| agents_memory_entry_sources_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_memory_entry_sources_evidenceHash_not_null | n | NOT NULL "evidenceHash" |
| agents_memory_entry_sources_evidenceText_not_null | n | NOT NULL "evidenceText" |
| agents_memory_entry_sources_id_not_null | n | NOT NULL id |
| agents_memory_entry_sources_memoryEntryId_not_null | n | NOT NULL "memoryEntryId" |
| agents_memory_entry_sources_threadId_not_null | n | NOT NULL "threadId" |
| agents_memory_entry_sources_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_451d387a182fa8dd8002dfc3a7 | CREATE INDEX "IDX_451d387a182fa8dd8002dfc3a7" ON public.agents_memory_entry_sources USING btree ("threadId") |
| IDX_a353ac251315ef0af6ad3c9f0a | CREATE UNIQUE INDEX "IDX_a353ac251315ef0af6ad3c9f0a" ON public.agents_memory_entry_sources USING btree ("memoryEntryId", "observationId", "evidenceHash") |
| IDX_agents_mem_src_candidate_unique | CREATE UNIQUE INDEX "IDX_agents_mem_src_candidate_unique" ON public.agents_memory_entry_sources USING btree ("memoryEntryId", "candidateId", "evidenceHash") WHERE ("candidateId" IS NOT NULL) |
| IDX_agents_memory_entry_sources_candidateId | CREATE INDEX "IDX_agents_memory_entry_sources_candidateId" ON public.agents_memory_entry_sources USING btree ("candidateId") |
| IDX_cb7c15d22fd068a0806aa57fc0 | CREATE INDEX "IDX_cb7c15d22fd068a0806aa57fc0" ON public.agents_memory_entry_sources USING btree ("observationId") |
| IDX_f9573af4ed653f13b0ba1f7b12 | CREATE INDEX "IDX_f9573af4ed653f13b0ba1f7b12" ON public.agents_memory_entry_sources USING btree ("agentId", "threadId") |
| PK_278f05e98e74baaaa93f52b4bab | CREATE UNIQUE INDEX "PK_278f05e98e74baaaa93f52b4bab" ON public.agents_memory_entry_sources USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Messages (`docs/generated/postgres-schema/public.agents_messages.md`)

# public.agents_messages

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| author | json |  | true |  |  | Original message author supplied by the chat platform |
| content | json |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.agent_execution_message_links](public.agent_execution_message_links.md) [public.agent_message_queue](public.agent_message_queue.md) [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) |  |  |
| modelContent | json |  | true |  |  | Enriched model input when it differs from the original content |
| modelContextAt | timestamp(3) with time zone |  | true |  |  | Runtime ordering timestamp. NULL inputs are excluded from model context |
| origin | json |  | true |  |  | Source identifiers and transcript visibility. NULL for legacy or SDK-only messages |
| resourceId | varchar(255) |  | false |  |  |  |
| role | varchar(36) |  | false |  |  |  |
| threadId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) |  |
| type | varchar(36) |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_0a8057a61afabd2999608ffd0d9 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| PK_81020dc608dfb0af1ede386d907 | PRIMARY KEY | PRIMARY KEY (id) |
| agents_messages_content_not_null | n | NOT NULL content |
| agents_messages_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_messages_id_not_null | n | NOT NULL id |
| agents_messages_resourceId_not_null | n | NOT NULL "resourceId" |
| agents_messages_role_not_null | n | NOT NULL role |
| agents_messages_threadId_not_null | n | NOT NULL "threadId" |
| agents_messages_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_agents_messages_model_context | CREATE INDEX "IDX_agents_messages_model_context" ON public.agents_messages USING btree ("threadId", COALESCE("modelContextAt", "createdAt"), id) |
| IDX_agents_messages_resourceId_threadId | CREATE INDEX "IDX_agents_messages_resourceId_threadId" ON public.agents_messages USING btree ("resourceId", "threadId") |
| IDX_agents_messages_threadId_createdAt | CREATE INDEX "IDX_agents_messages_threadId_createdAt" ON public.agents_messages USING btree ("threadId", "createdAt") |
| IDX_fc7bf858660bfafd19181e8e35 | CREATE INDEX "IDX_fc7bf858660bfafd19181e8e35" ON public.agents_messages USING btree ("threadId", "createdAt") |
| PK_81020dc608dfb0af1ede386d907 | CREATE UNIQUE INDEX "PK_81020dc608dfb0af1ede386d907" ON public.agents_messages USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Observation Cursors (`docs/generated/postgres-schema/public.agents_observation_cursors.md`)

# public.agents_observation_cursors

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this cursor |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| lastObservedAt | timestamp(3) with time zone |  | false |  |  |  |
| lastObservedMessageId | varchar(36) |  | false |  |  |  |
| observationScopeId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) | agents_threads.id source stream checkpointed by this cursor |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_64e92819f4b413661ed6e2c3c3d | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_87aa187d27ea67eafd164905154 | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| PK_eb777ac57ab872d38f8ebd19317 | PRIMARY KEY | PRIMARY KEY ("agentId", "observationScopeId") |
| agents_observation_cursors_agentId_not_null | n | NOT NULL "agentId" |
| agents_observation_cursors_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_observation_cursors_lastObservedAt_not_null | n | NOT NULL "lastObservedAt" |
| agents_observation_cursors_lastObservedMessageId_not_null | n | NOT NULL "lastObservedMessageId" |
| agents_observation_cursors_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| agents_observation_cursors_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_87aa187d27ea67eafd16490515 | CREATE INDEX "IDX_87aa187d27ea67eafd16490515" ON public.agents_observation_cursors USING btree ("observationScopeId") |
| PK_eb777ac57ab872d38f8ebd19317 | CREATE UNIQUE INDEX "PK_eb777ac57ab872d38f8ebd19317" ON public.agents_observation_cursors USING btree ("agentId", "observationScopeId") |

## Relations

```mermaid
erDiagram

"public.agents_observation_cursors" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agents_observation_cursors" }o--|| "public.agents_threads" : "FOREIGN KEY (#quot;observationScopeId#quot;) REFERENCES agents_threads(id) ON DELETE CASCADE"

"public.agents_observation_cursors" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone lastObservedAt
  varchar_36_ lastObservedMessageId
  varchar_255_ observationScopeId FK
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.agents_threads" {
  timestamp_3__with_time_zone createdAt
  varchar_128_ id
  text metadata
  varchar_255_ resourceId
  varchar_255_ title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Observation Locks (`docs/generated/postgres-schema/public.agents_observation_locks.md`)

# public.agents_observation_locks

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this lock |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| heldUntil | timestamp(3) with time zone |  | false |  |  |  |
| holderId | varchar(64) |  | false |  |  | Ephemeral background-task lock owner token, not a user ID |
| observationScopeId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) | agents_threads.id source stream locked for observation tasks |
| taskKind | varchar(20) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_observation_locks_taskKind | CHECK | CHECK ((("taskKind")::text = ANY ((ARRAY['observer'::character varying, 'reflector'::character varying])::text[]))) |
| FK_093e44ae20f2518e97d83a95433 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| FK_6b55089892e447c2f82e5ec60ed | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| PK_7e2e315162ac3d80587e15ac2c3 | PRIMARY KEY | PRIMARY KEY ("agentId", "observationScopeId", "taskKind") |
| agents_observation_locks_agentId_not_null | n | NOT NULL "agentId" |
| agents_observation_locks_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_observation_locks_heldUntil_not_null | n | NOT NULL "heldUntil" |
| agents_observation_locks_holderId_not_null | n | NOT NULL "holderId" |
| agents_observation_locks_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| agents_observation_locks_taskKind_not_null | n | NOT NULL "taskKind" |
| agents_observation_locks_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_6b55089892e447c2f82e5ec60e | CREATE INDEX "IDX_6b55089892e447c2f82e5ec60e" ON public.agents_observation_locks USING btree ("observationScopeId") |
| PK_7e2e315162ac3d80587e15ac2c3 | CREATE UNIQUE INDEX "PK_7e2e315162ac3d80587e15ac2c3" ON public.agents_observation_locks USING btree ("agentId", "observationScopeId", "taskKind") |

## Relations

```mermaid
erDiagram

"public.agents_observation_locks" }o--|| "public.agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES agents(id) ON DELETE CASCADE"
"public.agents_observation_locks" }o--|| "public.agents_threads" : "FOREIGN KEY (#quot;observationScopeId#quot;) REFERENCES agents_threads(id) ON DELETE CASCADE"

"public.agents_observation_locks" {
  varchar_36_ agentId FK
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone heldUntil
  varchar_64_ holderId
  varchar_255_ observationScopeId FK
  varchar_20_ taskKind
  timestamp_3__with_time_zone updatedAt
}
"public.agents" {
  varchar_36_ activeVersionId FK
  boolean availableInMCP
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  json integrations
  varchar_128_ name
  varchar_255_ projectId FK
  integer revision
  json schema
  varchar_16_ scope
  timestamp_3__with_time_zone setupCompletedAt
  json skills
  json tools
  timestamp_3__with_time_zone updatedAt
  varchar_36_ versionId
}
"public.agents_threads" {
  timestamp_3__with_time_zone createdAt
  varchar_128_ id
  text metadata
  varchar_255_ resourceId
  varchar_255_ title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Observations (`docs/generated/postgres-schema/public.agents_observations.md`)

# public.agents_observations

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | varchar(36) |  | false |  | [public.agents](public.agents.md) | Agent that owns this observation row |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) [public.agents_observations](public.agents_observations.md) |  | Application-generated n8n string ID, not a database UUID |
| marker | varchar(16) |  | false |  |  |  |
| observationScopeId | varchar(255) |  | false |  | [public.agents_threads](public.agents_threads.md) | agents_threads.id source stream for this observation log |
| parentId | varchar(36) |  | true |  | [public.agents_observations](public.agents_observations.md) |  |
| status | varchar(16) |  | false |  |  |  |
| supersededBy | varchar(36) |  | true |  | [public.agents_observations](public.agents_observations.md) |  |
| text | text |  | false |  |  |  |
| tokenCount | integer | 0 | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_agents_observations_marker | CHECK | CHECK (((marker)::text = ANY ((ARRAY['critical'::character varying, 'important'::character varying, 'info'::character varying, 'completion'::character varying])::text[]))) |
| CHK_agents_observations_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'superseded'::character varying, 'dropped'::character varying])::text[]))) |
| FK_127ee1078ffa952bb37b511efad | FOREIGN KEY | FOREIGN KEY ("supersededBy") REFERENCES agents_observations(id) |
| FK_4cfd8a70ebb0a5b0cf047dca3cf | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES agents_threads(id) ON DELETE CASCADE |
| FK_501e2d1701a10e24fb69ab5fc5f | FOREIGN KEY | FOREIGN KEY ("parentId") REFERENCES agents_observations(id) |
| FK_d206432be97b7ed88d187479b1b | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES agents(id) ON DELETE CASCADE |
| PK_9ad319654d12c2649f7caf27135 | PRIMARY KEY | PRIMARY KEY (id) |
| agents_observations_agentId_not_null | n | NOT NULL "agentId" |
| agents_observations_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_observations_id_not_null | n | NOT NULL id |
| agents_observations_marker_not_null | n | NOT NULL marker |
| agents_observations_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| agents_observations_status_not_null | n | NOT NULL status |
| agents_observations_text_not_null | n | NOT NULL text |
| agents_observations_tokenCount_not_null | n | NOT NULL "tokenCount" |
| agents_observations_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_07cb1e4a302629c5fa5d74d2bb | CREATE INDEX "IDX_07cb1e4a302629c5fa5d74d2bb" ON public.agents_observations USING btree ("agentId", "observationScopeId", status) |
| IDX_127ee1078ffa952bb37b511efa | CREATE INDEX "IDX_127ee1078ffa952bb37b511efa" ON public.agents_observations USING btree ("supersededBy") |
| IDX_4cfd8a70ebb0a5b0cf047dca3c | CREATE INDEX "IDX_4cfd8a70ebb0a5b0cf047dca3c" ON public.agents_observations USING btree ("observationScopeId") |
| IDX_501e2d1701a10e24fb69ab5fc5 | CREATE INDEX "IDX_501e2d1701a10e24fb69ab5fc5" ON public.agents_observations USING btree ("parentId") |
| PK_9ad319654d12c2649f7caf27135 | CREATE UNIQUE INDEX "PK_9ad319654d12c2649f7caf27135" ON public.agents_observations USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Resources (`docs/generated/postgres-schema/public.agents_resources.md`)

# public.agents_resources

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(255) |  | false | [public.agents_memory_entries](public.agents_memory_entries.md) [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) [public.agents_memory_entry_locks](public.agents_memory_entry_locks.md) |  |  |
| metadata | text |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_fa6b20b2d31a9991529dbf8ef7d | PRIMARY KEY | PRIMARY KEY (id) |
| agents_resources_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_resources_id_not_null | n | NOT NULL id |
| agents_resources_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_fa6b20b2d31a9991529dbf8ef7d | CREATE UNIQUE INDEX "PK_fa6b20b2d31a9991529dbf8ef7d" ON public.agents_resources USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Agents Threads (`docs/generated/postgres-schema/public.agents_threads.md`)

# public.agents_threads

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(128) |  | false | [public.agents_memory_entry_candidates](public.agents_memory_entry_candidates.md) [public.agents_memory_entry_sources](public.agents_memory_entry_sources.md) [public.agents_messages](public.agents_messages.md) [public.agents_observation_cursors](public.agents_observation_cursors.md) [public.agents_observation_locks](public.agents_observation_locks.md) [public.agents_observations](public.agents_observations.md) |  |  |
| metadata | text |  | true |  |  |  |
| resourceId | varchar(255) |  | false |  |  |  |
| title | varchar(255) |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_4a3feb0a13ffe315c009cce64e5 | PRIMARY KEY | PRIMARY KEY (id) |
| agents_threads_createdAt_not_null | n | NOT NULL "createdAt" |
| agents_threads_id_not_null | n | NOT NULL id |
| agents_threads_resourceId_not_null | n | NOT NULL "resourceId" |
| agents_threads_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_54fa1b94f34a409beafae567a4 | CREATE INDEX "IDX_54fa1b94f34a409beafae567a4" ON public.agents_threads USING btree ("resourceId") |
| PK_4a3feb0a13ffe315c009cce64e5 | CREATE UNIQUE INDEX "PK_4a3feb0a13ffe315c009cce64e5" ON public.agents_threads USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Ai Builder Temporary Workflow (`docs/generated/postgres-schema/public.ai_builder_temporary_workflow.md`)

# public.ai_builder_temporary_workflow

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | false |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_39b07732e819fb561d74c38763f | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| FK_85a87a1ba0f61999fe11dc56325 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE CASCADE |
| PK_85a87a1ba0f61999fe11dc56325 | PRIMARY KEY | PRIMARY KEY ("workflowId") |
| ai_builder_temporary_workflow_createdAt_not_null | n | NOT NULL "createdAt" |
| ai_builder_temporary_workflow_threadId_not_null | n | NOT NULL "threadId" |
| ai_builder_temporary_workflow_updatedAt_not_null | n | NOT NULL "updatedAt" |
| ai_builder_temporary_workflow_workflowId_not_null | n | NOT NULL "workflowId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_39b07732e819fb561d74c38763 | CREATE INDEX "IDX_39b07732e819fb561d74c38763" ON public.ai_builder_temporary_workflow USING btree ("threadId") |
| PK_85a87a1ba0f61999fe11dc56325 | CREATE UNIQUE INDEX "PK_85a87a1ba0f61999fe11dc56325" ON public.ai_builder_temporary_workflow USING btree ("workflowId") |

## Relations

```mermaid
erDiagram

"public.ai_builder_temporary_workflow" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"
"public.ai_builder_temporary_workflow" |o--|| "public.workflow_entity" : "FOREIGN KEY (#quot;workflowId#quot;) REFERENCES workflow_entity(id) ON DELETE CASCADE"

"public.ai_builder_temporary_workflow" {
  timestamp_3__with_time_zone createdAt
  uuid threadId FK
  timestamp_3__with_time_zone updatedAt
  varchar_36_ workflowId FK
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
"public.workflow_entity" {
  boolean active
  varchar_36_ activeVersionId FK
  json connections
  timestamp_3__with_time_zone createdAt
  text description
  varchar_36_ id
  boolean isArchived
  json meta
  varchar_128_ name
  json nodeGroups
  json nodes
  varchar_36_ parentFolderId FK
  json pinData
  json settings
  varchar sourceWorkflowId
  json staticData
  integer triggerCount
  timestamp_3__with_time_zone updatedAt
  integer versionCounter
  character_36_ versionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Ai Preference (`docs/generated/postgres-schema/public.ai_preference.md`)

# public.ai_preference

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| content | text |  | false |  |  | Instruction text injected into AI prompts |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| createdById | uuid |  | true |  | [public.user](public.user.md) | Author. NULL after the author is deleted |
| id | uuid |  | false |  |  |  |
| projectId | varchar(36) |  | true |  | [public.project](public.project.md) | Set for a project preference. NULL otherwise |
| source | varchar(16) |  | false |  |  | Surface that wrote the row: ui (settings), aia (assistant), mcp (client) |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | true |  | [public.user](public.user.md) | Set for a personal preference. NULL otherwise |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_ai_preference_single_target | CHECK | CHECK ((("userId" IS NULL) OR ("projectId" IS NULL))) |
| CHK_ai_preference_source | CHECK | CHECK (((source)::text = ANY ((ARRAY['ui'::character varying, 'aia'::character varying, 'mcp'::character varying])::text[]))) |
| FK_4ea340a1847ad0e40a0b0360fe4 | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| FK_aeb2ce3354b55bd61c8d7e17169 | FOREIGN KEY | FOREIGN KEY ("createdById") REFERENCES "user"(id) ON DELETE SET NULL |
| FK_e9059770c01bfda6062d78d9f8e | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_e7dbbeec9da3e06f6a20669e6e7 | PRIMARY KEY | PRIMARY KEY (id) |
| ai_preference_content_not_null | n | NOT NULL content |
| ai_preference_createdAt_not_null | n | NOT NULL "createdAt" |
| ai_preference_id_not_null | n | NOT NULL id |
| ai_preference_source_not_null | n | NOT NULL source |
| ai_preference_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_4ea340a1847ad0e40a0b0360fe | CREATE INDEX "IDX_4ea340a1847ad0e40a0b0360fe" ON public.ai_preference USING btree ("projectId") |
| IDX_e9059770c01bfda6062d78d9f8 | CREATE INDEX "IDX_e9059770c01bfda6062d78d9f8" ON public.ai_preference USING btree ("userId") |
| PK_e7dbbeec9da3e06f6a20669e6e7 | CREATE UNIQUE INDEX "PK_e7dbbeec9da3e06f6a20669e6e7" ON public.ai_preference USING btree (id) |

## Relations

```mermaid
erDiagram

"public.ai_preference" }o--o| "public.user" : "FOREIGN KEY (#quot;createdById#quot;) REFERENCES #quot;user#quot;(id) ON DELETE SET NULL"
"public.ai_preference" }o--o| "public.project" : "FOREIGN KEY (#quot;projectId#quot;) REFERENCES project(id) ON DELETE CASCADE"
"public.ai_preference" }o--o| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.ai_preference" {
  text content
  timestamp_3__with_time_zone createdAt
  uuid createdById FK
  uuid id
  varchar_36_ projectId FK
  varchar_16_ source
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
"public.project" {
  timestamp_3__with_time_zone createdAt
  uuid creatorId FK
  json customTelemetryTags
  varchar_512_ description
  json icon
  varchar_36_ id
  varchar_255_ name
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Annotation Tag Entity (`docs/generated/postgres-schema/public.annotation_tag_entity.md`)

# public.annotation_tag_entity

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(16) |  | false | [public.execution_annotation_tags](public.execution_annotation_tags.md) |  |  |
| name | varchar(24) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_69dfa041592c30bbc0d4b84aa00 | PRIMARY KEY | PRIMARY KEY (id) |
| annotation_tag_entity_createdAt_not_null | n | NOT NULL "createdAt" |
| annotation_tag_entity_id_not_null | n | NOT NULL id |
| annotation_tag_entity_name_not_null | n | NOT NULL name |
| annotation_tag_entity_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_ae51b54c4bb430cf92f48b623f | CREATE UNIQUE INDEX "IDX_ae51b54c4bb430cf92f48b623f" ON public.annotation_tag_entity USING btree (name) |
| PK_69dfa041592c30bbc0d4b84aa00 | CREATE UNIQUE INDEX "PK_69dfa041592c30bbc0d4b84aa00" ON public.annotation_tag_entity USING btree (id) |

## Relations

```mermaid
erDiagram

"public.execution_annotation_tags" }o--|| "public.annotation_tag_entity" : "FOREIGN KEY (#quot;tagId#quot;) REFERENCES annotation_tag_entity(id) ON DELETE CASCADE"

"public.annotation_tag_entity" {
  timestamp_3__with_time_zone createdAt
  varchar_16_ id
  varchar_24_ name
  timestamp_3__with_time_zone updatedAt
}
"public.execution_annotation_tags" {
  integer annotationId FK
  varchar_24_ tagId FK
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.App (`docs/generated/postgres-schema/public.app.md`)

# public.app

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| draftVersionId | uuid |  | true |  | [public.app_version](public.app_version.md) | Current working app version |
| id | uuid |  | false | [public.app_version](public.app_version.md) |  |  |
| name | varchar(128) |  | false |  |  |  |
| namespace | varchar(128) |  | false |  |  | Unique URL path segment for the app |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) |  |
| publishedVersionId | uuid |  | true |  | [public.app_version](public.app_version.md) | Published app version; null when unpublished |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| visibility | varchar(16) | 'project'::character varying | false |  |  | App access: everyone, project members, or instance users |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_app_visibility | CHECK | CHECK (((visibility)::text = ANY ((ARRAY['public'::character varying, 'project'::character varying, 'instance'::character varying])::text[]))) |
| FK_f84dd7eb539e46e0c233fa09b20 | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_9478629fc093d229df09e560aea | PRIMARY KEY | PRIMARY KEY (id) |
| app_createdAt_not_null | n | NOT NULL "createdAt" |
| app_draftVersionId_foreign | FOREIGN KEY | FOREIGN KEY ("draftVersionId") REFERENCES app_version(id) ON DELETE SET NULL |
| app_id_not_null | n | NOT NULL id |
| app_name_not_null | n | NOT NULL name |
| app_namespace_not_null | n | NOT NULL namespace |
| app_projectId_not_null | n | NOT NULL "projectId" |
| app_publishedVersionId_foreign | FOREIGN KEY | FOREIGN KEY ("publishedVersionId") REFERENCES app_version(id) ON DELETE SET NULL |
| app_updatedAt_not_null | n | NOT NULL "updatedAt" |
| app_visibility_not_null | n | NOT NULL visibility |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a73a1fa47c9e5097660f1161b3 | CREATE UNIQUE INDEX "IDX_a73a1fa47c9e5097660f1161b3" ON public.app USING btree (namespace) |
| IDX_ca0a32194dd73ba54acb0adabf | CREATE INDEX "IDX_ca0a32194dd73ba54acb0adabf" ON public.app USING btree ("draftVersionId") |
| IDX_e1c99aaf677c86879562203218 | CREATE INDEX "IDX_e1c99aaf677c86879562203218" ON public.app USING btree ("publishedVersionId") |
| IDX_f84dd7eb539e46e0c233fa09b2 | CREATE INDEX "IDX_f84dd7eb539e46e0c233fa09b2" ON public.app USING btree ("projectId") |
| PK_9478629fc093d229df09e560aea | CREATE UNIQUE INDEX "PK_9478629fc093d229df09e560aea" ON public.app USING btree (id) |

## Relations

```mermaid
erDiagram

"public.app" }o--o| "public.app_version" : "FOREIGN KEY (#quot;draftVersionId#quot;) REFERENCES app_version(id) ON DELETE SET NULL"
"public.app_version" }o--|| "public.app" : "FOREIGN KEY (#quot;appId#quot;) REFERENCES app(id) ON DELETE CASCADE"
"public.app" }o--|| "public.project" : "FOREIGN KEY (#quot;projectId#quot;) REFERENCES project(id) ON DELETE CASCADE"
"public.app" }o--o| "public.app_version" : "FOREIGN KEY (#quot;publishedVersionId#quot;) REFERENCES app_version(id) ON DELETE SET NULL"

"public.app" {
  timestamp_3__with_time_zone createdAt
  uuid draftVersionId FK
  uuid id
  varchar_128_ name
  varchar_128_ namespace
  varchar_36_ projectId FK
  uuid publishedVersionId FK
  timestamp_3__with_time_zone updatedAt
  varchar_16_ visibility
}
"public.app_version" {
  uuid appId FK
  integer buildAttempts
  varchar_16_ buildStatus
  timestamp_3__with_time_zone buildStatusUpdatedAt
  integer bundleArtifactId FK
  timestamp_3__with_time_zone createdAt
  uuid id
  varchar_255_ label
  integer sourceArtifactId FK
  timestamp_3__with_time_zone updatedAt
}
"public.project" {
  timestamp_3__with_time_zone createdAt
  uuid creatorId FK
  json customTelemetryTags
  varchar_512_ description
  json icon
  varchar_36_ id
  varchar_255_ name
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.App Artifact (`docs/generated/postgres-schema/public.app_artifact.md`)

# public.app_artifact

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| appId | uuid |  | false |  |  | No foreign key so the owning app ID remains available for cleanup after app deletion. |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | integer |  | false | [public.app_version](public.app_version.md) |  |  |
| sizeBytes | integer |  | false |  |  |  |
| storageKey | text |  | false |  |  | Reference to the object within its storage backend |
| storedAt | varchar(2) |  | false |  |  | Storage backend: database, filesystem, S3, or Azure |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| uploadStatus | varchar(16) | 'pending'::character varying | false |  |  | Upload state: pending or completed |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_app_artifact_storedAt | CHECK | CHECK ((("storedAt")::text = ANY ((ARRAY['db'::character varying, 'fs'::character varying, 's3'::character varying, 'az'::character varying])::text[]))) |
| CHK_app_artifact_uploadStatus | CHECK | CHECK ((("uploadStatus")::text = ANY ((ARRAY['pending'::character varying, 'completed'::character varying])::text[]))) |
| PK_307f7470d2b759f7c4bc056d3a5 | PRIMARY KEY | PRIMARY KEY (id) |
| app_artifact_appId_not_null | n | NOT NULL "appId" |
| app_artifact_createdAt_not_null | n | NOT NULL "createdAt" |
| app_artifact_id_not_null | n | NOT NULL id |
| app_artifact_sizeBytes_not_null | n | NOT NULL "sizeBytes" |
| app_artifact_storageKey_not_null | n | NOT NULL "storageKey" |
| app_artifact_storedAt_not_null | n | NOT NULL "storedAt" |
| app_artifact_updatedAt_not_null | n | NOT NULL "updatedAt" |
| app_artifact_uploadStatus_not_null | n | NOT NULL "uploadStatus" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_307f7470d2b759f7c4bc056d3a5 | CREATE UNIQUE INDEX "PK_307f7470d2b759f7c4bc056d3a5" ON public.app_artifact USING btree (id) |

## Relations

```mermaid
erDiagram

"public.app_version" }o--o| "public.app_artifact" : "FOREIGN KEY (#quot;bundleArtifactId#quot;) REFERENCES app_artifact(id) ON DELETE SET NULL"
"public.app_version" }o--|| "public.app_artifact" : "FOREIGN KEY (#quot;sourceArtifactId#quot;) REFERENCES app_artifact(id) ON DELETE RESTRICT"

"public.app_artifact" {
  uuid appId
  timestamp_3__with_time_zone createdAt
  integer id
  integer sizeBytes
  text storageKey
  varchar_2_ storedAt
  timestamp_3__with_time_zone updatedAt
  varchar_16_ uploadStatus
}
"public.app_version" {
  uuid appId FK
  integer buildAttempts
  varchar_16_ buildStatus
  timestamp_3__with_time_zone buildStatusUpdatedAt
  integer bundleArtifactId FK
  timestamp_3__with_time_zone createdAt
  uuid id
  varchar_255_ label
  integer sourceArtifactId FK
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.App Version (`docs/generated/postgres-schema/public.app_version.md`)

# public.app_version

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| appId | uuid |  | false |  | [public.app](public.app.md) |  |
| buildAttempts | integer | 0 | false |  |  |  |
| buildStatus | varchar(16) | 'queued'::character varying | false |  |  | Build state: queued, running, succeeded, or failed |
| buildStatusUpdatedAt | timestamp(3) with time zone |  | true |  |  |  |
| bundleArtifactId | integer |  | true |  | [public.app_artifact](public.app_artifact.md) |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | uuid |  | false | [public.app](public.app.md) |  |  |
| label | varchar(255) |  | true |  |  |  |
| sourceArtifactId | integer |  | false |  | [public.app_artifact](public.app_artifact.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_app_version_buildStatus | CHECK | CHECK ((("buildStatus")::text = ANY ((ARRAY['queued'::character varying, 'running'::character varying, 'succeeded'::character varying, 'failed'::character varying])::text[]))) |
| FK_2ab536cbf97d71bad59517afee5 | FOREIGN KEY | FOREIGN KEY ("bundleArtifactId") REFERENCES app_artifact(id) ON DELETE SET NULL |
| FK_9f1db6f02f5a0d1ae2f2b41a327 | FOREIGN KEY | FOREIGN KEY ("sourceArtifactId") REFERENCES app_artifact(id) ON DELETE RESTRICT |
| FK_e9aeab5b1db8dc77708231ae44e | FOREIGN KEY | FOREIGN KEY ("appId") REFERENCES app(id) ON DELETE CASCADE |
| PK_f2573b981a7eac664875e7483ac | PRIMARY KEY | PRIMARY KEY (id) |
| app_version_appId_not_null | n | NOT NULL "appId" |
| app_version_buildAttempts_not_null | n | NOT NULL "buildAttempts" |
| app_version_buildStatus_not_null | n | NOT NULL "buildStatus" |
| app_version_createdAt_not_null | n | NOT NULL "createdAt" |
| app_version_id_not_null | n | NOT NULL id |
| app_version_sourceArtifactId_not_null | n | NOT NULL "sourceArtifactId" |
| app_version_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_2ab536cbf97d71bad59517afee | CREATE INDEX "IDX_2ab536cbf97d71bad59517afee" ON public.app_version USING btree ("bundleArtifactId") |
| IDX_9f1db6f02f5a0d1ae2f2b41a32 | CREATE INDEX "IDX_9f1db6f02f5a0d1ae2f2b41a32" ON public.app_version USING btree ("sourceArtifactId") |
| IDX_e9aeab5b1db8dc77708231ae44 | CREATE INDEX "IDX_e9aeab5b1db8dc77708231ae44" ON public.app_version USING btree ("appId") |
| PK_f2573b981a7eac664875e7483ac | CREATE UNIQUE INDEX "PK_f2573b981a7eac664875e7483ac" ON public.app_version USING btree (id) |

## Relations

```mermaid
erDiagram

"public.app_version" }o--|| "public.app" : "FOREIGN KEY (#quot;appId#quot;) REFERENCES app(id) ON DELETE CASCADE"
"public.app_version" }o--o| "public.app_artifact" : "FOREIGN KEY (#quot;bundleArtifactId#quot;) REFERENCES app_artifact(id) ON DELETE SET NULL"
"public.app" }o--o| "public.app_version" : "FOREIGN KEY (#quot;draftVersionId#quot;) REFERENCES app_version(id) ON DELETE SET NULL"
"public.app" }o--o| "public.app_version" : "FOREIGN KEY (#quot;publishedVersionId#quot;) REFERENCES app_version(id) ON DELETE SET NULL"
"public.app_version" }o--|| "public.app_artifact" : "FOREIGN KEY (#quot;sourceArtifactId#quot;) REFERENCES app_artifact(id) ON DELETE RESTRICT"

"public.app_version" {
  uuid appId FK
  integer buildAttempts
  varchar_16_ buildStatus
  timestamp_3__with_time_zone buildStatusUpdatedAt
  integer bundleArtifactId FK
  timestamp_3__with_time_zone createdAt
  uuid id
  varchar_255_ label
  integer sourceArtifactId FK
  timestamp_3__with_time_zone updatedAt
}
"public.app" {
  timestamp_3__with_time_zone createdAt
  uuid draftVersionId FK
  uuid id
  varchar_128_ name
  varchar_128_ namespace
  varchar_36_ projectId FK
  uuid publishedVersionId FK
  timestamp_3__with_time_zone updatedAt
  varchar_16_ visibility
}
"public.app_artifact" {
  uuid appId
  timestamp_3__with_time_zone createdAt
  integer id
  integer sizeBytes
  text storageKey
  varchar_2_ storedAt
  timestamp_3__with_time_zone updatedAt
  varchar_16_ uploadStatus
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Auth Identity (`docs/generated/postgres-schema/public.auth_identity.md`)

# public.auth_identity

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| providerId | varchar(255) |  | false |  |  |  |
| providerType | varchar(32) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | true |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| auth_identity_createdAt_not_null | n | NOT NULL "createdAt" |
| auth_identity_pkey | PRIMARY KEY | PRIMARY KEY ("providerId", "providerType") |
| auth_identity_providerId_not_null | n | NOT NULL "providerId" |
| auth_identity_providerType_not_null | n | NOT NULL "providerType" |
| auth_identity_updatedAt_not_null | n | NOT NULL "updatedAt" |
| auth_identity_userId_fkey | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) |

## Indexes

| Name | Definition |
| ---- | ---------- |
| auth_identity_pkey | CREATE UNIQUE INDEX auth_identity_pkey ON public.auth_identity USING btree ("providerId", "providerType") |

## Relations

```mermaid
erDiagram

"public.auth_identity" }o--o| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id)"

"public.auth_identity" {
  timestamp_3__with_time_zone createdAt
  varchar_255_ providerId
  varchar_32_ providerType
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Auth Provider Sync History (`docs/generated/postgres-schema/public.auth_provider_sync_history.md`)

# public.auth_provider_sync_history

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| created | integer |  | false |  |  |  |
| disabled | integer |  | false |  |  |  |
| endedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP | false |  |  |  |
| error | text |  | true |  |  |  |
| id | integer | nextval('auth_provider_sync_history_id_seq'::regclass) | false |  |  |  |
| providerType | varchar(32) |  | false |  |  |  |
| runMode | text |  | false |  |  |  |
| scanned | integer |  | false |  |  |  |
| startedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP | false |  |  |  |
| status | text |  | false |  |  |  |
| updated | integer |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| auth_provider_sync_history_created_not_null | n | NOT NULL created |
| auth_provider_sync_history_disabled_not_null | n | NOT NULL disabled |
| auth_provider_sync_history_endedAt_not_null | n | NOT NULL "endedAt" |
| auth_provider_sync_history_id_not_null | n | NOT NULL id |
| auth_provider_sync_history_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| auth_provider_sync_history_providerType_not_null | n | NOT NULL "providerType" |
| auth_provider_sync_history_runMode_not_null | n | NOT NULL "runMode" |
| auth_provider_sync_history_scanned_not_null | n | NOT NULL scanned |
| auth_provider_sync_history_startedAt_not_null | n | NOT NULL "startedAt" |
| auth_provider_sync_history_status_not_null | n | NOT NULL status |
| auth_provider_sync_history_updated_not_null | n | NOT NULL updated |

## Indexes

| Name | Definition |
| ---- | ---------- |
| auth_provider_sync_history_pkey | CREATE UNIQUE INDEX auth_provider_sync_history_pkey ON public.auth_provider_sync_history USING btree (id) |

## Relations

```mermaid
erDiagram


"public.auth_provider_sync_history" {
  integer created
  integer disabled
  timestamp_3__with_time_zone endedAt
  text error
  integer id
  varchar_32_ providerType
  text runMode
  integer scanned
  timestamp_3__with_time_zone startedAt
  text status
  integer updated
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Binary Data (`docs/generated/postgres-schema/public.binary_data.md`)

# public.binary_data

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| data | bytea |  | false |  |  | Raw, not base64 encoded |
| fileId | uuid |  | false |  |  |  |
| fileName | varchar(255) |  | true |  |  |  |
| fileSize | integer |  | false |  |  | In bytes |
| mimeType | varchar(255) |  | true |  |  |  |
| sourceId | varchar(255) |  | false |  |  | ID of the source, e.g. execution ID |
| sourceType | varchar(50) |  | false |  |  | Source the file belongs to, e.g. 'execution' |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_binary_data_sourceType | CHECK | CHECK ((("sourceType")::text = ANY ((ARRAY['execution'::character varying, 'chat_message_attachment'::character varying, 'agent_file'::character varying, 'agent_chat_attachment'::character varying, 'app_artifact'::character varying])::text[]))) NOT VALID |
| PK_fc3691585b39408bb0551122af6 | PRIMARY KEY | PRIMARY KEY ("fileId") |
| binary_data_createdAt_not_null | n | NOT NULL "createdAt" |
| binary_data_data_not_null | n | NOT NULL data |
| binary_data_fileId_not_null | n | NOT NULL "fileId" |
| binary_data_fileSize_not_null | n | NOT NULL "fileSize" |
| binary_data_sourceId_not_null | n | NOT NULL "sourceId" |
| binary_data_sourceType_not_null | n | NOT NULL "sourceType" |
| binary_data_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_56900edc3cfd16612e2ef2c6a8 | CREATE INDEX "IDX_56900edc3cfd16612e2ef2c6a8" ON public.binary_data USING btree ("sourceType", "sourceId") |
| PK_fc3691585b39408bb0551122af6 | CREATE UNIQUE INDEX "PK_fc3691585b39408bb0551122af6" ON public.binary_data USING btree ("fileId") |

## Relations

```mermaid
erDiagram


"public.binary_data" {
  timestamp_3__with_time_zone createdAt
  bytea data
  uuid fileId
  varchar_255_ fileName
  integer fileSize
  varchar_255_ mimeType
  varchar_255_ sourceId
  varchar_50_ sourceType
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Agent Tools (`docs/generated/postgres-schema/public.chat_hub_agent_tools.md`)

# public.chat_hub_agent_tools

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | uuid |  | false |  | [public.chat_hub_agents](public.chat_hub_agents.md) |  |
| toolId | uuid |  | false |  | [public.chat_hub_tools](public.chat_hub_tools.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_2b53d796b3dbae91b1a9553c048 | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES chat_hub_agents(id) ON DELETE CASCADE |
| FK_43e70f04c53344f82483d0570f6 | FOREIGN KEY | FOREIGN KEY ("toolId") REFERENCES chat_hub_tools(id) ON DELETE CASCADE |
| PK_cc8806fdea48297a7d497035d72 | PRIMARY KEY | PRIMARY KEY ("agentId", "toolId") |
| chat_hub_agent_tools_agentId_not_null | n | NOT NULL "agentId" |
| chat_hub_agent_tools_toolId_not_null | n | NOT NULL "toolId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_cc8806fdea48297a7d497035d72 | CREATE UNIQUE INDEX "PK_cc8806fdea48297a7d497035d72" ON public.chat_hub_agent_tools USING btree ("agentId", "toolId") |

## Relations

```mermaid
erDiagram

"public.chat_hub_agent_tools" }o--|| "public.chat_hub_agents" : "FOREIGN KEY (#quot;agentId#quot;) REFERENCES chat_hub_agents(id) ON DELETE CASCADE"
"public.chat_hub_agent_tools" }o--|| "public.chat_hub_tools" : "FOREIGN KEY (#quot;toolId#quot;) REFERENCES chat_hub_tools(id) ON DELETE CASCADE"

"public.chat_hub_agent_tools" {
  uuid agentId FK
  uuid toolId FK
}
"public.chat_hub_agents" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ credentialId FK
  varchar_512_ description
  json files
  json icon
  uuid id
  varchar_64_ model
  varchar_256_ name
  uuid ownerId FK
  varchar_16_ provider
  json suggestedPrompts
  text systemPrompt
  timestamp_3__with_time_zone updatedAt
}
"public.chat_hub_tools" {
  timestamp_3__with_time_zone createdAt
  json definition
  boolean enabled
  uuid id
  varchar_255_ name
  uuid ownerId FK
  varchar_255_ type
  double_precision typeVersion
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Agents (`docs/generated/postgres-schema/public.chat_hub_agents.md`)

# public.chat_hub_agents

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | true |  | [public.credentials_entity](public.credentials_entity.md) |  |
| description | varchar(512) |  | true |  |  |  |
| files | json | '[]'::json | false |  |  |  |
| icon | json |  | true |  |  |  |
| id | uuid |  | false | [public.chat_hub_agent_tools](public.chat_hub_agent_tools.md) [public.chat_hub_messages](public.chat_hub_messages.md) [public.chat_hub_sessions](public.chat_hub_sessions.md) |  |  |
| model | varchar(64) |  | false |  |  | Model name used at the respective Model node, ie. "gpt-4" |
| name | varchar(256) |  | false |  |  |  |
| ownerId | uuid |  | false |  | [public.user](public.user.md) |  |
| provider | varchar(16) |  | false |  |  | ChatHubProvider enum: "openai", "anthropic", "google", "n8n" |
| suggestedPrompts | json | '[]'::json | false |  |  |  |
| systemPrompt | text |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_441ba2caba11e077ce3fbfa2cd8 | FOREIGN KEY | FOREIGN KEY ("ownerId") REFERENCES "user"(id) ON DELETE CASCADE |
| FK_9c61ad497dcbae499c96a6a78ba | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE SET NULL |
| PK_f39a3b36bbdf0e2979ddb21cf78 | PRIMARY KEY | PRIMARY KEY (id) |
| chat_hub_agents_createdAt_not_null | n | NOT NULL "createdAt" |
| chat_hub_agents_files_not_null | n | NOT NULL files |
| chat_hub_agents_id_not_null | n | NOT NULL id |
| chat_hub_agents_model_not_null | n | NOT NULL model |
| chat_hub_agents_name_not_null | n | NOT NULL name |
| chat_hub_agents_ownerId_not_null | n | NOT NULL "ownerId" |
| chat_hub_agents_provider_not_null | n | NOT NULL provider |
| chat_hub_agents_suggestedPrompts_not_null | n | NOT NULL "suggestedPrompts" |
| chat_hub_agents_systemPrompt_not_null | n | NOT NULL "systemPrompt" |
| chat_hub_agents_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_f39a3b36bbdf0e2979ddb21cf78 | CREATE UNIQUE INDEX "PK_f39a3b36bbdf0e2979ddb21cf78" ON public.chat_hub_agents USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Messages (`docs/generated/postgres-schema/public.chat_hub_messages.md`)

# public.chat_hub_messages

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | uuid |  | true |  | [public.chat_hub_agents](public.chat_hub_agents.md) | ID of the custom agent (if provider is "custom-agent") |
| attachments | json |  | true |  |  | File attachments for the message (if any), stored as JSON. Files are stored as base64-encoded data URLs. |
| content | text |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| executionId | integer |  | true |  | [public.execution_entity](public.execution_entity.md) |  |
| id | uuid |  | false | [public.chat_hub_messages](public.chat_hub_messages.md) |  |  |
| model | varchar(256) |  | true |  |  | Model name used at the respective Model node, ie. "gpt-4" |
| name | varchar(128) |  | false |  |  |  |
| previousMessageId | uuid |  | true |  | [public.chat_hub_messages](public.chat_hub_messages.md) |  |
| provider | varchar(16) |  | true |  |  | ChatHubProvider enum: "openai", "anthropic", "google", "n8n" |
| retryOfMessageId | uuid |  | true |  | [public.chat_hub_messages](public.chat_hub_messages.md) |  |
| revisionOfMessageId | uuid |  | true |  | [public.chat_hub_messages](public.chat_hub_messages.md) |  |
| sessionId | uuid |  | false |  | [public.chat_hub_sessions](public.chat_hub_sessions.md) |  |
| status | varchar(16) | 'success'::character varying | false |  |  | ChatHubMessageStatus enum, eg. "success", "error", "running", "cancelled" |
| type | varchar(16) |  | false |  |  | ChatHubMessageType enum: "human", "ai", "system", "tool", "generic" |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | true |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1f4998c8a7dec9e00a9ab15550e | FOREIGN KEY | FOREIGN KEY ("revisionOfMessageId") REFERENCES chat_hub_messages(id) ON DELETE CASCADE |
| FK_25c9736e7f769f3a005eef4b372 | FOREIGN KEY | FOREIGN KEY ("retryOfMessageId") REFERENCES chat_hub_messages(id) ON DELETE CASCADE |
| FK_6afb260449dd7a9b85355d4e0c9 | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES execution_entity(id) ON DELETE SET NULL |
| FK_acf8926098f063cdbbad8497fd1 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE SET NULL |
| FK_chat_hub_messages_agentId | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES chat_hub_agents(id) ON DELETE SET NULL |
| FK_e22538eb50a71a17954cd7e076c | FOREIGN KEY | FOREIGN KEY ("sessionId") REFERENCES chat_hub_sessions(id) ON DELETE CASCADE |
| FK_e5d1fa722c5a8d38ac204746662 | FOREIGN KEY | FOREIGN KEY ("previousMessageId") REFERENCES chat_hub_messages(id) ON DELETE CASCADE |
| PK_7704a5add6baed43eef835f0bfb | PRIMARY KEY | PRIMARY KEY (id) |
| chat_hub_messages_content_not_null | n | NOT NULL content |
| chat_hub_messages_createdAt_not_null | n | NOT NULL "createdAt" |
| chat_hub_messages_id_not_null | n | NOT NULL id |
| chat_hub_messages_name_not_null | n | NOT NULL name |
| chat_hub_messages_sessionId_not_null | n | NOT NULL "sessionId" |
| chat_hub_messages_status_not_null | n | NOT NULL status |
| chat_hub_messages_type_not_null | n | NOT NULL type |
| chat_hub_messages_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_chat_hub_messages_sessionId | CREATE INDEX "IDX_chat_hub_messages_sessionId" ON public.chat_hub_messages USING btree ("sessionId") |
| PK_7704a5add6baed43eef835f0bfb | CREATE UNIQUE INDEX "PK_7704a5add6baed43eef835f0bfb" ON public.chat_hub_messages USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Session Tools (`docs/generated/postgres-schema/public.chat_hub_session_tools.md`)

# public.chat_hub_session_tools

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| sessionId | uuid |  | false |  | [public.chat_hub_sessions](public.chat_hub_sessions.md) |  |
| toolId | uuid |  | false |  | [public.chat_hub_tools](public.chat_hub_tools.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_6596a328affd8d4967ffb303eee | FOREIGN KEY | FOREIGN KEY ("toolId") REFERENCES chat_hub_tools(id) ON DELETE CASCADE |
| FK_e649bf1295f4ed8d4299ed290f9 | FOREIGN KEY | FOREIGN KEY ("sessionId") REFERENCES chat_hub_sessions(id) ON DELETE CASCADE |
| PK_87aea76ff4c274c4a5ac838ebe3 | PRIMARY KEY | PRIMARY KEY ("sessionId", "toolId") |
| chat_hub_session_tools_sessionId_not_null | n | NOT NULL "sessionId" |
| chat_hub_session_tools_toolId_not_null | n | NOT NULL "toolId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_87aea76ff4c274c4a5ac838ebe3 | CREATE UNIQUE INDEX "PK_87aea76ff4c274c4a5ac838ebe3" ON public.chat_hub_session_tools USING btree ("sessionId", "toolId") |

## Relations

```mermaid
erDiagram

"public.chat_hub_session_tools" }o--|| "public.chat_hub_sessions" : "FOREIGN KEY (#quot;sessionId#quot;) REFERENCES chat_hub_sessions(id) ON DELETE CASCADE"
"public.chat_hub_session_tools" }o--|| "public.chat_hub_tools" : "FOREIGN KEY (#quot;toolId#quot;) REFERENCES chat_hub_tools(id) ON DELETE CASCADE"

"public.chat_hub_session_tools" {
  uuid sessionId FK
  uuid toolId FK
}
"public.chat_hub_sessions" {
  uuid agentId FK
  varchar_128_ agentName
  timestamp_3__with_time_zone createdAt
  varchar_36_ credentialId FK
  uuid id
  timestamp_3__with_time_zone lastMessageAt
  varchar_256_ model
  uuid ownerId FK
  varchar_16_ provider
  varchar_256_ title
  varchar_16_ type
  timestamp_3__with_time_zone updatedAt
  varchar_36_ workflowId FK
}
"public.chat_hub_tools" {
  timestamp_3__with_time_zone createdAt
  json definition
  boolean enabled
  uuid id
  varchar_255_ name
  uuid ownerId FK
  varchar_255_ type
  double_precision typeVersion
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Sessions (`docs/generated/postgres-schema/public.chat_hub_sessions.md`)

# public.chat_hub_sessions

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| agentId | uuid |  | true |  | [public.chat_hub_agents](public.chat_hub_agents.md) | ID of the custom agent (if provider is "custom-agent") |
| agentName | varchar(128) |  | true |  |  | Cached name of the custom agent (if provider is "custom-agent") |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | true |  | [public.credentials_entity](public.credentials_entity.md) |  |
| id | uuid |  | false | [public.chat_hub_messages](public.chat_hub_messages.md) [public.chat_hub_session_tools](public.chat_hub_session_tools.md) |  |  |
| lastMessageAt | timestamp(3) with time zone |  | false |  |  |  |
| model | varchar(256) |  | true |  |  | Model name used at the respective Model node, ie. "gpt-4" |
| ownerId | uuid |  | false |  | [public.user](public.user.md) |  |
| provider | varchar(16) |  | true |  |  | ChatHubProvider enum: "openai", "anthropic", "google", "n8n" |
| title | varchar(256) |  | false |  |  |  |
| type | varchar(16) | 'production'::character varying | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | true |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_chat_hub_sessions_type | CHECK | CHECK (((type)::text = ANY ((ARRAY['production'::character varying, 'manual'::character varying])::text[]))) |
| FK_7bc13b4c7e6afbfaf9be326c189 | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE SET NULL |
| FK_9f9293d9f552496c40e0d1a8f80 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE SET NULL |
| FK_chat_hub_sessions_agentId | FOREIGN KEY | FOREIGN KEY ("agentId") REFERENCES chat_hub_agents(id) ON DELETE SET NULL |
| FK_e9ecf8ede7d989fcd18790fe36a | FOREIGN KEY | FOREIGN KEY ("ownerId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_1eafef1273c70e4464fec703412 | PRIMARY KEY | PRIMARY KEY (id) |
| chat_hub_sessions_createdAt_not_null | n | NOT NULL "createdAt" |
| chat_hub_sessions_id_not_null | n | NOT NULL id |
| chat_hub_sessions_lastMessageAt_not_null | n | NOT NULL "lastMessageAt" |
| chat_hub_sessions_ownerId_not_null | n | NOT NULL "ownerId" |
| chat_hub_sessions_title_not_null | n | NOT NULL title |
| chat_hub_sessions_type_not_null | n | NOT NULL type |
| chat_hub_sessions_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_chat_hub_sessions_owner_lastmsg_id | CREATE INDEX "IDX_chat_hub_sessions_owner_lastmsg_id" ON public.chat_hub_sessions USING btree ("ownerId", "lastMessageAt" DESC, id) |
| PK_1eafef1273c70e4464fec703412 | CREATE UNIQUE INDEX "PK_1eafef1273c70e4464fec703412" ON public.chat_hub_sessions USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Chat Hub Tools (`docs/generated/postgres-schema/public.chat_hub_tools.md`)

# public.chat_hub_tools

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| definition | json |  | false |  |  |  |
| enabled | boolean | true | false |  |  |  |
| id | uuid |  | false | [public.chat_hub_agent_tools](public.chat_hub_agent_tools.md) [public.chat_hub_session_tools](public.chat_hub_session_tools.md) |  |  |
| name | varchar(255) |  | false |  |  |  |
| ownerId | uuid |  | false |  | [public.user](public.user.md) |  |
| type | varchar(255) |  | false |  |  |  |
| typeVersion | double precision |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_b8030b47af9213f1fd15450fb7f | FOREIGN KEY | FOREIGN KEY ("ownerId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_696d26426c704fba79b2c195ef5 | PRIMARY KEY | PRIMARY KEY (id) |
| chat_hub_tools_createdAt_not_null | n | NOT NULL "createdAt" |
| chat_hub_tools_definition_not_null | n | NOT NULL definition |
| chat_hub_tools_enabled_not_null | n | NOT NULL enabled |
| chat_hub_tools_id_not_null | n | NOT NULL id |
| chat_hub_tools_name_not_null | n | NOT NULL name |
| chat_hub_tools_ownerId_not_null | n | NOT NULL "ownerId" |
| chat_hub_tools_typeVersion_not_null | n | NOT NULL "typeVersion" |
| chat_hub_tools_type_not_null | n | NOT NULL type |
| chat_hub_tools_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_4c72ebdb265d1775bf61147af0 | CREATE UNIQUE INDEX "IDX_4c72ebdb265d1775bf61147af0" ON public.chat_hub_tools USING btree ("ownerId", name) |
| PK_696d26426c704fba79b2c195ef5 | CREATE UNIQUE INDEX "PK_696d26426c704fba79b2c195ef5" ON public.chat_hub_tools USING btree (id) |

## Relations

```mermaid
erDiagram

"public.chat_hub_agent_tools" }o--|| "public.chat_hub_tools" : "FOREIGN KEY (#quot;toolId#quot;) REFERENCES chat_hub_tools(id) ON DELETE CASCADE"
"public.chat_hub_session_tools" }o--|| "public.chat_hub_tools" : "FOREIGN KEY (#quot;toolId#quot;) REFERENCES chat_hub_tools(id) ON DELETE CASCADE"
"public.chat_hub_tools" }o--|| "public.user" : "FOREIGN KEY (#quot;ownerId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.chat_hub_tools" {
  timestamp_3__with_time_zone createdAt
  json definition
  boolean enabled
  uuid id
  varchar_255_ name
  uuid ownerId FK
  varchar_255_ type
  double_precision typeVersion
  timestamp_3__with_time_zone updatedAt
}
"public.chat_hub_agent_tools" {
  uuid agentId FK
  uuid toolId FK
}
"public.chat_hub_session_tools" {
  uuid sessionId FK
  uuid toolId FK
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Credential Dependency (`docs/generated/postgres-schema/public.credential_dependency.md`)

# public.credential_dependency

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | false |  | [public.credentials_entity](public.credentials_entity.md) |  |
| dependencyId | varchar(255) |  | false |  |  |  |
| dependencyType | varchar(64) |  | false |  |  |  |
| id | integer |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_5ec8e8c8d3539f3696cf73b43bf | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE CASCADE |
| PK_80212729ed0ffa0709417ab28f4 | PRIMARY KEY | PRIMARY KEY (id) |
| credential_dependency_createdAt_not_null | n | NOT NULL "createdAt" |
| credential_dependency_credentialId_not_null | n | NOT NULL "credentialId" |
| credential_dependency_dependencyId_not_null | n | NOT NULL "dependencyId" |
| credential_dependency_dependencyType_not_null | n | NOT NULL "dependencyType" |
| credential_dependency_id_not_null | n | NOT NULL id |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_5ec8e8c8d3539f3696cf73b43b | CREATE INDEX "IDX_5ec8e8c8d3539f3696cf73b43b" ON public.credential_dependency USING btree ("credentialId") |
| IDX_91ee85fa9619dd6776725e117b | CREATE INDEX "IDX_91ee85fa9619dd6776725e117b" ON public.credential_dependency USING btree ("dependencyType", "dependencyId") |
| IDX_credential_dependency_credentialId_dependencyType_dependenc | CREATE UNIQUE INDEX "IDX_credential_dependency_credentialId_dependencyType_dependenc" ON public.credential_dependency USING btree ("credentialId", "dependencyType", "dependencyId") |
| PK_80212729ed0ffa0709417ab28f4 | CREATE UNIQUE INDEX "PK_80212729ed0ffa0709417ab28f4" ON public.credential_dependency USING btree (id) |

## Relations

```mermaid
erDiagram

"public.credential_dependency" }o--|| "public.credentials_entity" : "FOREIGN KEY (#quot;credentialId#quot;) REFERENCES credentials_entity(id) ON DELETE CASCADE"

"public.credential_dependency" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ credentialId FK
  varchar_255_ dependencyId
  varchar_64_ dependencyType
  integer id
}
"public.credentials_entity" {
  timestamp_3__with_time_zone createdAt
  text data
  text description
  varchar_36_ id
  boolean isGlobal
  boolean isManaged
  boolean isResolvable
  varchar_128_ name
  timestamp_3__with_time_zone pendingAuthorizationExpiresAt
  boolean resolvableAllowFallback
  varchar_16_ resolverId FK
  varchar_128_ type
  timestamp_3__with_time_zone updatedAt
  varchar_16_ usageScope
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Credentials Entity (`docs/generated/postgres-schema/public.credentials_entity.md`)

# public.credentials_entity

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| data | text |  | false |  |  |  |
| description | text |  | true |  |  | User-supplied note on what the credential is for and where it belongs. Set and read through the credentials API |
| id | varchar(36) |  | false | [public.agent_credential_dependency](public.agent_credential_dependency.md) [public.chat_hub_agents](public.chat_hub_agents.md) [public.chat_hub_sessions](public.chat_hub_sessions.md) [public.credential_dependency](public.credential_dependency.md) [public.dynamic_credential_entry](public.dynamic_credential_entry.md) [public.dynamic_credential_user_entry](public.dynamic_credential_user_entry.md) [public.instance_ai_mcp_registry_connections](public.instance_ai_mcp_registry_connections.md) [public.instance_credential_assignment](public.instance_credential_assignment.md) [public.shared_credentials](public.shared_credentials.md) |  |  |
| isGlobal | boolean | false | false |  |  |  |
| isManaged | boolean | false | false |  |  |  |
| isResolvable | boolean | false | false |  |  |  |
| name | varchar(128) |  | false |  |  |  |
| pendingAuthorizationExpiresAt | timestamp(3) with time zone |  | true |  |  | Set on a credential created for an OAuth authorization the user has not completed yet. Cleared when a token is written; rows past this time are deleted by the pending-authorization cleanup task |
| resolvableAllowFallback | boolean | false | false |  |  |  |
| resolverId | varchar(16) |  | true |  | [public.dynamic_credential_resolver](public.dynamic_credential_resolver.md) |  |
| type | varchar(128) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| usageScope | varchar(16) | 'project'::character varying | false |  |  | Where the credential may be consumed: a project-owned feature or an instance-level feature |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_credentials_entity_usageScope | CHECK | CHECK ((("usageScope")::text = ANY ((ARRAY['project'::character varying, 'instance'::character varying])::text[]))) |
| credentials_entity_createdAt_not_null | n | NOT NULL "createdAt" |
| credentials_entity_data_not_null | n | NOT NULL data |
| credentials_entity_id_not_null1 | n | NOT NULL id |
| credentials_entity_isGlobal_not_null | n | NOT NULL "isGlobal" |
| credentials_entity_isManaged_not_null | n | NOT NULL "isManaged" |
| credentials_entity_isResolvable_not_null | n | NOT NULL "isResolvable" |
| credentials_entity_name_not_null | n | NOT NULL name |
| credentials_entity_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| credentials_entity_resolvableAllowFallback_not_null | n | NOT NULL "resolvableAllowFallback" |
| credentials_entity_resolverId_foreign | FOREIGN KEY | FOREIGN KEY ("resolverId") REFERENCES dynamic_credential_resolver(id) ON DELETE SET NULL |
| credentials_entity_type_not_null | n | NOT NULL type |
| credentials_entity_updatedAt_not_null | n | NOT NULL "updatedAt" |
| credentials_entity_usageScope_not_null | n | NOT NULL "usageScope" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_credentials_entity_is_global | CREATE INDEX "IDX_credentials_entity_is_global" ON public.credentials_entity USING btree (id) WHERE ("isGlobal" = true) |
| credentials_entity_pkey | CREATE UNIQUE INDEX credentials_entity_pkey ON public.credentials_entity USING btree (id) |
| idx_07fde106c0b471d8cc80a64fc8 | CREATE INDEX idx_07fde106c0b471d8cc80a64fc8 ON public.credentials_entity USING btree (type) |
| pk_credentials_entity_id | CREATE UNIQUE INDEX pk_credentials_entity_id ON public.credentials_entity USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Data Table (`docs/generated/postgres-schema/public.data_table.md`)

# public.data_table

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.data_table_column](public.data_table_column.md) |  |  |
| name | varchar(128) |  | false |  |  |  |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_c2a794257dee48af7c9abf681de | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_e226d0001b9e6097cbfe70617cb | PRIMARY KEY | PRIMARY KEY (id) |
| UQ_b23096ef747281ac944d28e8b0d | UNIQUE | UNIQUE ("projectId", name) |
| data_table_createdAt_not_null | n | NOT NULL "createdAt" |
| data_table_id_not_null | n | NOT NULL id |
| data_table_name_not_null | n | NOT NULL name |
| data_table_projectId_not_null | n | NOT NULL "projectId" |
| data_table_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_e226d0001b9e6097cbfe70617cb | CREATE UNIQUE INDEX "PK_e226d0001b9e6097cbfe70617cb" ON public.data_table USING btree (id) |
| UQ_b23096ef747281ac944d28e8b0d | CREATE UNIQUE INDEX "UQ_b23096ef747281ac944d28e8b0d" ON public.data_table USING btree ("projectId", name) |

## Relations

```mermaid
erDiagram

"public.data_table_column" }o--|| "public.data_table" : "FOREIGN KEY (#quot;dataTableId#quot;) REFERENCES data_table(id) ON DELETE CASCADE"
"public.data_table" }o--|| "public.project" : "FOREIGN KEY (#quot;projectId#quot;) REFERENCES project(id) ON DELETE CASCADE"

"public.data_table" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_128_ name
  varchar_36_ projectId FK
  timestamp_3__with_time_zone updatedAt
}
"public.data_table_column" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ dataTableId FK
  varchar_36_ id
  integer index
  varchar_128_ name
  varchar_32_ type
  timestamp_3__with_time_zone updatedAt
}
"public.project" {
  timestamp_3__with_time_zone createdAt
  uuid creatorId FK
  json customTelemetryTags
  varchar_512_ description
  json icon
  varchar_36_ id
  varchar_255_ name
  varchar_36_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Data Table Column (`docs/generated/postgres-schema/public.data_table_column.md`)

# public.data_table_column

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| dataTableId | varchar(36) |  | false |  | [public.data_table](public.data_table.md) |  |
| id | varchar(36) |  | false |  |  |  |
| index | integer |  | false |  |  | Column order, starting from 0 (0 = first column) |
| name | varchar(128) |  | false |  |  |  |
| type | varchar(32) |  | false |  |  | Expected: string, number, boolean, or date (not enforced as a constraint) |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_930b6e8faaf88294cef23484160 | FOREIGN KEY | FOREIGN KEY ("dataTableId") REFERENCES data_table(id) ON DELETE CASCADE |
| PK_673cb121ee4a8a5e27850c72c51 | PRIMARY KEY | PRIMARY KEY (id) |
| UQ_8082ec4890f892f0bc77473a123 | UNIQUE | UNIQUE ("dataTableId", name) |
| data_table_column_createdAt_not_null | n | NOT NULL "createdAt" |
| data_table_column_dataTableId_not_null | n | NOT NULL "dataTableId" |
| data_table_column_id_not_null | n | NOT NULL id |
| data_table_column_index_not_null | n | NOT NULL index |
| data_table_column_name_not_null | n | NOT NULL name |
| data_table_column_type_not_null | n | NOT NULL type |
| data_table_column_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_673cb121ee4a8a5e27850c72c51 | CREATE UNIQUE INDEX "PK_673cb121ee4a8a5e27850c72c51" ON public.data_table_column USING btree (id) |
| UQ_8082ec4890f892f0bc77473a123 | CREATE UNIQUE INDEX "UQ_8082ec4890f892f0bc77473a123" ON public.data_table_column USING btree ("dataTableId", name) |

## Relations

```mermaid
erDiagram

"public.data_table_column" }o--|| "public.data_table" : "FOREIGN KEY (#quot;dataTableId#quot;) REFERENCES data_table(id) ON DELETE CASCADE"

"public.data_table_column" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ dataTableId FK
  varchar_36_ id
  integer index
  varchar_128_ name
  varchar_32_ type
  timestamp_3__with_time_zone updatedAt
}
"public.data_table" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_128_ name
  varchar_36_ projectId FK
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Deployment Key (`docs/generated/postgres-schema/public.deployment_key.md`)

# public.deployment_key

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| algorithm | varchar(20) |  | true |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| status | varchar(20) |  | false |  |  |  |
| type | varchar(64) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| value | text |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_94bb7aeb5def5a0284a5fe9f9a0 | PRIMARY KEY | PRIMARY KEY (id) |
| deployment_key_createdAt_not_null | n | NOT NULL "createdAt" |
| deployment_key_id_not_null | n | NOT NULL id |
| deployment_key_status_not_null | n | NOT NULL status |
| deployment_key_type_not_null | n | NOT NULL type |
| deployment_key_updatedAt_not_null | n | NOT NULL "updatedAt" |
| deployment_key_value_not_null | n | NOT NULL value |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_deployment_key_data_encryption_active | CREATE UNIQUE INDEX "IDX_deployment_key_data_encryption_active" ON public.deployment_key USING btree (type) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'data_encryption'::text)) |
| IDX_deployment_key_instance_id_active | CREATE UNIQUE INDEX "IDX_deployment_key_instance_id_active" ON public.deployment_key USING btree (type) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'instance.id'::text)) |
| IDX_deployment_key_jwe_private_key_active | CREATE UNIQUE INDEX "IDX_deployment_key_jwe_private_key_active" ON public.deployment_key USING btree (type, algorithm) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'jwe.private-key'::text)) |
| IDX_deployment_key_oauth_signing_key_active | CREATE UNIQUE INDEX "IDX_deployment_key_oauth_signing_key_active" ON public.deployment_key USING btree (type, algorithm) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'oauth-server.signing-key'::text)) |
| IDX_deployment_key_signing_binary_data_active | CREATE UNIQUE INDEX "IDX_deployment_key_signing_binary_data_active" ON public.deployment_key USING btree (type) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'signing.binary_data'::text)) |
| IDX_deployment_key_signing_hmac_active | CREATE UNIQUE INDEX "IDX_deployment_key_signing_hmac_active" ON public.deployment_key USING btree (type) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'signing.hmac'::text)) |
| IDX_deployment_key_signing_jwt_active | CREATE UNIQUE INDEX "IDX_deployment_key_signing_jwt_active" ON public.deployment_key USING btree (type) WHERE (((status)::text = 'active'::text) AND ((type)::text = 'signing.jwt'::text)) |
| PK_94bb7aeb5def5a0284a5fe9f9a0 | CREATE UNIQUE INDEX "PK_94bb7aeb5def5a0284a5fe9f9a0" ON public.deployment_key USING btree (id) |

## Triggers

| Name | Definition |
| ---- | ---------- |
| prevent_deployment_key_delete | CREATE TRIGGER prevent_deployment_key_delete BEFORE DELETE ON public.deployment_key FOR EACH STATEMENT EXECUTE FUNCTION prevent_deployment_key_delete() |
| prevent_deployment_key_truncate | CREATE TRIGGER prevent_deployment_key_truncate BEFORE TRUNCATE ON public.deployment_key FOR EACH STATEMENT EXECUTE FUNCTION prevent_deployment_key_delete() |

## Relations

```mermaid
erDiagram


"public.deployment_key" {
  varchar_20_ algorithm
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_20_ status
  varchar_64_ type
  timestamp_3__with_time_zone updatedAt
  text value
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Dynamic Credential Entry (`docs/generated/postgres-schema/public.dynamic_credential_entry.md`)

# public.dynamic_credential_entry

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credential_id | varchar(16) |  | false |  | [public.credentials_entity](public.credentials_entity.md) |  |
| data | text |  | false |  |  |  |
| resolver_id | varchar(16) |  | false |  | [public.dynamic_credential_resolver](public.dynamic_credential_resolver.md) |  |
| subject_id | varchar(2048) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_a6d1dd080958304a47a02952aab | FOREIGN KEY | FOREIGN KEY (credential_id) REFERENCES credentials_entity(id) ON DELETE CASCADE |
| FK_d61a12235d268a49af6a3c09c13 | FOREIGN KEY | FOREIGN KEY (resolver_id) REFERENCES dynamic_credential_resolver(id) ON DELETE CASCADE |
| PK_5135ffcabecad4727ff6b9b803d | PRIMARY KEY | PRIMARY KEY (credential_id, subject_id, resolver_id) |
| tmp_dynamic_credential_entry_createdAt_not_null | n | NOT NULL "createdAt" |
| tmp_dynamic_credential_entry_credential_id_not_null | n | NOT NULL credential_id |
| tmp_dynamic_credential_entry_data_not_null | n | NOT NULL data |
| tmp_dynamic_credential_entry_resolver_id_not_null | n | NOT NULL resolver_id |
| tmp_dynamic_credential_entry_subject_id_not_null | n | NOT NULL subject_id |
| tmp_dynamic_credential_entry_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_62476b94b56d9dc7ed9ed75d3d | CREATE INDEX "IDX_62476b94b56d9dc7ed9ed75d3d" ON public.dynamic_credential_entry USING btree (subject_id) |
| IDX_d61a12235d268a49af6a3c09c1 | CREATE INDEX "IDX_d61a12235d268a49af6a3c09c1" ON public.dynamic_credential_entry USING btree (resolver_id) |
| PK_5135ffcabecad4727ff6b9b803d | CREATE UNIQUE INDEX "PK_5135ffcabecad4727ff6b9b803d" ON public.dynamic_credential_entry USING btree (credential_id, subject_id, resolver_id) |

## Relations

```mermaid
erDiagram

"public.dynamic_credential_entry" }o--|| "public.credentials_entity" : "FOREIGN KEY (credential_id) REFERENCES credentials_entity(id) ON DELETE CASCADE"
"public.dynamic_credential_entry" }o--|| "public.dynamic_credential_resolver" : "FOREIGN KEY (resolver_id) REFERENCES dynamic_credential_resolver(id) ON DELETE CASCADE"

"public.dynamic_credential_entry" {
  timestamp_3__with_time_zone createdAt
  varchar_16_ credential_id FK
  text data
  varchar_16_ resolver_id FK
  varchar_2048_ subject_id
  timestamp_3__with_time_zone updatedAt
}
"public.credentials_entity" {
  timestamp_3__with_time_zone createdAt
  text data
  text description
  varchar_36_ id
  boolean isGlobal
  boolean isManaged
  boolean isResolvable
  varchar_128_ name
  timestamp_3__with_time_zone pendingAuthorizationExpiresAt
  boolean resolvableAllowFallback
  varchar_16_ resolverId FK
  varchar_128_ type
  timestamp_3__with_time_zone updatedAt
  varchar_16_ usageScope
}
"public.dynamic_credential_resolver" {
  text config
  timestamp_3__with_time_zone createdAt
  varchar_16_ id
  varchar_128_ name
  varchar_128_ type
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Dynamic Credential Resolver (`docs/generated/postgres-schema/public.dynamic_credential_resolver.md`)

# public.dynamic_credential_resolver

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| config | text |  | false |  |  | Encrypted resolver configuration (JSON encrypted as string) |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(16) |  | false | [public.credentials_entity](public.credentials_entity.md) [public.dynamic_credential_entry](public.dynamic_credential_entry.md) [public.dynamic_credential_user_entry](public.dynamic_credential_user_entry.md) |  |  |
| name | varchar(128) |  | false |  |  |  |
| type | varchar(128) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_b76cfb088dcdaf5275e9980bb64 | PRIMARY KEY | PRIMARY KEY (id) |
| dynamic_credential_resolver_config_not_null | n | NOT NULL config |
| dynamic_credential_resolver_createdAt_not_null | n | NOT NULL "createdAt" |
| dynamic_credential_resolver_id_not_null | n | NOT NULL id |
| dynamic_credential_resolver_name_not_null | n | NOT NULL name |
| dynamic_credential_resolver_type_not_null | n | NOT NULL type |
| dynamic_credential_resolver_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_9c9ee9df586e60bb723234e499 | CREATE INDEX "IDX_9c9ee9df586e60bb723234e499" ON public.dynamic_credential_resolver USING btree (type) |
| PK_b76cfb088dcdaf5275e9980bb64 | CREATE UNIQUE INDEX "PK_b76cfb088dcdaf5275e9980bb64" ON public.dynamic_credential_resolver USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Dynamic Credential User Entry (`docs/generated/postgres-schema/public.dynamic_credential_user_entry.md`)

# public.dynamic_credential_user_entry

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(16) |  | false |  | [public.credentials_entity](public.credentials_entity.md) |  |
| data | text |  | false |  |  |  |
| resolverId | varchar(16) |  | false |  | [public.dynamic_credential_resolver](public.dynamic_credential_resolver.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_6edec973a6450990977bb854c38 | FOREIGN KEY | FOREIGN KEY ("resolverId") REFERENCES dynamic_credential_resolver(id) ON DELETE CASCADE |
| FK_945ba70b342a066d1306b12ccd2 | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE CASCADE |
| FK_a36dc616fabc3f736bb82410a22 | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_74f548e633abc66dc27c8f0ca77 | PRIMARY KEY | PRIMARY KEY ("credentialId", "userId", "resolverId") |
| dynamic_credential_user_entry_createdAt_not_null | n | NOT NULL "createdAt" |
| dynamic_credential_user_entry_credentialId_not_null | n | NOT NULL "credentialId" |
| dynamic_credential_user_entry_data_not_null | n | NOT NULL data |
| dynamic_credential_user_entry_resolverId_not_null | n | NOT NULL "resolverId" |
| dynamic_credential_user_entry_updatedAt_not_null | n | NOT NULL "updatedAt" |
| dynamic_credential_user_entry_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_6edec973a6450990977bb854c3 | CREATE INDEX "IDX_6edec973a6450990977bb854c3" ON public.dynamic_credential_user_entry USING btree ("resolverId") |
| IDX_a36dc616fabc3f736bb82410a2 | CREATE INDEX "IDX_a36dc616fabc3f736bb82410a2" ON public.dynamic_credential_user_entry USING btree ("userId") |
| PK_74f548e633abc66dc27c8f0ca77 | CREATE UNIQUE INDEX "PK_74f548e633abc66dc27c8f0ca77" ON public.dynamic_credential_user_entry USING btree ("credentialId", "userId", "resolverId") |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Evaluation Collection (`docs/generated/postgres-schema/public.evaluation_collection.md`)

# public.evaluation_collection

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| createdById | uuid |  | true |  | [public.user](public.user.md) |  |
| description | text |  | true |  |  |  |
| evaluationConfigId | varchar(36) |  | false |  | [public.evaluation_config](public.evaluation_config.md) |  |
| id | varchar(36) |  | false | [public.test_run](public.test_run.md) |  |  |
| insightsCache | json |  | true |  |  |  |
| name | varchar(128) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | false |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_a48ce930c3bc7604894b8f0eaad | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE CASCADE |
| FK_d634a0c93fd7de68a87eab951b2 | FOREIGN KEY | FOREIGN KEY ("evaluationConfigId") REFERENCES evaluation_config(id) ON DELETE CASCADE |
| FK_f4561f38b5a22a4f090d5cd3eae | FOREIGN KEY | FOREIGN KEY ("createdById") REFERENCES "user"(id) ON DELETE SET NULL |
| PK_e720b6efc1e45b878ebb0b2ca30 | PRIMARY KEY | PRIMARY KEY (id) |
| evaluation_collection_createdAt_not_null | n | NOT NULL "createdAt" |
| evaluation_collection_evaluationConfigId_not_null | n | NOT NULL "evaluationConfigId" |
| evaluation_collection_id_not_null | n | NOT NULL id |
| evaluation_collection_name_not_null | n | NOT NULL name |
| evaluation_collection_updatedAt_not_null | n | NOT NULL "updatedAt" |
| evaluation_collection_workflowId_not_null | n | NOT NULL "workflowId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a48ce930c3bc7604894b8f0eaa | CREATE INDEX "IDX_a48ce930c3bc7604894b8f0eaa" ON public.evaluation_collection USING btree ("workflowId") |
| IDX_d634a0c93fd7de68a87eab951b | CREATE INDEX "IDX_d634a0c93fd7de68a87eab951b" ON public.evaluation_collection USING btree ("evaluationConfigId") |
| PK_e720b6efc1e45b878ebb0b2ca30 | CREATE UNIQUE INDEX "PK_e720b6efc1e45b878ebb0b2ca30" ON public.evaluation_collection USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Evaluation Config (`docs/generated/postgres-schema/public.evaluation_config.md`)

# public.evaluation_config

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| datasetRef | json |  | false |  |  |  |
| datasetSource | varchar(32) |  | false |  |  |  |
| endNodeName | varchar(255) |  | false |  |  |  |
| id | varchar(36) |  | false | [public.evaluation_collection](public.evaluation_collection.md) [public.test_run](public.test_run.md) |  |  |
| invalidReason | varchar(64) |  | true |  |  |  |
| metrics | json |  | false |  |  |  |
| name | varchar(128) |  | false |  |  |  |
| startNodeName | varchar(255) |  | false |  |  |  |
| status | varchar(16) | 'valid'::character varying | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workflowId | varchar(36) |  | false |  | [public.workflow_entity](public.workflow_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_fd7542bb123074760285dc1bbf3 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE CASCADE |
| PK_59c14dccf8989df94070c2dcfda | PRIMARY KEY | PRIMARY KEY (id) |
| UQ_3c3c99a712e971835c52292e44c | UNIQUE | UNIQUE ("workflowId", name) |
| evaluation_config_createdAt_not_null | n | NOT NULL "createdAt" |
| evaluation_config_datasetRef_not_null | n | NOT NULL "datasetRef" |
| evaluation_config_datasetSource_not_null | n | NOT NULL "datasetSource" |
| evaluation_config_endNodeName_not_null | n | NOT NULL "endNodeName" |
| evaluation_config_id_not_null | n | NOT NULL id |
| evaluation_config_metrics_not_null | n | NOT NULL metrics |
| evaluation_config_name_not_null | n | NOT NULL name |
| evaluation_config_startNodeName_not_null | n | NOT NULL "startNodeName" |
| evaluation_config_status_not_null | n | NOT NULL status |
| evaluation_config_updatedAt_not_null | n | NOT NULL "updatedAt" |
| evaluation_config_workflowId_not_null | n | NOT NULL "workflowId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_fd7542bb123074760285dc1bbf | CREATE INDEX "IDX_fd7542bb123074760285dc1bbf" ON public.evaluation_config USING btree ("workflowId") |
| PK_59c14dccf8989df94070c2dcfda | CREATE UNIQUE INDEX "PK_59c14dccf8989df94070c2dcfda" ON public.evaluation_config USING btree (id) |
| UQ_3c3c99a712e971835c52292e44c | CREATE UNIQUE INDEX "UQ_3c3c99a712e971835c52292e44c" ON public.evaluation_config USING btree ("workflowId", name) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Event Destinations (`docs/generated/postgres-schema/public.event_destinations.md`)

# public.event_destinations

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| destination | jsonb |  | false |  |  |  |
| id | uuid |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| event_destinations_createdAt_not_null | n | NOT NULL "createdAt" |
| event_destinations_destination_not_null | n | NOT NULL destination |
| event_destinations_id_not_null | n | NOT NULL id |
| event_destinations_pkey | PRIMARY KEY | PRIMARY KEY (id) |
| event_destinations_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| event_destinations_pkey | CREATE UNIQUE INDEX event_destinations_pkey ON public.event_destinations USING btree (id) |

## Relations

```mermaid
erDiagram


"public.event_destinations" {
  timestamp_3__with_time_zone createdAt
  jsonb destination
  uuid id
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Execution Annotation Tags (`docs/generated/postgres-schema/public.execution_annotation_tags.md`)

# public.execution_annotation_tags

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| annotationId | integer |  | false |  | [public.execution_annotations](public.execution_annotations.md) |  |
| tagId | varchar(24) |  | false |  | [public.annotation_tag_entity](public.annotation_tag_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_a3697779b366e131b2bbdae2976 | FOREIGN KEY | FOREIGN KEY ("tagId") REFERENCES annotation_tag_entity(id) ON DELETE CASCADE |
| FK_c1519757391996eb06064f0e7c8 | FOREIGN KEY | FOREIGN KEY ("annotationId") REFERENCES execution_annotations(id) ON DELETE CASCADE |
| PK_979ec03d31294cca484be65d11f | PRIMARY KEY | PRIMARY KEY ("annotationId", "tagId") |
| execution_annotation_tags_annotationId_not_null | n | NOT NULL "annotationId" |
| execution_annotation_tags_tagId_not_null | n | NOT NULL "tagId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_a3697779b366e131b2bbdae297 | CREATE INDEX "IDX_a3697779b366e131b2bbdae297" ON public.execution_annotation_tags USING btree ("tagId") |
| IDX_c1519757391996eb06064f0e7c | CREATE INDEX "IDX_c1519757391996eb06064f0e7c" ON public.execution_annotation_tags USING btree ("annotationId") |
| PK_979ec03d31294cca484be65d11f | CREATE UNIQUE INDEX "PK_979ec03d31294cca484be65d11f" ON public.execution_annotation_tags USING btree ("annotationId", "tagId") |

## Relations

```mermaid
erDiagram

"public.execution_annotation_tags" }o--|| "public.execution_annotations" : "FOREIGN KEY (#quot;annotationId#quot;) REFERENCES execution_annotations(id) ON DELETE CASCADE"
"public.execution_annotation_tags" }o--|| "public.annotation_tag_entity" : "FOREIGN KEY (#quot;tagId#quot;) REFERENCES annotation_tag_entity(id) ON DELETE CASCADE"

"public.execution_annotation_tags" {
  integer annotationId FK
  varchar_24_ tagId FK
}
"public.execution_annotations" {
  timestamp_3__with_time_zone createdAt
  integer executionId FK
  integer id
  text note
  timestamp_3__with_time_zone updatedAt
  varchar_6_ vote
}
"public.annotation_tag_entity" {
  timestamp_3__with_time_zone createdAt
  varchar_16_ id
  varchar_24_ name
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Execution Annotations (`docs/generated/postgres-schema/public.execution_annotations.md`)

# public.execution_annotations

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| executionId | integer |  | false |  | [public.execution_entity](public.execution_entity.md) |  |
| id | integer | nextval('execution_annotations_id_seq'::regclass) | false | [public.execution_annotation_tags](public.execution_annotation_tags.md) |  |  |
| note | text |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| vote | varchar(6) |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_97f863fa83c4786f19565084960 | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES execution_entity(id) ON DELETE CASCADE |
| PK_7afcf93ffa20c4252869a7c6a23 | PRIMARY KEY | PRIMARY KEY (id) |
| execution_annotations_createdAt_not_null | n | NOT NULL "createdAt" |
| execution_annotations_executionId_not_null | n | NOT NULL "executionId" |
| execution_annotations_id_not_null | n | NOT NULL id |
| execution_annotations_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_97f863fa83c4786f1956508496 | CREATE UNIQUE INDEX "IDX_97f863fa83c4786f1956508496" ON public.execution_annotations USING btree ("executionId") |
| PK_7afcf93ffa20c4252869a7c6a23 | CREATE UNIQUE INDEX "PK_7afcf93ffa20c4252869a7c6a23" ON public.execution_annotations USING btree (id) |

## Relations

```mermaid
erDiagram

"public.execution_annotations" }o--|| "public.execution_entity" : "FOREIGN KEY (#quot;executionId#quot;) REFERENCES execution_entity(id) ON DELETE CASCADE"
"public.execution_annotation_tags" }o--|| "public.execution_annotations" : "FOREIGN KEY (#quot;annotationId#quot;) REFERENCES execution_annotations(id) ON DELETE CASCADE"

"public.execution_annotations" {
  timestamp_3__with_time_zone createdAt
  integer executionId FK
  integer id
  text note
  timestamp_3__with_time_zone updatedAt
  varchar_6_ vote
}
"public.execution_entity" {
  bigint binaryDataSizeBytes
  timestamp_3__with_time_zone createdAt
  varchar_255_ deduplicationKey
  timestamp_3__with_time_zone deletedAt
  boolean finished
  integer id
  bigint jsonSizeBytes
  varchar mode
  varchar retryOf
  varchar retrySuccessId
  timestamp_3__with_time_zone startedAt
  varchar status
  timestamp_3__with_time_zone stoppedAt
  varchar_2_ storedAt
  json tracingContext
  boolean usedPrivateCredentials
  timestamp_3__with_time_zone waitTill
  varchar_36_ workflowId FK
  varchar_36_ workflowVersionId
}
"public.execution_annotation_tags" {
  integer annotationId FK
  varchar_24_ tagId FK
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Execution Data (`docs/generated/postgres-schema/public.execution_data.md`)

# public.execution_data

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| data | text |  | false |  |  |  |
| executionId | integer |  | false |  | [public.execution_entity](public.execution_entity.md) |  |
| workflowData | json |  | false |  |  |  |
| workflowVersionId | varchar(36) |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| execution_data_data_not_null | n | NOT NULL data |
| execution_data_executionId_not_null | n | NOT NULL "executionId" |
| execution_data_fk | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES execution_entity(id) ON DELETE CASCADE |
| execution_data_pkey | PRIMARY KEY | PRIMARY KEY ("executionId") |
| execution_data_workflowData_not_null | n | NOT NULL "workflowData" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| execution_data_pkey | CREATE UNIQUE INDEX execution_data_pkey ON public.execution_data USING btree ("executionId") |

## Relations

```mermaid
erDiagram

"public.execution_data" |o--|| "public.execution_entity" : "FOREIGN KEY (#quot;executionId#quot;) REFERENCES execution_entity(id) ON DELETE CASCADE"

"public.execution_data" {
  text data
  integer executionId FK
  json workflowData
  varchar_36_ workflowVersionId
}
"public.execution_entity" {
  bigint binaryDataSizeBytes
  timestamp_3__with_time_zone createdAt
  varchar_255_ deduplicationKey
  timestamp_3__with_time_zone deletedAt
  boolean finished
  integer id
  bigint jsonSizeBytes
  varchar mode
  varchar retryOf
  varchar retrySuccessId
  timestamp_3__with_time_zone startedAt
  varchar status
  timestamp_3__with_time_zone stoppedAt
  varchar_2_ storedAt
  json tracingContext
  boolean usedPrivateCredentials
  timestamp_3__with_time_zone waitTill
  varchar_36_ workflowId FK
  varchar_36_ workflowVersionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Execution Entity (`docs/generated/postgres-schema/public.execution_entity.md`)

# public.execution_entity

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| binaryDataSizeBytes | bigint | 0 | false |  |  | Byte size of binary data offloaded to separate storage (db/fs/S3), deduplicated by blob; excludes inline binary counted in jsonSizeBytes. 0 means unknown. |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| deduplicationKey | varchar(255) |  | true |  |  |  |
| deletedAt | timestamp(3) with time zone |  | true |  |  |  |
| finished | boolean |  | false |  |  |  |
| id | integer | nextval('execution_entity_id_seq'::regclass) | false | [public.chat_hub_messages](public.chat_hub_messages.md) [public.execution_annotations](public.execution_annotations.md) [public.execution_data](public.execution_data.md) [public.execution_metadata](public.execution_metadata.md) [public.test_case_execution](public.test_case_execution.md) |  |  |
| jsonSizeBytes | bigint | 0 | false |  |  | Byte size of the JSON execution data bundle (run data, workflow snapshot, version id); excludes binary data. 0 means unknown. |
| mode | varchar |  | false |  |  |  |
| retryOf | varchar |  | true |  |  |  |
| retrySuccessId | varchar |  | true |  |  |  |
| startedAt | timestamp(3) with time zone |  | true |  |  |  |
| status | varchar |  | false |  |  |  |
| stoppedAt | timestamp(3) with time zone |  | true |  |  |  |
| storedAt | varchar(2) | 'db'::character varying | false |  |  |  |
| tracingContext | json |  | true |  |  |  |
| usedPrivateCredentials | boolean | false | false |  |  | Whether this execution ran with at least one dynamically-resolved private credential. |
| waitTill | timestamp(3) with time zone |  | true |  |  |  |
| workflowId | varchar(36) |  | false |  | [public.workflow_entity](public.workflow_entity.md) |  |
| workflowVersionId | varchar(36) | NULL::character varying | true |  |  | Version id of the workflow run by this execution; denormalized from the data bundle. |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_execution_entity_storedAt | CHECK | CHECK ((("storedAt")::text = ANY ((ARRAY['db'::character varying, 'fs'::character varying, 's3'::character varying, 'az'::character varying])::text[]))) |
| execution_entity_binaryDataSizeBytes_not_null | n | NOT NULL "binaryDataSizeBytes" |
| execution_entity_createdAt_not_null | n | NOT NULL "createdAt" |
| execution_entity_finished_not_null | n | NOT NULL finished |
| execution_entity_id_not_null | n | NOT NULL id |
| execution_entity_jsonSizeBytes_not_null | n | NOT NULL "jsonSizeBytes" |
| execution_entity_mode_not_null | n | NOT NULL mode |
| execution_entity_status_not_null | n | NOT NULL status |
| execution_entity_storedAt_not_null | n | NOT NULL "storedAt" |
| execution_entity_usedPrivateCredentials_not_null | n | NOT NULL "usedPrivateCredentials" |
| execution_entity_workflowId_not_null | n | NOT NULL "workflowId" |
| fk_execution_entity_workflow_id | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE CASCADE |
| pk_e3e63bbf986767844bbe1166d4e | PRIMARY KEY | PRIMARY KEY (id) |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_execution_entity_deduplicationKey | CREATE UNIQUE INDEX "IDX_execution_entity_deduplicationKey" ON public.execution_entity USING btree ("deduplicationKey") WHERE ("deduplicationKey" IS NOT NULL) |
| IDX_execution_entity_deletedAt | CREATE INDEX "IDX_execution_entity_deletedAt" ON public.execution_entity USING btree ("deletedAt") |
| IDX_execution_entity_workflowId_status_id | CREATE INDEX "IDX_execution_entity_workflowId_status_id" ON public.execution_entity USING btree ("workflowId", status, id) WHERE ("deletedAt" IS NULL) |
| idx_execution_entity_stopped_at_status_deleted_at | CREATE INDEX idx_execution_entity_stopped_at_status_deleted_at ON public.execution_entity USING btree ("stoppedAt", status, "deletedAt") WHERE (("stoppedAt" IS NOT NULL) AND ("deletedAt" IS NULL)) |
| idx_execution_entity_wait_till_status_deleted_at | CREATE INDEX idx_execution_entity_wait_till_status_deleted_at ON public.execution_entity USING btree ("waitTill", status, "deletedAt") WHERE (("waitTill" IS NOT NULL) AND ("deletedAt" IS NULL)) |
| idx_execution_entity_workflow_id_started_at | CREATE INDEX idx_execution_entity_workflow_id_started_at ON public.execution_entity USING btree ("workflowId", "startedAt") WHERE (("startedAt" IS NOT NULL) AND ("deletedAt" IS NULL)) |
| pk_e3e63bbf986767844bbe1166d4e | CREATE UNIQUE INDEX pk_e3e63bbf986767844bbe1166d4e ON public.execution_entity USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Execution Metadata (`docs/generated/postgres-schema/public.execution_metadata.md`)

# public.execution_metadata

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| executionId | integer |  | false |  | [public.execution_entity](public.execution_entity.md) |  |
| id | integer | nextval('execution_metadata_temp_id_seq'::regclass) | false |  |  |  |
| key | varchar(255) |  | false |  |  |  |
| value | text |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_31d0b4c93fb85ced26f6005cda3 | FOREIGN KEY | FOREIGN KEY ("executionId") REFERENCES execution_entity(id) ON DELETE CASCADE |
| PK_17a0b6284f8d626aae88e1c16e4 | PRIMARY KEY | PRIMARY KEY (id) |
| execution_metadata_temp_executionId_not_null | n | NOT NULL "executionId" |
| execution_metadata_temp_id_not_null | n | NOT NULL id |
| execution_metadata_temp_key_not_null | n | NOT NULL key |
| execution_metadata_temp_value_not_null | n | NOT NULL value |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_cec8eea3bf49551482ccb4933e | CREATE UNIQUE INDEX "IDX_cec8eea3bf49551482ccb4933e" ON public.execution_metadata USING btree ("executionId", key) |
| PK_17a0b6284f8d626aae88e1c16e4 | CREATE UNIQUE INDEX "PK_17a0b6284f8d626aae88e1c16e4" ON public.execution_metadata USING btree (id) |

## Relations

```mermaid
erDiagram

"public.execution_metadata" }o--|| "public.execution_entity" : "FOREIGN KEY (#quot;executionId#quot;) REFERENCES execution_entity(id) ON DELETE CASCADE"

"public.execution_metadata" {
  integer executionId FK
  integer id
  varchar_255_ key
  text value
}
"public.execution_entity" {
  bigint binaryDataSizeBytes
  timestamp_3__with_time_zone createdAt
  varchar_255_ deduplicationKey
  timestamp_3__with_time_zone deletedAt
  boolean finished
  integer id
  bigint jsonSizeBytes
  varchar mode
  varchar retryOf
  varchar retrySuccessId
  timestamp_3__with_time_zone startedAt
  varchar status
  timestamp_3__with_time_zone stoppedAt
  varchar_2_ storedAt
  json tracingContext
  boolean usedPrivateCredentials
  timestamp_3__with_time_zone waitTill
  varchar_36_ workflowId FK
  varchar_36_ workflowVersionId
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Folder (`docs/generated/postgres-schema/public.folder.md`)

# public.folder

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.folder](public.folder.md) [public.folder_tag](public.folder_tag.md) [public.workflow_entity](public.workflow_entity.md) |  |  |
| name | varchar(128) |  | false |  |  |  |
| parentFolderId | varchar(36) |  | true |  | [public.folder](public.folder.md) |  |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_804ea52f6729e3940498bd54d78 | FOREIGN KEY | FOREIGN KEY ("parentFolderId") REFERENCES folder(id) ON DELETE CASCADE |
| FK_a8260b0b36939c6247f385b8221 | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_6278a41a706740c94c02e288df8 | PRIMARY KEY | PRIMARY KEY (id) |
| folder_createdAt_not_null | n | NOT NULL "createdAt" |
| folder_id_not_null | n | NOT NULL id |
| folder_name_not_null | n | NOT NULL name |
| folder_projectId_not_null | n | NOT NULL "projectId" |
| folder_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_14f68deffaf858465715995508 | CREATE UNIQUE INDEX "IDX_14f68deffaf858465715995508" ON public.folder USING btree ("projectId", id) |
| PK_6278a41a706740c94c02e288df8 | CREATE UNIQUE INDEX "PK_6278a41a706740c94c02e288df8" ON public.folder USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Folder Tag (`docs/generated/postgres-schema/public.folder_tag.md`)

# public.folder_tag

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| folderId | varchar(36) |  | false |  | [public.folder](public.folder.md) |  |
| tagId | varchar(36) |  | false |  | [public.tag_entity](public.tag_entity.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_94a60854e06f2897b2e0d39edba | FOREIGN KEY | FOREIGN KEY ("folderId") REFERENCES folder(id) ON DELETE CASCADE |
| FK_dc88164176283de80af47621746 | FOREIGN KEY | FOREIGN KEY ("tagId") REFERENCES tag_entity(id) ON DELETE CASCADE |
| PK_27e4e00852f6b06a925a4d83a3e | PRIMARY KEY | PRIMARY KEY ("folderId", "tagId") |
| folder_tag_folderId_not_null | n | NOT NULL "folderId" |
| folder_tag_tagId_not_null | n | NOT NULL "tagId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_27e4e00852f6b06a925a4d83a3e | CREATE UNIQUE INDEX "PK_27e4e00852f6b06a925a4d83a3e" ON public.folder_tag USING btree ("folderId", "tagId") |

## Relations

```mermaid
erDiagram

"public.folder_tag" }o--|| "public.folder" : "FOREIGN KEY (#quot;folderId#quot;) REFERENCES folder(id) ON DELETE CASCADE"
"public.folder_tag" }o--|| "public.tag_entity" : "FOREIGN KEY (#quot;tagId#quot;) REFERENCES tag_entity(id) ON DELETE CASCADE"

"public.folder_tag" {
  varchar_36_ folderId FK
  varchar_36_ tagId FK
}
"public.folder" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_128_ name
  varchar_36_ parentFolderId FK
  varchar_36_ projectId FK
  timestamp_3__with_time_zone updatedAt
}
"public.tag_entity" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_24_ name
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Idempotency Key (`docs/generated/postgres-schema/public.idempotency_key.md`)

# public.idempotency_key

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| fingerprint | text |  | false |  |  | Hash of the request method, path, and body |
| id | varchar(16) |  | false |  |  | Application-generated n8n nano ID |
| idempotencyKey | varchar(128) |  | false |  |  | Client Idempotency-Key header. Opaque ASCII, length 1 to 128 |
| responseBody | json |  | true |  |  | Stored response body. NULL while status is processing |
| responseStatus | smallint |  | true |  |  | HTTP status of the stored response. NULL while processing, required once completed |
| status | varchar(16) | 'processing'::character varying | false |  |  | processing while the handler runs. completed after the response is stored |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_idempotency_key_responseStatus | CHECK | CHECK (((((status)::text = 'processing'::text) AND ("responseStatus" IS NULL)) OR (((status)::text = 'completed'::text) AND ("responseStatus" IS NOT NULL)))) |
| CHK_idempotency_key_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['processing'::character varying, 'completed'::character varying])::text[]))) |
| FK_idempotency_key_userId | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_213f125e14469be304f9ff1d452 | PRIMARY KEY | PRIMARY KEY (id) |
| idempotency_key_createdAt_not_null | n | NOT NULL "createdAt" |
| idempotency_key_fingerprint_not_null | n | NOT NULL fingerprint |
| idempotency_key_id_not_null | n | NOT NULL id |
| idempotency_key_idempotencyKey_not_null | n | NOT NULL "idempotencyKey" |
| idempotency_key_status_not_null | n | NOT NULL status |
| idempotency_key_updatedAt_not_null | n | NOT NULL "updatedAt" |
| idempotency_key_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_25289244569e505292cde510d7 | CREATE UNIQUE INDEX "IDX_25289244569e505292cde510d7" ON public.idempotency_key USING btree ("userId", "idempotencyKey") |
| IDX_38536b1937c55d305af4d69a97 | CREATE INDEX "IDX_38536b1937c55d305af4d69a97" ON public.idempotency_key USING btree ("createdAt") |
| PK_213f125e14469be304f9ff1d452 | CREATE UNIQUE INDEX "PK_213f125e14469be304f9ff1d452" ON public.idempotency_key USING btree (id) |

## Relations

```mermaid
erDiagram

"public.idempotency_key" }o--|| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.idempotency_key" {
  timestamp_3__with_time_zone createdAt
  text fingerprint
  varchar_16_ id
  varchar_128_ idempotencyKey
  json responseBody
  smallint responseStatus
  varchar_16_ status
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Insights By Period (`docs/generated/postgres-schema/public.insights_by_period.md`)

# public.insights_by_period

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| id | integer |  | false |  |  |  |
| metaId | integer |  | false |  | [public.insights_metadata](public.insights_metadata.md) |  |
| periodStart | timestamp(0) with time zone | CURRENT_TIMESTAMP | true |  |  |  |
| periodUnit | integer |  | false |  |  | 0: hour, 1: day, 2: week |
| type | integer |  | false |  |  | 0: time_saved_minutes, 1: runtime_milliseconds, 2: success, 3: failure |
| value | bigint |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_6414cfed98daabbfdd61a1cfbc0 | FOREIGN KEY | FOREIGN KEY ("metaId") REFERENCES insights_metadata("metaId") ON DELETE CASCADE |
| PK_b606942249b90cc39b0265f0575 | PRIMARY KEY | PRIMARY KEY (id) |
| insights_by_period_id_not_null | n | NOT NULL id |
| insights_by_period_metaId_not_null | n | NOT NULL "metaId" |
| insights_by_period_periodUnit_not_null | n | NOT NULL "periodUnit" |
| insights_by_period_type_not_null | n | NOT NULL type |
| insights_by_period_value_not_null | n | NOT NULL value |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_60b6a84299eeb3f671dfec7693 | CREATE UNIQUE INDEX "IDX_60b6a84299eeb3f671dfec7693" ON public.insights_by_period USING btree ("periodStart", type, "periodUnit", "metaId") |
| PK_b606942249b90cc39b0265f0575 | CREATE UNIQUE INDEX "PK_b606942249b90cc39b0265f0575" ON public.insights_by_period USING btree (id) |

## Relations

```mermaid
erDiagram

"public.insights_by_period" }o--|| "public.insights_metadata" : "FOREIGN KEY (#quot;metaId#quot;) REFERENCES insights_metadata(#quot;metaId#quot;) ON DELETE CASCADE"

"public.insights_by_period" {
  integer id
  integer metaId FK
  timestamp_0__with_time_zone periodStart
  integer periodUnit
  integer type
  bigint value
}
"public.insights_metadata" {
  integer metaId
  varchar_36_ projectId FK
  varchar_255_ projectName
  varchar_36_ workflowId FK
  varchar_128_ workflowName
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Insights Metadata (`docs/generated/postgres-schema/public.insights_metadata.md`)

# public.insights_metadata

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| metaId | integer |  | false | [public.insights_by_period](public.insights_by_period.md) [public.insights_raw](public.insights_raw.md) |  |  |
| projectId | varchar(36) |  | true |  | [public.project](public.project.md) |  |
| projectName | varchar(255) |  | false |  |  |  |
| workflowId | varchar(36) |  | true |  | [public.workflow_entity](public.workflow_entity.md) |  |
| workflowName | varchar(128) |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1d8ab99d5861c9388d2dc1cf733 | FOREIGN KEY | FOREIGN KEY ("workflowId") REFERENCES workflow_entity(id) ON DELETE SET NULL |
| FK_2375a1eda085adb16b24615b69c | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE SET NULL |
| PK_f448a94c35218b6208ce20cf5a1 | PRIMARY KEY | PRIMARY KEY ("metaId") |
| insights_metadata_metaId_not_null | n | NOT NULL "metaId" |
| insights_metadata_projectName_not_null | n | NOT NULL "projectName" |
| insights_metadata_workflowName_not_null | n | NOT NULL "workflowName" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_1d8ab99d5861c9388d2dc1cf73 | CREATE UNIQUE INDEX "IDX_1d8ab99d5861c9388d2dc1cf73" ON public.insights_metadata USING btree ("workflowId") |
| PK_f448a94c35218b6208ce20cf5a1 | CREATE UNIQUE INDEX "PK_f448a94c35218b6208ce20cf5a1" ON public.insights_metadata USING btree ("metaId") |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Insights Raw (`docs/generated/postgres-schema/public.insights_raw.md`)

# public.insights_raw

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| id | integer |  | false |  |  |  |
| metaId | integer |  | false |  | [public.insights_metadata](public.insights_metadata.md) |  |
| timestamp | timestamp(0) with time zone | CURRENT_TIMESTAMP | false |  |  |  |
| type | integer |  | false |  |  | 0: time_saved_minutes, 1: runtime_milliseconds, 2: success, 3: failure |
| value | bigint |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_6e2e33741adef2a7c5d66befa4e | FOREIGN KEY | FOREIGN KEY ("metaId") REFERENCES insights_metadata("metaId") ON DELETE CASCADE |
| PK_ec15125755151e3a7e00e00014f | PRIMARY KEY | PRIMARY KEY (id) |
| insights_raw_id_not_null | n | NOT NULL id |
| insights_raw_metaId_not_null | n | NOT NULL "metaId" |
| insights_raw_timestamp_not_null | n | NOT NULL "timestamp" |
| insights_raw_type_not_null | n | NOT NULL type |
| insights_raw_value_not_null | n | NOT NULL value |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_insights_raw_timestamp_id | CREATE INDEX "IDX_insights_raw_timestamp_id" ON public.insights_raw USING btree ("timestamp", id) |
| PK_ec15125755151e3a7e00e00014f | CREATE UNIQUE INDEX "PK_ec15125755151e3a7e00e00014f" ON public.insights_raw USING btree (id) |

## Relations

```mermaid
erDiagram

"public.insights_raw" }o--|| "public.insights_metadata" : "FOREIGN KEY (#quot;metaId#quot;) REFERENCES insights_metadata(#quot;metaId#quot;) ON DELETE CASCADE"

"public.insights_raw" {
  integer id
  integer metaId FK
  timestamp_0__with_time_zone timestamp
  integer type
  bigint value
}
"public.insights_metadata" {
  integer metaId
  varchar_36_ projectId FK
  varchar_255_ projectName
  varchar_36_ workflowId FK
  varchar_128_ workflowName
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Installed Nodes (`docs/generated/postgres-schema/public.installed_nodes.md`)

# public.installed_nodes

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| latestVersion | double precision | 1 | false |  |  |  |
| name | varchar(200) |  | false |  |  |  |
| package | varchar(241) |  | false |  | [public.installed_packages](public.installed_packages.md) |  |
| type | varchar(200) |  | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_73f857fc5dce682cef8a99c11dbddbc969618951 | FOREIGN KEY | FOREIGN KEY (package) REFERENCES installed_packages("packageName") ON UPDATE CASCADE ON DELETE CASCADE |
| PK_8ebd28194e4f792f96b5933423fc439df97d9689 | PRIMARY KEY | PRIMARY KEY (name) |
| installed_nodes_latestVersion_not_null | n | NOT NULL "latestVersion" |
| installed_nodes_name_not_null | n | NOT NULL name |
| installed_nodes_package_not_null | n | NOT NULL package |
| installed_nodes_type_not_null | n | NOT NULL type |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_8ebd28194e4f792f96b5933423fc439df97d9689 | CREATE UNIQUE INDEX "PK_8ebd28194e4f792f96b5933423fc439df97d9689" ON public.installed_nodes USING btree (name) |

## Relations

```mermaid
erDiagram

"public.installed_nodes" }o--|| "public.installed_packages" : "FOREIGN KEY (package) REFERENCES installed_packages(#quot;packageName#quot;) ON UPDATE CASCADE ON DELETE CASCADE"

"public.installed_nodes" {
  double_precision latestVersion
  varchar_200_ name
  varchar_241_ package FK
  varchar_200_ type
}
"public.installed_packages" {
  varchar_70_ authorEmail
  varchar_70_ authorName
  timestamp_3__with_time_zone createdAt
  varchar_50_ installedVersion
  varchar_214_ packageName
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Installed Packages (`docs/generated/postgres-schema/public.installed_packages.md`)

# public.installed_packages

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| authorEmail | varchar(70) |  | true |  |  |  |
| authorName | varchar(70) |  | true |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| installedVersion | varchar(50) |  | false |  |  |  |
| packageName | varchar(214) |  | false | [public.installed_nodes](public.installed_nodes.md) |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_08cc9197c39b028c1e9beca225940576fd1a5804 | PRIMARY KEY | PRIMARY KEY ("packageName") |
| installed_packages_createdAt_not_null | n | NOT NULL "createdAt" |
| installed_packages_installedVersion_not_null | n | NOT NULL "installedVersion" |
| installed_packages_packageName_not_null | n | NOT NULL "packageName" |
| installed_packages_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_08cc9197c39b028c1e9beca225940576fd1a5804 | CREATE UNIQUE INDEX "PK_08cc9197c39b028c1e9beca225940576fd1a5804" ON public.installed_packages USING btree ("packageName") |

## Relations

```mermaid
erDiagram

"public.installed_nodes" }o--|| "public.installed_packages" : "FOREIGN KEY (package) REFERENCES installed_packages(#quot;packageName#quot;) ON UPDATE CASCADE ON DELETE CASCADE"

"public.installed_packages" {
  varchar_70_ authorEmail
  varchar_70_ authorName
  timestamp_3__with_time_zone createdAt
  varchar_50_ installedVersion
  varchar_214_ packageName
  timestamp_3__with_time_zone updatedAt
}
"public.installed_nodes" {
  double_precision latestVersion
  varchar_200_ name
  varchar_241_ package FK
  varchar_200_ type
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Checkpoints (`docs/generated/postgres-schema/public.instance_ai_checkpoints.md`)

# public.instance_ai_checkpoints

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| expiredAt | timestamp(3) with time zone |  | true |  |  | Soft-delete timestamp: null means live; non-null marks the row as a tombstone. |
| hostRunId | varchar(64) |  | true |  |  | Host (Instance AI) run id; distinct from the agent-SDK runId parsed from the checkpoint key. |
| key | varchar(255) |  | false | [public.instance_ai_pending_confirmations](public.instance_ai_pending_confirmations.md) |  | Opaque checkpoint key from the agent runtime. |
| resourceId | varchar(255) |  | true |  |  | Resource ID recorded by the agent runtime. |
| runId | varchar(255) |  | true |  |  | Run ID parsed from the checkpoint key when available. |
| state | json |  | true |  |  | Serializable agent state snapshot stored as JSON. |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) | Instance AI thread that owns the checkpoint. |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_2b23f3f24a70bebb990203b011e | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_5315a45f0846d1f9d128c18a2ed | PRIMARY KEY | PRIMARY KEY (key) |
| instance_ai_checkpoints_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_checkpoints_key_not_null | n | NOT NULL key |
| instance_ai_checkpoints_state_tombstone_check | CHECK | CHECK (((("expiredAt" IS NOT NULL) AND (state IS NULL)) OR ("expiredAt" IS NULL))) |
| instance_ai_checkpoints_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_checkpoints_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_2b23f3f24a70bebb990203b011 | CREATE INDEX "IDX_2b23f3f24a70bebb990203b011" ON public.instance_ai_checkpoints USING btree ("threadId") |
| IDX_768189b506cc26c4fe878b87cb | CREATE INDEX "IDX_768189b506cc26c4fe878b87cb" ON public.instance_ai_checkpoints USING btree ("runId") |
| IDX_be9d0eca0b19fb93d4eb74b327 | CREATE INDEX "IDX_be9d0eca0b19fb93d4eb74b327" ON public.instance_ai_checkpoints USING btree ("resourceId") |
| PK_5315a45f0846d1f9d128c18a2ed | CREATE UNIQUE INDEX "PK_5315a45f0846d1f9d128c18a2ed" ON public.instance_ai_checkpoints USING btree (key) |

## Relations

```mermaid
erDiagram

"public.instance_ai_pending_confirmations" }o--o| "public.instance_ai_checkpoints" : "FOREIGN KEY (#quot;checkpointKey#quot;) REFERENCES instance_ai_checkpoints(key) ON DELETE CASCADE"
"public.instance_ai_checkpoints" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_checkpoints" {
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone expiredAt
  varchar_64_ hostRunId
  varchar_255_ key
  varchar_255_ resourceId
  varchar_255_ runId
  json state
  uuid threadId FK
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_pending_confirmations" {
  varchar_255_ checkpointKey FK
  varchar_36_ checkpointTaskId
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone expiresAt
  varchar_16_ kind
  varchar_36_ messageGroupId
  varchar_36_ requestId
  varchar_36_ runId
  uuid threadId FK
  varchar_64_ toolCallId
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Events (`docs/generated/postgres-schema/public.instance_ai_events.md`)

# public.instance_ai_events

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| payload | text |  | false |  |  | JSON of the canonical InstanceAiEvent |
| runId | varchar(64) |  | false |  |  | Run that emitted the event — opaque ID from the agent runtime |
| seq | integer |  | false |  |  | Per-thread monotonic sequence — the SSE replay cursor |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| type | varchar(64) |  | false |  |  | Event type discriminator, duplicated out of the payload |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_35909c5576a4a6c1d6a6fb71caa | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_12489cd6197feeac2089acc7ef6 | PRIMARY KEY | PRIMARY KEY ("threadId", seq) |
| instance_ai_events_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_events_payload_not_null | n | NOT NULL payload |
| instance_ai_events_runId_not_null | n | NOT NULL "runId" |
| instance_ai_events_seq_not_null | n | NOT NULL seq |
| instance_ai_events_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_events_type_not_null | n | NOT NULL type |
| instance_ai_events_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_32cdd799675715fb1d2a8683e9 | CREATE INDEX "IDX_32cdd799675715fb1d2a8683e9" ON public.instance_ai_events USING btree ("threadId", "runId") |
| PK_12489cd6197feeac2089acc7ef6 | CREATE UNIQUE INDEX "PK_12489cd6197feeac2089acc7ef6" ON public.instance_ai_events USING btree ("threadId", seq) |

## Relations

```mermaid
erDiagram

"public.instance_ai_events" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_events" {
  timestamp_3__with_time_zone createdAt
  text payload
  varchar_64_ runId
  integer seq
  uuid threadId FK
  varchar_64_ type
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Iteration Logs (`docs/generated/postgres-schema/public.instance_ai_iteration_logs.md`)

# public.instance_ai_iteration_logs

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| entry | text |  | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| taskKey | varchar |  | false |  |  |  |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_8bfcc6c51fd3d69b1eae8aebd49 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_21c2b214b44bc6c34a6d3551c90 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_iteration_logs_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_iteration_logs_entry_not_null | n | NOT NULL entry |
| instance_ai_iteration_logs_id_not_null | n | NOT NULL id |
| instance_ai_iteration_logs_taskKey_not_null | n | NOT NULL "taskKey" |
| instance_ai_iteration_logs_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_iteration_logs_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_02751202c9a2ad75f2d8e14f5e | CREATE INDEX "IDX_02751202c9a2ad75f2d8e14f5e" ON public.instance_ai_iteration_logs USING btree ("threadId", "taskKey", "createdAt") |
| PK_21c2b214b44bc6c34a6d3551c90 | CREATE UNIQUE INDEX "PK_21c2b214b44bc6c34a6d3551c90" ON public.instance_ai_iteration_logs USING btree (id) |

## Relations

```mermaid
erDiagram

"public.instance_ai_iteration_logs" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_iteration_logs" {
  timestamp_3__with_time_zone createdAt
  text entry
  varchar_36_ id
  varchar taskKey
  uuid threadId FK
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Mcp Registry Connections (`docs/generated/postgres-schema/public.instance_ai_mcp_registry_connections.md`)

# public.instance_ai_mcp_registry_connections

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| credentialId | varchar(36) |  | false |  | [public.credentials_entity](public.credentials_entity.md) |  |
| id | uuid |  | false |  |  |  |
| serverSlug | varchar(255) |  | false |  | [public.mcp_registry_server](public.mcp_registry_server.md) |  |
| toolPermissions | json |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1d25707354d2012da256eb2ec0a | FOREIGN KEY | FOREIGN KEY ("serverSlug") REFERENCES mcp_registry_server(slug) ON DELETE CASCADE |
| FK_1e826120e7e53ebc4681f026de8 | FOREIGN KEY | FOREIGN KEY ("credentialId") REFERENCES credentials_entity(id) ON DELETE CASCADE |
| FK_8b42c08a531d76410980c639a5b | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_e34e4d15d78eabbe8217e33ef03 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_mcp_registry_connections_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_mcp_registry_connections_credentialId_not_null | n | NOT NULL "credentialId" |
| instance_ai_mcp_registry_connections_id_not_null | n | NOT NULL id |
| instance_ai_mcp_registry_connections_serverSlug_not_null | n | NOT NULL "serverSlug" |
| instance_ai_mcp_registry_connections_toolPermissions_not_null | n | NOT NULL "toolPermissions" |
| instance_ai_mcp_registry_connections_updatedAt_not_null | n | NOT NULL "updatedAt" |
| instance_ai_mcp_registry_connections_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_16db3adb7b19df1ee55ff06b27 | CREATE UNIQUE INDEX "IDX_16db3adb7b19df1ee55ff06b27" ON public.instance_ai_mcp_registry_connections USING btree ("userId", "serverSlug", "credentialId") |
| PK_e34e4d15d78eabbe8217e33ef03 | CREATE UNIQUE INDEX "PK_e34e4d15d78eabbe8217e33ef03" ON public.instance_ai_mcp_registry_connections USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Messages (`docs/generated/postgres-schema/public.instance_ai_messages.md`)

# public.instance_ai_messages

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| content | text |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| resourceId | varchar(255) |  | true |  |  |  |
| role | varchar(16) |  | false |  |  |  |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| type | varchar(32) |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1eeb64cb9d66a927988de759e6e | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_156c6f287225e9befe0181bb02b | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_messages_content_not_null | n | NOT NULL content |
| instance_ai_messages_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_messages_id_not_null | n | NOT NULL id |
| instance_ai_messages_role_not_null | n | NOT NULL role |
| instance_ai_messages_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_messages_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_1eeb64cb9d66a927988de759e6 | CREATE INDEX "IDX_1eeb64cb9d66a927988de759e6" ON public.instance_ai_messages USING btree ("threadId") |
| IDX_76e212c6867fbaa06bf0decd6f | CREATE INDEX "IDX_76e212c6867fbaa06bf0decd6f" ON public.instance_ai_messages USING btree ("resourceId") |
| PK_156c6f287225e9befe0181bb02b | CREATE UNIQUE INDEX "PK_156c6f287225e9befe0181bb02b" ON public.instance_ai_messages USING btree (id) |

## Relations

```mermaid
erDiagram

"public.instance_ai_messages" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_messages" {
  text content
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_255_ resourceId
  varchar_16_ role
  uuid threadId FK
  varchar_32_ type
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Observation Cursors (`docs/generated/postgres-schema/public.instance_ai_observation_cursors.md`)

# public.instance_ai_observation_cursors

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| lastObservedAt | timestamp(3) with time zone |  | false |  |  |  |
| lastObservedMessageId | varchar(36) |  | false |  |  |  |
| observationScopeId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) | instance_ai_threads.id source stream checkpointed by this cursor |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_5b6319b2e9a37c1064a72428f9a | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_5b6319b2e9a37c1064a72428f9a | PRIMARY KEY | PRIMARY KEY ("observationScopeId") |
| instance_ai_observation_cursors_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_observation_cursors_lastObservedAt_not_null | n | NOT NULL "lastObservedAt" |
| instance_ai_observation_cursors_lastObservedMessageId_not_null | n | NOT NULL "lastObservedMessageId" |
| instance_ai_observation_cursors_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| instance_ai_observation_cursors_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_5b6319b2e9a37c1064a72428f9a | CREATE UNIQUE INDEX "PK_5b6319b2e9a37c1064a72428f9a" ON public.instance_ai_observation_cursors USING btree ("observationScopeId") |

## Relations

```mermaid
erDiagram

"public.instance_ai_observation_cursors" |o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;observationScopeId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_observation_cursors" {
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone lastObservedAt
  varchar_36_ lastObservedMessageId
  uuid observationScopeId FK
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Observation Locks (`docs/generated/postgres-schema/public.instance_ai_observation_locks.md`)

# public.instance_ai_observation_locks

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| heldUntil | timestamp(3) with time zone |  | false |  |  |  |
| holderId | varchar(64) |  | false |  |  | Ephemeral background-task lock owner token, not a user ID |
| observationScopeId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) | instance_ai_threads.id source stream locked for observation tasks |
| taskKind | varchar(20) |  | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_instance_ai_observation_locks_taskKind | CHECK | CHECK ((("taskKind")::text = ANY ((ARRAY['observer'::character varying, 'reflector'::character varying])::text[]))) |
| FK_103e2e5f454860b28ea05a82c74 | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_fc491dd378b9448655c3c683f85 | PRIMARY KEY | PRIMARY KEY ("observationScopeId", "taskKind") |
| instance_ai_observation_locks_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_observation_locks_heldUntil_not_null | n | NOT NULL "heldUntil" |
| instance_ai_observation_locks_holderId_not_null | n | NOT NULL "holderId" |
| instance_ai_observation_locks_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| instance_ai_observation_locks_taskKind_not_null | n | NOT NULL "taskKind" |
| instance_ai_observation_locks_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_fc491dd378b9448655c3c683f85 | CREATE UNIQUE INDEX "PK_fc491dd378b9448655c3c683f85" ON public.instance_ai_observation_locks USING btree ("observationScopeId", "taskKind") |

## Relations

```mermaid
erDiagram

"public.instance_ai_observation_locks" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;observationScopeId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_observation_locks" {
  timestamp_3__with_time_zone createdAt
  timestamp_3__with_time_zone heldUntil
  varchar_64_ holderId
  uuid observationScopeId FK
  varchar_20_ taskKind
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Observational Memory (`docs/generated/postgres-schema/public.instance_ai_observational_memory.md`)

# public.instance_ai_observational_memory

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| activeObservations | text | ''::text | false |  |  |  |
| bufferedMessageIds | json |  | true |  |  |  |
| bufferedObservationChunks | json |  | true |  |  |  |
| bufferedObservationTokens | integer |  | true |  |  |  |
| bufferedObservations | text |  | true |  |  |  |
| bufferedReflection | text |  | true |  |  |  |
| bufferedReflectionInputTokens | integer |  | true |  |  |  |
| bufferedReflectionTokens | integer |  | true |  |  |  |
| config | text |  | false |  |  |  |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| generationCount | integer | 0 | false |  |  |  |
| id | varchar(36) |  | false |  |  |  |
| isBufferingObservation | boolean | false | false |  |  |  |
| isBufferingReflection | boolean | false | false |  |  |  |
| isObserving | boolean | false | false |  |  |  |
| isReflecting | boolean | false | false |  |  |  |
| lastBufferedAtTime | timestamp(3) with time zone |  | true |  |  |  |
| lastBufferedAtTokens | integer | 0 | false |  |  |  |
| lastObservedAt | timestamp(3) with time zone |  | true |  |  |  |
| lookupKey | varchar(255) |  | false |  |  |  |
| metadata | json |  | true |  |  |  |
| observationTokenCount | integer | 0 | false |  |  |  |
| observedMessageIds | json |  | true |  |  |  |
| observedTimezone | varchar |  | true |  |  |  |
| originType | varchar(32) |  | false |  |  |  |
| pendingMessageTokens | integer | 0 | false |  |  |  |
| reflectedObservationLineCount | integer |  | true |  |  |  |
| resourceId | varchar(255) |  | false |  |  |  |
| scope | varchar(16) |  | false |  |  |  |
| threadId | uuid |  | true |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| totalTokensObserved | integer | 0 | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_34018c303885cd37093458e6409 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE SET NULL |
| PK_7192dd00cddba039bf1d3e6a098 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_observational_memor_isBufferingObservation_not_null | n | NOT NULL "isBufferingObservation" |
| instance_ai_observational_memory_activeObservations_not_null | n | NOT NULL "activeObservations" |
| instance_ai_observational_memory_config_not_null | n | NOT NULL config |
| instance_ai_observational_memory_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_observational_memory_generationCount_not_null | n | NOT NULL "generationCount" |
| instance_ai_observational_memory_id_not_null | n | NOT NULL id |
| instance_ai_observational_memory_isBufferingReflection_not_null | n | NOT NULL "isBufferingReflection" |
| instance_ai_observational_memory_isObserving_not_null | n | NOT NULL "isObserving" |
| instance_ai_observational_memory_isReflecting_not_null | n | NOT NULL "isReflecting" |
| instance_ai_observational_memory_lastBufferedAtTokens_not_null | n | NOT NULL "lastBufferedAtTokens" |
| instance_ai_observational_memory_lookupKey_not_null | n | NOT NULL "lookupKey" |
| instance_ai_observational_memory_observationTokenCount_not_null | n | NOT NULL "observationTokenCount" |
| instance_ai_observational_memory_originType_not_null | n | NOT NULL "originType" |
| instance_ai_observational_memory_pendingMessageTokens_not_null | n | NOT NULL "pendingMessageTokens" |
| instance_ai_observational_memory_resourceId_not_null | n | NOT NULL "resourceId" |
| instance_ai_observational_memory_scope_not_null | n | NOT NULL scope |
| instance_ai_observational_memory_totalTokensObserved_not_null | n | NOT NULL "totalTokensObserved" |
| instance_ai_observational_memory_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_92f13cb6bc694227e069447f7b | CREATE INDEX "IDX_92f13cb6bc694227e069447f7b" ON public.instance_ai_observational_memory USING btree ("lookupKey") |
| IDX_a680ac96aae02dc887bbaac512 | CREATE UNIQUE INDEX "IDX_a680ac96aae02dc887bbaac512" ON public.instance_ai_observational_memory USING btree (scope, "threadId", "resourceId") |
| PK_7192dd00cddba039bf1d3e6a098 | CREATE UNIQUE INDEX "PK_7192dd00cddba039bf1d3e6a098" ON public.instance_ai_observational_memory USING btree (id) |

## Relations

```mermaid
erDiagram

"public.instance_ai_observational_memory" }o--o| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE SET NULL"

"public.instance_ai_observational_memory" {
  text activeObservations
  json bufferedMessageIds
  json bufferedObservationChunks
  integer bufferedObservationTokens
  text bufferedObservations
  text bufferedReflection
  integer bufferedReflectionInputTokens
  integer bufferedReflectionTokens
  text config
  timestamp_3__with_time_zone createdAt
  integer generationCount
  varchar_36_ id
  boolean isBufferingObservation
  boolean isBufferingReflection
  boolean isObserving
  boolean isReflecting
  timestamp_3__with_time_zone lastBufferedAtTime
  integer lastBufferedAtTokens
  timestamp_3__with_time_zone lastObservedAt
  varchar_255_ lookupKey
  json metadata
  integer observationTokenCount
  json observedMessageIds
  varchar observedTimezone
  varchar_32_ originType
  integer pendingMessageTokens
  integer reflectedObservationLineCount
  varchar_255_ resourceId
  varchar_16_ scope
  uuid threadId FK
  integer totalTokensObserved
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Observations (`docs/generated/postgres-schema/public.instance_ai_observations.md`)

# public.instance_ai_observations

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(36) |  | false | [public.instance_ai_observations](public.instance_ai_observations.md) |  | Application-generated n8n string ID, not a database UUID |
| marker | varchar(16) |  | false |  |  |  |
| observationScopeId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) | instance_ai_threads.id source stream for this observation log |
| parentId | varchar(36) |  | true |  | [public.instance_ai_observations](public.instance_ai_observations.md) |  |
| status | varchar(16) |  | false |  |  |  |
| supersededBy | varchar(36) |  | true |  | [public.instance_ai_observations](public.instance_ai_observations.md) |  |
| text | text |  | false |  |  |  |
| tokenCount | integer | 0 | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_instance_ai_observations_marker | CHECK | CHECK (((marker)::text = ANY ((ARRAY['critical'::character varying, 'important'::character varying, 'info'::character varying, 'completion'::character varying])::text[]))) |
| CHK_instance_ai_observations_status | CHECK | CHECK (((status)::text = ANY ((ARRAY['active'::character varying, 'superseded'::character varying, 'dropped'::character varying])::text[]))) |
| FK_a80e0ee839a2f10ba4b86e19998 | FOREIGN KEY | FOREIGN KEY ("supersededBy") REFERENCES instance_ai_observations(id) |
| FK_d54fc84a6c8ac91b5e0db0378a4 | FOREIGN KEY | FOREIGN KEY ("observationScopeId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| FK_daef2195a4a846eb70eed15e039 | FOREIGN KEY | FOREIGN KEY ("parentId") REFERENCES instance_ai_observations(id) |
| PK_4d9b514cdf0f0b577650caf2ac2 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_observations_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_observations_id_not_null | n | NOT NULL id |
| instance_ai_observations_marker_not_null | n | NOT NULL marker |
| instance_ai_observations_observationScopeId_not_null | n | NOT NULL "observationScopeId" |
| instance_ai_observations_status_not_null | n | NOT NULL status |
| instance_ai_observations_text_not_null | n | NOT NULL text |
| instance_ai_observations_tokenCount_not_null | n | NOT NULL "tokenCount" |
| instance_ai_observations_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_0d5db648188d338df7fb2a8064 | CREATE INDEX "IDX_0d5db648188d338df7fb2a8064" ON public.instance_ai_observations USING btree ("observationScopeId", status, "createdAt", id) |
| IDX_a80e0ee839a2f10ba4b86e1999 | CREATE INDEX "IDX_a80e0ee839a2f10ba4b86e1999" ON public.instance_ai_observations USING btree ("supersededBy") |
| IDX_daef2195a4a846eb70eed15e03 | CREATE INDEX "IDX_daef2195a4a846eb70eed15e03" ON public.instance_ai_observations USING btree ("parentId") |
| PK_4d9b514cdf0f0b577650caf2ac2 | CREATE UNIQUE INDEX "PK_4d9b514cdf0f0b577650caf2ac2" ON public.instance_ai_observations USING btree (id) |

## Relations

```mermaid
erDiagram

"public.instance_ai_observations" }o--o| "public.instance_ai_observations" : "FOREIGN KEY (#quot;supersededBy#quot;) REFERENCES instance_ai_observations(id)"
"public.instance_ai_observations" }o--o| "public.instance_ai_observations" : "FOREIGN KEY (#quot;parentId#quot;) REFERENCES instance_ai_observations(id)"
"public.instance_ai_observations" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;observationScopeId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"

"public.instance_ai_observations" {
  timestamp_3__with_time_zone createdAt
  varchar_36_ id
  varchar_16_ marker
  uuid observationScopeId FK
  varchar_36_ parentId FK
  varchar_16_ status
  varchar_36_ supersededBy FK
  text text
  integer tokenCount
  timestamp_3__with_time_zone updatedAt
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Pending Confirmations (`docs/generated/postgres-schema/public.instance_ai_pending_confirmations.md`)

# public.instance_ai_pending_confirmations

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| checkpointKey | varchar(255) |  | true |  | [public.instance_ai_checkpoints](public.instance_ai_checkpoints.md) | FK to instance_ai_checkpoints.key; also the SDK runId used to resume. |
| checkpointTaskId | varchar(36) |  | true |  |  | Set when the suspended run was a planned-task checkpoint follow-up. |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| expiresAt | timestamp(3) with time zone |  | true |  |  | TTL for the leader-only sweep; null disables auto-expiry. |
| kind | varchar(16) |  | false |  |  | 'suspended' (resumable from checkpoint) or 'inline' (orchestrator-held Promise). |
| messageGroupId | varchar(36) |  | true |  |  | SSE event correlation group. |
| requestId | varchar(36) |  | false |  |  | HITL confirmation request identifier. |
| runId | varchar(36) |  | false |  |  | External run ID; reused on resume for SSE correlation. |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) | Instance AI thread that owns the confirmation. |
| toolCallId | varchar(64) |  | true |  |  | Suspended tool call awaiting confirmation. |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) | User who is expected to confirm or cancel. |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| CHK_instance_ai_pending_confirmations_kind | CHECK | CHECK (((kind)::text = ANY ((ARRAY['suspended'::character varying, 'inline'::character varying])::text[]))) |
| FK_0babdf6e3b897a86fe4678355eb | FOREIGN KEY | FOREIGN KEY ("checkpointKey") REFERENCES instance_ai_checkpoints(key) ON DELETE CASCADE |
| FK_ba67ee8dc311830a2eea89b6e96 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| FK_df5fd25c8bbfd2b042602600d8e | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_25c38179c8d45095b168adfff80 | PRIMARY KEY | PRIMARY KEY ("requestId") |
| instance_ai_pending_confirmations_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_pending_confirmations_kind_not_null | n | NOT NULL kind |
| instance_ai_pending_confirmations_requestId_not_null | n | NOT NULL "requestId" |
| instance_ai_pending_confirmations_runId_not_null | n | NOT NULL "runId" |
| instance_ai_pending_confirmations_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_pending_confirmations_updatedAt_not_null | n | NOT NULL "updatedAt" |
| instance_ai_pending_confirmations_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_0babdf6e3b897a86fe4678355e | CREATE INDEX "IDX_0babdf6e3b897a86fe4678355e" ON public.instance_ai_pending_confirmations USING btree ("checkpointKey") |
| IDX_ba67ee8dc311830a2eea89b6e9 | CREATE INDEX "IDX_ba67ee8dc311830a2eea89b6e9" ON public.instance_ai_pending_confirmations USING btree ("threadId") |
| IDX_d7a4aba7440449865e2b924377 | CREATE INDEX "IDX_d7a4aba7440449865e2b924377" ON public.instance_ai_pending_confirmations USING btree ("expiresAt") |
| IDX_df5fd25c8bbfd2b042602600d8 | CREATE INDEX "IDX_df5fd25c8bbfd2b042602600d8" ON public.instance_ai_pending_confirmations USING btree ("userId") |
| PK_25c38179c8d45095b168adfff80 | CREATE UNIQUE INDEX "PK_25c38179c8d45095b168adfff80" ON public.instance_ai_pending_confirmations USING btree ("requestId") |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Resources (`docs/generated/postgres-schema/public.instance_ai_resources.md`)

# public.instance_ai_resources

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | varchar(255) |  | false |  |  |  |
| metadata | json |  | true |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| workingMemory | text |  | true |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| PK_45b5b0b6f715dae4292b86603d8 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_resources_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_resources_id_not_null | n | NOT NULL id |
| instance_ai_resources_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| PK_45b5b0b6f715dae4292b86603d8 | CREATE UNIQUE INDEX "PK_45b5b0b6f715dae4292b86603d8" ON public.instance_ai_resources USING btree (id) |

## Relations

```mermaid
erDiagram


"public.instance_ai_resources" {
  timestamp_3__with_time_zone createdAt
  varchar_255_ id
  json metadata
  timestamp_3__with_time_zone updatedAt
  text workingMemory
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Thread Grants (`docs/generated/postgres-schema/public.instance_ai_thread_grants.md`)

# public.instance_ai_thread_grants

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| grantKey | varchar(512) |  | false |  |  | Namespaced "always allow" grant the user approved for the thread, e.g. "executions:run:\<workflowId\>". Wide enough to hold a namespace prefix plus a resource identifier. |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_401b94abf83d1ac7a841f31330e | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| FK_908202dbc0a9b52f669c11d730c | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| PK_56107d26ebeabf780c5cf311d66 | PRIMARY KEY | PRIMARY KEY ("threadId", "userId", "grantKey") |
| instance_ai_thread_grants_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_thread_grants_grantKey_not_null | n | NOT NULL "grantKey" |
| instance_ai_thread_grants_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_thread_grants_updatedAt_not_null | n | NOT NULL "updatedAt" |
| instance_ai_thread_grants_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_401b94abf83d1ac7a841f31330 | CREATE INDEX "IDX_401b94abf83d1ac7a841f31330" ON public.instance_ai_thread_grants USING btree ("userId") |
| PK_56107d26ebeabf780c5cf311d66 | CREATE UNIQUE INDEX "PK_56107d26ebeabf780c5cf311d66" ON public.instance_ai_thread_grants USING btree ("threadId", "userId", "grantKey") |

## Relations

```mermaid
erDiagram

"public.instance_ai_thread_grants" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"
"public.instance_ai_thread_grants" }o--|| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.instance_ai_thread_grants" {
  timestamp_3__with_time_zone createdAt
  varchar_512_ grantKey
  uuid threadId FK
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Thread Tabs (`docs/generated/postgres-schema/public.instance_ai_thread_tabs.md`)

# public.instance_ai_thread_tabs

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| state | json |  | false |  |  | Tabs the user has open in the thread: { tabs, closedTabs, activeTab, previewOpen }. "tabs" is in display order. "closedTabs" holds closed artifacts so they do not reopen. "previewOpen" tells if the preview panel is open. |
| threadId | uuid |  | false |  | [public.instance_ai_threads](public.instance_ai_threads.md) |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| userId | uuid |  | false |  | [public.user](public.user.md) |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_1087a0774e95922e3b5c9af8dd0 | FOREIGN KEY | FOREIGN KEY ("threadId") REFERENCES instance_ai_threads(id) ON DELETE CASCADE |
| FK_4109834dc3cb1c77748ed11e13a | FOREIGN KEY | FOREIGN KEY ("userId") REFERENCES "user"(id) ON DELETE CASCADE |
| PK_61fc902b3494c9b06fbb86a7664 | PRIMARY KEY | PRIMARY KEY ("threadId", "userId") |
| instance_ai_thread_tabs_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_thread_tabs_state_not_null | n | NOT NULL state |
| instance_ai_thread_tabs_threadId_not_null | n | NOT NULL "threadId" |
| instance_ai_thread_tabs_updatedAt_not_null | n | NOT NULL "updatedAt" |
| instance_ai_thread_tabs_userId_not_null | n | NOT NULL "userId" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_4109834dc3cb1c77748ed11e13 | CREATE INDEX "IDX_4109834dc3cb1c77748ed11e13" ON public.instance_ai_thread_tabs USING btree ("userId") |
| PK_61fc902b3494c9b06fbb86a7664 | CREATE UNIQUE INDEX "PK_61fc902b3494c9b06fbb86a7664" ON public.instance_ai_thread_tabs USING btree ("threadId", "userId") |

## Relations

```mermaid
erDiagram

"public.instance_ai_thread_tabs" }o--|| "public.instance_ai_threads" : "FOREIGN KEY (#quot;threadId#quot;) REFERENCES instance_ai_threads(id) ON DELETE CASCADE"
"public.instance_ai_thread_tabs" }o--|| "public.user" : "FOREIGN KEY (#quot;userId#quot;) REFERENCES #quot;user#quot;(id) ON DELETE CASCADE"

"public.instance_ai_thread_tabs" {
  timestamp_3__with_time_zone createdAt
  json state
  uuid threadId FK
  timestamp_3__with_time_zone updatedAt
  uuid userId FK
}
"public.instance_ai_threads" {
  timestamp_3__with_time_zone createdAt
  uuid id
  json metadata
  varchar_36_ projectId FK
  varchar_255_ resourceId
  text title
  timestamp_3__with_time_zone updatedAt
}
"public.user" {
  timestamp_3__with_time_zone createdAt
  boolean disabled
  varchar_255_ email
  varchar_32_ firstName
  uuid id
  date lastActiveAt
  varchar_32_ lastName
  boolean mfaEnabled
  text mfaRecoveryCodes
  text mfaSecret
  varchar_255_ password
  json personalizationAnswers
  varchar_128_ roleSlug FK
  json settings
  timestamp_3__with_time_zone updatedAt
}
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

### Generated Postgres Schema Public.Instance Ai Threads (`docs/generated/postgres-schema/public.instance_ai_threads.md`)

# public.instance_ai_threads

## Columns

| Name | Type | Default | Nullable | Children | Parents | Comment |
| ---- | ---- | ------- | -------- | -------- | ------- | ------- |
| createdAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |
| id | uuid |  | false | [public.ai_builder_temporary_workflow](public.ai_builder_temporary_workflow.md) [public.instance_ai_checkpoints](public.instance_ai_checkpoints.md) [public.instance_ai_events](public.instance_ai_events.md) [public.instance_ai_iteration_logs](public.instance_ai_iteration_logs.md) [public.instance_ai_messages](public.instance_ai_messages.md) [public.instance_ai_observation_cursors](public.instance_ai_observation_cursors.md) [public.instance_ai_observation_locks](public.instance_ai_observation_locks.md) [public.instance_ai_observational_memory](public.instance_ai_observational_memory.md) [public.instance_ai_observations](public.instance_ai_observations.md) [public.instance_ai_pending_confirmations](public.instance_ai_pending_confirmations.md) [public.instance_ai_thread_grants](public.instance_ai_thread_grants.md) [public.instance_ai_thread_tabs](public.instance_ai_thread_tabs.md) |  |  |
| metadata | json |  | true |  |  |  |
| projectId | varchar(36) |  | false |  | [public.project](public.project.md) | Project this thread is scoped to |
| resourceId | varchar(255) |  | false |  |  |  |
| title | text | ''::text | false |  |  |  |
| updatedAt | timestamp(3) with time zone | CURRENT_TIMESTAMP(3) | false |  |  |  |

## Constraints

| Name | Type | Definition |
| ---- | ---- | ---------- |
| FK_instance_ai_threads_projectId | FOREIGN KEY | FOREIGN KEY ("projectId") REFERENCES project(id) ON DELETE CASCADE |
| PK_35575100e45cdedeb89ae0643e9 | PRIMARY KEY | PRIMARY KEY (id) |
| instance_ai_threads_createdAt_not_null | n | NOT NULL "createdAt" |
| instance_ai_threads_id_not_null | n | NOT NULL id |
| instance_ai_threads_projectId_not_null | n | NOT NULL "projectId" |
| instance_ai_threads_resourceId_not_null | n | NOT NULL "resourceId" |
| instance_ai_threads_title_not_null | n | NOT NULL title |
| instance_ai_threads_updatedAt_not_null | n | NOT NULL "updatedAt" |

## Indexes

| Name | Definition |
| ---- | ---------- |
| IDX_f36dea4d38fe92e0e8f44d5a56 | CREATE INDEX "IDX_f36dea4d38fe92e0e8f44d5a56" ON public.instance_ai_threads USING btree ("resourceId") |
| IDX_instance_ai_threads_projectId | CREATE INDEX "IDX_instance_ai_threads_projectId" ON public.instance_ai_threads USING btree ("projectId") |
| IDX_instance_ai_threads_resourceId_updatedAt_id | CREATE INDEX "IDX_instance_ai_threads_resourceId_updatedAt_id" ON public.instance_ai_threads USING btree ("resourceId", "updatedAt", id) |
| PK_35575100e45cdedeb89ae0643e9 | CREATE UNIQUE INDEX "PK_35575100e45cdedeb89ae0643e9" ON public.instance_ai_threads USING btree (id) |

## Relations

```
/* Detailed source-code truncated for AI context efficiency. */
```

---

> Generated by [tbls](https://github.com/k1LoW/tbls)

---

--- METRICS ---
- Files Extracted: 101
- Estimated Token Budget: ~86180 tokens
- Canonical Reference: https://codewiki.google/github.com/n8n-io/n8n
