UNPKG

relaycode

Version:

A developer assistant that automates applying code changes from LLMs.

2 lines 1.76 kB
'use strict';var l=require('toasted-notifier'),constants=require('./constants'),logger=require('./logger');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);const a=l__default.default;const f=t=>{if(t.enableNotifications!==false)try{a.notify({title:t.title,message:t.message,sound:!1,wait:!1},r=>{});}catch{}},o=t=>(r,e=true)=>{f({title:constants.APP_NAME,message:t(r),enableNotifications:e});},h=o(t=>`New patch detected for project \`${t}\`.`),b=o(t=>`Action required to approve changes for \`${t}\`.`),y=o(t=>`Patch \`${t}\` applied successfully.`),N=o(t=>`Patch \`${t}\` failed and was rolled back.`),v=o(t=>`CRITICAL: Rollback for patch \`${t}\` FAILED. Manual intervention required.`),A=(t,r=true)=>r===false?Promise.resolve("unsupported"):new Promise(e=>{try{a.notify({title:`Approval Required for ${t}`,message:"A patch requires your approval. You can also approve/reject in the terminal.",sound:!0,wait:!0,actions:["Approve","Reject"],timeout:30},(i,p)=>{if(i)return logger.logger.debug(`Notification approval error: ${logger.getErrorMessage(i)}`),e("unsupported");const n=(p||"").toLowerCase().trim();n.startsWith("approve")?e("approved"):n.startsWith("reject")?e("rejected"):(logger.logger.debug(`Notification approval received non-action response: "${n}"`),e("timeout"));});}catch(i){logger.logger.debug(`Notification dispatch threw synchronous error: ${logger.getErrorMessage(i)}`),e("unsupported");}});exports.createNotifier=o;exports.notifyApprovalRequired=b;exports.notifyFailure=N;exports.notifyPatchDetected=h;exports.notifyRollbackFailure=v;exports.notifySuccess=y;exports.requestApprovalWithNotification=A;//# sourceMappingURL=notifier.cjs.map //# sourceMappingURL=notifier.cjs.map