惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
IT之家
IT之家
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42
爱范儿
爱范儿
博客园 - 聂微东
F
Fortinet All Blogs
V
Visual Studio Blog
Blog — PlanetScale
Blog — PlanetScale
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
L
LangChain Blog
雷峰网
雷峰网
B
Blog RSS Feed
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
test(gateway): guard native protocol levels · openclaw/op...
steipete · 2026-05-11 · via Recent Commits to openclaw:main

@@ -0,0 +1,136 @@

1+

import fs from "node:fs/promises";

2+

import path from "node:path";

3+

import { describe, it } from "vitest";

4+

import { MIN_CLIENT_PROTOCOL_VERSION, PROTOCOL_VERSION } from "./version.js";

5+6+

type ProtocolLevels = {

7+

min: number;

8+

max: number;

9+

};

10+11+

const expectedLevels: ProtocolLevels = {

12+

min: MIN_CLIENT_PROTOCOL_VERSION,

13+

max: PROTOCOL_VERSION,

14+

};

15+16+

async function readRepoFile(relativePath: string): Promise<string> {

17+

return fs.readFile(path.join(process.cwd(), relativePath), "utf8");

18+

}

19+20+

function extractInteger(

21+

content: string,

22+

pattern: RegExp,

23+

relativePath: string,

24+

label: string,

25+

): number {

26+

const match = pattern.exec(content);

27+

if (!match) {

28+

throw new Error(

29+

`${relativePath}: missing ${label}; keep native Gateway protocol levels in sync with src/gateway/protocol/version.ts.`,

30+

);

31+

}

32+

return Number.parseInt(match[1], 10);

33+

}

34+35+

function assertLevelsMatch(relativePath: string, actual: ProtocolLevels): void {

36+

if (actual.min === expectedLevels.min && actual.max === expectedLevels.max) {

37+

return;

38+

}

39+

throw new Error(

40+

`${relativePath}: Gateway protocol level mismatch: expected min=${expectedLevels.min} max=${expectedLevels.max} from src/gateway/protocol/version.ts, got min=${actual.min} max=${actual.max}. Update the native constants/generated artifacts before shipping.`,

41+

);

42+

}

43+44+

function assertPattern(

45+

content: string,

46+

relativePath: string,

47+

pattern: RegExp,

48+

message: string,

49+

): void {

50+

if (pattern.test(content)) {

51+

return;

52+

}

53+

throw new Error(`${relativePath}: ${message}`);

54+

}

55+56+

describe("native Gateway protocol levels", () => {

57+

it("match the TypeScript source of truth", async () => {

58+

if (MIN_CLIENT_PROTOCOL_VERSION > PROTOCOL_VERSION) {

59+

throw new Error(

60+

`src/gateway/protocol/version.ts: MIN_CLIENT_PROTOCOL_VERSION (${MIN_CLIENT_PROTOCOL_VERSION}) must not exceed PROTOCOL_VERSION (${PROTOCOL_VERSION}).`,

61+

);

62+

}

63+64+

const swiftGeneratedPath =

65+

"apps/shared/OpenClawKit/Sources/OpenClawProtocol/GatewayModels.swift";

66+

const swiftGenerated = await readRepoFile(swiftGeneratedPath);

67+

assertLevelsMatch(swiftGeneratedPath, {

68+

min: extractInteger(

69+

swiftGenerated,

70+

/public let GATEWAY_MIN_PROTOCOL_VERSION = (\d+)/,

71+

swiftGeneratedPath,

72+

"GATEWAY_MIN_PROTOCOL_VERSION",

73+

),

74+

max: extractInteger(

75+

swiftGenerated,

76+

/public let GATEWAY_PROTOCOL_VERSION = (\d+)/,

77+

swiftGeneratedPath,

78+

"GATEWAY_PROTOCOL_VERSION",

79+

),

80+

});

81+82+

const androidPath = "apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewayProtocol.kt";

83+

const android = await readRepoFile(androidPath);

84+

assertLevelsMatch(androidPath, {

85+

min: extractInteger(

86+

android,

87+

/const val GATEWAY_MIN_PROTOCOL_VERSION = (\d+)/,

88+

androidPath,

89+

"GATEWAY_MIN_PROTOCOL_VERSION",

90+

),

91+

max: extractInteger(

92+

android,

93+

/const val GATEWAY_PROTOCOL_VERSION = (\d+)/,

94+

androidPath,

95+

"GATEWAY_PROTOCOL_VERSION",

96+

),

97+

});

98+

});

99+100+

it("uses the min constant for native connect compatibility ranges", async () => {

101+

const swiftConnectFiles = [

102+

"apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayChannel.swift",

103+

"apps/macos/Sources/OpenClawMacCLI/WizardCommand.swift",

104+

];

105+

for (const relativePath of swiftConnectFiles) {

106+

const content = await readRepoFile(relativePath);

107+

assertPattern(

108+

content,

109+

relativePath,

110+

/"minProtocol": ProtoAnyCodable\(GATEWAY_MIN_PROTOCOL_VERSION\)/,

111+

"connect params must advertise GATEWAY_MIN_PROTOCOL_VERSION as minProtocol.",

112+

);

113+

assertPattern(

114+

content,

115+

relativePath,

116+

/"maxProtocol": ProtoAnyCodable\(GATEWAY_PROTOCOL_VERSION\)/,

117+

"connect params must advertise GATEWAY_PROTOCOL_VERSION as maxProtocol.",

118+

);

119+

}

120+121+

const androidPath = "apps/android/app/src/main/java/ai/openclaw/app/gateway/GatewaySession.kt";

122+

const android = await readRepoFile(androidPath);

123+

assertPattern(

124+

android,

125+

androidPath,

126+

/put\("minProtocol", JsonPrimitive\(GATEWAY_MIN_PROTOCOL_VERSION\)\)/,

127+

"connect params must advertise GATEWAY_MIN_PROTOCOL_VERSION as minProtocol.",

128+

);

129+

assertPattern(

130+

android,

131+

androidPath,

132+

/put\("maxProtocol", JsonPrimitive\(GATEWAY_PROTOCOL_VERSION\)\)/,

133+

"connect params must advertise GATEWAY_PROTOCOL_VERSION as maxProtocol.",

134+

);

135+

});

136+

});