MCPcopy Create free account
hub / github.com/browserbase/stagehand / resolveCallerFilePath

Function resolveCallerFilePath

packages/docs/scripts/runtimePaths.js:63–85  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

61};
62
63const resolveCallerFilePath = () => {
64 const packageCandidates = [];
65 const fallbackCandidates = [];
66
67 for (const callsite of readCallsites()) {
68 const filePath = readCallsitePath(callsite);
69 if (!filePath) continue;
70 if (isInternalCallsite(callsite)) continue;
71 if (filePath.includes(PACKAGE_SEGMENT)) {
72 packageCandidates.push(filePath);
73 continue;
74 }
75 fallbackCandidates.push(filePath);
76 }
77
78 const packageCandidate = packageCandidates[0];
79 if (packageCandidate) return packageCandidate;
80
81 const fallbackCandidate = fallbackCandidates[0];
82 if (fallbackCandidate) return fallbackCandidate;
83
84 throw new Error("Unable to resolve caller file path.");
85};
86
87export const getCurrentFilePath = () => resolveCallerFilePath();
88

Callers 1

getCurrentFilePathFunction · 0.70

Calls 4

includesMethod · 0.80
readCallsitesFunction · 0.70
readCallsitePathFunction · 0.70
isInternalCallsiteFunction · 0.70

Tested by

no test coverage detected