export { ScheduleService, ScheduleSchema, ScheduleDestinationSchema, ScheduleDeliverySchema, CreateScheduleParamsSchema, UpdateScheduleParamsSchema, CreateScheduleDestinationParamsSchema, ScheduleListResultSchema, ScheduleGetResultSchema, ScheduleCreateResultSchema, ScheduleDeliveryListResultSchema, } from '@agentuity/core/schedule';
import { ScheduleService, } from '@agentuity/core/schedule';
import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/adapter';
import { createMinimalLogger } from '@agentuity/core';
import { getEnv } from '@agentuity/core';
import { getServiceUrls } from '@agentuity/core/config';
import { z } from 'zod';
const isLogger = (val) => typeof val === 'object' &&
    val !== null &&
    ['info', 'warn', 'error', 'debug', 'trace'].every((m) => typeof val[m] === 'function');
export const ScheduleClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the Schedule API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class ScheduleClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = ScheduleClientOptionsSchema.parse(options);
        const apiKey = validatedOptions.apiKey || getEnv('AGENTUITY_SDK_KEY') || getEnv('AGENTUITY_CLI_KEY');
        const region = getEnv('AGENTUITY_REGION') ?? 'usc';
        const serviceUrls = getServiceUrls(region);
        const url = validatedOptions.url || getEnv('AGENTUITY_SCHEDULE_URL') || serviceUrls.catalyst;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, logger);
        this.#service = new ScheduleService(url, adapter);
    }
    async create(params) {
        return this.#service.create(params);
    }
    async list(params) {
        return this.#service.list(params);
    }
    async get(scheduleId) {
        return this.#service.get(scheduleId);
    }
    async update(scheduleId, params) {
        return this.#service.update(scheduleId, params);
    }
    async delete(scheduleId) {
        return this.#service.delete(scheduleId);
    }
    async createDestination(scheduleId, params) {
        return this.#service.createDestination(scheduleId, params);
    }
    async deleteDestination(destinationId) {
        return this.#service.deleteDestination(destinationId);
    }
    async listDeliveries(scheduleId, params) {
        return this.#service.listDeliveries(scheduleId, params);
    }
}
//# sourceMappingURL=index.js.map