import { z } from 'zod/v4';
import { CoderCreateSkillBucketRequestSchema, CoderCreateCustomSkillRequestSchema, CoderSavedSkillListResponseSchema, CoderSavedSkillSchema, CoderSaveSkillRequestSchema, CoderSkillBucketListResponseSchema, CoderSkillBucketSchema, } from "./types.js";
const SaveSkillResponseSchema = z
    .object({
    skill: CoderSavedSkillSchema.describe('Saved skill payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped save-skill response from coder hub');
const CreateSkillBucketResponseSchema = z
    .object({
    bucket: CoderSkillBucketSchema.describe('Created skill bucket payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped create-skill-bucket response from coder hub');
const OkResponseSchema = z
    .object({
    ok: z.boolean().describe('Operation success indicator'),
})
    .passthrough()
    .describe('Generic ok response from coder hub');
export async function coderListSavedSkills(client) {
    return client.get('/hub/skills/library', CoderSavedSkillListResponseSchema);
}
export async function coderSaveSkill(client, params) {
    const resp = await client.post('/hub/skills/library', params.body, SaveSkillResponseSchema, CoderSaveSkillRequestSchema);
    return resp.skill;
}
export async function coderCreateCustomSkill(client, params) {
    const body = CoderCreateCustomSkillRequestSchema.parse(params.body);
    return coderSaveSkill(client, {
        body: {
            source: 'custom',
            repo: 'custom',
            skillId: body.skillId,
            name: body.name,
            ...(body.description !== undefined ? { description: body.description } : {}),
            content: body.content,
        },
    });
}
export async function coderDeleteSavedSkill(client, params) {
    const path = `/hub/skills/library/${encodeURIComponent(params.skillId)}`;
    await client.delete(path, OkResponseSchema);
}
export async function coderListSkillBuckets(client) {
    return client.get('/hub/skills/buckets', CoderSkillBucketListResponseSchema);
}
export async function coderCreateSkillBucket(client, params) {
    const resp = await client.post('/hub/skills/buckets', params.body, CreateSkillBucketResponseSchema, CoderCreateSkillBucketRequestSchema);
    return resp.bucket;
}
export async function coderDeleteSkillBucket(client, params) {
    const path = `/hub/skills/buckets/${encodeURIComponent(params.bucketId)}`;
    await client.delete(path, OkResponseSchema);
}
//# sourceMappingURL=skills.js.map