Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
ts 37 lines 973 Bytes
Raw
1 import * as color from 'src/ui/colors';
2
3 import { stripCwdPath } from 'effect-errors/logic/path';
4 import type { PrettyPrintOptions } from 'effect-errors/types';
5
6 export const maybePrintNodeStacktrace = (
7 stack: string[] | undefined,
8 isPlainString: boolean,
9 { stripCwd, hideStackTrace }: PrettyPrintOptions
10 ): string[] => {
11 if (hideStackTrace) {
12 return [];
13 }
14
15 const stackHasNodes = stack !== undefined && stack.length > 0;
16 if (stackHasNodes) {
17 const nodes = stack.map(el => `│ ${stripCwd ? stripCwdPath(el) : el}`).join('\r\n');
18
19 return [
20 ' ',
21 `${color.bold(color.red('◯'))} ${color.redBright(color.underline('Node Stacktrace 🚨'))}`,
22 color.redBright(nodes),
23 color.redBright('┴'),
24 ];
25 }
26
27 if (!isPlainString) {
28 return [
29 ' ',
30 color.gray(
31 'ℹ️ Consider using a yieldable error such as Data.TaggedError and Schema.TaggedError to get a stacktrace.'
32 ),
33 ];
34 }
35
36 return [];
37 };