mapigate 0.5.160 → 0.5.162
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.
- package/README.md +1 -1
- package/dist/cli/tools/definitions/cursor/definition.js +1 -1
- package/dist/core/router/loadBalancer.js +1 -1
- package/dist/providers/composite/combo/fallbackStrategy.js +1 -1
- package/dist/providers/runtime/antigravity/executor.js +1 -1
- package/dist/providers/runtime/antigravity/metadata.js +1 -1
- package/dist/providers/runtime/antigravity/provider.js +1 -1
- package/dist/providers/runtime/antigravity/routes.js +1 -1
- package/dist/providers/runtime/antigravity/types.js +1 -1
- package/dist/providers/runtime/cursor/cursorModels.js +1 -1
- package/dist/providers/runtime/cursor/cursorSession.js +1 -1
- package/dist/providers/runtime/gemini-cli/provider.js +1 -1
- package/dist/providers/runtime/kiro/executor.js +4 -4
- package/dist/providers/runtime/kiro/metadata.js +1 -1
- package/dist/providers/runtime/kiro/provider.js +1 -1
- package/dist/providers/runtime/kiro/quota.js +1 -1
- package/dist/server/proxy/executorHelpers.js +1 -1
- package/dist/server/proxy/singleModelExecutor.js +5 -5
- package/dist/server/routes/apiCliTools.js +1 -1
- package/dist/server/routes/apiModels.js +1 -1
- package/dist/shared/utils/dnsResolver.js +1 -1
- package/dist/storage/repositories/providerRepo.js +5 -5
- package/dist/web/assets/CliToolsTab-iJozQAQx.js +168 -0
- package/dist/web/assets/{CombosTab-Cs2KWP8i.js → CombosTab-DdsJ2ova.js} +1 -1
- package/dist/web/assets/{ConfirmModal-73IbJAih.js → ConfirmModal-Co5OXd_g.js} +1 -1
- package/dist/web/assets/{ConsoleLogTab-DswA4_eC.js → ConsoleLogTab-BTGaJpcD.js} +1 -1
- package/dist/web/assets/{EditAccountModal-tMfNcAXT.js → EditAccountModal-DLyP9VNQ.js} +1 -1
- package/dist/web/assets/{EndpointTab-CweuNkGD.js → EndpointTab-DbjjVT7s.js} +1 -1
- package/dist/web/assets/{MitmTab-BBl5YAE3.js → MitmTab-DMRg64by.js} +2 -2
- package/dist/web/assets/{ModelAutocompleteInput-AZuprXC_.js → ModelAutocompleteInput-D0L1aj3-.js} +1 -1
- package/dist/web/assets/{ProviderDetailPage-CQh2gHX6.js → ProviderDetailPage-CeOUazix.js} +3 -3
- package/dist/web/assets/{ProvidersTab-CcpCZwlv.js → ProvidersTab-Dd-prffr.js} +1 -1
- package/dist/web/assets/{QuotaTab-CaoBW7ru.js → QuotaTab-zPkj0Rwo.js} +1 -1
- package/dist/web/assets/{SettingsTab-15Sy7cCT.js → SettingsTab-DUlhyz1z.js} +1 -1
- package/dist/web/assets/{UsageTab-wcmWwuXa.js → UsageTab-Da7c7zwV.js} +1 -1
- package/dist/web/assets/{index-CYeNOWj5.js → index-CtfMJ11V.js} +2 -2
- package/dist/web/assets/{index-HnsyZg0I.css → index-DXsZmXJg.css} +1 -1
- package/dist/web/assets/metadataRegistry-CGDAkFU1.js +1 -0
- package/dist/web/assets/{providersData-Bf-DlZQW.js → providersData-HX0E7hDv.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/CliToolsTab-B_lNHS7I.js +0 -168
- package/dist/web/assets/metadataRegistry-BkOuhIJ2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var T=Object.defineProperty;var y=(s,o)=>T(s,"name",{value:o,configurable:!0});import{Router as S}from"express";import g from"node:fs/promises";import j from"node:path";import $ from"node:os";import{CLI_TOOLS as m,getMapigateBaseUrl as k}from"../../shared/constants/cliTools.js";import{CliToolRegistry as w}from"../../cli/tools/index.js";import{DEFAULT_PORT as b}from"../../shared/constants/index.js";import{serverLifecycle as M}from"../lifecycle.js";import{checkBinaryInstalled as v}from"../../providers/core/base/baseProvider.js";import{ToolMappingRepository as l}from"../../storage/repositories/toolMappingRepo.js";const r=S();function h(s){if(!s)return null;const o=$.homedir();return s.startsWith("~/")||s.startsWith("~\\")?j.join(o,s.slice(2)):s.startsWith("~")?j.join(o,s.slice(1)):s}y(h,"resolveUserPath");async function f(s){if(!s)return!1;try{return await g.access(s),!0}catch{return!1}}y(f,"checkFileExists");async function d(s){const o=m[s];if(!o)return{id:s,name:s,installed:!1,configured:!1,status:"Not installed",hasMapigate:!1};const t=h(o.configPath||o.settingsFile),e=await v(o.binary),n=await f(t),a=e||n;let p=!1,u="";if(n&&t)try{u=await g.readFile(t,"utf-8");const c=String(M.getPort());(u.includes(c)||u.includes(String(b))||u.includes("mapigate"))&&(p=!0)}catch{}let i="Not installed";return p?i="Connected":a?o.configType==="guide"?i="Guide":i="Not configured":o.configType==="guide"?i="Guide":i="Not installed",{id:o.id,name:o.name,installed:a,configured:p,status:i,configPath:t||void 0,settingsPath:t||void 0,hasMapigate:p}}y(d,"inspectToolStatus"),r.get("/status",async(s,o)=>{try{const t=Object.keys(m),e=await Promise.all(t.map(a=>d(a))),n={};for(const a of e)n[a.id]=a;o.json(n)}catch(t){o.status(500).json({error:t.message||"Failed to inspect CLI tool statuses"})}}),r.get("/all-statuses",async(s,o)=>{try{const t=Object.keys(m),e=await Promise.all(t.map(a=>d(a))),n={};for(const a of e)n[a.id]=a;o.json(n)}catch(t){o.status(500).json({error:t.message||"Failed to inspect CLI tool statuses"})}}),r.get("/global-mappings",(s,o)=>{const t=l.getGlobalMappings();o.json(t)}),r.post("/global-mappings",(s,o)=>{const{sourceModel:t,targetModel:e}=s.body;if(!t||!e){o.status(400).json({error:"Missing sourceModel or targetModel"});return}l.saveGlobalMapping(t,e),o.json({success:!0,sourceModel:t,targetModel:e})}),r.delete("/global-mappings",(s,o)=>{const t=s.query.sourceModel||s.body?.sourceModel;if(!t){o.status(400).json({error:"Missing sourceModel parameter"});return}l.deleteGlobalMapping(t),o.json({success:!0,sourceModel:t})}),r.delete("/global-mappings/*",(s,o)=>{const t=s.params[0]||s.params.sourceModel;if(!t){o.status(400).json({error:"Missing sourceModel parameter"});return}l.deleteGlobalMapping(t),o.json({success:!0,sourceModel:t})}),r.post("/global-mappings/import/:tool",(s,o)=>{const{tool:t}=s.params,e=l.importToolDefaultsToGlobal(t);o.json({success:!0,tool:t,mappings:e})}),r.post("/global-mappings/reset",(s,o)=>{const t=l.resetGlobalMappings();o.json({success:!0,mappings:t})}),r.get("/mappings/:tool",(s,o)=>{const{tool:t}=s.params,e=l.getMappings(t);o.json(e)}),r.post("/mappings",(s,o)=>{const t=s.body.tool||s.body.toolId||s.body.ide,{sourceModel:e,targetModel:n}=s.body;if(!t||!e||!n){o.status(400).json({error:"Missing tool, sourceModel, or targetModel"});return}l.saveMapping(t,e,n),o.json({success:!0,tool:t,sourceModel:e,targetModel:n})}),r.post("/mappings/reset",(s,o)=>{const t=s.body.tool||s.body.toolId||s.body.ide||"claude",e=l.resetMappings(t);o.json({success:!0,tool:t,mappings:e})}),r.get("/:tool",async(s,o)=>{const{tool:t}=s.params;try{const e=await d(t);o.json(e)}catch(e){o.status(500).json({error:e.message||"Failed to inspect tool status"})}}),r.post("/:tool/apply",async(s,o)=>{const{tool:t}=s.params,e=m[t];if(!e){o.status(404).json({error:`Tool ${t} not found`});return}try{const n=w.get(t);if(n){await n.apply({baseUrl:k(M.getPort()),apiKey:s.body?.apiKey||"mapigate-local",model:s.body?.model||e.defaultModels?.[0]||"claude-sonnet-4-6"});const i=await d(t);o.json({success:!0,status:i});return}const a=h(e.configPath||e.settingsFile);if(!a){o.status(400).json({error:`Tool ${t} has no direct file configuration path`});return}const p=j.dirname(a);if(await g.mkdir(p,{recursive:!0}),e.configFileTemplate){const i=`${a}.bak-mapigate`;if(await f(a)&&!await f(i))try{await g.copyFile(a,i)}catch{}const c=M.getPort(),P=typeof s.body?.apiKey=="string"&&s.body.apiKey.trim()?s.body.apiKey.trim():"mapigate-local",F=e.configFileTemplate.replace(new RegExp(`127\\.0\\.0\\.1:${b}`,"g"),`127.0.0.1:${c}`).replace(new RegExp(`:${b}`,"g"),`:${c}`).replace(/mapigate-local/g,P);await g.writeFile(a,F,{encoding:"utf-8",mode:384})}else{o.status(400).json({error:`No config template available for ${t}`});return}const u=await d(t);o.json({success:!0,status:u})}catch(n){o.status(500).json({error:n.message||"Failed to apply configuration"})}}),r.post("/:tool/reset",async(s,o)=>{const{tool:t}=s.params,e=m[t];if(!e){o.status(404).json({error:`Tool ${t} not found`});return}try{const n=w.get(t);if(n){await n.reset();const i=await d(t);o.json({success:!0,status:i});return}const a=h(e.configPath||e.settingsFile);if(!a){o.status(400).json({error:`Tool ${t} has no file configuration path`});return}const p=`${a}.bak-mapigate`;if(await f(p))await g.copyFile(p,a);else if(await f(a))try{const i=await g.readFile(a,"utf-8");if(a.endsWith(".json")){const c=JSON.parse(i.replace(/,(\s*[}\]])/g,"$1"));c&&typeof c=="object"&&(c.baseUrl&&String(c.baseUrl).includes(String(M.getPort()))&&delete c.baseUrl,c.apiKey==="mapigate-local"&&delete c.apiKey,await g.writeFile(a,JSON.stringify(c,null,2),{encoding:"utf-8",mode:384}))}}catch{}const u=await d(t);o.json({success:!0,status:u})}catch(n){o.status(500).json({error:n.message||"Failed to reset configuration"})}}),r.get("/:tool/mappings",(s,o)=>{const{tool:t}=s.params,e=l.getMappings(t);o.json(e)}),r.post("/:tool/mappings",(s,o)=>{const{tool:t}=s.params,{sourceModel:e,targetModel:n}=s.body;if(!e||!n){o.status(400).json({error:"Missing sourceModel or targetModel"});return}l.saveMapping(t,e,n),o.json({success:!0,tool:t,sourceModel:e,targetModel:n})}),r.post("/:tool/mappings/reset",(s,o)=>{const{tool:t}=s.params,e=l.resetMappings(t);o.json({success:!0,tool:t,mappings:e})}),r.delete("/:tool/mappings",(s,o)=>{const{tool:t}=s.params,e=s.query.sourceModel||s.body?.sourceModel;if(!e){o.status(400).json({error:"Missing sourceModel parameter"});return}l.deleteMapping(t,e),o.json({success:!0,tool:t,sourceModel:e})}),r.delete("/:tool/mappings/*",(s,o)=>{const{tool:t}=s.params,e=s.params[0]||s.params.sourceModel;if(!e){o.status(400).json({error:"Missing sourceModel parameter"});return}l.deleteMapping(t,e),o.json({success:!0,tool:t,sourceModel:e})});export{r as cliToolsRouter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Y=Object.defineProperty;var R=($,g)=>Y($,"name",{value:g,configurable:!0});import{Router as J}from"express";import{ModelRepository as E}from"../../storage/repositories/modelRepo.js";import{ProviderRepository as W}from"../../storage/repositories/providerRepo.js";import{AccountModelRepository as T}from"../../storage/repositories/accountModelRepo.js";import{ComboRepository as z}from"../../storage/repositories/comboRepo.js";import{PROVIDER_REGISTRY as x,getRegistryProvider as N}from"../../shared/constants/providerRegistry.js";import{getCapabilitiesForModel as G,aggregateComboCapabilities as Q}from"../../core/capabilities/index.js";import X from"node:crypto";const U=J();U.get("/",($,g)=>{const a=E.getAllRules();g.json(a)}),U.get("/available",($,g)=>{try{const a=$.query.connectedOnly,B=a==="true"||a==="1",C=W.getAllAccounts(),S=W.getAllProviders(),I=new Map,L=new Map;for(const o of C)if(o.isActive){I.set(o.providerId,(I.get(o.providerId)||0)+1);const t=(o.tag||o.providerSpecificData?.tag)?.trim().toLowerCase();if(t){let s=L.get(o.providerId);s||(s=new Set,L.set(o.providerId,s)),s.add(t)}}const O=new Map(S.map(o=>[o.id,o])),j=new Map;for(const o of C)if(o.isActive){let t=j.get(o.providerId);t||(t=[],j.set(o.providerId,t)),t.push(o.id)}const _=R((o,t)=>{const s=new Set([o]);if(t?.alias&&s.add(t.alias),Array.isArray(t?.aliases))for(const n of t.aliases)s.add(n);const u=[];for(const n of s){const f=j.get(n);f&&u.push(...f)}return u.length>0?T.getModelsForAccounts(u):[]},"getScannedAccountModelsForProvider"),q=R((o,t)=>{const s=new Set([o]);if(t?.alias&&s.add(t.alias),Array.isArray(t?.aliases))for(const n of t.aliases)s.add(n);for(const n of s){const f=O.get(n);if(f&&Array.isArray(f.models)&&f.models.length>0)return!0}return _(o,t).length>0},"hasDbConfiguredModels"),F=R(o=>{let t=I.get(o)||0;const s=x[o]||N(o);if(s&&(s.alias&&s.alias!==s.id&&(t+=I.get(s.alias)||0),s.aliases))for(const u of s.aliases)u!==s.id&&u!==s.alias&&(t+=I.get(u)||0);return s?.noAuth||s?.requiresApiKey===!1||s?.authType==="none"||o==="opencode"||o==="oc"?Math.max(1,t):t},"getProviderAccountsCount"),e=[],i=new Set,b=[...z.getAllCombos()].sort((o,t)=>o.name.localeCompare(t.name,void 0,{sensitivity:"base"}));for(const o of b){if(!o.isActive)continue;let t=!1,s=0;for(const A of o.models){let v="";const p=A.indexOf("/");if(p!==-1)v=A.slice(0,p);else{for(const y of Object.values(x))if(y?.models?.some(D=>D.id===A)){v=y.id;break}if(!v){for(const y of S)if(Array.isArray(y.models)&&y.models.some(V=>{const H=typeof V=="string"?V:V?.id;return H===A||H===`${y.id}/${A}`})){v=y.id;break}}}const M=v.match(/^([^[\]]+)\[([^[\]]+)\]$/),h=M?M[1]:v,P=M?M[2].toLowerCase():void 0;if(h)if(P){const y=C.filter(D=>D.isActive&&D.providerId===h&&(D.tag||D.providerSpecificData?.tag)?.trim().toLowerCase()===P).length;y>0&&(t=!0,s+=y)}else{const y=F(h);y>0&&(t=!0,s+=y)}}if(B&&!t)continue;const u=o.name.startsWith("combo/")?o.name:`combo/${o.name}`;if(i.has(u))continue;i.add(u);const n=Q(o.models),f=!!n?.vision,w=!!n?.reasoning,r=!!(n?.audioInput||n?.audioOutput),d=n?.contextWindow||0;e.push({id:o.id,value:u,name:o.name,providerId:"combo",providerName:"Combos",hasConnectedAccount:t,accountsCount:s,caps:{vision:f,reasoning:w,audio:r},contextLength:d,isCombo:!0,strategy:o.strategy,models:o.models})}const m=new Set(S.map(o=>o.id)),c=[...S];for(const[o,t]of j.entries())if(!m.has(o)){const s=x[o]||N(o),u=T.getModelsForAccounts(t);u.length>0&&(c.push({id:o,name:s?.name||o,baseUrl:s?.baseUrl||"",format:s?.format||"openai",isActive:!0,priority:10,models:u,customHeaders:{},thinkingMode:"auto",strategy:null,stickyLimit:1,createdAt:Date.now(),updatedAt:Date.now()}),m.add(o))}const k=c.sort((o,t)=>(o.name||o.id).localeCompare(t.name||t.id,void 0,{sensitivity:"base"}));for(const o of k){const t=x[o.id]||N(o.id);let s=Array.isArray(o.models)?[...o.models]:[];const u=_(o.id,t);if(u.length>0){const r=new Set(s.map(d=>typeof d=="string"?d:d.id));for(const d of u)r.has(d)||(s.push(d),r.add(d))}if(s.length===0)continue;const n=[...s].sort((r,d)=>{const A=typeof r=="string"?r:r.name||r.id,v=typeof d=="string"?d:d.name||d.id;return A.localeCompare(v,void 0,{sensitivity:"base"})}),f=F(o.id),w=f>0;if(!(B&&!w))for(const r of n){const d=typeof r=="string"?r:r.id,A=typeof r=="string"?r:r.name||r.id,v=d.startsWith(`${o.id}/`)?d:`${o.id}/${d}`;if(i.has(v))continue;i.add(v);const p=G(o.id,d);e.push({id:d,value:v,name:A,providerId:o.id,providerName:o.name||o.id,hasConnectedAccount:w,accountsCount:f,caps:{vision:!!p.vision,reasoning:!!p.reasoning,audio:!!(p.audioInput||p.audioOutput)},contextLength:p.contextWindow||0});const M=L.get(o.id);if(M&&M.size>0)for(const h of M){const P=`${o.id}[${h}]/${d}`;i.has(P)||(i.add(P),e.push({id:d,value:P,name:`${A} [${h}]`,providerId:o.id,providerName:`${o.name||o.id} [${h}]`,hasConnectedAccount:!0,accountsCount:1,caps:{vision:!!p.vision,reasoning:!!p.reasoning,audio:!!(p.audioInput||p.audioOutput)},contextLength:p.contextWindow||0}))}}}const K=Object.values(x).sort((o,t)=>(o.name||o.id).localeCompare(t.name||t.id,void 0,{sensitivity:"base"}));for(const o of K){if(!o||!o.models||q(o.id,o))continue;const t=F(o.id),s=t>0;if(B&&!s)continue;const u=[...o.models].sort((n,f)=>(n.name||n.id).localeCompare(f.name||f.id,void 0,{sensitivity:"base"}));for(const n of u){const f=n.id.startsWith(`${o.id}/`)?n.id:`${o.id}/${n.id}`;if(i.has(f))continue;i.add(f);const w=n,r=G(o.id,n.id),d=R(h=>n.capabilities?Array.isArray(n.capabilities)?n.capabilities.includes(h):!!n.capabilities[h]:!1,"hasCap"),A=!!(w.vision!==void 0?w.vision:d("vision")||r.vision),v=!!(w.reasoning!==void 0?w.reasoning:d("reasoning")||r.reasoning),p=!!(w.audio!==void 0?w.audio:d("audio")||r.audioInput||r.audioOutput);e.push({id:n.id,value:f,name:n.name||n.id,providerId:o.id,providerName:o.name,hasConnectedAccount:s,accountsCount:t,caps:{vision:A,reasoning:v,audio:p},contextLength:n.contextLength||0});const M=L.get(o.id);if(M&&M.size>0)for(const h of M){const P=`${o.id}[${h}]/${n.id}`;i.has(P)||(i.add(P),e.push({id:n.id,value:P,name:`${n.name||n.id} [${h}]`,providerId:o.id,providerName:`${o.name} [${h}]`,hasConnectedAccount:!0,accountsCount:1,caps:{vision:A,reasoning:v,audio:p},contextLength:n.contextLength||0}))}}}g.json(e)}catch(a){g.status(500).json({error:a.message||"Failed to load available models"})}}),U.post("/rules",($,g)=>{try{const a=$.body||{};if(!a.alias||!a.targetModel||!a.targetProviderId){g.status(400).json({error:"Alias, targetModel, and targetProviderId are required."});return}a.targetProviderId&&a.targetProviderId!=="combo"&&W.ensureProviderExists(a.targetProviderId);const C={id:a.id||`rule_${X.randomUUID().slice(0,8)}`,alias:a.alias,targetModel:a.targetModel,targetProviderId:a.targetProviderId,fallbackRules:Array.isArray(a.fallbackRules)?a.fallbackRules:[],isDefault:!!a.isDefault},S=E.saveRule(C);g.json(S||C)}catch(a){g.status(500).json({error:a.message||"Failed to save model rule"})}}),U.delete("/rules/:id",($,g)=>{E.deleteRule($.params.id),g.json({success:!0})});function co($,g){try{const a=[],B=z.getAllCombos();for(const e of B)e.isActive&&a.push({id:e.name,object:"model",created:Math.floor(e.createdAt/1e3)||Math.floor(Date.now()/1e3),owned_by:"combo"});const C=new Set,S=W.getAllAccounts(),I=W.getAllProviders(),L=new Map(I.map(e=>[e.id,e])),O=new Map;for(const e of S)if(e.isActive){let i=O.get(e.providerId);i||(i=[],O.set(e.providerId,i)),i.push(e.id)}const j=R((e,i)=>{const l=new Set([e]);if(i?.alias&&l.add(i.alias),Array.isArray(i?.aliases))for(const m of i.aliases)l.add(m);const b=[];for(const m of l){const c=O.get(m);c&&b.push(...c)}return b.length>0?T.getModelsForAccounts(b):[]},"getScannedAccountModelsForProvider"),_=R((e,i)=>{const l=new Set([e]);if(i?.alias&&l.add(i.alias),Array.isArray(i?.aliases))for(const m of i.aliases)l.add(m);for(const m of l){const c=L.get(m);if(c&&Array.isArray(c.models)&&c.models.length>0)return!0}return j(e,i).length>0},"hasDbConfiguredModels"),q=new Set(I.map(e=>e.id)),F=[...I];for(const[e,i]of O.entries())if(!q.has(e)){const l=x[e]||N(e),b=T.getModelsForAccounts(i);b.length>0&&(F.push({id:e,name:l?.name||e,baseUrl:l?.baseUrl||"",format:l?.format||"openai",isActive:!0,priority:10,models:b,customHeaders:{},thinkingMode:"auto",strategy:null,stickyLimit:1,createdAt:Date.now(),updatedAt:Date.now()}),q.add(e))}for(const e of F){const i=x[e.id]||N(e.id);let l=Array.isArray(e.models)?[...e.models]:[];const b=j(e.id,i);if(b.length>0){const m=new Set(l.map(c=>typeof c=="string"?c:c.id));for(const c of b)m.has(c)||(l.push(c),m.add(c))}for(const m of l){const c=typeof m=="string"?m:m.id,k=c.startsWith(`${e.id}/`)?c:`${e.id}/${c}`;C.has(k)||(C.add(k),a.push({id:k,object:"model",created:Math.floor(e.updatedAt/1e3)||Math.floor(Date.now()/1e3),owned_by:e.id}))}}for(const e of Object.values(x))if(!(!e||!e.models)&&!_(e.id,e))for(const i of e.models){const l=i.id.startsWith(`${e.id}/`)?i.id:`${e.id}/${i.id}`;C.has(l)||(C.add(l),a.push({id:l,object:"model",created:Math.floor(Date.now()/1e3),owned_by:e.id}))}g.json({object:"list",data:a})}catch(a){g.status(500).json({error:a.message||"Failed to list models"})}}R(co,"handleOpenAiModelsList");export{co as handleOpenAiModelsList,U as modelRouter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=Object.defineProperty;var c=(e,t)=>d(e,"name",{value:t,configurable:!0});import T from"node:dns";import{promisify as g}from"node:util";import{Agent as y,fetch as m}from"undici";const a=Object.create(null),S=300*1e3,D=500,I=process.env.MAPIGATE_TLS_ECDH_CURVE||"X25519:prime256v1:secp384r1",M={autoSelectFamily:!0,autoSelectFamilyAttemptTimeout:250},x=4*1e3,A=1;function C(){const e=Number(process.env.MAPIGATE_FETCH_KEEPALIVE_TIMEOUT_MS),t=Number.isFinite(e)&&e>0?e:x;return{keepAliveTimeout:t,keepAliveMaxTimeout:t}}c(C,"resolveKeepAliveTimeouts");let u=null,v=null;function _(){return u||(u=new T.Resolver,u.setServers(["8.8.8.8","1.1.1.1"]),v=g(u.resolve4.bind(u))),{resolver:u,resolve4:v}}c(_,"getResolver");async function k(e){const t=a[e];if(t&&Date.now()-t.ts<S)return t.ip;try{const{resolve4:o}=_(),l=(await o(e))[0]||e,n=Object.keys(a);return n.length>=D&&!(e in a)&&delete a[n[0]],a[e]={ip:l,ts:Date.now()},l}catch{return e}}c(k,"resolveTargetIP");function U(e,t,o){const s=typeof t=="function"?t:o,l=typeof t=="function"?{}:t||{};k(e).then(n=>{const r=n.includes(":")?6:4;l.all?s(null,[{address:n,family:r}]):s(null,n,r)}).catch(n=>{s(n,l.all?[]:"",4)})}c(U,"publicDnsLookup");let f=null,p=null;function b(e,t){const{resolve4:o}=_();return new y({keepAliveTimeout:e,keepAliveMaxTimeout:t,connect:{...M,ecdhCurve:I,lookup:c((s,l,n)=>{let r=n,i=l;typeof i=="function"&&(r=i,i={}),o(s).then(E=>{i&&i.all?r(null,E.map(h=>({address:h,family:4}))):r(null,E[0],4)}).catch(()=>{T.lookup(s,i,r)})},"lookup")}})}c(b,"createPublicDnsAgent");function P(e){if(e?.forceFreshSocket)return p||(p=b(A,A)),p;if(!f){const{keepAliveTimeout:t,keepAliveMaxTimeout:o}=C();f=b(t,o)}return f}c(P,"getPublicDnsAgent");function H(){for(const e of[f,p])try{e?.destroy?.(),e?.close?.()}catch{}f=null,p=null}c(H,"clearPublicDnsAgents");const F=globalThis.fetch,L=process.env.NODE_ENV==="test"||process.env.MAPIGATE_TEST==="1";async function V(e,t){if(L&&typeof globalThis.fetch=="function"&&globalThis.fetch!==F)return await globalThis.fetch(e,t);const o=P();return await m(e,{...t||{},dispatcher:o})}c(V,"fetchWithDnsBypass");export{x as DEFAULT_KEEPALIVE_TIMEOUT_MS,M as EYEBALLS_CONNECT,A as FRESH_RETRY_KEEPALIVE_TIMEOUT_MS,I as TLS_ECDH_CURVE,H as clearPublicDnsAgents,V as fetchWithDnsBypass,P as getPublicDnsAgent,U as publicDnsLookup,C as resolveKeepAliveTimeouts,k as resolveTargetIP};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var h=Object.defineProperty;var A=(_,t)=>h(_,"name",{value:t,configurable:!0});import{getDatabase as c}from"../database.js";import{CryptoVault as m}from"../crypto/vault.js";import{getRegistryProvider as y}from"../../shared/constants/providerRegistry.js";function g(_){return _?m.encrypt(JSON.stringify(_)):null}A(g,"serializePsd");function f(_){if(_){if(_.trim().startsWith("{"))try{return JSON.parse(_)}catch{return}try{const t=m.decrypt(_);return t?JSON.parse(t):void 0}catch{return}}}A(f,"deserializePsd");class R{static{A(this,"ProviderRepository")}static getAllProviders(){return c().all("SELECT * FROM providers ORDER BY priority ASC, created_at ASC").map(e=>({id:e.id,name:e.name,baseUrl:e.base_url,format:e.format,isActive:!!e.is_active,priority:e.priority,models:JSON.parse(e.models||"[]"),customHeaders:JSON.parse(e.custom_headers||"{}"),proxyUrl:e.proxy_url||void 0,thinkingMode:e.thinking_mode||"auto",strategy:e.strategy||null,stickyLimit:e.sticky_limit!=null?Number(e.sticky_limit):1,createdAt:e.created_at,updatedAt:e.updated_at}))}static getProviderById(t){const i=c(),e=(t||"").trim();if(!e)return;const r=i.get("SELECT * FROM providers WHERE id = ?",e);if(r)return{id:r.id,name:r.name,baseUrl:r.base_url,format:r.format,isActive:!!r.is_active,priority:r.priority,models:JSON.parse(r.models||"[]"),customHeaders:JSON.parse(r.custom_headers||"{}"),proxyUrl:r.proxy_url||void 0,thinkingMode:r.thinking_mode||"auto",strategy:r.strategy||null,stickyLimit:r.sticky_limit!=null?Number(r.sticky_limit):1,createdAt:r.created_at,updatedAt:r.updated_at};const s=y(e);if(s&&s.id!==e)return this.getProviderById(s.id)}static getProviderWithDefaults(t){const i=y(t),e=this.getProviderById(t)||(i?this.getProviderById(i.id):void 0);if(!e&&!i)return;const r=e||{id:i.id,name:i.name,baseUrl:i.baseUrl,format:i.format,isActive:!0,priority:10,models:i.models.map(o=>o.id),customHeaders:{},proxyUrl:void 0,thinkingMode:i.thinkingMode||"auto",strategy:null,stickyLimit:1,noAuth:!!i?.noAuth,createdAt:Date.now(),updatedAt:Date.now()},s=r.format||i?.format||"openai",a=r.customHeaders||{},d={...i?.defaultHeaders||{}};for(const[o,n]of Object.entries(a))if(n===""||n===null||n===void 0){const p=Object.keys(d).find(l=>l.toLowerCase()===o.toLowerCase());p&&delete d[p],delete d[o]}else{const p=Object.keys(d).find(l=>l.toLowerCase()===o.toLowerCase());p&&p!==o&&delete d[p],d[o]=n}const u=r.models&&r.models.length>0?r.models:i?.models.map(o=>o.id)||[];return{...r,format:s,category:i?.category,noAuth:r.noAuth!==void 0?r.noAuth:!!i?.noAuth,customHeaders:d,userCustomHeaders:a,models:u,defaultHeaders:i?.defaultHeaders||{},catalogModels:i?.models||[],thinkingOptions:i?.thinkingOptions||["auto","none","low","medium","high"],regions:i?.regions,defaultRegion:i?.defaultRegion,supportedFormats:i?.supportedFormats,rescueInlineTools:i?.rescueInlineTools,hasProviderSpecificData:i?.hasProviderSpecificData}}static saveProvider(t){const i=c(),r=y(t.id)?.id||t.id;i.run(`INSERT INTO providers (id, name, base_url, format, is_active, priority, models, custom_headers, proxy_url, thinking_mode, strategy, sticky_limit, created_at, updated_at)
|
|
2
2
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
3
3
|
ON CONFLICT(id) DO UPDATE SET
|
|
4
4
|
name = excluded.name,
|
|
@@ -12,8 +12,8 @@ var g=Object.defineProperty;var A=(_,i)=>g(_,"name",{value:i,configurable:!0});i
|
|
|
12
12
|
thinking_mode = excluded.thinking_mode,
|
|
13
13
|
strategy = excluded.strategy,
|
|
14
14
|
sticky_limit = excluded.sticky_limit,
|
|
15
|
-
updated_at = excluded.updated_at`,r,
|
|
16
|
-
VALUES (?, ?, ?, ?, 1, 0, ?, ?, ?)`,
|
|
17
|
-
VALUES (?, ?, ?, ?, 1, 0, ?, ?, ?)`,s.id,a.id,s.name,n,
|
|
15
|
+
updated_at = excluded.updated_at`,r,t.name,t.baseUrl,t.format,t.isActive?1:0,t.priority??0,JSON.stringify(t.models||[]),JSON.stringify(t.customHeaders||{}),t.proxyUrl||null,t.thinkingMode||"auto",t.strategy||null,t.stickyLimit!=null?t.stickyLimit:1,t.createdAt??Date.now(),t.updatedAt??Date.now())}static ensureProviderExists(t,i){const e=(t||"").trim();if(!e)throw new Error("Provider ID cannot be empty");const r=this.getProviderById(e);if(r)return r;const s=y(e);if(s){const u=this.getProviderById(s.id);if(u)return u;const o=this.getProviderWithDefaults(s.id),n=Date.now(),p={id:s.id,name:o?.name||s.name||i||s.id,baseUrl:o?.baseUrl||s.baseUrl||"https://api.openai.com",format:o?.format||s.format||"openai",isActive:!0,priority:o?.priority??10,models:o?.models&&o.models.length>0?o.models:s.models?.map(l=>l.id)||[],customHeaders:o?.userCustomHeaders&&Object.keys(o.userCustomHeaders).length>0?o.userCustomHeaders:{},proxyUrl:o?.proxyUrl||void 0,thinkingMode:o?.thinkingMode||s.thinkingMode||"auto",strategy:o?.strategy||null,stickyLimit:o?.stickyLimit!=null?o.stickyLimit:1,createdAt:n,updatedAt:n};return this.saveProvider(p),p}const a=Date.now(),d={id:e,name:i||e,baseUrl:"https://api.openai.com",format:"openai",isActive:!0,priority:10,models:[],customHeaders:{},proxyUrl:void 0,thinkingMode:"auto",strategy:null,stickyLimit:1,createdAt:a,updatedAt:a};return this.saveProvider(d),d}static syncRegistryDefaults(){const t=this.getAllProviders();for(const i of t){const e=y(i.id);if(!e)continue;let r=!1;const s=Array.isArray(e.supportedFormats)&&e.supportedFormats.some(a=>(typeof a=="string"?a:a.value)===i.format);if(e.format&&i.format!==e.format&&!s&&(i.format=e.format,r=!0),Array.isArray(e.models)&&e.models.length>0&&(Array.isArray(i.models)&&i.models.length>0||(i.models=e.models.map(d=>d.id),r=!0)),i.customHeaders&&Object.keys(i.customHeaders).length>0){const a=e.defaultHeaders||{},d=Object.keys(a),u=Object.keys(i.customHeaders);if(d.length>1&&u.length===d.length&&u.every(n=>n in a&&i.customHeaders[n]!==""))i.customHeaders={},r=!0;else{const n={};let p=!1;for(const[l,v]of Object.entries(i.customHeaders))v!==""&&a[l]!==void 0&&a[l]===v?p=!0:n[l]=v;p&&(i.customHeaders=n,r=!0)}}r&&(i.updatedAt=Date.now(),this.saveProvider(i))}}static seedDefaultProviders(){const t=c();let i=!1;try{i=!!t.get("SELECT value FROM settings WHERE key = 'core_providers_seeded'")?.value}catch{}if(!i){const e=["claude","cursor","codex","kiro","antigravity","github","openai","deepseek","gemini"];for(const r of e)try{this.ensureProviderExists(r)}catch{}try{t.run("INSERT INTO settings (key, value) VALUES ('core_providers_seeded', '1') ON CONFLICT(key) DO NOTHING")}catch{}}try{this.syncRegistryDefaults()}catch{}}static updateProviderStrategy(t,i,e){const r=c(),s=this.ensureProviderExists(t);r.run("UPDATE providers SET strategy = ?, sticky_limit = ?, updated_at = ? WHERE id = ?",i,e,Date.now(),s.id)}static deleteProvider(t){c().run("DELETE FROM providers WHERE id = ?",t)}static getAllAccounts(){return c().all("SELECT * FROM provider_accounts ORDER BY provider_id ASC, sort_order ASC, created_at ASC, rowid ASC").map(e=>{const r=f(e.provider_specific_data);return{id:e.id,providerId:e.provider_id,name:e.name,tag:r?.tag||void 0,apiKeyEncrypted:e.api_key_encrypted,rawApiKey:m.decrypt(e.api_key_encrypted),isActive:!!e.is_active,rateLimitHits:e.rate_limit_hits,sortOrder:e.sort_order??0,lastUsedAt:e.last_used_at,createdAt:e.created_at,providerSpecificData:r,cachedQuotas:e.cached_quotas||void 0,quotaFetchedAt:e.quota_fetched_at||void 0}})}static bulkToggleAccounts(t,i){if(!t||t.length===0)return;const e=c();e.exec("BEGIN TRANSACTION;");try{for(const r of t)e.run("UPDATE provider_accounts SET is_active = ? WHERE id = ?",i?1:0,r);e.exec("COMMIT;")}catch(r){try{e.exec("ROLLBACK;")}catch{}throw r}}static updateCachedQuota(t,i,e=Date.now()){c().run("UPDATE provider_accounts SET cached_quotas = ?, quota_fetched_at = ? WHERE id = ?",i,e,t)}static getAllAccountsByProvider(t){const i=c(),e=y(t),r=e?.id||t,s=i.all("SELECT * FROM provider_accounts WHERE (provider_id = ? OR provider_id = ?) ORDER BY sort_order ASC, created_at ASC, rowid ASC",t,r),a=!!e?.noAuth||e?.requiresApiKey===!1||e?.authType==="none"||r==="opencode"||r==="oc";if(s.length===0&&a){const d=r==="opencode"||r==="oc";return[{id:d?"acc_opencode_free":`acc_${r}_default`,providerId:r,name:d?"OpenCode Free (Public)":`${e?.name||r} (Default)`,apiKeyEncrypted:"",rawApiKey:d?"public":"",isActive:!0,rateLimitHits:0,sortOrder:0,lastUsedAt:0,createdAt:0}]}return s.map(d=>{const u=f(d.provider_specific_data);return{id:d.id,providerId:d.provider_id,name:d.name,tag:u?.tag||void 0,apiKeyEncrypted:d.api_key_encrypted,rawApiKey:m.decrypt(d.api_key_encrypted),isActive:!!d.is_active,rateLimitHits:d.rate_limit_hits,sortOrder:d.sort_order??0,lastUsedAt:d.last_used_at,createdAt:d.created_at,providerSpecificData:u,cachedQuotas:d.cached_quotas||void 0,quotaFetchedAt:d.quota_fetched_at||void 0}})}static getAccountsByProvider(t){const i=c(),e=y(t),r=e?.id||t,s=i.all("SELECT * FROM provider_accounts WHERE (provider_id = ? OR provider_id = ?) AND is_active = 1 ORDER BY sort_order ASC, rate_limit_hits ASC, created_at ASC, rowid ASC",t,r),a=!!e?.noAuth||e?.requiresApiKey===!1||e?.authType==="none"||r==="opencode"||r==="oc";if(s.length===0&&a){const d=r==="opencode"||r==="oc";return[{id:d?"acc_opencode_free":`acc_${r}_default`,providerId:r,name:d?"OpenCode Free (Public)":`${e?.name||r} (Default)`,apiKeyEncrypted:"",rawApiKey:d?"public":"",isActive:!0,rateLimitHits:0,sortOrder:0,lastUsedAt:0,createdAt:0}]}return s.map(d=>{const u=f(d.provider_specific_data);return{id:d.id,providerId:d.provider_id,name:d.name,tag:u?.tag||void 0,apiKeyEncrypted:d.api_key_encrypted,rawApiKey:m.decrypt(d.api_key_encrypted),isActive:!!d.is_active,rateLimitHits:d.rate_limit_hits,sortOrder:d.sort_order??0,lastUsedAt:d.last_used_at,createdAt:d.created_at,providerSpecificData:u,cachedQuotas:d.cached_quotas||void 0,quotaFetchedAt:d.quota_fetched_at||void 0}})}static getAccountById(t){const e=c().get("SELECT * FROM provider_accounts WHERE id = ?",t);if(!e){if(t==="acc_opencode_free")return{id:"acc_opencode_free",providerId:"opencode",name:"OpenCode Free (Public)",apiKeyEncrypted:"",rawApiKey:"public",isActive:!0,rateLimitHits:0,lastUsedAt:0,createdAt:0};if(t.startsWith("acc_")&&t.endsWith("_default")){const s=t.slice(4,-8),a=y(s);if(a?.noAuth||a?.requiresApiKey===!1||a?.authType==="none")return{id:t,providerId:a.id||s,name:`${a.name||s} (Default)`,apiKeyEncrypted:"",rawApiKey:"",isActive:!0,rateLimitHits:0,lastUsedAt:0,createdAt:0}}return}const r=f(e.provider_specific_data);return{id:e.id,providerId:e.provider_id,name:e.name,tag:r?.tag||void 0,apiKeyEncrypted:e.api_key_encrypted,rawApiKey:m.decrypt(e.api_key_encrypted),isActive:!!e.is_active,rateLimitHits:e.rate_limit_hits,sortOrder:e.sort_order??0,lastUsedAt:e.last_used_at,createdAt:e.created_at,providerSpecificData:r,cachedQuotas:e.cached_quotas||void 0,quotaFetchedAt:e.quota_fetched_at||void 0}}static addAccount(t){const i=this.ensureProviderExists(t.providerId),e=c(),r=t.rawApiKey||"",s=m.encrypt(r),a=Date.now(),d=t.tag&&!t.providerSpecificData?.tag?{...t.providerSpecificData,tag:t.tag}:t.providerSpecificData,u=g(d),o=e.get("SELECT MAX(sort_order) as max_order FROM provider_accounts WHERE provider_id = ?",i.id),n=o?.max_order!==null&&o?.max_order!==void 0?Number(o.max_order)+1:0,p=t.sortOrder??n;e.run(`INSERT INTO provider_accounts (id, provider_id, name, api_key_encrypted, is_active, rate_limit_hits, sort_order, created_at, provider_specific_data)
|
|
16
|
+
VALUES (?, ?, ?, ?, 1, 0, ?, ?, ?)`,t.id,i.id,t.name,s,p,a,u)}static bulkAddAccounts(t){if(!t||t.length===0)return;const i=c(),e=Date.now();i.exec("BEGIN TRANSACTION;");try{for(let r=0;r<t.length;r++){const s=t[r],a=this.ensureProviderExists(s.providerId),d=s.rawApiKey||"",u=m.encrypt(d),o=g(s.providerSpecificData),n=s.sortOrder??r;i.run(`INSERT INTO provider_accounts (id, provider_id, name, api_key_encrypted, is_active, rate_limit_hits, sort_order, created_at, provider_specific_data)
|
|
17
|
+
VALUES (?, ?, ?, ?, 1, 0, ?, ?, ?)`,s.id,a.id,s.name,u,n,e,o)}i.exec("COMMIT;")}catch(r){try{i.exec("ROLLBACK;")}catch{}throw r}}static updateAccount(t,i){const e=c(),r=e.get("SELECT * FROM provider_accounts WHERE id = ?",t);if(!r)return;const s=i.rawApiKey!==void 0&&i.rawApiKey!=="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"?m.encrypt(i.rawApiKey):r.api_key_encrypted,a=i.name!==void 0?i.name:r.name,d=i.isActive!==void 0?i.isActive?1:0:r.is_active;let u=r.provider_specific_data;if(i.providerSpecificData!==void 0){const o={...i.providerSpecificData};if(r.provider_specific_data){const n=f(r.provider_specific_data);if(n)for(const[p,l]of Object.entries(o))l==="\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022"&&n[p]!==void 0&&(o[p]=n[p])}u=g(o)}e.run(`UPDATE provider_accounts
|
|
18
18
|
SET name = ?, api_key_encrypted = ?, is_active = ?, provider_specific_data = ?
|
|
19
|
-
WHERE id = ?`,a,s,d,
|
|
19
|
+
WHERE id = ?`,a,s,d,u,t)}static deleteAccount(t){c().run("DELETE FROM provider_accounts WHERE id = ?",t)}static recordAccountUsed(t){c().run("UPDATE provider_accounts SET last_used_at = ? WHERE id = ?",Date.now(),t)}static toggleAccount(t,i){const e=c();i!==void 0?e.run("UPDATE provider_accounts SET is_active = ? WHERE id = ?",i?1:0,t):e.run("UPDATE provider_accounts SET is_active = CASE WHEN is_active = 1 THEN 0 ELSE 1 END WHERE id = ?",t)}static reorderAccounts(t){if(!t||t.length===0)return;const i=c();i.exec("BEGIN TRANSACTION;");try{t.forEach((e,r)=>{i.run("UPDATE provider_accounts SET sort_order = ? WHERE id = ?",r,e)}),i.exec("COMMIT;")}catch(e){try{i.exec("ROLLBACK;")}catch{}throw e}}static recordRateLimitHit(t){c().run("UPDATE provider_accounts SET rate_limit_hits = rate_limit_hits + 1 WHERE id = ?",t)}static resetRateLimitHits(t){c().run("UPDATE provider_accounts SET rate_limit_hits = 0 WHERE provider_id = ?",t)}}export{R as ProviderRepository};
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import{r as i,j as e}from"./vendor-BcOI2aZ9.js";import{b as o,c as N,D as z,d as ue,u as ke,P as Te}from"./index-CtfMJ11V.js";import{a as Ie}from"./providersData-HX0E7hDv.js";import{T as ce}from"./ToolIcon-Cp4gSgFt.js";import{M as de}from"./ModelAutocompleteInput-D0L1aj3-.js";import{r as Se,s as Fe}from"./lucide-Cc35htxl.js";import"./metadataRegistry-CGDAkFU1.js";const Me={id:"amp",name:"Amp CLI",image:"/assets/tools/amp/icon.png",color:"#F97316",description:"Sourcegraph Amp coding assistant CLI",configType:"env",binary:"amp",baseUrlPath:"/v1",defaultModels:["claude-sonnet-4-6","claude-3-7-sonnet","claude-3-5-sonnet","claude-opus-5","claude-fable-5.1","gpt-5.6","gpt-6-astra","glm-5.3-flash","gpt-4o"],envVars:{baseUrl:"OPENAI_BASE_URL",apiKey:"OPENAI_API_KEY"},powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
2
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
3
|
+
amp`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
4
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
5
|
+
amp`,guideSteps:[{step:1,title:"Install Amp",desc:"Install Amp CLI via official instructions"},{step:2,title:"Configure Env",desc:"Set OPENAI_BASE_URL and OPENAI_API_KEY",value:o,copyable:!0},{step:3,title:"Run",desc:"amp --model claude-sonnet-4-6"}]},$e={id:"claude",name:"Claude Code",image:"/assets/providers/claude/icon.png",color:"#D97757",iconBg:"#FFFFFF",description:"Anthropic Claude Code CLI",configType:"env",binary:"claude",settingsFile:"~/.claude/settings.json",baseUrlPath:"",envVars:{baseUrl:"ANTHROPIC_BASE_URL",model:"ANTHROPIC_MODEL",opusModel:"ANTHROPIC_DEFAULT_OPUS_MODEL",sonnetModel:"ANTHROPIC_DEFAULT_SONNET_MODEL",fableModel:"ANTHROPIC_DEFAULT_FABLE_MODEL",haikuModel:"ANTHROPIC_DEFAULT_HAIKU_MODEL"},modelAliases:["default","sonnet","opus","fable","haiku","opusplan"],defaultModels:["claude-sonnet-5.5","claude-opus-5.5","claude-haiku-5.5","claude-fable-5.1","claude-sonnet-5","claude-opus-5","claude-fable-5","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-haiku-4.5","claude-3-opus","claude-3-7-sonnet","claude-3-5-sonnet","claude-3-5-haiku"],powershellTemplate:`$env:ANTHROPIC_BASE_URL = "${N}"
|
|
6
|
+
$env:ANTHROPIC_AUTH_TOKEN = "mapigate-local"
|
|
7
|
+
$env:ANTHROPIC_MODEL = "claude-sonnet-4-6"
|
|
8
|
+
claude`,bashTemplate:`export ANTHROPIC_BASE_URL="${N}"
|
|
9
|
+
export ANTHROPIC_AUTH_TOKEN="mapigate-local"
|
|
10
|
+
export ANTHROPIC_MODEL="claude-sonnet-4-6"
|
|
11
|
+
claude`,configFileTemplate:`{
|
|
12
|
+
"env": {
|
|
13
|
+
"ANTHROPIC_BASE_URL": "${N}",
|
|
14
|
+
"ANTHROPIC_AUTH_TOKEN": "mapigate-local",
|
|
15
|
+
"ANTHROPIC_MODEL": "claude-sonnet-4-6"
|
|
16
|
+
}
|
|
17
|
+
}`,guideSteps:[{step:1,title:"Install Claude Code",desc:"npm install -g @anthropic-ai/claude-code"},{step:2,title:"Set Base URL",desc:`Point ANTHROPIC_BASE_URL to Mapigate Port ${z}`,value:N,copyable:!0},{step:3,title:"Launch CLI",desc:"Run claude in your terminal"}]},Oe={id:"cline",name:"Cline",image:"/assets/providers/cline/icon.png",color:"#5B9BD5",description:"Cline AI Coding Assistant",configType:"file",configPath:"~/.cline/data/globalState.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet-20250219","claude-3-5-sonnet-20241022","claude-3-5-haiku-20241022","claude-sonnet-4-6","gpt-4o","gpt-4o-mini","o3-mini","o1","deepseek-chat","deepseek-reasoner"],guideSteps:[{step:1,title:"Open Cline Settings",desc:"Click the gear icon in the Cline panel"},{step:2,title:"Select Provider",desc:"Choose 'OpenAI Compatible'"},{step:3,title:"Base URL",value:o,copyable:!0},{step:4,title:"API Key",value:"mapigate-local",copyable:!0}],configFileTemplate:`{
|
|
18
|
+
"apiProvider": "openai-compatible",
|
|
19
|
+
"openAiBaseUrl": "${o}",
|
|
20
|
+
"openAiApiKey": "mapigate-local"
|
|
21
|
+
}`},Be={id:"codewhale",name:"CodeWhale",image:"/assets/tools/codewhale/icon.svg",color:"#4F46E5",description:"CodeWhale terminal coding agent",configType:"custom",binary:"codewhale",configPath:"~/.codewhale/config.toml",baseUrlPath:"/v1",defaultModels:["deepseek-v4-pro","deepseek-v4-flash","deepseek-chat","deepseek-reasoner","glm-5.3","glm-5.3-flash","kimi-k3","kimi-k2.7-code","claude-sonnet-4-6"],configFileTemplate:`[openai]
|
|
22
|
+
base_url = "${o}"
|
|
23
|
+
api_key = "mapigate-local"`},Ue={id:"codex",name:"OpenAI Codex CLI / App",image:"/assets/providers/codex/icon.png",color:"#10A37F",description:"OpenAI Codex CLI",configType:"env",binary:"codex",configPath:"~/.codex/config.toml",baseUrlPath:"/v1",modelAliases:["default"],defaultModels:["default","gpt-6.1-terra","gpt-6-luna","gpt-5.6-terra","gpt-5.6-luna","gpt-5.3-codex","gpt-5.2-codex","gpt-5.1-codex-mini","gpt-5.1-codex-max","gpt-5.5-codex","o3-mini","o1","gpt-4o","gpt-4o-mini"],envVars:{baseUrl:"OPENAI_BASE_URL",apiKey:"OPENAI_API_KEY"},powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
24
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
25
|
+
codex`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
26
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
27
|
+
codex`,configFileTemplate:`model_provider = "mapigate"
|
|
28
|
+
|
|
29
|
+
[model_providers.mapigate]
|
|
30
|
+
base_url = "${o}"
|
|
31
|
+
api_key = "mapigate-local"`},Le={id:"continue",name:"Continue",image:"/assets/tools/continue/icon.png",color:"#7C3AED",description:"Continue AI Assistant",configType:"file",configPath:"~/.continue/config.json",baseUrlPath:"/v1",defaultModels:["claude-sonnet-4-6","claude-opus-4-6","claude-3-7-sonnet","claude-3-5-sonnet","claude-3-5-haiku","gpt-4o","gpt-4o-mini","o3-mini","o1","deepseek-chat","deepseek-reasoner","codestral","qwen2.5-coder"],guideSteps:[{step:1,title:"Open Continue Config",desc:"Open ~/.continue/config.json or config.yaml"},{step:2,title:"Add Model",desc:"Insert the OpenAI provider configuration pointing to Mapigate"}],codeBlock:{language:"json",code:`{
|
|
32
|
+
"models": [
|
|
33
|
+
{
|
|
34
|
+
"title": "Mapigate Model",
|
|
35
|
+
"provider": "openai",
|
|
36
|
+
"model": "claude-sonnet-4-6",
|
|
37
|
+
"apiBase": "${o}",
|
|
38
|
+
"apiKey": "mapigate-local"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
}`},configFileTemplate:`{
|
|
42
|
+
"models": [
|
|
43
|
+
{
|
|
44
|
+
"title": "Mapigate Model",
|
|
45
|
+
"provider": "openai",
|
|
46
|
+
"model": "claude-sonnet-4-6",
|
|
47
|
+
"apiBase": "${o}",
|
|
48
|
+
"apiKey": "mapigate-local"
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}`},Re={id:"copilot",name:"GitHub Copilot",image:"/assets/providers/github/icon.png",color:"#1F6FEB",iconBg:"#FFFFFF",description:"GitHub Copilot in VS Code / CLI",configType:"guide",binary:"copilot",docsUrl:"https://marketplace.visualstudio.com/items?itemName=GitHub.copilot",defaultModels:["auto","claude-3.5-sonnet","claude-3.7-sonnet","claude-sonnet-4","claude-sonnet-4.6","claude-opus-4.8","gpt-4o","gpt-4o-mini","o1","o3-mini","gpt-5-mini","gpt-5.2-codex","gpt-5.3-codex","gemini-2.0-flash","gemini-2.5-pro","gemini-3.7-flash"],guideSteps:[{step:1,title:"Method A: Local MITM Proxy (Recommended)",desc:"Enable MITM Interceptor in Mapigate. Copilot traffic to api.githubcopilot.com will be intercepted and redirected automatically."},{step:2,title:"Method B: VS Code Copilot Extension Proxy",desc:"Install a Copilot proxy extension in VS Code and set the Gateway Server URL to:",value:N,copyable:!0},{step:3,title:"Select Model",desc:"In Copilot Chat, pick any model routed through Mapigate."}]},Ke={id:"cowork",name:"Claude Cowork",image:"/assets/providers/claude/icon.png",color:"#D97757",iconBg:"#FFFFFF",description:"Claude Desktop Cowork (third-party inference)",configType:"custom",configPath:"~/.claude/cowork.json",baseUrlPath:"",defaultModels:["claude-sonnet-5.5","claude-opus-5.5","claude-haiku-5.5","claude-fable-5.1","claude-sonnet-5","claude-opus-5","claude-fable-5","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-sonnet-4.6","claude-haiku-4.5","claude-3-opus","claude-3-7-sonnet","claude-3-5-sonnet","claude-3-5-haiku"],powershellTemplate:`$env:ANTHROPIC_BASE_URL = "${N}"`,bashTemplate:`export ANTHROPIC_BASE_URL="${N}"`},qe={id:"crush",name:"Crush",image:"/assets/tools/crush/icon.png",color:"#FB923C",iconBg:"#6b50ff",description:"Charm Crush terminal AI coding agent",configType:"custom",binary:"crush",configPath:"~/.config/crush/crush.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner"],configFileTemplate:`{
|
|
52
|
+
"providers": {
|
|
53
|
+
"mapigate": {
|
|
54
|
+
"type": "openai",
|
|
55
|
+
"base_url": "${o}",
|
|
56
|
+
"api_key": "mapigate-local"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}`},He={id:"cursor",name:"Cursor",image:"/assets/providers/cursor/icon.png",color:"#000000",iconBg:"#FFFFFF",description:"Cursor AI Code Editor",configType:"guide",binary:"cursor",docsUrl:"https://cursor.com",defaultModels:["claude-opus-5.5","claude-opus-5","claude-opus-4.8","claude-opus-4.7","claude-opus-4.6","claude-opus-4.5","claude-sonnet-5.5","claude-sonnet-5","claude-sonnet-4.6","claude-sonnet-4.5","claude-sonnet-4","claude-fable-5.2","claude-fable-5.1","claude-fable-5","claude-haiku-5.5","claude-haiku-4.5","gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna","gpt-5.5","gpt-5.4","gpt-5.4-mini","gpt-5.4-nano","gpt-5.3-codex","gemini-4-neon","gemini-4-carbon","gemini-4-hydrogen","gemini-4-argon","gemini-3.8-flash","gemini-3.1-pro","gemini-2.5-flash","grok-4.7","grok-4.6","grok-4.5","composer-2.5","cursor-small","muse-wonder","muse-spark-1.3","kimi-k3","glm-5.3","glm-5.3-flash","deepseek-v4.1-flash"],guideSteps:[{step:1,title:"Enable Security First",desc:"Before exposing port 20128 to the internet, enable Master Password in Settings and turn on Require API Key in Endpoint & Key."},{step:2,title:"Expose Local Gateway",desc:"Cursor routes requests through its cloud servers, so 127.0.0.1 is unreachable. Start an HTTPS tunnel (e.g. cloudflared or ngrok):",value:"cloudflared tunnel --url http://127.0.0.1:20128",copyable:!0},{step:3,title:"Open Cursor Settings",desc:"In Cursor, go to Settings → Models → API Keys"},{step:4,title:"Enable OpenAI API & Override Base URL",desc:"Toggle 'Use OpenAI API Key' and 'Override OpenAI Base URL' on, then enter your tunnel URL with /v1 (e.g. https://<your-tunnel>.trycloudflare.com/v1)"},{step:5,title:"Set API Key",desc:"Enter a Mapigate API Key created in Endpoint & Key (do not use a dummy key when exposed via tunnel)",type:"apiKeySelector"},{step:6,title:"Add Custom Model",desc:"Click '+ Add Custom Model' and enter a custom model ID or alias mapped in Tools & Mappings (avoid built-in Cursor model names if Cursor rejects them as invalid)"}],notes:[{type:"warning",text:"Security Warning: Exposing port 20128 via a public tunnel makes your gateway reachable from the internet. Always enable Master Password (Settings) and Require API Key (Endpoint & Key) before starting the tunnel, and stop the tunnel when not in use."},{type:"info",text:"Why a tunnel is required: Cursor sends requests from its cloud backend (api2.cursor.sh) to your Base URL, so local addresses like http://127.0.0.1:20128/v1 cannot be reached directly."}]},Ye={id:"deepseek-tui",name:"DeepSeek TUI",image:"/assets/tools/deepseek-tui/icon.png",color:"#4D6BFE",iconBg:"#FFFFFF",description:"DeepSeek Terminal Coding Agent (Rust TUI)",configType:"file",binary:"deepseek",configPath:"~/.deepseek/config.toml",baseUrlPath:"/v1",defaultModels:["deepseek-chat","deepseek-reasoner","deepseek-coder"],powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
60
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
61
|
+
deepseek`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
62
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
63
|
+
deepseek`,configFileTemplate:`[provider]
|
|
64
|
+
name = "openai"
|
|
65
|
+
base_url = "${o}"
|
|
66
|
+
api_key = "mapigate-local"
|
|
67
|
+
model = "claude-sonnet-4-6"`},Ge={id:"devin",name:"Devin CLI",image:"/assets/providers/devin/icon.png",color:"#6366F1",description:"Cognition Devin CLI",configType:"guide",binary:"devin",installUrl:"https://cli.devin.ai",defaultModels:["devin-code-v1","swe-2","swe-1.7","swe-1.6","swe-1.6-fast","swe-1.5","claude-sonnet-4-6","claude-opus-4-6","gpt-5.4","gpt-4o"],guideSteps:[{step:1,title:"Install Devin CLI",desc:"Install via official installer at cli.devin.ai"},{step:2,title:"Authenticate",desc:"Run devin auth login in terminal"},{step:3,title:"Ready",desc:"Devin CLI runs locally and connects with Mapigate"}]},We={id:"droid",name:"Factory Droid",image:"/assets/tools/droid/icon.png",color:"#00D4FF",iconBg:"#FFFFFF",description:"Factory Droid AI Assistant",configType:"custom",binary:"droid",configPath:"~/.factory/settings.json",baseUrlPath:"/v1",defaultModels:["claude-sonnet-4-6","claude-opus-4-7","claude-3-7-sonnet","claude-3-5-sonnet","gpt-5.4","gpt-5.3-codex","gpt-4o","deepseek-chat","deepseek-r1"],powershellTemplate:`$env:FACTORY_BASE_URL = "${o}"
|
|
68
|
+
$env:FACTORY_API_KEY = "mapigate-local"
|
|
69
|
+
droid`,bashTemplate:`export FACTORY_BASE_URL="${o}"
|
|
70
|
+
export FACTORY_API_KEY="mapigate-local"
|
|
71
|
+
droid`,configFileTemplate:`{
|
|
72
|
+
"baseUrl": "${o}",
|
|
73
|
+
"apiKey": "mapigate-local"
|
|
74
|
+
}`},Ve={id:"forge",name:"ForgeCode",image:"/assets/tools/forge/icon.png",color:"#EAB308",iconBg:"#FFFFFF",description:"Antinomy HQ ForgeCode agent harness",configType:"custom",binary:"forge",configPath:"~/.forge/config.toml",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","o3-mini","deepseek-chat","deepseek-reasoner"],configFileTemplate:`[openai]
|
|
75
|
+
base_url = "${o}"
|
|
76
|
+
api_key = "mapigate-local"`},De={id:"grok-build",name:"Grok Build",image:"/assets/tools/grok-build/icon.png",color:"#1DA1F2",iconBg:"#FFFFFF",description:"xAI Grok Build TUI coding agent",configType:"custom",binary:"grok",configPath:"~/.grok/config.toml",baseUrlPath:"/v1",defaultModels:["grok-build","grok-3","grok-3-mini","grok-2","grok-2-mini","grok-beta"],powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
77
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
78
|
+
grok`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
79
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
80
|
+
grok`,configFileTemplate:`[model.mapigate]
|
|
81
|
+
type = "openai"
|
|
82
|
+
base_url = "${o}"
|
|
83
|
+
api_key = "mapigate-local"`},Je={id:"hermes",name:"Hermes Agent",image:"/assets/tools/hermes/icon.png",color:"#8B5CF6",iconBg:"#FFFFFF",description:"Nous Research self-improving AI agent",configType:"custom",binary:"hermes",configPath:"~/.hermes/config.yaml",baseUrlPath:"/v1",defaultModels:["hermes-3","hermes-3-llama-3.1-405b","hermes-3-llama-3.1-70b","hermes-3-llama-3.1-8b","claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini"],roles:[{id:"delegation",label:"Delegation (subagents)"},{id:"vision",label:"Vision"},{id:"compression",label:"Compression"},{id:"title_generation",label:"Title Generation"},{id:"approval",label:"Approval"},{id:"skills_hub",label:"Skills Hub"},{id:"mcp",label:"MCP"},{id:"review",label:"Review (/review subagent)"},{id:"memory_query_rewrite",label:"Memory Query Rewrite"},{id:"background_review",label:"Background Review"},{id:"curator",label:"Curator"},{id:"monitor",label:"Monitor"},{id:"tts_audio_tags",label:"TTS Audio Tags"},{id:"triage_specifier",label:"Triage Specifier"},{id:"kanban_decomposer",label:"Kanban Decomposer"},{id:"profile_describer",label:"Profile Describer"},{id:"goal_judge",label:"Goal Judge"}],powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
84
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
85
|
+
hermes`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
86
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
87
|
+
hermes`,configFileTemplate:`model_provider: openai
|
|
88
|
+
base_url: ${o}
|
|
89
|
+
api_key: mapigate-local`},Qe={id:"jcode",name:"Jcode",image:"/assets/tools/jcode/icon.png",color:"#FF6B35",iconBg:"#FFFFFF",description:"High-performance Rust-based coding agent harness",configType:"custom",binary:"jcode",configPath:"~/.jcode/config.toml",baseUrlPath:"/v1",defaultModels:["claude-sonnet-4-6","claude-opus-5","gpt-6.1-sol","gemini-3.1-pro","claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o"],powershellTemplate:`$env:OPENAI_BASE_URL = "${o}"
|
|
90
|
+
$env:OPENAI_API_KEY = "mapigate-local"
|
|
91
|
+
jcode`,bashTemplate:`export OPENAI_BASE_URL="${o}"
|
|
92
|
+
export OPENAI_API_KEY="mapigate-local"
|
|
93
|
+
jcode`,configFileTemplate:`[model_provider.openai]
|
|
94
|
+
base_url = "${o}"
|
|
95
|
+
api_key = "mapigate-local"`},ze={id:"kilo",name:"Kilo Code",image:"/assets/providers/kilocode/icon.png",color:"#FF6B6B",iconBg:"#000000",description:"Kilo Code AI Assistant",configType:"custom",binary:"kilo",configPath:"~/.kilo/config.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","claude-sonnet-4-6","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner"],powershellTemplate:`$env:KILO_BASE_URL = "${o}"
|
|
96
|
+
kilo`,bashTemplate:`export KILO_BASE_URL="${o}"
|
|
97
|
+
kilo`,configFileTemplate:`{
|
|
98
|
+
"baseUrl": "${o}",
|
|
99
|
+
"apiKey": "mapigate-local"
|
|
100
|
+
}`},Ze={id:"omp",name:"Oh My Pi",image:"/assets/tools/omp/icon.png",color:"#EC4899",description:"Oh My Pi terminal AI agent with auto-discovery support",configType:"custom",binary:"omp",configPath:"~/.omp/agent/models.yml",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner","qwen-2.5-coder-32b"],configFileTemplate:`providers:
|
|
101
|
+
mapigate:
|
|
102
|
+
type: openai
|
|
103
|
+
base_url: ${o}
|
|
104
|
+
api_key: mapigate-local`},Xe={id:"openclaw",name:"Open Claw",image:"/assets/tools/openclaw/icon.png",color:"#FF6B35",iconBg:"#FFFFFF",description:"Open Claw AI Assistant",configType:"custom",binary:"openclaw",configPath:"~/.openclaw/config.json",baseUrlPath:"/v1",envVars:{baseUrl:"OPENCLAW_BASE_URL",apiKey:"OPENCLAW_API_KEY"},defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner"],powershellTemplate:`$env:OPENCLAW_BASE_URL = "${o}"
|
|
105
|
+
$env:OPENCLAW_API_KEY = "mapigate-local"
|
|
106
|
+
openclaw`,bashTemplate:`export OPENCLAW_BASE_URL="${o}"
|
|
107
|
+
export OPENCLAW_API_KEY="mapigate-local"
|
|
108
|
+
openclaw`,configFileTemplate:`{
|
|
109
|
+
"baseUrl": "${o}",
|
|
110
|
+
"apiKey": "mapigate-local"
|
|
111
|
+
}`},et={id:"opencode",name:"OpenCode",image:"/assets/providers/opencode/icon.png",color:"#E87040",description:"OpenCode AI Terminal Assistant",configType:"custom",binary:"opencode",configPath:"~/.config/opencode/opencode.json",baseUrlPath:"/v1",envVars:{baseUrl:"OPENCODE_BASE_URL",apiKey:"OPENCODE_API_KEY"},defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner","union-alpha"],powershellTemplate:`$env:OPENCODE_BASE_URL = "${o}"
|
|
112
|
+
$env:OPENCODE_API_KEY = "mapigate-local"
|
|
113
|
+
opencode`,bashTemplate:`export OPENCODE_BASE_URL="${o}"
|
|
114
|
+
export OPENCODE_API_KEY="mapigate-local"
|
|
115
|
+
opencode`,configFileTemplate:`{
|
|
116
|
+
"provider": {
|
|
117
|
+
"mapigate": {
|
|
118
|
+
"options": {
|
|
119
|
+
"baseURL": "${o}",
|
|
120
|
+
"apiKey": "mapigate-local"
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}`},tt={id:"opendesign",name:"OpenDesign",image:"/assets/tools/opendesign/icon.png",color:"#7C3AED",description:"Agent-native design skills pack",configType:"guide",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","claude-sonnet-4-6","gpt-4o","gpt-4o-mini","gemini-2.5-pro","gemini-2.5-flash"],guideSteps:[{step:1,title:"Install Plugin",desc:"Install into Claude Code, Cursor, or Codex CLI"},{step:2,title:"Automatic Routing",desc:"Inherits host agent model configuration pointing to Mapigate"},{step:3,title:"Run",desc:"Invoke with /opendesign <prompt>"}]},st={id:"pi",name:"Pi (pi-coding-agent)",image:"/assets/tools/pi/icon.svg",color:"#6366F1",description:"Pi coding agent — minimal, extensible agent harness",configType:"custom",binary:"pi",configPath:"~/.pi/agent/models.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner","qwen-2.5-coder-32b"],configFileTemplate:`{
|
|
125
|
+
"providers": {
|
|
126
|
+
"mapigate": {
|
|
127
|
+
"type": "openai",
|
|
128
|
+
"baseUrl": "${o}",
|
|
129
|
+
"apiKey": "mapigate-local"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}`},at={id:"qwen",name:"Qwen Code",image:"/assets/providers/qwen/icon.png",color:"#10B981",description:"Alibaba Qwen Code CLI",configType:"file",binary:"qwen",configPath:"~/.qwen/settings.json",baseUrlPath:"/v1",defaultModels:["qwen-max","qwen-plus","qwen-turbo","qwen-2.5-coder-32b","qwen-coder-plus","qwen2.5-coder-32b-instruct","claude-sonnet-4-6"],guideSteps:[{step:1,title:"Install Qwen Code",desc:"npm install -g @qwen-code/qwen-code"},{step:2,title:"Save Config",desc:"Copy the JSON below into ~/.qwen/settings.json"}],codeBlock:{language:"json",code:`{
|
|
133
|
+
"security": {
|
|
134
|
+
"auth": {
|
|
135
|
+
"selectedType": "openai",
|
|
136
|
+
"apiKey": "mapigate-local",
|
|
137
|
+
"baseUrl": "${o}"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"model": {
|
|
141
|
+
"name": "claude-sonnet-4-6"
|
|
142
|
+
}
|
|
143
|
+
}`},configFileTemplate:`{
|
|
144
|
+
"security": {
|
|
145
|
+
"auth": {
|
|
146
|
+
"selectedType": "openai",
|
|
147
|
+
"apiKey": "mapigate-local",
|
|
148
|
+
"baseUrl": "${o}"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"model": {
|
|
152
|
+
"name": "claude-sonnet-4-6"
|
|
153
|
+
}
|
|
154
|
+
}`},ot={id:"roo",name:"Roo Code",image:"/assets/tools/roo/icon.png",color:"#FF6B6B",iconBg:"#000000",description:"Roo AI Assistant",configType:"file",configPath:"~/.roo/config.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","claude-sonnet-4-5","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-reasoner","qwen-2.5-coder-32b"],guideSteps:[{step:1,title:"Open Roo Settings",desc:"Open the Roo Settings panel in VS Code"},{step:2,title:"Select Provider",desc:"Choose API Provider → OpenAI Compatible"},{step:3,title:"Base URL",value:o,copyable:!0},{step:4,title:"API Key",value:"mapigate-local",copyable:!0}],configFileTemplate:`{
|
|
155
|
+
"apiProvider": "openai-compatible",
|
|
156
|
+
"baseUrl": "${o}",
|
|
157
|
+
"apiKey": "mapigate-local"
|
|
158
|
+
}`},lt={id:"smelt",name:"Smelt",image:"/assets/tools/smelt/icon.svg",color:"#EF4444",description:"Smelt terminal AI coding assistant",configType:"custom",binary:"smelt",configPath:"~/.smelt/config.json",baseUrlPath:"/v1",defaultModels:["claude-3-7-sonnet","claude-3-5-sonnet","gpt-4o","gpt-4o-mini","deepseek-chat","deepseek-coder","qwen-2.5-coder-32b"],configFileTemplate:`{
|
|
159
|
+
"provider": "openai",
|
|
160
|
+
"baseUrl": "${o}",
|
|
161
|
+
"apiKey": "mapigate-local"
|
|
162
|
+
}`},Q={amp:Me,claude:$e,cline:Oe,codewhale:Be,codex:Ue,continue:Le,copilot:Re,cowork:Ke,crush:qe,cursor:He,"deepseek-tui":Ye,devin:Ge,droid:We,forge:Ve,"grok-build":De,hermes:Je,jcode:Qe,kilo:ze,omp:Ze,openclaw:Xe,opencode:et,opendesign:tt,pi:st,qwen:at,roo:ot,smelt:lt};var pe={};function me(u){if(typeof process<"u"&&pe)return pe[u]}function ge(u,d){const p=me("PORT"),x=me("HOST"),L=p?Number(p):z,j=x||ue;return`http://${j==="0.0.0.0"?"localhost":j}:${L}`}function nt(u,d){return`${ge()}/v1`}ge();nt();const gt=()=>{var re;const u=ke(t=>t.info),d=(u==null?void 0:u.port)||z,p=(u==null?void 0:u.host)||ue,[x,L]=i.useState(!1),[j,Z]=i.useState([]),[k,R]=i.useState("mapigate-local"),[X,ee]=i.useState(!1),w=i.useMemo(()=>j.filter(t=>t.isActive&&!t.isSystem),[j]),m=i.useMemo(()=>k&&k!=="mapigate-local"?k:x&&w.length>0?w[0].key:"mapigate-local",[k,x,w]),f=t=>t?t.replace(/127\.0\.0\.1:2012[78]/g,`${p}:${d}`).replace(/localhost:2012[78]/g,`localhost:${d}`).replace(/:2012[78]\b/g,`:${d}`).replace(/mapigate-local/g,m):"",[C,K]=i.useState("catalog"),[r,_]=i.useState(null),[h,y]=i.useState("powershell"),[c,te]=i.useState(null),[xe,he]=i.useState({}),[q,T]=i.useState(!1),[I,g]=i.useState(null),[se,H]=i.useState(null),[Y,S]=i.useState([]),[be,ae]=i.useState(!1),[A,oe]=i.useState(""),[fe,F]=i.useState(null),[G,E]=i.useState(""),[M,W]=i.useState(""),[$,V]=i.useState(""),[O,D]=i.useState(!1),[ye,ve]=i.useState(new Set),B=()=>{fetch("/api/cli-tools/status").then(t=>t.json()).then(t=>{t&&typeof t=="object"&&he(t)}).catch(()=>{})},Ne=()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const a=Array.isArray(t)?t:t.combos||[];ve(new Set(a.map(n=>(n.name||"").toLowerCase())))}).catch(()=>{})},J=async()=>{ae(!0);try{const t=await fetch("/api/model-mappings/global-mappings");if(t.ok){const a=await t.json();Array.isArray(a)&&S(a)}}catch{}finally{ae(!1)}},Ae=async()=>{try{const[t,a]=await Promise.all([fetch("/api/settings/endpoint"),fetch("/api/settings/endpoint/keys")]);let n=!1;if(t.ok){const l=await t.json();n=!!(l!=null&&l.requireApiKey),L(n)}if(a.ok){const l=await a.json();if(Array.isArray(l)){Z(l);const v=l.find(b=>b.isActive&&!b.isSystem);n&&v&&R(b=>b==="mapigate-local"?v.key:b)}}}catch{}},je=async t=>{ee(!0);try{const a=await fetch("/api/settings/endpoint/keys",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t?`${t} Key`:"CLI Tool Key"})});if(a.ok){const n=await a.json();Z(l=>[n,...l]),R(n.key),g({type:"success",text:`Created Gateway API Key "${n.name}" and selected it.`})}}catch{}finally{ee(!1)}};i.useEffect(()=>{B(),Ne(),J(),Ae()},[]);const P=t=>{navigator.clipboard.writeText(t),te(t),setTimeout(()=>te(null),2e3)},le=t=>{const a=xe[t.id];return a?a.status:t.status},ne=t=>t==="Connected"?e.jsxs("span",{className:"rt-badge rt-badge--success",children:[e.jsx("span",{className:"size-1.5 rounded-full bg-emerald-400 animate-pulse"}),"Connected"]}):t==="Guide"?e.jsx("span",{className:"rt-badge rt-badge--info",children:"Setup Guide"}):t==="Not configured"?e.jsx("span",{className:"rt-badge rt-badge--warning",children:"Not configured"}):e.jsx("span",{className:"rt-badge rt-badge--muted",children:"Not installed"}),s=r?Q[r.id]:void 0,we=async(t,a)=>{var n;try{const l=await fetch(`/api/model-mappings/global-mappings/import/${t}`,{method:"POST"});if(l.ok){const v=await l.json();Array.isArray(v.mappings)&&S(v.mappings);const b=a||((n=Q[t])==null?void 0:n.name)||t;H(`Imported model aliases from ${b} into Model Mappings!`),setTimeout(()=>H(null),4e3)}}catch(l){console.error("Failed to import tool aliases:",l)}},U=async(t,a)=>{if(!t.trim()||!a.trim())return;const n=t.trim(),l=a.trim();S(v=>[...v.filter(Pe=>Pe.sourceModel.toLowerCase()!==n.toLowerCase()),{toolId:"global",sourceModel:n,targetModel:l}]);try{await fetch("/api/model-mappings/global-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceModel:n,targetModel:l})})}catch{}finally{F(null),E(""),W(""),V(""),D(!1)}},Ce=async t=>{S(a=>a.filter(n=>n.sourceModel!==t));try{await fetch(`/api/model-mappings/global-mappings?sourceModel=${encodeURIComponent(t)}`,{method:"DELETE"})}catch{}},_e=async t=>{T(!0),g(null);try{const a=await fetch(`/api/cli-tools/${t}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:m})}),n=await a.json();a.ok?(g({type:"success",text:"Configuration applied successfully!"}),B()):g({type:"error",text:n.error||"Failed to apply config"})}catch(a){g({type:"error",text:a.message||"Network error"})}finally{T(!1)}},Ee=async t=>{T(!0),g(null);try{const a=await fetch(`/api/cli-tools/${t}/reset`,{method:"POST"}),n=await a.json();a.ok?(g({type:"success",text:"Configuration reset successfully."}),B()):g({type:"error",text:n.error||"Failed to reset config"})}catch(a){g({type:"error",text:a.message||"Network error"})}finally{T(!1)}},ie=i.useMemo(()=>{const t=A.trim().toLowerCase();return t?Y.filter(a=>a.sourceModel.toLowerCase().includes(t)||a.targetModel.toLowerCase().includes(t)):Y},[Y,A]);return e.jsxs("div",{className:"space-y-6 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[se&&e.jsxs("div",{className:"p-3 rounded-xl bg-blue-500/10 border border-blue-500/30 text-blue-300 text-xs flex items-center justify-between gap-3 shadow-lg animate-rt-scale-in",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] text-blue-400",children:"check_circle"}),e.jsx("span",{children:se})]}),e.jsx("button",{onClick:()=>H(null),className:"text-slate-400 hover:text-white p-1",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 bg-[#0B0F19] border border-[#1E293B] rounded-2xl p-2 sm:p-2.5 shadow-sm",children:[e.jsxs("div",{className:"bg-[#151C2C] p-1 rounded-xl border border-[#243048] flex items-center shrink-0",children:[e.jsxs("button",{onClick:()=>K("catalog"),className:`px-3.5 py-1.5 rounded-lg text-xs font-bold flex items-center gap-2 transition-all cursor-pointer ${C==="catalog"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),"Tool Catalog"]}),e.jsxs("button",{onClick:()=>{K("mappings"),J()},className:`px-3.5 py-1.5 rounded-lg text-xs font-bold flex items-center gap-2 transition-all cursor-pointer ${C==="mappings"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:[e.jsx(Fe,{className:"w-3.5 h-3.5"}),"Model Mappings"]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:C==="catalog"?e.jsxs("button",{onClick:B,className:"rt-btn rt-btn--secondary text-xs flex items-center gap-1.5 py-1.5 px-3 cursor-pointer",title:"Refresh installation status",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"}),"Refresh Status"]}):e.jsxs("button",{onClick:J,className:"rt-btn rt-btn--secondary text-xs flex items-center gap-1.5 py-1.5 px-3 cursor-pointer",title:"Refresh mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"refresh"}),"Refresh Mappings"]})})]}),C==="catalog"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-between text-xs text-slate-400 px-1",children:e.jsx("p",{children:"Click any tool card below to inspect connection instructions and sync its model aliases into Model Mappings."})}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(250px,1fr))] gap-3",children:Ie.map((t,a)=>{const n=le(t),l=Q[t.id];return e.jsxs("div",{onClick:()=>{_(t),g(null),l!=null&&l.guideSteps&&l.guideSteps.length>0&&!l.powershellTemplate?y("guide"):l!=null&&l.configFileTemplate&&!l.powershellTemplate?y("file"):y("powershell")},className:"rt-card stagger-item flex items-center justify-between gap-3 cursor-pointer py-3.5 px-4 hover:border-blue-500/40 hover:bg-[#131B2E] transition-all min-w-[250px] group",style:{animationDelay:`${a*15}ms`},children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(ce,{src:t.image,name:t.name,color:l==null?void 0:l.color,iconBg:(l==null?void 0:l.iconBg)||t.iconBg,size:"md"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h4",{className:"text-xs font-bold text-slate-100 truncate group-hover:text-blue-400 transition-colors",children:t.name}),e.jsx("div",{className:"mt-1",children:ne(n)})]})]}),e.jsx("span",{className:"material-symbols-outlined text-[18px] text-slate-500 group-hover:text-blue-400 transition-colors shrink-0",children:"chevron_right"})]},t.id)})})]}),C==="mappings"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h4",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-blue-400 text-[20px]",children:"alt_route"}),"Universal Model Mappings"]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-0.5",children:["Client model names (e.g. ",e.jsx("code",{children:"sonnet"}),", ",e.jsx("code",{children:"claude-3-7-sonnet"}),") are automatically translated to target models or fallback combos for all tools."]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{onClick:()=>D(!O),className:"px-3.5 py-1.5 text-xs font-semibold rounded-xl bg-blue-600 hover:bg-blue-500 shadow-md shadow-blue-600/30 text-white flex items-center gap-1.5 transition-all cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:O?"close":"add_circle"}),O?"Cancel":"Add Mapping"]})})]}),O&&e.jsxs("div",{className:"p-4 rounded-2xl bg-[#0E1424] border border-blue-500/40 space-y-3.5 animate-rt-scale-in",children:[e.jsxs("div",{className:"text-xs font-bold text-blue-300 flex items-center gap-1.5",children:[e.jsx("span",{className:"material-symbols-outlined text-[17px]",children:"add_circle"}),"Add New Model Mapping"]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-400 block mb-1",children:"Client Model (Source Alias):"}),e.jsx("input",{type:"text",value:M,onChange:t=>W(t.target.value),placeholder:"e.g. sonnet, claude-3-7-sonnet, my-coding-alias",className:"bg-[#080B11] border border-[#1E293B] focus:border-blue-400 rounded-xl px-3 py-2 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-400 block mb-1",children:"Gateway Target (Model or Combo):"}),e.jsx(de,{value:$,onChange:V,placeholder:"e.g. claude/claude-sonnet-4-6 or combo/...",className:"bg-[#080B11] border border-[#1E293B] focus:border-blue-400 rounded-xl px-3 py-2 text-xs text-white font-mono w-full focus:outline-none",onEnter:()=>U(M,$)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:()=>{D(!1),W(""),V("")},className:"px-3.5 py-1.5 text-xs rounded-xl bg-slate-800 text-slate-400 hover:text-white cursor-pointer",children:"Cancel"}),e.jsx("button",{onClick:()=>U(M,$),disabled:!M.trim()||!$.trim(),className:"px-4 py-1.5 text-xs font-semibold rounded-xl bg-blue-600 hover:bg-blue-500 text-white disabled:opacity-50 cursor-pointer shadow-md shadow-blue-600/30",children:"Save Mapping"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-slate-500 text-[18px]",children:"search"}),e.jsx("input",{type:"text",value:A,onChange:t=>oe(t.target.value),placeholder:"Search model alias or destination...",className:"w-full bg-[#0F1420]/80 border border-[#1E293B] focus:border-blue-500 rounded-xl pl-9 pr-4 py-2 text-xs text-slate-200 focus:outline-none"})]}),A&&e.jsx("button",{onClick:()=>oe(""),className:"text-xs text-slate-400 hover:text-white",children:"Clear"})]}),e.jsx("div",{className:"rounded-2xl border border-[#1E293B] overflow-hidden bg-[#0F1420]/80",children:be?e.jsxs("div",{className:"py-12 text-center text-xs text-slate-400 flex items-center justify-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[18px] animate-spin text-blue-400",children:"progress_activity"}),"Loading model mappings..."]}):ie.length===0?e.jsxs("div",{className:"py-14 text-center text-xs text-slate-400 space-y-2",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl text-slate-600 block",children:"alt_route"}),e.jsx("p",{className:"font-semibold text-slate-300",children:A?`No mappings match "${A}"`:"No model mappings configured yet"}),e.jsxs("p",{className:"text-slate-500 max-w-md mx-auto text-[11.5px] leading-relaxed",children:["Click ",e.jsx("strong",{className:"text-slate-300",children:"“Sync Aliases”"})," on any tool card in the Tool Catalog to add its models (with target left empty for you to select), or click ",e.jsx("strong",{className:"text-blue-400",children:"“+ Add Mapping”"})," above."]})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left border-collapse text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#1E293B] bg-[#0A0D14] text-slate-400 font-semibold",children:[e.jsx("th",{className:"p-3 pl-4",children:"Source Model (Client Sends)"}),e.jsx("th",{className:"p-3",children:"Target Destination (Model or Combo)"}),e.jsx("th",{className:"p-3 pr-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:ie.map(t=>{const a=fe===t.sourceModel,n=!!(t.targetModel&&(t.targetModel.startsWith("combo/")||ye.has(t.targetModel.toLowerCase())));return e.jsxs("tr",{className:`transition-colors ${a?"bg-blue-500/10":"hover:bg-white/5"}`,children:[e.jsx("td",{className:"p-3 pl-4 font-mono text-slate-200",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2.5 py-1 rounded-lg bg-slate-800/80 border border-slate-700/60 text-slate-100 font-medium",children:t.sourceModel}),e.jsx("button",{onClick:()=>P(t.sourceModel),className:"text-slate-500 hover:text-slate-300 p-0.5 cursor-pointer",title:"Copy source model",children:e.jsx("span",{className:"material-symbols-outlined text-[13px]",children:c===t.sourceModel?"done":"content_copy"})})]})}),e.jsx("td",{className:"p-3",children:a?e.jsxs("div",{className:"flex items-center gap-2 w-full max-w-md",children:[e.jsx("span",{className:"text-blue-400 font-mono",children:"→"}),e.jsx(de,{value:G,onChange:E,onEnter:()=>U(t.sourceModel,G),placeholder:"Search model or combo...",className:"bg-[#080B11] border border-blue-500/60 focus:border-blue-400 rounded-xl px-3 py-1.5 text-xs text-white font-mono w-full focus:outline-none",autoFocus:!0})]}):t.targetModel?e.jsxs("div",{className:"inline-flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-slate-500 font-mono",children:"→"}),n&&e.jsx("span",{className:"px-1.5 py-0.2 rounded bg-cyan-500/20 border border-cyan-500/40 text-[9.5px] font-mono text-cyan-300 font-semibold tracking-wide",children:"COMBO"}),e.jsx("span",{className:"text-emerald-300 font-mono font-medium text-xs",children:t.targetModel})]}):e.jsxs("button",{type:"button",onClick:()=>{F(t.sourceModel),E("")},className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg border border-dashed border-amber-500/40 bg-amber-500/10 text-amber-300 hover:border-amber-400 hover:text-amber-200 text-xs font-medium transition-colors cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),"Click to select target model or combo"]})}),e.jsx("td",{className:"p-3 pr-4 text-right space-x-2 whitespace-nowrap",children:a?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>U(t.sourceModel,G),className:"px-2.5 py-1 rounded-lg bg-blue-600 hover:bg-blue-500 text-white font-sans text-xs font-semibold transition-colors cursor-pointer",children:"Save"}),e.jsx("button",{onClick:()=>{F(null),E("")},className:"px-2.5 py-1 rounded-lg bg-slate-800 hover:bg-slate-700 text-slate-300 font-sans text-xs transition-colors cursor-pointer",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{F(t.sourceModel),E(t.targetModel||"")},className:"p-1 rounded-lg text-slate-400 hover:text-blue-400 hover:bg-blue-500/10 transition-colors cursor-pointer",title:"Edit target model",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"edit"})}),e.jsx("button",{onClick:()=>Ce(t.sourceModel),className:"p-1 rounded-lg text-slate-400 hover:text-red-400 hover:bg-red-500/10 transition-colors cursor-pointer",title:"Delete mapping",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"delete"})})]})})]},t.sourceModel)})})]})})})]}),e.jsx(Te,{isOpen:!!r,onClose:()=>_(null),maxWidthClass:"w-full max-w-4xl",children:r&&e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between pb-3.5 border-b border-[#1E293B]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ce,{src:r.image,name:r.name,color:s==null?void 0:s.color,iconBg:(s==null?void 0:s.iconBg)||r.iconBg,size:"lg"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base font-bold text-white",children:r.name}),ne(le(r))]}),e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:(s==null?void 0:s.description)||"Connect this tool directly to Mapigate Local Gateway."})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!!(s!=null&&s.defaultModels&&s.defaultModels.length>0||s!=null&&s.modelAliases&&s.modelAliases.length>0)&&e.jsxs("button",{onClick:()=>{we(r.id,r.name),_(null),K("mappings")},className:"px-3 py-1.5 text-xs font-semibold rounded-xl bg-blue-600/20 text-blue-300 border border-blue-500/30 hover:bg-blue-600/30 flex items-center gap-1.5 transition-all cursor-pointer",title:"Import this tool's model aliases into Model Mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"alt_route"}),"Sync Models to Mappings"]}),e.jsx("button",{onClick:()=>_(null),className:"text-slate-400 hover:text-white p-1 rounded-lg hover:bg-white/10 transition-colors cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]})]}),e.jsxs("div",{className:`p-3.5 rounded-xl border space-y-2.5 ${x&&m==="mapigate-local"?"bg-amber-500/10 border-amber-500/30":"bg-[#0A0D14] border-[#1E293B]"}`,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-amber-400",children:"vpn_key"}),e.jsx("span",{className:"text-xs font-semibold text-white",children:"Gateway API Key"}),x?e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-amber-500/20 text-amber-300 border border-amber-500/30",children:"Required"}):e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-slate-800 text-slate-400 border border-slate-700",children:"Optional"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 sm:flex-initial justify-end min-w-[240px]",children:[e.jsxs("select",{value:m,onChange:t=>R(t.target.value),className:"bg-[#0F1420] border border-[#243048] rounded-lg px-2.5 py-1.5 text-xs text-slate-200 font-mono focus:outline-none focus:border-blue-500 max-w-[280px] w-full",children:[!x&&e.jsx("option",{value:"mapigate-local",children:"mapigate-local (Placeholder)"}),x&&w.length===0&&e.jsx("option",{value:"mapigate-local",children:"No active key — create one →"}),w.map(t=>e.jsxs("option",{value:t.key,children:[t.name," (",t.key.slice(0,10),"…",t.key.slice(-4),")"]},t.id))]}),e.jsxs("button",{type:"button",disabled:X,onClick:()=>je(r.name),className:"px-2.5 py-1.5 rounded-lg bg-blue-600/20 hover:bg-blue-600/30 text-blue-300 border border-blue-500/30 text-xs font-semibold flex items-center gap-1 shrink-0 transition-colors cursor-pointer",title:"Create a new Gateway API Key and insert it into the commands below",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"add"}),X?"Creating...":"New Key"]})]})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-400",children:x?m==="mapigate-local"?e.jsxs("span",{className:"text-amber-300",children:[e.jsx("strong",{children:"Require API Key"})," is enabled in Endpoint settings."," ",e.jsx("code",{className:"font-mono",children:"mapigate-local"})," will be rejected with"," ",e.jsx("code",{className:"font-mono",children:"401 Unauthorized"})," — click ",e.jsx("strong",{children:"New Key"})," to generate a valid key."]}):e.jsxs("span",{children:[e.jsx("strong",{children:"Require API Key"})," is enabled. All commands and config templates below are populated with your selected Gateway API Key."]}):m==="mapigate-local"?e.jsxs("span",{children:[e.jsx("strong",{children:"Require API Key"})," is currently OFF, so ",e.jsx("code",{className:"font-mono text-slate-300",children:"mapigate-local"})," works as a placeholder. Select or create a real key if you want per-key usage tracking or plan to enable auth later."]}):e.jsx("span",{children:"Using your real Gateway API Key — requests from this tool will be authenticated and tracked under this key."})})]}),e.jsxs("div",{className:"flex border-b border-[#1E293B] gap-2 overflow-x-auto",children:[e.jsxs("button",{onClick:()=>y("powershell"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${h==="powershell"?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"terminal"}),"PowerShell (Windows)"]}),e.jsxs("button",{onClick:()=>y("bash"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${h==="bash"?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"code"}),"Bash / macOS / Linux"]}),((s==null?void 0:s.configFileTemplate)||(s==null?void 0:s.configPath)||(s==null?void 0:s.settingsFile))&&e.jsxs("button",{onClick:()=>y("file"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${h==="file"?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"description"}),"Config File"]}),(s==null?void 0:s.guideSteps)&&s.guideSteps.length>0&&e.jsxs("button",{onClick:()=>y("guide"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${h==="guide"?"border-blue-500 text-blue-400":"border-transparent text-slate-400 hover:text-slate-200"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"menu_book"}),"Setup Guide"]})]}),e.jsxs("div",{className:"space-y-4",children:[h==="powershell"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-slate-300 font-medium",children:"Run in Windows PowerShell:"}),e.jsxs("button",{onClick:()=>P(f(s==null?void 0:s.powershellTemplate)||`$env:OPENAI_BASE_URL = "http://${p}:${d}/v1"; $env:OPENAI_API_KEY = "${m}"`),className:"text-blue-400 hover:text-blue-300 flex items-center gap-1 font-semibold cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"content_copy"}),c!=null&&c.includes("$env:")?"Copied!":"Copy PowerShell"]})]}),e.jsx("pre",{className:"bg-[#0A0D14] border border-[#1E293B] p-4 rounded-xl text-emerald-400 font-mono text-xs overflow-x-auto whitespace-pre leading-relaxed",children:f(s==null?void 0:s.powershellTemplate)||`$env:OPENAI_BASE_URL = "http://${p}:${d}/v1"
|
|
163
|
+
$env:OPENAI_API_KEY = "${m}"`}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["💡 Sets environment variables in your current PowerShell session pointing to Mapigate port ",d,"."]})]}),h==="bash"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-slate-300 font-medium",children:"Run in Bash / Zsh / Git Bash:"}),e.jsxs("button",{onClick:()=>P(f(s==null?void 0:s.bashTemplate)||`export OPENAI_BASE_URL="http://${p}:${d}/v1"
|
|
164
|
+
export OPENAI_API_KEY="${m}"`),className:"text-blue-400 hover:text-blue-300 flex items-center gap-1 font-semibold cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"content_copy"}),c!=null&&c.includes("export ")?"Copied!":"Copy Bash"]})]}),e.jsx("pre",{className:"bg-[#0A0D14] border border-[#1E293B] p-4 rounded-xl text-emerald-400 font-mono text-xs overflow-x-auto whitespace-pre leading-relaxed",children:f(s==null?void 0:s.bashTemplate)||`export OPENAI_BASE_URL="http://${p}:${d}/v1"
|
|
165
|
+
export OPENAI_API_KEY="${m}"`}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"💡 Exports the environment variables for your current terminal session."})]}),h==="file"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("span",{className:"text-slate-300 font-medium",children:["Config Path:"," ",e.jsx("code",{className:"text-blue-400 font-mono bg-blue-500/10 px-1.5 py-0.5 rounded",children:(s==null?void 0:s.configPath)||(s==null?void 0:s.settingsFile)||"~/.config"})]}),e.jsxs("button",{onClick:()=>{var t;return P(f((s==null?void 0:s.configFileTemplate)||((t=s==null?void 0:s.codeBlock)==null?void 0:t.code))||`http://${p}:${d}/v1`)},className:"text-blue-400 hover:text-blue-300 flex items-center gap-1 font-semibold cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"content_copy"}),c!=null&&c.includes("{")||c!=null&&c.includes("[")?"Copied!":"Copy Config"]})]}),e.jsx("pre",{className:"bg-[#0A0D14] border border-[#1E293B] p-4 rounded-xl text-emerald-400 font-mono text-xs overflow-x-auto whitespace-pre leading-relaxed",children:f((s==null?void 0:s.configFileTemplate)||((re=s==null?void 0:s.codeBlock)==null?void 0:re.code))||`{
|
|
166
|
+
"baseUrl": "http://${p}:${d}/v1",
|
|
167
|
+
"apiKey": "${m}"
|
|
168
|
+
}`}),!!(s!=null&&s.configPath||s!=null&&s.settingsFile)&&e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs("button",{disabled:q,onClick:()=>_e(r.id),className:"rt-btn rt-btn--primary text-xs py-1.5 px-3 flex items-center gap-1.5 cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"save"}),q?"Applying...":"Apply to Config File"]}),e.jsxs("button",{disabled:q,onClick:()=>Ee(r.id),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-3 flex items-center gap-1.5 cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"undo"}),"Reset Config"]})]})]}),h==="guide"&&e.jsxs("div",{className:"space-y-3",children:[(s==null?void 0:s.guideSteps)&&e.jsx("div",{className:"space-y-2.5",children:s.guideSteps.map(t=>{const a=f(t.value);return e.jsxs("div",{className:"p-3.5 rounded-xl bg-[#0A0D14] border border-[#1E293B] flex items-start gap-3",children:[e.jsx("div",{className:"size-6 rounded-full bg-blue-500/20 text-blue-400 font-bold text-xs flex items-center justify-center shrink-0 border border-blue-500/30",children:t.step}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h5",{className:"text-xs font-bold text-white",children:t.title}),t.desc&&e.jsx("p",{className:"text-xs text-slate-400 mt-0.5 leading-relaxed",children:t.desc}),a&&e.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2 bg-[#0E1320] px-2.5 py-1.5 rounded-lg border border-[#1E293B]",children:[e.jsx("code",{className:"text-xs text-emerald-400 font-mono truncate",children:a}),t.copyable&&e.jsxs("button",{onClick:()=>P(a),className:"text-blue-400 hover:text-blue-300 text-xs flex items-center gap-1 font-semibold shrink-0 cursor-pointer",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"content_copy"}),c===a?"Copied!":"Copy"]})]})]})]},t.step)})}),(s==null?void 0:s.docsUrl)&&e.jsx("div",{className:"pt-1",children:e.jsxs("a",{href:s.docsUrl,target:"_blank",rel:"noreferrer",className:"text-xs text-blue-400 hover:underline flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"open_in_new"}),"Official Documentation & Plugin Details"]})})]}),I&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${I.type==="success"?"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400":"bg-red-500/10 border border-red-500/20 text-red-400"}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:I.type==="success"?"check_circle":"error"}),I.text]})]}),e.jsxs("div",{className:"flex items-center justify-between pt-3 border-t border-[#1E293B]",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("span",{className:"text-[11px] text-slate-500 font-mono",children:["Base URL: http://",p,":",d,(s==null?void 0:s.baseUrlPath)||""]})}),e.jsx("button",{onClick:()=>_(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-4 cursor-pointer",children:"Close"})]})]})})]})};export{gt as CliToolsTab};
|