| Chat.sys.mjs |
Execute a specific tool and return the result
Exported for testing purposes
@param {string} toolName - The name of the tool to execute
@param {object} toolParams - The parameters to pass to the tool
@param {string} toolCallId - The ID of the tool call
@param {ChatConversation} conversation - The conversation context
@param {BrowsingContext} browsingContext - The browsing context (can be null for some tools)
@param {string} mode - The mode of operation (e.g., "fullpage", "sidebar", "urlbar")
@param {number} currentTurn - The current turn number in the conversation
@returns {Promise<object>} The result of the tool execution
@private
|
21955 |
- |
| ChatUtils.sys.mjs |
Truncates and spotlights untrusted metadata text to guard against prompt injection by adding an
(Untrusted webpage data) tag.
Important! Changing this function requires a security review.
Metadata such as page titles and page descriptions are untrusted content from the web and
could contain prompt injections to try and change the behavior of language model
conversations. Typically untrusted content gets flagged in a conversation, and
subsequent tool calls can be restricted if they have access to private information as
well.
By truncating the length of this text, we limit (but do not remove) the ability for these
pieces of text to be used as prompt injections. In this case we have chosen to relax
the security flags to NOT mark these as untrusted when the text is truncated.
This is useful since page titles are used very frequently in chat conversations.
In addition, spotlighting this text helps the model to identify webpage data is untrusted.
We note that the spotlighting tokens added are are only a part of the delimiting. Prompts
have also been updated to include instructions about how to treat untrusted data.
@param {string} text
@param {boolean} truncateOnly
@returns {string}
|
15204 |
- |
| Conversation.sys.mjs |
@typedef {0 | 1 | 2 | 3} MessageRole
|
10781 |
- |
| ConversationSuggestions.sys.mjs |
Helper to trim conversation history to recent messages, dropping empty messages, tool calls and responses
@param {Array} messages - Array of chat messages
@param {number} maxMessages - Max number of messages to keep (default 15)
@returns {Array} Trimmed array of user/assistant messages
|
12589 |
- |
| HistoryThumbnails.sys.mjs |
Captures (or reuses a disk-cached) page thumbnail for an og:image URL and
returns a `moz-page-thumb://` URI, or null when there is no usable thumbnail.
Uses BackgroundPageThumbs so captures are cached on disk and reused across
conversations. Must run in the parent process.
@param {string} thumbnail an og:image url
@returns {Promise<string|null>}
A `moz-page-thumb://` URI on success, or null when there was no thumbnail
URL, the capture threw, or the cached file is the empty-failure marker.
|
1719 |
- |
| IntentClassifier.sys.mjs |
Intent Classifier Engine
|
5404 |
- |
| ManageTabs.sys.mjs |
@import { ChatConversation } from "moz-src:///browser/components/aiwindow/ui/modules/ChatConversation.sys.mjs"
|
6485 |
- |
| memories |
|
|
- |
| Message.sys.mjs |
Generic LLM message — a single turn in a Conversation. Holds the wire-shape
fields any consumer needs (role, content, ordinal, turnIndex) plus
lightweight metadata for replay/telemetry (id, createdDate, parentMessageId,
modelId, params, usage). Tool-call linkage (toolCallId, toolName) lives here
too so the base can serialize tool messages in the OpenAI chat-completions
format.
|
2161 |
- |
| moz.build |
|
1204 |
- |
| openAIEngine.sys.mjs |
The default endpoint used for preset models
|
12850 |
- |
| PreferencesNavMap.sys.mjs |
|
3655 |
- |
| PromptLoader.sys.mjs |
Reads Remote Settings and runs model-selection logic to pick the single
config record for a feature. Throws if no records exist for the feature or
if no record matches the current major version / model-choice prefs.
@param {string} feature - Feature identifier from MODEL_FEATURES
@param {object} [opts]
@param {number} [opts.majorVersionOverride] - Override the hardcoded major version
@param {string} [opts.modelChoiceIdOverride] - Override the user's model-choice pref (used by per-conversation model switching)
@returns {Promise<object>} The selected Remote Settings record
|
6135 |
- |
| PromptOptimizer.sys.mjs |
===================================================================
ARCHITECTURE ROADMAP: The Compaction Waterfall
===================================================================
This module prevents LLM context window collapse and reduces TTFT
(Time-To-First-Token) latency by deterministically compacting massive
background tool payloads before they are dispatched to the API.
* Planned Stages:
- Stage 1 (Active): ID-Based Upsert. Deduplicates repetitive get_page_content reads.
- Stage 2 (Planned): Proportional Bottom-Up Shave. Truncates old page content/Search payloads.
- Stage 3 (Planned): Copy-Paste Tax. Truncates massive old user queries.
- Stage 4 (Planned): LRU Eviction. Drops oldest conversation turns as a failsafe.
===================================================================
|
5105 |
- |
| scripts |
|
|
- |
| SearchBrowsingHistory.sys.mjs |
Convert ISO timestamp string to microseconds (moz_places format / PRTime).
@param {string|null} iso
@returns {number|null}
|
20305 |
- |
| SearchBrowsingHistoryDomainBoost.sys.mjs |
SearchBrowsingHistoryDomainBoost
Temporary heuristic for general-category queries (games, movies, news, etc.)
when semantic embeddings over title/description are insufficient.
Safe to remove once richer embeddings or better intent classification lands.
|
8882 |
- |
| SecurityProperties.sys.mjs |
Sticky security-flag container. A flag that has been set to `true` can never
be cleared back to `false`, preventing a later tool call from accidentally
downgrading a flag raised by an earlier one.
Flags are written to a staging area and only become visible after `commit()`
is called. This ensures that parallel tool calls requested in the same
conversation turn all see the same committed flags.
|
2803 |
- |
| SmartWindowNavigationInfo.sys.mjs |
Provides semantic search over Firefox preferences navigation entries to
answer user queries about where to find Smart Window settings, Memories, etc.
Navigation data is loaded from PreferencesNavMap.sys.mjs, which is
auto-generated by browser/components/aiwindow/models/scripts/generate_prefs_nav_map.py.
Run that script and commit the result whenever preferences.js or FTL files change.
|
3291 |
- |
| TelemetryManager.sys.mjs |
Schedules periodic LLM-based telemetry jobs
|
6155 |
- |
| TelemetryUtils.sys.mjs |
Represents a single telemetry trigger.
A trigger is evaluated against the conversation after each agent response.
If it fires and passes the sampling check, the trigger is included in the
set passed to runTelemetry.
|
15963 |
- |
| tests |
|
|
- |
| TitleGeneration.sys.mjs |
Generate a default title from the first four words of a message.
@param {string} message - The user's message
@returns {string} The default title
|
2808 |
- |
| TokenStreamParser.sys.mjs |
Bug 2017972
Turn a URL token back into the text we want to show in the chat.
Two cases:
1. The token is sitting inside a markdown link, like
`[click](§url§)`. We drop the URL straight in. We replace any
characters that would confuse markdown's link parser with their
percent-encoded equivalents:
- spaces and `<` `>` always get encoded
- `(` and `)` only get encoded when the URL has an unbalanced
pair, which is what the parser actually trips on. URLs with
matched parens (Wikipedia etc.) are left alone so the link
looks normal on hover.
2. The token is on its own, like `See §url§ for details`. We wrap
the URL in `<...>` so it renders as a clickable link. Spaces
and `<` `>` get percent-encoded so they can't break out of the
wrapper.
@param {string} url - The URL the token resolves to.
@param {string} recentPlain - Tail of recently emitted plain text,
used to detect whether the token sits inside a markdown link.
@returns {string} The text to inject into the streamed plain output.
|
9424 |
- |
| Tools.sys.mjs |
This file contains LLM tool abstractions and tool definitions.
|
44549 |
- |
| Utils.sys.mjs |
Gets the Remote Settings client for AI window configurations. Subscribes
the model-data cache to RS sync events on first use and caches the client
until the model pref changes.
@returns {RemoteSettingsClient}
|
16379 |
- |
| WCSMerinoClient.sys.mjs |
Small client for the Merino World Cup Soccer endpoints.
Lives alongside the Smart Window tool that consumes it. Intentionally
kept independent of newtab's TemporaryMerinoClientShim, which is shaped
around `/api/v1/suggest` semantics that don't match the WCS responses.
|
3136 |
- |