import { Custody, Loader, Memory, type Entropy, type Module } from '../contract/index.ts'; import { type Carried, type Defaults, type Dialed, type GroundProbe, type Sockets, type TcpListening, type WebListen } from '../harbor/index.ts'; import { PointerTerrain } from '../pointer/index.ts'; export type { Carried } from '../harbor/index.ts'; export declare const EDGE = "edge"; export interface EdgeStorage { get(key: string): Promise; put(entries: Record): Promise; delete(keys: string[]): Promise; list(options: { prefix: string; }): Promise>; transaction(work: (txn: EdgeStorage) => Promise): Promise; } export interface EdgeState { readonly storage: EdgeStorage; blockConcurrencyWhile(work: () => Promise): Promise; } export type EdgeEnv = { readonly NERVUR_SECRET?: string; }; export type EdgeGiven = { readonly state: EdgeState; readonly env: EdgeEnv; readonly loader?: EdgeLoader; readonly calls?: ChildCalls; readonly package?: Packed; }; export type CarriedModule = { readonly blob: string; readonly module: unknown; }; export type CallContext = { run(call: number, work: () => R): R; getStore(): number | undefined; }; export declare class ChildCalls { #private; constructor(context?: CallContext); run(call: number, work: () => R): R; refused(): void; kept(): void; again(call: number): boolean; } export declare class EdgeLoader extends Loader { #private; constructor(carried?: readonly CarriedModule[], calls?: ChildCalls); get carried(): string[]; refuse(refused: Readonly>): void; get refused(): ReadonlyMap; load(source: string, id: string): Promise; get missing(): boolean; missed(): Map; } export type Packed = { readonly sealed: string; readonly places: Carried['places']; }; export type Pack = Record; export declare const isHarborName: (name: unknown) => name is string; export declare const readPack: (value: unknown) => Pack | null; export declare const sealSeed: (secret: string, seed: Uint8Array, entropy?: Entropy) => Promise; export declare class EdgeMemory extends Memory { #private; constructor(storage: EdgeStorage, root?: string, voided?: () => boolean, calls?: ChildCalls); read(place: string): Promise>; write(place: string, entries: ReadonlyMap): Promise; places(): Promise; forget(place: string): Promise; } export declare class EdgeCustody extends Custody { #private; constructor(storage: EdgeStorage, secret: string | undefined, entropy?: Entropy, root?: string); kept(): Promise; land(sealed: string, txn?: EdgeStorage): Promise; seed(): Promise; } export declare class EdgeSockets implements Sockets { #private; dial(address: string, pk: string, bytes: Uint8Array): Promise; listen(): Promise; close(): Promise; } export type EdgeParts = { readonly given: EdgeGiven; readonly defaults: Defaults; }; export declare class EdgeTerrain extends PointerTerrain { #private; readonly given: EdgeGiven; constructor(parts: EdgeParts); get listening(): WebListen | undefined; claim(): Promise; } export declare const edgeGround: GroundProbe; export declare const harborNameOf: (request: Request) => string | null; export type Wanted = { readonly live: string; readonly liveBlobs: readonly string[]; readonly modules: Readonly>; readonly missed: readonly string[]; }; export type Opened = { readonly listen: WebListen | null; readonly wanted: Wanted | null; }; export type Arrived = { readonly reply: Uint8Array | null; readonly wanted: Wanted | null; readonly again: boolean; }; export declare const childKey: (live: string, blobs: readonly string[], liveBlobs: readonly string[]) => string; export declare class HarborChild { #private; constructor(state: EdgeState, env: EdgeEnv, key: string, carried: readonly CarriedModule[], context: CallContext); open(name: string, host: string, port: number, packed: Packed | null, refused: Readonly>): Promise; arrive(pk: string, box: Uint8Array, call: number): Promise; } type WorkerCode = { readonly compatibilityDate: string; readonly compatibilityFlags?: readonly string[]; readonly mainModule: string; readonly modules: Record; readonly env: Record; }; type LoadedWorker = { getDurableObjectClass(name: string): unknown; getEntrypoint(): { fetch(request: Request): Promise; }; }; export type WorkerLoader = { get(id: string, code: () => Promise): LoadedWorker; }; type ChildStub = { open(name: string, host: string, port: number, packed: Packed | null, refused: Record): Promise; arrive(pk: string, box: Uint8Array, call: number): Promise; }; type Facets = { get(name: string, start: () => Promise<{ class: unknown; }>): ChildStub; abort(name: string, reason: unknown): void; }; export type ShellState = { readonly facets: Facets; }; export type ShellEnv = EdgeEnv & { readonly LOADER?: WorkerLoader; }; export type HarborShellParts = { readonly kit: string; readonly pack: Pack | ((env: EdgeEnv) => Pack | undefined); }; export type HarborShell = { fetch(request: Request): Promise; }; export type HarborShellClass = new (state: ShellState, env: ShellEnv) => HarborShell; export declare const harborShell: ({ kit, pack }: HarborShellParts) => HarborShellClass; export declare const harborWorker: (binding?: string) => { fetch(request: Request, env: Record): Promise; };