* 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,
)
| 3245 | * to come from the server's own record, never from the wire. |
| 3246 | */ |
| 3247 | private withSessionView( |
| 3248 | toolName: string, |
| 3249 | args: Record<string, unknown>, |
| 3250 | sessionState: ExploreSessionState | undefined, |
| 3251 | ): Record<string, unknown> { |
| 3252 | if (!(EXPLORE_SESSION_VIEW_ARG in args) && (!sessionState || toolName !== 'codegraph_explore')) { |
| 3253 | return args; |
| 3254 | } |
| 3255 | const copy = { ...args }; |
| 3256 | delete copy[EXPLORE_SESSION_VIEW_ARG]; |
| 3257 | if (sessionState && toolName === 'codegraph_explore') { |
| 3258 | copy[EXPLORE_SESSION_VIEW_ARG] = sessionState.view(); |
| 3259 | } |
| 3260 | return copy; |
| 3261 | } |
| 3262 | |
| 3263 | /** |
| 3264 | * Record an explore call's emission into the caller's session state and strip |