Skip to content

Commit 8393b37

Browse files
committed
fix(setup): keep compatible Claude wrappers selectable
1 parent d636f5f commit 8393b37

10 files changed

Lines changed: 63 additions & 75 deletions

‎docs/gateway/cli-backends.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,18 @@ The `openclaw agent` command also has its own request deadline. Its 600-second f
116116

117117
### Claude CLI specifics
118118

119-
OpenClaw's managed Claude stdio sessions require Claude Code 2.1.206 or newer.
120-
At runtime OpenClaw does not trust the version string alone: it waits for
119+
OpenClaw's managed Claude stdio sessions require the `msg_lifecycle_v1`
120+
capability, first observed in the published Claude Code 2.1.206 build. At
121+
runtime OpenClaw does not trust the version string alone: it waits for
121122
Claude Code's `system/init` record to advertise `msg_lifecycle_v1`, then accepts
122123
assistant, tool, and result records only after the matching input lifecycle has
123124
started. Unknown capabilities are ignored. A CLI that omits the required
124125
capability fails immediately with `claude update` and gateway-restart guidance
125126
instead of waiting for the no-output watchdog.
126127

128+
Setup and Doctor treat 2.1.206 as advisory, so a lower-version compatible
129+
backport or wrapper remains selectable and is verified by the runtime gate.
130+
127131
```bash
128132
claude --version
129133
claude update

‎docs/providers/anthropic.md‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@ OpenClaw release:
9191

9292
<Steps>
9393
<Step title="Ensure Claude CLI is installed and logged in">
94-
OpenClaw's streamed session correlation requires Claude Code 2.1.206 or
95-
newer. Verify the installed version:
94+
OpenClaw's streamed session correlation requires the
95+
`msg_lifecycle_v1` capability. Claude Code 2.1.206 is the first
96+
published build known to advertise it. Verify the installed version:
9697

9798
```bash
9899
claude --version
99100
```
100101

101-
If it is older, update Claude Code and restart OpenClaw so the gateway
102+
A lower-version compatible backport or wrapper remains selectable;
103+
OpenClaw verifies the capability at runtime. If the runtime rejects the
104+
installed build, update Claude Code and restart OpenClaw so the gateway
102105
launches the new binary:
103106

104107
```bash
@@ -122,8 +125,8 @@ OpenClaw release:
122125

123126
<Note>
124127
Setup and runtime details for the Claude CLI backend are in [CLI Backends](/gateway/cli-backends).
125-
`openclaw doctor` also reports an installed Claude Code version below the
126-
supported floor.
128+
`openclaw doctor` also reports advisory guidance for an installed Claude
129+
Code version below the first-known compatible release.
127130
</Note>
128131

129132
<Warning>

‎src/agents/cli-backend-version-support.ts‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import { coerce as coerceSemver } from "semver";
33
import { compareValidSemver } from "../infra/semver.js";
44
import type { CliBackendLiveSessionRequirement } from "../plugins/cli-backend.types.js";
55

6-
type CliBackendVersionSupport =
7-
| { status: "supported"; version: string }
8-
| { status: "unsupported"; version: string }
6+
type CliBackendVersionGuidance =
7+
| { status: "at-or-above-known-floor"; version: string }
8+
| { status: "below-known-floor"; version: string }
99
| { status: "unknown" };
1010

11-
/** Compare human CLI version output with the provider's published compatibility floor. */
12-
export function resolveCliBackendVersionSupport(
11+
/** Compare human CLI version output with the provider's first-known compatible release. */
12+
export function resolveCliBackendVersionGuidance(
1313
versionOutput: string | undefined,
1414
requirement: CliBackendLiveSessionRequirement,
15-
): CliBackendVersionSupport {
15+
): CliBackendVersionGuidance {
1616
const parsed = versionOutput ? coerceSemver(versionOutput)?.version : undefined;
1717
if (!parsed) {
1818
return { status: "unknown" };
@@ -22,17 +22,16 @@ export function resolveCliBackendVersionSupport(
2222
return { status: "unknown" };
2323
}
2424
return {
25-
status: comparison < 0 ? "unsupported" : "supported",
25+
status: comparison < 0 ? "below-known-floor" : "at-or-above-known-floor",
2626
version: parsed,
2727
};
2828
}
2929

30-
/** Actionable guidance shared by setup, Doctor, and live-session failures. */
31-
export function formatCliBackendUpdateGuidance(params: {
30+
/** Advisory guidance; runtime capability negotiation remains authoritative. */
31+
export function formatCliBackendVersionAdvisory(params: {
3232
label: string;
3333
requirement: CliBackendLiveSessionRequirement;
34-
version?: string;
34+
version: string;
3535
}): string {
36-
const found = params.version ? `; found ${params.version}` : "";
37-
return `${params.label} ${params.requirement.minimumVersion} or newer is required${found}. Run \`${params.requirement.updateCommand}\`, restart OpenClaw, and retry.`;
36+
return `${params.label} ${params.requirement.minimumVersion} is the first published build known to advertise ${params.requirement.capability}; found ${params.version}. OpenClaw verifies this capability at runtime. If this build is rejected, run \`${params.requirement.updateCommand}\`, restart OpenClaw, and retry.`;
3837
}

‎src/commands/doctor-claude-cli.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("noteClaudeCliHealth", () => {
162162
});
163163
});
164164

165-
it("reports an installed Claude Code below the streamed-session floor", async () => {
165+
it("advises on a version below the first-known floor without declaring it unsupported", async () => {
166166
await withTempHome(({ homeDir, workspaceDir }) => {
167167
cliBackendsTesting.setDepsForTest({
168168
resolvePluginSetupCliBackend: () => undefined,
@@ -201,7 +201,7 @@ describe("noteClaudeCliHealth", () => {
201201
);
202202

203203
expect(noteBody(noteFn)).toContain(
204-
"Claude Code 2.1.206 or newer is required; found 2.1.205. Run `claude update`, restart OpenClaw, and retry.",
204+
"Binary version advisory: Claude Code 2.1.206 is the first published build known to advertise msg_lifecycle_v1; found 2.1.205. OpenClaw verifies this capability at runtime. If this build is rejected, run `claude update`, restart OpenClaw, and retry.",
205205
);
206206
});
207207
});

‎src/commands/doctor-claude-cli.ts‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import type {
2121
TokenCredential,
2222
} from "../agents/auth-profiles/types.js";
2323
import {
24-
formatCliBackendUpdateGuidance,
25-
resolveCliBackendVersionSupport,
24+
formatCliBackendVersionAdvisory,
25+
resolveCliBackendVersionGuidance,
2626
} from "../agents/cli-backend-version-support.js";
2727
import { resolveCliBackendConfig } from "../agents/cli-backends.js";
2828
import { readClaudeCliCredentialsCached } from "../agents/cli-credentials.js";
@@ -258,13 +258,13 @@ export function noteClaudeCliHealth(
258258
liveSessionRequirement.versionArgs,
259259
env,
260260
);
261-
const support = resolveCliBackendVersionSupport(versionOutput, liveSessionRequirement);
262-
if (support.status === "unsupported") {
261+
const guidance = resolveCliBackendVersionGuidance(versionOutput, liveSessionRequirement);
262+
if (guidance.status === "below-known-floor") {
263263
lines.push(
264-
`- Binary version: ${formatCliBackendUpdateGuidance({
264+
`- Binary version advisory: ${formatCliBackendVersionAdvisory({
265265
label: "Claude Code",
266266
requirement: liveSessionRequirement,
267-
version: support.version,
267+
version: guidance.version,
268268
})}`,
269269
);
270270
}

‎src/commands/onboard-inference-ambient.ts‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ export type InferenceBackendCandidate = {
2424
* unknown (e.g. macOS keychain-backed logins we must not prompt for here).
2525
*/
2626
credentials?: boolean;
27-
/** Installed route that setup must explain but never activate automatically. */
28-
unavailableReason?: string;
2927
};
3028

3129
export function detectAmbientInferenceBackends(

‎src/commands/onboard-inference.test.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ describe("detectInferenceBackends", () => {
152152
expect(candidates[1]?.credentials).toBeUndefined();
153153
});
154154

155-
it("marks an installed Claude Code below the streamed-session floor unavailable", async () => {
155+
it("keeps a lower-version Claude wrapper selectable with capability guidance", async () => {
156156
const candidates = await detectInferenceBackends({
157157
env: {},
158158
platform: "linux",
@@ -175,8 +175,9 @@ describe("detectInferenceBackends", () => {
175175
expect(candidates).toMatchObject([
176176
{
177177
kind: "claude-cli",
178-
unavailableReason:
179-
"Claude Code 2.1.206 or newer is required; found 2.1.205. Run `claude update`, restart OpenClaw, and retry.",
178+
credentials: true,
179+
detail:
180+
"logged in; Claude Code 2.1.206 is the first published build known to advertise msg_lifecycle_v1; found 2.1.205. OpenClaw verifies this capability at runtime. If this build is rejected, run `claude update`, restart OpenClaw, and retry.",
180181
},
181182
]);
182183
});

‎src/commands/onboard-inference.ts‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import path from "node:path";
55
import { expectDefined } from "@openclaw/normalization-core";
66
import { resolveAgentConfig, resolveDefaultAgentId } from "../agents/agent-scope-config.js";
77
import {
8-
formatCliBackendUpdateGuidance,
9-
resolveCliBackendVersionSupport,
8+
formatCliBackendVersionAdvisory,
9+
resolveCliBackendVersionGuidance,
1010
} from "../agents/cli-backend-version-support.js";
1111
import { resolveCliBackendLiveSessionRequirement } from "../agents/cli-backends.js";
1212
import {
@@ -234,37 +234,34 @@ export async function detectInferenceBackends(
234234
(
235235
options.deps?.resolveClaudeLiveSessionRequirement ?? resolveCliBackendLiveSessionRequirement
236236
)("claude-cli") ?? undefined;
237-
const versionSupport = liveSessionRequirement
238-
? resolveCliBackendVersionSupport(claudeProbe.version, liveSessionRequirement)
237+
const versionGuidance = liveSessionRequirement
238+
? resolveCliBackendVersionGuidance(claudeProbe.version, liveSessionRequirement)
239239
: { status: "unknown" as const };
240240
const claudeCredential = readClaude();
241241
const credentials = detectCliCredentialState({
242242
probe: claudeProbe,
243243
hasStoredCredentials: claudeCredential !== null,
244244
platform,
245245
});
246-
if (
247-
versionSupport.status !== "unsupported" &&
248-
credentials === true &&
249-
claudeCredential?.type === "oauth"
250-
) {
246+
if (credentials === true && claudeCredential?.type === "oauth") {
251247
subscriptionPromotionEligibleCliKinds.add("claude-cli");
252248
}
249+
const detail = describeCliDetail(credentials, "run `claude auth login`");
250+
// Only the live init record can prove capability support. Keep backports and
251+
// wrappers selectable here even when their version predates the known release.
253252
cliCandidates.push({
254253
kind: "claude-cli",
255254
modelRef: CLAUDE_CLI_DEFAULT_MODEL_REF,
256255
label: "Claude Code",
257-
detail: describeCliDetail(credentials, "run `claude auth login`"),
258-
...(credentials === undefined ? {} : { credentials }),
259-
...(versionSupport.status === "unsupported" && liveSessionRequirement
260-
? {
261-
unavailableReason: formatCliBackendUpdateGuidance({
256+
detail:
257+
versionGuidance.status === "below-known-floor" && liveSessionRequirement
258+
? `${detail}; ${formatCliBackendVersionAdvisory({
262259
label: "Claude Code",
263260
requirement: liveSessionRequirement,
264-
version: versionSupport.version,
265-
}),
266-
}
267-
: {}),
261+
version: versionGuidance.version,
262+
})}`
263+
: detail,
264+
...(credentials === undefined ? {} : { credentials }),
268265
});
269266
}
270267
if (codexProbe.found && !codexProbe.timedOut) {

‎src/system-agent/setup-inference-detect.ts‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,8 @@ export async function detectSetupInference(
137137
(candidate) => candidate.kind === "existing-model",
138138
)?.modelRef;
139139
const configuredCandidateKind = resolveConfiguredCandidateKind(cfg, configuredModel);
140-
const unavailableDetected = detected.filter((candidate) => candidate.unavailableReason);
141140
const raw = detected.filter(
142141
(candidate) =>
143-
!candidate.unavailableReason &&
144142
candidate.kind !== "gemini-cli" &&
145143
!(
146144
candidate.kind === configuredCandidateKind &&
@@ -165,19 +163,6 @@ export async function detectSetupInference(
165163
const manualProviders = listSetupInferenceManualProviders(authChoices);
166164
const authOptions = listSetupInferenceAuthOptions(authChoices);
167165
const prepareOptions = listSetupInferencePrepareOptions(authChoices);
168-
unavailableCandidates.push(
169-
...unavailableDetected.map((candidate) =>
170-
Object.assign(
171-
{
172-
id: candidate.kind,
173-
label: candidate.label,
174-
detail: candidate.detail,
175-
reason: candidate.unavailableReason ?? "Unavailable",
176-
},
177-
resolveCandidatePresentation(candidate, authChoices),
178-
),
179-
),
180-
);
181166
unavailableCandidates.push(...deferredUnavailableCandidates);
182167
const candidates: SetupInferenceCandidate[] = raw.map((candidate) =>
183168
// Released macOS clients require this field. Keep it false so the wire

‎src/system-agent/setup-inference.test.ts‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,16 +1268,15 @@ describe("detectSetupInference", () => {
12681268
expect(probeLocalCommand).not.toHaveBeenCalledWith("agy");
12691269
});
12701270

1271-
it("reports incompatible detected CLI backends without offering them for activation", async () => {
1271+
it("keeps lower-version capability-compatible CLI wrappers available for activation", async () => {
12721272
vi.mocked(detectInferenceBackends).mockResolvedValueOnce([
12731273
{
12741274
kind: "claude-cli",
12751275
modelRef: "claude-cli/claude-opus-5",
12761276
label: "Claude Code",
1277-
detail: "logged in",
1277+
detail:
1278+
"logged in; Claude Code 2.1.206 is the first published build known to advertise msg_lifecycle_v1; found 2.1.205. OpenClaw verifies this capability at runtime.",
12781279
credentials: true,
1279-
unavailableReason:
1280-
"Claude Code 2.1.206 or newer is required; found 2.1.205. Run `claude update`, restart OpenClaw, and retry.",
12811280
},
12821281
]);
12831282

@@ -1286,17 +1285,19 @@ describe("detectSetupInference", () => {
12861285
probeLocalCommand: vi.fn(async (command) => ({ command, found: false })),
12871286
});
12881287

1289-
expect(detection.candidates).toEqual([]);
1290-
expect(detection.unavailableCandidates).toEqual([
1288+
expect(detection.candidates).toEqual([
12911289
{
1292-
id: "claude-cli",
12931290
brandId: "claude",
1291+
credentials: true,
1292+
detail:
1293+
"logged in; Claude Code 2.1.206 is the first published build known to advertise msg_lifecycle_v1; found 2.1.205. OpenClaw verifies this capability at runtime.",
1294+
kind: "claude-cli",
12941295
label: "Claude Code",
1295-
detail: "logged in",
1296-
reason:
1297-
"Claude Code 2.1.206 or newer is required; found 2.1.205. Run `claude update`, restart OpenClaw, and retry.",
1296+
modelRef: "claude-cli/claude-opus-5",
1297+
recommended: false,
12981298
},
12991299
]);
1300+
expect(detection.unavailableCandidates).toEqual([]);
13001301
});
13011302
});
13021303

0 commit comments

Comments
 (0)