Harmonyalpha
DocsSkillsAboutSource ↗Sign in
Harmony

Open source platform for agents. Bring your own agent. Harmony provides the substrate.

Project

  • Source
  • Docs
  • Architecture

Status

  • alpha · skeleton
  • No public API yet
© 2026 Groupanyplatform.groupany.ai

Get started

  • Get started

API reference

  • API overview
  • Authentication
  • Workspaces
  • Sessions, events, traces
  • Skills
  • Agents
  • Tools
  • Teams
  • Projects
  • A2A protocol
  • Evaluation
  • Deployments

Webhooks

  • Webhook Triggers

MCP

  • MCPdraft

CLI

  • CLIdraft

Database model

  • Database model

Research

  • LangChain — what we learn from them

Status

  • Status

Roadmap

  • Roadmap

Database model

Harmony's persistent state lives in Postgres. The schema is owned by Prisma; migrations are the source of truth. The 23 tables today fall into four clusters: Auth.js (User/Account/Session/VerificationToken), workspace + secrets (Workspace/WorkspaceMember/ApiKey/Credential, the last per Decision 0013), versioned resources (Skill/Agent/Tool/Hook + per-type Version, per Decision 0007), and runtime (Run/RunEvent per Decision 0008, Thread per Decision 0016, Trigger per Decision 0017, ProviderConfig per Decision 0009, Deployment per Decision 0011). Plus the IdempotencyKey dedup store.

Why Run instead of Session

Auth.js v5 owns the Session model name (login sessions). Harmony's agent-run entity is Run in Prisma to avoid the collision. The API surface and these docs still call them "sessions" — Run is purely the database model name. When you read about sessions, sessions in trace.jsonl, /api/v1/sessions/..., they all mean Run underneath.

Entity relationship diagram

Models

Auth.js (User, Account, Session, VerificationToken)

Standard @auth/prisma-adapter tables. Don't mutate directly; Auth.js manages their lifecycle. Session here is the login session, not an agent run.

Workspace, WorkspaceMember, ApiKey, Credential

The isolation unit and its access. A workspace can have many members (role: owner | admin | member) and many API keys (bearer tokens with SHA-256-hashed secret, public prefix for identification). WorkspaceMember(workspaceId, userId) is unique.

Credential is the workspace secret vault (Decision 0013). Each row is { id, workspaceId, name, description?, encryptedValue, hint?, metadata?, createdById, lastUsedAt?, createdAt, rotatedAt? }, unique on (workspaceId, name). The name is the identifier you bind to (e.g. LINEAR_API_TOKEN); encryptedValue is an AES-256-GCM blob (base64) sealed with the same per-workspace HKDF-derived key as ProviderConfig. hint keeps the last-4 chars for visual confirmation; metadata is free-form provenance (where it came from, what tool it links to). MCP tools, agents, and webhook/trigger auth bind to credentials by name at the moment of injection — the cleartext value never leaves the runtime hop.

Versioned resources (Decision 0007)

Each resource type has a parent (Skill, Agent, Tool, Hook) holding the identity, and a versions table holding immutable content:

  • SkillVersion — semver versions, frontmatter parsed into metadata, body inline in body (will move to object storage when Decision 0009 lands)
  • AgentVersion — monotonic integer, pins a SkillVersion, toolScope + credentialBindings JSON, optional budget, optional computeProviderConfigId override
  • Tool — also carries requiredConfig (JSON: [{ key, credentialId, label }], the binding the deploy flow uses to fetch + inject the right Credential rows into the runtime's MCP client config) and registryRef (the Smithery qualified name, e.g. @smithery/linear, for re-fetching the connection spec and reconciling schema changes)
  • ToolVersion — keyed by catalogHash (8-char hex), holds the introspected catalog JSON and an endpoint. The parent Tool.transport enum is mcp_stdio | mcp_sse | mcp_websocket | direct_function (endpoint is a URL for sse/ws, a command for stdio, a ref for direct_function)
  • HookVersion — keyed by contentHash, holds script, language, timeoutMs

isLatest is a hint flag for the common "current version" query. Application code enforces uniqueness (exactly one isLatest = true per parent at all times).

Runtime — Run + RunEvent (Decision 0008)

A Run is one agent execution. The full row is { id, workspaceId, agentVersionId, skillVersionId, toolCatalogHash?, hookVersionIds, snapshot, status, projection, projectionVersion, threadId?, startedAt, finalizedAt?, lastEventAt }.

  • snapshot records the exact resource URIs at run start so traces are reproducible; toolCatalogHash and hookVersionIds (a JSON array of HookVersion ids) pin the precise tool catalog and hook set this run executed against.
  • projection is derived from the event stream ({ cost_usd, duration_ms, tool_call_count, status, last_event_at, … }); projectionVersion lets us replay when projection logic changes. lastEventAt tracks the most recent appended event for cheap ordering and liveness.
  • threadId is the optional FK linking the run to a conversation (Decision 0016). Runs in the same thread share message history; it's nullable for backfill and one-shot API calls that don't belong to a conversation. onDelete: SetNull so deleting a thread doesn't orphan its run history.

Run.status is the enum active | awaiting_approval | completed | failed | budget_exceeded | cancelled.

A RunEvent is { id, runId, sequence, type, payload, idempotencyKey?, createdAt }. Events are append-only and ordered by sequence, unique on @@unique([runId, sequence]). type is the typed union in src/lib/events.ts; payload is the event body; idempotencyKey dedups re-delivered appends.

Conversations — Thread (Decision 0016)

A first-class workspace entity that groups runs sharing a message history. Metadata only — the messages themselves reconstruct from the RunEvent log of the linked Runs. Fields: { id, workspaceId, title, archivedAt?, starred, shareSlug? @unique, createdAt, lastMessageAt }. title is auto-generated from the first user message and user-editable; shareSlug (when present, globally unique) exposes the thread read-only at /threads/{shareSlug} without auth; lastMessageAt is bumped on every appended Run.

Triggers — Trigger (Decision 0017)

Inbound starters: a webhook arrives or a cron timer fires and Harmony spawns a Run for a named Agent. A distinct family from Hooks (which are in-run interceptors). Fields: { id, workspaceId, agentId, kind, name, config, authBindingId?, enabled, lastFiredAt?, failureCount, createdAt }, unique on (workspaceId, name). kind is the TriggerKind enum webhook | cron | email_received | repo_event. config is kind-specific (webhook: { prompt_template? }, cron: { schedule, input_template }, email_received: { address }, repo_event: { repo, events }). authBindingId points at a Credential row holding the HMAC secret (webhook) or OAuth account ref (email/repo) — the auth secret lives in the vault, never inline.

Providers — ProviderConfig (Decision 0009)

One row per (workspace, concern, name). concern is the enum storage | vault | llm | vectorstore | transport | webhooks | compute | knowledge — note there is no sandbox value yet. encryptedConfig is base64 AES-GCM ciphertext encrypted with a per-workspace HKDF-derived key (Decision 0010). isPrimary flags the workspace's default for that concern. The connection-test result lands in lastTestedAt, lastTestStatus (ok | error | untested, default untested), and lastTestReason; capabilities records what the adapter reported at the last test.

Deployment (Decision 0011)

Per-AgentVersion compute placement record. adapterRef is adapter-specific (e.g. a Hetzner server ID, a Fly machine name). status is pending | deploying | ready | stopped | failed. lastHeartbeatAt is the runtime's liveness signal; truth comes from heartbeat, not from adapter status.

IdempotencyKey

Postgres-backed dedup for mutating endpoints. Keyed on the request's Idempotency-Key header. Stores responseStatus + responseBody for replay on retry. Records auto-expire (24-hour retention).

Conventions

  • Primary keys: CUIDs everywhere — sortable, URL-safe, 25 characters.
  • Timestamps: createdAt (default now()), updatedAt (Prisma @updatedAt). All timestamptz.
  • Cascades: a Workspace delete cleans up all owned resources and their versions. A User delete cascades into Auth.js rows. Versions cascade with their parent.
  • No soft-delete column today. Audit-relevant rows (ApiKey) use a revokedAt instead.

Migrations

npm run db:push          # sync schema without a migration (dev / skeleton)
npm run db:migrate:dev   # create a migration and apply it (proper)
npm run db:migrate       # apply migrations in production (no schema diff)

Migration history lands once we transition off db push — likely after the first Decision 0010 RLS migration.

What's not modelled yet

  • API key minting + bearer auth — schema exists (ApiKey), endpoints not yet shipped
  • Provider adapters — schema exists (ProviderConfig), no adapters wired
  • CredentialBinding extraction — currently a JSON field on AgentVersion; may become its own table when bindings need querying or per-binding TTL semantics
  • Webhook deliveries — designed in Decision 0009, no table yet
  • Memory — designed in /docs/api/sessions, no table yet
  • Eval runs — designed in /docs/api/sessions, no table yet
  • Audit log table — referenced in Decision 0010, no table yet

See the roadmap for the open backlog.