magpie-junie-auth 0.2.4 → 0.2.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/index.mjs CHANGED
@@ -151,6 +151,17 @@ export async function JuniePlugin(input, options = {}) {
151
151
  }
152
152
  }
153
153
  // 直连模式:用逆向的 Responses 协议(免费额度可用,无需 CLI 本体)。
154
+ // auth 可能为空(未登录/账号状态异常/轮换间隙),此时给出明确错误,
155
+ // 而不是让 `auth.access` 抛 TypeError 使整个 loader 崩掉。
156
+ if (!auth || (!auth.access && !auth.key)) {
157
+ return {
158
+ baseURL: "https://ingrazzio-cloud-prod.labs.jb.gg/v1",
159
+ apiKey: "",
160
+ fetch: async () => new Response(JSON.stringify({
161
+ error: { message: "Junie 尚未登录,请在 magpie 里添加/切换账号(magpie accounts junie)", type: "auth_error" },
162
+ }), { status: 401, headers: { "Content-Type": "application/json" } }),
163
+ }
164
+ }
154
165
  return {
155
166
  baseURL: "https://ingrazzio-cloud-prod.labs.jb.gg/v1",
156
167
  apiKey: auth.access ?? auth.key,
@@ -170,12 +181,15 @@ export async function JuniePlugin(input, options = {}) {
170
181
  provider: {
171
182
  id: PROVIDER,
172
183
  async models(providerModels, { auth } = {}) {
184
+ // gpt-6-luna 真机验证支持图片输入(data URI / URL),
185
+ // 声明 modalities 后 magpie 才会把它列进「识图模型」。
186
+ const modalities = { input: ["text", "image"], output: ["text"] }
173
187
  if (pluginOptions.bridgeUrl) {
174
- return { "junie-lite": { name: "Junie Lite (CLI)", limit: { context: 262144, output: 16384 }, tool_call: true } }
188
+ return { "junie-lite": { name: "Junie Lite (CLI)", limit: { context: 262144, output: 16384 }, tool_call: true, modalities } }
175
189
  }
176
190
  // 直连/桥接都只提供 junie-lite(底层 gpt-6-luna),与其他旧模型无关。
177
191
  return {
178
- "junie-lite": { name: "Junie Lite (GPT-6 Luna)", limit: { context: 262144, output: 16384 }, tool_call: true },
192
+ "junie-lite": { name: "Junie Lite (GPT-6 Luna)", limit: { context: 262144, output: 16384 }, tool_call: true, modalities },
179
193
  }
180
194
  },
181
195
  },
package/lib/auth.mjs CHANGED
@@ -50,8 +50,10 @@ export async function refreshAccessToken(auth) {
50
50
  try {
51
51
  const t = await exchangeToken({ grant_type: "refresh_token", refresh_token: auth.refresh })
52
52
  // 上游 Bearer 用 id_token;access_token 只用于 userinfo
53
+ const access = t.id_token ?? t.access_token ?? auth.access
53
54
  return {
54
- access: t.id_token ?? t.access_token ?? auth.access,
55
+ access,
56
+ key: access, // magpie 续期后仍可能按 key 取 apiKey,保持同步
55
57
  accessToken: t.access_token ?? auth.accessToken,
56
58
  idToken: t.id_token ?? auth.idToken,
57
59
  refresh: t.refresh_token ?? auth.refresh,
package/lib/direct.mjs CHANGED
@@ -406,6 +406,11 @@ export function makeDirectFetch(auth, options = {}) {
406
406
  const token = auth?.access ?? auth?.key
407
407
 
408
408
  return async function directFetch(input, init = {}) {
409
+ if (!token) {
410
+ return new Response(JSON.stringify({
411
+ error: { message: "Junie 未登录:缺少 access token", type: "auth_error" },
412
+ }), { status: 401, headers: { "Content-Type": "application/json" } })
413
+ }
409
414
  const url = new URL(String(input))
410
415
  url.pathname = "/v1/responses"
411
416
  url.search = ""
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magpie-junie-auth",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "magpie provider plugin: JetBrains Junie free tier (gpt-6-luna) via direct Responses API or CLI bridge; multi-account with browser PKCE / CLI login reuse",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",