fix(updates): scope minimum checks to the caller channel

This commit is contained in:
Dax Raad
2026-09-07 16:51:37 -04:00
parent a3bbcd5c73
commit 4aba093c98
2 changed files with 11 additions and 5 deletions
+4
View File
@@ -17,6 +17,10 @@ release preserves the minimum marker.
Clients send their running version as `?current=<version>` and use the CLI's default
`User-Agent: opencode/<channel>/<version>/cli`. When `current` is absent, the service
parses that User-Agent or the older `opencode/<version>` format.
The caller's channel comes from the default User-Agent, or from a preview version
such as `0.0.0-beta-18955` when that channel is absent. If an identified caller channel
differs from the requested channel, the service serves the active release without
applying the minimum. Historical `next` and `beta` count as the same channel.
A caller below the minimum receives that exact
artifact; callers at or above it receive the active artifact. An unparseable caller
version receives the minimum. Requests with neither version source receive the active
+7 -5
View File
@@ -70,11 +70,13 @@ export default {
}
const resolved = resolveChannel(path[0])
const agent = request.headers.get("User-Agent")?.match(/^opencode\/(?:[^/]+\/([^/]+)\/cli|(.*))$/)
const current = url.searchParams.get("current") ?? agent?.[1] ?? agent?.[2]
if (path.length === 1) return channel(env.DB, resolved, current)
if (path.length === 2) return artifactName(env.DB, resolved, path[1], current)
return artifactDistribution(env.DB, resolved, path[1], path[2], current)
const agent = request.headers.get("User-Agent")?.match(/^opencode\/(?:([^/]+)\/([^/]+)\/cli|(.*))$/)
const current = url.searchParams.get("current") ?? agent?.[2] ?? agent?.[3]
const source = agent?.[1] ?? current?.match(/^v?0\.0\.0-(.+)-\d+(?:\.\d+)?(?:\+.*)?$/)?.[1]
const caller = source === undefined || resolveChannel(source) === resolved ? current : undefined
if (path.length === 1) return channel(env.DB, resolved, caller)
if (path.length === 2) return artifactName(env.DB, resolved, path[1], caller)
return artifactDistribution(env.DB, resolved, path[1], path[2], caller)
},
} satisfies ExportedHandler<Env>