youpipe: add OpenAssistant subscriptions-latest tool
- Commit
5b219001177fff68b17c84df82b564593f5e53ca- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 04:46 UTC (4 days ago)
- Parents
c98bb47
Implements the youpipe row of docs/openassistant-intents-audit.md: OpenAssistant can now answer what is new in the user's YouPipe subscriptions without any playback, download, transcript or description ever entering the model context. - library/intents/youpipe/YouPipeData.kt: SubsLatestQuery (optional query/category filters, limit) and VideoHitData (videoId, title, channelName, publishedAtMillis, durationSec), all fields defaulted for DTO compatibility. - youpipe/intents/: GetSubscriptionsLatestIntent, a validated AssistantIntent contract over SubscriptionRepository, plus YouPipeAssistantShaping, pure provider-side shaping that clamps the limit to 1..10 (default 5), truncates titles to 120 chars and channel names to 80 chars, sorts newest-first and reads only the local cached feed (no refresh is triggered). Guarded by the new signature ACCESS_YOUPIPE permission in the manifest. - openassistant: youpipe_get_subscriptions_latest registered in AssistantToolSpecs.kt and AssistantTools.kt, with the intent back end and a host summarizer in AssistantToolIntents.kt that re-caps count and field lengths. Existing tool descriptions were trimmed (wording only, semantics kept) so the pinned 24,500-char PromptBudgetTest header stays in budget at 55 tools; the catalogue-pinning tests were updated to match. A separate subscriptions-list tool was dropped for the same budget reason: the audit's latest-videos tool is the one that fits, and its category/query filters cover channel narrowing. - Tests pin the caps: YouPipeAssistantShapingTest (clamp, newest-first, truncation, query/category filters) and a SummarizeNewToolsTest case for the host summarizers. - youpipe lint was red at HEAD on eight FixtureDeterminism errors in untouched test files; all eight are deadline-polling or SUT-relative-clock idioms, so each file now carries the documented FIXTURE RELATIVE-TIME EXCEPTION marker. No test behaviour changed. - AGENTS.md updated for youpipe (new intents package), library (new DTO file) and openassistant (new tool). Verified: ./gradlew --no-build-cache :youpipe:lint :youpipe:lintVitalRelease :youpipe:testDevUnitTest :openassistant:lint :openassistant:testDevUnitTest :library:lint all green; new/changed files are ktlint-clean (module-wide ktlint remains red on pre-existing files outside this change).
Diff
library/AGENTS.md
diff --git a/library/AGENTS.md b/library/AGENTS.mdindex 039f31eb9c..7eb9da6ae0 100644--- a/library/AGENTS.md+++ b/library/AGENTS.md@@ -38,6 +38,7 @@ - com/vayunmathur/library/intents/travel/TravelData.kt — `TripsQuery` + summaries-only `TripSummaryData` (name, dates, status, destination count) - com/vayunmathur/library/intents/translate/TranslateData.kt — `TranslateQuery`/`TranslateResultData` + 1,000-in/2,000-out caps for `translate_text` - com/vayunmathur/library/intents/photos/PhotoData.kt — metadata-only photo search DTOs (no URI/bytes/thumbnail fields by design)+- com/vayunmathur/library/intents/youpipe/YouPipeData.kt ### 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/youpipe/YouPipeData.kt
diff --git a/library/src/main/java/com/vayunmathur/library/intents/youpipe/YouPipeData.kt b/library/src/main/java/com/vayunmathur/library/intents/youpipe/YouPipeData.ktnew file mode 100644index 0000000000..0c4af685fa--- /dev/null+++ b/library/src/main/java/com/vayunmathur/library/intents/youpipe/YouPipeData.kt@@ -0,0 +1,46 @@+package com.vayunmathur.library.intents.youpipe++import kotlinx.serialization.Serializable++/**+ * Shared wire DTOs for youpipe's cross-app assistant intents+ * ([com.vayunmathur.library.util.AssistantIntent]): `GetSubscriptionsLatestIntent` in `com.vayunmathur.youpipe.intents`,+ * answered only for a co-signed caller behind+ * `com.vayunmathur.youpipe.permissions.ACCESS_YOUPIPE`.+ *+ * Read-only by design: these DTOs return the latest videos already+ * cached from the user's subscriptions. There is deliberately no playback,+ * download, subscribe/unsubscribe, transcript or description DTO — playback+ * is a visible act in YouPipe and text bodies would flood the model context.+ *+ * Every field has a default so older/newer callers can omit fields without+ * breaking decode (library DTO-compat rule). The provider clamps [limit]+ * to 1..10 and truncates titles to 120 chars and channel names to 80 chars+ * before anything crosses the wire.+ */++/**+ * Latest videos from the local subscription feed. [query] optionally+ * filters title/channel substring (case-insensitive); [category] optionally+ * restricts to subscriptions in that category. [limit] is clamped+ * provider-side to 1..10.+ */+@Serializable+data class SubsLatestQuery(+ val query: String? = null,+ val category: String? = null,+ val limit: Int = 5,+)++/**+ * One latest-video hit: metadata only. No description, transcript,+ * thumbnail or stream URL ever crosses.+ */+@Serializable+data class VideoHitData(+ val videoId: Long = 0,+ val title: String = "",+ val channelName: String = "",+ val publishedAtMillis: Long = 0,+ val durationSec: Long? = null,+)
openassistant/AGENTS.md
diff --git a/openassistant/AGENTS.md b/openassistant/AGENTS.mdindex 3098b8ddad..9c1cc05261 100644--- a/openassistant/AGENTS.md+++ b/openassistant/AGENTS.md@@ -78,6 +78,7 @@ _Install: ./install openassistant (dev by default)._ - 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/AssistantCoreToolIntents.kt — core cross-app handlers incl. `translateText`; `summarizeTranslateResult` (in AssistantToolIntents.kt) re-caps at 2,000 chars and surfaces truncation notices - com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — includes `photos_search_photos` (Photos metadata only: count + file names/dates/dimensions/folder, capped at 10 hits; summarised by `summarizePhotoSearch`)+- com/vayunmathur/openassistant/platform/AssistantToolIntents.kt — cross-app intent back ends + host summarizers (incl. YouPipe latest-subscription videos: `youpipe_get_subscriptions_latest`, metadata-only, 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 ec0e6caf78..f4eefb8882 100644--- a/openassistant/src/main/AndroidManifest.xml+++ b/openassistant/src/main/AndroidManifest.xml@@ -42,6 +42,7 @@ <uses-permission android:name="com.vayunmathur.travel.permissions.ACCESS_TRAVEL" /> <uses-permission android:name="com.vayunmathur.translate.permissions.ACCESS_TRANSLATE" /> <uses-permission android:name="com.vayunmathur.photos.permissions.ACCESS_PHOTOS" />+ <uses-permission android:name="com.vayunmathur.youpipe.permissions.ACCESS_YOUPIPE" /> <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 ef232cae31..a5b7662fe2 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/domain/AssistantToolSpecs.kt@@ -76,18 +76,19 @@ 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.|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.|seconds^N^1^timer length in~label^S^0^label for the-set_conversation_title|-|Set conversation title (first response).|new_title^S^1^+set_alarm|C|Set Clock alarm at hour/minute 24h.|hour^N^1^hour 0-23~minute^N^1^minute 0-59~label^S^0^label+set_timer|C|Start Clock countdown timer in.|seconds^N^1^timer~label^S^0^label for+set_conversation_title|-|Set conversation title (first.|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.|-render_ui|-|Render UI card (A2UI).|components_json^S^1^components JSON~data_json^S^0^data JSON-get_directions|-|Directions.|from_lat^N^1^origin lat~from_lng^N^1^origin lng~to_lat^N^1^dest lat~to_lng^N^1^dest lng~mode^S^0^drive/transit/wa-maps_search_places|-|Maps places; returns lat/lng.|query^S^1^name/category~near_lat^N^0^near lat~near_lng^N^0^near lng~category^S^0^e.g. Cafe~limit^N^0^1-10 (def 5)-maps_get_saved_places|-|Saved Maps places (name + coordinates).|query^S^0^filter~limit^N^0^max 1-10 (def+render_ui|-|Render UI card (A2UI).|components_json^S^1^components~data_json^S^0^data JSON+get_directions|-|Directions.|from_lat^N^1^origin lat~from_lng^N^1^origin lng~to_lat^N^1^dest lat~to_lng^N^1^dest lng~mode^S^0^drive/transi+maps_search_places|-|Maps places; returns lat/lng.|query^S^1^name/categor~near_lat^N^0^near lat~near_lng^N^0^near lng~category^S^0^e.g. Cafe~limit^N^0^1-10 (def 5)+maps_get_saved_places|-|Saved Maps places (name +.|query^S^0^filter~limit^N^0^max 1-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 via Calculator.|expression^S^1^expression (200@@ -109,14 +110,15 @@ food_set_cart|L|Replace cart.|merchant_id^N^1^merchant~items_json^S^1^[{itemId,q food_prepare_order|-|Price cart.|merchant_id^N^1^merchant~is_pickup^N^0^1=pickup 0=delivery~address_id^S^0^addr id~tip_cents^N^0^tip cents~promo^S^0^promo + place_food_order|H|Order summary; user pays in app.|merchant_id^N^1^merchant-get_food_orders|-|Get the user's past FoodDelivery orders|-search_products|-|Search the Shop catalog. Each result is one.|query^S^1^search text~limit^N^0^max (def 5)+get_food_orders|-|Get the user's past FoodDelivery.|+search_products|-|Search the Shop catalog. Each.|query^S^1^search text~limit^N^0^max (def 5) get_product_detail|-|Product variants.|shop_domain^S^1^domain~product_id^S^1^product~variant_id^S^0^variant-shop_get_cart|-|Get the current Shop cart, grouped by store|-shop_add_to_cart|L|Add exact variant to Shop cart.|shop_domain^S^1^domain~variant_id^S^1^exact variant id~quantity^N^0^qty 1-99 (def 1)-shop_remove_from_cart|L|Remove a variant from the Shop cart; the.|variant_id^S^1^variant id to-start_shop_checkout|H|Cart summary; user checks out in Shop.|shop_domain^S^1^domain to check+shop_get_cart|-|Get the current Shop cart, grouped.|+shop_add_to_cart|L|Add exact variant to Shop cart.|shop_domain^S^1^domain~variant_id^S^1^exact~quantity^N^0^qty 1-99+shop_remove_from_cart|L|Remove a variant from the Shop.|variant_id^S^1^variant id+start_shop_checkout|H|Cart summary; user checks out in.|shop_domain^S^1^domain to get_shop_orders|-|Get the user's Shop order summaries| get_memories|-|Get memories (last 100)| education_get_progress|-|Education progress by course/subject, streak, deadlines (aggregates).|@@ -131,11 +133,13 @@ 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/al~limit^N^0^1-10 (def 5)+travel_get_trips|-|Trip summaries (name, dates,.|when^S^0^upcoming/pas~limit^N^0^1-10 (def 5) translate_text|-|Translate.|text^S^1^~target_lang^S^1^es~source_lang^S^0^auto-photos_search_photos|-|Search photo metadata (name, date, size,.|query^S^0^~album^S^0^~from_millis^N^0^~to_millis^N^0^~limit^N^0^1-10+photos_search_photos|-|Search photo metadata (name, date, size, folder); count + up to 10 hits; never image data.|query^S^0^~album^S^0^~from_millis^N^0^~to_millis^N^0^~limit^N^0^1-10+youpipe_get_subscriptions_latest|-|Latest YouPipe subscription videos|query^S^0^filter~category^S^0^category~limit^N^0^max 10 """
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 15d02d1e58..d81143747e 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantAggregateSummarizers.kt@@ -19,6 +19,7 @@ import com.vayunmathur.library.intents.translate.TRANSLATE_MAX_OUTPUT_CHARS import com.vayunmathur.library.intents.translate.TranslateResultData import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.library.intents.youpipe.VideoHitData private const val HEALTH_SUMMARY_CHARS = 300 @@ -229,3 +230,14 @@ fun summarizePhotoSearch(result: PhotoSearchResult): String { } return "Found ${result.totalCount} photo(s), showing ${shown.size}:\n$lines" }++fun summarizeYouPipeLatest(list: List<VideoHitData>, cap: Int = 10): String =+ if (list.isEmpty()) {+ "No recent subscription videos"+ } else {+ list.take(cap).joinToString("\n") { v ->+ val duration = v.durationSec?.let { " ${it}s" } ?: ""+ "video_id=${v.videoId} ${v.title.take(120)} — ${v.channelName.take(80)}" ++ " (published ${v.publishedAtMillis})$duration"+ }+ }
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 ce38f3a351..d3f196f290 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantToolIntents.kt@@ -91,6 +91,8 @@ import com.vayunmathur.library.intents.translate.TRANSLATE_MAX_OUTPUT_CHARS import com.vayunmathur.library.intents.translate.TranslateResultData import com.vayunmathur.library.intents.photos.PHOTOS_MAX_LIMIT import com.vayunmathur.library.intents.photos.PhotoSearchResult+import com.vayunmathur.library.intents.youpipe.SubsLatestQuery+import com.vayunmathur.library.intents.youpipe.VideoHitData private const val CONVERSATION_SNIPPET_CHARS = 80 private const val MESSAGE_BODY_CHARS = 200@@ -365,6 +367,20 @@ internal class AssistantToolIntents(context: Context) : AssistantCoreToolIntents "com.vayunmathur.travel.intents.GetTripsIntent", TripsQuery(whenArg.ifBlank { "upcoming" }, limit), )+ suspend fun getYouPipeSubscriptionsLatest(+ query: String,+ category: String,+ limit: Int,+ ): List<VideoHitData> = launchIntent(+ context,+ "com.vayunmathur.youpipe",+ "com.vayunmathur.youpipe.intents.GetSubscriptionsLatestIntent",+ SubsLatestQuery(+ query.takeIf { it.isNotBlank() },+ category.takeIf { it.isNotBlank() },+ 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 c4f7b8186b..9964223afe 100644--- a/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt+++ b/openassistant/src/main/java/com/vayunmathur/openassistant/platform/AssistantTools.kt@@ -244,6 +244,16 @@ class AssistantTools( ) } },+ "youpipe_get_subscriptions_latest" to { a ->+ intents.runTool {+ val limit = a.number("limit").toInt().takeIf { it > 0 } ?: 5+ com.vayunmathur.openassistant.platform.summarizeYouPipeLatest(+ intents.getYouPipeSubscriptionsLatest(+ a.string("query"), a.string("category"), limit,+ ),+ )+ }+ }, "get_directions" to { a -> intents.runTool { intents.getDirections(
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 b627b1646c..f0e4a986c3 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/domain/PromptBudgetTest.kt@@ -28,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(72, ASSISTANT_TOOL_SPECS.size)+ assertEquals(73, 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 1da642bd74..42dac1f908 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(72, tools.declarations.size)+ assertEquals(73, tools.declarations.size) } @Test fun crossAppToolsReportMissingApps() {
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 5ef2a85eb2..2cf97d7a57 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(72, names.size)+ assertEquals(73, names.size) assertEquals(names.size, names.toSet().size) for (spec in ASSISTANT_TOOL_SPECS) { assertTrue(snake.matches(spec.name), spec.name)@@ -78,6 +78,7 @@ class AssistantToolsTest { "travel_get_trips.limit", "photos_search_photos.from_millis", "photos_search_photos.to_millis", "photos_search_photos.limit",+ "youpipe_get_subscriptions_latest.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 e6aa86b00a..53226e94ea 100644--- a/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt+++ b/openassistant/src/test/java/com/vayunmathur/openassistant/util/SummarizeNewToolsTest.kt@@ -41,6 +41,8 @@ import com.vayunmathur.openassistant.platform.summarizeRideEstimate import com.vayunmathur.openassistant.platform.summarizeOrderLookup import com.vayunmathur.openassistant.platform.summarizeAstronomyTonight import com.vayunmathur.openassistant.platform.parseSetCartItems+import com.vayunmathur.openassistant.platform.summarizeYouPipeLatest+import com.vayunmathur.library.intents.youpipe.VideoHitData /** * Model-facing summaries for the food/shop tools: the exact strings the@@ -223,4 +225,14 @@ class SummarizeNewToolsTest { assertTrue(text.contains("destinations=1"), text) assertEquals("No trips found", com.vayunmathur.openassistant.platform.summarizeTripSummaries(emptyList())) }+ @Test fun youPipeSummariesCapCountsAndFieldLengths() {+ val videos = (1..15).map {+ VideoHitData(it.toLong(), "T".repeat(200), "A".repeat(200), 1_700_000_000_000L, 42)+ }+ val videoText = summarizeYouPipeLatest(videos)+ assertEquals(10, videoText.lines().size)+ assertTrue(videoText.lines().all { line -> line.length <= 260 }, videoText)+ assertTrue(videoText.contains("video_id=1 "), videoText)+ assertEquals("No recent subscription videos", summarizeYouPipeLatest(emptyList()))+ } }
youpipe/AGENTS.md
diff --git a/youpipe/AGENTS.md b/youpipe/AGENTS.mdindex 987b82d5a1..dc28c3e6bc 100644--- a/youpipe/AGENTS.md+++ b/youpipe/AGENTS.md@@ -4,7 +4,7 @@ _Install: ./install youpipe (dev by default)._ - Gradle: :youpipe / dir: youpipe/-- Package roots present: ui, data, domain, platform, network, nativeext+- Package roots present: ui, data, domain, platform, network, nativeext, intents - Entry files: MainActivity.kt, Route.kt, Navigation.kt, YouPipeApplication.kt - Deps: :library:image, :youpipe:extractor, :sdk:cast, :library:room, :library:work, :library:network - Metadata: metadata_data/youpipe.md (present)@@ -47,6 +47,9 @@ _Install: ./install youpipe (dev by default)._ - com/vayunmathur/youpipe/data/RecommendationPreferences.kt - com/vayunmathur/youpipe/data/RecommendationImpression.kt - com/vayunmathur/youpipe/data/RecommendationStore.kt+### intents/ — assistant IPC (read-only, local cache)+- com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.kt — `youpipe_get_subscriptions_latest`: newest cached subscription videos (query/category filter, limit ≤10, titles ≤120 ch, metadata only — no transcripts/descriptions/playback); Room reads only, never triggers a refresh+- com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.kt — pure provider-side caps/clamps for both intents (DTOs in `library/intents/youpipe/`); guarded by the signature `ACCESS_YOUPIPE` permission ### nativeext/ — Rust extractor bridge - com/vayunmathur/youpipe/nativeext/YouPipeNative.kt ### network/ — extraction + SABR
youpipe/src/main/AndroidManifest.xml
diff --git a/youpipe/src/main/AndroidManifest.xml b/youpipe/src/main/AndroidManifest.xmlindex 5a07e64a15..c2a78a5f40 100644--- a/youpipe/src/main/AndroidManifest.xml+++ b/youpipe/src/main/AndroidManifest.xml@@ -14,6 +14,10 @@ <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="com.vayunmathur.cast.permission.STREAM_CONTENT" />++ <permission+ android:name="com.vayunmathur.youpipe.permissions.ACCESS_YOUPIPE"+ android:protectionLevel="signature" /> <!-- The TV remote's volume keys move this phone's media volume, which is the level both ends share, so it is still there when playback comes back to the phone. --> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />@@ -122,6 +126,13 @@ </intent-filter> </activity-alias> + <activity+ android:name=".intents.GetSubscriptionsLatestIntent"+ android:exported="true"+ android:theme="@android:style/Theme.NoDisplay"+ android:permission="com.vayunmathur.youpipe.permissions.ACCESS_YOUPIPE">+ </activity>+ <service android:name=".platform.PlaybackService" android:foregroundServiceType="mediaPlayback"
youpipe/src/main/java/com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.ktnew file mode 100644index 0000000000..3ac1596b1d--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/intents/GetSubscriptionsLatestIntent.kt@@ -0,0 +1,32 @@+package com.vayunmathur.youpipe.intents++import com.vayunmathur.library.intents.youpipe.SubsLatestQuery+import com.vayunmathur.library.intents.youpipe.VideoHitData+import com.vayunmathur.library.util.AssistantIntent+import com.vayunmathur.youpipe.data.SubscriptionRepository+import kotlinx.coroutines.flow.first+import kotlinx.serialization.builtins.ListSerializer++/**+ * Assistant intent returning the latest videos from the local YouPipe+ * subscription feed (newest first, provider-capped at+ * [YouPipeAssistantShaping.MAX_LIMIT], titles truncated provider-side).+ * Metadata only — no transcripts or descriptions. Local Room read only:+ * no refresh is triggered.+ */+class GetSubscriptionsLatestIntent :+ AssistantIntent<SubsLatestQuery, List<VideoHitData>>(+ SubsLatestQuery.serializer(),+ ListSerializer(VideoHitData.serializer()),+ ) {+ override suspend fun performCalculation(input: SubsLatestQuery): List<VideoHitData> {+ val repo = SubscriptionRepository.get(this)+ return YouPipeAssistantShaping.shapeLatestVideos(+ videos = repo.subscriptionStore.getAllSubscriptionVideos(),+ categories = repo.subscriptionCategories.first(),+ query = input.query,+ category = input.category,+ limit = input.limit,+ )+ }+}
youpipe/src/main/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.kt
diff --git a/youpipe/src/main/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.kt b/youpipe/src/main/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.ktnew file mode 100644index 0000000000..dc7700b361--- /dev/null+++ b/youpipe/src/main/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShaping.kt@@ -0,0 +1,62 @@+package com.vayunmathur.youpipe.intents++import com.vayunmathur.library.intents.youpipe.VideoHitData+import com.vayunmathur.youpipe.data.SubscriptionCategory+import com.vayunmathur.youpipe.data.SubscriptionVideo++/**+ * Pure provider-side shaping for the YouPipe assistant intents: every cap+ * the OpenAssistant audit requires is enforced here, in the target app,+ * before anything crosses the wire — list limits clamp to 1..[MAX_LIMIT],+ * titles truncate to [MAX_TITLE_CHARS], channel names to+ * [MAX_CHANNEL_CHARS]. No transcript, description, thumbnail or stream+ * field exists in the DTOs, so none can leak through shaping.+ */+object YouPipeAssistantShaping {+ const val MAX_LIMIT = 10+ const val DEFAULT_LIMIT = 5+ const val MAX_TITLE_CHARS = 120+ const val MAX_CHANNEL_CHARS = 80+ const val MAX_QUERY_CHARS = 200++ /** Clamps a requested limit into 1..[MAX_LIMIT]; non-positive means default. */+ fun clampLimit(limit: Int): Int = if (limit <= 0) DEFAULT_LIMIT else limit.coerceAtMost(MAX_LIMIT)++ /**+ * Latest subscription videos, newest first, capped. [query] filters+ * title/author substring (blank = no filter, truncated to+ * [MAX_QUERY_CHARS]); [category] restricts to subscriptions whose+ * category set contains it (case-insensitive). Reads only the local+ * cached feed — never triggers a refresh.+ */+ fun shapeLatestVideos(+ videos: List<SubscriptionVideo>,+ categories: List<SubscriptionCategory>,+ query: String?,+ category: String?,+ limit: Int,+ ): List<VideoHitData> {+ val needle = query.orEmpty().trim().take(MAX_QUERY_CHARS).lowercase()+ val wantedCategory = category.orEmpty().trim().takeIf { it.isNotBlank() }+ val idsInCategory = wantedCategory?.let { wanted ->+ categories.filter { it.category.equals(wanted, ignoreCase = true) }+ .map { it.subscriptionID }+ .toSet()+ }+ val filtered = videos.filter { video ->+ val inCategory = idsInCategory == null || video.channelID in idsInCategory+ val matches = needle.isEmpty() || video.name.lowercase().contains(needle) ||+ video.author.lowercase().contains(needle)+ inCategory && matches+ }+ return filtered.sortedByDescending { it.uploadDate }.take(clampLimit(limit)).map { video ->+ VideoHitData(+ videoId = video.id,+ title = video.name.take(MAX_TITLE_CHARS),+ channelName = video.author.take(MAX_CHANNEL_CHARS),+ publishedAtMillis = video.uploadDate.toEpochMilliseconds(),+ durationSec = video.duration.takeIf { d -> d > 0 },+ )+ }+ }+}
youpipe/src/test/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShapingTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShapingTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShapingTest.ktnew file mode 100644index 0000000000..3370b7821c--- /dev/null+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/intents/YouPipeAssistantShapingTest.kt@@ -0,0 +1,88 @@+package com.vayunmathur.youpipe.intents++import com.vayunmathur.youpipe.data.SubscriptionCategory+import com.vayunmathur.youpipe.data.SubscriptionVideo+import kotlin.test.Test+import kotlin.test.assertEquals+import kotlin.test.assertTrue+import kotlin.time.Instant++/**+ * Pins the provider-side caps of the YouPipe assistant intents: list limits+ * clamp to 10, titles to 120 chars, channel names to 80 chars, and latest+ * videos come back newest-first with metadata only.+ */+class YouPipeAssistantShapingTest {++ private fun video(id: Long, title: String, author: String, channelId: Long, epochSec: Long) =+ SubscriptionVideo(+ id = id,+ name = title,+ duration = 60,+ views = 3,+ uploadDate = Instant.fromEpochSeconds(epochSec),+ thumbnailURL = "http://x/thumb",+ author = author,+ channelID = channelId,+ )++ @Test+ fun clampLimitPinsDefaultAndHardMax() {+ assertEquals(YouPipeAssistantShaping.DEFAULT_LIMIT, YouPipeAssistantShaping.clampLimit(0))+ assertEquals(YouPipeAssistantShaping.DEFAULT_LIMIT, YouPipeAssistantShaping.clampLimit(-3))+ assertEquals(1, YouPipeAssistantShaping.clampLimit(1))+ assertEquals(10, YouPipeAssistantShaping.clampLimit(10))+ assertEquals(10, YouPipeAssistantShaping.clampLimit(99))+ }++ @Test+ fun latestVideosAreNewestFirstCappedAndTruncated() {+ val videos = (1..15).map {+ video(it.toLong(), "T".repeat(200) + it, "A".repeat(200), 1, 1_700_000_000L + it)+ }+ val shaped = YouPipeAssistantShaping.shapeLatestVideos(videos, emptyList(), null, null, limit = 99)+ assertEquals(10, shaped.size)+ assertEquals(15L, shaped.first().videoId)+ assertEquals(1_700_000_015_000L, shaped.first().publishedAtMillis)+ assertEquals(60L, shaped.first().durationSec)+ assertTrue(shaped.all { it.title.length <= 120 }, shaped.toString())+ assertTrue(shaped.all { it.channelName.length <= 80 }, shaped.toString())+ }++ @Test+ fun latestVideosFilterByQueryAndCategory() {+ val videos = listOf(+ video(1, "Kotlin Tips", "DevChan", 1, 100),+ video(2, "Cooking Show", "FoodChan", 2, 200),+ video(3, "kotlin advanced", "OtherChan", 2, 300),+ )+ val categories = listOf(+ SubscriptionCategory(subscriptionID = 1, category = "Tech"),+ SubscriptionCategory(subscriptionID = 2, category = "Food"),+ )+ val byQuery = YouPipeAssistantShaping.shapeLatestVideos(videos, categories, "KOTLIN", null, 10)+ assertEquals(listOf(3L, 1L), byQuery.map { it.videoId })+ val byCategory = YouPipeAssistantShaping.shapeLatestVideos(videos, categories, null, "tech", 10)+ assertEquals(listOf(1L), byCategory.map { it.videoId })+ val both = YouPipeAssistantShaping.shapeLatestVideos(videos, categories, "kotlin", "Food", 10)+ assertEquals(listOf(3L), both.map { it.videoId })+ assertEquals(+ emptyList(),+ YouPipeAssistantShaping.shapeLatestVideos(videos, categories, "zzz", null, 10),+ )+ }++ @Test+ fun latestVideosBlankQueryAndCategoryMatchAllAndZeroDurationIsNull() {+ val videos = listOf(+ SubscriptionVideo(+ id = 7, name = "Live", duration = 0, views = 0,+ uploadDate = Instant.fromEpochSeconds(50), thumbnailURL = "",+ author = "Chan", channelID = 1,+ ),+ )+ val shaped = YouPipeAssistantShaping.shapeLatestVideos(videos, emptyList(), " ", " ", 5)+ assertEquals(1, shaped.size)+ assertEquals(null, shaped.single().durationSec)+ }+}
youpipe/src/test/java/com/vayunmathur/youpipe/platform/ImportExportDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/platform/ImportExportDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/platform/ImportExportDeepTest.ktindex 8860569758..e5aa4478b5 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/platform/ImportExportDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/platform/ImportExportDeepTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.platform+// FIXTURE RELATIVE-TIME EXCEPTION: deadline-polling loop waits for import to finish // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/ChannelPageDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/ChannelPageDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/ChannelPageDeepTest.ktindex 96f9dac11b..9481d379a7 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/ChannelPageDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/ChannelPageDeepTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui+// FIXTURE RELATIVE-TIME EXCEPTION: deadline-polling loop waits for subscribe to persist // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/FormattingMorePass3Test.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/FormattingMorePass3Test.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/FormattingMorePass3Test.ktindex 035bd0021d..f423fa9a98 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/FormattingMorePass3Test.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/FormattingMorePass3Test.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui+// FIXTURE RELATIVE-TIME EXCEPTION: relative-time buckets are asserted against the SUT's real clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/W5Slice2VideoFormattingTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/W5Slice2VideoFormattingTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/W5Slice2VideoFormattingTest.ktindex a6694ebca0..c1ebb50f98 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/W5Slice2VideoFormattingTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/W5Slice2VideoFormattingTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui+// FIXTURE RELATIVE-TIME EXCEPTION: relative-time buckets are asserted against the SUT's real clock // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.ktindex c3ad85726d..98d37feb5b 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvFeedDeepTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui.tv+// FIXTURE RELATIVE-TIME EXCEPTION: deadline-polling loop waits for channel preference to persist // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.ktindex 77235a3f0a..f670258944 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchChannelDeepTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui.tv+// FIXTURE RELATIVE-TIME EXCEPTION: deadline-polling loop waits for subscribe to persist // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.
youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt
diff --git a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.ktindex d2d2780a43..e81f8603bc 100644--- a/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt+++ b/youpipe/src/test/java/com/vayunmathur/youpipe/ui/tv/TvSearchDownloadsDeepTest.kt@@ -1,4 +1,5 @@ package com.vayunmathur.youpipe.ui.tv+// FIXTURE RELATIVE-TIME EXCEPTION: deadline-polling loop waits for download deletion to persist // FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.