Skip to content

Commit 7e152f4

Browse files
committed
style: format code with prettier
1 parent dfc7dee commit 7e152f4

File tree

7 files changed

+41
-12
lines changed

7 files changed

+41
-12
lines changed

.github/workflows/test-windows.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Windows Compatibility Check
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88
workflow_dispatch:
99

1010
jobs:
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup Node.js
2020
uses: actions/setup-node@v4
2121
with:
22-
node-version: '22'
22+
node-version: "22"
2323

2424
- name: Install OpenClaw
2525
run: npm install -g openclaw@latest

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Done! Smart routing (`blockrun/auto`) is now your default model.
6060
**📖 Full Windows Guide:** [docs/windows-installation.md](docs/windows-installation.md)
6161

6262
**Quick Summary:**
63+
6364
- ✅ ClawRouter code is Windows-compatible
6465
- ❌ OpenClaw CLI has a `spawn EINVAL` bug on Windows
6566
- ✅ Works perfectly on **Linux** and **macOS**

docs/windows-installation.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This is an **OpenClaw framework bug**, not a ClawRouter issue. The OpenClaw CLI
1818
## Recommended Approach
1919

2020
**Wait for OpenClaw to fix Windows support.** ClawRouter works perfectly on:
21+
2122
-**Linux** (Ubuntu, Debian, RHEL, Alpine, etc.)
2223
-**macOS** (Intel and Apple Silicon)
2324

@@ -93,13 +94,15 @@ openclaw gateway restart
9394
The wallet address will be displayed in the gateway logs or use the `/wallet` command in OpenClaw.
9495

9596
Fund it with $5 USDC on Base network:
97+
9698
- Coinbase: Buy USDC, send to Base
9799
- Bridge: Move USDC from any chain to Base
98100
- CEX: Withdraw USDC to Base network
99101

100102
## Testing Infrastructure
101103

102104
ClawRouter has full Windows testing infrastructure ready:
105+
103106
- **GitHub Actions workflow**: [.github/workflows/test-windows.yml](../.github/workflows/test-windows.yml)
104107
- **Windows test script**: [test/test-model-selection.ps1](../test/test-model-selection.ps1)
105108
- **Docker support**: [test/Dockerfile.windows](../test/Dockerfile.windows)

src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,9 @@ function injectModelsConfig(logger: { info: (msg: string) => void }): void {
103103
mkdirSync(configDir, { recursive: true });
104104
logger.info("Created OpenClaw config directory");
105105
} catch (err) {
106-
logger.info(`Failed to create config dir: ${err instanceof Error ? err.message : String(err)}`);
106+
logger.info(
107+
`Failed to create config dir: ${err instanceof Error ? err.message : String(err)}`,
108+
);
107109
return;
108110
}
109111
}
@@ -119,7 +121,9 @@ function injectModelsConfig(logger: { info: (msg: string) => void }): void {
119121
needsWrite = true;
120122
}
121123
} catch (err) {
122-
logger.info(`Failed to parse config (will recreate): ${err instanceof Error ? err.message : String(err)}`);
124+
logger.info(
125+
`Failed to parse config (will recreate): ${err instanceof Error ? err.message : String(err)}`,
126+
);
123127
config = {};
124128
needsWrite = true;
125129
}
@@ -178,7 +182,11 @@ function injectModelsConfig(logger: { info: (msg: string) => void }): void {
178182
}
179183
// Always refresh models list (ensures new aliases are available)
180184
const currentModels = blockrun.models as unknown[];
181-
if (!currentModels || !Array.isArray(currentModels) || currentModels.length !== OPENCLAW_MODELS.length) {
185+
if (
186+
!currentModels ||
187+
!Array.isArray(currentModels) ||
188+
currentModels.length !== OPENCLAW_MODELS.length
189+
) {
182190
blockrun.models = OPENCLAW_MODELS;
183191
fixed = true;
184192
}

src/proxy.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ function transformPaymentError(errorBody: string): string {
101101
const currentUSD = (currentMicros / 1_000_000).toFixed(6);
102102
const requiredUSD = (requiredMicros / 1_000_000).toFixed(6);
103103
const wallet = innerJson.payer || "unknown";
104-
const shortWallet = wallet.length > 12 ? `${wallet.slice(0, 6)}...${wallet.slice(-4)}` : wallet;
104+
const shortWallet =
105+
wallet.length > 12 ? `${wallet.slice(0, 6)}...${wallet.slice(-4)}` : wallet;
105106

106107
return JSON.stringify({
107108
error: {
@@ -1094,7 +1095,11 @@ async function tryModelRequest(
10941095

10951096
// Normalize messages for thinking-enabled requests (add reasoning_content to tool calls)
10961097
// Check request flags AND target model - reasoning models have thinking enabled server-side
1097-
const hasThinkingEnabled = !!(parsed.thinking || parsed.extended_thinking || isReasoningModel(modelId));
1098+
const hasThinkingEnabled = !!(
1099+
parsed.thinking ||
1100+
parsed.extended_thinking ||
1101+
isReasoningModel(modelId)
1102+
);
10981103
if (hasThinkingEnabled && Array.isArray(parsed.messages)) {
10991104
parsed.messages = normalizeMessagesForThinking(parsed.messages as ExtendedChatMessage[]);
11001105
}
@@ -1592,7 +1597,9 @@ async function proxyRequest(
15921597
const parsed = JSON.parse(transformedErr);
15931598
errPayload = JSON.stringify(parsed);
15941599
} catch {
1595-
errPayload = JSON.stringify({ error: { message: rawErrBody, type: "provider_error", status: errStatus } });
1600+
errPayload = JSON.stringify({
1601+
error: { message: rawErrBody, type: "provider_error", status: errStatus },
1602+
});
15961603
}
15971604
const errEvent = `data: ${errPayload}\n\n`;
15981605
safeWrite(res, errEvent);

src/router/config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,11 @@ export const DEFAULT_ROUTING_CONFIG: RoutingConfig = {
660660
agenticTiers: {
661661
SIMPLE: {
662662
primary: "moonshot/kimi-k2.5", // Cheaper than Haiku ($0.5/$2.4 vs $1/$5), larger context
663-
fallback: ["anthropic/claude-haiku-4.5", "xai/grok-4-fast-non-reasoning", "openai/gpt-4o-mini"],
663+
fallback: [
664+
"anthropic/claude-haiku-4.5",
665+
"xai/grok-4-fast-non-reasoning",
666+
"openai/gpt-4o-mini",
667+
],
664668
},
665669
MEDIUM: {
666670
primary: "xai/grok-code-fast-1", // Code specialist for agentic coding

test/fallback.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,15 @@ async function runTests() {
258258

259259
// Should succeed via fallback to free model
260260
assert(res.ok, `Explicit model with fallback succeeds: ${res.status}`);
261-
assert(modelCalls.length === 2, `2 models called (primary + free fallback): ${modelCalls.join(", ")}`);
261+
assert(
262+
modelCalls.length === 2,
263+
`2 models called (primary + free fallback): ${modelCalls.join(", ")}`,
264+
);
262265
assert(modelCalls[0] === "openai/gpt-4o", `First tried explicit model: ${modelCalls[0]}`);
263-
assert(modelCalls[1] === "nvidia/gpt-oss-120b", `Then fell back to free model: ${modelCalls[1]}`);
266+
assert(
267+
modelCalls[1] === "nvidia/gpt-oss-120b",
268+
`Then fell back to free model: ${modelCalls[1]}`,
269+
);
264270
}
265271

266272
// Cleanup

0 commit comments

Comments
 (0)