LCOV - code coverage report
Current view: top level - src/workbench/extensions/agent/utils - agentMessageText.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 0.0 % 8 0
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import type { MediaType } from '@comfyorg/shared-frontend-utils/formatUtil'
       2              : import { getMediaTypeFromFilename } from '@comfyorg/shared-frontend-utils/formatUtil'
       3              : 
       4              : import type { ConversationEntry } from '@/workbench/extensions/agent/stores/agent/agentConversationStore'
       5              : import type { SkillReference } from '@/workbench/extensions/agent/types/skillReference'
       6              : import { promptReferenceParts } from './promptReferenceParts'
       7              : 
       8            0 : export function nodeReferenceText(name: string): string {
       9            0 :   return `@[Node: ${name}]`
      10              : }
      11              : 
      12            0 : export function assetReferenceText(
      13              :   name: string,
      14              :   resolvedKind?: MediaType
      15              : ): string {
      16              :   const kind = resolvedKind ?? getMediaTypeFromFilename(name)
      17              :   const label = {
      18              :     image: 'Image',
      19              :     video: 'Video',
      20              :     audio: 'Audio',
      21              :     '3D': '3D',
      22              :     text: 'File',
      23              :     other: 'File'
      24              :   }[kind]
      25            0 :   return `@[${label}: ${name}]`
      26              : }
      27              : 
      28            0 : export function agentMessageText(
      29              :   message: Pick<
      30              :     Extract<ConversationEntry, { role: 'user' }>,
      31              :     'text' | 'workflowReferences' | 'tags' | 'attachments'
      32              :   > & { skillReference?: SkillReference }
      33              : ): string {
      34            0 :   const text = promptReferenceParts(
      35              :     message.text,
      36              :     message.workflowReferences ?? [],
      37              :     message.skillReference
      38              :   )
      39              :     .map((part) =>
      40              :       part.type === 'text'
      41              :         ? part.text
      42              :         : part.type === 'skill'
      43              :           ? `/${part.reference.name}`
      44              :           : `@[Workflow: ${part.reference.name}]`
      45              :     )
      46              :     .join('')
      47            0 :   const context = [
      48              :     ...(message.tags ?? []).map(nodeReferenceText),
      49              :     ...(message.attachments ?? []).map(({ name, kind }) =>
      50              :       assetReferenceText(name, kind)
      51              :     )
      52              :   ].filter((label) => !text.includes(label))
      53            0 :   return [text, ...new Set(context)].filter(Boolean).join('\n')
      54              : }
        

Generated by: LCOV version 2.0-1