Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / docs / openassistant-intents-audit.md
| 1 | # OpenAssistant Intents Audit — Modern-Apps |
| 2 | |
| 3 | Date: 2026-12-01 (America/Denver) · Branch: `agent-oa-intents` · Worktree: |
| 4 | `/home/vayun/code/wt-oa-intents` · Scope read: `openassistant/` + |
| 5 | `library/` (`intents/`, `util/AssistantIntent.kt`) + every app's |
| 6 | `AGENTS.md` overview + each app's `intents/` package where one exists. |
| 7 | No app code was changed. This is an audit + design document only. |
| 8 | |
| 9 | ## 0. How to read this, and the context rule |
| 10 | |
| 11 | **Verified mechanism (not assumed).** Cross-app assistant calls go through |
| 12 | `AssistantIntent<In,Out>` (`library/util/AssistantIntent.kt`): a NoDisplay |
| 13 | `ComponentActivity` in the target app decodes JSON `DATA`, runs |
| 14 | `suspend performCalculation(input)`, and replies with JSON `RESPONSE_DATA` |
| 15 | over a `ResultReceiver`. `IntentLauncher` (same file) serialises launches |
| 16 | with a mutex and a 30 s timeout. Shared wire DTOs live in |
| 17 | `library/src/main/java/com/vayunmathur/library/intents/<app>/`; each app |
| 18 | exposes validated contracts in `<app>/.../intents/`. OpenAssistant |
| 19 | dispatches via `domain/AssistantToolSpecs.kt` (the catalogue: name, risk, |
| 20 | description, params) **and** `platform/AssistantTools.kt` (the handler |
| 21 | map) — an `init` check fails if they disagree. Host-side back ends are |
| 22 | `platform/AssistantCoreToolIntents.kt` (notes/todo/contacts/calendar/ |
| 23 | family/music/email/clock/weather/maps/taxi) and |
| 24 | `platform/AssistantToolIntents.kt` (communicate/food/shop + summarizers). |
| 25 | Tool names are snake_case. Risk classes in the catalogue: `-` = READ, |
| 26 | `C` = WRITE_CONFIRM (gated through a pending-call store, executed once |
| 27 | via `invokeConfirmed`), `L` = WRITE_LIGHT (executed immediately, result |
| 28 | rendered back), `H` = HANDOFF_PREP (prepares a summary; the user acts in |
| 29 | the target app; never money-moving). |
| 30 | |
| 31 | **Why size caps are the whole game.** `PromptBudgetTest` pins the system |
| 32 | header (default prompt + A2UI section + *all tool declarations*) at |
| 33 | ≤ 24,500 chars (≈ 6k tokens at ~4 chars/token). The on-device model |
| 34 | (Gemma 4 E2B) then fits history (`domain/HistoryFit`) and up to 6 tool |
| 35 | rounds (`domain/ToolLoop`). Every tool result is re-injected as text, so |
| 36 | one unbounded result evicts history and can dominate all later rounds. |
| 37 | **Design rule applied to every proposal below (owner's rule, restated as |
| 38 | a contract):** |
| 39 | |
| 40 | 1. Inputs are **filtered or query-based**: a text query, a date/range |
| 41 | window, a category/enum filter, an id from a prior search — never |
| 42 | "give me everything". |
| 43 | 2. Result counts are **capped provider-side** (validated/clamped in the |
| 44 | app's `intents/` backend, not just in the spec text), and the host |
| 45 | summarizer truncates each text field to a stated char cap. |
| 46 | 3. A full-dataset return is allowed **only** when the dataset is provably |
| 47 | small; the bound is named (e.g. "≤ 20 family members in practice, |
| 48 | hard-cap 50"). |
| 49 | 4. Estimates below use chars ÷ 4 ≈ tokens. "Typical" assumes realistic |
| 50 | personal data; "max" is the contractual worst case after caps. |
| 51 | |
| 52 | **Good existing patterns to copy.** `AssistantWebTools`: `web_search` |
| 53 | clamps count 1–10 and reshapes to `{title,url,snippet}`; `web_read` |
| 54 | returns 6,000-char pages paged by offset, with a 2M-char fetch cap and a |
| 55 | 4-page × 24k cache. Food/shop/communicate backends clamp limits |
| 56 | provider-side (`MAX_RESTAURANT_LIMIT=50`, `MAX_SEARCH_LIMIT=50`, |
| 57 | `MAX_FIND_LIMIT=50`/`MAX_MESSAGES_LIMIT=100`) and host summarizers cap |
| 58 | per-item text (conversation snippet 80 chars, message body 200 chars, |
| 59 | menu shown 24 items, orders shown 10). Calendar's provider caps at 500 |
| 60 | events explicitly to stay under the binder transaction limit. |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ## 1. What exists today |
| 65 | |
| 66 | ### 1.1 Tool catalogue (54 tools) |
| 67 | |
| 68 | Counted from `TOOL_DATA` in `AssistantToolSpecs.kt` and the handler map |
| 69 | in `AssistantTools.kt` (they agree — the init check enforces it). |
| 70 | |
| 71 | | App / surface | Tool | R/W | Input → Output (wire DTO) | Host summarizer? | |
| 72 | |---|---|---|---|---| |
| 73 | | notes | `get_notes` | R | `Unit → List<NoteData{title,content}>` | **No — raw `.toString()`** | |
| 74 | | notes | `create_note` | C | `NoteData → Unit` | n/a (success string) | |
| 75 | | todo | `get_todos` | R | `GetTodosQuery{scope} → List<TodoData>` (provider cap 200) | **No — raw `.toString()`** | |
| 76 | | todo | `create_todo` | C | `InsertTodoData → String(id)` | n/a | |
| 77 | | todo | `complete_todo` | C | `CompleteTodoData{id|title} → Boolean` | n/a | |
| 78 | | contacts | `get_contacts` | R | `Unit → List<ContactData{name,phone}>` | **No — raw `.toString()`** | |
| 79 | | contacts | `search_contacts` | R | query → filters the full list **host-side**, cap 10 | Yes (filter) | |
| 80 | | contacts | `create_contact` | C | `ContactData → Unit` | n/a | |
| 81 | | calendar | `get_calendar_events` | R | `Unit → List<EventData>` (provider cap 500) | **No — raw `.toString()`** | |
| 82 | | calendar | `create_calendar_event` | C | `EventData → Unit` (validated) | n/a | |
| 83 | | findfamily | `get_family_locations` | R | `Unit → List<FamilyMemberData{name,locationName,lat,lon}>` | **No — raw `.toString()`** | |
| 84 | | findfamily | `create_location_share_link` | C | `{name,duration} → String(link)` | n/a | |
| 85 | | music | `search_music` | R | `String(query) → List<MusicSearchResult{id,name,type}>` | **No cap anywhere** | |
| 86 | | music | `play_music` | C | `PlayMusicData{id,type} → Unit` | n/a | |
| 87 | | email | `search_emails` | R | `EmailSearchQuery → List<EmailData>` (DAO LIMIT 30) | **No — raw `.toString()`, body ≤2,000 ch each** | |
| 88 | | email | `get_recent_emails` | R | `Unit → List<EmailData>` (DAO LIMIT 30) | **No — same** | |
| 89 | | clock | `set_alarm` | C | `SetAlarmData{hour,minute,label} → Unit` | n/a | |
| 90 | | clock | `set_timer` | C | `SetTimerData{seconds,label} → Unit` | n/a | |
| 91 | | weather | `get_weather` | R | `{lat,lon} → WeatherData` (single record) | `.toString()` of one record — fine | |
| 92 | | weather | `get_weather_by_name` | R | `{name} → WeatherData` (geocode limit 1) | fine | |
| 93 | | maps | `get_directions` | R | `DirectionsRequest{coords,mode} → DirectionsResult{polyline,segments,totals}` | **Yes — totals + segment count only** | |
| 94 | | taxi | `get_ride_estimate` | R | `RideEstimateRequest → RideEstimateResult` | Yes — one line | |
| 95 | | fooddelivery | `food_order_lookup` | R | `OrderLookupRequest → OrderLookupResult` | Yes — one line | |
| 96 | | fooddelivery | `find_restaurants` | R | `FindRestaurants{query?,lat,lng,limit=5}` (backend cap 50) | Yes — address ≤60 ch | |
| 97 | | fooddelivery | `get_restaurant_menu` | R | `GetMenu{merchantId} → MenuData` (full menu over the wire) | Yes — 24 items shown | |
| 98 | | fooddelivery | `food_get_cart` | R | `GetCart → CartData` | Yes | |
| 99 | | fooddelivery | `food_set_cart` | L | `SetCart{merchantId,items}` (re-validated) | Yes — cart rendered back | |
| 100 | | fooddelivery | `food_prepare_order` | R | `PrepareOrder → OrderSummaryData` (prices only, creates nothing) | Yes | |
| 101 | | fooddelivery | `place_food_order` | H | merchantId → priced summary + `fooddelivery://checkout` | Yes — user pays in-app | |
| 102 | | fooddelivery | `get_food_orders` | R | `GetOrders → List<OrderData>` | Yes — cap 10 | |
| 103 | | shop | `search_products` | R | `SearchProductsQuery{query,limit=5}` (backend cap 50) | Yes — one line/variant | |
| 104 | | shop | `get_product_detail` | R | `GetProductQuery → ProductDetailData` (description field exists) | Yes — variants only, **description dropped** | |
| 105 | | shop | `shop_get_cart` | R | `Unit → CartData` (grouped by store) | Yes | |
| 106 | | shop | `shop_add_to_cart` | L | `AddToCartRequest` (exact variant re-verified) | Yes — cart rendered back | |
| 107 | | shop | `shop_remove_from_cart` | L | `RemoveFromCartRequest{variantId} → CartData` | Yes | |
| 108 | | shop | `start_shop_checkout` | H | shop_domain → per-store summary + `shop://cart` | Yes — user checks out in-app | |
| 109 | | shop | `get_shop_orders` | R | `Unit → List<OrderData>` | Yes — cap 10 | |
| 110 | | communicate | `find_conversations` | R | `FindConversationsQuery{query,limit=5}` (backend cap 50) | Yes — snippet ≤80 ch | |
| 111 | | communicate | `get_conversation_messages` | R | `GetMessagesQuery{threadKey,limit=10}` (backend cap 100) | Yes — body ≤200 ch/msg | |
| 112 | | communicate | `draft_message` | R* | recipient/line/body → A2UI composer card | Sends nothing (*renders UI) | |
| 113 | | communicate | `send_message_v2` | C | `SendMessageRequest → SendMessageResult` (GV typed-refused) | Yes | |
| 114 | | openassistant (internal) | `get_memories` / `add_to_memory` / `remove_memory` | R / R(!) / C | Room `MemoryDao` direct | **No cap on `get_memories`** | |
| 115 | | openassistant (internal) | `get_local_current_date_time`, `set_conversation_title` | R | device direct | tiny | |
| 116 | | openassistant (device) | `get_app_list` | R | launcher activities → labels | **No cap — raw list `.toString()`** | |
| 117 | | openassistant (device) | `open_app` | R(!) | package_id → launch intent | side effect, classified READ | |
| 118 | | openassistant (device, legacy) | `send_message` | R(!) | recipient+message → opens SMS composer (`ACTION_SENDTO`) | **Not WRITE_CONFIRM — see §1.3** | |
| 119 | | openassistant (device, legacy) | `make_phone_call` | R(!) | recipient → opens dialer (`ACTION_DIAL`) | **Not WRITE_CONFIRM — see §1.3** | |
| 120 | | openassistant (web) | `web_search` | R | query, count 1–10, kind text/news | Yes — `{title,url,snippet}` | |
| 121 | | openassistant (web) | `web_read` / `web_read_result` | R | url / index+offset | Yes — 6,000-ch pages | |
| 122 | | openassistant (UI) | `render_ui` | R | A2UI JSON, ≤12,000 ch enforced | n/a | |
| 123 | |
| 124 | DTO packages present in `library/intents/`: calendar, clock, communicate, |
| 125 | contacts, email, euicc (see §1.4), findfamily, fooddelivery, maps, music, |
| 126 | notes, shop, taxi, todo, weather. Apps with an `intents/` package: |
| 127 | calendar, clock, communicate, contacts, email, findfamily, fooddelivery, |
| 128 | logviewer (see §1.4), maps, music, notes, shop, taxi, todo, weather. |
| 129 | |
| 130 | ### 1.2 Data-volume estimates for existing reads |
| 131 | |
| 132 | | Tool | Typical | Worst case today | Verdict | |
| 133 | |---|---|---|---| |
| 134 | | `get_notes` | 30 notes × ~600 ch ≈ 18k ch (~4.5k tok) | 500 notes × 10k ch content — **unbounded** | 🔴 flood risk | |
| 135 | | `get_contacts` | 300 × ~35 ch ≈ 10k ch (~2.6k tok) | 5,000 contacts ≈ 175k ch | 🔴 flood + binder risk | |
| 136 | | `get_calendar_events` | 500 × ~60 ch ≈ 30k ch (~7.5k tok) | capped at 500, still ~30k ch | 🟠 too big for a "what's on" answer | |
| 137 | | `get_todos` | 200 × ~80 ch ≈ 16k ch (scope=today usually ≪) | 200 cap, ~16k ch | 🟠 shrink cap for `all` | |
| 138 | | `search_emails` / `get_recent_emails` | 30 × (subject+from+≤2,000 ch body) ≈ up to 66k ch (~16k tok) | same — DAO LIMIT 30 is the only cap | 🔴 **biggest single flood** | |
| 139 | | `search_music` | query-dependent; 4 entity types concatenated, **no cap** | whole library matches a common letter | 🔴 uncapped | |
| 140 | | `get_family_locations` | 5–15 members × ~60 ch ≈ 1k ch | unbounded in code; dataset provably small (family) | 🟢 add hard cap 50 anyway | |
| 141 | | `get_app_list` | 100–300 labels ≈ 3–8k ch | ~300+ labels | 🟠 cap/sort or query-based | |
| 142 | | `get_memories` | user-grown list, one line each | unbounded over years | 🟠 cap (e.g. last 100) | |
| 143 | | `get_conversation_messages` | 10 × ≤200 ch ≈ 2k ch | limit=100 → ~21k ch | 🟢 typical fine; clamp spec max to 50 | |
| 144 | | `get_restaurant_menu` | summarizer shows 24 items (~3k ch to model) | full `MenuData` (100+ items + modifiers) crosses the binder | 🟢 model-side fine; 🟠 wire-side: page provider-side | |
| 145 | | `get_weather`, `get_directions`, `get_ride_estimate`, `food_order_lookup` | single record / one line | — | 🟢 exemplars | |
| 146 | | `find_restaurants`, `search_products`, orders, carts | ≤5–10 short lines | backend caps 50 if model asks | 🟢 good | |
| 147 | | `web_search` / `web_read` | ≤10 hits / 6k ch page | — | 🟢 exemplar | |
| 148 | |
| 149 | ### 1.3 Risk-classification findings (existing) |
| 150 | |
| 151 | - `send_message` and `make_phone_call` (legacy device tools) are |
| 152 | classified READ (`-`) but open a composer/dialer. They do not send or |
| 153 | call directly (user taps), so impact is low — but they should be |
| 154 | re-classified or folded into `draft_message` / a dialer handoff, and |
| 155 | the catalogue should not carry two send paths (`send_message` vs |
| 156 | `send_message_v2`). |
| 157 | - `add_to_memory` is READ-class yet writes. It is the model's own memory |
| 158 | and `remove_memory` is WRITE_CONFIRM, so this looks deliberate; note |
| 159 | it, don't churn it. |
| 160 | - `open_app` is READ-class with a visible side effect (foregrounds an |
| 161 | app). Acceptable, worth a spec-wording tweak only. |
| 162 | - Writes that move money **do not exist** — by design. Food/shop use |
| 163 | HANDOFF_PREP + in-app checkout; travel (below) must follow the same |
| 164 | rule. Deletes: none exposed except `remove_memory` (confirm-gated) and |
| 165 | `shop_remove_from_cart` (light, local cart only). This is the right |
| 166 | posture; proposals keep it. |
| 167 | |
| 168 | ### 1.4 `intents/` ≠ assistant coverage |
| 169 | |
| 170 | - `euicc`: `library/intents/euicc/EsimLink.kt` is a shared eSIM deep-link |
| 171 | constant, not an `AssistantIntent`. No OA tool. Correct — see §4. |
| 172 | - `logviewer`: `intents/` holds `LogcatActivity`/`ErrorReportActivity` |
| 173 | entry points, not assistant contracts. No OA tool. |
| 174 | - `maps`: `intents/` also hosts cross-app *clients* (`OrderLookupClient`, |
| 175 | `RideEstimateClient`, `FamilyLocationClient`) — maps consuming |
| 176 | food/taxi/findfamily, not OA tools. |
| 177 | - `code`: "handles VIEW/EDIT intents" = Android intent filters, not |
| 178 | assistant intents. |
| 179 | |
| 180 | --- |
| 181 | |
| 182 | ## 2. Design rules for every proposal |
| 183 | |
| 184 | Each proposal names: tool (snake_case) · app · read/action (risk class) · |
| 185 | input DTO · output DTO + max response size · contract location |
| 186 | (`library/intents/<app>/…` DTOs + `<app>/…/intents/…Intent.kt` provider + |
| 187 | two OA touchpoints: `AssistantToolSpecs.kt` row + `AssistantTools.kt` |
| 188 | handler with a host summarizer in `AssistantToolIntents.kt`). |
| 189 | |
| 190 | Universal caps unless stated otherwise: list limit default 5, hard max |
| 191 | 20 (search) / 10 (detail lists); title ≤ 120 ch; snippet/body excerpt |
| 192 | ≤ 300 ch; one-line summaries ≤ 200 ch; ids are short stable strings from |
| 193 | the provider. **No proposal returns a full feed, full library, full |
| 194 | history, full document, or full message/email body.** Bodies are |
| 195 | available only through a follow-up get-by-id with a stated char cap and |
| 196 | offset paging where the text can be long (the `web_read` pattern). |
| 197 | |
| 198 | Priorities: **P0** = clear user value + small data + provider data |
| 199 | already local/queryable. **P1** = valuable, needs a new provider query |
| 200 | or moderate DTO work. **P2** = niche, sensitive, or larger design surface. |
| 201 | |
| 202 | --- |
| 203 | |
| 204 | ## 3. Proposed tools |
| 205 | |
| 206 | ### 3.0 P0 — News (owner-named; currently zero intents) |
| 207 | |
| 208 | News has **no** `intents/` package and no DTOs. Verified shape: feed is |
| 209 | Room-cached `CachedArticle{url,sourceId,title,publishedAtMillis,imageUrl, |
| 210 | keywords,bookmarked,storyId,storyOneLiner,storyTitle}` (cache pruned to |
| 211 | 500), grouped into `domain/Story` (server `storyId` only); categories are |
| 212 | `NewsCategory{WORLD,US,TECHNOLOGY,SCIENCE,LOCAL}` derived from the source |
| 213 | catalog; on-device search (`NewsRepository.search` + `domain/NewsSearch`, |
| 214 | relevance-ranked) already exists over titles/keywords/source/bodies of |
| 215 | opened articles; article bodies are extracted on device |
| 216 | (`NewsRepository.articleBody(url) → ExtractedArticle{blocks}`) and can be |
| 217 | long. **Never return the 500-article cache or an extracted body whole.** |
| 218 | |
| 219 | | Tool | R/W | Input DTO | Output DTO + cap | Max size | |
| 220 | |---|---|---|---|---| |
| 221 | | `news_search_headlines` | R | `NewsSearchQuery{query:String (req, ≤200 ch), category:String? (enum name), limit:Int=5 (clamp 1–10)}` | `List<NewsHeadlineData{storyId,url,title≤160 ch,sourceName,sourceCount,publishedAtMillis,oneLiner≤200 ch?}>` | 10 × ~350 ch ≈ **3.5k ch (~0.9k tok)** | |
| 222 | | `news_top_stories` | R | `NewsTopQuery{category:String?=null, local:Boolean=false, limit:Int=5 (clamp 1–10)}` | same `NewsHeadlineData` list, feed ranking (sourceCount desc, newest) | ≈ **3.5k ch** | |
| 223 | | `news_get_story` | R | `NewsStoryQuery{storyId:String (from search/top)}` | `NewsStoryData{title,oneLiner≤300 ch,members≤8×{title≤160 ch,sourceName,publishedAtMillis,url}}` | ≈ **2k ch** | |
| 224 | | `news_read_article` | R | `NewsArticleQuery{url:String (req, from a prior result), offset:Int=0}` | `NewsArticleExcerptData{title,byline?,excerpt≤3,000 ch,nextOffset:Int?}` — extracted paragraphs joined + truncated **provider-side**; paging by offset like `web_read` | **3k ch (~0.75k tok)**/page | |
| 225 | | `news_get_bookmarks` | R | `NewsBookmarksQuery{limit:Int=10 (clamp 1–20)}` | `List<NewsHeadlineData>` (bookmarked only) | 20 × ~350 ≈ **7k ch** worst; typical ≪ | |
| 226 | | `news_set_bookmark` | C (WRITE_CONFIRM) | `NewsBookmarkRequest{url,bookmarked:Boolean}` | `String` success | tiny | |
| 227 | |
| 228 | Contracts: `library/intents/news/NewsData.kt` (DTOs above) + |
| 229 | `news/.../intents/{SearchHeadlinesIntent,TopStoriesIntent,GetStoryIntent, |
| 230 | ReadArticleIntent,GetBookmarksIntent,SetBookmarkIntent}.kt` over |
| 231 | `NewsRepository` (search/top/bookmarks are Room reads; `read_article` |
| 232 | reuses `articleBody()` then truncates — the full `ExtractedArticle` must |
| 233 | **not** cross as-is). Privacy: all local; the only network the provider |
| 234 | may already do is its normal refresh — the intents should read the cache |
| 235 | and **not** trigger a refresh (stale headlines beat a 30 s tool timeout). |
| 236 | |
| 237 | Also note the overlap: `web_search kind=news` already searches the web |
| 238 | for news. These tools answer "what's in **my** news app / my feed / my |
| 239 | bookmarks" and read articles the app has already extracted — different |
| 240 | data, no duplication problem. |
| 241 | |
| 242 | ### 3.1 P0 — fixes to existing floods (no new app, shrink the wire) |
| 243 | |
| 244 | These are not new tools; they are cap retrofits the audit ranks P0 |
| 245 | because the tools already exist and already flood: |
| 246 | |
| 247 | | Fix | Change | |
| 248 | |---|---| |
| 249 | | `get_notes` → add `search_notes` | New `SearchNotesQuery{query,limit=10}` returning title + ≤200 ch excerpt; deprecate raw `get_notes` or cap it provider-side (limit param, content ≤300 ch/note). Contract: `library/intents/notes/` + `notes/intents/SearchIntent.kt`. | |
| 250 | | `get_contacts` | Cap provider-side (e.g. 200, sorted) as a binder guard; steer the model to `search_contacts` (already capped 10). Long-term: make `search_contacts` query provider-side instead of fetching all contacts to the host. | |
| 251 | | `search_emails`/`get_recent_emails` | Split DTO: list calls return `EmailData` **without body** (subject/from/date/isRead + ≤200 ch snippet); add `get_email_excerpt` (get-by-id, body ≤3,000 ch + offset). Needs an `id` field on `EmailData` (additive, defaulted — DTO-compat rule). | |
| 252 | | `search_music` | Provider-side cap 20 total (songs/albums/artists/playlists share the budget), spec gains optional `limit`. | |
| 253 | | `get_calendar_events` | Add range input (`CalendarQuery{fromMillis,toMillis,limit=50}`); default window = next 7 days. Keep 500 as a binder guard, not the model-visible size. | |
| 254 | | `get_todos(scope=all)` | Lower model-visible cap to 50 for `all` (provider already caps 200 for binder safety; summarizer-side take(50)). | |
| 255 | | `get_app_list` | Cap 100 sorted labels, or add `query` filter. | |
| 256 | | `get_memories` | Return last 100 (id desc) with a "(N more)" line. | |
| 257 | | `get_conversation_messages` | Clamp spec max 100 → 50 (backend already clamps; align the catalogue). | |
| 258 | |
| 259 | ### 3.2 P0/P1 — new app coverage |
| 260 | |
| 261 | | # | Tool | App | R/W | Input → Output (caps) | Max | Pri | |
| 262 | |---|---|---|---|---|---|---| |
| 263 | | 1 | `maps_search_places` | maps | R | `MapsPlaceSearchQuery{query,lat?,lng?,limit=5 (≤10)}` → `List<PlaceData{id,name≤120,address≤120,lat,lng,category?}>`. Today OA can only route between raw coordinates — it cannot answer "coffee near X" or resolve a place name to coordinates for `get_directions`/`get_ride_estimate`. This is the missing front door for three existing tools. Contracts: `library/intents/maps/PlaceData.kt` + `maps/intents/SearchPlacesIntent.kt` (offline POI index; no Google calls). | ~2.5k ch | **P0** | |
| 264 | | 2 | `health_get_metric_summary` | health | R | `HealthMetricQuery{metric:enum(steps,sleep,heart_rate,weight,hydration,…), range:enum(today,7d,30d)}` → `HealthMetricSummaryData{metric,range,latestValue?,average?,min?,max?,total?,unit,recordCount}` — **aggregates only** (`HealthRepository.sumInRange/getDailySums/getLastRecord` already exist). Never raw record lists. Contracts: `library/intents/health/` + `health/intents/GetMetricSummaryIntent.kt`. Sensitive: health data — read-only, no export of FHIR records, see §5. | ~300 ch | **P0** | |
| 265 | | 3 | `health_get_medications` | health | R | `HealthMedsQuery{date:String?=today}` → `List<MedicationDoseData{name≤80,dose≤40,scheduledTimeMillis,taken:Boolean?}>` cap 20. Answers "what do I take tonight?" — `MedicationSchedule` + `DoseScheduler` already model this. No dose changes proposed. | ~2k ch | **P0** | |
| 266 | | 4 | `flashcards_get_due_summary` | flashcards | R | `FlashcardsDueQuery{deckId:Long?=null}` → `DueSummaryData{dueCount,newCount,deckName?,nextDueMillis?}` or per-deck list cap 10 × `{deckId,deckName≤80,dueCount}`. Counts only — card fronts/backs stay out (a deck can hold thousands). Contracts: `library/intents/flashcards/` + `flashcards/intents/GetDueIntent.kt` (FSRS due query provider-side). | ~1k ch | **P0** | |
| 267 | | 5 | `translate_text` | translate | R (compute) | `TranslateQuery{text≤1,000 ch (req), targetLang (req, BCP-47/catalog code), sourceLang?=auto}` → `TranslateResultData{translatedText≤2,000 ch,detectedLang?}`. Pure on-device NLLB via `domain/TranslationEngine`; degrade with typed error when models aren't downloaded. Contracts: `library/intents/translate/` + `translate/intents/TranslateIntent.kt`. | ~2k ch | **P0** | |
| 268 | | 6 | `calculator_evaluate` | calculator | R (compute) | `EvaluateQuery{expression≤200 ch}` → `EvaluateResultData{result:String≤100,error?}` over the app's pure `Expression` helpers. | ~200 ch | **P0** | |
| 269 | | 7 | `calculator_convert_unit` | calculator | R (compute) | `ConvertQuery{value:Double,fromUnit,toUnit}` (ids from `domain/UnitRegistry`; currency pair allowed — rates are the app's one network call) → `ConvertResultData{result,unit,rate?,asOfMillis?}`. | ~300 ch | **P0** | |
| 270 | | 8 | `travel_get_trips` | travel | R | `TripsQuery{when:enum(upcoming,past,all)=upcoming, limit=5 (≤10)}` → `List<TripSummaryData{id,title≤120,startMillis,endMillis,status,origin?,destination?}>` from on-device Room (`getAllBookedTrips`, filtered/sorted provider-side). **No booking, no payment, no passenger PII** (no `Customer`/`FrequentFlyer` DTOs). Contracts: `library/intents/travel/` + `travel/intents/GetTripsIntent.kt`. | ~2k ch | **P0** | |
| 271 | | 9 | `screentime_get_usage` | screentime | R | `UsageQuery{period:enum(today,yesterday,7d)=today, limit=8 (≤15)}` → `UsageSummaryData{totalMillis,apps≤15×{label≤60,packageName,millis,limitMillis?,paused}}`. Aggregates from `platform/UsageHistory`; typed empty result when usage access isn't granted. Contracts: `library/intents/screentime/` + `screentime/intents/GetUsageIntent.kt`. | ~2k ch | **P1** | |
| 272 | | 10 | `photos_search_photos` | photos | R | `PhotoSearchQuery{query (content/OCR/person text), limit=10 (≤20)}` → `List<PhotoHitData{id,takenMillis,albumName?≤60,matchReason:enum(content,ocr,person,textMatch≤120)}` — **metadata only**: no image bytes, no paths the model could exfiltrate, no secure-folder results ever. Provider reuses the existing combined search. Contracts: `library/intents/photos/` + `photos/intents/SearchPhotosIntent.kt`. Follow-up open-in-app stays a deep link the user taps. | ~2.5k ch | **P1** | |
| 273 | | 11 | `astronomy_get_tonight` | astronomy | R | `TonightQuery{lat,lng,dateMillis?=today,limit=8 (≤12)}` → `List<SkyObjectData{id,name≤80,type,riseMillis?,setMillis?,peakAltitudeDeg?,magnitude?}>` from `domain/engine` rise/set calculators over bundled catalogs. Fully offline; dataset is a bounded catalog, results are computed, not dumped. Contracts: `library/intents/astronomy/` + `astronomy/intents/TonightIntent.kt`. | ~2k ch | **P1** | |
| 274 | | 12 | `web_get_bookmarks` | web | R | `BookmarkSearchQuery{query?=blank→recent, limit=10 (≤20)}` → `List<BookmarkData{title≤120,url≤300,folder?≤60}>`. | ~4k ch worst | **P1** | |
| 275 | | 13 | `web_search_history` | web | R | `HistorySearchQuery{query (req), limit=10 (≤20)}` → `List<HistoryHitData{title≤120,url≤300,visitedMillis}>`. **Private tabs excluded provider-side** (verify no private rows are stored; if they are, filter by flag). Contracts (12–13): `library/intents/web/` + `web/intents/…Intent.kt`. | ~4k ch worst | **P1** | |
| 276 | | 14 | `youpipe_get_subscriptions_latest` | youpipe | R | `SubsLatestQuery{category?=null, limit=8 (≤15)}` → `List<VideoHitData{videoId,title≤140,channelName≤80,publishedMillis,durationSec?}>` from the local subscription feed. Plus P2 `youpipe_search_history{query,limit}` over watch history. **No playback/download actions** (playback is a visible UI act; downloads are bulk data movement). Contracts: `library/intents/youpipe/` + `youpipe/intents/…`. | ~3k ch | **P1** | |
| 277 | | 15 | `files_search_files` | files | R | `FileSearchQuery{query (name substring, req), limit=15 (≤25)}` → `List<FileHitData{name≤120,path≤200,sizeBytes?,modifiedMillis,isDirectory}>` — name search only (MediaStore/SAF index), **no content reads, no move/copy/delete**. Contracts: `library/intents/files/` + `files/intents/SearchFilesIntent.kt`. | ~5k ch worst | **P1** | |
| 278 | | 16 | `appstore_search_apps` | appstore | R | `AppStoreSearchQuery{query, limit=8 (≤15)}` → `List<AppHitData{packageName,name≤80,source,securityTier≤80,versionName?≤40,summary≤200}>` over `searchLocal` (already limit-shaped). **No install/update action** — installs are signature-verified, user-reviewed acts (§5). Contracts: `library/intents/appstore/` + `appstore/intents/SearchAppsIntent.kt`. | ~3k ch | **P1** | |
| 279 | | 17 | `appstore_get_updates` | appstore | R | `Unit → List<AppUpdateData{packageName,name≤80,installedVersion≤40,availableVersion≤40,source}>` cap 20, via `updatesFor(installed)`. Provably small (installed-app count, hard cap). | ~3k ch | **P1** | |
| 280 | | 18 | `education_get_progress` | education | R | `ProgressQuery{}` → `ProgressSummaryData{learnerFirstName?≤40,band,streakDays,skillsStarted,skillsMastered, dueDeadlines≤5×{title≤80,dueMillis}}` — aggregates over `skillProgressFlow/deadlinesFlow`. Kids' data: first name only, read-only, no per-answer history. Contracts: `library/intents/education/` + `education/intents/GetProgressIntent.kt`. | ~1k ch | **P1** | |
| 281 | | 19 | `get_weather_forecast` | weather | R (extension) | `WeatherForecastQuery{location (name) or lat/lng, days=3 (clamp 1–7)}` → `List<ForecastDayData{dateMillis,highC,lowC,condition≤60,precipChancePercent}>`. Existing tools return *current* only; the app already fetches daily arrays to build `WeatherData`. Contracts: extend `library/intents/weather/` + new `weather/intents/GetForecastIntent.kt`. | 7 × ~120 ≈ **0.9k ch** | **P1** | |
| 282 | | 20 | `maps_get_saved_places` | maps | R | `SavedPlacesQuery{query?=null, limit=10 (≤20)}` → `List<PlaceData>` (same DTO as #1) from `SavedPlaceStore`. | ~2.5k ch | **P1** | |
| 283 | | 21 | `music_get_now_playing` + `music_get_playlists` | music | R | `Unit → NowPlayingData{title≤120,artist≤80,album≤80?,isPlaying,positionSec?,durationSec?}`; `Unit → List<PlaylistData{id,name≤80,trackCount}>` cap 20. Small, bounded. Contracts: extend `library/intents/music/` + `music/intents/…`. | ~1.5k ch | **P1** | |
| 284 | | 22 | `flashcards_search_cards` | flashcards | R | `CardSearchQuery{query, deckId?, limit=8 (≤10)}` → `List<CardHitData{cardId,deckName≤80,frontExcerpt≤200,backExcerpt≤200,dueMillis?}>`. Excerpts, never whole decks. | ~3.5k ch | **P1** | |
| 285 | | 23 | `office_list_recent_documents` | office | R | `RecentDocsQuery{query?=null, limit=10 (≤20)}` → `List<DocumentData{name≤120,kind:enum(text,sheet,slides,other),modifiedMillis,sizeBytes?}>` — recents metadata only. **No document content extraction** (documents are unbounded; a future get-by-id excerpt tool needs its own design + E2EE-collab exclusion). Contracts: `library/intents/office/` + `office/intents/ListRecentIntent.kt`. | ~3k ch | **P2** | |
| 286 | | 24 | `things_get_hydration` | things | R | `HydrationQuery{date?=today}` → `HydrationData{totalMl,goalMl,sipCount,lastSipMillis?}` — only when a bottle is paired; typed unavailable otherwise. Tiny and genuinely assistant-shaped ("how much water today?"). Contracts: `library/intents/things/` + `things/intents/GetHydrationIntent.kt`. | ~200 ch | **P2** | |
| 287 | | 25 | `games_get_achievements_summary` | games/hub | R | `Unit → AchievementSummaryData{level,xp,streakDays,recent≤5×{game≤60,achievement≤100,earnedMillis}}` via `:sdk:games` reporting data. Fun, tiny, zero risk. Contracts: `library/intents/games/` + hub `intents/`. | ~1k ch | **P2** | |
| 288 | | 26 | `email_draft_email` | email | C-prep (HANDOFF_PREP-like) | `DraftEmailRequest{to≤200,subject≤200,body≤4,000}` → opens composer prefilled in Email; **sending stays a user tap in Email**. Never a direct send tool. Contracts: `library/intents/email/` + `email/intents/DraftIntent.kt` (activity handoff, not a silent write). | tiny | **P2** | |
| 289 | | 27 | `calendar_get_events_in_range` | calendar | R | (See §3.1 — this is the `get_calendar_events` retrofit, listed there.) | — | P0* | |
| 290 | | 28 | `backup_get_status` | backup | R | `Unit → BackupStatusData{lastBackupMillis?,lastResult≤80,scheduled:Boolean,nextPlannedMillis?}` — status scalars only. **No restore, no backup trigger, no file lists, no key material** (§5). Contracts: `library/intents/backup/` + `backup/intents/GetStatusIntent.kt`. | ~300 ch | **P2** | |
| 291 | |
| 292 | ### 3.3 News worked example (the shape every proposal follows) |
| 293 | |
| 294 | User: *"What's happening in tech, and summarize the main story."* |
| 295 | |
| 296 | 1. `news_top_stories{category:"TECHNOLOGY", limit:5}` → 5 headlines with |
| 297 | `storyId`s, ≤ 3.5k chars total. The model picks one. |
| 298 | 2. `news_get_story{storyId}` → server one-liner + ≤ 8 member headlines |
| 299 | across sources (~2k chars) — enough to summarize *coverage*. |
| 300 | 3. Only if the user wants depth: `news_read_article{url, offset:0}` → |
| 301 | ≤ 3,000 chars of extracted text; further pages via `offset` (the |
| 302 | `web_read` contract). At no point do 500 cached articles, the full |
| 303 | feed JSON, or a whole extracted body enter context. |
| 304 | |
| 305 | --- |
| 306 | |
| 307 | ## 4. Apps deliberately skipped (and why) |
| 308 | |
| 309 | | App(s) | Why no intent | |
| 310 | |---|---| |
| 311 | | `passwords` | Vault contents must never enter an LLM context — credential exfiltration by design. No search, no get, no exceptions. (Autofill already serves the user without the assistant.) | |
| 312 | | `euicc` | Privileged LPA: profile enable/disable/delete/download are carrier-grade, irreversible-ish acts. The existing `EsimLink` deep link is the right surface. | |
| 313 | | `vpn` | Config import/connect state is security posture; an assistant toggling a tunnel or reading per-app bypass creates risk with near-zero conversational value. At most a future read-only `vpn_get_status{connected,configName≤60}` — P2 backlog, not proposed. | |
| 314 | | `updater` | A/B OTA apply/reboot is privileged and irreversible; status is already surfaced by system notifications. No tool. | |
| 315 | | `parentalcontrols` | PIN-gated supervision controls. Bypassing the PIN via assistant — even read-only rule dumps — defeats the product. Skip entirely. | |
| 316 | | `emergency` | Lockscreen medical/SOS surface. Reading medical info into chat is a privacy regression; triggering SOS is dangerous. Skip. (Health §3.2 #2–3 covers the *user's own, unlocked, in-app* health queries.) | |
| 317 | | `backup` (actions) | Restore/trigger/key handling excluded; only the scalar status read in §3.2 #28 survives, P2. | |
| 318 | | `camera` | Capture is a physical, permission-gated act with viewfinder state; "take a photo" via a headless intent produces blind photos and privacy surprises. Recent-photo questions belong to `photos` metadata search (#10). | |
| 319 | | `keyboard`, `speech` | IMEs and speech engines are system services already invoked directly by the user/OS. `speech` output via assistant adds a lossy hop; use device TTS settings instead. No tool. | |
| 320 | | `launcher`, `setupwizard`, `watch`, `auto`, `cast`, `share`, `networklocation`, `measure`, `tuner`, `logviewer` | System plumbing / one-shot surfaces / hardware-in-the-loop tools. No conversational query or safe action: launcher state duplicates `get_app_list`; setup is one-time; watch/auto/cast are transports; measure/tuner need live sensors in hand; logviewer output is *exactly* the massive-data case (logcat) — a future `logviewer_get_recent_crashes{limit=3, excerpt≤500}` is conceivable but P2 backlog, not proposed here. | |
| 321 | | `games/*` (all 12, except hub summary #25) | Game state (boards, hands, positions) is large, fast-moving, and useless in text form; no safe action. Hub aggregates are the only assistant-shaped data. | |
| 322 | | `everysync` | Sync engine; its *sinks* (notes/todos/contacts/passwords) are already covered by the sink apps' tools. Exposing vault metadata adds attack surface for no user question it answers better than the sink apps. Password-vault sync: doubly excluded (see `passwords`). | |
| 323 | | `findfamily-ios`, `apple/*` | SwiftPM/xtool target, not an Android `AssistantIntent` host. Out of scope for this mechanism. | |
| 324 | | `openassistant` itself | Already the dispatcher; internal tools (memory, web, device, render_ui) are §1.1. No self-intent. | |
| 325 | | `code` | File contents are unbounded and workspace-shaped; "search my project" needs a repo-scoped design (and leaks code into chat by default). Revisit only as `code_search_symbols{query,limit}` with path/title hits — P2 backlog, not proposed. | |
| 326 | | `things` (actions), `health` (writes), `travel` (booking), `fooddelivery`/`shop` (checkout), `appstore` (installs) | Actions excluded or handoff-only — see §5. Reads proposed where safe. | |
| 327 | |
| 328 | --- |
| 329 | |
| 330 | ## 5. Privacy & safety rules (binding on any implementation) |
| 331 | |
| 332 | 1. **Money never moves.** No place-order, book, pay, install-with-payment, |
| 333 | or checkout-creation tool — the existing food/shop HANDOFF_PREP pattern |
| 334 | (priced summary → user acts in-app) is the ceiling. Travel follows it: |
| 335 | trips are read-only; booking stays in `travel`. |
| 336 | 2. **Sends are confirm-gated or handoff.** `send_message_v2` already |
| 337 | requires WRITE_CONFIRM. New message/email creation is composer-handoff |
| 338 | (#26) — never silent send. The legacy device `send_message` (§1.3) |
| 339 | should be retired or reclassed when next touched. |
| 340 | 3. **Deletes: none proposed.** No delete-note/contact/event/photo/file/ |
| 341 | order tool in this audit. Cart-line removal (existing, local, light) |
| 342 | and bookmark toggle (#news, WRITE_CONFIRM) are the outer limit. |
| 343 | 4. **Location is sensitive.** `get_family_locations` already returns live |
| 344 | coordinates — keep it, but any *new* location-shaped tool must return |
| 345 | place names first and coordinates only when the caller already holds |
| 346 | them (the `maps_search_places` proposal takes optional user-supplied |
| 347 | coords, it does not read family location). |
| 348 | 5. **Health & education are read-only aggregates.** No FHIR record |
| 349 | export, no medication edits, no learner answer history. Results are |
| 350 | numbers/schedules the user already sees on their dashboard. |
| 351 | 6. **Credentials & vaults: absolute exclusion** (`passwords`, backup keys, |
| 352 | euicc profiles). Not read-only, not "just metadata" — nothing. |
| 353 | 7. **Provider-side validation is mandatory.** Every proposed intent |
| 354 | clamps limits, validates enums/ranges, and truncates text in the |
| 355 | *target app* (the food/shop/communicate backend pattern), because the |
| 356 | catalogue spec is model-facing text, not enforcement. Co-signed caller |
| 357 | + the app's `ACCESS_*` permission where the app already has one |
| 358 | (communicate/shop/fooddelivery pattern); add the permission for news/ |
| 359 | health/photos on first implementation. |
| 360 | 8. **No silent triggers.** Intents read the local cache/store; they do |
| 361 | not kick off syncs, refreshes, scans, or downloads (30 s launcher |
| 362 | timeout; stale data with an honest timestamp beats a hang). |
| 363 | |
| 364 | --- |
| 365 | |
| 366 | ## 6. Priority summary |
| 367 | |
| 368 | **P0 (do first):** News read trio (`news_search_headlines`, |
| 369 | `news_top_stories`, `news_get_story` + `news_read_article`), the §3.1 |
| 370 | flood retrofits (`search_notes`, email split, music/calendar/todos caps), |
| 371 | `maps_search_places`, `health_get_metric_summary`, |
| 372 | `health_get_medications`, `flashcards_get_due_summary`, `translate_text`, |
| 373 | `calculator_evaluate`, `calculator_convert_unit`, `travel_get_trips`. |
| 374 | |
| 375 | **P1:** `screentime_get_usage`, `photos_search_photos`, |
| 376 | `astronomy_get_tonight`, `web_get_bookmarks`, `web_search_history`, |
| 377 | `youpipe_get_subscriptions_latest`, `files_search_files`, |
| 378 | `appstore_search_apps`, `appstore_get_updates`, |
| 379 | `education_get_progress`, `get_weather_forecast`, `maps_get_saved_places`, |
| 380 | `music_get_now_playing`/`music_get_playlists`, `flashcards_search_cards`, |
| 381 | `news_get_bookmarks`/`news_set_bookmark`. |
| 382 | |
| 383 | **P2:** `office_list_recent_documents`, `things_get_hydration`, |
| 384 | `games_get_achievements_summary`, `email_draft_email`, |
| 385 | `backup_get_status`. Backlog-only (named, not designed): `vpn_get_status`, |
| 386 | `logviewer_get_recent_crashes`, `code_search_symbols`. |
| 387 | |
| 388 | ### Top 10 proposed tools (with hard caps) |
| 389 | |
| 390 | | # | Tool | App | Cap that keeps it safe | |
| 391 | |---|---|---|---| |
| 392 | | 1 | `news_search_headlines` | news | limit ≤ 10; title ≤ 160 ch; one-liner ≤ 200 ch | |
| 393 | | 2 | `news_top_stories` | news | limit ≤ 10; category-filtered; feed-ranked | |
| 394 | | 3 | `news_read_article` | news | 3,000-ch excerpt pages by offset; never whole body | |
| 395 | | 4 | `maps_search_places` | maps | limit ≤ 10; name/address ≤ 120 ch | |
| 396 | | 5 | `health_get_metric_summary` | health | aggregates only; zero raw records | |
| 397 | | 6 | `translate_text` | translate | input ≤ 1,000 ch; output ≤ 2,000 ch | |
| 398 | | 7 | `travel_get_trips` | travel | limit ≤ 10; summaries only; no PII fields in DTO | |
| 399 | | 8 | `flashcards_get_due_summary` | flashcards | counts only; zero card text | |
| 400 | | 9 | `news_get_story` | news | ≤ 8 member headlines; one-liner ≤ 300 ch | |
| 401 | | 10 | `calculator_evaluate` / `calculator_convert_unit` | calculator | expression ≤ 200 ch; scalar results | |
| 402 | |
| 403 | ## 7. Verification of this audit |
| 404 | |
| 405 | Read-only. Sources: `AssistantToolSpecs.kt` (54-row catalogue), |
| 406 | `AssistantTools.kt` handler map, `AssistantCoreToolIntents.kt` / |
| 407 | `AssistantToolIntents.kt` (launch targets + summarizers), all 17 |
| 408 | `library/intents/*` DTO files, per-app `intents/` listings, provider |
| 409 | caps grepped in notes/contacts/calendar/todo/email/music/findfamily/ |
| 410 | communicate/fooddelivery/shop/weather (`MAX_RESULTS`, DAO `LIMIT 30`, |
| 411 | backend `MAX_*_LIMIT`, `summarize*` truncations), `NewsRepository`/ |
| 412 | `Story`/`NewsSearch`/`CachedArticle` for the news design, repository |
| 413 | signatures for health/flashcards/travel/youpipe/web/appstore/education, |
| 414 | and `PromptBudgetTest` (24,500-char header budget). No builds were run — |
| 415 | no code changed. |