UNPKG

@tangle-network/tcloud

Version:

TypeScript SDK and CLI for Tangle Router, Sandbox, model routing, and agent service calls

202 lines (201 loc) • 6.38 kB
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const require_client = require("./client-BWymW7iu.cjs"); const require_shielded = require("./shielded.cjs"); const require_sandbox = require("./sandbox.cjs"); let _tangle_network_tcloud_attestation = require("@tangle-network/tcloud-attestation"); //#region src/index.ts /** * tcloud — Tangle AI Cloud SDK * * Drop-in replacement for the OpenAI SDK with decentralized operator routing * and optional privacy via ShieldedCredits. * * Usage: * * ```ts * // Standard mode (like OpenAI SDK) * import { TCloud } from 'tcloud' * const client = new TCloud({ apiKey: 'sk-tan-...' }) * const response = await client.ask('What is Tangle?') * * // Private mode (anonymous, no API key) * const private = TCloud.shielded() * const response = await private.ask('What is Tangle?') * // SpendAuth signed automatically, operator never knows who you are * * // Streaming * for await (const chunk of client.askStream('Tell me a story')) { * process.stdout.write(chunk) * } * * // Full OpenAI-compatible options * const completion = await client.chat({ * model: 'meta-llama/llama-4-maverick', * messages: [ * { role: 'system', content: 'You are helpful.' }, * { role: 'user', content: 'Hello' }, * ], * temperature: 0.7, * maxTokens: 1024, * }) * ``` */ var TCloud = class TCloud extends require_client.TCloudClient { constructor(config) { super(config); } /** * Create a standard client with API key authentication. * * ```ts * const client = TCloud.create({ apiKey: 'sk-tan-...' }) * ``` */ static create(config) { return new TCloud(config); } /** * Create a shielded (private) client. * Generates an ephemeral wallet and signs SpendAuth automatically. * No API key needed. The operator never learns your identity. * * ```ts * const client = TCloud.shielded() * const response = await client.ask('Hello from the shadows') * console.log(client.wallet.commitment) // anonymous credit account * ``` */ static shielded(config) { return require_shielded.createShieldedClient(config); } /** * Create a client that rotates operators per call. * See {@link TCloudClient.rotating} for semantics. * * ```ts * const client = TCloud.rotating({ * apiKey: process.env.TANGLE_API_KEY, * routing: { strategy: 'min-exposure' }, * }) * const stats = client.getRotationStats() * ``` */ static rotating(config) { return require_client.TCloudClient.rotating(config); } /** * Generate a new ephemeral wallet (without creating a client). * * ```ts * const wallet = TCloud.generateWallet() * console.log(wallet.address, wallet.commitment) * ``` */ static generateWallet = require_shielded.generateWallet; /** * Create a Sandbox SDK client using this TCloud client's API key by default. * * ```ts * const tcloud = new TCloud({ apiKey }) * const sandbox = await tcloud.sandbox().create({ name: 'runner' }) * ``` */ sandbox(config = {}) { const apiKey = config.apiKey ?? this.apiKey; if (!apiKey) throw new Error("TCloud.sandbox() requires an apiKey"); return new require_sandbox.TCloudSandbox({ ...config, apiKey }); } /** Create a standalone Sandbox SDK client. */ static sandbox(config) { return new require_sandbox.TCloudSandbox(config); } }; //#endregion exports.BridgeSession = require_client.BridgeSession; exports.MIN_CHILD_KEY_BUDGET_USD = require_client.MIN_CHILD_KEY_BUDGET_USD; exports.ParentBudgetExhaustedError = require_client.ParentBudgetExhaustedError; exports.PrivateRouter = require_client.PrivateRouter; exports.TCloud = TCloud; exports.TCloudClient = require_client.TCloudClient; exports.TCloudError = require_client.TCloudError; exports.TCloudSandbox = require_sandbox.TCloudSandbox; Object.defineProperty(exports, "assertAttestation", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.assertAttestation; } }); Object.defineProperty(exports, "createNitroHardwareVerifier", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.createNitroHardwareVerifier; } }); Object.defineProperty(exports, "createSevSnpHardwareVerifier", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.createSevSnpHardwareVerifier; } }); exports.createShieldedClient = require_shielded.createShieldedClient; Object.defineProperty(exports, "createTdxHardwareVerifier", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.createTdxHardwareVerifier; } }); exports.createTeeAttestationChallenge = require_sandbox.createTeeAttestationChallenge; exports.deriveChildBudgetUsd = require_client.deriveChildBudgetUsd; exports.estimateCost = require_shielded.estimateCost; exports.formatModelNotAllowedRefusal = require_client.formatModelNotAllowedRefusal; exports.generateAttestationNonce = require_sandbox.generateAttestationNonce; exports.generateWallet = require_shielded.generateWallet; Object.defineProperty(exports, "normalizeTeeType", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.normalizeTeeType; } }); Object.defineProperty(exports, "parseAttestation", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.parseAttestation; } }); exports.parseModelNotAllowed = require_client.parseModelNotAllowed; Object.defineProperty(exports, "parseNitroAttestationDocument", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.parseNitroAttestationDocument; } }); Object.defineProperty(exports, "parseSevSnpReport", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.parseSevSnpReport; } }); exports.resolveModelWithinAllowList = require_client.resolveModelWithinAllowList; exports.signSpendAuth = require_shielded.signSpendAuth; exports.startTeeAttestationHeartbeat = require_sandbox.startTeeAttestationHeartbeat; Object.defineProperty(exports, "toHex", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.toHex; } }); Object.defineProperty(exports, "verifyAttestation", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.verifyAttestation; } }); Object.defineProperty(exports, "verifyAttestationAsync", { enumerable: true, get: function() { return _tangle_network_tcloud_attestation.verifyAttestationAsync; } });