mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 01:28:55 +00:00
35 lines
2.4 KiB
TypeScript
35 lines
2.4 KiB
TypeScript
const HIKE = /\b(?:hik(?:e|es|ing)|wandern|wander(?:ung(?:en)?|tour(?:en)?|route|weg)|bergtour|trail)\b/iu;
|
||
const PLAN =
|
||
/\b(?:plan(?:e|en)?|erstell(?:e|en)?|lege?|anlegen|such(?:e|en)?|find(?:e|en)?|create|add|plot|map\s+out)\b/iu;
|
||
const CHALLENGING = /\b(?:anspruchsvoll\p{L}*|herausfordernd\p{L}*|challenging|demanding|strenuous)\b/iu;
|
||
const LIMIT =
|
||
/\b(?:t\s*[1-6]|(?:stufe|schwierigkeit|grade|level)\s*[1-6]|sac|max\p{L}*|höchstens|bis\s+zu|at\s+most|up\s+to|only|nur|aber|but|ohne|without|avoid|nicht|not|kein\p{L}*|beginner|anfänger)\b/iu;
|
||
|
||
/** Load the hiking tools directly when the latest request asks to find or plan a hike. */
|
||
export function isHikePlanningRequest(text: string): boolean {
|
||
return HIKE.test(text) && PLAN.test(text);
|
||
}
|
||
|
||
/** A bare request for a challenge leaves the routing ceiling up to TREK. */
|
||
export function wantsChallengingHike(text: string): boolean {
|
||
return isHikePlanningRequest(text) && CHALLENGING.test(text) && !LIMIT.test(text);
|
||
}
|
||
|
||
export function withChallengingHikeLimit(
|
||
tool: string,
|
||
args: Record<string, unknown>,
|
||
challenging: boolean | undefined,
|
||
): Record<string, unknown> {
|
||
if (!challenging || tool !== 'propose_hike' || args.variant_label) return args;
|
||
const limit = args.max_hiking_difficulty;
|
||
return limit === undefined || limit === 3 ? { ...args, max_hiking_difficulty: 4 } : args;
|
||
}
|
||
|
||
export const HIKE_PLANNING_CONTEXT = [
|
||
'Plan the hike with propose_hike. For a named trail, research its published distance, trailhead, finish and trail-defining stops first.',
|
||
'Look up each precise waypoint with search_place, using the local place name and mountain or town, and reuse the returned coordinates. Never guess coordinates for numbered stations or drop disputed waypoints to make a route work.',
|
||
'Keep the ascent on the documented ascent trail. End at the trail’s documented finish. If the highest summit requires a separate crater or ridge section, include it only as a clearly named extension.',
|
||
'For an explicitly challenging or demanding hike without a stated ceiling, use T4 for the first route proposal on steep rocky terrain. Keep any maximum the traveller explicitly gave.',
|
||
'Compare the routed distance and ascent with the reference. If it takes a substantial detour, correct the waypoints or routing limit within the request before showing it as the named trail. Say if the named trail could not be routed.',
|
||
].join(' ');
|