import { z } from 'zod/v4';
import { CoderCreateCustomAgentRequestSchema, CoderCustomAgentListResponseSchema, CoderCustomAgentSchema, CoderCustomAgentVersionListResponseSchema, CoderUpdateCustomAgentRequestSchema, } from "./types.js";
const CustomAgentResponseSchema = z
    .object({
    agent: CoderCustomAgentSchema.describe('Custom agent payload returned by coder hub'),
})
    .passthrough()
    .describe('Wrapped custom agent response from coder hub');
export const CoderCustomAgentIdParamsSchema = z
    .object({
    agentIdOrSlug: z.string().describe('Custom agent id or slug'),
    orgId: z.string().optional().describe('Optional org id for CLI auth context'),
})
    .describe('Common parameters for single custom-agent operations');
export const CoderListCustomAgentsParamsSchema = z
    .object({
    includeArchived: z
        .boolean()
        .optional()
        .describe('Whether archived custom agents should be included'),
    orgId: z.string().optional().describe('Optional org id for CLI auth context'),
})
    .describe('Parameters for listing custom agents');
export const CoderCreateCustomAgentParamsSchema = z
    .object({
    body: CoderCreateCustomAgentRequestSchema.describe('Create-custom-agent request body'),
    orgId: z.string().optional().describe('Optional org id for CLI auth context'),
})
    .describe('Parameters for creating a custom agent');
export const CoderUpdateCustomAgentParamsSchema = z
    .object({
    agentIdOrSlug: z.string().describe('Custom agent id or slug to update'),
    body: CoderUpdateCustomAgentRequestSchema.describe('Update-custom-agent request body'),
    orgId: z.string().optional().describe('Optional org id for CLI auth context'),
})
    .describe('Parameters for updating a custom agent');
function buildAgentListQuery(params) {
    const query = new URLSearchParams();
    if (params?.includeArchived !== undefined) {
        query.set('includeArchived', String(params.includeArchived));
    }
    const queryString = query.toString();
    return queryString ? `?${queryString}` : '';
}
export async function coderListCustomAgents(client, params) {
    const path = `/hub/agents${buildAgentListQuery(params)}`;
    return client.get(path, CoderCustomAgentListResponseSchema);
}
export async function coderGetCustomAgent(client, params) {
    const path = `/hub/agents/${encodeURIComponent(params.agentIdOrSlug)}`;
    const resp = await client.get(path, CustomAgentResponseSchema);
    return resp.agent;
}
export async function coderCreateCustomAgent(client, params) {
    const resp = await client.post('/hub/agents', params.body, CustomAgentResponseSchema, CoderCreateCustomAgentRequestSchema);
    return resp.agent;
}
export async function coderUpdateCustomAgent(client, params) {
    const path = `/hub/agents/${encodeURIComponent(params.agentIdOrSlug)}`;
    const resp = await client.patch(path, params.body, CustomAgentResponseSchema, CoderUpdateCustomAgentRequestSchema);
    return resp.agent;
}
export async function coderPublishCustomAgent(client, params) {
    const path = `/hub/agents/${encodeURIComponent(params.agentIdOrSlug)}/publish`;
    const resp = await client.post(path, undefined, CustomAgentResponseSchema);
    return resp.agent;
}
export async function coderArchiveCustomAgent(client, params) {
    const path = `/hub/agents/${encodeURIComponent(params.agentIdOrSlug)}/archive`;
    const resp = await client.post(path, undefined, CustomAgentResponseSchema);
    return resp.agent;
}
export async function coderListCustomAgentVersions(client, params) {
    const path = `/hub/agents/${encodeURIComponent(params.agentIdOrSlug)}/versions`;
    return client.get(path, CoderCustomAgentVersionListResponseSchema);
}
//# sourceMappingURL=agents.js.map