/**
 * Cloudflare AI API
 *
 * Generated from Cloudflare TypeScript SDK.
 * DO NOT EDIT - regenerate with: bun scripts/generate.ts --service ai
 */
import * as Schema from "effect/Schema";
import * as API from "../client/api.js";
import * as T from "../traits.js";
import {} from "../errors.js";
import { UploadableSchema } from "../schemas.js";
// =============================================================================
// Errors
// =============================================================================
export class AccountNotFound extends Schema.TaggedErrorClass()("AccountNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(AccountNotFound, [{ code: 7003 }]);
export class ModelNotFound extends Schema.TaggedErrorClass()("ModelNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ModelNotFound, [{ code: 7003 }, { code: 7000 }]);
export class ModelNotSupported extends Schema.TaggedErrorClass()("ModelNotSupported", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ModelNotSupported, [{ code: 1000 }]);
export class ModelSchemaNotFound extends Schema.TaggedErrorClass()("ModelSchemaNotFound", { code: Schema.Number, message: Schema.String }) {
}
T.applyErrorMatchers(ModelSchemaNotFound, [{ code: 6002 }]);
export const RunAiRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    modelName: Schema.String.pipe(T.HttpPath("modelName")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    text: Schema.String,
}).pipe(T.Http({ method: "POST", path: "/accounts/{account_id}/ai/run/{modelName}" }));
export const RunAiResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Union([
    Schema.Struct({
        text: Schema.String,
        vtt: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        wordCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        words: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                end: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                start: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                word: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        text: "text",
        vtt: "vtt",
        wordCount: "word_count",
        words: "words",
    })),
    Schema.Struct({
        response: Schema.String,
        toolCalls: Schema.optional(Schema.Union([
            Schema.Array(Schema.Struct({
                arguments: Schema.optional(Schema.Union([Schema.Unknown, Schema.Null])),
                name: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
            })),
            Schema.Null,
        ])),
        usage: Schema.optional(Schema.Union([
            Schema.Struct({
                completionTokens: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                promptTokens: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                totalTokens: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }).pipe(Schema.encodeKeys({
                completionTokens: "completion_tokens",
                promptTokens: "prompt_tokens",
                totalTokens: "total_tokens",
            })),
            Schema.Null,
        ])),
    }).pipe(Schema.encodeKeys({
        response: "response",
        toolCalls: "tool_calls",
        usage: "usage",
    })),
    Schema.Array(Schema.Struct({
        label: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        score: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    })),
    UploadableSchema.pipe(T.HttpFormDataFile()),
    Schema.Struct({
        audio: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }),
    Schema.Struct({
        data: Schema.optional(Schema.Union([Schema.Array(Schema.Array(Schema.Number)), Schema.Null])),
        shape: Schema.optional(Schema.Union([Schema.Array(Schema.Number), Schema.Null])),
    }),
    Schema.Array(Schema.Struct({
        box: Schema.optional(Schema.Union([
            Schema.Struct({
                xmax: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                xmin: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                ymax: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
                ymin: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            }),
            Schema.Null,
        ])),
        label: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
        score: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
    })),
    Schema.Struct({
        translatedText: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({ translatedText: "translated_text" })),
    Schema.Struct({
        summary: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }),
    Schema.Struct({
        description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }),
]).pipe(T.ResponsePath("result"));
export const runAi = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: RunAiRequest,
    output: RunAiResponse,
    errors: [ModelNotFound],
}));
export const ListAuthorsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/ai/authors/search" }));
export const ListAuthorsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Unknown),
});
export const listAuthors = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListAuthorsRequest,
    output: ListAuthorsResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const ListFinetunesRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/ai/finetunes" }));
export const ListFinetunesResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Array(Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    model: Schema.String,
    modifiedAt: Schema.String,
    name: Schema.String,
    description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
}).pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    model: "model",
    modifiedAt: "modified_at",
    name: "name",
    description: "description",
}))).pipe(T.ResponsePath("result"));
export const listFinetunes = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: ListFinetunesRequest,
    output: ListFinetunesResponse,
    errors: [AccountNotFound],
}));
export const CreateFinetuneRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    model: Schema.String,
    name: Schema.String,
    description: Schema.optional(Schema.String),
    public: Schema.optional(Schema.Boolean),
}).pipe(T.Http({ method: "POST", path: "/accounts/{account_id}/ai/finetunes" }));
export const CreateFinetuneResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    id: Schema.String,
    createdAt: Schema.String,
    model: Schema.String,
    modifiedAt: Schema.String,
    name: Schema.String,
    public: Schema.Boolean,
    description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
})
    .pipe(Schema.encodeKeys({
    id: "id",
    createdAt: "created_at",
    model: "model",
    modifiedAt: "modified_at",
    name: "name",
    public: "public",
    description: "description",
}))
    .pipe(T.ResponsePath("result"));
export const createFinetune = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateFinetuneRequest,
    output: CreateFinetuneResponse,
    errors: [ModelNotSupported, AccountNotFound],
}));
export const CreateFinetuneAssetRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    finetuneId: Schema.String.pipe(T.HttpPath("finetuneId")),
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    file: Schema.optional(UploadableSchema.pipe(T.HttpFormDataFile())),
    fileName: Schema.optional(Schema.String),
}).pipe(Schema.encodeKeys({ file: "file", fileName: "file_name" }), T.Http({
    method: "POST",
    path: "/accounts/{account_id}/ai/finetunes/{finetuneId}/finetune-assets",
    contentType: "multipart",
}));
export const CreateFinetuneAssetResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    success: Schema.Boolean,
});
export const createFinetuneAsset = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: CreateFinetuneAssetRequest,
    output: CreateFinetuneAssetResponse,
    errors: [ModelNotSupported, AccountNotFound],
}));
export const ListFinetunePublicsRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    limit: Schema.optional(Schema.Number).pipe(T.HttpQuery("limit")),
    offset: Schema.optional(Schema.Number).pipe(T.HttpQuery("offset")),
    orderBy: Schema.optional(Schema.String).pipe(T.HttpQuery("orderBy")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/ai/finetunes/public",
}));
export const ListFinetunePublicsResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        id: Schema.String,
        createdAt: Schema.String,
        model: Schema.String,
        modifiedAt: Schema.String,
        name: Schema.String,
        public: Schema.Boolean,
        description: Schema.optional(Schema.Union([Schema.String, Schema.Null])),
    }).pipe(Schema.encodeKeys({
        id: "id",
        createdAt: "created_at",
        model: "model",
        modifiedAt: "modified_at",
        name: "name",
        public: "public",
        description: "description",
    }))),
});
export const listFinetunePublics = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListFinetunePublicsRequest,
    output: ListFinetunePublicsResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const ListModelsRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    page: Schema.optional(Schema.Number).pipe(T.HttpQuery("page")),
    perPage: Schema.optional(Schema.Number).pipe(T.HttpQuery("per_page")),
    author: Schema.optional(Schema.String).pipe(T.HttpQuery("author")),
    hideExperimental: Schema.optional(Schema.Boolean).pipe(T.HttpQuery("hide_experimental")),
    search: Schema.optional(Schema.String).pipe(T.HttpQuery("search")),
    source: Schema.optional(Schema.Number).pipe(T.HttpQuery("source")),
    task: Schema.optional(Schema.String).pipe(T.HttpQuery("task")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/ai/models/search" }));
export const ListModelsResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Unknown),
    resultInfo: Schema.optional(Schema.Union([
        Schema.Struct({
            count: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            page: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            perPage: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
            totalCount: Schema.optional(Schema.Union([Schema.Number, Schema.Null])),
        }).pipe(Schema.encodeKeys({
            count: "count",
            page: "page",
            perPage: "per_page",
            totalCount: "total_count",
        })),
        Schema.Null,
    ])),
}).pipe(Schema.encodeKeys({ result: "result", resultInfo: "result_info" }));
export const listModels = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListModelsRequest,
    output: ListModelsResponse,
    errors: [],
    pagination: {
        mode: "page",
        inputToken: "page",
        outputToken: "resultInfo.page",
        items: "result",
        pageSize: "perPage",
    },
}));
export const GetModelSchemaRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
    model: Schema.String.pipe(T.HttpQuery("model")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/ai/models/schema" }));
export const GetModelSchemaResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Unknown.pipe(T.ResponsePath("result"));
export const getModelSchema = /*@__PURE__*/ /*#__PURE__*/ API.make(() => ({
    input: GetModelSchemaRequest,
    output: GetModelSchemaResponse,
    errors: [ModelNotSupported, ModelSchemaNotFound, AccountNotFound],
}));
export const ListTasksRequest = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "GET", path: "/accounts/{account_id}/ai/tasks/search" }));
export const ListTasksResponse = /*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Unknown),
});
export const listTasks = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: ListTasksRequest,
    output: ListTasksResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const SupportedToMarkdownRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({
    method: "GET",
    path: "/accounts/{account_id}/ai/tomarkdown/supported",
}));
export const SupportedToMarkdownResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        extension: Schema.String,
        mimeType: Schema.String,
    })),
});
export const supportedToMarkdown = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: SupportedToMarkdownRequest,
    output: SupportedToMarkdownResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
export const TransformToMarkdownRequest = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    accountId: Schema.String.pipe(T.HttpPath("account_id")),
}).pipe(T.Http({ method: "POST", path: "/accounts/{account_id}/ai/tomarkdown" }));
export const TransformToMarkdownResponse = 
/*@__PURE__*/ /*#__PURE__*/ Schema.Struct({
    result: Schema.Array(Schema.Struct({
        data: Schema.String,
        format: Schema.String,
        mimeType: Schema.String,
        name: Schema.String,
        tokens: Schema.String,
    })),
});
export const transformToMarkdown = /*@__PURE__*/ /*#__PURE__*/ API.makePaginated(() => ({
    input: TransformToMarkdownRequest,
    output: TransformToMarkdownResponse,
    errors: [],
    pagination: {
        mode: "single",
        items: "result",
    },
}));
//# sourceMappingURL=ai.js.map