@tscgoods/effort-discovery-core 0.5.2 → 0.5.6
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 +39 -39
- package/src/index.js +22 -1
package/package.json
CHANGED
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tscgoods/effort-discovery-core",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "Core probe/catalog/cache logic shared by every effort-discovery host plugin.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"exports": {
|
|
8
|
-
".": {
|
|
9
|
-
"types": "./src/index.d.ts",
|
|
10
|
-
"default": "./src/index.js"
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
"bin": {
|
|
14
|
-
"effort-discovery": "src/cli.js"
|
|
15
|
-
},
|
|
16
|
-
"files": [
|
|
17
|
-
"src",
|
|
18
|
-
"README.md"
|
|
19
|
-
],
|
|
20
|
-
"engines": {
|
|
21
|
-
"node": ">=20"
|
|
22
|
-
},
|
|
23
|
-
"keywords": [
|
|
24
|
-
"reasoning-effort",
|
|
25
|
-
"opencode",
|
|
26
|
-
"claude-code",
|
|
27
|
-
"codex",
|
|
28
|
-
"deepseek-harness",
|
|
29
|
-
"antigravity"
|
|
30
|
-
],
|
|
31
|
-
"repository": {
|
|
32
|
-
"type": "git",
|
|
33
|
-
"url": "git+https://github.com/lxgy1024/effort-discovery.git",
|
|
34
|
-
"directory": "packages/core"
|
|
35
|
-
},
|
|
36
|
-
"publishConfig": {
|
|
37
|
-
"access": "public"
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@tscgoods/effort-discovery-core",
|
|
3
|
+
"version": "0.5.6",
|
|
4
|
+
"description": "Core probe/catalog/cache logic shared by every effort-discovery host plugin.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./src/index.d.ts",
|
|
10
|
+
"default": "./src/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"effort-discovery": "src/cli.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=20"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"reasoning-effort",
|
|
25
|
+
"opencode",
|
|
26
|
+
"claude-code",
|
|
27
|
+
"codex",
|
|
28
|
+
"deepseek-harness",
|
|
29
|
+
"antigravity"
|
|
30
|
+
],
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/lxgy1024/effort-discovery.git",
|
|
34
|
+
"directory": "packages/core"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/index.js
CHANGED
|
@@ -84,6 +84,20 @@ export function parseLevels(text) {
|
|
|
84
84
|
return null
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* 通用网关有时把所有枚举值都回显出来(serde 的 expected one of),
|
|
89
|
+
* 只有互相印证的窄子集才能作为模型级证据。
|
|
90
|
+
*/
|
|
91
|
+
export function pickLevels(candidates) {
|
|
92
|
+
const specific = candidates.filter((levels) => levels.length > 0 && levels.length < 6)
|
|
93
|
+
if (specific.length === 0) return null
|
|
94
|
+
let result = specific[0]
|
|
95
|
+
for (const levels of specific.slice(1)) {
|
|
96
|
+
result = result.filter((level) => levels.includes(level))
|
|
97
|
+
}
|
|
98
|
+
return result.length > 0 ? result : null
|
|
99
|
+
}
|
|
100
|
+
|
|
87
101
|
/**
|
|
88
102
|
* 用非法值探一次,读回上游自己声明的合法档位。
|
|
89
103
|
* 个别网关只对特定非法值透传上游报错,因此按 sentinels 依次尝试。
|
|
@@ -98,6 +112,7 @@ export async function probeEffort(input) {
|
|
|
98
112
|
|
|
99
113
|
let last = { levels: null, source: "error", at: Date.now() }
|
|
100
114
|
let sawOk = false
|
|
115
|
+
const candidates = []
|
|
101
116
|
|
|
102
117
|
for (const sentinel of sentinels) {
|
|
103
118
|
let response
|
|
@@ -124,13 +139,19 @@ export async function probeEffort(input) {
|
|
|
124
139
|
if (response.ok) { sawOk = true; continue }
|
|
125
140
|
|
|
126
141
|
const levels = parseLevels(text)
|
|
127
|
-
if (levels)
|
|
142
|
+
if (levels) {
|
|
143
|
+
candidates.push(levels)
|
|
144
|
+
continue
|
|
145
|
+
}
|
|
128
146
|
|
|
129
147
|
last = { levels: null, source: `http-${response.status}`, at: Date.now() }
|
|
130
148
|
// 限流/鉴权错误换 sentinel 也没用,直接返回
|
|
131
149
|
if (response.status === 401 || response.status === 403 || response.status === 429) return last
|
|
132
150
|
}
|
|
133
151
|
|
|
152
|
+
const levels = pickLevels(candidates)
|
|
153
|
+
if (levels) return { levels, source: "validated", at: Date.now() }
|
|
154
|
+
if (candidates.length > 0) return { levels: null, source: "no-validation", at: Date.now() }
|
|
134
155
|
return sawOk ? { levels: null, source: "no-validation", at: Date.now() } : last
|
|
135
156
|
}
|
|
136
157
|
|