@mcowger/oh-my-pi-plexus 1.4.3 → 1.4.6
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 +67 -56
- package/package.json +8 -8
package/dist/extension.js
CHANGED
|
@@ -109420,11 +109420,18 @@ function convertToDescriptor(raw, baseUrl) {
|
|
|
109420
109420
|
function isChatModel(model) {
|
|
109421
109421
|
if (!model.id)
|
|
109422
109422
|
return false;
|
|
109423
|
+
const inputModalities = model.architecture?.input_modalities;
|
|
109424
|
+
if (inputModalities !== undefined && inputModalities.length > 0 && !inputModalities.includes("text")) {
|
|
109425
|
+
return false;
|
|
109426
|
+
}
|
|
109423
109427
|
const outputModalities = model.architecture?.output_modalities;
|
|
109424
109428
|
if (outputModalities !== undefined && !outputModalities.includes("text"))
|
|
109425
109429
|
return false;
|
|
109426
109430
|
const modality = model.architecture?.modality;
|
|
109427
109431
|
if (modality?.includes("->")) {
|
|
109432
|
+
const input = modality.split("->")[0] ?? "";
|
|
109433
|
+
if (!input.toLowerCase().includes("text"))
|
|
109434
|
+
return false;
|
|
109428
109435
|
const output = modality.split("->").at(-1) ?? "";
|
|
109429
109436
|
if (!output.toLowerCase().includes("text"))
|
|
109430
109437
|
return false;
|
|
@@ -129431,49 +129438,43 @@ function descriptorToOhMyPiModel(descriptor) {
|
|
|
129431
129438
|
|
|
129432
129439
|
// src/extension.ts
|
|
129433
129440
|
var PROVIDER_NAME = "plexus";
|
|
129434
|
-
var currentModels = [];
|
|
129435
129441
|
function getProviderApiKeyConfig() {
|
|
129436
129442
|
return Bun.env[ENV_API_KEY]?.trim() ? { apiKey: ENV_API_KEY, authHeader: true } : {};
|
|
129437
129443
|
}
|
|
129444
|
+
var currentModels = [];
|
|
129438
129445
|
function plexusExtension(pi) {
|
|
129446
|
+
const cached3 = readCachedModelsSync();
|
|
129447
|
+
const suppressPatterns = getSuppressedModels();
|
|
129439
129448
|
const startupBaseUrl = getBaseUrl() ?? "http://localhost/v1";
|
|
129449
|
+
const startupModels = (cached3?.models ?? []).filter((m) => !isModelSuppressed({ id: m.id, name: m.name }, suppressPatterns)).map(descriptorToOhMyPiModel);
|
|
129440
129450
|
log("startup", {
|
|
129441
|
-
|
|
129442
|
-
|
|
129451
|
+
cachedModelCount: startupModels.length,
|
|
129452
|
+
startupBaseUrl
|
|
129443
129453
|
});
|
|
129444
129454
|
pi.registerProvider(PROVIDER_NAME, {
|
|
129445
129455
|
api: "openai-completions",
|
|
129446
129456
|
...getProviderApiKeyConfig(),
|
|
129447
129457
|
baseUrl: startupBaseUrl,
|
|
129448
|
-
|
|
129449
|
-
|
|
129450
|
-
oauth: createPlexusLoginProvider()
|
|
129458
|
+
models: startupModels,
|
|
129459
|
+
oauth: createPlexusLoginProvider(pi)
|
|
129451
129460
|
});
|
|
129452
|
-
|
|
129453
|
-
|
|
129461
|
+
currentModels = startupModels;
|
|
129462
|
+
pi.on("session_start", async (_event, ctx) => {
|
|
129463
|
+
const apiKey = await ctx.modelRegistry.authStorage.getApiKey(PROVIDER_NAME) ?? getEnvApiKey();
|
|
129454
129464
|
const baseUrl = getBaseUrl();
|
|
129455
|
-
log("session_start", {
|
|
129456
|
-
if (!baseUrl) {
|
|
129457
|
-
log("session_start: no
|
|
129465
|
+
log("session_start", { hasApiKey: !!apiKey, baseUrl });
|
|
129466
|
+
if (!apiKey || !baseUrl) {
|
|
129467
|
+
log("session_start: no auth configured, skipping refresh");
|
|
129458
129468
|
return;
|
|
129459
129469
|
}
|
|
129460
|
-
|
|
129461
|
-
syncCurrentModels(ctx);
|
|
129462
|
-
log("session_start: background refresh complete", { count: currentModels.length });
|
|
129463
|
-
}).catch((error51) => {
|
|
129464
|
-
log("session_start: background refresh failed", { error: String(error51) });
|
|
129465
|
-
});
|
|
129470
|
+
await doRefresh(pi, apiKey, ctx);
|
|
129466
129471
|
});
|
|
129467
|
-
pi.registerCommand(
|
|
129472
|
+
pi.registerCommand("plexus", {
|
|
129468
129473
|
description: "Plexus provider commands: refresh, set-default-model (setup: /login plexus)",
|
|
129469
129474
|
getArgumentCompletions: (prefix) => {
|
|
129470
129475
|
const subcommands = [
|
|
129471
129476
|
{ value: "refresh", label: "refresh", description: "Refresh Plexus models from the API" },
|
|
129472
|
-
{
|
|
129473
|
-
value: "set-default-model",
|
|
129474
|
-
label: "set-default-model",
|
|
129475
|
-
description: "Choose the model Oh My Pi should use by default"
|
|
129476
|
-
}
|
|
129477
|
+
{ value: "set-default-model", label: "set-default-model", description: "Choose the model Oh My Pi should use by default" }
|
|
129477
129478
|
];
|
|
129478
129479
|
if (!prefix.includes(" ")) {
|
|
129479
129480
|
return subcommands.filter((command) => command.value.startsWith(prefix));
|
|
@@ -129493,7 +129494,7 @@ function plexusExtension(pi) {
|
|
|
129493
129494
|
const trimmed = args2.trim();
|
|
129494
129495
|
const sub = trimmed.toLowerCase();
|
|
129495
129496
|
if (sub === "refresh" || sub === "") {
|
|
129496
|
-
await handleRefresh(ctx);
|
|
129497
|
+
await handleRefresh(pi, ctx);
|
|
129497
129498
|
return;
|
|
129498
129499
|
}
|
|
129499
129500
|
if (sub === "set-default-model" || sub.startsWith("set-default-model ")) {
|
|
@@ -129504,7 +129505,7 @@ function plexusExtension(pi) {
|
|
|
129504
129505
|
}
|
|
129505
129506
|
});
|
|
129506
129507
|
}
|
|
129507
|
-
function createPlexusLoginProvider() {
|
|
129508
|
+
function createPlexusLoginProvider(pi) {
|
|
129508
129509
|
return {
|
|
129509
129510
|
name: "Plexus",
|
|
129510
129511
|
async login(callbacks) {
|
|
@@ -129518,28 +129519,20 @@ function createPlexusLoginProvider() {
|
|
|
129518
129519
|
if (!apiKey)
|
|
129519
129520
|
throw new Error("Plexus API key is required.");
|
|
129520
129521
|
await saveBaseUrl(baseUrl);
|
|
129521
|
-
callbacks.onProgress?.("Plexus
|
|
129522
|
+
callbacks.onProgress?.("Refreshing Plexus models...");
|
|
129523
|
+
await doRefresh(pi, apiKey, null);
|
|
129522
129524
|
return apiKey;
|
|
129523
129525
|
}
|
|
129524
129526
|
};
|
|
129525
129527
|
}
|
|
129526
|
-
async function handleRefresh(ctx) {
|
|
129527
|
-
const apiKey = await ctx.modelRegistry.
|
|
129528
|
+
async function handleRefresh(pi, ctx) {
|
|
129529
|
+
const apiKey = await ctx.modelRegistry.authStorage.getApiKey(PROVIDER_NAME) ?? getEnvApiKey();
|
|
129528
129530
|
if (!apiKey) {
|
|
129529
129531
|
ctx.ui.notify("No Plexus API key configured. Run /login plexus first.", "error");
|
|
129530
129532
|
return;
|
|
129531
129533
|
}
|
|
129532
|
-
if (!getBaseUrl()) {
|
|
129533
|
-
ctx.ui.notify("Plexus base URL not configured. Run /login plexus first.", "error");
|
|
129534
|
-
return;
|
|
129535
|
-
}
|
|
129536
129534
|
ctx.ui.notify("Refreshing Plexus models\u2026", "info");
|
|
129537
|
-
await
|
|
129538
|
-
syncCurrentModels(ctx);
|
|
129539
|
-
ctx.ui.notify(currentModels.length > 0 ? `Refreshed ${currentModels.length} Plexus models` : "Refresh finished but no Plexus models are available. Check the Plexus server and /login plexus.", currentModels.length > 0 ? "info" : "warning");
|
|
129540
|
-
}
|
|
129541
|
-
function syncCurrentModels(ctx) {
|
|
129542
|
-
currentModels = ctx.models.list().filter((model) => model.provider === PROVIDER_NAME);
|
|
129535
|
+
await doRefresh(pi, apiKey, ctx);
|
|
129543
129536
|
}
|
|
129544
129537
|
async function handleSetDefaultModel(pi, ctx, requestedModelId) {
|
|
129545
129538
|
let modelId = requestedModelId;
|
|
@@ -129565,27 +129558,45 @@ async function handleSetDefaultModel(pi, ctx, requestedModelId) {
|
|
|
129565
129558
|
const active = await pi.setModel(registryModel);
|
|
129566
129559
|
ctx.ui.notify(active ? `Plexus model selected: ${model.id}.` : `Plexus model ${model.id} was saved but could not be selected in this session.`, active ? "info" : "warning");
|
|
129567
129560
|
}
|
|
129568
|
-
async function
|
|
129561
|
+
async function doRefresh(pi, apiKey, ctx) {
|
|
129569
129562
|
const modelsUrl = getModelsUrl();
|
|
129570
129563
|
const baseUrl = getBaseUrl();
|
|
129571
|
-
if (!modelsUrl || !baseUrl
|
|
129572
|
-
|
|
129573
|
-
|
|
129574
|
-
|
|
129575
|
-
|
|
129564
|
+
if (!modelsUrl || !baseUrl) {
|
|
129565
|
+
if (ctx)
|
|
129566
|
+
ctx.ui.notify("Plexus base URL not configured. Run /login plexus first.", "warning");
|
|
129567
|
+
log("doRefresh: no base URL configured");
|
|
129568
|
+
return;
|
|
129569
|
+
}
|
|
129570
|
+
try {
|
|
129571
|
+
const cached3 = readCachedModelsSync();
|
|
129572
|
+
const { models: apiModels, raw, etag, notModified } = await fetchPlexusModels(apiKey, modelsUrl, undefined, cached3?.etag);
|
|
129573
|
+
if (notModified) {
|
|
129574
|
+
log("doRefresh: not modified", { etag: cached3?.etag });
|
|
129575
|
+
if (ctx)
|
|
129576
|
+
ctx.ui.notify(`Refreshed ${currentModels.length} Plexus models (not modified)`, "info");
|
|
129577
|
+
return;
|
|
129578
|
+
}
|
|
129576
129579
|
const suppressPatterns = getSuppressedModels();
|
|
129577
|
-
const
|
|
129578
|
-
|
|
129579
|
-
|
|
129580
|
-
|
|
129581
|
-
|
|
129582
|
-
|
|
129583
|
-
|
|
129584
|
-
|
|
129585
|
-
|
|
129586
|
-
|
|
129587
|
-
|
|
129588
|
-
|
|
129580
|
+
const descriptors3 = convertDescriptors(apiModels, baseUrl, suppressPatterns);
|
|
129581
|
+
const ohMyPiModels = descriptors3.map(descriptorToOhMyPiModel);
|
|
129582
|
+
await Promise.all([writeCachedModels(descriptors3, etag), raw ? writeRawResponse(raw) : Promise.resolve()]);
|
|
129583
|
+
currentModels = ohMyPiModels;
|
|
129584
|
+
pi.registerProvider(PROVIDER_NAME, {
|
|
129585
|
+
api: "openai-completions",
|
|
129586
|
+
...getProviderApiKeyConfig(),
|
|
129587
|
+
baseUrl,
|
|
129588
|
+
models: ohMyPiModels,
|
|
129589
|
+
oauth: createPlexusLoginProvider(pi)
|
|
129590
|
+
});
|
|
129591
|
+
log("doRefresh: registered", { count: ohMyPiModels.length });
|
|
129592
|
+
if (ctx)
|
|
129593
|
+
ctx.ui.notify(`Refreshed ${ohMyPiModels.length} Plexus models`, "info");
|
|
129594
|
+
} catch (error51) {
|
|
129595
|
+
log("doRefresh: failed", { error: String(error51) });
|
|
129596
|
+
if (ctx) {
|
|
129597
|
+
ctx.ui.notify(`Refresh failed: ${error51 instanceof Error ? error51.message : String(error51)}`, "error");
|
|
129598
|
+
}
|
|
129599
|
+
}
|
|
129589
129600
|
}
|
|
129590
129601
|
export {
|
|
129591
129602
|
plexusExtension as default,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcowger/oh-my-pi-plexus",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.6",
|
|
4
4
|
"description": "Plexus AI proxy plugin for the Oh My Pi coding agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"build": "bun run build.ts"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@oh-my-pi/pi-ai": ">=
|
|
30
|
-
"@oh-my-pi/pi-coding-agent": ">=
|
|
31
|
-
"@oh-my-pi/pi-utils": ">=
|
|
29
|
+
"@oh-my-pi/pi-ai": ">=17.1.0",
|
|
30
|
+
"@oh-my-pi/pi-coding-agent": ">=17.1.0",
|
|
31
|
+
"@oh-my-pi/pi-utils": ">=17.1.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@oh-my-pi/pi-ai": "^
|
|
35
|
-
"@oh-my-pi/pi-catalog": "
|
|
36
|
-
"@oh-my-pi/pi-coding-agent": "^
|
|
37
|
-
"@oh-my-pi/pi-utils": "
|
|
34
|
+
"@oh-my-pi/pi-ai": "^17.1.0",
|
|
35
|
+
"@oh-my-pi/pi-catalog": "^17.1.0",
|
|
36
|
+
"@oh-my-pi/pi-coding-agent": "^17.1.0",
|
|
37
|
+
"@oh-my-pi/pi-utils": "^17.1.0",
|
|
38
38
|
"@types/bun": "latest"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|