@marsapi/cli 0.0.161 → 0.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as t,existsSync as r,readFileSync as e}from"fs";import{join as n}from"path";import{i18n as o}from"../i18n.js";import{prettyModelName as i}from"../gateway-models.js";import{getAgyRules as a}from"../model-registry.js";import{logger as l}from"../../utils/logger.js";import{readPersistentEnvFile as s,removePersistentEnv as c,writePersistentEnv as u}from"../persistent-env.js";import{backupBeforeWrite as p,atomicWriteFile as g}from"./backup.js";import{findInstalls as d,mirrorInstallCommand as m}from"./tool-installs.js";import{toolHome as y}from"./types.js";import{brand as f,PROVIDER_KEY as v}from"../brand.js";const A="agy",_="
|
|
1
|
+
import{chmodSync as t,existsSync as r,readFileSync as e}from"fs";import{join as n}from"path";import{i18n as o}from"../i18n.js";import{prettyModelName as i}from"../gateway-models.js";import{getAgyRules as a}from"../model-registry.js";import{logger as l}from"../../utils/logger.js";import{readPersistentEnvFile as s,removePersistentEnv as c,writePersistentEnv as u}from"../persistent-env.js";import{backupBeforeWrite as p,atomicWriteFile as g}from"./backup.js";import{findInstalls as d,mirrorInstallCommand as m}from"./tool-installs.js";import{toolHome as y}from"./types.js";import{brand as f,PROVIDER_KEY as v}from"../brand.js";const A="agy",_="AGY_LLM_GATEWAY_URL",h="AGY_LLM_GATEWAY_API_KEY",E="AGY_LLM_GATEWAY_MODELS",j=["GEMINI_API_KEY","GOOGLE_GEMINI_BASE_URL"],w="gemini",K=()=>n(y(),".gemini","antigravity-cli"),b=()=>n(K(),"settings.json"),I=()=>n(K(),`${v}.env`),P=()=>n(y(),".antigravity","settings.json"),M=f().installMirror?.agy,G={command:"agy",native:{binDir:"win32"===process.platform?["AppData","Local","agy","bin"]:[".local","bin"],updateArgs:["update"],dataDirs:[]},...M?{mirrorScript:{sh:`${M}/install.sh`,ps1:`${M}/install.ps1`}}:{}};function L(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function C(t,n){if(!r(t))return{};const o=e(t,"utf-8");if(!o.trim())return{};try{const t=JSON.parse(o);if(!L(t))throw new Error(`${n} root must be an object`);return t}catch(t){throw new Error(`Existing ${n} cannot be parsed; back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}}const N=()=>C(b(),"~/.gemini/antigravity-cli/settings.json"),S=()=>C(P(),"~/.antigravity/settings.json");function Y(r,e,n){p(r),g(r,JSON.stringify(e,null,2)+"\n",n),void 0!==n&&t(r,n)}function $(t){return(t||"").replace(/\/+$/,"").replace(/\/v1(beta)?$/,"")}function k(t){const r=a().gatewayModels,e=t?r.filter(r=>t.models.includes(r)):[];return e.length>0?e:r}const O=t=>i(t.replace(/-preview$/,""));function x(t){const r=t.gateway;return L(r)&&!0===r.enabled&&"string"==typeof r.apiKey&&r.apiKey.trim()&&"string"==typeof r.url?{url:r.url,apiKey:r.apiKey}:null}function U(t){const r=t.models;return L(r)&&Array.isArray(r.list)?r.list.map(t=>L(t)&&"string"==typeof t.modelId?t.modelId:"").filter(Boolean):[]}function D(){try{if(N().modelProvider!==w)return null}catch{return null}const t=s(I()),r=t.GEMINI_API_KEY;return r&&r.trim()?{apiKey:r,url:t.GOOGLE_GEMINI_BASE_URL??""}:null}function R(t){const r=s(I());return r[_]===t.url&&r[h]===t.apiKey}function T(t,r,e){const n=N(),o=S();o.gateway={...L(o.gateway)?o.gateway:{},enabled:!0,url:r,apiKey:t,wireProtocol:"genai"},o.models={...L(o.models)?o.models:{},defaultModelId:e[0],list:e.map(t=>({modelId:t,displayName:O(t),supportsThinking:!0}))},Y(P(),o,384),j.some(t=>void 0!==s(I())[t])&&c(A,I(),j);const i=u(A,I(),{[_]:r,[h]:t,[E]:e.join(",")}).rcFiles;for(const t of j)delete process.env[t];return n.modelProvider===w&&(delete n.modelProvider,Y(b(),n)),i}let B=null,W=null;export const antigravityAdapter={name:"agy",displayName:"Antigravity CLI",command:"agy",installCommand:m(G),installSpec:G,configPath:P(),wantsModelCatalog:!0,loadPrivateConfig(t){N(),S();const r=k(t.catalog);B=T(t.apiKey,$(t.baseUrl),r),W=r},unloadPrivateConfig(){try{const t=S();x(t)&&(delete t.gateway,delete t.models,Y(P(),t,384))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}try{const t=N();t.modelProvider===w&&(delete t.modelProvider,Y(b(),t))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}c(A,I(),[_,h,E,...j])},detectCurrentConfig(){try{const t=x(S());if(t)return{apiKey:t.apiKey}}catch{return{apiKey:null}}return{apiKey:D()?.apiKey??null}},listedModels(){try{const t=S(),r=x(t);if(r)return R(r)?U(t):[]}catch{return null}return D()?[]:null},refreshModelMenu(t){const r=S(),e=x(r)??D();if(!e)return;const n=k(t.catalog),o=e.url||$(t.baseUrl),i=x(r);null!==i&&R(i)&&U(r).join(",")===n.join(",")&&s(I())[E]===n.join(",")&&null===D()||T(e.apiKey,o,n)},getConfig(){try{return S()}catch(t){return l.logError("antigravityAdapter.getConfig",t),null}},applyNotes(){const t=[];if(W&&W.length>0){const r=W.map(O);t.push({kind:"summary",text:o.t("tools.agy.menu_written",{count:String(r.length),list:r.join(o.t("tools.grok.list_separator")),default:r[0]})})}return null===B||0===d(G).length||t.push({kind:"action",text:o.t("tools.agy.open_new_terminal")}),t},backupPaths:()=>[P(),b(),I()],forceResetPaths:()=>[I()]};
|
package/dist/locales/en_US.json
CHANGED
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
"version_outdated": "version {{current}} is too old (needs {{min}} or later); upgrade with {{upgrade}}",
|
|
375
375
|
"agy": {
|
|
376
376
|
"menu_written": "{{count}} models in the menu ({{list}}), default {{default}}",
|
|
377
|
-
"
|
|
377
|
+
"open_new_terminal": "Run agy in a new terminal: terminals already open do not see the new settings"
|
|
378
378
|
},
|
|
379
379
|
"grok": {
|
|
380
380
|
"menu_written": "{{count}} models in the menu ({{list}}), default {{default}}",
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -374,7 +374,7 @@
|
|
|
374
374
|
"version_outdated": "版本 {{current}} 过旧,需要 {{min}} 或更高版本,运行 {{upgrade}} 升级",
|
|
375
375
|
"agy": {
|
|
376
376
|
"menu_written": "模型菜单共 {{count}} 个({{list}}),默认 {{default}}",
|
|
377
|
-
"
|
|
377
|
+
"open_new_terminal": "在新开的终端里运行 agy;已打开的终端读不到新配置"
|
|
378
378
|
},
|
|
379
379
|
"grok": {
|
|
380
380
|
"menu_written": "模型菜单共 {{count}} 个({{list}}),默认 {{default}}",
|