* Unwrap execution result. The kernel wraps results as * `{ status: "completed", result: , logs: [...] }`. * Return just the inner result value.
(structured: Record<string, unknown> | undefined | null)
| 165 | * Return just the inner result value. |
| 166 | */ |
| 167 | function unwrapResult(structured: Record<string, unknown> | undefined | null): unknown { |
| 168 | if ( |
| 169 | structured && |
| 170 | typeof structured === "object" && |
| 171 | "status" in structured && |
| 172 | "result" in structured |
| 173 | ) { |
| 174 | return structured.result; |
| 175 | } |
| 176 | return structured; |
| 177 | } |
| 178 | |
| 179 | function parseTextContent(r: { content?: Array<{ type: string; text?: string }> }): unknown { |
| 180 | const text = r.content?.find((c) => c.type === "text")?.text; |