feat(session): expose transient generation API (#37433)

This commit is contained in:
Kit Langton 2026-07-17 09:25:50 -04:00 committed by GitHub
commit 3db4458e6c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 157 additions and 39 deletions

View file

@ -627,6 +627,22 @@ export const SessionHandler = HttpApiBuilder.group(Api, "server.session", (handl
return HttpApiSchema.NoContent.make()
}),
)
.handle(
"session.generate",
Effect.fn(function* (ctx) {
const text = yield* session.generate({ sessionID: ctx.params.sessionID, prompt: ctx.payload.prompt }).pipe(
Effect.mapError((error) =>
error._tag === "Session.NotFoundError"
? new SessionNotFoundError({
sessionID: error.sessionID,
message: `Session not found: ${error.sessionID}`,
})
: new ServiceUnavailableError({ message: error.message, service: "session generation" }),
),
)
return { data: { text } }
}),
)
.handle(
"session.log",
Effect.fn((ctx) =>