MCPcopy Index your code
hub / github.com/Noumena-Network/code / read

Method read

src/cli/structuredIO.ts:216–262  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Calls 3

processLineMethod · 0.95
logForDiagnosticsNoPIIFunction · 0.85
rejectMethod · 0.80

Tested by 1

readResponseTextFunction · 0.36