import { Context, Effect, Layer, Schema } from "effect";
//#region src/bundle-fs-resolve.d.ts
/**
 * Local-first bundle resolution (ADR 0011 amendment; unified policy, ADR 0021
 * amendment): a self-contained runtime image stages its own namespace under
 * `BOS_BUNDLE_DIR` as `bundles/<account>/<gateway>/<workspace>/…` and consumes
 * those bytes directly from disk; a miss falls through to the network, so a
 * partially-staged namespace boots over the wire instead of failing. The
 * registry tier (children, `BOS_BUNDLE_DIR` unset) keeps the network fetch —
 * the namespace guard below only ever matches the runtime's own
 * account/gateway, never another runtime's layout.
 */
interface BundleNamespace {
  readonly bundleDir: string;
  readonly account: string;
  readonly gateway: string;
}
declare const BundleReadError_base: Schema.Class<BundleReadError, Schema.TaggedStruct<"BundleReadError", {
  readonly path: Schema.String;
  readonly cause: Schema.optional<Schema.Unknown>;
}>, import("effect/Cause").YieldableError>;
declare class BundleReadError extends BundleReadError_base {}
/**
 * Own-namespace path for a bundle URL: the shared URL→staged-path mapping,
 * narrowed to the runtime identity — a URL whose encoded namespace differs
 * from `namespace.account`/`namespace.gateway` must fall to the network/cache
 * path, never serve a sibling namespace's staged bytes.
 */
declare function bundleUrlToLocalPath(url: string, namespace: BundleNamespace): string | null;
declare const BundleResolver_base: Context.ServiceClass<BundleResolver, "everything-dev/bundle-fs-resolve/BundleResolver", {
  /** Resolve a fetch target from the staged namespace; null = miss or not our namespace — fall through to the network. */
  readonly lookup: (input: string | URL | Request) => Effect.Effect<Response | null>;
}>;
declare class BundleResolver extends BundleResolver_base {
  static layer(namespace: BundleNamespace): Layer.Layer<BundleResolver>;
}
interface BundleFetchHandle {
  readonly uninstall: () => Promise<void>;
}
interface BundleFetchOptions {
  /** Own-namespace FS resolution — requires a staged `BOS_BUNDLE_DIR`. */
  namespace?: BundleNamespace;
  /**
   * Foreign-namespace stale-if-error cache (child tier): `/bundles/…` URLs
   * outside the own namespace write through to disk on success and serve
   * the last-known-good bytes when the origin fails. Enabled implicitly
   * when `namespace` is present (deployment contexts), or explicitly via
   * `BOS_BUNDLE_CACHE_DIR`.
   */
  cacheDir?: string;
}
/**
 * Installs the resolver as a global fetch interceptor — the one seam every
 * boot-time consumer shares (config manifest discovery, contract-type
 * fetches, orchestrator host loading, MF remoteEntry/identity probes).
 * One layered resolution policy: staged disk → network → stale-if-error.
 * Own-namespace URLs resolve from the staged directory and fall through to
 * the original fetch on a miss (a partially-staged namespace boots over the
 * wire instead of failing); a miss never touches the write-through cache —
 * for the own namespace the staged disk IS the resilience artifact. Foreign
 * `/bundles/…` URLs get the network with the stale-if-error cache; every
 * other URL falls through to the original fetch untouched. Inert when
 * neither a staged namespace nor a cache is configured.
 */
declare function installGlobalBundleFetch(options: BundleFetchOptions): BundleFetchHandle;
/**
 * Boot-time installer for the CLI: derives the own namespace from
 * `BOS_BUNDLE_DIR` plus the runtime identity (`BOS_ACCOUNT`/`BOS_GATEWAY`
 * registry env taking precedence over the bos.config.json fields), and the
 * foreign-namespace cache from `BOS_BUNDLE_CACHE_DIR`. Tier auto-detection
 * (ADR 0021): an identity whose namespace is not actually staged under the
 * bundle dir drops to the registry tier — plain network fetch — instead of
 * deterministically 404ing own-namespace URLs against a foreign image's
 * staged bytes. Never throws — a missing or malformed identity leaves the
 * default network fetch in place.
 */
declare function installBundleFetchFromEnv(input: {
  configPath?: string | null;
}): BundleFetchHandle | null;
//#endregion
export { BundleFetchHandle, BundleFetchOptions, BundleNamespace, BundleReadError, BundleResolver, bundleUrlToLocalPath, installBundleFetchFromEnv, installGlobalBundleFetch };
//# sourceMappingURL=bundle-fs-resolve.d.cts.map