@mcowger/pi-plexus 1.7.1 → 1.8.1
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/README.md +8 -0
- package/dist/extension.js +145 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -139,6 +139,14 @@ Inspect the effective URL, authentication availability, and catalog source witho
|
|
|
139
139
|
/plexus status
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
+
Choose the per-session OpenAI service tier:
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
/service-tier fast
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Tiers are `default` (aliases `off`, `none`), `fast` (alias `priority`), `flex`, and `ultrafast`; `/service-tier status` reports the active tier and whether the current model supports it. Eligibility follows OpenAI's per-tier model support: `priority` covers the Fast-mode set (GPT-5 and newer, GPT-4.1+, GPT-4o, and o3/o4-mini), while `flex` and `ultrafast` are limited to their documented models. The tier is injected as `service_tier` only for eligible Plexus models and resets to `default` on every session start. `/plexus-service-tier` is an alias for the same command.
|
|
149
|
+
|
|
142
150
|
Select a Plexus model in `/model`. Save its startup default with the host's normal model-picker action; Plexus does not maintain a separate default-model setting.
|
|
143
151
|
|
|
144
152
|
Use `/login plexus` for setup and `/logout plexus` to remove stored credentials.
|
package/dist/extension.js
CHANGED
|
@@ -639,6 +639,99 @@ function normalizeMalformedFunctionCall(message, providerName) {
|
|
|
639
639
|
return { message: { ...message, errorMessage: NORMALIZED_MESSAGE } };
|
|
640
640
|
}
|
|
641
641
|
|
|
642
|
+
// src/service-tier.ts
|
|
643
|
+
var TIER_ALIASES = {
|
|
644
|
+
default: "default",
|
|
645
|
+
off: "default",
|
|
646
|
+
none: "default",
|
|
647
|
+
priority: "priority",
|
|
648
|
+
fast: "priority",
|
|
649
|
+
flex: "flex",
|
|
650
|
+
ultrafast: "ultrafast"
|
|
651
|
+
};
|
|
652
|
+
function parseServiceTierArg(input) {
|
|
653
|
+
return TIER_ALIASES[input.trim().toLowerCase()];
|
|
654
|
+
}
|
|
655
|
+
var OPENAI_RESPONSES_APIS = ["openai-responses", "openai-codex-responses"];
|
|
656
|
+
var GPT_VERSION = /^gpt-(\d+)(?:\.(\d+))?(?:-|$)/i;
|
|
657
|
+
var PRIORITY_EXTRA_FAMILIES = [/^gpt-4o(?=$|-)/i, /^o3(?=$|-)/i, /^o4-mini(?=$|-)/i];
|
|
658
|
+
function isPriorityEligible(modelId) {
|
|
659
|
+
const id = modelId.trim();
|
|
660
|
+
const match = GPT_VERSION.exec(id);
|
|
661
|
+
if (match) {
|
|
662
|
+
const major = Number(match[1]);
|
|
663
|
+
const minor = match[2] === undefined ? 0 : Number(match[2]);
|
|
664
|
+
return major >= 5 || major === 4 && minor >= 1;
|
|
665
|
+
}
|
|
666
|
+
return PRIORITY_EXTRA_FAMILIES.some((pattern) => pattern.test(id));
|
|
667
|
+
}
|
|
668
|
+
function isFlexEligible(modelId) {
|
|
669
|
+
const match = GPT_VERSION.exec(modelId.trim());
|
|
670
|
+
if (!match)
|
|
671
|
+
return false;
|
|
672
|
+
const major = Number(match[1]);
|
|
673
|
+
const minor = match[2] === undefined ? 0 : Number(match[2]);
|
|
674
|
+
return major > 5 || major === 5 && minor >= 5;
|
|
675
|
+
}
|
|
676
|
+
var ULTRAFAST_FAMILIES = [/^gpt-6(?:\.\d+)?-astra(?=$|-)/i, /^gpt-5\.6-sol(?=$|-)/i];
|
|
677
|
+
var OPENAI_RESPONSES_DIALECT = {
|
|
678
|
+
id: "openai-responses",
|
|
679
|
+
apis: OPENAI_RESPONSES_APIS,
|
|
680
|
+
parameter: "service_tier",
|
|
681
|
+
tiers: ["priority", "flex", "ultrafast"],
|
|
682
|
+
supportsModel: isPriorityEligible,
|
|
683
|
+
supportsTier(modelId, tier) {
|
|
684
|
+
switch (tier) {
|
|
685
|
+
case "priority":
|
|
686
|
+
return isPriorityEligible(modelId);
|
|
687
|
+
case "flex":
|
|
688
|
+
return isFlexEligible(modelId);
|
|
689
|
+
case "ultrafast":
|
|
690
|
+
return ULTRAFAST_FAMILIES.some((pattern) => pattern.test(modelId));
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
var SERVICE_TIER_DIALECTS = [OPENAI_RESPONSES_DIALECT];
|
|
695
|
+
function dialectForApi(api, dialects = SERVICE_TIER_DIALECTS) {
|
|
696
|
+
if (!api)
|
|
697
|
+
return;
|
|
698
|
+
return dialects.find((dialect) => dialect.apis.includes(api));
|
|
699
|
+
}
|
|
700
|
+
function isTierSupportedByModel(model, tier, dialects = SERVICE_TIER_DIALECTS) {
|
|
701
|
+
if (tier === "default")
|
|
702
|
+
return true;
|
|
703
|
+
if (!model)
|
|
704
|
+
return false;
|
|
705
|
+
const dialect = dialectForApi(model.api, dialects);
|
|
706
|
+
if (!dialect || !dialect.supportsModel(model.id))
|
|
707
|
+
return false;
|
|
708
|
+
return dialect.supportsTier(model.id, tier);
|
|
709
|
+
}
|
|
710
|
+
function applyServiceTier(payload, model, tier, options) {
|
|
711
|
+
if (tier === "default" || !model || model.provider !== options.provider)
|
|
712
|
+
return payload;
|
|
713
|
+
const dialect = dialectForApi(model.api, options.dialects);
|
|
714
|
+
if (!dialect || !dialect.supportsModel(model.id) || !dialect.supportsTier(model.id, tier)) {
|
|
715
|
+
return payload;
|
|
716
|
+
}
|
|
717
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
718
|
+
return payload;
|
|
719
|
+
return { ...payload, [dialect.parameter]: tier };
|
|
720
|
+
}
|
|
721
|
+
var SERVICE_TIER_NOTIFICATION_TYPE = "plexus.serviceTier";
|
|
722
|
+
var SERVICE_TIER_COMMAND = "service-tier";
|
|
723
|
+
function buildServiceTierNotification(input) {
|
|
724
|
+
return JSON.stringify({
|
|
725
|
+
type: SERVICE_TIER_NOTIFICATION_TYPE,
|
|
726
|
+
command: SERVICE_TIER_COMMAND,
|
|
727
|
+
success: input.success,
|
|
728
|
+
tier: input.tier,
|
|
729
|
+
supported: input.supported,
|
|
730
|
+
provider: input.provider,
|
|
731
|
+
model: input.model
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
|
|
642
735
|
// src/extension.ts
|
|
643
736
|
var PROVIDER_NAME = "plexus";
|
|
644
737
|
var PROVIDER_API_KEY_TEMPLATE = "${PLEXUS_API_KEY}";
|
|
@@ -679,7 +772,17 @@ function plexusExtension(pi) {
|
|
|
679
772
|
const startupModels = (storedCatalog?.models ?? []).filter((model) => !isModelSuppressed({ id: model.id, name: model.name }, suppressPatterns));
|
|
680
773
|
currentModels = startupModels;
|
|
681
774
|
catalogSource = startupModels.length > 0 ? "host store" : "none";
|
|
682
|
-
|
|
775
|
+
let activeServiceTier = "default";
|
|
776
|
+
pi.on("session_start", () => {
|
|
777
|
+
activeServiceTier = "default";
|
|
778
|
+
});
|
|
779
|
+
pi.on("before_provider_request", (event, ctx) => {
|
|
780
|
+
if (ctx.model?.provider !== PROVIDER_NAME)
|
|
781
|
+
return;
|
|
782
|
+
const withTier = applyServiceTier(event.payload, ctx.model, activeServiceTier, { provider: PROVIDER_NAME });
|
|
783
|
+
const next = enforceMinimumOutputTokens(withTier);
|
|
784
|
+
return next === event.payload ? undefined : next;
|
|
785
|
+
});
|
|
683
786
|
log("startup", {
|
|
684
787
|
baseUrl: startupBaseUrl,
|
|
685
788
|
hasEnvApiKey: !!envApiKey,
|
|
@@ -713,6 +816,47 @@ function plexusExtension(pi) {
|
|
|
713
816
|
ctx.ui.notify(`Unknown sub-command: "${args}". Use /login plexus, /plexus refresh, or /plexus status.`, "warning");
|
|
714
817
|
}
|
|
715
818
|
});
|
|
819
|
+
const handleServiceTier = async (args, ctx) => {
|
|
820
|
+
const sub = args.trim().toLowerCase();
|
|
821
|
+
if (sub === "" || sub === "status") {
|
|
822
|
+
notifyServiceTier(ctx, activeServiceTier, true);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
const tier = parseServiceTierArg(sub);
|
|
826
|
+
if (!tier) {
|
|
827
|
+
notifyServiceTier(ctx, activeServiceTier, false);
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
activeServiceTier = tier;
|
|
831
|
+
notifyServiceTier(ctx, tier, true);
|
|
832
|
+
};
|
|
833
|
+
const serviceTierCommand = {
|
|
834
|
+
description: "Set the per-session Plexus service tier: default, fast, flex, ultrafast, or status",
|
|
835
|
+
getArgumentCompletions: (prefix) => {
|
|
836
|
+
const tiers = [
|
|
837
|
+
{ value: "default", label: "default", description: "Use the provider's default tier" },
|
|
838
|
+
{ value: "fast", label: "fast", description: "Priority tier (alias: priority)" },
|
|
839
|
+
{ value: "flex", label: "flex", description: "Flex tier" },
|
|
840
|
+
{ value: "ultrafast", label: "ultrafast", description: "Ultrafast tier" },
|
|
841
|
+
{ value: "status", label: "status", description: "Show the current service tier" }
|
|
842
|
+
];
|
|
843
|
+
return tiers.filter((tier) => tier.value.startsWith(prefix.trim().toLowerCase()));
|
|
844
|
+
},
|
|
845
|
+
handler: handleServiceTier
|
|
846
|
+
};
|
|
847
|
+
pi.registerCommand("service-tier", serviceTierCommand);
|
|
848
|
+
pi.registerCommand("plexus-service-tier", serviceTierCommand);
|
|
849
|
+
}
|
|
850
|
+
function notifyServiceTier(ctx, tier, success) {
|
|
851
|
+
const model = ctx.model;
|
|
852
|
+
const supported = isTierSupportedByModel(model, tier);
|
|
853
|
+
ctx.ui.notify(buildServiceTierNotification({
|
|
854
|
+
tier,
|
|
855
|
+
success,
|
|
856
|
+
supported,
|
|
857
|
+
provider: model?.provider ?? PROVIDER_NAME,
|
|
858
|
+
model: model?.id ?? ""
|
|
859
|
+
}), !success || !supported ? "warning" : "info");
|
|
716
860
|
}
|
|
717
861
|
async function refreshPlexusModels(context) {
|
|
718
862
|
const baseUrl = getBaseUrl();
|