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

Method read

source code/cli/structuredIO.ts:217–263  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215 }
216
217 private async *read() {
218 let content = ''
219
220 // Called once before for-await (an empty this.input otherwise skips the
221 // loop body entirely), then again per block. prependedLines re-check is
222 // inside the while so a prepend pushed between two messages in the SAME
223 // block still lands first.
224 const splitAndProcess = async function* (this: StructuredIO) {
225 for (;;) {
226 if (this.prependedLines.length > 0) {
227 content = this.prependedLines.join('') + content
228 this.prependedLines = []
229 }
230 const newline = content.indexOf('\n')
231 if (newline === -1) break
232 const line = content.slice(0, newline)
233 content = content.slice(newline + 1)
234 const message = await this.processLine(line)
235 if (message) {
236 logForDiagnosticsNoPII('info', 'cli_stdin_message_parsed', {
237 type: message.type,
238 })
239 yield message
240 }
241 }
242 }.bind(this)
243
244 yield* splitAndProcess()
245
246 for await (const block of this.input) {
247 content += block
248 yield* splitAndProcess()
249 }
250 if (content) {
251 const message = await this.processLine(content)
252 if (message) {
253 yield message
254 }
255 }
256 this.inputClosed = true
257 for (const request of this.pendingRequests.values()) {
258 // Reject all pending requests if the input stream
259 request.reject(
260 new Error('Tool permission stream closed before response received'),
261 )
262 }
263 }
264
265 getPendingPermissionRequests() {
266 return Array.from(this.pendingRequests.values())

Callers 15

constructorMethod · 0.95
drainStdinFunction · 0.45
AppClass · 0.45
trustedDevice.tsFile · 0.45
clearTrustedDeviceTokenFunction · 0.45
enrollTrustedDeviceFunction · 0.45
readStreamMethod · 0.45
getCachedIdpIdTokenFunction · 0.45
saveIdpIdTokenFunction · 0.45
clearIdpIdTokenFunction · 0.45
saveIdpClientSecretFunction · 0.45
getIdpClientSecretFunction · 0.45

Calls 3

processLineMethod · 0.95
logForDiagnosticsNoPIIFunction · 0.85
rejectMethod · 0.80

Tested by

no test coverage detected