@sleep2agi/commhub-server 0.9.0-preview.52 → 0.9.0-preview.53
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sleep2agi/commhub-server",
|
|
3
|
-
"version": "0.9.0-preview.
|
|
3
|
+
"version": "0.9.0-preview.53",
|
|
4
4
|
"description": "CommHub Server — AI Agent communication hub with MCP protocol, multi-network isolation, user auth, and MCP tools (17 collaboration-core + node/provider ops tools; authoritative list: docs-site/docs/api/mcp-tools.md).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -35,6 +35,15 @@ describe("validateRuntime / validateModel (§4.2.2)", () => {
|
|
|
35
35
|
expect(() => validateModel("gpt-4o")).not.toThrow();
|
|
36
36
|
expect(() => validateModel("bad model")).toThrow(ValidationError);
|
|
37
37
|
expect(() => validateModel("x;rm")).toThrow(ValidationError);
|
|
38
|
+
// provider/model(OpenCode 共存;桌面向导 0.2.61 起发这种形状,Vincent 2026-09-08 撞到 model_invalid)
|
|
39
|
+
expect(() => validateModel("opencode/mimo-v2.5-free")).not.toThrow();
|
|
40
|
+
expect(() => validateModel("anthropic/claude-sonnet-4")).not.toThrow();
|
|
41
|
+
expect(() => validateModel("a/b/c")).toThrow(ValidationError); // 只许一个斜杠
|
|
42
|
+
expect(() => validateModel("/model")).toThrow(ValidationError); // 不能以斜杠开头
|
|
43
|
+
expect(() => validateModel("provider/")).toThrow(ValidationError); // 不能以斜杠结尾
|
|
44
|
+
expect(() => validateModel("../x")).toThrow(ValidationError); // 纯点段(路径穿越形状)
|
|
45
|
+
expect(() => validateModel("x/.")).toThrow(ValidationError);
|
|
46
|
+
expect(() => validateModel("open code/m")).toThrow(ValidationError);
|
|
38
47
|
expect(() => validateModel("")).toThrow(ValidationError);
|
|
39
48
|
});
|
|
40
49
|
});
|
|
@@ -58,7 +58,11 @@ const ENV_KEY_RE = /^[A-Z][A-Z0-9_]{0,63}$/;
|
|
|
58
58
|
|
|
59
59
|
// §4.2.2 name + model.
|
|
60
60
|
const NAME_RE = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
61
|
-
|
|
61
|
+
// OpenCode 共存的模型带 provider 前缀(`opencode/mimo-v2.5-free`,agent-node parseModelRef 按第一个 `/` 切),
|
|
62
|
+
// 桌面向导 0.2.61 起就发这种形状 —— 允许**恰好一个**斜杠分隔的两段;每段仍是原字符集,且不能是纯点(`..`/`.`)。
|
|
63
|
+
const MODEL_SEGMENT = "[a-zA-Z0-9._:\\-]+";
|
|
64
|
+
const MODEL_RE = new RegExp(`^${MODEL_SEGMENT}(?:/${MODEL_SEGMENT})?$`);
|
|
65
|
+
const MODEL_DOT_ONLY_SEGMENT = /(^|\/)\.+(\/|$)/;
|
|
62
66
|
|
|
63
67
|
export function validateName(s: unknown): asserts s is string {
|
|
64
68
|
if (typeof s !== "string" || !NAME_RE.test(s)) {
|
|
@@ -90,7 +94,7 @@ export function validateRuntime(s: unknown): asserts s is Runtime {
|
|
|
90
94
|
|
|
91
95
|
export function validateModel(s: unknown): asserts s is string | undefined | null {
|
|
92
96
|
if (s === undefined || s === null) return;
|
|
93
|
-
if (typeof s !== "string" || s.length === 0 || s.length > 100 || !MODEL_RE.test(s)) {
|
|
97
|
+
if (typeof s !== "string" || s.length === 0 || s.length > 100 || !MODEL_RE.test(s) || MODEL_DOT_ONLY_SEGMENT.test(s)) {
|
|
94
98
|
throw new ValidationError("model_invalid", { value: typeof s === "string" ? s.slice(0, 80) : typeof s });
|
|
95
99
|
}
|
|
96
100
|
}
|