mapigate 0.5.162 → 0.5.170

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 (120) hide show
  1. package/README.md +1 -1
  2. package/dist/cli/tools/definitions/amp/definition.js +1 -1
  3. package/dist/cli/tools/definitions/claude/configurator.js +1 -1
  4. package/dist/cli/tools/definitions/claude/definition.js +5 -2
  5. package/dist/cli/tools/definitions/cline/definition.js +1 -1
  6. package/dist/cli/tools/definitions/codewhale/definition.js +1 -1
  7. package/dist/cli/tools/definitions/codex/definition.js +1 -1
  8. package/dist/cli/tools/definitions/continue/definition.js +1 -1
  9. package/dist/cli/tools/definitions/copilot/definition.js +1 -1
  10. package/dist/cli/tools/definitions/cowork/definition.js +1 -1
  11. package/dist/cli/tools/definitions/crush/definition.js +1 -1
  12. package/dist/cli/tools/definitions/deepseek-tui/definition.js +1 -1
  13. package/dist/cli/tools/definitions/droid/definition.js +1 -1
  14. package/dist/cli/tools/definitions/forge/definition.js +1 -1
  15. package/dist/cli/tools/definitions/grok-build/definition.js +1 -1
  16. package/dist/cli/tools/definitions/hermes/definition.js +1 -1
  17. package/dist/cli/tools/definitions/jcode/definition.js +1 -1
  18. package/dist/cli/tools/definitions/kilo/definition.js +1 -1
  19. package/dist/cli/tools/definitions/omp/definition.js +1 -1
  20. package/dist/cli/tools/definitions/openclaw/definition.js +1 -1
  21. package/dist/cli/tools/definitions/opencode/definition.js +1 -1
  22. package/dist/cli/tools/definitions/pi/definition.js +1 -1
  23. package/dist/cli/tools/definitions/qwen/definition.js +1 -1
  24. package/dist/cli/tools/definitions/roo/definition.js +1 -1
  25. package/dist/cli/tools/definitions/smelt/definition.js +1 -1
  26. package/dist/core/adapters/anthropic/requestAnthropicToOpenAi.js +3 -3
  27. package/dist/core/adapters/anthropic/requestOpenAiToAnthropic.js +2 -2
  28. package/dist/core/adapters/anthropic/responseConverters.js +3 -3
  29. package/dist/core/adapters/anthropic/streamOpenAiToAnthropic.js +29 -29
  30. package/dist/core/adapters/anthropic/types.js +1 -1
  31. package/dist/core/adapters/anthropicAdapter.js +1 -1
  32. package/dist/core/adapters/helpers/index.js +1 -1
  33. package/dist/core/adapters/helpers/streamToolCallTracker.js +1 -0
  34. package/dist/core/adapters/helpers/toolCallRescue.js +1 -1
  35. package/dist/core/adapters/helpers/toolSchemaNormalize.js +1 -1
  36. package/dist/core/adapters/helpers/zeroContentCheck.js +1 -1
  37. package/dist/core/adapters/responsesAdapter.js +2 -2
  38. package/dist/core/caching/promptCacheAffinity.js +3 -3
  39. package/dist/core/capabilities/index.js +1 -1
  40. package/dist/core/capabilities/patterns.js +1 -1
  41. package/dist/mitm/handlers/base.js +2 -2
  42. package/dist/providers/catalog/cerebras/metadata.js +1 -1
  43. package/dist/providers/catalog/coarena/metadata.js +1 -1
  44. package/dist/providers/catalog/groq/metadata.js +1 -1
  45. package/dist/providers/catalog/iteracompute/metadata.js +1 -1
  46. package/dist/providers/catalog/jan/metadata.js +1 -1
  47. package/dist/providers/catalog/kilo-gateway/metadata.js +1 -1
  48. package/dist/providers/catalog/lm-studio/metadata.js +1 -1
  49. package/dist/providers/catalog/mistral/metadata.js +1 -1
  50. package/dist/providers/catalog/nvidia/metadata.js +1 -1
  51. package/dist/providers/catalog/ollama-local/metadata.js +1 -1
  52. package/dist/providers/catalog/onomeo/metadata.js +1 -1
  53. package/dist/providers/catalog/opencode-go/responses.js +5 -5
  54. package/dist/providers/catalog/opencode-zen/metadata.js +1 -1
  55. package/dist/providers/catalog/openrouter/metadata.js +1 -1
  56. package/dist/providers/catalog/sail/metadata.js +1 -1
  57. package/dist/providers/catalog/sambanova/metadata.js +1 -1
  58. package/dist/providers/runtime/antigravity/executor.js +8 -8
  59. package/dist/providers/runtime/antigravity/metadata.js +1 -1
  60. package/dist/providers/runtime/antigravity/provider.js +1 -1
  61. package/dist/providers/runtime/antigravity/quota.js +1 -1
  62. package/dist/providers/runtime/antigravity/routes.js +1 -1
  63. package/dist/providers/runtime/antigravity/types.js +1 -1
  64. package/dist/providers/runtime/antigravity/weekly.js +1 -1
  65. package/dist/providers/runtime/cloudflare/metadata.js +1 -1
  66. package/dist/providers/runtime/gemini/metadata.js +1 -1
  67. package/dist/providers/runtime/gemini/provider.js +1 -1
  68. package/dist/providers/runtime/gemini-cli/provider.js +1 -1
  69. package/dist/providers/runtime/gemini-cli/quota.js +1 -1
  70. package/dist/providers/runtime/gemini-cli/routes.js +1 -1
  71. package/dist/providers/runtime/kiro/constants.js +1 -0
  72. package/dist/providers/runtime/kiro/createResponseStream.js +4 -4
  73. package/dist/providers/runtime/kiro/executor.js +6 -6
  74. package/dist/providers/runtime/kiro/index.js +1 -1
  75. package/dist/providers/runtime/kiro/metadata.js +1 -1
  76. package/dist/providers/runtime/kiro/provider.js +1 -1
  77. package/dist/providers/runtime/kiro/quota.js +1 -1
  78. package/dist/providers/runtime/ollama/metadata.js +1 -1
  79. package/dist/providers/runtime/opencode/metadata.js +1 -1
  80. package/dist/server/index.js +3 -3
  81. package/dist/server/middlewares/doubledV1Middleware.js +1 -0
  82. package/dist/server/proxy/executorHelpers.js +1 -1
  83. package/dist/server/proxy/pipeline.js +5 -5
  84. package/dist/server/proxy/responseHandlers.js +1 -1
  85. package/dist/server/proxy/routeSimulator.js +1 -0
  86. package/dist/server/proxy/singleModelExecutor.js +5 -5
  87. package/dist/server/proxy/streaming/sseStreamer.js +18 -18
  88. package/dist/server/routes/apiCliTools.js +1 -1
  89. package/dist/server/routes/apiModels.js +1 -1
  90. package/dist/storage/repositories/settingsRepo.js +2 -2
  91. package/dist/storage/repositories/toolMappingRepo.js +5 -4
  92. package/dist/web/assets/CliToolsTab-AP4tHWEj.js +171 -0
  93. package/dist/web/assets/ComboDetailPage-8ZPxPl5N.js +1 -0
  94. package/dist/web/assets/CombosTab-D0T91znw.js +1 -0
  95. package/dist/web/assets/{ConfirmModal-Co5OXd_g.js → ConfirmModal-gmHKbGNe.js} +1 -1
  96. package/dist/web/assets/{ConsoleLogTab-BTGaJpcD.js → ConsoleLogTab-Bpvxqa2f.js} +1 -1
  97. package/dist/web/assets/{EditAccountModal-DLyP9VNQ.js → EditAccountModal-PEltZRS8.js} +1 -1
  98. package/dist/web/assets/{EndpointTab-DbjjVT7s.js → EndpointTab-CYnFpxjA.js} +1 -1
  99. package/dist/web/assets/MitmTab-De7zsN2f.js +14 -0
  100. package/dist/web/assets/ModelAutocompleteInput-BH4gr6Dr.js +1 -0
  101. package/dist/web/assets/ModelSelectModal-B7-jAYUU.js +1 -0
  102. package/dist/web/assets/{ProviderDetailPage-CeOUazix.js → ProviderDetailPage-DvqxjQHh.js} +1 -1
  103. package/dist/web/assets/{ProvidersTab-Dd-prffr.js → ProvidersTab-DyeFqcx4.js} +1 -1
  104. package/dist/web/assets/{QuotaTab-zPkj0Rwo.js → QuotaTab-DrNRwUP6.js} +1 -1
  105. package/dist/web/assets/{SettingsTab-DUlhyz1z.js → SettingsTab-DS6HQKrg.js} +1 -1
  106. package/dist/web/assets/{ToolIcon-Cp4gSgFt.js → ToolIcon-BZE0Fv7L.js} +1 -1
  107. package/dist/web/assets/{UsageTab-Da7c7zwV.js → UsageTab-Du6U3MIb.js} +1 -1
  108. package/dist/web/assets/index-9wZva5_f.css +1 -0
  109. package/dist/web/assets/index-BvY11iVv.js +2 -0
  110. package/dist/web/assets/metadataRegistry-4BIaQVmV.js +1 -0
  111. package/dist/web/assets/{providersData-HX0E7hDv.js → providersData-C-7jZmPi.js} +1 -1
  112. package/dist/web/index.html +2 -2
  113. package/package.json +1 -1
  114. package/dist/web/assets/CliToolsTab-iJozQAQx.js +0 -168
  115. package/dist/web/assets/CombosTab-DdsJ2ova.js +0 -1
  116. package/dist/web/assets/MitmTab-DMRg64by.js +0 -14
  117. package/dist/web/assets/ModelAutocompleteInput-D0L1aj3-.js +0 -1
  118. package/dist/web/assets/index-CtfMJ11V.js +0 -2
  119. package/dist/web/assets/index-DXsZmXJg.css +0 -1
  120. package/dist/web/assets/metadataRegistry-CGDAkFU1.js +0 -1
@@ -1,2 +1,2 @@
1
- var E=Object.defineProperty;var y=(a,e)=>E(a,"name",{value:e,configurable:!0});import{randomBytes as f}from"node:crypto";import{getDatabase as m}from"../database.js";import{CryptoVault as b}from"../crypto/vault.js";import{DEFAULT_ALLOWED_HOSTS as c}from"../../shared/utils/security.js";import{DEFAULT_HOST as S,DEFAULT_PORT as h}from"../../shared/constants/index.js";import{DEFAULT_TOKEN_SAVER_SETTINGS as d}from"../../core/tokenSaver/core/types.js";const R="oc/mimo-v2.6-flash-free",l={vision:{enabled:!1,roundRobin:!1,models:[]},audioInput:{enabled:!1,roundRobin:!1,models:[]},pdf:{enabled:!1,roundRobin:!1,models:[]},videoInput:{enabled:!1,roundRobin:!1,models:[]}},p={host:S,port:h,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:c},v={enabled:!1};function u(a,e){return a&&typeof a=="object"?{enabled:a.enabled!==void 0?!!a.enabled:e.enabled,roundRobin:!!a.roundRobin,models:Array.isArray(a.models)?a.models.map(t=>typeof t=="string"?t:t?.model||"").filter(Boolean):[...e.models]}:{...e}}y(u,"normalizeCapEntry");class M{static{y(this,"SettingsRepository")}static getSetting(e,t){const o=m().get("SELECT value FROM settings WHERE key = ?",e);if(!o)return t;try{return JSON.parse(o.value)}catch{return o.value}}static setSetting(e,t){const n=m();let o=t;if(e==="gatewayApiKeys"&&Array.isArray(t)){const s=/^[0-9a-f]{24}:[0-9a-f]{32}:[0-9a-f]+$/i;o=t.map(i=>{if(!i||typeof i!="object"||typeof i.key!="string"||!i.key)return i;const A=s.test(i.key);return{...i,key:A?i.key:b.encrypt(i.key)}})}const r=typeof o=="string"?o:JSON.stringify(o);n.run(`INSERT INTO settings (key, value) VALUES (?, ?)
2
- ON CONFLICT(key) DO UPDATE SET value = excluded.value`,e,r)}static getCapacityAdapterSettings(){const e=this.getSetting("capacityAdapter");return!e||typeof e!="object"?JSON.parse(JSON.stringify(l)):{vision:u(e.vision,l.vision),audioInput:u(e.audioInput,l.audioInput),pdf:u(e.pdf,l.pdf),videoInput:u(e.videoInput,l.videoInput)}}static setCapacityAdapterSettings(e){const t=this.getCapacityAdapterSettings(),n={...t};return e.vision&&(n.vision={enabled:e.vision.enabled!==void 0?e.vision.enabled:t.vision.enabled,roundRobin:e.vision.roundRobin!==void 0?e.vision.roundRobin:t.vision.roundRobin,models:Array.isArray(e.vision.models)?e.vision.models.map(o=>typeof o=="string"?o:o?.model||"").filter(Boolean):t.vision.models}),e.audioInput&&(n.audioInput={enabled:e.audioInput.enabled!==void 0?e.audioInput.enabled:t.audioInput.enabled,roundRobin:e.audioInput.roundRobin!==void 0?e.audioInput.roundRobin:t.audioInput.roundRobin,models:Array.isArray(e.audioInput.models)?e.audioInput.models.map(o=>typeof o=="string"?o:o?.model||"").filter(Boolean):t.audioInput.models}),e.pdf&&(n.pdf={enabled:e.pdf.enabled!==void 0?e.pdf.enabled:t.pdf?.enabled??!1,roundRobin:e.pdf.roundRobin!==void 0?e.pdf.roundRobin:t.pdf?.roundRobin??!1,models:Array.isArray(e.pdf.models)?e.pdf.models.map(o=>typeof o=="string"?o:o?.model||"").filter(Boolean):t.pdf?.models??[]}),e.videoInput&&(n.videoInput={enabled:e.videoInput.enabled!==void 0?e.videoInput.enabled:t.videoInput?.enabled??!1,roundRobin:e.videoInput.roundRobin!==void 0?e.videoInput.roundRobin:t.videoInput?.roundRobin??!1,models:Array.isArray(e.videoInput.models)?e.videoInput.models.map(o=>typeof o=="string"?o:o?.model||"").filter(Boolean):t.videoInput?.models??[]}),this.setSetting("capacityAdapter",n),n}static getEndpointSettings(){const e=this.getSetting("endpointSettings");return!e||typeof e!="object"?{...p}:{host:typeof e.host=="string"&&e.host.trim()?e.host.trim():p.host,port:typeof e.port=="number"&&e.port>0?e.port:p.port,requireApiKey:!!e.requireApiKey,proxyUrl:typeof e.proxyUrl=="string"?e.proxyUrl:p.proxyUrl,customHeaders:e.customHeaders&&typeof e.customHeaders=="object"?e.customHeaders:{},allowedHosts:typeof e.allowedHosts=="string"&&e.allowedHosts.trim()?e.allowedHosts.trim():c}}static setEndpointSettings(e){const t=this.getEndpointSettings(),n={host:e.host!==void 0&&typeof e.host=="string"&&e.host.trim()?e.host.trim():t.host,port:e.port!==void 0&&typeof e.port=="number"&&e.port>0?e.port:t.port,requireApiKey:e.requireApiKey!==void 0?!!e.requireApiKey:t.requireApiKey,proxyUrl:e.proxyUrl!==void 0?String(e.proxyUrl):t.proxyUrl,customHeaders:e.customHeaders!==void 0&&typeof e.customHeaders=="object"?e.customHeaders:t.customHeaders,allowedHosts:e.allowedHosts!==void 0&&typeof e.allowedHosts=="string"&&e.allowedHosts.trim()?e.allowedHosts.trim():t.allowedHosts||c};return this.setSetting("endpointSettings",n),n}static MITM_KEY_ID="key_mitm_default";static MITM_KEY_NAME="MITM Interceptor";static getGatewayApiKeys(){const e=this.getSetting("gatewayApiKeys");if(!Array.isArray(e))return[];const t=/^[0-9a-f]{24}:[0-9a-f]{32}:[0-9a-f]+$/i;return e.map(n=>{const o=String(n.key||""),r=t.test(o)&&b.decrypt(o)||o;return{id:String(n.id),key:r,name:String(n.name||"Default Key"),isActive:n.isActive!==!1,createdAt:Number(n.createdAt)||Date.now(),lastUsedAt:n.lastUsedAt?Number(n.lastUsedAt):void 0,isSystem:!!(n.isSystem||n.id===this.MITM_KEY_ID)}})}static getOrCreateMitmApiKey(){const e=this.getGatewayApiKeys(),t=e.find(o=>o.id===this.MITM_KEY_ID||o.name===this.MITM_KEY_NAME);if(t){let o=!1;return t.isActive||(t.isActive=!0,o=!0),t.isSystem||(t.isSystem=!0,o=!0),o&&this.setSetting("gatewayApiKeys",e),t}const n={id:this.MITM_KEY_ID,key:"sk-rt-"+f(24).toString("hex"),name:this.MITM_KEY_NAME,isActive:!0,createdAt:Date.now(),isSystem:!0};return e.push(n),this.setSetting("gatewayApiKeys",e),n}static createGatewayApiKey(e){const t=this.getGatewayApiKeys(),n="key_"+f(8).toString("hex"),o="sk-rt-"+f(24).toString("hex"),r={id:n,key:o,name:e&&typeof e=="string"&&e.trim()?e.trim():`Key ${t.length+1}`,isActive:!0,createdAt:Date.now()};return t.unshift(r),this.setSetting("gatewayApiKeys",t),r}static deleteGatewayApiKey(e){const t=this.getGatewayApiKeys(),n=t.find(s=>s.id===e||s.key===e);if(n?.isSystem||n?.id===this.MITM_KEY_ID)return!1;const o=t.length,r=t.filter(s=>s.id!==e&&s.key!==e);return r.length!==o?(this.setSetting("gatewayApiKeys",r),!0):!1}static toggleGatewayApiKey(e){const t=this.getGatewayApiKeys(),n=t.findIndex(o=>o.id===e||o.key===e);if(n!==-1)return t[n].isSystem||t[n].id===this.MITM_KEY_ID||(t[n].isActive=!t[n].isActive,this.setSetting("gatewayApiKeys",t)),t[n]}static recordGatewayApiKeyUsage(e){const t=this.getGatewayApiKeys(),n=t.findIndex(o=>o.id===e||o.key===e);n!==-1&&(t[n].lastUsedAt=Date.now(),this.setSetting("gatewayApiKeys",t))}static getTokenSaverSettings(){const e=this.getSetting("tokenSaver");return!e||typeof e!="object"?{...d}:{rtkEnabled:e.rtkEnabled!==void 0?!!e.rtkEnabled:d.rtkEnabled,cavemanEnabled:e.cavemanEnabled!==void 0?!!e.cavemanEnabled:d.cavemanEnabled,cavemanLevel:typeof e.cavemanLevel=="string"&&e.cavemanLevel.trim()?e.cavemanLevel.trim():d.cavemanLevel,ponytailEnabled:e.ponytailEnabled!==void 0?!!e.ponytailEnabled:d.ponytailEnabled,ponytailLevel:typeof e.ponytailLevel=="string"&&e.ponytailLevel.trim()?e.ponytailLevel.trim():d.ponytailLevel,customPromptEnabled:e.customPromptEnabled!==void 0?!!e.customPromptEnabled:d.customPromptEnabled,customPrompt:typeof e.customPrompt=="string"?e.customPrompt:d.customPrompt}}static setTokenSaverSettings(e){const t=this.getTokenSaverSettings(),n={...t,rtkEnabled:e.rtkEnabled!==void 0?!!e.rtkEnabled:t.rtkEnabled,cavemanEnabled:e.cavemanEnabled!==void 0?!!e.cavemanEnabled:t.cavemanEnabled,cavemanLevel:e.cavemanLevel!==void 0&&typeof e.cavemanLevel=="string"&&e.cavemanLevel.trim()?e.cavemanLevel.trim():t.cavemanLevel,ponytailEnabled:e.ponytailEnabled!==void 0?!!e.ponytailEnabled:t.ponytailEnabled,ponytailLevel:e.ponytailLevel!==void 0&&typeof e.ponytailLevel=="string"&&e.ponytailLevel.trim()?e.ponytailLevel.trim():t.ponytailLevel,customPromptEnabled:e.customPromptEnabled!==void 0?!!e.customPromptEnabled:t.customPromptEnabled,customPrompt:e.customPrompt!==void 0&&typeof e.customPrompt=="string"?e.customPrompt:t.customPrompt};return this.setSetting("tokenSaver",n),n}static getMasterPasswordConfig(){const e=this.getSetting("masterPassword");return!e||typeof e!="object"||!e.enabled?{...v}:{enabled:!!e.enabled,hash:typeof e.hash=="string"?e.hash:void 0,salt:typeof e.salt=="string"?e.salt:void 0,algorithm:typeof e.algorithm=="string"?e.algorithm:"scrypt",updatedAt:typeof e.updatedAt=="number"?e.updatedAt:void 0,logoutAt:typeof e.logoutAt=="number"?e.logoutAt:void 0}}static setMasterPasswordConfig(e){const t={enabled:!!e.enabled,hash:e.hash,salt:e.salt,algorithm:e.algorithm||"scrypt",updatedAt:e.updatedAt||Date.now(),logoutAt:typeof e.logoutAt=="number"?e.logoutAt:void 0};return this.setSetting("masterPassword",t),t}static clearMasterPassword(){this.setSetting("masterPassword",{...v})}static getLogLevel(){const e=this.getSetting("logLevel");return typeof e=="string"&&e.trim()?e.trim().toLowerCase():"info"}static setLogLevel(e){const t=e&&typeof e=="string"?e.trim().toLowerCase():"info";return this.setSetting("logLevel",t),t}static getObservabilityMode(){const e=process.env.MAPIGATE_OBSERVABILITY_MODE;if(e==="off"||e==="errors_only"||e==="all")return e;const t=this.getSetting("observabilityMode");return t==="off"||t==="errors_only"||t==="all"?t:"all"}static setObservabilityMode(e){const t=e==="off"||e==="errors_only"?e:"all";return this.setSetting("observabilityMode",t),t}static getLogRetentionDays(){const e=Number(process.env.MAPIGATE_LOG_RETENTION_DAYS);if(!isNaN(e)&&e>=0)return e;const t=this.getSetting("logRetentionDays");return typeof t=="number"&&t>=0?t:10}static setLogRetentionDays(e){const t=typeof e=="number"&&e>=0?Math.floor(e):10;return this.setSetting("logRetentionDays",t),t}}export{l as DEFAULT_CAPACITY_ADAPTER_SETTINGS,p as DEFAULT_ENDPOINT_SETTINGS,R as DEFAULT_FALLBACK_MODEL,v as DEFAULT_MASTER_PASSWORD_CONFIG,d as DEFAULT_TOKEN_SAVER_SETTINGS,M as SettingsRepository};
1
+ var E=Object.defineProperty;var y=(a,e)=>E(a,"name",{value:e,configurable:!0});import{randomBytes as f}from"node:crypto";import{getDatabase as m}from"../database.js";import{CryptoVault as b}from"../crypto/vault.js";import{DEFAULT_ALLOWED_HOSTS as c}from"../../shared/utils/security.js";import{DEFAULT_HOST as S,DEFAULT_PORT as h}from"../../shared/constants/index.js";import{DEFAULT_TOKEN_SAVER_SETTINGS as d}from"../../core/tokenSaver/core/types.js";const K="oc/mimo-v2.6-flash-free",l={vision:{enabled:!1,roundRobin:!1,models:[]},audioInput:{enabled:!1,roundRobin:!1,models:[]},pdf:{enabled:!1,roundRobin:!1,models:[]},videoInput:{enabled:!1,roundRobin:!1,models:[]}},p={host:S,port:h,requireApiKey:!1,proxyUrl:"",customHeaders:{},allowedHosts:c},v={enabled:!1};function u(a,e){return a&&typeof a=="object"?{enabled:a.enabled!==void 0?!!a.enabled:e.enabled,roundRobin:!!a.roundRobin,models:Array.isArray(a.models)?a.models.map(t=>typeof t=="string"?t:t?.model||"").filter(Boolean):[...e.models]}:{...e}}y(u,"normalizeCapEntry");class R{static{y(this,"SettingsRepository")}static getModelExposureMode(){return this.getSetting("modelExposureMode","all")||"all"}static setModelExposureMode(e){const o=["all","connected","mapped_only"].includes(e)?e:"all";this.setSetting("modelExposureMode",o)}static getSetting(e,t){const n=m().get("SELECT value FROM settings WHERE key = ?",e);if(!n)return t;try{return JSON.parse(n.value)}catch{return n.value}}static setSetting(e,t){const o=m();let n=t;if(e==="gatewayApiKeys"&&Array.isArray(t)){const s=/^[0-9a-f]{24}:[0-9a-f]{32}:[0-9a-f]+$/i;n=t.map(i=>{if(!i||typeof i!="object"||typeof i.key!="string"||!i.key)return i;const A=s.test(i.key);return{...i,key:A?i.key:b.encrypt(i.key)}})}const r=typeof n=="string"?n:JSON.stringify(n);o.run(`INSERT INTO settings (key, value) VALUES (?, ?)
2
+ ON CONFLICT(key) DO UPDATE SET value = excluded.value`,e,r)}static getCapacityAdapterSettings(){const e=this.getSetting("capacityAdapter");return!e||typeof e!="object"?JSON.parse(JSON.stringify(l)):{vision:u(e.vision,l.vision),audioInput:u(e.audioInput,l.audioInput),pdf:u(e.pdf,l.pdf),videoInput:u(e.videoInput,l.videoInput)}}static setCapacityAdapterSettings(e){const t=this.getCapacityAdapterSettings(),o={...t};return e.vision&&(o.vision={enabled:e.vision.enabled!==void 0?e.vision.enabled:t.vision.enabled,roundRobin:e.vision.roundRobin!==void 0?e.vision.roundRobin:t.vision.roundRobin,models:Array.isArray(e.vision.models)?e.vision.models.map(n=>typeof n=="string"?n:n?.model||"").filter(Boolean):t.vision.models}),e.audioInput&&(o.audioInput={enabled:e.audioInput.enabled!==void 0?e.audioInput.enabled:t.audioInput.enabled,roundRobin:e.audioInput.roundRobin!==void 0?e.audioInput.roundRobin:t.audioInput.roundRobin,models:Array.isArray(e.audioInput.models)?e.audioInput.models.map(n=>typeof n=="string"?n:n?.model||"").filter(Boolean):t.audioInput.models}),e.pdf&&(o.pdf={enabled:e.pdf.enabled!==void 0?e.pdf.enabled:t.pdf?.enabled??!1,roundRobin:e.pdf.roundRobin!==void 0?e.pdf.roundRobin:t.pdf?.roundRobin??!1,models:Array.isArray(e.pdf.models)?e.pdf.models.map(n=>typeof n=="string"?n:n?.model||"").filter(Boolean):t.pdf?.models??[]}),e.videoInput&&(o.videoInput={enabled:e.videoInput.enabled!==void 0?e.videoInput.enabled:t.videoInput?.enabled??!1,roundRobin:e.videoInput.roundRobin!==void 0?e.videoInput.roundRobin:t.videoInput?.roundRobin??!1,models:Array.isArray(e.videoInput.models)?e.videoInput.models.map(n=>typeof n=="string"?n:n?.model||"").filter(Boolean):t.videoInput?.models??[]}),this.setSetting("capacityAdapter",o),o}static getEndpointSettings(){const e=this.getSetting("endpointSettings");return!e||typeof e!="object"?{...p}:{host:typeof e.host=="string"&&e.host.trim()?e.host.trim():p.host,port:typeof e.port=="number"&&e.port>0?e.port:p.port,requireApiKey:!!e.requireApiKey,proxyUrl:typeof e.proxyUrl=="string"?e.proxyUrl:p.proxyUrl,customHeaders:e.customHeaders&&typeof e.customHeaders=="object"?e.customHeaders:{},allowedHosts:typeof e.allowedHosts=="string"&&e.allowedHosts.trim()?e.allowedHosts.trim():c}}static setEndpointSettings(e){const t=this.getEndpointSettings(),o={host:e.host!==void 0&&typeof e.host=="string"&&e.host.trim()?e.host.trim():t.host,port:e.port!==void 0&&typeof e.port=="number"&&e.port>0?e.port:t.port,requireApiKey:e.requireApiKey!==void 0?!!e.requireApiKey:t.requireApiKey,proxyUrl:e.proxyUrl!==void 0?String(e.proxyUrl):t.proxyUrl,customHeaders:e.customHeaders!==void 0&&typeof e.customHeaders=="object"?e.customHeaders:t.customHeaders,allowedHosts:e.allowedHosts!==void 0&&typeof e.allowedHosts=="string"&&e.allowedHosts.trim()?e.allowedHosts.trim():t.allowedHosts||c};return this.setSetting("endpointSettings",o),o}static MITM_KEY_ID="key_mitm_default";static MITM_KEY_NAME="MITM Interceptor";static getGatewayApiKeys(){const e=this.getSetting("gatewayApiKeys");if(!Array.isArray(e))return[];const t=/^[0-9a-f]{24}:[0-9a-f]{32}:[0-9a-f]+$/i;return e.map(o=>{const n=String(o.key||""),r=t.test(n)&&b.decrypt(n)||n;return{id:String(o.id),key:r,name:String(o.name||"Default Key"),isActive:o.isActive!==!1,createdAt:Number(o.createdAt)||Date.now(),lastUsedAt:o.lastUsedAt?Number(o.lastUsedAt):void 0,isSystem:!!(o.isSystem||o.id===this.MITM_KEY_ID)}})}static getOrCreateMitmApiKey(){const e=this.getGatewayApiKeys(),t=e.find(n=>n.id===this.MITM_KEY_ID||n.name===this.MITM_KEY_NAME);if(t){let n=!1;return t.isActive||(t.isActive=!0,n=!0),t.isSystem||(t.isSystem=!0,n=!0),n&&this.setSetting("gatewayApiKeys",e),t}const o={id:this.MITM_KEY_ID,key:"sk-rt-"+f(24).toString("hex"),name:this.MITM_KEY_NAME,isActive:!0,createdAt:Date.now(),isSystem:!0};return e.push(o),this.setSetting("gatewayApiKeys",e),o}static createGatewayApiKey(e){const t=this.getGatewayApiKeys(),o="key_"+f(8).toString("hex"),n="sk-rt-"+f(24).toString("hex"),r={id:o,key:n,name:e&&typeof e=="string"&&e.trim()?e.trim():`Key ${t.length+1}`,isActive:!0,createdAt:Date.now()};return t.unshift(r),this.setSetting("gatewayApiKeys",t),r}static deleteGatewayApiKey(e){const t=this.getGatewayApiKeys(),o=t.find(s=>s.id===e||s.key===e);if(o?.isSystem||o?.id===this.MITM_KEY_ID)return!1;const n=t.length,r=t.filter(s=>s.id!==e&&s.key!==e);return r.length!==n?(this.setSetting("gatewayApiKeys",r),!0):!1}static toggleGatewayApiKey(e){const t=this.getGatewayApiKeys(),o=t.findIndex(n=>n.id===e||n.key===e);if(o!==-1)return t[o].isSystem||t[o].id===this.MITM_KEY_ID||(t[o].isActive=!t[o].isActive,this.setSetting("gatewayApiKeys",t)),t[o]}static recordGatewayApiKeyUsage(e){const t=this.getGatewayApiKeys(),o=t.findIndex(n=>n.id===e||n.key===e);o!==-1&&(t[o].lastUsedAt=Date.now(),this.setSetting("gatewayApiKeys",t))}static getTokenSaverSettings(){const e=this.getSetting("tokenSaver");return!e||typeof e!="object"?{...d}:{rtkEnabled:e.rtkEnabled!==void 0?!!e.rtkEnabled:d.rtkEnabled,cavemanEnabled:e.cavemanEnabled!==void 0?!!e.cavemanEnabled:d.cavemanEnabled,cavemanLevel:typeof e.cavemanLevel=="string"&&e.cavemanLevel.trim()?e.cavemanLevel.trim():d.cavemanLevel,ponytailEnabled:e.ponytailEnabled!==void 0?!!e.ponytailEnabled:d.ponytailEnabled,ponytailLevel:typeof e.ponytailLevel=="string"&&e.ponytailLevel.trim()?e.ponytailLevel.trim():d.ponytailLevel,customPromptEnabled:e.customPromptEnabled!==void 0?!!e.customPromptEnabled:d.customPromptEnabled,customPrompt:typeof e.customPrompt=="string"?e.customPrompt:d.customPrompt}}static setTokenSaverSettings(e){const t=this.getTokenSaverSettings(),o={...t,rtkEnabled:e.rtkEnabled!==void 0?!!e.rtkEnabled:t.rtkEnabled,cavemanEnabled:e.cavemanEnabled!==void 0?!!e.cavemanEnabled:t.cavemanEnabled,cavemanLevel:e.cavemanLevel!==void 0&&typeof e.cavemanLevel=="string"&&e.cavemanLevel.trim()?e.cavemanLevel.trim():t.cavemanLevel,ponytailEnabled:e.ponytailEnabled!==void 0?!!e.ponytailEnabled:t.ponytailEnabled,ponytailLevel:e.ponytailLevel!==void 0&&typeof e.ponytailLevel=="string"&&e.ponytailLevel.trim()?e.ponytailLevel.trim():t.ponytailLevel,customPromptEnabled:e.customPromptEnabled!==void 0?!!e.customPromptEnabled:t.customPromptEnabled,customPrompt:e.customPrompt!==void 0&&typeof e.customPrompt=="string"?e.customPrompt:t.customPrompt};return this.setSetting("tokenSaver",o),o}static getMasterPasswordConfig(){const e=this.getSetting("masterPassword");return!e||typeof e!="object"||!e.enabled?{...v}:{enabled:!!e.enabled,hash:typeof e.hash=="string"?e.hash:void 0,salt:typeof e.salt=="string"?e.salt:void 0,algorithm:typeof e.algorithm=="string"?e.algorithm:"scrypt",updatedAt:typeof e.updatedAt=="number"?e.updatedAt:void 0,logoutAt:typeof e.logoutAt=="number"?e.logoutAt:void 0}}static setMasterPasswordConfig(e){const t={enabled:!!e.enabled,hash:e.hash,salt:e.salt,algorithm:e.algorithm||"scrypt",updatedAt:e.updatedAt||Date.now(),logoutAt:typeof e.logoutAt=="number"?e.logoutAt:void 0};return this.setSetting("masterPassword",t),t}static clearMasterPassword(){this.setSetting("masterPassword",{...v})}static getLogLevel(){const e=this.getSetting("logLevel");return typeof e=="string"&&e.trim()?e.trim().toLowerCase():"info"}static setLogLevel(e){const t=e&&typeof e=="string"?e.trim().toLowerCase():"info";return this.setSetting("logLevel",t),t}static getObservabilityMode(){const e=process.env.MAPIGATE_OBSERVABILITY_MODE;if(e==="off"||e==="errors_only"||e==="all")return e;const t=this.getSetting("observabilityMode");return t==="off"||t==="errors_only"||t==="all"?t:"all"}static setObservabilityMode(e){const t=e==="off"||e==="errors_only"?e:"all";return this.setSetting("observabilityMode",t),t}static getLogRetentionDays(){const e=Number(process.env.MAPIGATE_LOG_RETENTION_DAYS);if(!isNaN(e)&&e>=0)return e;const t=this.getSetting("logRetentionDays");return typeof t=="number"&&t>=0?t:10}static setLogRetentionDays(e){const t=typeof e=="number"&&e>=0?Math.floor(e):10;return this.setSetting("logRetentionDays",t),t}}export{l as DEFAULT_CAPACITY_ADAPTER_SETTINGS,p as DEFAULT_ENDPOINT_SETTINGS,K as DEFAULT_FALLBACK_MODEL,v as DEFAULT_MASTER_PASSWORD_CONFIG,d as DEFAULT_TOKEN_SAVER_SETTINGS,R as SettingsRepository};
@@ -1,6 +1,7 @@
1
- var E=Object.defineProperty;var u=(p,s)=>E(p,"name",{value:s,configurable:!0});import{getDatabase as d}from"../database.js";import{getDefaultMappings as _}from"../../mitm/toolsHelper.js";import{CLI_TOOLS as M}from"../../shared/constants/cliTools.js";import{ComboRepository as f}from"./comboRepo.js";import{normalizeModelCompareKey as g}from"../../shared/utils/modelUtils.js";class b{static{u(this,"ToolMappingRepository")}static sortMappingsCanonical(s){return[...s].sort((o,t)=>{const e=o.sourceModel.toLowerCase()==="auto"||o.sourceModel.toLowerCase()==="default",l=t.sourceModel.toLowerCase()==="auto"||t.sourceModel.toLowerCase()==="default";return e&&!l?-1:!e&&l?1:o.sourceModel.localeCompare(t.sourceModel,void 0,{numeric:!0,sensitivity:"base"})})}static getDefaultMappings(s){const o=(s||"").toLowerCase(),t=_(o);if(t&&t.length>0)return t.map(l=>({toolId:o,sourceModel:l.sourceModel,targetModel:l.targetModel||""}));const e=M[o];if(e){const l=[],i=new Set;if(e.modelAliases&&e.modelAliases.length>0)for(const n of e.modelAliases)n&&!i.has(n.toLowerCase())&&(i.add(n.toLowerCase()),l.push({toolId:o,sourceModel:n,targetModel:""}));if(e.defaultModels&&e.defaultModels.length>0)for(const n of e.defaultModels){const a=typeof n=="string"?n:n.alias||n.id;a&&!i.has(a.toLowerCase())&&(i.add(a.toLowerCase()),l.push({toolId:o,sourceModel:a,targetModel:""}))}if(l.length>0)return l}return[]}static getMappings(s){const o=(s||"").toLowerCase(),e=d().all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = ?",o);if(e.length===0){const i=this.getDefaultMappings(o);return i.length>0?(this.initDefaultMappings(o,i),this.sortMappingsCanonical(i)):[]}const l=e.map(i=>({toolId:i.tool_id,sourceModel:i.source_model,targetModel:i.target_model}));return this.sortMappingsCanonical(l)}static getAllMappings(){return d().all("SELECT tool_id, source_model, target_model FROM tool_mappings").map(t=>({toolId:t.tool_id,sourceModel:t.source_model,targetModel:t.target_model}))}static initDefaultMappings(s,o){const t=(s||"").toLowerCase(),e=d();for(const l of o)e.run("INSERT OR IGNORE INTO tool_mappings (tool_id, source_model, target_model) VALUES (?, ?, ?)",t,l.sourceModel,l.targetModel)}static normalizeTargetModel(s){const o=(s||"").trim();if(!o)return"";if(o.startsWith("combo/"))return o;try{if(f.getAllCombos().some(l=>l.isActive&&l.name.toLowerCase()===o.toLowerCase()))return`combo/${o}`}catch{}return o}static saveMapping(s,o,t){const e=(s||"").toLowerCase(),l=this.normalizeTargetModel(t),i=d();i.run(`INSERT INTO tool_mappings (tool_id, source_model, target_model)
1
+ var L=Object.defineProperty;var _=(f,l)=>L(f,"name",{value:l,configurable:!0});import{getDatabase as c}from"../database.js";import{getDefaultMappings as T}from"../../mitm/toolsHelper.js";import{CLI_TOOLS as C}from"../../shared/constants/cliTools.js";import{ComboRepository as h}from"./comboRepo.js";import{normalizeModelCompareKey as p}from"../../shared/utils/modelUtils.js";class S{static{_(this,"ToolMappingRepository")}static sortMappingsCanonical(l){return[...l].sort((o,e)=>{const t=o.sourceModel.toLowerCase()==="auto"||o.sourceModel.toLowerCase()==="default",s=e.sourceModel.toLowerCase()==="auto"||e.sourceModel.toLowerCase()==="default";return t&&!s?-1:!t&&s?1:o.sourceModel.localeCompare(e.sourceModel,void 0,{numeric:!0,sensitivity:"base"})})}static getDefaultMappings(l){const o=(l||"").toLowerCase(),e=T(o);if(e&&e.length>0)return e.map(s=>({toolId:o,sourceModel:s.sourceModel,targetModel:s.targetModel||""}));const t=C[o];if(t){const s=[],n=new Set;if(t.modelAliases&&t.modelAliases.length>0)for(const i of t.modelAliases)i&&!n.has(i.toLowerCase())&&(n.add(i.toLowerCase()),s.push({toolId:o,sourceModel:i,targetModel:""}));if(t.defaultModels&&t.defaultModels.length>0)for(const i of t.defaultModels){const r=typeof i=="string"?i:i.alias||i.id;r&&!n.has(r.toLowerCase())&&(n.add(r.toLowerCase()),s.push({toolId:o,sourceModel:r,targetModel:""}))}if(s.length>0)return s}return[]}static getMappings(l){const o=(l||"").toLowerCase(),t=c().all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = ?",o);if(t.length===0){const n=this.getDefaultMappings(o);return n.length>0?(this.initDefaultMappings(o,n),this.sortMappingsCanonical(n)):[]}const s=t.map(n=>({toolId:n.tool_id,sourceModel:n.source_model,targetModel:n.target_model}));return this.sortMappingsCanonical(s)}static getAllMappings(){return c().all("SELECT tool_id, source_model, target_model FROM tool_mappings").map(e=>({toolId:e.tool_id,sourceModel:e.source_model,targetModel:e.target_model}))}static initDefaultMappings(l,o){const e=(l||"").toLowerCase(),t=c();for(const s of o)t.run("INSERT OR IGNORE INTO tool_mappings (tool_id, source_model, target_model) VALUES (?, ?, ?)",e,s.sourceModel,s.targetModel)}static normalizeTargetModel(l){const o=(l||"").trim();if(!o)return"";if(o.startsWith("combo/"))return o;try{if(h.getAllCombos().some(s=>s.isActive&&s.name.toLowerCase()===o.toLowerCase()))return`combo/${o}`}catch{}return o}static saveMapping(l,o,e){const t=(l||"").toLowerCase(),s=this.normalizeTargetModel(e),n=c();n.run(`INSERT INTO tool_mappings (tool_id, source_model, target_model)
2
2
  VALUES (?, ?, ?)
3
- ON CONFLICT(tool_id, source_model) DO UPDATE SET target_model = excluded.target_model`,e,o,l);try{i.run(`INSERT INTO mitm_mappings (ide, source_model, target_model)
3
+ ON CONFLICT(tool_id, source_model) DO UPDATE SET target_model = excluded.target_model`,t,o,s);try{n.run(`INSERT INTO mitm_mappings (ide, source_model, target_model)
4
4
  VALUES (?, ?, ?)
5
- ON CONFLICT(ide, source_model) DO UPDATE SET target_model = excluded.target_model`,e,o,l)}catch{}}static deleteMapping(s,o){const t=(s||"").toLowerCase(),e=d();e.run("DELETE FROM tool_mappings WHERE tool_id = ? AND source_model = ?",t,o);try{e.run("DELETE FROM mitm_mappings WHERE ide = ? AND source_model = ?",t,o)}catch{}}static resetMappings(s){const o=(s||"").toLowerCase(),t=d(),e=t.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = ?",o),l=new Map;for(const a of e)a.target_model&&a.target_model.trim().length>0&&l.set(a.source_model,a.target_model.trim());const n=this.getDefaultMappings(o).map(a=>({toolId:o,sourceModel:a.sourceModel,targetModel:l.get(a.sourceModel)||a.targetModel||""}));t.exec("BEGIN TRANSACTION;");try{t.run("DELETE FROM tool_mappings WHERE tool_id = ?",o);try{t.run("DELETE FROM mitm_mappings WHERE ide = ?",o)}catch{}for(const a of n){t.run("INSERT INTO tool_mappings (tool_id, source_model, target_model) VALUES (?, ?, ?)",a.toolId,a.sourceModel,a.targetModel);try{t.run("INSERT INTO mitm_mappings (ide, source_model, target_model) VALUES (?, ?, ?)",a.toolId,a.sourceModel,a.targetModel)}catch{}}t.exec("COMMIT;")}catch(a){try{t.exec("ROLLBACK;")}catch{}throw a}return this.sortMappingsCanonical(n)}static getGlobalMappings(){const t=d().all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = 'global'").map(e=>({toolId:"global",sourceModel:e.source_model,targetModel:e.target_model||""}));return this.sortMappingsCanonical(t)}static saveGlobalMapping(s,o){this.saveMapping("global",s,o)}static deleteGlobalMapping(s){this.deleteMapping("global",s)}static importToolDefaultsToGlobal(s){const o=(s||"").toLowerCase(),t=d(),e=t.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = 'global'"),l=new Map;for(const r of e)l.set(r.source_model.toLowerCase(),r.target_model||"");const i=new Set,n=M[o];if(n){for(const r of n.defaultModels||[]){const c=typeof r=="string"?r:r.alias||r.id;c&&i.add(c)}for(const r of n.modelAliases||[])r&&i.add(r)}const a=_(o);for(const r of a)r.sourceModel&&i.add(r.sourceModel);for(const r of i){const c=r.toLowerCase();l.has(c)||t.run(`INSERT INTO tool_mappings (tool_id, source_model, target_model) VALUES ('global', ?, '')
6
- ON CONFLICT(tool_id, source_model) DO NOTHING`,r)}return this.getGlobalMappings()}static resetGlobalMappings(){return d().run("DELETE FROM tool_mappings WHERE tool_id = 'global'"),this.getGlobalMappings()}static resolveModelMapping(s,o){if(!o)return null;const t=(s||"").toLowerCase(),e=o.trim();if(!e)return null;const l=d(),i=g(e);if(t&&t!=="global"&&t!=="unknown"){const r=l.get("SELECT target_model FROM tool_mappings WHERE tool_id = ? AND LOWER(source_model) = LOWER(?) LIMIT 1",t,e);if(r&&r.target_model&&r.target_model.trim().length>0)return r.target_model.trim();const c=l.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = ?",t);for(const m of c)if(m.target_model&&m.target_model.trim().length>0&&g(m.source_model)===i)return m.target_model.trim()}const n=l.get("SELECT target_model FROM tool_mappings WHERE tool_id = 'global' AND LOWER(source_model) = LOWER(?) LIMIT 1",e);if(n)return n.target_model&&n.target_model.trim().length>0?n.target_model.trim():null;const a=l.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = 'global'");for(const r of a)if(g(r.source_model)===i)return r.target_model&&r.target_model.trim().length>0?r.target_model.trim():null;if(!t||t==="unknown"){const r=l.get("SELECT target_model FROM tool_mappings WHERE LOWER(source_model) = LOWER(?) LIMIT 1",e);if(r&&r.target_model&&r.target_model.trim().length>0)return r.target_model.trim();const c=l.all("SELECT source_model, target_model FROM tool_mappings");for(const m of c)if(m.target_model&&m.target_model.trim().length>0&&g(m.source_model)===i)return m.target_model.trim()}return null}}export{b as ToolMappingRepository};
5
+ ON CONFLICT(ide, source_model) DO UPDATE SET target_model = excluded.target_model`,t,o,s)}catch{}}static deleteMapping(l,o){const e=(l||"").toLowerCase(),t=c();t.run("DELETE FROM tool_mappings WHERE tool_id = ? AND source_model = ?",e,o);try{t.run("DELETE FROM mitm_mappings WHERE ide = ? AND source_model = ?",e,o)}catch{}}static resetMappings(l){const o=(l||"").toLowerCase(),e=c(),t=e.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = ?",o),s=new Map;for(const r of t)r.target_model&&r.target_model.trim().length>0&&s.set(r.source_model,r.target_model.trim());const i=this.getDefaultMappings(o).map(r=>({toolId:o,sourceModel:r.sourceModel,targetModel:s.get(r.sourceModel)||r.targetModel||""}));e.exec("BEGIN TRANSACTION;");try{e.run("DELETE FROM tool_mappings WHERE tool_id = ?",o);try{e.run("DELETE FROM mitm_mappings WHERE ide = ?",o)}catch{}for(const r of i){e.run("INSERT INTO tool_mappings (tool_id, source_model, target_model) VALUES (?, ?, ?)",r.toolId,r.sourceModel,r.targetModel);try{e.run("INSERT INTO mitm_mappings (ide, source_model, target_model) VALUES (?, ?, ?)",r.toolId,r.sourceModel,r.targetModel)}catch{}}e.exec("COMMIT;")}catch(r){try{e.exec("ROLLBACK;")}catch{}throw r}return this.sortMappingsCanonical(i)}static getGlobalMappings(){const e=c().all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = 'global'").map(t=>({toolId:"global",sourceModel:t.source_model,targetModel:t.target_model||""}));return this.sortMappingsCanonical(e)}static saveGlobalMapping(l,o){this.saveMapping("global",l,o)}static deleteGlobalMapping(l){this.deleteMapping("global",l)}static importToolDefaultsToGlobal(l){const o=(l||"").toLowerCase(),e=c(),t=e.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = 'global'"),s=new Map;for(const a of t)s.set(a.source_model.toLowerCase(),a.target_model||"");const n=new Set,i=C[o];if(i){for(const a of i.defaultModels||[]){const g=typeof a=="string"?a:a.alias||a.id;g&&n.add(g)}for(const a of i.modelAliases||[])a&&n.add(a)}const r=T(o);for(const a of r)a.sourceModel&&n.add(a.sourceModel);for(const a of n){const g=a.toLowerCase();s.has(g)||e.run(`INSERT INTO tool_mappings (tool_id, source_model, target_model) VALUES ('global', ?, '')
6
+ ON CONFLICT(tool_id, source_model) DO NOTHING`,a)}return this.getGlobalMappings()}static importCombosToGlobal(){const l=c(),o=h.getAllCombos(),e=l.all("SELECT source_model, target_model FROM tool_mappings WHERE tool_id = 'global'"),t=new Map;for(const s of e)t.set(s.source_model.toLowerCase(),s.target_model||"");for(const s of o){if(!s.isActive)continue;const n=s.name,i=n.toLowerCase();if(!t.has(i)){const r=`combo/${n}`;l.run(`INSERT INTO tool_mappings (tool_id, source_model, target_model) VALUES ('global', ?, ?)
7
+ ON CONFLICT(tool_id, source_model) DO NOTHING`,n,r)}}return this.getGlobalMappings()}static resetGlobalMappings(){return c().run("DELETE FROM tool_mappings WHERE tool_id = 'global'"),this.getGlobalMappings()}static matchMappingRows(l,o,e){if(l.length===0)return{matched:!1,targetModel:null};const t=o.toLowerCase(),s=p(o),n=o.indexOf("/"),i=n!==-1?o.slice(n+1).trim():null,r=i?p(i):null,a=n!==-1?o.slice(0,n).trim().toLowerCase():null,g=!!(a&&/\[[^[\]]+\]/.test(a)),E=a==="mapigate"||a==="gateway"||!!a&&a===(e||"").toLowerCase(),m=_(d=>({matched:!0,targetModel:d.target_model&&d.target_model.trim().length>0?d.target_model.trim():null,sourceModel:d.source_model,toolId:d.tool_id}),"resolveRowTarget");for(const d of l)if(d.source_model.toLowerCase()===t)return m(d);for(const d of l)if(p(d.source_model)===s)return m(d);if(i&&r&&!g&&E)for(const d of l){const u=d.source_model.indexOf("/"),M=u!==-1?d.source_model.slice(u+1).trim():d.source_model;if(p(d.source_model)===r||p(M)===r)return m(d)}if(!g){for(const d of l)if(d.source_model.includes("*")){const u="^"+d.source_model.toLowerCase().replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,".*")+"$",M=new RegExp(u);if(M.test(t)||E&&i&&M.test(i.toLowerCase()))return m(d)}}return{matched:!1,targetModel:null}}static resolveModelMappingDetailed(l,o){if(!o)return{targetModel:null,ruleType:"none"};const e=(l||"").toLowerCase(),t=o.trim();if(!t)return{targetModel:null,ruleType:"none"};const s=c();if(e&&e!=="global"&&e!=="unknown"){const r=s.all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = ?",e),a=this.matchMappingRows(r,t,e);if(a.matched&&a.targetModel)return{targetModel:a.targetModel,ruleType:"tool",matchedToolId:e,sourceModel:a.sourceModel}}const n=s.all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id = 'global'"),i=this.matchMappingRows(n,t,e);if(i.matched)return i.targetModel?{targetModel:i.targetModel,ruleType:"global",matchedToolId:"global",sourceModel:i.sourceModel}:{targetModel:null,ruleType:"global",matchedToolId:"global",sourceModel:i.sourceModel};if(!e||e==="unknown"){const r=s.all("SELECT tool_id, source_model, target_model FROM tool_mappings WHERE tool_id != 'global'"),a=this.matchMappingRows(r,t,e);if(a.matched&&a.targetModel)return{targetModel:a.targetModel,ruleType:"any",matchedToolId:a.toolId,sourceModel:a.sourceModel}}return{targetModel:null,ruleType:"none"}}static resolveModelMapping(l,o){return this.resolveModelMappingDetailed(l,o).targetModel}}export{S as ToolMappingRepository};
@@ -0,0 +1,171 @@
1
+ import{r as n,j as e}from"./vendor-BcOI2aZ9.js";import{b as o,c as w,D as ce,d as Ie,u as et,P as Ee}from"./index-BvY11iVv.js";import{a as tt}from"./providersData-C-7jZmPi.js";import{T as ke}from"./ToolIcon-BZE0Fv7L.js";import{M as Pe}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{r as st,s as at}from"./lucide-Cc35htxl.js";import"./metadataRegistry-4BIaQVmV.js";const ot={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"}]},lt={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 = "${w}"
6
+ $env:ANTHROPIC_AUTH_TOKEN = "mapigate-local"
7
+ $env:ANTHROPIC_MODEL = "claude-sonnet-4-6"
8
+ $env:CLAUDE_CODE_AUTO_MODE_SERVER = "0"
9
+ claude`,bashTemplate:`export ANTHROPIC_BASE_URL="${w}"
10
+ export ANTHROPIC_AUTH_TOKEN="mapigate-local"
11
+ export ANTHROPIC_MODEL="claude-sonnet-4-6"
12
+ export CLAUDE_CODE_AUTO_MODE_SERVER="0"
13
+ claude`,configFileTemplate:`{
14
+ "env": {
15
+ "ANTHROPIC_BASE_URL": "${w}",
16
+ "ANTHROPIC_AUTH_TOKEN": "mapigate-local",
17
+ "ANTHROPIC_MODEL": "claude-sonnet-4-6",
18
+ "CLAUDE_CODE_AUTO_MODE_SERVER": "0"
19
+ }
20
+ }`,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 ${ce}`,value:w,copyable:!0},{step:3,title:"Launch CLI",desc:"Run claude in your terminal"}]},nt={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:`{
21
+ "apiProvider": "openai-compatible",
22
+ "openAiBaseUrl": "${o}",
23
+ "openAiApiKey": "mapigate-local"
24
+ }`},it={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]
25
+ base_url = "${o}"
26
+ api_key = "mapigate-local"`},rt={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}"
27
+ $env:OPENAI_API_KEY = "mapigate-local"
28
+ codex`,bashTemplate:`export OPENAI_BASE_URL="${o}"
29
+ export OPENAI_API_KEY="mapigate-local"
30
+ codex`,configFileTemplate:`model_provider = "mapigate"
31
+
32
+ [model_providers.mapigate]
33
+ base_url = "${o}"
34
+ api_key = "mapigate-local"`},ct={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:`{
35
+ "models": [
36
+ {
37
+ "title": "Mapigate Model",
38
+ "provider": "openai",
39
+ "model": "claude-sonnet-4-6",
40
+ "apiBase": "${o}",
41
+ "apiKey": "mapigate-local"
42
+ }
43
+ ]
44
+ }`},configFileTemplate:`{
45
+ "models": [
46
+ {
47
+ "title": "Mapigate Model",
48
+ "provider": "openai",
49
+ "model": "claude-sonnet-4-6",
50
+ "apiBase": "${o}",
51
+ "apiKey": "mapigate-local"
52
+ }
53
+ ]
54
+ }`},dt={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:w,copyable:!0},{step:3,title:"Select Model",desc:"In Copilot Chat, pick any model routed through Mapigate."}]},pt={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 = "${w}"`,bashTemplate:`export ANTHROPIC_BASE_URL="${w}"`},mt={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:`{
55
+ "providers": {
56
+ "mapigate": {
57
+ "type": "openai",
58
+ "base_url": "${o}",
59
+ "api_key": "mapigate-local"
60
+ }
61
+ }
62
+ }`},ut={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."}]},xt={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}"
63
+ $env:OPENAI_API_KEY = "mapigate-local"
64
+ deepseek`,bashTemplate:`export OPENAI_BASE_URL="${o}"
65
+ export OPENAI_API_KEY="mapigate-local"
66
+ deepseek`,configFileTemplate:`[provider]
67
+ name = "openai"
68
+ base_url = "${o}"
69
+ api_key = "mapigate-local"
70
+ model = "claude-sonnet-4-6"`},gt={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"}]},ht={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}"
71
+ $env:FACTORY_API_KEY = "mapigate-local"
72
+ droid`,bashTemplate:`export FACTORY_BASE_URL="${o}"
73
+ export FACTORY_API_KEY="mapigate-local"
74
+ droid`,configFileTemplate:`{
75
+ "baseUrl": "${o}",
76
+ "apiKey": "mapigate-local"
77
+ }`},bt={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]
78
+ base_url = "${o}"
79
+ api_key = "mapigate-local"`},ft={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}"
80
+ $env:OPENAI_API_KEY = "mapigate-local"
81
+ grok`,bashTemplate:`export OPENAI_BASE_URL="${o}"
82
+ export OPENAI_API_KEY="mapigate-local"
83
+ grok`,configFileTemplate:`[model.mapigate]
84
+ type = "openai"
85
+ base_url = "${o}"
86
+ api_key = "mapigate-local"`},yt={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}"
87
+ $env:OPENAI_API_KEY = "mapigate-local"
88
+ hermes`,bashTemplate:`export OPENAI_BASE_URL="${o}"
89
+ export OPENAI_API_KEY="mapigate-local"
90
+ hermes`,configFileTemplate:`model_provider: openai
91
+ base_url: ${o}
92
+ api_key: mapigate-local`},vt={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}"
93
+ $env:OPENAI_API_KEY = "mapigate-local"
94
+ jcode`,bashTemplate:`export OPENAI_BASE_URL="${o}"
95
+ export OPENAI_API_KEY="mapigate-local"
96
+ jcode`,configFileTemplate:`[model_provider.openai]
97
+ base_url = "${o}"
98
+ api_key = "mapigate-local"`},jt={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}"
99
+ kilo`,bashTemplate:`export KILO_BASE_URL="${o}"
100
+ kilo`,configFileTemplate:`{
101
+ "baseUrl": "${o}",
102
+ "apiKey": "mapigate-local"
103
+ }`},Nt={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:
104
+ mapigate:
105
+ type: openai
106
+ base_url: ${o}
107
+ api_key: mapigate-local`},wt={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}"
108
+ $env:OPENCLAW_API_KEY = "mapigate-local"
109
+ openclaw`,bashTemplate:`export OPENCLAW_BASE_URL="${o}"
110
+ export OPENCLAW_API_KEY="mapigate-local"
111
+ openclaw`,configFileTemplate:`{
112
+ "baseUrl": "${o}",
113
+ "apiKey": "mapigate-local"
114
+ }`},At={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}"
115
+ $env:OPENCODE_API_KEY = "mapigate-local"
116
+ opencode`,bashTemplate:`export OPENCODE_BASE_URL="${o}"
117
+ export OPENCODE_API_KEY="mapigate-local"
118
+ opencode`,configFileTemplate:`{
119
+ "provider": {
120
+ "mapigate": {
121
+ "options": {
122
+ "baseURL": "${o}",
123
+ "apiKey": "mapigate-local"
124
+ }
125
+ }
126
+ }
127
+ }`},Ct={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>"}]},_t={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:`{
128
+ "providers": {
129
+ "mapigate": {
130
+ "type": "openai",
131
+ "baseUrl": "${o}",
132
+ "apiKey": "mapigate-local"
133
+ }
134
+ }
135
+ }`},Et={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:`{
136
+ "security": {
137
+ "auth": {
138
+ "selectedType": "openai",
139
+ "apiKey": "mapigate-local",
140
+ "baseUrl": "${o}"
141
+ }
142
+ },
143
+ "model": {
144
+ "name": "claude-sonnet-4-6"
145
+ }
146
+ }`},configFileTemplate:`{
147
+ "security": {
148
+ "auth": {
149
+ "selectedType": "openai",
150
+ "apiKey": "mapigate-local",
151
+ "baseUrl": "${o}"
152
+ }
153
+ },
154
+ "model": {
155
+ "name": "claude-sonnet-4-6"
156
+ }
157
+ }`},kt={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:`{
158
+ "apiProvider": "openai-compatible",
159
+ "baseUrl": "${o}",
160
+ "apiKey": "mapigate-local"
161
+ }`},Pt={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:`{
162
+ "provider": "openai",
163
+ "baseUrl": "${o}",
164
+ "apiKey": "mapigate-local"
165
+ }`},re={amp:ot,claude:lt,cline:nt,codewhale:it,codex:rt,continue:ct,copilot:dt,cowork:pt,crush:mt,cursor:ut,"deepseek-tui":xt,devin:gt,droid:ht,forge:bt,"grok-build":ft,hermes:yt,jcode:vt,kilo:jt,omp:Nt,openclaw:wt,opencode:At,opendesign:Ct,pi:_t,qwen:Et,roo:kt,smelt:Pt};var Te={};function Se(g){if(typeof process<"u"&&Te)return Te[g]}function Me(g,p){const u=Se("PORT"),f=Se("HOST"),D=u?Number(u):ce,_=f||Ie;return`http://${_==="0.0.0.0"?"localhost":_}:${D}`}function Tt(g,p){return`${Me()}/v1`}Me();Tt();const Rt=()=>{var Ce,_e;const g=et(t=>t.info),p=(g==null?void 0:g.port)||ce,u=(g==null?void 0:g.host)||Ie,[f,D]=n.useState(!1),[_,de]=n.useState([]),[F,V]=n.useState("mapigate-local"),[pe,me]=n.useState(!1),E=n.useMemo(()=>_.filter(t=>t.isActive&&!t.isSystem),[_]),x=n.useMemo(()=>F&&F!=="mapigate-local"?F:f&&E.length>0?E[0].key:"mapigate-local",[F,f,E]),j=t=>t?t.replace(/127\.0\.0\.1:2012[78]/g,`${u}:${p}`).replace(/localhost:2012[78]/g,`localhost:${p}`).replace(/:2012[78]\b/g,`:${p}`).replace(/mapigate-local/g,x):"",[k,W]=n.useState("catalog"),[c,P]=n.useState(null),[v,N]=n.useState("powershell"),[d,ue]=n.useState(null),[Oe,Fe]=n.useState({}),[z,$]=n.useState(!1),[B,h]=n.useState(null),[xe,y]=n.useState(null),[J,A]=n.useState([]),[$e,R]=n.useState(!1),[C,ge]=n.useState(""),[T,Be]=n.useState("source"),[S,he]=n.useState("asc"),[Re,U]=n.useState(null),[Q,I]=n.useState(""),[L,Z]=n.useState(""),[K,X]=n.useState(""),[q,ee]=n.useState(!1),[Ue,Le]=n.useState(new Set),be=t=>{T===t?he(a=>a==="asc"?"desc":"asc"):(Be(t),he("asc"))},[te,fe]=n.useState("all"),[Ke,se]=n.useState(!1),[H,qe]=n.useState(""),[ye,He]=n.useState(""),[r,ae]=n.useState(null),[oe,ve]=n.useState(!1),G=()=>{fetch("/api/cli-tools/status").then(t=>t.json()).then(t=>{t&&typeof t=="object"&&Fe(t)}).catch(()=>{})},Ge=()=>{fetch("/api/combos").then(t=>t.ok?t.json():[]).then(t=>{const a=Array.isArray(t)?t:t.combos||[];Le(new Set(a.map(i=>(i.name||"").toLowerCase())))}).catch(()=>{})},le=async()=>{R(!0);try{const t=await fetch("/api/model-mappings/global-mappings");if(t.ok){const a=await t.json();Array.isArray(a)&&A(a)}}catch{}finally{R(!1)}},Ye=async()=>{try{const[t,a]=await Promise.all([fetch("/api/settings/endpoint"),fetch("/api/settings/endpoint/keys")]);let i=!1;if(t.ok){const l=await t.json();i=!!(l!=null&&l.requireApiKey),D(i)}if(a.ok){const l=await a.json();if(Array.isArray(l)){de(l);const b=l.find(m=>m.isActive&&!m.isSystem);i&&b&&V(m=>m==="mapigate-local"?b.key:m)}}}catch{}},De=async t=>{me(!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 i=await a.json();de(l=>[i,...l]),V(i.key),h({type:"success",text:`Created Gateway API Key "${i.name}" and selected it.`})}}catch{}finally{me(!1)}},Ve=async()=>{try{const t=await fetch("/api/model-mappings/exposure-mode");if(t.ok){const a=await t.json();a.mode&&fe(a.mode)}}catch{}},ne=async t=>{fe(t);try{await fetch("/api/model-mappings/exposure-mode",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:t})}),y({all:"Exposing all provider models via /v1/models",connected:"Exposing only connected provider models & combos via /v1/models",mapped_only:"Strict mode: Exposing only mapped models & combos via /v1/models"}[t]),setTimeout(()=>y(null),3500)}catch{}},We=async()=>{try{const t=await fetch("/api/model-mappings/global-mappings/import-combos",{method:"POST"});if(t.ok){const a=await t.json();Array.isArray(a.mappings)&&A(a.mappings),y("Synchronized all active combos into Model Mappings!"),setTimeout(()=>y(null),4e3)}}catch(t){console.error("Failed to import combos:",t)}},je=async()=>{if(H.trim()){ve(!0),ae(null);try{const t=await fetch("/api/model-mappings/simulate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:H.trim(),toolId:ye||void 0})});if(t.ok){const a=await t.json();ae(a)}}catch{}finally{ve(!1)}}};n.useEffect(()=>{G(),Ge(),le(),Ye(),Ve()},[]);const M=t=>{navigator.clipboard.writeText(t),ue(t),setTimeout(()=>ue(null),2e3)},Ne=t=>{const a=Oe[t.id];return a?a.status:t.status},we=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=c?re[c.id]:void 0,ze=async(t,a)=>{var i;try{const l=await fetch(`/api/model-mappings/global-mappings/import/${t}`,{method:"POST"});if(l.ok){const b=await l.json();Array.isArray(b.mappings)&&A(b.mappings);const m=a||((i=re[t])==null?void 0:i.name)||t;y(`Imported model aliases from ${m} into Model Mappings!`),setTimeout(()=>y(null),4e3)}}catch(l){console.error("Failed to import tool aliases:",l)}},Y=async(t,a)=>{if(!t.trim()||!a.trim())return;const i=t.trim(),l=a.trim();A(b=>[...b.filter(O=>O.sourceModel.toLowerCase()!==i.toLowerCase()),{toolId:"global",sourceModel:i,targetModel:l}]);try{await fetch("/api/model-mappings/global-mappings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceModel:i,targetModel:l})})}catch{}finally{U(null),I(""),Z(""),X(""),ee(!1)}},Je=async t=>{A(a=>a.filter(i=>i.sourceModel!==t));try{await fetch(`/api/model-mappings/global-mappings?sourceModel=${encodeURIComponent(t)}`,{method:"DELETE"})}catch{}},Qe=async()=>{R(!0);try{const t=await fetch("/api/model-mappings/global-mappings/reset",{method:"POST"});if(t.ok){const a=await t.json();Array.isArray(a.mappings)&&A(a.mappings),y("Restored default canonical model mappings!"),setTimeout(()=>y(null),3e3)}}catch{}finally{R(!1)}},Ze=async t=>{$(!0),h(null);try{const a=await fetch(`/api/cli-tools/${t}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:x})}),i=await a.json();a.ok?(h({type:"success",text:"Configuration applied successfully!"}),G()):h({type:"error",text:i.error||"Failed to apply config"})}catch(a){h({type:"error",text:a.message||"Network error"})}finally{$(!1)}},Xe=async t=>{$(!0),h(null);try{const a=await fetch(`/api/cli-tools/${t}/reset`,{method:"POST"}),i=await a.json();a.ok?(h({type:"success",text:"Configuration reset successfully."}),G()):h({type:"error",text:i.error||"Failed to reset config"})}catch(a){h({type:"error",text:a.message||"Network error"})}finally{$(!1)}},Ae=n.useMemo(()=>{const t=C.trim().toLowerCase();return(t?J.filter(i=>i.sourceModel.toLowerCase().includes(t)||i.targetModel.toLowerCase().includes(t)):[...J]).sort((i,l)=>{if(T==="target"){const m=i.targetModel||"",O=l.targetModel||"";if(!m&&O)return 1;if(m&&!O)return-1;const ie=m.localeCompare(O,void 0,{numeric:!0,sensitivity:"base"});if(ie!==0)return S==="asc"?ie:-ie}const b=i.sourceModel.localeCompare(l.sourceModel,void 0,{numeric:!0,sensitivity:"base"});return S==="asc"?b:-b})},[J,C,T,S]);return e.jsxs("div",{className:"space-y-6 w-full px-2 sm:px-4 pb-16 animate-rt-fade-in",children:[xe&&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:xe})]}),e.jsx("button",{onClick:()=>y(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:()=>W("catalog"),className:`px-3.5 py-1.5 rounded-lg text-xs font-bold flex items-center gap-2 transition-all cursor-pointer ${k==="catalog"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:[e.jsx(st,{className:"w-3.5 h-3.5"}),"Tool Catalog"]}),e.jsxs("button",{onClick:()=>{W("mappings"),le()},className:`px-3.5 py-1.5 rounded-lg text-xs font-bold flex items-center gap-2 transition-all cursor-pointer ${k==="mappings"?"bg-blue-600 text-white shadow-xs":"text-slate-400 hover:text-white"}`,children:[e.jsx(at,{className:"w-3.5 h-3.5"}),"Model Mappings"]})]}),e.jsx("div",{className:"flex items-center gap-2 shrink-0",children:k==="catalog"?e.jsxs("button",{onClick:G,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:le,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"]})})]}),k==="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:tt.map((t,a)=>{const i=Ne(t),l=re[t.id];return e.jsxs("div",{onClick:()=>{P(t),h(null),l!=null&&l.guideSteps&&l.guideSteps.length>0&&!l.powershellTemplate?N("guide"):l!=null&&l.configFileTemplate&&!l.powershellTemplate?N("file"):N("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(ke,{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:we(i)})]})]}),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)})})]}),k==="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 xl:flex-row items-start xl: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.jsxs("div",{className:"flex flex-wrap items-center gap-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1 bg-[#080B11] border border-[#1E293B] p-1 rounded-xl text-xs",children:[e.jsxs("span",{className:"text-[11px] text-slate-400 px-2 flex items-center gap-1 font-medium",children:[e.jsx("span",{className:"material-symbols-outlined text-[14px] text-slate-500",children:"visibility"}),"/v1/models:"]}),e.jsx("button",{type:"button",onClick:()=>ne("all"),className:`px-2 py-1 rounded-lg text-[11px] transition-all cursor-pointer ${te==="all"?"bg-blue-600 text-white font-semibold shadow-sm":"text-slate-400 hover:text-white"}`,title:"Expose all registered and scanned models in /v1/models",children:"All"}),e.jsx("button",{type:"button",onClick:()=>ne("connected"),className:`px-2 py-1 rounded-lg text-[11px] transition-all cursor-pointer ${te==="connected"?"bg-blue-600 text-white font-semibold shadow-sm":"text-slate-400 hover:text-white"}`,title:"Expose only connected providers with active accounts + combos",children:"Connected"}),e.jsx("button",{type:"button",onClick:()=>ne("mapped_only"),className:`px-2 py-1 rounded-lg text-[11px] transition-all cursor-pointer ${te==="mapped_only"?"bg-blue-600 text-white font-semibold shadow-sm":"text-slate-400 hover:text-white"}`,title:"Strict: Expose ONLY models defined in Mappings + Combos",children:"Mappings Only"})]}),e.jsxs("button",{type:"button",onClick:Qe,className:"px-3 py-1.5 text-xs font-medium rounded-xl bg-slate-800/80 hover:bg-slate-700/80 border border-[#1E293B] hover:border-slate-600 text-slate-200 flex items-center gap-1.5 transition-all cursor-pointer",title:"Reset to default canonical mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] text-slate-400",children:"restart_alt"}),"Reset to Default"]}),e.jsxs("button",{type:"button",onClick:We,className:"px-3 py-1.5 text-xs font-medium rounded-xl bg-slate-800/80 hover:bg-slate-700/80 border border-[#1E293B] hover:border-slate-600 text-slate-200 flex items-center gap-1.5 transition-all cursor-pointer",title:"Automatically import all active combos into Model Mappings",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-cyan-400",children:"sync_alt"}),"Sync Combos"]}),e.jsxs("button",{type:"button",onClick:()=>{se(!0),ae(null)},className:"px-3 py-1.5 text-xs font-medium rounded-xl bg-slate-800/80 hover:bg-slate-700/80 border border-[#1E293B] hover:border-slate-600 text-slate-200 flex items-center gap-1.5 transition-all cursor-pointer",title:"Test and simulate which provider and model a client request routes to",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px] text-emerald-400",children:"play_circle"}),"Test Route"]}),e.jsxs("button",{type:"button",onClick:()=>ee(!q),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:q?"close":"add_circle"}),q?"Cancel":"Add Mapping"]})]})]}),q&&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:L,onChange:t=>Z(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(Pe,{value:K,onChange:X,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:()=>Y(L,K)})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-1",children:[e.jsx("button",{onClick:()=>{ee(!1),Z(""),X("")},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:()=>Y(L,K),disabled:!L.trim()||!K.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:C,onChange:t=>ge(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"})]}),C&&e.jsx("button",{onClick:()=>ge(""),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:$e?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..."]}):Ae.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:C?`No mappings match "${C}"`:"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",{onClick:()=>be("source"),className:"p-3 pl-4 cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Source Model",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Source Model (Client Sends)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:T==="source"?S==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{onClick:()=>be("target"),className:"p-3 cursor-pointer hover:text-white select-none transition-colors",title:"Click to sort by Target Destination",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{children:"Target Destination (Model or Combo)"}),e.jsx("span",{className:"material-symbols-outlined text-[14px] text-blue-400",children:T==="target"?S==="asc"?"arrow_upward":"arrow_downward":"unfold_more"})]})}),e.jsx("th",{className:"p-3 pr-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-[#1E293B]",children:Ae.map(t=>{const a=Re===t.sourceModel,i=!!(t.targetModel&&(t.targetModel.startsWith("combo/")||Ue.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:()=>M(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:d===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(Pe,{value:Q,onChange:I,onEnter:()=>Y(t.sourceModel,Q),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:"→"}),i&&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:()=>{U(t.sourceModel),I("")},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:()=>Y(t.sourceModel,Q),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:()=>{U(null),I("")},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:()=>{U(t.sourceModel),I(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:()=>Je(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(Ee,{isOpen:!!c,onClose:()=>P(null),maxWidthClass:"w-full max-w-4xl",children:c&&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(ke,{src:c.image,name:c.name,color:s==null?void 0:s.color,iconBg:(s==null?void 0:s.iconBg)||c.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:c.name}),we(Ne(c))]}),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:()=>{ze(c.id,c.name),P(null),W("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:()=>P(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 ${f&&x==="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"}),f?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:x,onChange:t=>V(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:[!f&&e.jsx("option",{value:"mapigate-local",children:"mapigate-local (Placeholder)"}),f&&E.length===0&&e.jsx("option",{value:"mapigate-local",children:"No active key — create one →"}),E.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:pe,onClick:()=>De(c.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"}),pe?"Creating...":"New Key"]})]})]}),e.jsx("p",{className:"text-[11px] leading-relaxed text-slate-400",children:f?x==="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."]}):x==="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:()=>N("powershell"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${v==="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:()=>N("bash"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${v==="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:()=>N("file"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${v==="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:()=>N("guide"),className:`pb-2.5 px-3 text-xs font-semibold flex items-center gap-1.5 transition-colors border-b-2 cursor-pointer ${v==="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:[v==="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:()=>M(j(s==null?void 0:s.powershellTemplate)||`$env:OPENAI_BASE_URL = "http://${u}:${p}/v1"; $env:OPENAI_API_KEY = "${x}"`),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"}),d!=null&&d.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:j(s==null?void 0:s.powershellTemplate)||`$env:OPENAI_BASE_URL = "http://${u}:${p}/v1"
166
+ $env:OPENAI_API_KEY = "${x}"`}),e.jsxs("p",{className:"text-[11px] text-slate-400",children:["💡 Sets environment variables in your current PowerShell session pointing to Mapigate port ",p,"."]})]}),v==="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:()=>M(j(s==null?void 0:s.bashTemplate)||`export OPENAI_BASE_URL="http://${u}:${p}/v1"
167
+ export OPENAI_API_KEY="${x}"`),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"}),d!=null&&d.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:j(s==null?void 0:s.bashTemplate)||`export OPENAI_BASE_URL="http://${u}:${p}/v1"
168
+ export OPENAI_API_KEY="${x}"`}),e.jsx("p",{className:"text-[11px] text-slate-400",children:"💡 Exports the environment variables for your current terminal session."})]}),v==="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 M(j((s==null?void 0:s.configFileTemplate)||((t=s==null?void 0:s.codeBlock)==null?void 0:t.code))||`http://${u}:${p}/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"}),d!=null&&d.includes("{")||d!=null&&d.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:j((s==null?void 0:s.configFileTemplate)||((Ce=s==null?void 0:s.codeBlock)==null?void 0:Ce.code))||`{
169
+ "baseUrl": "http://${u}:${p}/v1",
170
+ "apiKey": "${x}"
171
+ }`}),!!(s!=null&&s.configPath||s!=null&&s.settingsFile)&&e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs("button",{disabled:z,onClick:()=>Ze(c.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"}),z?"Applying...":"Apply to Config File"]}),e.jsxs("button",{disabled:z,onClick:()=>Xe(c.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"]})]})]}),v==="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=j(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:()=>M(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"}),d===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"]})})]}),B&&e.jsxs("div",{className:`p-2.5 rounded-xl text-xs flex items-center gap-2 ${B.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:B.type==="success"?"check_circle":"error"}),B.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://",u,":",p,(s==null?void 0:s.baseUrlPath)||""]})}),e.jsx("button",{onClick:()=>P(null),className:"rt-btn rt-btn--secondary text-xs py-1.5 px-4 cursor-pointer",children:"Close"})]})]})}),e.jsx(Ee,{isOpen:Ke,onClose:()=>se(!1),maxWidthClass:"w-full max-w-xl",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-[#1E293B]",children:[e.jsxs("h3",{className:"text-sm font-bold text-white flex items-center gap-2",children:[e.jsx("span",{className:"material-symbols-outlined text-emerald-400 text-[20px]",children:"play_circle"}),"Route Simulator (Conflict & Target Resolution)"]}),e.jsx("button",{onClick:()=>se(!1),className:"text-slate-400 hover:text-white cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[20px]",children:"close"})})]}),e.jsx("p",{className:"text-xs text-slate-400 leading-relaxed",children:"Enter the exact model string a coding assistant (OpenCode, Cursor, Claude Code) sends to see which mapping rule, provider, or combo Mapigate will route to."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-slate-300 block mb-1 font-medium",children:"Client Sent Model:"}),e.jsx("input",{type:"text",value:H,onChange:t=>qe(t.target.value),onKeyDown:t=>t.key==="Enter"&&je(),placeholder:"e.g. claude-3-7-sonnet, anthropic/claude-3-7-sonnet, gpt-4o",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-300 block mb-1 font-medium",children:"Calling Assistant / Tool (Optional):"}),e.jsxs("select",{value:ye,onChange:t=>He(t.target.value),className:"bg-[#080B11] border border-[#1E293B] focus:border-blue-400 rounded-xl px-3 py-2 text-xs text-slate-200 w-full focus:outline-none",children:[e.jsx("option",{value:"",children:"Auto Detect / Generic Client"}),e.jsx("option",{value:"opencode",children:"OpenCode"}),e.jsx("option",{value:"claude",children:"Claude Code"}),e.jsx("option",{value:"cursor",children:"Cursor"}),e.jsx("option",{value:"cline",children:"Cline"}),e.jsx("option",{value:"copilot",children:"GitHub Copilot"}),e.jsx("option",{value:"kiro",children:"Kiro IDE"})]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsxs("button",{type:"button",onClick:je,disabled:!H.trim()||oe,className:"px-4 py-2 text-xs font-semibold rounded-xl bg-emerald-600 hover:bg-emerald-500 text-white flex items-center gap-1.5 transition-all disabled:opacity-50 cursor-pointer shadow-md shadow-emerald-600/30",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:oe?"progress_activity":"route"}),oe?"Simulating...":"Simulate Route"]})}),r&&e.jsxs("div",{className:"mt-4 p-4 rounded-xl bg-[#080B11] border border-[#1E293B] space-y-2.5 animate-rt-scale-in text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-[#1E293B]",children:[e.jsx("span",{className:"text-slate-400 font-sans",children:"Mapping Rule:"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-blue-500/20 text-blue-300 border border-blue-500/40",children:r.matchedRule==="global"?"Global Universal Mapping":r.matchedRule==="tool"?`Tool Specific: ${r.matchedToolId||"tool"}`:r.matchedRule==="any"?`Tool Fallback: ${r.matchedToolId||"tool"}`:"Direct (No Mapping)"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-sans",children:"Resolved Destination:"}),e.jsx("span",{className:"text-emerald-300 font-bold",children:r.effectiveModel})]}),r.isCombo?e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-sans",children:"Target Combo:"}),e.jsx("span",{className:"text-cyan-300 font-semibold",children:r.comboName})]}),e.jsxs("div",{className:"text-[11px] text-slate-400",children:["Combo Candidates:"," ",e.jsx("span",{className:"text-slate-300",children:(r.comboModels||[]).join(", ")})]})]}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-slate-400 font-sans",children:"Target Provider:"}),e.jsxs("span",{className:r.isFallback?"text-amber-300 font-semibold":"text-purple-300 font-semibold",children:[r.targetProviderId," / ",r.targetModel,r.isFallback&&" (Fallback)"]})]}),e.jsxs("div",{className:"flex items-start justify-between pt-2 border-t border-[#1E293B] gap-2",children:[e.jsx("span",{className:"text-slate-400 font-sans shrink-0",children:"Model Status:"}),r.isCombo?r.hasActiveAccount?e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1 font-semibold font-sans",children:[e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 animate-pulse"}),"Ready (",r.readyCandidatesCount,"/",((_e=r.comboModels)==null?void 0:_e.length)||1," candidates ready, ",r.activeAccountsCount," accounts)"]}):e.jsxs("span",{className:"text-rose-400 flex items-center gap-1 font-semibold font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),"No active accounts for any combo candidates"]}):r.isFallback?e.jsxs("span",{className:"text-amber-400 flex items-center gap-1 font-sans text-[11px] text-right",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px] shrink-0 text-amber-400",children:"warning"}),"Unknown model: not recognized in catalog. Will fallback directly to '",r.targetProviderId,"' (may fail upstream with 404)."]}):r.hasActiveAccount?e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1 font-semibold font-sans",children:[e.jsx("span",{className:"size-2 rounded-full bg-emerald-400 animate-pulse"}),"Ready (",r.activeAccountsCount," active account",r.activeAccountsCount>1?"s":"",")"]}):e.jsxs("span",{className:"text-rose-400 flex items-center gap-1 font-semibold font-sans",children:[e.jsx("span",{className:"material-symbols-outlined text-[15px]",children:"error"}),"No active account for '",r.targetProviderId,"'"]})]})]})]})]})})]})};export{Rt as CliToolsTab};
@@ -0,0 +1 @@
1
+ import{j as e,r as d}from"./vendor-BcOI2aZ9.js";import{C as B}from"./ConfirmModal-gmHKbGNe.js";import{M as Q}from"./ModelSelectModal-B7-jAYUU.js";import{g as V,C as D,a as G,M as H,i as E}from"./ModelAutocompleteInput-BH4gr6Dr.js";import{S as J}from"./Select-BNRH8LIG.js";import"./index-BvY11iVv.js";import"./lucide-Cc35htxl.js";import"./dnd-kit-DecqzwfZ.js";import"./ToolIcon-BZE0Fv7L.js";import"./metadataRegistry-4BIaQVmV.js";const K=({model:i,index:a,total:r,onMoveToTop:p,onMoveUp:s,onMoveDown:u,onMoveToBottom:h,onRemove:b})=>{let n="",m=i;if(i.includes("/")){const j=i.indexOf("/");n=i.slice(0,j),m=i.slice(j+1)}const x=V(n||null,m),v=a===0,c=a===r-1;return e.jsxs("div",{className:"flex items-center justify-between gap-3 px-3.5 py-2.5 rounded-xl border border-[#1E293B] bg-[#0A0D14] hover:border-slate-700 hover:bg-[#0F1420] transition-colors group",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("span",{className:`size-6 rounded-lg text-[10px] font-mono font-bold flex items-center justify-center shrink-0 border ${a===0?"bg-blue-500/20 text-blue-300 border-blue-500/30":a===1?"bg-cyan-500/15 text-cyan-300 border-cyan-500/25":"bg-[#141B2D] text-slate-400 border-[#1E293B]"}`,title:`Priority #${a+1}`,children:a+1}),n&&e.jsx("span",{className:"px-2 py-0.5 rounded-md bg-[#161F30] border border-[#26354D] text-[11px] text-cyan-400 font-mono font-medium shrink-0 max-w-[140px] sm:max-w-none truncate",children:n}),e.jsx("span",{className:"text-xs text-white font-mono font-semibold truncate flex-1 min-w-0",children:m}),x&&e.jsx("div",{className:"shrink-0 hidden sm:block",children:e.jsx(D,{caps:x,size:"xs"})})]}),e.jsxs("div",{className:"flex items-center gap-1 text-slate-400 shrink-0",children:[e.jsx("button",{type:"button",disabled:v,onClick:()=>p(a),title:"Move to top priority (#1)",className:"p-1 rounded-md transition-colors hover:bg-white/10 hover:text-white disabled:opacity-20 disabled:pointer-events-none cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"vertical_align_top"})}),e.jsx("button",{type:"button",disabled:v,onClick:()=>s(a),title:"Move up",className:"p-1 rounded-md transition-colors hover:bg-white/10 hover:text-white disabled:opacity-20 disabled:pointer-events-none cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_upward"})}),e.jsx("button",{type:"button",disabled:c,onClick:()=>u(a),title:"Move down",className:"p-1 rounded-md transition-colors hover:bg-white/10 hover:text-white disabled:opacity-20 disabled:pointer-events-none cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"arrow_downward"})}),e.jsx("button",{type:"button",disabled:c,onClick:()=>h(a),title:"Move to lowest priority",className:"p-1 rounded-md transition-colors hover:bg-white/10 hover:text-white disabled:opacity-20 disabled:pointer-events-none cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"vertical_align_bottom"})}),e.jsx("div",{className:"h-4 w-px bg-[#1E293B] mx-0.5"}),e.jsx("button",{type:"button",onClick:()=>b(a),title:"Remove model from combo",className:"p-1 rounded-md transition-colors hover:bg-rose-500/20 hover:text-rose-400 text-slate-500 cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"close"})})]})]})},W=({combo:i,providersCount:a,saving:r,onBack:p,onUpdateStrategy:s,onToggleActive:u,onDeleteRequest:h})=>{const[b,n]=d.useState(!1),m=G(i.models),x=i.isActive!==!1,v=()=>{navigator.clipboard.writeText(i.name),n(!0),setTimeout(()=>n(!1),2e3)};return e.jsx("div",{className:"w-full p-5 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-4",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{type:"button",onClick:p,className:"p-2 rounded-xl bg-[#0A0D14] border border-[#1E293B] text-slate-400 hover:text-white hover:border-slate-700 transition-colors cursor-pointer shrink-0",title:"Back to Combos",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"arrow_back"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-mono text-base font-bold text-white tracking-tight truncate",children:i.name}),m&&e.jsx(D,{caps:m,size:"xs"}),!x&&e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-slate-800 text-slate-400 text-[10px] uppercase font-bold",children:"Disabled"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400 mt-1",children:[e.jsxs("span",{children:[e.jsx("strong",{className:"text-white",children:i.models.length})," models configured"]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:[e.jsx("strong",{className:"text-cyan-400",children:a})," providers"]}),r&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsxs("span",{className:"text-blue-400 font-mono text-[11px] flex items-center gap-1",children:[e.jsx("span",{className:"material-symbols-outlined text-[12px] animate-spin",children:"progress_activity"}),"Saving..."]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{type:"button",onClick:v,className:`px-3 py-1.5 rounded-xl border text-xs font-semibold flex items-center gap-1.5 transition-colors cursor-pointer ${b?"bg-emerald-500/10 text-emerald-400 border-emerald-500/20":"bg-[#0A0D14] text-slate-300 border-[#1E293B] hover:text-white hover:border-slate-700"}`,title:"Copy combo alias",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:b?"check":"content_copy"}),e.jsx("span",{children:b?"Copied":"Copy Alias"})]}),e.jsx(J,{value:i.strategy,onChange:c=>s(c),options:[{value:"fallback",label:"Fallback (in order)"},{value:"round-robin",label:"Round Robin"},{value:"fusion",label:"Fusion (parallel)"},{value:"lkgp",label:"LKGP (prompt cache)"},{value:"p2c",label:"P2C (two choices)"}],className:"min-w-[170px]"}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer ml-1",title:x?"Disable combo":"Enable combo",children:[e.jsx("input",{type:"checkbox",checked:x,onChange:u,className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-[#1E293B] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-blue-600"})]}),e.jsx("button",{type:"button",onClick:h,className:"p-2 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-400 hover:bg-rose-500/20 transition-colors cursor-pointer",title:"Delete Combo",children:e.jsx("span",{className:"material-symbols-outlined text-[18px]",children:"delete"})})]})]})})},X=({totalModels:i,searchQuery:a,onSearchChange:r,providersList:p,providerFilter:s,onProviderFilterChange:u,onRemoveProviderRequest:h,onBrowseCatalog:b,newModelInput:n,onNewModelInputChange:m,onQuickAdd:x,existingModels:v})=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-[240px]",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx("span",{className:"material-symbols-outlined absolute left-3 top-1/2 -translate-y-1/2 text-[16px] text-slate-500",children:"search"}),e.jsx("input",{type:"text",placeholder:`Search among ${i} models...`,value:a,onChange:c=>r(c.target.value),className:"w-full bg-[#0A0D14] border border-[#1E293B] rounded-xl pl-9 pr-8 py-1.5 text-xs text-white placeholder-slate-500 focus:outline-none focus:border-blue-500/50"}),a&&e.jsx("button",{type:"button",onClick:()=>r(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-slate-500 hover:text-white text-xs cursor-pointer",children:e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"close"})})]}),p.length>1&&e.jsxs("select",{value:s,onChange:c=>u(c.target.value),className:"bg-[#0A0D14] border border-[#1E293B] rounded-xl px-3 py-1.5 text-xs text-slate-300 focus:outline-none focus:border-blue-500/50 cursor-pointer",children:[e.jsxs("option",{value:"all",children:["All Providers (",p.length,")"]}),p.map(c=>e.jsx("option",{value:c,children:c},c))]}),s!=="all"&&e.jsxs("button",{type:"button",onClick:()=>h(s),className:"px-2.5 py-1.5 rounded-xl bg-rose-500/10 border border-rose-500/20 text-rose-400 hover:bg-rose-500/20 text-xs font-semibold flex items-center gap-1 cursor-pointer",title:`Remove all models from ${s}`,children:[e.jsx("span",{className:"material-symbols-outlined text-[14px]",children:"delete_sweep"}),e.jsxs("span",{children:["Remove “",s,"”"]})]})]}),e.jsxs("button",{type:"button",onClick:b,className:"px-3.5 py-1.5 rounded-xl bg-blue-600 hover:bg-blue-500 text-xs font-semibold text-white flex items-center gap-1.5 shadow-lg shadow-blue-600/20 cursor-pointer shrink-0",children:[e.jsx("span",{className:"material-symbols-outlined text-[16px]",children:"add_circle"}),e.jsx("span",{children:"Browse Catalog"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 pt-1 border-t border-[#1E293B]/60",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(H,{value:n,onChange:m,onEnter:x,placeholder:"Quick add model (e.g. anthropic/claude-3-7-sonnet or devin/gpt-5-low)...",excludeValues:v,allowCombos:!1})}),e.jsx("button",{type:"button",disabled:!n.trim(),onClick:x,className:"px-4 py-2 rounded-xl bg-[#1E293B] hover:bg-blue-600 text-xs font-semibold text-white transition-colors disabled:opacity-40 disabled:pointer-events-none cursor-pointer shrink-0",children:"Add"})]})]}),ne=({combo:i,onBack:a,onComboUpdated:r,onComboDeleted:p})=>{const[s,u]=d.useState(i),[h,b]=d.useState(""),[n,m]=d.useState("all"),[x,v]=d.useState(""),[c,j]=d.useState(!1),[T,M]=d.useState(!1),[C,k]=d.useState(!1),[y,N]=d.useState(null),S=d.useMemo(()=>{const t=new Set;for(const l of s.models)if(l.includes("/")){const o=l.split("/")[0].replace(/\(.*?\)/,"").trim();o&&t.add(o)}return Array.from(t).sort()},[s.models]),f=d.useCallback(async t=>{const l=s,o={...s,...t};u(o),r==null||r(o);try{M(!0);const g=await fetch(`/api/combos/${s.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:o.name,models:o.models,strategy:o.strategy,isActive:o.isActive})});if(g.ok){const w=await g.json();u(w),r==null||r(w),E()}else{const w=await g.json().catch(()=>({}));console.error("Failed to update combo:",w.error||g.statusText),u(l),r==null||r(l)}}catch(g){console.error("Failed to update combo:",g),u(l),r==null||r(l)}finally{M(!1)}},[s,r]),R=t=>{if(t<=0)return;const o=[s.models[t],...s.models.slice(0,t),...s.models.slice(t+1)];f({models:o})},$=t=>{if(t<=0)return;const l=[...s.models],o=l[t];l[t]=l[t-1],l[t-1]=o,f({models:l})},_=t=>{if(t>=s.models.length-1)return;const l=[...s.models],o=l[t];l[t]=l[t+1],l[t+1]=o,f({models:l})},F=t=>{if(t>=s.models.length-1)return;const l=s.models[t],o=[...s.models.slice(0,t),...s.models.slice(t+1),l];f({models:o})},P=t=>{const l=s.models.filter((o,g)=>g!==t);f({models:l})},I=()=>{const t=x.trim();!t||new Set([s.name,`combo/${s.name}`,s.id]).has(t)||s.models.includes(t)||(f({models:[...s.models,t]}),v(""))},O=t=>{f({models:t}),j(!1)},L=d.useMemo(()=>{const t=[];return s!=null&&s.id&&t.push(s.id),s!=null&&s.name&&(t.push(s.name),t.push(`combo/${s.name}`)),t},[s]),q=t=>{const l=s.models.filter(o=>o.split("/")[0].replace(/\(.*?\)/,"").trim()!==t);f({models:l}),N(null),n===t&&m("all")},z=async()=>{try{(await fetch(`/api/combos/${s.id}`,{method:"DELETE"})).ok&&(E(),p==null||p(),a())}catch(t){console.error("Failed to delete combo:",t)}},A=d.useMemo(()=>{const t=h.trim().toLowerCase();return s.models.map((l,o)=>({model:l,originalIndex:o})).filter(({model:l})=>!(n!=="all"&&l.split("/")[0].replace(/\(.*?\)/,"").trim()!==n||t&&!l.toLowerCase().includes(t)))},[s.models,h,n]);return e.jsxs("div",{className:"space-y-6 w-full pb-16 animate-rt-fade-in",children:[e.jsx(W,{combo:s,providersCount:S.length,saving:T,onBack:a,onUpdateStrategy:t=>f({strategy:t}),onToggleActive:()=>f({isActive:s.isActive===!1}),onDeleteRequest:()=>k(!0)}),e.jsxs("div",{className:"w-full p-5 rounded-2xl bg-[#0F1420]/80 border border-[#1E293B] space-y-4",children:[e.jsx(X,{totalModels:s.models.length,searchQuery:h,onSearchChange:b,providersList:S,providerFilter:n,onProviderFilterChange:m,onRemoveProviderRequest:t=>N(t),onBrowseCatalog:()=>j(!0),newModelInput:x,onNewModelInputChange:v,onQuickAdd:I,existingModels:s.models}),e.jsx("div",{className:"space-y-2 pt-2",children:A.length===0?e.jsxs("div",{className:"py-12 text-center text-slate-500 bg-[#0A0D14]/60 rounded-xl border border-[#1E293B]",children:[e.jsx("span",{className:"material-symbols-outlined text-3xl mb-1 text-slate-600",children:"filter_list_off"}),e.jsx("p",{className:"text-xs",children:"No models match current filter"}),(h||n!=="all")&&e.jsx("button",{type:"button",onClick:()=>{b(""),m("all")},className:"mt-2 text-xs text-blue-400 hover:underline cursor-pointer",children:"Clear filters"})]}):A.map(({model:t,originalIndex:l})=>e.jsx(K,{model:t,index:l,total:s.models.length,onMoveToTop:R,onMoveUp:$,onMoveDown:_,onMoveToBottom:F,onRemove:P},`${t}-${l}`))})]}),C&&e.jsx(B,{isOpen:C,title:"Delete Combo",message:`Are you sure you want to delete combo "${s.name}"? This action cannot be undone.`,confirmText:"Delete Combo",variant:"danger",onClose:()=>k(!1),onConfirm:z}),y&&e.jsx(B,{isOpen:!!y,title:`Remove ${y} Models`,message:`Remove all models belonging to provider "${y}" from this combo?`,confirmText:"Remove Models",variant:"danger",onClose:()=>N(null),onConfirm:()=>q(y)}),c&&e.jsx(Q,{isOpen:c,onClose:()=>j(!1),title:`Manage Models in ${s.name}`,addedModelValues:s.models,initialSelectedModels:s.models,excludeModelIds:L,onConfirm:O,multiSelect:!0,allowCombos:!1})]})};export{ne as ComboDetailPage};