Commit Graph

221 Commits

Author SHA1 Message Date
yuchou87 dea381c385 improve(agent): clarify MCP tool registration logging
Separate tool counting metrics for better clarity:
- unique_tools: number of distinct MCP tools
- total_registrations: total tool registrations across all agents
- agent_count: number of agents receiving the tools

Previously, tool_count was misleading as it showed total registrations,
making it appear that more unique tools were registered than actually exist.

Addresses Copilot code review feedback.
2026-02-19 19:31:13 +08:00
yuchou87 ffa01986ce fix(agent): scope MCP manager cleanup to successful initialization
Move defer cleanup inside else block to only clean up when MCP servers
are successfully initialized. This prevents unnecessary cleanup attempts
when LoadFromMCPConfig fails.

Addresses Copilot code review feedback.
2026-02-19 19:26:02 +08:00
yuchou87 a5d2e109bf chore: merge main branch into mcp-tools-support
Resolved conflicts in:
- config/config.example.json: Added empty MCP config block
- pkg/config/config.go: Added MCP config structures to new ToolsConfig
- pkg/agent/loop.go: Integrated MCP tools with new AgentRegistry architecture

MCP tools now register to all agents in the registry during startup.
2026-02-19 19:06:37 +08:00
yuchou87 47533a00cd style: format code with gofmt 2026-02-19 18:53:24 +08:00
Ruslan Semagin 32c5c4b3a4 refactor: replace bool map with set-style map for internal channels (#472)
* refactor: replace bool map with set-style map for internal channels

Use map[string]struct{} and comma-ok idiom for clearer and more idiomatic membership checks.

* Update pkg/constants/channels.go

Co-authored-by: Harsh Bansal <122075346+harshbansal7@users.noreply.github.com>

---------

Co-authored-by: Harsh Bansal <122075346+harshbansal7@users.noreply.github.com>
2026-02-19 11:48:17 +01:00
hsohinna 56a060ff61 feat(onebot): enhance OneBot channel (#192)
* fix: change BotStatus type to json.RawMessage and add isAPIResponse function

* feat(onebot): add rich media, API callback, keepalive and voice transcription

   Comprehensive improvements to the OneBot channel for better NapCatQQ
   compatibility:

   - Add echo-based API callback mechanism (sendAPIRequest) for
     request/response correlation via pending map
   - Add WebSocket ping/pong keepalive (30s ping, 60s read deadline)
   - Fetch bot self ID via get_login_info on connect/reconnect
   - Refactor parseMessageContentEx into parseMessageSegments supporting
     image, record, video, file, reply, face, forward segments
   - Add voice transcription via Groq transcriber (SetTranscriber)
   - Switch to message segment array format for sending with auto reply
     quote via lastMessageID tracking
   - Add message_sent event handling and detailed notice event processing
     (recall, poke, group increase/decrease, friend add, etc.)
   - Use sync/atomic for echoCounter, optimize listen() lock pattern
   - Clean up pending callbacks on Stop(), defer temp file cleanup
   - Mount Groq transcriber on OneBot channel in main.go gateway

* feat(onebot): add user ID allowlist check for incoming messages

- Currently, the agent does not respond to messages sent by users outside the allowlist.

* refactor(onebot): simplify channel implementation and add emoji reaction

- onebot.go from 1179 to 980 lines (~17%)
2026-02-19 14:39:35 +08:00
mattn e8afd31b28 Replace \s+ with [^\S\n]+ to preserve newlines (#299) 2026-02-19 02:02:28 +01:00
Kai Xia(夏恺) d167b47431 dead code cleanup (#210) 2026-02-19 01:54:13 +01:00
fipso bb0424e1e2 fix: also use max_completion_tokens for gpt5 era models (#445) 2026-02-19 01:29:34 +01:00
Hua Audio 0d6b22fb3a Update pkg/utils/message.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-18 23:26:39 +01:00
Huaaudio 98afd39913 remove unicode 2026-02-18 23:18:17 +01:00
Huaaudio a46fe140a3 update dynamic buffer 2026-02-18 23:14:44 +01:00
Huaaudio 7d8894d842 update message test, change dynamic buffer 2026-02-18 23:14:24 +01:00
Hua Audio dfc3dffd06 Update pkg/utils/message.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-18 22:43:49 +01:00
Huaaudio 82a2faed9d Privated function 2026-02-18 22:37:45 +01:00
Huaaudio f38ce0d4ac Update to support extra long code blocks 2026-02-18 22:31:18 +01:00
Hua Audio 4ccee85561 Update pkg/utils/message.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-18 22:16:19 +01:00
Hua Audio 0a9d24e2a2 Merge branch 'sipeed:main' into feat/base-layer-message-split 2026-02-18 22:03:11 +01:00
harshbansal7 b122abd30f fix 2026-02-19 02:28:44 +05:30
Huaaudio e35a827624 update documents 2026-02-18 21:44:25 +01:00
Hua e03124dc8a refactor: improve SplitMessage API clarity
- Accept hard upper limit (maxLen) instead of pre-subtracted value
- Caller now passes actual platform limit (e.g., 2000 for Discord)
- Internal buffer of 500 chars is handled within message.go
- Preferred split at maxLen - 500, may extend to maxLen for code blocks
- Never exceeds maxLen, no more mental math for callers
2026-02-18 20:21:51 +00:00
Hua 94a1b8664b refactor: extract message splitting logic to shared utils
- Move FindLast, findLast, and SplitMessage from discord.go to pkg/utils/message.go
- Update discord.go to use utils.SplitMessage()
- Makes splitting logic reusable across other channels
2026-02-18 20:01:53 +00:00
Leandro Barbosa f7ec89d82d Merge pull request #411 from harshbansal7/frontmatter_fix
Bug Fix: Fix parsing of SKILL.md file frontmatter - regex
2026-02-18 16:48:47 -03:00
harshbansal7 287100f303 Comments resolved 2026-02-18 23:13:47 +05:30
Leandro Barbosa b1e3b11a5d Merge pull request #304 from mymmrac/golangci-lint
feat(linters): Added golangci-lint config & CI job
2026-02-18 12:16:58 -03:00
Leandro Barbosa 447c17aeb1 merge: sync upstream/main (PR #213) into feat/multi-agent-routing
Resolve conflicts in pkg/providers/types.go and pkg/agent/loop.go:
- types.go: use protocoltypes aliases from PR #213, keep fallback types
- loop.go: drop old single-agent createToolRegistry (replaced by multi-agent pattern)

Refactor to align with PR #213 patterns:
- instance.go: use NewExecToolWithConfig (accept full config for deny patterns)
- registry.go: pass full config to NewAgentInstance
- loop.go: add Perplexity web search options to registerSharedTools
2026-02-18 11:39:14 -03:00
Artem Yadelskyi df52d4ad01 feat(linters): Fix linter 2026-02-18 16:26:35 +02:00
Artem Yadelskyi ef8965048a Merge branch 'main' into golangci-lint 2026-02-18 16:26:18 +02:00
Artem Yadelskyi b88f4c9ab5 feat(linters): Fix linter 2026-02-18 16:24:55 +02:00
Leandro Barbosa 2276bd149e merge: sync upstream/main, wire WebSearch through factory
Merge upstream/main into refactor/provider-protocol-122.
Resolve http_provider.go conflict (keep thin delegate).
Wire OpenAIProviderConfig.WebSearch through providerSelection
and into CodexProvider for codex-auth and codex-cli-token paths.
2026-02-18 11:09:18 -03:00
lxowalle eda6e37332 feat: Support modifying the command filtering list of the exec tool (#410) 2026-02-18 19:31:15 +08:00
harshbansal7 02b5811b95 add support for \r as well 2026-02-18 16:58:27 +05:30
harshbansal7 994ec72d91 Fix parsing of SKILL.md file frontmatter - regex 2026-02-18 16:55:20 +05:30
Zenix 3390576eea Feature/websearch OpenAI (#118)
* feature: add web search for codex models

* fix: use more elegant way to solve the issue.
2026-02-18 16:30:30 +08:00
lxowalle 01d694b998 fix: Add comprehensive command injection and system abuse prevention patterns (#401)
* Add comprehensive command injection and system abuse prevention patterns

* fix: Container running as root
2026-02-18 15:33:34 +08:00
Jared Mahotiere c4cbb5fb35 providers: finalize PR213 review fixes
Phase 1: centralize protocol message/tool/response types in protocoltypes and keep compatibility aliases in providers and protocol packages.

Phase 1: preserve HTTPProvider constructor compatibility and route Anthropic api_base through factory auth/provider constructors with base URL normalization.

Phase 2: expand provider routing/auth tests (deepseek/nvidia/shengsuanyun, codex/claude oauth/codex-cli) and add openai_compat + anthropic coverage for proxy transport, model normalization, numeric option coercion, token-source refresh, and base URL behavior.

Phase 3: apply gofmt and validate with Dockerized tests (go test ./pkg/providers/... ./pkg/migrate and go test ./...).
2026-02-17 11:13:10 -05:00
Leandro Barbosa 4fde0175cf Merge pull request #227 from mattn/fix-shadowing-running
Fix shadowing field runnnig
2026-02-17 12:58:48 -03:00
zenix.huang 0d16525fab fix: codex tool call 2026-02-17 22:56:31 +08:00
zenix.huang 4cd3f99dd6 fix: remove max_tokens 2026-02-17 22:56:31 +08:00
Jared Mahotiere e3c246a36f Merge origin/main into refactor/provider-protocol-122 2026-02-17 09:28:56 -05:00
daming大铭 7b9b8104c8 Merge pull request #225 from yinwm/feat/cron-exec-timeout-config
feat(cron): add configurable execution timeout for cron jobs
2026-02-17 21:12:59 +08:00
yinwm 881999aceb refactor(shell): interpret zero timeout as unlimited execution
Replace unconditional WithTimeout usage with conditional context creation
based on timeout configuration. Zero values now bypass timeout enforcement,
using WithCancel for graceful cancellation while preserving existing timeout
behavior for positive values. Simplifies CronTool initialization by removing
unnecessary conditional timeout assignment.
2026-02-17 21:10:20 +08:00
Hua Audio f929268ab2 feat: Add Perplexity search provider integration (#138)
* feat: Add Perplexity search provider integration

- Add PerplexityConfig struct to config package
- Add PerplexitySearchProvider implementing SearchProvider interface
- Update WebSearchTool to support Perplexity with priority system (Perplexity > Brave > DuckDuckGo)
- Update agent loop to pass Perplexity config options
- Update config.example.json with Perplexity configuration template
- Uses Perplexity's 'sonar' model for web search capabilities

* Edit config example

* make fmt

---------

Co-authored-by: Hua <zhangmikoto@gmail.com>
2026-02-17 21:02:56 +08:00
yinwm 684e7413e1 Merge remote-tracking branch 'origin/main' into feat/cron-exec-timeout-config 2026-02-17 20:53:31 +08:00
yuchou87 4113190c2a chore(config): remove example MCP servers from default config
Remove pre-populated example servers (filesystem, github, brave-search,
postgres) from DefaultConfig() to reduce memory footprint per instance.

Changes:
- Set MCP.Servers to empty map instead of 4 example servers
- Reduces default config size by ~500 bytes per instance
- Users should add MCP servers via config.json or documentation

Example configurations are still available in:
- README.md MCP section
- config.example.json
- Official MCP documentation

This optimization benefits deployments with many agent instances.
2026-02-17 10:41:29 +08:00
yuchou87 6892d006d6 perf(agent): reduce memory footprint by storing minimal MCP dependencies
Replace full *config.Config reference with config.MCPConfig value type
in AgentLoop to allow garbage collection of unused configuration data.

Changes:
- AgentLoop now stores only MCPConfig and workspacePath (minimal deps)
- Add mcp.Manager.LoadFromMCPConfig() for minimal dependency version
- Keep LoadFromConfig() for backward compatibility
- Full Config object can be GC'd after NewAgentLoop() returns

This optimization reduces memory usage by not holding references to
unused channel, provider, gateway, and device configurations.
2026-02-17 10:39:39 +08:00
Leandro Barbosa 12007b5670 merge: sync upstream/main into feat/multi-agent-routing
Resolve conflicts:
- pkg/agent/loop.go: integrate context compression, command handling,
  utf8 token estimation, and summarization notification into
  multi-agent routing architecture
- pkg/config/config_test.go: merge imports from both branches
- pkg/agent/loop_test.go: update test to use registry-based sessions
2026-02-16 10:34:55 -03:00
yuchou87 0f6fadb445 fix(agent): register MCP tools after server initialization
Critical bug fix:
- MCP tools were never registered because servers loaded in Run()
  but tool registration happened in NewAgentLoop() with empty manager
- Move MCP tool registration from createToolRegistry to Run()
- Register MCP tools for both main agent and subag after successful server loading
- Add subagentManager field to AgentLoop for dynamic registration
- Add tool_count logging for better observability

This ensures MCP tools are properly available to both agent and subagents.
2026-02-16 20:00:37 +08:00
yuchou87 2318232b71 fix(agent): ensure MCP cleanup on all Run() exit paths
- Add defer in Run() to guarantee MCP connection cleanup
- Handles both normal termination and context cancellation
- Prevents resource leaks when Run() exits via ctx.Done()
- MCP Manager.Close() is idempotent, safe to call from both defer and Stop()

This fixes GitHub Copilot feedback that MCP cleanup only happened in
Stop() but Run() could return on ctx.Done() without cleanup, causing
subprocess/session leaks on normal cancellation shutdown.
2026-02-16 19:56:00 +08:00
yuchou87 aed7296c0d fix(agent): tie MCP connections to agent lifecycle context
- Defer MCP server initialization to Run() using agent's context
- Add mcpConfig and mcpInitOnce fields to AgentLoop
- Use sync.Once to ensure MCP loads exactly once with proper context
- Prevents orphaned subprocesses and resource leaks on cancellation

This fixes GitHub Copilot feedback that MCP connections with
context.Background() won't terminate when the agent stops, causing
potential resource leaks and orphaned stdio/SSE connections.
2026-02-16 19:53:15 +08:00