MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / getInputPrompt

Function getInputPrompt

source code/main.tsx:859–885  ·  view source on GitHub ↗
(prompt: string, inputFormat: 'text' | 'stream-json')

Source from the content-addressed store, hash-verified

857 profileCheckpoint('main_after_run');
858}
859async function getInputPrompt(prompt: string, inputFormat: 'text' | 'stream-json'): Promise<string | AsyncIterable<string>> {
860 if (!process.stdin.isTTY &&
861 // Input hijacking breaks MCP.
862 !process.argv.includes('mcp')) {
863 if (inputFormat === 'stream-json') {
864 return process.stdin;
865 }
866 process.stdin.setEncoding('utf8');
867 let data = '';
868 const onData = (chunk: string) => {
869 data += chunk;
870 };
871 process.stdin.on('data', onData);
872 // If no data arrives in 3s, stop waiting and warn. Stdin is likely an
873 // inherited pipe from a parent that isn't writing (subprocess spawned
874 // without explicit stdin handling). 3s covers slow producers like curl,
875 // jq on large files, python with import overhead. The warning makes
876 // silent data loss visible for the rare producer that's slower still.
877 const timedOut = await peekForStdinData(process.stdin, 3000);
878 process.stdin.off('data', onData);
879 if (timedOut) {
880 process.stderr.write('Warning: no stdin data received in 3s, proceeding without it. ' + 'If piping from a slow command, redirect stdin explicitly: < /dev/null to skip, or wait longer.\n');
881 }
882 return [prompt, data].filter(Boolean).join('\n');
883 }
884 return prompt;
885}
886async function run(): Promise<CommanderCommand> {
887 profileCheckpoint('run_function_start');
888

Callers 1

runFunction · 0.85

Calls 2

peekForStdinDataFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected