export type PatchApiApiAgentsIdSoulArgs = {id: string, body: Record}; export type PatchApiApiAgentsIdSoulOptions = {baseUrl: string, sessionCookie?: string | undefined, fetch?: typeof fetch | undefined}; /** * List or load soul templates * * PATCH /api/agents/{id}/soul * * Also accepts auth: apiKey */ export const patchApiApiAgentsIdSoul = async (args: PatchApiApiAgentsIdSoulArgs, options: PatchApiApiAgentsIdSoulOptions) => { const {baseUrl, fetch: fetchFn = fetch, sessionCookie} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (sessionCookie !== undefined) cookies.push("__Host-mc-session=" + encodeURIComponent(sessionCookie)) const url = `${baseUrl.replace(/\/+$/, '')}/api/agents/${encodeURIComponent(String(args.id))}/soul${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 undefined };