UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

18 lines (17 loc) • 810 B
import { isAbsoluteForFamily, isUncSpelling, joinForFamily, win32NamespaceScreen } from "../tools/fs/safety.js"; export async function symlinkChainHops(env, path, signal, family, baseCwd, onUnanswerable) { if (typeof env.canonicalChain !== "function") return []; const screened = win32NamespaceScreen(path, family); if (!screened.ok) return []; const spelled = screened.spelled; if (family === "win" && isUncSpelling(spelled)) return []; const target = baseCwd !== undefined && baseCwd.length > 0 && !isAbsoluteForFamily(family, spelled) ? joinForFamily(family, baseCwd, spelled) : spelled; const chain = await env.canonicalChain(target, signal); if (chain.ok) return chain.value.hops; onUnanswerable?.(chain.error.message); return []; }