mirror of
https://github.com/coder/coder.git
synced 2026-06-04 13:38:21 +00:00
a02339c66a
- **computeruse.go**: Decode base64 screenshot data before storing in
`ToolResponse.Data` (was casting base64 string to bytes without
decoding)
- **chatloop.go**: Re-encode `ToolResponse.Data` to base64 via
`base64.StdEncoding.EncodeToString` instead of `string()` cast
- **mcpclient.go**: UTF-8 validate all text from MCP responses in
`convertCallResult()` using `strings.ToValidUTF8`
- **chatprompt.go (persist)**: Defense-in-depth UTF-8 sanitization of
text and media Text fields before database storage
- **chatprompt.go (replay)**: Antivenom layer that validates base64 and
UTF-8 at read time, auto-healing already-poisoned chats without
requiring a migration
- `TestToolResultAntivenom`: 4 subtests covering poisoned text, poisoned
media, valid media round-trip, and media with invalid UTF-8 text
- Adds `TestConvertCallResult_UTF8Sanitization`: 4 subtests covering invalid
UTF-8 in TextContent, EmbeddedResource, valid passthrough, and
multi-part
- Adds `TestComputerUseTool_Run_ScreenshotDataIsDecodedBinary`: Verifies no
double-encode in the computer-use path
- Updated existing computer-use tests for the new decoded-binary
contract
> 🤖
22 lines
668 B
Go
22 lines
668 B
Go
package chatprompt
|
|
|
|
import (
|
|
"charm.land/fantasy"
|
|
|
|
"cdr.dev/slog/v3"
|
|
"github.com/coder/coder/v2/codersdk"
|
|
)
|
|
|
|
// IsSyntheticPasteForTest exposes isSyntheticPaste for external tests.
|
|
var IsSyntheticPasteForTest = isSyntheticPaste
|
|
|
|
// ToolResultPartToMessagePartForTest exposes toolResultPartToMessagePart
|
|
// for external tests.
|
|
var ToolResultPartToMessagePartForTest = toolResultPartToMessagePart
|
|
|
|
// ToolResultContentToPartForTest exposes toolResultContentToPart
|
|
// for external tests.
|
|
var ToolResultContentToPartForTest = func(logger slog.Logger, content fantasy.ToolResultContent) codersdk.ChatMessagePart {
|
|
return toolResultContentToPart(logger, content, nil)
|
|
}
|