Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
import { Effect, pipe } from 'effect';
import { removeNodeModulesEntriesFromStack } from 'effect-errors/logic/spans';
import { isErrorRelatedSources, isRawErrorLocation } from './mapped-sources';
import { maybeMapSourcemaps } from './maybe-map-sourcemaps';
export const getSourcesFromStack = (maybeStack: string | undefined) =>
pipe(
Effect.gen(function* () {
if (maybeStack === undefined) {
return {
sources: [],
location: [],
};
}
const relevantStackEntries = removeNodeModulesEntriesFromStack(maybeStack);
const sourcesOrLocation = yield* maybeMapSourcemaps('', relevantStackEntries);
return {
sources: sourcesOrLocation.filter(isErrorRelatedSources),
location: sourcesOrLocation.filter(isRawErrorLocation),
};
}),
Effect.withSpan('get-sources-from-stack')
);