* Attach the caller's session view to an explore call's args (CG-17), on a * COPY so the caller's object is never mutated. Nothing else sees it: a * non-explore tool, or a caller with no session state, gets the args * unchanged and pays nothing. * * A client that spells the internal k
(
toolName: string,
args: Record<string, unknown>,
sessionState: ExploreSessionState | undefined,
)
| 3305 | * to come from the server's own record, never from the wire. |
| 3306 | */ |
| 3307 | private withSessionView( |
| 3308 | toolName: string, |
| 3309 | args: Record<string, unknown>, |
| 3310 | sessionState: ExploreSessionState | undefined, |
| 3311 | ): Record<string, unknown> { |
| 3312 | if (!(EXPLORE_SESSION_VIEW_ARG in args) && (!sessionState || toolName !== 'codegraph_explore')) { |
| 3313 | return args; |
| 3314 | } |
| 3315 | const copy = { ...args }; |
| 3316 | delete copy[EXPLORE_SESSION_VIEW_ARG]; |
| 3317 | if (sessionState && toolName === 'codegraph_explore') { |
| 3318 | copy[EXPLORE_SESSION_VIEW_ARG] = sessionState.view(); |
| 3319 | } |
| 3320 | return copy; |
| 3321 | } |
| 3322 | |
| 3323 | /** |
| 3324 | * Record an explore call's emission into the caller's session state and strip |