MCPcopy
hub / github.com/deepnote/deepnote / createRunProjectCallbacks

Function createRunProjectCallbacks

packages/cli/src/commands/run.ts:1035–1156  ·  view source on GitHub ↗
({
  engine,
  isMachineOutput,
  state,
}: {
  engine: ExecutionEngine
  isMachineOutput: boolean
  state: RunExecutionState
})

Source from the content-addressed store, hash-verified

1033}
1034
1035function createRunProjectCallbacks({
1036 engine,
1037 isMachineOutput,
1038 state,
1039}: {
1040 engine: ExecutionEngine
1041 isMachineOutput: boolean
1042 state: RunExecutionState
1043}) {
1044 return {
1045 onBlockStart: async (block: RuntimeDeepnoteBlock, index: number, total: number) => {
1046 const label = getBlockLabel(block)
1047 state.blockLabels.set(block.id, label)
1048
1049 if (!isMachineOutput) {
1050 state.agentStreamed = false
1051 state.agentTextBuffer = ''
1052 state.reasoningActive = false
1053 state.activeBlockId = block.id
1054 const c = getChalk()
1055 process.stdout.write(`${c.cyan(`[${index + 1}/${total}] ${label}`)} `)
1056 }
1057
1058 await captureMemoryBeforeBlock(state, engine, block.id)
1059 },
1060
1061 onOutput: (blockId: string, blockOutput: IOutput) => {
1062 if (isMachineOutput || !state.blockLabels.has(blockId)) {
1063 return
1064 }
1065
1066 if (!state.blocksWithStreamedOutput.has(blockId)) {
1067 output('')
1068 }
1069
1070 renderOutput(blockOutput)
1071 state.blocksWithStreamedOutput.add(blockId)
1072 },
1073
1074 onBlockDone: async (result: BlockExecutionResult) => {
1075 const label = state.blockLabels.get(result.blockId) ?? result.blockType
1076 state.blockLabels.delete(result.blockId) // Clean up to avoid memory growth
1077 state.blockResults.push({
1078 id: result.blockId,
1079 type: result.blockType,
1080 label,
1081 success: result.success,
1082 durationMs: result.durationMs,
1083 outputs: result.outputs,
1084 error: result.error?.message,
1085 })
1086
1087 const memoryDeltaStr = await recordBlockProfile(state, engine, result, label)
1088
1089 if (!isMachineOutput && (!state.activeBlockId || result.blockId === state.activeBlockId)) {
1090 const c = getChalk()
1091 const hadStreamedOutput = state.blocksWithStreamedOutput.delete(result.blockId)
1092 const prefix = state.agentStreamed || hadStreamedOutput ? '\n' : ''

Callers 1

runDeepnoteProjectFunction · 0.85

Calls 7

getBlockLabelFunction · 0.90
getChalkFunction · 0.90
outputFunction · 0.90
renderOutputFunction · 0.90
debugFunction · 0.90
captureMemoryBeforeBlockFunction · 0.85
recordBlockProfileFunction · 0.85

Tested by

no test coverage detected