Minds is a runtime for building persistent autonomous entities called Minds. A Mind has an identity, purpose, goals, durable state, memory, event subscriptions, tasks, and a lifecycle. It can wake for an event, act, wait for input, resume later, and sleep when it has no work.
The Mind persists beyond any one task or worker execution. Workers are disposable and perform work on the Mind's behalf. Minds is not tied to GitHub or to a particular agent engine.
The first MVP uses one Repository Mind whose purpose is to keep a GitHub repository healthy. GitHub is the first external environment, not the definition of a Mind. The MVP tests whether a persistent Mind can react to events, execute durable tasks, wait for approval, resume, preserve its history, and recover after the runtime restarts.
The current prototype stores runtime data in PostgreSQL. Phases 3-7 are implemented; phases 3-6 are locally verified, and the Phase 7 web UI and its read endpoints are verified against a seeded throwaway database. A live GitHub Actions approval round trip also passed. The MVP is not complete. See progress.md for current status and verification results.
The planned architecture keeps durable responsibilities in Minds:
- Identity, purpose, goals, and current state
- Memory, event subscriptions, and lifecycle
- Tasks, approvals, execution history, and recovery
- Choosing an executor for a task
Workers perform task execution, such as interacting with an agent engine, tools, shell commands, or a repository. A worker may disappear without losing the Mind's identity or persisted state. The current code has two executors: an in-process local executor and a disposable GitHub Actions worker.
For the first MVP, the implemented worker path is:
- GitHub sends a signed webhook to the Minds server.
- The runtime stores the event and creates a task and one execution attempt.
- The GitHub worker executor dispatches a workflow in the configured repository.
- The worker reports
acceptedwith its workflow run number, then reports one outcome toPOST /executions/:id/reports. - The runtime records the outcome and returns the Mind to sleep.
Every execution row is one attempt with a typed outcome. An executor may report what happened; the runtime decides what that means for the task and the Mind. If a report never arrives, the runtime probes the attempt when its lease expires. A live attempt keeps its lease, and a gone attempt is abandoned. A restart probes open attempts instead of assuming they died.
To submit a user message, send POST /messages with a non-empty message. Set requiresApproval to true when the worker must wait for a human decision. The worker reports its approval request to the runtime. The runtime persists the request and leaves the Mind in waiting. POST /tasks/:id/approve dispatches a new worker execution with the saved continuation context. POST /tasks/:id/reject records a terminal rejection.
The prototype API does not authenticate reads. Mutations require Authorization: Bearer <MINDS_API_TOKEN>, but GET routes still rely on a trusted network. Do not expose these routes to untrusted networks.
The runtime stores structured memory records by Mind. Call remember(type, content) to add a fact, action, decision, or repository knowledge. The runtime also records completed, failed, and rejected task outcomes. Call getMemory(limit) to read a Mind's records.
Before each worker execution, the runtime sends the latest bounded memory context as read-only workflow input. Workers do not write to the memory table. Memory uses PostgreSQL's existing memory table. This phase does not add embeddings or semantic search.
apps/clicontains the local-executor demo.apps/servercontains the Fastify server.apps/webcontains the Phase 7 Next.js observability and control UI.packages/memoryowns structured Mind memory and worker context.packages/runtimeowns the Mind lifecycle, task orchestration, supervision, and recovery.packages/githubverifies and maps GitHub webhook events.packages/executorscontains the executor contract and the local and GitHub Actions worker executors.packages/dbcontains the PostgreSQL client, migrations, and database scripts.tests/unit,tests/integration, andtests/manualcontain the test suites..github/workflows/minds-worker.ymlcontains the disposable worker workflow.
- Bun 1.4.2
- PostgreSQL
- A GitHub repository for webhook events and workflow dispatch
- A GitHub token with access to that repository and permission to dispatch workflows
Create a .env file in the repository root. Do not commit this file.
DB_HOST=localhost
DB_PORT=5432
DB_NAME=minds
DB_USER=postgres
DB_PASSWORD=
GITHUB_OWNER=your-owner
GITHUB_REPO=your-repository
GITHUB_TOKEN=your-token
GITHUB_WEBHOOK_SECRET=your-webhook-secret
MINDS_REPORT_SECRET=your-report-secret
MINDS_API_TOKEN=your-operator-token
MINDS_SERVER_URL=https://your-public-server-url
PORT=3000
MIND_ID=repository
# Default executor for a Mind with no "executor" field: github-worker or local.
# MINDS_EXECUTOR=github-worker
# Uncomment only after creating the file, for example by copying
# minds.example.json to minds.json.
# MINDS_CONFIG=minds.json
NGROK_URL=https://your-public-server-urlThe server requires GITHUB_OWNER, GITHUB_REPO, GITHUB_WEBHOOK_SECRET, MINDS_REPORT_SECRET, and MINDS_API_TOKEN. Set GITHUB_TOKEN to dispatch worker workflows and call the GitHub API. GitHub Actions must be able to reach MINDS_SERVER_URL to report acceptance and outcomes. The integration test uses NGROK_URL as the public server URL.
MINDS_API_TOKEN authenticates operator mutations: POST /messages, POST /tasks/:id/approve, POST /tasks/:id/reject, POST /tasks/:id/deadline, POST /wake-intents, and DELETE /wake-intents/:id. Each requires Authorization: Bearer <token> and returns 401 without it. POST /events keeps its GitHub signature check, POST /executions/:id/reports uses the per-execution report token, and GET /health stays public. Reads are still unauthenticated and rely on a trusted network in this version.
MINDS_EXECUTOR defaults to github-worker. Set it to local, or set executor on a Mind definition, to run that Mind's tasks in the server process. An unknown executor kind fails startup with the registered kinds in the message.
The database settings default to localhost:5432, database minds, user postgres, and an empty password. PORT defaults to 3000, and MIND_ID defaults to repository.
In the configured GitHub repository, add the worker workflow from .github/workflows/minds-worker.yml. The server sends each dispatched attempt its own report_token workflow input, and the worker returns it in the X-Minds-Report-Token header; no repository secret is needed for that. Configure a webhook that sends workflow_run and pull_request events to https://your-public-server-url/events, using the same value as GITHUB_WEBHOOK_SECRET.
MIND_ID is always the primary Mind and is registered even when no configuration file exists, so a single-Mind deployment needs no extra setup. To register more Minds in the same server process, copy minds.example.json to minds.json in the working directory and add entries, or point MINDS_CONFIG at another JSON file. Set MINDS_CONFIG only after that file exists: an explicitly named file that is missing aborts startup, while an absent default minds.json simply means no additional Minds.
The file is a JSON array of Mind definitions:
[
{
"id": "research",
"name": "Research Mind",
"purpose": "Track open questions.",
"goals": ["answer outstanding questions"],
"subscriptions": ["user.message"],
"executor": "local"
}
]id, name, and purpose are required. goals and subscriptions are optional string arrays, and executor is an optional executor kind. Unknown fields are rejected so a typo fails at startup. The minds table stays the durable source of truth: the runtime writes each definition's name and purpose when it initializes the Mind and never changes its lifecycle state. Every registered Mind gets its own tasks, events, executions, memory, wake intents, supervisor loop, and scheduler loop. GET /health still reports the primary MIND_ID, and the web UI still reads only that Mind. Use the optional mindId field on POST /messages and POST /wake-intents, or the optional mindId query parameter on GET /tasks and GET /wake-intents, to address another registered Mind. Routes that take a task, execution, or wake-intent ID resolve the owning Mind from the stored row.
Create a PostgreSQL database named minds, then run:
bun install --frozen-lockfile
bun run db:init
bun run db:migratedb:init reads the DB_* variables. The current db:migrate script connects to localhost:5432, database minds, as postgres with an empty password. Configure PostgreSQL to match those defaults before running it.
Start the HTTP server:
bun run serverThe health endpoint is GET /health. The server listens on port 3000 by default.
Run the local-executor demo:
bun run startBoth commands require a working PostgreSQL database. The server also requires the GitHub, report, and operator settings listed above.
The UI is a separate Next.js process. It observes and controls the Fastify runtime; it is never part of the Mind lifecycle, and the Mind keeps running when the UI is down.
Install its dependencies once; they are separate from the root install:
bun install --cwd apps/webStart the server, then start the UI:
bun run webOpen http://localhost:3001. MINDS_API_URL defaults to http://127.0.0.1:3000 and MINDS_ID to repository. Set both in apps/web/.env (see apps/web/.env.example) to match the server. Set MINDS_API_TOKEN there too, to the same value as the server: the web server attaches it as a bearer token for the mutations it sends through server actions, and the value never reaches the browser because the API client refuses to load there. The UI polls the Fastify API through a same-origin read-only proxy, and mutations go through server actions. The UI reads the server's runtime Mind ID from GET /health; if it differs from MINDS_ID, or the server does not report it, the UI reports the mismatch and disables mutations.
The UI is trusted-network only. Mutations carry the operator token; reads are unauthenticated. Do not expose it publicly. Its design is in docs/web-ui-design.md.
For a production build:
bun run web:build
bun --cwd apps/web run startRun the unit tests, server recovery integration test, and TypeScript check:
bun test tests/unit/
bun test tests/integration/server-restart.test.ts
bun run tsc --noEmit
bun run typecheck:webThe GitHub integration commands contact and modify the configured repository. Use a disposable repository and valid credentials before running them:
bun run test:phase3
bun run test:integrationtest:phase3 runs the worker, PR, idempotency, and failure-callback scenarios. The full integration command also runs the broader GitHub integration suite. Both need PostgreSQL, a running server, a public callback URL, and the required GitHub settings.
The repository table currently stores the GitHub token and webhook secret in PostgreSQL. Do not use production credentials with this prototype. Define protected credential storage before deploying Minds for production use.
The runtime initializes one primary Repository Mind plus any Minds in minds.json. The web UI reads only the primary Mind. The GitHub worker receives memory context, but its current deterministic task handlers do not use the context to change their results. See PLAN.md for MVP scope and progress.md for implementation details.