import {z} from 'zod' export type CreateApiV2AgentsSuggestionsIdConsumeArgs = {id: string, body: {revision_id?: string | undefined}}; export type CreateApiV2AgentsSuggestionsIdConsumeOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const createApiV2AgentsSuggestionsIdConsumeResponse = z.object({data: z.union([z.object({id: z.string(), agent_id: z.string(), status: z.enum(["pending", "consumed", "rejected", "superseded"]), generated_by: z.enum(["connection_llm", "eval", "dreaming"]), title: z.string(), description: z.string(), dedup_key: z.string(), resolved_at: z.string().nullable(), resolved_by_user_id: z.string().nullable(), superseded_reason: z.string().nullable(), superseded_by_suggestion_id: z.string().nullable(), created_at: z.string(), updated_at: z.string(), sources: z.array(z.object({agent_run_id: z.string(), run_number: z.number().int().lte(9007199254740991), created_at: z.string()})), type: z.literal("aop"), payload: z.object({oldSop: z.string(), newSop: z.string()})}), z.object({id: z.string(), agent_id: z.string(), status: z.enum(["pending", "consumed", "rejected", "superseded"]), generated_by: z.enum(["connection_llm", "eval", "dreaming"]), title: z.string(), description: z.string(), dedup_key: z.string(), resolved_at: z.string().nullable(), resolved_by_user_id: z.string().nullable(), superseded_reason: z.string().nullable(), superseded_by_suggestion_id: z.string().nullable(), created_at: z.string(), updated_at: z.string(), sources: z.array(z.object({agent_run_id: z.string(), run_number: z.number().int().lte(9007199254740991), created_at: z.string()})), type: z.literal("connection_add"), payload: z.object({toSlug: z.enum(["googlecalendar", "google-calendar", "gmail", "slack", "googledocs", "googlesheets", "googledrive", "firecrawl", "exa", "exa-search", "exa-company-search", "exa-people-search", "deep-research", "system", "browser-agent", "browser-agent-devtools", "notion", "linear", "confluence", "custom_mcp", "user_mcp", "snowflake", "sharepoint", "teams", "onedrive", "bigquery", "databricks", "netsuite", "outlook", "microsoft-calendar", "excel", "word", "saps4hana", "md365", "businesscentral", "oraclefusion", "workday", "coupa", "signavio", "sap-ecc", "msteams", "human-in-the-loop", "email-attachments-reader", "document-processor", "google-docs", "google-sheets", "google-drive", "outbound-call", "case-queue-producer", "case-queue-consumer", "handover", "shopify", "hubspot", "zendesk", "intercom", "powerbi", "salesforce", "pipedrive", "tableau", "image-generation", "forecasting", "supabase", "attio", "amplitude", "websets", "firecrawl-platform", "duvo-computer-use", "duvo-computer-use-rdp", "eu-commodity-prices", "asana", "ssh", "scheduling", "github", "linear-native", "notion-native", "granola", "apify", "bamboohr"]), toIntegrationId: z.string()})}), z.object({id: z.string(), agent_id: z.string(), status: z.enum(["pending", "consumed", "rejected", "superseded"]), generated_by: z.enum(["connection_llm", "eval", "dreaming"]), title: z.string(), description: z.string(), dedup_key: z.string(), resolved_at: z.string().nullable(), resolved_by_user_id: z.string().nullable(), superseded_reason: z.string().nullable(), superseded_by_suggestion_id: z.string().nullable(), created_at: z.string(), updated_at: z.string(), sources: z.array(z.object({agent_run_id: z.string(), run_number: z.number().int().lte(9007199254740991), created_at: z.string()})), type: z.literal("connection_replace"), payload: z.object({fromSlug: z.enum(["googlecalendar", "google-calendar", "gmail", "slack", "googledocs", "googlesheets", "googledrive", "firecrawl", "exa", "exa-search", "exa-company-search", "exa-people-search", "deep-research", "system", "browser-agent", "browser-agent-devtools", "notion", "linear", "confluence", "custom_mcp", "user_mcp", "snowflake", "sharepoint", "teams", "onedrive", "bigquery", "databricks", "netsuite", "outlook", "microsoft-calendar", "excel", "word", "saps4hana", "md365", "businesscentral", "oraclefusion", "workday", "coupa", "signavio", "sap-ecc", "msteams", "human-in-the-loop", "email-attachments-reader", "document-processor", "google-docs", "google-sheets", "google-drive", "outbound-call", "case-queue-producer", "case-queue-consumer", "handover", "shopify", "hubspot", "zendesk", "intercom", "powerbi", "salesforce", "pipedrive", "tableau", "image-generation", "forecasting", "supabase", "attio", "amplitude", "websets", "firecrawl-platform", "duvo-computer-use", "duvo-computer-use-rdp", "eu-commodity-prices", "asana", "ssh", "scheduling", "github", "linear-native", "notion-native", "granola", "apify", "bamboohr"]), toSlug: z.enum(["googlecalendar", "google-calendar", "gmail", "slack", "googledocs", "googlesheets", "googledrive", "firecrawl", "exa", "exa-search", "exa-company-search", "exa-people-search", "deep-research", "system", "browser-agent", "browser-agent-devtools", "notion", "linear", "confluence", "custom_mcp", "user_mcp", "snowflake", "sharepoint", "teams", "onedrive", "bigquery", "databricks", "netsuite", "outlook", "microsoft-calendar", "excel", "word", "saps4hana", "md365", "businesscentral", "oraclefusion", "workday", "coupa", "signavio", "sap-ecc", "msteams", "human-in-the-loop", "email-attachments-reader", "document-processor", "google-docs", "google-sheets", "google-drive", "outbound-call", "case-queue-producer", "case-queue-consumer", "handover", "shopify", "hubspot", "zendesk", "intercom", "powerbi", "salesforce", "pipedrive", "tableau", "image-generation", "forecasting", "supabase", "attio", "amplitude", "websets", "firecrawl-platform", "duvo-computer-use", "duvo-computer-use-rdp", "eu-commodity-prices", "asana", "ssh", "scheduling", "github", "linear-native", "notion-native", "granola", "apify", "bamboohr"]), toIntegrationId: z.string()})}), z.object({id: z.string(), agent_id: z.string(), status: z.enum(["pending", "consumed", "rejected", "superseded"]), generated_by: z.enum(["connection_llm", "eval", "dreaming"]), title: z.string(), description: z.string(), dedup_key: z.string(), resolved_at: z.string().nullable(), resolved_by_user_id: z.string().nullable(), superseded_reason: z.string().nullable(), superseded_by_suggestion_id: z.string().nullable(), created_at: z.string(), updated_at: z.string(), sources: z.array(z.object({agent_run_id: z.string(), run_number: z.number().int().lte(9007199254740991), created_at: z.string()})), type: z.literal("connection_remove"), payload: z.object({slug: z.enum(["googlecalendar", "google-calendar", "gmail", "slack", "googledocs", "googlesheets", "googledrive", "firecrawl", "exa", "exa-search", "exa-company-search", "exa-people-search", "deep-research", "system", "browser-agent", "browser-agent-devtools", "notion", "linear", "confluence", "custom_mcp", "user_mcp", "snowflake", "sharepoint", "teams", "onedrive", "bigquery", "databricks", "netsuite", "outlook", "microsoft-calendar", "excel", "word", "saps4hana", "md365", "businesscentral", "oraclefusion", "workday", "coupa", "signavio", "sap-ecc", "msteams", "human-in-the-loop", "email-attachments-reader", "document-processor", "google-docs", "google-sheets", "google-drive", "outbound-call", "case-queue-producer", "case-queue-consumer", "handover", "shopify", "hubspot", "zendesk", "intercom", "powerbi", "salesforce", "pipedrive", "tableau", "image-generation", "forecasting", "supabase", "attio", "amplitude", "websets", "firecrawl-platform", "duvo-computer-use", "duvo-computer-use-rdp", "eu-commodity-prices", "asana", "ssh", "scheduling", "github", "linear-native", "notion-native", "granola", "apify", "bamboohr"])})})]), applied_revision_id: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Consume Agent Suggestion * * POST /v2/agents/suggestions/{id}/consume */ export const createApiV2AgentsSuggestionsIdConsume = async (args: CreateApiV2AgentsSuggestionsIdConsumeArgs, options?: CreateApiV2AgentsSuggestionsIdConsumeOptions) => { const {baseUrl = "https://api.duvo.ai", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/agents/suggestions/${encodeURIComponent(String(args.id))}/consume${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(createApiV2AgentsSuggestionsIdConsumeResponse, await res.json()) };