@mcowger/pi-plexus 1.7.0 → 1.8.0
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 +138 -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,92 @@ 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
|
+
var FLEX_FAMILIES = [/^gpt-6-astra(?=$|-)/i, /^gpt-5\.6-(?:sol|terra|luna)(?=$|-)/i];
|
|
669
|
+
var ULTRAFAST_FAMILIES = [/^gpt-6-astra(?=$|-)/i, /^gpt-5\.6-sol(?=$|-)/i];
|
|
670
|
+
var OPENAI_RESPONSES_DIALECT = {
|
|
671
|
+
id: "openai-responses",
|
|
672
|
+
apis: OPENAI_RESPONSES_APIS,
|
|
673
|
+
parameter: "service_tier",
|
|
674
|
+
tiers: ["priority", "flex", "ultrafast"],
|
|
675
|
+
supportsModel: isPriorityEligible,
|
|
676
|
+
supportsTier(modelId, tier) {
|
|
677
|
+
switch (tier) {
|
|
678
|
+
case "priority":
|
|
679
|
+
return isPriorityEligible(modelId);
|
|
680
|
+
case "flex":
|
|
681
|
+
return FLEX_FAMILIES.some((pattern) => pattern.test(modelId));
|
|
682
|
+
case "ultrafast":
|
|
683
|
+
return ULTRAFAST_FAMILIES.some((pattern) => pattern.test(modelId));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var SERVICE_TIER_DIALECTS = [OPENAI_RESPONSES_DIALECT];
|
|
688
|
+
function dialectForApi(api, dialects = SERVICE_TIER_DIALECTS) {
|
|
689
|
+
if (!api)
|
|
690
|
+
return;
|
|
691
|
+
return dialects.find((dialect) => dialect.apis.includes(api));
|
|
692
|
+
}
|
|
693
|
+
function isTierSupportedByModel(model, tier, dialects = SERVICE_TIER_DIALECTS) {
|
|
694
|
+
if (tier === "default")
|
|
695
|
+
return true;
|
|
696
|
+
if (!model)
|
|
697
|
+
return false;
|
|
698
|
+
const dialect = dialectForApi(model.api, dialects);
|
|
699
|
+
if (!dialect || !dialect.supportsModel(model.id))
|
|
700
|
+
return false;
|
|
701
|
+
return dialect.supportsTier(model.id, tier);
|
|
702
|
+
}
|
|
703
|
+
function applyServiceTier(payload, model, tier, options) {
|
|
704
|
+
if (tier === "default" || !model || model.provider !== options.provider)
|
|
705
|
+
return payload;
|
|
706
|
+
const dialect = dialectForApi(model.api, options.dialects);
|
|
707
|
+
if (!dialect || !dialect.supportsModel(model.id) || !dialect.supportsTier(model.id, tier)) {
|
|
708
|
+
return payload;
|
|
709
|
+
}
|
|
710
|
+
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
711
|
+
return payload;
|
|
712
|
+
return { ...payload, [dialect.parameter]: tier };
|
|
713
|
+
}
|
|
714
|
+
var SERVICE_TIER_NOTIFICATION_TYPE = "plexus.serviceTier";
|
|
715
|
+
var SERVICE_TIER_COMMAND = "service-tier";
|
|
716
|
+
function buildServiceTierNotification(input) {
|
|
717
|
+
return JSON.stringify({
|
|
718
|
+
type: SERVICE_TIER_NOTIFICATION_TYPE,
|
|
719
|
+
command: SERVICE_TIER_COMMAND,
|
|
720
|
+
success: input.success,
|
|
721
|
+
tier: input.tier,
|
|
722
|
+
supported: input.supported,
|
|
723
|
+
provider: input.provider,
|
|
724
|
+
model: input.model
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
|
|
642
728
|
// src/extension.ts
|
|
643
729
|
var PROVIDER_NAME = "plexus";
|
|
644
730
|
var PROVIDER_API_KEY_TEMPLATE = "${PLEXUS_API_KEY}";
|
|
@@ -679,7 +765,17 @@ function plexusExtension(pi) {
|
|
|
679
765
|
const startupModels = (storedCatalog?.models ?? []).filter((model) => !isModelSuppressed({ id: model.id, name: model.name }, suppressPatterns));
|
|
680
766
|
currentModels = startupModels;
|
|
681
767
|
catalogSource = startupModels.length > 0 ? "host store" : "none";
|
|
682
|
-
|
|
768
|
+
let activeServiceTier = "default";
|
|
769
|
+
pi.on("session_start", () => {
|
|
770
|
+
activeServiceTier = "default";
|
|
771
|
+
});
|
|
772
|
+
pi.on("before_provider_request", (event, ctx) => {
|
|
773
|
+
if (ctx.model?.provider !== PROVIDER_NAME)
|
|
774
|
+
return;
|
|
775
|
+
const withTier = applyServiceTier(event.payload, ctx.model, activeServiceTier, { provider: PROVIDER_NAME });
|
|
776
|
+
const next = enforceMinimumOutputTokens(withTier);
|
|
777
|
+
return next === event.payload ? undefined : next;
|
|
778
|
+
});
|
|
683
779
|
log("startup", {
|
|
684
780
|
baseUrl: startupBaseUrl,
|
|
685
781
|
hasEnvApiKey: !!envApiKey,
|
|
@@ -713,6 +809,47 @@ function plexusExtension(pi) {
|
|
|
713
809
|
ctx.ui.notify(`Unknown sub-command: "${args}". Use /login plexus, /plexus refresh, or /plexus status.`, "warning");
|
|
714
810
|
}
|
|
715
811
|
});
|
|
812
|
+
const handleServiceTier = async (args, ctx) => {
|
|
813
|
+
const sub = args.trim().toLowerCase();
|
|
814
|
+
if (sub === "" || sub === "status") {
|
|
815
|
+
notifyServiceTier(ctx, activeServiceTier, true);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
const tier = parseServiceTierArg(sub);
|
|
819
|
+
if (!tier) {
|
|
820
|
+
notifyServiceTier(ctx, activeServiceTier, false);
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
activeServiceTier = tier;
|
|
824
|
+
notifyServiceTier(ctx, tier, true);
|
|
825
|
+
};
|
|
826
|
+
const serviceTierCommand = {
|
|
827
|
+
description: "Set the per-session Plexus service tier: default, fast, flex, ultrafast, or status",
|
|
828
|
+
getArgumentCompletions: (prefix) => {
|
|
829
|
+
const tiers = [
|
|
830
|
+
{ value: "default", label: "default", description: "Use the provider's default tier" },
|
|
831
|
+
{ value: "fast", label: "fast", description: "Priority tier (alias: priority)" },
|
|
832
|
+
{ value: "flex", label: "flex", description: "Flex tier" },
|
|
833
|
+
{ value: "ultrafast", label: "ultrafast", description: "Ultrafast tier" },
|
|
834
|
+
{ value: "status", label: "status", description: "Show the current service tier" }
|
|
835
|
+
];
|
|
836
|
+
return tiers.filter((tier) => tier.value.startsWith(prefix.trim().toLowerCase()));
|
|
837
|
+
},
|
|
838
|
+
handler: handleServiceTier
|
|
839
|
+
};
|
|
840
|
+
pi.registerCommand("service-tier", serviceTierCommand);
|
|
841
|
+
pi.registerCommand("plexus-service-tier", serviceTierCommand);
|
|
842
|
+
}
|
|
843
|
+
function notifyServiceTier(ctx, tier, success) {
|
|
844
|
+
const model = ctx.model;
|
|
845
|
+
const supported = isTierSupportedByModel(model, tier);
|
|
846
|
+
ctx.ui.notify(buildServiceTierNotification({
|
|
847
|
+
tier,
|
|
848
|
+
success,
|
|
849
|
+
supported,
|
|
850
|
+
provider: model?.provider ?? PROVIDER_NAME,
|
|
851
|
+
model: model?.id ?? ""
|
|
852
|
+
}), !success || !supported ? "warning" : "info");
|
|
716
853
|
}
|
|
717
854
|
async function refreshPlexusModels(context) {
|
|
718
855
|
const baseUrl = getBaseUrl();
|