MCPcopy Create free account
hub / github.com/freecodexyz/free-code / validateInput

Function validateInput

src/tools/PowerShellTool/PowerShellTool.tsx:352–374  ·  view source on GitHub ↗
(input: PowerShellToolInput)

Source from the content-addressed store, hash-verified

350 return true;
351 },
352 async validateInput(input: PowerShellToolInput): Promise<ValidationResult> {
353 // Defense-in-depth: also guarded in call() for direct callers.
354 if (isWindowsSandboxPolicyViolation()) {
355 return {
356 result: false,
357 message: WINDOWS_SANDBOX_POLICY_REFUSAL,
358 errorCode: 11
359 };
360 }
361 if (feature('MONITOR_TOOL') && !isBackgroundTasksDisabled && !input.run_in_background) {
362 const sleepPattern = detectBlockedSleepPattern(input.command);
363 if (sleepPattern !== null) {
364 return {
365 result: false,
366 message: `Blocked: ${sleepPattern}. Run blocking commands in the background with run_in_background: true — you'll get a completion notification when done. For streaming events (watching logs, polling APIs), use the Monitor tool. If you genuinely need a delay (rate limiting, deliberate pacing), keep it under 2 seconds.`,
367 errorCode: 10
368 };
369 }
370 }
371 return {
372 result: true
373 };
374 },
375 async checkPermissions(input: PowerShellToolInput, context: Parameters<Tool['checkPermissions']>[1]): Promise<PermissionResult> {
376 return await powershellToolHasPermission(input, context);
377 },

Callers

nothing calls this directly

Calls 2

Tested by

no test coverage detected