(messages: Array<{ role: string; content: unknown; bp?: boolean }>)
| 16 | const MC_SYSTEM = "## Magic Context\nyou are a long-term partner."; |
| 17 | |
| 18 | function req(messages: Array<{ role: string; content: unknown; bp?: boolean }>) { |
| 19 | return { |
| 20 | body: { |
| 21 | system: MC_SYSTEM, |
| 22 | messages: messages.map((m) => ({ |
| 23 | role: m.role, |
| 24 | // Real OpenCode wire keeps a message's content shape stable across |
| 25 | // turns; only the cache_control marker moves. Render every message |
| 26 | // in the identical block-array form so a message looks the same |
| 27 | // whether it sits in the tail (with breakpoint) or the prefix |
| 28 | // (breakpoint moved on). The oracle strips cache_control before |
| 29 | // hashing, so the only difference between tail and prefix is the |
| 30 | // (stripped) marker — never the content shape. |
| 31 | content: m.bp |
| 32 | ? [{ type: "text", text: String(m.content), cache_control: { type: "ephemeral" } }] |
| 33 | : Array.isArray(m.content) |
| 34 | ? m.content |
| 35 | : [{ type: "text", text: String(m.content) }], |
| 36 | })), |
| 37 | }, |
| 38 | }; |
| 39 | } |
| 40 | |
| 41 | /** A user turn whose final message carries the moving cache_control breakpoint. */ |
| 42 | function turn(prefix: Array<{ role: string; content: string }>, tail: string) { |
no outgoing calls
no test coverage detected