-- name: ListAgentKindConfigFiles :many
SELECT id, agent_kind_id, rel_path, encrypted_content, updated_by, created_at, updated_at
FROM acp_agent_kind_config_files
WHERE agent_kind_id = $1
ORDER BY rel_path ASC;

-- name: UpsertAgentKindConfigFile :one
INSERT INTO acp_agent_kind_config_files (
  id, agent_kind_id, rel_path, encrypted_content, updated_by
) VALUES ($1, $2, $3, $4, $5)
ON CONFLICT (agent_kind_id, rel_path) DO UPDATE
SET encrypted_content = EXCLUDED.encrypted_content,
    updated_by        = EXCLUDED.updated_by,
    updated_at        = now()
RETURNING id, agent_kind_id, rel_path, encrypted_content, updated_by, created_at, updated_at;

-- name: DeleteAgentKindConfigFile :execrows
DELETE FROM acp_agent_kind_config_files
WHERE agent_kind_id = $1 AND rel_path = $2;
