diff --git a/packages/codearts/index.mjs b/packages/codearts/index.mjs index db23baf..27fdd5c 100644 --- a/packages/codearts/index.mjs +++ b/packages/codearts/index.mjs @@ -3196,8 +3196,15 @@ export const CodeArtsAuthPlugin = async ({ client } = {}, options = {}) => { if (checked.error) return { type: "failed", error: checked.error } const cred = { ...read.cred, ...checked.fields, session_id: randomHex(16) } const identity = accountIdentityOf(cred) + // refresh is here, empty, because a host keeps an OAuth + // sign-in only when the result has one (OpenCode's CLI and + // magpie's host.js both test `"refresh" in result`): without + // it the sign-in said ok and nothing was stored (#998). This + // one has no refresh token; it is renewed by reading the IDE's + // file again. return { type: "success", + refresh: "", access: JSON.stringify(cred), expires: expiresFromCredential(cred), accountId: identity.id, diff --git a/packages/codearts/index.test.mjs b/packages/codearts/index.test.mjs index f0e487d..df746c1 100644 --- a/packages/codearts/index.test.mjs +++ b/packages/codearts/index.test.mjs @@ -4449,7 +4449,9 @@ test("signing in from the CodeArts Agent: checked with its station, the account assert.equal(r.type, "success", r.error) assert.equal(r.accountId, "dom1") assert.equal(r.uid, "dom1") - assert.equal(r.refresh, undefined) + // a host keeps an OAuth sign-in only when "refresh" is in the result (#998) + assert.ok("refresh" in r, "kept by the host") + assert.equal(r.refresh, "", "no refresh token: renewed from the IDE's file") assert.equal(r.expires, Date.parse("2030-01-01T00:00:00Z")) const cred = JSON.parse(r.access) assert.equal(cred.station, "international") diff --git a/packages/codearts/package.json b/packages/codearts/package.json index 33022c9..6549c81 100644 --- a/packages/codearts/package.json +++ b/packages/codearts/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-codearts-auth", - "version": "0.3.13", + "version": "0.3.14", "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",