MCPcopy Create free account
hub / github.com/apache/maka / decodeToolUsageQuery

Function decodeToolUsageQuery

packages/runtime-host/src/protocol/usage-pricing.ts:656–667  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

654}
655
656function decodeToolUsageQuery(value: unknown): ToolUsageQuery {
657 const query = requireRecord(value, 'tool usage query');
658 assertAllowedKeys(query, TOOL_USAGE_QUERY_FIELDS, 'tool usage query');
659 if (!Object.hasOwn(query, 'range')) {
660 throw invalidProtocolFrame('Invalid tool usage query fields');
661 }
662 return {
663 range: decodeUsageRange(query.range),
664 ...optionalQueryText(query, 'toolName'),
665 ...(query.status === undefined ? {} : { status: decodeUsageStatus(query.status) }),
666 };
667}
668
669function decodeUsageRange(value: unknown): UsageQuery['range'] {
670 if (value === '24h' || value === '7d' || value === '30d' || value === 'all') return value;

Callers 1

decodeUsageQueryInputFunction · 0.85

Calls 6

invalidProtocolFrameFunction · 0.85
decodeUsageRangeFunction · 0.85
optionalQueryTextFunction · 0.85
decodeUsageStatusFunction · 0.85
requireRecordFunction · 0.70
assertAllowedKeysFunction · 0.70

Tested by

no test coverage detected