/** * @license * Copyright 2023 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { InputValues, Kit, NodeHandlers, NodeTypeIdentifier, NodeValue, OutputValues } from "@breadboard-ai/types"; import { ProxyServerConfig, TunnelDestinations, TunnelConstraints, TunnelSpec } from "./config.js"; /** * Polyfill for atob and btoa. */ export declare const atob: (str: string) => string; export declare const btoa: (str: string) => string; /** * All tunnels defined for a particular node (the tunnel entry). */ export type NodeTunnels = { [outputName: string]: NodeTunnel[]; }; /** * The map of the entire network of tunnels for all nodes. */ export type TunnelMap = { [node: NodeTypeIdentifier]: NodeTunnels; }; export type TunnelDestinationMap = { [destinationNode: NodeTypeIdentifier]: NodeTunnel[]; }; export declare class NodeTunnel implements TunnelDestinations { readonly outputName: string; readonly from: NodeTypeIdentifier; readonly to: NodeTypeIdentifier; readonly when: TunnelConstraints; constructor(outputName: string, from: NodeTypeIdentifier, to: NodeTypeIdentifier, when?: TunnelConstraints); getInputNames(): string[]; matches(inputs: InputValues): boolean; } export declare const readConfig: (config: ProxyServerConfig) => TunnelMap; export declare const readNodeSpec: (node: NodeTypeIdentifier, spec: TunnelSpec) => NodeTunnels; type OutputReplacer = (outputName: string, outputValue: NodeValue) => NodeValue; export declare const replaceOutputs: (outputs: void | OutputValues, tunnels: NodeTunnels, replacer: OutputReplacer) => void | OutputValues; type InputReplacer = (inputValue: NodeValue, allow: boolean) => Promise; export declare const replaceInputs: (inputs: InputValues, tunnels: NodeTunnel[], replacer: InputReplacer) => Promise; export declare const getTunnelValue: (nodeType: NodeTypeIdentifier, outputName: string, inputs: InputValues) => string; type TunnelScanResult = ({ value: string; } | { nodeType: NodeTypeIdentifier; outputName: string; inputs: string; })[]; export declare const scanTunnelValue: (value: string) => TunnelScanResult; type TunnelValueReplacer = (nodeType: NodeTypeIdentifier, inputs: InputValues) => Promise; export declare const replaceTunnelledInputs: (input: NodeValue, /** * If true, the tunneled inputs will be replaced with the original value. * If false, the tunneled inputs should be blocked. The tunnel value * is replaced with a BLOCKED_TUNNEL_VALUE. */ allow: boolean, replacer: TunnelValueReplacer) => Promise; export declare const createDestinationMap: (map: TunnelMap) => TunnelDestinationMap; /** * A special kit that provides tunneling of outputs and inputs as specified * by the Tunnels spec. * * This kit is constructed from existing NodeHandlers and the Tunnels spec. * It reads the spec and wraps the node handlers to add the tunneling logic. * * The tunnel entries, or the outputs of nodes that are tunneled, are replaced * with a special value that is computed from the node type and the output name. * * The tunnel destinations, or the inputs of the nodes to which a tunnel leads, are * replaced with the original value of the tunnel entry. */ export declare const createTunnelKit: (map: TunnelMap, handlers: NodeHandlers) => Kit; export {}; //# sourceMappingURL=tunnel.d.ts.map