export { TaskStorageService, TaskSchema, TaskPrioritySchema, TaskTypeSchema, TaskStatusSchema, EntityRefSchema, UserTypeSchema, UserEntityRefSchema, CommentSchema, TagSchema, TaskChangelogEntrySchema, CreateTaskParamsSchema, UpdateTaskParamsSchema, ListTasksParamsSchema, ListTasksResultSchema, BatchDeleteTasksParamsSchema, BatchDeleteTasksResultSchema, TaskChangelogResultSchema, ListCommentsResultSchema, ListTagsResultSchema, AttachmentSchema, CreateAttachmentParamsSchema, PresignUploadResponseSchema, PresignDownloadResponseSchema, ListAttachmentsResultSchema, ListUsersResultSchema, ListProjectsResultSchema, TaskActivityParamsSchema, TaskActivityResultSchema, normalizeTaskStatus, } from '@agentuity/core/task';
import { TaskStorageService, } from '@agentuity/core/task';
import { createServerFetchAdapter, buildClientHeaders } from '@agentuity/server';
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 TaskClientOptionsSchema = z.object({
    apiKey: z.string().optional().describe('API key for authentication'),
    url: z.string().optional().describe('Base URL for the Task API'),
    orgId: z.string().optional().describe('Organization ID for multi-tenant operations'),
    logger: z.custom(isLogger).optional().describe('Custom logger instance'),
});
export class TaskClient {
    #service;
    constructor(options = {}) {
        const validatedOptions = TaskClientOptionsSchema.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_TASK_URL') || serviceUrls.catalyst;
        const logger = validatedOptions.logger ?? createMinimalLogger();
        const headers = buildClientHeaders({
            apiKey,
            orgId: validatedOptions.orgId,
        });
        const adapter = createServerFetchAdapter({ headers }, logger);
        this.#service = new TaskStorageService(url, adapter);
    }
    async create(params) {
        return this.#service.create(params);
    }
    async get(id) {
        return this.#service.get(id);
    }
    async list(params) {
        return this.#service.list(params);
    }
    async update(id, params) {
        return this.#service.update(id, params);
    }
    async close(id) {
        return this.#service.close(id);
    }
    async softDelete(id) {
        return this.#service.softDelete(id);
    }
    async changelog(id, params) {
        return this.#service.changelog(id, params);
    }
    async createComment(taskId, body, userId, author) {
        return this.#service.createComment(taskId, body, userId, author);
    }
    async getComment(commentId) {
        return this.#service.getComment(commentId);
    }
    async updateComment(commentId, body) {
        return this.#service.updateComment(commentId, body);
    }
    async deleteComment(commentId) {
        return this.#service.deleteComment(commentId);
    }
    async listComments(taskId, params) {
        return this.#service.listComments(taskId, params);
    }
    async createTag(name, color) {
        return this.#service.createTag(name, color);
    }
    async getTag(tagId) {
        return this.#service.getTag(tagId);
    }
    async updateTag(tagId, name, color) {
        return this.#service.updateTag(tagId, name, color);
    }
    async deleteTag(tagId) {
        return this.#service.deleteTag(tagId);
    }
    async listTags() {
        const result = await this.#service.listTags();
        return result.tags;
    }
    async addTagToTask(taskId, tagId) {
        return this.#service.addTagToTask(taskId, tagId);
    }
    async removeTagFromTask(taskId, tagId) {
        return this.#service.removeTagFromTask(taskId, tagId);
    }
    async listTagsForTask(taskId) {
        return this.#service.listTagsForTask(taskId);
    }
    async uploadAttachment(taskId, params) {
        return this.#service.uploadAttachment(taskId, params);
    }
    async confirmAttachment(attachmentId) {
        return this.#service.confirmAttachment(attachmentId);
    }
    async downloadAttachment(attachmentId) {
        return this.#service.downloadAttachment(attachmentId);
    }
    async listAttachments(taskId) {
        return this.#service.listAttachments(taskId);
    }
    async deleteAttachment(attachmentId) {
        return this.#service.deleteAttachment(attachmentId);
    }
    async listUsers() {
        return this.#service.listUsers();
    }
    async listProjects() {
        return this.#service.listProjects();
    }
    async getActivity(params) {
        return this.#service.getActivity(params);
    }
}
//# sourceMappingURL=index.js.map