Commit graph

451 commits

Author SHA1 Message Date
PeterChrz
8f34a1e36b
fix(buzz): require durable replay persistence 2026-08-25 07:37:23 -04:00
PeterChrz
b8bf0ab34f
fix(buzz): restore relay-driven NIP-42 subscription 2026-08-25 00:25:55 -04:00
PeterChrz
02961af54f
fix(buzz): suppress replayed events after restart 2026-08-25 00:25:21 -04:00
PeterChrz
23765f756f
fix(buzz): wait for NIP-42 challenge before calling Auth()
The go-nostr RelayConnect returns immediately after the WebSocket
handshake, but the relay has not yet sent the AUTH challenge. Calling
relay.Auth() right away signs the auth event with an empty challenge
tag, which the Buzz relay rejects permanently ('verification failed'
then 'authentication already failed' on retries).

Add a 2s sleep between RelayConnect and Auth() to give the background
read loop time to receive and store the challenge. The relay typically
delivers it within a few hundred milliseconds.
2026-08-11 21:59:20 -04:00
PeterChrz
9b4df86182
feat(channels): add Buzz (Nostr relay) channel
Implements a Buzz channel backed by a Nostr relay:
- kind:9 events scoped by "h" tag, "p" tags for mentions
- NIP-42 (kind:22242) auth before subscription
- optional threaded replies via "e" tag
- registered as config.ChannelBuzz with BuzzSettings
2026-08-11 21:41:16 -04:00
Mauro
b6e6d25d75
Merge pull request #3189 from chengzhichao-xydt/codex/line-body-close
fix(line): explicitly ignore resp.Body.Close() errors in Send and classifySDKError
2026-07-05 09:35:40 +02:00
Mauro
cf24f32896
Merge pull request #3156 from loafoe/feat/session-token-usage
feat(pico): emit per-turn LLM token usage on finalized message
2026-07-03 09:14:36 +02:00
pancake
612e485d4e WIP: Initial support for deltachat gateway
Features:
- Support voice messages
- Optional crossposting
- Automatic account creation
- Custom avatar image
2026-07-02 15:23:35 +02:00
程智超0668000959
9068fde274 fix: gofumpt formatting on line.go 2026-06-27 10:20:37 +08:00
程智超0668000959
ce4a6c9bba fix(line): explicitly ignore resp.Body.Close() errors in Send and classifySDKError 2026-06-27 09:19:13 +08:00
Mauro
979f440af7
Merge pull request #3184 from chengzhichao-xydt/codex/ws-body-close
fix(channels): explicitly ignore resp.Body.Close() errors in websocket dial cleanup
2026-06-26 18:10:06 +02:00
程智超0668000959
500ce72436 fix(onebot): explicitly ignore resp.Body.Close() error after websocket dial 2026-06-26 22:42:43 +08:00
程智超0668000959
1bd2e84527 fix(channels): explicitly ignore resp.Body.Close() errors in websocket dial cleanup 2026-06-26 22:15:03 +08:00
Andy Lo-A-Foe
cc7b4ca86b
fix(pico): deliver per-turn token usage to the streamer
Two bugs prevented the usage block from ever reaching the wire:

1. CallLLM read turnStateFromContext(ctx), but the raw ctx is not seeded
   with the turn state (only turnCtx is), so SetLastUsage/SetLastFinishReason
   were dropped — GetLastUsage() returned nil at finalize. Set them on the
   ts parameter directly, which is also what the streaming publisher reads.

2. The manager wraps the channel streamer in finalizeHookStreamer /
   splitMarkerStreamer, neither of which forwarded SetTurnUsage (it is not
   part of the bus.Streamer interface), so the type assertion in the
   publisher's Finalize failed silently. Mirror the existing SetModelName
   forwarding: add a turnUsageStreamer interface + setStreamerTurnUsage
   helper and SetTurnUsage methods on both wrappers (splitMarker also stores
   and re-applies usage to each freshly-begun part streamer).

Adds regression tests asserting both wrappers forward SetTurnUsage.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 15:38:46 +02:00
Andy Lo-A-Foe
697e94fe8c
feat(pico): emit real per-turn token usage on finalized message 2026-06-22 13:15:35 +02:00
Andy Lo-A-Foe
052c742fe7
feat(pico): add SetTurnUsage and usage payload helper 2026-06-22 13:07:48 +02:00
lc6464
234bd03018 fix(onebot): block private inbound media fetches 2026-06-17 17:00:24 +08:00
Mauro
86221d470b
Merge pull request #3135 from ZOOWH/fix/3110-telegram-forum-thread-id
fix(telegram): use compositeChatID in InboundContext.ChatID for forum topics
2026-06-16 22:06:31 +02:00
徐闻涵0668001344
7019143c8e fix(telegram): use compositeChatID in InboundContext.ChatID for forum topics
When handling inbound Telegram messages from forum topics, InboundContext.ChatID was set to the plain chat ID (without thread). This caused outbound messages to lose the thread routing, sending replies to the General topic instead of the specific forum topic — even though typing indicators correctly targeted the right thread because StartTyping received the compositeChatID.

The fix sets InboundContext.ChatID to compositeChatID (chatID/threadID format) for forum messages, matching the format already used for session routing and typing indicators. TopicID is still preserved as a redundant fallback for any path that strips the composite format.

Closes #3110
2026-06-16 20:43:37 +08:00
SiYue-ZO
b292defd95 fix: add panic recovery to core-path goroutines
Add defer-recover to 11 goroutines across 4 files to prevent
ungoroutine panics from crashing the entire process:

- pkg/tools/toolloop.go: parallel tool execution
- pkg/channels/manager.go: HTTP server (x2), channel registration
- pkg/events/subscription.go: concurrent dispatch, timeout handler,
  watchContext
- pkg/tools/shell.go: cmd.Wait, PTY cmd.Wait, PTY read, pipe read

Key design decisions:
- Recover handlers send fallback values to channels (shell done,
  subscription done) to prevent deadlocks when the producer panics
- PTY cmd.Wait sets session.Status='error' on panic for consistency
- toolloop sets ErrorResult on panic so the LLM gets a meaningful
  response instead of a nil result
- subscription.go uses log.Printf to match existing invokeHandler style
- Other files use project logger (ErrorCF) with stack traces

Refs: FIX-PLAN-0.3.0 #2
2026-06-15 23:06:11 +08:00
Mauro
13a38bd1c4
Merge pull request #2904 from SiYue-ZO/feature/fix-agent-loop-stability
Fix agent loop reload and panic cleanup stability
2026-06-14 21:22:53 +02:00
Mauro
f091c04ca9
Merge pull request #3066 from chengzhichao-xydt/codex/tmpfile-close-errors
fix: explicitly ignore Close() errors on temp file write/sync failure paths
2026-06-13 18:18:47 +02:00
程智超0668000959
7338df2cfb fix(channels): check json marshal/unmarshal errors in toChannelHashes
Replace silently discarded json.Marshal and json.Unmarshal errors with
explicit checks. If serialization fails, log a warning and either
return early (for the config-level marshal/unmarshal) or skip the
channel (for per-channel marshal). This prevents silent data loss
when channel configuration contains unexpected types.
2026-06-12 14:18:28 +08:00
Mauro
413d37494b
Merge pull request #2957 from loafoe/fix/tool-calls-filtering
fix(channels): prevent tool_calls from being dropped during streaming
2026-06-11 21:45:59 +02:00
SiYue-ZO
a7208983d0 feat(bus): add backpressure drop budget for audio streams only 2026-06-11 13:55:56 +08:00
程智超0668000959
6b004f6a5f fix: explicitly ignore Close() errors on temp file write/sync failure paths 2026-06-09 09:52:48 +08:00
2023478
3bba6338ca fix: handle Telegram location messages 2026-06-08 15:53:42 +08:00
程智超0668000959
3f435c5e56 fix: use %w instead of %v for error wrapping
errutil.go: Change %v to %w in ClassifySendError and ClassifyNetError so callers can use errors.Is/errors.As on the underlying HTTP/network error.

isolated_command_transport.go: Change %v to %w in Close() and Write() error paths for the same reason.
2026-06-08 09:10:14 +08:00
程智超0668000959
f037a112b2 fix: avoid err shadow in feishu close check
Use distinct variable names (writeErr, closeErr) to avoid
shadowing the outer err, so a deferred close failure is
still captured.
2026-06-07 20:35:57 +08:00
程智超0668000959
b1d727ebaf fix: check Close() error on feishu resource download 2026-06-07 11:57:10 +08:00
程智超0668000959
5f0d368995 fix: add ok checks for sync.Map LoadAndDelete/Load type assertions 2026-06-06 21:17:07 +08:00
程智超0668000959
4752a67a7c fix: type-switch capture, nil guard, LastInsertId error check
Three defensive fixes: 1) whatsapp_native - use type-switch capture instead of redundant unchecked assertion 2) config - add nil receiver guard to FilterSensitiveData 3) seahorse/store - check LastInsertId error in 3 locations
2026-06-06 16:32:14 +08:00
Mauro
b10f9cdf18
Merge pull request #2985 from chengzhichao-xydt/codex/context-show-summarize-threshold
fix(context): show both summarize and compress thresholds in /context
2026-06-05 19:24:54 +02:00
Mauro
0b7aaac2b2
Merge pull request #3009 from chengzhichao-xydt/codex/onebot-group-reply-fix
fix(onebot): use prefixed chatID for group reply routing
2026-06-05 19:14:56 +02:00
程智超0668000959
9f246a6482 test(channels): add edge case tests for toChannelHashes type assertions
Add 3 tests covering scenarios that previously panicked: 1) missing enabled key in settings 2) enabled field with non-bool type 3) teams_webhook with webhooks using map[string]any from JSON unmarshal
2026-06-06 00:31:44 +08:00
程智超0668000959
7a7e205cc8 fix(context): expose history tokens and remove leaked state files
Address remaining review feedback: 1) Add HistoryTokens field to ContextUsage/ContextStats, showing history-only token count in /context and frontend UI alongside SummarizeAtTokens so users can see the actual summarization trigger comparison. 2) Remove .codebuddy/github-contribute/ state files accidentally included in the PR.
2026-06-06 00:28:32 +08:00
程智超0668000959
e5c7772d3c fix(channels): add ok checks for type assertions in toChannelHashes
Two type assertions in toChannelHashes could panic when channel config values had unexpected types from JSON unmarshal: 1) value[enabled].(bool) panics if the key is missing or not a bool 2) vv.(map[string]string) panics when JSON unmarshal produces map[string]any. Add ok checks to safely handle both cases.
2026-06-05 09:49:44 +08:00
程智超0668000959
32ea611f0c fix(onebot): use prefixed chatID for group reply routing
When an incoming group message is received, the inbound context ChatID was set to the raw group number without the group: prefix. This caused the outbound reply to use send_private_msg instead of send_group_msg. Fix by using the prefixed chatID as inbound context ChatID. Closes #3002
2026-06-05 09:37:00 +08:00
程智超0668000959
296a8ae287 fix(context): address review - clarify threshold alignment, i18n strings, add test coverage 2026-06-05 09:27:45 +08:00
Mauro
49e3a03def fix: adapt to larksuite oapi-sdk-go v3.9.4 breaking changes
The SDK renamed ReceiveIdTypeChatId to CreateMessageV1ReceiveIDTypeChatId
in v3.9.4. Update all 5 usages in feishu_64.go and bump the dependency
version.

This fixes the build failure for Dependabot PR #3005.
2026-06-04 23:19:04 +02:00
程智超0668000959
5f826f4448 fix(context): show both summarize and compress thresholds in /context
The /context command previously showed only the hard budget compression
threshold (contextWindow - maxTokens), which confused users who expected
to see the soft summarization trigger from summarize_token_percent.

This commit adds SummarizeAtTokens alongside the existing CompressAtTokens
so that both thresholds are visible:

- Compress at: contextWindow - maxTokens (hard budget, triggers proactive
  compression when exceeded)
- Summarize at: contextWindow * summarizeTokenPercent / 100 (soft trigger,
  matches maybeSummarize's threshold)

The fix updates the /context command output, the Web UI popover, and the
pico channel WebSocket payload.

Fixes #2968
2026-06-04 11:03:16 +08:00
Mauro
ba8065923b
Merge pull request #2856 from bogdanovich/feat/message-media-outbound
feat(message): support media attachments and Telegram rich delivery
2026-05-31 11:38:38 +02:00
Andy Lo-A-Foe
89e7a61a69
fix(channels): prevent tool_calls from being dropped during streaming
The auxiliary message filtering introduced in #2892 incorrectly drops
tool_calls messages when there is an active stream or a tombstone from
a recently finished stream.

This causes tool_calls to not be delivered to the UI when users make
consecutive requests, as the second request's tool_calls message arrives
while the first request's stream is still active or within the 30-second
tombstone window.

The fix excludes tool_calls from auxiliary message filtering, since they
represent new tool invocations that must be delivered to the UI, not
stale auxiliary content like feedback or thoughts.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-27 20:36:23 +02:00
hschne
96b4c543f4
fix(discord): download attachments for vision pipeline
Discord only downloaded audio attachments before passing them to the agent. Non-audio attachments (images, videos, files) were passed as raw Discord CDN URLs, which do not flow through resolveMediaRefs and are not serialized as vision inputs.

Download every attachment, store it in the MediaStore with Discord's filename and content type metadata, and emit a media placeholder tag that matches the attachment kind. This lets resolveMediaRefs replace the placeholder with the local path-bearing tag and encode supported images for vision-capable providers. If a download fails, keep the previous raw URL fallback.
2026-05-23 10:01:33 +02:00
Anton Bogdanovich
1bf0d898de test(message): cover slack and feishu media fallbacks 2026-05-22 16:28:28 -07:00
Anton Bogdanovich
c05e5e29c6 test(message): cover pico and weixin media text semantics 2026-05-22 16:25:50 -07:00
Anton Bogdanovich
987f117f31 style(telegram): satisfy formatter rules 2026-05-22 16:25:50 -07:00
Anton Bogdanovich
5a4e42d1b6 feat(message): support media attachments in outbound tool 2026-05-22 16:25:50 -07:00
lxowalle
2992eccbf0
feat: add request-scoped context policies (#2914)
* feat: add request-scoped context policies

Add named turn profiles under agents.defaults so callers can opt into
per-request context and tool policies without changing default chat behavior.

Profiles can disable history, system context, skill prompts, or tools, and can
limit skills/tools with allow lists. Wire profile selection through Pico message
payloads, agent turn execution, Web chat selection, and Web visual config.

Reject invalid turn profiles before saving config through Web APIs and document
the new request context policy behavior.

* fix: address turn profile review blockers

* feat: simplify request context policy config

* fix: suppress tool prompt when turn tools are disabled

* fix: enforce turn profile tool restrictions
2026-05-22 10:06:40 +08:00
LC
b7db059544
feat(chat,seahorse): persist and display model_name across history (#2897)
* feat(chat,seahorse): persist and display model_name across history

* test(seahorse): fix lint regressions in repair coverage

* fix(pico): preserve model_name in live updates

* fix(pico): preserve model_name through live stream wrappers
2026-05-20 13:42:21 +08:00