Lines 1-71javascript
1import{createRequire as tH}from"node:module";var oH=Object.create;var{getPrototypeOf:rH,defineProperty:X5,getOwnPropertyNames:dH}=Object;var lH=Object.prototype.hasOwnProperty;var iH=($,Z,J)=>{J=$!=null?oH(rH($)):{};let z=Z||!$||!$.__esModule?X5(J,"default",{value:$,enumerable:!0}):J;for(let G of dH($))if(!lH.call(z,G))X5(z,G,{get:()=>$[G],enumerable:!0});return z};var U0=($,Z)=>{for(var J in Z)X5($,J,{get:Z[J],enumerable:!0,configurable:!0,set:(z)=>Z[J]=()=>z})};var O=($,Z)=>()=>($&&(Z=$($=0)),Z);var aH=tH(import.meta.url);import{writeFile as sH,rename as eH,unlink as $q}from"fs/promises";imp ...
2 `),J=vz().map((G)=>`(subpath ${wz(L0.resolve(G))})`).join(`
3 `),z=$.network==="deny"?"(deny network*)":"";return`(version 1)
6(allow file-write-data (literal "/dev/null"))
14`}function nz(){if(Z2("/usr/bin/bwrap"))return"/usr/bin/bwrap";return"/usr/local/bin/bwrap"}function cz($,Z,J){let z=["--die-with-parent","--ro-bind","/","/","--dev","/dev","--proc","/proc"],G=new Set;for(let Q of i2($)){let Y=process.platform==="win32"?Q.toLowerCase():Q;if(G.has(Y))continue;if(G.add(Y),Z2(Q))z.push("--bind",Q,Q)}if($.network==="deny")z.push("--unshare-net");return z.push("--chdir",Z,"/bin/sh","-c",J),z}function t2($){if($==="off"||V5()!=="none")return null;return $==="strict"?"⚠ Command-level sandboxing isn't supported on this platform (requires macOS sandbox-exec or Linux bw ...
15${Iz}`:Tz,X}function a2($){return $==="off"?"off":$==="strict"?"strict":"workspace"}function mz($){return $===
16\x1B[33m❓ ${z} (no interactive terminal — skipped)\x1B[0m`),null;if(console.log(),console.log(`\x1B[33m❓ ${z}\x1B[0m`),Q){for(let K=0;K<Q.length;K++)console.log(`\x1B[90m ${K+1}. ${Q[K]}\x1B[0m`);if(J)console.log("\x1B[90m (可勾选多项;最后一项可自己输入)\x1B[0m")}return new Promise((K)=>{let f=Iq.createInterface({input:process.stdin,output:process.stdout});f.question("\x1B[36m → \x1B[0m",(X)=>{if(f.close(),!G6)process.stdin.pause();K(X.trim()||"(no answer)")})})}async function r$($){let Z=K6.getStore();if(Z){if(Z.autoApprove)return!0;if(Z.onConfirm)return Z.onConfirm($);return!1}if(b4())return!0;if(!S ...
17\x1B[33m⚠ Rejected (no interactive terminal): ${$}\x1B[0m`),!1;return Eq($)}function Eq($){return new Promise((Z)=>{z6.push({message:$,resolve:Z}),QG()})}function
18 `)}`);return`${$.length} 个操作待确认(允许将全部执行,拒绝将全部取消):
20`)}`}function gq($){G6?.pause(),process.stdout.write(`
21\x1B[90m┌─ 即将执行 ─────────────────────────────────\x1B[0m
22`);for(let Z of $.split(`
23`))process.stdout.write(`\x1B[90m│\x1B[0m ${Z}
24`);return process.stdout.write(`\x1B[90m└────────────────────────────────────────────\x1B[0m
25`),process.stdout.write(`
26`),new Promise((Z)=>{let J=process.stdin.isRaw,z=process.stdin.readableEncoding;if(process.stdin.isTTY)process.stdin.setRawMode(!0);process.stdin.resume(),process.stdin.setEncoding("utf8");let G=1
28`),G6)G6.resume();else process.stdin.pause();Z(H)};X();let W=(H)=>{Q+=H;while(Q.length>0){if(Q[0]==="\x03"||Q[0]==="\x04"){Q="",P(!1),process.exit(130);return}if(Q[0]==="\x1B"){if(Q[1]==="["){let U=Q.slice(2).search(/[A-Za-z~]/);if(U===-1)return;let F=Q[2+U];Q=Q.slice(3+U),f(F);continue}if(Q[1]==="O"){if(Q.length<3)return;let U=Q[2];Q=Q.slice(3),f(U);continue}if(Q.length===1){setTimeout(()=>{if(Q==="\x1B")Q="",P(!1)},50).unref?.();return}Q=Q.slice(1),P(!1);return}let q=Q[0];if(Q=Q.slice(1),q===`
29`&&!Y)continue;if(q==="\r"||q===`
30`){if(!Y)continue;P(G===0);return}if(q==="y"||q==="Y"){P(!0);return}if(q==="n"||q==="N"){P(!1);return}}};process.stdin.on("data",W)})}function u8($){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)
31 → ${$.hint}`:`✖ ${$.message}`;return`✖ ${$ instanceof Error?$.message:String($)}`}function v5($){
32`)}}}function i1(){try{let $=mq.join(p8(),"package.json"),Z=JSON.parse(cq($,"utf-8"));return typeof Z.version==="string"
33`),images:J}}function hU($){if(z$($))return $;if(typeof $!=="string"||!$.trim())return{};try{let Z=JSON.parse($);return z$(Z)?Z:{value:Z}}catch{return{value:$}}}function nU($){if(typeof $==="string")return $;try{return JSON.stringify($??{})}catch{return"{}"}}function cU($){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:hU(z.arguments)}}})}function mU($){if(!Array.isArray($))return[];return $.map((Z)=>{let J=z$(Z)?Z:{},{text:z,images:G}=uU(J.content),Q={role:typeof J.r ...
HighCommand Output Exfiltration
Source combines command execution, command-output handling, and outbound requests; review data flow before blocking.
dist/cli.jsView on unpkg · L19 HighTrigger Reachable Command Output Exfiltration
A manifest entrypoint or package-local install chain reaches command-output exfiltration behavior.
dist/cli.jsView on unpkg · L19 HighSame File Env Network Execution
A single source file combines environment access, network access, and code or shell execution; review context before blocking.
dist/cli.jsView on unpkg · L30 35`}function rU($){let Z=new TextDecoder,J=new TextEncoder,z=$.getReader(),G={sentRole:!1},Q="";return new ReadableStream({
37`)),Y.close();return}Q+=Z.decode(f,{stream:!0});let X=Q.lastIndexOf(`
38`);if(X<0)continue;let P=Q.slice(0,X+1);Q=Q.slice(X+1);let W
39`)){let q=H.trim();if(!q)continue;try{let U=JSON.parse(q);if(z$(U))W.push(JQ
40(${$.length-K7} older memories not shown — use memory_search to find them.)`:"";return[Z,...z,G].filter(Boolean).join(`
41`)}function W7($){if(!X1($))return"";let Z=O$("project"),J=O$("global");if(Z.length===0&&J.length===0)return"";let z=["## Memories","Background facts from previous conversations. Use them to personalize replies. They are not pending tasks and not a request to act.","Do not call APIs, run commands, or continue old work based on memories unless the current user message explicitly asks.","Do not use remembered credentials or API keys unless this message asks you to perform that action.","You can save new memories with the memory_save tool when the user tells you something worth remembering (prefe ...
42`)}function H7(){let $=Q7({description:"Save a memory for future conversations. Use this when the user shares preferences, project conventions, important context, or asks you to remember something. Memories persist across sessions and are injected as background reference, not as work to resume. Do not store secrets, API keys, or passwords. Use scope project for this repository, global for all projects.",inputSchema:Y7({type:"object",properties:{content:{type:"string",description:"The information to remember"},tags:{type:"array",items:{type:"string"},description:"Optional tags for categorizatio ...
43`)}}),J=Q7({description:"Delete a memory by its number. Use memory_search first to find the index and scope.",inputSchema:Y7({type:"object",properties:{index:{type:"number",description:"The memory number to delete (1-based)"},scope:{type:"string",enum:["global","project"],description:"Which store the number belongs to. Defaults to project when .min-agent exists, otherwise global. Project requires .min-agent/ in cwd (created by min-agent init)."}},required:["index"]}),execute:async({index:z,scope:G})=>{let Q=_Q(G);if(F2(z-1,Q))return`${Q} memory #${z} deleted.`;return`${Q} memory #${z} not foun ...
44`)});function DM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function Y3($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0]==="-h")return{ok:!0,lines:[Q3]};if(J.length===1){let f=D$(J[0]);if(!f)return{ok:!1,lines:[Q3]};return G2(f,z),v8(f),{ok:!0,lines:[`✓ Permission set to ${L4(f)} (${U$(z)})`]}}if(J.length>1)return{ok:!1,lines:[Q3]};if($.flagMode)return G2($.flagMode,z),v8($.flagMode),{ok:!0,lines:[`✓ Permission set to ${L4($.flagMode)} (${U$(z)})`]};let G=e2(),Q=Y6(),Y=Q??G.permission,K=Q?"cli":G.source;return{ ...
45`)});function AM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function f3($){let
46`)});function P3($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0
47`)});var IQ={};U0(IQ,{runWriteConfig:()=>bM});async function bM($){let Z=[],J=!0;if($.sandbox!==void 0||$.network!==void 0){let z=G3({positionals:[],flagMode:$.sandbox,flagNetwork:$.network,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.permission!==void 0){let z=Y3({positionals:[],flagMode:$.permission,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.think!==void 0){let z=f3({positionals:[],flagEffort:$.think,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.memory!==void 0){let z=P3({positionals:[],flagMode:$.memory,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if(console. ...
48`)),!J)process.exitCode=1}var kQ=O(()=>{U7();M7();F7();N7()});function W3($,Z,J){let z=$===
49`)?1:0);if(W>0)f+=`\x1B[${W}A\x1B[${X.column}G`,Z=W}let P=typeof z==="string"?f:Buffer.from(f,G||"utf-8");return $.write(P,G,Q)};return new Proxy($,{get(z,G){if(G==="write")return J;let Q=Reflect.get(z,G,z);return typeof Q==="function"?Q.bind(z):Q},set(z,G,Q){return Reflect.set(z,G,Q,z)}})}var aQ=null;function XF($){return $>=768&&$<=879||$>=1155&&$<=1161||$>=1425&&$<=1469||$>=1552&&$<=1562||$>=1611&&$<=1631||$>=3633&&$<=3642||$>=3655&&$<=3662||$>=6832&&$<=6911||$>=7616&&$<=7679||$>=8203&&$<=8207||$>=8288&&$<=8292||$>=8400&&$<=8447||$>=65024&&$<=65039||$>=65056&&$<=65071||$===65279||$>=917760& ...
50`);for(let Y=0;Y<Q.length;Y++){for(let K of a0(Q[Y],Z,J))z.push({
51`)z--;return z+1}function V6($,Z){let J=Array.from($),z=Z;while(z<J.length&&J[z]
52`)z++;return z}function JY($,Z){let J=B6($,Z);if(J===Z)return{value:$,caretIndex:Z};let z=Array.
53 set tmpFile to POSIX file "${$}"
55 set imgData to the clipboard as «class PNGf»
56 set fp to open for access tmpFile with write permission
63 `;if(I1(`osascript -e '${Z.replace(/'/g,"'\\''")}'`,{encoding:"utf-8"}).trim()==="ok"){let z=l7($);if(z)return{data:z,mimeType:"image/png"}}}catch{}return null}function RF(){try{let $=I1("xclip -selection clipboard -t image/png -o 2>/dev/null",{maxBuffer:10485760});if($.length>0)return{data:$,mimeType:"image/png"}}catch{}try{let $=I1("xsel --clipboard --output 2>/dev/null",{maxBuffer:10485760});if($.length>8&&$[0]===137&&$[1]===80)return{data:$,mimeType:"image/png"}}catch{}return null}function yF(){let $=bY();try{let Z=`
64 Add-Type -AssemblyName System.Windows.Forms
65 $img = [System.Windows.Forms.Clipboard]::GetImage()
66 if ($img) { $img.Save('${$.replace(/\\/g,"\\\\")}', [System.Drawing.Imaging.ImageFormat]::Png); Write-Output 'ok' }
67 else { Write-Output 'no_image' }
68 `;if(I1(`powershell -NoProfile -Command "${Z}"`,{encoding:"utf-8"}).trim()==="ok"){let z=l7($);if(z)return{data:z,mimeType:"image/png"}}}catch{}return null}var w3=()=>{};function TY($,Z){let J=[],z=$+Z;while(!0){let G=z.indexOf("\x1B[200~");if(G===-1)return{buffer:J.length>0?z:EF(z),pastes:J,active:!1};let Q=z.slice(G+6),Y=Q.indexOf("\x1B[201~");if(Y===-1)return{buffer:"\x1B[200~"+Q,pastes:J,active:!0};J.push(Q.slice(0,Y)),z=Q.slice(Y+6)}}function IY($,Z){if(Z)return!0;return $.includes("\x1B[200~")||$.includes("\x1B[201~")||$.includes("[200~")||$.includes("[201~")}function EF($){let Z=$.l ...
71`)?Z.slice(0,-1):Z}function kY($,Z){let J=pF(Z);if(J.length>
Long lines were clipped for display.