// Quote by default. Add --submit to create a new potentially billable operation. // Set MOTIONGIT_TASK_ID to observe an existing task without generating again. import crypto from 'node:crypto'; const base=process.env.MOTIONGIT_BASE_URL||'https://motiongit.com'; const key=process.env.MOTIONGIT_API_KEY; if(!key)throw new Error('Set MOTIONGIT_API_KEY'); async function request(path,body,operation){ const response=await fetch(base+'/api/v1/'+path,{method:body===undefined?'GET':'POST',headers:{authorization:'Bearer '+key,'content-type':'application/json',...(operation?{'idempotency-key':operation}:{})},body:body===undefined?undefined:JSON.stringify(body)}); const data=await response.json();if(!response.ok)throw new Error(data.error?.code||'request_failed');return data; } if(process.env.MOTIONGIT_TASK_ID)console.log(await request('tasks/'+encodeURIComponent(process.env.MOTIONGIT_TASK_ID))); else { const quote=await request('quotes',{capability:'images.generate',model:'native-image',input:{prompt:process.env.MOTIONGIT_PROMPT||'Abstract geometric background',size:'1024x1024',count:1}}); console.log(quote); if(process.argv.includes('--submit')){ const maximum=Number(process.env.MOTIONGIT_MAX_CREDITS); if(!Number.isSafeInteger(maximum)||maximum