Commit graph

1995 commits

Author SHA1 Message Date
maxiaoyang
5b0634286c feat(providers/bedrock): prefix user content with sender name
Bedrock's Converse API multiplexes Claude, Llama, Titan, Mistral and
others through a single content-block protocol. None of those families
expose a per-message author identity in a unified way, so prefixing in
the text content block keeps multi-user attribution consistent
regardless of which underlying model the request lands on.

buildUserContent now passes msg through messageutil.ApplyUserNamePrefix
before constructing the text ContentBlockMemberText. Tool result paths
go through a separate code path (toolResultBlock) and are unaffected.
Image media handling is unchanged.

Tests:
- buildUserContent with Name set produces the prefixed text block
- buildUserContent without Name preserves byte-identical behavior
- existing image and base64 cases continue to pass

The Bedrock build is gated behind //go:build bedrock so this path is
only exercised in builds that opt in via that tag.

Refs #2702.
2026-04-29 21:05:07 +08:00
maxiaoyang
cd4372368e feat(providers/anthropic): prefix user content with sender name
Sibling change to the anthropic_messages adapter, this time for the
SDK-based path that talks to the official Anthropic endpoint via
anthropic-sdk-go. The Messages API there is the same shape, so the
fix is identical: wrap user content with messageutil.ApplyUserNamePrefix
when the message carries Name attribution; tool result blocks pass
through unchanged.

The prefix is applied at marshal time only; the persisted message is
not mutated. Existing single-user / direct-channel flows are
unaffected because Name is empty there.

Existing provider tests continue to pass; behavior is exercised by
the messageutil unit tests (which cover ApplyUserNamePrefix
exhaustively) and the agent-level integration tests added earlier.

Refs #2702.
2026-04-29 21:04:37 +08:00
maxiaoyang
f89b4cdf48 feat(providers/anthropic_messages): prefix user content with sender name
Anthropic's Messages API has no per-message author identity, so the
attribution from Message.Name needs to be rendered into content for
the model to see it. This adapter handles the HTTP path used by
self-hosted and custom Anthropic-compatible endpoints.

User content is wrapped via messageutil.ApplyUserNamePrefix at marshal
time, giving wire payloads like

    {"role": "user", "content": "[U_alice] My name is Alice"}

The persisted Message is never mutated; the prefix exists only in the
outgoing request body.

Tool result blocks (msg.ToolCallID set) are explicitly not prefixed
because they are function outputs, not user utterances. Direct
single-user channels see no change because Name is empty there.

Tests cover the four relevant cases: prefix applied, no-name no-prefix,
tool result untouched, and a multi-user history scenario reproducing
the issue #2702 example.

Refs #2702.
2026-04-29 21:04:19 +08:00
maxiaoyang
1895fc69ae feat(providers/common): emit OpenAI Chat Completions name field
SerializeMessages is the wire serializer shared by every OpenAI-style
backend in the project (openai_compat, azure, deepseek, glm, qwen,
groq, and other endpoints that accept the OpenAI Chat Completions
schema). The OpenAI spec defines an optional `name` field on each
message that disambiguates participants in multi-user conversations.

This change adds the field to the openaiMessage wire struct (with
omitempty) and the multipart map branch (only when set), so any
Message.Name produced upstream is forwarded to the model. Sanitization
upstream guarantees the wire-level constraint ^[a-zA-Z0-9_-]{1,64}$,
so backends that strictly enforce it will not reject the request.

Tests cover three properties:

- name appears on the plain-text path when set
- name appears on the multipart-with-media path when set
- both paths omit the field entirely when Name is empty (legacy
  single-user channels stay byte-identical on the wire)

Refs #2702.
2026-04-29 21:03:48 +08:00
maxiaoyang
7129c97dd2 feat(agent): plumb sender ID through user message persistence
Connects the inbound SenderID, which was already carried end-to-end via
InboundContext to PromptBuildRequest, into the per-turn user message so
historical messages remember who said what.

- userPromptMessage gains a senderID parameter. Real human IDs are
  sanitized via SanitizeMessageName; synthetic triggers (cron,
  heartbeat, async:*) are filtered out via IsSystemSenderID so they
  do not surface as distinct users.

- pipeline_setup.go now passes ts.opts.Dispatch.SenderID() and uses
  AddFullMessage unconditionally. The previous AddMessage(role,
  content) shortcut for media-less turns silently dropped the new
  Name field, breaking history disambiguation.

- context.go (BuildMessagesFromPrompt) propagates req.SenderID onto
  the current-turn user message that goes to the LLM.

After this commit, sessions persist sender attribution and provider
adapters receive it on each user message. Adapters that consume Name
(OpenAI native field, Anthropic-style content prefix) land in
follow-up commits.

The existing "## Current Sender" block in buildDynamicContext is
unchanged; it continues to describe the latest speaker in the system
prompt while Name covers the per-message channel for history.

Refs #2702.
2026-04-29 21:02:59 +08:00
maxiaoyang
7c7d7146ef feat(messageutil): add IsSystemSenderID and ApplyUserNamePrefix helpers
Two more helpers needed for end-to-end multi-user attribution:

- IsSystemSenderID filters synthetic trigger sources (cron, heartbeat,
  async:* tool callbacks, system channel) so internal events do not
  surface as distinct human users in the conversation. Without this,
  cron-triggered messages would carry attribution like cron, producing
  a confusing [cron] [System: cron] ... double prefix on adapters that
  fall back to in-content rendering.

- ApplyUserNamePrefix renders msg.Name as a [name] prefix on user
  content for adapters whose APIs do not support a per-message author
  identity (Anthropic, Bedrock, OpenAI Responses). The persisted
  message is never mutated; only the wire payload carries the prefix.
  Tool result messages and non-user roles pass through unchanged.

These helpers are pure and independently testable; they will be wired
into the agent and provider adapters in subsequent commits.

Refs #2702.
2026-04-29 21:01:03 +08:00
maxiaoyang
d1e9bb6ae3 feat(messageutil): add SanitizeMessageName for OpenAI wire compliance
OpenAI's Chat Completions name field requires ^[a-zA-Z0-9_-]{1,64}$.
Real-world sender IDs (Discord alice#1234, numeric Telegram IDs, Slack
U07AB12C3DEF, free-form CLI names) often violate this, so a sanitizer
sits between the raw inbound ID and any wire payload.

Disallowed characters collapse into a single underscore, leading and
trailing underscores are trimmed, and the result is byte-safely
truncated to 64 (output is pure ASCII).

This helper will be wired into the agent pipeline in a later commit.

Refs #2702.
2026-04-29 20:59:21 +08:00
maxiaoyang
72005ae06c feat(protocol): add Name field to providers.Message
Adds an optional Name field on providers.Message so per-message sender
attribution can be carried through the persistence layer and onto the
wire. The field is JSON-tagged `name,omitempty`, so:

- the OpenAI Chat Completions wire format will be able to emit the
  native `name` field that disambiguates participants in multi-user
  conversations;
- session stores that round-trip messages via json.Marshal preserve
  the field with no extra plumbing;
- existing session files load cleanly with Name = "".

This is the schema-only change. Adapters and the agent pipeline are
updated in subsequent commits.

Refs #2702.
2026-04-29 20:54:11 +08:00
Guoguo
62d0e34ec9
fix(docker): restore make docker-build by adding build directives and fixing Go version (#2700)
* fix(docker): restore `make docker-build` by adding build directives and fixing Go version

docker-compose.yml only had `image:` references with no `build:` sections,
so `docker compose build` had nothing to build. Also fixed golang:1.26.0-alpine
(nonexistent) to golang:1.25-alpine in Dockerfile.full/heavy, and removed
LICENSE from .dockerignore since scripts/copydir.go needs it as a repo-root anchor
during `go generate`.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(docker): inject version metadata ldflags in Dockerfile.launcher

Mirror the ldflags from web/Makefile (Version, GitCommit, BuildTime,
GoVersion) into the picoclaw-launcher go build command so Docker-built
launcher images include proper version/build metadata.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-29 16:19:15 +08:00
美電球
db1bc6a1f8
Merge pull request #2689 from afjcjsbx/fix/cron-session-key-propagation
fix(cron): propagate sessionKey to prevent duplicate tool responses
2026-04-28 23:03:09 +08:00
LC
9b109dc7a8
fix(serial_windows): remove unused import (#2697) 2026-04-28 16:19:59 +08:00
Guoguo
fc24676924
Add cross-platform serial tool support (#2673)
* feat(tools): add cross-platform serial hardware tool

* feat(config): wire serial tool into runtime and dashboard

* hardware/serial: tighten validation and error handling

* hardware/serial: improve unix cancellation and timeout polling

* hardware/serial: improve windows I/O handling

* hardware/serial: fix darwin cross-compilation build

* docs(design): summarize hardware support and serial limits

* build: keep go generate on host during cross builds

* onboard: drop unrelated go generate change from serial work

* style(tools): wrap serial lines for golines
2026-04-28 13:10:32 +08:00
SiYue-ZO
bd867a16cd style(tools): wrap serial lines for golines 2026-04-28 12:58:26 +08:00
SiYue-ZO
29e7461837 onboard: drop unrelated go generate change from serial work 2026-04-28 12:58:26 +08:00
SiYue-ZO
688d47d236 build: keep go generate on host during cross builds 2026-04-28 12:57:44 +08:00
SiYue-ZO
2baeee2834 docs(design): summarize hardware support and serial limits 2026-04-28 12:57:44 +08:00
SiYue-ZO
893e61dc51 hardware/serial: fix darwin cross-compilation build 2026-04-28 12:57:44 +08:00
SiYue-ZO
64e48163d0 hardware/serial: improve windows I/O handling 2026-04-28 12:57:25 +08:00
SiYue-ZO
1f0a5f4eda hardware/serial: improve unix cancellation and timeout polling 2026-04-28 12:57:09 +08:00
SiYue-ZO
338fa258b3 hardware/serial: tighten validation and error handling 2026-04-28 12:56:47 +08:00
SiYue-ZO
2114e1a53f feat(config): wire serial tool into runtime and dashboard 2026-04-28 12:56:27 +08:00
SiYue-ZO
0f52076762 feat(tools): add cross-platform serial hardware tool 2026-04-28 12:54:28 +08:00
LC
c44bd6138c
refactor(pico): unify message kind handling of tool_calls and thought (#2680)
* refactor(pico): unify message kind handling of tool_calls and thought

* fix(pico): add legacy compatibility for thought payload in Send method

Co-authored-by: Copilot <copilot@github.com>

---------

Co-authored-by: Copilot <copilot@github.com>
2026-04-28 10:17:12 +08:00
afjcjsbx
0bb0fc429a fix(cron): propagate sessionKey to prevent duplicate tool responses 2026-04-27 13:17:25 +02:00
Guoguo
0161298154
ci: add stale bot to auto-close inactive issues and PRs (#2685)
Two-phase strategy: 7 days inactive → stale warning, 7 more days → close.
Exempt labels: pinned, keep-open, wip, do-not-close, type: roadmap.
Draft PRs are also exempt. Runs daily at 03:00 JST.
Scan oldest items first (ascending: true) with 500 ops budget to avoid
backlog starvation.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-27 17:15:02 +08:00
美電球
f90e756e21
Merge pull request #2663 from SiYue-ZO/feature/config-save-restart-prompts
feat: improve config save and restart feedback
2026-04-27 15:45:38 +08:00
Mauro
ed687d62ae
fix(config): show precise malformed config diagnostics (#2415)
* fix(config): show precise malformed config diagnostics

* fix lint

* fix test
2026-04-27 09:45:52 +08:00
SiYue-ZO
ddf2d7c655 fix gateway boot signature after pico setup 2026-04-26 22:09:00 +08:00
SiYue-ZO
cbe6a0907c feat: complete tool and model restart feedback 2026-04-26 22:09:00 +08:00
SiYue-ZO
02d9a0d190 feat: track channel and web search restart requirements 2026-04-26 22:09:00 +08:00
SiYue-ZO
afc600baed feat: add config save and restart prompts 2026-04-26 22:09:00 +08:00
美電球
39dec35408
Merge pull request #2672 from lc6464/fix-tool-calls-thought-ui
feat(pico): add structured tool call support to web chat
2026-04-26 21:27:28 +08:00
lc6464
d6b38c4236
fix(chat): update tool_calls structure and ensure kind is always set 2026-04-26 20:13:13 +08:00
LC
1b9e7e32bd
fix(chat): add \r? for regular expressions
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-26 19:59:55 +08:00
lc6464
1acab59fc7
fix(tests): format error message 2026-04-26 19:48:22 +08:00
lc6464
bfc37b784e
fix(channels): bypass placeholder edits for thought and tool calls 2026-04-26 19:43:25 +08:00
lc6464
9d42282672
fix(chat): tolerate animated legacy tool feedback parsing 2026-04-26 01:19:19 +08:00
lc6464
303ff8137d
feat(chat): unify reasoning and tool call visibility 2026-04-26 00:50:18 +08:00
lc6464
6d04d15ce0
fix(tool-feedback): dedupe duplicate content and keep full explanations 2026-04-26 00:40:55 +08:00
lc6464
5cd10b594a
feat(pico): add support for tool_calls in chat messages 2026-04-25 23:43:10 +08:00
美電球
77be169db4
Merge pull request #2654 from SiYue-ZO/fix/launcher-hide-windows-console-flash
fix(launcher): hide windows child-process console flashes
2026-04-25 18:00:50 +08:00
美電球
726ef4fa99
Merge pull request #2661 from SiYue-ZO/feature/toggle-thought-visibility
feat: add thought visibility toggle
2026-04-25 17:15:49 +08:00
SiYue-ZO
d784ec4611 feat: add thought visibility toggle 2026-04-25 17:08:37 +08:00
美電球
41f4d95597
Merge pull request #2657 from lc6464/fix-deepseek-v4-thinking-history
fix(reasoning): persist canonical history for DeepSeek and web chat
2026-04-25 15:08:48 +08:00
Mauro
04b62745e4
Merge pull request #2664 from afjcjsbx/fix/mcp-http-session-lifecycle
fix(mcp): retry tool calls on lost HTTP sessions and fix client lifec…
2026-04-25 08:51:28 +02:00
BeaconCat
78e4e59ac3
chore: update WeChat group QR code (#2667)
Co-authored-by: BeaconCat <BeaconCat@users.noreply.github.com>
2026-04-25 13:15:37 +08:00
lc6464
ae162a72b1
fix(message): ignore transient assistant thoughts in message count and history truncation 2026-04-25 12:26:28 +08:00
美電球
788f76f422
Merge pull request #2666 from afjcjsbx/fix/mcp-nil-arguments
fix(mcp): send empty object instead of null for tool
2026-04-25 11:38:48 +08:00
美電球
2f91cc0a80
Merge pull request #2660 from afjcjsbx/fix/tool-feedback-json-format
fix(tool-feedback): format tool args as JSON code blocks
2026-04-25 11:34:09 +08:00
美電球
93e9bddc6e
Merge pull request #2659 from SiYue-ZO/fix/thought-bubble-collapse-state
fix: isolate thought bubble collapse state
2026-04-25 11:30:35 +08:00