// `support.summarize` — EXECUTOR (server-only). // // Calls `@voltro/ai`'s `generateObject`, which constrains the model // output to the `SummaryResult` Effect Schema (converted to JSON Schema // for the provider, then decoded back so brands/refinements hold). A // provider failure or malformed output surfaces as a typed `AiError` // (`reason: 'generation' | 'decode'`) on the Effect failure channel — // declare it on the descriptor's `error:` to surface it typed to the // client, or `Effect.catchTag('AiError', …)` to handle it here. // // The provider is read from env (AI_PROVIDER / AI_MODEL + the key var) // because we don't pass `provider`. No key → the call fails with an // `AiError`; the app still BOOTS and discovers this action regardless. import { Effect } from 'effect' import { generateObject } from '@voltro/ai' import { SummaryResult } from './summarize.action' const execute = (input: { text: string }) => Effect.gen(function* () { const { object } = yield* generateObject({ schema: SummaryResult, system: 'Summarise the given support text. Produce a short title, a 1-2 sentence ' + 'summary, the key points as a list, and the overall sentiment.', prompt: input.text, maxTokens: 500, }) return object }) export default execute