@victor-software-house/pi-openai-proxy 4.0.4 → 4.0.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/extensions/proxy.ts +70 -17
- package/package.json +1 -1
package/extensions/proxy.ts
CHANGED
|
@@ -99,11 +99,14 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
// Resolve pi-proxy binary: try
|
|
102
|
+
// Resolve pi-proxy binary: try local dev build, then installed package, then PATH
|
|
103
103
|
function findProxyBinary(): string {
|
|
104
|
-
//
|
|
105
|
-
const
|
|
106
|
-
if (existsSync(
|
|
104
|
+
// Local development: dist/index.mjs in the same package root
|
|
105
|
+
const localBin = resolve(packageRoot, "dist", "index.mjs");
|
|
106
|
+
if (existsSync(localBin)) return localBin;
|
|
107
|
+
// Installed as dependency: node_modules/pi-proxy/dist/index.mjs
|
|
108
|
+
const depBin = resolve(packageRoot, "node_modules", "pi-proxy", "dist", "index.mjs");
|
|
109
|
+
if (existsSync(depBin)) return depBin;
|
|
107
110
|
// Fallback: assume pi-proxy is in PATH
|
|
108
111
|
return "pi-proxy";
|
|
109
112
|
}
|
|
@@ -611,6 +614,40 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
611
614
|
};
|
|
612
615
|
}
|
|
613
616
|
|
|
617
|
+
// --- Dynamic descriptions ---
|
|
618
|
+
|
|
619
|
+
const ID_MODE_DESCRIPTIONS: Record<string, string> = {
|
|
620
|
+
"collision-prefixed": "Short names; adds provider/ prefix only when models collide",
|
|
621
|
+
universal: "Short names only; fails if any model name is shared by two providers",
|
|
622
|
+
"always-prefixed": "Always provider/model-id for every model",
|
|
623
|
+
};
|
|
624
|
+
|
|
625
|
+
const EXPOSURE_MODE_DESCRIPTIONS: Record<string, string> = {
|
|
626
|
+
scoped: "Expose models from pi's configured auth (default)",
|
|
627
|
+
all: "Expose all registered models, including those without auth",
|
|
628
|
+
custom: "Expose only manually selected models",
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
function idModeDescription(): string {
|
|
632
|
+
return ID_MODE_DESCRIPTIONS[config.publicModelIdMode] ?? "";
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function exposureModeDescription(): string {
|
|
636
|
+
return EXPOSURE_MODE_DESCRIPTIONS[config.modelExposureMode] ?? "";
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
function customModelsDescription(): string {
|
|
640
|
+
if (config.modelExposureMode === "custom") return "Press Enter to open model selector";
|
|
641
|
+
return "Switch exposure mode to 'custom' to select models";
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
function authDescription(): string {
|
|
645
|
+
if (config.authToken.length > 0) {
|
|
646
|
+
return `Token: ${config.authToken.slice(0, 8)}... (use /proxy show to copy)`;
|
|
647
|
+
}
|
|
648
|
+
return "Require bearer token for all requests";
|
|
649
|
+
}
|
|
650
|
+
|
|
614
651
|
function buildSettingItems(): SettingItem[] {
|
|
615
652
|
return [
|
|
616
653
|
// --- Server ---
|
|
@@ -638,10 +675,7 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
638
675
|
{
|
|
639
676
|
id: "authToken",
|
|
640
677
|
label: "Proxy auth",
|
|
641
|
-
description:
|
|
642
|
-
config.authToken.length > 0
|
|
643
|
-
? `Token: ${config.authToken.slice(0, 8)}... (use /proxy show to copy)`
|
|
644
|
-
: "Require bearer token for all requests",
|
|
678
|
+
description: authDescription(),
|
|
645
679
|
currentValue: config.authToken.length > 0 ? "enabled" : "disabled",
|
|
646
680
|
values: ["disabled", "enabled"],
|
|
647
681
|
},
|
|
@@ -669,32 +703,50 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
669
703
|
// --- Model exposure ---
|
|
670
704
|
{
|
|
671
705
|
id: "publicModelIdMode",
|
|
672
|
-
label: "
|
|
673
|
-
description:
|
|
706
|
+
label: "Model ID format",
|
|
707
|
+
description: idModeDescription(),
|
|
674
708
|
currentValue: config.publicModelIdMode,
|
|
675
709
|
values: ["collision-prefixed", "universal", "always-prefixed"],
|
|
676
710
|
},
|
|
677
711
|
{
|
|
678
712
|
id: "modelExposureMode",
|
|
679
713
|
label: "Exposure mode",
|
|
680
|
-
description:
|
|
681
|
-
"scoped = pi's available models, all = all registered, custom = manual selection",
|
|
714
|
+
description: exposureModeDescription(),
|
|
682
715
|
currentValue: config.modelExposureMode,
|
|
683
716
|
values: ["scoped", "all", "custom"],
|
|
684
717
|
},
|
|
685
718
|
{
|
|
686
719
|
id: "customModels",
|
|
687
720
|
label: "Select models",
|
|
688
|
-
description:
|
|
689
|
-
config.modelExposureMode === "custom"
|
|
690
|
-
? "Press Enter to open model selector"
|
|
691
|
-
: "Switch exposure mode to 'custom' to select models",
|
|
721
|
+
description: customModelsDescription(),
|
|
692
722
|
currentValue: customModelsDisplay(),
|
|
693
723
|
submenu: config.modelExposureMode === "custom" ? buildModelSelectorSubmenu : undefined,
|
|
694
724
|
},
|
|
695
725
|
];
|
|
696
726
|
}
|
|
697
727
|
|
|
728
|
+
/**
|
|
729
|
+
* Update descriptions on items that change dynamically based on the current value.
|
|
730
|
+
*/
|
|
731
|
+
function refreshDescriptions(items: SettingItem[]): void {
|
|
732
|
+
for (const item of items) {
|
|
733
|
+
switch (item.id) {
|
|
734
|
+
case "publicModelIdMode":
|
|
735
|
+
item.description = idModeDescription();
|
|
736
|
+
break;
|
|
737
|
+
case "modelExposureMode":
|
|
738
|
+
item.description = exposureModeDescription();
|
|
739
|
+
break;
|
|
740
|
+
case "customModels":
|
|
741
|
+
item.description = customModelsDescription();
|
|
742
|
+
break;
|
|
743
|
+
case "authToken":
|
|
744
|
+
item.description = authDescription();
|
|
745
|
+
break;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
698
750
|
const VALID_ID_MODES = new Set<string>(["collision-prefixed", "universal", "always-prefixed"]);
|
|
699
751
|
|
|
700
752
|
function isPublicModelIdMode(v: string): v is PublicModelIdMode {
|
|
@@ -818,8 +870,9 @@ export default function proxyExtension(pi: ExtensionAPI): void {
|
|
|
818
870
|
ctx.ui.notify(`Auth token: ${lastGeneratedToken}`, "info");
|
|
819
871
|
}
|
|
820
872
|
|
|
821
|
-
// Update display value in-place (
|
|
873
|
+
// Update display value and descriptions in-place (preserves selection)
|
|
822
874
|
settingsList.updateValue(id, getDisplayValue(id));
|
|
875
|
+
refreshDescriptions(items);
|
|
823
876
|
|
|
824
877
|
// When exposure mode changes, update the "Select models" item
|
|
825
878
|
if (id === "modelExposureMode") {
|
package/package.json
CHANGED