9 Commits

Author SHA1 Message Date
Rohit Kushwaha
6a6f91f2da feat(composio): v1 tool-provider integration (OSS-EE split layout)
Wires Composio — 200+ pre-built OAuth integrations (Gmail, Slack,
GitHub, Calendar, Drive, …) — into every supported chat backend.
Re-port of #1105 onto the post-split two-package layout.

Architecture (open-core safe):
- Feature module lives in pocketpaw-ee: ee/pocketpaw_ee/cloud/composio/.
- The OSS core never imports pocketpaw_ee — Composio is reached only
  through entry points:
    * claude_agent_sdk: an in-process MCP server via a new
      pocketpaw.mcp_servers provider (CloudComposioMcpProvider).
    * deep_agents / google_adk / openai_agents: native function tools
      via a new pocketpaw.composio_tools entry point, fetched per
      stream by tool_bridge.composio_tools_for().
- import-linter "OSS core may not import from EE" stays KEPT.

Behaviour:
- tool_bridge drops legacy gmail_*/calendar_*/drive_* tools when
  Composio is enabled, so the agent has one integration path per
  service.
- agent_service adds a runtime-identity rule + Composio auth/search
  prompt guidance, gated on composio_service.is_enabled().
- config.py gains composio_* settings; composio_api_key without
  composio_enterprise_id fails fast at Settings.load().

Deps: composio + 4 provider packages added to ee/pyproject.toml.

Supersedes #1105.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 07:15:13 +05:30
Rohit Kushwaha
869407bf69 refactor: provider adapter pattern + LiteLLM support (#595)
* feat: add LiteLLM provider support and unified env resolution

Add LiteLLM as a provider option for all backends (Claude SDK, OpenAI
Agents, Google ADK, Copilot SDK), enabling access to 100+ LLM providers
including HuggingFace, Ollama, vLLM, Together AI, Groq, Mistral, and
more through a single proxy or direct SDK integration.

Key changes:
- New config fields: litellm_api_base, litellm_api_key, litellm_model
- OpenAI Agents: native LitellmModel extension with proxy fallback
- Google ADK: LiteLlm model wrapper for cross-provider support
- Claude SDK: routes through LiteLLM proxy via ANTHROPIC_BASE_URL
- Copilot SDK: LiteLLM via OpenAI-compatible BYOK config
- resolve_backend_env() pushes unified POCKETPAW_* keys to env vars
  each SDK expects, fixing the issue where switching backends required
  manually reconfiguring environment variables

* fix: complete LiteLLM integration across dashboard, health checks, and WS

- Fix health check false warning: add 'litellm' to provider skip list
  in check_api_key_primary() for Claude SDK, OpenAI Agents, and
  Google ADK backends
- Add google_adk_provider to WS settings handler and broadcast
- Add litellm_api_base, litellm_api_key, litellm_model to WS handler
- Add 'LiteLLM (100+ Providers)' option to provider dropdowns in
  settings UI for Claude SDK and OpenAI Agents backends
- Add LiteLLM config fields (proxy URL, API key, model) shown when
  litellm provider is selected in the settings modal

* fix: add LiteLLM provider to Copilot SDK and Google ADK settings UI

- Add LiteLLM option to Copilot SDK provider dropdown
- Add provider dropdown to Google ADK settings (was missing entirely)
- Add LiteLLM config fields (proxy URL, API key, model) for Google ADK
  when litellm provider is selected

* fix: sync env vars at runtime when API keys change via dashboard

resolve_backend_env() now accepts force=True to overwrite existing env
vars. Called after every settings/API-key save so backends immediately
see updated keys without a restart. Codex CLI subprocess gets an
explicit env snapshot via env=os.environ.copy().

* refactor: provider adapter pattern for LLM providers

Extract provider-specific logic (config resolution, client creation,
env var setup, error formatting) into adapter classes under
llm/providers/. Six adapters: Anthropic, Ollama, OpenAICompatible,
OpenRouter, Gemini, LiteLLM.

LLMClient delegates to adapters internally while keeping its public
API stable. Backends (OpenAI Agents, Google ADK, Copilot SDK) now use
adapters directly, replacing 70+ line if/elif chains with ~5 line
adapter calls. Adding a new provider means adding one adapter file
and registering it, no backend changes needed.

30 new tests for adapters, registry, model resolution, and LLMClient
delegation.

* fix: _stderr_lines UnboundLocalError and test_fast_path failures

Move _stderr_lines initialization before the try block so the except
handler can always access it. Add missing _HookMatcher and is_litellm
to test mocks.

* style: format test files and fix UP038 lint

* docs: add Discord deployment config with multi-provider support

Add Docker Compose, Dockerfile, env example, and identity files for
headless Discord bot deployment. Supports direct Anthropic, LiteLLM
proxy, OpenAI-compatible, and OpenAI Agents backends out of the box.

* chore: remove Discord deploy files (moved to separate PR #597)

Deploy config now lives under deploy/discord/ in the
deploy/discord-docker branch to keep this PR focused on
the provider adapter pattern and LiteLLM integration.

* fix: LiteLLM max_tokens setting, config persistence, and health recheck

- Add litellm_max_tokens config option so users can cap output tokens
  for models like DeepSeek (8192 limit)
- Fix LiteLLM settings not persisting on reload: litellmApiBase,
  litellmModel, litellmMaxTokens were missing from SETTINGS_MAP in
  app.js, so the frontend never loaded them back from the server
- Also add 13 other missing backend settings to SETTINGS_MAP
  (openaiAgentsModel, googleAdkProvider, codexCliModel, etc.)
- Re-run health checks after settings save so switching to LiteLLM
  immediately clears the "no Anthropic API key" degraded warning
- Claude SDK fast-path respects provider max_tokens instead of
  hardcoding 1024

* fix: LiteLLM proxy routing, adapter bugs, and remove plan docs

- Fix LiteLLM + OpenAI Agents: use OpenAI-compat proxy path when
  base_url is set instead of native LitellmModel which tried to route
  directly (causing Vertex AI credential errors)
- Fix operator precedence in _to_provider_config() base_url resolution
- Fix dashboard unable to clear LiteLLM API key (falsy vs None check)
- Fix fragile hasattr duck-typing in openai_agents, add explicit
  provider == "litellm" guard
- Replace unnecessary getattr() with direct attribute access in
  google_adk now that the field exists in Settings
- Pass api_key and base_url to ADK LiteLlm wrapper explicitly
- Remove plan design doc

* docs: add OpenRouter and LiteLLM provider documentation

- Add dedicated OpenRouter and LiteLLM sections to LLM providers guide
  with configuration examples for proxy vs direct SDK mode
- Update backend compatibility matrix to include both new providers
- Update per-backend provider tables (Claude SDK, OpenAI Agents,
  Google ADK, Copilot SDK) with LiteLLM and OpenRouter support
- Add OpenRouter and LiteLLM config fields to configuration reference
- Update getting-started configuration with OpenRouter and LiteLLM
  environment variable examples
- Replace OpenRouter-only section in backends index with combined
  OpenRouter + LiteLLM section
2026-03-14 03:46:02 +05:30
Vaibhavee Singh
232a5f2d84 docs: add type column to configuration reference tables (#305)
* docs: add type column to configuration reference tables

Add Type column to all configuration tables showing data types:
- string - API keys, tokens, URLs, model names
- integer - ports, IDs, numeric limits
- boolean - true/false flags
- string[] - comma-separated lists (allowed IDs, tools)
- integer[] - numeric ID lists (Discord guilds/users)
- enum - fields with specific allowed values (with options listed)

This improves developer experience by making it clear:
- Whether dashboard_port is a string or integer
- Whether tools_allow is a JSON array or comma-separated string
- Whether mem0_auto_learn is boolean or string "true"/"false"
- What values are valid for enum fields like llm_provider

Fixes #148

* Fix incorrect default values in configuration reference

Cross-checked defaults against config.py and corrected:
- tool_profile: coding → full
- whatsapp_mode: business → "" (unset until configured)
- mem0_llm_provider: ollama → anthropic
- mem0_llm_model: llama3.2 → claude-haiku-4-5-20251001
- mem0_embedder_provider: ollama → openai
- mem0_embedder_model: nomic-embed-text → text-embedding-3-small
2026-02-24 20:55:33 +05:30
Rohit Kushwaha
94f393da2a Merge branch 'dev' into fix/smart-routing-claude-sdk-settings 2026-02-17 21:59:32 +05:30
Rohit Kushwaha
c26ad7ef04 docs(mcp): document OAuth support, CIMD, and transport changes
Update MCP documentation to reflect the OAuth support, registry
removal, and transport improvements from 38c0aac:

- Add OAuth authentication section with full flow explanation
- Add CIMD guide explaining why GitHub MCP needs it (no dynamic
  client registration) and how to set it up
- Document new transport types: streamable-http, sse, and http
  auto-detect (tries Streamable HTTP then falls back to SSE)
- Add oauth field to preset and server config API docs
- Add mcp_client_metadata_url to configuration reference
- Add mcp_oauth_redirect WebSocket message type
- Create new /api/mcp/oauth/callback endpoint doc
- Update REST API table with actual implemented endpoints
- Replace "Popular MCP Servers" table with preset catalog section
- Add error handling section (ExceptionGroup unwrapping, OAuth hints)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:51:55 +05:30
Rohit Kushwaha
441fa36087 docs: update docs for Claude SDK settings and smart routing changes
- backends/claude-sdk: add Claude SDK Settings section with model
  override, max turns, and callouts about auto-select vs smart routing
- advanced/model-router: note disabled by default, add configuration
  env vars, update callout text
- api/configuration-reference: add claude_sdk_model, claude_sdk_max_turns,
  smart_routing_enabled, and model tier settings to the table
- getting-started/configuration: add Claude SDK env vars and config.json
  fields with info callout
- README: update smart router description, add SDK fields to config example
- CLAUDE.md: mention SDK-specific settings in backend description

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 17:14:08 +05:30
Rohit Kushwaha
b6e24334bb fix: rename POCKETCLAW_ env prefix and paths to POCKETPAW_
Complete the user-facing rename from pocketclaw to pocketpaw across
env vars, Docker paths (~/.pocketclaw → ~/.pocketpaw), and all
documentation references.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 23:44:46 +05:30
Rohit Kushwaha
b665a1a9cd feat: add centralized LLMClient abstraction and Ollama support across all backends
Consolidate duplicated provider detection, AsyncAnthropic client creation,
env var construction, and error formatting into a single LLMClient dataclass
with a resolve_llm_client() factory. Refactor 10 consumer files to use it.

- New llm/client.py: LLMClient frozen dataclass + resolve_llm_client()
- Claude SDK backend: Ollama env vars via llm.to_sdk_env(), --check-ollama CLI
- PocketPaw Native: replace _llm_provider tracking with LLMClient
- Security modules: force_provider="anthropic" for Guardian + InjectionScanner
- Dashboard: Ollama settings UI, provider selection
- Docs: Ollama backend documentation
- Tests: 19 new LLMClient tests, updated Ollama + concurrency tests

Closes #53

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-14 00:52:21 +05:30
Rohit Kushwaha
4bb7313829 feat: move docs into monorepo, add deploy workflow
Consolidate documentation from the separate pocketpaw-web repo into the
main pocketpaw repo. This keeps docs and code in sync so PRs can update
both atomically.

- Remove docs/ from .gitignore
- Remove docs' own .git (was pocketpaw/pocketpaw-web)
- Add .github/workflows/deploy-docs.yml (builds from docs/ subdirectory)
- Track all 120+ MDX pages, config, landing page, and public assets

The separate pocketpaw-web repo can now be archived.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 13:12:04 +05:30