export * from "./service.js";
export * from "./types.js";
import { KeyValueStorageService, } from "./service.js";
import { getServiceUrls } from '@agentuity/config';
import { createServiceAdapter, isLogger, resolveApiKey, resolveRegion, resolveServiceUrl, } from '@agentuity/client';
import { z } from 'zod';
export const KeyValueClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the KV API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class KeyValueClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = KeyValueClientOptionsSchema.parse(options);
        const serviceUrls = getServiceUrls(resolveRegion());
        const url = resolveServiceUrl({
            url: validatedOptions.url,
            envKey: 'AGENTUITY_KEYVALUE_URL',
            fallback: serviceUrls.keyvalue,
        });
        const { adapter } = createServiceAdapter({
            apiKey: resolveApiKey(validatedOptions.apiKey),
            orgId: validatedOptions.orgId,
            logger: validatedOptions.logger,
        });
        this.#service = new KeyValueStorageService(url, adapter);
    }
    async get(name, key) {
        return this.#service.get(name, key);
    }
    async set(name, key, value, params) {
        return this.#service.set(name, key, value, params);
    }
    async delete(name, key) {
        return this.#service.delete(name, key);
    }
    async getStats(name) {
        return this.#service.getStats(name);
    }
    async getAllStats(params) {
        return this.#service.getAllStats(params);
    }
    async getNamespaces() {
        return this.#service.getNamespaces();
    }
    async search(name, keyword) {
        return this.#service.search(name, keyword);
    }
    async getKeys(name) {
        return this.#service.getKeys(name);
    }
    async deleteNamespace(name) {
        return this.#service.deleteNamespace(name);
    }
    async createNamespace(name, params) {
        return this.#service.createNamespace(name, params);
    }
}
//# sourceMappingURL=index.js.map