codearts 0.3.14: a CodeArts Agent sign-in is kept (#998)

Signing in with "Sign in from CodeArts Agent" said ok, but the account
was never stored. A host keeps an OAuth sign-in only when the result has
a `refresh` field (OpenCode's CLI and magpie's host.js both test
`"refresh" in result`), and the IDE method's success had none. It now
has `refresh: ""`. This sign-in has no refresh token: it is renewed by
reading the IDE's state file again, and every reader of the refresh
token (firstOf) already skips an empty string.

The IDE sign-in test now checks the field is there and empty.

Ran on mica (Bun, HOME=$(mktemp -d)): bun test packages/codearts 203
pass 0 fail; bun scripts/check.mjs exit 0.
Broken by hand: without the refresh line, "signing in from the CodeArts
Agent: checked with its station…" goes red (202 pass, 1 fail).
Not tried: a real CodeArts Agent sign-in (no account here).

Reported-by: AyakaChen1 <AyakaChen1@users.noreply.github.com>
This commit is contained in:
yetone
2026-11-12 11:06:52 +08:00
parent b829a5541e
commit 4e3a786814
3 changed files with 11 additions and 2 deletions
+7
View File
@@ -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,