Commit Graph

244 Commits

Author SHA1 Message Date
xuhao
a579cdfbec
fix(tools): address code review findings for feishu_doc
- Reorder convert-before-delete in action_write, action_update_block,
  and write_single_cell to prevent data loss if markdown conversion fails
- Separate create POST from verification retry loop in action_create
  to prevent duplicate document creation on retry
- Add resolve_doc_token to upload_image and upload_file so wiki
  node_token resolution works for upload actions
- Add SSRF protection to download_media: validate URL scheme (http/https
  only), block local/private hosts via existing url_validation module
- Guard empty credentials in mod.rs: skip FeishuDocTool registration
  when app_id or app_secret are empty/whitespace-only

(cherry picked from commit feb1d46f41)
2026-02-27 15:58:43 +00: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
reidliu41
df6f7455e7 feat(tools): add docx_read tool for DOCX text extraction
Summary

  - Problem: Agent cannot read DOCX files — file_read returns garbled binary/XML, making Word documents inaccessible to the
  agent
  - Why it matters: DOCX is the most common business document format; without native extraction, users must manually convert
  files, breaking autonomous workflows
  - What changed: Added docx_read tool using zip (existing) + quick-xml (new) to extract plain text from DOCX Office Open XML
  - What did not change: No changes to file_read, agent loop, security policy, config schema, or any existing tool behavior

  Label Snapshot (required)

  - Risk label: risk: low
  - Size label: size: S
  - Scope labels: tool
  - Module labels: tool: docx_read
  - If any auto-label is incorrect: N/A

  Change Metadata

  - Change type: feature
  - Primary scope: tool

  Linked Issue

  - Closes #(issue number)

  Validation Evidence (required)

  cargo fmt --all -- --check   # pass
  cargo clippy --all-targets -- -D warnings   # pass (zero new warnings)
  cargo test docx_read   # 14/14 passed

  - Evidence provided: test results, manual verification with zeroclaw agent -m against real DOCX file

  Security Impact (required)

  - New permissions/capabilities? No (mirrors existing pdf_read security model exactly)
  - New external network calls? No
  - Secrets/tokens handling changed? No
  - File system access scope changed? No

  Privacy and Data Hygiene (required)

  - Data-hygiene status: pass
  - Redaction/anonymization notes: Test fixtures use neutral content ("Hello DOCX", "First", "Second")
  - Neutral wording confirmation: Yes

  Compatibility / Migration

  - Backward compatible? Yes
  - Config/env changes? No
  - Migration needed? No

  i18n Follow-Through

  - i18n follow-through triggered? No (no docs or user-facing wording changes)

  Human Verification (required)

  - Verified scenarios: zeroclaw agent -m "read the file test-test.docx and output the content" — model selected docx_read,
  extracted text correctly
  - Edge cases checked: invalid ZIP, missing word/document.xml, symlink escape, path traversal, rate limiting, truncation
  - What was not verified: encrypted DOCX (out of scope), extremely large files (>50MB)

  Side Effects / Blast Radius (required)

  - Affected subsystems/workflows: Tool registry only — one new tool added
  - Potential unintended effects: None — additive only, no existing behavior changed
  - Guardrails/monitoring: Tool follows identical security chain as pdf_read

  Rollback Plan (required)

  - Fast rollback command/path: git revert <commit>
  - Feature flags or config toggles: None needed (always-on, like pdf_read)
  - Observable failure symptoms: docx_read tool missing from tool list

  Risks and Mitigations

  - Risk: quick-xml new dependency adds to compile time
    - Mitigation: quick-xml is lightweight pure Rust (~15K LOC), widely used (100M+ downloads), and will be shared when
  XLSX/PPTX tools are added later
2026-02-27 10:39:53 -05:00
argenis de la rosa
7307aab103 feat(tools): add Tavily provider and API-key round-robin 2026-02-27 06:37:57 -05:00
argenis de la rosa
bde9d45ead feat(cron): add lark and feishu delivery targets 2026-02-26 22:52:46 -05:00
Argenis
7f3b7302b1 fix(config): resolve env credential reporting and safer compaction default
- report api_key_configured via provider credential resolution (env + overrides)\n- set agent.compact_context default to true for new configs\n- align docs and tests with the new default\n\nRefs: #1983\nRefs: #1984\nContext: #1358\n\nCo-authored-by: Argenis <144828210+theonlyhennygod@users.noreply.github.com>
2026-02-27 03:15:55 +00:00
Argenis
4fa8206332
Merge pull request #2013 from zeroclaw-labs/issue-1380-mcp-main
feat(mcp): add external MCP server support on main
2026-02-26 22:14:33 -05:00
argenis de la rosa
6186b34903 refactor(mcp): use schema paths to avoid config re-export conflicts 2026-02-26 22:13:27 -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
d63a6a8ceb feat(security): unify URL validation with configurable CIDR/domain allowlist 2026-02-26 22:07:07 -05:00
argenis de la rosa
4f8c9d2066 feat(mcp): add external MCP server support on main 2026-02-26 21:43:54 -05:00
argenis de la rosa
ffaf927690 fix(web): improve web access guidance and search failure diagnostics 2026-02-26 21:42:13 -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
b355956400 fix(model-routing): detect env-backed provider credentials
Compute api_key_configured through provider credential resolution so env-variable credentials are reported correctly for scenarios and delegate agents.

Closes #1983
2026-02-26 21:07:07 -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
argenis de la rosa
7b20697d93 fix(security): harden env passthrough validation coverage 2026-02-26 20:34:46 +08:00
argenis de la rosa
eeaa010f1a fix(security): allow configured shell env expansions 2026-02-26 20:34:46 +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
Chummy
dfc8c239ef fix(apply-patch): avoid format_push_string on logs
(cherry picked from commit 873ebce6b3)
2026-02-26 12:59:23 +08:00
Chummy
13d53f388e style(tools): rustfmt apply_patch implementation
(cherry picked from commit 17a3a4a3b0)
2026-02-26 12:59:23 +08:00
hopesojourner
fbb3c6aee0 feat(tools): add apply_patch tool and update tests
(cherry picked from commit 8594ad98ae)
2026-02-26 12:59:23 +08:00
Chummy
d3af83db63
fix: align merged code with dev to restore build 2026-02-26 03:47:01 +00:00
Chummy
e0f6f24a5e
merge: promote dev into main (dev-first conflict resolution) 2026-02-26 03:41:59 +00:00
Chummy
d8a1d1d14c fix: reconcile non-cli approval governance with current dev APIs 2026-02-26 02:19:14 +08:00
Chummy
1fcf2df28b feat: harden non-CLI approval governance and runtime policy sync 2026-02-26 02:19:14 +08:00
Chummy
5ac885de7b fix(subagent): avoid lossy signed-to-unsigned cast 2026-02-26 02:14:20 +08:00
dave
c90853ba99 fix: address CodeRabbit review — race condition, UTF-8 safety, cast
Fixes all 4 issues from CodeRabbit review:

1. Race condition in spawn: replaced separate running_count() check +
   insert() with atomic try_insert(session, max) that holds the write
   lock for both the count check and insertion.

2. UTF-8 byte slice panic in subagent_manage: output truncation now
   uses char_indices().nth(500) to find a safe byte boundary.

3. UTF-8 byte slice panic in truncate_task: now uses chars().count()
   for length check and char_indices().nth() for safe slicing.
   Added truncate_task_multibyte_safe test with emoji input.

4. cast_unsigned() replaced with 'as u64' — standard Rust cast for
   duration milliseconds.

Test count: 57 (56 + 1 new multibyte safety test).
2026-02-26 02:14:20 +08:00
dave
90289ccc91 docs: add module-level and item-level docstrings for subagent tools
Improve docstring coverage to meet the 80% threshold required
by CI. Adds //! module docs and /// item docs to all public
types and functions in the subagent tool modules.
2026-02-26 02:14:20 +08:00
dave
067eb8a188 feat(tools): add sub-agent orchestration (spawn, list, manage)
Add background sub-agent orchestration tools that extend the existing
delegate tool with async execution, session tracking, and lifecycle
management.

New tools:
- subagent_spawn: Spawn delegate agents in background via tokio::spawn,
  returns session_id immediately. Respects security policy, depth limits,
  rate limits, and configurable concurrent session cap.
- subagent_list: List running/completed/failed/killed sessions with
  status filtering. Read-only, allowed in all autonomy modes.
- subagent_manage: Kill running sessions via CancellationToken or
  query status with partial output. Enforces Act policy for kill.

Shared state:
- SubAgentRegistry: Thread-safe session store using
  Arc<parking_lot::RwLock<HashMap>> with lazy cleanup of sessions
  older than 1 hour. Tracks session metadata, status, timing, and
  results.

Test coverage: 56 tests across all 4 modules covering happy paths,
error handling, security enforcement, concurrency, parameter
validation, and edge cases.

No new dependencies added. No existing tests broken.
2026-02-26 02:14:20 +08:00
Chummy
11b9fe759f style(ci): apply rustfmt for lint-gate compatibility 2026-02-25 23:43:42 +08:00
Chummy
de6f572051 fix(ci): align onboard + web search tests with current APIs 2026-02-25 23:43:42 +08:00
Ricardo Magaña
da62bd172f feat(tools): add user_agent config and setup_web_tools wizard step
Ports remaining changes from feat/unify-web-fetch-providers that were
not yet integrated into dev:

- config/schema.rs: add `user_agent` field (default "ZeroClaw/1.0") to
  HttpRequestConfig, WebFetchConfig, and WebSearchConfig, with a shared
  default_user_agent() helper. Field is serde-default so existing configs
  remain backward compatible.

- tools/http_request.rs: accept user_agent in constructor; pass it to
  reqwest::Client via .user_agent() replacing the implicit default.

- tools/web_fetch.rs: accept user_agent in constructor; replace hardcoded
  "ZeroClaw/0.1 (web_fetch)" in build_http_client with the configured value.

- tools/web_search_tool.rs: accept user_agent in constructor; replace
  hardcoded Chrome UA string in search_duckduckgo and add .user_agent()
  to the Brave and Firecrawl client builders.

- tools/mod.rs: wire user_agent from each config struct into the
  corresponding tool constructor (HttpRequestTool, WebFetchTool,
  WebSearchTool).

- onboard/wizard.rs: add setup_web_tools() as wizard Step 6 "Web &
  Internet Tools" (total steps bumped from 9 to 10). Configures
  WebSearchConfig, WebFetchConfig, and HttpRequestConfig interactively
  with provider selection and optional API key/URL prompts. Step 5
  setup_tool_mode() http_request and web_search outputs are now discarded
  (_, _) since step 6 owns that configuration. Uses dev's generic
  api_key/api_url schema fields unchanged.

Co-authored-by: Cursor <cursoragent@cursor.com>
(cherry picked from commit fb83da8db021903cf5844852bdb67b9b259941d7)
2026-02-25 23:43:42 +08:00
Chummy
584af05020 fix(coordination): satisfy strict-delta clippy gates 2026-02-25 23:16:27 +08:00
Chummy
c692ff98c1 fix(coordination): harden delegate key parser and overflow correlation consistency 2026-02-25 23:16:27 +08:00
Chummy
82bc66bc9b fix(coordination): enforce delegate context correlation invariants
- normalize correlation matching in inbox filtered peek path\n- reject delegate context patches with invalid key shape\n- require correlation_id for delegate context patches\n- reject delegate context patches when key correlation != envelope correlation\n- expose delegate context count fields in status output for clearer semantics\n- add regression coverage for new validation and normalized correlation behavior
2026-02-25 23:16:27 +08:00
Chummy
856afe8780 feat(coordination): deep-complete agent coordination message bus
- add typed coordination protocol envelopes/payload validation and deterministic in-memory bus\n- integrate delegate runtime lifecycle tracing with shared coordination bus\n- add delegate_coordination_status read-only observability tool\n- add config/onboarding wiring and coordination enable/limits controls\n- harden retention/memory bounds with inbox/dead-letter/context/dedupe caps\n- add runtime metrics and pagination/offset metadata for status inspection\n- add correlation-scoped fast-path indexes for context/dead-letter/inbox queries\n- expand unit/integration tests for ordering, idempotency, conflict handling, paging, and filters
2026-02-25 23:16:27 +08:00
Chummy
163f2fb524 feat(wasm): harden module integrity and symlink policy 2026-02-25 22:49:57 +08:00
Chummy
604f64f3e7 feat(runtime): add configurable wasm security runtime and tooling 2026-02-25 21:46:05 +08:00
Chummy
efdd40787c feat(config): add deprecated runtime reasoning_level compatibility alias 2026-02-25 21:00:59 +08:00
Chummy
cfe1e578bf feat(security): add and harden syscall anomaly detection 2026-02-25 20:43:38 +08:00
Chummy
346f58a6a1 hardening: strengthen tool policy enforcement and sandbox defaults 2026-02-25 18:33:28 +08:00
Chummy
701f293785 test(runtime): fix postgres and browser test compatibility after rebase 2026-02-25 17:51:04 +08:00
argenis de la rosa
aac87ca437 feat(provider): add reasoning level override
(cherry picked from commit 8d46469c40)
2026-02-25 17:51:00 +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
Chummy
cd4d816a83 fix(providers): keep runtime options backward compatible 2026-02-25 10:56:31 +08:00
reidliu41
3a38c80c05 feat(config): add model_support_vision override for per-model vision control
`supports_vision` is currently hardcoded per-provider. The same Ollama instance can run `llava` (vision) or
  `codellama` (no vision), but the code fixes vision support at the provider level with no user override.

  This adds a top-level `model_support_vision: Option<bool>` config key — tri-state:
  - **Unset (default):** provider's built-in value, zero behavior change
  - **`true`:** force vision on (e.g. Ollama + llava)
  - **`false`:** force vision off

  Follows the exact same pattern as `reasoning_enabled`. Override is applied at the wrapper layer (`ReliableProvider` /
   `RouterProvider`) — no concrete provider code is touched.

  ## Changes

  **Config surface:**
  - Top-level `model_support_vision` field in `Config` struct with `#[serde(default)]`
  - Env override: `ZEROCLAW_MODEL_SUPPORT_VISION` / `MODEL_SUPPORT_VISION`

  **Provider wrappers (core logic):**
  - `ReliableProvider`: `vision_override` field + `with_vision_override()` builder + `supports_vision()` override
  - `RouterProvider`: same pattern

  **Wiring (1-line each):**
  - `ProviderRuntimeOptions` struct + factory functions
  - 5 construction sites: `loop_.rs`, `channels/mod.rs`, `gateway/mod.rs`, `tools/mod.rs`, `onboard/wizard.rs`

  **Docs (i18n parity):**
  - `config-reference.md` — Core Keys table
  - `providers-reference.md` — new "Ollama Vision Override" section
  - Vietnamese sync: `docs/i18n/vi/` + `docs/vi/` (4 files)

  ## Non-goals

  - Does not change any concrete provider implementation
  - Does not auto-detect model vision capability

  ## Test plan

  - [x] `cargo fmt --all -- --check`
  - [x] `cargo clippy --all-targets -- -D warnings` (no new errors)
  - [x] 5 new tests passing:
    - `model_support_vision_deserializes` — TOML parse + default None
    - `env_override_model_support_vision` — env var override + invalid value ignored
    - `vision_override_forces_true` — ReliableProvider override
    - `vision_override_forces_false` — ReliableProvider override
    - `vision_override_none_defers_to_provider` — passthrough behavior

  ## Risk and Rollback

  - **Risk:** Low. `None` default = zero behavior change for existing users.
  - **Rollback:** Revert commit. Field is `#[serde(default)]` so old configs without it will deserialize fine.

(cherry picked from commit a1b8dee785)
2026-02-25 10:56:31 +08:00
Chummy
83ef0a3cf6 fix(tools): address codeql api key handling alerts 2026-02-25 03:30:45 +08:00
Chummy
ffe340f849 fix(tools): satisfy strict delta lint for firecrawl dispatch 2026-02-25 03:30:45 +08:00
Chummy
b4df1dc30d feat(tools): add web_fetch provider dispatch and shared URL validation 2026-02-25 03:30:45 +08:00
Mike-7777777
0e14c199af refactor(tools): deduplicate IpcDb initialization and simplify inbox
Extract shared init logic (pragmas, schema creation, agent registration)
into IpcDb::init(), eliminating ~45 lines of duplication between open()
and open_with_id(). Extract SQL strings into PRAGMA_SQL and SCHEMA_SQL
constants for single source of truth. Remove unused (i64, Value) tuple
in AgentsInboxTool by collecting directly into Vec<Value>.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 01:14:47 +08:00