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

Function contentShapeForHash

packages/runtime/src/request-shape.ts:635–653  ·  view source on GitHub ↗
(content: unknown)

Source from the content-addressed store, hash-verified

633}
634
635function contentShapeForHash(content: unknown): unknown {
636 if (typeof content === 'string') {
637 return { type: 'text', chars: content.length };
638 }
639 if (Array.isArray(content)) {
640 return content.map((part) => {
641 if (!isObjectLike(part)) return { type: typeof part };
642 const type = typeof part.type === 'string' ? part.type : 'unknown';
643 return {
644 type,
645 ...(typeof part.toolName === 'string' ? { toolName: part.toolName } : {}),
646 ...(typeof part.toolCallId === 'string' ? { toolCallId: part.toolCallId } : {}),
647 ...(typeof part.text === 'string' ? { chars: part.text.length } : {}),
648 ...('output' in part ? { output: payloadShapeForHash(part.output) } : {}),
649 };
650 });
651 }
652 return { type: typeof content };
653}
654
655function payloadShapeForHash(value: unknown): unknown {
656 const serialized = stableStringify(value);

Callers 1

messageShapeForHashFunction · 0.85

Calls 2

isObjectLikeFunction · 0.85
payloadShapeForHashFunction · 0.85

Tested by

no test coverage detected