clawmux 0.3.14 → 0.3.15
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 +2 -0
- package/dist/cli.cjs +54 -11
- package/dist/index.cjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,8 @@ ClawMux registers as a single provider `clawmux` in OpenClaw with model `auto`.
|
|
|
83
83
|
openclaw provider clawmux
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
`clawmux init` manages the `clawmux` provider entry in `openclaw.json` (and the per-agent `models.json` caches) for you. It sets `api` to match your MEDIUM tier's API format and computes the correct `baseUrl` from that — `http://localhost:<port>/v1` for OpenAI-style APIs (where the upstream SDK appends `/chat/completions` or `/responses`) and `http://localhost:<port>` for everything else. Do not hand-edit these fields; rerun `clawmux init` after changing the MEDIUM model in `~/.openclaw/clawmux.json`.
|
|
87
|
+
|
|
86
88
|
## How It Works
|
|
87
89
|
|
|
88
90
|
```
|
package/dist/cli.cjs
CHANGED
|
@@ -3,6 +3,7 @@ var __create = Object.create;
|
|
|
3
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
8
|
function __accessProp(key) {
|
|
8
9
|
return this[key];
|
|
@@ -29,6 +30,23 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
29
30
|
cache.set(mod, to);
|
|
30
31
|
return to;
|
|
31
32
|
};
|
|
33
|
+
var __toCommonJS = (from) => {
|
|
34
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
35
|
+
if (entry)
|
|
36
|
+
return entry;
|
|
37
|
+
entry = __defProp({}, "__esModule", { value: true });
|
|
38
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
39
|
+
for (var key of __getOwnPropNames(from))
|
|
40
|
+
if (!__hasOwnProp.call(entry, key))
|
|
41
|
+
__defProp(entry, key, {
|
|
42
|
+
get: __accessProp.bind(from, key),
|
|
43
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
__moduleCache.set(from, entry);
|
|
47
|
+
return entry;
|
|
48
|
+
};
|
|
49
|
+
var __moduleCache;
|
|
32
50
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
33
51
|
var __returnValue = (v) => v;
|
|
34
52
|
function __exportSetter(name, newValue) {
|
|
@@ -112214,13 +112232,18 @@ var require_dist4 = __commonJS((exports2, module2) => {
|
|
|
112214
112232
|
});
|
|
112215
112233
|
|
|
112216
112234
|
// src/cli.ts
|
|
112235
|
+
var exports_cli = {};
|
|
112236
|
+
__export(exports_cli, {
|
|
112237
|
+
resolveProviderBaseUrl: () => resolveProviderBaseUrl
|
|
112238
|
+
});
|
|
112239
|
+
module.exports = __toCommonJS(exports_cli);
|
|
112217
112240
|
var import_promises8 = require("node:fs/promises");
|
|
112218
112241
|
var import_node_path7 = require("node:path");
|
|
112219
112242
|
var import_node_child_process = require("node:child_process");
|
|
112220
112243
|
var import_node_os2 = require("node:os");
|
|
112221
112244
|
|
|
112222
112245
|
// src/proxy/router.ts
|
|
112223
|
-
var VERSION = process.env.npm_package_version ?? "0.3.
|
|
112246
|
+
var VERSION = process.env.npm_package_version ?? "0.3.15";
|
|
112224
112247
|
function jsonResponse(body, status = 200) {
|
|
112225
112248
|
return new Response(JSON.stringify(body), {
|
|
112226
112249
|
status,
|
|
@@ -121143,6 +121166,13 @@ function resolveProviderApi(mediumModel, openclawProviders) {
|
|
|
121143
121166
|
return api;
|
|
121144
121167
|
return PROVIDER_API_FALLBACK;
|
|
121145
121168
|
}
|
|
121169
|
+
function resolveProviderBaseUrl(apiType, port) {
|
|
121170
|
+
const origin = `http://localhost:${port}`;
|
|
121171
|
+
if (apiType === "openai-completions" || apiType === "openai-responses") {
|
|
121172
|
+
return `${origin}/v1`;
|
|
121173
|
+
}
|
|
121174
|
+
return origin;
|
|
121175
|
+
}
|
|
121146
121176
|
async function fileExistsLocal(path4) {
|
|
121147
121177
|
try {
|
|
121148
121178
|
await import_promises8.access(path4);
|
|
@@ -121421,7 +121451,7 @@ async function update() {
|
|
|
121421
121451
|
process.exit(1);
|
|
121422
121452
|
}
|
|
121423
121453
|
}
|
|
121424
|
-
async function fixAgentModelsJson(homeDir, providerKey,
|
|
121454
|
+
async function fixAgentModelsJson(homeDir, providerKey, servicePort, fallbackApiType) {
|
|
121425
121455
|
const agentsDir = import_node_path7.join(homeDir, ".openclaw", "agents");
|
|
121426
121456
|
let agentDirs;
|
|
121427
121457
|
try {
|
|
@@ -121439,13 +121469,15 @@ async function fixAgentModelsJson(homeDir, providerKey, correctBaseUrl) {
|
|
|
121439
121469
|
if (!agentProviders?.[providerKey])
|
|
121440
121470
|
continue;
|
|
121441
121471
|
const entry = agentProviders[providerKey];
|
|
121472
|
+
const agentApiType = typeof entry["api"] === "string" && entry["api"].length > 0 ? entry["api"] : fallbackApiType;
|
|
121473
|
+
const correctBaseUrl = resolveProviderBaseUrl(agentApiType, servicePort);
|
|
121442
121474
|
const current = String(entry["baseUrl"] ?? "");
|
|
121443
121475
|
if (current === correctBaseUrl)
|
|
121444
121476
|
continue;
|
|
121445
121477
|
entry["baseUrl"] = correctBaseUrl;
|
|
121446
121478
|
await import_promises8.writeFile(modelsPath, JSON.stringify(data, null, 2) + `
|
|
121447
121479
|
`);
|
|
121448
|
-
console.log(` fixed agent ${agentId} ${providerKey} baseUrl: ${current} → ${correctBaseUrl}`);
|
|
121480
|
+
console.log(` fixed agent ${agentId} ${providerKey} baseUrl: ${current} → ${correctBaseUrl} (api=${agentApiType})`);
|
|
121449
121481
|
} catch {}
|
|
121450
121482
|
}
|
|
121451
121483
|
}
|
|
@@ -121504,31 +121536,42 @@ async function init() {
|
|
|
121504
121536
|
} catch {
|
|
121505
121537
|
console.log(`[info] clawmux.json not readable, using default api: ${providerApi}`);
|
|
121506
121538
|
}
|
|
121539
|
+
const servicePort = process.env.CLAWMUX_PORT ?? "3456";
|
|
121540
|
+
const providerBaseUrl = resolveProviderBaseUrl(providerApi, servicePort);
|
|
121507
121541
|
if (providers[PROVIDER_KEY]) {
|
|
121508
121542
|
const existing = providers[PROVIDER_KEY];
|
|
121509
|
-
|
|
121543
|
+
const existingApi = existing["api"];
|
|
121544
|
+
const existingBaseUrl = existing["baseUrl"];
|
|
121545
|
+
let dirty = false;
|
|
121546
|
+
if (existingApi !== providerApi) {
|
|
121510
121547
|
existing["api"] = providerApi;
|
|
121548
|
+
dirty = true;
|
|
121549
|
+
}
|
|
121550
|
+
if (existingBaseUrl !== providerBaseUrl) {
|
|
121551
|
+
existing["baseUrl"] = providerBaseUrl;
|
|
121552
|
+
dirty = true;
|
|
121553
|
+
}
|
|
121554
|
+
if (dirty) {
|
|
121511
121555
|
await import_promises8.writeFile(openclawConfigPath, JSON.stringify(config, null, 2) + `
|
|
121512
121556
|
`);
|
|
121513
|
-
console.log(` updated ${PROVIDER_KEY} provider api
|
|
121557
|
+
console.log(` updated ${PROVIDER_KEY} provider (api=${providerApi}, baseUrl=${providerBaseUrl})`);
|
|
121514
121558
|
} else {
|
|
121515
|
-
console.log(` skip ${PROVIDER_KEY} (already exists, api=${providerApi})`);
|
|
121559
|
+
console.log(` skip ${PROVIDER_KEY} (already exists, api=${providerApi}, baseUrl=${providerBaseUrl})`);
|
|
121516
121560
|
}
|
|
121517
121561
|
} else {
|
|
121518
121562
|
providers[PROVIDER_KEY] = {
|
|
121519
|
-
baseUrl:
|
|
121563
|
+
baseUrl: providerBaseUrl,
|
|
121520
121564
|
api: providerApi,
|
|
121521
121565
|
models: [{ id: "auto", name: "ClawMux Auto Router" }]
|
|
121522
121566
|
};
|
|
121523
121567
|
await import_promises8.writeFile(openclawConfigPath, JSON.stringify(config, null, 2) + `
|
|
121524
121568
|
`);
|
|
121525
|
-
console.log(` added ${PROVIDER_KEY} provider to openclaw.json (api=${providerApi})`);
|
|
121569
|
+
console.log(` added ${PROVIDER_KEY} provider to openclaw.json (api=${providerApi}, baseUrl=${providerBaseUrl})`);
|
|
121526
121570
|
}
|
|
121527
|
-
await fixAgentModelsJson(homeDir, PROVIDER_KEY,
|
|
121528
|
-
const port = process.env.CLAWMUX_PORT ?? "3456";
|
|
121571
|
+
await fixAgentModelsJson(homeDir, PROVIDER_KEY, servicePort, providerApi);
|
|
121529
121572
|
if (!noService) {
|
|
121530
121573
|
console.log("");
|
|
121531
|
-
await installService(
|
|
121574
|
+
await installService(servicePort, process.cwd());
|
|
121532
121575
|
}
|
|
121533
121576
|
console.log(`
|
|
121534
121577
|
[info] ClawMux setup complete!`);
|
package/dist/index.cjs
CHANGED
|
@@ -112238,7 +112238,7 @@ __export(exports_src2, {
|
|
|
112238
112238
|
module.exports = __toCommonJS(exports_src2);
|
|
112239
112239
|
|
|
112240
112240
|
// src/proxy/router.ts
|
|
112241
|
-
var VERSION = process.env.npm_package_version ?? "0.3.
|
|
112241
|
+
var VERSION = process.env.npm_package_version ?? "0.3.15";
|
|
112242
112242
|
function jsonResponse(body, status = 200) {
|
|
112243
112243
|
return new Response(JSON.stringify(body), {
|
|
112244
112244
|
status,
|