Commit Graph

115 Commits

Author SHA1 Message Date
Preventnetworkhacking
84b43ba4b2 feat(memory): add reindex command to rebuild embeddings [CDV-28]
Adds `zeroclaw memory reindex` CLI command to rebuild embeddings for all
stored memories. Use this after changing the embedding model/provider to
ensure vector search works correctly with the new embeddings.

Changes:
- Add `Reindex` variant to `MemoryCommands` enum (lib.rs, main.rs)
- Add `reindex` method to `Memory` trait with default not-supported impl
- Implement `reindex` in SqliteMemory:
  - Clears embedding_cache table
  - Iterates all memories and recomputes embeddings
  - Updates embedding column in memories table
- Add CLI handler with confirmation prompt and progress output

Usage:
  zeroclaw memory reindex        # Interactive confirmation
  zeroclaw memory reindex --yes  # Skip confirmation
  zeroclaw memory reindex --progress=false  # Hide progress

Fixes #2273
2026-02-28 20:56:03 -05:00
xj
9095a54de3 fix(main): restore rust gates after bluebubbles merge 2026-02-28 17:00:18 -08:00
argenis de la rosa
10b12ba2cb fix(build): restore rust 1.87 compatibility for plugin foundation 2026-02-28 19:51:37 -05:00
Chummy
d9d9bedf3e feat(migration): ship merge-first openclaw onboarding + agent tool 2026-02-28 19:01:50 -05:00
ZeroClaw Bot
630a52b397 fix(auth): harden OAuth UX per CodeRabbit review
- Replace brittle split("state=") with parse_query_params utility
- Use const PROFILE_MISMATCH_PREFIX with starts_with instead of fragile contains

Made-with: Cursor
2026-02-28 18:33:17 -05:00
ZeroClaw Bot
fd1a9b7a07 fix(auth): address CodeRabbit review feedback on OAuth UX
Made-with: Cursor
2026-02-28 18:33:17 -05:00
ZeroClaw Bot
2d5c0142d2 feat(auth): improve OAuth UX for server environments
Add stale pending login detection (auto-cleanup after 24h), improved
device-code flow error messages with Cloudflare/403 detection, shared
OAuth helpers, and Box::pin fixes for large async futures.

Made-with: Cursor
2026-02-28 18:33:17 -05:00
argenis de la rosa
728782d369 fix(agent): close run() wrapper calls in replayed hook wiring 2026-02-28 18:19:48 -05:00
argenis de la rosa
408616b34e feat(agent): expose hooks parameter in public run() entry point
Add `hooks: Option<&crate::hooks::HookRunner>` as the last parameter
to the public `agent::run()` (re-exported from `loop_::run`).

This enables library consumers to inject custom HookHandler
implementations (before_tool_call, on_after_tool_call) without
patching the crate. The hooks are threaded through to
`run_tool_call_loop` which already accepts and dispatches them.

All existing call sites pass `None`, preserving backward compatibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 18:19:48 -05:00
argenis de la rosa
f7de9cda3a Merge remote-tracking branch 'origin/main' into pr2093-mainmerge 2026-02-28 17:33:17 -05:00
argenis de la rosa
9784e3bfc1 feat(channel): add github native channel MVP 2026-02-28 14:03:10 -05:00
argenis de la rosa
aa319e71b0 test(cli): add coverage for config show/get/set 2026-02-28 14:00:35 -05:00
argenis de la rosa
20ed60d2a0 feat(config): add show/get/set subcommands for runtime config inspection and modification 2026-02-28 14:00:35 -05:00
ZeroClaw Bot
5ac9c3e955 fix(quota): address CodeRabbit review feedback
- Fix low-quota warning format string readability (parenthesized percentage)
- Add QuotaFormat enum for CLI --format validation (fail-fast on invalid input)
- Fix backoff eviction strategy comments (soonest-to-expire, not LRU)
- Custom Default for ProviderUsageMetrics (last_reset_at = Utc::now())
- Fix fail_count==0 always-fail case in stress test
- Add providers-quota to commands-reference.md
- Document fresh ProviderHealthTracker intent in quota_tools.rs

Made-with: Cursor
2026-02-28 11:45:02 -05:00
ZeroClaw Bot
247d89e39e feat(providers): implement quota monitoring system with CLI and agent tools
Add comprehensive quota monitoring: QuotaMetadata types, quota-aware
agent loop with proactive warnings, CLI providers-quota command, and
3 built-in tools (check_provider_quota, switch_provider,
estimate_quota_cost).

Depends on: circuit breaker + provider health (#1842)

Made-with: Cursor
2026-02-28 11:45:02 -05:00
VirtualHotBar
0a357064d9 session/history: allowlist persistable roles (user, assistant) via ROLE_* constants; unify filtering in channel + agent; memory/session: reduce read contention with RwLock+AtomicI64 and refresh updated_at on get_history; providers: export role constants and helper; security: switch HMAC verifications to ring::hmac for Linq/Nextcloud/WhatsApp; channels tests: auto-approve mock_price to avoid non-CLI approval dead-wait; misc: ignore target_ci/.idea; main: use local rag module. 2026-02-28 18:40:48 +08:00
VirtualHotBar
0a42329ca5 fix: session leftovers after db47f56
- Demote session normal flow logs to debug\n- Skip session operations when CHANNEL_SESSION_CONFIG is uninitialized\n- Add spawn_blocking panic context for SQLite session manager\n- Fix fmt/clippy regressions (Box::pin large futures, cfg features, misc lints)
2026-02-28 15:23:42 +08:00
xuhao
dcd712d825
feat(tools): add Feishu document operation tool with 13 actions
Add FeishuDocTool implementing the Tool trait with full Feishu/Lark
document API coverage: read, write, append, create, list_blocks,
get_block, update_block, delete_block, create_table, write_table_cells,
create_table_with_values, upload_image, and upload_file.

Key design decisions:
- Self-contained tenant_access_token auth with auto-refresh cache
- Feishu/Lark dual-domain support via use_feishu config flag
- Wiki node_token resolution for wiki-hosted documents
- Autonomy-level enforcement: read ops always allowed, write ops
  require Act permission
- Prompt-level behavioral rules in tool description for agent guidance
- Create verification with retry to prevent phantom document tokens

Gated behind existing channel-lark feature flag. Reads app_id and
app_secret from channels_config.feishu or channels_config.lark.

14/14 integration tests pass against live Feishu API.

(cherry picked from commit 6a228944ae)
2026-02-27 15:58:43 +00:00
argenis de la rosa
a258741e2f feat(security): enable otp by default in quick setup 2026-02-26 22:23:23 -05:00
argenis de la rosa
8180e7dc82 feat(skills): add WASM skill engine with secure registry install 2026-02-26 22:09:24 -05:00
argenis de la rosa
b27b44829a chore: promote dev snapshot to main (resolve #1978/#1970) 2026-02-26 21:09:33 -05:00
argenis de la rosa
36d5d2f3f8 feat(skills): seed bundled zeroclaw skill on startup 2026-02-26 21:04:13 -05:00
Chummy
c54a30f68c supersede: file-replay changes from #1897
Automated conflict recovery via changed-file replay on latest main.
2026-02-26 16:37:17 +00:00
Chummy
b081077b9a ci(sec-audit): scope heavy checks to rust-surface changes 2026-02-26 20:14:36 +08:00
Chummy
64d317ac2a fix(ci): restore crate unsafe guard in main crate 2026-02-26 20:14:36 +08:00
Chum Yin
9b0e70b2f2
supersede: file-replay changes from #1895 (#1926)
Automated conflict recovery via changed-file replay on latest main.
2026-02-26 04:15:47 -05:00
argenis de la rosa
390373dbcb feat(cli): add self-update command
Implements self-update functionality that downloads the latest release
from GitHub and replaces the current binary.

Features:
- `zeroclaw update` - downloads and installs latest version
- `zeroclaw update --check` - checks for updates without installing
- `zeroclaw update --force` - forces update even if already latest
- Cross-platform support (Linux, macOS, Windows)
- Atomic binary replacement on Unix, rename+copy on Windows
- Platform-specific archive handling (.tar.gz on Unix, .zip on Windows)

Closes #1352

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
(cherry picked from commit c4ba69b6bf)
2026-02-26 12:59:23 +08:00
Allen Huang
6064890415 feat: goals engine, heartbeat delivery, daemon improvements, and cron consolidation
- goals: add autonomous goal loop engine for long-term goal execution
- goals: add goal-level reflection for stalled goals
- goals: make GoalStatus and StepStatus deserialization self-healing
- goals: remove initiative planning from Rust, use cron job instead
- daemon: add PID lock and goal-loop supervisor
- daemon: add per-task failure tracking and auto-disable for heartbeat
- daemon: deliver heartbeat results to configured channels
- cron: add nightly consolidation cron job
- cron: set delete_after_run for one-shot shell jobs
- cron: add session_source to agent prompt building
- service: forward provider env vars into generated service files
- agent: add reflection flywheel — cron context injection, tool audit, nightly consolidation
- agent: make state reconciliation opt-in per call site

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-26 01:50:24 +08:00
Chummy
938d900106 fix(build): include coordination module in binary crate 2026-02-25 23:16:27 +08:00
FlashFamily
931cf40636 fix: resolve all clippy warnings across codebase
Fix all clippy errors reported by `cargo clippy --all-targets -- -D warnings`
on Rust 1.93, covering both the original codebase and upstream dev changes.

Changes by category:
- format!() appended to String → write!/writeln! (telegram, discord)
- Redundant field names, unnecessary boolean not (agent/loop_)
- Long numeric literals (wati, nextcloud, telegram, gemini)
- Wildcard match on single variant (security/leak_detector)
- Derivable Default impls (config/schema)
- &Option<T> → Option<&T> or allow (config/schema, config/mod, gateway/api)
- Identical match arms merged (gateway/ws, observability, providers, main, onboard)
- Cast truncation allowed with rationale (discord, lark)
- Unnecessary borrows/returns removed (multiple files)
- Unused imports removed (channels/mod, peripherals/mod, tests)
- MSRV-gated APIs allowed locally (memory/hygiene, tools/shell, tools/screenshot)
- Unnecessary .get().is_none() → !contains_key() (gemini)
- Explicit iteration → reference loop (gateway/api)
- Test-only: useless vec!, field_reassign_with_default, doc indentation

Validated: cargo fmt, cargo clippy --all-targets -- -D warnings, cargo test
Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit 49e90cf3e4)
2026-02-25 17:50:56 +08:00
Allen Huang
b36dd3aa81 feat(logging): use local timezone for log timestamps
Replace default UTC timer with ChronoLocal::rfc_3339() so daemon and
CLI log lines display the operator's local time, making correlation
with external events easier.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-24 23:02:13 +08:00
Chummy
99bf8f29be fix(unsafe-debt): remove runtime unsafe UID check and forbid unsafe code (RMN-37 RMN-38) 2026-02-24 18:30:36 +08:00
reidliu41
8f263cd336 feat(agent): add CLI parameters for runtime config overrides 2026-02-24 18:12:33 +08:00
Chummy
59d4f7d36d feat: stabilize codex oauth and add provider model connectivity workflow 2026-02-24 12:24:51 +08:00
reidliu41
04e8eb2d8e feat(models): add list, set, and status subcommands 2026-02-23 08:09:28 +08:00
Chummy
a36b1466ff feat(security): add otp and estop phase-1 foundation 2026-02-21 23:19:36 +08:00
InuDial
9f844173b8 Use channels(&self) and channels_except_webhook(&self)
to reduce repeat
2026-02-21 19:38:19 +08:00
chumyin0912@gmail.com
77262d1ed4 style: apply rustfmt in auth refresh handler 2026-02-21 19:06:45 +08:00
Aleksandr Prilipko
38029c1e78 fix(auth): add Gemini OAuth refresh CLI support and fix ManagedOAuth bearer token
Fixes two related issues with Gemini OAuth:

1. CLI command `zeroclaw auth refresh --provider gemini` was hardcoded to
   only support OpenAI Codex, making manual token refresh impossible for
   Gemini profiles. Extended the CLI handler to support both providers.

2. GeminiProvider.build_generate_content_request() was missing bearer token
   for ManagedOAuth auth type. The method applied OAuth bearer token only
   for CLI OAuth (GeminiAuth::OAuthToken), but not for managed profiles
   (GeminiAuth::ManagedOAuth), causing 401 Unauthorized errors even after
   successful token refresh.

Changes:
- src/main.rs: AuthCommands::Refresh now handles both openai-codex and
  gemini providers via pattern match
- src/providers/gemini.rs: Extended OAuth bearer token handling to include
  GeminiAuth::ManagedOAuth case (line 837)

Verification:
- Manual test: zeroclaw auth refresh --provider gemini --profile second
- E2E test: echo "hello" | zeroclaw agent --provider gemini --model gemini-2.5-pro
- Unit tests: cargo test providers::gemini (38 passed)

Risk: Low (isolated auth flow changes, no API contract changes)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-21 18:53:11 +08:00
Aleksandr Prilipko
d56c061896 refactor(auth): add Gemini OAuth and consolidate OAuth utilities (DRY)
- Add src/auth/gemini_oauth.rs: Full Gemini/Google OAuth2 implementation
  - PKCE authorization code flow with loopback redirect
  - Device code flow for headless environments
  - Token refresh with automatic expiration handling
  - Stdin fallback for remote/headless OAuth callback capture

- Add src/auth/oauth_common.rs: Shared OAuth utilities
  - PkceState struct and generate_pkce_state()
  - url_encode/url_decode (RFC 3986)
  - parse_query_params for URL parameter parsing
  - random_base64url for cryptographic random generation

- Update src/auth/mod.rs: Add Gemini support to AuthService
  - store_gemini_tokens() for saving OAuth tokens
  - get_valid_gemini_access_token() with automatic refresh
  - get_gemini_profile() for provider initialization

- Update src/main.rs: Generic PendingOAuthLogin
  - Consolidate PendingOpenAiLogin and PendingGeminiLogin into generic struct
  - Reduce 10 functions to 4 generic functions
  - Support both openai-codex and gemini providers in auth commands

- Update src/providers/gemini.rs: ManagedOAuth authentication
  - GeminiAuth enum with ApiKey and ManagedOAuth variants
  - new_with_auth() constructor for OAuth-based authentication
  - Automatic token refresh via AuthService integration

- Update src/providers/mod.rs: Wire GeminiProvider with AuthService

Net reduction: ~290 lines of duplicated code

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-02-21 18:53:11 +08:00
Chummy
628654ebe5 fix: improve allowed_roots guidance for filesystem access 2026-02-21 17:33:11 +08:00
BenedictKing
816cf74552 fix(cli): use Cargo.toml version instead of hardcoded string
Replace hardcoded `version = "0.1.0"` in clap command attribute with
`version` (no value), which makes clap read from CARGO_PKG_VERSION
automatically. This ensures `zeroclaw -V` always reflects the version
defined in Cargo.toml.
2026-02-21 17:26:38 +08:00
Chummy
61f98a8fd3 feat(observability): add runtime trace diagnostics and trace doctor query 2026-02-21 17:00:38 +08:00
chumyin0912@gmail.com
179e7949c2 fix(gateway): align dashboard API client and embed built web assets 2026-02-21 16:14:01 +08:00
chumyin0912@gmail.com
81b05deb64 fix(test): include hooks field after rebase 2026-02-21 15:12:27 +08:00
Allen Huang
7d81715b60 fix(agent): skip interactive approval in daemon/cron context
Daemon heartbeat and cron tasks called agent::run() which hardcoded
channel_name as "cli" and always created an ApprovalManager, causing
[Y]es / [N]o / [A]lways stdin prompts on the unattended daemon terminal.

Add interactive parameter to agent::run(): CLI passes true (preserving
approval flow), daemon/cron pass false (no ApprovalManager, channel
marked as "daemon").

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-02-21 14:52:44 +08:00
xj
0638266b63 feat(hooks): integrate HookRunner into agent loop, channels, and gateway
Thread Option<&HookRunner> into run_tool_call_loop with hook fire points
for LLM input, before/after tool calls. Add hooks field to
ChannelRuntimeContext for message received/sending interception.
Build HookRunner from config in run_gateway and fire gateway_start.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-21 13:34:09 +08:00
Jayson Reis
aff9ef91cf fix(onboard): make model refresh and doctor model checks async-safe 2026-02-21 13:03:10 +08:00
xiaotianxt
bf08f1a1bb fix(cli): restore shared command enum wiring 2026-02-21 11:57:29 +08:00
xiaotianxt
b1694b63a9 refactor(cli): reuse shared command enums from lib 2026-02-21 11:57:29 +08:00