Commit Graph

304 Commits

Author SHA1 Message Date
Zhaoyikaiii edc78191c9 style: fix gci formatting in protocoltypes/types.go 2026-02-25 15:36:54 +08:00
Zhaoyikaiii 1f7cbd9164 fix: cache system prompt with mtime-based auto-invalidation (#607)
Avoid rebuilding the entire system prompt on every BuildMessages() call
by caching the static portion (identity, bootstrap, skills summary,
memory) and only recomputing it when workspace source files change.

Key changes:

- ContextBuilder caches the static prompt behind an RWMutex with
  double-checked locking. Source file changes are detected via cheap
  os.Stat mtime checks so no explicit invalidation is needed.

- Track file existence at cache time (existedAtCache map) so that
  newly created or deleted bootstrap/memory files also trigger a
  rebuild — the old modifiedSince() silently returned false on
  os.IsNotExist.

- Walk the skills directory recursively with filepath.WalkDir to
  catch content-only edits at any nesting depth; directory mtime
  alone misses in-place file modifications on most filesystems.

- ToolRegistry.sortedToolNames() sorts tool names before iteration,
  ensuring deterministic tool definition order across calls — a
  prerequisite for LLM-side prefix/KV cache reuse.

- Merge all context (static + dynamic + summary) into a single
  system message for provider compatibility: the Anthropic adapter
  extracts messages[0] as the top-level system parameter, and Codex
  reads only the first system message as instructions.

- Fix a data race in BuildMessages() where cachedSystemPrompt was
  read without holding the lock in a debug log statement.

- Add tests: single system message invariant, mtime auto-invalidation,
  new-file creation detection, skill file content change, explicit
  InvalidateCache, cache stability, concurrent access (20 goroutines
  x 50 iterations, passes go test -race), and a benchmark.
2026-02-25 15:27:45 +08:00
Achton Smidt Winther ec6da7a530 fix: reject empty task in spawn tool (#740)
The spawn tool accepts empty strings as valid task arguments, which
causes a subagent to run with no meaningful work. The subagent's
completion message is then routed back to the originating channel
(e.g. Signal, Discord), where the main agent processes it and may
hallucinate an unrelated response that gets sent to users.

Validate that the task parameter is non-empty after trimming whitespace.

Related: #545

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 07:39:49 +11:00
daming大铭 fd26fa7459 Merge pull request #587 from nayihz/feat_webtool_proxy
feat: add HTTP proxy support for web tools
2026-02-24 23:51:01 +08:00
daming大铭 eb138a3f13 Merge pull request #642 from Lixeer/main
fix: better session management for `github_copilot_provider`
2026-02-24 23:18:14 +08:00
Lixeer d09c64fcee fix: implement code review suggestions
Address all feedback from PR review:
- Lock granularity
- Empty response handling
- Shutdown race condition
- Interface naming
2026-02-24 22:33:04 +08:00
Kai Xia(夏恺) 100356e8ec refactor: cleanup dead code and turn on dead code detection in CI (#515)
* cleanup dead code.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* add these two back with flag.

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* fix ci

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* remove this confusing line

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* make fmt

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

* remove unused method.

picked up by golangci-lint run

Signed-off-by: Kai Xia <kaix+github@fastmail.com>

---------

Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-24 21:52:25 +08:00
daming大铭 9cc0f8e685 Merge pull request #724 from mqyang56/fix/model-list-default-value-leak
fix: prevent DefaultConfig template values from leaking into user model_list entries
2026-02-24 19:43:23 +08:00
daming大铭 d20cb364a2 Merge pull request #677 from yinwm/refactor/model-to-model-name
refactor(config): rename model field to model_name
2026-02-24 19:05:40 +08:00
yinwm 01e2354b97 fix: align map values for proper formatting 2026-02-24 19:04:38 +08:00
yangmanqing 0d761ca608 fix: prevent DefaultConfig template values from leaking into user model_list entries 2026-02-24 17:57:28 +08:00
nayihz 76f2b42d5b feat: improve web proxy handling and coverage 2026-02-24 17:17:14 +08:00
daming大铭 b6e965e549 Merge pull request #604 from winterfx/fix/reasoning-content-missing
fix: preserve reasoning_content for OpenAI-compatible reasoning models
2026-02-24 14:20:36 +08:00
Kai Xia 6fb61539d7 translate Chinese comments
Signed-off-by: Kai Xia <kaix+github@fastmail.com>
2026-02-24 10:27:49 +11:00
mattn 6fe3920a4d perf: refactoring collecting skills (#688)
* perf: refactoring collecting skills

* Fix order to store dir.Name()

* Add tests
2026-02-24 10:07:09 +11:00
Goksu Ceylan 09b1992dd7 fix(security): ensure custom deny patterns extend defaults instead of replacing them (#479)
* fix (security): custom deny patterns denying default patterns

* fix formatting whitespace
2026-02-24 09:02:44 +11:00
0x5487 2fa51d7b86 fix(security): change gateway default bind to 127.0.0.1 (#393)
* chore: Update default host bindings from 0.0.0.0 to 127.0.0.1 for various services and examples.

* config: Update default host bindings to 0.0.0.0 for improved Docker accessibility and add related documentation.

* chore: resolve conflict

* chore: remove link

* docs: Add a tip for Docker users regarding gateway host configuration to the French and Vietnamese READMEs.

* fix: typo issue

* docs: Update Chinese README.zh.md.
2026-02-24 08:54:10 +11:00
Chujiang 8a53cb9665 fix: align Docker Go version with go.mod and optimize logger (#596)
- Update Dockerfile to use golang:1.25-alpine to match go.mod (go 1.25.7)
- Optimize logger by avoiding string concatenation in file writes
- Add explicit empty string assignment for fieldStr when no fields

These changes improve build consistency and reduce memory allocations
in the hot logging path, which is important for the project's goal
of running on resource-constrained devices (<10MB RAM).

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-24 08:52:16 +11:00
美電球 ae74fa3812 Merge pull request #541 from edouard-claude/feat/mistral-provider
feat: add native Mistral AI provider support
2026-02-23 21:06:26 +08:00
0x5487 19c698356c fix(security): workspace sandbox avoid time-of-check/time-of-use (TOCTOU) races (#464)
* chore: Update default host bindings from 0.0.0.0 to 127.0.0.1 for various services and examples.

* config: Update default host bindings to 0.0.0.0 for improved Docker accessibility and add related documentation.

* refactor: reimplement filesystem tools with `os.OpenRoot` for enhanced security and simplified path validation.

* chore: revert other PR content from this branch

* docs: Update Chinese README.

* docs: Update Chinese README.

* docs: Update Chinese README.

* refactor: Reorder filesystem helper functions, extract directory entry formatting logic, and enhance `WriteFileTool`'s result message.

* feat: Enhance `mkdirAllInRoot` to prevent creating directories over existing files and add tests for directory creation functionality.

* Refactor filesystem tools to use a `fileReadWriter` interface for both host and sandboxed I/O, improving atomic writes and error handling.

* refactor: unify filesystem read/write operations with atomic write guarantees and clearer naming.

* refactor: rename `appendFileWithRW` function to `appendFile`

* refactor: unify filesystem access by introducing a `fileSystem` interface and updating tools to use it directly, removing `os.Root` dependency from `sandboxFs`.

* chore: run make fmt

* fix: `validatePath` now returns an error when the workspace is empty.
2026-02-23 20:09:53 +11:00
yinwm e76e45f30f Merge remote-tracking branch 'origin/main' into refactor/model-to-model-name 2026-02-23 16:56:20 +08:00
yinwm 712f5a8300 refactor(config): rename model field to model_name
The configuration field for specifying the model has been renamed from
"model" to "model_name" for better clarity and consistency with the
model_list configuration.

A GetModelName() accessor method has been added to maintain backward
compatibility. Existing configurations using the old "model" field will
continue to work correctly.

This change affects:
- Configuration structure (AgentDefaults struct)
- All references across the codebase
- Documentation in all language variants
- Example configuration files
2026-02-23 16:55:06 +08:00
Vidish 4cc8b90da9 Fix: missing Tavily config in loop.go, and the invalid config param in web_search (#660) 2026-02-23 12:12:34 +08:00
Vidish c6865fe852 feat: integrate Tavily search (#340)
* feat: integrate Tavily search

* fix: set include_raw_content to false in Tavily search as wealready get relevant data inside content

* refactor: update Go type declarations to `any`, apply formatting fixes.
2026-02-23 00:30:14 +08:00
Lixeer 3d605a4f53 fix: run fmt and lint 2026-02-22 23:02:29 +08:00
Lixeer a849e02917 fix: better session management for github_copilot_provider 2026-02-22 22:30:53 +08:00
King Tai cb0c8703fb test(tools,utils): add ToolRegistry unit tests and fix Truncate panic on negative maxLen (#517)
Add comprehensive unit tests for the ToolRegistry covering registration,
lookup, execution, context injection, async callbacks, schema generation,
provider definition conversion, and concurrent access.

Fix a defensive edge case in Truncate where a negative maxLen would cause
a slice bounds panic, and add table-driven tests covering boundary
conditions, zero/negative lengths, and Unicode handling.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-22 21:40:59 +11:00
Edouard CLAUDE 34a8ce5af0 fix: remove extra fields from ToolCall JSON serialization
Mistral's API strictly validates tool_calls in assistant messages and
rejects non-standard fields. The ToolCall struct had Name and Arguments
as top-level JSON fields, duplicating data already in Function.Name
and Function.Arguments. OpenAI silently ignored these extras but
Mistral returns 422.

Change json tags to "-" so these internal fields are no longer
serialized to API payloads while remaining available in Go code.
2026-02-22 11:40:21 +04:00
Edouard CLAUDE 65422a16a4 feat: add native Mistral AI provider support
Add Mistral as a first-class provider alongside the 17 existing ones.
Mistral uses the OpenAI-compatible API at https://api.mistral.ai/v1
with provider-specific model prefix stripping (mistral/model → model).

Changes:
- Add Mistral to ProvidersConfig, IsEmpty(), HasProvidersConfig()
- Add mistral entry in default model_list (defaults.go)
- Add mistral protocol in factory_provider.go and getDefaultAPIBase()
- Add mistral prefix stripping in openai_compat normalizeModel()
- Add mistral case in legacy factory.go resolveProviderSelection()
- Add mistral migration entry in ConvertProvidersToModelList()
- Add mistral to supported providers in migrate/config.go
- Add mistral section in config.example.json
- Update AllProviders test (17 → 18 providers)

Tested end-to-end with mistral-small-latest model.
2026-02-22 11:40:21 +04:00
winterfx d224397f40 fix: preserve reasoning_content for OpenAI-compatible reasoning models
Models like Moonshot kimi-k2.5 and DeepSeek-R1 return a
reasoning_content field in assistant messages. When thinking is enabled,
the API requires this field to be echoed back in subsequent requests.
PicoClaw was silently dropping it, causing 400 errors on tool-call
round-trips.

- Add ReasoningContent to Message and LLMResponse types
- Parse reasoning_content in openai_compat parseResponse()
- Carry reasoning_content through assistant tool-call messages
- Add unit test for reasoning_content parsing

Fixes #588
2026-02-21 23:29:40 +08:00
Hoshina 0066602294 fix: golangci-lint run --fix 2026-02-21 16:20:15 +08:00
Hoshina 3df7f70540 fix: golangci-lint fmt 2026-02-21 16:05:39 +08:00
Luke Milby 80c8b57533 Fix Memory Write (#557)
* fix issue where memory will only trigger when asked to remember something

* updated prompt for memory usage
2026-02-21 08:21:38 +08:00
Meng Zhuo 273a8a2318 Merge pull request #550 from mymmrac/govet-linter
feat(linter): Fix govet linter
2026-02-21 08:20:35 +08:00
Goksu Ceylan 244eb0b47d fix (security): ExecTool working_dir sandbox escape (#478)
* fix (security) Shell working_dir bypass

* Feedback from @mengzhuo & Discord
- reuse internal security package to validate path
- add tests for workspace escape
2026-02-21 08:15:46 +08:00
Artem Yadelskyi 02b4d9fbe2 feat(linter): Fix govet linter 2026-02-20 22:35:16 +02:00
Artem Yadelskyi 0675ce7c38 feat(fmt): Fix formatting 2026-02-20 20:03:11 +02:00
Artem Yadelskyi ad8c2d48c8 Merge branch 'main' into fix-formatting
# Conflicts:
#	cmd/picoclaw/main.go
#	pkg/agent/context.go
#	pkg/agent/loop.go
#	pkg/channels/dingtalk.go
#	pkg/channels/feishu_64.go
#	pkg/channels/line.go
#	pkg/channels/manager.go
#	pkg/config/config.go
#	pkg/migrate/migrate_test.go
#	pkg/providers/anthropic/provider_test.go
#	pkg/providers/claude_provider_test.go
#	pkg/providers/http_provider.go
#	pkg/providers/openai_compat/provider.go
#	pkg/providers/protocoltypes/types.go
#	pkg/providers/types.go
2026-02-20 20:02:53 +02:00
Meng Zhuo 5b525f6139 Merge pull request #378 from lunareed720/fix/exec-timeout-process-tree
fix(exec): kill child process tree on timeout to prevent orphaned tasks
2026-02-20 23:32:05 +08:00
Meng Zhuo 55227762e4 Merge pull request #524 from mattn/perf/strings-builder
Use strings.Builder instead of += concatenation in loops
2026-02-20 23:24:47 +08:00
daming大铭 1ef33c90ed Merge pull request #474 from swordkee/main
add wecom and wecomApp
2026-02-20 21:17:59 +08:00
swordkee 0f70f783bd feat: add wecom and wecomApp test 2026-02-20 20:01:22 +08:00
Yasuhiro Matsumoto df49f6698a Fix 2026-02-20 20:48:43 +09:00
swordkee ca481035a4 feat: add wecom and wecomApp test 2026-02-20 19:39:12 +08:00
Vernon Stinebaker 2fb2a733d4 feat(discord): add mention_only option for @-mention responses (#518)
* feat(discord): add mention_only option for @-mention responses

Add MentionOnly config option to Discord channel. When enabled, the bot
only responds when explicitly @-mentioned, useful for shared servers.

- Add MentionOnly bool field to DiscordConfig
- Store botUserID on startup for mention checking
- Check m.Mentions before processing messages when MentionOnly is true
- Update config example and README documentation

* fix(discord): resolve race condition and strip mention from content

- Get botUserID before opening session to avoid race condition
- Add stripBotMention to remove @mention from message content
- Handles both <@USER_ID> and <@!USER_ID> mention formats

* fix(discord): skip mention_only check for DMs

DMs should always be responded to regardless of mention_only setting.
Added check to skip the mention_only logic when GuildID is empty.

* Update README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Hua Audio <161028864+Huaaudio@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-20 12:18:37 +01:00
Yasuhiro Matsumoto bca92433ba Use strings.Builder instead of += concatenation in loops 2026-02-20 20:09:13 +09:00
Harsh Bansal d692cc0cc6 Feature: Implement Skill Discovery - With Clawhub Integration and Caching (#332)
* Add Find Skills and Install Skills

* Improvements

* fix file name

* Update pkg/skills/clawhub_registry.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix

* Comments addressed

* Resolve comments

* fix tests

* fixes

* Comments resolved

* Update pkg/skills/search_cache_repro_test.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* minor fix

* fix test

* fixes

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-02-20 18:55:04 +08:00
swordkee 14ccfb39d9 feat: add wecom and wecomApp test 2026-02-20 18:28:10 +08:00
swordkee 59772cdbf2 feat: add wecom and wecomApp channel support 2026-02-20 17:40:59 +08:00
lxowalle f1223eec42 fix: revert enable endy patterns (#519) 2026-02-20 17:16:42 +08:00