"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLocalCustomProviderPath = isLocalCustomProviderPath;
exports.assertServerAllowsLocalCustomProviderPath = assertServerAllowsLocalCustomProviderPath;
const LOCAL_PROVIDER_PATH_PATTERN = /\.(py|js|mjs|cjs|ts|go)$/i;
function isLocalCustomProviderPath(path) {
    const trimmed = path.trim();
    if (!trimmed) {
        return false;
    }
    if (trimmed.startsWith('file://')) {
        return true;
    }
    return LOCAL_PROVIDER_PATH_PATTERN.test(trimmed);
}
/**
 * Server-side policy: uploaded Custom AI bundles must run in Azure Sessions, not via local file:// providers.
 * Local paths are allowed only when TRUSYS_ALLOW_LOCAL_CUSTOM_PROVIDER=1 (dev/CLI-adjacent tooling).
 */
function assertServerAllowsLocalCustomProviderPath(providerPath) {
    if (!isLocalCustomProviderPath(providerPath)) {
        return;
    }
    if (process.env.TRUSYS_ALLOW_LOCAL_CUSTOM_PROVIDER === '1') {
        return;
    }
    throw new Error('Local custom provider file paths are disabled on the server. Use Custom AI "Upload Code" with Azure Sessions, or run evaluations via the Trusys CLI.');
}
//# sourceMappingURL=assertCustomAIExecutionPolicy.js.map