MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / pQ

Function pQ

package/cli.js:2967–2967  ·  view source on GitHub ↗
(q,K,_,z)

Source from the content-addressed store, hash-verified

2965`,irz,rrz,orz,CYK=2000,srz=1000,trz=15000,erz,bYK="Enterprise policy requires sandboxing, but sandboxing is not available on native Windows. Shell command execution is blocked on this platform by policy.",o68,IYK,_oz,zoz,Yoz,mj6;var xL6=y(()=>{x7();v8();k8();Bq();vK6();b68();m8();y8();U7();E8();vK();wI8();tN();K$();TK6();B68();GL6();Ij();ZL6();kw6();IG();IL6();fI8();NI8();Q68();UzK();TYK();kYK();RL6();hYK();qs1=O6(D6(),1),irz=new Set(["select-string","get-childitem","findstr","where.exe"]),rrz=new Set(["get-content","get-item","test-path","resolve-path","get-process","get-service","get-childitem","get-location","get-filehash","get-acl","format-hex"]),orz=new Set(["write-output","write-host"]);erz=["start-sleep","sleep"];o68=i6(process.env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS),IYK=B6(()=>L.strictObject({command:L.string().describe("The PowerShell command to execute"),timeout:eN(L.number().optional()).describe(`Optional timeout in milliseconds (max ${r68()})`),description:L.string().optional().describe("Clear, concise description of what this command does in active voice."),run_in_background:BX(L.boolean().optional()).describe("Set to true to run this command in the background. Use Read to read the output later."),dangerouslyDisableSandbox:BX(L.boolean().optional()).describe("Set this to true to dangerously override sandbox mode and run commands without sandboxing.")})),_oz=B6(()=>o68?IYK().omit({run_in_background:!0}):IYK()),zoz=B6(()=>L.object({stdout:L.string().describe("The standard output of the command"),stderr:L.string().describe("The standard error output of the command"),interrupted:L.boolean().describe("Whether the command was interrupted"),returnCodeInterpretation:L.string().optional().describe("Semantic interpretation for non-error exit codes with special meaning"),isImage:L.boolean().optional().describe("Flag to indicate if stdout contains image data"),persistedOutputPath:L.string().optional().describe("Path to persisted full output when too large for inline"),persistedOutputSize:L.number().optional().describe("Total output size in bytes when persisted"),backgroundTaskId:L.string().optional().describe("ID of the background task if command is running in background"),backgroundedByUser:L.boolean().optional().describe("True if the user manually backgrounded the command with Ctrl+B"),assistantAutoBackgrounded:L.boolean().optional().describe("True if the command was auto-backgrounded by the assistant-mode blocking budget")})),Yoz=["npm","yarn","pnpm","node","python","python3","go","cargo","make","docker","terraform","webpack","vite","jest","pytest","curl","Invoke-WebRequest","build","test","serve","watch","dev"];mj6=sq({name:s9,searchHint:"execute Windows PowerShell commands",maxResultSizeChars:30000,strict:!0,async description({description:q}){return q||"Run PowerShell command"},async prompt(){return vYK()},isConcurrencySafe(q){return this.isReadOnly?.(q)??!1},isSearchOrReadCommand(q){if(!q.command)return{isSearch:!1,isRead:!1};return arz(q.command)},isReadOnly(q){if(qYK(q.command))return!1;return SI8(q.command)},toAutoClassifierInput(q){return q.command},get inputSchema(){return _oz()},get outputSchema(){return zoz()},userFacingName(){return"PowerShell"},getToolUseSummary(q){if(!q?.command)return null;let{command:K,description:_}=q;if(_)return _;return d5(K,PN)},getActivityDescription(q){if(!q?.command)return"Running command";return`Running ${q.description??d5(q.command,PN)}`},isEnabled(){return!0},async validateInput(q){if(xYK())return{result:!1,message:bYK,errorCode:11};return{result:!0}},async checkPermissions(q,K){return await GYK(q,K)},renderToolUseMessage:NYK,renderToolUseProgressMessage:yYK,renderToolUseQueuedMessage:EYK,renderToolResultMessage:LYK,renderToolUseErrorMessage:RYK,mapToolResultToToolResultBlockParam({interrupted:q,stdout:K,stderr:_,isImage:z,persistedOutputPath:Y,persistedOutputSize:$,backgroundTaskId:A,backgroundedByUser:O,assistantAutoBackgrounded:w},j){if(z){let X=TI8(K,j);if(X)return X}let H=K;if(Y){let X=K?K.replace(/^(\s*\n)+/,"").trimEnd():"",P=Xa6(X,WN6);H=DN6({filepath:Y,originalSize:$??0,isJson:!1,preview:P.preview,hasMore:P.hasMore})}else if(K)H=K.replace(/^(\s*\n)+/,""),H=H.trimEnd();let J=_.trim();if(q){if(_)J+=SYK;J+="<error>Command was aborted before completion</error>"}let M="";if(A){let X=sz(A);if(w)M=`Command exceeded the assistant-mode blocking budget (${trz/1000}s) and was moved to the background with ID: ${A}. It is still running — you will be notified when it completes. Output is being written to: ${X}. In assistant mode, delegate long-running work to a subagent or use run_in_background to keep this conversation responsive.`;else if(O)M=`Command was manually backgrounded by user with ID: ${A}. Output is being written to: ${X}`;else M=`Command running in background with ID: ${A}. Output is being written to: ${X}`}return{tool_use_id:j,type:"tool_result",content:[H,J,M].filter(Boolean).join(`
2966`),is_error:q}},async call(q,K,_,z,Y){if(xYK())throw Error(bYK);let{abortController:$,setAppState:A,setToolJSX:O}=K,w=!K.agentId,j=0;try{let H=$oz({input:q,abortController:$,setAppState:K.setAppStateForTasks??A,setToolJSX:O,preventCwdChanges:!w,isMainThread:w,toolUseId:K.toolUseId,agentId:K.agentId}),J;do if(J=await H.next(),!J.done&&Y){let I=J.value;Y({toolUseID:`ps-progress-${j++}`,data:{type:"powershell_progress",output:I.output,fullOutput:I.fullOutput,elapsedTimeSeconds:I.elapsedTimeSeconds,totalLines:I.totalLines,totalBytes:I.totalBytes,timeoutMs:I.timeoutMs,taskId:I.taskId}})}while(!J.done);let M=J.value;if(!(M.code===0&&!M.stdout&&M.stderr&&!M.backgroundTaskId))yI8(q.command,M.code,M.stdout);let P=M.interrupted&&$.signal.reason==="interrupt",W="";if(w){let I=K.getAppState();if(VI8(I.toolPermissionContext))W=kI8("")}if(M.backgroundTaskId){let I=C68(M.stdout||"",q.command);if(w&&I.hints.length>0)for(let B of I.hints)x68(B);return{data:{stdout:I.stripped,stderr:[M.stderr||"",W].filter(Boolean).join(`
2967`),interrupted:!1,backgroundTaskId:M.backgroundTaskId,backgroundedByUser:M.backgroundedByUser,assistantAutoBackgrounded:M.assistantAutoBackgrounded}}}let D=new kp6,f=(M.stdout||"").trimEnd();D.append(f+SYK);let G=FzK(q.command,M.code,f,M.stderr||""),Z=GI8(D.toString()),T=C68(Z,q.command);if(Z=T.stripped,w&&T.hints.length>0)for(let I of T.hints)x68(I);if(M.preSpawnError)throw Error(M.preSpawnError);if(G.isError&&!P)throw new AE(Z,M.stderr||"",M.code,M.interrupted);let v=67108864,V,E;if(M.outputFilePath&&M.outputTaskId)try{let I=await crz(M.outputFilePath);E=I.size,await Cw6();let B=Ma6(M.outputTaskId,!1);if(I.size>v)await lrz(M.outputFilePath,v);try{await nrz(M.outputFilePath,B)}catch{await drz(M.outputFilePath,B)}V=B}catch{}let S=U68(Z),R=Z;if(S){let I=await vI8(Z,M.outputFilePath,E);if(I)R=I;else S=!1}let x=[M.stderr||"",W].filter(Boolean).join(`
2968`);return d("tengu_powershell_tool_command_executed",{command_type:FI8(q.command),stdout_length:R.length,stderr_length:x.length,exit_code:M.code,interrupted:M.interrupted}),{data:{stdout:R,stderr:x,interrupted:M.interrupted,returnCodeInterpretation:G.message,isImage:S,persistedOutputPath:V,persistedOutputSize:E}}}finally{if(O)O(null)}},isResultTruncated(q){return UC(q.stdout)||UC(q.stderr)}})});import{randomUUID as Aoz}from"crypto";async function pQ(q,K,_,z){let Y=q,$=z==="powershell"&&Rk6()?Ooz():R4,A=q.matchAll(woz),O=q.includes("!`")?q.matchAll(joz):[];return await Promise.all([...A,...O].map(async(w)=>{let j=w[1]?.trim();if(j)try{let H=await uX($,{command:j},K,nG({content:[]}),"");if(H.behavior!=="allow")throw N(`Shell command permission check failed for command in ${_}: ${j}. Error: ${H.message}`),new zB(`Shell command permission check failed for pattern "${w[0]}": ${H.message||"Permission denied"}`);let{data:J}=await $.call({command:j},K),M=await fN6($,J,Aoz()),X=typeof M.content==="string"?M.content:uYK(J.stdout,J.stderr);Y=Y.replace(w[0],()=>X)}catch(H){if(H instanceof zB)throw H;Hoz(H,w[0])}})),Y}function uYK(q,K,_=!1){let z=[];if(q.trim())z.push(q.trim());if(K.trim())if(_)z.push(`[stderr: ${K.trim()}]`);else z.push(`[stderr]
2969${K.trim()}`);return z.join(_?" ":`
2970`)}function Hoz(q,K,_=!1){if(q instanceof AE){if(q.interrupted)throw new zB(`Shell command interrupted for pattern "${K}": [Command interrupted]`);let $=uYK(q.stdout,q.stderr,_);throw new zB(`Shell command failed for pattern "${K}": ${$}`)}let z=d6(q),Y=_?`[Error: ${z}]`:`[Error]

Callers 2

getPromptForCommandFunction · 0.85

Calls 12

Rk6Function · 0.85
uXFunction · 0.85
nGFunction · 0.85
NFunction · 0.85
fN6Function · 0.85
uYKFunction · 0.85
HozFunction · 0.85
matchAllMethod · 0.80
includesMethod · 0.80
callMethod · 0.80
trimMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected