export { StreamStorageService, STREAM_MIN_TTL_SECONDS, STREAM_MAX_TTL_SECONDS, STREAM_DEFAULT_TTL_SECONDS, CreateStreamPropsSchema, ListStreamsParamsSchema, ListStreamsResponseSchema, StreamInfoSchema, StreamSortFieldSchema, } from '@agentuity/core/stream';
import { StreamStorageService, } from '@agentuity/core/stream';
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 StreamClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the Stream API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class StreamClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = StreamClientOptionsSchema.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_STREAM_URL') || serviceUrls.stream;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, logger);
        this.#service = new StreamStorageService(url, adapter);
    }
    /**
     * Create a new stream for writing data that can be read multiple times
     */
    async create(namespace, props) {
        return this.#service.create(namespace, props);
    }
    /**
     * Get stream metadata by ID
     */
    async get(id) {
        return this.#service.get(id);
    }
    /**
     * Download stream content
     */
    async download(id) {
        return this.#service.download(id);
    }
    /**
     * List streams with optional filtering and pagination
     */
    async list(params) {
        return this.#service.list(params);
    }
    /**
     * Delete a stream by its ID
     */
    async delete(id) {
        return this.#service.delete(id);
    }
}
//# sourceMappingURL=index.js.map