Lines 1-50javascript
1import{createRequire as PU}from"node:module";var YU=Object.defineProperty;var KU=($)=>$;function XU($,Z){this[$]=KU.bind(null,Z)}var M0=($,Z)=>{for(var J in Z)YU($,J,{get:Z[J],enumerable:!0,configurable:!0,set:XU.bind(Z,J)})};var C=($,Z)=>()=>($&&(Z=$($=0)),Z);var WU=PU(import.meta.url);import{writeFile as HU,rename as UU,unlink as qU}from"fs/promises";import{writeFileSync as MU,renameSync as FU,unlinkSync as NU}from"fs";import{randomBytes as BU}from"crypto";import e9 from"path";function L8($){return e9.join(e9.dirname($),`.${e9.basename($)}.${process.pid}.${BU(4).toString("hex")}.tmp`)}async ...
2 `),J=Lz().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 Cz(){if(Z2("/usr/bin/bwrap"))return"/usr/bin/bwrap";return"/usr/local/bin/bwrap"}function bz($,Z,J){let z=["--die-with-parent","--ro-bind","/","/","--dev","/dev","--proc","/proc"],G=new Set;for(let Q of r2($)){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 l2($){if($==="off"||X5()!=="none")return null;return $==="strict"?"⚠ Command-level sandboxing isn't supported on this platform (requires macOS sandbox-exec or Linux bw ...
15${Fz}`:Mz,P}function i2($){return $==="off"?"off":$==="strict"?"strict":"workspace"}function wz($){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=cU.createInterface({input:process.stdin,output:process.stdout});X.question("\x1B[36m → \x1B[0m",(P)=>{if(X.close(),!J6)process.stdin.pause();K(P.trim()||"(no answer)")})})}async function d$($){let Z=Q6.getStore();if(Z){if(Z.autoApprove)return!0;if(Z.onConfirm)return Z.onConfirm($);return!1}if(O4())return!0;if(!R ...
17\x1B[33m⚠ Rejected (no interactive terminal): ${$}\x1B[0m`),!1;return rU($)}function rU($){return new Promise((Z)=>{Z6.push({message:$,resolve:Z}),pz
18 `)}`);return`${$.length} 个操作待确认(允许将全部执行,拒绝将全部取消):
20`)}`}function tU($){J6?.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`),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`&&!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)
31 → ${$.hint}`:`✖ ${$.message}`;return`✖ ${$ instanceof Error?$.message:String($)}`}function O5($){
32`)}}}function l1(){try{let $=Jq.join(h8(),"package.json"),Z=JSON.parse(Zq($,"utf-8"));return typeof Z.version==="string"
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.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 sq($){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 q=U.trim();if(!q)continue;try{let M=JSON.parse(q);if(z$(M))H.push(bG
40(${$.length-o5} older memories not shown — use memory_search to find them.)`:"";return[Z,...z,G].filter(Boolean).join(`
41`)}function i5($){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 t5(){let $=c5({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:p5({type:"object",properties:{content:{type:"string",description:"The information to remember"},tags:{type:"array",items:{type:"string"},description:"Optional tags for categorizatio ...
43`)}}),J=c5({description:"Delete a memory by its number. Use memory_search first to find the index and scope.",inputSchema:p5({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=rG(G);if(F2(z-1,Q))return`${Q} memory #${z} deleted.`;return`${Q} memory #${z} not foun ...
44`)});function CM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function a8($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0]==="-h")return{ok:!0,lines:[t8]};if(J.length===1){let X=A$(J[0]);if(!X)return{ok:!1,lines:[t8]};return G2(X,z),k8(X),{ok:!0,lines:[`✓ Permission set to ${L4(X)} (${q$(z)})`]}}if(J.length>1)return{ok:!1,lines:[t8]};if($.flagMode)return G2($.flagMode,z),k8($.flagMode),{ok:!0,lines:[`✓ Permission set to ${L4($.flagMode)} (${q$(z)})`]};let G=a2(),Q=G6(),Y=Q??G.permission,K=Q?"cli":G.source;return{ ...
45`)});function bM($){return $==="cli"?"this run":$==="project"?"project":$==="global"?"global":"default"}function e8($){let
46`)});function Z3($){let{scope:Z,rest:J}=l$($.positionals),z=Z??$.scope??"global";if(J[0]==="--help"||J[0
47`)});var zQ={};M0(zQ,{runWriteConfig:()=>wM});async function wM($){let Z=[],J=!0;if($.sandbox!==void 0||$.network!==void 0){let z=i8({positionals:[],flagMode:$.sandbox,flagNetwork:$.network,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.permission!==void 0){let z=a8({positionals:[],flagMode:$.permission,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.think!==void 0){let z=e8({positionals:[],flagEffort:$.think,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if($.memory!==void 0){let z=Z3({positionals:[],flagMode:$.memory,scope:$.scope});if(Z.push(...z.lines),!z.ok)J=!1}if(console. ...
48`)),!J)process.exitCode=1}var GQ=C(()=>{s5();e5();$7();Z7()});function J3($,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 DQ=null;function UF($){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.