magpie-marvis 0.2.2 → 0.2.3
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/CHANGELOG.md +6 -1
- package/package.json +1 -1
- package/src/marvis/login.mjs +10 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
> 每个版本一节,**一条一行**,说用户能感知的变化。
|
|
4
4
|
> 格式与规矩见 [UPDATING.md](./UPDATING.md)。
|
|
5
5
|
|
|
6
|
-
## 0.2.
|
|
6
|
+
## 0.2.3 — 2026-11-06
|
|
7
|
+
|
|
8
|
+
**修复**
|
|
9
|
+
|
|
10
|
+
- **响应解析对格式不敏感**:浏览器渲染 `application/json` 会加缩进/包装,
|
|
11
|
+
原来只看 `startsWith("{")` 会漏判。改成「抠第一个 `{` 到最后一个 `}`」再解析
|
|
7
12
|
|
|
8
13
|
**修复**
|
|
9
14
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magpie-marvis",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "magpie / OpenCode provider plugin for Tencent Marvis: its DeepSeek V4 Pro, Kimi K2.5, Claude Opus/Sonnet 4.6, GPT-5.4 and Hunyuan models through the Marvis model gateway — no API key to paste, sign in with QQ or WeChat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.mjs",
|
package/src/marvis/login.mjs
CHANGED
|
@@ -176,12 +176,19 @@ export async function exchangeCode(code, loginType, _guid, state) {
|
|
|
176
176
|
export async function parseCallback(callbackUrl, body, opts = {}) {
|
|
177
177
|
const text = String(body ?? "").trim()
|
|
178
178
|
|
|
179
|
-
//
|
|
180
|
-
|
|
179
|
+
// 主路径:正文就是 JSON。
|
|
180
|
+
// ⚠ 不能只看 `startsWith("{")` —— 浏览器渲染 `application/json` 时会加缩进/包装,
|
|
181
|
+
// 也可能前后带空白。改成「抠第一个 `{` 到最后一个 `}`」再解析。
|
|
182
|
+
const jsonText = (() => {
|
|
183
|
+
const a = text.indexOf("{")
|
|
184
|
+
const b = text.lastIndexOf("}")
|
|
185
|
+
return a >= 0 && b > a ? text.slice(a, b + 1) : ""
|
|
186
|
+
})()
|
|
187
|
+
if (jsonText) {
|
|
181
188
|
/** @type {any} */
|
|
182
189
|
let body0
|
|
183
190
|
try {
|
|
184
|
-
body0 = JSON.parse(
|
|
191
|
+
body0 = JSON.parse(jsonText)
|
|
185
192
|
} catch {
|
|
186
193
|
body0 = null
|
|
187
194
|
}
|