{"version":3,"sources":["../transport/types.ts","../transport/base.ts"],"sourcesContent":["import z from \"zod\";\nimport type { SerializableValue } from \"@/shared/canon\";\nimport * as op from \"@/shared/operation\";\nimport type { MaybePromise } from \"@/shared/types\";\n\n// RPC messages\nexport const rpcRequestSchema = z.object({\n  type: z.literal(\"request\"),\n  id: z.string(),\n  name: z.string(),\n  input: z.unknown().optional(),\n});\n\nexport const rpcResponseSchema = z.object({\n  type: z.literal(\"response\"),\n  id: z.string(),\n  result: op.resultSchema.transform((result) => result as op.OperationResult<SerializableValue>),\n});\n\nexport const rpcMessageSchema = z.discriminatedUnion(\"type\", [rpcRequestSchema, rpcResponseSchema]);\n\nexport type RPCRequest<Input = SerializableValue> = Omit<\n  z.infer<typeof rpcRequestSchema>,\n  \"input\"\n> & {\n  input?: Input;\n};\n\nexport type RPCResponse<Result = op.OperationResult<SerializableValue>> = Omit<\n  z.infer<typeof rpcResponseSchema>,\n  \"result\"\n> & {\n  result: Result;\n};\n\nexport type RPCMessage = RPCRequest | RPCResponse;\n\n// RPC procedure\nexport type RPCProcedureSchema = { input?: z.ZodObject; output?: z.ZodObject };\nexport type RPCProcedure<Schema extends RPCProcedureSchema = RPCProcedureSchema> = {\n  name: string;\n  schema?: Schema;\n  execute: (\n    input: Schema[\"input\"] extends z.ZodObject ? z.infer<Schema[\"input\"]> : undefined,\n  ) => MaybePromise<\n    op.OperationResult<Schema[\"output\"] extends z.ZodObject ? z.infer<Schema[\"output\"]> : void>\n  >;\n};\n","import type z from \"zod\";\nimport { canon, type SerializableValue } from \"@/shared/canon\";\nimport { type LifeError, obfuscateLifeError } from \"@/shared/error\";\nimport * as op from \"@/shared/operation\";\nimport { newId } from \"@/shared/prefixed-id\";\nimport type { MaybePromise, Todo } from \"@/shared/types\";\nimport type { TelemetryClient } from \"@/telemetry/clients/base\";\nimport type { TransportProviderClientBase } from \"./providers/base\";\nimport {\n  type RPCProcedure,\n  type RPCProcedureSchema,\n  type RPCRequest,\n  rpcMessageSchema,\n} from \"./types\";\n\n// Runtime-agnostic logic between transport classes\nexport abstract class TransportClientBase {\n  readonly #provider: TransportProviderClientBase<z.ZodObject>;\n  readonly #obfuscateErrors: boolean;\n  readonly #procedures = new Map<string, RPCProcedure>();\n  readonly #resolveResults = new Map<\n    string,\n    (value?: op.OperationResult<SerializableValue>) => MaybePromise<void>\n  >();\n  readonly #telemetry: TelemetryClient | null = null;\n  #rpcUnsubscribe?: () => void;\n\n  constructor({\n    provider,\n    telemetry,\n    obfuscateErrors = false,\n  }: {\n    provider: TransportProviderClientBase<z.ZodObject>;\n    obfuscateErrors?: boolean;\n    telemetry?: TelemetryClient | null;\n  }) {\n    this.#provider = provider;\n    this.#obfuscateErrors = obfuscateErrors;\n    this.#telemetry = telemetry ?? null;\n  }\n\n  async sendText(topic: string, text: string) {\n    try {\n      const [errWriter, writer] = await this.streamText(topic);\n      if (errWriter) return op.failure(errWriter);\n      await writer.write(text);\n      await writer.close();\n      return op.success();\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  receiveText(\n    topic: string,\n    callback: (text: string, participantId: string) => MaybePromise<void>,\n    onError?: (error: LifeError) => void,\n  ) {\n    try {\n      const [errReceive, unsubscribe] = this.receiveStreamText(\n        topic,\n        async (iterator: AsyncIterable<string>, participantId: string) => {\n          const [err] = await op.attempt(async () => {\n            let result = \"\";\n            for await (const chunk of iterator) result += chunk;\n            await callback(result, participantId);\n          });\n          if (err) onError?.(err);\n        },\n        onError,\n      );\n      if (errReceive) return op.failure(errReceive);\n      return op.success(unsubscribe);\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  async sendObject(topic: string, obj: SerializableValue) {\n    try {\n      const [errCanon, serialized] = canon.stringify(obj);\n      if (errCanon) return op.failure(errCanon);\n      const [errSend] = await this.sendText(topic, serialized);\n      if (errSend) return op.failure(errSend);\n      return op.success();\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  receiveObject(\n    topic: string,\n    callback: (obj: unknown, participantId: string) => MaybePromise<void>,\n    onError?: (error: LifeError) => void,\n  ) {\n    try {\n      const [err, unsubscribe] = this.receiveText(\n        topic,\n        async (text, participantId) => {\n          try {\n            // Parse the text into an object\n            const [errParse, deserialized] = canon.parse(text);\n            if (errParse) return onError?.(errParse);\n\n            // Call the callback\n            const [errCallback] = await op.attempt(\n              async () => await callback(deserialized, participantId),\n            );\n            if (errCallback) return onError?.(errCallback);\n          } catch (error) {\n            onError?.(error as LifeError);\n          }\n        },\n        onError,\n      );\n\n      // Return the unsubscribe function\n      if (err) return op.failure(err);\n      return op.success(unsubscribe);\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  /**\n   * Register a remote procedure.\n   * @param procedure - The procedure to register\n   */\n  register<Schema extends RPCProcedureSchema>(procedure: RPCProcedure<Schema>) {\n    this.#procedures.set(procedure.name, procedure);\n  }\n\n  /**\n   * Call a remote procedure.\n   * @param name - The name of the procedure to call\n   * @param inputs - The parameters to pass to the procedure\n   * @returns A promise that resolves to the response from the procedure\n   */\n  async call<Schema extends RPCProcedureSchema>({\n    name,\n    schema,\n    input,\n    timeoutMs = 10_000,\n  }: {\n    name: string;\n    schema?: Schema;\n    timeoutMs?: number;\n  } & (Schema[\"input\"] extends z.ZodObject\n    ? { input: z.infer<Schema[\"input\"]> }\n    : { input?: never })): Promise<\n    op.OperationResult<Schema[\"output\"] extends z.ZodObject ? z.infer<Schema[\"output\"]> : void>\n  > {\n    const id = newId(\"rpc\");\n\n    try {\n      // Validate input data\n      let parsedInput: SerializableValue | undefined;\n      if (schema?.input) {\n        const { error: errInput, data: parsedInput_ } = schema.input.safeParse(input);\n        if (errInput) return op.failure({ code: \"Validation\", cause: errInput });\n        parsedInput = parsedInput_ as SerializableValue;\n      }\n\n      // Prepare a resolver and timeout promises\n      const resultPromise = new Promise<\n        op.OperationResult<Schema[\"output\"] extends z.ZodObject ? z.infer<Schema[\"output\"]> : never>\n      >((resolve) => {\n        this.#resolveResults.set(id, (res) => {\n          resolve(\n            res as unknown as op.OperationResult<\n              Schema[\"output\"] extends z.ZodObject ? z.infer<Schema[\"output\"]> : never\n            >,\n          );\n        });\n      });\n\n      const timeoutPromise = new Promise<op.OperationResult<SerializableValue>>((resolve) => {\n        setTimeout(() => {\n          resolve(\n            op.failure({\n              code: \"Timeout\",\n              message: `RPC call to procedure '${name}' timed out after ${timeoutMs}ms.`,\n            }),\n          );\n        }, timeoutMs);\n      });\n\n      // Call the procedure\n      const [errCall] = await this.sendObject(\"rpc\", {\n        type: \"request\",\n        id,\n        name,\n        ...(parsedInput ? { input: parsedInput } : {}),\n      } satisfies RPCRequest);\n      if (errCall) return op.failure(errCall);\n\n      // Capture whichever resolves first between the timeout and result\n      const [err, data] = await Promise.race([resultPromise, timeoutPromise]);\n\n      // Return the error if any\n      if (err) return op.failure(err);\n\n      // Validate the output data\n      if (schema?.output) {\n        const { error: errOutput, data: parsedOutput } = schema.output.safeParse(data);\n        if (errOutput) return op.failure({ code: \"Validation\", cause: errOutput });\n        return op.success(parsedOutput) as Todo;\n      }\n      return op.success() as Todo;\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    } finally {\n      this.#resolveResults.delete(id);\n    }\n  }\n\n  // Initialize RPC\n  async #onRPCMessage(rawMessage: unknown) {\n    try {\n      // Validate the incoming RPC message shape\n      const { data: parsedMessage, error: messageError } = rpcMessageSchema.safeParse(rawMessage);\n      if (messageError)\n        return this.#telemetry?.log.error({\n          message: \"Invalid RPC message.\",\n          error: messageError,\n        });\n\n      // Handle responses\n      if (parsedMessage.type === \"response\") {\n        const resolveResult = this.#resolveResults.get(parsedMessage.id);\n        if (resolveResult) await resolveResult(parsedMessage.result);\n        return;\n      }\n\n      // Handle requests\n      // - Helper to send a response\n      // biome-ignore lint/style/useConst: biome bug\n      let procedure: RPCProcedure | undefined;\n      const requestMessage = parsedMessage as RPCRequest;\n      const sendResult = async (result: op.OperationResult<SerializableValue>) => {\n        let [error, data] = result;\n\n        // Log error\n        if (error)\n          this.#telemetry?.log.error({\n            message: `Failed to respond to RPC request for handler '${requestMessage.name}'.`,\n            error,\n          });\n\n        // Obfuscate the error if required\n        if (this.#obfuscateErrors && error) error = obfuscateLifeError(error);\n\n        // Send the response\n        const [errSend] = await this.sendObject(\"rpc\", {\n          type: \"response\",\n          id: requestMessage.id,\n          result: error ? op.failure(error) : op.success(data),\n        });\n        if (errSend)\n          return this.#telemetry?.log.error({\n            message: \"Failed to send RPC response.\",\n            error: errSend,\n          });\n      };\n\n      // - Get the local procedure function, error if not found\n      procedure = this.#procedures.get(parsedMessage.name);\n      if (!procedure)\n        return await sendResult(\n          op.failure({\n            code: \"NotFound\",\n            message: `Procedure not found: '${parsedMessage.name}'.`,\n          }),\n        );\n\n      // - Parse the procedure's input, error if invalid\n      const { data: input, error: inputError } = procedure.schema?.input\n        ? procedure.schema.input.safeParse(parsedMessage.input)\n        : { data: undefined, error: null };\n      if (inputError)\n        return await sendResult(\n          op.failure({\n            code: \"Validation\",\n            message: `Invalid input parameters for procedure '${parsedMessage.name}'.`,\n            cause: inputError,\n          }),\n        );\n\n      // - Execute the procedure\n      const [err, rawOutput] = await procedure.execute(input as never);\n      if (err) return await sendResult(op.failure(err));\n\n      // - Validate the output\n      const { data: output, error: outputError } = procedure.schema?.output\n        ? await procedure.schema.output.safeParseAsync(rawOutput)\n        : { data: rawOutput, error: null };\n      if (outputError) {\n        return await sendResult(\n          op.failure({\n            code: \"Validation\",\n            message: `Invalid output from procedure '${parsedMessage.name}'.`,\n            cause: outputError,\n          }),\n        );\n      }\n\n      // - Send the output result\n      return await sendResult(op.success(output as SerializableValue));\n    } catch (error) {\n      this.#telemetry?.log.error({ message: \"Unknown error while handling RPC message.\", error });\n    }\n  }\n\n  #startRPC() {\n    try {\n      const [errReceive, unsubscribe] = this.receiveObject(\"rpc\", this.#onRPCMessage.bind(this));\n      if (errReceive) return op.failure(errReceive);\n      this.#rpcUnsubscribe = unsubscribe;\n      return op.success();\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  #stopRPC() {\n    try {\n      this.#rpcUnsubscribe?.();\n      this.#resolveResults.clear();\n      this.#procedures.clear();\n      return op.success();\n    } catch (error) {\n      return op.failure({ code: \"Unknown\", cause: error });\n    }\n  }\n\n  on: TransportProviderClientBase<z.ZodObject>[\"on\"] = (...args) => this.#provider.on(...args);\n\n  joinRoom: TransportProviderClientBase<z.ZodObject>[\"joinRoom\"] = async (...args) => {\n    const [errJoin] = await this.#provider.joinRoom(...args);\n    if (errJoin) return op.failure(errJoin);\n    const [errStart] = this.#startRPC();\n    if (errStart) return op.failure(errStart);\n    return op.success();\n  };\n\n  leaveRoom: TransportProviderClientBase<z.ZodObject>[\"leaveRoom\"] = async (...args) => {\n    const [errLeave] = await this.#provider.leaveRoom(...args);\n    if (errLeave) return op.failure(errLeave);\n    const [errStop] = this.#stopRPC();\n    if (errStop) return op.failure(errStop);\n    return op.success();\n  };\n\n  streamText: TransportProviderClientBase<z.ZodObject>[\"streamText\"] = (...args) =>\n    this.#provider.streamText(...args);\n\n  receiveStreamText: TransportProviderClientBase<z.ZodObject>[\"receiveStreamText\"] = (...args) =>\n    this.#provider.receiveStreamText(...args);\n\n  enableMicrophone: TransportProviderClientBase<z.ZodObject>[\"enableMicrophone\"] = (...args) =>\n    this.#provider.enableMicrophone(...args);\n\n  playAudio: TransportProviderClientBase<z.ZodObject>[\"playAudio\"] = (...args) =>\n    this.#provider.playAudio(...args);\n\n  streamAudioChunk: TransportProviderClientBase<z.ZodObject>[\"streamAudioChunk\"] = (...args) =>\n    this.#provider.streamAudioChunk(...args);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,OAAO,OAAO;AAMP,IAAM,mBAAmB,EAAE,OAAO;AAAA,EACvC,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,IAAI,EAAE,OAAO;AAAA,EACb,MAAM,EAAE,OAAO;AAAA,E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