Agents: providers, models and tool summaries
The three modules ported into src/agents from the shared UI package: the provider registry, model list curation, and the tool row summary registry.

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

provider-registry.ts

frontend/packages/ui/src/agents/provider-registry.ts

agentsOverview (form options), agentsSaveProvider, model curation

model-utils.ts

frontend/packages/ui/src/agents/model-utils.ts

agentsModels

tool-summary.ts

"the RN shared tool-summary registry; no React/runtime dependencies"

chatRows in model.ts

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

OpenAI

https://api.openai.com/v1

no

yes

anthropic

Anthropic

https://api.anthropic.com

no

yes

google

Google

https://generativelanguage.googleapis.com/v1beta

no

yes

openrouter

OpenRouter

https://openrouter.ai/api/v1

no

yes

deepseek

DeepSeek

https://api.deepseek.com

no

yes

groq

Groq

https://api.groq.com/openai/v1

no

yes

xai

xAI (Grok)

https://api.x.ai/v1

no

yes

ollama

Ollama

http://localhost:11434/v1

yes

no

custom

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

~/memory, ~/memory/...

memory

memory

~/tools, ~/tools/<name>

tools

tools

hm://...

hm

hm doc

http://, https://

web

web

ipfs://<cid>

ipfs

ipfs

activity:...

activity

activity

attachment:<id>

attachment

attachment

thread:<id>

thread

thread

run:<id>

run

run

anything else

unknown

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).

Do you like what you are reading? Subscribe to receive updates.

Unsubscribe anytime

Connections0
Linked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentLinked document ยท Outgoing linkLinked documentAgents: providers, models and tool summariesAgents: providers, modelsโ€ฆ
Citations 0Children & links 13

Loading child documentsโ€ฆ

Connections show where other documents or comments link to this document.

Related documents

Loading connectionsโ€ฆ