opencode-translate 0.3.0 → 0.3.1

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/README.md CHANGED
@@ -137,7 +137,7 @@ If `model` uses OpenAI and OpenCode auth is backed by the ChatGPT/Codex OAuth fl
137
137
 
138
138
  For OAuth-backed OpenAI requests, the plugin routes the OpenAI AI SDK request to `https://chatgpt.com/backend-api/codex/responses`, adds the required Codex beta/originator headers, normalizes the request body to Codex's expected typed `input` shape, and converts Codex SSE responses back to JSON for translation calls. This supports models such as `openai/gpt-5.5` when your ChatGPT plan has access.
139
139
 
140
- If you prefer a plain API key, set `OPENAI_API_KEY`, use `opencode auth login openai`, or pass `apiKey` in plugin options.
140
+ For OpenAI, an OAuth record from `opencode auth login openai` takes precedence over `OPENAI_API_KEY` and plugin `apiKey`. API keys are only used when no OpenAI OAuth record is available.
141
141
 
142
142
  ## Manual Smoke Test
143
143
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-translate",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "OpenCode plugin that lets the user chat in a configured language while the main chat loop only sees English.",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
package/src/auth/index.ts CHANGED
@@ -119,10 +119,20 @@ export function createCredentialResolver(
119
119
  async function resolve(providerModel: string): Promise<ResolvedCredential> {
120
120
  const { providerID } = parseTranslatorModel(providerModel)
121
121
  const cached = credentialCache.get(providerID)
122
- if (cached) return cached
122
+ if (cached && providerID !== "openai") return cached
123
123
 
124
124
  const provider = await getProvider(client, providerID)
125
125
  const authInfo = await resolveAuthInfo(providerID)
126
+ if (providerID === "openai" && authInfo?.type === "oauth") {
127
+ const oauthInfo = await resolveOAuth(providerID)
128
+ if (oauthInfo) {
129
+ const resolved = credentialFromOAuth(providerID, provider, oauthInfo)
130
+ credentialCache.set(providerID, resolved)
131
+ return resolved
132
+ }
133
+ }
134
+ if (cached && !(providerID === "openai" && cached.mode === "oauth" && authInfo?.type !== "oauth")) return cached
135
+
126
136
  if (options.apiKey) {
127
137
  const resolved = { providerID, provider, authInfo, apiKey: options.apiKey, mode: "apiKey" as const }
128
138
  credentialCache.set(providerID, resolved)