* 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,
)
| 3422 | * to come from the server's own record, never from the wire. |
| 3423 | */ |
| 3424 | private withSessionView( |
| 3425 | toolName: string, |
| 3426 | args: Record<string, unknown>, |
| 3427 | sessionState: ExploreSessionState | undefined, |
| 3428 | ): Record<string, unknown> { |
| 3429 | if (!(EXPLORE_SESSION_VIEW_ARG in args) && (!sessionState || toolName !== 'codegraph_explore')) { |
| 3430 | return args; |
| 3431 | } |
| 3432 | const copy = { ...args }; |
| 3433 | delete copy[EXPLORE_SESSION_VIEW_ARG]; |
| 3434 | if (sessionState && toolName === 'codegraph_explore') { |
| 3435 | copy[EXPLORE_SESSION_VIEW_ARG] = sessionState.view(); |
| 3436 | } |
| 3437 | return copy; |
| 3438 | } |
| 3439 | |
| 3440 | /** |
| 3441 | * Record an explore call's emission into the caller's session state and strip |