UNPKG

@workflow-manager/runner

Version:

CLI runner for in-memory and markdown workflow orchestration using ATEP-like envelopes

44 lines (43 loc) 1.42 kB
export function createContextMetricsBuilder() { const skills = []; let systemPromptsChars = 0; let globalStateChars = 0; let previousOutputChars = 0; let contextChars = 0; let objectiveChars = 0; return { addSystemPrompts(text) { systemPromptsChars += text.length; }, addSkill(name, content) { skills.push({ name, chars: content.length }); }, addGlobalState(text) { globalStateChars += text.length; }, addPreviousOutput(text) { previousOutputChars += text.length; }, addContext(text) { contextChars += text.length; }, addObjective(text) { objectiveChars += text.length; }, build() { const skillsChars = skills.reduce((sum, skill) => sum + skill.chars, 0); const totalChars = systemPromptsChars + skillsChars + globalStateChars + previousOutputChars + contextChars + objectiveChars; return { totalChars, sections: { systemPrompts: systemPromptsChars, skills, globalState: globalStateChars, previousOutput: previousOutputChars, context: contextChars, objective: objectiveChars, }, }; }, }; }