{"version":3,"file":"index.cjs","names":["ActionBase","ActionBase","ActionPayload","NiceError","ActionPayload_Request","RuntimeCoordinate","isAction_Base_JsonObject","isAction_Base_JsonObject","isActionPayload_Any_JsonObject","err_nice_action","ActionPayload","err_nice_action","RuntimeCoordinate","err_nice_action","RunningAction","err_nice_action","ActionLocalHandler","RuntimeCoordinate","ActionPayload_Request","ActionPayload_Result","err_nice_transport"],"sources":["../src/ActionDefinition/Action/Context/ActionContext.ts","../src/ActionDefinition/Action/Core/ActionCore.ts","../src/utils/isAction_Context_JsonObject.ts","../src/utils/isAction_Core_JsonObject.ts","../src/utils/isAction_Any_JsonObject.ts","../src/utils/assertIsActionJson.ts","../src/utils/isAction_Any_Instance.ts","../src/ActionDefinition/Domain/ActionDomainBase.ts","../src/ActionRuntime/ActionRuntimeManager.ts","../src/ActionDefinition/Domain/ActionRootDomain.ts","../src/ActionDefinition/Domain/ActionDomain.ts","../src/ActionDefinition/Domain/helpers/createRootActionDomain.ts","../src/ActionRuntime/Gateway/actionRouter.ts","../src/ActionRuntime/Transport/Carrier/adaptWireCarrierSource.ts","../src/ActionRuntime/Transport/Carrier/duplex/inMemory/inMemoryCarrier.ts","../src/ActionRuntime/Transport/Carrier/duplex/rtc/rtcCarrier.ts","../src/ActionRuntime/Transport/Carrier/duplex/ws/err_nice_transport_ws.ts","../src/ActionRuntime/Transport/Carrier/duplex/ws/wsCarrier.ts","../src/ActionRuntime/Transport/Carrier/exchange/http/httpCarrier.ts"],"sourcesContent":["import { RuntimeCoordinate } from \"@nice-code/wire\";\nimport type { ActionDomain } from \"../../Domain/ActionDomain\";\nimport type {\n  IActionDomain,\n  TInferInputFromSchema,\n  TInferOutputFromSchema,\n} from \"../../Domain/ActionDomain.types\";\nimport { ActionBase } from \"../ActionBase\";\nimport { EActionForm } from \"../ActionBase.types\";\nimport type {\n  IActionContext,\n  IActionContext_Data,\n  IActionContext_Data_JsonObject,\n  IActionContext_JsonObject,\n  IActionRouteItem,\n  IHandledReliability,\n} from \"./ActionContext.types\";\n\nexport class ActionContext<\n    DOM extends IActionDomain,\n    ID extends keyof DOM[\"actionSchema\"] & string = keyof DOM[\"actionSchema\"] & string,\n  >\n  extends ActionBase<EActionForm.context, DOM, ID>\n  implements IActionContext<DOM, ID>\n{\n  readonly form = EActionForm.context;\n  readonly _routing: IActionRouteItem[];\n  readonly timeCreated: number;\n  readonly cuid: string;\n  originClient: RuntimeCoordinate;\n  /**\n   * Local-only receiver-side reliable-delivery facts for the frame this context arrived on —\n   * `(seq, streamKey, redelivered)`, the free idempotency key for exactly-once effects. Present only\n   * inside the executing handler of a `.reliable()` action; `undefined` for best-effort actions and on\n   * the sending side. Never serialized (see {@link IHandledReliability}).\n   */\n  readonly reliability?: IHandledReliability;\n\n  constructor(\n    readonly _domain: ActionDomain<DOM>,\n    id: ID,\n    hydrationData: IActionContext_Data,\n  ) {\n    super(EActionForm.context, _domain, id);\n    this.timeCreated = hydrationData.timeCreated;\n    this.cuid = hydrationData.cuid;\n    this._routing = hydrationData.routing;\n    this.originClient = hydrationData.originClient;\n    this.reliability = hydrationData.reliability;\n  }\n\n  _setOriginClient(client: RuntimeCoordinate): void {\n    this.originClient = client;\n  }\n\n  toJsonString(): string {\n    return JSON.stringify(this.toJsonObject());\n  }\n\n  toContextDataJsonObject(): IActionContext_Data_JsonObject {\n    // `reliability` is deliberately NOT written: it is a local-only receiver-side stamp (see\n    // IHandledReliability) — a reply serialized off this context must be byte-identical whether or not\n    // the frame arrived reliably.\n    return {\n      timeCreated: this.timeCreated,\n      cuid: this.cuid,\n      routing: this.routing.map((item) => ({\n        runtime: item.runtime.toJsonObject(),\n        handler: item.handler,\n        time: item.time,\n      })),\n      originClient: this.originClient.toJsonObject(),\n    };\n  }\n\n  toJsonObject(): IActionContext_JsonObject<DOM, ID> {\n    return {\n      ...super.toJsonObject(),\n      ...this.toContextDataJsonObject(),\n    };\n  }\n\n  get routing(): IActionRouteItem[] {\n    return this._routing;\n  }\n\n  addRouteItem(item: IActionRouteItem): void {\n    this._routing.push(item);\n  }\n\n  deserializeInput(\n    serialized: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"SerdeInput\"],\n  ): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"] {\n    return this.schema.deserializeInput(serialized);\n  }\n\n  serializeInput(\n    raw: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"],\n  ): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"SerdeInput\"] {\n    return this.schema.serializeInput(raw);\n  }\n\n  validateInput(input: unknown): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"] {\n    return this.schema.validateInput(input, {\n      domain: this.domain,\n      actionId: this.id,\n    });\n  }\n\n  validateOutput(output: unknown): TInferOutputFromSchema<DOM[\"actionSchema\"][ID]>[\"Output\"] {\n    return this.schema.validateOutput(output, {\n      domain: this.domain,\n      actionId: this.id,\n    });\n  }\n}\n","import { NiceError } from \"@nice-code/error\";\nimport { RuntimeCoordinate } from \"@nice-code/wire\";\nimport { nanoid } from \"nanoid\";\nimport type { ActionDomain } from \"../../Domain/ActionDomain\";\nimport type {\n  IActionDomain,\n  TInferInputFromSchema,\n  TInferOutputFromSchema,\n} from \"../../Domain/ActionDomain.types\";\nimport type { TInferActionError } from \"../../Schema/ActionSchema\";\nimport type { TNarrowActionType } from \"../Action.combined.types\";\nimport { ActionBase } from \"../ActionBase\";\nimport { EActionForm, type IActionBase, type IActionBase_JsonObject } from \"../ActionBase.types\";\nimport { ActionContext } from \"../Context/ActionContext\";\nimport { ActionPayload } from \"../Payload/ActionPayload\";\nimport { ActionPayload_Request } from \"../Payload/ActionPayload_Request\";\nimport type { IActionCore } from \"./ActionCore.types\";\n\nexport class ActionCore<\n    DOM extends IActionDomain,\n    ID extends keyof DOM[\"actionSchema\"] & string = keyof DOM[\"actionSchema\"] & string,\n  >\n  extends ActionBase<EActionForm.core, DOM, ID>\n  implements IActionCore<DOM, ID>\n{\n  readonly form = EActionForm.core;\n\n  constructor(\n    readonly _domain: ActionDomain<DOM>,\n    id: ID,\n  ) {\n    super(EActionForm.core, _domain, id);\n  }\n\n  is<ACT extends IActionBase<any, any, any>>(\n    action: ACT | unknown | null | undefined,\n  ): action is TNarrowActionType<DOM, ACT, ID> {\n    return (\n      action instanceof ActionPayload && action.domain === this.domain && action.id === this.id\n    );\n  }\n\n  /**\n   * Type-guard for the throw-style path (`runToOutput` rethrows on failure):\n   * narrows a caught value to this action's declared error union when it is one\n   * the action declared via `.throws()`. Everything else (foreign throws,\n   * undeclared `NiceError`s) returns `false`.\n   */\n  isExpectedError(error: unknown): error is TInferActionError<DOM[\"actionSchema\"][ID]> {\n    return error instanceof NiceError && this.schema.isExpectedError(error);\n  }\n\n  toJsonObject(): IActionBase_JsonObject<EActionForm.core, DOM, ID> {\n    return {\n      id: this.id,\n      form: this.form,\n      domain: this.domain,\n      allDomains: this.allDomains,\n    };\n  }\n\n  request(\n    ...args: [TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"]] extends [never]\n      ? [input?: never]\n      : [input: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"]]\n  ): ActionPayload_Request<DOM, ID> {\n    const input: unknown = args[0];\n    const validatedInput = this.schema.validateInput(input, {\n      actionId: this.id,\n      domain: this.domain,\n    });\n\n    const context = new ActionContext(this._domain, this.id, {\n      cuid: nanoid(),\n      timeCreated: Date.now(),\n      routing: [],\n      originClient: RuntimeCoordinate.unknown,\n    });\n\n    return new ActionPayload_Request({ context }, validatedInput, {\n      time: Date.now(),\n    });\n  }\n\n  // async run(\n  //   input: TInferInputFromSchema<DOM[\"actions\"][ID]>[\"Input\"],\n  //   options?: IExecuteActionOptions<DOM, ID>,\n  // ): Promise<RunningAction<DOM, ID>> {\n  //   return this.request(input).run(options);\n  // }\n\n  // async runToOutput(\n  //   input: TInferInputFromSchema<DOM[\"actions\"][ID]>[\"Input\"],\n  //   options?: IExecuteActionOptions<DOM, ID>,\n  // ): Promise<TInferOutputFromSchema<DOM[\"actions\"][ID]>[\"Output\"]> {\n  //   return this.request(input).runToOutput(options);\n  // }\n\n  // async runToOutputSafe(\n  //   input: TInferInputFromSchema<DOM[\"actions\"][ID]>[\"Input\"],\n  //   options?: IExecuteActionOptions<DOM, ID>,\n  // ): Promise<\n  //   TActionResult<\n  //     TInferOutputFromSchema<DOM[\"actions\"][ID]>[\"Output\"],\n  //     TInferActionError<DOM[\"actions\"][ID]>\n  //   >\n  // > {\n  //   return this.request(input).runToOutputSafe(options);\n  // }\n\n  deserializeInput(\n    serialized: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"SerdeInput\"],\n  ): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"] {\n    return this.schema.deserializeInput(serialized);\n  }\n\n  serializeInput(\n    raw: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"],\n  ): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"SerdeInput\"] {\n    return this.schema.serializeInput(raw);\n  }\n\n  validateInput(input: unknown): TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"] {\n    return this.schema.validateInput(input, {\n      domain: this.domain,\n      actionId: this.id,\n    });\n  }\n\n  validateOutput(output: unknown): TInferOutputFromSchema<DOM[\"actionSchema\"][ID]>[\"Output\"] {\n    return this.schema.validateOutput(output, {\n      domain: this.domain,\n      actionId: this.id,\n    });\n  }\n}\n","import { EActionForm } from \"../ActionDefinition/Action/ActionBase.types\";\nimport type { IActionContext_JsonObject } from \"../ActionDefinition/Action/Context/ActionContext.types\";\nimport { isAction_Base_JsonObject } from \"./isAction_Base_JsonObject\";\n\nexport const isAction_Context_JsonObject = (obj: unknown): obj is IActionContext_JsonObject => {\n  return isAction_Base_JsonObject(obj) && obj.form === EActionForm.context;\n};\n","import { EActionForm } from \"../ActionDefinition/Action/ActionBase.types\";\nimport type { IActionCore_JsonObject } from \"../ActionDefinition/Action/Core/ActionCore.types\";\nimport { isAction_Base_JsonObject } from \"./isAction_Base_JsonObject\";\n\nexport const isAction_Core_JsonObject = (obj: unknown): obj is IActionCore_JsonObject => {\n  return isAction_Base_JsonObject(obj) && obj.form === EActionForm.core;\n};\n","import type { TAction_Any_JsonObject } from \"../ActionDefinition/Action/Action.combined.types\";\nimport { isAction_Context_JsonObject } from \"./isAction_Context_JsonObject\";\nimport { isAction_Core_JsonObject } from \"./isAction_Core_JsonObject\";\nimport { isActionPayload_Any_JsonObject } from \"./isActionPayload_Any_JsonObject\";\n\nexport function isAction_Any_JsonObject(obj: unknown): obj is TAction_Any_JsonObject {\n  return (\n    isActionPayload_Any_JsonObject(obj) ||\n    isAction_Context_JsonObject(obj) ||\n    isAction_Core_JsonObject(obj)\n  );\n}\n","import type { IActionBase_JsonObject } from \"../ActionDefinition/Action/ActionBase.types\";\nimport { EErrId_NiceAction, err_nice_action } from \"../errors/err_nice_action\";\nimport { isAction_Any_JsonObject } from \"./isAction_Any_JsonObject\";\n\nexport function assertIsActionJson(obj: unknown): asserts obj is IActionBase_JsonObject {\n  if (!isAction_Any_JsonObject(obj)) {\n    throw err_nice_action.fromId(EErrId_NiceAction.wire_not_action_data);\n  }\n}\n","import type { TAction_Any_Instance } from \"../ActionDefinition/Action/Action.combined.types\";\nimport type { IActionBase } from \"../ActionDefinition/Action/ActionBase.types\";\nimport { ActionContext } from \"../ActionDefinition/Action/Context/ActionContext\";\nimport { ActionCore } from \"../ActionDefinition/Action/Core/ActionCore\";\nimport { ActionPayload } from \"../ActionDefinition/Action/Payload/ActionPayload\";\n\nexport function isAction_Any_Instance<ACT extends IActionBase<any, any>>(\n  value: unknown | ACT,\n): value is TAction_Any_Instance<any, any> {\n  return (\n    value instanceof ActionCore || value instanceof ActionPayload || value instanceof ActionContext\n  );\n}\n","import type {\n  TDistributeRunningActionUpdateListener,\n  TRunningActionUpdateListener,\n} from \"../Action/RunningAction.types\";\nimport type { IActionDomain } from \"./ActionDomain.types\";\n\nexport abstract class ActionDomainBase<ACT_DOM extends IActionDomain = IActionDomain>\n  implements IActionDomain<ACT_DOM[\"allDomains\"], ACT_DOM[\"actionSchema\"]>\n{\n  readonly domain: ACT_DOM[\"domain\"];\n  readonly allDomains: ACT_DOM[\"allDomains\"];\n  readonly actionSchema: ACT_DOM[\"actionSchema\"];\n\n  protected _listeners: TRunningActionUpdateListener<any, any>[] = [];\n\n  constructor(definition: ACT_DOM) {\n    this.domain = definition.domain;\n    this.allDomains = definition.allDomains;\n    this.actionSchema = definition.actionSchema;\n  }\n\n  /**\n   * Add an observer that is called after every action dispatched through this domain.\n   * Returns an unsubscribe function — call it to remove the listener.\n   */\n  addActionListener(\n    listener: TDistributeRunningActionUpdateListener<\n      ACT_DOM,\n      keyof ACT_DOM[\"actionSchema\"] & string\n    >,\n  ): () => void {\n    this._listeners.push(listener as TRunningActionUpdateListener<any, any>);\n    return () => {\n      this._listeners = this._listeners.filter((l) => l !== listener);\n    };\n  }\n\n  /**\n   * @internal\n   * Observers registered directly on this domain via {@link addActionListener}.\n   * Used to wire observers (e.g. devtools) onto RunningActions that aren't created\n   * through the local-dispatch path — notably inbound actions pushed from a backend\n   * or another client over a bidirectional transport.\n   */\n  _getActionObservers(): TRunningActionUpdateListener<any, any>[] {\n    return this._listeners;\n  }\n}\n","import {\n  type IRuntimeCoordinate,\n  RuntimeCoordinate,\n  runtimeCoordinateToStringIds,\n  type TRuntimeCoordinateStringId,\n} from \"@nice-code/wire\";\nimport type { TActionPayload_Any_Instance } from \"../ActionDefinition/Action/Payload/ActionPayload.types\";\nimport { EErrId_NiceAction, err_nice_action } from \"../errors/err_nice_action\";\nimport type { ActionRuntime } from \"./ActionRuntime\";\nimport type { IActionHandlerAndRuntime, IActionRuntimeManagerContext } from \"./ActionRuntime.types\";\nimport type { IHandleActionOptions } from \"./Handler/ActionHandler.types\";\n\nexport class ActionRuntimeManager {\n  private _runtimes: Map<TRuntimeCoordinateStringId, ActionRuntime> = new Map();\n  private _preferredRuntimeClientId: TRuntimeCoordinateStringId | null = null;\n  private _context: IActionRuntimeManagerContext;\n\n  constructor(context?: IActionRuntimeManagerContext) {\n    this._context = context ?? {};\n  }\n\n  registerRuntime(runtime: ActionRuntime): void {\n    const runtimeId = runtime.coordinate.stringId;\n    if (this._runtimes.has(runtimeId)) {\n      throw err_nice_action.fromId(EErrId_NiceAction.client_runtime_already_registered, {\n        context: this._context,\n        client: runtime.coordinate,\n      });\n    }\n\n    for (const id of runtime.coordinate.toStringIds()) {\n      if (this._runtimes.has(id)) {\n        continue;\n      }\n\n      this._runtimes.set(id, runtime);\n    }\n  }\n\n  getRuntimeAndHandlerForAction(\n    action: TActionPayload_Any_Instance<any, any>,\n    options?: IHandleActionOptions,\n    throwOnIssue?: boolean,\n  ): IActionHandlerAndRuntime | undefined {\n    const localRuntime = options?.targetLocalRuntime;\n\n    if (localRuntime != null) {\n      const runtime = throwOnIssue\n        ? this.getBestRuntimeOrThrow(options?.targetLocalRuntime?.coordinate)\n        : this.getBestRuntime(options?.targetLocalRuntime?.coordinate);\n\n      if (runtime == null) {\n        return;\n      }\n\n      const handler = runtime._getHandlerForAction(action, options);\n\n      if (handler != null) {\n        return { handler, runtime };\n      }\n\n      if (throwOnIssue) {\n        throw err_nice_action.fromId(EErrId_NiceAction.no_action_execution_handler, {\n          domain: action.domain,\n          actionId: action.id,\n          specifiedClient: localRuntime.coordinate,\n        });\n      }\n    }\n\n    // If no client specified, try to find a runtime that can handle the action\n    for (const runtime of this._runtimes.values()) {\n      const handler = runtime._getHandlerForAction(action);\n      if (handler) {\n        return { handler, runtime };\n      }\n    }\n\n    if (throwOnIssue) {\n      throw err_nice_action.fromId(EErrId_NiceAction.no_action_execution_handler, {\n        domain: action.domain,\n        actionId: action.id,\n        specifiedClient: options?.targetLocalRuntime?.coordinate,\n      });\n    }\n  }\n\n  getRuntimeAndHandlerForActionOrThrow(\n    action: TActionPayload_Any_Instance<any, any>,\n    options?: IHandleActionOptions,\n  ): IActionHandlerAndRuntime {\n    return this.getRuntimeAndHandlerForAction(action, options, true)!;\n  }\n\n  setPreferredRuntime(runtime: ActionRuntime): void {\n    const runtimeId = runtime.coordinate.stringId;\n    this._preferredRuntimeClientId = runtimeId;\n  }\n\n  getPreferredRuntime(): ActionRuntime | undefined {\n    if (this._preferredRuntimeClientId) {\n      const runtime = this._runtimes.get(this._preferredRuntimeClientId);\n      if (runtime) {\n        return runtime;\n      }\n    }\n    return this._runtimes.values().next().value;\n  }\n\n  getBestRuntimeForSpecifier(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined {\n    const actionClient = new RuntimeCoordinate(clientSpecifier);\n    const ids = actionClient.toStringIds();\n\n    for (const id of ids) {\n      const runtime = this._runtimes.get(id);\n      if (runtime) {\n        return runtime;\n      }\n    }\n  }\n\n  getBestRuntime(clientSpecifier?: IRuntimeCoordinate): ActionRuntime | undefined {\n    return clientSpecifier != null\n      ? this.getBestRuntimeForSpecifier(clientSpecifier)\n      : this.getPreferredRuntime();\n  }\n\n  hasRuntime(runtime: ActionRuntime): boolean {\n    return this._runtimes.has(runtime.coordinate.stringId);\n  }\n\n  getBestRuntimeOrThrow(specifier?: IRuntimeCoordinate): ActionRuntime {\n    const runtime = this.getBestRuntime(specifier);\n\n    if (!runtime) {\n      if (specifier == null) {\n        throw err_nice_action.fromId(EErrId_NiceAction.no_client_runtimes_registered, {\n          context: this._context,\n        });\n      }\n\n      throw err_nice_action.fromId(EErrId_NiceAction.client_runtime_not_registered, {\n        context: this._context,\n        clientStringId: runtimeCoordinateToStringIds(specifier)[0],\n      });\n    }\n\n    return runtime;\n  }\n}\n","import type { IRuntimeCoordinate } from \"@nice-code/wire\";\nimport type { ActionRuntime } from \"../../ActionRuntime/ActionRuntime\";\nimport type { IActionHandlerAndRuntime } from \"../../ActionRuntime/ActionRuntime.types\";\nimport { ActionRuntimeManager } from \"../../ActionRuntime/ActionRuntimeManager\";\nimport type { IExecuteActionOptions } from \"../../ActionRuntime/Handler/ActionHandler.types\";\nimport { EErrId_NiceAction, err_nice_action } from \"../../errors/err_nice_action\";\nimport type { ActionPayload_Request } from \"../Action/Payload/ActionPayload_Request\";\nimport { RunningAction } from \"../Action/RunningAction\";\nimport { ActionDomain } from \"./ActionDomain\";\nimport type {\n  IActionDomain,\n  IActionDomainChildOptions,\n  IActionRootDomain,\n  TActionDomainChildDef,\n} from \"./ActionDomain.types\";\nimport { ActionDomainBase } from \"./ActionDomainBase\";\n\nexport class ActionRootDomain<\n  ROOT_DOM extends IActionRootDomain = IActionRootDomain,\n> extends ActionDomainBase<ROOT_DOM> {\n  private _actionRuntimeManager: ActionRuntimeManager;\n\n  constructor(\n    readonly domainDefinition: {\n      domain: ROOT_DOM[\"domain\"];\n    },\n  ) {\n    const domainId = domainDefinition.domain;\n\n    super({\n      domain: domainId,\n      allDomains: [domainId],\n      actionSchema: {},\n    } as ROOT_DOM);\n\n    this._actionRuntimeManager = new ActionRuntimeManager({ domain: domainId });\n  }\n\n  createChildDomain<SUB_DOM extends IActionDomainChildOptions>(\n    subDomainDef: SUB_DOM & {\n      [K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;\n    },\n  ): ActionDomain<TActionDomainChildDef<ROOT_DOM, SUB_DOM>> {\n    if (this.allDomains.includes(subDomainDef.domain)) {\n      throw err_nice_action.fromId(EErrId_NiceAction.domain_already_exists_in_hierarchy, {\n        domain: subDomainDef.domain,\n        allParentDomains: this.allDomains,\n        parentDomain: this.domain,\n      });\n    }\n\n    return new ActionDomain<TActionDomainChildDef<ROOT_DOM, SUB_DOM>>(\n      {\n        allDomains: [...this.allDomains, subDomainDef.domain],\n        domain: subDomainDef.domain,\n        actionSchema: subDomainDef.actions,\n      },\n      { rootDomain: this },\n    );\n  }\n\n  _registerRuntime(runtime: ActionRuntime): void {\n    this._actionRuntimeManager.registerRuntime(runtime);\n  }\n\n  _hasRuntime(runtime: ActionRuntime): boolean {\n    return this._actionRuntimeManager.hasRuntime(runtime);\n  }\n\n  getRuntime(clientSpecifier: IRuntimeCoordinate): ActionRuntime | undefined {\n    return this._actionRuntimeManager.getBestRuntimeForSpecifier(clientSpecifier);\n  }\n\n  async _runAction<\n    DOM extends IActionDomain,\n    ID extends keyof DOM[\"actionSchema\"] & string = keyof DOM[\"actionSchema\"] & string,\n    ACT extends ActionPayload_Request<DOM, ID> = ActionPayload_Request<DOM, ID>,\n  >(actionPayload: ACT, options?: IExecuteActionOptions<DOM, ID>): Promise<RunningAction<DOM, ID>> {\n    const allListeners = [...this._listeners, ...(options?.listeners ?? [])];\n\n    let handlerAndRuntime: IActionHandlerAndRuntime;\n    try {\n      handlerAndRuntime = this._actionRuntimeManager.getRuntimeAndHandlerForActionOrThrow(\n        actionPayload,\n        options,\n      );\n    } catch (err) {\n      const runningAction = new RunningAction<DOM, ID>({\n        context: actionPayload.context,\n        request: actionPayload,\n        callSite: actionPayload._callSite,\n      });\n      runningAction.addUpdateListeners(allListeners);\n      runningAction._failWithError(err);\n      throw err;\n    }\n\n    const { handler, runtime } = handlerAndRuntime;\n\n    actionPayload.context._setOriginClient(runtime.coordinate);\n\n    const runningAction = await handler.handleActionRequest(actionPayload, {\n      targetLocalRuntime: runtime,\n      // Forward the reliable-delivery streamKey (E3) so the connector can scope an independent stream.\n      streamKey: options?.streamKey,\n    });\n\n    runningAction.addUpdateListeners(allListeners);\n\n    return runningAction;\n  }\n}\n","import { castNiceError } from \"@nice-code/error\";\nimport { RuntimeCoordinate } from \"@nice-code/wire\";\nimport type { ActionRuntime } from \"../../ActionRuntime/ActionRuntime\";\nimport type { IExecuteActionOptions } from \"../../ActionRuntime/Handler/ActionHandler.types\";\nimport { ActionLocalHandler } from \"../../ActionRuntime/Handler/Local/ActionLocalHandler\";\nimport { EErrId_NiceAction, err_nice_action } from \"../../errors/err_nice_action\";\nimport { assertIsActionJson } from \"../../utils/assertIsActionJson\";\nimport { isAction_Any_Instance } from \"../../utils/isAction_Any_Instance\";\nimport type {\n  TAction_Any_JsonObject,\n  TDistributeActionPayload_Request,\n  TDistributeActionPayload_Result,\n  TDistributedDomainActions,\n  TNarrowActionJsonTypeToActionInstanceType,\n} from \"../Action/Action.combined.types\";\nimport { EActionForm, type IActionBase } from \"../Action/ActionBase.types\";\nimport { ActionContext } from \"../Action/Context/ActionContext\";\nimport type { IActionContext_Data_JsonObject } from \"../Action/Context/ActionContext.types\";\nimport { ActionCore } from \"../Action/Core/ActionCore\";\nimport {\n  EActionPayloadType,\n  type IActionPayload_Request_JsonObject,\n  type IActionPayload_Result_JsonObject,\n} from \"../Action/Payload/ActionPayload.types\";\nimport { ActionPayload_Request } from \"../Action/Payload/ActionPayload_Request\";\nimport { ActionPayload_Result } from \"../Action/Payload/ActionPayload_Result\";\nimport type { RunningAction } from \"../Action/RunningAction\";\nimport type { TRunningActionUpdateListener } from \"../Action/RunningAction.types\";\nimport type {\n  IActionDomain,\n  IActionDomainChildOptions,\n  TActionDomainChildDef,\n  TWrappableDomainActionHandler,\n} from \"./ActionDomain.types\";\nimport { ActionDomainBase } from \"./ActionDomainBase\";\nimport { type ActionRootDomain } from \"./ActionRootDomain\";\n\ntype TActionMap<ACT_DOM extends IActionDomain> = {\n  [K in keyof ACT_DOM[\"actionSchema\"] & string]: ActionCore<ACT_DOM, K>;\n};\n\nexport class ActionDomain<\n  ACT_DOM extends IActionDomain = IActionDomain,\n> extends ActionDomainBase<ACT_DOM> {\n  private _rootDomain: ActionRootDomain<any>;\n  private readonly _actionMap: TActionMap<ACT_DOM>;\n\n  constructor(\n    definition: ACT_DOM,\n    {\n      rootDomain,\n    }: {\n      rootDomain: ActionRootDomain<any>;\n    },\n  ) {\n    super(definition);\n    this._rootDomain = rootDomain;\n    this._actionMap = this.createActionMap();\n  }\n\n  get rootDomain() {\n    return this._rootDomain;\n  }\n\n  /**\n   * @internal\n   * All action observers that should see actions on this domain: the root domain's\n   * observers plus this subdomain's own. Mirrors the listener set the local-dispatch\n   * path assembles in `runAction`/`_runAction`, so inbound actions (pushed from a\n   * backend or another client) can be wired up identically and surface in devtools.\n   */\n  _collectActionObservers(): TRunningActionUpdateListener<any, any>[] {\n    return [...this._rootDomain._getActionObservers(), ...this._getActionObservers()];\n  }\n\n  _registerRuntime(runtime: ActionRuntime): void {\n    this._rootDomain._registerRuntime(runtime);\n  }\n\n  createChildDomain<SUB_DOM extends IActionDomainChildOptions>(\n    subDomainDef: SUB_DOM & {\n      [K in Exclude<keyof SUB_DOM, keyof IActionDomainChildOptions>]: never;\n    },\n  ): ActionDomain<TActionDomainChildDef<ACT_DOM, SUB_DOM>> {\n    if (this.allDomains.includes(subDomainDef.domain)) {\n      throw err_nice_action.fromId(EErrId_NiceAction.domain_already_exists_in_hierarchy, {\n        domain: subDomainDef.domain,\n        allParentDomains: this.allDomains,\n        parentDomain: this.domain,\n      });\n    }\n\n    return new ActionDomain<TActionDomainChildDef<ACT_DOM, SUB_DOM>>(\n      {\n        allDomains: [...this.allDomains, subDomainDef.domain],\n        domain: subDomainDef.domain,\n        actionSchema: subDomainDef.actions,\n      },\n      { rootDomain: this._rootDomain },\n    );\n  }\n\n  get action(): TActionMap<ACT_DOM> {\n    return this._actionMap;\n  }\n\n  actionsMap(): TActionMap<ACT_DOM> {\n    return this._actionMap;\n  }\n\n  actionForId<ID extends keyof ACT_DOM[\"actionSchema\"] & string>(id: ID): ActionCore<ACT_DOM, ID> {\n    const actionSchema = this.actionSchema[id];\n    if (!actionSchema) {\n      throw err_nice_action.fromId(EErrId_NiceAction.action_id_not_in_domain, {\n        domain: this.domain,\n        actionId: id as string,\n      });\n    }\n\n    return new ActionCore<ACT_DOM, ID>(this, id);\n  }\n\n  wrapAsPartialLocalHandler(\n    wrappedActionExecutor: Partial<TWrappableDomainActionHandler<ACT_DOM>>,\n  ): ActionLocalHandler {\n    const _handler = new ActionLocalHandler();\n    const executor = wrappedActionExecutor as unknown as Record<string, (input: any) => any>;\n\n    for (const actionKey in wrappedActionExecutor) {\n      if (!this.actionSchema[actionKey]) {\n        continue;\n      }\n\n      _handler.forAction(this.actionForId(actionKey), (request) =>\n        executor[request.id](request.input),\n      );\n    }\n\n    return _handler;\n  }\n\n  wrapAsLocalHandler(\n    wrappedActionExecutor: TWrappableDomainActionHandler<ACT_DOM>,\n  ): ActionLocalHandler {\n    const _handler = new ActionLocalHandler();\n    const executor = wrappedActionExecutor as unknown as Record<string, (input: any) => any>;\n    return _handler.forDomain(this, (request) => executor[request.id](request.input));\n  }\n\n  hydrateContext<ID extends keyof ACT_DOM[\"actionSchema\"] & string>(\n    id: ID,\n    contextData: IActionContext_Data_JsonObject,\n  ): ActionContext<ACT_DOM, ID> {\n    return new ActionContext(this, id, {\n      timeCreated: contextData.timeCreated,\n      cuid: contextData.cuid,\n      routing: contextData.routing.map((item) => {\n        return {\n          runtime: new RuntimeCoordinate(item.runtime),\n          handler: item.handler,\n          time: item.time,\n        };\n      }),\n      originClient: contextData.originClient\n        ? new RuntimeCoordinate(contextData.originClient)\n        : RuntimeCoordinate.unknown,\n      // Local-only receiver-side stamp (never on a real wire — the accepting side sets it post-decode).\n      reliability: contextData.reliability,\n    });\n  }\n\n  isDomainAction<ACT extends IActionBase<any, ACT_DOM, any>>(\n    action: ACT | unknown | null | undefined,\n  ): action is TDistributedDomainActions<ACT_DOM, ACT> {\n    return isAction_Any_Instance(action) && action.domain === this.domain;\n  }\n\n  hydrateRequestPayload<\n    ID extends keyof ACT_DOM[\"actionSchema\"] & string,\n    P extends IActionPayload_Request_JsonObject<ACT_DOM, ID>,\n  >(serialized: P): TDistributeActionPayload_Request<ACT_DOM, ID> {\n    if (serialized.type !== EActionPayloadType.request) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_action_state_mismatch, {\n        expected: EActionPayloadType.request,\n        received: serialized.type,\n      });\n    }\n\n    if (serialized.domain !== this.domain) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_domain_mismatch, {\n        expected: this.domain,\n        received: serialized.domain,\n      });\n    }\n\n    const id = serialized.id;\n    if (!this.actionSchema[id]) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_action_id_not_found, {\n        domain: this.domain,\n        actionId: serialized.id,\n      });\n    }\n\n    const contextAction = this.hydrateContext(id, serialized.context);\n\n    return new ActionPayload_Request(\n      { context: contextAction },\n      contextAction.deserializeInput(serialized.input),\n      {\n        time: serialized.time,\n      },\n    ) as TDistributeActionPayload_Request<ACT_DOM, ID>;\n  }\n\n  hydrateResultPayload<\n    ID extends keyof ACT_DOM[\"actionSchema\"] & string,\n    R extends IActionPayload_Result_JsonObject<ACT_DOM, ID>,\n  >(serialized: R): TDistributeActionPayload_Result<ACT_DOM, ID> {\n    if (serialized.type !== EActionPayloadType.result) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_action_state_mismatch, {\n        expected: EActionPayloadType.result,\n        received: serialized.type,\n      });\n    }\n\n    if (serialized.domain !== this.domain) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_domain_mismatch, {\n        expected: this.domain,\n        received: serialized.domain,\n      });\n    }\n\n    const id = serialized.id;\n\n    if (!this.actionSchema[id]) {\n      throw err_nice_action.fromId(EErrId_NiceAction.hydration_action_id_not_found, {\n        domain: this.domain,\n        actionId: serialized.id,\n      });\n    }\n\n    const contextAction = this.hydrateContext(id, serialized.context);\n\n    const result = serialized.result.ok\n      ? {\n          ok: true as const,\n          output: contextAction.schema.deserializeOutput(serialized.result.output),\n        }\n      : // Reconstruct the wire error into a real NiceError so `expected` can be\n        // re-derived against this side's schema and `error` carries its methods.\n        { ok: false as const, error: castNiceError(serialized.result.error) };\n\n    return new ActionPayload_Result({ context: contextAction }, result, {\n      time: serialized.time,\n    }) as TDistributeActionPayload_Result<ACT_DOM, ID>;\n  }\n\n  hydrateAnyAction<\n    ID extends keyof ACT_DOM[\"actionSchema\"] & string,\n    AJ extends TAction_Any_JsonObject<ACT_DOM, ID>,\n  >(actionJson: AJ): TNarrowActionJsonTypeToActionInstanceType<ACT_DOM, AJ, ID> {\n    assertIsActionJson(actionJson);\n\n    if (actionJson.form === EActionForm.data) {\n      if (actionJson.type === EActionPayloadType.request) {\n        return this.hydrateRequestPayload(\n          actionJson,\n        ) as unknown as TNarrowActionJsonTypeToActionInstanceType<ACT_DOM, AJ, ID>;\n      }\n\n      if (actionJson.type === EActionPayloadType.result) {\n        return this.hydrateResultPayload(\n          actionJson,\n        ) as unknown as TNarrowActionJsonTypeToActionInstanceType<ACT_DOM, AJ, ID>;\n      }\n    }\n\n    return this.actionForId(actionJson.id) as TNarrowActionJsonTypeToActionInstanceType<\n      ACT_DOM,\n      AJ,\n      ID\n    >;\n  }\n\n  async runAction<\n    ID extends keyof ACT_DOM[\"actionSchema\"] & string,\n    ACT extends ActionPayload_Request<ACT_DOM, ID>,\n  >(\n    request: ACT,\n    options?: IExecuteActionOptions<ACT_DOM, ID>,\n  ): Promise<RunningAction<ACT_DOM, ID>> {\n    const allListeners: TRunningActionUpdateListener<any, any>[] = [\n      ...(options?.listeners ?? []),\n      ...this._listeners,\n    ];\n\n    return this._rootDomain._runAction(request, {\n      ...options,\n      listeners: allListeners,\n    });\n  }\n\n  private createActionMap(): {\n    [K in keyof ACT_DOM[\"actionSchema\"] & string]: ActionCore<ACT_DOM, K>;\n  } {\n    const map = {} as {\n      [K in keyof ACT_DOM[\"actionSchema\"] & string]: ActionCore<ACT_DOM, K>;\n    };\n\n    for (const id in this.actionSchema) {\n      map[id] = new ActionCore(this, id);\n    }\n\n    return map;\n  }\n}\n","import type { IActionRootDomain } from \"../ActionDomain.types\";\nimport { ActionRootDomain } from \"../ActionRootDomain\";\n\nexport const createActionRootDomain = <ID extends string>(definition: {\n  domain: ID;\n}): ActionRootDomain<IActionRootDomain<ID>> => {\n  return new ActionRootDomain<IActionRootDomain<ID>>(definition);\n};\n","import { type IFetchHandler, type IRouteContext } from \"./forwardTo\";\n\n/**\n * The optional, framework-free multiplexer for a front-door entry. It matches a request path against an\n * ordered list of patterns and dispatches to the first match — where every entry is just an\n * {@link IFetchHandler}: a served channel-set (`serveChannels`/`serveWorker`), an opaque `forwardTo`, or\n * even a whole nested router/sub-app. It also answers the CORS `OPTIONS` preflight once at the edge.\n *\n * You don't need it if you already have a router — the helpers are `{ fetch }`, so in Hono you call them\n * straight from routes (Hono extracts params). `actionRouter` is the batteries-included option for a raw\n * Worker `export default { fetch }`.\n *\n * ```ts\n * const router = actionRouter()\n *   .route(\"/bridge/:id/*\", forwardToDurableObject(({ params }) => env.DO_BRIDGE.get(env.DO_BRIDGE.idFromString(params.id))))\n *   .route(\"/api/*\",        serveApi)         // local final-runtime (a serveWorker { fetch })\n *   .otherwise(restOfApp);                    // anything unmatched → an existing app\n * export default { fetch: (request: Request) => router.fetch(request) };\n * ```\n */\n\n/** Permissive CORS, matching the rest of the action HTTP surface. */\nconst DEFAULT_ROUTER_CORS: Record<string, string> = {\n  \"Access-Control-Allow-Origin\": \"*\",\n  \"Access-Control-Allow-Methods\": \"GET, POST, OPTIONS\",\n  \"Access-Control-Allow-Headers\": \"Content-Type\",\n  \"Access-Control-Max-Age\": \"86400\",\n};\n\n/** A route target: a `{ fetch }` handler, or a bare function receiving the request + matched-route context. */\nexport type TRoutable =\n  | IFetchHandler\n  | ((request: Request, route: IRouteContext) => Promise<Response> | Response);\n\nexport interface IActionRouterOptions {\n  /**\n   * CORS headers for the edge-answered `OPTIONS` preflight on a *matched* route (default: the permissive\n   * `*` set). `false` forwards `OPTIONS` to the matched handler instead. Unmatched requests are never\n   * touched — they fall through to `otherwise` (which may answer its own preflight).\n   */\n  cors?: Record<string, string> | false;\n}\n\ninterface ICompiledRoute {\n  segments: string[];\n  handler: TRoutable;\n}\n\n/**\n * Match a path against a compiled pattern. Supports `:param` (captures one segment) and a `*` segment\n * (matches the remaining path, zero or more segments). Returns the captured params, or `null` on no match.\n */\nfunction matchPath(segments: string[], pathname: string): Record<string, string> | null {\n  const pathSegments = pathname.split(\"/\").filter((segment) => segment.length > 0);\n  const params: Record<string, string> = {};\n\n  for (let i = 0; i < segments.length; i++) {\n    const patternSegment = segments[i];\n    if (patternSegment === \"*\") return params; // wildcard tail — match the rest\n    const pathSegment = pathSegments[i];\n    if (pathSegment == null) return null;\n    if (patternSegment.startsWith(\":\")) {\n      params[patternSegment.slice(1)] = decodeURIComponent(pathSegment);\n    } else if (patternSegment !== pathSegment) {\n      return null;\n    }\n  }\n\n  // All pattern segments consumed with no wildcard: only an exact-length path matches.\n  return pathSegments.length === segments.length ? params : null;\n}\n\nfunction dispatch(\n  handler: TRoutable,\n  request: Request,\n  route: IRouteContext,\n): Promise<Response> | Response {\n  return typeof handler === \"function\" ? handler(request, route) : handler.fetch(request, route);\n}\n\nclass ActionRouter implements IFetchHandler {\n  private readonly routes: ICompiledRoute[] = [];\n  private fallback?: TRoutable;\n\n  constructor(private readonly options: IActionRouterOptions = {}) {}\n\n  /** Add a route. Patterns support `:param` and a trailing `*`. Matched in declaration order, first wins. */\n  route(pattern: string, handler: TRoutable): this {\n    const segments = pattern.split(\"/\").filter((segment) => segment.length > 0);\n    this.routes.push({ segments, handler });\n    return this;\n  }\n\n  /** The handler for any request no route matched (default: a `404`). */\n  otherwise(handler: TRoutable): this {\n    this.fallback = handler;\n    return this;\n  }\n\n  async fetch(request: Request): Promise<Response> {\n    const url = new URL(request.url);\n\n    for (const route of this.routes) {\n      const params = matchPath(route.segments, url.pathname);\n      if (params == null) continue;\n      // Edge-answer the preflight on a matched action route (so a downstream DO is never woken for it).\n      if (request.method === \"OPTIONS\" && this.options.cors !== false) {\n        return new Response(null, {\n          status: 204,\n          headers: this.options.cors ?? DEFAULT_ROUTER_CORS,\n        });\n      }\n      return dispatch(route.handler, request, { url, params });\n    }\n\n    if (this.fallback != null) return dispatch(this.fallback, request, { url, params: {} });\n    return new Response(\"Not found\", { status: 404 });\n  }\n}\n\n/** Create an {@link ActionRouter} — the optional framework-free front-door multiplexer. */\nexport function actionRouter(options?: IActionRouterOptions): ActionRouter {\n  return new ActionRouter(options);\n}\n\nexport type { ActionRouter };\n","import type {\n  IWireDialParams,\n  IWireDuplexCarrierSource,\n  IWireExchangeCarrierSource,\n} from \"@nice-code/wire\";\nimport type { TTransportRouteParams } from \"../Transport.types\";\nimport type { IDuplexCarrierSource, IExchangeCarrierSource } from \"./Carrier.types\";\n\n/**\n * The E2 bridge (shared-base-connect plan, Phase 2): wire's carrier sources are generalized over\n * an opaque dial context, and nice-action's domain concept for it is the whole per-dispatch\n * routing params — the action being sent decides the URL/cache key (e.g. the pixel demo keys its\n * socket by the action's game id). These adapters wrap a wire source instantiated with\n * `TDial = TTransportRouteParams` back into the action-shaped sources the transport\n * factory (and hand-written test carriers) already speak, so consumer code compiles unchanged.\n */\n\nexport function toActionDialParams(\n  input: TTransportRouteParams,\n): IWireDialParams<TTransportRouteParams> {\n  return {\n    localClient: input.localClient,\n    externalClient: input.externalClient,\n    dialContext: input,\n  };\n}\n\nexport function adaptWireDuplexCarrierSource(\n  source: IWireDuplexCarrierSource<TTransportRouteParams>,\n): IDuplexCarrierSource {\n  const { getCacheKey, getRouteInfo } = source;\n  return {\n    carrierLabel: source.carrierLabel,\n    open: (input) => source.open(toActionDialParams(input)),\n    getCacheKey:\n      getCacheKey == null ? undefined : (input) => getCacheKey(toActionDialParams(input)),\n    getRouteInfo:\n      getRouteInfo == null ? undefined : (input) => getRouteInfo(toActionDialParams(input)),\n  };\n}\n\nexport function adaptWireExchangeCarrierSource(\n  source: IWireExchangeCarrierSource<TTransportRouteParams>,\n): IExchangeCarrierSource {\n  const { getCacheKey, getRouteInfo } = source;\n  return {\n    shape: \"exchange\",\n    carrierLabel: source.carrierLabel,\n    open: (input) => source.open(toActionDialParams(input)),\n    getCacheKey:\n      getCacheKey == null ? undefined : (input) => getCacheKey(toActionDialParams(input)),\n    getRouteInfo:\n      getRouteInfo == null ? undefined : (input) => getRouteInfo(toActionDialParams(input)),\n  };\n}\n","import type { IInMemoryServerEndpoint } from \"@nice-code/wire\";\nimport { inMemoryCarrier as wireInMemoryCarrier } from \"@nice-code/wire\";\nimport type { TTransportRouteParams } from \"../../../Transport.types\";\nimport { adaptWireDuplexCarrierSource } from \"../../adaptWireCarrierSource\";\nimport type { IDuplexCarrierSource } from \"../../Carrier.types\";\n\nexport interface IInMemoryCarrier {\n  /** The connector end — pass as the `carrier` to one of `connectChannel`'s transports. */\n  carrier: IDuplexCarrierSource;\n  /** The acceptor end — wire into an `ChannelAcceptor` (`send` + `receive`). */\n  serverEndpoint: IInMemoryServerEndpoint;\n}\n\n/**\n * A loopback duplex carrier with no socket — two cross-wired in-process ends, the action\n * instantiation of wire's `inMemoryCarrier` (plan Phase 2). The connector end is an\n * {@link IDuplexCarrierSource} for `connectChannel`; the acceptor end plugs into an\n * `ChannelAcceptor`. Ideal for tests and for running two runtimes in one process, or proving a\n * non-WS carrier end to end.\n */\nexport function inMemoryCarrier(): IInMemoryCarrier {\n  const { carrier, serverEndpoint } = wireInMemoryCarrier<TTransportRouteParams>();\n  return { carrier: adaptWireDuplexCarrierSource(carrier), serverEndpoint };\n}\n","import type { IRtcDataChannelLike } from \"@nice-code/wire\";\nimport { rtcCarrier as wireRtcCarrier } from \"@nice-code/wire\";\nimport type { ITransportRouteInfo, TTransportRouteParams } from \"../../../Transport.types\";\nimport { adaptWireDuplexCarrierSource } from \"../../adaptWireCarrierSource\";\nimport type { IDuplexCarrierSource } from \"../../Carrier.types\";\n\nexport interface IRtcCarrierOptions {\n  getTransportCacheKey?: (input: TTransportRouteParams) => string[];\n  getRouteInfo?: (input: TTransportRouteParams) => ITransportRouteInfo;\n}\n\n/**\n * A WebRTC {@link IDuplexCarrierSource} over an already-negotiated `RTCDataChannel` (signaling is\n * the app's concern) — the action instantiation of wire's `rtcCarrier` (plan Phase 2 / E2). Pass\n * it as a `carrier` to `connectChannel` so two browsers/apps linked peer-to-peer run the identical\n * secure session as a WebSocket.\n */\nexport function rtcCarrier(\n  dataChannel: IRtcDataChannelLike,\n  options: IRtcCarrierOptions = {},\n): IDuplexCarrierSource {\n  const { getTransportCacheKey, getRouteInfo } = options;\n  return adaptWireDuplexCarrierSource(\n    wireRtcCarrier<TTransportRouteParams>(dataChannel, {\n      getCacheKey:\n        getTransportCacheKey == null\n          ? undefined\n          : (params) => getTransportCacheKey(params.dialContext),\n      getRouteInfo: getRouteInfo == null ? undefined : (params) => getRouteInfo(params.dialContext),\n    }),\n  );\n}\n","import { err } from \"@nice-code/error\";\nimport { err_nice_transport } from \"../../../err_nice_transport\";\n\nexport enum EErrId_NiceTransport_WebSocket {\n  ws_disconnected = \"ws_disconnected\",\n  ws_create_failed = \"ws_create_failed\",\n  ws_error = \"ws_error\",\n}\n\nexport const err_nice_transport_ws = err_nice_transport.createChildDomain({\n  domain: \"err_nice_transport_ws\",\n  schema: {\n    [EErrId_NiceTransport_WebSocket.ws_disconnected]: err<Record<string, never>>({\n      message: () => `WebSocket transport disconnected.`,\n    }),\n    [EErrId_NiceTransport_WebSocket.ws_create_failed]: err<{\n      originalError?: Error;\n    }>({\n      message: ({ originalError }) =>\n        `Failed to create WebSocket transport.${originalError ? ` Original error: ${originalError.message}` : \"\"}`,\n    }),\n    [EErrId_NiceTransport_WebSocket.ws_error]: err<{\n      originalError?: Error;\n    }>({\n      message: ({ originalError }) =>\n        `WebSocket transport error.${originalError ? ` Original error: ${originalError.message}` : \"\"}`,\n    }),\n  },\n});\n","import { type IWsCarrierRequest, wsCarrier as wireWsCarrier } from \"@nice-code/wire\";\nimport type { ITransportRouteInfo, TTransportRouteParams } from \"../../../Transport.types\";\nimport { adaptWireDuplexCarrierSource } from \"../../adaptWireCarrierSource\";\nimport type { IDuplexCarrierSource } from \"../../Carrier.types\";\n\n/** The WebSocket an action's socket is opened against — wire's request shape, re-exported. */\nexport type { IWsCarrierRequest } from \"@nice-code/wire\";\n\nexport interface IWsCarrierOptions {\n  /** Override the reuse key (defaults to `[url]`, so one socket is shared per endpoint). */\n  getTransportCacheKey?: (input: TTransportRouteParams) => string[];\n  /** Override the devtools route info for a specific action. */\n  getRouteInfo?: (input: TTransportRouteParams) => ITransportRouteInfo;\n  /**\n   * Construct the socket for a dial — the **testability seam** (resilience-surface §2): inject a\n   * controllable socket to simulate outage/latency/drops without touching globals. Gates every\n   * dial, keep-alive redials included. Passed straight through to wire's `wsCarrier`.\n   */\n  createWebSocket?: (url: string) => WebSocket;\n}\n\n/**\n * A WebSocket {@link IDuplexCarrierSource}: the action instantiation of wire's `wsCarrier`\n * (shared-base-connect plan, Phase 2 / E2) — the dial context is the per-action routing params,\n * so `createRequest` still derives the socket URL per action exactly as before. Pass it as a\n * `carrier` to `connectChannel`.\n *\n * `createRequest` may return `null` for \"no valid endpoint right now\" (resilience-surface §6) —\n * the keep-alive redial then PARKS instead of dialing garbage, so a dynamic-endpoint teardown\n * (`_activeMatchId = undefined`) needs no careful ordering against `releaseLink()`.\n */\nexport function wsCarrier(\n  createRequest: (input: TTransportRouteParams) => IWsCarrierRequest | null,\n  options: IWsCarrierOptions = {},\n): IDuplexCarrierSource {\n  const { getTransportCacheKey, getRouteInfo, createWebSocket } = options;\n  return adaptWireDuplexCarrierSource(\n    wireWsCarrier<TTransportRouteParams>((params) => createRequest(params.dialContext), {\n      getCacheKey:\n        getTransportCacheKey == null\n          ? undefined\n          : (params) => getTransportCacheKey(params.dialContext),\n      getRouteInfo: getRouteInfo == null ? undefined : (params) => getRouteInfo(params.dialContext),\n      createWebSocket,\n    }),\n  );\n}\n","import { type IHttpCarrierRequest, httpCarrier as wireHttpCarrier } from \"@nice-code/wire\";\nimport type { ITransportRouteInfo, TTransportRouteParams } from \"../../../Transport.types\";\nimport { adaptWireExchangeCarrierSource } from \"../../adaptWireCarrierSource\";\nimport type { IExchangeCarrierSource } from \"../../Carrier.types\";\n\n/** Wire's request shape + fetch slice, re-exported under their pre-move import path. */\nexport type { IHttpCarrierRequest, TCarrierFetch } from \"@nice-code/wire\";\n\nimport type { TCarrierFetch } from \"@nice-code/wire\";\n\nexport interface IHttpCarrierOptions {\n  /** Override the reuse key (defaults to `[url]`, so one session is shared per endpoint). */\n  getTransportCacheKey?: (input: TTransportRouteParams) => string[];\n  /** Override the devtools route info for a specific action. */\n  getRouteInfo?: (input: TTransportRouteParams) => ITransportRouteInfo;\n  /** Override `fetch` (e.g. to route to an in-memory handler in tests). Defaults to global `fetch`. */\n  fetch?: TCarrierFetch;\n}\n\n/**\n * An HTTP {@link IExchangeCarrierSource} — the action instantiation of wire's `httpCarrier` (plan\n * Phase 2 / E2): each `exchange` POSTs one frame body to the action endpoint and resolves with the\n * response body as the single correlated reply. Pass it as a `carrier` to `connectChannel` — a\n * secure HTTP transport then runs the *same* secure session as a duplex carrier.\n */\nexport function httpCarrier(\n  createRequest: (input: TTransportRouteParams) => IHttpCarrierRequest,\n  options: IHttpCarrierOptions = {},\n): IExchangeCarrierSource {\n  const { getTransportCacheKey, getRouteInfo } = options;\n  return adaptWireExchangeCarrierSource(\n    wireHttpCarrier<TTransportRouteParams>((params) => createRequest(params.dialContext), {\n      getCacheKey:\n        getTransportCacheKey == null\n          ? undefined\n          : (params) => getTransportCacheKey(params.dialContext),\n      getRouteInfo: getRouteInfo == null ? undefined : (params) => getRouteInfo(params.dialContext),\n      fetch: options.fetch,\n    }),\n  );\n}\n"],"mappings":";;;;;;;;;AAkBA,IAAa,gBAAb,cAIUA,0CAAAA,WAEV;CAea;CAdX,OAAS;CACT;CACA;CACA;CACA;;;;;;;CAOA;CAEA,YACE,SACA,IACA,eACA;EACA,MAAA,WAA2B,SAAS,EAAE;EAJ7B,KAAA,UAAA;EAKT,KAAK,cAAc,cAAc;EACjC,KAAK,OAAO,cAAc;EAC1B,KAAK,WAAW,cAAc;EAC9B,KAAK,eAAe,cAAc;EAClC,KAAK,cAAc,cAAc;CACnC;CAEA,iBAAiB,QAAiC;EAChD,KAAK,eAAe;CACtB;CAEA,eAAuB;EACrB,OAAO,KAAK,UAAU,KAAK,aAAa,CAAC;CAC3C;CAEA,0BAA0D;EAIxD,OAAO;GACL,aAAa,KAAK;GAClB,MAAM,KAAK;GACX,SAAS,KAAK,QAAQ,KAAK,UAAU;IACnC,SAAS,KAAK,QAAQ,aAAa;IACnC,SAAS,KAAK;IACd,MAAM,KAAK;GACb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