MCPcopy Create free account
hub / github.com/cortexkit/magic-context / textOf

Function textOf

packages/pi-plugin/src/test-utils.test.ts:87–103  ·  view source on GitHub ↗
(message: PiMessage | undefined)

Source from the content-addressed store, hash-verified

85}
86
87export function textOf(message: PiMessage | undefined): string {
88 if (!message) return "";
89 const content = (message as { content?: unknown }).content;
90 if (typeof content === "string") return content;
91 if (!Array.isArray(content)) return "";
92 return content
93 .filter((part): part is { type: "text"; text: string } => {
94 return (
95 typeof part === "object" &&
96 part !== null &&
97 (part as { type?: unknown }).type === "text" &&
98 typeof (part as { text?: unknown }).text === "string"
99 );
100 })
101 .map((part) => part.text)
102 .join("");
103}
104
105export function createFakePi() {
106 const handlers = new Map<string, (...args: never[]) => unknown>();

Calls

no outgoing calls

Tested by

no test coverage detected