(q)
| 5097 | |
| 5098 | This policy spec defines how to determine the prefix of a ${z} command:`]),userPrompt:J?`Command: ${q}`:`${Y} |
| 5099 | |
| 5100 | Command: ${q}`,signal:K,options:{enablePromptCaching:J,querySource:A,agents:[],isNonInteractiveSession:_,hasAppendSystemPrompt:!1,mcpTools:[]}});clearTimeout(w);let X=Date.now()-j,P=typeof M.message.content==="string"?M.message.content:Array.isArray(M.message.content)?M.message.content.find((W)=>W.type==="text")?.text??"none":"none";if(so(P))d($,{success:!1,error:"API error",durationMs:X}),H=null;else if(P==="command_injection_detected")d($,{success:!1,error:"command_injection_detected",durationMs:X}),H={commandPrefix:null};else if(P==="git"||H$Y.has(P.toLowerCase()))d($,{success:!1,error:"dangerous_shell_prefix",durationMs:X}),H={commandPrefix:null};else if(P==="none")d($,{success:!1,error:'prefix "none"',durationMs:X}),H={commandPrefix:null};else if(!q.startsWith(P))d($,{success:!1,error:"command did not start with prefix",durationMs:X}),H={commandPrefix:null};else d($,{success:!0,durationMs:X}),H={commandPrefix:P};return H}catch(J){throw clearTimeout(w),J}}async function M$Y(q,K,_,z,Y){let $=await Y(q),[A,...O]=await Promise.all([z(q,K,_),...$.map(async(j)=>({subcommand:j,prefix:await z(j,K,_)}))]);if(!A)return null;let w=O.reduce((j,{subcommand:H,prefix:J})=>{if(J)j.set(H,J);return j},new Map);return{...A,subcommandPrefixes:w}}var H$Y;var MZK=y(()=>{x3();o1();k8();ew();SC();VB();l8();H$Y=new Set(["sh","bash","zsh","fish","csh","tcsh","ksh","dash","cmd","cmd.exe","powershell","powershell.exe","pwsh","pwsh.exe","bash.exe"])});import{randomBytes as X$Y}from"crypto";function PZK(){let q=X$Y(8).toString("hex");return{SINGLE_QUOTE:`__SINGLE_QUOTE_${q}__`,DOUBLE_QUOTE:`__DOUBLE_QUOTE_${q}__`,NEW_LINE:`__NEW_LINE_${q}__`,ESCAPED_OPEN_PAREN:`__ESCAPED_OPEN_PAREN_${q}__`,ESCAPED_CLOSE_PAREN:`__ESCAPED_CLOSE_PAREN_${q}__`}}function P$Y(q){if(/[\s'"]/.test(q))return!1;if(q.length===0)return!1;if(q.startsWith("#"))return!1;return!q.startsWith("!")&&!q.startsWith("=")&&!q.includes("$")&&!q.includes("`")&&!q.includes("*")&&!q.includes("?")&&!q.includes("[")&&!q.includes("{")&&!q.includes("~")&&!q.includes("(")&&!q.includes("<")&&!q.startsWith("&")}function LV6(q){let K=[],_=PZK(),{processedCommand:z,heredocs:Y}=Dq6(q),$=z.replace(/\\+\n/g,(j)=>{let H=j.length-1;if(H%2===1)return"\\".repeat(H-1);else return j}),A=q.replace(/\\+\n/g,(j)=>{let H=j.length-1;if(H%2===1)return"\\".repeat(H-1);return j}),O=o$($.replaceAll('"',`"${_.DOUBLE_QUOTE}`).replaceAll("'",`'${_.SINGLE_QUOTE}`).replaceAll(` |
| 5101 | `,` |
| 5102 | ${_.NEW_LINE} |
no test coverage detected