@devries-cameron20 / composio Mirror · read-only
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 04:45 UTC

next
ts 38 lines 1.59 KB
Raw
1 import * as color from 'src/ui/colors';
2
3 import { stripCwdPath } from 'effect-errors/logic/path';
4 import { missingSpansWarning, spanStackTrailingChar } from 'effect-errors/pretty-print/common';
5 import type { ErrorSpan, PrettyPrintOptions } from 'effect-errors/types';
6
7 // Recovered from the `Cause.StackTrace` reason annotation (see
8 // `logic/errors/span-annotation.ts`) — only span names and call-site
9 // locations are available in v4, not the v3 timeline's per-span duration or
10 // attributes, so each entry renders just those two lines.
11 export const maybePrintSpansTimeline = (
12 spans: ReadonlyArray<ErrorSpan> | undefined,
13 isPlainString: boolean,
14 { stripCwd }: PrettyPrintOptions
15 ): string[] => {
16 if (spans === undefined) {
17 return isPlainString === false ? [' ', missingSpansWarning, ' '] : [];
18 }
19
20 return spans.reduce<string[]>((output, { name, location }, index) => {
21 const isFirstEntry = index === 0;
22 const isLastEntry = index === spans.length - 1;
23
24 const maybeCircle = isFirstEntry ? `\r\n${color.gray('◯')}\r\n` : '';
25 const trailing = spanStackTrailingChar(isLastEntry);
26 const spanName = ` ${stripCwd !== undefined ? color.underline(color.bold(stripCwdPath(name))) : color.underline(name)}`;
27 const formattedLocation =
28 location !== undefined
29 ? `\r\n${isLastEntry ? ' ' : color.gray('│')} ${color.gray(stripCwd !== undefined ? stripCwdPath(location) : location)}`
30 : '';
31
32 const timelineEntry = color.white(
33 `${maybeCircle}${trailing}${color.gray('─')}${spanName}${formattedLocation}`
34 );
35
36 return [...output, timelineEntry];
37 }, []);
38 };