MCPcopy
hub / github.com/codeaashu/claude-code / call

Function call

src/tools/PowerShellTool/PowerShellTool.tsx:437–658  ·  view source on GitHub ↗
(input: PowerShellToolInput, toolUseContext: Parameters<Tool['call']>[1], _canUseTool?: CanUseToolFn, _parentMessage?: AssistantMessage, onProgress?: ToolCallProgress<PowerShellProgress>)

Source from the content-addressed store, hash-verified

435 };
436 },
437 async call(input: PowerShellToolInput, toolUseContext: Parameters<Tool['call']>[1], _canUseTool?: CanUseToolFn, _parentMessage?: AssistantMessage, onProgress?: ToolCallProgress<PowerShellProgress>): Promise<{
438 data: Out;
439 }> {
440 // Load-bearing guard: promptShellExecution.ts and processBashCommand.tsx
441 // call PowerShellTool.call() directly, bypassing validateInput. This is
442 // the check that covers ALL callers. See isWindowsSandboxPolicyViolation
443 // comment for the policy rationale.
444 if (isWindowsSandboxPolicyViolation()) {
445 throw new Error(WINDOWS_SANDBOX_POLICY_REFUSAL);
446 }
447 const {
448 abortController,
449 setAppState,
450 setToolJSX
451 } = toolUseContext;
452 const isMainThread = !toolUseContext.agentId;
453 let progressCounter = 0;
454 try {
455 const commandGenerator = runPowerShellCommand({
456 input,
457 abortController,
458 // Use the always-shared task channel so async agents' background
459 // shell tasks are actually registered (and killable on agent exit).
460 setAppState: toolUseContext.setAppStateForTasks ?? setAppState,
461 setToolJSX,
462 preventCwdChanges: !isMainThread,
463 isMainThread,
464 toolUseId: toolUseContext.toolUseId,
465 agentId: toolUseContext.agentId
466 });
467 let generatorResult;
468 do {
469 generatorResult = await commandGenerator.next();
470 if (!generatorResult.done && onProgress) {
471 const progress = generatorResult.value;
472 onProgress({
473 toolUseID: `ps-progress-${progressCounter++}`,
474 data: {
475 type: 'powershell_progress',
476 output: progress.output,
477 fullOutput: progress.fullOutput,
478 elapsedTimeSeconds: progress.elapsedTimeSeconds,
479 totalLines: progress.totalLines,
480 totalBytes: progress.totalBytes,
481 timeoutMs: progress.timeoutMs,
482 taskId: progress.taskId
483 }
484 });
485 }
486 } while (!generatorResult.done);
487 const result = generatorResult.value;
488
489 // Feed git/PR usage metrics (same counters as BashTool). PS invokes
490 // git/gh/glab/curl as external binaries with identical syntax, so the
491 // shell-agnostic regex detection in trackGitOperations works as-is.
492 // Called before the backgroundTaskId early-return so backgrounded
493 // commands are counted too (matches BashTool.tsx:912).
494 //

Callers

nothing calls this directly

Calls 15

appendMethod · 0.95
toStringMethod · 0.95
runPowerShellCommandFunction · 0.85
trackGitOperationsFunction · 0.85
resetCwdIfOutsideProjectFunction · 0.85
extractClaudeCodeHintsFunction · 0.85
maybeRecordPluginHintFunction · 0.85
stripEmptyLinesFunction · 0.85
ensureToolResultsDirFunction · 0.85
getToolResultPathFunction · 0.85

Tested by

no test coverage detected