{"version":3,"file":"OpenAIRealtimeSession.mjs","names":[],"sources":["../src/OpenAIRealtimeSession.ts"],"sourcesContent":["/**\n * OpenAI Realtime speech-to-speech Layer. Registers the typed\n * `OpenAIRealtimeSession` tag and the generic `RealtimeSession` tag.\n *\n * No `RealtimeVideoInput` marker: OpenAI Realtime takes still images as\n * conversation items but has no video input, so `sendVideoFrame` against this\n * Layer alone is a compile error.\n *\n * Pulls in `ws` (peer dep) transitively. Node and Bun only, since the browser\n * `WebSocket` API cannot set the `Authorization` header.\n */\nimport { Context, Effect, Layer, type Scope } from \"effect\"\nimport type * as AiError from \"@effect-uai/core/AiError\"\nimport type { CommonSessionRequest } from \"@effect-uai/core/Realtime\"\nimport {\n  RealtimeSession,\n  type RealtimeSessionHandle,\n  type RealtimeSessionService,\n} from \"@effect-uai/core/RealtimeSession\"\nimport {\n  type Config,\n  type OpenAIRealtimeRequest,\n  openSession,\n  refuseResume,\n} from \"./realtimeSession.js\"\n\nexport type { Config, OpenAIRealtimeRequest } from \"./realtimeSession.js\"\n\nexport type OpenAIRealtimeSessionService = {\n  readonly open: (\n    request: OpenAIRealtimeRequest,\n  ) => Effect.Effect<RealtimeSessionHandle, AiError.AiError, Scope.Scope>\n}\n\nexport class OpenAIRealtimeSession extends Context.Service<\n  OpenAIRealtimeSession,\n  OpenAIRealtimeSessionService\n>()(\"@betalyra/effect-uai/providers/openai/OpenAIRealtimeSession\") {}\n\nexport const make = (cfg: Config): OpenAIRealtimeSessionService => ({ open: openSession(cfg) })\n\nexport const layer = (cfg: Config): Layer.Layer<OpenAIRealtimeSession | RealtimeSession> =>\n  Layer.mergeAll(\n    Layer.succeed(OpenAIRealtimeSession, make(cfg)),\n    Layer.succeed(RealtimeSession, {\n      open: (request: CommonSessionRequest) =>\n        Effect.andThen(refuseResume(request), make(cfg).open(request as OpenAIRealtimeRequest)),\n    } satisfies RealtimeSessionService),\n  )\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAkCA,IAAa,wBAAb,cAA2C,QAAQ,QAGjD,CAAC,CAAC,6DAA6D,CAAC,CAAC,CAAC;AAEpE,MAAa,QAAQ,SAA+C,EAAE,MAAM,YAAY,GAAG,EAAE;AAE7F,MAAa,SAAS,QACpB,MAAM,SACJ,MAAM,QAAQ,uBAAuB,KAAK,GAAG,CAAC,GAC9C,MAAM,QAAQ,iBAAiB,EAC7B,OAAO,YACL,OAAO,QAAQ,aAAa,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC,KAAK,OAAgC,CAAC,EAC1F,CAAkC,CACpC"}