import type { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve';
/** The detected JavaScript runtime environment */
export type RuntimePlatform = 'node' | 'bun';
/**
 * The esbuild/bundler platform setting.
 * - 'node': Assumes Node.js environment, externalizes built-in modules
 * - 'browser': Assumes browser environment, polyfills Node APIs
 * - 'neutral': Runtime-agnostic, preserves all globals as-is (used for Bun)
 */
export type BundlerPlatform = 'node' | 'browser' | 'neutral';
/**
 * Get nodeResolve plugin options based on the target platform.
 *
 * For 'browser' platform (e.g., Cloudflare Workers), uses browser-compatible
 * export conditions so packages like the Cloudflare SDK resolve to their
 * web runtime instead of Node.js-specific code.
 *
 * For 'node' and 'neutral' (Bun) platforms, uses Node.js module resolution.
 */
export declare function getNodeResolveOptions(platform: BundlerPlatform): RollupNodeResolveOptions;
/**
 * Detect the current JavaScript runtime environment.
 *
 * This is used by the bundler to determine the appropriate esbuild platform
 * setting. When running under Bun, we need to use 'neutral' platform to
 * preserve Bun-specific globals (like Bun.s3).
 */
export declare function detectRuntime(): RuntimePlatform;
export declare function upsertMastraDir({ dir }: {
    dir?: string;
}): void;
export declare function isDependencyPartOfPackage(dep: string, packageName: string): boolean;
/**
 * Get the package name from a module ID
 */
export declare function getPackageName(id: string): string | undefined;
/**
 * Check if an import specifier uses a protocol scheme rather than a package name.
 * Examples: `cloudflare:workers`, `data:text/javascript,...`, `node:fs`.
 */
export declare function hasImportProtocol(specifier: string): boolean;
/**
 * Check if a specifier uses a non-builtin protocol that should be preserved at
 * runtime instead of being treated as an installable dependency.
 */
export declare function isExternalProtocolImport(specifier: string, excludeList?: readonly string[]): boolean;
/**
 * During `mastra dev` we are compiling TS files to JS (inside workspaces) so that users can just their workspace packages.
 * We store these compiled files inside `node_modules/.cache` for each workspace package.
 */
export declare function getCompiledDepCachePath(rootPath: string, packageName: string): string;
/**
 * Convert windows backslashes to posix slashes
 *
 * @example
 * ```ts
 * slash('C:\\Users\\user\\code\\mastra') // 'C:/Users/user/code/mastra'
 * ```
 */
export declare function slash(path: string): string;
/**
 * Make a Rollup-safe name: pathless, POSIX, and without parent/absolute segments
 */
export declare function rollupSafeName(name: string, rootDir: string): string;
/**
 * Finds the first real package from node_modules that likely contains native bindings, filtering out virtual modules and native binding loader infrastructure.
 *
 * @param moduleIds - Array of module IDs from a Rollup chunk
 * @returns The module ID of the actual native package, or undefined if not found
 *
 * @example
 * const moduleIds = [
 *   '\x00/path/node_modules/bcrypt/bcrypt.js?commonjs-module',
 *   '/path/node_modules/node-gyp-build/index.js',
 *   '/path/node_modules/bcrypt/bcrypt.js',
 * ];
 * findNativePackageModule(moduleIds); // Returns '/path/node_modules/bcrypt/bcrypt.js'
 */
export declare function findNativePackageModule(moduleIds: string[]): string | undefined;
/**
 * Ensures that server.studioBase is normalized:
 * - Adds leading slash if missing (e.g., 'admin' → '/admin')
 * - Removes trailing slashes (e.g., '/admin/' → '/admin')
 * - Normalizes multiple slashes to single slash (e.g., '//api' → '/api')
 * - Returns empty string for root paths ('/' or '')
 *
 * @param studioBase - The studioBase path to normalize
 * @returns Normalized studioBase path string
 * @throws Error if path contains invalid characters ('..', '?', '#')
 */
export declare function normalizeStudioBase(studioBase: string): string;
/**
 * Configuration values for Studio's index.html placeholder injection.
 *
 * Each value is the **exact JavaScript expression** that replaces the
 * corresponding `'%%PLACEHOLDER%%'` token (including surrounding quotes).
 *
 * For literal strings pass `"'value'"` (quoted).
 * For runtime expressions pass the raw JS, e.g. `"window.location.hostname"`.
 */
export interface StudioInjectionConfig {
    host: string;
    port: string;
    protocol: string;
    apiPrefix: string;
    basePath: string;
    hideCloudCta: string;
    cloudApiEndpoint: string;
    experimentalFeatures: string;
    templates: string;
    telemetryDisabled: string;
    requestContextPresets: string;
    experimentalUI: string;
    agentSignals: string;
    autoDetectUrl?: string;
}
/**
 * Replace all `%%MASTRA_*%%` placeholders in the Studio `index.html` with the
 * supplied configuration values.
 *
 * The `<base href>` tag and the `window.MASTRA_STUDIO_BASE_PATH` assignment
 * use `basePath` as a plain string (no surrounding quotes), while all other
 * placeholders replace `'%%TOKEN%%'` (with surrounding single-quotes in the
 * source HTML) with the provided expression verbatim.
 */
export declare function injectStudioHtmlConfig(html: string, config: StudioInjectionConfig): string;
/**
 * Check if a module is a Node.js builtin module
 * @param specifier - Module specifier
 * @returns True if it's a builtin module
 */
export declare function isBuiltinModule(specifier: string): boolean;
/**
 * Check whether a module specifier is a bare module import rather than a path,
 * virtual module, or Node builtin.
 */
export declare function isBareModuleSpecifier(specifier: string): boolean;
//# sourceMappingURL=utils.d.ts.map