primkit

Configuration Reference

All four primitives (taskprim, stateprim, knowledgeprim, and queueprim) read the same YAML configuration format. Copy config.example.yaml to config.yaml and edit to suit your environment. knowledgeprim adds additional fields for embedding and auto-connect.

Resolution Order

Configuration is resolved differently depending on whether you pass --config.

Highest precedence wins:

  1. --db / --port CLI flags — explicit per-invocation overrides
  2. YAML file — values from your config file, with ${ENV_VAR} interpolation for secrets
  3. Hardcoded defaults — e.g., port 8090

Environment variable overrides (TASKPRIM_DB, etc.) are not applied when a config file is present. This prevents a global env var from silently overriding per-agent configuration in multi-agent deployments. Use ${VAR} interpolation inside the YAML when you need to inject a dynamic value.

Without --config (env-only / container deployments)

Highest precedence wins:

  1. --db / --port CLI flags
  2. Environment overrides — prefix-based env vars (TASKPRIM_*, STATEPRIM_*, KNOWLEDGEPRIM_*, QUEUEPRIM_*)
  3. Hardcoded defaults

Full YAML Spec

storage:
  db: ~/.taskprim/default.db
  replicate:
    enabled: false
    provider: r2
    bucket: ${R2_BUCKET}
    path: taskprim.db
    endpoint: ${R2_ENDPOINT}
    access_key_id: ${R2_ACCESS_KEY_ID}
    secret_access_key: ${R2_SECRET_ACCESS_KEY}

auth:
  keys:
    - key: "tp_sk_your_api_key_here"
      name: "johanna"

server:
  port: 8090

taskprim:
  default_list: ""              # reserved — use TASKPRIM_LIST env var instead

# knowledgeprim-only settings (ignored by taskprim and stateprim)
embedding:
  provider: ""              # gemini | openai | custom (empty = disabled)
  model: ""                 # e.g., text-embedding-004 (Gemini), text-embedding-3-small (OpenAI)
  dimensions: 768           # expected output dimensions
  api_key: ${EMBEDDING_API_KEY}
  endpoint: ""              # custom endpoint for local models or proxies

auto_connect:
  enabled: true             # auto-link new entities to similar ones on capture
  threshold: 0.35           # cosine distance threshold (lower = more similar)
  max_connections: 10       # max auto-connections per capture

Fields

storage

FieldTypeDefaultDescription
dbstring~/.taskprim/default.dbPath to the SQLite database file. Created automatically if it doesn't exist. Parent directories are created as needed.

storage.replicate

Litestream replication configuration. When enabled, WAL frames are continuously streamed to object storage for durability. Replication runs for all commands (CLI, serve, MCP).

FieldTypeDefaultDescription
enabledboolfalseEnable WAL replication to object storage.
providerstringObject storage provider: r2, s3, b2, or gcs.
bucketstringBucket name in the object storage provider.
pathstringObject path within the bucket (e.g., taskprim.db).
endpointstringCustom S3-compatible endpoint. Required for R2 and B2. Not needed for AWS S3.
access_key_idstringAccess key for the object storage provider. Use ${ENV_VAR} interpolation.
secret_access_keystringSecret key for the object storage provider. Use ${ENV_VAR} interpolation.

auth

Authentication is only used in serve and MCP SSE modes. CLI mode relies on filesystem permissions.

FieldTypeDefaultDescription
keyslist[]List of API keys and their human-readable names. When empty, authentication is disabled (open mode).

Each key entry:

FieldTypeDescription
keystringThe API key value. Passed as Authorization: Bearer <key>.
namestringHuman-readable name mapped to this key. Used as the source field when creating tasks or records via the API, so you can tell who created what.

server

FieldTypeDefaultDescription
portint8090HTTP server port for serve and MCP SSE transport.

taskprim

taskprim-specific settings (ignored by stateprim). Note: the default_list field shown in the YAML spec is reserved for future use. Currently, the default list is set via the TASKPRIM_LIST environment variable only.

FieldTypeDefaultDescription
default_liststring""Reserved. Use the TASKPRIM_LIST environment variable to set the default list for new tasks when --list is omitted.

embedding (knowledgeprim only)

Vector embedding configuration. When a provider is configured, knowledgeprim generates embeddings on capture and enables vector and hybrid search modes.

FieldTypeDefaultDescription
providerstring""Embedding provider: gemini, openai, or custom. Empty string disables embedding.
modelstring""Provider-specific model name (e.g., text-embedding-004 for Gemini, text-embedding-3-small for OpenAI).
dimensionsint768Expected output vector dimensions. Must match the model's output.
api_keystringAPI key for the embedding provider. Use ${ENV_VAR} interpolation.
endpointstring""Custom endpoint URL. Required for custom provider. Optional for openai (overrides default). Unused for gemini.

Supported providers:

ProviderModelDimensionsNotes
geminitext-embedding-004768Google Gemini (default model; supports Matryoshka dimensions)
openaitext-embedding-3-small1536OpenAI
openaitext-embedding-3-large3072OpenAI (highest quality)
customAnyConfigurableAny OpenAI-compatible endpoint (local models, proxies)

auto_connect (knowledgeprim only)

Auto-connect configuration. When embedding is enabled, new entities are automatically linked to semantically similar existing entities on capture.

FieldTypeDefaultDescription
enabledbooltrueEnable auto-connect when capturing with embeddings.
thresholdfloat0.35Cosine distance threshold. Lower = more similar. Entities below this threshold get automatic similar_to edges.
max_connectionsint10Maximum number of auto-connections created per capture.

Environment Variable Interpolation

Any value in the YAML file can reference environment variables using ${VAR_NAME} syntax. Variables are interpolated at startup. Missing variables resolve to an empty string.

storage:
  replicate:
    access_key_id: ${R2_ACCESS_KEY_ID}
    secret_access_key: ${R2_SECRET_ACCESS_KEY}

This lets you keep secrets out of the config file while still having a single file for all other settings.

Environment Variable Overrides

Environment variables with the appropriate prefix are used when no --config file is provided. They are the primary configuration mechanism for container and CI deployments where mounting a config file is impractical.

Multi-agent note: If you run multiple primitive instances each with its own --config file (e.g. taskprim --config /configs/agent-a.yaml serve), env var overrides are skipped and each instance uses its own file exclusively. Use ${VAR} interpolation inside the YAML to inject secrets while keeping the file authoritative.

taskprim prefix: TASKPRIM_

Env VarOverrides
TASKPRIM_DBstorage.db
TASKPRIM_SERVER_PORTserver.port
TASKPRIM_REPLICATE_ENABLEDstorage.replicate.enabled
TASKPRIM_REPLICATE_PROVIDERstorage.replicate.provider
TASKPRIM_REPLICATE_BUCKETstorage.replicate.bucket
TASKPRIM_REPLICATE_PATHstorage.replicate.path
TASKPRIM_REPLICATE_ENDPOINTstorage.replicate.endpoint
TASKPRIM_REPLICATE_ACCESS_KEY_IDstorage.replicate.access_key_id
TASKPRIM_REPLICATE_SECRET_ACCESS_KEYstorage.replicate.secret_access_key

stateprim prefix: STATEPRIM_

Same mapping as taskprim, with STATEPRIM_ prefix:

Env VarOverrides
STATEPRIM_DBstorage.db
STATEPRIM_SERVER_PORTserver.port
STATEPRIM_REPLICATE_ENABLEDstorage.replicate.enabled
STATEPRIM_REPLICATE_PROVIDERstorage.replicate.provider
STATEPRIM_REPLICATE_BUCKETstorage.replicate.bucket
STATEPRIM_REPLICATE_PATHstorage.replicate.path
STATEPRIM_REPLICATE_ENDPOINTstorage.replicate.endpoint
STATEPRIM_REPLICATE_ACCESS_KEY_IDstorage.replicate.access_key_id
STATEPRIM_REPLICATE_SECRET_ACCESS_KEYstorage.replicate.secret_access_key

knowledgeprim prefix: KNOWLEDGEPRIM_

Same storage/server mapping as above, plus embedding-specific overrides:

Env VarOverrides
KNOWLEDGEPRIM_DBstorage.db
KNOWLEDGEPRIM_SERVER_PORTserver.port
KNOWLEDGEPRIM_REPLICATE_ENABLEDstorage.replicate.enabled
KNOWLEDGEPRIM_REPLICATE_PROVIDERstorage.replicate.provider
KNOWLEDGEPRIM_REPLICATE_BUCKETstorage.replicate.bucket
KNOWLEDGEPRIM_REPLICATE_PATHstorage.replicate.path
KNOWLEDGEPRIM_REPLICATE_ENDPOINTstorage.replicate.endpoint
KNOWLEDGEPRIM_REPLICATE_ACCESS_KEY_IDstorage.replicate.access_key_id
KNOWLEDGEPRIM_REPLICATE_SECRET_ACCESS_KEYstorage.replicate.secret_access_key
KNOWLEDGEPRIM_EMBEDDING_PROVIDERembedding.provider
KNOWLEDGEPRIM_EMBEDDING_MODELembedding.model
KNOWLEDGEPRIM_EMBEDDING_DIMENSIONSembedding.dimensions
KNOWLEDGEPRIM_EMBEDDING_API_KEYembedding.api_key
KNOWLEDGEPRIM_EMBEDDING_ENDPOINTembedding.endpoint

queueprim prefix: QUEUEPRIM_

Same storage/server mapping as taskprim and stateprim. No primitive-specific fields beyond the shared base.

Env VarOverrides
QUEUEPRIM_DBstorage.db
QUEUEPRIM_SERVER_PORTserver.port
QUEUEPRIM_REPLICATE_ENABLEDstorage.replicate.enabled
QUEUEPRIM_REPLICATE_PROVIDERstorage.replicate.provider
QUEUEPRIM_REPLICATE_BUCKETstorage.replicate.bucket
QUEUEPRIM_REPLICATE_PATHstorage.replicate.path
QUEUEPRIM_REPLICATE_ENDPOINTstorage.replicate.endpoint
QUEUEPRIM_REPLICATE_ACCESS_KEY_IDstorage.replicate.access_key_id
QUEUEPRIM_REPLICATE_SECRET_ACCESS_KEYstorage.replicate.secret_access_key

Examples

Minimal (local development)

storage:
  db: ~/.taskprim/default.db

Everything else uses defaults. No auth, no replication.

With Cloudflare R2 replication

storage:
  db: /data/taskprim.db
  replicate:
    enabled: true
    provider: r2
    bucket: primkit-backups
    path: taskprim.db
    endpoint: https://abc123.r2.cloudflarestorage.com
    access_key_id: ${R2_ACCESS_KEY_ID}
    secret_access_key: ${R2_SECRET_ACCESS_KEY}

auth:
  keys:
    - key: "tp_sk_prod_key_1"
      name: "api-server"
    - key: "tp_sk_prod_key_2"
      name: "agent-01"

server:
  port: 8090

Environment-only (no config file)

export TASKPRIM_DB=/data/taskprim.db
export TASKPRIM_SERVER_PORT=9090
export TASKPRIM_REPLICATE_ENABLED=true
export TASKPRIM_REPLICATE_PROVIDER=s3
export TASKPRIM_REPLICATE_BUCKET=my-bucket
export TASKPRIM_REPLICATE_ACCESS_KEY_ID=AKIA...
export TASKPRIM_REPLICATE_SECRET_ACCESS_KEY=secret...

taskprim serve

When no --config flag is provided, defaults are used and env overrides are applied as the primary configuration mechanism.

knowledgeprim with Gemini embedding

storage:
  db: ~/.knowledgeprim/default.db

embedding:
  provider: gemini
  model: text-embedding-004
  dimensions: 768
  api_key: ${GEMINI_API_KEY}

auto_connect:
  enabled: true
  threshold: 0.35
  max_connections: 10

server:
  port: 8092

knowledgeprim without embedding (FTS-only)

storage:
  db: ~/.knowledgeprim/default.db

Works immediately. Full-text search, manual edges, graph traversal, and discovery all work without embedding.

Database Path Resolution

The database path is resolved in priority order. The rules differ based on whether --config is provided:

With --config /path/to/config.yaml (per-agent configuration):

PrioritySource
1--db flag
2storage.db in the config file
3Home directory default (~/.taskprim/default.db, etc.)

Without --config (env-only / container deployments):

PrioritySource
1--db flag
2TASKPRIM_DB / STATEPRIM_DB / KNOWLEDGEPRIM_DB env var
3Home directory default (~/.taskprim/default.db, etc.)

The database file and its parent directory are created automatically if they do not exist.

SQLite Pragmas

The following SQLite pragmas are applied automatically when the database is opened:

PragmaValuePurpose
journal_modeWALAllows concurrent reads during writes. Required for Litestream replication and HTTP serve mode.
foreign_keysONEnforces referential integrity (e.g., task labels reference tasks).
busy_timeout5000Waits up to 5 seconds for locks instead of failing immediately, preventing "database is locked" errors.