import {z} from 'zod' export type PatchApiApiV1WWIdAssistantAgentConfigurationsSIdArgs = {wId: string, sId: string, body: {userFavorite?: boolean | undefined, agent?: ({handle?: string | undefined, description?: string | undefined, scope?: ('visible' | 'hidden') | undefined, avatar_url?: string | undefined, max_steps_per_run?: number | undefined, visualization_enabled?: boolean | undefined}) | undefined, instructions?: string | undefined, generation_settings?: ({model_id?: string | undefined, provider_id?: string | undefined, temperature?: number | undefined, reasoning_effort?: string | undefined}) | undefined, tags?: (Array<{name?: string | undefined, kind?: ('standard' | 'protected') | undefined}>) | undefined, editors?: Array | undefined, skills?: Array<{sId: string, name: string}> | undefined, toolset?: (Array<{name?: string | undefined, description?: string | undefined, type?: 'MCP' | undefined, configuration?: ({mcp_server_name?: string | undefined}) | undefined}>) | undefined}}; export type PatchApiApiV1WWIdAssistantAgentConfigurationsSIdOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const agentSkill = z.object({sId: z.string().optional(), name: z.string().optional()}); export const agentConfiguration = z.object({id: z.number().int().optional(), agentModelId: z.number().int().nullable().optional(), sId: z.string().optional(), version: z.number().int().optional(), versionCreatedAt: z.string().nullable().optional(), versionAuthorId: z.string().nullable().optional(), name: z.string().optional(), description: z.string().optional(), instructions: z.string().nullable().optional(), pictureUrl: z.string().optional(), status: z.string().optional(), scope: z.string().optional(), userFavorite: z.boolean().optional(), model: z.object({providerId: z.string().optional(), modelId: z.string().optional(), temperature: z.number().optional()}).optional(), actions: z.array(z.unknown()).optional(), skills: z.array(agentSkill).optional(), tags: z.array(z.object({sId: z.string().optional(), name: z.string().optional(), kind: z.enum(["standard", "protected"]).optional()})).optional(), requestedSpaceIds: z.array(z.string()).optional(), maxStepsPerRun: z.number().int().optional(), templateId: z.string().nullable().optional(), ignoreCreditSpendThresholdAlert: z.boolean().optional(), canViewContent: z.boolean().optional()}); export const patchApiApiV1WWIdAssistantAgentConfigurationsSIdResponse = z.object({agentConfiguration: agentConfiguration.optional(), skippedActions: z.array(z.object({name: z.string().optional(), reason: z.string().optional()})).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 }; /** * Update agent configuration * * PATCH /api/v1/w/{wId}/assistant/agent_configurations/{sId} */ export const patchApiApiV1WWIdAssistantAgentConfigurationsSId = async (args: PatchApiApiV1WWIdAssistantAgentConfigurationsSIdArgs, options?: PatchApiApiV1WWIdAssistantAgentConfigurationsSIdOptions) => { const {baseUrl = "https://dust.tt", 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(/\/+$/, '')}/api/v1/w/${encodeURIComponent(String(args.wId))}/assistant/agent_configurations/${encodeURIComponent(String(args.sId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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(patchApiApiV1WWIdAssistantAgentConfigurationsSIdResponse, await res.json()) };