@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 30 lines 1.01 KB
Raw
1 import * as color from 'src/ui/colors';
2
3 import { stripCwdPath } from 'effect-errors/logic/path';
4 import type { ErrorRelatedSources } from 'effect-errors/sourcemaps';
5 import type { ErrorSpan, PrettyPrintOptions } from 'effect-errors/types';
6
7 export const printEffectStacktrace = (
8 sources: Omit<ErrorRelatedSources, '_tag'>[] | undefined,
9 spans: ReadonlyArray<ErrorSpan> | undefined,
10 { stripCwd }: PrettyPrintOptions
11 ) => {
12 const isEmpty =
13 spans === undefined || spans.length === 0 || sources === undefined || sources.length === 0;
14 if (isEmpty) {
15 return [];
16 }
17
18 const paths = sources.map(({ name, runPath, sourcesPath }) => {
19 const path = sourcesPath ?? runPath;
20 return { path: stripCwd ? stripCwdPath(path) : path, name };
21 });
22
23 return [
24 `${color.bold(color.redBright('◯'))} ${color.redBright('Sources')} 🕵️`,
25 ...paths.map(({ path, name }) =>
26 color.redBright(`│ at ${name.length === 0 ? 'module code' : color.underline(name)} (${path})`)
27 ),
28 color.redBright('┴'),
29 ];
30 };