import { ToolResult } from '@conveniencepro/ctp-core'; /** * ConveniencePro Tool Protocol (CTP) - Server Runtime * * Node.js-based tool execution runtime. * Uses Node.js APIs (crypto, Buffer, etc.) for processing. * * @module @conveniencepro/ctp-runtime/server */ /** * Check if running in Node.js environment */ declare function isNode(): boolean; /** * Assert Node.js environment */ declare function assertNode(): void; /** * Get Node.js version */ declare function getNodeVersion(): string | null; /** * Encode text to Base64 (Node.js) */ declare function base64Encode(text: string, urlSafe?: boolean): string; /** * Decode Base64 to text (Node.js) */ declare function base64Decode(input: string): string; /** * URL encode text */ declare function urlEncode(text: string): string; /** * URL decode text */ declare function urlDecode(input: string): string; /** * HTML encode (escape special characters) */ declare function htmlEncode(text: string): string; /** * HTML decode (unescape entities) */ declare function htmlDecode(input: string): string; /** * Supported hash algorithms (Node.js naming) */ type HashAlgorithm = 'sha1' | 'sha256' | 'sha384' | 'sha512' | 'md5'; /** * Hash text using Node.js crypto */ declare function hash(text: string, algorithm: HashAlgorithm): Promise; /** * SHA-256 hash */ declare function sha256(text: string): Promise; /** * SHA-512 hash */ declare function sha512(text: string): Promise; /** * SHA-1 hash (deprecated for security) */ declare function sha1(text: string): Promise; /** * MD5 hash (not secure for cryptographic purposes) */ declare function md5(text: string): Promise; /** * Synchronous hash (for SSR where async isn't ideal) */ declare function hashSync(text: string, algorithm: HashAlgorithm): string; /** * Generate a UUID v4 using Node.js crypto */ declare function generateUUID(): Promise; /** * Synchronous UUID generation */ declare function generateUUIDSync(): string; /** * Validate UUID format */ declare function isValidUUID(uuid: string): boolean; /** * Format JSON with indentation */ declare function formatJSON(json: string, indent?: number): ToolResult; /** * Minify JSON */ declare function minifyJSON(json: string): ToolResult; /** * Validate JSON */ declare function validateJSON(json: string): ToolResult; /** * Get text statistics */ declare function getTextStats(text: string): ToolResult; /** * Case conversion types */ type CaseType = 'upper' | 'lower' | 'title' | 'sentence' | 'camel' | 'pascal' | 'snake' | 'kebab' | 'constant'; /** * Convert text case */ declare function convertCase(text: string, to: CaseType): string; /** * Server runtime configuration */ interface ServerRuntimeConfig { /** Timeout for async operations (ms) */ timeout?: number; /** Enable debug logging */ debug?: boolean; } /** * Server runtime instance */ declare class ServerRuntime { private config; constructor(config?: ServerRuntimeConfig); /** * Check environment compatibility */ checkEnvironment(): { compatible: boolean; nodeVersion: string | null; }; /** * Execute a function with timeout */ withTimeout(fn: () => Promise, timeout?: number): Promise; /** * Log debug message */ debug(message: string, ...args: unknown[]): void; } /** * Create a server runtime instance */ declare function createServerRuntime(config?: ServerRuntimeConfig): ServerRuntime; /** * Default server runtime */ declare const serverRuntime: ServerRuntime; export { type CaseType, type HashAlgorithm, ServerRuntime, type ServerRuntimeConfig, assertNode, base64Decode, base64Encode, convertCase, createServerRuntime, formatJSON, generateUUID, generateUUIDSync, getNodeVersion, getTextStats, hash, hashSync, htmlDecode, htmlEncode, isNode, isValidUUID, md5, minifyJSON, serverRuntime, sha1, sha256, sha512, urlDecode, urlEncode, validateJSON };