@@ -10,25 +10,87 @@ const props = defineProps<{
1010 hasOutputs: boolean ;
1111}>();
1212
13+ const tools = computed (() => {
14+ if (props .fieldType !== FieldType .Tools ) return {};
15+ return parseToolsField (props .fieldValue );
16+ });
17+
1318const hasToolsButNoFunctionTools = computed (() => {
1419 if (props .fieldType !== FieldType .Tools ) return false ;
15- const tools = parseToolsField (props .fieldValue );
16- const toolKeys = Object .keys (tools );
20+ const toolKeys = Object .keys (tools .value );
1721 if (toolKeys .length === 0 ) return false ;
18- return ! toolKeys .some ((key ) => tools [key ]?.type === " function" );
22+ return ! toolKeys .some ((key ) => tools .value [key ]?.type === " function" );
23+ });
24+
25+ function formatGraphIds(graphIds : unknown ): string | null {
26+ if (! graphIds ) return null ;
27+
28+ if (Array .isArray (graphIds ) && graphIds .length > 0 ) {
29+ const ids = graphIds .filter (
30+ (id ) => typeof id === " string" && ! id .startsWith (" @{" ),
31+ );
32+ return ids .length > 0 ? ids .join (" , " ) : null ;
33+ }
34+
35+ if (typeof graphIds === " string" && ! graphIds .startsWith (" @{" )) {
36+ return graphIds ;
37+ }
38+
39+ return null ;
40+ }
41+
42+ function isFunctionTool(tool : unknown ): boolean {
43+ return (
44+ tool !== null &&
45+ typeof tool === " object" &&
46+ " type" in tool &&
47+ tool .type === " function"
48+ );
49+ }
50+
51+ function formatToolName(toolName : string , tool : unknown ): string {
52+ if (! tool || typeof tool !== " object" || ! (" type" in tool )) {
53+ return toolName ;
54+ }
55+
56+ if (tool .type === " graph" && " graph_ids" in tool ) {
57+ const formattedIds = formatGraphIds (tool .graph_ids );
58+ if (formattedIds ) {
59+ return ` ${toolName } (${formattedIds }) ` ;
60+ }
61+ }
62+
63+ return toolName ;
64+ }
65+
66+ const nonFunctionToolKeys = computed (() => {
67+ return Object .keys (tools .value ).filter ((toolName ) => {
68+ return ! isFunctionTool (tools .value [toolName ]);
69+ });
1970});
2071
2172const displayText = computed (() => {
73+ if (nonFunctionToolKeys .value .length > 0 ) {
74+ return nonFunctionToolKeys .value
75+ .map ((toolName ) => formatToolName (toolName , tools .value [toolName ]))
76+ .join (" , " );
77+ }
78+
2279 if (! props .hasOutputs && hasToolsButNoFunctionTools .value ) {
2380 return " No outputs" ;
2481 }
82+
2583 return " None configured." ;
2684});
85+
86+ const shouldRender = computed (() => {
87+ return ! props .hasOutputs || nonFunctionToolKeys .value .length > 0 ;
88+ });
2789 </script >
2890
2991<template >
3092 <div
31- v-if =" !hasOutputs "
93+ v-if =" shouldRender "
3294 class =" BlueprintsNode__main__outputs__output BlueprintsNode__main__outputs__empty"
3395 >
3496 {{ displayText }}
0 commit comments