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 +1 -1
- package/package.json +1 -1
- package/src/auth/index.ts +11 -1
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
|
-
|
|
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
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)
|