Three files in src/agents are ports of code that the desktop and web clients keep in frontend/packages/ui/src/agents. They hold product knowledge that is not part of the wire protocol: which model providers exist and how their forms behave, how to turn a provider's raw model list into a short menu, and how to word a tool call. They are copies, not imports, so that the data module stays free of the UI package. Each is plain data in, data out.
File | Ported from (per its header) | Used by |
|---|---|---|
|
| |
|
| |
"the RN shared tool-summary registry; no React/runtime dependencies" |
|
The reason for copying is inferred; the headers state only the origin. Nothing keeps the copies in sync automatically, so a provider added on desktop must be added here by hand.
Provider registry
PROVIDER_METADATA maps each provider type to its form behaviour. PROVIDER_TYPE_ORDER fixes the dropdown order.
Type | Label | Default base URL | Base URL editable | Key required |
|---|---|---|---|---|
| OpenAI |
| no | yes |
| Anthropic |
| no | yes |
|
| no | yes | |
| OpenRouter |
| no | yes |
| DeepSeek |
| no | yes |
| Groq |
| no | yes |
| xAI (Grok) |
| no | yes |
| Ollama |
| yes | no |
| Custom (OpenAI-compatible) | empty | yes | no |
Each entry also has priorityPrefixes (model families that sort first), preferredDefaultModelIds, and for OpenAI preferredEnabledModelIds and a subscription block describing ChatGPT sign-in. The mobile app reads label, defaultBaseUrl, showBaseUrlField, requiresApiKey, priorityPrefixes and preferredDefaultModelIds. The subscription metadata is carried but unused: the providers sheet says "Subscription sign-in is available on desktop".
emptyOverview in sources.ts turns the registry into the providerOptions list (shape AgentProviderOption) that the providers sheet uses, so the contract holds no provider table of its own. providerLabel(type) gives the display label, and isModelProviderType guards a type string.
Model utilities
curateProviderModels(models, providerType) reduces a raw model list:
isChatModel drops ids containing any of 23 substrings such as embedding, whisper, tts, dall-e, image-, moderation, -instruct.
canonicalModelId strips -latest and date-like suffixes (-2024-08-06, -20241022, -0125-preview, -0613) but never semantic ones such as -mini.
One model is kept per canonical id, preferring the stable alias, else the newest snapshot.
Both lists sort by the provider's priorityPrefixes index, then by id.
It returns {recommended, all, hasMore}. The app shows only recommended; there is no "show all" control.
pickDefaultProviderModel returns the first recommended model matching a preferredDefaultModelIds entry (compared after canonicalising and replacing dots with dashes, so claude-sonnet-4.6 matches claude-sonnet-4-6), else the first recommended, else the first of all. modelLabel renders Name (id) when a model has a distinct name. pickDefaultEnabledModels is ported but not called by any source.
agentsModels uses the provider type remembered from the last ListModelProviders reply. The root's agentsDefaultModel task then copies defaultId into agentsModel when the form has no model yet.
Tool summaries
tool-summary.ts answers "what does this tool row say, and where does a tap go". Agent tools are address-polymorphic: read {address} may be a memory file, a Hypermedia document, a web page, an attachment or a thread. The module resolves the address once.
parseToolAddress classifies an address and assigns a source chip:
Address | Kind | Chip |
|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
anything else |
| none |
Three exports are used by chatRows:
toolCallAddress(part): for read and write tools only, the first string among address, id, url, path in the arguments.
resolveToolRowSummary(part): {verb, label, target, detail, chip, title} for an address-shaped call, or undefined. Verbs depend on kind and output: Read, Listed, Fetched, Viewed for reads; Wrote, Saved, Deleted, Downloaded, Published, Updated, Saved tool, Deleted tool for writes. An hm or web read takes its label from the output's title.
toolRowSourceChip(part): the chip, with two special cases. A web read whose output type is hypermedia_document shows hm doc, and a pre-verb transcript whose arguments carry a dotted command shows hm doc.
In chatRows the summary's verb becomes the row title and its label the row text. A url target or an hm:// or http(s) address becomes the row's "Open source" link, and a session target becomes /s/<id>. memory and tools targets have no screen on mobile and produce no link.
Tests
agents.test.ts: "model choices retain chat aliases and the RN preferred defaults".
parity.test.ts: "source chips cover the complete RN address registry and legacy writes"; and lines 157-185: every non-custom provider saves with its metadata default URL.
agents.test.contract: provider labels and default URLs for hosted, Ollama and custom types.
User stories
The code described here exists to deliver these stories. Each story lists this page in its Trace (traceability).
US-AGENT-03 Set up a model provider: Provider metadata: labels, default addresses, which types need a key
US-AGENT-04 Create an agent: Model curation, the default model and model labels
US-AGENT-06 See what the agent is doing: Tool summaries: verbs, labels and source chips
US-AGENT-10 Open documents and links an agent refers to: Tool address parsing, link targets and source chips
US-APP-09 Know the app only reaches what it must: Provider submission refuses remote plain HTTP
Related
Agents: reads, commands and the clock: the provider save flow
Agents: screens and components: the providers sheet and tool rows
Do you like what you are reading? Subscribe to receive updates.
Unsubscribe anytime