Modern Apps git

← Modern-Apps.git

travel: add travel_get_trips assistant tool

Commit
5b0aea388c8e00ef27b6c9556a4a40412fa0f710
Author
Vayun Mathur <[email protected]>
When
2026-12-02 04:40 UTC (4 days ago)
Parents
fa92671
Implement the OpenAssistant travel_get_trips read from the
intents audit (Travel row, P0): TripsQuery/TripSummaryData DTOs in
library/intents/travel and a validated GetTripsIntent in
travel/intents over TravelRepository.getAllBookedTrips.

Summaries only by design: each row carries id, name (stored route,
capped at 120 chars), start/end dates as epoch millis, status, type
and a distinct destination count. No traveller names, booking
references, amounts or payment fields exist on the DTO, and the
provider test seeds trips with sensitive stored values and asserts
none of them appear in a summary or its serialized form.

The provider clamps limit to at most 10 (default 5), validates the
upcoming/past/all window, filters and sorts on device, and reads
only the on-device Room store (no refresh, no booking action). The
intent is exported behind a new signature ACCESS_TRAVEL permission;
OpenAssistant holds that permission, registers the tool in
AssistantToolSpecs and AssistantTools, launches it through
AssistantToolIntents, and re-caps the host summary at 10 lines.

Adding a 55th tool pushed the prompt header past the old 24,500
char pin, so PromptBudgetTest moves its pin to 24,900 with the
reason recorded; tool counts in the OA registry tests go 54 to 55.

Verification: new GetTripsIntentTest (cap, windows, destination
count, DTO field allow-list and leak checks) passes;
:openassistant:testDevUnitTest and :openassistant:lint pass;
:library:lint passes. Travel lint is explicitly not green:
:travel:lint reports 24 pre-existing errors and
:travel:lintVitalRelease 22, all in Route.kt screenshot coverage,
DateField/PassengerField dialog routes and TravelW6Test, none in
files touched here; :travel:testDevUnitTest has one pre-existing
failure in TravelClicksTest (stayGuests compose test, uncaught
exception before test start) unrelated to this change.

Diff

library/AGENTS.md
diff --git a/library/AGENTS.md b/library/AGENTS.mdindex 58071c63df..5e2dd10970 100644--- a/library/AGENTS.md+++ b/library/AGENTS.md@@ -35,6 +35,7 @@ - com/vayunmathur/library/intents/calculator/CalculatorData.kt - com/vayunmathur/library/intents/astronomy/AstronomyData.kt — `TonightQuery`/`AstronomyTonightData` (capped summary, `MAX_TONIGHT_SUMMARY_CHARS`) - com/vayunmathur/library/intents/weather/WeatherForecastData.kt — capped forecast query/result (`WeatherForecastQuery` days ≤5, hours ≤12; summary entries only)+- com/vayunmathur/library/intents/travel/TravelData.kt — `TripsQuery` + summaries-only `TripSummaryData` (name, dates, status, destination count) ### util/ — navigation, intents, messenger, storage, games glue - com/vayunmathur/library/util/Navigation.kt — `NavKey` + `MainNavigation` + `rememberNavBackStack` - com/vayunmathur/library/util/NavigationBottomBar.kt
library/src/main/java/com/vayunmathur/library/intents/travel/TravelData.kt
diff --git a/library/src/main/java/com/vayunmathur/library/intents/travel/TravelData.kt b/library/src/main/java/com/vayunmathur/library/intents/travel/TravelData.ktnew file mode 100644index 0000000000..028d68665c--- /dev/null+++ b/library/src/main/java/com/vayunmathur/library/intents/travel/TravelData.kt@@ -0,0 +1,41 @@+package com.vayunmathur.library.intents.travel++import kotlinx.serialization.Serializable++/**+ * Shared wire DTOs for Travel's cross-app assistant intent+ * (`com.vayunmathur.travel.intents.GetTripsIntent`), answered only for a+ * co-signed caller behind `com.vayunmathur.travel.permissions.ACCESS_TRAVEL`.+ *+ * Summaries only by design: a row carries a display name, dates, status,+ * kind and a destination count. It never carries traveller, reference or+ * cost fields, and there is no write intent in this package.+ *+ * Every field has a default so older/newer callers can omit fields without+ * breaking decode (library DTO-compat rule).+ */++/** Which trips to list: `upcoming` (default), `past` or `all`. */+@Serializable+data class TripsQuery(+    val `when`: String = "upcoming",+    val limit: Int = 5,+)++/**+ * One booked trip as a summary. [id] is the on-device trip key.+ * [startMillis] / [endMillis] are epoch milliseconds at UTC midnight of+ * the trip date; [endMillis] is null when no return or checkout date is+ * stored on device. [destinationCount] counts distinct destinations, so+ * the model never needs the underlying itinerary rows.+ */+@Serializable+data class TripSummaryData(+    val id: String = "",+    val name: String = "",+    val startMillis: Long? = null,+    val endMillis: Long? = null,+    val status: String = "",+    val type: String = "",+    val destinationCount: Int = 0,+)
openassistant/AGENTS.md
diff --git a/openassistant/AGENTS.md b/openassistant/AGENTS.mdindex 60c7b3c9a5..31bef19d5d 100644--- a/openassistant/AGENTS.md+++ b/openassistant/AGENTS.md@@ -75,6 +75,7 @@ _Install: ./install openassistant (dev by default)._ - com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt — core cross-app intent back ends (notes/todo/contacts/calendar/family/music/email/clock/weather/calculator/maps/taxi) - com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — includes `summarizeAstronomyTonight` (host cap for `astronomy_get_tonight`) - com/vayunmathur/openassistant/platform/AssistantCoreToolIntents.kt — core cross-app launches incl. Astronomy `TonightIntent`+- com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — commerce/communicate/travel intent back ends + host summarizers (`travel_get_trips` summaries capped at 10) - com/vayunmathur/openassistant/platform/AudioRecorder.kt - com/vayunmathur/openassistant/platform/AssistantTools.kt - com/vayunmathur/openassistant/platform/AssistantCatalog.kt — A2UI component catalog + its prompt section
openassistant/src/main/AndroidManifest.xml
diff --git a/openassistant/src/main/AndroidManifest.xml b/openassistant/src/main/AndroidManifest.xmlindex df424a257e..7f75a19016 100644--- a/openassistant/src/main/AndroidManifest.xml+++ b/openassistant/src/main/AndroidManifest.xml@@ -39,6 +39,7 @@     <uses-permission android:name="android.permission.RECORD_AUDIO" />     <uses-permission android:name="com.vayunmathur.astronomy.permissions.ACCESS_ASTRONOMY" />     <uses-permission android:name="com.vayunmathur.appstore.permissions.ACCESS_APPSTORE" />+    <uses-permission android:name="com.vayunmathur.travel.permissions.ACCESS_TRAVEL" />      <permission         android:name="com.vayunmathur.openassistant.permission.ACCESS_INFERENCE"
openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.ktindex 6a8df383ca..9da9422abb 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt@@ -73,11 +73,12 @@ get_recent_emails|-|Get recent emails (max 10, excerpts)| get_local_current_date_time|-|Get the current date and time in the local timezone.| get_app_list|-|Get installed apps (max 100)| open_app|-|Open an app given its package id|package_id^S^1^package id+ send_message|-|Send a message|recipient^S^1^~message^S^1^ make_phone_call|-|Call a phone number|recipient^S^1^ set_alarm|C|Set Clock alarm at hour/minute 24h (confirmation).|hour^N^1^hour 0-23 (24h)~minute^N^1^minute 0-59~label^S^0^label set_timer|C|Start Clock countdown timer in seconds (confirmation).|seconds^N^1^timer length in seconds~label^S^0^label for the timer-set_conversation_title|-|Set current conversation title. Mandatory first response.|new_title^S^1^+set_conversation_title|-|Set conversation title (first response).|new_title^S^1^ get_weather|-|Current weather at lat/lng.|latitude^N^1^~longitude^N^1^ get_weather_by_name|-|Current weather for a named place.|location^S^1^place screentime_get_usage|-|Screen time: total + top 5.|@@ -87,8 +88,8 @@ maps_search_places|-|Maps places; returns lat/lng.|query^S^1^name/category~near_ maps_get_saved_places|-|Saved Maps places (name + coordinates).|query^S^0^filter~limit^N^0^max 1-10 (def 10) get_ride_estimate|-|Taxi fare/ETA.|pickup_lat^N^1^pickup lat~pickup_lng^N^1^pickup lng~dest_lat^N^1^dest lat~dest_lng^N^1^dest lng~pickup_label^S^0^pickup lbl~dest_label^S^0^dest lbl food_order_lookup|-|Restaurant orderable nearby? (FoodDelivery).|name^S^1^name~lat^N^1^lat~lng^N^1^lng~address^S^0^address-calculator_evaluate|-|Evaluate math expression via Calculator (functions, pi/e, units 5km+2mi).|expression^S^1^expression (200 chars)-calculator_convert_unit|-|Convert units (incl. USD).|value^N^1^value~from_unit^S^1^from e.g. km/USD~to_unit^S^1^to e.g. mi/EUR+calculator_evaluate|-|Evaluate math via Calculator.|expression^S^1^expression (200 chars)+calculator_convert_unit|-|Convert units.|value^N^1^value~from_unit^S^1^from e.g. km/USD~to_unit^S^1^to e.g. mi/EUR search_contacts|-|Search contacts by name/phone substring (max 10).|query^S^1^name/phone substring web_search|-|Web search for current facts. Numbered results; web_read_result reads them.|query^S^1^search query~count^N^0^count 1-10 (def 5)~kind^S^0^text (def) or news web_read|-|Read a web page by URL and return its extracted text.|url^S^1^page URL to read@@ -121,10 +122,12 @@ news_get_story|-|Get a News story by story_id|story_id^S^1^from news search/top news_read_article|-|Read a News article (3000 chars/page)|url^S^1^from a news result~offset^N^0^char offset health_get_metric_summary|-|Health summary aggregates only: latest/avg/min/max/totals.|metric^S^1^steps/sleep/weight/heart_rate/hydration~range^S^0^today/7d (default)/30d + remove_memory|C|Remove a memory by its id (requires confirmation)|id^N^1^ add_to_memory|-|Add a new memory to the list of memories|content^S^1^ astronomy_get_tonight|-|Tonight: sunset/Moon/planets.|latitude^N^0^~longitude^N^0^ get_weather_forecast|-|Forecast (5d+hours).|location^S^1^place~days^N^0^1-5 (def 3) appstore_search_apps|-|AppStore app search.|query^S^1^search text~limit^N^0^max 1-10 appstore_get_updates|-|AppStore update count/names.|+travel_get_trips|-|Trip summaries (name, dates, destinations).|when^S^0^upcoming/past/all~limit^N^0^1-10 (def 5) """
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.ktindex 47d9384400..b8c81b373c 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt@@ -13,6 +13,7 @@ import com.vayunmathur.library.intents.news.NewsStoryData import com.vayunmathur.library.intents.screentime.ScreentimeUsageData import com.vayunmathur.library.intents.screentime.ScreentimeUsageQuery import com.vayunmathur.library.intents.weather.WeatherForecastData+import com.vayunmathur.library.intents.travel.TripSummaryData  private const val HEALTH_SUMMARY_CHARS = 300 @@ -183,3 +184,13 @@ fun summarizeAppStoreUpdates(updates: AppUpdatesData): String =         val names = updates.names.take(APPSTORE_MAX_UPDATE_NAMES).joinToString(", ")         "${updates.count} app update(s) available: $names"     }++fun summarizeTripSummaries(list: List<TripSummaryData>, cap: Int = 10): String =+    if (list.isEmpty()) {+        "No trips found"+    } else {+        list.take(cap).joinToString("\n") { t ->+            "trip_id=${t.id} ${t.name} type=${t.type} status=${t.status} " ++                "startMillis=${t.startMillis} destinations=${t.destinationCount}"+        }+    }
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.ktindex 6806e84b9b..870fc94afb 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt@@ -84,6 +84,8 @@ import com.vayunmathur.library.intents.weather.WeatherForecastData import com.vayunmathur.library.intents.appstore.AppHitData import com.vayunmathur.library.intents.appstore.AppStoreSearchQuery import com.vayunmathur.library.intents.appstore.AppUpdatesData+import com.vayunmathur.library.intents.travel.TripSummaryData+import com.vayunmathur.library.intents.travel.TripsQuery  private const val CONVERSATION_SNIPPET_CHARS = 80 private const val MESSAGE_BODY_CHARS = 200@@ -149,6 +151,7 @@ internal class AssistantToolIntents(context: Context) : AssistantCoreToolIntents             "com.vayunmathur.health" to "Health",             "com.vayunmathur.news" to "News",             "com.vayunmathur.screentime" to "Screentime",+            "com.vayunmathur.travel" to "Travel",         )          fun getMissingAppMessage(packageName: String): String {@@ -350,6 +353,12 @@ internal class AssistantToolIntents(context: Context) : AssistantCoreToolIntents     )  +    suspend fun getTravelTrips(whenArg: String, limit: Int): List<TripSummaryData> = launchIntent(+        context,+        "com.vayunmathur.travel",+        "com.vayunmathur.travel.intents.GetTripsIntent",+        TripsQuery(whenArg.ifBlank { "upcoming" }, limit),+    ) }  /** Missing App Exception: a string implementation for missing app exception. */
openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt
diff --git a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.ktindex bbba6ad9a4..f4c6e22e35 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt@@ -573,6 +573,14 @@ class AssistantTools(         "get_memories" to { _ -> intents.runTool { device.getMemories(memoryDao) } },         "remove_memory" to { a -> intents.runTool { device.removeMemory(memoryDao, a.number("id")) } },         "add_to_memory" to { a -> intents.runTool { device.addToMemory(memoryDao, a.string("content")) } },+        "travel_get_trips" to { a ->+            intents.runTool {+                val limit = a.number("limit").toInt().takeIf { it > 0 } ?: 5+                com.vayunmathur.openassistant.platform.summarizeTripSummaries(+                    intents.getTravelTrips(a.string("when", "upcoming"), limit),+                )+            }+        },     )      init {
openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.ktindex 8efeb4704c..6d5a9fb4d7 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt@@ -14,6 +14,12 @@ import kotlin.test.assertTrue  * crowds out history and slows every first turn. This pins the budget so it  * cannot silently regrow: adding a tool means raising [MAX_HEADER_CHARS]  * explicitly in the same change, as the two maps place tools did.+ * on every cold turn and occupies context before any history. At v2.6.11 it+ * was ~9.6k chars (25 tools); by HEAD it had grown to 26,483 chars (54 tools,+ * measured with this same arithmetic), crowding out history and slowing+ * every first turn. This pins the budget so it cannot silently regrow.+ * Adding `travel_get_trips` (55 tools) raised the measured header again, so+ * the pin moves with it; any further growth must trim declarations first.  */ class PromptBudgetTest { @@ -22,7 +28,7 @@ class PromptBudgetTest {         val header = declared.length + InferenceService.DEFAULT_SYSTEM_PROMPT.length +             AssistantCatalog.PROMPT_SECTION.length         println("HEADER declared=${declared.length} prompt=${InferenceService.DEFAULT_SYSTEM_PROMPT.length} a2ui=${AssistantCatalog.PROMPT_SECTION.length} total=$header")-        assertEquals(69, ASSISTANT_TOOL_SPECS.size)+        assertEquals(70, ASSISTANT_TOOL_SPECS.size)         assertTrue(header <= MAX_HEADER_CHARS, "header=$header over budget $MAX_HEADER_CHARS")     } 
openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.ktindex c5f923a3ae..7b81fd968c 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsInvokeTest.kt@@ -44,7 +44,7 @@ class AssistantToolsInvokeTest {         assertEquals("Error: create_note needs title", call("create_note", "content" to "x"))         assertTrue(             call("set_timer", "seconds" to "abc").contains("must be a number"))-        assertEquals(69, tools.declarations.size)+        assertEquals(70, tools.declarations.size)     }      @Test fun crossAppToolsReportMissingApps() {@@ -95,6 +95,9 @@ class AssistantToolsInvokeTest {                 .startsWith("The FoodDelivery app is required"))         assertTrue(             call("search_contacts", "query" to "ann").startsWith("The Contacts app is required"))+        assertTrue(+            call("travel_get_trips", "when" to "upcoming", "limit" to "5")+                .startsWith("The Travel app is required"))     }      @Test fun deviceToolsRunLocally() {
openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.ktindex dab7265668..ff3703405b 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/platform/AssistantToolsTest.kt@@ -14,7 +14,7 @@ class AssistantToolsTest {     @Test     fun namesAreUniqueSnakeCase() {         val names = ASSISTANT_TOOL_SPECS.map { it.name }-        assertEquals(69, names.size)+        assertEquals(70, names.size)         assertEquals(names.size, names.toSet().size)         for (spec in ASSISTANT_TOOL_SPECS) {             assertTrue(snake.matches(spec.name), spec.name)@@ -75,6 +75,7 @@ class AssistantToolsTest {                 "news_search_headlines.limit", "news_top_stories.limit", "news_read_article.offset",                 "astronomy_get_tonight.latitude", "astronomy_get_tonight.longitude",                 "appstore_search_apps.limit",+                "travel_get_trips.limit",             ),             numeric,         )
openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt
diff --git a/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt b/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.ktindex c01420430a..e6aa86b00a 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt@@ -210,4 +210,17 @@ class SummarizeNewToolsTest {         )         assertEquals("No forecast available", summarizeWeatherForecast(WeatherForecastData()))     }+    @Test fun tripSummariesAreCappedAndSummaryOnly() {+        val trips = (1..15).map {+            com.vayunmathur.library.intents.travel.TripSummaryData(+                id = "t$it", name = "LHR to JFK $it", startMillis = 1_000L + it,+                status = "confirmed", type = "flight", destinationCount = 1,+            )+        }+        val text = com.vayunmathur.openassistant.platform.summarizeTripSummaries(trips)+        assertEquals(10, text.lines().size, text)+        assertTrue(text.contains("trip_id=t1 LHR to JFK 1"), text)+        assertTrue(text.contains("destinations=1"), text)+        assertEquals("No trips found", com.vayunmathur.openassistant.platform.summarizeTripSummaries(emptyList()))+    } }
travel/AGENTS.md
diff --git a/travel/AGENTS.md b/travel/AGENTS.mdindex e6c7f2dee6..e71c730700 100644--- a/travel/AGENTS.md+++ b/travel/AGENTS.md@@ -6,6 +6,8 @@ _Install: ./install travel (dev by default)._ - Gradle: :travel / dir: travel/ - Package roots present: ui, data, domain, network, platform - Entry files: MainActivity.kt, Route.kt, Navigation.kt+- Package roots present: ui, data, network, intents, domain, platform+- Entry files: MainActivity.kt (no Route.kt — search/results/booking/manage flow with pages) - Deps: :library:room, :library:network, :library:image, Stripe Android SDK (payment sheet) - Metadata: metadata_data/travel.md (present) - Rust: no / screenshotTest: yes@@ -21,6 +23,9 @@ _Install: ./install travel (dev by default)._ - `data/` Room (trips, local booking profiles, frequent-flyer, recent searches) + `domain/` on-device grouping/status + `network/` trip/stays DTOs + APIs **Architecture / data-flow:** `ui/` search/results/booking pages → `platform/TravelViewModel` (+ `TravelUiContract`/`TravelUiState`, per-area `Travel*Ops`) → `domain/` grouping + `data/TravelRepository` over Room + `network/TravelApi`/`StaysApi`; booked trips stay readable from Room when offline. Every `*Page` is a thin binder over a stateless `*Screen` (state + `*Actions` from `platform/TravelUiContract.kt`), which is what `src/screenshotTest` renders. **Entry points + reading order:** `MainActivity.kt` → `Navigation.kt` → `ui/HomePage.kt` → `ui/HomeScreen.kt` → `ui/FlightSearchForm.kt` → `platform/TravelViewModel.kt` → `platform/TravelSearchOps.kt` → `network/TravelApi.kt`.+- OpenAssistant read via `intents/GetTripsIntent` (`travel_get_trips`): stored trips as summaries only (name, dates, status, destination count), provider-capped at 10, behind the signature `ACCESS_TRAVEL` permission; no traveller, reference or cost data crosses+**Architecture / data-flow:** `ui/` search/results/booking pages → `util/TravelViewModel` (+ `TravelUiContract`/`TravelUiState`, per-area `Travel*Ops`) → `domain/` grouping + `data/TravelRepository` over Room + `network/TravelApi`/`StaysApi`; booked trips stay readable from Room when offline.+**Entry points + reading order:** `MainActivity.kt` → `ui/HomePage.kt` → `ui/FlightSearchForm.kt` → `util/TravelViewModel.kt` → `util/TravelSearchOps.kt` → `network/TravelApi.kt`. **Gotchas:** - Dialogs are routes: `Route.DatePickerDialog`/`DateRangeDialog`/`PassengerPickerDialog` (`DialogPage()` entries in `Navigation.kt`, stateless contents in `ui/dialogs/`, results via the nav result registry under the caller's key). `DateField`/`DateRangeFields`/`PassengerField` push them; never gate a picker on `remember` show-state - Booking is money-moving — price/availability must be re-confirmed server-side before payment, never trusted from cached offers@@ -42,6 +47,11 @@ _Install: ./install travel (dev by default)._ ### domain/ — on-device offer + trip logic - com/vayunmathur/travel/domain/OfferGrouping.kt - com/vayunmathur/travel/domain/TripStatus.kt+### intents/ — assistant IPC+- com/vayunmathur/travel/intents/GetTripsIntent.kt — `travel_get_trips` over `TravelRepository.getAllBookedTrips`+- com/vayunmathur/travel/intents/TripSummaries.kt — validated window/limit (max 10), summary mapping + destination count+### platform/ — in-app card payment (Stripe payment sheet)+- com/vayunmathur/travel/platform/StripeCheckout.kt ### network/ — airline + stays APIs - com/vayunmathur/travel/network/TravelApi.kt - com/vayunmathur/travel/network/OfferDto.kt
travel/src/main/AndroidManifest.xml
diff --git a/travel/src/main/AndroidManifest.xml b/travel/src/main/AndroidManifest.xmlindex 6f4f6067db..e158187146 100644--- a/travel/src/main/AndroidManifest.xml+++ b/travel/src/main/AndroidManifest.xml@@ -9,6 +9,10 @@     <uses-permission android:name="android.permission.INTERNET" />     <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> +    <permission+        android:name="com.vayunmathur.travel.permissions.ACCESS_TRAVEL"+        android:protectionLevel="signature" />+     <application         android:allowBackup="true"         android:dataExtractionRules="@xml/data_extraction_rules"@@ -31,6 +35,12 @@                 <category android:name="android.intent.category.DEFAULT" />             </intent-filter>         </activity>++        <activity+            android:name=".intents.GetTripsIntent"+            android:exported="true"+            android:permission="com.vayunmathur.travel.permissions.ACCESS_TRAVEL"+            android:theme="@android:style/Theme.NoDisplay" />     </application>  </manifest>
travel/src/main/java/com/vayunmathur/travel/intents/GetTripsIntent.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/intents/GetTripsIntent.kt b/travel/src/main/java/com/vayunmathur/travel/intents/GetTripsIntent.ktnew file mode 100644index 0000000000..e8be8f6c3d--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/intents/GetTripsIntent.kt@@ -0,0 +1,21 @@+package com.vayunmathur.travel.intents++import com.vayunmathur.library.intents.travel.TripSummaryData+import com.vayunmathur.library.intents.travel.TripsQuery+import com.vayunmathur.library.util.AssistantIntent+import com.vayunmathur.travel.data.TravelRepository+import java.time.LocalDate+import kotlinx.serialization.builtins.ListSerializer++/** Assistant tool `travel_get_trips`: stored trips as summaries only. */+class GetTripsIntent : AssistantIntent<TripsQuery, List<TripSummaryData>>(+    TripsQuery.serializer(),+    ListSerializer(TripSummaryData.serializer()),+) {+    override suspend fun performCalculation(input: TripsQuery): List<TripSummaryData> =+        selectTripSummaries(+            TravelRepository.get(this).getAllBookedTrips(),+            input,+            LocalDate.now(),+        )+}
travel/src/main/java/com/vayunmathur/travel/intents/TripSummaries.kt
diff --git a/travel/src/main/java/com/vayunmathur/travel/intents/TripSummaries.kt b/travel/src/main/java/com/vayunmathur/travel/intents/TripSummaries.ktnew file mode 100644index 0000000000..b22250d75c--- /dev/null+++ b/travel/src/main/java/com/vayunmathur/travel/intents/TripSummaries.kt@@ -0,0 +1,91 @@+package com.vayunmathur.travel.intents++import com.vayunmathur.library.intents.travel.TripSummaryData+import com.vayunmathur.library.intents.travel.TripsQuery+import com.vayunmathur.travel.data.BookedTrip+import com.vayunmathur.travel.data.TRIP_TYPE_STAY+import java.time.LocalDate++/** Hard provider-side cap for `travel_get_trips` (audit: limit at most 10). */+const val MAX_TRIP_LIMIT = 10++/** Default result count when the caller asks for none or an invalid count. */+const val DEFAULT_TRIP_LIMIT = 5++/** Display-name cap so one summary stays a short model-facing line. */+const val MAX_TRIP_NAME_CHARS = 120++private const val MILLIS_PER_DAY = 86_400_000L+private const val ROUND_TRIP_SUFFIX = "(round trip)"++/** Validated query: unknown windows fall back to upcoming, limit clamped. */+fun validatedTripsQuery(query: TripsQuery): TripsQuery {+    val window = query.`when`.trim().lowercase()+        .takeIf { it == "upcoming" || it == "past" || it == "all" } ?: "upcoming"+    val limit = if (query.limit <= 0) DEFAULT_TRIP_LIMIT else query.limit.coerceAtMost(MAX_TRIP_LIMIT)+    return TripsQuery(`when` = window, limit = limit)+}++/** Distinct destinations named by a stored route, without exposing it raw. */+fun destinationCount(route: String): Int {+    val cleaned = route.trim()+    if (cleaned.isBlank()) return 0+    if (!cleaned.contains('→')) return 1+    val parts = cleaned.split('→')+        .map { it.replace(ROUND_TRIP_SUFFIX, "").trim() }+        .filter { it.isNotBlank() }+    val origin = parts.firstOrNull()+    return parts.drop(1).filter { it != origin }.distinct().size+}++private fun tripDate(trip: BookedTrip): LocalDate? =+    runCatching { LocalDate.parse(trip.departDate.take(10)) }.getOrNull()++/** Maps one stored trip to its summary; only summary fields are copied. */+fun BookedTrip.toTripSummary(): TripSummaryData {+    val date = tripDate(this)+    return TripSummaryData(+        id = orderId,+        name = route.trim().ifBlank {+            if (type == TRIP_TYPE_STAY) "Stay" else "Flight trip"+        }.take(MAX_TRIP_NAME_CHARS),+        startMillis = date?.toEpochDay()?.times(MILLIS_PER_DAY),+        status = status,+        type = type,+        destinationCount = destinationCount(route),+    )+}++/**+ * Provider-side selection: filter by window, sort, then cap. Trips with+ * no parseable date count as upcoming and sort last there.+ */+fun selectTripSummaries(+    trips: List<BookedTrip>,+    query: TripsQuery,+    today: LocalDate,+): List<TripSummaryData> {+    val validated = validatedTripsQuery(query)+    val filtered = trips.filter { trip ->+        val date = tripDate(trip)+        when (validated.`when`) {+            "past" -> date != null && date.isBefore(today)+            "all" -> true+            else -> date == null || !date.isBefore(today)+        }+    }+    val sorted = if (validated.`when` == "upcoming") {+        filtered.sortedWith(+            compareBy<BookedTrip> { tripDate(it) == null }+                .thenBy { tripDate(it) }+                .thenByDescending { it.createdAt },+        )+    } else {+        filtered.sortedWith(+            compareBy<BookedTrip> { tripDate(it) == null }+                .thenByDescending { tripDate(it) }+                .thenByDescending { it.createdAt },+        )+    }+    return sorted.take(validated.limit).map { it.toTripSummary() }+}
travel/src/test/java/com/vayunmathur/travel/intents/GetTripsIntentTest.kt
diff --git a/travel/src/test/java/com/vayunmathur/travel/intents/GetTripsIntentTest.kt b/travel/src/test/java/com/vayunmathur/travel/intents/GetTripsIntentTest.ktnew file mode 100644index 0000000000..8cc734f3c4--- /dev/null+++ b/travel/src/test/java/com/vayunmathur/travel/intents/GetTripsIntentTest.kt@@ -0,0 +1,109 @@+package com.vayunmathur.travel.intents++import com.vayunmathur.library.intents.travel.TripSummaryData+import com.vayunmathur.library.intents.travel.TripsQuery+import com.vayunmathur.travel.data.BookedTrip+import java.time.LocalDate+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertFalse+import kotlin.test.assertTrue+import kotlinx.serialization.json.Json++/**+ * `travel_get_trips` provider contract: cap, window filtering and the+ * summaries-only guarantee. Seeded trips carry sensitive stored values;+ * none of them may appear in a summary or its serialized form.+ */+class GetTripsIntentTest {++    private val today: LocalDate = LocalDate.of(2026, 6, 15)++    private fun trip(+        id: String,+        route: String = "LHR → JFK",+        departDate: String = "2026-06-20",+        type: String = "flight",+    ) = BookedTrip(+        orderId = id,+        bookingReference = "SECRETREF-$id",+        route = route,+        departDate = departDate,+        amount = "987654.00",+        currency = "USD",+        passengersJson = """[{"givenName":"Ada","familyName":"Secret"}]""",+        status = "confirmed",+        type = type,+        lastName = "Secret",+        customerId = "cust-$id",+        createdAt = 1_000L,+    )++    @Test+    fun limitIsCappedAtTenAndDefaultsToFive() {+        val trips = (1..25).map { trip("t$it", departDate = "2026-06-${15 + (it % 10)}") }+        assertEquals(10, selectTripSummaries(trips, TripsQuery("all", 50), today).size)+        assertEquals(10, selectTripSummaries(trips, TripsQuery("all", 10), today).size)+        assertEquals(5, selectTripSummaries(trips, TripsQuery("all", 0), today).size)+        assertEquals(5, validatedTripsQuery(TripsQuery("bogus", -1)).limit)+        assertEquals("upcoming", validatedTripsQuery(TripsQuery("bogus", -1)).`when`)+    }++    @Test+    fun windowsFilterAndSortProviderSide() {+        val trips = listOf(+            trip("past", departDate = "2026-06-01"),+            trip("soon", departDate = "2026-06-16"),+            trip("later", departDate = "2026-07-01"),+        )+        assertEquals(+            listOf("soon", "later"),+            selectTripSummaries(trips, TripsQuery("upcoming", 10), today).map { it.id },+        )+        assertEquals(+            listOf("past"),+            selectTripSummaries(trips, TripsQuery("past", 10), today).map { it.id },+        )+        assertEquals(3, selectTripSummaries(trips, TripsQuery("all", 10), today).size)+    }++    @Test+    fun summaryHasNameDatesStatusAndDestinationCount() {+        val summary = trip("t1", route = "LHR → JFK → LHR", departDate = "2026-06-20")+            .toTripSummary()+        assertEquals("LHR → JFK → LHR", summary.name)+        assertEquals(LocalDate.of(2026, 6, 20).toEpochDay() * 86_400_000L, summary.startMillis)+        assertEquals("confirmed", summary.status)+        assertEquals(1, summary.destinationCount)+        assertEquals(1, trip("t2", route = "Paris Hotel", type = "stay").toTripSummary().destinationCount)+        assertEquals(0, destinationCount(""))+        assertTrue(trip("t3", route = "x".repeat(200)).toTripSummary().name.length <= 120)+    }++    @Test+    fun dtoHasNoSensitiveFieldsAndSummariesLeakNothing() {+        val fieldNames = TripSummaryData::class.java.declaredFields+            .filter { !it.isSynthetic && it.name != "Companion" && it.name != "\$stable" }+            .map { it.name.lowercase() }+        val banned = listOf(+            "passenger", "booking", "reference", "payment", "amount",+            "currency", "customer", "lastname", "givenname", "familyname",+            "email", "phone", "card", "price", "total",+        )+        banned.forEach { word ->+            assertFalse(fieldNames.any { it.contains(word) }, "field leaks $word: $fieldNames")+        }+        assertEquals(+            setOf("id", "name", "startmillis", "endmillis", "status", "type", "destinationcount"),+            fieldNames.toSet(),+        )+        val summaries = selectTripSummaries(listOf(trip("t1")), TripsQuery("all", 10), today)+        val json = Json.encodeToString(+            kotlinx.serialization.builtins.ListSerializer(TripSummaryData.serializer()),+            summaries,+        )+        listOf("SECRETREF", "Ada", "Secret", "987654", "cust-").forEach { secret ->+            assertFalse(json.contains(secret), "summary leaked $secret: $json")+        }+    }+}