mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
fix(roadtrip): match cross-day returns to their rental
Keep located waypoints when the return desk is missing and assign them unique IDs. Join separate days only for the same hire car in both the planner and server. Keep the existing public terminal roles.
This commit is contained in:
@@ -26,6 +26,7 @@ import {
|
||||
carrierSeam,
|
||||
foldRouteRun,
|
||||
hotelBookendsOn,
|
||||
incomingDayJoin,
|
||||
isStationaryJoin,
|
||||
oneNightPerStay,
|
||||
splitIntoRuns,
|
||||
@@ -288,17 +289,17 @@ export class RoadtripPlanService {
|
||||
for (const run of splitIntoRuns(day.stops, (from) => from.legMode ?? fallback))
|
||||
await fetchRun(run.stops, day.dayId, run.mode);
|
||||
}
|
||||
const driveDays = plan.filter((d) => standsAsDay(d.stops));
|
||||
const quietDays = plan.filter((d) => !standsAsDay(d.stops));
|
||||
const chains = window
|
||||
? plan.filter((d) => d.stops.length)
|
||||
: spillChains(
|
||||
plan.filter((d) => d.stops.length > 1),
|
||||
plan.filter((d) => d.stops.length < 2),
|
||||
(a, b) => allLegs[stopKey(a) + '>' + stopKey(b)],
|
||||
);
|
||||
let previous: RoadtripStop | undefined;
|
||||
: spillChains(driveDays, quietDays, (a, b) => allLegs[stopKey(a) + '>' + stopKey(b)]);
|
||||
let previous: readonly RoadtripStop[] = [];
|
||||
for (const chain of chains) {
|
||||
const pairs = chain.stops.slice(0, -1).map((from, index) => ({ from, to: chain.stops[index + 1] }));
|
||||
if (connectDays && previous && chain.stops.length) pairs.push({ from: previous, to: chain.stops[0] });
|
||||
const to = chain.stops[0];
|
||||
const from = incomingDayJoin(previous, chain.stops, connectDays);
|
||||
if (from && to) pairs.push({ from, to });
|
||||
for (const { from, to } of pairs) {
|
||||
// A night spent at one hotel is no drive, and no router is asked about it.
|
||||
if (isStationaryJoin(from, to) || asked.has(stopKey(from) + '>' + stopKey(to))) continue;
|
||||
@@ -308,7 +309,7 @@ export class RoadtripPlanService {
|
||||
from.legMode ?? context.days.find((d) => d.id === chain.dayId)?.default_transport_mode ?? 'driving',
|
||||
);
|
||||
}
|
||||
previous = chain.stops[chain.stops.length - 1] ?? previous;
|
||||
if (chain.stops.length) previous = chain.stops;
|
||||
}
|
||||
const vehicleKind = preferences.roadtrip_vehicle || null;
|
||||
const rangeKm =
|
||||
@@ -324,8 +325,8 @@ export class RoadtripPlanService {
|
||||
preferences.roadtrip_range_km,
|
||||
) || null;
|
||||
const calculated = assembleRoadtrip({
|
||||
plan: plan.filter((d) => standsAsDay(d.stops)),
|
||||
quietDays: plan.filter((d) => !standsAsDay(d.stops)),
|
||||
plan: driveDays,
|
||||
quietDays,
|
||||
window,
|
||||
allLegs,
|
||||
snapByDay,
|
||||
|
||||
@@ -49,7 +49,7 @@ export class RoadtripPlanningMcp {
|
||||
@Tool({
|
||||
name: 'calculate_roadtrip',
|
||||
description:
|
||||
'Calculate a saved trip without an open browser, using the same daily scheduling and vehicle-range rules as the planner. Returns derived days, arrivals, departures, driving limits, fuel warnings, automatic pauses and routing failures. A flight, train, ferry, cruise or bus booking with located terminals is a seam: its terminals appear as stops carrying `carrier` (role departure or arrival), the road ends at the departure terminal and resumes at the arrival one, and the leg between them is the ride, in the mode of the booking type, with its timetable minutes and no distance. The departure terminal is pinned a check-in ahead of the timetable departure (an hour for a flight); reaching it after that is a late warning with the full minutes, however many, and the ride keeps its own day, so the drive after the arrival terminal goes on from the timetable arrival. On a day a ride leaves and lands on, the stop of a stay checked into that day comes after the arrival terminal when the stay lies nearer to it than to the departure terminal: a check-in is the earliest arrival, not a time that seats the stay ahead of the ride, and it pins the stay only when the ride lands before it. A time set on the stop itself keeps its seat. A hire car booking with a located pick-up desk puts that desk on the road as a stop carrying `carrier` with role pickup, and its return desk with role return when the booking names a return day and place; the road runs through both. A flight, train, ferry, cruise or bus booking that is on none of the days of the trip (saved without a date, or on a day the trip no longer has) is not on the drive at all, although its terminals are located: undatedRides lists each one (id, type, title) so it can be given a date within the trip with the reservation tools, after which the road ends at its terminal. With roadtrip_hotel_bookends switched on (missing means off), a day after a booked night starts at that stay and a day before one ends there. Such stops carry `bookend` {phase, accommodationId, reservationId, checkingOut, checkingIn, checkOut, and checkIn on the evening a stay begins when it has a check-in time}, stopType hotel, the real placeId of the stay and a synthetic negative assignmentId that belongs to no assignment: they cannot be reordered, edited or given via points, and `failures` may name them. The check-out and check-in are labels, never a departure or arrival time. A day between two nights in the same stay with no visit has no drive. Nor does a day with nothing on it but the check-in of the next stay when a flight, train, ferry, cruise or bus is booked on that day, with or without located terminals: the booking is the move between the two stays. A stay is never joined by road to a terminal more than 2000 km away in a straight line. Pass settings {roadtrip_hotel_bookends:true} to preview the drive from and to the stays without saving it. A hotel visited more than once on the check-in day of its stay is the night (night true, checkInTime set) at one visit only: the visit that ends the day, else the stop the booking put on the day, else the last visit; the other visits are ordinary stops. Fixed visit times retain priority. The end time of a visit is when the drive leaves it, in place of its stay; reaching the visit after it is reported as a missedLeave warning. No accommodation or place is created. Optional settings are a read-only preview, not saved. Distances are metres, durations seconds, dwell times minutes. A failed leg or conflicting window means the output is incomplete: never present its totals as a complete route. Up to 150 legs; requests are paced for public routing servers and can take time. Existing place/assignment tools edit stops, stays and ordering, update_roadtrip_settings saves preferences, set_assignment_end_day and set_day_boundary set exceptions. Recalculate after changes. Plugin profiles follow installed route-provider permissions.',
|
||||
'Calculate a saved trip without an open browser, using the same daily scheduling and vehicle-range rules as the planner. Returns derived days, arrivals, departures, driving limits, fuel warnings, automatic pauses and routing failures. A flight, train, ferry, cruise or bus booking with located terminals is a seam: its terminals appear as stops carrying `carrier` (role departure or arrival), the road ends at the departure terminal and resumes at the arrival one, and the leg between them is the ride, in the mode of the booking type, with its timetable minutes and no distance. The departure terminal is pinned a check-in ahead of the timetable departure (an hour for a flight); reaching it after that is a late warning with the full minutes, however many, and the ride keeps its own day, so the drive after the arrival terminal goes on from the timetable arrival. On a day a ride leaves and lands on, the stop of a stay checked into that day comes after the arrival terminal when the stay lies nearer to it than to the departure terminal: a check-in is the earliest arrival, not a time that seats the stay ahead of the ride, and it pins the stay only when the ride lands before it. A time set on the stop itself keeps its seat. A hire car booking with a located pick-up desk puts it on the road with role pickup, and its located return desk with role return. Located intermediate stops stay on the road even when the booking has no return desk. Those stops have synthetic negative assignment IDs and no carrier role. A flight, train, ferry, cruise or bus booking that is on none of the days of the trip (saved without a date, or on a day the trip no longer has) is not on the drive at all, although its terminals are located: undatedRides lists each one (id, type, title) so it can be given a date within the trip with the reservation tools, after which the road ends at its terminal. With roadtrip_hotel_bookends switched on (missing means off), a day after a booked night starts at that stay and a day before one ends there. Such stops carry `bookend` {phase, accommodationId, reservationId, checkingOut, checkingIn, checkOut, and checkIn on the evening a stay begins when it has a check-in time}, stopType hotel, the real placeId of the stay and a synthetic negative assignmentId that belongs to no assignment: they cannot be reordered, edited or given via points, and `failures` may name them. The check-out and check-in are labels, never a departure or arrival time. A day between two nights in the same stay with no visit has no drive. Nor does a day with nothing on it but the check-in of the next stay when a flight, train, ferry, cruise or bus is booked on that day, with or without located terminals: the booking is the move between the two stays. A stay is never joined by road to a terminal more than 2000 km away in a straight line. Pass settings {roadtrip_hotel_bookends:true} to preview the drive from and to the stays without saving it. A hotel visited more than once on the check-in day of its stay is the night (night true, checkInTime set) at one visit only: the visit that ends the day, else the stop the booking put on the day, else the last visit; the other visits are ordinary stops. Fixed visit times retain priority. The end time of a visit is when the drive leaves it, in place of its stay; reaching the visit after it is reported as a missedLeave warning. No accommodation or place is created. Optional settings are a read-only preview, not saved. Distances are metres, durations seconds, dwell times minutes. A failed leg or conflicting window means the output is incomplete: never present its totals as a complete route. Up to 150 legs; requests are paced for public routing servers and can take time. Existing place/assignment tools edit stops, stays and ordering, update_roadtrip_settings saves preferences, set_assignment_end_day and set_day_boundary set exceptions. Recalculate after changes. Plugin profiles follow installed route-provider permissions.',
|
||||
inputSchema: roadtripPlanRequestSchema.shape,
|
||||
annotations: TOOL_ANNOTATIONS_READONLY,
|
||||
access: { group: 'trips', mode: 'read' },
|
||||
@@ -74,7 +74,8 @@ export class RoadtripPlanningMcp {
|
||||
dayNumber: day.dayNumber,
|
||||
date: day.date,
|
||||
title: day.title,
|
||||
stops: day.stops,
|
||||
// Waypoints are synthesised stops. Keep the public carrier roles for terminals only.
|
||||
stops: day.stops.map((stop) => (stop.carrier?.role === 'stop' ? { ...stop, carrier: undefined } : stop)),
|
||||
schedule: day.schedule,
|
||||
legs: day.legs,
|
||||
distanceMetres: day.distance,
|
||||
|
||||
Reference in New Issue
Block a user