MCPcopy Create free account
hub / github.com/openai/plugins / computeBudgetProfile

Function computeBudgetProfile

plugins/plugin-eval/src/core/budget.js:241–269  ·  view source on GitHub ↗
(target)

Source from the content-addressed store, hash-verified

239}
240
241export async function computeBudgetProfile(target) {
242 if (target.kind === "skill") {
243 return computeSkillBudget(target.path);
244 }
245 if (target.kind === "plugin") {
246 const manifest = await readJson(path.join(target.path, ".codex-plugin", "plugin.json"));
247 return computePluginBudget(target.path, manifest);
248 }
249
250 const files = await gatherDeferredTextFiles(target.path);
251 const components = [];
252 for (const filePath of files) {
253 const content = await readText(filePath);
254 components.push(
255 createComponent(
256 relativePath(target.path, filePath),
257 filePath,
258 estimateTokenCount(content),
259 "Generic text file budget",
260 ),
261 );
262 }
263 return {
264 kind: target.kind,
265 trigger_cost_tokens: { value: 0, components: [] },
266 invoke_cost_tokens: { value: 0, components: [] },
267 deferred_cost_tokens: { value: sumTokenCounts(components), components },
268 };
269}
270
271export function applyBudgetBands(rawBudget, baseline) {
272 const profile = baseline?.[rawBudget.kind] || baseline?.directory || baseline?.skill;

Callers 2

analyzePathFunction · 0.90
explainBudgetFunction · 0.90

Calls 9

readJsonFunction · 0.90
readTextFunction · 0.90
relativePathFunction · 0.90
estimateTokenCountFunction · 0.90
sumTokenCountsFunction · 0.90
computeSkillBudgetFunction · 0.85
computePluginBudgetFunction · 0.85
gatherDeferredTextFilesFunction · 0.85
createComponentFunction · 0.85

Tested by

no test coverage detected