Commit Graph

130 Commits

Author SHA1 Message Date
iven
6f82723225 feat(runtime): implement streaming in AgentLoop
- Implement run_streaming() method with async channel
- Stream chunks from LLM driver and emit LoopEvent
- Save assistant message to memory on completion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:45:50 +08:00
iven
820e3a1ffe feat(runtime): add streaming support to LlmDriver trait
- Add StreamChunk and StreamEvent types for Tauri event emission
- Add stream() method to LlmDriver trait with async-stream
- Implement Anthropic streaming with SSE parsing
- Implement OpenAI streaming with SSE parsing
- Add placeholder stream() for Gemini and Local drivers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:44:40 +08:00
iven
4ba0a531aa docs: add v0.2.0 release implementation plan
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:34:17 +08:00
iven
fb263a8ae2 docs: add v0.2.0 release plan design document
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:16:52 +08:00
iven
5c8b1b53ce feat(intelligence): add reflection config persistence and proactive personality suggestions
Config Persistence:
- Save reflection config to localStorage
- Load config on startup with fallback defaults
- Auto-sync config changes to backend

Proactive Personality Suggestions (P2):
- Add check_personality_improvement to heartbeat engine
- Detects user correction patterns (啰嗦/简洁, etc.)
- Add check_learning_opportunities to heartbeat engine
- Identifies learning opportunities from conversations
- Both checks generate HeartbeatAlert when thresholds met

These enhancements complete the self-evolution capability chain.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:08:24 +08:00
iven
3286ffe77e fix(intelligence): sync reflection config to enable identity proposals
- Initialize reflection engine with allow_soul_modification: true
- Sync config changes to backend when loading data
- Ensures reflection can generate identity change proposals

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 01:03:33 +08:00
iven
bfad61c3da feat(intelligence): add self-evolution UI for identity change proposals
P1.1: Identity Change Proposal UI
- Create IdentityChangeProposal.tsx with diff view for SOUL.md changes
- Add approve/reject buttons with visual feedback
- Show evolution history timeline with restore capability

P1.2: Connect Reflection Engine to Identity Proposals
- Update ReflectionLog.tsx to convert reflection proposals to identity proposals
- Add ReflectionIdentityProposal type for non-persisted proposals
- Auto-create identity proposals when reflection detects personality changes

P1.3: Evolution History and Rollback
- Display identity snapshots with timestamps
- One-click restore to previous personality versions
- Visual diff between current and proposed content

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 00:51:03 +08:00
iven
6c64d704d7 docs: add self-evolution documentation and fix SOUL.md persistence
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- Create 01-identity-evolution.md: Identity system architecture (SOUL.md, USER.md, change proposals, version management)
- Create 04-heartbeat-engine.md: Proactive behavior system (heartbeat config, alerts, proactivity levels)
- Create 06-context-compaction.md: Context compression system (token management, summarization, information retention)
- Update ZCLAW_AGENT_INTELLIGENCE_EVOLUTION.md: Add Phase 5 self-evolution UX roadmap
- Fix AgentOnboardingWizard: Persist SOUL.md and USER.md after agent creation
- Fix llm-service: Add Tauri kernel mode detection for memory system LLM calls
- Fix kernel: Kernel config takes priority over agent's persisted model

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-24 00:38:31 +08:00
iven
a389082dd4 fix(llm-service): 在内核模式下使用 Tauri invoke 而非 HTTP 端点
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
问题:记忆系统尝试调用 /api/agents/default/message 导致 ECONNREFUSED
根因:GatewayLLMAdapter 在内核模式下仍使用外部 OpenFang HTTP 端点

修复:检测 Tauri 运行时,使用 agent_chat Tauri 命令代替 HTTP 请求

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 23:59:50 +08:00
iven
afb48f7b80 docs: add v0.2.0 release design spec
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 23:24:08 +08:00
iven
cbd3da46a3 chore: remove debug logging
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Remove temporary console.log and eprintln! statements added during
troubleshooting the model configuration issue.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 23:06:20 +08:00
iven
ae4bf815e3 fix(kernel): 使用 Kernel 配置的 model 而非 Agent 持久化的旧值
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
问题:在"模型与 API"页面切换模型后,对话仍使用旧模型
根因:Agent 配置从数据库恢复,其 model 字段优先于 Kernel 配置

修复:
- kernel.rs: send_message/send_message_stream 始终使用 Kernel 的当前 model
- openai.rs: 添加 User-Agent header 解决 Coding Plan API 405 错误
- kernel_commands.rs: 添加详细调试日志便于追踪配置传递
- troubleshooting.md: 记录此问题的排查过程和解决方案

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-23 22:56:06 +08:00
iven
86e79b4ad1 docs: mark Phase 5 as completed - all tests passing 2026-03-22 09:50:17 +08:00
iven
e8b9e813a6 chore: cleanup phase 5, remove external runtime dependencies 2026-03-22 09:43:01 +08:00
iven
58cd24f85b feat: add internal ZCLAW kernel crates to git tracking 2026-03-22 09:26:36 +08:00
iven
d72c0f7161 chore: update plan, fix UTF-8 issue, update tauri.conf 2026-03-22 09:23:45 +08:00
iven
2fb914c965 fix: UTF-8 boundary issue in compactor and remove openfang-runtime from bundle 2026-03-22 09:23:19 +08:00
iven
34f4654039 docs: update architecture to reflect internal Rust kernel 2026-03-22 09:08:25 +08:00
iven
c7bfad8261 docs: update Phase 5 progress - openfang-runtime removed 2026-03-22 09:05:44 +08:00
iven
f9fefc1557 chore: remove openfang-runtime and update start script 2026-03-22 09:04:39 +08:00
iven
3d614d743c docs: update Phase 4 status to completed 2026-03-22 08:58:01 +08:00
iven
0ab2f7afda feat(phase4): complete zclaw-skills, zclaw-hands, zclaw-channels, zclaw-protocols 模块实现 2026-03-22 08:57:37 +08:00
iven
7abfca9d5c feat(kernel): add internal ZCLAW kernel integration with Tauri
Phase 1-3 of independence architecture:
- zclaw-types: Add ToolDefinition, ToolResult, KernelConfig, ModelConfig
- zclaw-kernel: Fix AgentInfo provider field, export config module
- desktop: Add kernel_commands for internal kernel access
- Add AgentId FromStr implementation for parsing

New Tauri commands:
- kernel_init, kernel_status, kernel_shutdown
- agent_create, agent_list, agent_get, agent_delete
- agent_chat

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 08:37:20 +08:00
iven
185763868a feat: production readiness improvements
## Error Handling
- Add GlobalErrorBoundary with error classification and recovery
- Add custom error types (SecurityError, ConnectionError, TimeoutError)
- Fix ErrorAlert component syntax errors

## Offline Mode
- Add offlineStore for offline state management
- Implement message queue with localStorage persistence
- Add exponential backoff reconnection (1s→60s)
- Add OfflineIndicator component with status display
- Queue messages when offline, auto-retry on reconnect

## Security Hardening
- Add AES-256-GCM encryption for chat history storage
- Add secure API key storage with OS keychain integration
- Add security audit logging system
- Add XSS prevention and input validation utilities
- Add rate limiting and token generation helpers

## CI/CD (Gitea Actions)
- Add .gitea/workflows/ci.yml for continuous integration
- Add .gitea/workflows/release.yml for release automation
- Support Windows Tauri build and release

## UI Components
- Add LoadingSpinner, LoadingOverlay, LoadingDots components
- Add MessageSkeleton, ConversationListSkeleton skeletons
- Add EmptyMessages, EmptyConversations empty states
- Integrate loading states in ChatArea and ConversationList

## E2E Tests
- Fix WebSocket mock for streaming response tests
- Fix approval endpoint route matching
- Add store state exposure for testing
- All 19 core-features tests now passing

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-22 00:03:22 +08:00
iven
ce562e8bfc feat: complete Phase 1-3 architecture optimization
Phase 1 - Security:
- Add AES-GCM encryption for localStorage fallback
- Enforce WSS protocol for non-localhost WebSocket connections
- Add URL sanitization to prevent XSS in markdown links

Phase 2 - Domain Reorganization:
- Create Intelligence Domain with Valtio store and caching
- Add unified intelligence-client for Rust backend integration
- Migrate from legacy agent-memory, heartbeat, reflection modules

Phase 3 - Core Optimization:
- Add virtual scrolling for ChatArea with react-window
- Implement LRU cache with TTL for intelligence operations
- Add message virtualization utilities

Additional:
- Add OpenFang compatibility test suite
- Update E2E test fixtures
- Add audit logging infrastructure
- Update project documentation and plans

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 22:11:50 +08:00
iven
815c56326b docs(phase3): add integration verification report
- Track A: Chat virtual scrolling - PASS
- Track B: Hands Worker isolation - SKIPPED (architecture already secure)
- Track C: Intelligence cache - PASS (completed in Phase 2.5)

All TypeScript compilation passed, all domain implementations verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 21:27:59 +08:00
iven
a65b3d3958 feat(chat): add virtual scrolling for large message lists
- Integrate react-window v2 List component for messages > 100
- Add VirtualizedMessageList and VirtualizedMessageRow components
- Use useVirtualizedMessages hook for dynamic height measurement
- Preserve smooth animations for small message counts (< 100)
- Auto-scroll to bottom for both virtualized and non-virtualized modes

Performance improvements:
- Only render visible messages in viewport
- Dynamic height measurement for accurate positioning
- LRU cache for message content

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 20:43:07 +08:00
iven
35b06f2e4a docs(phase3): add core optimization implementation plan
- Track A: Chat virtual scrolling with react-window
- Track B: Hands Web Worker isolation for security
- Track C: Intelligence caching (already completed)

Plan includes:
- File structure and task breakdown
- Code examples for each component
- Verification checklist
- Integration requirements

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 20:03:13 +08:00
iven
32b9b41144 feat(domains): add Intelligence Domain with Valtio store and caching
- Create types.ts with frontend-friendly types
- Create cache.ts with LRU cache + TTL support
- Create store.ts wrapping intelligence-client with reactive state
- Create hooks.ts for React component integration
- Re-export backend types for compatibility

Intelligence Domain provides:
- Memory: store, search, delete with caching
- Heartbeat: init, start, stop, tick operations
- Compaction: threshold check and compact
- Reflection: conversation tracking and reflection
- Identity: load, build prompt, propose changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 20:01:47 +08:00
iven
e2fb79917b docs(phase2): add Phase 2 domain reorganization changelog
- Document completed tasks and file structure
- Record technical decisions and architecture changes
- Note verification results and next steps

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 19:53:07 +08:00
iven
5513d5d8e4 fix(domains): resolve TypeScript type errors in domain hooks
- Add type assertions for Valtio snapshot readonly arrays
- Remove unused fromPromise import from hands machine
- Ensures type compatibility with Valtio's useSnapshot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 19:52:14 +08:00
iven
7ffd5e1531 feat(domains): create domain-driven architecture for Phase 2
Chat Domain:
- Add types.ts with Message, Conversation, Agent types
- Add store.ts with Valtio-based state management
- Add hooks.ts with useChatState, useMessages, etc.
- Add index.ts for public API export

Hands Domain:
- Add types.ts with Hand, Trigger, Approval types
- Add machine.ts with XState state machine
- Add store.ts with Valtio-based state management
- Add hooks.ts with useHands, useApprovalQueue, etc.

Shared Module:
- Add types.ts with Result, AsyncResult, PaginatedResponse
- Add error-handling.ts with AppError, NetworkError, etc.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 19:47:48 +08:00
iven
20eed290f8 feat(deps): add Valtio and XState for Phase 2
- Add valtio for Proxy-based state management
- Add xstate and @xstate/react for state machines
- Create domains directory structure (chat, hands, intelligence, skills)
- Create shared directory for common utilities

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 19:43:12 +08:00
iven
4ac6da1c88 docs: add Phase 1 changelog
- Document security enhancements (encrypted storage, WSS enforcement)
- Document test infrastructure setup
- Document migration notes and breaking changes
- Document test results and coverage

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 19:33:44 +08:00
iven
32c9f93a7b feat(security): enforce WSS for non-localhost connections
- Add SecurityError class for clear error handling
- Add validateWebSocketSecurity function
- Block ws:// connections to non-localhost hosts
- Add unit tests for security validation logic

Security: Prevents man-in-the-middle attacks on remote connections
by requiring WSS protocol for all non-localhost WebSocket connections.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 17:27:56 +08:00
iven
d266a1435f feat(security): add AES-GCM encryption for localStorage fallback
- Encrypt credentials before storing in localStorage when OS keyring unavailable
- Decrypt on retrieval with automatic fallback
- Backward compatible with existing unencrypted data (migration on next set)
- Add comprehensive unit tests (11 test cases)

Security: Credentials are now encrypted using AES-GCM when
OS keyring is unavailable, preventing plaintext exposure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 17:13:50 +08:00
iven
a199434e08 test(crypto): add generateMasterKey test coverage
- Add test for base64 string output
- Add test for 32-byte key length
- Add test for uniqueness

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 17:07:08 +08:00
iven
f070d9151e feat(crypto): add AES-GCM encryption utilities
- Add arrayToBase64/base64ToArray conversion functions
- Add deriveKey for PBKDF2 key derivation
- Add encrypt/decrypt using AES-GCM
- Add generateMasterKey for random key generation
- Update setup.ts to use real Web Crypto API instead of mock
- Add comprehensive unit tests for all crypto functions

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 17:05:15 +08:00
iven
47a84f52a2 fix(test): add @vitest/coverage-v8 dependency for coverage reports
- Add @vitest/coverage-v8@2.1.8 matching vitest version
- Required for test:coverage script to work

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 17:00:09 +08:00
iven
2c80a2c3c2 test: add Vitest configuration and setup
- Add vitest.config.ts with jsdom environment and path aliases
- Add tests/setup.ts with mocks for Tauri API, crypto, and localStorage
- Add test:coverage script to package.json

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:55:44 +08:00
iven
9fc17e9d36 test(desktop): add Vitest and testing dependencies
Install testing framework dependencies for unit testing:
- vitest@2.1.8 - Test runner
- @testing-library/react@16.1.0 - React component testing
- @testing-library/jest-dom@6.6.3 - Jest DOM matchers
- jsdom@25.0.1 - DOM simulation environment

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:50:38 +08:00
iven
60ddb0b1e9 fix(plan): address review feedback for Phase 1 plan
- Fix mock path in setup.ts to use @ alias
- Add Web Crypto polyfill for Node.js test environment
- Use pnpm exec for vitest version check
- Update Task 4.1 to note existing isLocalhost function
- Add cross-platform notes for Windows users

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:42:38 +08:00
iven
5edb8e347f docs(plan): add Phase 1 implementation plan
Detailed plan for Security + Testing phase (2 weeks):
- Task 1.1-1.2: Test framework setup (Vitest)
- Task 2.1-2.2: Crypto utilities module
- Task 3.1: Secure storage encryption enhancement
- Task 4.1: WSS enforcement
- Task 5.1: ChatStore unit tests
- Task 6.1-6.4: Integration and verification

Each task has bite-sized steps with exact commands and expected output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:38:04 +08:00
iven
d1c200a243 docs(spec): revise architecture optimization spec based on review
Fixes from code review:
- Fix terminology: VZustand → Valtio
- Add terminology table for clarity
- Add existing code analysis section
- Add migration mapping table
- Remove incorrect Web Worker claims
- Update Hands section to focus on XState
- Update Intelligence cache to acknowledge existing impl
- Add detailed task breakdown with estimates
- Add performance measurement methods
- Update dependency versions to specific versions
- Add 2-week buffer to timeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:23:57 +08:00
iven
52c5e8a732 docs(spec): add architecture optimization design spec
Comprehensive design for 14-week architecture overhaul:
- VZustand for fine-grained reactivity
- Web Worker isolation for security
- XState for Hands state machine
- Domain-driven directory structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 16:16:24 +08:00
iven
e5cdd36118 docs: Add comprehensive project analysis and brainstorming session documents
- ZCLAW-DEEP-ANALYSIS-v2.md: Complete analysis covering 12 dimensions
- BRAINSTORMING-SESSION.md: Brainstorming notes on architecture, tech, performance
- OPTIMIZATION-ROADMAP.md: 4-phase implementation plan
- ISSUE-TRACKER.md: 18 issues tracked with priorities
- project-systematic-analysis-plan.md: Analysis plan document
2026-03-21 16:16:16 +08:00
iven
1900abe152 test(intelligence): update tests to use intelligenceClient
- Rewrite context-compactor.test.ts to use intelligenceClient
- Rewrite heartbeat-reflection.test.ts to use intelligenceClient
- Rewrite swarm-skills.test.ts to use intelligenceClient
- Update CLAUDE.md architecture section for unified intelligence layer

All tests now mock Tauri backend calls for unit testing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 15:26:35 +08:00
iven
f3ec3c8d4c feat(intelligence): complete migration to Rust backend
- Unify all intelligence modules to use intelligenceClient
- Delete legacy TS implementations (agent-memory, reflection-engine, heartbeat-engine, context-compactor, agent-identity, memory-index)
- Update all consumers to use snake_case backend types
- Remove deprecated llm-integration.test.ts

This eliminates code duplication between frontend and backend, resolves
localStorage limitations, and enables persistent intelligence features.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 15:17:39 +08:00
iven
17fb1e69aa feat(intelligence): add TypeScript frontend adapter for Rust commands
Provides unified API for calling Tauri intelligence commands:

- memory: store, search, get, delete, stats, export/import
- heartbeat: init, start, stop, tick, config management
- compactor: token estimation, threshold check, compact
- reflection: should_reflect, reflect, history, state
- identity: get/update files, proposals, snapshots

Usage:
```typescript
import { intelligence } from './intelligence-backend';
await intelligence.memory.store({ ... });
await intelligence.heartbeat.start('agent-1');
```

Part of Phase 4: Integration and documentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 00:54:31 +08:00
iven
d97c03fb28 docs(plan): update intelligence layer migration progress
Phase 2-3 complete:
- Heartbeat Engine: 
- Context Compactor: 
- Reflection Engine: 
- Agent Identity: 

Added implementation progress tracking section with:
- Completed modules table
- List of implemented Tauri commands
- Pending work items

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-21 00:53:31 +08:00