@tinyclaw/heartware
Tiny Claw’s self-configuration workspace. Heartware is a secure, sandboxed file system where the agent can read and write its own configuration files (identity, preferences, memory, soul traits).Installation
Core Concepts
Heartware is a restricted workspace with:- Allowed files - Specific markdown files the agent can read/write
- Immutable files - Read-only system files (SOUL.md, GUIDE.md)
- Audit logging - All write operations are logged with SHA-256 hashes
- Automatic backups - Every write creates a timestamped backup
- Rate limiting - Prevents runaway write operations
- Content validation - File size limits and content checks
Main Exports
HeartwareManager
new HeartwareManager(config: HeartwareConfig)
Create a new heartware manager.
Base directory for heartware files
User ID for audit logging
Audit log directory (default:
baseDir/audit)Backup directory (default:
baseDir/.backups)Rate limiting configuration
Methods
initialize(): Promise<void>
Initialize the heartware workspace (create directories, load templates).
read(filename: string): Promise<string>
Read a heartware file.
write(filename: string, content: string): Promise<void>
Write to a heartware file (with validation, backup, and audit logging).
list(): Promise<string[]>
List all heartware files.
search(query: string): Promise<SearchResult[]>
Search across all heartware files.
close(): Promise<void>
Close the manager and cleanup resources.
Loaders
loadHeartwareContext(manager: HeartwareManager): Promise<string>
Load all heartware files and format them for agent system prompt injection.
loadMemoryByDate(manager: HeartwareManager, date: string): Promise<string>
Load a specific memory file by date.
loadMemoryRange(manager: HeartwareManager, startDate: string, endDate: string): Promise<string>
Load memory files in a date range.
loadShieldContent(baseDir: string): Promise<string | null>
Load the SHIELD.md threat feed.
Tools
createHeartwareTools(manager: HeartwareManager): Tool[]
Create agent tools for heartware operations.
- heartware_read - Read a heartware file
- heartware_write - Write to a heartware file (owner-only)
- heartware_list - List all heartware files
- heartware_search - Search across heartware files
- identity_update - Update IDENTITY.md (owner-only)
- soul_update - Update SOUL.md (immutable after bootstrap)
- preferences_set - Update PREFERENCES.md
- memory_add - Add to today’s memory file
- memory_daily_log - Log to today’s memory file
- memory_recall - Search memory files
- bootstrap_complete - Mark bootstrap as complete
Security Features
Sandbox
IDENTITY.md- Agent name and taglineSOUL.md- Personality traits (immutable after bootstrap)FRIEND.md- Owner profileFRIENDS.md- Friend profilesPREFERENCES.md- Agent preferencesGUIDE.md- System guide (immutable)SHIELD.md- Security threat feed (immutable)MEMORY-YYYY-MM-DD.md- Daily memory logs
Audit Logging
Backups
Rate Limiting
Soul Generator
Generate unique personality traits using seed-based generation.SoulTraits
Templates
Pre-built templates for heartware files.Creator Meta
Fetch creator metadata from GitHub.Error Handling
INVALID_PATH- Path validation failedFILE_NOT_ALLOWED- File is not in the allowed listFILE_IMMUTABLE- File is read-onlyCONTENT_TOO_LARGE- File exceeds size limitRATE_LIMIT_EXCEEDED- Too many operationsCONTENT_VALIDATION_FAILED- Content validation failed
Example Usage
Basic Setup
Memory Management
Related Packages
- @tinyclaw/core - Core agent runtime
- @tinyclaw/types - Type definitions
- @tinyclaw/shield - Security enforcement