export type CreateApiSmolmachinesV1MachinesIdExecArgs = {id: string, body: {command: string, cwd?: string | undefined, env?: Record | undefined, stdin?: string | undefined, stream?: boolean | undefined, timeoutSeconds?: number | undefined}}; export type CreateApiSmolmachinesV1MachinesIdExecOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Run a command inside a machine. Pass command as a shell string ("ls -la") or argv array (["ls","-la"]). Machine must be ready before calling. * * POST /smolmachines/v1/machines/{id}/exec */ export const createApiSmolmachinesV1MachinesIdExec = async (args: CreateApiSmolmachinesV1MachinesIdExecArgs, options?: CreateApiSmolmachinesV1MachinesIdExecOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/smolmachines/v1/machines/${encodeURIComponent(String(args.id))}/exec${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 undefined };