MCPcopy Create free account
hub / github.com/GongShichen/LuminaCode / ReorderAttachments

Function ReorderAttachments

agent/normalize.go:37–59  ·  view source on GitHub ↗
(messages []map[string]any)

Source from the content-addressed store, hash-verified

35}
36
37func ReorderAttachments(messages []map[string]any) []map[string]any {
38 out := make([]map[string]any, 0, len(messages))
39 for _, msg := range messages {
40 blocks := contentBlocks(msg["content"])
41 if blocks == nil {
42 out = append(out, msg)
43 continue
44 }
45 attachments := make([]map[string]any, 0, len(blocks))
46 others := make([]map[string]any, 0, len(blocks))
47 for _, block := range blocks {
48 if _, ok := attachmentBlockTypes[stringFromAny(block["type"])]; ok {
49 attachments = append(attachments, block)
50 } else {
51 others = append(others, block)
52 }
53 }
54 cp := copyMap(msg)
55 cp["content"] = append(attachments, others...)
56 out = append(out, cp)
57 }
58 return out
59}
60
61func FilterVirtualMessages(messages []map[string]any) []map[string]any {
62 out := make([]map[string]any, 0, len(messages))

Callers 1

NormalizeMessagesFunction · 0.85

Calls 3

contentBlocksFunction · 0.70
stringFromAnyFunction · 0.70
copyMapFunction · 0.70

Tested by

no test coverage detected