import { buildClientHeaders, createServerFetchAdapter, } from '@agentuity/adapter';
import { getEnv } from '@agentuity/config';
import { createMinimalLogger } from "./logger.js";
export { createMinimalLogger } from "./logger.js";
export { ListParamsSchema, PaginatedListSchema, PaginationParamsSchema, SortDirectionSchema, SortParamsSchema, } from "./pagination.js";
export function isLogger(val) {
    return (typeof val === 'object' &&
        val !== null &&
        ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function'));
}
export function resolveApiKey(apiKey) {
    return apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
}
export function resolveRegion() {
    return getEnv('AGENTUITY_REGION') ?? 'usc';
}
export function resolveServiceUrl(options) {
    return options.url || getEnv(options.envKey) || options.fallback;
}
export function createServiceAdapter(options = {}) {
    const logger = options.logger ?? createMinimalLogger();
    const headers = buildClientHeaders({
        apiKey: resolveApiKey(options.apiKey),
        orgId: options.orgId,
    });
    return {
        adapter: createServerFetchAdapter({ headers }, logger),
        logger,
    };
}
//# sourceMappingURL=index.js.map