@tinyclaw/config
SQLite-backed, Zod-validated configuration management for Tiny Claw. Stores non-sensitive settings like provider preferences, channel configurations, and user preferences.Installation
Main Exports
ConfigManager
new ConfigManager(config?: ConfigManagerConfig)
Create a new configuration manager instance.
Override the config storage directory (defaults to
~/.tinyclaw/data/)Methods
get<V>(key: string, defaultValue?: V): V | undefined
Retrieve a config value by dot-notation key.
has(key: string): boolean
Check if a config key exists.
set(key: string, value: unknown): void
Set a config value by dot-notation key.
set(object: Record<string, unknown>): void
Set multiple values at once.
delete(key: string): void
Delete a config key.
reset(...keys: string[]): void
Reset specific keys to their defaults.
clear(): void
Clear all config and restore defaults.
close(): void
Close the underlying config engine.
Properties
store: Record<string, unknown>
Get the full config snapshot.
size: number
Number of top-level config entries.
path: string
Absolute path to the config database file.
Watchers
onDidChange<V>(key: string, callback: (newValue?: V, oldValue?: V) => void): () => void
Watch a specific key for changes. Returns an unsubscribe function.
onDidAnyChange(callback: (newValue?: Record<string, unknown>, oldValue?: Record<string, unknown>) => void): () => void
Watch the entire config for any change.
Config Tools
createConfigTools(configManager: ConfigManagerInterface): Tool[]
Create agent tools for config management.
-
config_get - Get a config value
key: string- Dot-notation key- Returns: The config value or “not set”
-
config_set - Set a config value
key: string- Dot-notation keyvalue: unknown- Value to set- Returns: Confirmation message
-
config_reset - Reset keys to defaults
keys: string[]- Keys to reset- Returns: Confirmation message
Config Schema
TinyClawConfigSchema
Zod schema for config validation.
CONFIG_DEFAULTS
Default config values.
Config Structure
TinyClawConfigData
Example Usage
Basic Configuration
Watching for Changes
Using with Agent Context
Security Notes
- Non-sensitive data only - API keys and tokens belong in
@tinyclaw/secrets - Config is stored in plain text SQLite
- Owner authority is enforced at the tool level (owner-only tools)
- Config paths are validated to prevent directory traversal
Related Packages
- @tinyclaw/types - Type definitions
- @tinyclaw/secrets - Encrypted secrets storage
- @tinyclaw/core - Core agent runtime