agentsw 0.3.0 → 0.4.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/dist/import.js +14 -1
- package/dist/index.js +0 -0
- package/package.json +1 -1
package/dist/import.js
CHANGED
|
@@ -4,7 +4,16 @@ import { targets } from "./targets/index.js";
|
|
|
4
4
|
export function normalizeUrl(u) {
|
|
5
5
|
return u.replace(/\/+$/, "");
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
/** True when a base URL already names the API version, e.g. `.../v1`. */
|
|
8
|
+
const hasApiVersion = (baseUrl) => /\/v\d+(?:beta\d*)?$/i.test(baseUrl);
|
|
9
|
+
/**
|
|
10
|
+
* Endpoint identity for dedupe. Apps disagree about who owns the `/v1` segment:
|
|
11
|
+
* omp/pi/opencode store it in the base URL, while Codex (and cc-switch's Codex
|
|
12
|
+
* rows) leave it off because the client appends it. `https://host` and
|
|
13
|
+
* `https://host/v1` on one protocol are the same upstream, so they must merge
|
|
14
|
+
* into one provider instead of importing twice.
|
|
15
|
+
*/
|
|
16
|
+
const matchKey = (protocol, baseUrl) => `${protocol}|${normalizeUrl(baseUrl).replace(/\/v\d+(?:beta\d*)?$/i, "")}`;
|
|
8
17
|
/** pure merge: dedupe candidates by protocol+baseUrl, union models, keep first resolved key */
|
|
9
18
|
export function mergeCandidates(rows, existing) {
|
|
10
19
|
const merged = new Map();
|
|
@@ -29,6 +38,10 @@ export function mergeCandidates(rows, existing) {
|
|
|
29
38
|
cur.models.push(m);
|
|
30
39
|
if (!cur.defaultModel && c.defaultModel)
|
|
31
40
|
cur.defaultModel = c.defaultModel;
|
|
41
|
+
// keep the variant that names the API version: model discovery and most adapters
|
|
42
|
+
// need the full endpoint, and only Codex fills the segment in itself
|
|
43
|
+
if (!hasApiVersion(cur.baseUrl) && hasApiVersion(normalizeUrl(c.baseUrl)))
|
|
44
|
+
cur.baseUrl = normalizeUrl(c.baseUrl);
|
|
32
45
|
// responses wins: an endpoint one app drives over /v1/responses serves it for all of them,
|
|
33
46
|
// and codex speaks nothing else
|
|
34
47
|
if (c.openaiApi === "responses" || !cur.openaiApi)
|
package/dist/index.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentsw",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "CLI provider switcher for coding agents: manage OpenAI/Anthropic-protocol providers in one place and sync them, with models.dev metadata, into Claude Code, Codex, omp, pi, prime-agent, opencode, Hermes, WorkBuddy and DeepSeek Harness",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|