Extension points
Core is the whole product. One person runs it on their own machine from one Compose file.
Custom code extends parts of the server and the operator app through extension points. An extension supplies another implementation of a core interface. Core ships a default for every point and runs with no extension loaded.
The hosted service is one repository that does this. It supplies the extensions it needs, including sign-in, billing, and sandboxes on more than one host. Any repository can supply extensions the same way. That service is proprietary and documented in its own repository.
Rules
- An extension depends on core, never the reverse. No core module imports an extension's, reads its settings, queries its tables, or branches on the extension that is running.
- Core is the whole product. Guilds, agents, runs, tools, connectors, subscription agents, Studio, Builder, recipes, collections, and usage are core. An extension adds no agent feature.
- Core starts on Docker alone. No cloud account, email provider, payment provider, or object store. Every instance key is optional: the operator sets the ones they want, each switches its feature on, and a feature without its key is off and says so. A run needs the organisation's own model key: core reads no instance key for a model provider.
- Core does not authenticate. Whoever reaches the port is the operator. The stack listens on loopback. A box reached from elsewhere sits behind the operator's own proxy, and that proxy decides who gets through (Remote access).
- Core runs every guild on one host. The control plane and every organisation's machines run on the Docker host of the Compose stack. Core never assumes every machine shares one host: where a machine runs and where its directory lives come from the sandbox provider.
- Custom code attaches at an extension point. When an extension needs something core lacks, core gains an extension point with a default of its own. Core gains no branch for that extension.
- The core repository is the source of truth. Core changes land here. A repository that extends core adds its code over a pinned core revision and carries no patch to core.
What an extension may replace
Each extension point is a core interface with a core default. An extension supplies another implementation when it composes the server or the operator app.
The server's composition root is createServer (src/compose.ts). It takes a list of ServerExtension (src/extension.ts). The extending repository has an entry point that loads its configuration and hands its extensions to runServer (src/run.ts). Core's src/server.ts passes none.
A factory on ServerExtension (policy, modelCredentials, instanceAdmin, sandboxes, identity) runs once at boot and receives the database connection as db, a Queryable (db/pg.js); sandboxes also receives the configuration and the master key, identity the configuration. blobStore receives the configuration alone. Where several extensions supply a factory, the first one that returns a value is used; every extension's orgCreated hook runs. The extension reads and writes core's tables through the db/ modules the package exports (db/orgs.js, db/users.js, db/connectors.js, db/mcp.js, db/usage.js, db/machines.js), builds the column lists of its own tables with db/columns.js and throws db/errors.js's RowMissing where a write finds no row, and loads a connector with its overrides applied through connectors/servers.js. Each function takes that connection, or the client of a transaction the extension has open, as its first argument; a function whose writes commit together runs them in a savepoint of that transaction.
loadConfig (src/config/index.ts) takes the AUTH_MODE values an extension identifies requests in, beside core's compat-cookie and trusted-header. Paths below are under apps/orchestrator/src/ unless they say apps/web.
| Extension point | Interface | Supplied by | Core's default |
|---|---|---|---|
| Identity | IdentityProvider (http/identity.ts) | ServerExtension.identity | compat-cookie or trusted-header |
| Organisation policy | OrgPolicy (policy/index.ts) | ServerExtension.policy | OPEN_POLICY: no cap |
| Model credentials | ModelCredentialsProvider (llm/credentials.ts, exported as llm/credentials.js) | ServerExtension.modelCredentials | The organisation's own row under Settings → Model keys |
| Organisation created | OrgCreatedHook (db/orgs.ts) | ServerExtension.orgCreated | Nothing |
| Sandbox provider | SandboxProvider (extension.ts) | ServerExtension.sandboxes | One RunSandboxes (sandbox/) |
| Blob store | BlobStore (lib/blob-store.ts) | ServerExtension.blobStore | FileBlobStore under ATTACHMENTS_ROOT |
| Instance admin | InstanceAdmin (http/instance-admin.ts) | ServerExtension.instanceAdmin | An owner of the seed organisation org_home |
| Instance integrations | Integration[] (instance/integrations.ts) | ServerExtension.integrations | Core's registry (Instance keys) |
| Connectors | ConnectorEntry[] (connectors/registry.ts) | ServerExtension.connectors | Core's folders under src/connectors/ |
| Database | migrate(pool), seed(pool) | ServerExtension.migrate, .seed | Core's chain and seeds (Data) |
| Routes | routes(app, deps) | ServerExtension.routes | Core's routes |
| Operator app slots | AppSlots (apps/web/src/app/slots.ts) | mount(slots) (apps/web/src/mount.tsx) | None filled (Web app) |
| Operator app build | the build directory | ServerExtension.webApp | apps/web/dist |
What each point takes
- Identity.
currentUser(request)returns the request's user or a 401. An optionalonSendrenews a credential as each response is sent. An optionaldescribe()adds what its sign-in page needs toGET /api/auth/config. Core's modes read theX-Guilds-Userheader orguilds_usercookie (compat-cookie), or the proxy's email header (trusted-header). A mode core does not implement, with no provider for it, signs no one in.GET /api/auth/configandGET /api/auth/meare core's (http/me-routes.ts). - Organisation policy.
standing(orgId)returns the organisation'sOrgLimitsand whether it is blocked. The limits are the agent (maxAgents), browser-agent (maxBrowserAgents), subscription-agent (maxSubscriptionAgents, every agent that holds a harness, ascountsAsSubscriptionAgentreads it), guild, machine (maxMachines), agents-per-machine (maxAgentsPerMachine, never above core's 32), and concurrent-run caps; the monthly Studio and Builder quota and their generation budgets; the organisation's own MCP servers; and monthly calls on a connector's platform login by slug.OPEN_POLICYcaps nothing, and every organisation runs under the instance's own ceiling (MAX_CONCURRENT_GENERATIONS). Core checks every cap against the policy it is given. A refusal names the limits'source(<source> limit reached: agents). - Model credentials.
modelCredentials(orgId, provider)returns theapiKey, an optionalbaseURL, and an optionalonUsagecallback core calls once per completion with the run id, model, token usage, and cost. It returns null while the provider is not connected. It may throw aPolicyError, which core shows and does not start the run on. A provider whose credentials resolve while the organisation's row holds no key is shown as provided by the platform (source: "platform"). Core's default decrypts the organisation's row and has no callback. Who pays, whether a budget exists, and what the callback does are the implementation's (Orchestrator). - Organisation created. The hook runs inside the transaction that creates an organisation. Hooks from several extensions run in order.
insertOrgandinsertUser(db/orgs.ts,db/users.ts) run the hook they are passed. The routes passAppDeps.orgCreated, which is the extensions' hooks unless the caller ofbuildAppgives its own. - Sandbox provider.
GenerationSandboxes(generation/machines.ts), keyed by machine:ensure(machine),connectRunning,destroy,listRunningMachineIds, and an optionalharnessesOf(machineId)(the harness CLIs the machine's container carries). On an agent's seat (agent id, machine id, slot, browser language):startBrowser,stopBrowser,purgeAgent,novncTarget,cdpTarget(the upstream base and headers of the agent's DevTools relay),startCli, andcliTarget. An optionalmachineHost(machineId)gives the host id, workspace root, and proxy URL a machine runs with.SandboxProvideraddsstart,close, and an optionaldestroyAgentSandboxesthe boot layout step calls. Core'sRunSandboxesruns onOPENSANDBOX_URLandWORKSPACE_ROOT, every machine on this host. Moving an agent between machines whose workspace roots differ is refused. - Blob store.
ATTACHMENTS_ROOTisSTATE_ROOT/attachmentson the Compose stack. Without it, core usesMemoryBlobStore, which the tests use. - Instance integrations. Each declares its
source(storeorenv) and itsfields. An extension's are listed with core's inGET /api/instance, and its store integrations are written through the same admin routes. - Connectors. Each is built from a connector folder with
folderEntry(manifest, adapter, folder, publisher). An extension's are installed after core's, before the seed runs, and are listed and seeded like core's. A slug core already has fails boot. - Database. An extension's migrations and seeds run after core's, on every boot.
- Routes. An extension's routes are registered on the Fastify app before core's.
- Operator app slots. Core's entry passes none: the app is whole without a slot. The app reads
GET /api/instancefor the integrations.
How an extending repository holds core
A repository that extends core holds this repository as a git submodule pinned to a commit. Beside it sit its own server package, its own operator app, its Compose overlays, and its deployment files. It passes its extensions when it composes the server and the operator app.
- Workspace. Its pnpm workspace spans core's packages (
core/apps/*,core/packages/*) and its own, under a lockfile of its own. Its packages list core's as dependencies and import only what those packages export.apps/orchestrator/package.jsonlists underexportsthe modules another package may import: the composition root and process runner, the extension interfaces, and the domain modules and test helpers an extension builds on. A module left off the list does not resolve from outside.apps/web/package.jsonexportsmount, the slots (app/slots), the router (app/router), the build recipe (vite,appConfig()invite.app.ts), and what an extension's screens use: the API client and session (api/client,api/session), the API types, one module per domain (api/types/<domain>), the guards that narrow what the server sends (api/wire), identity (app/identity), formatting (app/format), the tool-call formatting of a run (features/agent/runs/toolFormat), and the member role helpers (features/settings/members). - Boundary lint.
lint/boundary.jsis an Oxlint plugin a core package loads from its.oxlintrc.jsonwith the packages it may not import and the repository its relative imports must stay inside. It fails any orchestrator, web or design-system file, tests and scripts included, that imports one of those packages or a relative path that leaves core's repository. No file is excepted. Core's repository holds nothing of an extension and passes its own check alone. The same plugin refuses a module that hands on another module's exports, except the indexes the package names (Code guidelines). - Images. Core's image (
apps/orchestrator/Dockerfile) holds no extension code, starts core's entry point, and serves core's build of the operator app. ItsCOREbuild argument is where core sits in the build context and under/app. The extending repository builds that Dockerfile from its own root withCORE=<its core directory>, so the install comes from its lockfile. Its own Dockerfile adds its server package and its app's build to the result, started from its entry point. - Compose. Its Compose files are overlays on core's
docker-compose.yml. Relative paths in the merged files resolve from core's directory. - Makefile. Core's
Makefileruns in whichever root includes it.COREis core's path under that root (.in core's repository).COMPOSEis the Compose command that reads that root's.env. The extending repository's Makefile setsCORE, its development stack (DEV_STACK,COMPOSE_DEV,DEV_BASE_IMAGE,WEB_PACKAGE,SEED_USER,SEED_ORG_SLUG,EXTENSION_TEST_PACKAGES,EXTENSION_COMPOSE_FILES), andSECRET_GOALS, the goals that start a box with real secrets and therefore get no development default. It then includes core's and adds its own targets. In that repositorymake upandmake devstart its stack.make -C <core directory> upstarts core alone. - Check.
scripts/check.shchecks that repository whenCHECK_ROOTnames its root. The checkout, the install, and every step happen there, with core and any other submodule at the commit it pins. Itscheck.stepsadds steps, one per line: the lane it joins (orchestratororweb), a name, and the command (Development).
Instance keys
An instance key is a credential the box holds for everyone on it, as opposed to an organisation's model key, secret, or connection. No instance key serves a model provider: the organisation's own key does (Orchestrator). Each belongs to an integration. An integration declares its fields (name, label, secret, optional, multiline, placeholder, and for an env field a default used while the variable is unset) and its source, store or env. It is on when every required field has a value, incomplete when some do, and off when none does; an optional field tunes it and never switches it off.
- Core requires none and starts with none.
- A
storeintegration's values are entered by a platform admin on Admin's Platform keys tab, throughPUT /api/admin/instance/keys/:integration, and removed withDELETEon the same path (http/admin-instance-routes.tsoverconnectors/instance-keys.ts; anyone but an instance admin gets 404). The store (instance/keys.ts) keeps one row per integration ininstance_keys, encrypted with AES-GCM underSECRETS_MASTER_KEY, with who wrote it and when. It is decrypted into a process snapshot at boot and again after every write, and a reader resolves a field from that snapshot at call time, so a change takes effect without a restart. A write's effects (connectors/instance.ts) sync the platform logins, and a GitHub App replaced by one with another App ID, or removed, disconnects every GitHub login installed with it, after the admin confirms with the count. No route returns a value. - An
envintegration's values are read from the orchestrator's environment at start. The operator writes them in.env(Configure). The Compose files name no instance key;.envreaches the container throughenv_file, so a variable set in the shell alone does not. Platform keys shows them read-only. - One registry (
src/instance/integrations.ts) names every integration, its source, its fields, and what it switches on. Modules ask the registry (integrationValue,integrationValues,missingFields,integrationState), not the environment or the table. An extension registers its own integrations through its extension, in the same shape: each declares itssourceand itsfields, and astoreone is written through the same routes. An integration's optionalvalidate(values)refuses values its fields alone allow by throwing anIntegrationValueError; the write is then a 422 with its message. System One's refuses aproviderother thantypesafe. - A connector may declare an integration of its own,
connector:<slug>: a platform key (auth.instance: { "own": true }on a token connector; its fields are the login fields) or an OAuth client (configuredwith no provider;client_idandclient_secret).connectors/instance.tsderives these from the platform connector rows at boot and after a connector is installed, updated, removed, reloaded, created, or patched, andinstalledIntegrations()lists core's, an extension's, then these. They are store integrations like the others, written through the same routes; a registry connector's row is deleted with it. The{ integration, field }form ofauth.instance, the box's OAuth client (oauth.provider), and the GitHub App are for connectors the box ships, core or an extension: a connector installed at runtime may not name them (Registry). - The instance descriptor (
GET /api/instance, any signed-in user) reports each integration'ssource, its state, which fields are set (for an env field, whether the variable itself is set; a default does not count), never a value, its setup flow when it has one, and what it switches on: native tools and connector slugs. An instance admin also sees when and by whom a store integration was written. The operator app turns off what depends on a missing integration, names it, and offers a platform admin the way to Platform keys. Admin's Platform keys tab lists every integration with its state and takes a store integration's values. - An instance key is the instance's own. A connector's platform login on one counts each organisation's calls a month, and
OrgLimits.monthlyConnectorCallscaps them; core's open policy caps none.
| Integration | Source | Fields | Switches on | Without it |
|---|---|---|---|---|
| Web search | store | api_key | The Tavily connector's platform login, tavily_search | The platform login is disconnected and runs leave tavily_search out; an organisation may connect a Tavily key of its own |
| System One | store | api_key, and provider (typesafe while blank, and the only one accepted) and model to tune it | Recipient and history selection in group chat, and the agent-optimized browser | Tag rules and the last 10 messages, and no agent-optimized browser |
| GitHub App | store | app_id, slug, private_key, client_id, client_secret, entered by hand or filled by the manifest flow (GitHub) | The GitHub connector and a guild's repositories | Tools marks the connector Not set up, names the missing fields, and disables Connect; a Connect sent anyway answers 422 |
| Google connectors | store | client_id, client_secret | The Gmail and Drive connectors (Gmail and Drive) | As for the GitHub App |
| Error reporting | env | SENTRY_DSN | Sentry | Structured logs only |
| Registry | env | REGISTRY_URL, the guilds.run registry while unset; REGISTRY_PUBLIC_KEY | Installing connectors and recipes from a registry; with the key, only from a signed index | Set empty, the box is offline |
| Connector code | env | CONNECTORS_CODE_TIER=1, CONNECTORS_ROOT | Registry connectors with adapter code, loaded at boot | A code install is refused and code on disk is not loaded |
SECRETS_MASTER_KEY, the PostgreSQL password, and the OpenSandbox key are not integrations. The box cannot run without them. ./setup.sh generates them. .env.example lists the error reporting variables and no store integration's fields. The Compose file sets CONNECTORS_ROOT under STATE_ROOT. Code and the other pages call instance keys platform keys.
Data
Core's tables are in schema public. Its migration chain starts at 0001_baseline in apps/orchestrator/drizzle/, a snapshot of its tables, recorded in public.__drizzle_migrations (Orchestrator).
An extension keeps its tables in a schema of its own. The two never share a name. A core box has no such schema. Its migration chain starts at a baseline of its own, recorded in that schema, and is applied by its extension's migrate after core's.
An extension's table may reference a core table. No core table references an extension's. An extension's SQL that reads core's tables, and a seed that writes rows in them, follows a change to those tables' columns.
A database applies a migration only when its stamp is later than the last one it recorded. Every migration is stamped after the one before it and before the build that ships it.
Names
The product is guilds.run. Cigale AI is the company that makes and operates it.
Identifiers carry the product's name:
- the
@guildsrun/*packages - the Compose project
guilds - the
guilds-*runtime helpers andGUILDS_*sandbox variables - the
guilds_*cookies andX-Guilds-*headers - the
guilds.recipeformat
"Cigale" names the company or its data product and nothing else. The Cigale connector in the catalog is the one place it appears in core.
Licence
Core is free software under the GNU Affero General Public License, version 3 only, copyright Cigale AI (LICENSE). Every core package declares AGPL-3.0-only.
Custom code plugs into core by importing it. Under the licence anyone who offers that extended software publishes it. The copyright holder does not have to. That holds only while Cigale AI owns or can relicense everything in core, and no contributor agreement is in place.
THIRD_PARTY_NOTICES.md lists what a build ships that others wrote.