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

Method execute

src/tools/REPLTool/pyReplFactory.tsx:309–346  ·  view source on GitHub ↗
(
    input: { code: string; timeoutMs: number },
    runtime: ReplWrapperRuntime,
  )

Source from the content-addressed store, hash-verified

307 }
308
309 async execute(
310 input: { code: string; timeoutMs: number },
311 runtime: ReplWrapperRuntime,
312 ): Promise<{ output: string; error?: string }> {
313 return this.runExclusive(async () => {
314 await this.ensureStarted()
315 const child = this.child
316 if (!child?.stdin.writable) {
317 throw new Error('Python REPL kernel stdin is not writable')
318 }
319
320 const execId = randomUUID()
321 const pending = await new Promise<PythonKernelExecResultMessage>((resolve, reject) => {
322 this.pendingExecs.set(execId, { resolve, reject, runtime })
323 child.stdin.write(
324 `${JSON.stringify({
325 type: 'exec',
326 id: execId,
327 code: input.code,
328 timeout_ms: input.timeoutMs,
329 })}\n`,
330 )
331 }).finally(() => {
332 this.pendingExecs.delete(execId)
333 })
334
335 if (!pending.ok) {
336 return {
337 output: pending.output,
338 error: pending.error ?? 'Python REPL execution failed',
339 }
340 }
341
342 return {
343 output: pending.output,
344 }
345 })
346 }
347
348 async reset(): Promise<void> {
349 await this.runExclusive(async () => {

Callers 2

callFunction · 0.80
handleVimInputFunction · 0.80

Calls 6

runExclusiveMethod · 0.95
ensureStartedMethod · 0.95
randomUUIDFunction · 0.90
setMethod · 0.80
deleteMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected