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

Function onProgress

package/cli.js:2963–2963  ·  view source on GitHub ↗
(F,U,c,K6,t)

Source from the content-addressed store, hash-verified

2961 - Before running destructive operations (e.g., git reset --hard, git push --force, git checkout --), consider whether there is a safer alternative that achieves the same goal. Only use destructive operations when they are truly the best approach.
2962 - Never skip hooks (--no-verify) or bypass signing (--no-gpg-sign, -c commit.gpgsign=false) unless the user has explicitly asked for it. If a hook fails, investigate and fix the underlying issue.`}var kYK=y(()=>{m8();m68();GL6();IY();E2();qM()});function NYK(q,{verbose:K,theme:_}){let{command:z}=q;if(!z)return null;let Y=z;if(!K){let $=Y.split(`
2963`),A=$.length>VYK,O=Y.length>ea1;if(A||O){let w=Y;if(A)w=$.slice(0,VYK).join(`
2964`);if(w.length>ea1)w=w.slice(0,ea1);return h_.createElement(k,null,w.trim(),"…")}}return Y}function yYK(q,{verbose:K,tools:_,terminalSize:z,inProgressToolCallCount:Y}){let $=q.at(-1);if(!$||!$.data)return h_.createElement(s8,{height:1},h_.createElement(k,{dimColor:!0},"Running…"));let A=$.data;return h_.createElement(kL6,{fullOutput:A.fullOutput,output:A.output,elapsedTimeSeconds:A.elapsedTimeSeconds,totalLines:A.totalLines,totalBytes:A.totalBytes,timeoutMs:A.timeoutMs,taskId:A.taskId,verbose:K})}function EYK(){return h_.createElement(s8,{height:1},h_.createElement(k,{dimColor:!0},"Waiting…"))}function LYK(q,K,{verbose:_,theme:z,tools:Y,style:$}){let O=K.at(-1)?.data?.timeoutMs,{stdout:w,stderr:j,interrupted:H,returnCodeInterpretation:J,isImage:M,backgroundTaskId:X}=q;if(M)return h_.createElement(s8,{height:1},h_.createElement(k,{dimColor:!0},"[Image data detected and sent to Claude]"));return h_.createElement(u,{flexDirection:"column"},w!==""?h_.createElement(uL,{content:w,verbose:_}):null,j.trim()!==""?h_.createElement(uL,{content:j,verbose:_,isError:!0}):null,w===""&&j.trim()===""?h_.createElement(s8,{height:1},h_.createElement(k,{dimColor:!0},X?h_.createElement(h_.Fragment,null,"Running in the background"," ",h_.createElement(t8,{shortcut:"↓",action:"manage",parens:!0})):H?"Interrupted":J||"(No output)")):null,O?h_.createElement(s8,null,h_.createElement(Hj6,{timeoutMs:O})):null)}function RYK(q,{verbose:K,progressMessagesForMessage:_,tools:z}){return h_.createElement(Y2,{result:q,verbose:K})}var h_,VYK=2,ea1=160;var hYK=y(()=>{rK();bN();gK();Vw6();DI8();xb8();s6();h_=O6(D6(),1)});var UI8={};T8(UI8,{detectBlockedSleepPattern:()=>Koz,PowerShellTool:()=>mj6});import{copyFile as drz,stat as crz,truncate as lrz,link as nrz}from"fs/promises";function arz(q){let K=q.trim();if(!K)return{isSearch:!1,isRead:!1};let _=K.split(/\s*[;|]\s*/).filter(Boolean);if(_.length===0)return{isSearch:!1,isRead:!1};let z=!1,Y=!1,$=!1;for(let A of _){let O=A.trim().split(/\s+/)[0];if(!O)continue;let w=PY(O);if(orz.has(w))continue;$=!0;let j=irz.has(w),H=rrz.has(w);if(!j&&!H)return{isSearch:!1,isRead:!1};if(j)z=!0;if(H)Y=!0}if(!$)return{isSearch:!1,isRead:!1};return{isSearch:z,isRead:Y}}function qoz(q){let K=q.trim().split(/\s+/)[0];if(!K)return!0;let _=PY(K);return!erz.includes(_)}function Koz(q){let K=q.trim().split(/[;|&\r\n]/)[0]?.trim()??"",_=/^(?:start-sleep|sleep)(?:\s+-s(?:econds)?)?\s+(\d+)\s*$/i.exec(K);if(!_)return null;let z=parseInt(_[1],10);if(z<2)return null;let Y=q.trim().slice(K.length).replace(/^[\s;|&]+/,"");return Y?`Start-Sleep ${z} followed by: ${Y}`:`standalone Start-Sleep ${z}`}function xYK(){return Z1()==="windows"&&M7.isSandboxEnabledInSettings()&&!M7.areUnsandboxedCommandsAllowed()}function FI8(q){let _=q.trim().split(/\s+/)[0]||"";for(let z of Yoz)if(_.toLowerCase()===z.toLowerCase())return z;return"other"}async function*$oz({input:q,abortController:K,setAppState:_,setToolJSX:z,preventCwdChanges:Y,isMainThread:$,toolUseId:A,agentId:O}){let{command:w,description:j,timeout:H,run_in_background:J,dangerouslyDisableSandbox:M}=q,X=Math.min(H||gI8(),r68()),P="",W="",D=0,f=0,G=void 0,Z=!1,T=!1,v=null;function V(){return new Promise((F)=>{v=()=>F(null)})}let E=!o68&&qoz(w);if(!await Pa())return{stdout:"",stderr:"PowerShell is not available on this system.",code:0,interrupted:!1};let R;try{R=await TL6(w,K.signal,"powershell",{timeout:X,onProgress(F,U,c,K6,t){W=F,P=U,D=c,f=t?K6:0},preventCwdChanges:Y,shouldUseSandbox:Z1()==="windows"?!1:Gb({command:w,dangerouslyDisableSandbox:M}),shouldAutoBackground:E})}catch(F){return H6(F),{stdout:"",stderr:`Failed to execute PowerShell command: ${d6(F)}`,code:0,interrupted:!1}}let x=R.result;async function I(){return(await QI8({command:w,description:j||w,shellCommand:R,toolUseId:A,agentId:O},{abortController:K,getAppState:()=>{throw Error("getAppState not available in runPowerShellCommand context")},setAppState:_})).taskId}function B(F,U){if(g){if(!cI8(g,R,j||w,_,A))return;G=g,d(F,{command_type:FI8(w)}),U?.(g);return}I().then((c)=>{G=c;let K6=v;if(K6)v=null,K6();if(d(F,{command_type:FI8(w)}),U)U(c)})}if(R.onTimeout&&E)R.onTimeout((F)=>{B("tengu_powershell_command_timeout_backgrounded",F)});if(J===!0&&!o68){let F=await I();return d("tengu_powershell_command_explicitly_backgrounded",{command_type:FI8(w)}),{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:F}}JO.startPolling(R.taskOutput.taskId);let p=Date.now(),C=p+CYK,g=void 0;try{while(!0){let F=Date.now(),U=Math.max(0,C-F),c=V(),K6=await Promise.race([x,new Promise((e)=>setTimeout((i)=>i(null),U,e).unref()),c]);if(K6!==null){if(K6.backgroundTaskId!==void 0){lI8(K6.backgroundTaskId,_);let e={...K6,backgroundTaskId:void 0},{taskOutput:i}=R;if(i.stdoutToFile&&!i.outputFileRedundant)e.outputFilePath=i.path,e.outputFileSize=i.outputFileSize,e.outputTaskId=i.taskId;return R.cleanup(),e}return K6}if(G)return{stdout:Z?P:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:G,assistantAutoBackgrounded:T};if(K.signal.aborted&&K.signal.reason==="interrupt"&&!Z){if(Z=!0,!o68){B("tengu_powershell_command_interrupt_backgrounded");continue}R.kill()}if(g){if(R.status==="backgrounded")return{stdout:"",stderr:"",code:0,interrupted:!1,backgroundTaskId:g,backgroundedByUser:!0}}let t=Date.now()-p,q6=Math.floor(t/1000);if(!o68&&G===void 0&&q6>=CYK/1000&&z){if(!g)g=dI8({command:w,description:j||w,shellCommand:R,agentId:O},_,A);z({jsx:qs1.createElement(NL6,null),shouldHidePromptInput:!1,shouldContinueAnimation:!0,showSpinner:!0})}yield{type:"progress",fullOutput:P,output:W,elapsedTimeSeconds:q6,totalLines:D,totalBytes:f,taskId:R.taskOutput.taskId,...H?{timeoutMs:X}:void 0},C=Date.now()+srz}}finally{if(JO.stopPolling(R.taskOutput.taskId),!G&&R.status!=="backgrounded"){if(g)nI8(g,_);R.cleanup()}}}var qs1,SYK=`
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(`

Callers

nothing calls this directly

Calls 1

UFunction · 0.85

Tested by

no test coverage detected