Page:
Source Layout
Clone
2
Source Layout
Shinwoo PARK edited this page 2026-05-15 13:27:29 +09:00
Source Layout
BoxBrain's implementation is intentionally compact because the project is a framework core, not a full chatbot product.
Root files
| Path | Purpose |
|---|---|
README.md |
High-level project overview and quick API examples |
package.json |
Package metadata, Bun scripts, runtime dependencies |
tsconfig.json |
TypeScript configuration |
bun.lock |
Bun lockfile |
.gitea/workflows/ci.yml |
Gitea CI workflow |
Source files
| Path | Purpose |
|---|---|
src/index.ts |
Root barrel export for public APIs |
src/types.ts |
Public TypeScript contracts: memory, schedules, models, messages, debug events |
src/memory.ts |
InMemoryMemoryStore, IdentityDbMemoryStore, SQLite helper |
src/schedule.ts |
Datetime helpers, deterministic schedule generation, availability derivation |
src/conversation.ts |
Message-history formatting, prompts/instructions, mandatory context assembly |
src/persona.ts |
Main Persona class and orchestration pipeline |
Tests
| Path | Covered behavior |
|---|---|
tests/persona.test.ts |
persona creation/loading, initialization facts, debug events |
tests/schedule.test.ts |
daily schedule generation, availability, pruning |
tests/conversation.test.ts |
mandatory context, missing memory marker, stale rewrite, proactive opener |
tests/sleep-memory.test.ts |
objectivized memory extraction and persistence |
tests/memory.test.ts |
fact listing for in-memory and SQLite IdentityDB stores |
Public export shape
src/index.ts exports everything from:
export * from './types';
export * from './memory';
export * from './schedule';
export * from './conversation';
export * from './persona';
This means consumers can import framework types and helper functions from boxbrain directly.
Implementation notes
Persona initialization
src/persona.ts provides constructor overloads:
new Persona(displayName, seedMessage, options)
new Persona(spaceId, options)
Create mode stores a new memory space. Load mode retrieves an existing space. ready() awaits the initialization promise.
Memory storage
src/memory.ts has two concrete stores:
InMemoryMemoryStorefor tests/demosIdentityDbMemoryStorefor persistent IdentityDB-backed spaces
Schedule entries in the IdentityDB store are saved as facts with metadata.scheduleEntry.
Schedule and availability
src/schedule.ts provides a deterministic default routine:
- 144 ten-minute blocks for a daily schedule
- 30 day-level entries for monthly schedules
- keyword-based activity choice for work/study/job-search/travel
- availability ranges derived from schedule activity metadata
Conversation context
src/conversation.ts centralizes mandatory context:
- formatted message history
- yesterday/today/tomorrow schedule lookup
- persona/user fact lookup
기억이 없음marker when no mandatory memory is found- schedule-derived availability snapshot
Persona orchestration
src/persona.ts ties the pieces together:
- schedule creation and pruning
- availability refresh/cache
- reply generation
- proactive conversation start
- stale-draft rewrite checks
- sleep-memory persistence
- debug event emission
Verification commands
From the repository root:
bun install
bun run test
bun run check
bun run build