@effect-uai/google 0.11.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Gemini.d.mts +8 -2
- package/dist/Gemini.d.mts.map +1 -1
- package/dist/Gemini.mjs +1 -1
- package/dist/Gemini.mjs.map +1 -1
- package/dist/GeminiEmbedding.d.mts +2 -3
- package/dist/GeminiEmbedding.d.mts.map +1 -1
- package/dist/GeminiEmbedding.mjs +1 -1
- package/dist/GeminiEmbedding.mjs.map +1 -1
- package/dist/GeminiSynthesizer.d.mts +14 -6
- package/dist/GeminiSynthesizer.d.mts.map +1 -1
- package/dist/GeminiSynthesizer.mjs +13 -12
- package/dist/GeminiSynthesizer.mjs.map +1 -1
- package/dist/GeminiSynthesizer.test.d.mts +1 -1
- package/dist/GeminiSynthesizer.test.mjs +1 -1
- package/dist/GeminiSynthesizer.test.mjs.map +1 -1
- package/dist/GeminiTools.d.mts +9 -5
- package/dist/GeminiTools.d.mts.map +1 -1
- package/dist/GeminiTools.mjs +1 -1
- package/dist/GeminiTools.mjs.map +1 -1
- package/dist/GoogleDeepResearch.d.mts +58 -7
- package/dist/GoogleDeepResearch.d.mts.map +1 -1
- package/dist/GoogleDeepResearch.mjs +77 -23
- package/dist/GoogleDeepResearch.mjs.map +1 -1
- package/dist/GoogleDeepResearch.test.d.mts +1 -0
- package/dist/GoogleDeepResearch.test.mjs +66 -0
- package/dist/GoogleDeepResearch.test.mjs.map +1 -0
- package/dist/LyriaGenerator.d.mts +0 -2
- package/dist/LyriaGenerator.d.mts.map +1 -1
- package/dist/LyriaGenerator.mjs +9 -6
- package/dist/LyriaGenerator.mjs.map +1 -1
- package/dist/LyriaGenerator.test.d.mts +1 -1
- package/dist/LyriaGenerator.test.mjs +153 -8
- package/dist/LyriaGenerator.test.mjs.map +1 -1
- package/dist/codec.d.mts +36 -11
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs +27 -4
- package/dist/codec.mjs.map +1 -1
- package/dist/geminiSpeechCodec.d.mts +0 -1
- package/dist/geminiSpeechCodec.d.mts.map +1 -1
- package/dist/geminiSpeechCodec.mjs.map +1 -1
- package/dist/geminiSpeechCodec.test.d.mts +1 -1
- package/dist/geminiSpeechCodec.test.mjs +1 -1
- package/dist/geminiSpeechCodec.test.mjs.map +1 -1
- package/dist/geminiTools.test.d.mts +1 -1
- package/dist/geminiTools.test.mjs +44 -19
- package/dist/geminiTools.test.mjs.map +1 -1
- package/dist/{magic-string.es-CaWgF-3p.mjs → magic-string.es-CUAnjKYC.mjs} +14 -13
- package/dist/{magic-string.es-CaWgF-3p.mjs.map → magic-string.es-CUAnjKYC.mjs.map} +1 -1
- package/dist/models.d.mts.map +1 -1
- package/dist/{dist-CWoAuwS9.mjs → test.DNmyFkvJ-N3QqMRwZ.mjs} +257 -381
- package/dist/test.DNmyFkvJ-N3QqMRwZ.mjs.map +1 -0
- package/package.json +5 -5
- package/src/Gemini.ts +4 -7
- package/src/GeminiEmbedding.ts +36 -48
- package/src/GeminiSynthesizer.ts +20 -27
- package/src/GeminiTools.ts +4 -6
- package/src/GoogleDeepResearch.test.ts +80 -0
- package/src/GoogleDeepResearch.ts +127 -37
- package/src/LyriaGenerator.ts +19 -23
- package/src/codec.ts +98 -12
- package/src/geminiTools.test.ts +21 -3
- package/dist/dist-CWoAuwS9.mjs.map +0 -1
- /package/dist/{chunk-uyGKjUfl.mjs → rolldown-runtime-EAsCxrDo.mjs} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LyriaGenerator.mjs","names":[],"sources":["../src/LyriaGenerator.ts"],"sourcesContent":["import {\n Context,\n Duration,\n Effect,\n Encoding,\n Layer,\n Match,\n Redacted,\n Result,\n Schema,\n Stream,\n} from \"effect\"\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\"\nimport * as AiError from \"@effect-uai/core/AiError\"\nimport type { AudioChunk, AudioFormat } from \"@effect-uai/core/Audio\"\nimport { warnDroppedWhen } from \"@effect-uai/core/Capabilities\"\nimport type {\n CommonGenerateMusicRequest,\n CommonStreamGenerateMusicRequest,\n GenerateResult,\n MusicResult,\n MusicSessionInput,\n MusicStreamEvent,\n} from \"@effect-uai/core/Music\"\nimport { singleVariant } from \"@effect-uai/core/Music\"\nimport { MusicGenerator, type MusicGeneratorService } from \"@effect-uai/core/MusicGenerator\"\nimport type { LyriaModel } from \"./models.js\"\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Lyria-typed generate request. Narrows `model` to `LyriaModel`.\n *\n * Lyria 3 sync `generateContent` has no structured wire fields for\n * `lyrics` / `duration` / `seed` / `instrumental` / `bpm` / `scale` /\n * etc. Those fields on the Common request are logged as\n * dropped-bucket-2 hints; the adapter never rewrites or augments the\n * caller's prompt on their behalf. If you want lyrics or vocal\n * suppression, include them in your `prompt` text yourself.\n *\n * Output format: only `audio/mp3` and `audio/wav` are accepted; other\n * containers fail `Unsupported`. The Clip model variant is fixed at\n * `audio/mp3`.\n */\nexport type LyriaGenerateRequest = Omit<CommonGenerateMusicRequest, \"model\"> & {\n readonly model: LyriaModel\n}\n\nexport type LyriaGeneratorService = {\n readonly generate: (\n request: LyriaGenerateRequest,\n ) => Effect.Effect<GenerateResult, AiError.AiError>\n readonly streamGeneration: (\n request: LyriaGenerateRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n readonly streamGenerationFrom: <E, R>(\n input: Stream.Stream<MusicSessionInput, E, R>,\n request: CommonStreamGenerateMusicRequest,\n ) => Stream.Stream<MusicStreamEvent, AiError.AiError | E, R>\n}\n\nexport class LyriaGenerator extends Context.Service<LyriaGenerator, LyriaGeneratorService>()(\n \"@betalyra/effect-uai/providers/google/LyriaGenerator\",\n) {}\n\nexport type Config = {\n readonly apiKey: Redacted.Redacted\n readonly baseUrl?: string\n}\n\n// ---------------------------------------------------------------------------\n// Codec: AudioFormat → Lyria mimeType\n// ---------------------------------------------------------------------------\n\nexport type LyriaResponseMimeType = \"audio/mp3\" | \"audio/wav\"\n\nexport const containerToMimeType: (\n container: AudioFormat[\"container\"],\n) => Effect.Effect<LyriaResponseMimeType, AiError.AiError> = Match.type<\n AudioFormat[\"container\"]\n>().pipe(\n Match.when(\"mp3\", () => Effect.succeed<LyriaResponseMimeType>(\"audio/mp3\")),\n Match.when(\"wav\", () => Effect.succeed<LyriaResponseMimeType>(\"audio/wav\")),\n Match.whenOr(\"ogg\", \"opus\", \"flac\", \"aac\", \"webm\", \"raw\", (c) =>\n Effect.fail(\n new AiError.Unsupported({\n provider: \"lyria\",\n capability: \"outputFormat\",\n reason: `Lyria 3 only produces audio/mp3 or audio/wav; ${c} is not available. Use container: \"mp3\" or \"wav\".`,\n }),\n ),\n ),\n Match.exhaustive,\n)\n\n/**\n * Is this a Lyria 3 Clip model variant? Clip is fixed at 30 s MP3, it\n * does not accept a `responseFormat` on `generationConfig` (the live\n * API rejects unknown fields). Pro accepts the documented\n * `responseFormat` knob.\n */\nconst isClipModel = (model: string): boolean => model.includes(\"clip\")\n\nexport const realizedFormat: (mime: LyriaResponseMimeType) => AudioFormat =\n Match.type<LyriaResponseMimeType>().pipe(\n Match.when(\n \"audio/mp3\",\n (): AudioFormat => ({ container: \"mp3\", encoding: \"mp3\", sampleRate: 44100, channels: 2 }),\n ),\n Match.when(\n \"audio/wav\",\n (): AudioFormat => ({\n container: \"wav\",\n encoding: \"pcm_s16le\",\n sampleRate: 44100,\n channels: 2,\n }),\n ),\n Match.exhaustive,\n )\n\n// ---------------------------------------------------------------------------\n// Bucket-2 warn-and-drop for Common fields Lyria 3 can't honor\n// ---------------------------------------------------------------------------\n\n/**\n * Warn (don't fail) when the caller passed Common fields Lyria 3 has\n * no wire field for. Bucket-2 per capabilities policy: provider has\n * no structured interpretation; the output is still valid music, just\n * less aligned with the caller's hint. We never embed these into the\n * prompt on the caller's behalf, prompt construction is the\n * developer's job.\n */\nconst warnDroppedHints = (request: LyriaGenerateRequest): Effect.Effect<void> =>\n Effect.all(\n [\n warnDroppedWhen(request.lyrics, {\n provider: \"lyria\",\n capability: \"lyrics\",\n field: \"lyrics\",\n reason:\n \"Lyria 3 sync has no `lyrics` wire field. If you want vocals to follow specific lyrics, embed them in your prompt yourself (e.g. with `[Verse]` / `[Chorus]` tags).\",\n }),\n warnDroppedWhen(\n request.duration !== undefined ? Duration.toMillis(request.duration) : undefined,\n {\n provider: \"lyria\",\n capability: \"duration\",\n field: \"duration\",\n reason:\n \"Lyria 3 clip is fixed at 30 s; pro derives duration from prompt content. There is no wire field for duration. If you want to steer length, mention it in your prompt.\",\n },\n ),\n warnDroppedWhen(request.seed, {\n provider: \"lyria\",\n capability: \"seed\",\n field: \"seed\",\n reason:\n \"Lyria 3 (Gemini surface) does not expose a seed parameter. Output is non-deterministic across identical prompts. Use Lyria 2 (Vertex) for seeded generation.\",\n }),\n ],\n { discard: true },\n )\n\n// ---------------------------------------------------------------------------\n// Wire response schema\n// ---------------------------------------------------------------------------\n\nconst InlineData = Schema.Struct({\n mimeType: Schema.optional(Schema.String),\n data: Schema.String,\n})\n\nconst Part = Schema.Struct({\n text: Schema.optional(Schema.String),\n inlineData: Schema.optional(InlineData),\n})\n\nconst Content = Schema.Struct({\n parts: Schema.optional(Schema.Array(Part)),\n})\n\nconst Candidate = Schema.Struct({\n content: Schema.optional(Content),\n})\n\nconst Wire = Schema.Struct({\n candidates: Schema.optional(Schema.Array(Candidate)),\n})\n\nconst decodeWire = Schema.decodeUnknownEffect(Wire)\n\n// ---------------------------------------------------------------------------\n// HTTP plumbing\n// ---------------------------------------------------------------------------\n\nconst baseUrl = (cfg: Config): string =>\n cfg.baseUrl ?? \"https://generativelanguage.googleapis.com/v1beta\"\n\nconst transportFailure = (cause: unknown): AiError.AiError =>\n new AiError.Unavailable({ provider: \"lyria\", raw: cause })\n\nconst httpStatusError: (status: number, body: string) => AiError.AiError = (status, body) =>\n Match.value(status).pipe(\n Match.when(\n 429,\n (): AiError.AiError => new AiError.RateLimited({ provider: \"lyria\", raw: body }),\n ),\n Match.whenOr(\n 408,\n 504,\n (): AiError.AiError => new AiError.Timeout({ provider: \"lyria\", raw: body }),\n ),\n Match.when(\n 401,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"auth\", raw: body }),\n ),\n Match.when(\n 403,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"permission\", raw: body }),\n ),\n Match.when(\n 402,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"billing\", raw: body }),\n ),\n Match.when(\n (n) => n >= 500,\n (n): AiError.AiError => new AiError.Unavailable({ provider: \"lyria\", status: n, raw: body }),\n ),\n Match.orElse(\n (): AiError.AiError => new AiError.InvalidRequest({ provider: \"lyria\", raw: body }),\n ),\n )\n\nconst decodeBase64ToBytes = (b64: string): Effect.Effect<Uint8Array, AiError.AiError> =>\n Result.match(Encoding.decodeBase64(b64), {\n onSuccess: Effect.succeed,\n onFailure: (cause) =>\n Effect.fail(new AiError.InvalidRequest({ provider: \"lyria\", param: \"audio\", raw: cause })),\n })\n\n/**\n * Find the first inline-data audio part and the concatenated text parts\n * from a Wire response.\n */\nconst extractParts = (\n wire: typeof Wire.Type,\n): { readonly inline?: typeof InlineData.Type; readonly text?: string } => {\n const allParts = (wire.candidates ?? []).flatMap((c) => c.content?.parts ?? [])\n const inline = allParts.find((p) => p.inlineData !== undefined)?.inlineData\n const textParts = allParts.flatMap((p) => (p.text !== undefined ? [p.text] : []))\n const text = textParts.length === 0 ? undefined : textParts.join(\"\\n\")\n return {\n ...(inline !== undefined && { inline }),\n ...(text !== undefined && { text }),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Service implementation\n// ---------------------------------------------------------------------------\n\nconst generateImpl =\n (cfg: Config) =>\n (\n request: LyriaGenerateRequest,\n ): Effect.Effect<GenerateResult, AiError.AiError, HttpClient.HttpClient> =>\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const requestedContainer = (request.outputFormat?.container ??\n \"mp3\") satisfies AudioFormat[\"container\"]\n const requestedMime = yield* containerToMimeType(requestedContainer)\n // lyria-3-clip-preview has no `responseFormat` wire field and always\n // emits mp3, so there is no format to send and no 400 to surface. Rather\n // than keep a per-model table that rejects `wav`, report the format the\n // model actually produces (mp3) so the result is never mislabeled.\n // lyria-3-pro honours the requested container.\n const mimeType = isClipModel(request.model) ? (\"audio/mp3\" as const) : requestedMime\n yield* warnDroppedHints(request)\n const body = isClipModel(request.model)\n ? { contents: [{ parts: [{ text: request.prompt }] }] }\n : {\n contents: [{ parts: [{ text: request.prompt }] }],\n generationConfig: {\n responseModalities: [\"AUDIO\", \"TEXT\"],\n responseFormat: { audio: { mimeType } },\n },\n }\n const httpRequest = HttpClientRequest.post(\n `${baseUrl(cfg)}/models/${request.model}:generateContent`,\n ).pipe(\n HttpClientRequest.setHeader(\"x-goog-api-key\", Redacted.value(cfg.apiKey)),\n HttpClientRequest.bodyJsonUnsafe(body),\n )\n const response = yield* client.execute(httpRequest).pipe(Effect.mapError(transportFailure))\n if (response.status >= 400) {\n const text = yield* response.text.pipe(Effect.orElseSucceed(() => \"\"))\n return yield* httpStatusError(response.status, text)\n }\n const json = yield* response.json.pipe(Effect.mapError(transportFailure))\n const wire = yield* decodeWire(json).pipe(\n Effect.mapError(\n (cause): AiError.AiError =>\n new AiError.GenerationFailed({ provider: \"lyria\", raw: cause }),\n ),\n )\n const { inline, text } = extractParts(wire)\n if (inline === undefined) {\n return yield* new AiError.GenerationFailed({\n provider: \"lyria\",\n raw: {\n message: \"Lyria response had no inlineData audio part.\",\n hint: \"Likely a prompt-filter rejection. Lyria filters references to real artists / copyrighted song lyrics. Rephrase with descriptive style language instead of artist names.\",\n textParts: text,\n response: json,\n },\n })\n }\n const bytes = yield* decodeBase64ToBytes(inline.data)\n const result: MusicResult = {\n audio: { format: realizedFormat(mimeType), bytes },\n provider: \"lyria\",\n ...(text !== undefined && { lyrics: text }),\n watermark: \"synthid\",\n }\n return singleVariant(result)\n })\n\nconst streamGenerationImpl =\n (cfg: Config) =>\n (\n request: LyriaGenerateRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError, HttpClient.HttpClient> =>\n Stream.unwrap(\n Effect.map(generateImpl(cfg)(request), (result) =>\n Stream.succeed<AudioChunk>({ bytes: result.primary.audio.bytes }),\n ),\n )\n\n/**\n * Lyria 3 sync has no bidirectional session at the wire level, that's\n * Lyria RealTime (separate Layer). The provider Layer here also does\n * NOT register `MusicInteractiveSession`, so callers using\n * `MusicGenerator.streamGenerationFrom` against only this Layer get a\n * compile-time error before this runtime fallback ever fires.\n */\nconst streamGenerationFromUnsupported = <E, R>(\n _input: Stream.Stream<MusicSessionInput, E, R>,\n _request: CommonStreamGenerateMusicRequest,\n): Stream.Stream<MusicStreamEvent, AiError.AiError | E, R> => {\n const fail: Stream.Stream<MusicStreamEvent, AiError.AiError | E, R> = Stream.fail(\n new AiError.Unsupported({\n provider: \"lyria\",\n capability: \"streamGenerationFrom\",\n reason:\n \"Lyria 3 sync does not support bidirectional sessions. Use the Lyria RealTime Layer (WebSocket BidiGenerateMusic) for interactive mid-session prompts.\",\n }),\n )\n return fail\n}\n\n// ---------------------------------------------------------------------------\n// Constructors\n// ---------------------------------------------------------------------------\n\nexport const make = (\n cfg: Config,\n): Effect.Effect<LyriaGeneratorService, never, HttpClient.HttpClient> =>\n Effect.map(HttpClient.HttpClient, (client) => ({\n generate: (request) =>\n generateImpl(cfg)(request).pipe(Effect.provideService(HttpClient.HttpClient, client)),\n streamGeneration: (request) =>\n streamGenerationImpl(cfg)(request).pipe(Stream.provideService(HttpClient.HttpClient, client)),\n streamGenerationFrom: streamGenerationFromUnsupported,\n }))\n\n/**\n * Layer that registers both the provider-specific `LyriaGenerator` tag\n * and the generic `MusicGenerator` tag.\n *\n * Does NOT register the `MusicInteractiveSession` capability marker,\n * Lyria 3 sync has no bidirectional session at the wire level. Code\n * calling `MusicGenerator.streamGenerationFrom` will fail to typecheck\n * against this Layer alone, which is the intended UX.\n */\nexport const layer = (\n cfg: Config,\n): Layer.Layer<LyriaGenerator | MusicGenerator, never, HttpClient.HttpClient> =>\n Layer.merge(\n Layer.effect(LyriaGenerator, make(cfg)),\n Layer.effect(\n MusicGenerator,\n Effect.map(\n make(cfg),\n (s): MusicGeneratorService => ({\n generate: (req: CommonGenerateMusicRequest) =>\n s.generate({ ...req, model: req.model as LyriaModel }),\n streamGeneration: (req: CommonStreamGenerateMusicRequest) =>\n s.streamGeneration({ ...req, model: req.model as LyriaModel }),\n streamGenerationFrom: s.streamGenerationFrom,\n }),\n ),\n ),\n )\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,IAAa,iBAAb,cAAoC,QAAQ,SAAgD,CAC1F,uDACD,CAAC;AAaF,MAAa,sBAEgD,MAAM,MAEhE,CAAC,KACF,MAAM,KAAK,aAAa,OAAO,QAA+B,YAAY,CAAC,EAC3E,MAAM,KAAK,aAAa,OAAO,QAA+B,YAAY,CAAC,EAC3E,MAAM,OAAO,OAAO,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,MACzD,OAAO,KACL,IAAI,QAAQ,YAAY;CACtB,UAAU;CACV,YAAY;CACZ,QAAQ,iDAAiD,EAAE;CAC5D,CAAC,CACH,CACF,EACD,MAAM,WACP;;;;;;;AAQD,MAAM,eAAe,UAA2B,MAAM,SAAS,OAAO;AAEtE,MAAa,iBACX,MAAM,MAA6B,CAAC,KAClC,MAAM,KACJ,oBACoB;CAAE,WAAW;CAAO,UAAU;CAAO,YAAY;CAAO,UAAU;CAAG,EAC1F,EACD,MAAM,KACJ,oBACoB;CAClB,WAAW;CACX,UAAU;CACV,YAAY;CACZ,UAAU;CACX,EACF,EACD,MAAM,WACP;;;;;;;;;AAcH,MAAM,oBAAoB,YACxB,OAAO,IACL;CACE,gBAAgB,QAAQ,QAAQ;EAC9B,UAAU;EACV,YAAY;EACZ,OAAO;EACP,QACE;EACH,CAAC;CACF,gBACE,QAAQ,aAAa,KAAA,IAAY,SAAS,S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C1C,WAAW;EAEc,CAAC;EAC5B;AAEN,MAAM,wBACH,SAEC,YAEA,OAAO,OACL,OAAO,IAAI,aAAa,IAAI,CAAC,QAAQ,GAAG,WACtC,OAAO,QAAoB,EAAE,OAAO,OAAO,QAAQ,MAAM,OAAO,CAAC,CAClE,CACF;;;;;;;;AASL,MAAM,mCACJ,QACA,aAC4D;AAS5D,QARsE,OAAO,KAC3E,IAAI,QAAQ,YAAY;EACtB,UAAU;EACV,YAAY;EACZ,QACE;EACH,CAAC,CAEO;;AAOb,MAAa,QACX,QAEA,OAAO,IAAI,WAAW,aAAa,YAAY;CAC7C,WAAW,YACT,aAAa,IAAI,CAAC,QAAQ,CAAC,KAAK,OAAO,eAAe,WAAW,YAAY,OAAO,CAAC;CACvF,mBAAmB,YACjB,qBAAqB,IAAI,CAAC,QAAQ,CAAC,KAAK,OAAO,eAAe,WAAW,YAAY,OAAO,CAAC;CAC/F,sBAAsB;CACvB,EAAE;;;;;;;;;;AAWL,MAAa,SACX,QAEA,MAAM,MACJ,MAAM,OAAO,gBAAgB,KAAK,IAAI,CAAC,EACvC,MAAM,OACJ,gBACA,OAAO,IACL,KAAK,IAAI,GACR,OAA8B;CAC7B,WAAW,QACT,EAAE,SAAS;EAAE,GAAG;EAAK,OAAO,IAAI;EAAqB,CAAC;CACxD,mBAAmB,QACjB,EAAE,iBAAiB;EAAE,GAAG;EAAK,OAAO,IAAI;EAAqB,CAAC;CAChE,sBAAsB,EAAE;CACzB,EACF,CACF,CACF"}
|
|
1
|
+
{"version":3,"file":"LyriaGenerator.mjs","names":[],"sources":["../src/LyriaGenerator.ts"],"sourcesContent":["import {\n Context,\n Duration,\n Effect,\n Encoding,\n Layer,\n Match,\n Redacted,\n Result,\n Schema,\n Stream,\n} from \"effect\"\nimport { HttpClient, HttpClientRequest } from \"effect/unstable/http\"\nimport * as AiError from \"@effect-uai/core/AiError\"\nimport type { AudioChunk, AudioFormat } from \"@effect-uai/core/Audio\"\nimport { warnDroppedWhen } from \"@effect-uai/core/Capabilities\"\nimport type {\n CommonGenerateMusicRequest,\n CommonStreamGenerateMusicRequest,\n GenerateResult,\n MusicResult,\n MusicSessionInput,\n MusicStreamEvent,\n} from \"@effect-uai/core/Music\"\nimport { singleVariant } from \"@effect-uai/core/Music\"\nimport { MusicGenerator, type MusicGeneratorService } from \"@effect-uai/core/MusicGenerator\"\nimport type { LyriaModel } from \"./models.js\"\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\n/**\n * Lyria-typed generate request. Narrows `model` to `LyriaModel`.\n *\n * Lyria 3 sync `generateContent` has no structured wire fields for\n * `lyrics` / `duration` / `seed` / `instrumental` / `bpm` / `scale` /\n * etc. Those fields on the Common request are logged as\n * dropped-bucket-2 hints; the adapter never rewrites or augments the\n * caller's prompt on their behalf. If you want lyrics or vocal\n * suppression, include them in your `prompt` text yourself.\n *\n * Output format: only `audio/mp3` and `audio/wav` are accepted; other\n * containers fail `Unsupported`. The Clip model variant is fixed at\n * `audio/mp3`.\n */\nexport type LyriaGenerateRequest = Omit<CommonGenerateMusicRequest, \"model\"> & {\n readonly model: LyriaModel\n}\n\nexport type LyriaGeneratorService = {\n readonly generate: (\n request: LyriaGenerateRequest,\n ) => Effect.Effect<GenerateResult, AiError.AiError>\n readonly streamGeneration: (\n request: LyriaGenerateRequest,\n ) => Stream.Stream<AudioChunk, AiError.AiError>\n readonly streamGenerationFrom: <E, R>(\n input: Stream.Stream<MusicSessionInput, E, R>,\n request: CommonStreamGenerateMusicRequest,\n ) => Stream.Stream<MusicStreamEvent, AiError.AiError | E, R>\n}\n\nexport class LyriaGenerator extends Context.Service<LyriaGenerator, LyriaGeneratorService>()(\n \"@betalyra/effect-uai/providers/google/LyriaGenerator\",\n) {}\n\nexport type Config = {\n readonly apiKey: Redacted.Redacted\n readonly baseUrl?: string\n}\n\n// ---------------------------------------------------------------------------\n// Codec: AudioFormat → Lyria mimeType\n// ---------------------------------------------------------------------------\n\nexport type LyriaResponseMimeType = \"audio/mp3\" | \"audio/wav\"\n\nexport const containerToMimeType: (\n container: AudioFormat[\"container\"],\n) => Effect.Effect<LyriaResponseMimeType, AiError.AiError> = Match.type<\n AudioFormat[\"container\"]\n>().pipe(\n Match.when(\"mp3\", () => Effect.succeed<LyriaResponseMimeType>(\"audio/mp3\")),\n Match.when(\"wav\", () => Effect.succeed<LyriaResponseMimeType>(\"audio/wav\")),\n Match.whenOr(\"ogg\", \"opus\", \"flac\", \"aac\", \"webm\", \"raw\", (c) =>\n Effect.fail(\n new AiError.Unsupported({\n provider: \"lyria\",\n capability: \"outputFormat\",\n reason: `Lyria 3 only produces audio/mp3 or audio/wav; ${c} is not available. Use container: \"mp3\" or \"wav\".`,\n }),\n ),\n ),\n Match.exhaustive,\n)\n\n/**\n * Is this a Lyria 3 Clip model variant? Clip is fixed at 30 s MP3, it\n * does not accept a `responseFormat` on `generationConfig` (the live\n * API rejects unknown fields). Pro accepts the documented\n * `responseFormat` knob.\n */\nconst isClipModel = (model: string): boolean => model.includes(\"clip\")\n\nexport const realizedFormat: (mime: LyriaResponseMimeType) => AudioFormat =\n Match.type<LyriaResponseMimeType>().pipe(\n Match.when(\"audio/mp3\", (): AudioFormat => ({\n container: \"mp3\",\n encoding: \"mp3\",\n sampleRate: 44100,\n channels: 2,\n })),\n Match.when(\"audio/wav\", (): AudioFormat => ({\n container: \"wav\",\n encoding: \"pcm_s16le\",\n sampleRate: 44100,\n channels: 2,\n })),\n Match.exhaustive,\n )\n\n// ---------------------------------------------------------------------------\n// Bucket-2 warn-and-drop for Common fields Lyria 3 can't honor\n// ---------------------------------------------------------------------------\n\n/**\n * Warn (don't fail) when the caller passed Common fields Lyria 3 has\n * no wire field for. Bucket-2 per capabilities policy: provider has\n * no structured interpretation; the output is still valid music, just\n * less aligned with the caller's hint. We never embed these into the\n * prompt on the caller's behalf, prompt construction is the\n * developer's job.\n */\nconst warnDroppedHints = (request: LyriaGenerateRequest): Effect.Effect<void> =>\n Effect.all(\n [\n warnDroppedWhen(request.lyrics, {\n provider: \"lyria\",\n capability: \"lyrics\",\n field: \"lyrics\",\n reason:\n \"Lyria 3 sync has no `lyrics` wire field. If you want vocals to follow specific lyrics, embed them in your prompt yourself (e.g. with `[Verse]` / `[Chorus]` tags).\",\n }),\n warnDroppedWhen(\n request.duration !== undefined ? Duration.toMillis(request.duration) : undefined,\n {\n provider: \"lyria\",\n capability: \"duration\",\n field: \"duration\",\n reason:\n \"Lyria 3 clip is fixed at 30 s; pro derives duration from prompt content. There is no wire field for duration. If you want to steer length, mention it in your prompt.\",\n },\n ),\n warnDroppedWhen(request.seed, {\n provider: \"lyria\",\n capability: \"seed\",\n field: \"seed\",\n reason:\n \"Lyria 3 (Gemini surface) does not expose a seed parameter. Output is non-deterministic across identical prompts. Use Lyria 2 (Vertex) for seeded generation.\",\n }),\n ],\n { discard: true },\n )\n\n// ---------------------------------------------------------------------------\n// Wire response schema\n// ---------------------------------------------------------------------------\n\nconst InlineData = Schema.Struct({\n mimeType: Schema.optional(Schema.String),\n data: Schema.String,\n})\n\nconst Part = Schema.Struct({\n text: Schema.optional(Schema.String),\n inlineData: Schema.optional(InlineData),\n})\n\nconst Content = Schema.Struct({\n parts: Schema.optional(Schema.Array(Part)),\n})\n\nconst Candidate = Schema.Struct({\n content: Schema.optional(Content),\n})\n\nconst Wire = Schema.Struct({\n candidates: Schema.optional(Schema.Array(Candidate)),\n})\n\nconst decodeWire = Schema.decodeUnknownEffect(Wire)\n\n// ---------------------------------------------------------------------------\n// HTTP plumbing\n// ---------------------------------------------------------------------------\n\nconst baseUrl = (cfg: Config): string =>\n cfg.baseUrl ?? \"https://generativelanguage.googleapis.com/v1beta\"\n\nconst transportFailure = (cause: unknown): AiError.AiError =>\n new AiError.Unavailable({ provider: \"lyria\", raw: cause })\n\nconst httpStatusError: (status: number, body: string) => AiError.AiError = (status, body) =>\n Match.value(status).pipe(\n Match.when(\n 429,\n (): AiError.AiError => new AiError.RateLimited({ provider: \"lyria\", raw: body }),\n ),\n Match.whenOr(\n 408,\n 504,\n (): AiError.AiError => new AiError.Timeout({ provider: \"lyria\", raw: body }),\n ),\n Match.when(\n 401,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"auth\", raw: body }),\n ),\n Match.when(\n 403,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"permission\", raw: body }),\n ),\n Match.when(\n 402,\n (): AiError.AiError =>\n new AiError.AuthFailed({ provider: \"lyria\", subtype: \"billing\", raw: body }),\n ),\n Match.when(\n (n) => n >= 500,\n (n): AiError.AiError => new AiError.Unavailable({ provider: \"lyria\", status: n, raw: body }),\n ),\n Match.orElse(\n (): AiError.AiError => new AiError.InvalidRequest({ provider: \"lyria\", raw: body }),\n ),\n )\n\nconst decodeBase64ToBytes = (b64: string): Effect.Effect<Uint8Array, AiError.AiError> =>\n Result.match(Encoding.decodeBase64(b64), {\n onSuccess: Effect.succeed,\n onFailure: (cause) =>\n Effect.fail(new AiError.InvalidRequest({ provider: \"lyria\", param: \"audio\", raw: cause })),\n })\n\n/**\n * Find the first inline-data audio part and the concatenated text parts\n * from a Wire response.\n */\nconst extractParts = (\n wire: typeof Wire.Type,\n): { readonly inline?: typeof InlineData.Type; readonly text?: string } => {\n const allParts = (wire.candidates ?? []).flatMap((c) => c.content?.parts ?? [])\n const inline = allParts.find((p) => p.inlineData !== undefined)?.inlineData\n const textParts = allParts.flatMap((p) => (p.text !== undefined ? [p.text] : []))\n const text = textParts.length === 0 ? undefined : textParts.join(\"\\n\")\n return {\n ...(inline !== undefined && { inline }),\n ...(text !== undefined && { text }),\n }\n}\n\n// ---------------------------------------------------------------------------\n// Service implementation\n// ---------------------------------------------------------------------------\n\nconst generateImpl =\n (cfg: Config) =>\n (\n request: LyriaGenerateRequest,\n ): Effect.Effect<GenerateResult, AiError.AiError, HttpClient.HttpClient> =>\n Effect.gen(function* () {\n const client = yield* HttpClient.HttpClient\n const requestedContainer = (request.outputFormat?.container ??\n \"mp3\") satisfies AudioFormat[\"container\"]\n const requestedMime = yield* containerToMimeType(requestedContainer)\n // lyria-3-clip-preview has no `responseFormat` wire field and always\n // emits mp3, so there is no format to send and no 400 to surface. Rather\n // than keep a per-model table that rejects `wav`, report the format the\n // model actually produces (mp3) so the result is never mislabeled.\n // lyria-3-pro honours the requested container.\n const mimeType = isClipModel(request.model) ? (\"audio/mp3\" as const) : requestedMime\n yield* warnDroppedHints(request)\n const body = isClipModel(request.model)\n ? { contents: [{ parts: [{ text: request.prompt }] }] }\n : {\n contents: [{ parts: [{ text: request.prompt }] }],\n generationConfig: {\n responseModalities: [\"AUDIO\", \"TEXT\"],\n responseFormat: { audio: { mimeType } },\n },\n }\n const httpRequest = HttpClientRequest.post(\n `${baseUrl(cfg)}/models/${request.model}:generateContent`,\n ).pipe(\n HttpClientRequest.setHeader(\"x-goog-api-key\", Redacted.value(cfg.apiKey)),\n HttpClientRequest.bodyJsonUnsafe(body),\n )\n const response = yield* client.execute(httpRequest).pipe(Effect.mapError(transportFailure))\n if (response.status >= 400) {\n const text = yield* response.text.pipe(Effect.orElseSucceed(() => \"\"))\n return yield* httpStatusError(response.status, text)\n }\n const json = yield* response.json.pipe(Effect.mapError(transportFailure))\n const wire = yield* decodeWire(json).pipe(\n Effect.mapError(\n (cause): AiError.AiError =>\n new AiError.GenerationFailed({ provider: \"lyria\", raw: cause }),\n ),\n )\n const { inline, text } = extractParts(wire)\n if (inline === undefined) {\n return yield* new AiError.GenerationFailed({\n provider: \"lyria\",\n raw: {\n message: \"Lyria response had no inlineData audio part.\",\n hint: \"Likely a prompt-filter rejection. Lyria filters references to real artists / copyrighted song lyrics. Rephrase with descriptive style language instead of artist names.\",\n textParts: text,\n response: json,\n },\n })\n }\n const bytes = yield* decodeBase64ToBytes(inline.data)\n const result: MusicResult = {\n audio: { format: realizedFormat(mimeType), bytes },\n provider: \"lyria\",\n ...(text !== undefined && { lyrics: text }),\n watermark: \"synthid\",\n }\n return singleVariant(result)\n })\n\nconst streamGenerationImpl =\n (cfg: Config) =>\n (\n request: LyriaGenerateRequest,\n ): Stream.Stream<AudioChunk, AiError.AiError, HttpClient.HttpClient> =>\n Stream.unwrap(\n Effect.map(generateImpl(cfg)(request), (result) =>\n Stream.succeed<AudioChunk>({ bytes: result.primary.audio.bytes }),\n ),\n )\n\n/**\n * Lyria 3 sync has no bidirectional session at the wire level, that's\n * Lyria RealTime (separate Layer). The provider Layer here also does\n * NOT register `MusicInteractiveSession`, so callers using\n * `MusicGenerator.streamGenerationFrom` against only this Layer get a\n * compile-time error before this runtime fallback ever fires.\n */\nconst streamGenerationFromUnsupported = <E, R>(\n _input: Stream.Stream<MusicSessionInput, E, R>,\n _request: CommonStreamGenerateMusicRequest,\n): Stream.Stream<MusicStreamEvent, AiError.AiError | E, R> => {\n const fail: Stream.Stream<MusicStreamEvent, AiError.AiError | E, R> = Stream.fail(\n new AiError.Unsupported({\n provider: \"lyria\",\n capability: \"streamGenerationFrom\",\n reason:\n \"Lyria 3 sync does not support bidirectional sessions. Use the Lyria RealTime Layer (WebSocket BidiGenerateMusic) for interactive mid-session prompts.\",\n }),\n )\n return fail\n}\n\n// ---------------------------------------------------------------------------\n// Constructors\n// ---------------------------------------------------------------------------\n\nexport const make = (\n cfg: Config,\n): Effect.Effect<LyriaGeneratorService, never, HttpClient.HttpClient> =>\n Effect.map(HttpClient.HttpClient, (client) => ({\n generate: (request) =>\n generateImpl(cfg)(request).pipe(Effect.provideService(HttpClient.HttpClient, client)),\n streamGeneration: (request) =>\n streamGenerationImpl(cfg)(request).pipe(Stream.provideService(HttpClient.HttpClient, client)),\n streamGenerationFrom: streamGenerationFromUnsupported,\n }))\n\n/**\n * Layer that registers both the provider-specific `LyriaGenerator` tag\n * and the generic `MusicGenerator` tag.\n *\n * Does NOT register the `MusicInteractiveSession` capability marker,\n * Lyria 3 sync has no bidirectional session at the wire level. Code\n * calling `MusicGenerator.streamGenerationFrom` will fail to typecheck\n * against this Layer alone, which is the intended UX.\n */\nexport const layer = (\n cfg: Config,\n): Layer.Layer<LyriaGenerator | MusicGenerator, never, HttpClient.HttpClient> =>\n Layer.merge(\n Layer.effect(LyriaGenerator, make(cfg)),\n Layer.effect(\n MusicGenerator,\n Effect.map(make(cfg), (s): MusicGeneratorService => ({\n generate: (req: CommonGenerateMusicRequest) =>\n s.generate({ ...req, model: req.model as LyriaModel }),\n streamGeneration: (req: CommonStreamGenerateMusicRequest) =>\n s.streamGeneration({ ...req, model: req.model as LyriaModel }),\n streamGenerationFrom: s.streamGenerationFrom,\n })),\n ),\n )\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,IAAa,iBAAb,cAAoC,QAAQ,QAA+C,CAAC,CAC1F,sDACF,CAAC,CAAC,CAAC;AAaH,MAAa,sBAEgD,MAAM,KAEjE,CAAC,CAAC,KACF,MAAM,KAAK,aAAa,OAAO,QAA+B,WAAW,CAAC,GAC1E,MAAM,KAAK,aAAa,OAAO,QAA+B,WAAW,CAAC,GAC1E,MAAM,OAAO,OAAO,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,MACzD,OAAO,KACL,IAAI,QAAQ,YAAY;CACtB,UAAU;CACV,YAAY;CACZ,QAAQ,iDAAiD,EAAE;AAC7D,CAAC,CACH,CACF,GACA,MAAM,UACR;;;;;;;AAQA,MAAM,eAAe,UAA2B,MAAM,SAAS,MAAM;AAErE,MAAa,iBACX,MAAM,KAA4B,CAAC,CAAC,KAClC,MAAM,KAAK,oBAAiC;CAC1C,WAAW;CACX,UAAU;CACV,YAAY;CACZ,UAAU;AACZ,EAAE,GACF,MAAM,KAAK,oBAAiC;CAC1C,WAAW;CACX,UAAU;CACV,YAAY;CACZ,UAAU;AACZ,EAAE,GACF,MAAM,UACR;;;;;;;;;AAcF,MAAM,oBAAoB,YACxB,OAAO,IACL;CACE,gBAAgB,QAAQ,QAAQ;EAC9B,UAAU;EACV,YAAY;EACZ,OAAO;EACP,QACE;CACJ,CAAC;CACD,gBACE,QAAQ,aAAa,KAAA,IAAY,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2
|
+
import { n as describe, r as it, t as globalExpect } from "./test.DNmyFkvJ-N3QqMRwZ.mjs";
|
|
2
3
|
import { LyriaGenerator, containerToMimeType, layer, realizedFormat } from "./LyriaGenerator.mjs";
|
|
3
4
|
import { Duration, Effect, Layer, Redacted, Stream } from "effect";
|
|
4
5
|
import { FetchHttpClient } from "effect/unstable/http";
|
|
5
6
|
import { promptsInput } from "@effect-uai/core/Music";
|
|
6
7
|
import * as MusicGenerator$1 from "@effect-uai/core/MusicGenerator";
|
|
8
|
+
//#region ../../../node_modules/.pnpm/vite@7.3.2_@types+node@26.2.0_jiti@2.6.1_lightningcss@1.32.0_tsx@4.23.12_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js
|
|
9
|
+
let SOURCEMAPPING_URL = "sourceMa";
|
|
10
|
+
SOURCEMAPPING_URL += "ppingURL";
|
|
11
|
+
typeof process < "u" && process.platform;
|
|
12
|
+
(async function() {}).constructor;
|
|
13
|
+
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
14
|
+
var intToChar = /* @__PURE__ */ new Uint8Array(64);
|
|
15
|
+
var charToInt = /* @__PURE__ */ new Uint8Array(128);
|
|
16
|
+
for (let i = 0; i < chars.length; i++) {
|
|
17
|
+
let c = chars.charCodeAt(i);
|
|
18
|
+
intToChar[i] = c, charToInt[c] = i;
|
|
19
|
+
}
|
|
20
|
+
`${SOURCEMAPPING_URL}`;
|
|
21
|
+
Error.prepareStackTrace;
|
|
22
|
+
const customizationHookNamespace = "vite-module-runner:import-meta-resolve/v1/";
|
|
23
|
+
`${JSON.stringify(customizationHookNamespace)}${JSON.stringify(customizationHookNamespace)}`;
|
|
24
|
+
new Proxy({}, { get(_, p) {
|
|
25
|
+
throw Error(`[module runner] Dynamic access of "import.meta.env" is not supported. Please, use "import.meta.env.${String(p)}" instead.`);
|
|
26
|
+
} });
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region ../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js
|
|
29
|
+
var require_branding = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
}));
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region ../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js
|
|
34
|
+
var require_messages = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
}));
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region ../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js
|
|
39
|
+
var require_overloads = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
}));
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region ../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js
|
|
44
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
}));
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region ../../../node_modules/.pnpm/vitest@4.1.11_@types+node@26.2.0_vite@7.3.2_@types+node@26.2.0_jiti@2.6.1_lightningcss@1.32.0_tsx@4.23.12_yaml@2.9.0_/node_modules/vitest/dist/index.js
|
|
49
|
+
var import_dist = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
50
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
51
|
+
if (k2 === void 0) k2 = k;
|
|
52
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
53
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function() {
|
|
56
|
+
return m[k];
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(o, k2, desc);
|
|
60
|
+
}) : (function(o, m, k, k2) {
|
|
61
|
+
if (k2 === void 0) k2 = k;
|
|
62
|
+
o[k2] = m[k];
|
|
63
|
+
}));
|
|
64
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports$1) {
|
|
65
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
66
|
+
};
|
|
67
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
68
|
+
exports.expectTypeOf = void 0;
|
|
69
|
+
__exportStar(require_branding(), exports);
|
|
70
|
+
__exportStar(require_messages(), exports);
|
|
71
|
+
__exportStar(require_overloads(), exports);
|
|
72
|
+
__exportStar(require_utils(), exports);
|
|
73
|
+
const fn = () => true;
|
|
74
|
+
/**
|
|
75
|
+
* Similar to Jest's `expect`, but with type-awareness.
|
|
76
|
+
* Gives you access to a number of type-matchers that let you make assertions about the
|
|
77
|
+
* form of a reference or generic type parameter.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { foo, bar } from '../foo'
|
|
82
|
+
* import { expectTypeOf } from 'expect-type'
|
|
83
|
+
*
|
|
84
|
+
* test('foo types', () => {
|
|
85
|
+
* // make sure `foo` has type { a: number }
|
|
86
|
+
* expectTypeOf(foo).toMatchTypeOf({ a: 1 })
|
|
87
|
+
* expectTypeOf(foo).toHaveProperty('a').toBeNumber()
|
|
88
|
+
*
|
|
89
|
+
* // make sure `bar` is a function taking a string:
|
|
90
|
+
* expectTypeOf(bar).parameter(0).toBeString()
|
|
91
|
+
* expectTypeOf(bar).returns.not.toBeAny()
|
|
92
|
+
* })
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @description
|
|
96
|
+
* See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.
|
|
97
|
+
*/
|
|
98
|
+
const expectTypeOf = (_actual) => {
|
|
99
|
+
const nonFunctionProperties = [
|
|
100
|
+
"parameters",
|
|
101
|
+
"returns",
|
|
102
|
+
"resolves",
|
|
103
|
+
"not",
|
|
104
|
+
"items",
|
|
105
|
+
"constructorParameters",
|
|
106
|
+
"thisParameter",
|
|
107
|
+
"instance",
|
|
108
|
+
"guards",
|
|
109
|
+
"asserts",
|
|
110
|
+
"branded"
|
|
111
|
+
];
|
|
112
|
+
const obj = {
|
|
113
|
+
toBeAny: fn,
|
|
114
|
+
toBeUnknown: fn,
|
|
115
|
+
toBeNever: fn,
|
|
116
|
+
toBeFunction: fn,
|
|
117
|
+
toBeObject: fn,
|
|
118
|
+
toBeArray: fn,
|
|
119
|
+
toBeString: fn,
|
|
120
|
+
toBeNumber: fn,
|
|
121
|
+
toBeBoolean: fn,
|
|
122
|
+
toBeVoid: fn,
|
|
123
|
+
toBeSymbol: fn,
|
|
124
|
+
toBeNull: fn,
|
|
125
|
+
toBeUndefined: fn,
|
|
126
|
+
toBeNullable: fn,
|
|
127
|
+
toBeBigInt: fn,
|
|
128
|
+
toMatchTypeOf: fn,
|
|
129
|
+
toEqualTypeOf: fn,
|
|
130
|
+
toBeConstructibleWith: fn,
|
|
131
|
+
toMatchObjectType: fn,
|
|
132
|
+
toExtend: fn,
|
|
133
|
+
map: exports.expectTypeOf,
|
|
134
|
+
toBeCallableWith: exports.expectTypeOf,
|
|
135
|
+
extract: exports.expectTypeOf,
|
|
136
|
+
exclude: exports.expectTypeOf,
|
|
137
|
+
pick: exports.expectTypeOf,
|
|
138
|
+
omit: exports.expectTypeOf,
|
|
139
|
+
toHaveProperty: exports.expectTypeOf,
|
|
140
|
+
parameter: exports.expectTypeOf
|
|
141
|
+
};
|
|
142
|
+
nonFunctionProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));
|
|
143
|
+
return obj;
|
|
144
|
+
};
|
|
145
|
+
exports.expectTypeOf = expectTypeOf;
|
|
146
|
+
})))();
|
|
147
|
+
//#endregion
|
|
7
148
|
//#region src/LyriaGenerator.test.ts
|
|
8
149
|
const cfg = { apiKey: Redacted.make("test-key") };
|
|
9
150
|
const live = Layer.provide(layer(cfg), FetchHttpClient.layer);
|
|
@@ -57,19 +198,22 @@ describe("LyriaGenerator Layer (compile-time)", () => {
|
|
|
57
198
|
model: "lyria-3-clip-preview",
|
|
58
199
|
prompt: ""
|
|
59
200
|
}));
|
|
60
|
-
|
|
201
|
+
const provided = Stream.runDrain(events).pipe(Effect.provide(live));
|
|
202
|
+
(0, import_dist.expectTypeOf)(provided).toEqualTypeOf();
|
|
61
203
|
});
|
|
62
204
|
it("sync `generate` returns GenerateResult and requires no marker", () => {
|
|
63
|
-
|
|
205
|
+
const gen = MusicGenerator$1.generate({
|
|
64
206
|
model: "lyria-3-clip-preview",
|
|
65
207
|
prompt: "ambient"
|
|
66
|
-
}).pipe(Effect.provide(live))
|
|
208
|
+
}).pipe(Effect.provide(live));
|
|
209
|
+
(0, import_dist.expectTypeOf)(gen).toEqualTypeOf();
|
|
67
210
|
});
|
|
68
211
|
it("chunked `streamGeneration` requires no marker", () => {
|
|
69
|
-
|
|
212
|
+
const _stream = Stream.runCollect(MusicGenerator$1.streamGeneration({
|
|
70
213
|
model: "lyria-3-clip-preview",
|
|
71
214
|
prompt: "ambient"
|
|
72
|
-
})).pipe(Effect.provide(live))
|
|
215
|
+
})).pipe(Effect.provide(live));
|
|
216
|
+
globalExpect(_stream).toBeDefined();
|
|
73
217
|
});
|
|
74
218
|
it("Lyria-typed request accepts no `instrumental` field", () => {
|
|
75
219
|
globalExpect({
|
|
@@ -79,11 +223,12 @@ describe("LyriaGenerator Layer (compile-time)", () => {
|
|
|
79
223
|
}).toBeDefined();
|
|
80
224
|
});
|
|
81
225
|
it("Common request supports `duration: Duration.Duration`", () => {
|
|
82
|
-
|
|
226
|
+
const _req = {
|
|
83
227
|
model: "lyria-3-clip-preview",
|
|
84
228
|
prompt: "ambient",
|
|
85
229
|
duration: Duration.seconds(30)
|
|
86
|
-
}
|
|
230
|
+
};
|
|
231
|
+
globalExpect(_req).toBeDefined();
|
|
87
232
|
});
|
|
88
233
|
});
|
|
89
234
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LyriaGenerator.test.mjs","names":["LyriaGenerator.layer","LyriaGenerator.containerToMimeType","LyriaGenerator.realizedFormat","MusicGenerator"],"sources":["../src/LyriaGenerator.test.ts"],"sourcesContent":["import { Duration, Effect, Layer, Redacted, Stream } from \"effect\"\nimport { FetchHttpClient } from \"effect/unstable/http\"\nimport { describe, expect, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"@effect-uai/core/AiError\"\nimport type { GenerateResult } from \"@effect-uai/core/Music\"\nimport { promptsInput } from \"@effect-uai/core/Music\"\nimport * as MusicGenerator from \"@effect-uai/core/MusicGenerator\"\nimport * as LyriaGenerator from \"./LyriaGenerator.js\"\n\nconst cfg: LyriaGenerator.Config = { apiKey: Redacted.make(\"test-key\") }\n// FetchHttpClient is required for `make`, but these tests only exercise the\n// compile-time gating and runtime Unsupported branches, no real HTTP is made.\nconst live = Layer.provide(LyriaGenerator.layer(cfg), FetchHttpClient.layer)\n\ndescribe(\"containerToMimeType\", () => {\n it(\"maps mp3 and wav\", async () => {\n expect(await Effect.runPromise(LyriaGenerator.containerToMimeType(\"mp3\"))).toBe(\"audio/mp3\")\n expect(await Effect.runPromise(LyriaGenerator.containerToMimeType(\"wav\"))).toBe(\"audio/wav\")\n })\n\n it(\"fails Unsupported for ogg / opus / flac / aac / webm / raw\", async () => {\n const exit = await Effect.runPromiseExit(LyriaGenerator.containerToMimeType(\"ogg\"))\n expect(exit._tag).toBe(\"Failure\")\n if (exit._tag === \"Failure\") {\n expect(JSON.stringify(exit.cause)).toContain(\"Unsupported\")\n expect(JSON.stringify(exit.cause)).toContain(\"outputFormat\")\n }\n })\n})\n\ndescribe(\"realizedFormat\", () => {\n it(\"reports 44.1 kHz stereo for both mp3 and wav\", () => {\n expect(LyriaGenerator.realizedFormat(\"audio/mp3\")).toEqual({\n container: \"mp3\",\n encoding: \"mp3\",\n sampleRate: 44100,\n channels: 2,\n })\n expect(LyriaGenerator.realizedFormat(\"audio/wav\")).toEqual({\n container: \"wav\",\n encoding: \"pcm_s16le\",\n sampleRate: 44100,\n channels: 2,\n })\n })\n})\n\ndescribe(\"LyriaGenerator capability guards (runtime)\", () => {\n it(\"streamGenerationFrom returns an Unsupported stream\", async () => {\n const program = LyriaGenerator.LyriaGenerator.use((s) =>\n Stream.runDrain(\n s.streamGenerationFrom(Stream.fromIterable([promptsInput([{ text: \"x\" }])]), {\n model: \"lyria-3-clip-preview\",\n prompt: \"\",\n }),\n ),\n )\n const exit = await Effect.runPromiseExit(program.pipe(Effect.provide(live)))\n expect(exit._tag).toBe(\"Failure\")\n if (exit._tag === \"Failure\") {\n expect(JSON.stringify(exit.cause)).toContain(\"Unsupported\")\n expect(JSON.stringify(exit.cause)).toContain(\"streamGenerationFrom\")\n }\n })\n})\n\ndescribe(\"LyriaGenerator Layer (compile-time)\", () => {\n it(\"leaves `MusicInteractiveSession` unsatisfied when using `streamGenerationFrom` against this Layer\", () => {\n const inputs = Stream.fromIterable([promptsInput([{ text: \"techno\" }])])\n const events = inputs.pipe(\n MusicGenerator.streamGenerationFrom({\n model: \"lyria-3-clip-preview\",\n prompt: \"\",\n }),\n )\n const provided = Stream.runDrain(events).pipe(Effect.provide(live))\n expectTypeOf(provided).toEqualTypeOf<\n Effect.Effect<void, AiError.AiError, MusicGenerator.MusicInteractiveSession>\n >()\n })\n\n it(\"sync `generate` returns GenerateResult and requires no marker\", () => {\n const gen = MusicGenerator.generate({\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n }).pipe(Effect.provide(live))\n expectTypeOf(gen).toEqualTypeOf<Effect.Effect<GenerateResult, AiError.AiError, never>>()\n })\n\n it(\"chunked `streamGeneration` requires no marker\", () => {\n const _stream = Stream.runCollect(\n MusicGenerator.streamGeneration({\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n }),\n ).pipe(Effect.provide(live))\n expect(_stream).toBeDefined()\n })\n\n it(\"Lyria-typed request accepts no `instrumental` field\", () => {\n const _req: LyriaGenerator.LyriaGenerateRequest = {\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n // @ts-expect-error: instrumental was removed from LyriaGenerateRequest in v0.7\n instrumental: true,\n }\n expect(_req).toBeDefined()\n })\n\n it(\"Common request supports `duration: Duration.Duration`\", () => {\n const _req: MusicGenerator.CommonGenerateMusicRequest = {\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n duration: Duration.seconds(30),\n }\n expect(_req).toBeDefined()\n })\n})\n"],"mappings":";;;;;;;AASA,MAAM,MAA6B,EAAE,QAAQ,SAAS,KAAK,WAAW,EAAE;AAGxE,MAAM,OAAO,MAAM,QAAQA,MAAqB,IAAI,EAAE,gBAAgB,MAAM;AAE5E,SAAS,6BAA6B;AACpC,IAAG,oBAAoB,YAAY;AACjC,eAAO,MAAM,OAAO,WAAWC,oBAAmC,MAAM,CAAC,CAAC,CAAC,KAAK,YAAY;AAC5F,eAAO,MAAM,OAAO,WAAWA,oBAAmC,MAAM,CAAC,CAAC,CAAC,KAAK,YAAY;GAC5F;AAEF,IAAG,8DAA8D,YAAY;EAC3E,MAAM,OAAO,MAAM,OAAO,eAAeA,oBAAmC,MAAM,CAAC;AACnF,eAAO,KAAK,KAAK,CAAC,KAAK,UAAU;AACjC,MAAI,KAAK,SAAS,WAAW;AAC3B,gBAAO,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC,UAAU,cAAc;AAC3D,gBAAO,KAAK,UAAU,KAAK,MAAM,CAAC,CAAC,UAAU,eAAe;;GAE9D;EACF;AAEF,SAAS,wBAAwB;AAC/B,IAAG,sDAAsD;AACvD,eAAOC,eAA8B,YAAY,CAAC,CAAC,QAAQ;GACzD,WAAW;GACX,UAAU;GACV,YAAY;GACZ,UAAU;GACX,CAAC;AACF,eAAOA,eAA8B,YAAY,CAA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C,aAAa;GAC7B;AAEF,IAAG,6DAA6D;AAO9D,eAAO;GALL,OAAO;GACP,QAAQ;GAER,cAAc;GAEL,CAAC,CAAC,aAAa;GAC1B;AAEF,IAAG,+DAA+D;AAMhE,eAAO;GAJL,OAAO;GACP,QAAQ;GACR,UAAU,SAAS,QAAQ,GAAG;GAErB,CAAC,CAAC,aAAa;GAC1B;EACF"}
|
|
1
|
+
{"version":3,"file":"LyriaGenerator.test.mjs","names":["exports","LyriaGenerator.layer","LyriaGenerator.containerToMimeType","LyriaGenerator.realizedFormat","MusicGenerator"],"sources":["../../../../node_modules/.pnpm/vite@7.3.2_@types+node@26.2.0_jiti@2.6.1_lightningcss@1.32.0_tsx@4.23.12_yaml@2.9.0/node_modules/vite/dist/node/module-runner.js","../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/branding.js","../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/messages.js","../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/overloads.js","../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/utils.js","../../../../node_modules/.pnpm/expect-type@1.3.0/node_modules/expect-type/dist/index.js","../../../../node_modules/.pnpm/vitest@4.1.11_@types+node@26.2.0_vite@7.3.2_@types+node@26.2.0_jiti@2.6.1_lightningcss@1.32.0_tsx@4.23.12_yaml@2.9.0_/node_modules/vitest/dist/index.js","../src/LyriaGenerator.test.ts"],"sourcesContent":["let SOURCEMAPPING_URL = \"sourceMa\";\nSOURCEMAPPING_URL += \"ppingURL\";\nconst isWindows = typeof process < \"u\" && process.platform === \"win32\";\nfunction unwrapId(id) {\n\treturn id.startsWith(\"/@id/\") ? id.slice(5).replace(\"__x00__\", \"\\0\") : id;\n}\nconst windowsSlashRE = /\\\\/g;\nfunction slash(p) {\n\treturn p.replace(windowsSlashRE, \"/\");\n}\nconst postfixRE = /[?#].*$/;\nfunction cleanUrl(url) {\n\treturn url.replace(postfixRE, \"\");\n}\nfunction isPrimitive(value) {\n\treturn !value || typeof value != \"object\" && typeof value != \"function\";\n}\nconst AsyncFunction = async function() {}.constructor;\nlet asyncFunctionDeclarationPaddingLineCount;\nfunction getAsyncFunctionDeclarationPaddingLineCount() {\n\tif (asyncFunctionDeclarationPaddingLineCount === void 0) {\n\t\tlet body = \"/*code*/\", source = new AsyncFunction(\"a\", \"b\", body).toString();\n\t\tasyncFunctionDeclarationPaddingLineCount = source.slice(0, source.indexOf(body)).split(\"\\n\").length - 1;\n\t}\n\treturn asyncFunctionDeclarationPaddingLineCount;\n}\nfunction promiseWithResolvers() {\n\tlet resolve$1, reject;\n\treturn {\n\t\tpromise: new Promise((_resolve, _reject) => {\n\t\t\tresolve$1 = _resolve, reject = _reject;\n\t\t}),\n\t\tresolve: resolve$1,\n\t\treject\n\t};\n}\nconst _DRIVE_LETTER_START_RE = /^[A-Za-z]:\\//;\nfunction normalizeWindowsPath(input = \"\") {\n\treturn input && input.replace(/\\\\/g, \"/\").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());\n}\nconst _IS_ABSOLUTE_RE = /^[/\\\\](?![/\\\\])|^[/\\\\]{2}(?!\\.)|^[A-Za-z]:[/\\\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;\nfunction cwd() {\n\treturn typeof process < \"u\" && typeof process.cwd == \"function\" ? process.cwd().replace(/\\\\/g, \"/\") : \"/\";\n}\nconst resolve = function(...arguments_) {\n\targuments_ = arguments_.map((argument) => normalizeWindowsPath(argument));\n\tlet resolvedPath = \"\", resolvedAbsolute = !1;\n\tfor (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {\n\t\tlet path = index >= 0 ? arguments_[index] : cwd();\n\t\t!path || path.length === 0 || (resolvedPath = `${path}/${resolvedPath}`, resolvedAbsolute = isAbsolute(path));\n\t}\n\treturn resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute), resolvedAbsolute && !isAbsolute(resolvedPath) ? `/${resolvedPath}` : resolvedPath.length > 0 ? resolvedPath : \".\";\n};\nfunction normalizeString(path, allowAboveRoot) {\n\tlet res = \"\", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;\n\tfor (let index = 0; index <= path.length; ++index) {\n\t\tif (index < path.length) char = path[index];\n\t\telse if (char === \"/\") break;\n\t\telse char = \"/\";\n\t\tif (char === \"/\") {\n\t\t\tif (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {\n\t\t\t\tif (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== \".\" || res[res.length - 2] !== \".\") {\n\t\t\t\t\tif (res.length > 2) {\n\t\t\t\t\t\tlet lastSlashIndex = res.lastIndexOf(\"/\");\n\t\t\t\t\t\tlastSlashIndex === -1 ? (res = \"\", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf(\"/\")), lastSlash = index, dots = 0;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t} else if (res.length > 0) {\n\t\t\t\t\t\tres = \"\", lastSegmentLength = 0, lastSlash = index, dots = 0;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tallowAboveRoot && (res += res.length > 0 ? \"/..\" : \"..\", lastSegmentLength = 2);\n\t\t\t} else res.length > 0 ? res += `/${path.slice(lastSlash + 1, index)}` : res = path.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;\n\t\t\tlastSlash = index, dots = 0;\n\t\t} else char === \".\" && dots !== -1 ? ++dots : dots = -1;\n\t}\n\treturn res;\n}\nconst isAbsolute = function(p) {\n\treturn _IS_ABSOLUTE_RE.test(p);\n}, dirname = function(p) {\n\tlet segments = normalizeWindowsPath(p).replace(/\\/$/, \"\").split(\"/\").slice(0, -1);\n\treturn segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += \"/\"), segments.join(\"/\") || (isAbsolute(p) ? \"/\" : \".\");\n}, decodeBase64 = typeof atob < \"u\" ? atob : (str) => Buffer.from(str, \"base64\").toString(\"utf-8\"), percentRegEx = /%/g, backslashRegEx = /\\\\/g, newlineRegEx = /\\n/g, carriageReturnRegEx = /\\r/g, tabRegEx = /\\t/g, questionRegex = /\\?/g, hashRegex = /#/g;\nfunction encodePathChars(filepath) {\n\treturn filepath.indexOf(\"%\") !== -1 && (filepath = filepath.replace(percentRegEx, \"%25\")), !isWindows && filepath.indexOf(\"\\\\\") !== -1 && (filepath = filepath.replace(backslashRegEx, \"%5C\")), filepath.indexOf(\"\\n\") !== -1 && (filepath = filepath.replace(newlineRegEx, \"%0A\")), filepath.indexOf(\"\\r\") !== -1 && (filepath = filepath.replace(carriageReturnRegEx, \"%0D\")), filepath.indexOf(\"\t\") !== -1 && (filepath = filepath.replace(tabRegEx, \"%09\")), filepath;\n}\nconst posixDirname = dirname, posixResolve = resolve;\nfunction posixPathToFileHref(posixPath) {\n\tlet resolved = posixResolve(posixPath), filePathLast = posixPath.charCodeAt(posixPath.length - 1);\n\treturn (filePathLast === 47 || isWindows && filePathLast === 92) && resolved[resolved.length - 1] !== \"/\" && (resolved += \"/\"), resolved = encodePathChars(resolved), resolved.indexOf(\"?\") !== -1 && (resolved = resolved.replace(questionRegex, \"%3F\")), resolved.indexOf(\"#\") !== -1 && (resolved = resolved.replace(hashRegex, \"%23\")), new URL(`file://${resolved}`).href;\n}\nfunction toWindowsPath(path) {\n\treturn path.replace(/\\//g, \"\\\\\");\n}\nvar comma = 44, chars = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\", intToChar = new Uint8Array(64), charToInt = new Uint8Array(128);\nfor (let i = 0; i < chars.length; i++) {\n\tlet c = chars.charCodeAt(i);\n\tintToChar[i] = c, charToInt[c] = i;\n}\nfunction decodeInteger(reader, relative) {\n\tlet value = 0, shift = 0, integer = 0;\n\tdo\n\t\tinteger = charToInt[reader.next()], value |= (integer & 31) << shift, shift += 5;\n\twhile (integer & 32);\n\tlet shouldNegate = value & 1;\n\treturn value >>>= 1, shouldNegate && (value = -2147483648 | -value), relative + value;\n}\nfunction hasMoreVlq(reader, max) {\n\treturn reader.pos >= max ? !1 : reader.peek() !== comma;\n}\nvar StringReader = class {\n\tconstructor(buffer) {\n\t\tthis.pos = 0, this.buffer = buffer;\n\t}\n\tnext() {\n\t\treturn this.buffer.charCodeAt(this.pos++);\n\t}\n\tpeek() {\n\t\treturn this.buffer.charCodeAt(this.pos);\n\t}\n\tindexOf(char) {\n\t\tlet { buffer, pos } = this, idx = buffer.indexOf(char, pos);\n\t\treturn idx === -1 ? buffer.length : idx;\n\t}\n};\nfunction decode(mappings) {\n\tlet { length } = mappings, reader = new StringReader(mappings), decoded = [], genColumn = 0, sourcesIndex = 0, sourceLine = 0, sourceColumn = 0, namesIndex = 0;\n\tdo {\n\t\tlet semi = reader.indexOf(\";\"), line = [], sorted = !0, lastCol = 0;\n\t\tfor (genColumn = 0; reader.pos < semi;) {\n\t\t\tlet seg;\n\t\t\tgenColumn = decodeInteger(reader, genColumn), genColumn < lastCol && (sorted = !1), lastCol = genColumn, hasMoreVlq(reader, semi) ? (sourcesIndex = decodeInteger(reader, sourcesIndex), sourceLine = decodeInteger(reader, sourceLine), sourceColumn = decodeInteger(reader, sourceColumn), hasMoreVlq(reader, semi) ? (namesIndex = decodeInteger(reader, namesIndex), seg = [\n\t\t\t\tgenColumn,\n\t\t\t\tsourcesIndex,\n\t\t\t\tsourceLine,\n\t\t\t\tsourceColumn,\n\t\t\t\tnamesIndex\n\t\t\t]) : seg = [\n\t\t\t\tgenColumn,\n\t\t\t\tsourcesIndex,\n\t\t\t\tsourceLine,\n\t\t\t\tsourceColumn\n\t\t\t]) : seg = [genColumn], line.push(seg), reader.pos++;\n\t\t}\n\t\tsorted || sort(line), decoded.push(line), reader.pos = semi + 1;\n\t} while (reader.pos <= length);\n\treturn decoded;\n}\nfunction sort(line) {\n\tline.sort(sortComparator);\n}\nfunction sortComparator(a, b) {\n\treturn a[0] - b[0];\n}\nvar COLUMN = 0, SOURCES_INDEX = 1, SOURCE_LINE = 2, SOURCE_COLUMN = 3, NAMES_INDEX = 4, found = !1;\nfunction binarySearch(haystack, needle, low, high) {\n\tfor (; low <= high;) {\n\t\tlet mid = low + (high - low >> 1), cmp = haystack[mid][COLUMN] - needle;\n\t\tif (cmp === 0) return found = !0, mid;\n\t\tcmp < 0 ? low = mid + 1 : high = mid - 1;\n\t}\n\treturn found = !1, low - 1;\n}\nfunction upperBound(haystack, needle, index) {\n\tfor (let i = index + 1; i < haystack.length && haystack[i][COLUMN] === needle; index = i++);\n\treturn index;\n}\nfunction lowerBound(haystack, needle, index) {\n\tfor (let i = index - 1; i >= 0 && haystack[i][COLUMN] === needle; index = i--);\n\treturn index;\n}\nfunction memoizedBinarySearch(haystack, needle, state, key) {\n\tlet { lastKey, lastNeedle, lastIndex } = state, low = 0, high = haystack.length - 1;\n\tif (key === lastKey) {\n\t\tif (needle === lastNeedle) return found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle, lastIndex;\n\t\tneedle >= lastNeedle ? low = lastIndex === -1 ? 0 : lastIndex : high = lastIndex;\n\t}\n\treturn state.lastKey = key, state.lastNeedle = needle, state.lastIndex = binarySearch(haystack, needle, low, high);\n}\nvar LINE_GTR_ZERO = \"`line` must be greater than 0 (lines start at line 1)\", COL_GTR_EQ_ZERO = \"`column` must be greater than or equal to 0 (columns start at column 0)\", LEAST_UPPER_BOUND = -1, GREATEST_LOWER_BOUND = 1;\nfunction cast(map) {\n\treturn map;\n}\nfunction decodedMappings(map) {\n\tvar _a;\n\treturn (_a = cast(map))._decoded || (_a._decoded = decode(cast(map)._encoded));\n}\nfunction originalPositionFor(map, needle) {\n\tlet { line, column, bias } = needle;\n\tif (line--, line < 0) throw Error(LINE_GTR_ZERO);\n\tif (column < 0) throw Error(COL_GTR_EQ_ZERO);\n\tlet decoded = decodedMappings(map);\n\tif (line >= decoded.length) return OMapping(null, null, null, null);\n\tlet segments = decoded[line], index = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);\n\tif (index === -1) return OMapping(null, null, null, null);\n\tlet segment = segments[index];\n\tif (segment.length === 1) return OMapping(null, null, null, null);\n\tlet { names, resolvedSources } = map;\n\treturn OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);\n}\nfunction OMapping(source, line, column, name) {\n\treturn {\n\t\tsource,\n\t\tline,\n\t\tcolumn,\n\t\tname\n\t};\n}\nfunction traceSegmentInternal(segments, memo, line, column, bias) {\n\tlet index = memoizedBinarySearch(segments, column, memo, line);\n\treturn found ? index = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index) : bias === LEAST_UPPER_BOUND && index++, index === -1 || index === segments.length ? -1 : index;\n}\nvar DecodedMap = class {\n\t_encoded;\n\t_decoded;\n\t_decodedMemo;\n\turl;\n\tfile;\n\tversion;\n\tnames = [];\n\tresolvedSources;\n\tconstructor(map, from) {\n\t\tthis.map = map;\n\t\tlet { mappings, names, sources } = map;\n\t\tthis.version = map.version, this.names = names || [], this._encoded = mappings || \"\", this._decodedMemo = memoizedState(), this.url = from, this.file = from;\n\t\tlet originDir = posixDirname(from);\n\t\tthis.resolvedSources = (sources || []).map((s) => posixResolve(originDir, s || \"\"));\n\t}\n};\nfunction memoizedState() {\n\treturn {\n\t\tlastKey: -1,\n\t\tlastNeedle: -1,\n\t\tlastIndex: -1\n\t};\n}\nfunction getOriginalPosition(map, needle) {\n\tlet result = originalPositionFor(map, needle);\n\treturn result.column == null ? null : result;\n}\nconst MODULE_RUNNER_SOURCEMAPPING_REGEXP = /* @__PURE__ */ RegExp(`//# ${SOURCEMAPPING_URL}=data:application/json;base64,(.+)`);\nvar EvaluatedModuleNode = class {\n\timporters = /* @__PURE__ */ new Set();\n\timports = /* @__PURE__ */ new Set();\n\tevaluated = !1;\n\tmeta;\n\tpromise;\n\texports;\n\tfile;\n\tmap;\n\tconstructor(id, url) {\n\t\tthis.id = id, this.url = url, this.file = cleanUrl(id);\n\t}\n}, EvaluatedModules = class {\n\tidToModuleMap = /* @__PURE__ */ new Map();\n\tfileToModulesMap = /* @__PURE__ */ new Map();\n\turlToIdModuleMap = /* @__PURE__ */ new Map();\n\tgetModuleById(id) {\n\t\treturn this.idToModuleMap.get(id);\n\t}\n\tgetModulesByFile(file) {\n\t\treturn this.fileToModulesMap.get(file);\n\t}\n\tgetModuleByUrl(url) {\n\t\treturn this.urlToIdModuleMap.get(unwrapId(url));\n\t}\n\tensureModule(id, url) {\n\t\tif (id = normalizeModuleId(id), this.idToModuleMap.has(id)) {\n\t\t\tlet moduleNode$1 = this.idToModuleMap.get(id);\n\t\t\treturn this.urlToIdModuleMap.set(url, moduleNode$1), moduleNode$1;\n\t\t}\n\t\tlet moduleNode = new EvaluatedModuleNode(id, url);\n\t\tthis.idToModuleMap.set(id, moduleNode), this.urlToIdModuleMap.set(url, moduleNode);\n\t\tlet fileModules = this.fileToModulesMap.get(moduleNode.file) || /* @__PURE__ */ new Set();\n\t\treturn fileModules.add(moduleNode), this.fileToModulesMap.set(moduleNode.file, fileModules), moduleNode;\n\t}\n\tinvalidateModule(node) {\n\t\tnode.evaluated = !1, node.meta = void 0, node.map = void 0, node.promise = void 0, node.exports = void 0, node.imports.clear();\n\t}\n\tgetModuleSourceMapById(id) {\n\t\tlet mod = this.getModuleById(id);\n\t\tif (!mod) return null;\n\t\tif (mod.map) return mod.map;\n\t\tif (!mod.meta || !(\"code\" in mod.meta)) return null;\n\t\tlet pattern = `//# ${SOURCEMAPPING_URL}=data:application/json;base64,`, lastIndex = mod.meta.code.lastIndexOf(pattern);\n\t\tif (lastIndex === -1) return null;\n\t\tlet mapString = MODULE_RUNNER_SOURCEMAPPING_REGEXP.exec(mod.meta.code.slice(lastIndex))?.[1];\n\t\treturn mapString ? (mod.map = new DecodedMap(JSON.parse(decodeBase64(mapString)), mod.file), mod.map) : null;\n\t}\n\tclear() {\n\t\tthis.idToModuleMap.clear(), this.fileToModulesMap.clear(), this.urlToIdModuleMap.clear();\n\t}\n};\nconst prefixedBuiltins = new Set([\n\t\"node:sea\",\n\t\"node:sqlite\",\n\t\"node:test\",\n\t\"node:test/reporters\"\n]);\nfunction normalizeModuleId(file) {\n\treturn prefixedBuiltins.has(file) ? file : slash(file).replace(/^\\/@fs\\//, isWindows ? \"\" : \"/\").replace(/^node:/, \"\").replace(/^\\/+/, \"/\").replace(/^file:\\/+/, isWindows ? \"\" : \"/\");\n}\nvar HMRContext = class {\n\tnewListeners;\n\tconstructor(hmrClient, ownerPath) {\n\t\tthis.hmrClient = hmrClient, this.ownerPath = ownerPath, hmrClient.dataMap.has(ownerPath) || hmrClient.dataMap.set(ownerPath, {});\n\t\tlet mod = hmrClient.hotModulesMap.get(ownerPath);\n\t\tmod && (mod.callbacks = []);\n\t\tlet staleListeners = hmrClient.ctxToListenersMap.get(ownerPath);\n\t\tif (staleListeners) for (let [event, staleFns] of staleListeners) {\n\t\t\tlet listeners = hmrClient.customListenersMap.get(event);\n\t\t\tlisteners && hmrClient.customListenersMap.set(event, listeners.filter((l) => !staleFns.includes(l)));\n\t\t}\n\t\tthis.newListeners = /* @__PURE__ */ new Map(), hmrClient.ctxToListenersMap.set(ownerPath, this.newListeners);\n\t}\n\tget data() {\n\t\treturn this.hmrClient.dataMap.get(this.ownerPath);\n\t}\n\taccept(deps, callback) {\n\t\tif (typeof deps == \"function\" || !deps) this.acceptDeps([this.ownerPath], ([mod]) => deps?.(mod));\n\t\telse if (typeof deps == \"string\") this.acceptDeps([deps], ([mod]) => callback?.(mod));\n\t\telse if (Array.isArray(deps)) this.acceptDeps(deps, callback);\n\t\telse throw Error(\"invalid hot.accept() usage.\");\n\t}\n\tacceptExports(_, callback) {\n\t\tthis.acceptDeps([this.ownerPath], ([mod]) => callback?.(mod));\n\t}\n\tdispose(cb) {\n\t\tthis.hmrClient.disposeMap.set(this.ownerPath, cb);\n\t}\n\tprune(cb) {\n\t\tthis.hmrClient.pruneMap.set(this.ownerPath, cb);\n\t}\n\tdecline() {}\n\tinvalidate(message) {\n\t\tlet firstInvalidatedBy = this.hmrClient.currentFirstInvalidatedBy ?? this.ownerPath;\n\t\tthis.hmrClient.notifyListeners(\"vite:invalidate\", {\n\t\t\tpath: this.ownerPath,\n\t\t\tmessage,\n\t\t\tfirstInvalidatedBy\n\t\t}), this.send(\"vite:invalidate\", {\n\t\t\tpath: this.ownerPath,\n\t\t\tmessage,\n\t\t\tfirstInvalidatedBy\n\t\t}), this.hmrClient.logger.debug(`invalidate ${this.ownerPath}${message ? `: ${message}` : \"\"}`);\n\t}\n\ton(event, cb) {\n\t\tlet addToMap = (map) => {\n\t\t\tlet existing = map.get(event) || [];\n\t\t\texisting.push(cb), map.set(event, existing);\n\t\t};\n\t\taddToMap(this.hmrClient.customListenersMap), addToMap(this.newListeners);\n\t}\n\toff(event, cb) {\n\t\tlet removeFromMap = (map) => {\n\t\t\tlet existing = map.get(event);\n\t\t\tif (existing === void 0) return;\n\t\t\tlet pruned = existing.filter((l) => l !== cb);\n\t\t\tif (pruned.length === 0) {\n\t\t\t\tmap.delete(event);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tmap.set(event, pruned);\n\t\t};\n\t\tremoveFromMap(this.hmrClient.customListenersMap), removeFromMap(this.newListeners);\n\t}\n\tsend(event, data) {\n\t\tthis.hmrClient.send({\n\t\t\ttype: \"custom\",\n\t\t\tevent,\n\t\t\tdata\n\t\t});\n\t}\n\tacceptDeps(deps, callback = () => {}) {\n\t\tlet mod = this.hmrClient.hotModulesMap.get(this.ownerPath) || {\n\t\t\tid: this.ownerPath,\n\t\t\tcallbacks: []\n\t\t};\n\t\tmod.callbacks.push({\n\t\t\tdeps,\n\t\t\tfn: callback\n\t\t}), this.hmrClient.hotModulesMap.set(this.ownerPath, mod);\n\t}\n}, HMRClient = class {\n\thotModulesMap = /* @__PURE__ */ new Map();\n\tdisposeMap = /* @__PURE__ */ new Map();\n\tpruneMap = /* @__PURE__ */ new Map();\n\tdataMap = /* @__PURE__ */ new Map();\n\tcustomListenersMap = /* @__PURE__ */ new Map();\n\tctxToListenersMap = /* @__PURE__ */ new Map();\n\tcurrentFirstInvalidatedBy;\n\tconstructor(logger, transport, importUpdatedModule) {\n\t\tthis.logger = logger, this.transport = transport, this.importUpdatedModule = importUpdatedModule;\n\t}\n\tasync notifyListeners(event, data) {\n\t\tlet cbs = this.customListenersMap.get(event);\n\t\tcbs && await Promise.allSettled(cbs.map((cb) => cb(data)));\n\t}\n\tsend(payload) {\n\t\tthis.transport.send(payload).catch((err) => {\n\t\t\tthis.logger.error(err);\n\t\t});\n\t}\n\tclear() {\n\t\tthis.hotModulesMap.clear(), this.disposeMap.clear(), this.pruneMap.clear(), this.dataMap.clear(), this.customListenersMap.clear(), this.ctxToListenersMap.clear();\n\t}\n\tasync prunePaths(paths) {\n\t\tawait Promise.all(paths.map((path) => {\n\t\t\tlet disposer = this.disposeMap.get(path);\n\t\t\tif (disposer) return disposer(this.dataMap.get(path));\n\t\t})), await Promise.all(paths.map((path) => {\n\t\t\tlet fn = this.pruneMap.get(path);\n\t\t\tif (fn) return fn(this.dataMap.get(path));\n\t\t}));\n\t}\n\twarnFailedUpdate(err, path) {\n\t\t(!(err instanceof Error) || !err.message.includes(\"fetch\")) && this.logger.error(err), this.logger.error(`Failed to reload ${path}. This could be due to syntax errors or importing non-existent modules. (see errors above)`);\n\t}\n\tupdateQueue = [];\n\tpendingUpdateQueue = !1;\n\tasync queueUpdate(payload) {\n\t\tif (this.updateQueue.push(this.fetchUpdate(payload)), !this.pendingUpdateQueue) {\n\t\t\tthis.pendingUpdateQueue = !0, await Promise.resolve(), this.pendingUpdateQueue = !1;\n\t\t\tlet loading = [...this.updateQueue];\n\t\t\tthis.updateQueue = [], (await Promise.all(loading)).forEach((fn) => fn && fn());\n\t\t}\n\t}\n\tasync fetchUpdate(update) {\n\t\tlet { path, acceptedPath, firstInvalidatedBy } = update, mod = this.hotModulesMap.get(path);\n\t\tif (!mod) return;\n\t\tlet fetchedModule, isSelfUpdate = path === acceptedPath, qualifiedCallbacks = mod.callbacks.filter(({ deps }) => deps.includes(acceptedPath));\n\t\tif (isSelfUpdate || qualifiedCallbacks.length > 0) {\n\t\t\tlet disposer = this.disposeMap.get(acceptedPath);\n\t\t\tdisposer && await disposer(this.dataMap.get(acceptedPath));\n\t\t\ttry {\n\t\t\t\tfetchedModule = await this.importUpdatedModule(update);\n\t\t\t} catch (e) {\n\t\t\t\tthis.warnFailedUpdate(e, acceptedPath);\n\t\t\t}\n\t\t}\n\t\treturn () => {\n\t\t\ttry {\n\t\t\t\tthis.currentFirstInvalidatedBy = firstInvalidatedBy;\n\t\t\t\tfor (let { deps, fn } of qualifiedCallbacks) fn(deps.map((dep) => dep === acceptedPath ? fetchedModule : void 0));\n\t\t\t\tlet loggedPath = isSelfUpdate ? path : `${acceptedPath} via ${path}`;\n\t\t\t\tthis.logger.debug(`hot updated: ${loggedPath}`);\n\t\t\t} finally {\n\t\t\t\tthis.currentFirstInvalidatedBy = void 0;\n\t\t\t}\n\t\t};\n\t}\n};\nfunction analyzeImportedModDifference(mod, rawId, moduleType, metadata) {\n\tif (!metadata?.isDynamicImport && metadata?.importedNames?.length) {\n\t\tlet missingBindings = metadata.importedNames.filter((s) => !(s in mod));\n\t\tif (missingBindings.length) {\n\t\t\tlet lastBinding = missingBindings[missingBindings.length - 1];\n\t\t\tthrow moduleType === \"module\" ? SyntaxError(`[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`) : SyntaxError(`\\\n[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from '${rawId}';\nconst {${missingBindings.join(\", \")}} = pkg;\n`);\n\t\t}\n\t}\n}\nlet nanoid = (size = 21) => {\n\tlet id = \"\", i = size | 0;\n\tfor (; i--;) id += \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\"[Math.random() * 64 | 0];\n\treturn id;\n};\nfunction reviveInvokeError(e) {\n\tlet error = Error(e.message || \"Unknown invoke error\");\n\treturn Object.assign(error, e, { runnerError: /* @__PURE__ */ Error(\"RunnerError\") }), error;\n}\nconst createInvokeableTransport = (transport) => {\n\tif (transport.invoke) return {\n\t\t...transport,\n\t\tasync invoke(name, data) {\n\t\t\tlet result = await transport.invoke({\n\t\t\t\ttype: \"custom\",\n\t\t\t\tevent: \"vite:invoke\",\n\t\t\t\tdata: {\n\t\t\t\t\tid: \"send\",\n\t\t\t\t\tname,\n\t\t\t\t\tdata\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (\"error\" in result) throw reviveInvokeError(result.error);\n\t\t\treturn result.result;\n\t\t}\n\t};\n\tif (!transport.send || !transport.connect) throw Error(\"transport must implement send and connect when invoke is not implemented\");\n\tlet rpcPromises = /* @__PURE__ */ new Map();\n\treturn {\n\t\t...transport,\n\t\tconnect({ onMessage, onDisconnection }) {\n\t\t\treturn transport.connect({\n\t\t\t\tonMessage(payload) {\n\t\t\t\t\tif (payload.type === \"custom\" && payload.event === \"vite:invoke\") {\n\t\t\t\t\t\tlet data = payload.data;\n\t\t\t\t\t\tif (data.id.startsWith(\"response:\")) {\n\t\t\t\t\t\t\tlet invokeId = data.id.slice(9), promise = rpcPromises.get(invokeId);\n\t\t\t\t\t\t\tif (!promise) return;\n\t\t\t\t\t\t\tpromise.timeoutId && clearTimeout(promise.timeoutId), rpcPromises.delete(invokeId);\n\t\t\t\t\t\t\tlet { error, result } = data.data;\n\t\t\t\t\t\t\terror ? promise.reject(error) : promise.resolve(result);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tonMessage(payload);\n\t\t\t\t},\n\t\t\t\tonDisconnection\n\t\t\t});\n\t\t},\n\t\tdisconnect() {\n\t\t\treturn rpcPromises.forEach((promise) => {\n\t\t\t\tpromise.reject(/* @__PURE__ */ Error(`transport was disconnected, cannot call ${JSON.stringify(promise.name)}`));\n\t\t\t}), rpcPromises.clear(), transport.disconnect?.();\n\t\t},\n\t\tsend(data) {\n\t\t\treturn transport.send(data);\n\t\t},\n\t\tasync invoke(name, data) {\n\t\t\tlet promiseId = nanoid(), wrappedData = {\n\t\t\t\ttype: \"custom\",\n\t\t\t\tevent: \"vite:invoke\",\n\t\t\t\tdata: {\n\t\t\t\t\tname,\n\t\t\t\t\tid: `send:${promiseId}`,\n\t\t\t\t\tdata\n\t\t\t\t}\n\t\t\t}, sendPromise = transport.send(wrappedData), { promise, resolve: resolve$1, reject } = promiseWithResolvers(), timeout = transport.timeout ?? 6e4, timeoutId;\n\t\t\ttimeout > 0 && (timeoutId = setTimeout(() => {\n\t\t\t\trpcPromises.delete(promiseId), reject(/* @__PURE__ */ Error(`transport invoke timed out after ${timeout}ms (data: ${JSON.stringify(wrappedData)})`));\n\t\t\t}, timeout), timeoutId?.unref?.()), rpcPromises.set(promiseId, {\n\t\t\t\tresolve: resolve$1,\n\t\t\t\treject,\n\t\t\t\tname,\n\t\t\t\ttimeoutId\n\t\t\t}), sendPromise && sendPromise.catch((err) => {\n\t\t\t\tclearTimeout(timeoutId), rpcPromises.delete(promiseId), reject(err);\n\t\t\t});\n\t\t\ttry {\n\t\t\t\treturn await promise;\n\t\t\t} catch (err) {\n\t\t\t\tthrow reviveInvokeError(err);\n\t\t\t}\n\t\t}\n\t};\n}, normalizeModuleRunnerTransport = (transport) => {\n\tlet invokeableTransport = createInvokeableTransport(transport), isConnected = !invokeableTransport.connect, connectingPromise;\n\treturn {\n\t\t...transport,\n\t\t...invokeableTransport.connect ? { async connect(onMessage) {\n\t\t\tif (isConnected) return;\n\t\t\tif (connectingPromise) {\n\t\t\t\tawait connectingPromise;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tlet maybePromise = invokeableTransport.connect({\n\t\t\t\tonMessage: onMessage ?? (() => {}),\n\t\t\t\tonDisconnection() {\n\t\t\t\t\tisConnected = !1;\n\t\t\t\t}\n\t\t\t});\n\t\t\tmaybePromise && (connectingPromise = maybePromise, await connectingPromise, connectingPromise = void 0), isConnected = !0;\n\t\t} } : {},\n\t\t...invokeableTransport.disconnect ? { async disconnect() {\n\t\t\tisConnected && (connectingPromise && await connectingPromise, isConnected = !1, await invokeableTransport.disconnect());\n\t\t} } : {},\n\t\tasync send(data) {\n\t\t\tif (invokeableTransport.send) {\n\t\t\t\tif (!isConnected) if (connectingPromise) await connectingPromise;\n\t\t\t\telse throw Error(\"send was called before connect\");\n\t\t\t\tawait invokeableTransport.send(data);\n\t\t\t}\n\t\t},\n\t\tasync invoke(name, data) {\n\t\t\tif (!isConnected) if (connectingPromise) await connectingPromise;\n\t\t\telse throw Error(\"invoke was called before connect\");\n\t\t\treturn invokeableTransport.invoke(name, data);\n\t\t}\n\t};\n}, createWebSocketModuleRunnerTransport = (options) => {\n\tlet pingInterval = options.pingInterval ?? 3e4, ws, pingIntervalId;\n\treturn {\n\t\tasync connect({ onMessage, onDisconnection }) {\n\t\t\tlet socket = options.createConnection();\n\t\t\tsocket.addEventListener(\"message\", async ({ data }) => {\n\t\t\t\tonMessage(JSON.parse(data));\n\t\t\t});\n\t\t\tlet isOpened = socket.readyState === socket.OPEN;\n\t\t\tisOpened || await new Promise((resolve$1, reject) => {\n\t\t\t\tsocket.addEventListener(\"open\", () => {\n\t\t\t\t\tisOpened = !0, resolve$1();\n\t\t\t\t}, { once: !0 }), socket.addEventListener(\"close\", async () => {\n\t\t\t\t\tif (!isOpened) {\n\t\t\t\t\t\treject(/* @__PURE__ */ Error(\"WebSocket closed without opened.\"));\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tonMessage({\n\t\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\t\tevent: \"vite:ws:disconnect\",\n\t\t\t\t\t\tdata: { webSocket: socket }\n\t\t\t\t\t}), onDisconnection();\n\t\t\t\t});\n\t\t\t}), onMessage({\n\t\t\t\ttype: \"custom\",\n\t\t\t\tevent: \"vite:ws:connect\",\n\t\t\t\tdata: { webSocket: socket }\n\t\t\t}), ws = socket, pingIntervalId = setInterval(() => {\n\t\t\t\tsocket.readyState === socket.OPEN && socket.send(JSON.stringify({ type: \"ping\" }));\n\t\t\t}, pingInterval);\n\t\t},\n\t\tdisconnect() {\n\t\t\tclearInterval(pingIntervalId), ws?.close();\n\t\t},\n\t\tsend(data) {\n\t\t\tws.send(JSON.stringify(data));\n\t\t}\n\t};\n};\nfunction createIsBuiltin(builtins) {\n\tlet plainBuiltinsSet = new Set(builtins.filter((builtin) => typeof builtin == \"string\")), regexBuiltins = builtins.filter((builtin) => typeof builtin != \"string\");\n\treturn (id) => plainBuiltinsSet.has(id) || regexBuiltins.some((regexp) => regexp.test(id));\n}\nconst ssrModuleExportsKey = \"__vite_ssr_exports__\", ssrImportKey = \"__vite_ssr_import__\", ssrDynamicImportKey = \"__vite_ssr_dynamic_import__\", ssrExportAllKey = \"__vite_ssr_exportAll__\", ssrExportNameKey = \"__vite_ssr_exportName__\", ssrImportMetaKey = \"__vite_ssr_import_meta__\", noop = () => {}, silentConsole = {\n\tdebug: noop,\n\terror: noop\n}, hmrLogger = {\n\tdebug: (...msg) => console.log(\"[vite]\", ...msg),\n\terror: (error) => console.log(\"[vite]\", error)\n};\nfunction createHMRHandler(handler) {\n\tlet queue = new Queue();\n\treturn (payload) => queue.enqueue(() => handler(payload));\n}\nvar Queue = class {\n\tqueue = [];\n\tpending = !1;\n\tenqueue(promise) {\n\t\treturn new Promise((resolve$1, reject) => {\n\t\t\tthis.queue.push({\n\t\t\t\tpromise,\n\t\t\t\tresolve: resolve$1,\n\t\t\t\treject\n\t\t\t}), this.dequeue();\n\t\t});\n\t}\n\tdequeue() {\n\t\tif (this.pending) return !1;\n\t\tlet item = this.queue.shift();\n\t\treturn item ? (this.pending = !0, item.promise().then(item.resolve).catch(item.reject).finally(() => {\n\t\t\tthis.pending = !1, this.dequeue();\n\t\t}), !0) : !1;\n\t}\n};\nfunction createHMRHandlerForRunner(runner) {\n\treturn createHMRHandler(async (payload) => {\n\t\tlet hmrClient = runner.hmrClient;\n\t\tif (!(!hmrClient || runner.isClosed())) switch (payload.type) {\n\t\t\tcase \"connected\":\n\t\t\t\thmrClient.logger.debug(\"connected.\");\n\t\t\t\tbreak;\n\t\t\tcase \"update\":\n\t\t\t\tawait hmrClient.notifyListeners(\"vite:beforeUpdate\", payload), await Promise.all(payload.updates.map(async (update) => {\n\t\t\t\t\tif (update.type === \"js-update\") return update.acceptedPath = unwrapId(update.acceptedPath), update.path = unwrapId(update.path), hmrClient.queueUpdate(update);\n\t\t\t\t\thmrClient.logger.error(\"css hmr is not supported in runner mode.\");\n\t\t\t\t})), await hmrClient.notifyListeners(\"vite:afterUpdate\", payload);\n\t\t\t\tbreak;\n\t\t\tcase \"custom\":\n\t\t\t\tawait hmrClient.notifyListeners(payload.event, payload.data);\n\t\t\t\tbreak;\n\t\t\tcase \"full-reload\": {\n\t\t\t\tlet { triggeredBy } = payload, clearEntrypointUrls = triggeredBy ? getModulesEntrypoints(runner, getModulesByFile(runner, slash(triggeredBy))) : findAllEntrypoints(runner);\n\t\t\t\tif (!clearEntrypointUrls.size) break;\n\t\t\t\thmrClient.logger.debug(\"program reload\"), await hmrClient.notifyListeners(\"vite:beforeFullReload\", payload), runner.evaluatedModules.clear();\n\t\t\t\tfor (let url of clearEntrypointUrls) try {\n\t\t\t\t\tawait runner.import(url);\n\t\t\t\t} catch (err) {\n\t\t\t\t\terr.code !== \"ERR_OUTDATED_OPTIMIZED_DEP\" && hmrClient.logger.error(`An error happened during full reload\\n${err.message}\\n${err.stack}`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"prune\":\n\t\t\t\tawait hmrClient.notifyListeners(\"vite:beforePrune\", payload), await hmrClient.prunePaths(payload.paths);\n\t\t\t\tbreak;\n\t\t\tcase \"error\": {\n\t\t\t\tawait hmrClient.notifyListeners(\"vite:error\", payload);\n\t\t\t\tlet err = payload.err;\n\t\t\t\thmrClient.logger.error(`Internal Server Error\\n${err.message}\\n${err.stack}`);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"ping\": break;\n\t\t\tdefault: return payload;\n\t\t}\n\t});\n}\nfunction getModulesByFile(runner, file) {\n\tlet nodes = runner.evaluatedModules.getModulesByFile(file);\n\treturn nodes ? [...nodes].map((node) => node.id) : [];\n}\nfunction getModulesEntrypoints(runner, modules, visited = /* @__PURE__ */ new Set(), entrypoints = /* @__PURE__ */ new Set()) {\n\tfor (let moduleId of modules) {\n\t\tif (visited.has(moduleId)) continue;\n\t\tvisited.add(moduleId);\n\t\tlet module = runner.evaluatedModules.getModuleById(moduleId);\n\t\tif (module) {\n\t\t\tif (!module.importers.size) {\n\t\t\t\tentrypoints.add(module.url);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (let importer of module.importers) getModulesEntrypoints(runner, [importer], visited, entrypoints);\n\t\t}\n\t}\n\treturn entrypoints;\n}\nfunction findAllEntrypoints(runner, entrypoints = /* @__PURE__ */ new Set()) {\n\tfor (let mod of runner.evaluatedModules.idToModuleMap.values()) mod.importers.size || entrypoints.add(mod.url);\n\treturn entrypoints;\n}\nconst sourceMapCache = {}, fileContentsCache = {}, evaluatedModulesCache = /* @__PURE__ */ new Set(), retrieveFileHandlers = /* @__PURE__ */ new Set(), retrieveSourceMapHandlers = /* @__PURE__ */ new Set(), createExecHandlers = (handlers) => ((...args) => {\n\tfor (let handler of handlers) {\n\t\tlet result = handler(...args);\n\t\tif (result) return result;\n\t}\n\treturn null;\n}), retrieveFileFromHandlers = createExecHandlers(retrieveFileHandlers), retrieveSourceMapFromHandlers = createExecHandlers(retrieveSourceMapHandlers);\nlet overridden = !1;\nconst originalPrepare = Error.prepareStackTrace;\nfunction resetInterceptor(runner, options) {\n\tevaluatedModulesCache.delete(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.delete(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.delete(options.retrieveSourceMap), evaluatedModulesCache.size === 0 && (Error.prepareStackTrace = originalPrepare, overridden = !1);\n}\nfunction interceptStackTrace(runner, options = {}) {\n\treturn overridden ||= (Error.prepareStackTrace = prepareStackTrace, !0), evaluatedModulesCache.add(runner.evaluatedModules), options.retrieveFile && retrieveFileHandlers.add(options.retrieveFile), options.retrieveSourceMap && retrieveSourceMapHandlers.add(options.retrieveSourceMap), () => resetInterceptor(runner, options);\n}\nfunction supportRelativeURL(file, url) {\n\tif (!file) return url;\n\tlet dir = posixDirname(slash(file)), match = /^\\w+:\\/\\/[^/]*/.exec(dir), protocol = match ? match[0] : \"\", startPath = dir.slice(protocol.length);\n\treturn protocol && /^\\/\\w:/.test(startPath) ? (protocol += \"/\", protocol + slash(posixResolve(startPath, url))) : protocol + posixResolve(startPath, url);\n}\nfunction getRunnerSourceMap(position) {\n\tfor (let moduleGraph of evaluatedModulesCache) {\n\t\tlet sourceMap = moduleGraph.getModuleSourceMapById(position.source);\n\t\tif (sourceMap) return {\n\t\t\turl: position.source,\n\t\t\tmap: sourceMap,\n\t\t\tvite: !0\n\t\t};\n\t}\n\treturn null;\n}\nfunction retrieveFile(path) {\n\tif (path in fileContentsCache) return fileContentsCache[path];\n\tlet content = retrieveFileFromHandlers(path);\n\treturn typeof content == \"string\" ? (fileContentsCache[path] = content, content) : null;\n}\nfunction retrieveSourceMapURL(source) {\n\tlet fileData = retrieveFile(source);\n\tif (!fileData) return null;\n\tlet re = /\\/\\/[@#]\\s*sourceMappingURL=([^\\s'\"]+)\\s*$|\\/\\*[@#]\\s*sourceMappingURL=[^\\s*'\"]+\\s*\\*\\/\\s*$/gm, lastMatch, match;\n\tfor (; match = re.exec(fileData);) lastMatch = match;\n\treturn lastMatch ? lastMatch[1] : null;\n}\nconst reSourceMap = /^data:application\\/json[^,]+base64,/;\nfunction retrieveSourceMap(source) {\n\tlet urlAndMap = retrieveSourceMapFromHandlers(source);\n\tif (urlAndMap) return urlAndMap;\n\tlet sourceMappingURL = retrieveSourceMapURL(source);\n\tif (!sourceMappingURL) return null;\n\tlet sourceMapData;\n\tif (reSourceMap.test(sourceMappingURL)) {\n\t\tlet rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(\",\") + 1);\n\t\tsourceMapData = Buffer.from(rawData, \"base64\").toString(), sourceMappingURL = source;\n\t} else sourceMappingURL = supportRelativeURL(source, sourceMappingURL), sourceMapData = retrieveFile(sourceMappingURL);\n\treturn sourceMapData ? {\n\t\turl: sourceMappingURL,\n\t\tmap: sourceMapData\n\t} : null;\n}\nfunction mapSourcePosition(position) {\n\tif (!position.source) return position;\n\tlet sourceMap = getRunnerSourceMap(position);\n\tif (sourceMap ||= sourceMapCache[position.source], !sourceMap) {\n\t\tlet urlAndMap = retrieveSourceMap(position.source);\n\t\tif (urlAndMap && urlAndMap.map) {\n\t\t\tlet url = urlAndMap.url;\n\t\t\tsourceMap = sourceMapCache[position.source] = {\n\t\t\t\turl,\n\t\t\t\tmap: new DecodedMap(typeof urlAndMap.map == \"string\" ? JSON.parse(urlAndMap.map) : urlAndMap.map, url)\n\t\t\t};\n\t\t\tlet contents = sourceMap.map?.map.sourcesContent;\n\t\t\tsourceMap.map && contents && sourceMap.map.resolvedSources.forEach((source, i) => {\n\t\t\t\tlet content = contents[i];\n\t\t\t\tif (content && source && url) {\n\t\t\t\t\tlet contentUrl = supportRelativeURL(url, source);\n\t\t\t\t\tfileContentsCache[contentUrl] = content;\n\t\t\t\t}\n\t\t\t});\n\t\t} else sourceMap = sourceMapCache[position.source] = {\n\t\t\turl: null,\n\t\t\tmap: null\n\t\t};\n\t}\n\tif (sourceMap.map && sourceMap.url) {\n\t\tlet originalPosition = getOriginalPosition(sourceMap.map, position);\n\t\tif (originalPosition && originalPosition.source != null) return originalPosition.source = supportRelativeURL(sourceMap.url, originalPosition.source), sourceMap.vite && (originalPosition._vite = !0), originalPosition;\n\t}\n\treturn position;\n}\nfunction mapEvalOrigin(origin) {\n\tlet match = /^eval at ([^(]+) \\((.+):(\\d+):(\\d+)\\)$/.exec(origin);\n\tif (match) {\n\t\tlet position = mapSourcePosition({\n\t\t\tname: null,\n\t\t\tsource: match[2],\n\t\t\tline: +match[3],\n\t\t\tcolumn: match[4] - 1\n\t\t});\n\t\treturn `eval at ${match[1]} (${position.source}:${position.line}:${position.column + 1})`;\n\t}\n\treturn match = /^eval at ([^(]+) \\((.+)\\)$/.exec(origin), match ? `eval at ${match[1]} (${mapEvalOrigin(match[2])})` : origin;\n}\nfunction CallSiteToString() {\n\tlet fileName, fileLocation = \"\";\n\tif (this.isNative()) fileLocation = \"native\";\n\telse {\n\t\tfileName = this.getScriptNameOrSourceURL(), !fileName && this.isEval() && (fileLocation = this.getEvalOrigin(), fileLocation += \", \"), fileName ? fileLocation += fileName : fileLocation += \"<anonymous>\";\n\t\tlet lineNumber = this.getLineNumber();\n\t\tif (lineNumber != null) {\n\t\t\tfileLocation += `:${lineNumber}`;\n\t\t\tlet columnNumber = this.getColumnNumber();\n\t\t\tcolumnNumber && (fileLocation += `:${columnNumber}`);\n\t\t}\n\t}\n\tlet line = \"\", functionName = this.getFunctionName(), addSuffix = !0, isConstructor = this.isConstructor();\n\tif (this.isToplevel() || isConstructor) isConstructor ? line += `new ${functionName || \"<anonymous>\"}` : functionName ? line += functionName : (line += fileLocation, addSuffix = !1);\n\telse {\n\t\tlet typeName = this.getTypeName();\n\t\ttypeName === \"[object Object]\" && (typeName = \"null\");\n\t\tlet methodName = this.getMethodName();\n\t\tfunctionName ? (typeName && functionName.indexOf(typeName) !== 0 && (line += `${typeName}.`), line += functionName, methodName && functionName.indexOf(`.${methodName}`) !== functionName.length - methodName.length - 1 && (line += ` [as ${methodName}]`)) : line += `${typeName}.${methodName || \"<anonymous>\"}`;\n\t}\n\treturn addSuffix && (line += ` (${fileLocation})`), line;\n}\nfunction cloneCallSite(frame) {\n\tlet object = {};\n\treturn Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach((name) => {\n\t\tlet key = name;\n\t\tobject[key] = /^(?:is|get)/.test(name) ? function() {\n\t\t\treturn frame[key].call(frame);\n\t\t} : frame[key];\n\t}), object.toString = CallSiteToString, object;\n}\nfunction wrapCallSite(frame, state) {\n\tif (state === void 0 && (state = {\n\t\tnextPosition: null,\n\t\tcurPosition: null\n\t}), frame.isNative()) return state.curPosition = null, frame;\n\tlet source = frame.getFileName() || frame.getScriptNameOrSourceURL();\n\tif (source) {\n\t\tlet line = frame.getLineNumber(), column = frame.getColumnNumber() - 1;\n\t\tline === 1 && column > 62 && !frame.isEval() && (column -= 62);\n\t\tlet position = mapSourcePosition({\n\t\t\tname: null,\n\t\t\tsource,\n\t\t\tline,\n\t\t\tcolumn\n\t\t});\n\t\tstate.curPosition = position, frame = cloneCallSite(frame);\n\t\tlet originalFunctionName = frame.getFunctionName;\n\t\treturn frame.getFunctionName = function() {\n\t\t\tlet name = (() => state.nextPosition == null ? originalFunctionName() : state.nextPosition.name || originalFunctionName())();\n\t\t\treturn name === \"eval\" && \"_vite\" in position ? null : name;\n\t\t}, frame.getFileName = function() {\n\t\t\treturn position.source ?? null;\n\t\t}, frame.getLineNumber = function() {\n\t\t\treturn position.line;\n\t\t}, frame.getColumnNumber = function() {\n\t\t\treturn position.column + 1;\n\t\t}, frame.getScriptNameOrSourceURL = function() {\n\t\t\treturn position.source;\n\t\t}, frame;\n\t}\n\tlet origin = frame.isEval() && frame.getEvalOrigin();\n\treturn origin ? (origin = mapEvalOrigin(origin), frame = cloneCallSite(frame), frame.getEvalOrigin = function() {\n\t\treturn origin || void 0;\n\t}, frame) : frame;\n}\nfunction prepareStackTrace(error, stack) {\n\tlet errorString = `${error.name || \"Error\"}: ${error.message || \"\"}`, state = {\n\t\tnextPosition: null,\n\t\tcurPosition: null\n\t}, processedStack = [];\n\tfor (let i = stack.length - 1; i >= 0; i--) processedStack.push(`\\n at ${wrapCallSite(stack[i], state)}`), state.nextPosition = state.curPosition;\n\treturn state.curPosition = state.nextPosition = null, errorString + processedStack.reverse().join(\"\");\n}\nfunction enableSourceMapSupport(runner) {\n\tif (runner.options.sourcemapInterceptor === \"node\") {\n\t\tif (typeof process > \"u\") throw TypeError(\"Cannot use \\\"sourcemapInterceptor: 'node'\\\" because global \\\"process\\\" variable is not available.\");\n\t\tif (typeof process.setSourceMapsEnabled != \"function\") throw TypeError(\"Cannot use \\\"sourcemapInterceptor: 'node'\\\" because \\\"process.setSourceMapsEnabled\\\" function is not available. Please use Node >= 16.6.0.\");\n\t\tlet isEnabledAlready = process.sourceMapsEnabled ?? !1;\n\t\treturn process.setSourceMapsEnabled(!0), () => !isEnabledAlready && process.setSourceMapsEnabled(!1);\n\t}\n\treturn interceptStackTrace(runner, typeof runner.options.sourcemapInterceptor == \"object\" ? runner.options.sourcemapInterceptor : void 0);\n}\nvar ESModulesEvaluator = class {\n\tstartOffset = getAsyncFunctionDeclarationPaddingLineCount();\n\tasync runInlinedModule(context, code) {\n\t\tawait new AsyncFunction(ssrModuleExportsKey, ssrImportMetaKey, ssrImportKey, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, \"\\\"use strict\\\";\" + code)(context[ssrModuleExportsKey], context[ssrImportMetaKey], context[ssrImportKey], context[ssrDynamicImportKey], context[ssrExportAllKey], context[ssrExportNameKey]), Object.seal(context[ssrModuleExportsKey]);\n\t}\n\trunExternalModule(filepath) {\n\t\treturn import(filepath);\n\t}\n};\nconst customizationHookNamespace = \"vite-module-runner:import-meta-resolve/v1/\", customizationHooksModule = `\n\nexport async function resolve(specifier, context, nextResolve) {\n if (specifier.startsWith(${JSON.stringify(customizationHookNamespace)})) {\n const data = specifier.slice(${JSON.stringify(customizationHookNamespace)}.length)\n const [parsedSpecifier, parsedImporter] = JSON.parse(data)\n specifier = parsedSpecifier\n context.parentURL = parsedImporter\n }\n return nextResolve(specifier, context)\n}\n\n`;\nfunction customizationHookResolve(specifier, context, nextResolve) {\n\tif (specifier.startsWith(customizationHookNamespace)) {\n\t\tlet data = specifier.slice(42), [parsedSpecifier, parsedImporter] = JSON.parse(data);\n\t\tspecifier = parsedSpecifier, context.parentURL = parsedImporter;\n\t}\n\treturn nextResolve(specifier, context);\n}\nasync function createImportMetaResolver() {\n\tlet module;\n\ttry {\n\t\tmodule = (await import(\"node:module\")).Module;\n\t} catch {\n\t\treturn;\n\t}\n\tif (module) {\n\t\tif (module.registerHooks) return module.registerHooks({ resolve: customizationHookResolve }), importMetaResolveWithCustomHook;\n\t\tif (module.register) {\n\t\t\ttry {\n\t\t\t\tlet hookModuleContent = `data:text/javascript,${encodeURI(customizationHooksModule)}`;\n\t\t\t\tmodule.register(hookModuleContent);\n\t\t\t} catch (e) {\n\t\t\t\tif (\"code\" in e && e.code === \"ERR_NETWORK_IMPORT_DISALLOWED\") return;\n\t\t\t\tthrow e;\n\t\t\t}\n\t\t\treturn importMetaResolveWithCustomHook;\n\t\t}\n\t}\n}\nfunction importMetaResolveWithCustomHook(specifier, importer) {\n\treturn import.meta.resolve(`${customizationHookNamespace}${JSON.stringify([specifier, importer])}`);\n}\n`${customizationHookNamespace}`;\nconst envProxy = new Proxy({}, { get(_, p) {\n\tthrow Error(`[module runner] Dynamic access of \"import.meta.env\" is not supported. Please, use \"import.meta.env.${String(p)}\" instead.`);\n} });\nfunction createDefaultImportMeta(modulePath) {\n\tlet href = posixPathToFileHref(modulePath), filename = modulePath, dirname$1 = posixDirname(modulePath);\n\treturn {\n\t\tfilename: isWindows ? toWindowsPath(filename) : filename,\n\t\tdirname: isWindows ? toWindowsPath(dirname$1) : dirname$1,\n\t\turl: href,\n\t\tenv: envProxy,\n\t\tresolve(_id, _parent) {\n\t\t\tthrow Error(\"[module runner] \\\"import.meta.resolve\\\" is not supported.\");\n\t\t},\n\t\tglob() {\n\t\t\tthrow Error(\"[module runner] \\\"import.meta.glob\\\" is statically replaced during file transformation. Make sure to reference it by the full name.\");\n\t\t}\n\t};\n}\nlet importMetaResolverCache;\nasync function createNodeImportMeta(modulePath) {\n\tlet defaultMeta = createDefaultImportMeta(modulePath), href = defaultMeta.url;\n\timportMetaResolverCache ??= createImportMetaResolver();\n\tlet importMetaResolver = await importMetaResolverCache;\n\treturn {\n\t\t...defaultMeta,\n\t\tmain: !1,\n\t\tresolve(id, parent) {\n\t\t\treturn (importMetaResolver ?? defaultMeta.resolve)(id, parent ?? href);\n\t\t}\n\t};\n}\nvar ModuleRunner = class {\n\tevaluatedModules;\n\thmrClient;\n\ttransport;\n\tresetSourceMapSupport;\n\tconcurrentModuleNodePromises = /* @__PURE__ */ new Map();\n\tisBuiltin;\n\tbuiltinsPromise;\n\tclosed = !1;\n\tconstructor(options, evaluator = new ESModulesEvaluator(), debug) {\n\t\tif (this.options = options, this.evaluator = evaluator, this.debug = debug, this.evaluatedModules = options.evaluatedModules ?? new EvaluatedModules(), this.transport = normalizeModuleRunnerTransport(options.transport), options.hmr !== !1) {\n\t\t\tlet optionsHmr = options.hmr ?? !0;\n\t\t\tif (this.hmrClient = new HMRClient(optionsHmr === !0 || optionsHmr.logger === void 0 ? hmrLogger : optionsHmr.logger === !1 ? silentConsole : optionsHmr.logger, this.transport, ({ acceptedPath }) => this.import(acceptedPath)), !this.transport.connect) throw Error(\"HMR is not supported by this runner transport, but `hmr` option was set to true\");\n\t\t\tthis.transport.connect(createHMRHandlerForRunner(this));\n\t\t} else this.transport.connect?.();\n\t\toptions.sourcemapInterceptor !== !1 && (this.resetSourceMapSupport = enableSourceMapSupport(this));\n\t}\n\tasync import(url) {\n\t\tlet fetchedModule = await this.cachedModule(url);\n\t\treturn await this.cachedRequest(url, fetchedModule);\n\t}\n\tclearCache() {\n\t\tthis.evaluatedModules.clear(), this.hmrClient?.clear();\n\t}\n\tasync close() {\n\t\tthis.resetSourceMapSupport?.(), this.clearCache(), this.hmrClient = void 0, this.closed = !0, await this.transport.disconnect?.();\n\t}\n\tisClosed() {\n\t\treturn this.closed;\n\t}\n\tprocessImport(exports, fetchResult, metadata) {\n\t\tif (!(\"externalize\" in fetchResult)) return exports;\n\t\tlet { url, type } = fetchResult;\n\t\treturn type !== \"module\" && type !== \"commonjs\" || analyzeImportedModDifference(exports, url, type, metadata), exports;\n\t}\n\tisCircularModule(mod) {\n\t\tfor (let importedFile of mod.imports) if (mod.importers.has(importedFile)) return !0;\n\t\treturn !1;\n\t}\n\tisCircularImport(importers, moduleUrl, visited = /* @__PURE__ */ new Set()) {\n\t\tfor (let importer of importers) {\n\t\t\tif (visited.has(importer)) continue;\n\t\t\tif (visited.add(importer), importer === moduleUrl) return !0;\n\t\t\tlet mod = this.evaluatedModules.getModuleById(importer);\n\t\t\tif (mod && mod.importers.size && this.isCircularImport(mod.importers, moduleUrl, visited)) return !0;\n\t\t}\n\t\treturn !1;\n\t}\n\tasync cachedRequest(url, mod, callstack = [], metadata) {\n\t\tlet meta = mod.meta, moduleId = meta.id, { importers } = mod, importee = callstack[callstack.length - 1];\n\t\tif (importee && importers.add(importee), (callstack.includes(moduleId) || this.isCircularModule(mod) || this.isCircularImport(importers, moduleId)) && mod.exports) return this.processImport(mod.exports, meta, metadata);\n\t\tlet debugTimer;\n\t\tthis.debug && (debugTimer = setTimeout(() => {\n\t\t\tthis.debug(`[module runner] module ${moduleId} takes over 2s to load.\\n${(() => `stack:\\n${[...callstack, moduleId].reverse().map((p) => ` - ${p}`).join(\"\\n\")}`)()}`);\n\t\t}, 2e3));\n\t\ttry {\n\t\t\tif (mod.promise) return this.processImport(await mod.promise, meta, metadata);\n\t\t\tlet promise = this.directRequest(url, mod, callstack);\n\t\t\treturn mod.promise = promise, mod.evaluated = !1, this.processImport(await promise, meta, metadata);\n\t\t} finally {\n\t\t\tmod.evaluated = !0, debugTimer && clearTimeout(debugTimer);\n\t\t}\n\t}\n\tasync cachedModule(url, importer) {\n\t\tlet cached = this.concurrentModuleNodePromises.get(url);\n\t\tif (cached) this.debug?.(\"[module runner] using cached module info for\", url);\n\t\telse {\n\t\t\tlet cachedModule = this.evaluatedModules.getModuleByUrl(url);\n\t\t\tcached = this.getModuleInformation(url, importer, cachedModule).finally(() => {\n\t\t\t\tthis.concurrentModuleNodePromises.delete(url);\n\t\t\t}), this.concurrentModuleNodePromises.set(url, cached);\n\t\t}\n\t\treturn cached;\n\t}\n\tensureBuiltins() {\n\t\tif (!this.isBuiltin) return this.builtinsPromise ??= (async () => {\n\t\t\ttry {\n\t\t\t\tthis.debug?.(\"[module runner] fetching builtins from server\");\n\t\t\t\tlet builtins = (await this.transport.invoke(\"getBuiltins\", [])).map((builtin) => typeof builtin == \"object\" && builtin && \"type\" in builtin ? builtin.type === \"string\" ? builtin.value : new RegExp(builtin.source, builtin.flags) : builtin);\n\t\t\t\tthis.isBuiltin = createIsBuiltin(builtins), this.debug?.(\"[module runner] builtins loaded:\", builtins);\n\t\t\t} finally {\n\t\t\t\tthis.builtinsPromise = void 0;\n\t\t\t}\n\t\t})(), this.builtinsPromise;\n\t}\n\tasync getModuleInformation(url, importer, cachedModule) {\n\t\tif (this.closed) throw Error(\"Vite module runner has been closed.\");\n\t\tawait this.ensureBuiltins(), this.debug?.(\"[module runner] fetching\", url);\n\t\tlet isCached = !!(typeof cachedModule == \"object\" && cachedModule.meta), fetchedModule = url.startsWith(\"data:\") || this.isBuiltin?.(url) ? {\n\t\t\texternalize: url,\n\t\t\ttype: \"builtin\"\n\t\t} : await this.transport.invoke(\"fetchModule\", [\n\t\t\turl,\n\t\t\timporter,\n\t\t\t{\n\t\t\t\tcached: isCached,\n\t\t\t\tstartOffset: this.evaluator.startOffset\n\t\t\t}\n\t\t]);\n\t\tif (\"cache\" in fetchedModule) {\n\t\t\tif (!cachedModule || !cachedModule.meta) throw Error(`Module \"${url}\" was mistakenly invalidated during fetch phase.`);\n\t\t\treturn cachedModule;\n\t\t}\n\t\tlet moduleId = \"externalize\" in fetchedModule ? fetchedModule.externalize : fetchedModule.id, moduleUrl = \"url\" in fetchedModule ? fetchedModule.url : url, module = this.evaluatedModules.ensureModule(moduleId, moduleUrl);\n\t\treturn \"invalidate\" in fetchedModule && fetchedModule.invalidate && this.evaluatedModules.invalidateModule(module), fetchedModule.url = moduleUrl, fetchedModule.id = moduleId, module.meta = fetchedModule, module;\n\t}\n\tasync directRequest(url, mod, _callstack) {\n\t\tlet fetchResult = mod.meta, moduleId = fetchResult.id, callstack = [..._callstack, moduleId], request = async (dep, metadata) => {\n\t\t\tlet importer = \"file\" in fetchResult && fetchResult.file || moduleId, depMod = await this.cachedModule(dep, importer);\n\t\t\treturn depMod.importers.add(moduleId), mod.imports.add(depMod.id), this.cachedRequest(dep, depMod, callstack, metadata);\n\t\t}, dynamicRequest = async (dep) => (dep = String(dep), dep[0] === \".\" && (dep = posixResolve(posixDirname(url), dep)), request(dep, { isDynamicImport: !0 }));\n\t\tif (\"externalize\" in fetchResult) {\n\t\t\tlet { externalize } = fetchResult;\n\t\t\tthis.debug?.(\"[module runner] externalizing\", externalize);\n\t\t\tlet exports$1 = await this.evaluator.runExternalModule(externalize);\n\t\t\treturn mod.exports = exports$1, exports$1;\n\t\t}\n\t\tlet { code, file } = fetchResult;\n\t\tif (code == null) {\n\t\t\tlet importer = callstack[callstack.length - 2];\n\t\t\tthrow Error(`[module runner] Failed to load \"${url}\"${importer ? ` imported from ${importer}` : \"\"}`);\n\t\t}\n\t\tlet createImportMeta = this.options.createImportMeta ?? createDefaultImportMeta, modulePath = cleanUrl(file || moduleId), href = posixPathToFileHref(modulePath), meta = await createImportMeta(modulePath), exports = Object.create(null);\n\t\tObject.defineProperty(exports, Symbol.toStringTag, {\n\t\t\tvalue: \"Module\",\n\t\t\tenumerable: !1,\n\t\t\tconfigurable: !1\n\t\t}), mod.exports = exports;\n\t\tlet hotContext;\n\t\tthis.hmrClient && Object.defineProperty(meta, \"hot\", {\n\t\t\tenumerable: !0,\n\t\t\tget: () => {\n\t\t\t\tif (!this.hmrClient) throw Error(\"[module runner] HMR client was closed.\");\n\t\t\t\treturn this.debug?.(\"[module runner] creating hmr context for\", mod.url), hotContext ||= new HMRContext(this.hmrClient, mod.url), hotContext;\n\t\t\t},\n\t\t\tset: (value) => {\n\t\t\t\thotContext = value;\n\t\t\t}\n\t\t});\n\t\tlet context = {\n\t\t\t[ssrImportKey]: request,\n\t\t\t[ssrDynamicImportKey]: dynamicRequest,\n\t\t\t[ssrModuleExportsKey]: exports,\n\t\t\t[ssrExportAllKey]: (obj) => exportAll(exports, obj),\n\t\t\t[ssrExportNameKey]: (name, getter) => Object.defineProperty(exports, name, {\n\t\t\t\tenumerable: !0,\n\t\t\t\tconfigurable: !0,\n\t\t\t\tget: getter\n\t\t\t}),\n\t\t\t[ssrImportMetaKey]: meta\n\t\t};\n\t\treturn this.debug?.(\"[module runner] executing\", href), await this.evaluator.runInlinedModule(context, code, mod), exports;\n\t}\n};\nfunction exportAll(exports, sourceModule) {\n\tif (exports !== sourceModule && !(isPrimitive(sourceModule) || Array.isArray(sourceModule) || sourceModule instanceof Promise)) {\n\t\tfor (let key in sourceModule) if (key !== \"default\" && key !== \"__esModule\" && !(key in exports)) try {\n\t\t\tObject.defineProperty(exports, key, {\n\t\t\t\tenumerable: !0,\n\t\t\t\tconfigurable: !0,\n\t\t\t\tget: () => sourceModule[key]\n\t\t\t});\n\t\t} catch {}\n\t}\n}\nexport { ESModulesEvaluator, EvaluatedModules, ModuleRunner, createDefaultImportMeta, createNodeImportMeta, createWebSocketModuleRunnerTransport, normalizeModuleId, ssrDynamicImportKey, ssrExportAllKey, ssrExportNameKey, ssrImportKey, ssrImportMetaKey, ssrModuleExportsKey };\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @internal\n */\nconst inverted = Symbol('inverted');\n/**\n * @internal\n */\nconst expectNull = Symbol('expectNull');\n/**\n * @internal\n */\nconst expectUndefined = Symbol('expectUndefined');\n/**\n * @internal\n */\nconst expectNumber = Symbol('expectNumber');\n/**\n * @internal\n */\nconst expectString = Symbol('expectString');\n/**\n * @internal\n */\nconst expectBoolean = Symbol('expectBoolean');\n/**\n * @internal\n */\nconst expectVoid = Symbol('expectVoid');\n/**\n * @internal\n */\nconst expectFunction = Symbol('expectFunction');\n/**\n * @internal\n */\nconst expectObject = Symbol('expectObject');\n/**\n * @internal\n */\nconst expectArray = Symbol('expectArray');\n/**\n * @internal\n */\nconst expectSymbol = Symbol('expectSymbol');\n/**\n * @internal\n */\nconst expectAny = Symbol('expectAny');\n/**\n * @internal\n */\nconst expectUnknown = Symbol('expectUnknown');\n/**\n * @internal\n */\nconst expectNever = Symbol('expectNever');\n/**\n * @internal\n */\nconst expectNullable = Symbol('expectNullable');\n/**\n * @internal\n */\nconst expectBigInt = Symbol('expectBigInt');\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\n/**\n * @internal\n */\nconst secret = Symbol('secret');\n/**\n * @internal\n */\nconst mismatch = Symbol('mismatch');\n/**\n * A type which should match anything passed as a value but *doesn't*\n * match {@linkcode Mismatch}. It helps TypeScript select the right overload\n * for {@linkcode PositiveExpectTypeOf.toEqualTypeOf | .toEqualTypeOf()} and\n * {@linkcode PositiveExpectTypeOf.toMatchTypeOf | .toMatchTypeOf()}.\n *\n * @internal\n */\nconst avalue = Symbol('avalue');\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.expectTypeOf = void 0;\n__exportStar(require(\"./branding\"), exports); // backcompat, consider removing in next major version\n__exportStar(require(\"./messages\"), exports); // backcompat, consider removing in next major version\n__exportStar(require(\"./overloads\"), exports);\n__exportStar(require(\"./utils\"), exports); // backcompat, consider removing in next major version\nconst fn = () => true;\n/**\n * Similar to Jest's `expect`, but with type-awareness.\n * Gives you access to a number of type-matchers that let you make assertions about the\n * form of a reference or generic type parameter.\n *\n * @example\n * ```ts\n * import { foo, bar } from '../foo'\n * import { expectTypeOf } from 'expect-type'\n *\n * test('foo types', () => {\n * // make sure `foo` has type { a: number }\n * expectTypeOf(foo).toMatchTypeOf({ a: 1 })\n * expectTypeOf(foo).toHaveProperty('a').toBeNumber()\n *\n * // make sure `bar` is a function taking a string:\n * expectTypeOf(bar).parameter(0).toBeString()\n * expectTypeOf(bar).returns.not.toBeAny()\n * })\n * ```\n *\n * @description\n * See the [full docs](https://npmjs.com/package/expect-type#documentation) for lots more examples.\n */\nconst expectTypeOf = (_actual) => {\n const nonFunctionProperties = [\n 'parameters',\n 'returns',\n 'resolves',\n 'not',\n 'items',\n 'constructorParameters',\n 'thisParameter',\n 'instance',\n 'guards',\n 'asserts',\n 'branded',\n ];\n const obj = {\n /* eslint-disable @typescript-eslint/no-unsafe-assignment */\n toBeAny: fn,\n toBeUnknown: fn,\n toBeNever: fn,\n toBeFunction: fn,\n toBeObject: fn,\n toBeArray: fn,\n toBeString: fn,\n toBeNumber: fn,\n toBeBoolean: fn,\n toBeVoid: fn,\n toBeSymbol: fn,\n toBeNull: fn,\n toBeUndefined: fn,\n toBeNullable: fn,\n toBeBigInt: fn,\n toMatchTypeOf: fn,\n toEqualTypeOf: fn,\n toBeConstructibleWith: fn,\n toMatchObjectType: fn,\n toExtend: fn,\n map: exports.expectTypeOf,\n toBeCallableWith: exports.expectTypeOf,\n extract: exports.expectTypeOf,\n exclude: exports.expectTypeOf,\n pick: exports.expectTypeOf,\n omit: exports.expectTypeOf,\n toHaveProperty: exports.expectTypeOf,\n parameter: exports.expectTypeOf,\n };\n const getterProperties = nonFunctionProperties;\n getterProperties.forEach((prop) => Object.defineProperty(obj, prop, { get: () => (0, exports.expectTypeOf)({}) }));\n return obj;\n};\nexports.expectTypeOf = expectTypeOf;\n","export { N as BenchmarkRunner, S as Snapshots, T as TestRunner, a as assert, c as createExpect, g as expect, i as inject, s as should, v as vi, b as vitest } from './chunks/test.DNmyFkvJ.js';\nexport { b as bench } from './chunks/benchmark.CX_oY03V.js';\nexport { V as EvaluatedModules } from './chunks/evaluatedModules.Dg1zASAC.js';\nexport { a as assertType } from './chunks/index.DdgEv5B1.js';\nexport { expectTypeOf } from 'expect-type';\nexport { afterAll, afterEach, aroundAll, aroundEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, recordArtifact, suite, test } from '@vitest/runner';\nexport { chai } from '@vitest/expect';\nimport '@vitest/utils/helpers';\nimport '@vitest/utils/timers';\nimport './chunks/utils.BX5Fg8C4.js';\nimport '@vitest/runner/utils';\nimport '@vitest/utils/error';\nimport 'pathe';\nimport '@vitest/spy';\nimport '@vitest/utils/offset';\nimport '@vitest/utils/source-map';\nimport './chunks/_commonjsHelpers.D26ty3Ew.js';\nimport './chunks/rpc.MzXet3jl.js';\nimport './chunks/index.Chj8NDwU.js';\nimport '@vitest/snapshot';\nimport 'vite/module-runner';\n","import { Duration, Effect, Layer, Redacted, Stream } from \"effect\"\nimport { FetchHttpClient } from \"effect/unstable/http\"\nimport { describe, expect, expectTypeOf, it } from \"vitest\"\nimport type * as AiError from \"@effect-uai/core/AiError\"\nimport type { GenerateResult } from \"@effect-uai/core/Music\"\nimport { promptsInput } from \"@effect-uai/core/Music\"\nimport * as MusicGenerator from \"@effect-uai/core/MusicGenerator\"\nimport * as LyriaGenerator from \"./LyriaGenerator.js\"\n\nconst cfg: LyriaGenerator.Config = { apiKey: Redacted.make(\"test-key\") }\n// FetchHttpClient is required for `make`, but these tests only exercise the\n// compile-time gating and runtime Unsupported branches, no real HTTP is made.\nconst live = Layer.provide(LyriaGenerator.layer(cfg), FetchHttpClient.layer)\n\ndescribe(\"containerToMimeType\", () => {\n it(\"maps mp3 and wav\", async () => {\n expect(await Effect.runPromise(LyriaGenerator.containerToMimeType(\"mp3\"))).toBe(\"audio/mp3\")\n expect(await Effect.runPromise(LyriaGenerator.containerToMimeType(\"wav\"))).toBe(\"audio/wav\")\n })\n\n it(\"fails Unsupported for ogg / opus / flac / aac / webm / raw\", async () => {\n const exit = await Effect.runPromiseExit(LyriaGenerator.containerToMimeType(\"ogg\"))\n expect(exit._tag).toBe(\"Failure\")\n if (exit._tag === \"Failure\") {\n expect(JSON.stringify(exit.cause)).toContain(\"Unsupported\")\n expect(JSON.stringify(exit.cause)).toContain(\"outputFormat\")\n }\n })\n})\n\ndescribe(\"realizedFormat\", () => {\n it(\"reports 44.1 kHz stereo for both mp3 and wav\", () => {\n expect(LyriaGenerator.realizedFormat(\"audio/mp3\")).toEqual({\n container: \"mp3\",\n encoding: \"mp3\",\n sampleRate: 44100,\n channels: 2,\n })\n expect(LyriaGenerator.realizedFormat(\"audio/wav\")).toEqual({\n container: \"wav\",\n encoding: \"pcm_s16le\",\n sampleRate: 44100,\n channels: 2,\n })\n })\n})\n\ndescribe(\"LyriaGenerator capability guards (runtime)\", () => {\n it(\"streamGenerationFrom returns an Unsupported stream\", async () => {\n const program = LyriaGenerator.LyriaGenerator.use((s) =>\n Stream.runDrain(\n s.streamGenerationFrom(Stream.fromIterable([promptsInput([{ text: \"x\" }])]), {\n model: \"lyria-3-clip-preview\",\n prompt: \"\",\n }),\n ),\n )\n const exit = await Effect.runPromiseExit(program.pipe(Effect.provide(live)))\n expect(exit._tag).toBe(\"Failure\")\n if (exit._tag === \"Failure\") {\n expect(JSON.stringify(exit.cause)).toContain(\"Unsupported\")\n expect(JSON.stringify(exit.cause)).toContain(\"streamGenerationFrom\")\n }\n })\n})\n\ndescribe(\"LyriaGenerator Layer (compile-time)\", () => {\n it(\"leaves `MusicInteractiveSession` unsatisfied when using `streamGenerationFrom` against this Layer\", () => {\n const inputs = Stream.fromIterable([promptsInput([{ text: \"techno\" }])])\n const events = inputs.pipe(\n MusicGenerator.streamGenerationFrom({\n model: \"lyria-3-clip-preview\",\n prompt: \"\",\n }),\n )\n const provided = Stream.runDrain(events).pipe(Effect.provide(live))\n expectTypeOf(provided).toEqualTypeOf<\n Effect.Effect<void, AiError.AiError, MusicGenerator.MusicInteractiveSession>\n >()\n })\n\n it(\"sync `generate` returns GenerateResult and requires no marker\", () => {\n const gen = MusicGenerator.generate({\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n }).pipe(Effect.provide(live))\n expectTypeOf(gen).toEqualTypeOf<Effect.Effect<GenerateResult, AiError.AiError, never>>()\n })\n\n it(\"chunked `streamGeneration` requires no marker\", () => {\n const _stream = Stream.runCollect(\n MusicGenerator.streamGeneration({\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n }),\n ).pipe(Effect.provide(live))\n expect(_stream).toBeDefined()\n })\n\n it(\"Lyria-typed request accepts no `instrumental` field\", () => {\n const _req: LyriaGenerator.LyriaGenerateRequest = {\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n // @ts-expect-error: instrumental was removed from LyriaGenerateRequest in v0.7\n instrumental: true,\n }\n expect(_req).toBeDefined()\n })\n\n it(\"Common request supports `duration: Duration.Duration`\", () => {\n const _req: MusicGenerator.CommonGenerateMusicRequest = {\n model: \"lyria-3-clip-preview\",\n prompt: \"ambient\",\n duration: Duration.seconds(30),\n }\n expect(_req).toBeDefined()\n })\n})\n"],"x_google_ignoreList":[0,1,2,3,4,5,6],"mappings":";;;;;;;;AAAA,IAAI,oBAAoB;AACxB,qBAAqB;AACH,OAAO,UAAU,OAAO,QAAQ;CAe5B,iBAAiB,CAAC,EAAA,CAAE;AA8E1B,IAAA,QAAQ;AAAoE,IAAA,4BAAY,IAAI,WAAW,EAAE;AAAG,IAAA,4BAAY,IAAI,WAAW,GAAG;AAC1J,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KA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AS,6CAA6C;CACpD,GAAG,2GAA2G;EAE5G,MAAM,SADS,OAAO,aAAa,CAAC,aAAa,CAAC,EAAE,MAAM,SAAS,CAAC,CAAC,CAAC,CAClD,CAAC,CAAC,KACpBC,iBAAe,qBAAqB;GAClC,OAAO;GACP,QAAQ;EACV,CAAC,CACH;EACA,MAAM,WAAW,OAAO,SAAS,MAAM,CAAC,CAAC,KAAK,OAAO,QAAQ,IAAI,CAAC;EAClE,CAAA,GAAA,YAAA,aAAA,CAAa,QAAQ,CAAC,CAAC,cAErB;CACJ,CAAC;CAED,GAAG,uEAAuE;EACxE,MAAM,MAAMA,iBAAe,SAAS;GAClC,OAAO;GACP,QAAQ;EACV,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,IAAI,CAAC;EAC5B,CAAA,GAAA,YAAA,aAAA,CAAa,GAAG,CAAC,CAAC,cAAqE;CACzF,CAAC;CAED,GAAG,uDAAuD;EACxD,MAAM,UAAU,OAAO,WACrBA,iBAAe,iBAAiB;GAC9B,OAAO;GACP,QAAQ;EACV,CAAC,CACH,CAAC,CAAC,KAAK,OAAO,QAAQ,IAAI,CAAC;EAC3B,aAAO,OAAO,CAAC,CAAC,YAAY;CAC9B,CAAC;CAED,GAAG,6DAA6D;EAO9D,aAAO;GALL,OAAO;GACP,QAAQ;GAER,cAAc;EAEN,CAAC,CAAC,CAAC,YAAY;CAC3B,CAAC;CAED,GAAG,+DAA+D;EAChE,MAAM,OAAkD;GACtD,OAAO;GACP,QAAQ;GACR,UAAU,SAAS,QAAQ,EAAE;EAC/B;EACA,aAAO,IAAI,CAAC,CAAC,YAAY;CAC3B,CAAC;AACH,CAAC"}
|
package/dist/codec.d.mts
CHANGED
|
@@ -2,12 +2,20 @@ import { Option, Schema } from "effect";
|
|
|
2
2
|
import { CommonRequest } from "@effect-uai/core/LanguageModel";
|
|
3
3
|
import { ToolDescriptor } from "@effect-uai/core/Tool";
|
|
4
4
|
import { Turn } from "@effect-uai/core/Turn";
|
|
5
|
-
import { HistoryItem } from "@effect-uai/core/Items";
|
|
6
|
-
|
|
7
|
-
//#region src/codec.d.ts
|
|
5
|
+
import { Annotation, HistoryItem } from "@effect-uai/core/Items";
|
|
8
6
|
declare namespace codec_d_exports {
|
|
9
|
-
export { AccumulatedFunctionCall, Accumulator, ChunkPart, ChunkResult, GenerationConfig, RequestBody, RequestTool, ThinkingConfig, WireChunk, accumulatorToTurn, buildRequestBody, emptyAccumulator, hasUrlImageSource, ingestChunk };
|
|
7
|
+
export { AccumulatedFunctionCall, Accumulator, ChunkPart, ChunkResult, GenerationConfig, GroundingMetadata, RequestBody, RequestTool, ThinkingConfig, WireChunk, accumulatorToTurn, buildRequestBody, emptyAccumulator, groundingToAnnotations, hasUrlImageSource, ingestChunk };
|
|
10
8
|
}
|
|
9
|
+
declare const GroundingMetadata: Schema.Struct<{
|
|
10
|
+
readonly groundingChunks: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
|
|
11
|
+
readonly web: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
12
|
+
readonly uri: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
13
|
+
readonly title: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
14
|
+
}>>>;
|
|
15
|
+
}>>>>;
|
|
16
|
+
}>;
|
|
17
|
+
type GroundingMetadata = typeof GroundingMetadata.Type;
|
|
18
|
+
declare const groundingToAnnotations: (...metas: ReadonlyArray<GroundingMetadata | null | undefined>) => ReadonlyArray<Annotation>;
|
|
11
19
|
declare const WireChunk: Schema.Struct<{
|
|
12
20
|
readonly candidates: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
13
21
|
readonly content: Schema.optional<Schema.Struct<{
|
|
@@ -29,6 +37,14 @@ declare const WireChunk: Schema.Struct<{
|
|
|
29
37
|
readonly thoughtSignature: Schema.optional<Schema.String>;
|
|
30
38
|
}>]>>>;
|
|
31
39
|
}>>;
|
|
40
|
+
readonly groundingMetadata: Schema.optional<Schema.Struct<{
|
|
41
|
+
readonly groundingChunks: Schema.optional<Schema.NullOr<Schema.$Array<Schema.Struct<{
|
|
42
|
+
readonly web: Schema.optional<Schema.NullOr<Schema.Struct<{
|
|
43
|
+
readonly uri: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
44
|
+
readonly title: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
45
|
+
}>>>;
|
|
46
|
+
}>>>>;
|
|
47
|
+
}>>;
|
|
32
48
|
readonly finishReason: Schema.optional<Schema.String>;
|
|
33
49
|
readonly index: Schema.optional<Schema.Number>;
|
|
34
50
|
}>>>;
|
|
@@ -57,6 +73,7 @@ type RequestPart = {
|
|
|
57
73
|
readonly thoughtSignature?: string;
|
|
58
74
|
} | {
|
|
59
75
|
readonly functionResponse: {
|
|
76
|
+
readonly id?: string;
|
|
60
77
|
readonly name: string;
|
|
61
78
|
readonly response: Record<string, unknown>;
|
|
62
79
|
};
|
|
@@ -103,8 +120,10 @@ type GenerationConfig = {
|
|
|
103
120
|
readonly temperature?: number;
|
|
104
121
|
readonly maxOutputTokens?: number;
|
|
105
122
|
readonly topP?: number;
|
|
106
|
-
readonly thinkingConfig?: ThinkingConfig;
|
|
107
|
-
|
|
123
|
+
readonly thinkingConfig?: ThinkingConfig;
|
|
124
|
+
/** Set together with `responseJsonSchema` to constrain output to JSON. */
|
|
125
|
+
readonly responseMimeType?: string;
|
|
126
|
+
/** JSON Schema constraint on the output. */
|
|
108
127
|
readonly responseJsonSchema?: Record<string, unknown>;
|
|
109
128
|
};
|
|
110
129
|
type RequestBody = {
|
|
@@ -123,16 +142,22 @@ type RequestBody = {
|
|
|
123
142
|
declare const hasUrlImageSource: (history: ReadonlyArray<HistoryItem>) => boolean;
|
|
124
143
|
declare const buildRequestBody: (history: ReadonlyArray<HistoryItem>, generationConfig: Option.Option<GenerationConfig>, tools?: ReadonlyArray<ToolDescriptor>, providerToolEntries?: ReadonlyArray<RequestTool>, toolChoice?: CommonRequest["toolChoice"]) => RequestBody;
|
|
125
144
|
type AccumulatedFunctionCall = {
|
|
126
|
-
/** Synthesized id-or-name we surface as `call_id` on the canonical item. */
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
|
|
145
|
+
/** Synthesized id-or-name we surface as `call_id` on the canonical item. */
|
|
146
|
+
readonly callId: string;
|
|
147
|
+
readonly name: string;
|
|
148
|
+
/** Wire id from Gemini 3, when present - echoed back on `functionResponse`. */
|
|
149
|
+
readonly providerId: Option.Option<string>;
|
|
150
|
+
/** Thought signature from Gemini 3, replayed on the next request's part. */
|
|
151
|
+
readonly signature: Option.Option<string>;
|
|
152
|
+
/** Args as JSON-encoded string, mirroring `Items.ToolCall.arguments`. */
|
|
130
153
|
readonly arguments: string;
|
|
131
154
|
};
|
|
132
155
|
type Accumulator = {
|
|
133
156
|
readonly text: string;
|
|
134
157
|
readonly reasoning: string;
|
|
135
158
|
readonly functionCalls: ReadonlyArray<AccumulatedFunctionCall>;
|
|
159
|
+
/** Grounding citations, accumulated (de-duped by url) across chunks. */
|
|
160
|
+
readonly annotations: ReadonlyArray<Annotation>;
|
|
136
161
|
readonly finishReason: Option.Option<string>;
|
|
137
162
|
readonly usage: {
|
|
138
163
|
readonly input_tokens?: number;
|
|
@@ -173,5 +198,5 @@ type ChunkResult = {
|
|
|
173
198
|
declare const ingestChunk: (acc: Accumulator, chunk: WireChunk) => ChunkResult;
|
|
174
199
|
declare const accumulatorToTurn: (acc: Accumulator) => Turn;
|
|
175
200
|
//#endregion
|
|
176
|
-
export { AccumulatedFunctionCall, Accumulator, ChunkPart, ChunkResult, GenerationConfig, RequestBody, RequestTool, ThinkingConfig, WireChunk, accumulatorToTurn, buildRequestBody, emptyAccumulator, hasUrlImageSource, ingestChunk, codec_d_exports as t };
|
|
201
|
+
export { AccumulatedFunctionCall, Accumulator, ChunkPart, ChunkResult, GenerationConfig, GroundingMetadata, RequestBody, RequestTool, ThinkingConfig, WireChunk, accumulatorToTurn, buildRequestBody, emptyAccumulator, groundingToAnnotations, hasUrlImageSource, ingestChunk, codec_d_exports as t };
|
|
177
202
|
//# sourceMappingURL=codec.d.mts.map
|
package/dist/codec.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codec.d.mts","names":[],"sources":["../src/codec.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codec.d.mts","names":[],"sources":["../src/codec.ts"],"mappings":";;;;;;;;cAoEa,mBAAiB,OAAA;;;;;;;;KAGlB,2BAA2B,kBAAkB;cAU5C,4BAAsB,OACvB,cAAc,0CACvB,cAAc;cA+BJ,WAAS,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIV,mBAAmB,UAAU;KAMpC;WACU;;WACA;aAAuB;aAA2B;;;WAElD;aACE;aACA;aACA;;WAEF;;WAGA;aACE;aACA;aACA,UAAU;;;KAItB;WACM;WACA,OAAO,cAAc;;KAG3B;WACM,OAAO;aAAyB;;;;;;;;;;KAU/B;WAEG,sBAAsB;aACpB;aACA;aACA,YAAY;;;WAGd;;WACA;;WACA;;KAEV;WACM;aACE;aACA,uBAAuB;;;KAIxB;WACD;;KAGC;WACD;WACA;WACA;WACA,iBAAiB;;WAEjB;;WAEA,qBAAqB;;KAGpB;WACD,UAAU,cAAc;WACxB,oBAAoB;WACpB,mBAAmB;WACnB,QAAQ,cAAc;WACtB,aAAa;;;;;;;;cA8QX,oBAAiB,SAAa,cAAc;cAO5C,mBAAgB,SAClB,cAAc,cAAY,kBACjB,OAAO,OAAO,mBAAiB,QAC1C,cAAc,iBAAe,sBACf,cAAc,cAAY,aACnC,gCACX;KAoCS;;WAED;WACA;;WAEA,YAAY,OAAO;;WAEnB,WAAW,OAAO;;WAElB;;KAGC;WACD;WACA;WACA,eAAe,cAAc;;WAE7B,aAAa,cAAc;WAC3B,cAAc,OAAO;WACrB;aACE;aACA;aACA;aACA;eAAkC;;aAClC;eAAmC;;;;cAInC,kBAAkB;;;;;;KAcnB;WACG;WAAuB;;WACvB;WAA4B;;WAE5B;WACA,IAAI,OAAO;WACX,WAAW,OAAO;WAClB;WACA;;KAGH;WACD,aAAa;WACb,OAAO,cAAc;WACrB;;cAuGE,cAAW,KAAS,aAAW,OAAS,cAAY;cA0DpD,oBAAiB,KAAS,gBAAc"}
|