Skip to content

Commit b530b16

Browse files
author
Michael Gasperini
committed
fix: keep subscription inference on the adapter
- unref the loopback server so one-shot CLI processes can exit - stop pinning api.meta.ai in the manifest catalog; the runtime provider entry supplies the adapter origin - map reasoning.effort none/off to minimal - raise the adapter output floor to 1024 for connection probes - list the Muse Wonder models in the static catalog - document per-agent login on multi-agent gateways Reported in #17.
1 parent fad882f commit b530b16

15 files changed

Lines changed: 170 additions & 46 deletions

‎ADAPTER_CONTRACT.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ rejects it, and bump `ADAPTER_VERSION`.
7676
2. **`tool_choice`.** Meta accepts only `"auto"`. Any other value (named function, `"none"`,
7777
`"required"`) is replaced with `"auto"`.
7878
3. **Reasoning effort.** A top-level `reasoning_effort` string moves to `reasoning.effort`; an
79-
explicit `reasoning.effort` already present wins.
80-
4. **Output floor.** `max_output_tokens` below 16 is raised to 16.
79+
explicit `reasoning.effort` already present wins. `none` and `off` map to `minimal`, the lowest
80+
level Meta accepts.
81+
4. **Output floor.** `max_output_tokens` below 16 is raised to 16 by default. The OpenClaw plugin
82+
starts its adapter with a 1024-token floor so its connection probe leaves room for the
83+
reasoning budget; the shared default stays 16.
8184
5. **Reasoning replay.** `reasoning.encrypted_content` is appended to `include` when missing, so a
8285
host that replays provider items can keep the encrypted reasoning item.
8386
6. **Version header.** `x-api-version: 1.0.0` is added when the host did not set it.

‎CHANGELOG.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.6.1] - 2026-10-31
11+
12+
### Fixed
13+
14+
- The loopback adapter is unref'd, so one-shot CLI commands that load the plugin can exit instead
15+
of hanging on the listener.
16+
- The manifest catalog no longer pins `api.meta.ai`: the host resolves the provider base URL from
17+
the runtime entry, which points at the adapter, so inference keeps going through aliasing and
18+
normalization.
19+
- `reasoning.effort: "none"` (OpenClaw's thinking-off level) maps to `minimal` instead of being
20+
rejected by Meta.
21+
- The adapter's output floor is 1024 tokens for OpenClaw, so connection probes are not consumed by
22+
the reasoning budget and return text.
23+
- The static catalog lists `muse-wonder-1.0` and `muse-wonder-1.0-contributor`, so the live models
24+
are visible before discovery.
25+
26+
### Documented
27+
28+
- Multi-agent gateways need one
29+
`models auth login --provider muse-code --method device-code --agent <id>` per agent.
30+
1031
## [0.6.0] - 2026-10-30
1132

1233
### Added

‎CITATION.cff‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
cff-version: 1.2.0
22
message: "If you use this software, please cite it as below."
33
title: "openclaw-muse-code"
4-
version: 0.6.0
5-
date-released: "2026-10-30"
4+
version: 0.6.1
5+
date-released: "2026-10-31"
66
url: "https://github.com/TheStreamCode/openclaw-muse-code"
77
repository-code: "https://github.com/TheStreamCode/openclaw-muse-code"
88
license: MIT

‎README.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ discovery, is relayed untouched. The wire rules are pinned in
3838
wire format, and Meta's policy still applies. If Meta still refuses the request, the adapter
3939
retries once with every tool aliased.
4040

41+
The adapter is unref'd, so one-shot CLI commands that load the plugin can exit, and its output
42+
floor is 1024 tokens for OpenClaw: the connection probe asks for a tiny budget that a reasoning
43+
turn would otherwise consume before producing text. `reasoning.effort` values `none` and `off`
44+
map to `minimal`, which is the lowest effort Meta accepts. The static manifest catalog carries
45+
display metadata only and deliberately omits a base URL, so the host resolves the adapter origin
46+
from the runtime provider entry instead of pinning `api.meta.ai`.
47+
4148
`MUSE_CODE_ADAPTER=off` keeps the proxy in place and disables only the rewriting, so a base URL
4249
already observed by OpenClaw stays valid. If the adapter cannot bind, the plugin logs the failure
4350
and the provider keeps the direct `https://api.meta.ai/v1` endpoint.
@@ -75,6 +82,10 @@ openclaw plugins install --link .
7582
The onboarding choice requires OpenClaw 2026.9.5 or newer. On older gateways, use the
7683
`models auth login` command above.
7784

85+
On a multi-agent Gateway, sign in once per agent with
86+
`openclaw models auth login --provider muse-code --method device-code --agent <id>`:
87+
credentials do not carry across agents.
88+
7889
2. Approve the code in the browser. If the browser does not open, use the displayed URL and code.
7990
OpenClaw saves an auth profile, and the plugin also writes its existing local cache at
8091
`~/.openclaw/muse-code-sub.json` (override with `MUSE_CODE_SUB_CREDENTIALS`). The key is never
@@ -109,6 +120,8 @@ but not an existing OpenClaw auth profile; use the browser login above to replac
109120
| --- | --- | --- |
110121
| `muse-code/muse-spark-1.3` | Standard (default) | 1,048,576 |
111122
| `muse-code/muse-spark-1.3-contributor` | Contributor | 1,048,576 |
123+
| `muse-code/muse-wonder-1.0` | Standard | 1,048,576 |
124+
| `muse-code/muse-wonder-1.0-contributor` | Contributor | 1,048,576 |
112125
| `muse-code/muse-spark-1.2` | Standard | 1,048,576 |
113126
| `muse-code/muse-spark-1.2-contributor` | Contributor | 1,048,576 |
114127
| `muse-code/muse-spark-1.1` | Standard | 1,048,576 |

‎dist/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const META_BASE_URL = "https://api.meta.ai/v1";
2929
* host stays valid when the wire rules are switched off.
3030
*/
3131
export const ADAPTER_ENV_VAR = "MUSE_CODE_ADAPTER";
32-
const defaultAdapterFactory = (options) => startMuseCodeAdapter(options);
32+
const defaultAdapterFactory = (options) => startMuseCodeAdapter({ ...options, minOutputTokens: 1024 });
3333
let adapterFactory = defaultAdapterFactory;
3434
let adapterLogger;
3535
let adapterStart;

‎dist/src/adapter.js‎

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ function applyAliases(body, plan) {
169169
* are preserved untouched. Pass a plan from {@link planToolAliases} to reuse a
170170
* mapping, for example the full-aliasing retry.
171171
*/
172-
export function transformRequestBody(body, plan) {
172+
export function transformRequestBody(body, plan, options = {}) {
173173
const next = { ...body };
174174
const notes = [];
175175
const chosen = plan ?? planToolAliases(next["tools"]);
@@ -183,17 +183,29 @@ export function transformRequestBody(body, plan) {
183183
next["tool_choice"] = "auto";
184184
notes.push("tool_choice=auto");
185185
}
186-
const effort = next["reasoning_effort"];
187-
if (typeof effort === "string") {
188-
const reasoning = isRecord(next["reasoning"]) ? next["reasoning"] : {};
189-
next["reasoning"] = { ...reasoning, effort: reasoning["effort"] ?? effort };
190-
delete next["reasoning_effort"];
191-
notes.push("reasoning_effort->reasoning.effort");
186+
const reasoning = isRecord(next["reasoning"]) ? next["reasoning"] : undefined;
187+
const legacyEffort = next["reasoning_effort"];
188+
const effort = typeof reasoning?.["effort"] === "string"
189+
? reasoning["effort"]
190+
: typeof legacyEffort === "string"
191+
? legacyEffort
192+
: undefined;
193+
if (effort !== undefined && (legacyEffort !== undefined || effort === "none" || effort === "off")) {
194+
// Meta accepts only minimal..max on the reasoning effort; OpenClaw's
195+
// thinking-off level arrives as "none" and would otherwise be a 400.
196+
const normalized = effort === "none" || effort === "off" ? "minimal" : effort;
197+
next["reasoning"] = { ...(reasoning ?? {}), effort: normalized };
198+
if (legacyEffort !== undefined)
199+
delete next["reasoning_effort"];
200+
notes.push(normalized !== effort
201+
? `reasoning.effort ${effort}->${normalized}`
202+
: "reasoning_effort->reasoning.effort");
192203
}
193204
const maxOutput = next["max_output_tokens"];
194-
if (typeof maxOutput === "number" && maxOutput < 16) {
195-
next["max_output_tokens"] = 16;
196-
notes.push("max_output_tokens>=16");
205+
const floor = options.minOutputTokens ?? 16;
206+
if (typeof maxOutput === "number" && maxOutput < floor) {
207+
next["max_output_tokens"] = floor;
208+
notes.push(`max_output_tokens>=${String(floor)}`);
197209
}
198210
const include = Array.isArray(next["include"]) ? next["include"] : [];
199211
if (!include.includes("reasoning.encrypted_content")) {
@@ -413,6 +425,7 @@ export async function startMuseCodeAdapter(options = {}) {
413425
const passthrough = options.passthrough === true;
414426
const log = options.log ?? (() => { });
415427
const candidates = options.ports ?? DEFAULT_PORTS;
428+
const minOutputTokens = options.minOutputTokens ?? 16;
416429
let lastError;
417430
let server;
418431
let port = 0;
@@ -431,6 +444,9 @@ export async function startMuseCodeAdapter(options = {}) {
431444
throw new Error(`muse-code adapter could not bind a loopback port: ${String(lastError)}`);
432445
}
433446
const running = server;
447+
// The adapter is a background service: it must not keep a one-shot CLI
448+
// process alive after the host has finished its work.
449+
running.unref();
434450
running.on("request", (request, response) => {
435451
void handle(request, response).catch((error) => {
436452
log(`muse-code adapter error: ${error instanceof Error ? error.message : String(error)}`);
@@ -460,7 +476,7 @@ export async function startMuseCodeAdapter(options = {}) {
460476
const parsed = JSON.parse(raw.toString("utf8"));
461477
if (isRecord(parsed)) {
462478
parsedBody = parsed;
463-
const adapted = transformRequestBody(parsed);
479+
const adapted = transformRequestBody(parsed, undefined, { minOutputTokens });
464480
body = Buffer.from(JSON.stringify(adapted.body), "utf8");
465481
reverse = adapted.plan.reverse;
466482
notes.push(...adapted.notes);
@@ -484,7 +500,7 @@ export async function startMuseCodeAdapter(options = {}) {
484500
if (probe.includes("client_attestation_denied")) {
485501
const allPlan = planToolAliases(parsedBody["tools"], { all: true });
486502
if (allPlan.aliases.size > reverse.size) {
487-
const retry = transformRequestBody(parsedBody, allPlan);
503+
const retry = transformRequestBody(parsedBody, allPlan, { minOutputTokens });
488504
reverse = allPlan.reverse;
489505
notes.push(`gate refused; retried with all ${String(allPlan.aliases.size)} tools aliased`);
490506
upstreamResponse = await send(Buffer.from(JSON.stringify(retry.body), "utf8"));

‎dist/src/baseline.models.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ export const museCodeBaselineModels = [
1414
name: "Muse Spark 1.3 Contributor",
1515
context_length: 1048576,
1616
},
17+
{ id: "muse-wonder-1.0", name: "Muse Wonder 1.0", context_length: 1048576 },
18+
{
19+
id: "muse-wonder-1.0-contributor",
20+
name: "Muse Wonder 1.0 Contributor",
21+
context_length: 1048576,
22+
},
1723
{ id: "muse-spark-1.2", name: "Muse Spark 1.2", context_length: 1048576 },
1824
{
1925
id: "muse-spark-1.2-contributor",

‎index.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ type AdapterLogger = {
5959
warn?: (message: string) => void;
6060
};
6161

62-
const defaultAdapterFactory: MuseCodeAdapterFactory = (options) => startMuseCodeAdapter(options);
62+
const defaultAdapterFactory: MuseCodeAdapterFactory = (options) =>
63+
startMuseCodeAdapter({ ...options, minOutputTokens: 1024 });
6364

6465
let adapterFactory: MuseCodeAdapterFactory = defaultAdapterFactory;
6566
let adapterLogger: AdapterLogger | undefined;

‎openclaw.plugin.json‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,12 @@
3939
"modelCatalog": {
4040
"providers": {
4141
"muse-code": {
42-
"baseUrl": "https://api.meta.ai/v1",
4342
"api": "openai-responses",
4443
"models": [
4544
{
4645
"id": "muse-spark-1.3",
4746
"name": "Muse Spark 1.3",
4847
"api": "openai-responses",
49-
"baseUrl": "https://api.meta.ai/v1",
5048
"reasoning": true,
5149
"input": ["text", "image"],
5250
"contextWindow": 1048576,
@@ -57,7 +55,26 @@
5755
"id": "muse-spark-1.3-contributor",
5856
"name": "Muse Spark 1.3 Contributor",
5957
"api": "openai-responses",
60-
"baseUrl": "https://api.meta.ai/v1",
58+
"reasoning": true,
59+
"input": ["text", "image"],
60+
"contextWindow": 1048576,
61+
"maxTokens": 131072,
62+
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
63+
},
64+
{
65+
"id": "muse-wonder-1.0",
66+
"name": "Muse Wonder 1.0",
67+
"api": "openai-responses",
68+
"reasoning": true,
69+
"input": ["text", "image"],
70+
"contextWindow": 1048576,
71+
"maxTokens": 131072,
72+
"cost": { "input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0 }
73+
},
74+
{
75+
"id": "muse-wonder-1.0-contributor",
76+
"name": "Muse Wonder 1.0 Contributor",
77+
"api": "openai-responses",
6178
"reasoning": true,
6279
"input": ["text", "image"],
6380
"contextWindow": 1048576,
@@ -68,7 +85,6 @@
6885
"id": "muse-spark-1.2",
6986
"name": "Muse Spark 1.2",
7087
"api": "openai-responses",
71-
"baseUrl": "https://api.meta.ai/v1",
7288
"reasoning": true,
7389
"input": ["text", "image"],
7490
"contextWindow": 1048576,
@@ -79,7 +95,6 @@
7995
"id": "muse-spark-1.2-contributor",
8096
"name": "Muse Spark 1.2 Contributor",
8197
"api": "openai-responses",
82-
"baseUrl": "https://api.meta.ai/v1",
8398
"reasoning": true,
8499
"input": ["text", "image"],
85100
"contextWindow": 1048576,
@@ -90,7 +105,6 @@
90105
"id": "muse-spark-1.1",
91106
"name": "Muse Spark 1.1",
92107
"api": "openai-responses",
93-
"baseUrl": "https://api.meta.ai/v1",
94108
"reasoning": true,
95109
"input": ["text", "image"],
96110
"contextWindow": 1048576,

‎package-lock.json‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)