(bearer: string)
| 24 | /** The org the bearer is scoped to — the Autumn customer id `trackExecution` |
| 25 | * meters against — read from the JWT's public claims. */ |
| 26 | const orgIdOf = (bearer: string): string => { |
| 27 | const claims = JSON.parse(Buffer.from(bearer.split(".")[1] ?? "", "base64url").toString()) as { |
| 28 | readonly org_id?: string; |
| 29 | }; |
| 30 | if (!claims.org_id) throw new Error("orgIdOf: bearer carries no org_id claim"); |
| 31 | return claims.org_id; |
| 32 | }; |
| 33 | |
| 34 | const textOf = (result: { content?: unknown; toolResult?: unknown }): string => |
| 35 | ((result.content ?? []) as Array<{ type: string; text?: string }>) |
no test coverage detected