@mcowger/pi-plexus 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension.js +9 -6
- package/package.json +1 -1
package/dist/extension.js
CHANGED
|
@@ -465,6 +465,7 @@ function descriptorToPiModel(descriptor) {
|
|
|
465
465
|
id: descriptor.id,
|
|
466
466
|
name: descriptor.name,
|
|
467
467
|
api: descriptor.preferredApi,
|
|
468
|
+
provider: descriptor.provider,
|
|
468
469
|
baseUrl: descriptor.baseUrl,
|
|
469
470
|
reasoning: descriptor.reasoning,
|
|
470
471
|
input: descriptor.input,
|
|
@@ -505,7 +506,7 @@ function plexusExtension(pi) {
|
|
|
505
506
|
log("session_start", { hasApiKey: !!apiKey, baseUrl });
|
|
506
507
|
if (!apiKey || !baseUrl) {
|
|
507
508
|
log("session_start: no auth configured, skipping refresh");
|
|
508
|
-
await trySetDefaultModel(pi, startupModels);
|
|
509
|
+
await trySetDefaultModel(pi, startupModels, ctx);
|
|
509
510
|
return;
|
|
510
511
|
}
|
|
511
512
|
await doRefresh(pi, apiKey, ctx, true);
|
|
@@ -561,7 +562,7 @@ function createPlexusLoginProvider(pi) {
|
|
|
561
562
|
throw new Error("Plexus API key is required.");
|
|
562
563
|
await saveBaseUrl(baseUrl);
|
|
563
564
|
callbacks.onProgress?.("Refreshing Plexus models...");
|
|
564
|
-
await doRefresh(pi, apiKey, null,
|
|
565
|
+
await doRefresh(pi, apiKey, null, true);
|
|
565
566
|
return {
|
|
566
567
|
access: apiKey,
|
|
567
568
|
refresh: apiKey,
|
|
@@ -613,7 +614,8 @@ async function handleSetDefaultModel(pi, ctx, requestedModelId) {
|
|
|
613
614
|
return;
|
|
614
615
|
}
|
|
615
616
|
await saveDefaultModel(model.id);
|
|
616
|
-
const
|
|
617
|
+
const registryModel = ctx.modelRegistry.find(PROVIDER_NAME, model.id) ?? model;
|
|
618
|
+
const active = await pi.setModel(registryModel);
|
|
617
619
|
ctx.ui.notify(active ? `Default Plexus model set to ${model.id}.` : `Default Plexus model set to ${model.id}; it will be selected when Plexus authentication is available.`, active ? "info" : "warning");
|
|
618
620
|
}
|
|
619
621
|
async function doRefresh(pi, apiKey, ctx, setDefault) {
|
|
@@ -643,7 +645,7 @@ async function doRefresh(pi, apiKey, ctx, setDefault) {
|
|
|
643
645
|
if (ctx)
|
|
644
646
|
ctx.ui.notify(`Refreshed ${piModels.length} Plexus models`, "info");
|
|
645
647
|
if (setDefault)
|
|
646
|
-
await trySetDefaultModel(pi, piModels);
|
|
648
|
+
await trySetDefaultModel(pi, piModels, ctx);
|
|
647
649
|
} catch (error) {
|
|
648
650
|
log("doRefresh: failed", { error: String(error) });
|
|
649
651
|
if (ctx) {
|
|
@@ -651,7 +653,7 @@ async function doRefresh(pi, apiKey, ctx, setDefault) {
|
|
|
651
653
|
}
|
|
652
654
|
}
|
|
653
655
|
}
|
|
654
|
-
async function trySetDefaultModel(pi, models) {
|
|
656
|
+
async function trySetDefaultModel(pi, models, ctx) {
|
|
655
657
|
const defaultModelId = getDefaultModel();
|
|
656
658
|
if (!defaultModelId)
|
|
657
659
|
return;
|
|
@@ -660,7 +662,8 @@ async function trySetDefaultModel(pi, models) {
|
|
|
660
662
|
log("trySetDefaultModel: model not found", { defaultModelId });
|
|
661
663
|
return;
|
|
662
664
|
}
|
|
663
|
-
const
|
|
665
|
+
const registryModel = ctx?.modelRegistry.find(PROVIDER_NAME, defaultModelId) ?? model;
|
|
666
|
+
const ok = await pi.setModel(registryModel);
|
|
664
667
|
log("trySetDefaultModel", { defaultModelId, ok });
|
|
665
668
|
}
|
|
666
669
|
export {
|