Skip to content

Commit cb731d7

Browse files
author
Punam Dahiya
committed
Update entrypoint and service to aimode in FxA authentication
Updated with OpenAI pipeline changes from D271303 Point to stage FxA server
1 parent 8f1d031 commit cb731d7

File tree

6 files changed

+42
-3
lines changed

6 files changed

+42
-3
lines changed

browser/app/profile/firefox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ pref("browser.smartwindow.developer", false);
11721172
pref("browser.smartwindow.enabled", true);
11731173
pref("browser.smartwindow.endpoint", "https://stage.llm-proxy.nonprod.dataservices.mozgcp.net/");
11741174
pref("browser.smartwindow.insights", "{}");
1175-
pref("browser.smartwindow.key", "");
1175+
pref("browser.smartwindow.key", "sk-K0mV22WP5K5v-jRX1XmKSg");
11761176
pref("browser.smartwindow.model", "qwen3-235b-a22b-instruct-2507-maas");
11771177
pref("browser.smartwindow.chatHistory.loglevel", "Warn");
11781178
pref("browser.smartwindow.skipOnboarding", true);
@@ -2304,7 +2304,7 @@ pref("identity.sync.tokenserver.uri", "https://token.services.mozilla.com/1.0/sy
23042304
// [identity.fxaccounts.autoconfig.uri]/.well-known/fxa-client-configuration
23052305
// This is now the prefered way of pointing to a custom FxA server, instead
23062306
// of making changes to "identity.fxaccounts.*.uri".
2307-
pref("identity.fxaccounts.autoconfig.uri", "");
2307+
pref("identity.fxaccounts.autoconfig.uri", "https://accounts.stage.mozaws.net");
23082308

23092309
// URL for help link about Send Tab.
23102310
pref("identity.sendtabpromo.url", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/send-tab");

browser/base/content/browser-smart-window.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ var SmartWindow = {
122122
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
123123
data: {
124124
entrypoint: "aimode",
125+
extraParams: {
126+
service: "aimode",
127+
}
125128
},
126129
},
127130
gBrowser.selectedBrowser

browser/components/smartwindow/content/utils.mjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ ChromeUtils.defineESModuleGetters(lazy, {
1212

1313
import { createEngine } from "chrome://global/content/ml/EngineProcess.sys.mjs";
1414
import { SmartAssistEngine } from "moz-src:///browser/components/genai/SmartAssistEngine.sys.mjs";
15+
import { getFxAccountsSingleton } from "resource://gre/modules/FxAccounts.sys.mjs";
16+
import {
17+
SCOPE_PROFILE,
18+
OAUTH_CLIENT_ID,
19+
} from "resource://gre/modules/FxAccountsCommon.sys.mjs";
1520

1621
const { ChatHistoryMessage } = ChromeUtils.importESModule(
1722
"resource:///modules/smartwindow/ChatHistory.sys.mjs"
@@ -53,6 +58,20 @@ export async function detectQueryType(query, isFollowup = false) {
5358
}
5459
}
5560

61+
const getFxAccountToken = async () => {
62+
try {
63+
const fxAccounts = getFxAccountsSingleton();
64+
const token = await fxAccounts.getOAuthToken({
65+
scope: SCOPE_PROFILE,
66+
client_id: OAUTH_CLIENT_ID,
67+
});
68+
return token;
69+
} catch (error) {
70+
console.error("Error obtaining FxA token:", error);
71+
throw error;
72+
}
73+
};
74+
5675
/**
5776
* Creates an OpenAI engine instance configured with Smart Window preferences.
5877
*
@@ -61,6 +80,7 @@ export async function detectQueryType(query, isFollowup = false) {
6180
*/
6281
export async function createOpenAIEngine(engineId = "smart-openai") {
6382
try {
83+
const fxAccountToken = await getFxAccountToken();
6484
const engineInstance = await createEngine({
6585
apiKey: Services.prefs.getStringPref("browser.smartwindow.key"),
6686
backend: "openai",
@@ -69,6 +89,7 @@ export async function createOpenAIEngine(engineId = "smart-openai") {
6989
modelId: Services.prefs.getStringPref("browser.smartwindow.model"),
7090
modelRevision: "main",
7191
taskName: "text-generation",
92+
fxAccountToken,
7293
});
7394
return engineInstance;
7495
} catch (error) {

browser/components/smartwindow/content/welcome.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ XPCOMUtils.defineLazyPreferenceGetter(
6969
{
7070
data: {
7171
entrypoint: "aimode",
72+
extraParams: {
73+
service: "aimode",
74+
}
7275
},
7376
type: "FXA_SMART_WINDOW_SIGNIN_FLOW",
7477
navigate: true,

toolkit/components/ml/content/EngineProcess.sys.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ export class PipelineOptions {
801801
"baseURL",
802802
"apiKey",
803803
"staticEmbeddingsOptions",
804+
"fxAccountToken",
804805
];
805806

806807
if (options instanceof PipelineOptions) {
@@ -946,6 +947,7 @@ export class PipelineOptions {
946947
baseURL: this.baseURL,
947948
apiKey: this.apiKey,
948949
staticEmbeddingsOptions: this.staticEmbeddingsOptions,
950+
fxAccountToken: this.fxAccountToken,
949951
};
950952
}
951953

toolkit/components/ml/content/backends/OpenAIPipeline.mjs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,21 @@ export class OpenAIPipeline {
326326
) {
327327
lazy.console.debug("Running OpenAI pipeline");
328328
try {
329-
const { baseURL, apiKey, modelId } = this.#options;
329+
const { baseURL, apiKey, modelId, fxAccountToken } = this.#options;
330+
331+
if (!fxAccountToken) {
332+
console.warn("No FxA token available;");
333+
}
334+
335+
const defaultHeaders = fxAccountToken
336+
? { "x-fxa-authorization": `Bearer ${fxAccountToken}` } // or "X-FxA-Access-Token": fxAccountToken
337+
: undefined;
338+
330339
const client = new OpenAIPipeline.OpenAILib.OpenAI({
331340
baseURL: baseURL ? baseURL : "http://localhost:11434/v1",
332341
apiKey: apiKey || "ollama",
333342
maxRetries: 10,
343+
...(defaultHeaders ? { defaultHeaders } : {}),
334344
});
335345
const stream = request.streamOptions?.enabled || false;
336346
const tools = request.tools || [];

0 commit comments

Comments
 (0)