Commit Graph

1056 Commits

Author SHA1 Message Date
沈青川 e414b82ac3 fix(cron): publish agent response to outbound bus for cron-triggered jobs (#2100)
* fix(cron): publish agent response to outbound bus for cron-triggered jobs

When a cron job triggers agent execution via ProcessDirectWithChannel,
the agent response was silently discarded — the code assumed AgentLoop
would auto-publish it, but SendResponse is false on this path.

Delegate to PublishResponseIfNeeded (exported from AgentLoop) so the
response reaches the originating channel (e.g. Telegram) only when the
message tool did not already deliver content in the same round.

Also adds a "directive" message type to CronPayload, allowing cron jobs
to instruct the agent to execute a task rather than echo static text.

* fix(cron): add type validation and directive test coverage

Address reviewer blocking feedback:

1. Server-side whitelist for `type` parameter — the `enum` in
   Parameters() is only an LLM schema hint; any string was persisted.
   Now `addJob` rejects values other than "message" and "directive".

2. Comprehensive test coverage for the directive code path:
   - directive adds prompt prefix to ProcessDirectWithChannel
   - deliver=true + directive routes through agent (not direct publish)
   - directive prompt content, sessionKey, channel, chatID are correct
   - invalid type is rejected; valid types ("", "message", "directive") pass
   - deliver=true message type goes directly to bus (regression)
   - agent error path does not trigger publish (regression)

Also merge the two UpdateJob calls in addJob into one to avoid
redundant disk I/O (non-blocking suggestion from review).

* fix(cron): remove omitempty from CronPayload.Type for consistent JSON

Empty string and "message" are semantically equivalent defaults;
always serializing the field avoids asymmetric JSON output.

* test(cron): remove redundant test, strengthen error path coverage

- Remove ExecuteJobDirectivePassesCorrectContent: its assertions on
  sessionKey/channel/chatID duplicate ExecuteJobPublishesAgentResponse;
  its prompt check duplicates DirectiveAddsPromptPrefix.
- Strengthen DirectiveAddsPromptPrefix with exact prompt match and
  publish response assertion.
- Fix ReturnsErrorWithoutPublish: set non-empty stub response so the
  test verifies the error branch early-return, not the response==""
  guard.

* fix(ci): satisfy golines and gosmopolitan in cron code
2026-03-29 13:47:28 +08:00
zeed zhao 6ea364e67d feat(web): protect launcher dashboard with token and SPA login (#1953)
Add token-based authentication for the Launcher's embedded Web Dashboard.

- Ephemeral token generated in-memory each run (or via PICOCLAW_LAUNCHER_TOKEN env var)
- HMAC-SHA256 session cookie (HttpOnly, SameSite=Lax, Secure when HTTPS)
- Bearer token support for API/script access
- Rate limiting on login (10 attempts/IP/min)
- Referrer-Policy: no-referrer on all responses
- POST-only logout with JSON content-type (CSRF-safe)
- System tray "Copy dashboard token" action
- Login page shows contextual help (console/tray/log file path)
- Path traversal protection via path.Clean
- X-Forwarded-Host/Port/Proto support for reverse proxy deployments
- Full i18n support (English, Chinese)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 13:11:43 +08:00
Kunal Karmakar 1809d04905 chore(provider): use openai responses api for azure openai endpoints (#2110)
Migrate Azure OpenAI provider from legacy Chat Completions API to the OpenAI Responses API.

- Switch API endpoint from `/openai/deployments/{deployment}/chat/completions` to `/openai/v1/responses`
- Change auth header from `Api-Key` to `Authorization: Bearer`
- Use `responses.ResponseNewParams` SDK types for request construction
- Extract shared Responses API utilities into `openai_responses_common` package
- Deduplicate 178 lines from codex_provider.go by reusing shared package
- Add 593 lines of comprehensive test coverage for the shared package

Closes #2111

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-28 20:50:24 +08:00
Mauro 026a1339c7 simplified duplicated code (#1935) 2026-03-28 20:28:24 +08:00
champly 11dec0c80a fix(weixin): persist context tokens to disk to survive restarts (#2124) 2026-03-28 20:23:14 +08:00
Guoguo 62d40a02d4 fix: resolve typecheck errors in loop_test.go and dingtalk_test.go (#2122)
- loop_test.go: replace undefined WithSecurity/SecurityConfig/ModelSecurityEntry
  with direct APIKeys field using SimpleSecureStrings()
- dingtalk_test.go: use ClientSecret.String() and ClientSecret.Set()
  instead of non-existent ClientSecret() and SetClientSecret() methods

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 18:58:09 +08:00
Alix-007 b6951b6925 fix(dingtalk): honor mention-only groups and strip leading mentions (#2054)
* fix(dingtalk): honor @mention flag in mention-only groups

* fix(dingtalk): strip leading mentions in group payloads

---------

Co-authored-by: Alix-007 <267018309+Alix-007@users.noreply.github.com>
2026-03-28 18:26:10 +08:00
Hua Audio 0e13f6bdec fix/wechat-new-protocol (#2106)
* fix/wechat-new-protocol

* fix cdn download logic
2026-03-28 18:18:01 +08:00
Mauro 230942d234 fix(loop): polling (#2103) 2026-03-28 16:36:06 +08:00
xiwuqi e011284d8f fix(agent): use light provider for routed model calls (#2038) 2026-03-28 15:25:23 +08:00
Cytown f1cb7cc8f5 fix gateway reload will cause pico stop working issue (#2082)
* fix gateway reload will cause pico stop working issue

* fix for review
2026-03-28 11:30:31 +08:00
Mauro 60d7ec20a5 feat(log): prompt tokens (#2047) 2026-03-28 02:00:12 +08:00
Cytown b646d3b8fe refactor config and security to simplified the structure (#2068) 2026-03-28 00:03:34 +08:00
Cytown 98c78363b3 change default debug level to warn (#2084) 2026-03-27 21:04:28 +08:00
Cytown 0c9e4f0658 fix for FlexibleStringSlice cause picoclaw start crash issue (#2078) 2026-03-27 20:49:51 +08:00
daming大铭 25ce52715d Merge pull request #2070 from afjcjsbx/feat/improve-web-tools
feat(tools) time range in web_search
2026-03-27 19:36:24 +08:00
afjcjsbx d385491592 fix(config): array placeholder 2026-03-26 21:40:38 +01:00
afjcjsbx e2018c4aa7 fix lint 2026-03-26 21:33:43 +01:00
afjcjsbx b7f6ab7176 fix conf 2026-03-26 21:27:35 +01:00
afjcjsbx 48c04e050d feat(tools) range in web_search 2026-03-26 21:02:46 +01:00
Mauro 4bdf8f0e1d Merge pull request #1829 from perhapzz/test/add-fileutil-health-tests
test: add unit tests for pkg/fileutil and pkg/health
2026-03-26 10:42:13 +01:00
Alix-007 5c210e6f15 fix(config): disable tool feedback by default (#2026)
Co-authored-by: Alix-007 <267018309+Alix-007@users.noreply.github.com>
2026-03-26 09:31:42 +08:00
Mauro 5db1e94693 Merge pull request #1998 from abnerhexu/main
feat(config): allow placeholder text to be string or list
2026-03-25 22:47:39 +01:00
Mauro 1dff5e6903 Merge pull request #2016 from badgerbees/fix/context-overflow-errors
fix(providers): improve context overflow detection and classification
2026-03-25 21:58:53 +01:00
Badgerbees ae94893605 adding test units 2026-03-26 03:03:19 +07:00
Badgerbees 97dec16769 fix(providers): improve context overflow detection and classification 2026-03-26 01:07:56 +07:00
柚子 ed618e14aa feat(channels): support multi-message sending via split marker (#2008)
* Add multi-message sending via split marker

* Add marker and length split integration tests

Tests that SplitByMarker and SplitMessage work together correctly, and
that code block boundaries are preserved during marker splitting.

* Simplify message chunking logic in channel worker

Extract splitByLength helper function and remove goto-based control
flow.
The logic now flows more naturally - try marker splitting first, then
fall
back to length-based splitting.

* Update multi-message output instructions in agent context

* Add split_on_marker to config defaults

* Add split_on_marker config option

* Rename 'Multi-Message Sending' setting to 'Chatty Mode'

* Add SplitOnMarker config option
2026-03-26 01:33:49 +08:00
daming大铭 664e23e4fb Merge pull request #1828 from liuy/feat/logging-config
feat(logger): add PICOCLAW_LOG_FILE env var for file-only logging
2026-03-25 23:54:29 +08:00
daming大铭 70c4714988 feat(tools): add exec tool enhancement with background execution and PTY support
Merge #1869: Unified exec tool with actions (run/list/poll/read/write/send-keys/kill), PTY support, background execution, process session management.
2026-03-25 23:50:42 +08:00
肆月 bb2eddc79d Feature/add mimo provider (#1987)
* feat: add Xiaomi MiMo provider support

- Add 'mimo' protocol prefix support in factory_provider.go
- Add default API base URL for MiMo: https://api.xiaomimimo.com/v1
- Update provider-label.ts to include Xiaomi MiMo label
- Add MiMo to provider tables in both English and Chinese documentation
- Add comprehensive unit tests for MiMo provider

MiMo API is compatible with OpenAI API format, making it easy to integrate
with the existing HTTPProvider infrastructure.

Users can now use MiMo by configuring:
{
  "model_name": "mimo",
  "model": "mimo/mimo-v2-pro",
  "api_key": "your-mimo-api-key"
}

* hassas dosyaları kaldırma

* Add .security.yml and onboard to .gitignore
2026-03-25 23:29:44 +08:00
Liu Yuan 155af28841 feat(logger): add PICOCLAW_LOG_FILE env var for file-only logging 2026-03-25 21:34:27 +08:00
Liu Yuan 3f1ac297d4 feat(tools): add exec tool enhancement with background execution and PTY support (#1752)
- Unified exec tool with actions: run/list/poll/read/write/send-keys/kill
- PTY support using creack/pty library
- Process session management with background execution
- Process group kill for cleaning up child processes
- Session cleanup: 30-minute TTL for old sessions
- Output buffer: 100MB limit with truncation

Actions:
- run: execute command (sync or background)
- list: list all sessions
- poll: check session status
- read: read session output
- write: send input to session stdin
- send-keys: send special keys (up, down, ctrl-c, enter, etc.)
- kill: terminate session

Tests:
- PTY: allowed commands, write/read, poll, kill, process group kill
- Non-PTY: background execution, list, read, write, poll, kill, process group kill
- Session management: add/get/remove/list/cleanup
2026-03-25 21:02:49 +08:00
hezixu 123b9db6a9 fix: correct struct field alignment for gci 2026-03-25 18:03:27 +08:00
hezixu dc956f2feb feat(config): allow placeholder text to be string or list
Allow PlaceholderConfig.Text to accept either a single string or an
array of strings, from which one is randomly selected at runtime.
This maintains backward compatibility with existing single-string configs
while enabling random placeholder selection.

Changes:
- Modify PlaceholderConfig.Text type from string to FlexibleStringSlice
- Add GetRandomText() helper method for random selection
- Update SendPlaceholder in all channels to use GetRandomText()
- Update config.example.json with array placeholder examples
- Update Matrix channel documentation
2026-03-25 17:57:11 +08:00
wenjie 51f8285f93 fix(build): disable Matrix gateway import on freebsd/arm
Exclude the Matrix gateway shim from freebsd/arm builds because
modernc.org/libc currently fails to compile on that target.
Document the upstream 32-bit FreeBSD codegen mismatch as well.
2026-03-25 16:59:11 +08:00
lxowalle 6bd8fec87a Fix security config precedence during migration (#1984)
* Fix security config precedence during migration

* add doc

* fix ci

* add baidu search
2026-03-25 15:29:43 +08:00
xiwuqi 85dfb341a8 fix(agent): suppress heartbeat tool feedback (#1937) 2026-03-25 14:22:41 +08:00
Cytown 4398e3e070 Merge branch 'main' into fix-doc 2026-03-25 11:13:17 +08:00
uiyzzi be6bf9f6c6 Add virtual model support for multi-key expansion
Virtual models generated from multi-key expansion are now marked and
filtered during config persistence. Virtual models display with a badge
in the UI and cannot be set as default.
2026-03-25 00:00:36 +08:00
xiwuqi 9fb01bc7f8 fix(config): persist disabled placeholder settings (#1902) 2026-03-24 23:49:01 +08:00
Luo Peng 2ccac1819c fix(build): exclude matrix on unsupported mipsle and netbsd targets (#1975) 2026-03-24 23:40:51 +08:00
daming大铭 1b9445b806 Merge pull request #1955 from alexhoshina/refactor/wecom
Refactor/wecom
2026-03-24 23:37:35 +08:00
Christoforus Surjoputro 08fa9bb64b fix: agent triggered on empty message in telegram (#1927)
* add handler for empty message

* fix undefined: time

* fix linter

* update test to remove 100ms wait time since the handleMessage publishes synchronously
2026-03-24 23:31:03 +08:00
LC 6aff5b7ccd fix(pico): use O(1) session indexing and harden websocket concurrency handling (#1970)
* perf(pico): implement O(1) session lookup for pico connections

- Replace `sync.Map` with `connections` and `sessionConnections`.
- Add `addConnection`, `removeConnection`, `sessionConnectionsSnapshot`, and `takeAllConnections` with `connsMu` for concurrency.
- `broadcastToSession` now dispatches directly to `sessionConnections`.
- Add `newUniqueConnID` to avoid UUID collision/overwrites.
- Ensure `Stop` and `readLoop` use the new helpers for safe cleanup and correct `connCount` updates.

* refactor(pico): replace addConnection with createAndAddConnection for atomic connID generation

* refactor(pico): clear connections in one time to improve perf

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

* fix(pico): keep connCount consistent with connection indexes

* refactor(pico): make connCount a regular int guarded by connsMu

* fix(pico): enforce MaxConnections atomically on registration

* fix(pico): use temporary over-limit error and remove conn counter

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-24 23:25:27 +08:00
daming大铭 9381da29bf feat(matrix): support encrypted messages with E2EE
Merging after review. E2EE support for Matrix channel.
2026-03-24 22:52:34 +08:00
Mauro 2a0efb6e52 Merge pull request #1889 from afjcjsbx/fix/binary-tool-output-handling
fix(tool): route binary outputs through the media pipeline
2026-03-24 15:37:06 +01:00
RussellLuo 74a9dcaa5c fix(ci): Make CI happy 2026-03-24 21:51:58 +08:00
RussellLuo 7f163658c9 docs(matrix): Update docs 2026-03-24 21:46:12 +08:00
RussellLuo fab9603547 feat(matrix): support encrypted messages with E2EE
- Add `crypto_database_path` and `crypto_passphrase` configuration
- Integrate cryptohelper for decrypting `m.room.encrypted` events
- Handle both plaintext and encrypted messages in `handleMessageEvent`
- Enable `goolm` build tag for libsignal crypto support

Fixes #1840.
2026-03-24 21:46:10 +08:00
Hoshina cd48c3bde8 fix(config): remove stale wecom security merge fields 2026-03-24 20:27:31 +08:00