( nextStepParams: NextStepParamsMap | undefined, handlerNextSteps: NextStep[] | undefined, catalog: ToolCatalog, )
| 187 | } |
| 188 | |
| 189 | function buildEffectiveNextStepParams( |
| 190 | nextStepParams: NextStepParamsMap | undefined, |
| 191 | handlerNextSteps: NextStep[] | undefined, |
| 192 | catalog: ToolCatalog, |
| 193 | ): NextStepParamsMap | undefined { |
| 194 | if (!handlerNextSteps || handlerNextSteps.length === 0) { |
| 195 | return nextStepParams; |
| 196 | } |
| 197 | |
| 198 | let merged: NextStepParamsMap | undefined = nextStepParams; |
| 199 | for (const step of handlerNextSteps) { |
| 200 | if (!step.tool || !step.params || Object.keys(step.params).length === 0) { |
| 201 | continue; |
| 202 | } |
| 203 | const target = catalog.getByMcpName(step.tool); |
| 204 | const toolId = target?.id ?? step.tool; |
| 205 | if (merged?.[toolId]) { |
| 206 | continue; |
| 207 | } |
| 208 | merged = { ...merged, [toolId]: step.params as NextStepParams }; |
| 209 | } |
| 210 | return merged; |
| 211 | } |
| 212 | |
| 213 | export function postProcessSession(params: { |
| 214 | tool: ToolDefinition; |
no test coverage detected