aicommit2 2.5.11 → 2.5.13

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.
Files changed (37) hide show
  1. package/README.md +36 -0
  2. package/dist/ai.service-f59388bb.mjs +17 -0
  3. package/dist/anthropic.service-fb44d54e.mjs +1 -0
  4. package/dist/bedrock.service-40cbd1e5.mjs +1 -0
  5. package/dist/cli-d193cf90.mjs +273 -0
  6. package/dist/cli.mjs +1 -1
  7. package/dist/codestral.service-f6ae65a5.mjs +1 -0
  8. package/dist/cohere.service-af885cf7.mjs +1 -0
  9. package/dist/copilot-sdk.service-f1cc1873.mjs +5 -0
  10. package/dist/deep-seek.service-de8b4395.mjs +1 -0
  11. package/dist/gemini.service-c9b02d26.mjs +1 -0
  12. package/dist/{github-models.service-7c104b0a.mjs → github-models.service-becd2e94.mjs} +3 -3
  13. package/dist/groq.service-180e7478.mjs +1 -0
  14. package/dist/hugging-face.service-2c8f4576.mjs +2 -0
  15. package/dist/mistral.service-7a553113.mjs +1 -0
  16. package/dist/ollama.service-31b2908b.mjs +1 -0
  17. package/dist/{openai-compatible.service-987d206d.mjs → openai-compatible.service-2bea7313.mjs} +1 -1
  18. package/dist/{openai-22ac0386.mjs → openai-dc366083.mjs} +1 -1
  19. package/dist/{openai.service-fb8b0aec.mjs → openai.service-ca071f6c.mjs} +1 -1
  20. package/dist/openrouter.service-2e239655.mjs +1 -0
  21. package/dist/perplexity.service-fe8bfcd5.mjs +1 -0
  22. package/package.json +4 -2
  23. package/dist/ai.service-1ba3c081.mjs +0 -17
  24. package/dist/anthropic.service-7842f514.mjs +0 -1
  25. package/dist/bedrock.service-65bb3c73.mjs +0 -1
  26. package/dist/cli-e0859d73.mjs +0 -273
  27. package/dist/codestral.service-cd9177f4.mjs +0 -1
  28. package/dist/cohere.service-03179c4c.mjs +0 -1
  29. package/dist/copilot-sdk.service-5c240291.mjs +0 -5
  30. package/dist/deep-seek.service-0c494b66.mjs +0 -1
  31. package/dist/gemini.service-ef22fdae.mjs +0 -1
  32. package/dist/groq.service-ecd1e518.mjs +0 -1
  33. package/dist/hugging-face.service-e6a0100a.mjs +0 -2
  34. package/dist/mistral.service-902039e1.mjs +0 -1
  35. package/dist/ollama.service-d60eeaa2.mjs +0 -1
  36. package/dist/openrouter.service-16a86909.mjs +0 -1
  37. package/dist/perplexity.service-6a36f05d.mjs +0 -1
@@ -1 +0,0 @@
1
- import f from"chalk";import{concatMap as g,from as u,map as C,catchError as y}from"rxjs";import{fromPromise as v}from"rxjs/internal/observable/innerFrom";import{A as M,l as k,a as R,b as _,c as x,e as P,d as $}from"./ai.service-1ba3c081.mjs";import{D,b as E,g as N,k as A,n as S,H as B}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class U extends M{constructor(t){super(t),this.params=t,this.apiKey="",this.colors={primary:"#e28c58",secondary:"#fff"},this.serviceName=f.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Codestral/${this.params.config.model}]`),this.errorPrefix=f.red.bold(`[Codestral/${this.params.config.model}]`),this.apiKey=this.params.config.key}getServiceSpecificErrorMessage(t){const e=t.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your Codestral API key in configuration":e.includes("rate_limit")||e.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or upgrade your Codestral plan":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the Codestral model name is correct":e.includes("Invalid model type")?"Invalid model type. Use supported models: codestral-latest, codestral-2501":e.includes("overloaded")||e.includes("capacity")?"Codestral service is overloaded. Try again in a few minutes":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this Codestral model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your Codestral model configuration":e.includes("500")||e.includes("Internal Server Error")?"Codestral server error. Try again later":null}generateCommitMessage$(){return v(this.generateMessage("commit")).pipe(g(t=>u(t)),C(this.formatAsChoice),y(this.handleError$))}generateCodeReview$(){return v(this.generateMessage("review")).pipe(g(t=>u(t)),C(this.formatCodeReviewAsChoice),y(this.handleError$))}async generateMessage(t){const e=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:s,codeReviewPromptPath:c,logging:i,locale:l,generate:a,type:n,maxLength:p}=this.params.config,o={...D,locale:l,maxLength:p,type:n,generate:a,systemPrompt:r,systemPromptPath:s,codeReviewPromptPath:c,vcs_branch:this.params.branchName||""},d=t==="review"?E(o):N(o);this.checkAvailableModels();const m=A(e,t),I=`${this.params.config.url||"https://codestral.mistral.ai"}/v1/chat/completions`,b={Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"};k(e,t,"Codestral",this.params.config.model,I,b,i),R(e,t,"Codestral",d,m,i);const h=await this.createChatCompletions(d,t);return t==="review"?this.parseCodeReview(h):this.parseMessage(h,n,a)}checkAvailableModels(){if(["codestral-latest","codestral-2501"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of Codestral AI")}async createChatCompletions(t,e){const r=this.params.stagedDiff.diff,{logging:s}=this.params.config,c=this.params.config.url||"https://codestral.mistral.ai",i={model:this.params.config.model,messages:[{role:"system",content:t},{role:"user",content:A(this.params.stagedDiff.diff,e)}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:S(10,1e3)};e==="commit"&&(i.response_format={type:"json_object"}),_(r,e,"Codestral",i,s);const l=Date.now();try{const n=await new B({method:"POST",baseURL:`${c}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody(i).execute(),p=Date.now()-l,o=n.data;if(x(r,e,"Codestral",o,s),!o.choices||o.choices.length===0||!o.choices[0].message?.content)throw P(r,e,"Codestral",{message:"No Content on response",result:o},s),new Error("No Content on response. Please open a Bug report");const m=o.choices[0].message.content;return $(r,e,"Codestral",p,m,s),m}catch(a){throw P(r,e,"Codestral",a,s),a}}}export{U as CodestralService};
@@ -1 +0,0 @@
1
- import h from"chalk";import{CohereClientV2 as x}from"cohere-ai";import{concatMap as d,from as l,map as g,catchError as f}from"rxjs";import{fromPromise as u}from"rxjs/internal/observable/innerFrom";import{A as E,l as S,a as $,b as D,c as _,d as N,e as V}from"./ai.service-1ba3c081.mjs";import{D as O,b as F,g as U,n as H}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class L extends E{constructor(r){super(r),this.params=r,this.colors={primary:"#D18EE2",secondary:"#fff"},this.serviceName=h.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Cohere/${this.params.config.model}]`),this.errorPrefix=h.red.bold(`[Cohere/${this.params.config.model}]`),this.cohere=new x({token:this.params.config.key})}isValidCohereV2Response(r){const e=r;return e?.message?.content!==void 0&&Array.isArray(e.message.content)&&e.message.content.length>0&&typeof e.message.content[0]?.text=="string"}getServiceSpecificErrorMessage(r){const e=r.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your Cohere API key in configuration":e.includes("rate_limit")||e.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or upgrade your Cohere plan":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the Cohere model name is correct":e.includes("overloaded")||e.includes("capacity")?"Cohere service is overloaded. Try again in a few minutes":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this Cohere model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your Cohere model configuration":e.includes("500")||e.includes("Internal Server Error")?"Cohere server error. Try again later":null}generateCommitMessage$(){return u(this.generateMessage("commit")).pipe(d(r=>l(r)),g(this.formatAsChoice),f(this.handleError$))}generateCodeReview$(){return u(this.generateMessage("review")).pipe(d(r=>l(r)),g(this.formatCodeReviewAsChoice),f(this.handleError$))}async generateMessage(r){const e=this.params.stagedDiff.diff,{systemPrompt:C,systemPromptPath:v,codeReviewPromptPath:y,logging:o,temperature:P,locale:A,generate:n,type:a,maxLength:I,maxTokens:w}=this.params.config,m={...O,locale:A,maxLength:I,type:a,generate:n,systemPrompt:C,systemPromptPath:v,codeReviewPromptPath:y,vcs_branch:this.params.branchName||""},i=r==="review"?F(m):U(m),c=`Here is the diff: ${e}`,k=[...i?[{role:"system",content:i}]:[],{role:"user",content:c}],M=`${this.params.config.url}/v2/chat`;S(e,r,"Cohere",this.params.config.model,M,{},o),$(e,r,"Cohere",i,c,o);const p={model:this.params.config.model,messages:k,max_tokens:w,temperature:P,seed:H(10,1e3),p:this.params.config.topP};D(e,r,"Cohere",p,o);const R=Date.now();try{const t=await this.cohere.chat(p,{timeoutInSeconds:Math.floor(this.params.config.timeout/1e3)}),b=Date.now()-R;if(!this.isValidCohereV2Response(t))throw new Error("Invalid response structure from Cohere v2 API");const s=t.message.content[0].text;return _(e,r,"Cohere",t,o),N(e,r,"Cohere",b,s,o),r==="review"?this.parseCodeReview(s):this.parseMessage(s,a,n)}catch(t){throw V(e,r,"Cohere",t,o),t}}}export{L as CohereService};
@@ -1,5 +0,0 @@
1
- import S from"chalk";import{concatMap as _,from as A,map as L,catchError as I}from"rxjs";import{fromPromise as T}from"rxjs/internal/observable/innerFrom";import{A as M,l as b,a as y,b as U,c as R,d as x,e as z}from"./ai.service-1ba3c081.mjs";import{D as B,b as H,g as F}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";const D="gpt-4.1",$=["gpt-4.1","gpt-4o","gpt-5-mini"],w={"openai/gpt-4.1":"gpt-4.1","openai/gpt-4o":"gpt-4o","openai/gpt-5-mini":"gpt-5-mini"},G=e=>{const o=(e||"").trim().toLowerCase();return o?o in w?w[o]:o.includes("/")&&o.split("/").pop()||o:D},j=e=>[G(e),...$].filter((t,i,r)=>r.indexOf(t)===i),N=e=>{const o=e.toLowerCase();return o.includes("unknown_model")||o.includes("unknown model")||o.includes("unavailable_model")||o.includes("unavailable model")||o.includes("model not found")||o.includes("not available")||o.includes("not enabled")||o.includes("not allowed")},K=e=>{const o=e.toLowerCase();return o.includes("auth")||o.includes("unauthorized")||o.includes("forbidden")||o.includes("token")||o.includes("copilot cli")},V=e=>{const o=e.toLowerCase();return o.includes("classic personal access tokens")&&o.includes("ghp_")},W=(e=process.env)=>{const o={...e};delete o.GH_TOKEN,delete o.GITHUB_TOKEN;const t=(e.COPILOT_GITHUB_TOKEN||"").trim();return t.length>0?(o.COPILOT_GITHUB_TOKEN=t,{githubToken:t,useLoggedInUser:!1,env:o}):(delete o.COPILOT_GITHUB_TOKEN,{useLoggedInUser:!0,env:o})};class q extends M{constructor(o){super(o),this.params=o,this.colors={primary:"#1f6feb",secondary:"#FFF"},this.serviceName=S.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Copilot SDK/${this.params.config.model}]`),this.errorPrefix=S.red.bold(`[Copilot SDK/${this.params.config.model}]`)}getServiceSpecificErrorMessage(o){const t=o.message||"";return o.code==="SDK_NOT_INSTALLED"?"Copilot SDK is not installed. Run: npm install @github/copilot-sdk":V(t)?"Copilot rejected classic ghp_ token. Use COPILOT_GITHUB_TOKEN with a Fine-Grained PAT or authenticate via copilot /login.":o.code==="AUTHENTICATION_FAILED"||K(t)?"Copilot authentication failed. Install/authenticate Copilot CLI, then retry.":t.includes("ERR_UNKNOWN_BUILTIN_MODULE")&&t.includes("node:sqlite")?"Copilot SDK requires a newer Node.js runtime (node:sqlite is unavailable). Please use Node.js 22+ and retry.":o.code==="MODEL_NOT_AVAILABLE"||N(t)?"Model is unavailable in Copilot SDK for this account/plan/client. Try another model.":o.code==="NO_CONTENT"?"Copilot SDK returned no content.":null}generateCommitMessage$(){return T(this.generateMessage("commit")).pipe(_(o=>A(o)),L(this.formatAsChoice),I(this.handleError$))}generateCodeReview$(){return T(this.generateMessage("review")).pipe(_(o=>A(o)),L(this.formatCodeReviewAsChoice),I(this.handleError$))}async generateMessage(o){const t=this.params.stagedDiff.diff,{systemPrompt:i,systemPromptPath:r,codeReviewPromptPath:a,locale:l,generate:g,type:c,maxLength:s}=this.params.config,m={...B,locale:l,maxLength:s,type:c,generate:g,systemPrompt:i,systemPromptPath:r,codeReviewPromptPath:a,vcs_branch:this.params.branchName||""},p=o==="review"?H(m):F(m),E=o==="review"?t:`Here's the diff:
2
-
3
- ${t}`,h=await this.makeRequest(p,E,o,t);return o==="review"?this.parseCodeReview(h):this.parseMessage(h,c,g)}async loadSdkModule(){try{return await import("@github/copilot-sdk")}catch(o){const t=new Error("Copilot SDK package is missing. Install with: npm install @github/copilot-sdk");throw t.code="SDK_NOT_INSTALLED",t.originalError=o,t}}extractContent(o){if(!o||typeof o!="object")return"";const t=o,i=t.data,r=t.content,a=i?.content;if(typeof r=="string")return r.trim();if(typeof a=="string")return a.trim();const l=i?.message?.content;return typeof l=="string"?l.trim():""}async makeRequest(o,t,i,r){const{CopilotClient:a,approveAll:l}=await this.loadSdkModule(),g=Array.isArray(this.params.config.model)?this.params.config.model[0]:this.params.config.model||D,c=j(g),{logging:s}=this.params.config;let m;for(const p of c){const E="copilot-sdk://session",h={Authorization:"Copilot CLI session"},P={model:p,prompt:t};b(r,i,"Copilot SDK",p,E,h,s),y(r,i,"Copilot SDK",o,t,s),U(r,i,"Copilot SDK",P,s);const v=Date.now();let C;try{const d=W(process.env);C=new a(d);const u=await(await C.createSession({model:p,onPermissionRequest:l})).sendAndWait({prompt:`${o}
4
-
5
- ${t}`}),f=this.extractContent(u);if(!f){const O=new Error("No content in Copilot SDK response");throw O.code="NO_CONTENT",O}const k=Date.now()-v;return R(r,i,"Copilot SDK",u,s),x(r,i,"Copilot SDK",k,f,s),f}catch(d){const n=d instanceof Error?d:new Error(String(d)),u=n.message||String(d);if(!n.code&&K(u)&&(n.code="AUTHENTICATION_FAILED"),!n.code&&N(u)&&(n.code="MODEL_NOT_AVAILABLE"),z(r,i,"Copilot SDK",n,s),m=n,!(n.code==="MODEL_NOT_AVAILABLE"&&p!==c[c.length-1]))throw n}finally{C?.stop&&await C.stop()}}throw m||new Error("Copilot SDK request failed for all candidate models")}}export{q as CopilotSdkService};
@@ -1 +0,0 @@
1
- import v from"chalk";import K from"openai";import{concatMap as w,from as A,map as C,catchError as I}from"rxjs";import{fromPromise as M}from"rxjs/internal/observable/innerFrom";import{A as W,l as b,a as x,b as $,c as R,d as _,e as E}from"./ai.service-1ba3c081.mjs";import{D as U,g as O,b as Y,k as L}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class G extends W{constructor(t){super(t),this.params=t,this.generateStreamingCommitMessage$=()=>{const{generate:s,type:o}=this.params.config;return this.createStreamingCommitMessages$(i=>{this.streamChunks(i).catch(a=>i.error(a))},o,s)},this.streamChunks=async s=>{const o=this.params.stagedDiff.diff,{systemPrompt:i,systemPromptPath:a,codeReviewPromptPath:p,logging:r,locale:c,generate:m,type:n,maxLength:l}=this.params.config,h={...U,locale:c,maxLength:l,type:n,generate:m,systemPrompt:i,systemPromptPath:a,codeReviewPromptPath:p,vcs_branch:this.params.branchName||""},f=O(h);this.checkAvailableModels();const d=L(o,"commit"),g=`${this.params.config.url||"https://api.deepseek.com"}/chat/completions`,N={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json"};b(o,"commit","DeepSeek",this.params.config.model,g,N,r),x(o,"commit","DeepSeek",f,d,r);const D={messages:[{role:"system",content:f},{role:"user",content:d}],model:this.params.config.model,max_tokens:this.params.config.maxTokens,top_p:this.params.config.topP,temperature:this.params.config.temperature,stream:!0};$(o,"commit","DeepSeek",D,r);const T=Date.now();let u="";try{const F=await this.deepSeek.chat.completions.create(D,{timeout:this.params.config.timeout});for await(const P of F){const B=P.choices?.[0]?.delta?.content||"",H=P.choices?.[0]?.delta?.reasoning_content||"",S=`${B}${H}`;S&&(u+=S,s.next(S))}const z=Date.now()-T;R(o,"commit","DeepSeek",{streamed:!0,totalLength:u.length},r),_(o,"commit","DeepSeek",z,u,r),s.complete()}catch(k){E(o,"commit","DeepSeek",k,r),s.error(k)}},this.colors={primary:"#53a3f9",secondary:"#fff"},this.serviceName=v.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[DeepSeek/${this.params.config.model}]`),this.errorPrefix=v.red.bold(`[DeepSeek/${this.params.config.model}]`);const e=this.params.config.url||"https://api.deepseek.com";this.deepSeek=new K({baseURL:e,apiKey:this.params.config.key})}getServiceSpecificErrorMessage(t){const e=t.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your DeepSeek API key in configuration":e.includes("rate_limit")||e.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or upgrade your DeepSeek plan":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the DeepSeek model name is correct":e.includes("Invalid model type")?"Invalid model type. Use supported models: deepseek-reasoner, deepseek-chat":e.includes("overloaded")||e.includes("capacity")?"DeepSeek service is overloaded. Try again in a few minutes":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this DeepSeek model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your DeepSeek model configuration":e.includes("500")||e.includes("Internal Server Error")?"DeepSeek server error. Try again later":null}generateCommitMessage$(){return this.params.config.stream||!1?this.generateStreamingCommitMessage$():M(this.generateMessage("commit")).pipe(w(e=>A(e)),C(this.formatAsChoice),I(this.handleError$))}generateCodeReview$(){return M(this.generateMessage("review")).pipe(w(t=>A(t)),C(this.formatCodeReviewAsChoice),I(this.handleError$))}async generateMessage(t){const e=this.params.stagedDiff.diff,{systemPrompt:s,systemPromptPath:o,codeReviewPromptPath:i,logging:a,locale:p,generate:r,type:c,maxLength:m}=this.params.config,n={...U,locale:p,maxLength:m,type:c,generate:r,systemPrompt:s,systemPromptPath:o,codeReviewPromptPath:i,vcs_branch:this.params.branchName||""},l=t==="review"?Y(n):O(n);this.checkAvailableModels();const h=L(e,t),d=`${this.params.config.url||"https://api.deepseek.com"}/chat/completions`,y={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json"};b(e,t,"DeepSeek",this.params.config.model,d,y,a),x(e,t,"DeepSeek",l,h,a);const g=await this.createChatCompletions(l,h,t);return t==="review"?this.parseCodeReview(g):this.parseMessage(g,c,r)}checkAvailableModels(){if(["deepseek-reasoner","deepseek-chat"].includes(this.params.config.model))return!0;throw new Error("Invalid model type of DeepSeek")}async createChatCompletions(t,e,s){const o=this.params.stagedDiff.diff,{logging:i}=this.params.config,a={messages:[{role:"system",content:t},{role:"user",content:e}],model:this.params.config.model,max_tokens:this.params.config.maxTokens,top_p:this.params.config.topP,temperature:this.params.config.temperature};$(o,s,"DeepSeek",a,i);const p=Date.now();try{const r=await this.deepSeek.chat.completions.create(a,{timeout:this.params.config.timeout}),c=Date.now()-p,m=r.choices?.[0];if(!m?.message)throw new Error("DeepSeek API returned invalid response structure");const n=m.message.content||m.message.reasoning_content||"";if(!n)throw new Error("DeepSeek API returned empty response");return R(o,s,"DeepSeek",r,i),_(o,s,"DeepSeek",c,n,i),n}catch(r){throw E(o,s,"DeepSeek",r,i),r}}}export{G as DeepSeekService};
@@ -1 +0,0 @@
1
- import{HarmCategory as n,HarmBlockThreshold as a,GoogleGenerativeAI as W}from"@google/generative-ai";import S from"chalk";import{concatMap as x,from as v,map as L,catchError as N}from"rxjs";import{fromPromise as w}from"rxjs/internal/observable/innerFrom";import{A as X,l as D,a as b,b as B,c as H,d as $,e as Y}from"./ai.service-1ba3c081.mjs";import{D as U,g as K,b as F,k as V}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class q extends X{constructor(t){super(t),this.params=t,this.generateStreamingCommitMessage$=()=>{const{generate:e,type:o}=this.params.config;return this.createStreamingCommitMessages$(c=>{this.streamChunks(c).catch(r=>c.error(r))},o,e)},this.streamChunks=async e=>{const o=this.params.stagedDiff.diff,{systemPrompt:c,systemPromptPath:r,codeReviewPromptPath:O,logging:s,locale:f,generate:A,type:E,maxLength:T}=this.params.config,_=this.params.config.maxTokens,h={...U,locale:f,maxLength:T,type:E,generate:A,systemPrompt:c,systemPromptPath:r,codeReviewPromptPath:O,vcs_branch:this.params.branchName||""},p=K(h),y={maxOutputTokens:_,temperature:this.params.config.temperature,topP:this.params.config.topP},u=this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:p,generationConfig:y,safetySettings:[{category:n.HARM_CATEGORY_HATE_SPEECH,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_HARASSMENT,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:a.BLOCK_LOW_AND_ABOVE}]}),C=V(o,"commit"),k=`${this.params.config.url||"https://generativelanguage.googleapis.com"}/v1beta/models/${this.params.config.model}:streamGenerateContent`,I={"Content-Type":"application/json","x-goog-api-key":this.params.config.key};D(o,"commit","Gemini",this.params.config.model,k,I,s),b(o,"commit","Gemini",p,C,s),B(o,"commit","Gemini",{systemInstruction:{parts:[{text:p}]},contents:[{parts:[{text:C}]}],generationConfig:y},s);const g=Date.now();let m="";try{const i=this.params.config.timeout>1e4?{request:{timeout:this.params.config.timeout}}:void 0,M=await u.generateContentStream(C,i);for await(const P of M.stream){const l=P.text();l&&(m+=l,e.next(l))}const d=Date.now()-g;H(o,"commit","Gemini",{streamed:!0,totalLength:m.length},s),$(o,"commit","Gemini",d,m,s),e.complete()}catch(i){Y(o,"commit","Gemini",i,s),e.error(i)}},this.colors={primary:"#0077FF",secondary:"#fff"},this.serviceName=S.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Gemini/${this.params.config.model}]`),this.errorPrefix=S.red.bold(`[Gemini/${this.params.config.model}]`),this.genAI=new W(this.params.config.key)}getServiceSpecificErrorMessage(t){const e=t.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your Google AI Studio API key in configuration":e.includes("quota")||e.includes("QUOTA_EXCEEDED")?"API quota exceeded. Check your Google AI Studio usage limits":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the Gemini model name is correct":e.includes("SAFETY")||e.includes("safety")?"Content blocked by safety filters. Try rephrasing your request":e.includes("RECITATION")||e.includes("recitation")?"Content blocked due to recitation concerns. Try a different approach":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this Gemini model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your Gemini model configuration":e.includes("500")||e.includes("Internal Server Error")?"Google AI service error. Try again later":e.includes("MAX_TOKENS")||e.includes("truncated")||e.includes("maxOutputTokens")?"Response truncated due to token limit. Gemini 2.5+ models use thinking tokens. Try increasing maxTokens (recommended: 8192+)":null}generateCommitMessage$(){return this.params.config.stream||!1?this.generateStreamingCommitMessage$():w(this.generateMessage("commit")).pipe(x(e=>v(e)),L(this.formatAsChoice),N(this.handleError$))}generateCodeReview$(){return w(this.generateMessage("review")).pipe(x(t=>v(t)),L(this.formatCodeReviewAsChoice),N(this.handleError$))}async generateMessage(t){const e=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:c,logging:r,locale:O,codeReviewPromptPath:s,generate:f,type:A,maxLength:E}=this.params.config,T=this.params.config.maxTokens,_={...U,locale:O,maxLength:E,type:A,generate:f,systemPrompt:o,systemPromptPath:c,codeReviewPromptPath:s,vcs_branch:this.params.branchName||""},h=t==="review"?F(_):K(_),p={maxOutputTokens:T,temperature:this.params.config.temperature,topP:this.params.config.topP},y=this.genAI.getGenerativeModel({model:this.params.config.model,systemInstruction:h,generationConfig:p,safetySettings:[{category:n.HARM_CATEGORY_HATE_SPEECH,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_HARASSMENT,threshold:a.BLOCK_LOW_AND_ABOVE},{category:n.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:a.BLOCK_LOW_AND_ABOVE}]}),u=V(e,t),G=`${this.params.config.url||"https://generativelanguage.googleapis.com"}/v1beta/models/${this.params.config.model}:generateContent`,k={"Content-Type":"application/json","x-goog-api-key":this.params.config.key};D(e,t,"Gemini",this.params.config.model,G,k,r),b(e,t,"Gemini",h,u,r),B(e,t,"Gemini",{systemInstruction:{parts:[{text:h}]},contents:[{parts:[{text:u}]}],generationConfig:p},r);const R=Date.now();try{const g=this.params.config.timeout>1e4?{request:{timeout:this.params.config.timeout}}:void 0,m=await y.generateContent(u,g),i=m.response;if(i.candidates?.[0]?.finishReason==="MAX_TOKENS"){const l=i.usageMetadata;throw new Error(`Response truncated: maxOutputTokens exceeded. Thinking tokens: ${l?.thoughtsTokenCount??"N/A"}, Output tokens: ${l?.candidatesTokenCount??"N/A"}. Increase maxTokens config for Gemini 2.5+ thinking models.`)}const d=i.text(),P=Date.now()-R;return H(e,t,"Gemini",{response:d,candidates:m.response.candidates,usageMetadata:m.response.usageMetadata},r),$(e,t,"Gemini",P,d,r),t==="review"?this.parseCodeReview(d):this.parseMessage(d,A,f)}catch(g){throw Y(e,t,"Gemini",g,r),g}}}export{q as GeminiService};
@@ -1 +0,0 @@
1
- import A from"chalk";import L from"groq-sdk";import{concatMap as C,from as x,map as M,catchError as $}from"rxjs";import{fromPromise as I}from"rxjs/internal/observable/innerFrom";import{A as F,l as S,a as b,b as R,c as _,d as D,e as E}from"./ai.service-1ba3c081.mjs";import{D as T,g as N,b as H}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class z extends F{constructor(e){super(e),this.params=e,this.generateStreamingCommitMessage$=()=>{const{generate:t,type:o}=this.params.config;return this.createStreamingCommitMessages$(n=>{this.streamChunks(n).catch(m=>n.error(m))},o,t)},this.streamChunks=async t=>{const o=this.params.stagedDiff.diff,{systemPrompt:n,systemPromptPath:m,codeReviewPromptPath:r,logging:i,locale:y,temperature:h,generate:l,type:P,maxLength:v}=this.params.config,g=this.params.config.maxTokens,d={...T,locale:y,maxLength:v,type:P,generate:l,systemPrompt:n,systemPromptPath:m,codeReviewPromptPath:r,vcs_branch:this.params.branchName||""},c=N(d),G=`Here is the diff: ${o}`,q=`${this.params.config.url||"https://api.groq.com"}/openai/v1/chat/completions`,f={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json"};S(o,"commit","Groq",this.params.config.model,q,f,i),b(o,"commit","Groq",c,G,i);const u={messages:[{role:"system",content:c},{role:"user",content:G}],model:this.params.config.model,max_tokens:g,top_p:this.params.config.topP,temperature:h,stream:!0};R(o,"commit","Groq",u,i);const a=Date.now();let p="";try{const s=await this.groq.chat.completions.create(u,{timeout:this.params.config.timeout});for await(const U of s){const k=U.choices?.[0]?.delta?.content||"";k&&(p+=k,t.next(k))}const O=Date.now()-a;_(o,"commit","Groq",{streamed:!0,totalLength:p.length},i),D(o,"commit","Groq",O,p,i),t.complete()}catch(s){E(o,"commit","Groq",s,i),t.error(s)}},this.colors={primary:"#f55036",secondary:"#fff"},this.serviceName=A.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Groq/${this.params.config.model}]`),this.errorPrefix=A.red.bold(`[Groq/${this.params.config.model}]`),this.groq=new L({apiKey:this.params.config.key})}getServiceSpecificErrorMessage(e){const t=e.message||"";return t.includes("API key")||t.includes("api_key")?"Invalid API key. Check your Groq API key in configuration":t.includes("rate_limit")||t.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or upgrade your Groq plan":t.includes("model")||t.includes("Model")?"Model not found or not accessible. Check if the Groq model name is correct":t.includes("overloaded")||t.includes("capacity")?"Groq service is overloaded. Try again in a few minutes":t.includes("403")||t.includes("Forbidden")?"Access denied. Your API key may not have permission for this Groq model":t.includes("404")||t.includes("Not Found")?"Model or endpoint not found. Check your Groq model configuration":t.includes("500")||t.includes("Internal Server Error")?"Groq server error. Try again later":null}generateCommitMessage$(){return this.params.config.stream||!1?this.generateStreamingCommitMessage$():I(this.generateMessage("commit")).pipe(C(t=>x(t)),M(this.formatAsChoice),$(this.handleError$))}generateCodeReview$(){return I(this.generateMessage("review")).pipe(C(e=>x(e)),M(this.formatCodeReviewAsChoice),$(this.handleError$))}async generateMessage(e){const t=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:m,logging:r,locale:i,temperature:y,generate:h,type:l,maxLength:P}=this.params.config,v=this.params.config.maxTokens,g={...T,locale:i,maxLength:P,type:l,generate:h,systemPrompt:o,systemPromptPath:n,codeReviewPromptPath:m,vcs_branch:this.params.branchName||""},d=e==="review"?H(g):N(g),c=`Here is the diff: ${t}`,w=`${this.params.config.url||"https://api.groq.com"}/openai/v1/chat/completions`,q={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json"};S(t,e,"Groq",this.params.config.model,w,q,r),b(t,e,"Groq",d,c,r);const f={messages:[{role:"system",content:d},{role:"user",content:c}],model:this.params.config.model,max_tokens:v,top_p:this.params.config.topP,temperature:y};R(t,e,"Groq",f,r);const u=Date.now();try{const a=await this.groq.chat.completions.create(f,{timeout:this.params.config.timeout}),p=Date.now()-u,s=a.choices[0].message.content||"";return _(t,e,"Groq",a,r),D(t,e,"Groq",p,s,r),e==="review"?this.parseCodeReview(s):this.parseMessage(s,l,h)}catch(a){throw E(t,e,"Groq",a,r),a}}}export{z as GroqService};
@@ -1,2 +0,0 @@
1
- import b from"chalk";import{concatMap as k,from as D,map as P,catchError as E}from"rxjs";import{fromPromise as F}from"rxjs/internal/observable/innerFrom";import{A as $,l as H,a as R,c as U,d as S,e as x}from"./ai.service-1ba3c081.mjs";import{D as N,b as T,g as _}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class j extends ${constructor(o){super(o),this.params=o,this.headers={},this.models=[],this.currentModelId=null,this.currentConversation=void 0,this.currentConversionID=void 0,this.cookie="",this.colors={primary:"#FED21F",secondary:"#000"},this.serviceName=b.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[HuggingFace/${this.params.config.model}]`),this.errorPrefix=b.red.bold(`[HuggingFace/${this.params.config.model}]`),this.cookie=this.params.config.cookie;const e=this.params.config.url||"https://huggingface.co";this.headers={accept:"*/*","accept-language":"en-US,en;q=0.9","sec-ch-ua":'"Chromium";v="116", "Not)A;Brand";v="24", "Google Chrome";v="116"',"sec-ch-ua-mobile":"?0","sec-ch-ua-platform":'"Windows"',"sec-fetch-dest":"empty","sec-fetch-mode":"cors","sec-fetch-site":"same-origin",origin:e,"Referrer-Policy":"strict-origin-when-cross-origin"}}getServiceSpecificErrorMessage(o){const e=o.message||"";return e.includes("cookie")||e.includes("Cookie")?"Invalid cookie. Check your Hugging Face session cookie in configuration":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the Hugging Face model name is correct":e.includes("conversation")||e.includes("conversion")?"Failed to create conversation. Try again or check your session":e.includes("401")||e.includes("Unauthorized")?"Authentication failed. Your Hugging Face session may have expired":e.includes("403")||e.includes("Forbidden")?"Access denied. You may not have permission to access this model":e.includes("404")||e.includes("Not Found")?"Model not found. Check your Hugging Face model configuration":e.includes("500")||e.includes("Internal Server Error")?"Hugging Face server error. Try again later":e.includes("overloaded")||e.includes("capacity")?"Hugging Face service is overloaded. Try again in a few minutes":null}generateCommitMessage$(){return F(this.generateMessage("commit")).pipe(k(o=>D(o)),P(this.formatAsChoice),E(this.handleError$))}generateCodeReview$(){return F(this.generateMessage("review")).pipe(k(o=>D(o)),P(this.formatCodeReviewAsChoice),E(this.handleError$))}async generateMessage(o){await this.initialize();const e=this.params.stagedDiff.diff,{systemPrompt:r,systemPromptPath:t,codeReviewPromptPath:p,logging:a,locale:i,generate:d,type:s,maxLength:u,temperature:m,maxTokens:v,topP:h,timeout:g}=this.params.config,n={...N,locale:i,maxLength:u,type:s,generate:d,systemPrompt:r,systemPromptPath:t,codeReviewPromptPath:p,vcs_branch:this.params.branchName||""},c=o==="review"?T(n):_(n),l=`Here is the diff: ${e}`,w=`${this.params.config.url||"https://huggingface.co"}/chat/conversation`,I={...this.headers,cookie:this.cookie};H(e,o,"HuggingFace",this.params.config.model,w,I,a),R(e,o,"HuggingFace",c,l,a);const A=Date.now();try{const y=await this.getNewChat(c),C=await(await this.sendMessage(l,y.id)).completeResponsePromise();await this.deleteConversation(y.id);const M=Date.now()-A;return U(e,o,"HuggingFace",{response:C},a),S(e,o,"HuggingFace",M,C,a),o==="review"?this.parseCodeReview(C):this.parseMessage(C,s,d)}catch(y){throw x(e,o,"HuggingFace",y,a),y}}async initialize(){const o=await this.getRemoteLlms(),e=o.find(r=>r.name?.toLowerCase()===this.params.config.model.toLowerCase());if(e){this.currentModel=e,this.currentModelId=e.id;return}this.currentModel=o[0],this.currentModelId=o[0].id}async getRemoteLlms(){const o=this.params.config.url||"https://huggingface.co",e=await fetch(`${o}/chat/__data.json`,{headers:{...this.headers,cookie:this.cookie},body:null,method:"GET"});if(e.status!==200)throw new Error(`Failed to get remote LLMs with status code: ${e.status}`);const t=(await e.json()).nodes[0].data,p=t[t[0].models],a=[],i=d=>d===-1?null:t[d];for(const d of p){const s=t[d];if(t[s.unlisted])continue;const u={id:i(s.id),name:i(s.name),displayName:i(s.displayName),preprompt:i(s.preprompt),promptExamples:[],websiteUrl:i(s.websiteUrl),description:i(s.description),datasetName:i(s.datasetName),datasetUrl:i(s.datasetUrl),modelUrl:i(s.modelUrl),parameters:{}},m=i(s.promptExamples);if(m!==null){const g=m.map(n=>i(n));u.promptExamples=g.map(n=>({title:t[n.title],prompt:t[n.prompt]}))}const v=i(s.parameters),h={};for(const[g,n]of Object.entries(v)){if(n===-1){h[g]=null;continue}if(Array.isArray(t[n])){h[g]=t[n].map(c=>t[c]);continue}h[g]=t[n]}u.parameters=h,a.push(u)}return this.models=a,a}async getNewChat(o){const e={model:this.currentModelId,preprompt:o};let r=0;const t=this.params.config.url||"https://huggingface.co";for(;r<5;){const p=await fetch(`${t}/chat/conversation`,{headers:{...this.headers,"content-type":"application/json",cookie:this.cookie,Referer:`${t}/chat/`},body:JSON.stringify(e),method:"POST"}),{conversationId:a}=await p.json();if(a){this.currentConversionID=a;break}else r++}if(!this.currentConversionID)throw new Error("Failed to create new conversion");return await this.getConversationHistory(this.currentConversionID)}async getConversationHistory(o){if(!o)throw new Error("conversationId is required for getConversationHistory");const e=this.params.config.url||"https://huggingface.co",r=await fetch(`${e}/chat/conversation/${o}/__data.json`,{headers:{...this.headers,cookie:this.cookie,Referer:`${e}/chat/`},body:null,method:"GET"});if(r.status!=200)throw new Error("Unable get conversation details "+r);{const t=await r.json();return this.metadataParser(t,o)}}metadataParser(o,e){const r={id:"",model:"",systemPrompt:"",title:"",history:[]},t=o.nodes[1].data,p=t[t[0].model],a=t[t[0].preprompt],i=t[t[0].title],d=t[t[0].messages],s=[];for(const u of d){const m=t[u],v=new Date(t[m.createdAt][1]).getTime()/1e3,h=new Date(t[m.updatedAt][1]).getTime()/1e3;s.push({id:t[m.id],role:t[m.from],content:t[m.content],createdAt:v,updatedAt:h})}return r.id=e,r.model=p,r.systemPrompt=a,r.title=i,r.history=s,this.currentConversation=r,r}async sendMessage(o,e){if(o==="")throw new Error("the prompt can not be empty.");if(!e&&!this.currentConversionID?await this.getNewChat():e?(this.currentConversionID=e,await this.getConversationHistory(e)):this.currentConversionID&&await this.getConversationHistory(this.currentConversionID),!this.currentConversation)throw new Error("Failed to create new conversion");const r={inputs:o,id:this.currentConversation.history[this.currentConversation.history.length-1].id,is_retry:!1,is_continue:!1,web_search:!1,tools:[]},t=new FormData;t.append("data",JSON.stringify(r));const p=this.params.config.url||"https://huggingface.co",a=new AbortController,i=setTimeout(()=>a.abort(),this.params.config.timeout),d=await fetch(`${p}/chat/conversation/${this.currentConversionID}`,{headers:{...this.headers,cookie:this.cookie,Referer:`${p}/chat/conversation/${this.currentConversionID}`},body:t,method:"POST",signal:a.signal});clearTimeout(i);function s(n){try{const c=n.split(`
2
- `),l=[];for(const f of c)f.trim()&&l.push(JSON.parse(f));return l}catch{return[{}]}}const u=new TextDecoder;let m="";const v=new TransformStream({async transform(n,c){const l=u.decode(n);try{const f=s(l);for(const w of f)w.type==="finalAnswer"?(m=w?.text||"",c.terminate()):w.type==="stream"&&c.enqueue(w?.token||"")}catch{throw new Error("Error during parsing response")}}}),h=d.body?.pipeThrough(v);async function g(){return new Promise(async(n,c)=>{try{if(!h)c("ModifiedStream undefined");else{const l=h.getReader();for(;;){const{done:f,value:w}=await l.read();if(f){n(m);break}}}}catch(l){c(l)}})}return{id:this.currentConversionID,stream:h,completeResponsePromise:g}}async deleteConversation(o){const e=this.params.config.url||"https://huggingface.co";return(await fetch(`${e}/chat/conversation/${o}`,{headers:{...this.headers,cookie:this.cookie,Referer:`${e}/chat/`},body:null,method:"DELETE"})).json()}}export{j as HuggingFaceService};
@@ -1 +0,0 @@
1
- import f from"chalk";import{concatMap as g,from as u,map as A,catchError as M}from"rxjs";import{fromPromise as y}from"rxjs/internal/observable/innerFrom";import{A as C,l as k,a as $,b as R,c as x,e as I,d as E}from"./ai.service-1ba3c081.mjs";import{D as N,b as D,g as S,H as v,n as _}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class U extends C{constructor(e){super(e),this.params=e,this.apiKey="",this.colors={primary:"#ff7000",secondary:"#fff"},this.serviceName=f.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[MistralAI/${this.params.config.model}]`),this.errorPrefix=f.red.bold(`[MistralAI/${this.params.config.model}]`),this.apiKey=this.params.config.key}getServiceSpecificErrorMessage(e){const t=e.message||"";return t.includes("API key")||t.includes("api_key")?"Invalid API key. Check your Mistral AI API key in configuration":t.includes("quota")||t.includes("usage")?"API quota exceeded. Check your Mistral AI usage limits":t.includes("model")||t.includes("Model")?"Model not found or not accessible. Check if the Mistral model name is correct":t.includes("403")||t.includes("Forbidden")?"Access denied. Your API key may not have permission for this Mistral model":t.includes("404")||t.includes("Not Found")?"Model or endpoint not found. Check your Mistral model configuration":t.includes("500")||t.includes("Internal Server Error")?"Mistral AI server error. Try again later":null}generateCommitMessage$(){return y(this.generateMessage("commit")).pipe(g(e=>u(e)),A(this.formatAsChoice),M(this.handleError$))}generateCodeReview$(){return y(this.generateMessage("review")).pipe(g(e=>u(e)),A(this.formatCodeReviewAsChoice),M(this.handleError$))}async generateMessage(e){const t=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:s,codeReviewPromptPath:i,logging:n,locale:p,generate:a,type:c,maxLength:l}=this.params.config,r={...N,locale:p,maxLength:l,type:c,generate:a,systemPrompt:o,systemPromptPath:s,codeReviewPromptPath:i,vcs_branch:this.params.branchName||""},h=e==="review"?D(r):S(r);await this.checkAvailableModels();const m=`Here is the diff: ${t}`,b=`${this.params.config.url||"https://api.mistral.ai"}/v1/chat/completions`,w={Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"};k(t,e,"MistralAI",this.params.config.model,b,w,n),$(t,e,"MistralAI",h,m,n);const d=await this.createChatCompletions(h,m,e);return e==="review"?this.parseCodeReview(d):this.parseMessage(d,c,a)}async checkAvailableModels(){if((await this.getAvailableModels()).includes(this.params.config.model))return!0;throw new Error(`Invalid model type of Mistral AI: ${this.params.config.model}`)}async getAvailableModels(){const e=this.params.config.url||"https://api.mistral.ai";return(await new v({method:"GET",baseURL:`${e}/v1/models`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).execute()).data.data.filter(o=>o.object==="model").map(o=>o.id)}async createChatCompletions(e,t,o){const s=this.params.stagedDiff.diff,{logging:i}=this.params.config,n={model:this.params.config.model,messages:[{role:"system",content:e},{role:"user",content:t}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1,safe_prompt:!1,random_seed:_(10,1e3)};R(s,o,"MistralAI",n,i);const p=Date.now();try{const a=this.params.config.url||"https://api.mistral.ai",c=await new v({method:"POST",baseURL:`${a}/v1/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody(n).execute(),l=Date.now()-p,r=c.data;if(x(s,o,"MistralAI",r,i),!r.choices||r.choices.length===0||!r.choices[0].message?.content)throw I(s,o,"MistralAI",{message:"No Content on response",result:r},i),new Error("No Content on response. Please open a Bug report");const m=r.choices[0].message.content;return E(s,o,"MistralAI",l,m,i),m}catch(a){throw I(s,o,"MistralAI",a,i),a}}}export{U as MistralService};
@@ -1 +0,0 @@
1
- import P from"chalk";import{Ollama as L}from"ollama";import{concatMap as w,from as k,map as A,catchError as v}from"rxjs";import{fromPromise as C}from"rxjs/internal/observable/innerFrom";import{fetch as T,Agent as z}from"undici";import{A as H,l as x,a as D,b as S,c as _,d as M,e as O}from"./ai.service-1ba3c081.mjs";import{o as R,t as U,n as E,c as N,P as b,D as B,b as G,g as J,H as K}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class Q extends H{constructor(s){super(s),this.params=s,this.host=R,this.model="",this.key="",this.auth="",this.getTruncatedDiff=()=>{const t=this.params.stagedDiff.diff,e=this.params.config.maxDiffSize||0;if(e<=0)return t;const{diff:o}=U(t,e);return o},this.generateStreamingCommitMessage$=()=>{const{generate:t,type:e}=this.params.config;return this.createStreamingCommitMessages$(o=>{this.streamChunks(o).catch(n=>o.error(n))},e,t)},this.streamChunks=async t=>{const e=this.getTruncatedDiff(),{logging:o}=this.params.config,n=this.buildCommitPrompt();await this.checkIsAvailableOllama();const h=`Here is the diff: ${e}`,i=`Ollama_${this.model}`,d=`${this.host}/api/chat`,a=this.key?{Authorization:`${this.auth} ${this.key}`}:{};x(e,"commit",i,this.model,d,a,o),D(e,"commit",i,n,h,o);const{numCtx:c,temperature:m,topP:p,timeout:f,maxTokens:r}=this.params.config,g={model:this.model,messages:[{role:"system",content:n},{role:"user",content:h}],stream:!0,keep_alive:f,options:{num_ctx:c,temperature:m,top_p:p,seed:E(10,1e3),num_predict:r??-1}};S(e,"commit",i,g,o);const l=Date.now();let u="";try{const y=await this.ollama.chat(g);for await(const F of y){const $=F.message.content;$&&(u+=$,t.next($))}const I=Date.now()-l;_(e,"commit",i,{streamed:!0,totalLength:u.length},o),M(e,"commit",i,I,u,o),t.complete()}catch(y){O(e,"commit",i,y,o),t.error(y)}},this.setupFetch=(t,e={})=>T(t,{...e,dispatcher:new z({headersTimeout:this.params.config.timeout})}),this.colors={primary:"#FFF",secondary:"#000"},this.model=this.params.keyName,this.serviceName=P.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[${N(this.model)}]`),this.errorPrefix=P.red.bold(`[${N(this.model)}]`),this.host=this.params.config.host||R,this.auth=this.params.config.auth||"Bearer",this.key=this.params.config.key||"",this.ollama=new L({host:this.host,fetch:this.setupFetch,...this.key&&{headers:{Authorization:`${this.auth} ${this.key}`}}})}getServiceSpecificErrorMessage(s){const t=s.message||"";return t.includes("ECONNREFUSED")||t.includes("connection refused")?b.ollamaNotRunning():t.includes("model")&&(t.includes("not found")||t.includes("404"))?b.ollamaModelNotPulled(this.model):null}generateCommitMessage$(){return this.params.config.stream||!1?this.generateStreamingCommitMessage$():C(this.generateMessage("commit")).pipe(w(t=>k(t)),A(this.formatAsChoice),v(this.handleError$))}generateCodeReview$(){return C(this.generateMessage("review")).pipe(w(s=>k(s)),A(this.formatCodeReviewAsChoice),v(this.handleError$))}async generateMessage(s){const t=this.getTruncatedDiff(),{systemPrompt:e,systemPromptPath:o,codeReviewPromptPath:n,logging:h,locale:i,generate:d,type:a,maxLength:c}=this.params.config,m={...B,locale:i,maxLength:c,type:a,generate:d,systemPrompt:e,systemPromptPath:o,codeReviewPromptPath:n,vcs_branch:this.params.branchName||""},p=s==="review"?G(m):J(m);await this.checkIsAvailableOllama();const f=`Here is the diff: ${t}`,r=`Ollama_${this.model}`,g=`${this.host}/api/chat`,l=this.key?{Authorization:`${this.auth} ${this.key}`}:{};x(t,s,r,this.model,g,l,h),D(t,s,r,p,f,h);const u=await this.createChatCompletions(p,f,s);return s==="review"?this.parseCodeReview(u):this.parseMessage(u,a,d)}async checkIsAvailableOllama(){const s=new K({method:"GET",baseURL:`${this.host}`,timeout:this.params.config.timeout});return this.key&&s.setHeaders({Authorization:`${this.auth} ${this.key}`}),(await s.execute()).data}async createChatCompletions(s,t,e){const{numCtx:o,temperature:n,topP:h,timeout:i,maxTokens:d,logging:a}=this.params.config,c=this.params.stagedDiff.diff,m=`Ollama_${this.model}`,p={model:this.model,messages:[{role:"system",content:s},{role:"user",content:t}],stream:!1,keep_alive:i,options:{num_ctx:o,temperature:n,top_p:h,seed:E(10,1e3),num_predict:d??-1}};S(c,e,m,p,a);const f=Date.now();try{const r=await this.ollama.chat(p),g=Date.now()-f,l=r.message.content;return _(c,e,m,{response:l,fullResponse:r},a),M(c,e,m,g,l,a),l}catch(r){throw O(c,e,m,r,a),r}}}export{Q as OllamaService};
@@ -1 +0,0 @@
1
- import x from"chalk";import L from"openai";import{concatMap as b,from as k,map as S,catchError as I}from"rxjs";import{fromPromise as H}from"rxjs/internal/observable/innerFrom";import{A as z,l as _,a as E,b as T,c as j,d as U,e as D}from"./ai.service-1ba3c081.mjs";import{i as X}from"./openai-22ac0386.mjs";import{D as F,g as K,H as G,b as W}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"http";import"https";import"net";import"tls";import"url";import"assert";import"tty";import"util";import"os";import"events";import"cleye";import"module";import"crypto";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"node:fs";import"buffer";import"stream";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"node:fs/promises";import"chokidar";import"rxjs/operators";const $=class d extends z{constructor(r){super(r),this.params=r,this.getOpenRouterBaseUrl=()=>(this.params.config.url||"https://openrouter.ai").replace(/\/$/,""),this.getOpenRouterCatalogUrl=()=>`${this.getOpenRouterBaseUrl()}/api/v1`,this.getOpenRouterHeaders=()=>({"HTTP-Referer":"https://github.com/tak-bro/aicommit2","X-OpenRouter-Title":"aicommit2","X-OpenRouter-Categories":"cli-agent"}),this.getOpenRouterAuthHeaders=()=>({Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json",...this.getOpenRouterHeaders()}),this.hasRequestObject=t=>typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length>0,this.getRequestedModel=()=>Array.isArray(this.params.config.model)?this.params.config.model[0]||"":typeof this.params.config.model=="string"?this.params.config.model:"",this.getCatalogCacheKey=()=>`${this.getOpenRouterCatalogUrl()}|${this.params.config.key||""}`,this.getModelCacheKey=()=>`${this.getCatalogCacheKey()}|${this.getRequestedModel()}`,this.matchOpenRouterModel=(t,o)=>{const s=t.trim();return o.find(a=>[a.id,a.canonical_slug,a.name].filter(i=>!!i).some(i=>i===s))},this.getRequestPayloadExtras=async()=>{const t=this.params.config,o={},s=this.hasRequestObject(t.responseFormat)?t.responseFormat:{type:"json_object"};s&&await this.isResponseFormatSupported()&&(o.response_format=s),this.hasRequestObject(t.provider)&&(o.provider=t.provider);const a=await this.getReasoningPayload();return a&&(o.reasoning=a),o},this.extractOpenRouterText=t=>{if(!t||typeof t!="object")return"";const o=t;return o.content||o.reasoning_content||o.reasoning||""},this.buildChatCompletionPayload=async(t,o,s)=>{const a=this.params.config.maxTokens,m=this.params.config.temperature,i=X(this.params.config.model),u=this.getRequestedModel();return{messages:[{role:"system",content:t},{role:"user",content:o}],model:u,stream:s,...await this.getRequestPayloadExtras()||{},...i?{max_completion_tokens:a,temperature:1}:{max_tokens:a,top_p:this.params.config.topP,temperature:m}}},this.generateStreamingCommitMessage$=()=>{const{generate:t,type:o}=this.params.config;return this.createStreamingCommitMessages$(s=>{this.streamChunks(s).catch(a=>s.error(a))},o,t)},this.streamChunks=async t=>{const o=this.params.stagedDiff.diff,{systemPrompt:s,systemPromptPath:a,codeReviewPromptPath:m,logging:i,locale:u,generate:C,type:g,maxLength:f,timeout:R}=this.params.config,p={...F,locale:u,maxLength:f,type:g,generate:C,systemPrompt:s,systemPromptPath:a,codeReviewPromptPath:m,vcs_branch:this.params.branchName||""},y=K(p),O=`Here is the diff: ${o}`,c="OpenRouter",P=`${this.params.config.url||"https://openrouter.ai"}${this.params.config.path||"/api/v1/chat/completions"}`,h={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json",...this.getOpenRouterHeaders()};_(o,"commit",c,this.params.config.model,P,h,i),E(o,"commit",c,y,O,i);const l=await this.buildChatCompletionPayload(y,O,!0);T(o,"commit",c,l,i);const w=Date.now();let M="";try{const q=await this.openAI.chat.completions.create(l,{timeout:R});for await(const B of q){const A=this.extractOpenRouterText(B.choices?.[0]?.delta);A&&(M+=A,t.next(A))}const N=Date.now()-w;j(o,"commit",c,{streamed:!0,totalLength:M.length},i),U(o,"commit",c,N,M,i),t.complete()}catch(v){D(o,"commit",c,v,i),t.error(v)}},this.colors={primary:"#f97316",secondary:"#fff"},this.serviceName=x.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[OpenRouter/${this.params.config.model}]`),this.errorPrefix=x.red.bold(`[OpenRouter/${this.params.config.model}]`);const e=this.params.config.url||"https://openrouter.ai",n=(this.params.config.path||"/api/v1/chat/completions").replace(/\/chat\/completions\/?$/,"");this.openAI=new L({apiKey:this.params.config.key,baseURL:`${e}${n}`,defaultHeaders:{...this.getOpenRouterHeaders()}})}async fetchOpenRouterCatalog(){const r=this.getCatalogCacheKey(),e=d.catalogCache.get(r);if(e)return e;const n=["/models/user","/models"];let t;for(const o of n)try{const a=(await new G({method:"GET",baseURL:`${this.getOpenRouterCatalogUrl()}${o}`,timeout:this.params.config.timeout}).setHeaders(this.getOpenRouterAuthHeaders()).execute()).data?.data??[];return d.catalogCache.set(r,a),a}catch(s){if(t=s,!(s instanceof Error?s.message:String(s)).includes("404"))throw s}throw t instanceof Error?t:new Error(String(t))}async getOpenRouterModel(){const r=this.getRequestedModel();if(!r||r==="openrouter/auto")return null;const e=this.getModelCacheKey(),n=d.modelCache.get(e);if(n!==void 0)return n;try{const t=await this.fetchOpenRouterCatalog(),o=this.matchOpenRouterModel(r,t)||null;return d.modelCache.set(e,o),o}catch{return null}}async supportsOpenRouterParameters(r){const e=await this.getOpenRouterModel();return e?r.some(n=>e.supported_parameters?.includes(n)??!1):!1}async isResponseFormatSupported(){return this.supportsOpenRouterParameters(["response_format"])}async isReasoningSupported(){return this.supportsOpenRouterParameters(["reasoning","include_reasoning"])}async getReasoningPayload(){if(!await this.isReasoningSupported())return;const r=this.params.config,e=this.hasRequestObject(r.reasoning)?{...r.reasoning}:void 0,n=e?{...e}:{};return"exclude"in n||(n.exclude=!0),n}getServiceSpecificErrorMessage(r){const e=r.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your OpenRouter API key in configuration":e.includes("402")||e.includes("Payment Required")?"OpenRouter credits are exhausted or billing is required. Check your account balance.":e.includes("rate_limit")||e.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or check your OpenRouter limits":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the OpenRouter model name is correct":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this OpenRouter model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your OpenRouter configuration":e.includes("500")||e.includes("Internal Server Error")?"OpenRouter server error. Try again later":e.includes("overloaded")||e.includes("capacity")?"OpenRouter is overloaded. Try again in a few minutes":null}generateCommitMessage$(){return this.params.config.stream||!1?this.generateStreamingCommitMessage$():H(this.generateMessage("commit")).pipe(b(e=>k(e)),S(this.formatAsChoice),I(this.handleError$))}generateCodeReview$(){return H(this.generateMessage("review")).pipe(b(r=>k(r)),S(this.formatCodeReviewAsChoice),I(this.handleError$))}async generateMessage(r){const e=this.params.stagedDiff.diff,{systemPrompt:n,systemPromptPath:t,codeReviewPromptPath:o,logging:s,locale:a,generate:m,type:i,maxLength:u,timeout:C}=this.params.config,g={...F,locale:a,maxLength:u,type:i,generate:m,systemPrompt:n,systemPromptPath:t,codeReviewPromptPath:o,vcs_branch:this.params.branchName||""},f=r==="review"?W(g):K(g),R=`Here is the diff: ${e}`,p="OpenRouter",y=`${this.params.config.url||"https://openrouter.ai"}${this.params.config.path||"/api/v1/chat/completions"}`,O={Authorization:`Bearer ${this.params.config.key}`,"Content-Type":"application/json",...this.getOpenRouterHeaders()};_(e,r,p,this.params.config.model,y,O,s),E(e,r,p,f,R,s);const c=await this.buildChatCompletionPayload(f,R,!1);T(e,r,p,c,s);const P=Date.now();try{const h=await this.openAI.chat.completions.create(c,{timeout:C}),l=this.extractOpenRouterText(h.choices?.[0]?.message),w=Date.now()-P;return j(e,r,p,h,s),U(e,r,p,w,l,s),r==="review"?this.parseCodeReview(l):this.parseMessage(l,i,m)}catch(h){throw D(e,r,p,h,s),h}}};$.catalogCache=new Map,$.modelCache=new Map;let Y=$;export{Y as OpenRouterService};
@@ -1 +0,0 @@
1
- import g from"chalk";import{concatMap as f,from as u,map as y,catchError as P}from"rxjs";import{fromPromise as x}from"rxjs/internal/observable/innerFrom";import{A as b,l as k,a as I,b as R,c as M,e as v,d as $}from"./ai.service-1ba3c081.mjs";import{D as E,b as N,g as S,H as D}from"./cli-e0859d73.mjs";import"fs";import"path";import"@pacote/xxhash";import"winston";import"cleye";import"module";import"crypto";import"os";import"node:buffer";import"node:path";import"node:child_process";import"node:process";import"child_process";import"node:url";import"node:os";import"assert";import"events";import"node:fs";import"buffer";import"stream";import"util";import"node:util";import"inquirer";import"fs/promises";import"readline";import"figlet";import"gradient-string";import"ora";import"inquirer-reactive-list-prompt";import"winston-daily-rotate-file";import"axios";import"url";import"node:fs/promises";import"chokidar";import"rxjs/operators";class O extends b{constructor(r){super(r),this.params=r,this.apiKey="",this.colors={primary:"#20808D",secondary:"#FFF"},this.serviceName=g.bgHex(this.colors.primary).hex(this.colors.secondary).bold(`[Perplexity/${this.params.config.model}]`),this.errorPrefix=g.red.bold(`[Perplexity/${this.params.config.model}]`),this.apiKey=this.params.config.key}getServiceSpecificErrorMessage(r){const e=r.message||"";return e.includes("API key")||e.includes("api_key")?"Invalid API key. Check your Perplexity API key in configuration":e.includes("rate_limit")||e.includes("Rate limit")?"Rate limit exceeded. Wait a moment and try again, or upgrade your Perplexity plan":e.includes("model")||e.includes("Model")?"Model not found or not accessible. Check if the Perplexity model name is correct":e.includes("overloaded")||e.includes("capacity")?"Perplexity service is overloaded. Try again in a few minutes":e.includes("403")||e.includes("Forbidden")?"Access denied. Your API key may not have permission for this Perplexity model":e.includes("404")||e.includes("Not Found")?"Model or endpoint not found. Check your Perplexity model configuration":e.includes("500")||e.includes("Internal Server Error")?"Perplexity server error. Try again later":null}generateCommitMessage$(){return x(this.generateMessage("commit")).pipe(f(r=>u(r)),y(this.formatAsChoice),P(this.handleError$))}generateCodeReview$(){return x(this.generateMessage("review")).pipe(f(r=>u(r)),y(this.formatCodeReviewAsChoice),P(this.handleError$))}extractJSONFromError(r){const e=/[{[]{1}([,:{}[\]0-9.\-+Eaeflnr-u \n\r\t]|".*?")+[}\]]{1}/gis,o=r.match(e);if(o){const t={};for(const i of o)try{Object.assign(t,JSON.parse(i))}catch{}return Object.keys(t).length>0?t:{error:{message:"Unknown error"}}}return{error:{message:"Unknown error"}}}async generateMessage(r){const e=this.params.stagedDiff.diff,{systemPrompt:o,systemPromptPath:t,codeReviewPromptPath:i,logging:n,locale:m,generate:a,type:c,maxLength:l}=this.params.config,s={...E,locale:m,maxLength:l,type:c,generate:a,systemPrompt:o,systemPromptPath:t,codeReviewPromptPath:i,vcs_branch:this.params.branchName||""},h=r==="review"?N(s):S(s),p=`Here is the diff: ${e}`,A=`${this.params.config.url||"https://api.perplexity.ai"}/chat/completions`,C={Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"};k(e,r,"Perplexity",this.params.config.model,A,C,n),I(e,r,"Perplexity",h,p,n);const d=await this.createChatCompletions(h,p,r);return r==="review"?this.parseCodeReview(d):this.parseMessage(d,c,a)}async createChatCompletions(r,e,o){const t=this.params.stagedDiff.diff,{logging:i}=this.params.config,n={model:this.params.config.model,messages:[{role:"system",content:r},{role:"user",content:e}],temperature:this.params.config.temperature,top_p:this.params.config.topP,max_tokens:this.params.config.maxTokens,stream:!1};R(t,o,"Perplexity",n,i);const m=Date.now();try{const a=this.params.config.url||"https://api.perplexity.ai",c=await new D({method:"POST",baseURL:`${a}/chat/completions`,timeout:this.params.config.timeout}).setHeaders({Authorization:`Bearer ${this.apiKey}`,"content-type":"application/json"}).setBody(n).execute(),l=Date.now()-m,s=c.data;if(M(t,o,"Perplexity",s,i),!s.choices||s.choices.length===0||!s.choices[0].message?.content)throw v(t,o,"Perplexity",{message:"No Content on response",result:s},i),new Error("No Content on response. Please open a Bug report");const p=s.choices[0].message.content;return $(t,o,"Perplexity",l,p,i),p}catch(a){throw v(t,o,"Perplexity",a,i),a}}}export{O as PerplexityService};