Lines 1-50javascript
1import{createRequire as Xq}from"node:module";var Qq=Object.defineProperty;var Yq=($)=>$;function Kq($,Z){this[$]=Yq.bind(null,Z)}var M0=($,Z)=>{for(var J in Z)Qq($,J,{get:Z[J],enumerable:!0,configurable:!0,set:Kq.bind(Z,J)})};var C=($,Z)=>()=>($&&(Z=$($=0)),Z);var Pq=Xq(import.meta.url);import{writeFile as Wq,rename as Hq,unlink as qq}from"fs/promises";import{writeFileSync as Uq,renameSync as Mq,unlinkSync as Fq}from"fs";import{randomBytes as Nq}from"crypto";import a9 from"path";function f8($){return a9.join(a9.dirname($),`.${a9.basename($)}.${process.pid}.${Nq(4).toString("hex")}.tmp`)}async ...
2 `),J=_z().map((G)=>`(subpath ${qz(L0.resolve(G))})`).join(`
3 `),z=$.network==="deny"?"(deny network*)":"";return`(version 1)
6(allow file-write-data (literal "/dev/null"))
14`}function Oz(){if(s4("/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 d2($)){let Y=process.platform==="win32"?Q.toLowerCase():Q;if(G.has(Y))continue;if(G.add(Y),s4(Q))z.push("--bind",Q,Q)}if($.network==="deny")z.push("--unshare-net");return z.push("--chdir",Z,"/bin/sh","-c",J),z}function r2($){if($==="off"||Y5()!=="none")return null;return $==="strict"?"⚠ Command-level sandboxing isn't supported on this platform (requires macOS sandbox-exec or Linux bw ...
15${Mz}`:Uz,P}function l2($){return $==="off"?"off":$==="strict"?"strict":"workspace"}function bz($){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 X=cq.createInterface({input:process.stdin,output:process.stdout});X.question("\x1B[36m → \x1B[0m",(P)=>{if(X.close(),!Z6)process.stdin.pause();K(P.trim()||"(no answer)")})})}async function d$($){let Z=G6.getStore();if(Z){if(Z.autoApprove)return!0;if(Z.onConfirm)return Z.onConfirm($);return!1}if(A4())return!0;if(!I ...
17\x1B[33m⚠ Rejected (no interactive terminal): ${$}\x1B[0m`),!1;return dq($)}function dq($){return new Promise((Z)=>{$6.push({message:$,resolve:Z}),nz()})}function
18 `)}`);return`${$.length} 个操作待确认(允许将全部执行,拒绝将全部取消):
20`)}`}function iq($){Z6?.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`),Z6)Z6.resume();else process.stdin.pause();Z(q)};P();let H=(q)=>{Q+=q;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 U=Q[0];if(Q=Q.slice(1),U===`
29`&&!Y)continue;if(U==="\r"||U===`
30`){if(!Y)continue;W(G===0);return}if(U==="y"||U==="Y"){W(!0);return}if(U==="n"||U==="N"){W(!1);return}}};process.stdin.on("data",H)})}function y8($){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 A5($){
32`)}}}function r1(){try{let $=ZU.join(g8(),"package.json"),Z=JSON.parse($U($,"utf-8"));return typeof Z.version===
33`),images:J}}function oU($){if(J$($))return $;if(typeof $!=="string"||!$.trim())return{};try{let Z=JSON.parse($);return J$(Z)?Z:{value:Z}}catch{return{value:$}}}function dU($){if(typeof $==="string")return $;try{return JSON.stringify($??{})}catch{return"{}"}}function rU($){if(!Array.isArray($)||$.length===0)return;return $.map((Z)=>{let J=J$(Z)?Z:{},z=J$(J.function)?J.function:J;return{function:{name:typeof z.name==="string"?z.name:"",arguments:oU(z.arguments)}}})}function lU($){if(!Array.isArray($))return[];return $.map((Z)=>{let J=J$(Z)?Z:{},{text:z,images:G}=pU(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 aU($){let Z=new TextDecoder,J=new TextEncoder,z=$.getReader(),G={sentRole:!1},Q="";return new ReadableStream({
37`)),Y.close();return}Q+=Z.decode(X,{stream:!0});let P=Q.lastIndexOf(`
38`);if(P<0)continue;let W=Q.slice(0,P+1);Q=Q.slice(P+1);let H
39`)){let U=q.trim();if(!U)continue;try{let M=JSON.parse(U);if(J$(M))H.
40(${$.length-n5} older memories not shown — use memory_search to find them.)`:"";return[Z,...z,G].filter(Boolean).join(`
41`)}function r5($){if(!X1($))return"";let Z=C$("project"),J=C$("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 l5(){let $=m5({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:c5({type:"object",properties:{content:{type:"string",description:"The information to remember"},tags:{type:"array",items:{type:"string"},description:"Optional tags for categorizatio ...
43`)}}),J=m5({description:"Delete a memory by its number. Use memory_search first to find the index and scope.",inputSchema:c5({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=dG(G);if(U2(z-1,Q))return`${Q} memory #${z} deleted.`;return`${Q} memory #${z} not foun ...
44`)});function OM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function i8($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0]==="-h")return{ok:!0,lines:[l8]};if(J.length===1){let X=A$(J[0]);if(!X)return{ok:!1,lines:[l8]};return J2(X,z),T8(X),{ok:!0,lines:[`✓ Permission set to ${f4(X)} (${U$(z)})`]}}if(J.length>1)return{ok:!1,lines:[l8]};if($.flagMode)return J2($.flagMode,z),T8($.flagMode),{ok:!0,lines:[`✓ Permission set to ${f4($.flagMode)} (${U$(z)})`]};let G=t2(),Q=z6(),Y=Q??G.permission,K=Q?"cli":G.source;return{ ...
45`)});function CM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function a8($){let
46`)});function e8($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0
47`)});var JQ={};M0(JQ,{runWriteConfig:()=>bM});async function bM($){let Z=[],J=!0;if($.sandbox!==void 0||$.network!==void 0){let z=r8({positionals:[],flagMode:$.sandbox,flagNetwork:$.network,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.permission!==void 0){let z=i8({positionals:[],flagMode:$.permission,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.think!==void 0){let z=a8({positionals:[],flagEffort:$.think,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.memory!==void 0){let z=e8({positionals:[],flagMode:$.memory,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if(console. ...
48`)),!J)process.exitCode=1}var zQ=C(()=>{t5();a5();s5();e5()});function $3($,Z,J){let z=$===
49`)?1:0);if(H>0)X+=`\x1B[${H}A\x1B[${P.column}G`,Z=H}let W=typeof z==="string"?X:Buffer.from(X,G||"utf-8");return $.write(W,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 HF($){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({
Long lines were clipped for display.