Commit Graph

374 Commits

Author SHA1 Message Date
yuchou87 f1b798434d fix(mcp): prevent race condition between CallTool and Close
Add a closed flag to the Manager struct to prevent CallTool from
accessing server connections after Close has been called. The flag
is checked within the RLock in CallTool to ensure thread-safety.

Previously, CallTool could obtain a server reference using RLock,
then that reference could be closed by Close() running concurrently,
leading to use-after-close errors. Now:

1. CallTool checks the closed flag before accessing servers
2. Close sets the closed flag before closing connections
3. CallTool directly accesses m.servers within the lock instead
   of using GetServer() to avoid releasing the lock prematurely

This ensures CallTool will not use a server connection that is
being closed or has been closed.

Addresses Copilot code review feedback.
2026-02-19 19:47:05 +08:00
yuchou87 7577414761 fix(mcp): ensure proper environment variable override semantics
Use a map to merge environment variables with guaranteed override
behavior. Config variables (cfg.Env) now properly override file
variables (envFile), which in turn override parent process environment.

Previously, simply appending to a slice could result in duplicate
variables, and while most systems use the last occurrence, this
behavior is not guaranteed and could lead to unexpected results.

Addresses Copilot code review feedback.
2026-02-19 19:45:15 +08:00
yuchou87 f0ce26ff2b style(config): use snake_case for EnvFile JSON field name
Change 'envFile' to 'env_file' to maintain consistency with the rest
of the codebase which uses snake_case for JSON field names (e.g.,
'api_key', 'api_base', 'max_results', 'exec_timeout_minutes').

Addresses Copilot code review feedback.
2026-02-19 19:43:48 +08:00
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 59fd391248 Merge pull request #436 from Huaaudio/feat/base-layer-message-split
Refactor/base layer message split from #143
2026-02-18 23:29:29 +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
Hua Audio 048cd08e41 Merge pull request #437 from harshbansal7/fix_build
[Hot Fix] Fix Failing Linter
2026-02-18 22:02:33 +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
zepan 1b3da2ca29 1. update wechat group qrcode 2026-02-18 23:03:24 +08:00
Leandro Barbosa 1eb6b83b8f Merge pull request #418 from DanielVenturini/fix/add-missing-accentuation-in-ptbr-readme
docs(readme): add brazilian accentuation on pt-br README
2026-02-18 11:52:48 -03:00
Leandro Barbosa ab805fd5e3 Merge pull request #131 from Leeaandrob/feat/multi-agent-routing
feat: model fallback chain + multi-agent routing
2026-02-18 11:48:37 -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
Leandro Barbosa e61786cc6b Merge pull request #213 from jmahotiedu/refactor/provider-protocol-122
Refactor providers by protocol family (discussion #122)
2026-02-18 11:25:01 -03:00
Artem Yadelskyi b88f4c9ab5 feat(linters): Fix linter 2026-02-18 16:24:55 +02:00
Artem Yadelskyi 272cabc627 feat(linters): Fix version 2026-02-18 16:24:30 +02:00
Artem Yadelskyi d6f052f6b1 feat(linters): Fixed golangci-lint version 2026-02-18 16:23:31 +02:00
Artem Yadelskyi 24e35a199b Merge branch 'main' into golangci-lint
# Conflicts:
#	.github/workflows/release.yml
2026-02-18 16:22:43 +02:00
Leandro Barbosa 8a3be993cd Merge remote-tracking branch 'upstream/main' into refactor/provider-protocol-122 2026-02-18 11:19:09 -03:00
Daniel Venturini f8bd883387 docs(readme): add brazilian accentuation on pt-br README 2026-02-18 11:11:41 -03:00
Leandro Barbosa 87aee78900 Merge pull request #337 from quybquang/docs/add-vietnamese-readme
docs: add Vietnamese README (README.vi.md)
2026-02-18 11:11:31 -03: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
AlbertBui010 1e88df3ea8 Merge branch 'upstream/main' into docs/add-vietnamese-readme
Resolved conflicts in README.md, README.ja.md, and README.zh.md by keeping both Portuguese (upstream) and Vietnamese (local) language links.
2026-02-18 20:01:42 +07: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
Leandro Barbosa b77a40315e Merge pull request #218 from mattn/fix-readme-ja
Fix Japanese translation
2026-02-18 07:58:06 -03:00