( sessionId = "ses-test", cwd = process.cwd(), entryIds: string[] = ["entry-1"], /** * Optional message references used as `entry.message` on each fake * SessionEntry. Pi's runtime keeps `entry.message === sourceAgentMessage` * by reference (session-manager.js:580), and Magic Context's * `collectMessageEntryIdsByRef` relies on that reference identity to * map event.messages → entry ids. Tests that want boundary-id * resolution to work should pass the same message objects they put * into `event.messages`. Without explicit messages, we fall back to * synthesized userMessage instances — which intentionally do NOT * match anything the test passes via `event.messages`, exercising * the unmapped-slot fallback path. */ messages?: PiMessage[], )
| 125 | } |
| 126 | |
| 127 | export function fakeContext( |
| 128 | sessionId = "ses-test", |
| 129 | cwd = process.cwd(), |
| 130 | entryIds: string[] = ["entry-1"], |
| 131 | /** |
| 132 | * Optional message references used as `entry.message` on each fake |
| 133 | * SessionEntry. Pi's runtime keeps `entry.message === sourceAgentMessage` |
| 134 | * by reference (session-manager.js:580), and Magic Context's |
| 135 | * `collectMessageEntryIdsByRef` relies on that reference identity to |
| 136 | * map event.messages → entry ids. Tests that want boundary-id |
| 137 | * resolution to work should pass the same message objects they put |
| 138 | * into `event.messages`. Without explicit messages, we fall back to |
| 139 | * synthesized userMessage instances — which intentionally do NOT |
| 140 | * match anything the test passes via `event.messages`, exercising |
| 141 | * the unmapped-slot fallback path. |
| 142 | */ |
| 143 | messages?: PiMessage[], |
| 144 | ) { |
| 145 | return { |
| 146 | cwd, |
| 147 | hasUI: true, |
| 148 | signal: new AbortController().signal, |
| 149 | ui: { notify: () => undefined }, |
| 150 | sessionManager: { |
| 151 | getSessionId: () => sessionId, |
| 152 | getBranch: () => |
| 153 | entryIds.map((id, index) => ({ |
| 154 | type: "message", |
| 155 | id, |
| 156 | message: messages?.[index] ?? userMessage("", index + 1), |
| 157 | })), |
| 158 | }, |
| 159 | getContextUsage: () => ({ tokens: 0, percent: 0, contextWindow: 100_000 }), |
| 160 | }; |
| 161 | } |
no test coverage detected