Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPSTREAM_VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.15.10
6 changes: 6 additions & 0 deletions packages/core/src/installation/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ declare global {
const OPENCODE_VERSION: string
const OPENCODE_CHANNEL: string
const OPENCODE_PLUGIN_VERSION: string | undefined
const OPENCODE_HTTP_VERSION: string | undefined
}

export const InstallationVersion = typeof OPENCODE_VERSION === "string" ? OPENCODE_VERSION : "local"
Expand All @@ -14,3 +15,8 @@ if (!InstallationLocal && !DefinedInstallationPluginVersion) {
}
export const InstallationPluginVersion =
DefinedInstallationPluginVersion ?? "latest"

export const InstallationHTTPVersion =
typeof OPENCODE_HTTP_VERSION === "string" && OPENCODE_HTTP_VERSION.trim()
? OPENCODE_HTTP_VERSION.trim()
: InstallationVersion
Comment thread
coderabbitai[bot] marked this conversation as resolved.
1 change: 1 addition & 0 deletions packages/desktop-electron/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const FEEDBACK_SESSION_EXPORT_TIMEOUT_MS = 3_000
const userDataRoot = CI_SMOKE_HOME ?? app.getPath("appData")

app.setName(app.isPackaged ? APP_NAMES[CHANNEL] : "PawWork Dev")
app.userAgentFallback = app.userAgentFallback.replace(/PawWork(?:\s\w+)?\//g, "opencode/")
if (CI_SMOKE_HOME) {
app.setPath("appData", CI_SMOKE_HOME)
}
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/script/build-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ await Bun.build({
OPENCODE_PLUGIN_VERSION: `'${pluginPkg.version}'`,
OPENCODE_MIGRATIONS: JSON.stringify(migrations),
OPENCODE_CHANNEL: `'${Script.channel}'`,
OPENCODE_HTTP_VERSION: `'${Script.httpVersion}'`,
},
files: {
"opencode-web-ui.gen.ts": "",
Expand Down
1 change: 1 addition & 0 deletions packages/opencode/script/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ for (const item of targets) {
OPENCODE_PLUGIN_VERSION: `'${pluginPkg.version}'`,
OPENCODE_MIGRATIONS: JSON.stringify(migrations),
OPENCODE_CHANNEL: `'${Script.channel}'`,
OPENCODE_HTTP_VERSION: `'${Script.httpVersion}'`,
OPENCODE_LIBC: item.os === "linux" ? `'${item.abi ?? "glibc"}'` : "",
},
})
Expand Down
4 changes: 3 additions & 1 deletion packages/opencode/src/account/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "effect/unstable/http"

import { withTransientReadRetry } from "@/util/effect-http-client"
import { Installation } from "@/installation"
import { AccountRepo, type AccountRow } from "./repo"
import { normalizeServerUrl } from "./url"
import {
Expand Down Expand Up @@ -186,7 +187,8 @@ export namespace Account {
Service,
Effect.gen(function* () {
const repo = yield* AccountRepo
const http = yield* HttpClient.HttpClient
const rawHttp = yield* HttpClient.HttpClient
const http = HttpClient.mapRequest(rawHttp, HttpClientRequest.setHeaders(Installation.httpIdentity()))
const httpRead = withTransientReadRetry(http)
const httpOk = HttpClient.filterStatusOk(http)
const httpReadOk = HttpClient.filterStatusOk(httpRead)
Expand Down
15 changes: 14 additions & 1 deletion packages/opencode/src/installation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import z from "zod"
import { BusEvent } from "@/bus/bus-event"
import { Flag } from "@opencode-ai/core/flag/flag"
import { Log } from "@opencode-ai/core/util/log"
import { InstallationChannel as channel, InstallationVersion as version } from "@opencode-ai/core/installation/version"
import {
InstallationChannel as channel,
InstallationVersion as version,
InstallationHTTPVersion,
} from "@opencode-ai/core/installation/version"

import semver from "semver"

Expand Down Expand Up @@ -57,7 +61,16 @@ export namespace Installation {

export const VERSION = version
export const CHANNEL = channel
export const HTTP_VERSION = InstallationHTTPVersion
export const USER_AGENT = `opencode/${CHANNEL}/${VERSION}/${Flag.OPENCODE_CLIENT}`
export const HTTP_USER_AGENT = `opencode/latest/${HTTP_VERSION}/${Flag.OPENCODE_CLIENT}`

export function httpIdentity(): Record<string, string> {
return {
"User-Agent": HTTP_USER_AGENT,
"x-opencode-client": Flag.OPENCODE_CLIENT,
}
}

export function isPreview() {
return CHANNEL !== "latest"
Expand Down
2 changes: 1 addition & 1 deletion packages/opencode/src/provider/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ function skip(force: boolean) {

const fetchApi = async () => {
const result = await fetch(`${url()}/api.json`, {
headers: { "User-Agent": Installation.USER_AGENT },
headers: { "User-Agent": Installation.HTTP_USER_AGENT },
signal: AbortSignal.timeout(10000),
})
return { ok: result.ok, text: await result.text() }
Expand Down
6 changes: 3 additions & 3 deletions packages/opencode/src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
const providerConfig = (yield* dep.config()).provider?.["gitlab"]

const aiGatewayHeaders = {
"User-Agent": `opencode/${Installation.VERSION} gitlab-ai-provider/${GITLAB_PROVIDER_VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`,
"User-Agent": `opencode/${Installation.HTTP_VERSION} gitlab-ai-provider/${GITLAB_PROVIDER_VERSION} (${os.platform()} ${os.release()}; ${os.arch()})`,
"anthropic-beta": "context-1m-2025-08-07",
...providerConfig?.options?.aiGatewayHeaders,
}
Expand Down Expand Up @@ -730,7 +730,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
options: {
apiKey,
headers: {
"User-Agent": `opencode/${Installation.VERSION} cloudflare-workers-ai (${os.platform()} ${os.release()}; ${os.arch()})`,
"User-Agent": `opencode/${Installation.HTTP_VERSION} cloudflare-workers-ai (${os.platform()} ${os.release()}; ${os.arch()})`,
},
},
async getModel(sdk: any, modelID: string) {
Expand Down Expand Up @@ -801,7 +801,7 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
skipCache: input.options?.skipCache,
collectLog: input.options?.collectLog,
headers: {
"User-Agent": `opencode/${Installation.VERSION} cloudflare-ai-gateway (${os.platform()} ${os.release()}; ${os.arch()})`,
"User-Agent": `opencode/${Installation.HTTP_VERSION} cloudflare-ai-gateway (${os.platform()} ${os.release()}; ${os.arch()})`,
},
}

Expand Down
3 changes: 2 additions & 1 deletion packages/opencode/src/session/llm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ const live: Layer.Layer<
headers: {
...(input.model.providerID.startsWith("opencode")
? {
"User-Agent": Installation.HTTP_USER_AGENT,
"x-opencode-project": Instance.project.id,
"x-opencode-session": input.sessionID,
"x-opencode-request": input.user.id,
Expand All @@ -400,7 +401,7 @@ const live: Layer.Layer<
: {
"x-session-affinity": input.sessionID,
...(input.parentSessionID ? { "x-parent-session-id": input.parentSessionID } : {}),
"User-Agent": `opencode/${Installation.VERSION}`,
"User-Agent": `opencode/${Installation.HTTP_VERSION}`,
}),
...input.model.headers,
...headers,
Expand Down
9 changes: 9 additions & 0 deletions packages/script/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const VERSION = await (async () => {
return `${major}.${minor}.${patch + 1}`
})()

const UPSTREAM_VERSION_PATH = path.resolve(import.meta.dir, "../../../UPSTREAM_VERSION")
const HTTP_VERSION = await Bun.file(UPSTREAM_VERSION_PATH)
.text()
.then((x) => x.trim())
.catch(() => VERSION)

const bot = ["actions-user", "opencode", "opencode-agent[bot]"]
const teamPath = path.resolve(import.meta.dir, "../../../.github/TEAM_MEMBERS")
const team = [
Expand All @@ -64,6 +70,9 @@ export const Script = {
get version() {
return VERSION
},
get httpVersion() {
return HTTP_VERSION
},
get preview() {
return IS_PREVIEW
},
Expand Down