@staff0rd/assist 0.914.0 → 0.915.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{function
|
|
1
|
+
"use strict";(()=>{function c(s){let{type:e,pageId:o,prompt:t}=s??{};return e==="assist-docs-feedback"&&typeof o=="string"&&typeof t=="string"}async function r(s,e,o){let t;try{t=await fetch(`${s}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})}catch{return{ok:!1,message:`assist web server unreachable at ${s}`}}let n=await t.json().catch(()=>({}));return t.ok?{ok:!0,data:n}:{ok:!1,message:n.error??`assist web server returned ${t.status}`}}async function u(s,{type:e,...o}){let t=await r(s,"/api/sessions/docs-feedback",o);return t.ok?{ok:!0,message:t.data.message??"Sent to the docs session"}:t}function p(){return globalThis.browser?.storage?.local}function g(s){let e;try{e=new URL(s.trim())}catch{return}if(!(e.protocol!=="http:"&&e.protocol!=="https:"))return e.origin}var A="http://localhost:3100",m="serverUrl";async function d(){let e=(await p()?.get(m).catch(()=>{}))?.[m];return typeof e=="string"&&g(e)||A}var S={draft:["draft","--once"]};function f(s){return typeof s=="string"&&Object.hasOwn(S,s)}function l(s){let{type:e,url:o,args:t,mode:n}=s??{};return e==="assist-send"&&typeof o=="string"&&(t===void 0||Array.isArray(t)&&t.every(i=>typeof i=="string"))&&(n===void 0||f(n))}function y(){return globalThis.browser?.runtime}async function b(s,{url:e,instructions:o,args:t,mode:n}){let[i,k]=t?["review-from-github",{url:e,args:t}]:["from-github",{url:e,instructions:o,mode:n}],a=await r(s,`/api/sessions/${i}`,k);return a.ok?{ok:!0,message:`assist session started in ${a.data.cwd}`}:a}function h(){y()?.onMessage.addListener(s=>{if(l(s))return d().then(e=>b(e,s));if(c(s))return d().then(e=>u(e,s))})}h();})();
|