/**
 * @wrnexus/rpc — typed request/response between workspace apps.
 *
 * A contract lives in the workspace's shared package and is imported by both
 * sides: the callee `implement`s it, the caller gets a typed proxy. Types flow
 * through a normal import, so there is no code generator and no generated file
 * to go stale.
 */

export type {
  AnyProcedures,
  InferInput,
  InputSchema,
  InferProcedureInput,
  InferProcedureOutput,
  ProcedureDef,
  ServiceContract,
  ServiceResult,
} from "./types.ts";

export { RPC_ERROR_CODES, ServiceError, failure, isRetryableStatus, success } from "./errors.ts";
export type { RpcErrorCode, ToResultOptions } from "./errors.ts";

export { defineService, procedure, ProcedureBuilder } from "./contract.ts";

export {
  RPC_IDENTITY_HEADER,
  exportSubjectContext,
  importSubjectContext,
  rpcSecret,
} from "./identity.ts";
export type { ExportOptions, ImportOptions, SubjectContext } from "./identity.ts";

export { inProcessTransport, retryingTransport } from "./transport.ts";
export type {
  CallOptions,
  InProcessHandler,
  RetryTransportOptions,
  RpcTarget,
  Transport,
} from "./transport.ts";
export { implement } from "./server.ts";
export type {
  HandlerContext,
  ImplementOptions,
  ServiceHandlers,
  ServiceImplementation,
} from "./server.ts";
export { serviceClient } from "./client.ts";
export type { ServiceClient, ServiceClientOptions } from "./client.ts";
export {
  RPC_INTERNAL_HEADER,
  RPC_PATH_PREFIX,
  httpTransport,
  resolveAppOrigin,
  rpcPath,
} from "./http.ts";
export type { HttpTransportOptions } from "./http.ts";
export { implementStream, rpcStreamPath, RPC_STREAM_PATH_PREFIX, streamClient } from "./stream.ts";
export type {
  StreamClient,
  StreamClientOptions,
  StreamHandlers,
  StreamImplementOptions,
  StreamImplementation,
  StreamMetricsSnapshot,
} from "./stream.ts";
export { StreamMetrics } from "./stream.ts";
