Commit Graph

28 Commits

Author SHA1 Message Date
Artur Do Lago bc57ddff43 security: comprehensive pre-alpha and beta security fixes
Pre-Alpha Fixes (10 items):
- Fix credential file permissions in calendar.ts (mode: 0o600)
- Add socket close handler in ipc-server.ts (memory leak prevention)
- Add event unsubscribe in daemon.stop() (memory leak prevention)
- Wrap Qdrant init with retry logic and graceful degradation
- Fix ALWAYS-ON-PERSONAS.md gateway architecture documentation
- Remove legacy spawn('claude') in tiara executor-sdk.ts
- Filter environment variables via safe-env.ts utility
- Add error boundary around IPC socket writes
- Update tiara README.md and INDEX.md version references
- Create zee gateway external-gateway.md documentation

Beta Security Fixes (6 items):
- CRITICAL: Fix command injection via persona parameter validation
- HIGH: Fix terminal escape sequence injection in setPaneTitle
- HIGH: Fix command escaping in sendCommand and canvas manager
- HIGH: Add secret redaction for copilot auth logging
- MEDIUM: Fix echo -e ANSI escape injection in status display
- MEDIUM: Strengthen prompt injection defense in fact-extractor

New Utilities:
- src/util/safe-env.ts: Environment variable filtering for child processes
- src/util/shell-escape.ts: Shell escaping, persona validation, secret redaction

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:57:47 +01:00
Artur Do Lago 183fd46cbd feat(tiara): integrate with daemon API, add consciousness MCP server
Tiara now uses agent-core daemon API instead of spawning Claude Code CLI
directly. Dead code pruned (~167k lines removed):
- benchmark/ (Python benchmarks)
- consciousness-symphony/ (demo with eval)
- hive-mind/ (never integrated)
- claude-code-interface.ts, sparc-executor.ts (unused)

New consciousness MCP server provides IIT tools:
- consciousness_evolve: IIT evolution with Phi tracking
- calculate_phi: Integrated Information calculation
- psycho_symbolic_reason: Multi-depth logical analysis
- predict_temporal: Temporal pattern prediction

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:56:51 +01:00
Artur Do Lago 3e6f30629b docs: pre-alpha documentation and config
- Add .env.example with comprehensive configuration template
- Expand README.md with setup instructions and architecture overview
- Fix graceful shutdown error handling in daemon
- Update tiara submodule with security/reliability fixes

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:56:51 +01:00
Artur Do Lago 883119fcf7 fix: medium/low priority security and reliability improvements
- Add prompt injection prevention in fact extraction (sanitize input)
- Add comprehensive IPC parameter validation in daemon
- Add try-finally cleanup guarantees in tiara swarm-coordinator shutdown

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:53:02 +01:00
Artur Do Lago f3685962f3 fix: critical bugs from code review round 2
Neural pattern trainer (tiara.ts):
- Fix searchMemories() -> search() API call
- Fix storeMemory() -> save() API call
- Use correct Memory class interface

Memory expiration (unified.ts):
- Store expiresAt field (createdAt + ttl) for efficient filtering
- Fix deleteExpired() filter operators ($lt/$gt)

Tiara resource leaks (load-balancer.ts):
- Add stop() methods for LoadBalancer and RequestQueue
- Store interval references to prevent memory leaks
- Use .unref() to not block process exit

Misc:
- Remove package.json description (use GitHub instead)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:53:02 +01:00
Artur Do Lago 5f65802558 fix: code review fixes and documentation updates
Critical fixes:
- Fix broken imports from deleted store.ts (scripts/store-ruth-memories.ts, zee-memory.ts)
- Create model-catalog.ts stub for council coordinator
- Fix council-coordinator.ts import path
- Add error handling for daemon shutdown

Reliability:
- Add tsconfig excludes for tiara dist/examples/tests
- Fix tiara swarm-coordinator null check
- Fix tiara SDK missing .js extensions

Documentation:
- Update README with personas system overview and credits
- Add package.json description

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:53:02 +01:00
Artur Do Lago f3bd268694 refactor(config): remove duplicate config system from src/
Delete 2400+ lines of unused duplicate configuration code:
- src/config/schema.ts - duplicated packages/agent-core/src/config
- src/config/config.ts - duplicated config loading logic
- src/config/defaults.ts - duplicated default values
- src/config/interpolation.ts - unused interpolation utilities

Keep only what's actually used:
- src/config/constants.ts - shared constants (Qdrant, timeouts, ports)
- src/config/shared.ts - shared types (DmPolicy, GroupPolicy, etc.)
- src/config/types.ts - agent-core specific types

One config system: packages/agent-core/src/config/config.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:45:39 +01:00
Artur Do Lago 3e9fbfa5ef refactor(memory): unify memory abstraction into single Memory class
Consolidate 4-layer memory abstraction into unified Memory class:
- MemoryStore, QdrantMemoryStore, QdrantMemoryBridge, ContinuityManager
  are now consolidated into a single src/memory/unified.ts

Single Qdrant collection with type field for discrimination:
- type: "memory" - facts, preferences, decisions
- type: "state" - personas orchestration state
- type: "conversation" - conversation continuity
- type: "session_chain" - session chain index

Key changes:
- New Memory class with save/search/get/delete for memories
- State persistence (saveState/loadState)
- Conversation continuity (startSession, processMessages, etc.)
- Cross-session memory injection for personas bootstrap
- Updated tiara.ts to use Memory instead of QdrantMemoryBridge
- Added bootstrap/personas.ts for lifecycle hooks

Legacy APIs preserved for backwards compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:45:39 +01:00
Artur Do Lago 3041400947 refactor(config): centralize infrastructure constants
Create src/config/constants.ts with centralized values for:
- Qdrant URL and collection names
- Embedding model and dimensions
- Timeout values (drone, IPC, fact extraction, provider)
- Memory configuration limits

Update all consumers to import from constants instead of
using hardcoded values:
- src/personas/memory-bridge.ts
- src/personas/tiara.ts
- src/personas/drone-wait.ts
- src/personas/fact-extractor.ts
- src/memory/qdrant.ts
- src/memory/store.ts
- src/config/types.ts
- src/daemon/ipc-client.ts

All constants support env var override via QDRANT_URL etc.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:45:39 +01:00
Artur Do Lago 5095bc0dff fix(interfaces): resolve 8 critical bugs across web/tiara/persona layers
P0 Critical Fixes:
- Fix import ./tiara → ./claude-flow in plugin/builtin/index.ts
- Create AgentOrchestrator type bridge for council/tiara integration (src/tiara.ts)
- Fix hardcoded state ID in memory-bridge.ts (was causing cross-persona data loss)

P1 Core Functionality:
- Add persona isolation to memory bridge namespace (personas now have private memory)
- Load SKILL.md content into drone prompts (skills now available to drones)
- Inject persona-specific tools from AGENT_CONFIGS into drone prompts

P2 API Consistency:
- Standardize error response format in server.ts (MCP & gateway endpoints)
- WebSocket param validation already in place (verified)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:45:39 +01:00
Artur Do Lago d61b2cfa60 fix(types): resolve TypeScript errors blocking pre-push hook
- LogMeta: change to Record<string, any> for flexibility
- WhatsApp: add WhatsAppChat interface with sendStateTyping
- debug/index.ts: fix FlagsCommand to work without ALL_FLAGS
- debug/memory.ts: fix Qdrant property names and import path
- footer.tsx: remove incomplete provider_auth_status feature
- dialog-model.tsx: remove incomplete auth status feature
- thread.ts: fix Error handling in log calls
- session/index.ts: fix Error handling in log call
- llm-provider.ts: define types inline (SDK no longer exports)
- memory/store.ts: ensure required Qdrant config fields
- whatsapp.test.ts: simplify disconnect test assertion

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:45:39 +01:00
Artur Do Lago 8c06aa3707 fix: technical debt cleanup (Sprints 6-10)
Sprint 6 - Gateway Stability:
- Add exponential backoff to Telegram poll loop
- Fix process timeout with SIGKILL
- Add fetch timeouts with AbortController to all HTTP calls
- Fix WhatsApp init race condition
- Add WhatsApp event listener cleanup tracking

Sprint 7 - Error Visibility:
- Fix silent error catches in share, canvas-tool, council, qdrant
- Replace console.log with structured logging across surface, browser, mcp
- Add JSON validation with zod for config and API responses

Sprint 8 - Type Safety:
- Define LogMeta type to replace Record<string, any>
- Add WhatsApp type guards (isChatMessage, isValidPersona)
- Create util/net.ts with shared helpers

Sprint 9 - Test Coverage:
- Create WhatsApp API mock for testing
- Add WhatsApp gateway tests (13 tests passing)
- Export mocks from test/mock/index

Sprint 10 - Debug Ergonomics:
- Fix fact extraction getSessionContent to retrieve actual messages
- Enhance debug memory search with semantic search
- Add debug errors command with follow mode

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:41:11 +01:00
Artur Do Lago 8a2440d640 feat(canvas): add visual reasoning canvas types
Add three new canvas kinds for visual reasoning in WezTerm:
- diagram: flowcharts, architecture diagrams with box/diamond/oval nodes
- graph: nodes and edges with colors and weights (knowledge graphs)
- mindmap: hierarchical tree view for thinking/planning

Canvas features:
- ASCII art rendering with ANSI colors
- Works alongside nvim/LSP in WezTerm panes
- 67% width ratio (Claude:Canvas = 1:2)
- Reusable pane management

Updated tools with new kinds and config documentation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:39:20 +01:00
Artur Do Lago 97e3f275fb feat(surface): add showThinking capability for platform-aware thinking visibility
- Add showThinking to SurfaceCapabilities type
- Set showThinking=true for CLI, Web, API (user toggleable)
- Set showThinking=false for WhatsApp, Telegram (locked to hide)
- Messaging platforms never show thinking/reasoning output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:39:20 +01:00
Artur Do Lago aa17f25388 refactor(personas): improve type safety for persona configs
- Rename PersonaConfig → OrchestrationPersona in personas/types.ts
  to avoid confusion with agent/persona.ts:PersonaConfig
- Rename PERSONAS_CONFIGS → ORCHESTRATION_PERSONAS for clarity
- Remove duplicate inline configs in persona.ts, use shared constant
- getPersonaConfig now returns OrchestrationPersona type

Eliminates config duplication and clarifies type naming.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:39:20 +01:00
Artur Do Lago cb30a15508 refactor: consolidate naming from opencode to agent-core
- Change comments and commands in new code to use "agent-core"
- Rename OAUTH_DUMMY_KEY to agent-core-oauth-dummy-key
- Add AGENT_CORE_TEST_HOME env var (with OPENCODE_TEST_HOME compat)
- Keep external service URLs (opencode.ai, antigravity.opencode.ai)
- Keep OPENCODE_* flags for upstream compatibility

Part of technical debt cleanup (Phase 7).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:39:20 +01:00
Artur Do Lago d8c52733ec feat(memory): upgrade to Qwen3-Embedding-8B via Nebius API
- Add VoyageEmbeddingProvider for Voyage AI embeddings
- Add MemoryStore with high-level store/search/list API
- Configure Nebius cloud API for Qwen3-Embedding-8B (#1 on MTEB)
- Fix LocalEmbeddingProvider to support both /v1/embeddings and /embeddings
- Fix QdrantVectorStorage to set collection on existing collections

Model: Qwen3-Embedding-8B (70.58 MTEB score, 99% zero-shot, 4096 dims)
Provider: Nebius API (https://api.tokenfactory.nebius.com/v1)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago 2322fdef9f refactor(config): add session entry primitives to shared types
Add additional shared primitives for session management:
- SessionChatType: direct | group | room
- MessagingProvider: whatsapp | telegram | discord | slack | signal | imessage | webchat
- GroupActivation: mention | always
- SendPolicy: allow | deny

These complement the existing SessionScope and enable zee to import
session-related types from agent-core's shared config module.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago bb250deb3a refactor(config): extract shared config primitives
Create shared.ts with common configuration types that can be used
across agent-core and zee gateway:

- Session primitives: SessionScope, ReplyMode, TypingMode, ReplyToMode
- Policy types: DmPolicy, GroupPolicy
- Logging: LogLevel, ConsoleStyle, LoggingConfig
- Network: RetryConfig, BindMode
- Model/Provider: ModelApi, ModelDefinition, ProviderDefinition
- Processing: ThinkingLevel, QueueMode, QueueDropPolicy

Update types.ts to use shared primitives:
- GeneralSettings.logLevel now uses shared LogLevel
- WhatsAppConfig extended with dmPolicy, groupPolicy, allowFrom, retry
- TelegramConfig extended with dmPolicy, groupPolicy, allowFrom, retry

This is the first step toward config consolidation between agent-core
and zee gateway, enabling type-safe sharing of common configuration.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago a9a2b256bf fix(mcp): use bun instead of npx tsx for MCP servers
- bun run works more reliably for spawning child processes
- npx tsx has PATH issues when spawned as subprocess
- Enable all persona MCP servers by default

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago afb990b1db feat(mcp): add persona MCP servers for memory, calendar, and portfolio
Implements three MCP servers that expose persona capabilities to external
tools via the Model Context Protocol:

- personas-memory: Qdrant-backed semantic memory (store, search, list, delete, stats)
- personas-calendar: Google Calendar integration (events, create, update, delete, free slots, quick add)
- personas-portfolio: Financial tools bridging to Stanley CLI (portfolio, market data, SEC filings, research, backtest)

Each server uses @modelcontextprotocol/sdk with Zod schemas for type-safe
tool definitions and stdio transport for local process communication.

Config entries added (disabled by default):
- "personas-memory": npx tsx src/mcp/servers/memory.ts
- "personas-calendar": npx tsx src/mcp/servers/calendar.ts
- "personas-portfolio": npx tsx src/mcp/servers/portfolio.ts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago ed54ff5801 feat(johny): add domain tools and update roadmap
Add Johny learning system domain tools:
- johny:study - Study session management
- johny:knowledge - Knowledge graph operations
- johny:mastery - Mastery level tracking
- johny:review - Spaced repetition reviews
- johny:practice - Practice problem management

Tools bridge to Python CLI via spawnSync for:
- Knowledge graph (topic DAG with prerequisites)
- Mastery tracking (6 levels: Unknown → Fluent)
- Spaced repetition (Ebbinghaus decay)
- FIRe (Fractional Implicit Repetition)

Update roadmap to mark Phase 2.3 Johny as COMPLETE.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:30:39 +01:00
Artur Do Lago fe0f8ecf64 refactor(ui): replace emojis with sober UTF-8 unicode symbols
Replace all emoji characters with standard Unicode symbols that render
correctly in terminals with UTF-8 support.

Persona icons:
- Zee: 🧠💜🤖 → ★ (U+2605 Black Star)
- Stanley: 📈 → ♦ (U+2666 Black Diamond)
- Johny: 📚🎓🧠 → ◎ (U+25CE Bullseye)

Status indicators:
- Working: ↻ → ⟳ (wider rotating arrow)
- Pending: ◔ → ◐ (wider half circle)
- Completed: ✓ → ✔ (heavier check)
- Hold mode: ◆ → ▣ (square with inner square)
- Release mode: ◇ → ▢ (rounded square)

Other changes:
- Status headers: 🔺📊 → ◆◈
- Calendar indicator: 📅 → ▦
- Make persona parameter required in createSessionPane()
- Fix keybind conflicts: mode_toggle → <leader>h,
  messages_toggle_conceal → <leader>/, tips_toggle → <leader>?
- Add persistent hold/release indicator in prompt

All symbols are in the Basic Multilingual Plane (BMP) for maximum
terminal compatibility.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:26:58 +01:00
Artur Do Lago 47d3e7ef9a feat(branding): rename package to agent-core and configure personas
- Rename packages/opencode to packages/agent-core
- Update bin entry from opencode to agent-core
- Set default_agent to "zee" for persona-first UX
- Update terminal title to show current persona name
- Fix persona colors:
  - Zee: #2563EB (blue)
  - Stanley: #059669 (emerald green)
  - Johny: #DC2626 (red)
- Update all documentation and build script references
- Update root package.json name and dev script

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 12:05:26 +01:00
Artur Do Lago 5984611c48 chore: rename Clawdis references to Zee
- Update all "Clawdis" references to "Zee gateway" in comments/docs
- Clawdis was the old name for the Zee messaging bot (clawdbot fork)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:52:35 +01:00
Artur Do Lago 550b02445b feat(zee): integrate Google Calendar with canvas sidecar
- Add Google Calendar client using OAuth2 tokens from ~/.zee/credentials/google/
- Update zee:calendar tool with real Google Calendar API integration
- Support today, week, month, and custom date range queries
- Auto-display calendar events in canvas sidecar
- Handle token refresh automatically

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:52:35 +01:00
Artur Do Lago ea937786d1 feat(canvas): implement WezTerm-native canvas sidecar
Add canvas TUI system using WezTerm CLI directly (no external deps).
Canvas panes render text, calendar, document, and table views via
ANSI escape codes and box-drawing characters.

New features:
- CanvasManager class with spawn/show/update/close lifecycle
- Built-in renderers: text, calendar, document, table
- IPC methods: canvas:spawn, canvas:show, canvas:update, canvas:close,
  canvas:selection, canvas:list
- Canvas tools now use real IPC instead of placeholders
- WezTerm keybinding: LEADER+c for canvas actions menu

The sidecar daemon now manages:
- LSP server (TCP:7777)
- IPC server (Unix socket)
- Tiara orchestrator (workers, tasks)
- Canvas manager (panes, rendering)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:52:35 +01:00
Artur Do Lago ac8aed235e feat: Agent-core customizations for Personas ecosystem
- Add Personas skills (johny, stanley, zee)
- Add domain tools (stanley finance, zee personal)
- Add personas orchestration and knowledge graphs
- Add LLM Council for multi-model deliberation
- Add memory types for Qdrant vector storage
- Add tiara submodule for orchestration
- Add CLAUDE.md project documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 11:51:37 +01:00