diff --git a/packages/cline/index.mjs b/packages/cline/index.mjs index b66a7ad..3dfa1d4 100644 --- a/packages/cline/index.mjs +++ b/packages/cline/index.mjs @@ -1071,6 +1071,7 @@ export const ClinePlugin = async ({ client } = {}, options = {}) => { // saves what this gives (it is merged over the sign-in): only what // changed comes back, and remember isn't called here. refreshLead: RENEW_LEAD, + rotating: true, refresh: (auth) => locked(async () => { const a = authOf(auth) diff --git a/packages/cline/package.json b/packages/cline/package.json index 4b1a917..774df45 100644 --- a/packages/cline/package.json +++ b/packages/cline/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-cline-auth", - "version": "0.1.14", + "version": "0.1.15", "description": "Cline (cline.bot) on your own account — usage billing, ClinePass and the free models — in OpenCode and magpie", "type": "module", "main": "./opencode.mjs", diff --git a/packages/cline/refresh.test.mjs b/packages/cline/refresh.test.mjs index 78064a6..690c4ff 100644 --- a/packages/cline/refresh.test.mjs +++ b/packages/cline/refresh.test.mjs @@ -56,6 +56,7 @@ const due = () => ({ type: "oauth", access: "jwt1", refresh: "r1", expires: Date test("the lead is no shorter than the check before each request", async () => { const { hooks } = await plugin(due()) expect(hooks.auth.refreshLead).toBeGreaterThanOrEqual(5 * 60 * 1000) + expect(hooks.auth.rotating).toBe(true) expect(typeof hooks.auth.refresh).toBe("function") }) diff --git a/packages/codearts/index.mjs b/packages/codearts/index.mjs index 88eb856..db23baf 100644 --- a/packages/codearts/index.mjs +++ b/packages/codearts/index.mjs @@ -3249,6 +3249,7 @@ export const CodeArtsAuthPlugin = async ({ client } = {}, options = {}) => { auth: { provider: PROVIDER, refreshLead: REFRESH_LEAD_MS, + rotating: true, // The gateway's own cap: more in flight only queues in the plugin. maxConcurrency: maxInflight, @@ -4639,6 +4640,7 @@ export const OfficeAceAuthPlugin = async ({ client } = {}, options = {}) => { icon: OFFICEACE_ICON, maxConcurrency: 3, refreshLead: OA_REFRESH_LEAD_MS, + rotating: true, methods: [ { diff --git a/packages/codearts/index.test.mjs b/packages/codearts/index.test.mjs index e57a8ee..f0e487d 100644 --- a/packages/codearts/index.test.mjs +++ b/packages/codearts/index.test.mjs @@ -3824,11 +3824,13 @@ test("a renewal never invalidates the other card's record", async () => { oa.refreshLineages.clear() const ca2 = await CodeArtsAuthPlugin({ client }, { fetch: ca.fetcher, ledgerPath }) + assert.equal(ca2.auth.rotating, true) const renewed = await ca2.auth.refresh(store.get(codeartsKey)) assert.equal(accessOf(renewed), "AK-1CA") // ... and the other card's record still renews with its own token const of = await OfficeAceAuthPlugin({ client }, { fetch: oaSts.fetcher, ledgerPath }) + assert.equal(of.auth.rotating, true) const again = await of.auth.refresh(store.get(officeaceKey)) assert.equal(accessOf(again), "AK-1OA") }) diff --git a/packages/codearts/package.json b/packages/codearts/package.json index 1e2c94e..33022c9 100644 --- a/packages/codearts/package.json +++ b/packages/codearts/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-codearts-auth", - "version": "0.3.12", + "version": "0.3.13", "description": "Huawei Cloud in OpenCode and magpie: CodeArts (码道) and OfficeAce (AgentArts), each from its own Huawei Cloud OAuth sign-in — models, credit rates, credit usage and the daily check-in (unofficial)", "type": "module", "main": "./opencode.mjs", diff --git a/packages/factory/index.mjs b/packages/factory/index.mjs index 5edf328..ad1bf10 100644 --- a/packages/factory/index.mjs +++ b/packages/factory/index.mjs @@ -2080,6 +2080,7 @@ export const FactoryAuthPlugin = async ({ client, magpie }) => { // spend one refresh token; that check stays for OpenCode, which // doesn't call this refreshLead: MAGPIE_LEAD, + rotating: true, async refresh(auth) { if (auth?.type !== "oauth" || !auth.access || !auth.refresh) return undefined return locked(async () => { diff --git a/packages/factory/package.json b/packages/factory/package.json index bb717d9..7445268 100644 --- a/packages/factory/package.json +++ b/packages/factory/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-factory-auth", - "version": "0.1.45", + "version": "0.1.46", "description": "Sign in to a Factory (Droid) subscription from OpenCode or magpie", "type": "module", "main": "./opencode.mjs", diff --git a/packages/factory/refresh.test.mjs b/packages/factory/refresh.test.mjs index e6c9323..0dd6e62 100644 --- a/packages/factory/refresh.test.mjs +++ b/packages/factory/refresh.test.mjs @@ -53,6 +53,7 @@ test("renews a sign-in near its end, giving magpie the new tokens to save", asyn const seen = serve() const { hooks, sets } = await plugin(due()) expect(hooks.auth.refreshLead).toBe(3 * 60 * 1000) + expect(hooks.auth.rotating).toBe(true) const got = await hooks.auth.refresh(due(), "factory") expect(got).toMatchObject({ access: NEW, refresh: "r-new", expires: Math.floor(later / 1000) * 1000, activeOrganizationId: "fac_A" }) expect(got.type).toBeUndefined() diff --git a/packages/minimax/index.mjs b/packages/minimax/index.mjs index 1675194..b39e5c3 100644 --- a/packages/minimax/index.mjs +++ b/packages/minimax/index.mjs @@ -1070,6 +1070,7 @@ function makePlugin(site) { // check before each request below stays for OpenCode, which // doesn't call this refreshLead: LEAD_MS, + rotating: true, async refresh(auth) { if (auth?.type !== "oauth" || !auth.access || !auth.refresh) return undefined const a = latest(site, auth) diff --git a/packages/minimax/package.json b/packages/minimax/package.json index b265078..498339f 100644 --- a/packages/minimax/package.json +++ b/packages/minimax/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-minimax-auth", - "version": "0.2.8", + "version": "0.2.9", "description": "OpenCode provider plugins for MiniMax Code accounts: their credits and M Plan, China (minimax-code) and international (minimax-code-global), with MiniMax Code's own device sign-in", "type": "module", "main": "./opencode.mjs", diff --git a/packages/minimax/refresh.test.mjs b/packages/minimax/refresh.test.mjs index cb149ed..299e7c1 100644 --- a/packages/minimax/refresh.test.mjs +++ b/packages/minimax/refresh.test.mjs @@ -139,6 +139,7 @@ test("magpie renews the sign-in ahead of its end through auth.refresh, once with const s = store({ access: "old", refresh: "r1", expires: Date.now() - 1 }) const hooks = await MiniMaxCodeAuthPlugin({ client: s.client }) expect(hooks.auth.refreshLead).toBe(10 * 60 * 1000) + expect(hooks.auth.rotating).toBe(true) // magpie's renewal and a request's own check, at once const [got, res] = await Promise.all([hooks.auth.refresh({ ...s.auth }, "minimax-code"), chat(await hooks.auth.loader(s.getAuth))]) expect(got).toMatchObject({ access: "new", refresh: "r2" }) diff --git a/packages/nous/index.mjs b/packages/nous/index.mjs index 1c4e6f0..e61657f 100644 --- a/packages/nous/index.mjs +++ b/packages/nous/index.mjs @@ -111,7 +111,7 @@ export async function NousPortalAuthPlugin({ client }) { }, }, auth: { - provider: ID, icon: "nousresearch", refreshLead: LEAD, + provider: ID, icon: "nousresearch", refreshLead: LEAD, rotating: true, refresh: auth.refresh, async loader(getAuth) { if ((await auth.read(getAuth))?.type !== "oauth") return {} diff --git a/packages/nous/index.test.mjs b/packages/nous/index.test.mjs index d87e3e9..ea08106 100644 --- a/packages/nous/index.test.mjs +++ b/packages/nous/index.test.mjs @@ -327,6 +327,7 @@ test("one entrypoint, distinct provider id, non-destructive config and standard assert.equal(config.provider[ID].name, "Custom label") assert.equal(config.provider[ID].models.custom.name, "Mine") assert.equal(hooks.auth.refreshLead, LEAD) + assert.equal(hooks.auth.rotating, true) assert.deepEqual(await hooks.auth.loader(async () => ({ type: "api", key: "unrelated" })), {}) assert.equal((await hooks.auth.loader(s.get)).apiKey, "nous-portal-oauth") }) diff --git a/packages/nous/package.json b/packages/nous/package.json index 51a4cf6..9755e2f 100644 --- a/packages/nous/package.json +++ b/packages/nous/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-nous-auth", - "version": "0.1.2", + "version": "0.1.3", "description": "Nous Portal OAuth with device sign-in and automatic token renewal in OpenCode and magpie", "type": "module", "main": "./opencode.mjs", diff --git a/packages/qoder/index.mjs b/packages/qoder/index.mjs index c0bce19..75046ef 100644 --- a/packages/qoder/index.mjs +++ b/packages/qoder/index.mjs @@ -3797,6 +3797,7 @@ const makePlugin = (site) => async ({ client }) => { // doesn't call this. The device token of a job-token account has no // end on record: usage rotates it once Qoder refuses it, as before. refreshLead: RENEW_LEAD, + rotating: true, async refresh(auth) { // a Lingma 1.0 account: the IDE's newer token, when it has one; // nothing when it hasn't yet (fresh says so once it is needed) diff --git a/packages/qoder/package.json b/packages/qoder/package.json index 1d9cbfb..8d1b559 100644 --- a/packages/qoder/package.json +++ b/packages/qoder/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-qoder-auth", - "version": "0.2.65", + "version": "0.2.66", "description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains", "type": "module", "main": "./opencode.mjs", diff --git a/packages/qoder/refresh.test.mjs b/packages/qoder/refresh.test.mjs index c696296..3c021bd 100644 --- a/packages/qoder/refresh.test.mjs +++ b/packages/qoder/refresh.test.mjs @@ -59,6 +59,7 @@ for (const site of SITES) { const calls = serve(site) const { hooks, sets } = await plugin(site, account()) expect(hooks.auth.refreshLead).toBe(10 * 60 * 1000) + expect(hooks.auth.rotating).toBe(true) const got = await hooks.auth.refresh(account(), { id: site.name }) expect(got).toMatchObject({ access: "jt-2", refresh: "jrt-2" }) // the renewal also names the account (the phone, not its uuid), so an diff --git a/packages/sensenova/index.mjs b/packages/sensenova/index.mjs index 3052b8d..eb734bd 100644 --- a/packages/sensenova/index.mjs +++ b/packages/sensenova/index.mjs @@ -328,6 +328,7 @@ export async function SenseNovaAuthPlugin({ client, magpie } = {}, options = {}) auth: { provider: PROVIDER_ID, refreshLead: EARLY_MS, + rotating: true, maxConcurrency: 1, options: [ diff --git a/packages/sensenova/package.json b/packages/sensenova/package.json index d026b4c..6cd37bf 100644 --- a/packages/sensenova/package.json +++ b/packages/sensenova/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-sensenova-auth", - "version": "0.2.2", + "version": "0.2.3", "description": "SenseNova (SenseTime 日日新) Token Plan in OpenCode and magpie: browser or password sign-in for the credit pools, windows and grants, plus the plan's models through a Token Plan API key", "type": "module", "main": "./opencode.mjs", diff --git a/packages/sensenova/signin.test.mjs b/packages/sensenova/signin.test.mjs index 6a0566c..9e08736 100644 --- a/packages/sensenova/signin.test.mjs +++ b/packages/sensenova/signin.test.mjs @@ -106,6 +106,7 @@ test("a refresh token is renewed, and the new one replaces the old", async () => return json({ access_token: "jwt-2", refresh_token: "new-r", expires_in: 10800 }) }) const p = await SenseNovaAuthPlugin({ client: { auth: { set: async () => {} } } }) + expect(p.auth.rotating).toBe(true) const renewed = await p.auth.refresh({ type: "oauth", access: "old", refresh: "old-r", expires: Date.now() + 1000 }) expect(await unseal(renewed.access)).toBe("jwt-2") expect(await unseal(renewed.refresh)).toBe("new-r") @@ -299,4 +300,4 @@ test("a Windows session whose DPAPI refuses still refreshes, storing plaintext a } finally { _setCryptoForTests(null) } -}) \ No newline at end of file +}) diff --git a/packages/workbuddy/index.mjs b/packages/workbuddy/index.mjs index 8ef8171..e075b74 100644 --- a/packages/workbuddy/index.mjs +++ b/packages/workbuddy/index.mjs @@ -3919,6 +3919,7 @@ function makePlugin(site) { // which doesn't call this. Desktop's sign-in has no expiry stored // and is renewed as before. refreshLead: LEAD_MS, + rotating: true, refresh: (auth) => refreshed(site, auth), // the account's daily check-in: magpie can run it once a day per // account, when its WorkBuddy check-in switch is on; the button in diff --git a/packages/workbuddy/package.json b/packages/workbuddy/package.json index ad42824..fd9332f 100644 --- a/packages/workbuddy/package.json +++ b/packages/workbuddy/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-workbuddy-auth", - "version": "0.2.29", + "version": "0.2.30", "description": "OpenCode provider plugins for WorkBuddy's plans: WorkBuddy (CodeBuddy, copilot.tencent.com) and WorkBuddy AI (www.workbuddy.ai)", "type": "module", "main": "./opencode.mjs", diff --git a/packages/workbuddy/refresh.test.mjs b/packages/workbuddy/refresh.test.mjs index 0624460..4230f3c 100644 --- a/packages/workbuddy/refresh.test.mjs +++ b/packages/workbuddy/refresh.test.mjs @@ -45,6 +45,7 @@ test("auth.refresh renews and gives the new fields, saving nothing itself", asyn const sets = [] const hooks = await WorkBuddyAIAuthPlugin({ client: { auth: { set: async (x) => sets.push(x) } } }) expect(hooks.auth.refreshLead).toBeGreaterThanOrEqual(60 * 1000) + expect(hooks.auth.rotating).toBe(true) const got = await hooks.auth.refresh(auth(), "workbuddy-ai") expect(got.access).toBe("new") expect(got.refresh).toBe("r2")