Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { Effect, pipe } from 'effect'; |
| 2 | |
| 3 | import { removeNodeModulesEntriesFromStack } from 'effect-errors/logic/spans'; |
| 4 | |
| 5 | import { isErrorRelatedSources, isRawErrorLocation } from './mapped-sources'; |
| 6 | import { maybeMapSourcemaps } from './maybe-map-sourcemaps'; |
| 7 | |
| 8 | export const getSourcesFromStack = (maybeStack: string | undefined) => |
| 9 | pipe( |
| 10 | Effect.gen(function* () { |
| 11 | if (maybeStack === undefined) { |
| 12 | return { |
| 13 | sources: [], |
| 14 | location: [], |
| 15 | }; |
| 16 | } |
| 17 | |
| 18 | const relevantStackEntries = removeNodeModulesEntriesFromStack(maybeStack); |
| 19 | const sourcesOrLocation = yield* maybeMapSourcemaps('', relevantStackEntries); |
| 20 | |
| 21 | return { |
| 22 | sources: sourcesOrLocation.filter(isErrorRelatedSources), |
| 23 | location: sourcesOrLocation.filter(isRawErrorLocation), |
| 24 | }; |
| 25 | }), |
| 26 | Effect.withSpan('get-sources-from-stack') |
| 27 | ); |