min-agent 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/package.json +1 -1
- package/skills/self-config/SKILL.md +1 -1
package/dist/cli.js
CHANGED
|
@@ -27,7 +27,7 @@ ${Z.join(`
|
|
|
27
27
|
|
|
28
28
|
`),J6)J6.resume();else process.stdin.pause();Z(U)};P();let H=(U)=>{Q+=U;while(Q.length>0){if(Q[0]==="\x03"||Q[0]==="\x04"){Q="",W(!1),process.exit(130);return}if(Q[0]==="\x1B"){if(Q[1]==="["){let M=Q.slice(2).search(/[A-Za-z~]/);if(M===-1)return;let F=Q[2+M];Q=Q.slice(3+M),X(F);continue}if(Q[1]==="O"){if(Q.length<3)return;let M=Q[2];Q=Q.slice(3),X(M);continue}if(Q.length===1){setTimeout(()=>{if(Q==="\x1B")Q="",W(!1)},50).unref?.();return}Q=Q.slice(1),W(!1);return}let q=Q[0];if(Q=Q.slice(1),q===`
|
|
29
29
|
`&&!Y)continue;if(q==="\r"||q===`
|
|
30
|
-
`){if(!Y)continue;W(G===0);return}if(q==="y"||q==="Y"){W(!0);return}if(q==="n"||q==="N"){W(!1);return}}};process.stdin.on("data",H)})}function E8($){return[/\brm\s+(-[a-z]*[rf][a-z]*|--recursive|--force)\s/,/\brm\s+-[a-z]*[rf]/,/\bfind\b[^|;&]*\s+-delete\b/,/\bfind\b[^|;&]*\s+-(exec|execdir|ok)\s+rm\b/,/\b(drop|truncate)\s+(table|database|schema)\b/i,/\bdelete\s+from\b/i,/\bmkfs\b/,/\bdd\s+/,/\b(shred|wipefs)\b/,/>+\s*\/dev\/(sd[a-z]+|nvme\d|disk\d)/,/\bformat\b.*\b[a-z]:\b/i,/\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/,/\b(docker|podman)\s+(rm|rmi|prune|system\s+prune)\b/].some((J)=>J.test($))}function A5($){return[/\brm\s+(-[a-z]*[rf][a-z]*|--recursive)\s/,/\bsudo\b/,/\bmkfs\b/,/\bdd\s+/,/\b(shutdown|reboot|halt|poweroff)\b/,/\bgit\s+(
|
|
30
|
+
`){if(!Y)continue;W(G===0);return}if(q==="y"||q==="Y"){W(!0);return}if(q==="n"||q==="N"){W(!1);return}}};process.stdin.on("data",H)})}function E8($){return[/\brm\s+(-[a-z]*[rf][a-z]*|--recursive|--force)\s/,/\brm\s+-[a-z]*[rf]/,/\bfind\b[^|;&]*\s+-delete\b/,/\bfind\b[^|;&]*\s+-(exec|execdir|ok)\s+rm\b/,/\b(drop|truncate)\s+(table|database|schema)\b/i,/\bdelete\s+from\b/i,/\bmkfs\b/,/\bdd\s+/,/\b(shred|wipefs)\b/,/>+\s*\/dev\/(sd[a-z]+|nvme\d|disk\d)/,/\bformat\b.*\b[a-z]:\b/i,/\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/,/\b(docker|podman)\s+(rm|rmi|prune|system\s+prune)\b/].some((J)=>J.test($))}function A5($){return[/\brm\s+(-[a-z]*[rf][a-z]*|--recursive)\s/,/\bsudo\b/,/\bmkfs\b/,/\bdd\s+/,/\b(shutdown|reboot|halt|poweroff)\b/,/\bgit\s+push\b[^|;&]*\s(--force\b|-[a-z]*f[a-z]*\b|--force-with-lease\b)/,/\bgit\s+(reset\s+--hard|clean\s+-[a-z]*f)/,/\bnpm\s+(publish|unpublish)\b/,/\b(drop|truncate)\s+(table|database)\b/i,/\bdelete\s+from\b/i,/\bformat\b.*\b[a-z]:\b/i,/\bfind\b[^|;&]*\s+-delete\b/,/\bfind\b[^|;&]*\s+-(exec|execdir|ok)\s+rm\b/,/\|\s*(ba|z|fi)?sh\b/,/\bchown\s+-R\b/,/\bkill(all)?\s+(-9|-[a-z]*9)/,/\b(pkill|killall)\b/,/\bgit\s+checkout\s+\./,/\bgit\s+stash\s+(drop|clear)\b/,/\b(docker|podman)\s+(rm|prune|system)\b/,/\b(shred|wipefs)\b/,/\b(cp|mv)\s+-[a-z]*f\b/,/[^<>=!&]\s*>>?\s*[^<>=&]|^\s*>>?\s*[^<>=&]/,/:\(\)\s*\{/,/>+\s*\/dev\/(sd[a-z]+|nvme\d|disk\d)/].some((J)=>J.test($))}var cz=!1,V5=!1,T8,Q6,J6=null,R8=null,B5=null,dU=20,Z6,w8=null,I8=!1;var Z$=C(()=>{d();$6();Q6=new nU;Z6=[]});var oz={};M0(oz,{userError:()=>Q1,runtimeError:()=>D5,formatCliError:()=>x8,exitCodeFor:()=>O5,CliError:()=>t});function Q1($,Z){return new t($,{exitCode:1,hint:Z})}function D5($,Z){return new t($,{exitCode:2,hint:Z})}function x8($){if($ instanceof t)return $.hint?`✖ ${$.message}
|
|
31
31
|
→ ${$.hint}`:`✖ ${$.message}`;return`✖ ${$ instanceof Error?$.message:String($)}`}function O5($){if($ instanceof t)return $.exitCode;return 2}var t;var J$=C(()=>{t=class t extends Error{exitCode;hint;constructor($,Z){super($);this.name="CliError",this.exitCode=Z?.exitCode??1,this.hint=Z?.hint}}});import{Option as sD}from"commander";function C5($,Z="global"){if($.project)return"project";if($.global)return"global";return Z}function dz($){let Z=y$($);if(!Z)throw Q1(`Invalid --sandbox value: "${$}"`,"use one of: off, workspace, strict");return Z}function rz($){let Z=o$($);if(!Z)throw Q1(`Invalid --network value: "${$}"`,"use one of: allow, deny");return Z}function lz($){let Z=A$($);if(!Z)throw Q1(`Invalid --permission value: "${$}"`,"use one of: ask, accept-edits, allow-all");return Z}function iz($){let Z=S0($);if(!Z)throw Q1(`Invalid --think value: "${$}"`,"use one of: off, low, medium, high, max");return Z}function tz($){let Z=h0($);if(!Z)throw Q1(`Invalid --memory value: "${$}"`,"use one of: on, off");return Z}function Y6($){return(Z)=>{let J=Number.parseInt(Z,10);if(!Number.isFinite(J)||J<=0)throw Q1(`Invalid ${$} value: "${Z}"`,"use a positive integer");return J}}var g8=C(()=>{u0();d();J$()});import{existsSync as aU,readFileSync as sU}from"fs";import u8 from"path";import{fileURLToPath as eU}from"url";function h8(){let $=u8.dirname(eU(import.meta.url)),Z=$;for(;;){let J=u8.join(Z,"package.json");if(aU(J))try{if(JSON.parse(sU(J,"utf-8")).name===$q)return Z}catch{}let z=u8.dirname(Z);if(z===Z)return u8.resolve($,"..");Z=z}}var $q="min-agent";var b5=()=>{};import{readFileSync as Zq}from"fs";import Jq from"path";import{spawnSync as zq}from"child_process";function Kq(){return[ez,...$G].join(" ")}function Xq($,Z=process.stderr){if(!Z.isTTY)return{stop:()=>{}};let J=0,z=()=>Z.write(`\r${az[J++%az.length]} ${$}`);z();let G=setInterval(z,80);return{stop:(Q)=>{if(clearInterval(G),Z.write("\r\x1B[2K"),Q)Z.write(`${Q}
|
|
32
32
|
`)}}}function l1(){try{let $=Jq.join(h8(),"package.json"),Z=JSON.parse(Zq($,"utf-8"));return typeof Z.version==="string"&&Z.version.length>0?Z.version:"0.0.0"}catch{return"0.0.0"}}function ZG($,Z){let J=$.split("-")[0].split(".").map(Number),z=Z.split("-")[0].split(".").map(Number);for(let G=0;G<Math.max(J.length,z.length);G++){let Q=J[G]??0,Y=z[G]??0,K=Number.isFinite(Q)?Q:0,X=Number.isFinite(Y)?Y:0;if(K!==X)return K-X}return 0}function Pq($){if(typeof $!=="string"||!Qq.test($))return null;return $}async function JG($=fetch){let Z;try{Z=await $(Gq,{signal:AbortSignal.timeout(Yq),headers:{Accept:"application/json"}})}catch{return null}if(!Z.ok)return null;let J;try{J=await Z.json()}catch{return null}if(!J||typeof J!=="object"||!("version"in J))return null;return Pq(J.version)}async function zG($){let Z=$?.currentVersion??l1(),J=await JG($?.fetchFn);return{current:Z,latest:J,updateAvailable:J!==null&&ZG(Z,J)<0}}function Wq(){let $=zq(ez,[...$G],{stdio:"inherit",shell:process.platform==="win32",env:process.env});if($.error)return{ok:!1,missing:$.error.code==="ENOENT"};return{ok:$.status===0}}async function GG($={}){let Z=$.log??((P)=>console.log(P)),J=$.error??((P)=>console.error(P)),z=$.spinner??Xq,G=$.currentVersion?.()??l1(),Q=Kq();Z(`当前版本: ${G}`);let Y=z("正在检查最新版本…"),K=$.fetchLatest?await $.fetchLatest():await JG();if(Y.stop(),!K)return J(`无法检查新版本(网络不可用)。请稍后重试,或手动执行: ${Q}`),{status:"check-failed",current:G,latest:null};if(ZG(G,K)>=0)return Z(`已是最新版本 (${K})`),{status:"up-to-date",current:G,latest:K};Z(`发现新版本: ${K}(当前 ${G})`),Z(`正在安装,可能需要一会儿…(${Q})`);let X=($.install??Wq)();if(!X.ok){if(X.missing)J(`未找到 npm。请先安装 Node.js,然后执行: ${Q}`);else J(`自动升级失败。请手动执行: ${Q}`);return{status:"install-failed",current:G,latest:K}}return Z(`✓ 已升级到 ${K}`),{status:"updated",current:G,latest:K}}var sz="min-agent",Gq,ez="npm",$G,Qq,Yq=1e4,az;var K6=C(()=>{b5();Gq=`https://registry.npmjs.org/${sz}/latest`,$G=["install","-g",sz],Qq=/^\d+\.\d+\.\d+/;az=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"]});import{readFileSync as Hq,mkdirSync as Uq,existsSync as qq}from"fs";import WG from"path";function Bq(){let $=process.env.MIN_AGENT_MODELS_API_URL?.trim();if(!$)return Mq;return $.replace(/\/$/,"")}function HG(){return WG.join(H0(),"model-catalog-cache.json")}function UG(){let $=HG();if(!qq($))return{};try{return JSON.parse(Hq($,"utf-8"))}catch{return{}}}function Vq($){let Z=HG();Uq(WG.dirname(Z),{recursive:!0}),T0(Z,JSON.stringify($))}function Q2($){let Z=R5.get($);if(Z&&Z.version===T5&&Date.now()-Z.timestamp<=QG)return Z;let J=UG()[$];if(!J||J.version!==T5||Date.now()-J.timestamp>QG)return null;return R5.set($,J),J}function fq($,Z){R5.set($,Z);let J=UG();J[$]=Z,Vq(J)}function i1($){return Boolean($)&&typeof $==="object"&&!Array.isArray($)}function qG($){if(!Array.isArray($))return{toggle:!1,efforts:[]};let Z=!1,J=new Set;for(let z of $){if(!i1(z))continue;if(z.type==="toggle")Z=!0;if(z.type==="effort"&&Array.isArray(z.values)){for(let G of z.values)if(typeof G==="string"&&G&&G!=="default")J.add(G)}}if(J.has("none"))Z=!0;return{toggle:Z,efforts:[...J]}}function _q($,Z){let J=Z.toLowerCase(),z=$.find((Q)=>Q.id.toLowerCase()===J);if(z)return z;let G=$.find((Q)=>{let Y=Q.id.toLowerCase();return Y.endsWith(`/${J}`)||J.endsWith(`/${Y}`)});if(G)return G;return $.find((Q)=>Q.name?.toLowerCase()===J)}function Lq($,Z){if(!Z||$.length===0)return;let J="";try{J=new URL(Z).hostname.toLowerCase()}catch{return}return $.find((z)=>{let G=String(z.providerId??"").toLowerCase().replace(/_/g,"-");if(!G)return!1;if(J.includes(G))return!0;let Q=G.split("-")[0]??"";return Q.length>=4&&J.includes(Q)})}function Aq($){return $.efforts.some((Z)=>{let J=S0(Z);return Boolean(J&&J!=="off")})}function Dq($){let Z=$.map((W)=>qG(W.reasoningOptions)).filter((W)=>W.toggle||W.efforts.length>0);if(Z.length===0)return{toggle:!1,efforts:[]};let J=Z.filter(Aq),z=Z.length/2,G=J.length===0?Number.POSITIVE_INFINITY:J.length/2,Q=0,Y=0,K=new Map;for(let W of Z)if(W.toggle||W.efforts.includes("none"))Q++;for(let W of J){let H=new Set;for(let U of W.efforts){if(U==="xhigh"||U==="extra-high")Y++;let q=S0(U);if(!q||q==="off"||H.has(q))continue;H.add(q),K.set(q,(K.get(q)??0)+1)}}let X=Q>=z,P=[];if(X)P.push("none");for(let W of jq)if((K.get(W)??0)>=G)P.push(W);if(P.includes("max")&&Y>0)P.push("xhigh");return{toggle:X,efforts:P}}function KG($){let Z=$?.context;if(typeof Z==="number"&&Number.isFinite(Z)&&Z>=4096)return Math.floor(Z);return}function Oq($,Z,J){let z=$.offerings??[],G=Lq(z,J),Q=G?qG(G.reasoningOptions):Dq(z),Y=KG(G?.limit)??KG($.limit);return{version:T5,modelId:Z,lonaeId:$.id,...Y!=null?{contextWindow:Y}:{},reasoning:Q,timestamp:Date.now()}}async function I5($){try{let Z=await fetch($,{signal:AbortSignal.timeout(Nq)});if(!Z.ok)return null;return await Z.json()}catch{return null}}function XG($){let Z=i1($)?$:null,J=Z&&i1(Z.data)?Z.data:Z;if(!J||typeof J.id!=="string")return null;let z=i1(J.limit)?{context:typeof J.limit.context==="number"?J.limit.context:void 0}:void 0,G=Array.isArray(J.offerings)?J.offerings.filter(i1).map((Q)=>({providerId:typeof Q.providerId==="string"?Q.providerId:void 0,limit:i1(Q.limit)?{context:typeof Q.limit.context==="number"?Q.limit.context:void 0}:void 0,reasoningOptions:Q.reasoningOptions})):[];return{id:J.id,limit:z,reasoning:J.reasoning===!0,offerings:G}}function Cq($){let Z=i1($)?$:null;return(Z&&Array.isArray(Z.data)?Z.data:Array.isArray($)?$:[]).flatMap((z)=>{if(!i1(z)||typeof z.id!=="string")return[];return[{id:z.id,name:typeof z.name==="string"?z.name:void 0,context:typeof z.context==="number"?z.context:void 0}]})}function PG($){return $.split("/").map((Z)=>encodeURIComponent(Z)).join("/")}async function bq($){let Z=Bq();if($.includes("/")){let G=XG(await I5(`${Z}/api/v1/models/${PG($)}`));if(G)return G}let J=Cq(await I5(`${Z}/api/v1/models?q=${encodeURIComponent($)}&page_size=20`)),z=_q(J,$);if(!z)return null;return XG(await I5(`${Z}/api/v1/models/${PG(z.id)}`))}async function m8($,Z){let J=Q2($);if(J)return J;let z=YG.get($);if(z!==void 0&&Date.now()-z<=Fq)return null;let G=w5.get($);if(G)return G;let Q=bq($).then((Y)=>{if(!Y)return YG.set($,Date.now()),null;let K=Oq(Y,$,Z);return fq($,K),K});w5.set($,Q);try{return await Q}finally{w5.delete($)}}var Mq="https://models.lonae.com",QG=604800000,T5=3,Fq=3600000,Nq=1e4,R5,w5,YG,jq;var k5=C(()=>{L$();d();R5=new Map,w5=new Map,YG=new Map;jq=["low","medium","high","max"]});import{readFileSync as wq,mkdirSync as Iq,existsSync as Tq}from"fs";import NG from"path";function K2($){return Boolean($)&&typeof $==="object"&&!Array.isArray($)}function c8($){return $.replace(/\/$/,"").replace(/\/v1$/i,"")}function VG($,Z){let J="";try{J=new URL($).hostname.toLowerCase()}catch{J=c8($).toLowerCase()}let z=Z.trim().toLowerCase();return J?`${J}::${z}`:z}function Y2($){let Z=typeof $==="string"&&$.trim()!==""?Number($):$;if(typeof Z!=="number"||!Number.isFinite(Z)||Z<BG)return;return Math.floor(Z)}function yq($){let Z=[];for(let[J,z]of Object.entries($))if(J==="context_length"||J.endsWith(".context_length")){let G=Y2(z);if(G!=null)Z.push(G)}if(Z.length===0)return;return Math.max(...Z)}function Sq($){if(typeof $==="number")return Y2($);if(K2($))return Y2($.num_ctx);if(typeof $!=="string")return;let Z=$.match(/(?:^|\n)\s*num_ctx\s+(\d+)/);if(Z?.[1])return Y2(Number(Z[1]));return Y2($)}function Eq($){if(!Array.isArray($))return null;return $.some((Z)=>String(Z).toLowerCase()==="thinking")}function vq($,Z){if($!=null)return $;if(Z!=null)return Math.min(Z,E5);return}function fG($,Z){let J=K2($.options)?$.options:{};return{...$,options:{...J,num_ctx:Z}}}function _G($,Z){if(Z===!1)return!1;if(!$)return;if(!$.thinkingEnabled)return!1;let J=$.reasoningEffort;if(J==="low"||J==="medium"||J==="high")return J;if(J==="none")return!1;return"high"}function LG($,Z){let J=r(z0());if(typeof J?.contextWindow==="number"&&Number.isFinite(J.contextWindow)&&J.contextWindow>=BG)return Math.floor(J.contextWindow);return t1($,Z??J?.baseURL)?.contextWindow??n8}function xq($,Z){let J=K2($)?$:{},z=K2(J.model_info)?J.model_info:{},G=vq(Sq(J.parameters),yq(z));return{version:X6,modelId:Z,...G!=null?{contextWindow:G}:{},thinking:Eq(J.capabilities),timestamp:Date.now()}}function jG($){if($.thinking===!1)return["off"];return["off","low","medium","high","max"]}function AG(){return NG.join(H0(),"ollama-model-cache.json")}function DG(){let $=AG();if(!Tq($))return{};try{let Z=JSON.parse(wq($,"utf-8"));if(!K2(Z))return{};let J={};for(let[z,G]of Object.entries(Z)){if(!K2(G)||G.version!==X6)continue;if(typeof G.modelId!=="string")continue;let Q=G.thinking===!0||G.thinking===!1?G.thinking:null,Y=Y2(G.contextWindow),K=typeof G.timestamp==="number"?G.timestamp:0;J[z]={version:X6,modelId:G.modelId,...Y!=null?{contextWindow:Y}:{},thinking:Q,timestamp:K}}return J}catch{return{}}}function gq($){let Z=AG();Iq(NG.dirname(Z),{recursive:!0}),T0(Z,JSON.stringify($))}function t1($,Z){let J=VG(Z??"",$),z=S5.get(J);if(z&&z.version===X6&&Date.now()-z.timestamp<=MG)return z;let G=DG()[J];if(!G||G.version!==X6||Date.now()-G.timestamp>MG)return null;return S5.set(J,G),G}function uq($,Z){S5.set($,Z);let J=DG();J[$]=Z,gq(J)}async function hq($,Z){try{let J=await fetch(`${c8($)}/api/show`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Z}),signal:AbortSignal.timeout(kq)});if(!J.ok)return null;return await J.json()}catch{return null}}async function P6($,Z){let J=Z??"",z=VG(J,$),G=t1($,J);if(G)return G;let Q=FG.get(z);if(Q!==void 0&&Date.now()-Q<=Rq)return null;let Y=y5.get(z);if(Y)return Y;let K=hq(J,$).then((X)=>{if(!X)return FG.set(z,Date.now()),null;let P=xq(X,$);return uq(z,P),P});y5.set(z,K);try{return await K}finally{y5.delete(z)}}var X6=2,MG=604800000,Rq=3600000,kq=8000,BG=512,n8=2048,E5=32768,S5,y5,FG;var p8=C(()=>{d();L$();S5=new Map,y5=new Map,FG=new Map});function z$($){return Boolean($)&&typeof $==="object"&&!Array.isArray($)}function mq($){return typeof $==="string"?$:$ instanceof URL?$.href:$.url}function nq($){try{return/\/chat\/completions\/?$/i.test(new URL($).pathname)}catch{return/\/chat\/completions\/?$/i.test($)}}function cq($){let Z=$.replace(/\/v1\/chat\/completions\/?$/i,"").replace(/\/chat\/completions\/?$/i,"");return`${c8(Z)}/api/chat`}async function wG($){if($==null)return null;if(typeof $==="string")return $;if($ instanceof Uint8Array)return new TextDecoder().decode($);if($ instanceof ArrayBuffer)return new TextDecoder().decode($);if(Buffer?.isBuffer($))return $.toString("utf8");if(typeof Blob<"u"&&$ instanceof Blob)return await $.text();if(typeof ReadableStream<"u"&&$ instanceof ReadableStream){let Z=$.getReader(),J=[];for(;;){let{done:Y,value:K}=await Z.read();if(Y)break;if(K)J.push(K)}let z=J.reduce((Y,K)=>Y+K.length,0),G=new Uint8Array(z),Q=0;for(let Y of J)G.set(Y,Q),Q+=Y.length;return new TextDecoder().decode(G)}return null}function pq($){return $.match(/^data:[^;]+;base64,(.+)$/s)?.[1]??null}function oq($){if(typeof $==="string")return{text:$,images:[]};if(!Array.isArray($))return{text:$==null?"":JSON.stringify($),images:[]};let Z=[],J=[];for(let z of $){if(!z$(z))continue;if(z.type==="text"&&typeof z.text==="string")Z.push(z.text);else if(z.type==="image_url"){let G=z$(z.image_url)?z.image_url.url:void 0;if(typeof G==="string"){let Q=pq(G);if(Q)J.push(Q)}}else if(typeof z.text==="string")Z.push(z.text)}return{text:Z.join(`
|
|
33
33
|
`),images:J}}function dq($){if(z$($))return $;if(typeof $!=="string"||!$.trim())return{};try{let Z=JSON.parse($);return z$(Z)?Z:{value:Z}}catch{return{value:$}}}function rq($){if(typeof $==="string")return $;try{return JSON.stringify($??{})}catch{return"{}"}}function lq($){if(!Array.isArray($)||$.length===0)return;return $.map((Z)=>{let J=z$(Z)?Z:{},z=z$(J.function)?J.function:J;return{function:{name:typeof z.name==="string"?z.name:"",arguments:dq(z.arguments)}}})}function iq($){if(!Array.isArray($))return[];return $.map((Z)=>{let J=z$(Z)?Z:{},{text:z,images:G}=oq(J.content),Q={role:typeof J.role==="string"?J.role:"user",content:z};if(G.length>0)Q.images=G;let Y=lq(J.tool_calls);if(Y)Q.tool_calls=Y;return Q})}function tq($){let Z=z$($.options)?{...$.options}:{};if(typeof $.temperature==="number")Z.temperature=$.temperature;if(typeof $.top_p==="number")Z.top_p=$.top_p;if(typeof $.seed==="number")Z.seed=$.seed;if(typeof $.max_tokens==="number")Z.num_predict=$.max_tokens;if(typeof $.max_completion_tokens==="number")Z.num_predict=$.max_completion_tokens;if(Array.isArray($.stop)||typeof $.stop==="string")Z.stop=$.stop;return Z}function aq($,Z){let J={model:$.model,messages:iq($.messages),stream:$.stream!==!1,options:tq($)};if(Array.isArray($.tools)&&$.tools.length>0)J.tools=$.tools;if($.format!=null)J.format=$.format;if(Z.think!==void 0)J.think=Z.think;return fG(J,Z.numCtx)}function IG($,Z){if(Array.isArray(Z)&&Z.length>0)return"tool_calls";if($==="length"||$==="max_tokens")return"length";return"stop"}function TG($){let Z=typeof $.prompt_eval_count==="number"?$.prompt_eval_count:void 0,J=typeof $.eval_count==="number"?$.eval_count:void 0;if(Z==null&&J==null)return;let z=Z??0,G=J??0;return{prompt_tokens:z,completion_tokens:G,total_tokens:z+G}}function RG($){if(!Array.isArray($)||$.length===0)return;return $.map((Z,J)=>{let z=z$(Z)?Z:{},G=z$(z.function)?z.function:z,Q=typeof z.id==="string"&&z.id?z.id:`ollama_call_${J}`;return{index:J,id:Q,type:"function",function:{name:typeof G.name==="string"?G.name:"",arguments:rq(G.arguments)}}})}function OG($,Z){let J=z$($.message)?$.message:{},z=typeof J.content==="string"?J.content:"",G=typeof J.thinking==="string"?J.thinking:"",Q=RG(J.tool_calls),Y=$.done===!0,K={};if(!Z.sentRole)K.role="assistant",Z.sentRole=!0;if(G)K.reasoning=G;if(z)K.content=z;if(Q)K.tool_calls=Q;let X={id:"chatcmpl-ollama",object:"chat.completion.chunk",created:Math.floor(Date.now()/1000),model:typeof $.model==="string"?$.model:"",choices:[{index:0,delta:K,finish_reason:Y?IG($.done_reason,J.tool_calls):null}]},P=TG($);if(P)X.usage=P;return X}function CG($){let Z=z$($.message)?$.message:{},J=typeof Z.content==="string"?Z.content:"",z=typeof Z.thinking==="string"?Z.thinking:"",G=RG(Z.tool_calls),Q={role:"assistant",content:J};if(z)Q.reasoning=z;if(G)Q.tool_calls=G;let Y={id:"chatcmpl-ollama",object:"chat.completion",created:Math.floor(Date.now()/1000),model:typeof $.model==="string"?$.model:"",choices:[{index:0,message:Q,finish_reason:IG($.done_reason,Z.tool_calls)}]},K=TG($);if(K)Y.usage=K;return Y}function bG($){return`data: ${JSON.stringify($)}
|
package/package.json
CHANGED
|
@@ -80,7 +80,7 @@ Instructions...
|
|
|
80
80
|
|
|
81
81
|
- Rules: edit the files in the table above. `/reload` reloads rules only, not MCP.
|
|
82
82
|
- Memory: **off** by default. Config `memory` is `on` | `off` (`true`/`enable` → on, `false`/`disable` → off). Project overlays global; writing `memory` globally also removes a project `memory` overlay. When off, memories are not injected and `memory_save` / `memory_search` / `memory_delete` are not registered (takes effect next turn after you change the file). CLI `min-agent memory on|off` / `--memory` follow the same write-vs-this-run rule as permission. `/memory on|off` writes **global** by default (and clears a project overlay); `/memory --project` writes only the project file. `/memory` lists the switch plus stored entries; `/memory <text>` still writes `memory.json` even when off. Default save scope is project when `.min-agent/` exists. Shape: `{ "content": string, "tags": string[], "created": ISO string }` array. When on, memories are injected each turn as background reference, not as work to resume. Do not store secrets or API keys. HTTP: `GET/POST /v1/memory/mode`, chat body `memory`, and `GET /v1/memory` include `memory` / `source` / `label`.
|
|
83
|
-
- Permission: `accept-edits` (default) | `ask` | `allow-all` in config `permission`. CLI `min-agent permission …` / `--permission` without a message writes config and exits; with a message it is this session only. `--yes` is this session only and does not write config. `min-agent exec` (one-shot) uses a permissive default when neither `--permission` nor `--yes` is given: file edits and ordinary commands run without asking, and only genuinely destructive commands (deleting files/dirs, `drop`/`truncate`/`delete from`, `mkfs`/`dd`/raw-device writes, `shred`/`wipefs`, `git reset --hard`/`git clean -f`, `docker rm`/`prune`, `find … -delete`/`-exec rm`) still prompt. An explicit `--permission` (or `--yes`) overrides this and behaves exactly as in interactive sessions (`allow-all` runs even destructive commands silently). Confirmation prompts are coalesced: when several actions in one step need approval, a single overlay lists them all and one allow/deny decision applies to the whole batch instead of stacking separate prompts.
|
|
83
|
+
- Permission: `accept-edits` (default) | `ask` | `allow-all` in config `permission`. CLI `min-agent permission …` / `--permission` without a message writes config and exits; with a message it is this session only. `--yes` is this session only and does not write config. `min-agent exec` (one-shot) uses a permissive default when neither `--permission` nor `--yes` is given: file edits and ordinary commands run without asking, and only genuinely destructive commands (deleting files/dirs, `drop`/`truncate`/`delete from`, `mkfs`/`dd`/raw-device writes, `shred`/`wipefs`, `git reset --hard`/`git clean -f`, `docker rm`/`prune`, `find … -delete`/`-exec rm`) still prompt. An explicit `--permission` (or `--yes`) overrides this and behaves exactly as in interactive sessions (`allow-all` runs even destructive commands silently). In `ask` / `accept-edits`, "dangerous commands" that still prompt do NOT include ordinary `git push`, `git stash`/`git stash pop`, `git rebase`, or `chmod` — only their harmful forms count: force pushes (`git push --force`/`-f`/`--force-with-lease`) and `git stash drop`/`git stash clear` (plus `git reset --hard`, `git clean -f`, `git checkout .`, `rm -r/-f`, `sudo`, disk/db operations, etc.). Confirmation prompts are coalesced: when several actions in one step need approval, a single overlay lists them all and one allow/deny decision applies to the whole batch instead of stacking separate prompts.
|
|
84
84
|
- Thinking intensity: `off` | `low` | `medium` | `high` | `max` in config `thinking`. Omit the field to use **medium**, then clamp to levels the current model actually exposes (from the model catalog). `/think` opens an interactive picker of those English levels and writes **global** config; that also clears a project `thinking` overlay so a leftover project `off` cannot hide the new value after restart. `/think --project` writes only the project file. Typed `/think off|low|medium|high|max` still works when the model supports that value. `min-agent think …` / `--think` follow the same write-vs-this-run rule as permission. `xhigh` / `extra-high` / `none` are accepted as aliases (`xhigh` → `max`, `none` → `off`). Each request maps that intensity onto the current model and gateway (MiniMax uses `adaptive`/`disabled`; official OpenAI omits `thinking` and maps `max` to `xhigh`; an `ollama` provider uses native chat with `think` plus the configured window). Learned mappings are cached in `~/.min-agent/thinking-wire-cache.json` for 7 days. Per-model context window and supported effort values are loaded from the model catalog (`https://models.lonae.com`, override with `MIN_AGENT_MODELS_API_URL`) and cached in `~/.min-agent/model-catalog-cache.json` for 7 days after a successful lookup. When the provider host is unknown, effort levels are the majority across offerings that actually list efforts (toggle-only rows do not vote), so a single gateway cannot invent `medium`. An `ollama` provider skips that catalog and uses native `POST /api/show` instead (whether the model advertises thinking, plus the loaded window: Modelfile `num_ctx` if set, otherwise the architecture length capped at 32768). Chat completions are sent to native `POST /api/chat` so `options.num_ctx` and `think` actually apply — the OpenAI-compatible `/v1` endpoint ignores both. `/ctx` opens a picker of `2k` / `4k` / `8k` / `12k` / `16k` / `32k` / `64k` / `128k` / `256k` / `auto` and writes the active provider's `contextWindow` (global only; providers are not in project config). Typed `/ctx 8k` and CLI `min-agent ctx 8k` do the same; `auto` clears the override. The menu item is hidden unless the active provider is ollama. Results are cached in `~/.min-agent/ollama-model-cache.json` for 7 days.
|
|
85
85
|
- Sandbox default is **off**. `mode`: `off` | `workspace` | `strict`. Optional `network`, `extraWriteRoots`, `extraReadRoots`. Isolation is independent of permission. `--sandbox` / `--network` without a message write config and exit.
|
|
86
86
|
|