import toolGroupsConfigJson from '../../config/tool-groups.json' with { type: 'json' };
const config = toolGroupsConfigJson;
const TRIGGER_CONFIDENCE = 0.9;
const MEMBER_CONFIDENCE = 0.5;
/**
 * Analyzes the last invoked tool and suggests groups that should be activated.
 * Returns suggestions sorted by confidence (highest first).
 */
export function analyzeContext(lastToolUsed, enabledGroups) {
    const suggestions = [];
    for (const group of config.groups) {
        if (enabledGroups.has(group.id)) {
            continue;
        }
        const isTrigger = group.triggerTools?.includes(lastToolUsed) ?? false;
        const isMember = group.tools.includes(lastToolUsed);
        if (isTrigger) {
            suggestions.push({
                suggestedGroup: group.id,
                reason: `Tool "${lastToolUsed}" is a trigger for group "${group.name}"`,
                confidence: TRIGGER_CONFIDENCE,
            });
        }
        else if (isMember) {
            suggestions.push({
                suggestedGroup: group.id,
                reason: `Tool "${lastToolUsed}" belongs to group "${group.name}"`,
                confidence: MEMBER_CONFIDENCE,
            });
        }
    }
    return suggestions.sort((a, b) => b.confidence - a.confidence);
}
/**
 * Returns the group id that a given tool belongs to, or undefined.
 */
export function findGroupForTool(toolName) {
    return config.groups.find((g) => g.tools.includes(toolName))?.id;
}
//# sourceMappingURL=context-analyzer.js.map