@vtstech/pi-api 1.1.2 → 1.1.4

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.
Files changed (2) hide show
  1. package/api.js +10 -0
  2. package/package.json +2 -2
package/api.js CHANGED
@@ -188,12 +188,22 @@ function api_temp_default(pi) {
188
188
  if (!normalizedUrl.startsWith("http")) {
189
189
  normalizedUrl = "http://" + normalizedUrl;
190
190
  }
191
+ try {
192
+ new URL(normalizedUrl);
193
+ } catch {
194
+ ctx.ui.notify(`Invalid URL: "${url}"`, "error");
195
+ return;
196
+ }
191
197
  const config = readModelsJson();
192
198
  const provider = config.providers[providerName];
193
199
  if (!provider) {
194
200
  ctx.ui.notify(`Provider "${providerName}" not found in models.json`, "error");
195
201
  return;
196
202
  }
203
+ const apiMode = provider.api || "";
204
+ if (apiMode.includes("openai") && !normalizedUrl.endsWith("/v1")) {
205
+ normalizedUrl = normalizedUrl.replace(/\/+$/, "") + "/v1";
206
+ }
197
207
  const oldUrl = provider.baseUrl || "(not set)";
198
208
  provider.baseUrl = normalizedUrl;
199
209
  writeModelsJson(config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vtstech/pi-api",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
4
  "description": "API Mode Switcher extension for Pi Coding Agent",
5
5
  "main": "api.js",
6
6
  "keywords": ["pi-extensions"],
@@ -14,7 +14,7 @@
14
14
  "url": "https://github.com/VTSTech/pi-coding-agent"
15
15
  },
16
16
  "dependencies": {
17
- "@vtstech/pi-shared": "1.1.2"
17
+ "@vtstech/pi-shared": "1.1.4"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@mariozechner/pi-coding-agent": ">=0.66"