/** * Starter Trail bundle — the 5 reference trails ship with the SDK. * * `STARTER_TRAILS` is an array of pre-parsed Trail objects suitable for handing straight to * `TrailLibrary.fromArray(...)`. Browser callers get them in the bundle automatically (no * filesystem access needed); Node callers can either use the bundle or load fresh from disk via * `TrailLibrary.fromDirectory()`. * * Adding a new starter trail: drop a `.trail.json` into this directory, add it to STARTER_TRAILS * below. The static import gives you compile-time JSON validation against the Trail type. */ import { parseTrail, type Trail } from "../trail.js"; import morphoLeveragedPosition from "./morpho.leveraged_position.trail.json" with { type: "json" }; import morphoUnwind from "./morpho.unwind.trail.json" with { type: "json" }; import aaveLeveragedPosition from "./aave.leveraged_position.trail.json" with { type: "json" }; import spotSwapAndBuyPt from "./spot.swap_and_buy_pt.trail.json" with { type: "json" }; import dnPendleHyperliquid from "./dn.pendle_hyperliquid.trail.json" with { type: "json" }; const RAW_TRAILS: unknown[] = [ morphoLeveragedPosition, morphoUnwind, aaveLeveragedPosition, spotSwapAndBuyPt, dnPendleHyperliquid, ]; /** * Pre-validated starter trails. Parsed once at module load. * * Design note: we DO NOT throw on individual trail failures here. A broken trail json should * not take down the entire SDK module — that cascades to every consumer (UI, CLI, MCP) and * makes the LLM provider classes (which have nothing to do with trails) unreachable. Instead * we filter out bad trails + log a warning so the issue is visible without being fatal. * Schema violations should be caught by the trail test suite at SDK build time. */ export const STARTER_TRAILS: Trail[] = RAW_TRAILS .map((j, i): Trail | null => { try { return parseTrail(j); } catch (e) { const msg = e instanceof Error ? e.message : String(e); // eslint-disable-next-line no-console console.warn(`[@lucidly/sdk] STARTER_TRAILS[${i}] failed validation, skipping. ${msg.slice(0, 200)}`); return null; } }) .filter((t): t is Trail => t !== null); /** Get a single starter trail by id; convenience wrapper for one-off references. */ export function getStarterTrail(id: string): Trail | undefined { return STARTER_TRAILS.find((t) => t.id === id); }