(message: PiMessage | undefined)
| 85 | } |
| 86 | |
| 87 | export 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 | |
| 105 | export function createFakePi() { |
| 106 | const handlers = new Map<string, (...args: never[]) => unknown>(); |
no outgoing calls
no test coverage detected