@@ -2,6 +2,8 @@ import { z } from "zod"
22import type { Logger } from "../logger"
33import type { PruningStrategy } from "../config"
44import type { PluginState } from "../state"
5+ import type { ToolMetadata } from "../fetch-wrapper/types"
6+ import { findCurrentAgent } from "../hooks"
57import { buildAnalysisPrompt } from "./prompt"
68import { selectModel , extractModelFromSession } from "../model-selector"
79import { estimateTokensBatch , formatTokenCount } from "../tokenizer"
@@ -28,7 +30,7 @@ export interface PruningResult {
2830 prunedCount : number
2931 tokensSaved : number
3032 llmPrunedIds : string [ ]
31- toolMetadata : Map < string , { tool : string , parameters ?: any } >
33+ toolMetadata : Map < string , ToolMetadata >
3234 sessionStats : SessionStats
3335}
3436
@@ -263,7 +265,7 @@ async function runLlmAnalysis(
263265 messages : any [ ] ,
264266 unprunedToolCallIds : string [ ] ,
265267 alreadyPrunedIds : string [ ] ,
266- toolMetadata : Map < string , { tool : string , parameters ?: any } > ,
268+ toolMetadata : Map < string , ToolMetadata > ,
267269 options : PruningOptions
268270) : Promise < string [ ] > {
269271 const { client, state, logger, config } = ctx
@@ -400,7 +402,7 @@ function replacePrunedToolOutputs(messages: any[], prunedIds: string[]): any[] {
400402interface ParsedMessages {
401403 toolCallIds : string [ ]
402404 toolOutputs : Map < string , string >
403- toolMetadata : Map < string , { tool : string , parameters ?: any } >
405+ toolMetadata : Map < string , ToolMetadata >
404406}
405407
406408export function parseMessages (
@@ -437,17 +439,6 @@ export function parseMessages(
437439 return { toolCallIds, toolOutputs, toolMetadata }
438440}
439441
440- function findCurrentAgent ( messages : any [ ] ) : string | undefined {
441- for ( let i = messages . length - 1 ; i >= 0 ; i -- ) {
442- const msg = messages [ i ]
443- const info = msg . info
444- if ( info ?. role === 'user' ) {
445- return info . agent || 'build'
446- }
447- }
448- return undefined
449- }
450-
451442// ============================================================================
452443// Helpers
453444// ============================================================================
0 commit comments