@tangle-network/tcloud
Version:
TypeScript SDK and CLI for Tangle Router, Sandbox, model routing, and agent service calls
54 lines • 1.77 kB
text/typescript
import { Et as SpendAuth, Ot as TCloudConfig, o as TCloudClient } from "./client-EyknRDtd.cjs";
import { Hex } from "viem";
//#region src/shielded.d.ts
interface ShieldedWallet {
/** Ephemeral spending private key (hex) */
privateKey: Hex;
/** Derived address */
address: string;
/** Credit account commitment */
commitment: Hex;
/** Random salt */
salt: Hex;
}
/** Generate a new ephemeral shielded wallet */
declare function generateWallet(): ShieldedWallet;
/** Sign a SpendAuth for a request */
declare function signSpendAuth(wallet: ShieldedWallet, params: {
serviceId: bigint;
jobIndex: number;
amount: bigint;
operator: Hex;
nonce: bigint;
expiry: bigint;
chainId: number;
creditsAddress: Hex;
}): Promise<SpendAuth>;
/** Estimate cost in tsUSD base units (6 decimals) */
declare function estimateCost(inputTokens: number, maxOutputTokens: number, inputPricePerM?: number, outputPricePerM?: number): bigint;
interface AutoReplenishOptions {
minBalance: bigint;
replenishAmount: bigint;
checkIntervalMs?: number;
fundingSource: 'relayer' | 'direct';
relayerUrl?: string;
fundingWalletKey?: Hex;
tokenAddress?: Hex;
}
/**
* Create a shielded TCloudClient that signs SpendAuth automatically.
* Every request is anonymous — no API key, no identity.
*/
declare function createShieldedClient(config?: TCloudConfig & {
wallet?: ShieldedWallet;
operatorAddress?: Hex;
chainId?: number;
creditsAddress?: Hex;
serviceId?: bigint;
autoReplenish?: AutoReplenishOptions;
}): TCloudClient & {
wallet: ShieldedWallet;
stopAutoReplenish: () => void;
};
//#endregion
export { generateWallet as a, estimateCost as i, ShieldedWallet as n, signSpendAuth as o, createShieldedClient as r, AutoReplenishOptions as t };