TOML Control for Agents
Everything an Admin sets in Settings can also be written in one file, captain.toml, and applied to the install. This covers branding, mail, sign-in, the Installation tab and the network settings the installer takes. The file never holds a secret, so you can commit it and review every change to it in a pull request, and an agent can apply it without anyone opening Settings.
A field written in the file is managed by the file. Settings shows it read-only with the note "Managed by captain.toml", and a field you leave out stays editable there. If you delete a field from the file, the next apply hands it back to Settings and keeps its value. Applying the same file twice changes nothing.
The file
The kit ships this example as examples/captain.toml, with a sample logo beside it.
schema = 1
[branding]
brand_color = "#1d4ed8" # buttons and links
text_color = "#111827"
logo = "logo.svg" # a PNG or SVG next to this file
[mail]
enabled = true
host = "smtp.example.com"
port = 587
security = "starttls"
from_address = "captain@example.com"
password = "env:SMTP_PASSWORD" # read from your environment when you apply
[sign_in]
password_sign_in = true
allowed_domains = ["example.com"]
[installation.retention]
query_text_days = 90
chat_days = 180
[models.embedding] # an OpenAI embedding model, with your own key
provider = "openai"
model = "text-embedding-3-large"
dimensions = 3072
key = "secret:captain-openai-key"
[control_plane]
health_report = "off"
[network] # applied by the installer, with --include-network
extra_hosts = ["smtp.example.com"]
[network.model_provider_cidrs]
openai = ["198.51.100.0/24"] # the range you reach OpenAI throughA secret is written as where it comes from: "installer" for the secret you gave the installer, "env:NAME" for a variable on the machine that runs the installer, which is sealed with the install's own key, "sealed" to keep the one an Admin typed in Settings, or "none".
Sections
| Section | What it sets |
|---|---|
[branding] | brand_color, text_color and logo, with the same contrast and logo rules as Settings. |
[mail] | enabled, host, port, security, username, from_address and password. |
[sign_in] | Password sign-in, single sign-on (sso_enabled, issuer, client_id, client_secret), allowed_domains, new_user_role, and the claims and groups under More settings. |
[installation] | data_residency, and the Installation tab in [installation.models], [installation.files], [installation.retention], [installation.alerts] and [installation.sync]. Each field has the name of its setting, for example chat_days or max_upload_mb. |
[models.chat], [models.embedding], [models.vision], [models.tagging], [models.rerank] | The model behind each job: provider (Vertex AI, Bedrock, Azure OpenAI, or Anthropic and OpenAI with your own key), model, region, dimensions for embeddings, and key, the name of the secret in your cloud's secret store that holds the key, written "secret:<name>". These apply with --include-network, and the provider's address ranges go in [network.model_provider_cidrs]. |
[control_plane] | health_report, and Captain's addresses for updates and health reports with their address ranges. |
[network] | Hosts and address ranges Captain may reach, model provider ranges, global_access, access to the cluster's API, and the private domain and its certificate. |
[[sources.s3]], [[sources.azure]], [[sources.gcs]], [[sources.r2]], [[sources.supabase]], [[sources.backblaze]], [[sources.sharepoint]] | One block for each bucket or tenant the install may read, with the same fields as the install's sync.sources entries: for S3 name, bucket, region, queue_url, role_arn, external_id, endpoint and hosts. [sources] holds what applies to every source. These apply with --include-network. |
[sources.aws_account] | The module you run in your own AWS account for S3: name, region, buckets, google_service_account_ids, external_id, kms_key_arns for buckets encrypted with your own keys, and enable_bucket_eventbridge. The plan writes a ready terraform.tfvars.json into byoc/terraform/sync-sources/aws, with the install's own service account ids filled in when you leave google_service_account_ids out, and prints the one command your AWS admin runs in that account. Captain never runs it. |
[installation.vector_store] | tier, "disk" or "hot". It applies to collections created after the change, with --include-network. |
[[syncs]] | One block for each sync that keeps a collection in step with a bucket: collection, provider, then the fields of that provider's sync, such as bucket, prefix, region, role_arn, include_patterns, deletion_policy and sync_interval_minutes. A sync's secret is "env:NAME", or "sealed" to keep the one it already holds. |
./install.sh settings export writes every field with its current value, which is the easiest way to see them all.
Commands
./install.sh settings plan captain.toml # check the file and show what would change
./install.sh settings apply captain.toml # apply the app settings
./install.sh settings apply captain.toml --include-network # also run the installer for [network]
./install.sh settings export captain.toml # write the install's current settingsA plan lists the app settings and the install settings apart, and changes nothing:
App settings (saved in the running install):
branding.brand_color: "Captain's" -> "#1d4ed8"
installation.retention.chat_days: 0 -> 180
Install settings (Terraform and chart, applied by the installer):
chart networkPolicy.extraHosts: as in values.customer.yaml -> ["smtp.example.com"]The app settings are saved through the same checks as a save in Settings, and each change appears in the change history as made by captain.toml. The install settings change the cluster or the network, so they apply only with --include-network, which runs the installer and shows Terraform's plan before it changes anything. To bring up a new install already configured, set CAPTAIN_SETTINGS=captain.toml on ./install.sh install.
An agent that has an Admin's API key but no access to the cluster can send the file to the API instead. It applies the app settings the same way, and the install settings still go through the installer.
curl -X POST https://api.<your domain>/v2/install/settings/plan \
-H "Authorization: Bearer $CAPTAIN_API_KEY" -H "Content-Type: application/toml" \
--data-binary @captain.tomlPOST /v2/install/settings/apply takes the same body.
A plan names each new sync with the collection it fills, its source and the number of files its first run will index. Apply creates or updates syncs and never deletes one. A sync you remove from the file goes back to the Sync Manager and keeps running.
S3 in a locked-down install
Every S3 request goes through the install's outbound proxy, which opens HTTPS only to the hosts your S3 sources name. Declare the bucket in captain.toml, then index it once with the index endpoint, or keep it current with a [[syncs]] block.
schema = 1
[network]
sync_other_clouds = true # on Google Cloud: the NAT and one HTTPS firewall rule for the outbound proxy
nat_addresses = "reserved" # fixed outbound addresses, for an allowlist on the bucket's side
nat_address_count = 1
[sources]
aws_sts_region = "us-west-1"
s3_retry_mode = "adaptive" # backs off on its own when S3 slows the install down
s3_max_attempts = 5
[sources.aws_account] # the role, its trust and its queue, in your AWS account
name = "captain-sync"
region = "us-west-1"
buckets = ["acme-docs"]
external_id = "captain-sync"
kms_key_arns = ["arn:aws:kms:us-west-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab"]
enable_bucket_eventbridge = true
[[sources.s3]]
name = "docs-s3"
bucket = "acme-docs"
region = "us-west-1"
queue_url = "https://sqs.us-west-1.amazonaws.com/123456789012/acme-docs-events"
role_arn = "arn:aws:iam::123456789012:role/captain-sync"
external_id = "captain-sync"
# request_payer = true # for a requester-pays bucket
[[syncs]]
collection = "contracts"
environment = "production"
provider = "s3"
bucket = "acme-docs"
prefix = "legal/"
region = "us-west-1"
role_arn = "arn:aws:iam::123456789012:role/captain-sync"
external_id = "captain-sync"
sync_interval_minutes = 60Run ./install.sh settings plan captain.toml. The install settings list shows the new source entry, the reserved addresses and the way out, the AWS account list shows the role, its trust and its KMS keys with the one command to run in that account, and the app settings list shows the sync and how many files it will index. The plan also checks that the queue is in the bucket's region and that the role and region are well formed, and it says which line to fix if not. The plan has already written the module's terraform.tfvars.json, so your AWS admin can run the one command it printed, which creates the role the install assumes and the queue. Then run ./install.sh settings apply captain.toml --include-network. The installer opens the way out, and the sync is created once the install can reach the bucket. If the role does not exist yet, the sync waits with a sentence that says it cannot read its bucket, everything else is applied, and the next apply creates it. In AWS, the role's trust policy must allow the install's identity with the external id you named. ./install.sh settings export and ./install.sh addresses print the reserved outbound addresses, for a bucket policy or a firewall that allows only them. Every bucket the install reads, by a sync or by the index endpoint, must have its own [[sources.s3]] block. The plan says so for a sync, and the index endpoint answers source_not_reachable with the block to add.
To index the bucket once instead of keeping it in sync, leave out the [[syncs]] block, apply the file, and call the index endpoint.
curl -X POST https://api.<your domain>/v2/collections/contracts/index/s3 \
-H "Authorization: Bearer $CAPTAIN_API_KEY" -H "Content-Type: application/json" \
-d '{
"bucket_name": "acme-docs",
"bucket_region": "us-west-1",
"auth": {
"type": "assume_role",
"role_arn": "arn:aws:iam::123456789012:role/captain-sync",
"external_id": "captain-sync"
}
}'/index/s3/directory indexes everything under one path, and /index/s3/file indexes one object. Both take the same auth block.
Step by step
- Run
./install.sh settings export captain.tomlto start from what the install has now, syncs included. - Change what you need, and delete the fields the file should not manage. Put secrets in the environment, never in the file.
- Run
./install.sh settings plan captain.tomland read both lists. A mistake is reported with its line and field. - Run
./install.sh settings apply captain.toml, adding--include-networkonly when a person has agreed to the infrastructure change. - Run the plan again and confirm it has nothing left to change.