@tscgoods/codex-effort-discovery 0.5.2 → 0.5.5
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/.codex-plugin/plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/lib.mjs +19 -1
package/package.json
CHANGED
package/scripts/lib.mjs
CHANGED
|
@@ -86,10 +86,22 @@ export function parseLevels(text) {
|
|
|
86
86
|
return null
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
/** 通用网关可能回显全枚举;只有互相印证的窄子集才算模型级证据 */
|
|
90
|
+
export function pickLevels(candidates) {
|
|
91
|
+
const specific = candidates.filter((levels) => levels.length > 0 && levels.length < 6)
|
|
92
|
+
if (specific.length === 0) return null
|
|
93
|
+
let result = specific[0]
|
|
94
|
+
for (const levels of specific.slice(1)) {
|
|
95
|
+
result = result.filter((level) => levels.includes(level))
|
|
96
|
+
}
|
|
97
|
+
return result.length > 0 ? result : null
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
export async function probeOpenAI({ baseURL, apiKey, model, headers = {}, timeoutMs = 20_000 }) {
|
|
90
101
|
const url = `${String(baseURL).replace(/\/+$/, "")}/chat/completions`
|
|
91
102
|
let last = { levels: null, source: "error", at: Date.now() }
|
|
92
103
|
let sawOk = false
|
|
104
|
+
const candidates = []
|
|
93
105
|
for (const sentinel of ["effort-discovery-probe", "ultra", "maximum", "bogus"]) {
|
|
94
106
|
let response
|
|
95
107
|
try {
|
|
@@ -116,10 +128,16 @@ export async function probeOpenAI({ baseURL, apiKey, model, headers = {}, timeou
|
|
|
116
128
|
const text = await response.text()
|
|
117
129
|
if (response.ok) { sawOk = true; continue }
|
|
118
130
|
const levels = parseLevels(text)
|
|
119
|
-
if (levels)
|
|
131
|
+
if (levels) {
|
|
132
|
+
candidates.push(levels)
|
|
133
|
+
continue
|
|
134
|
+
}
|
|
120
135
|
last = { levels: null, source: `http-${response.status}`, at: Date.now() }
|
|
121
136
|
if ([401, 403, 429].includes(response.status)) return last
|
|
122
137
|
}
|
|
138
|
+
const levels = pickLevels(candidates)
|
|
139
|
+
if (levels) return { levels, source: "validated", at: Date.now() }
|
|
140
|
+
if (candidates.length > 0) return { levels: null, source: "no-validation", at: Date.now() }
|
|
123
141
|
return sawOk ? { levels: null, source: "no-validation", at: Date.now() } : last
|
|
124
142
|
}
|
|
125
143
|
|