diff --git a/packages/app/component-tests/pairing.spec.ts b/packages/app/component-tests/pairing.spec.ts
index 6123a645215f..e56cd4fb6247 100644
--- a/packages/app/component-tests/pairing.spec.ts
+++ b/packages/app/component-tests/pairing.spec.ts
@@ -1,5 +1,19 @@
import { expect, story } from "../../stories/playwright/story"
+story("the connect screen can retry a failed health check after scanning a one-time QR code", async ({ mount }) => {
+ const component = await mount("app-connect-to-server--retry-after-scan")
+ await component.getByRole("button", { name: "Read fixture QR code" }).click()
+ await expect(component.getByRole("alert")).toHaveText(
+ "Could not connect. Check the server address and password, then try again.",
+ )
+ await expect(component.getByLabel("Pairing link", { exact: true })).toHaveValue(
+ "https://build.example.test/auth/connect/example",
+ )
+
+ await component.getByRole("button", { name: "Connect", exact: true }).click()
+ await expect(component.getByRole("status")).toHaveText("Connected to https://build.example.test in this preview.")
+})
+
story("a Keep screen active read that fails offers Try again and keeps the switch enabled", async ({ mount, page }) => {
// The page reads three more times, 1, 2 and 4 seconds apart, before it shows the failure.
await page.clock.install()
diff --git a/packages/app/src/servers/connect/connect.fixture.tsx b/packages/app/src/servers/connect/connect.fixture.tsx
new file mode 100644
index 000000000000..1c38074a4b61
--- /dev/null
+++ b/packages/app/src/servers/connect/connect.fixture.tsx
@@ -0,0 +1,222 @@
+import { Button } from "@opencode/ui/button"
+import { useDialog } from "@opencode/ui/context/dialog"
+import { createEffect, createSignal, onMount, Show, type ComponentProps } from "solid-js"
+import type { ServerConnection } from "@/runtime/server/registry"
+import { createServerConnectController, type ServerConnectControllerOptions } from "./controller"
+import { DialogServer } from "./dialog"
+import type { ServerCameraSupport, ServerConnectEvent, ServerConnectField, ServerConnectTarget } from "./machine"
+import { PairingScanner } from "./scanner"
+import { ConnectServerForm } from "./screen"
+
+export const address = "https://build.example.test"
+
+export const link = `${address}/auth/connect/example`
+
+export const field = (field: ServerConnectField, value: string) => ({ type: "field.changed", field, value }) as const
+
+export const password = { type: "method.changed", method: "password" } satisfies ServerConnectEvent
+
+export const submit = { type: "submitted" } satisfies ServerConnectEvent
+
+type CameraScene = "ready" | "opening" | "denied" | "invalid" | "decode" | "expired" | "redeeming" | "timeout"
+
+type Preset = {
+ camera?: ServerCameraSupport | "probing"
+ events?: Extract[]
+ scanner?: CameraScene
+ exchange?: "expired" | "unreachable"
+ check?: "unreachable" | "pending"
+}
+
+type DialogPreset = Preset & { target?: Extract; closed?: boolean }
+
+export function serverStory(preset: DialogPreset = {}) {
+ return { render: () => }
+}
+
+function DialogStory(props: { preset: DialogPreset }) {
+ const dialog = useDialog()
+
+ const [saved, setSaved] = createSignal("")
+
+ const open = () => {
+ setSaved("")
+ void dialog.show(() => (
+ setSaved(server.displayName ?? server.http.url)}
+ createForm={(dialog) =>
+ createPreviewForm(
+ { ...dialog, target: props.preset.target ?? { kind: "add" }, removeTabs() {} },
+ props.preset,
+ )
+ }
+ scanner={(scanner) => }
+ />
+ ))
+ }
+
+ onMount(() => {
+ if (!props.preset.closed) open()
+ })
+
+ return (
+
+
+ Open {props.preset.target?.kind ?? "add"} server dialog
+
+
{(name) => Saved {name()} in this preview.
}
+
+ )
+}
+
+export function screenStory(preset: Preset & { url?: string } = {}) {
+ return { render: () => }
+}
+
+function ScreenStory(props: { preset: Preset & { url?: string } }) {
+ const [connected, setConnected] = createSignal("")
+
+ // On success the app routes away. In the lab show the saved address and let the next run start with a fresh form.
+ const Screen = () => {
+ const form = createPreviewForm(
+ { surface: "screen", target: { kind: "connect", url: props.preset.url } },
+ props.preset,
+ (server) => setConnected(server.http.url),
+ )
+
+ return (
+ }
+ />
+ )
+ }
+
+ return (
+
+
}>
+ {(url) => (
+
+
Connected to {url()} in this preview.
+
setConnected("")}>
+ Pair again
+
+
+ )}
+
+
+ )
+}
+
+function createPreviewForm(
+ options: ServerConnectControllerOptions,
+ preset: Preset,
+ onSave?: (server: ServerConnection.Http) => void,
+) {
+ const pending = new Promise(() => {})
+
+ const spent = new Set(["expired"])
+
+ let check = preset.check
+
+ let exchange = preset.exchange
+
+ const form = createServerConnectController(options, {
+ camera: preset.camera === "probing" ? "probe" : (preset.camera ?? "probe"),
+ probeCamera: () => (preset.camera === "probing" ? pending : Promise.resolve(true)),
+ pageHref: "https://lab.example.test",
+ servers: {
+ list: [],
+ add(server) {
+ onSave?.(server)
+
+ return server
+ },
+ remove() {},
+ },
+ exchange: async (request) => {
+ if (request.code === "pending") return pending
+
+ if (spent.has(request.code)) return { type: "expired" }
+
+ if (exchange) {
+ const type = exchange
+ exchange = undefined
+
+ if (type === "expired") spent.add(request.code)
+
+ return { type }
+ }
+
+ spent.add(request.code)
+
+ return { type: "paired", pairing: { url: request.urls[0], password: "fixture" } }
+ },
+ check: async () => {
+ if (check === "pending") return pending
+
+ if (check === "unreachable") {
+ check = undefined
+
+ return { type: "unreachable" }
+ }
+
+ await new Promise((resolve) => setTimeout(resolve, 700))
+
+ return { type: "healthy" }
+ },
+ })
+
+ preset.events?.forEach(form.dispatch)
+
+ if (preset.scanner) {
+ let opened = false
+ createEffect(() => {
+ if (opened || !form.view().canScan) return
+ opened = true
+ form.dispatch({ type: "scan.started" })
+ })
+ }
+
+ return form
+}
+
+function CameraPreview(props: ComponentProps & { scene: CameraScene }) {
+ let detect: ((data: string) => void) | undefined
+
+ const camera: NonNullable["camera"]> = (_, read, failed) => {
+ detect = read
+ let frame: ReturnType
+
+ return {
+ start: async () => {
+ if (props.scene === "denied") throw new Error("Camera permission denied")
+
+ if (props.scene === "opening") return new Promise(() => {})
+ frame = requestAnimationFrame(() => {
+ if (props.scene === "invalid") read("not a pairing code")
+
+ if (props.scene === "decode") failed()
+
+ if (props.scene === "expired") read(JSON.stringify({ code: "expired", urls: [address] }))
+
+ if (props.scene === "redeeming" || props.scene === "timeout") read(`${address}/auth/connect/pending`)
+ })
+ },
+ stop() {},
+ destroy: () => cancelAnimationFrame(frame),
+ }
+ }
+
+ return (
+ <>
+
+
+ detect?.(JSON.stringify({ code: "example", urls: [address] }))}>
+ Read fixture QR code
+
+
+ >
+ )
+}
diff --git a/packages/app/src/servers/connect/dialog.fixture.tsx b/packages/app/src/servers/connect/dialog.fixture.tsx
deleted file mode 100644
index 587bb87cb25c..000000000000
--- a/packages/app/src/servers/connect/dialog.fixture.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-import { Button } from "@opencode/ui/button"
-import { useDialog } from "@opencode/ui/context/dialog"
-import { createEffect, createSignal, onMount, Show, type ComponentProps } from "solid-js"
-import { createServerConnectController } from "./controller"
-import { DialogServer } from "./dialog"
-import type { ServerCameraSupport, ServerConnectEvent, ServerConnectTarget } from "./machine"
-import { PairingScanner } from "./scanner"
-
-export const address = "https://build.example.test"
-
-export const link = `${address}/auth/connect/example`
-
-type CameraScene = "ready" | "opening" | "denied" | "invalid" | "decode" | "redeeming" | "timeout"
-
-type Preset = {
- camera?: ServerCameraSupport | "probing"
- target?: Extract
- events?: Extract[]
- scanner?: CameraScene
- exchange?: "expired" | "unreachable"
- check?: "unreachable" | "pending"
- closed?: boolean
-}
-
-export function serverStory(preset: Preset = {}) {
- return { render: () => }
-}
-
-function Story(props: { preset: Preset }) {
- const dialog = useDialog()
-
- const [saved, setSaved] = createSignal("")
-
- const open = () => {
- setSaved("")
- void dialog.show(() => (
- setSaved(server.displayName ?? server.http.url)} />
- ))
- }
-
- onMount(() => {
- if (!props.preset.closed) open()
- })
-
- return (
-
-
- Open {props.preset.target?.kind ?? "add"} server dialog
-
-
{(name) => Saved {name()} in this preview.
}
-
- )
-}
-
-function Preview(props: { preset: Preset; onSave: ComponentProps["onSave"] }) {
- const preset = props.preset
-
- const createForm: NonNullable["createForm"]> = (dialog) => {
- const pending = new Promise(() => {})
-
- let check = preset.check
-
- let exchange = preset.exchange
-
- const form = createServerConnectController(
- { ...dialog, target: preset.target ?? { kind: "add" }, removeTabs() {} },
- {
- camera: preset.camera === "probing" ? "probe" : (preset.camera ?? "probe"),
- probeCamera: () => (preset.camera === "probing" ? pending : Promise.resolve(true)),
- pageHref: "https://lab.example.test",
- servers: { list: [], add: (server) => server, remove() {} },
- exchange: async (request) => {
- if (request.code === "pending") return pending
-
- if (exchange) {
- const type = exchange
- exchange = undefined
-
- return { type }
- }
-
- return { type: "paired", pairing: { url: request.urls[0], password: "fixture" } }
- },
- check: async () => {
- if (check === "pending") return pending
-
- if (check === "unreachable") {
- check = undefined
-
- return { type: "unreachable" }
- }
-
- await new Promise((resolve) => setTimeout(resolve, 700))
-
- return { type: "healthy" }
- },
- },
- )
-
- preset.events?.forEach(form.dispatch)
-
- if (preset.scanner) {
- let opened = false
- createEffect(() => {
- if (opened || !form.view().canScan) return
- opened = true
- form.dispatch({ type: "scan.started" })
- })
- }
-
- return form
- }
-
- return (
- }
- />
- )
-}
-
-function CameraPreview(props: ComponentProps & { scene: CameraScene }) {
- let detect: ((data: string) => void) | undefined
-
- const camera: NonNullable["camera"]> = (_, read, failed) => {
- detect = read
- let frame: ReturnType
-
- return {
- start: async () => {
- if (props.scene === "denied") throw new Error("Camera permission denied")
-
- if (props.scene === "opening") return new Promise(() => {})
- frame = requestAnimationFrame(() => {
- if (props.scene === "invalid") read("not a pairing code")
-
- if (props.scene === "decode") failed()
-
- if (props.scene === "redeeming" || props.scene === "timeout") read(`${address}/auth/connect/pending`)
- })
- },
- stop() {},
- destroy: () => cancelAnimationFrame(frame),
- }
- }
-
- return (
- <>
-
-
- detect?.(link)}>
- Read fixture QR code
-
-
- >
- )
-}
diff --git a/packages/app/src/servers/connect/dialog.stories.tsx b/packages/app/src/servers/connect/dialog.stories.tsx
index 813e6faf55bd..6901b276cec4 100644
--- a/packages/app/src/servers/connect/dialog.stories.tsx
+++ b/packages/app/src/servers/connect/dialog.stories.tsx
@@ -1,11 +1,5 @@
-import { address, link, serverStory } from "./dialog.fixture"
-import type { ServerConnectEvent, ServerConnectField, ServerConnectTarget } from "./machine"
-
-const field = (field: ServerConnectField, value: string) => ({ type: "field.changed", field, value }) as const
-
-const password = { type: "method.changed", method: "password" } satisfies ServerConnectEvent
-
-const submit = { type: "submitted" } satisfies ServerConnectEvent
+import { address, field, link, password, serverStory, submit } from "./connect.fixture"
+import type { ServerConnectTarget } from "./machine"
const edit = {
kind: "edit",
@@ -62,6 +56,8 @@ export const InvalidQrCode = serverStory({ scanner: "invalid" })
export const DecodeFailed = serverStory({ scanner: "decode" })
+export const ExpiredQrCode = serverStory({ scanner: "expired" })
+
export const ScanTimedOut = serverStory({ scanner: "timeout" })
export const EditPassword = serverStory({ target: edit })
diff --git a/packages/app/src/servers/connect/screen.stories.tsx b/packages/app/src/servers/connect/screen.stories.tsx
new file mode 100644
index 000000000000..aa624386f633
--- /dev/null
+++ b/packages/app/src/servers/connect/screen.stories.tsx
@@ -0,0 +1,63 @@
+import { address, field, link, password, screenStory, submit } from "./connect.fixture"
+
+export default {
+ title: "App/Servers/Connect to Server",
+ id: "app-connect-to-server",
+ parameters: { layout: "fullscreen" },
+}
+
+export const PairingLink = screenStory()
+
+export const ReadyToPair = screenStory({ events: [field("link", link)] })
+
+// A signed-out server keeps its original address when the new pairing token works there.
+export const PairAgain = screenStory({ url: "https://saved.example.test", events: [field("link", link)] })
+
+export const Password = screenStory({ events: [password] })
+
+export const BareServerAddress = screenStory({ events: [field("link", address), submit] })
+
+export const InvalidLink = screenStory({ events: [field("link", "incomplete"), submit] })
+
+export const LegacyLink = screenStory({ events: [field("link", `${address}/connect#example`), submit] })
+
+export const ExpiredLink = screenStory({ events: [field("link", link), submit], exchange: "expired" })
+
+export const UnreachableLink = screenStory({ events: [field("link", link), submit], exchange: "unreachable" })
+
+export const MixedContent = screenStory({
+ events: [field("link", "http://build.example.test/auth/connect/example"), submit],
+ exchange: "unreachable",
+})
+
+export const Checking = screenStory({ events: [field("link", link), submit], check: "pending" })
+
+export const ConnectionFailed = screenStory({ events: [field("link", link), submit], check: "unreachable" })
+
+export const InvalidAddress = screenStory({ events: [password, field("url", "file:///example"), submit] })
+
+export const CameraProbing = screenStory({ camera: "probing" })
+
+export const CameraUnavailable = screenStory({ camera: "unavailable" })
+
+export const CameraInsecure = screenStory({ camera: "insecure" })
+
+export const NativePairing = screenStory({ camera: "none" })
+
+export const OpeningCamera = screenStory({ scanner: "opening" })
+
+export const Scanning = screenStory({ scanner: "ready" })
+
+export const RetryAfterScan = screenStory({ scanner: "ready", check: "unreachable" })
+
+export const RedeemingScan = screenStory({ scanner: "redeeming" })
+
+export const CameraError = screenStory({ scanner: "denied" })
+
+export const InvalidQrCode = screenStory({ scanner: "invalid" })
+
+export const ExpiredQrCode = screenStory({ scanner: "expired" })
+
+export const DecodeFailed = screenStory({ scanner: "decode" })
+
+export const ScanTimedOut = screenStory({ scanner: "timeout" })
diff --git a/packages/app/src/servers/connect/screen.tsx b/packages/app/src/servers/connect/screen.tsx
index 045209786b6a..9a0968a5c619 100644
--- a/packages/app/src/servers/connect/screen.tsx
+++ b/packages/app/src/servers/connect/screen.tsx
@@ -1,4 +1,4 @@
-import { lazy, Show, Suspense } from "solid-js"
+import { lazy, Show, Suspense, type Component, type ComponentProps } from "solid-js"
import { Button } from "@opencode/ui/button"
import { TextInput } from "@opencode/ui/text-input"
import { Wordmark } from "@opencode/ui/wordmark"
@@ -10,9 +10,20 @@ import "./screen.css"
const PairingScanner = lazy(() => import("./scanner").then((module) => ({ default: module.PairingScanner })))
export function ConnectServerScreen(props: { url?: string } = {}) {
- const language = useLanguage()
// Read once: the screen leaves when the server it signs in to answers, so its address does not change while it shows.
const form = createServerConnectController({ surface: "screen", target: { kind: "connect", url: props.url } })
+
+ return
+}
+
+export function ConnectServerForm(props: {
+ form: ReturnType
+ scanner: Component>
+}) {
+ const language = useLanguage()
+
+ const form = props.form
+
const view = form.view
return (
@@ -33,7 +44,7 @@ export function ConnectServerScreen(props: { url?: string } = {}) {
when={!view().scanning}
fallback={
{language.t("server.connect.camera.starting")}
}>
- form.dispatch({ type: "scan.cancelled" })}
onScan={(link) => form.dispatch({ type: "scan.completed", link })}
diff --git a/packages/app/src/session/timeline/cache.ts b/packages/app/src/session/timeline/cache.ts
index d73922409da4..71c3af99c4bf 100644
--- a/packages/app/src/session/timeline/cache.ts
+++ b/packages/app/src/session/timeline/cache.ts
@@ -120,9 +120,6 @@ export function createTimelineCache(
get agents() {
return agents()
},
- get copyAlwaysVisible() {
- return data.copyAlwaysVisible
- },
navigateToSession: data.navigateToSession,
sessionHref: data.sessionHref,
readMedia: data.readMedia,
diff --git a/packages/app/src/shell/routes/session-ui-provider.tsx b/packages/app/src/shell/routes/session-ui-provider.tsx
index 8df23d77b0bf..40fd02ccc0de 100644
--- a/packages/app/src/shell/routes/session-ui-provider.tsx
+++ b/packages/app/src/shell/routes/session-ui-provider.tsx
@@ -45,8 +45,6 @@ export function SessionUIProvider(
const language = useLanguage()
const settings = useSettings()
const directory = () => props.directory
- const releaseChannel = import.meta.env.VITE_OPENCODE_CHANNEL ?? "local"
- const copyAlwaysVisible = releaseChannel === "dev" || releaseChannel === "local"
const readImage = createMemo(() => {
const dir = directory()
@@ -240,7 +238,6 @@ export function SessionUIProvider(
directory={directory()}
sessionID={params.id}
agents={settings.visibility.customAgents()}
- copyAlwaysVisible={copyAlwaysVisible}
shellRunning={(id) => !!data.shell.get(id)}
shellOutput={(input) => serverSDK.api.shell.output(input)}
readMedia={(uri, mime, signal) => serverSDK.media.load(uri, mime, signal)}
diff --git a/packages/cli/src/server-process.ts b/packages/cli/src/server-process.ts
index 2f64e3ec7b86..c565eac22a6d 100644
--- a/packages/cli/src/server-process.ts
+++ b/packages/cli/src/server-process.ts
@@ -124,7 +124,7 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
project: !truthy(
process.env.OPENCODE_CONFIG_PROJECT_DISABLE ?? process.env.OPENCODE_DISABLE_PROJECT_CONFIG,
),
- // .claude is only read for skills, so both flags gate the same roots.
+ // Config reads .claude only for skills; CLAUDE.md is gated under instructions.
claude: !(
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE) ||
truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE_SKILLS)
@@ -132,6 +132,14 @@ const processEffect = Effect.fnUntraced(function* (options: Options) {
file: process.env.OPENCODE_CONFIG,
content: process.env.OPENCODE_CONFIG_CONTENT,
},
+ instructions: {
+ claude: !truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE),
+ // As in V1, the prompt flag only skips ~/.claude/CLAUDE.md.
+ claudeGlobal: !(
+ truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE) ||
+ truthy(process.env.OPENCODE_DISABLE_CLAUDE_CODE_PROMPT)
+ ),
+ },
windows: {
gitbash: process.env.OPENCODE_GIT_BASH_PATH,
},
diff --git a/packages/codemode/src/codemode.ts b/packages/codemode/src/codemode.ts
index 3e64f89b2fcd..e02e9c6c92e3 100644
--- a/packages/codemode/src/codemode.ts
+++ b/packages/codemode/src/codemode.ts
@@ -4,7 +4,14 @@ import { scanTools } from "./scan.js"
import { type Services, type ToolDescription, ToolRuntime } from "./tool-runtime.js"
import type { Tools } from "./tools.js"
import { fromJson } from "./data.js"
-import { finishExecution, resumeProgram, type Running, type Setup, startProgram, SuspendError } from "./runtime/execute.js"
+import {
+ finishExecution,
+ resumeProgram,
+ type Running,
+ type Setup,
+ startProgram,
+ SuspendError,
+} from "./runtime/execute.js"
import { extensionGlobals } from "./runtime/extensions.js"
import { globalNames } from "./runtime/globals.js"
import { fromBytes, type Snapshot, SnapshotError, type SnapshotHeader, toBytes } from "./snapshot/snapshot.js"
@@ -46,8 +53,18 @@ export type ResolvedExecutionLimits = {
readonly maxOutputBytes: number | undefined
}
+/** Options for one run of a runtime's program: `Runtime.execute`, `Runtime.program`, and `Runtime.resume`. */
+export type RunOptions = {
+ /**
+ * Which of the runtime's extensions this run gets as globals; all of them by default. Each must be one the runtime
+ * was made with, so its services are already part of the runtime's environment. A resumed run needs the ones it
+ * started with.
+ */
+ readonly extensions?: ReadonlyArray
+}
+
/** Options for `Runtime.program`. */
-export type ProgramOptions = {
+export type ProgramOptions = RunOptions & {
/** Names this run's host calls (`:`); a random UUID by default. */
readonly runId?: string
}
@@ -157,7 +174,11 @@ export type Outcome = Result | Suspended
/** Reusable confined runtime over explicit tools and extensions. */
export type Runtime = {
readonly catalog: ReadonlyArray
- readonly execute: (code: string, bindings?: Readonly>) => Effect.Effect
+ readonly execute: (
+ code: string,
+ bindings?: Readonly>,
+ options?: RunOptions,
+ ) => Effect.Effect
/** A program ready to run once; nothing runs until `program.run()`. */
readonly program: (
code: string,
@@ -169,7 +190,7 @@ export type Runtime = {
* same build with the same extensions. The state is checked when it runs: `run()` fails with a `SnapshotError` when
* it can't be resumed here.
*/
- readonly resume: (state: Snapshot | Uint8Array) => Program
+ readonly resume: (state: Snapshot | Uint8Array, options?: RunOptions) => Program
}
/**
@@ -217,7 +238,7 @@ export function make<
type R = Environment
const prepared = ToolRuntime.prepare((options.tools ?? {}) as Tools>)
const limits = resolveExecutionLimits(options.limits)
- const extensions = options.extensions ?? []
+ const extensions: ReadonlyArray = options.extensions ?? []
const bound = new Set(globalNames)
for (const extension of extensions) {
for (const name of Object.keys(extension.globals)) {
@@ -225,27 +246,43 @@ export function make<
bound.add(name)
}
}
- const setup: Setup = {
- prepared,
- limits,
- hooks: options.hooks ?? {},
- globals: extensions.length === 0 ? undefined : (ctx) => extensionGlobals(ctx, extensions),
- lossy: extensions.some((extension) => extension.snapshot === undefined),
+ const setupFor = (selected: ReadonlyArray = extensions): Setup => {
+ for (const extension of selected) {
+ if (!extensions.includes(extension)) {
+ throw new TypeError(`Extension "${extension.name}" isn't one this runtime was made with.`)
+ }
+ }
+ // In the runtime's order, so the same extensions picked in any order give the same globals, and resume alike.
+ const picked = extensions.filter((extension) => selected.includes(extension))
+ return {
+ prepared,
+ limits,
+ hooks: options.hooks ?? {},
+ globals: picked.length === 0 ? undefined : (ctx) => extensionGlobals(ctx, picked),
+ lossy: picked.some((extension) => extension.snapshot === undefined),
+ }
}
+ const setup = setupFor()
const data = (bindings: Readonly> | undefined) =>
bindings === undefined
? undefined
: (ctx: Parameters[0]) =>
Object.entries(bindings).map(([name, value]) => [name, fromJson(ctx, value)] as const)
- const program = (code: string, bindings?: Readonly>, programOptions?: ProgramOptions) =>
- makeProgram(() => Effect.succeed(startProgram(setup, code, data(bindings), programOptions?.runId)))
+ const program = (code: string, bindings?: Readonly>, programOptions?: ProgramOptions) => {
+ const run = programOptions?.extensions === undefined ? setup : setupFor(programOptions.extensions)
+ return makeProgram(() => Effect.succeed(startProgram(run, code, data(bindings), programOptions?.runId)))
+ }
return {
get catalog() {
return prepared.catalog
},
- execute: (code, bindings) => Effect.suspend(() => finishExecution(program(code, bindings).run())),
+ execute: (code, bindings, runOptions) =>
+ Effect.suspend(() => finishExecution(program(code, bindings, runOptions).run())),
program,
- resume: (state) => makeProgram(() => resumeProgram(setup, state)),
+ resume: (state, runOptions) => {
+ const run = runOptions?.extensions === undefined ? setup : setupFor(runOptions.extensions)
+ return makeProgram(() => resumeProgram(run, state))
+ },
}
}
diff --git a/packages/codemode/src/index.ts b/packages/codemode/src/index.ts
index 9e5c45ff7317..9ed61ecf60ab 100644
--- a/packages/codemode/src/index.ts
+++ b/packages/codemode/src/index.ts
@@ -13,6 +13,7 @@ export {
type Outcome,
type Program,
type ProgramOptions,
+ type RunOptions,
type Runtime,
type Snapshot,
type SnapshotHeader,
diff --git a/packages/codemode/test/extensions.test.ts b/packages/codemode/test/extensions.test.ts
index 236a149fcacb..ed24c49735eb 100644
--- a/packages/codemode/test/extensions.test.ts
+++ b/packages/codemode/test/extensions.test.ts
@@ -659,6 +659,23 @@ describe("configuration", () => {
})
})
+ test("a run can get only some of the runtime's extensions", async () => {
+ const files = Extension.make({ name: "files", globals: { read: () => "text" } })
+ const target = CodeMode.make({ extensions: [extension, files] })
+ expect(await value(`return [typeof read, typeof later]`, target)).toEqual(["function", "function"])
+ const only = await Effect.runPromise(
+ target.execute(`return [typeof read, typeof later, await later(1)]`, undefined, { extensions: [extension] }),
+ )
+ expect(only).toMatchObject({ ok: true, value: ["undefined", "function", 2] })
+ const none = await Effect.runPromise(
+ target.execute(`return [typeof read, typeof later]`, undefined, { extensions: [] }),
+ )
+ expect(none).toMatchObject({ ok: true, value: ["undefined", "undefined"] })
+ expect(() =>
+ target.program(`1`, undefined, { extensions: [Extension.make({ name: "other", globals: { f: () => 1 } })] }),
+ ).toThrow(`Extension "other" isn't one this runtime was made with.`)
+ })
+
test("a global must be a function or an object", () => {
expect(() => Extension.make({ name: "bad", globals: { n: 1 as never } })).toThrow(
'Extension "bad" global "n" must be a function or an object.',
diff --git a/packages/codemode/test/suspend.test.ts b/packages/codemode/test/suspend.test.ts
index 7471f9b55d65..ef3aec35405c 100644
--- a/packages/codemode/test/suspend.test.ts
+++ b/packages/codemode/test/suspend.test.ts
@@ -450,9 +450,7 @@ describe("suspend", () => {
test("the snapshot codec does not import Effect", async () => {
for (const file of ["codec.ts", "snapshot.ts"]) {
- expect(await Bun.file(path.join(import.meta.dir, "../src/snapshot", file)).text()).not.toMatch(
- /from "effect"/,
- )
+ expect(await Bun.file(path.join(import.meta.dir, "../src/snapshot", file)).text()).not.toMatch(/from "effect"/)
}
})
})
@@ -510,9 +508,7 @@ describe("resume", () => {
)
const saved = suspendedOf(await Effect.runPromise(long.suspend))
expect(
- await Effect.runPromise(
- background(CodeMode.make({ tools: { step: step2.tool } }).resume(saved.state)).result,
- ),
+ await Effect.runPromise(background(CodeMode.make({ tools: { step: step2.tool } }).resume(saved.state)).result),
).toMatchObject({ ok: true, truncated: true })
})
@@ -538,6 +534,31 @@ describe("resume", () => {
expect(timedOut).toMatchObject({ ok: false, error: { kind: "TimeoutExceeded" }, toolCalls: [{ name: "step" }] })
})
+ test("a run started with some of the runtime's extensions resumes with the same ones, in any order", async () => {
+ const now = Extension.make({ name: "now", globals: { now: () => 7 } })
+ const later = Extension.make({ name: "later", globals: { later: () => 8 } })
+ const unused = Extension.make({ name: "unused", globals: { unused: () => 1 } })
+ const step = stepTool()
+ const runtime = CodeMode.make({ tools: { step: step.tool }, extensions: [now, later, unused] })
+ const run = background(
+ runtime.program(
+ `await tools.step({ value: 1 }); const t = Date.now(); while (Date.now() - t < 300) {} return [now(), later(), typeof unused]`,
+ undefined,
+ { extensions: [later, now] },
+ ),
+ )
+ await step.called()
+ await Bun.sleep(10)
+ const state = suspendedOf(await Effect.runPromise(run.suspend)).state
+ expect((await refusal(runtime.resume(state))).message).toMatch("saved by a runtime with other host globals")
+ expect((await refusal(runtime.resume(state, { extensions: [now] }))).message).toMatch(
+ "saved by a runtime with other host globals",
+ )
+ expect(
+ await Effect.runPromise(background(runtime.resume(state, { extensions: [now, later, now] })).result),
+ ).toMatchObject({ ok: true, value: [7, 8, "undefined"] })
+ })
+
test("a state is refused by another build, other extensions, or a changed source", async () => {
const { suspended } = await suspendAt(
`await tools.step({ value: 1 }); const t = Date.now(); while (Date.now() - t < 300) {} return 1`,
@@ -587,9 +608,7 @@ describe("resume", () => {
[extension],
)
const outcome = await Effect.runPromise(
- background(
- CodeMode.make({ tools: { step: step.tool }, extensions: [extension] }).resume(suspended.state),
- ).result,
+ background(CodeMode.make({ tools: { step: step.tool }, extensions: [extension] }).resume(suspended.state)).result,
)
expect(outcome).toMatchObject({
ok: true,
@@ -647,8 +666,7 @@ describe("resume", () => {
}`
const { step, suspended } = await suspendAt(code)
const outcome = await Effect.runPromise(
- background(CodeMode.make({ tools: { step: step.tool } }).resume(CodeMode.toBytes(suspended.state)))
- .result,
+ background(CodeMode.make({ tools: { step: step.tool } }).resume(CodeMode.toBytes(suspended.state))).result,
)
expect(outcome).toMatchObject({
ok: true,
@@ -1295,9 +1313,9 @@ describe("idempotent and durable tools", () => {
})
const toolSets: ReadonlyArray> = [{}, { job: plainTool }, { job: read.tool }]
for (const tools of toolSets) {
- expect(
- (await refusal(CodeMode.make({ tools }).resume(suspendedWhileStarted.state))).message,
- ).toContain("cannot resume because that tool is no longer a durable tool")
+ expect((await refusal(CodeMode.make({ tools }).resume(suspendedWhileStarted.state))).message).toContain(
+ "cannot resume because that tool is no longer a durable tool",
+ )
}
// Complete `job` while `read` is still running: `job` moves to the inbox with its `data` cleared.
@@ -1514,8 +1532,7 @@ describe("extension snapshot hooks", () => {
const other = Extension.make({ name: "other", globals: extension.globals, snapshot: extension.snapshot })
for (const extensions of [[], [unhooked], [other]]) {
expect(
- (await refusal(CodeMode.make({ tools: { job: jobs.tool }, extensions }).resume(suspended.state)))
- .message,
+ (await refusal(CodeMode.make({ tools: { job: jobs.tool }, extensions }).resume(suspended.state))).message,
).toBe("This state was saved by a runtime with other host globals (extensions); resume it with the same ones.")
}
})
diff --git a/packages/core/src/codemode/path.ts b/packages/core/src/codemode/path.ts
new file mode 100644
index 000000000000..d86ff1d4a797
--- /dev/null
+++ b/packages/core/src/codemode/path.ts
@@ -0,0 +1,32 @@
+export * as CodeModePath from "./path.js"
+
+import { Extension } from "@opencode/codemode"
+import { Effect, Option } from "effect"
+import path from "path"
+import { Location } from "../location.js"
+
+// Only functions and separators cross; `posix` and `win32` point back at their module, which a global can't hold, so
+// each becomes a copy of its own functions. Programs have no `process.cwd()`: the host's flavour resolves from the
+// session's directory. The other flavour can't read that directory as absolute (`C:\\proj` isn't a POSIX path), so it
+// resolves from its own root instead of falling back to the server's working directory.
+const flavor = (module: path.PlatformPath) => {
+ const { posix: _posix, win32: _win32, ...functions } = module
+ const base: Effect.Effect = module === path ? directory : Effect.succeed(module.sep)
+ return {
+ ...functions,
+ resolve: (...parts: Array) => Effect.map(base, (from) => module.resolve(from, ...parts)),
+ relative: (from: string, to: string) =>
+ Effect.map(base, (start) => module.relative(module.resolve(start, from), module.resolve(start, to))),
+ }
+}
+
+// A run gets `path` only with the session's Location (see `CodeModeTool.create`).
+const directory = Effect.flatMap(Effect.serviceOption(Location.Service), (location) =>
+ Option.isSome(location) ? Effect.succeed(location.value.directory) : Effect.die("Code Mode path needs a Location."),
+)
+
+/** The host's own path module, as Node gives it, with `path.posix` and `path.win32`. */
+export const extension = Extension.make({
+ name: "path",
+ globals: { path: { ...flavor(path), posix: flavor(path.posix), win32: flavor(path.win32) } },
+})
diff --git a/packages/core/src/codemode/tool.ts b/packages/core/src/codemode/tool.ts
index 8c757a7c3601..a4483a2d6c5b 100644
--- a/packages/core/src/codemode/tool.ts
+++ b/packages/core/src/codemode/tool.ts
@@ -16,10 +16,12 @@ import { CallID } from "@opencode/schema/tool"
import { Clock, Context, Effect, Ref, Schema, Scope, Semaphore } from "effect"
import { toSessionError } from "../session/to-session-error.js"
import { definition, normalizedName } from "../tool/runtime.js"
+import { Location } from "../location.js"
import { Permission } from "../permission.js"
import { CodeModeCatalog } from "./catalog.js"
import { CodeModeExecution } from "./execution.js"
import { CodeModeFetch } from "./fetch.js"
+import { CodeModePath } from "./path.js"
const ExecuteFile = Schema.Struct({
data: Schema.String,
@@ -88,6 +90,8 @@ export const create = (
inventory: Inventory,
executeTool: (name: string, tool: Info, input: unknown, context: ToolContext) => Effect.Effect,
permission: Permission.Interface,
+ /** With `full_codemode`, the session's Location, which turns on the experimental `path` global. */
+ location?: Location.Interface,
) => {
return {
name: "execute",
@@ -123,7 +127,9 @@ export const create = (
}),
)
const result = yield* runtime(inventory)
- .execute(code)
+ .execute(code, undefined, {
+ extensions: location ? [CodeModeFetch.extension, CodeModePath.extension] : [CodeModeFetch.extension],
+ })
.pipe(
Effect.provideService(Run, {
executeTool: (name, tool, input) =>
@@ -159,6 +165,7 @@ export const create = (
// Readers outlive the fetch call that returned them, up to the end of this program's scope.
Effect.provideService(CodeModeExecution.Service, { ...context, signal: yield* Effect.abortSignal }),
Effect.provideService(Permission.Service, permission),
+ (program) => (location ? Effect.provideService(program, Location.Service, location) : program),
)
const toolCalls = yield* Ref.get(calls)
const collected = (yield* Ref.get(files))
@@ -283,9 +290,10 @@ function runtime(inventory: Inventory) {
const cached = runtimes.get(inventory)
if (cached) return cached
const tools = inventoryTools(inventory)
- const created = CodeMode.make({
+ // Every extension a run may get; `create` picks each run's.
+ const created = CodeMode.make({
tools,
- extensions: [CodeModeFetch.extension],
+ extensions: [CodeModeFetch.extension, CodeModePath.extension],
hooks: runHooks,
})
runtimes.set(inventory, created)
diff --git a/packages/core/src/config/plugin/instruction.ts b/packages/core/src/config/plugin/instruction.ts
index d67a2239f358..ca211e894e44 100644
--- a/packages/core/src/config/plugin/instruction.ts
+++ b/packages/core/src/config/plugin/instruction.ts
@@ -39,6 +39,10 @@ export const Plugin = define({
const project = discovery.project && FSUtil.contains(root, start)
const stop = FSUtil.contains(home, start) ? home : root
const globalFile = yield* fs.resolve(join(global.config, "AGENTS.md"))
+ // ~/.claude/CLAUDE.md stands in for the global AGENTS.md when it is missing.
+ const claudeGlobalFile = yield* fs.resolve(join(home, ".claude", "CLAUDE.md"))
+ const names = InstructionDiscovery.filenames(discovery)
+ const globalFiles = discovery.claudeGlobal ? [globalFile, claudeGlobalFile] : [globalFile]
const loaded: { current: Loaded } = { current: { type: "available", files: [] } }
const configured: { sources: string[]; remote: Map } = {
sources: [],
@@ -49,11 +53,11 @@ export const Plugin = define({
// The ancestor walk can reach the global file when the location sits
// beneath the global config dir; global: false excludes it there too.
const candidates = [
- ...(discovery.global ? [globalFile] : []),
+ ...(discovery.global ? globalFiles : []),
...(project
? ancestorDirectories(start, stop)
- .map((directory) => join(directory, "AGENTS.md"))
- .filter((file) => discovery.global || file !== globalFile)
+ .flatMap((directory) => names.map((name) => join(directory, name)))
+ .filter((file) => discovery.global || !globalFiles.includes(file))
: []),
]
for (const file of new Set(candidates)) {
@@ -76,18 +80,20 @@ export const Plugin = define({
})
const globalSource = Effect.fn("ConfigInstructionPlugin.globalSource")(function* () {
- if (!discovery.global || !(yield* fs.isFile(globalFile))) return []
- const file = yield* read(globalFile)
- return file instanceof InstructionDiscovery.File ? [file] : []
+ if (!discovery.global) return []
+ for (const candidate of globalFiles) {
+ if (!(yield* fs.isFile(candidate))) continue
+ const file = yield* read(candidate)
+ return file instanceof InstructionDiscovery.File ? [file] : []
+ }
+ return []
})
const projectSource = Effect.fn("ConfigInstructionPlugin.projectSource")(function* () {
if (!project) return []
- const walked = yield* Effect.forEach(
- yield* fs.up({ targets: ["AGENTS.md"], start, stop, type: "file" }),
- fs.resolve,
- )
- const discovered = new Set(walked.filter((file) => discovery.global || file !== globalFile))
+ const found = yield* fs.up({ targets: names, start, stop, type: "file" })
+ const walked = yield* Effect.forEach(InstructionDiscovery.preferAgents(found), fs.resolve)
+ const discovered = new Set(walked.filter((file) => discovery.global || !globalFiles.includes(file)))
const files = yield* Effect.forEach(discovered, read, { concurrency: "unbounded" })
if (files.some((file) => file === undefined)) return Instructions.unavailable
return files.filter((file) => file instanceof InstructionDiscovery.File)
diff --git a/packages/core/src/instruction-discovery.ts b/packages/core/src/instruction-discovery.ts
index 1bf4a5a0aaf6..de826cb94612 100644
--- a/packages/core/src/instruction-discovery.ts
+++ b/packages/core/src/instruction-discovery.ts
@@ -3,6 +3,7 @@ export * as InstructionDiscovery from "./instruction-discovery.js"
import { Context, Effect, Layer, Schema, Types } from "effect"
import { makeLocationNode } from "@opencode/util/effect/app-node"
import { createPatch } from "diff"
+import { basename, dirname, join } from "path"
import { Bus } from "./bus.js"
import { Instructions } from "./instructions/index.js"
import { State } from "./state.js"
@@ -40,6 +41,10 @@ export interface Interface extends State.Transformable {
// Move it into plugin config once plugins can consume their own options.
readonly project: boolean
readonly global: boolean
+ // Also read CLAUDE.md where no AGENTS.md exists.
+ readonly claude: boolean
+ // Read ~/.claude/CLAUDE.md when the global AGENTS.md is missing.
+ readonly claudeGlobal: boolean
readonly list: () => Effect.Effect
readonly load: () => Effect.Effect
}
@@ -47,6 +52,8 @@ export interface Interface extends State.Transformable {
export const Options = Schema.Struct({
project: Schema.optional(Schema.Boolean),
global: Schema.optional(Schema.Boolean),
+ claude: Schema.optional(Schema.Boolean),
+ claudeGlobal: Schema.optional(Schema.Boolean),
})
export type Options = typeof Options.Type
@@ -98,6 +105,8 @@ export const layer = (options?: Options) =>
return Service.of({
project: options?.project !== false,
global: options?.global !== false,
+ claude: options?.claude !== false,
+ claudeGlobal: options?.claudeGlobal !== false,
transform: state.transform,
reload: state.reload,
list,
@@ -120,6 +129,16 @@ export function configured(options?: Options) {
export const node = configured()
+// CLAUDE.md stands in for AGENTS.md in a directory that has none.
+export function filenames(discovery: Pick) {
+ return discovery.claude ? ["AGENTS.md", "CLAUDE.md"] : ["AGENTS.md"]
+}
+
+/** Drops each CLAUDE.md whose directory also has an AGENTS.md among `found`. */
+export function preferAgents(found: readonly string[]) {
+ return found.filter((file) => basename(file) !== "CLAUDE.md" || !found.includes(join(dirname(file), "AGENTS.md")))
+}
+
function render(files: ReadonlyArray) {
return files.map((file) => `Instructions from: ${file.path}\n${file.content}`).join("\n\n")
}
diff --git a/packages/core/src/session/context.ts b/packages/core/src/session/context.ts
index 424c86a1b146..489d31ac8649 100644
--- a/packages/core/src/session/context.ts
+++ b/packages/core/src/session/context.ts
@@ -152,7 +152,7 @@ const layer = Layer.effect(
const permissions = Permission.merge(agent.info.permissions, session.permissions ?? [])
const loaded = yield* Effect.all(
{
- tools: registry.snapshot(permissions),
+ tools: registry.snapshot(permissions, location),
builtins: builtins.load(),
discovery: discovery.load(),
skills: skillInstructions.load(permissions),
diff --git a/packages/core/src/tool.ts b/packages/core/src/tool.ts
index 1dd64796bfb5..04de7d8752b0 100644
--- a/packages/core/src/tool.ts
+++ b/packages/core/src/tool.ts
@@ -11,7 +11,9 @@ import type { Agent } from "./agent.js"
import { CodeModeCatalog } from "./codemode/catalog.js"
import { CodeModeJob } from "./codemode/job.js"
import { CodeModeTool } from "./codemode/tool.js"
+import { Flag } from "./flag.js"
import { Image } from "./image.js"
+import type { Location } from "./location.js"
import { Permission } from "./permission.js"
import { PluginHooks } from "./plugin/hooks.js"
import { SessionMessage } from "./session/message.js"
@@ -44,7 +46,8 @@ type Data = {
export interface Interface extends State.Transformable {
readonly list: () => Effect.Effect>
- readonly snapshot: (permissions?: Permission.Ruleset) => Effect.Effect
+ /** With `full_codemode`, Code Mode gets the experimental `path` global, resolving against `location`'s directory. */
+ readonly snapshot: (permissions?: Permission.Ruleset, location?: Location.Interface) => Effect.Effect
/**
* Runs a Code Mode program with no model step over only the Code Mode tools named in `tools` (still subject to
* whole-tool permission filtering and each tool's own executor policy), with no `fetch`.
@@ -90,6 +93,7 @@ const layer = Layer.effect(
const hooks = yield* PluginHooks.Service
const image = yield* Image.Service
const permission = yield* Permission.Service
+ const flags = yield* Flag.Service
type NormalizedItem = Tool.Content | "decode" | "size"
const normalizeImages = Effect.fnUntraced(function* (content: ReadonlyArray) {
@@ -200,6 +204,7 @@ const layer = Layer.effect(
| {
data: Data
names: string
+ path: boolean
inventory: CodeModeTool.Inventory
value: CodeModeCatalog.Inventory
definition: ToolDefinition
@@ -263,8 +268,9 @@ const layer = Layer.effect(
transform: state.transform,
reload: state.reload,
list: () => Effect.sync(() => Array.from(state.get().tools.values())),
- snapshot: Effect.fn("Tool.snapshot")((permissions) =>
- Effect.sync(() => {
+ snapshot: Effect.fn("Tool.snapshot")((permissions, location) =>
+ Effect.map(flags.enabled("full_codemode"), (enabled) => {
+ const path = enabled && location !== undefined
const data = state.get()
const active = new Map()
const rules = permissions ?? []
@@ -282,13 +288,15 @@ const layer = Layer.effect(
// Discovery is immutable for a registry revision and visible tool set. Keep executors
// fresh, but share the inventory, whose prepared runtime and much larger rendered catalog
// are cached by identity, and the execute tool's definition across steps.
- const cached = catalog?.data === data && catalog.names === names ? catalog : undefined
+ const cached =
+ catalog?.data === data && catalog.names === names && catalog.path === path ? catalog : undefined
const codeModeInventory = cached?.inventory ?? { tools: codeModeTools, namespaces: data.namespaces }
const codeModeTool = codeModeEnabled
? CodeModeTool.create(
codeModeInventory,
(name, tool, input, context) => run(codeModeInventory.tools, tool, name, input, context),
permission,
+ path ? location : undefined,
)
: undefined
const codeModeCatalog = !codeModeEnabled
@@ -299,6 +307,7 @@ const layer = Layer.effect(
catalog = {
data,
names,
+ path,
inventory: codeModeInventory,
value: codeModeCatalog,
definition: codeModeDefinition,
@@ -441,5 +450,5 @@ function namespaceError(name: string) {
export const node = makeLocationNode({
service: Service,
layer,
- deps: [PluginHooks.node, Image.node, Permission.node],
+ deps: [PluginHooks.node, Image.node, Permission.node, Flag.node],
})
diff --git a/packages/core/src/tool/plugin/read.ts b/packages/core/src/tool/plugin/read.ts
index ac13348c313e..e85490bd75d7 100644
--- a/packages/core/src/tool/plugin/read.ts
+++ b/packages/core/src/tool/plugin/read.ts
@@ -10,6 +10,7 @@ import { ConfigEntryObserver } from "../../config/plugin/entry-observer.js"
import { Flag } from "../../flag.js"
import { Location } from "../../location.js"
import { FileAccess } from "../../file-access.js"
+import { InstructionDiscovery } from "../../instruction-discovery.js"
import { Permission } from "../../permission.js"
import { SessionInstructions } from "../../session/instructions.js"
import { AbsolutePath } from "../../schema.js"
@@ -19,7 +20,6 @@ import { ReadToolFileSystem } from "../read-filesystem.js"
import { Environment } from "../../environment/index.js"
export const name = "read"
-const FILENAME = "AGENTS.md"
const LocationInput = Schema.Struct({
path: Schema.String.annotate({ description: "File or directory to read" }),
offset: ReadToolFileSystem.PageInput.fields.offset.annotate({
@@ -46,6 +46,7 @@ export const Plugin = {
const config = yield* Config.Service
const loaded = yield* ConfigEntryObserver.observe(config, ctx.event, ctx.tool.reload())
const flags = yield* Flag.Service
+ const discovery = yield* InstructionDiscovery.Service
yield* ctx.tool
.transform((editor) => {
@@ -68,8 +69,7 @@ export const Plugin = {
output: ReadToolFileSystem.Output,
execute: (input, context) => {
return Effect.gen(function* () {
- if (input.limit === 0)
- return yield* new ToolFailure({ message: "Limit must be a positive integer" })
+ if (input.limit === 0) return yield* new ToolFailure({ message: "Limit must be a positive integer" })
if (Skill.isUri(input.path)) {
const parsed = parseSkillUri(input.path)
if (!parsed) return yield* new ToolFailure({ message: `File not found: ${input.path}` })
@@ -143,7 +143,7 @@ export const Plugin = {
}),
),
)
- // After a successful read, discover nearby AGENTS.md walking up to the Location
+ // After a successful read, discover nearby AGENTS.md (or CLAUDE.md) walking up to the Location
// root exclusive and inject them as durable synthetic instructions. For a
// directory listing the walk starts at the directory itself (so its own AGENTS.md
// is discovered); for a file it starts at the file's dirname. External reads are
@@ -155,14 +155,15 @@ export const Plugin = {
// The Location and its ancestors are already supplied by initial instructions,
// even when an upward walk from elsewhere in the project cannot reach root.
const discovered = yield* fs.up({
- targets: [FILENAME],
+ targets: InstructionDiscovery.filenames(discovery),
start: result.content.type === "directory" ? resolved : dirname(resolved),
stop: root,
type: "file",
})
- const candidates = (yield* Effect.forEach(discovered, fs.resolve)).filter(
- (file) => !FSUtil.contains(dirname(file), root) && file !== resolved,
- )
+ const candidates = (yield* Effect.forEach(
+ InstructionDiscovery.preferAgents(discovered),
+ fs.resolve,
+ )).filter((file) => !FSUtil.contains(dirname(file), root) && file !== resolved)
if (candidates.length === 0) return
yield* sessionInstructions.load({ sessionID: context.sessionID, paths: candidates })
}).pipe(
diff --git a/packages/core/test/instruction-discovery.test.ts b/packages/core/test/instruction-discovery.test.ts
index 8e39c46102cc..ed69a80d15aa 100644
--- a/packages/core/test/instruction-discovery.test.ts
+++ b/packages/core/test/instruction-discovery.test.ts
@@ -33,6 +33,8 @@ const instructionLayer = (input: {
instructions?: string[]
http?: HttpClient.HttpClient
project?: boolean
+ claude?: boolean
+ claudeGlobal?: boolean
}) => {
const watcher = Watcher.testLayer
const config = Config.testLayer(input.instructions ? [configured(input.instructions)] : [])
@@ -49,7 +51,13 @@ const instructionLayer = (input: {
]),
[
Config.node.replace(config),
- InstructionDiscovery.node.replace(InstructionDiscovery.configured({ project: input.project })),
+ InstructionDiscovery.node.replace(
+ InstructionDiscovery.configured({
+ project: input.project,
+ claude: input.claude,
+ claudeGlobal: input.claudeGlobal,
+ }),
+ ),
Global.node.replace(
input.config || input.home
? Global.layerWith({
@@ -223,11 +231,17 @@ describe("ConfigInstructionPlugin.Plugin", () => {
const watcher = yield* Watcher.Test
expect(yield* watcher.subscriptions()).toEqual([
{ path: globalFile, type: "file" },
+ { path: path.join(home, ".claude", "CLAUDE.md"), type: "file" },
{ path: packageFile, type: "file" },
+ { path: path.join(directory, "CLAUDE.md"), type: "file" },
{ path: path.join(project, "packages", "AGENTS.md"), type: "file" },
+ { path: path.join(project, "packages", "CLAUDE.md"), type: "file" },
{ path: projectFile, type: "file" },
+ { path: path.join(project, "CLAUDE.md"), type: "file" },
{ path: sharedFile, type: "file" },
+ { path: path.join(shared, "CLAUDE.md"), type: "file" },
{ path: path.join(home, "AGENTS.md"), type: "file" },
+ { path: path.join(home, "CLAUDE.md"), type: "file" },
])
expect(yield* watcher.subscriptions()).not.toContainEqual({
path: path.join(tmp.path, "AGENTS.md"),
@@ -415,6 +429,72 @@ describe("ConfigInstructionPlugin.Plugin", () => {
),
)
+ it.live("falls back to CLAUDE.md where no AGENTS.md exists", () =>
+ tmpdirScoped().pipe(
+ Effect.flatMap((tmp) => {
+ const global = path.join(tmp.path, "global")
+ const home = path.join(tmp.path, "home")
+ const project = path.join(home, "repo")
+ const directory = path.join(project, "packages", "core")
+ const claudeGlobal = path.join(home, ".claude", "CLAUDE.md")
+ const projectAgents = path.join(project, "AGENTS.md")
+ const packageClaude = path.join(directory, "CLAUDE.md")
+ const load = (options: { claude?: boolean; claudeGlobal?: boolean } = {}) =>
+ Effect.gen(function* () {
+ const discovery = yield* start()
+ return (yield* readInitial(yield* discovery.load())).text
+ }).pipe(Effect.provide(layer(options)), Effect.scoped)
+ const layer = (options: { claude?: boolean; claudeGlobal?: boolean }) =>
+ instructionLayer({
+ config: global,
+ home,
+ ...options,
+ locationServiceLayer: Layer.succeed(
+ Location.Service,
+ Location.Service.of(
+ location({ directory: AbsolutePath.make(directory) }, { projectDirectory: AbsolutePath.make(project) }),
+ ),
+ ),
+ })
+ return Effect.gen(function* () {
+ yield* Effect.promise(async () => {
+ await fs.mkdir(path.dirname(claudeGlobal), { recursive: true })
+ await fs.mkdir(directory, { recursive: true })
+ await fs.writeFile(claudeGlobal, "claude global")
+ await fs.writeFile(projectAgents, "project agents")
+ await fs.writeFile(path.join(project, "CLAUDE.md"), "project claude")
+ await fs.writeFile(packageClaude, "package claude")
+ })
+
+ expect(yield* load()).toBe(
+ [
+ `Instructions from: ${claudeGlobal}\nclaude global`,
+ `Instructions from: ${packageClaude}\npackage claude`,
+ `Instructions from: ${projectAgents}\nproject agents`,
+ ].join("\n\n"),
+ )
+
+ // The prompt flag only drops the global fallback, as in V1.
+ const withoutGlobal = yield* load({ claudeGlobal: false })
+ expect(withoutGlobal).not.toContain("claude global")
+ expect(withoutGlobal).toContain(`Instructions from: ${packageClaude}\npackage claude`)
+
+ yield* Effect.promise(async () => {
+ await fs.mkdir(global, { recursive: true })
+ await fs.writeFile(path.join(global, "AGENTS.md"), "global agents")
+ })
+ const preferred = yield* load()
+ expect(preferred).toContain(`Instructions from: ${path.join(global, "AGENTS.md")}\nglobal agents`)
+ expect(preferred).not.toContain("claude global")
+
+ const disabled = yield* load({ claude: false, claudeGlobal: false })
+ expect(disabled).not.toContain("CLAUDE.md")
+ expect(disabled).toContain(`Instructions from: ${projectAgents}\nproject agents`)
+ })
+ }),
+ ),
+ )
+
it.live("keeps an empty AGENTS.md as available context", () =>
tmpdirScoped().pipe(
Effect.flatMap((tmp) =>
@@ -495,9 +575,13 @@ describe("ConfigInstructionPlugin.Plugin", () => {
const watcher = yield* Watcher.Test
expect(yield* watcher.subscriptions()).toEqual([
{ path: path.join(global, "AGENTS.md"), type: "file" },
+ { path: path.join(home, ".claude", "CLAUDE.md"), type: "file" },
{ path: path.join(directory, "AGENTS.md"), type: "file" },
+ { path: path.join(directory, "CLAUDE.md"), type: "file" },
{ path: path.join(project, "packages", "AGENTS.md"), type: "file" },
+ { path: path.join(project, "packages", "CLAUDE.md"), type: "file" },
{ path: path.join(project, "AGENTS.md"), type: "file" },
+ { path: path.join(project, "CLAUDE.md"), type: "file" },
])
}).pipe(
Effect.provide(
@@ -719,7 +803,7 @@ describe("ConfigInstructionPlugin.Plugin", () => {
)
const repo = path.resolve("/repo")
- expect(observed.values).toEqual([{ targets: ["AGENTS.md"], start: repo, stop: repo, type: "file" }])
+ expect(observed.values).toEqual([{ targets: ["AGENTS.md", "CLAUDE.md"], start: repo, stop: repo, type: "file" }])
}),
)
})
diff --git a/packages/core/test/session-generate.test.ts b/packages/core/test/session-generate.test.ts
index f9800330c032..4a901bc4e6c5 100644
--- a/packages/core/test/session-generate.test.ts
+++ b/packages/core/test/session-generate.test.ts
@@ -127,6 +127,8 @@ const builtins = Layer.mock(InstructionBuiltIns.Service, {
const discovery = Layer.mock(InstructionDiscovery.Service, {
project: true,
global: true,
+ claude: true,
+ claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skills = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
diff --git a/packages/core/test/session-instructions.test.ts b/packages/core/test/session-instructions.test.ts
index 6363fb8ae730..938a55577e3e 100644
--- a/packages/core/test/session-instructions.test.ts
+++ b/packages/core/test/session-instructions.test.ts
@@ -14,6 +14,7 @@ import { Global } from "@opencode/util/global"
import { Image } from "@opencode/core/image"
import { Location } from "@opencode/core/location"
import { FileAccess } from "@opencode/core/file-access"
+import { InstructionDiscovery } from "@opencode/core/instruction-discovery"
import { Environment } from "@opencode/core/environment/index"
import { Model } from "@opencode/core/model"
import { Permission } from "@opencode/core/permission"
@@ -50,6 +51,7 @@ const readToolNode = makeLocationNode({
Image.node,
Permission.node,
SessionInstructions.node,
+ InstructionDiscovery.node,
Skill.node,
FSUtil.node,
Environment.node,
@@ -196,6 +198,31 @@ describe("SessionInstructions", () => {
}),
)
+ it.live("falls back to CLAUDE.md above a read where a directory has no AGENTS.md", () =>
+ Effect.gen(function* () {
+ const location = yield* Location.Service
+ const dir = location.directory
+ const subAgents = path.resolve(dir, "sub", "AGENTS.md")
+ const deepClaude = path.resolve(dir, "sub", "deep", "CLAUDE.md")
+ yield* mkdir(path.resolve(dir, "sub", "deep"))
+ yield* writeAgents(subAgents, "sub-agents")
+ yield* writeAgents(path.resolve(dir, "sub", "CLAUDE.md"), "sub-claude")
+ yield* writeAgents(deepClaude, "deep-claude")
+ yield* Effect.promise(() => fs.writeFile(path.resolve(dir, "sub", "deep", "file.txt"), "content"))
+
+ const session = yield* Session.Service
+ const registry = yield* Tool.Service
+ const sessionID = (yield* session.create({ location: Location.Ref.make({ directory: dir }) })).id
+ yield* executeTool(registry, readCall(sessionID, "call-deep", "sub/deep/file.txt"))
+
+ const injected = yield* synthetics(sessionID)
+ expect(injected).toHaveLength(1)
+ expect(injected[0]!.text).toBe(
+ `Instructions from: ${deepClaude}\ndeep-claude\n\nInstructions from: ${subAgents}\nsub-agents`,
+ )
+ }),
+ )
+
it.live("does not re-inject paths already recorded in durable session history", () =>
Effect.gen(function* () {
const location = yield* Location.Service
diff --git a/packages/core/test/session-runner-recorded.test.ts b/packages/core/test/session-runner-recorded.test.ts
index 2c2d3894239e..e35f07efb32b 100644
--- a/packages/core/test/session-runner-recorded.test.ts
+++ b/packages/core/test/session-runner-recorded.test.ts
@@ -79,6 +79,8 @@ const systemContext = Layer.mock(InstructionBuiltIns.Service, { load: () => Effe
const instructionContext = Layer.mock(InstructionDiscovery.Service, {
project: true,
global: true,
+ claude: true,
+ claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skillInstructions = Layer.mock(SkillInstructions.Service, { load: () => Effect.succeed(Instructions.empty) })
diff --git a/packages/core/test/session-runner.test.ts b/packages/core/test/session-runner.test.ts
index 242512f382e6..624de615c261 100644
--- a/packages/core/test/session-runner.test.ts
+++ b/packages/core/test/session-runner.test.ts
@@ -414,6 +414,8 @@ const layer = Layer.unwrap(
const instructionContext = Layer.mock(InstructionDiscovery.Service, {
project: true,
global: true,
+ claude: true,
+ claudeGlobal: true,
load: () => Effect.succeed(Instructions.empty),
})
const skillInstructions = Layer.mock(SkillInstructions.Service, {
diff --git a/packages/core/test/tool-execute.test.ts b/packages/core/test/tool-execute.test.ts
index 05023200b082..6af0132eb6e9 100644
--- a/packages/core/test/tool-execute.test.ts
+++ b/packages/core/test/tool-execute.test.ts
@@ -1,5 +1,7 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test"
+import path from "path"
import { CodeModeTool } from "@opencode/core/codemode/tool"
+import { AbsolutePath } from "@opencode/core/schema"
import { Permission } from "@opencode/core/permission"
import { Tool } from "@opencode/core/tool"
import { execute } from "@opencode/core/tool/runtime"
@@ -9,6 +11,7 @@ import { SessionMessage } from "@opencode/schema/session-message"
import type { Info } from "@opencode/schema/tool"
import { Deferred, Effect, Fiber, Schema } from "effect"
import { TestClock } from "effect/testing"
+import { location } from "./fixture/location"
import { it } from "./lib/effect"
import { permissionService } from "./lib/permission"
@@ -152,6 +155,46 @@ test("execute rejects filesystem fetches", async () => {
expect(result.output.output).toContain("fetch cannot be used for filesystem access.")
})
+describe("path", () => {
+ const directory = AbsolutePath.make(path.resolve("/session/dir"))
+ const withPath = () =>
+ CodeModeTool.create(
+ { tools: new Map() },
+ (_, tool, input, context) => execute(tool, input, context),
+ allowAll,
+ location({ directory }),
+ )
+ const run = async (code: string, codeMode = withPath()) =>
+ JSON.parse((await Effect.runPromise(codeMode.execute({ code }, context))).output.output)
+
+ test("without the experimental flag there is no path", async () => {
+ expect(await run("return [typeof path]", createCodeMode(new Map()))).toEqual(["undefined"])
+ })
+
+ test("path is the host's path module, resolving against the session's directory", async () => {
+ expect(
+ await run(
+ `return [path.resolve("a", "b"), path.relative("a", "c"), path.join("out", "..", "x.txt"), path.basename("/a/b.ts", ".ts"), path.posix.join("a", "b"), path.win32.join("a", "b"), path.sep]`,
+ ),
+ ).toEqual([path.resolve(directory, "a", "b"), path.join("..", "c"), "x.txt", "b", "a/b", "a\\b", path.sep])
+ })
+
+ test("the other platform's flavour resolves from its own root, not the server's working directory", async () => {
+ const other = path.sep === "/" ? "win32" : "posix"
+ const [resolved] = await run(`return [path.${other}.resolve("a")]`)
+ expect(resolved).toBe(path[other].resolve(path[other].sep, "a"))
+ expect(resolved).not.toContain(process.cwd())
+ })
+
+ test("path is importable by its Node module names", async () => {
+ expect(
+ await run(`import { join } from "node:path"
+ const posix = require("path").posix
+ return [join("a", "b"), posix.dirname("a/b")]`),
+ ).toEqual([path.join("a", "b"), "a"])
+ })
+})
+
describe("execute output", () => {
const run = async (code: string) =>
(await Effect.runPromise(createCodeMode(new Map()).execute({ code }, context))).output.output
diff --git a/packages/core/test/tool-read.test.ts b/packages/core/test/tool-read.test.ts
index c19a4e642aaa..7bdaa54b4bac 100644
--- a/packages/core/test/tool-read.test.ts
+++ b/packages/core/test/tool-read.test.ts
@@ -15,6 +15,7 @@ import { Skill } from "@opencode/core/skill"
import { AbsolutePath } from "@opencode/core/schema"
import { Global } from "@opencode/util/global"
import { FileAccess } from "@opencode/core/file-access"
+import { InstructionDiscovery } from "@opencode/core/instruction-discovery"
import { Flag } from "@opencode/core/flag"
import { hostEnvironmentLayer } from "./fixture/environment"
import { location } from "./fixture/location"
@@ -39,6 +40,7 @@ const readToolNode = makeLocationNode({
Image.node,
Permission.node,
SessionInstructions.node,
+ InstructionDiscovery.node,
Skill.node,
FSUtil.node,
Environment.node,
@@ -831,9 +833,10 @@ describe("ReadTool", () => {
)
expect(yield* readMissing(tmp.path, "short/ui.ts")).toBe("File not found: short/ui.ts")
// Case-insensitive filesystems, such as macOS by default, simply read the file.
- expect([undefined, `File not found: case/readme.md\n\nDid you mean one of these?\n${path.join("case", "README.md")}`]).toContain(
- yield* readMissing(tmp.path, "case/readme.md"),
- )
+ expect([
+ undefined,
+ `File not found: case/readme.md\n\nDid you mean one of these?\n${path.join("case", "README.md")}`,
+ ]).toContain(yield* readMissing(tmp.path, "case/readme.md"))
}),
),
)
diff --git a/packages/core/test/tool-registry.test.ts b/packages/core/test/tool-registry.test.ts
index 755ad4e7872a..110afd5f1fa9 100644
--- a/packages/core/test/tool-registry.test.ts
+++ b/packages/core/test/tool-registry.test.ts
@@ -1,6 +1,8 @@
import { describe, expect } from "bun:test"
import { Agent } from "@opencode/core/agent"
import { Permission } from "@opencode/core/permission"
+import { Flag } from "@opencode/core/flag"
+import { AbsolutePath } from "@opencode/core/schema"
import { AppNodeBuilder } from "@opencode/core/effect/app-node-builder"
import { Image } from "@opencode/core/image"
import { PluginHooks } from "@opencode/core/plugin/hooks"
@@ -14,6 +16,7 @@ import { codeModeListings, executeTool, toolDefinitions, toolNodeReplacements }
import { Deferred, Effect, Exit, Fiber, Layer, Logger, Schema, SchemaGetter, SchemaIssue, Scope } from "effect"
import { z } from "zod"
import { testEffect } from "./lib/effect"
+import { location } from "./fixture/location"
const imageStore = Layer.mock(Image.Service, {
normalize: (resource, content) => {
@@ -42,6 +45,7 @@ const registryLayer = AppNodeBuilder.build(LayerNode.group([Tool.node, PluginHoo
Image.node.replace(imageStore),
])
const it = testEffect(registryLayer)
+const codeModeIt = testEffect(registryLayer.pipe(Layer.provide(Layer.succeed(Flag.Overrides, "full_codemode"))))
const identity = {
agent: Agent.ID.make("build"),
messageID: SessionMessage.ID.make("msg_registry"),
@@ -74,6 +78,31 @@ const transform = (service: Tool.Interface, tools: Readonly
Object.entries(tools).forEach(([name, tool]) => editor.add({ ...tool, name, options: options ?? tool.options })),
)
+describe("Code Mode path", () => {
+ const session = location({ directory: AbsolutePath.make("/session/dir") })
+ const typeOfPath = Effect.gen(function* () {
+ const tools = yield* Tool.Service
+ const snapshot = yield* tools.snapshot(undefined, session)
+ const result = yield* snapshot.execute({
+ ...call("execute"),
+ call: { type: "tool-call", id: "call-path", name: "execute", input: { code: `return [typeof path]` } },
+ })
+ return JSON.parse(result.output.output)
+ })
+
+ it.effect("is not available without full_codemode", () =>
+ Effect.gen(function* () {
+ expect(yield* typeOfPath).toEqual(["undefined"])
+ }),
+ )
+
+ codeModeIt.effect("is available with full_codemode", () =>
+ Effect.gen(function* () {
+ expect(yield* typeOfPath).toEqual(["object"])
+ }),
+ )
+})
+
describe("Tool", () => {
it.effect("reads the current editor tools by effective name", () =>
Effect.gen(function* () {
diff --git a/packages/gui-plugins/src/pairing/dialog.stories.tsx b/packages/gui-plugins/src/pairing/dialog.stories.tsx
index addccef5bf86..67450b1b916e 100644
--- a/packages/gui-plugins/src/pairing/dialog.stories.tsx
+++ b/packages/gui-plugins/src/pairing/dialog.stories.tsx
@@ -1,49 +1,69 @@
-import { onMount } from "solid-js"
+import { createSignal, onMount } from "solid-js"
import { PairingHost, pairingRemote } from "../../../stories/mocks/gui-plugins/pairing"
import PairingPage from "./page"
-function PairingDialogStory(props: {
- mode: "ready" | "pending" | "failed"
- response?: "Code request fails" | "Copy fails"
-}) {
- const mock = pairingRemote({
- enabled: props.mode === "ready",
- response: props.mode === "failed" ? "Remote change fails" : props.response,
- })
+type Preset = Parameters[0] & { holdSetup?: boolean }
+
+function PairingDialogStory(props: { preset: Preset; localServer: boolean }) {
+ const mock = pairingRemote(props.preset)
- const client = {
- ...mock.client,
- setRemote: (...args: Parameters) => {
- if (props.mode === "pending") return new Promise(() => {})
+ const client = props.preset.holdSetup
+ ? { ...mock.client, setRemote: () => new Promise(() => {}) }
+ : mock.client
- return mock.client.setRemote(...args)
- },
- }
+ const [opened, setOpened] = createSignal(false)
let root!: HTMLDivElement
- onMount(() => root.getElementsByTagName("button")[0].click())
+ onMount(() => {
+ root.getElementsByTagName("button")[0].click()
+ // Pair device needs the server to open. Once open, the dialog follows its loss and return.
+ setOpened(true)
+ })
return (
-
mock.server} pairing={() => ({ status: "active", value: client, generation: 1 })} />
+ (!opened() || props.localServer ? mock.server : undefined)}
+ pairing={() => ({ status: "active", value: client, generation: 1 })}
+ />
)
}
+const story = (preset: Preset, args?: { localServer: boolean }) => ({
+ args,
+ render: (props: { localServer: boolean }) => ,
+})
+
export default {
title: "App/Dialogs/Pair Device",
id: "app-dialog-pair-device",
+ args: { localServer: true },
}
-export const Ready = { render: () => }
+export const Ready = story({ enabled: true })
+
+export const SettingUp = story({ enabled: false, holdSetup: true })
+
+/** Turns on remote access and waits for the tunnel to connect before the first code arrives. */
+export const FirstPairing = story({ enabled: false, response: "Tunnel connects slowly" })
+
+/** Try again turns remote access on after the first attempt fails. */
+export const Failed = story({ enabled: false, response: "Remote change fails" })
+
+export const Unavailable = story({ enabled: true }, { localServer: false })
+
+/** The first request shows the code loader. Refresh code keeps the previous QR visible until its replacement arrives. */
+export const GeneratingCode = story({ enabled: true, response: "Code arrives slowly" })
-export const SettingUp = { render: () => }
+export const CodeRequestFailed = story({ enabled: true, response: "Code request fails" })
-export const Failed = { render: () => }
+/** Refresh code fails once, then the same action fetches a replacement from the error state. */
+export const RefreshFailsOnce = story({ enabled: true, response: "Code refresh fails" })
-export const CodeRequestFailed = { render: () => }
+export const ExpiringCode = story({ enabled: true, expiresIn: 5 })
-export const CopyFailsOnce = { render: () => }
+export const CopyFailsOnce = story({ enabled: true, response: "Copy fails" })
diff --git a/packages/server/src/options.ts b/packages/server/src/options.ts
index 483406d8bfab..0381dad9694a 100644
--- a/packages/server/src/options.ts
+++ b/packages/server/src/options.ts
@@ -40,6 +40,14 @@ export const ServerOptions = Schema.Struct({
content: Schema.optional(Schema.String),
}),
),
+ instructions: Schema.optional(
+ Schema.Struct({
+ // false skips the per-directory CLAUDE.md fallback.
+ claude: Schema.optional(Schema.Boolean),
+ // false skips the ~/.claude/CLAUDE.md fallback.
+ claudeGlobal: Schema.optional(Schema.Boolean),
+ }),
+ ),
windows: Schema.optional(
Schema.Struct({
gitbash: Schema.optional(Schema.String),
diff --git a/packages/server/src/routes.ts b/packages/server/src/routes.ts
index 0d6108ab323f..41630d5862db 100644
--- a/packages/server/src/routes.ts
+++ b/packages/server/src/routes.ts
@@ -153,7 +153,13 @@ function makeRoutes(
content: options.config?.content,
}),
),
- InstructionDiscovery.node.replace(InstructionDiscovery.configured({ project: options.config?.project })),
+ InstructionDiscovery.node.replace(
+ InstructionDiscovery.configured({
+ project: options.config?.project,
+ claude: options.instructions?.claude,
+ claudeGlobal: options.instructions?.claudeGlobal,
+ }),
+ ),
ShellSelect.node.replace(ShellSelect.configured({ gitbash: options.windows?.gitbash })),
Mcp.node.replace(
Mcp.configured({
diff --git a/packages/session-ui/component-tests/session-timeline-mobile.spec.ts b/packages/session-ui/component-tests/session-timeline-mobile.spec.ts
index 2953d367c8f6..9b542e316134 100644
--- a/packages/session-ui/component-tests/session-timeline-mobile.spec.ts
+++ b/packages/session-ui/component-tests/session-timeline-mobile.spec.ts
@@ -98,49 +98,66 @@ story.describe("touch timeline", () => {
})
})
-story("desktop message actions still appear on hover and keyboard focus", async ({ mount, page }) => {
+story("desktop user message actions still appear on hover and keyboard focus", async ({ mount, page }) => {
const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "interruption" } })
expect(await page.evaluate(() => matchMedia("(hover: hover)").matches)).toBe(true)
- for (const action of [
- { slot: "user-message-menu", name: "More actions" },
- { slot: "text-part-copy-wrapper", name: "Copy response" },
- ]) {
- const actions = timeline.locator(`[data-slot="${action.slot}"]`)
- await expect(actions).toHaveCount(1)
- await expect(actions).toHaveCSS("opacity", "0")
- await expect(actions).toHaveCSS("pointer-events", "none")
- await actions.locator("..").hover()
- await expect(actions).toHaveCSS("opacity", "1")
- await expect(actions).toHaveCSS("pointer-events", "auto")
-
- if (action.slot === "text-part-copy-wrapper") {
- await expect(actions).toHaveCSS("height", "20px")
- await expect(actions).toHaveCSS("margin-top", "8px")
- await expect(actions).toHaveCSS("gap", "4px")
- const meta = actions.locator('[data-slot="text-part-meta"]')
- await expect(meta).toHaveCSS("font-size", "12px")
- await expect(meta).toHaveCSS("line-height", "18px")
- await expect(meta).toHaveCSS("gap", "4px")
- await expect(meta.locator('[data-slot="text-part-meta-item"]')).toHaveText(["Build", "Claude Sonnet 4", "4s"])
- const separators = meta.locator('[data-slot="text-part-meta-separator"]')
- await expect(separators).toHaveCount(2)
-
- for (const separator of await separators.all()) {
- await expect(separator).toHaveText("\u00B7")
- }
+ const actions = timeline.locator('[data-slot="user-message-menu"]')
+ await expect(actions).toHaveCount(1)
+ await expect(actions).toHaveCSS("opacity", "0")
+ await expect(actions).toHaveCSS("pointer-events", "none")
+ await actions.locator("..").hover()
+ await expect(actions).toHaveCSS("opacity", "1")
+ await expect(actions).toHaveCSS("pointer-events", "auto")
+ await page.mouse.move(0, 0)
+ await expect(actions).toHaveCSS("opacity", "0")
+ await actions.getByRole("button", { name: "More actions", exact: true }).focus()
+ await expect(actions).toHaveCSS("opacity", "1")
+ await expect(actions).toHaveCSS("pointer-events", "auto")
+})
- const copy = actions.getByRole("button", { name: action.name, exact: true })
- await expect(copy).toHaveCSS("width", "20px")
- await expect(copy).toHaveCSS("height", "20px")
- await expect(copy.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px")
- }
+story("desktop response copy stays visible while its metadata waits for hover or focus", async ({ mount, page }) => {
+ const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "interruption" } })
+ expect(await page.evaluate(() => matchMedia("(hover: hover)").matches)).toBe(true)
- await page.mouse.move(0, 0)
- await expect(actions).toHaveCSS("opacity", "0")
- await actions.getByRole("button", { name: action.name, exact: true }).focus()
- await expect(actions).toHaveCSS("opacity", "1")
- await expect(actions).toHaveCSS("pointer-events", "auto")
- await page.getByRole("button", { name: "Reset", exact: true }).focus()
+ const actions = timeline.locator('[data-slot="text-part-copy-wrapper"]')
+ await expect(actions).toHaveCount(1)
+ await expect(actions).toHaveCSS("height", "20px")
+ await expect(actions).toHaveCSS("margin-top", "8px")
+ await expect(actions).toHaveCSS("gap", "4px")
+ await expect(actions).toHaveCSS("opacity", "1")
+ await expect(actions).toHaveCSS("pointer-events", "auto")
+
+ const copy = actions.getByRole("button", { name: "Copy response", exact: true })
+ await expect(copy).toBeVisible()
+ await expect(copy).toHaveCSS("width", "20px")
+ await expect(copy).toHaveCSS("height", "20px")
+ await expect(copy.locator('[data-slot="icon-svg"]')).toHaveCSS("width", "14px")
+ const rest = await copy.boundingBox()
+
+ const meta = actions.locator('[data-slot="text-part-meta"]')
+ await expect(meta).toHaveCSS("opacity", "0")
+ await expect(meta).toHaveCSS("pointer-events", "none")
+ await expect(meta).toHaveCSS("font-size", "12px")
+ await expect(meta).toHaveCSS("line-height", "18px")
+ await expect(meta).toHaveCSS("gap", "4px")
+ await expect(meta.locator('[data-slot="text-part-meta-item"]')).toHaveText(["Build", "Claude Sonnet 4", "4s"])
+ const separators = meta.locator('[data-slot="text-part-meta-separator"]')
+ await expect(separators).toHaveCount(2)
+
+ for (const separator of await separators.all()) {
+ await expect(separator).toHaveText("\u00B7")
}
+
+ await actions.locator("..").hover()
+ await expect(meta).toHaveCSS("opacity", "1")
+ await expect(meta).toHaveCSS("pointer-events", "auto")
+ expect(await copy.boundingBox()).toEqual(rest)
+
+ await page.mouse.move(0, 0)
+ await expect(meta).toHaveCSS("opacity", "0")
+ await expect(actions).toHaveCSS("opacity", "1")
+ await copy.focus()
+ await expect(meta).toHaveCSS("opacity", "1")
+ await expect(meta).toHaveCSS("pointer-events", "auto")
})
diff --git a/packages/session-ui/src/components/message-part.css b/packages/session-ui/src/components/message-part.css
index 6ed1a521a835..de0b853bd411 100644
--- a/packages/session-ui/src/components/message-part.css
+++ b/packages/session-ui/src/components/message-part.css
@@ -582,16 +582,9 @@
justify-content: flex-start;
gap: 4px;
- /* Production keeps the whole footer hover-only. Dev channels keep the copy control visible and
- hide only the metadata. Keeping the metadata in flow means the copy control does not move. */
- @media (hover: hover) {
- &:not([data-copy-always-visible]) {
- opacity: 0;
- pointer-events: none;
- }
- }
-
- &[data-copy-always-visible] [data-slot="text-part-meta"] {
+ /* The copy control stays visible; only the metadata waits for hover or focus. Keeping the metadata
+ in flow means the copy control does not move. */
+ [data-slot="text-part-meta"] {
@media (hover: hover) {
opacity: 0;
pointer-events: none;
@@ -668,14 +661,8 @@
transition: none;
}
- &:hover [data-slot="text-part-copy-wrapper"],
- &:focus-within [data-slot="text-part-copy-wrapper"] {
- opacity: 1;
- pointer-events: auto;
- }
-
- &:hover [data-slot="text-part-copy-wrapper"][data-copy-always-visible] [data-slot="text-part-meta"],
- &:focus-within [data-slot="text-part-copy-wrapper"][data-copy-always-visible] [data-slot="text-part-meta"] {
+ &:hover [data-slot="text-part-copy-wrapper"] [data-slot="text-part-meta"],
+ &:focus-within [data-slot="text-part-copy-wrapper"] [data-slot="text-part-meta"] {
opacity: 1;
pointer-events: auto;
}
diff --git a/packages/session-ui/src/context/data.tsx b/packages/session-ui/src/context/data.tsx
index a35f082710ed..7790873fe118 100644
--- a/packages/session-ui/src/context/data.tsx
+++ b/packages/session-ui/src/context/data.tsx
@@ -72,8 +72,6 @@ export const {
sessionID?: string
/** Whether message meta names the agent; the app follows its Show agent setting. Defaults to true. */
agents?: boolean
- /** Whether the assistant copy control stays visible at rest; the app enables this on dev/local builds. */
- copyAlwaysVisible?: boolean
shellRunning?: (id: string) => boolean
shellOutput?: (input: ShellOutputInput) => Promise
turnDiff?: TurnDiffSource
@@ -95,9 +93,6 @@ export const {
get agents() {
return props.agents ?? true
},
- get copyAlwaysVisible() {
- return props.copyAlwaysVisible === true
- },
navigateToSession: props.onNavigateToSession,
sessionHref: props.onSessionHref,
shellRunning: props.shellRunning,
diff --git a/packages/session-ui/src/message/message-content.tsx b/packages/session-ui/src/message/message-content.tsx
index f651e6a6246e..2abad82f91aa 100644
--- a/packages/session-ui/src/message/message-content.tsx
+++ b/packages/session-ui/src/message/message-content.tsx
@@ -1232,11 +1232,7 @@ export function AssistantTextContent(props: {
function copyFooter() {
return (
-
+
((resolve) => setTimeout(resolve, 2000))
+ signal?.throwIfAborted()
+}
+
/** In-memory settings, tunnel discovery, codes and clipboard, scoped to one story instance. */
export function pairingRemote(input: {
enabled: boolean
@@ -57,7 +64,9 @@ export function pairingRemote(input: {
return { urls }
},
- pair: async () => {
+ pair: async ({ signal }) => {
+ if (input.response === "Code arrives slowly") await slowResponse(signal)
+ if (state.issued > 0) fail("Code refresh fails")
fail("Code request fails")
state.issued += 1
// As with server codes, encode 16 bytes. A new fixture replays the same sequence of QR codes.
@@ -76,8 +85,7 @@ export function pairingRemote(input: {
return state.enabled
},
setRemote: async (enabled, options) => {
- await new Promise((resolve) => setTimeout(resolve, 2000))
- options?.signal?.throwIfAborted()
+ await slowResponse(options?.signal)
fail("Remote change fails")
state.enabled = enabled
},
diff --git a/services/site/src/docs/content/console/models.mdx b/services/site/src/docs/content/console/models.mdx
index e509a966a15a..1a4c3d3fdfad 100644
--- a/services/site/src/docs/content/console/models.mdx
+++ b/services/site/src/docs/content/console/models.mdx
@@ -36,102 +36,103 @@ translates. See [Base URLs](/console/harnesses#base-urls) for the full set.
-| Model | Model ID | Endpoint | AI SDK Package |
-| ------------------------------- | ------------------------------- | -------------------------------------------------------------------------- | --------------------------- |
-| GPT 6 Astra | gpt-6-astra | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 6 Sol | gpt-6-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 6.1 Sol | gpt-6.1-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 6 Luna | gpt-6-luna | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.6 Sol | gpt-5.6-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.6 Terra | gpt-5.6-terra | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.6 Luna | gpt-5.6-luna | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.5 | gpt-5.5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.5 Pro | gpt-5.5-pro | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.4 | gpt-5.4 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.4 Pro | gpt-5.4-pro | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.4 Mini | gpt-5.4-mini | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.4 Nano | gpt-5.4-nano | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.3 Codex | gpt-5.3-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.3 Codex Spark | gpt-5.3-codex-spark | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.2 | gpt-5.2 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.2 Codex | gpt-5.2-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.1 | gpt-5.1 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.1 Codex | gpt-5.1-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.1 Codex Max | gpt-5.1-codex-max | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5.1 Codex Mini | gpt-5.1-codex-mini | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5 | gpt-5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5 Codex | gpt-5-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| GPT 5 Nano | gpt-5-nano | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Claude Fable 5.2 | claude-fable-5-2 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Fable 5.1 | claude-fable-5-1 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Fable 5 | claude-fable-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 5.5 | claude-opus-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 5 | claude-opus-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 4.8 | claude-opus-4-8 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 4.7 | claude-opus-4-7 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 4.6 | claude-opus-4-6 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Opus 4.5 | claude-opus-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Sonnet 5.5 | claude-sonnet-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Sonnet 5 | claude-sonnet-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Sonnet 4.6 | claude-sonnet-4-6 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Sonnet 4.5 | claude-sonnet-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Haiku 5.5 | claude-haiku-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Claude Haiku 4.5 | claude-haiku-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Gemini 4 Carbon | gemini-4-carbon | `https://opencode.ai/inference/google/v1beta/models/gemini-4-carbon` | `@ai-sdk/google` |
-| Gemini 4 Argon | gemini-4-argon | `https://opencode.ai/inference/google/v1beta/models/gemini-4-argon` | `@ai-sdk/google` |
-| Gemini 4 Hydrogen | gemini-4-hydrogen | `https://opencode.ai/inference/google/v1beta/models/gemini-4-hydrogen` | `@ai-sdk/google` |
-| Gemini 3.8 Flash | gemini-3.8-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.8-flash` | `@ai-sdk/google` |
-| Gemini 3.7 Flash | gemini-3.7-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.7-flash` | `@ai-sdk/google` |
-| Gemini 3.6 Flash | gemini-3.6-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.6-flash` | `@ai-sdk/google` |
-| Gemini 3.5 Flash | gemini-3.5-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.5-flash` | `@ai-sdk/google` |
-| Gemini 3.5 Flash Lite | gemini-3.5-flash-lite | `https://opencode.ai/inference/google/v1beta/models/gemini-3.5-flash-lite` | `@ai-sdk/google` |
-| Grok 4.7 | grok-4.7 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Grok 4.6 | grok-4.6 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Grok 4.5 | grok-4.5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Grok Build 0.1 | grok-build-0.1 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Muse Ember 1.0 | muse-ember-1.0 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Muse Wonder 1.0 | muse-wonder-1.0 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Muse Spark 1.3 | muse-spark-1.3 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Muse Spark 1.2 | muse-spark-1.2 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
-| Qwen3.8 Max | qwen3.8-max | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Qwen3.8 Flash | qwen3.8-flash | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Qwen3.6 Plus | qwen3.6-plus | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| Qwen3.5 Plus | qwen3.5-plus | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
-| DeepSeek V4.1 Flash | deepseek-v4.1-flash | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| DeepSeek V4 Pro | deepseek-v4-pro | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| MiniMax M3 | minimax-m3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| MiniMax M2.7 | minimax-m2.7 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| MiniMax M2.5 | minimax-m2.5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM 5.3 Flash | glm-5.3-flash | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM 5.3 | glm-5.3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM 5.2 | glm-5.2 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM 5.1 | glm-5.1 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM 5 | glm-5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Kimi K2.5 | kimi-k2.5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Kimi K2.6 | kimi-k2.6 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Kimi K2.7 Code | kimi-k2.7-code | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Kimi K3 | kimi-k3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Mistral Large 4 | mistral-large-4 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GPT 6 Luna Decision | gpt-6-luna-decision | `https://opencode.ai/inference/systemone/v1/systemone` | - |
-| Gemini Decision 1 | gemini-decision-1 | `https://opencode.ai/inference/systemone/v1/systemone` | - |
-| Jev 1.13 | jev-1.13 | `https://opencode.ai/inference/systemone/v1/systemone` | - |
-| Jev 1.13 Free | jev-1.13-free | `https://opencode.ai/inference/systemone/v1/systemone` | - |
-| GPT Image 2.5 Sunburst | gpt-image-2.5-sunburst | `https://opencode.ai/inference/openai/v1/images/generations` | `@ai-sdk/openai` |
-| Nano Banana 2.1 | gemini-nano-banana-2.1 | `https://opencode.ai/inference/google/v1beta/models/gemini-nano-banana-2.1:generateContent` | `@ai-sdk/google` |
-| Grok Imagine Image 2.0 | grok-imagine-image-2.0 | `https://opencode.ai/inference/xai/v1/images/generations` | `@ai-sdk/xai` |
-| GPT-Live 1 | gpt-live-1 | `https://opencode.ai/inference/openai/v1/live/sessions` | - |
-| Big Pickle | big-pickle | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Iceman Free | iceman-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Inkling 2 Small Free | inkling-2-small-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| GLM-5.3-Flash Free | glm-5.3-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| DeepSeek V4.1 Flash Free | deepseek-v4.1-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Beam Free | beam-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Flint 40B Free | flint-40b-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| LongCat 2.5 Free | longcat-2.5-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Hy4 flash Free | hy4-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| MiMo-V2.6-Flash Free | mimo-v2.6-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Nemotron 3.5 Lightning Free | nemotron-3.5-lightning-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
-| Nemotron 3.5 Super VL Free | nemotron-3.5-super-vl-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Model | Model ID | Endpoint | AI SDK Package |
+| --------------------------- | --------------------------- | ------------------------------------------------------------------------------------------- | --------------------------- |
+| GPT 6.2 Astra | gpt-6.2-astra | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 6.2 Sol | gpt-6.2-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 6 Astra | gpt-6-astra | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 6 Sol | gpt-6-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 6.1 Sol | gpt-6.1-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 6 Luna | gpt-6-luna | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.6 Sol | gpt-5.6-sol | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.6 Terra | gpt-5.6-terra | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.6 Luna | gpt-5.6-luna | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.5 | gpt-5.5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.5 Pro | gpt-5.5-pro | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.4 | gpt-5.4 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.4 Pro | gpt-5.4-pro | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.4 Mini | gpt-5.4-mini | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.4 Nano | gpt-5.4-nano | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.3 Codex | gpt-5.3-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.3 Codex Spark | gpt-5.3-codex-spark | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.2 | gpt-5.2 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.2 Codex | gpt-5.2-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.1 | gpt-5.1 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.1 Codex | gpt-5.1-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.1 Codex Max | gpt-5.1-codex-max | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5.1 Codex Mini | gpt-5.1-codex-mini | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5 | gpt-5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5 Codex | gpt-5-codex | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| GPT 5 Nano | gpt-5-nano | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Claude Fable 5.2 | claude-fable-5-2 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Fable 5.1 | claude-fable-5-1 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Fable 5 | claude-fable-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 5.5 | claude-opus-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 5 | claude-opus-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 4.8 | claude-opus-4-8 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 4.7 | claude-opus-4-7 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 4.6 | claude-opus-4-6 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Opus 4.5 | claude-opus-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Sonnet 5.5 | claude-sonnet-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Sonnet 5 | claude-sonnet-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Sonnet 4.6 | claude-sonnet-4-6 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Sonnet 4.5 | claude-sonnet-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Haiku 5.5 | claude-haiku-5-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Claude Haiku 4.5 | claude-haiku-4-5 | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Gemini 4 Carbon | gemini-4-carbon | `https://opencode.ai/inference/google/v1beta/models/gemini-4-carbon` | `@ai-sdk/google` |
+| Gemini 4 Argon | gemini-4-argon | `https://opencode.ai/inference/google/v1beta/models/gemini-4-argon` | `@ai-sdk/google` |
+| Gemini 4 Hydrogen | gemini-4-hydrogen | `https://opencode.ai/inference/google/v1beta/models/gemini-4-hydrogen` | `@ai-sdk/google` |
+| Gemini 3.8 Flash | gemini-3.8-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.8-flash` | `@ai-sdk/google` |
+| Gemini 3.7 Flash | gemini-3.7-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.7-flash` | `@ai-sdk/google` |
+| Gemini 3.6 Flash | gemini-3.6-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.6-flash` | `@ai-sdk/google` |
+| Gemini 3.5 Flash | gemini-3.5-flash | `https://opencode.ai/inference/google/v1beta/models/gemini-3.5-flash` | `@ai-sdk/google` |
+| Gemini 3.5 Flash Lite | gemini-3.5-flash-lite | `https://opencode.ai/inference/google/v1beta/models/gemini-3.5-flash-lite` | `@ai-sdk/google` |
+| Grok 4.7 | grok-4.7 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Grok 4.6 | grok-4.6 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Grok 4.5 | grok-4.5 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Grok Build 0.1 | grok-build-0.1 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Muse Ember 1.0 | muse-ember-1.0 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Muse Wonder 1.0 | muse-wonder-1.0 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Muse Spark 1.3 | muse-spark-1.3 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Muse Spark 1.2 | muse-spark-1.2 | `https://opencode.ai/inference/openai/v1/responses` | `@ai-sdk/openai` |
+| Qwen3.8 Max | qwen3.8-max | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Qwen3.8 Flash | qwen3.8-flash | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Qwen3.6 Plus | qwen3.6-plus | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| Qwen3.5 Plus | qwen3.5-plus | `https://opencode.ai/inference/anthropic/v1/messages` | `@ai-sdk/anthropic` |
+| DeepSeek V4.1 Flash | deepseek-v4.1-flash | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| DeepSeek V4 Pro | deepseek-v4-pro | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| MiniMax M3 | minimax-m3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| MiniMax M2.7 | minimax-m2.7 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| MiniMax M2.5 | minimax-m2.5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM 5.3 Flash | glm-5.3-flash | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM 5.3 | glm-5.3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM 5.2 | glm-5.2 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM 5.1 | glm-5.1 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM 5 | glm-5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Kimi K2.5 | kimi-k2.5 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Kimi K2.6 | kimi-k2.6 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Kimi K2.7 Code | kimi-k2.7-code | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Kimi K3 | kimi-k3 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Mistral Large 4 | mistral-large-4 | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GPT 6 Luna Decision | gpt-6-luna-decision | `https://opencode.ai/inference/systemone/v1/systemone` | - |
+| Gemini Decision 1 | gemini-decision-1 | `https://opencode.ai/inference/systemone/v1/systemone` | - |
+| Jev 1.13 | jev-1.13 | `https://opencode.ai/inference/systemone/v1/systemone` | - |
+| Jev 1.13 Free | jev-1.13-free | `https://opencode.ai/inference/systemone/v1/systemone` | - |
+| GPT Image 2.5 Sunburst | gpt-image-2.5-sunburst | `https://opencode.ai/inference/openai/v1/images/generations` | `@ai-sdk/openai` |
+| Nano Banana 2.1 | gemini-nano-banana-2.1 | `https://opencode.ai/inference/google/v1beta/models/gemini-nano-banana-2.1:generateContent` | `@ai-sdk/google` |
+| Grok Imagine Image 2.0 | grok-imagine-image-2.0 | `https://opencode.ai/inference/xai/v1/images/generations` | `@ai-sdk/xai` |
+| Big Pickle | big-pickle | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Iceman Free | iceman-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Inkling 2 Small Free | inkling-2-small-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| GLM-5.3-Flash Free | glm-5.3-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| DeepSeek V4.1 Flash Free | deepseek-v4.1-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Beam Free | beam-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Flint 40B Free | flint-40b-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| LongCat 2.5 Free | longcat-2.5-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Hy4 flash Free | hy4-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| MiMo-V2.6-Flash Free | mimo-v2.6-flash-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Nemotron 3.5 Lightning Free | nemotron-3.5-lightning-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
+| Nemotron 3.5 Super VL Free | nemotron-3.5-super-vl-free | `https://opencode.ai/inference/openai/v1/chat/completions` | `@ai-sdk/openai-compatible` |
@@ -225,10 +226,9 @@ curl https://opencode.ai/inference/systemone/v1/systemone \
}'
```
-### Image and voice models
+### Image models
-`gpt-image-2.5-sunburst`, `gemini-nano-banana-2.1`, and `grok-imagine-image-2.0` generate and edit images, and
-`gpt-live-1` runs voice sessions. They aren't chat models, so they never appear in `/models` or the models endpoint,
+`gpt-image-2.5-sunburst`, `gemini-nano-banana-2.1`, and `grok-imagine-image-2.0` generate and edit images. They aren't chat models, so they never appear in `/models` or the models endpoint,
and `opencode/` doesn't select them. Call them on their native API with a Console key, or let OpenCode's
[`experimental_image_generate`](/tools#image-generate) tool use an image model by setting
`experimental.image_generate.model`, for example `opencode/gpt-image-2.5-sunburst`.
@@ -245,125 +245,127 @@ curl https://opencode.ai/inference/openai/v1/images/generations \
```
Google takes its native `contents` and `generationConfig`, and xAI its native options such as `resolution` and
-`quality`. OpenAI Images and xAI Images also accept edits at `/images/edits`. For `gpt-live-1`, start a WebRTC session
-at `POST /inference/openai/v1/live/sessions` with OpenAI's session request and return its SDP answer; session time
-bills per minute as it runs.
+`quality`. OpenAI Images and xAI Images also accept edits at `/images/edits`.
## Pricing
-Console uses pay-as-you-go pricing. Below are the prices **per 1M tokens**, with image and voice models priced per
-image or per minute.
+Console uses pay-as-you-go pricing. Below are the prices **per 1M tokens**, with image models priced per image where
+noted.
-| Model | Input | Output | Cached Read | Cached Write |
-| --------------------------------- | --------------- | --------------- | --------------- | ------------ |
-| Big Pickle | Free | Free | Free | - |
-| Iceman Free | Free | Free | Free | - |
-| Inkling 2 Small Free | Free | Free | Free | - |
-| GLM-5.3-Flash Free | Free | Free | Free | - |
-| DeepSeek V4.1 Flash Free | Free | Free | Free | - |
-| Beam Free | Free | Free | Free | - |
-| Flint 40B Free | Free | Free | Free | - |
-| LongCat 2.5 Free | Free | Free | Free | - |
-| Hy4 flash Free | Free | Free | Free | - |
-| MiMo-V2.6-Flash Free | Free | Free | Free | - |
-| Nemotron 3.5 Lightning Free | Free | Free | Free | - |
-| Nemotron 3.5 Super VL Free | Free | Free | Free | - |
-| Jev 1.13 Free | Free | Free | - | - |
-| Jev 1.13 | $0.042 | Free | - | - |
-| Gemini Decision 1 | $0.10 | Free | - | - |
-| GPT 6 Luna Decision (≤ 272K tokens) | $0.10 | Free | $0.01 | $0.125 |
-| GPT 6 Luna Decision (> 272K tokens) | $0.20 | Free | $0.02 | $0.25 |
-| MiniMax M3 | $0.30 | $1.20 | $0.06 | - |
-| MiniMax M2.7 | $0.30 | $1.20 | $0.06 | - |
-| MiniMax M2.5 | $0.30 | $1.20 | $0.06 | - |
-| GLM 5.3 Flash | $0.15 | $0.50 | $0.03 | - |
-| GLM 5.3 | $1.40 | $4.40 | $0.26 | - |
-| GLM 5.2 | $1.40 | $4.40 | $0.26 | - |
-| GLM 5.1 | $1.40 | $4.40 | $0.26 | - |
-| GLM 5 | $1.00 | $3.20 | $0.20 | - |
-| Kimi K2.7 Code | $0.95 | $4.00 | $0.19 | - |
-| Kimi K3 | $3.00 | $15.00 | $0.30 | $3.00 |
-| Kimi K2.6 | $0.95 | $4.00 | $0.16 | - |
-| Kimi K2.5 | $0.60 | $3.00 | $0.10 | - |
-| Mistral Large 4 (50% off) | ~~$1.36~~ $0.68 | ~~$4.18~~ $2.09 | ~~$0.14~~ $0.07 | - |
-| Qwen3.8 Max | $2.00 | $6.00 | $0.25 | $2.50 |
-| Qwen3.8 Flash | $0.15 | $0.47 | $0.016 | $0.20 |
-| Qwen3.6 Plus | $0.50 | $3.00 | $0.05 | $0.625 |
-| Qwen3.5 Plus | $0.20 | $1.20 | $0.02 | $0.25 |
-| DeepSeek V4.1 Flash | $0.30 | $1.20 | $0.006 | - |
-| DeepSeek V4 Pro | $1.74 | $3.48 | $0.145 | - |
-| Claude Fable 5.2 | $8.00 | $40.00 | $0.20 | $10.00 |
-| Claude Fable 5.1 | $10.00 | $50.00 | $0.25 | $12.50 |
-| Claude Fable 5 | $10.00 | $50.00 | $1.00 | $12.50 |
-| Claude Opus 5.5 | $4.00 | $20.00 | $0.20 | $5.00 |
-| Claude Opus 5 | $5.00 | $25.00 | $0.50 | $6.25 |
-| Claude Opus 4.8 | $5.00 | $25.00 | $0.50 | $6.25 |
-| Claude Opus 4.7 | $5.00 | $25.00 | $0.50 | $6.25 |
-| Claude Opus 4.6 | $5.00 | $25.00 | $0.50 | $6.25 |
-| Claude Opus 4.5 | $5.00 | $25.00 | $0.50 | $6.25 |
-| Claude Sonnet 5.5 | $2.00 | $10.00 | $0.10 | $2.50 |
-| Claude Sonnet 5 | $2.00 | $10.00 | $0.20 | $2.50 |
-| Claude Sonnet 4.6 | $3.00 | $15.00 | $0.30 | $3.75 |
-| Claude Sonnet 4.5 (≤ 200K tokens) | $3.00 | $15.00 | $0.30 | $3.75 |
-| Claude Sonnet 4.5 (> 200K tokens) | $6.00 | $22.50 | $0.60 | $7.50 |
-| Claude Haiku 5.5 (≤ 100K tokens) | $0.10 | $0.50 | $0.01 | $0.125 |
-| Claude Haiku 5.5 (> 100K tokens) | $0.50 | $2.50 | $0.05 | $0.625 |
-| Claude Haiku 4.5 | $1.00 | $5.00 | $0.10 | $1.25 |
-| Gemini 4 Carbon (50% off) | ~~$4.00~~ $2.00 | ~~$20.00~~ $10.00 | ~~$0.20~~ $0.10 | - |
-| Gemini 4 Argon (50% off) | ~~$4.00~~ $2.00 | ~~$20.00~~ $10.00 | ~~$0.20~~ $0.10 | - |
-| Gemini 4 Hydrogen | $1.50 | $7.50 | $0.075 | - |
-| Gemini 3.8 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
-| Gemini 3.7 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
-| Gemini 3.6 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
-| Gemini 3.5 Flash | $1.50 | $9.00 | $0.15 | - |
-| Gemini 3.5 Flash Lite | $0.30 | $2.50 | $0.03 | - |
-| Grok 4.7 (≤ 200K tokens) | $2.00 | $6.00 | $0.50 | - |
-| Grok 4.7 (> 200K tokens) | $4.00 | $12.00 | $1.00 | - |
-| Grok 4.6 (≤ 200K tokens) | $2.00 | $6.00 | $0.50 | - |
-| Grok 4.6 (> 200K tokens) | $4.00 | $12.00 | $1.00 | - |
-| Grok 4.5 (≤ 200K tokens) | $2.00 | $6.00 | $0.30 | - |
-| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
-| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
-| Muse Ember 1.0 (≤ 200K tokens) | $0.10 | $0.50 | $0.004 | - |
-| Muse Ember 1.0 (> 200K tokens) | $0.30 | $1.50 | $0.012 | - |
-| Muse Wonder 1.0 | $4.00 | $20.00 | $0.20 | - |
-| Muse Spark 1.3 | $1.25 | $4.25 | $0.15 | - |
-| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
-| GPT 6 Astra (≤ 272K tokens) | $10.00 | $50.00 | $1.00 | $12.50 |
-| GPT 6 Astra (> 272K tokens) | $20.00 | $75.00 | $2.00 | $25.00 |
-| GPT 6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
-| GPT 6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
-| GPT 6.1 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.10 | $2.50 |
-| GPT 6.1 Sol (> 272K tokens) | $4.00 | $15.00 | $0.20 | $5.00 |
-| GPT 6 Luna (≤ 272K tokens) | $0.10 | $0.50 | $0.01 | $0.125 |
-| GPT 6 Luna (> 272K tokens) | $0.20 | $0.75 | $0.02 | $0.25 |
-| GPT 5.6 Sol (≤ 272K tokens) | $4.00 | $20.00 | $0.40 | $5.00 |
-| GPT 5.6 Sol (> 272K tokens) | $8.00 | $30.00 | $0.80 | $10.00 |
-| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
-| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
-| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
-| GPT 5.6 Luna (> 272K tokens) | $0.40 | $1.80 | $0.04 | $0.50 |
-| GPT 5.5 (≤ 272K tokens) | $5.00 | $30.00 | $0.50 | - |
-| GPT 5.5 (> 272K tokens) | $10.00 | $45.00 | $1.00 | - |
-| GPT 5.5 Pro | $30.00 | $180.00 | $30.00 | - |
-| GPT 5.4 (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | - |
-| GPT 5.4 (> 272K tokens) | $5.00 | $22.50 | $0.50 | - |
-| GPT 5.4 Pro | $30.00 | $180.00 | $30.00 | - |
-| GPT 5.4 Mini | $0.75 | $4.50 | $0.075 | - |
-| GPT 5.4 Nano | $0.20 | $1.25 | $0.02 | - |
-| GPT 5.3 Codex Spark | $1.75 | $14.00 | $0.175 | - |
-| GPT 5.3 Codex | $1.75 | $14.00 | $0.175 | - |
-| GPT 5.2 | $1.75 | $14.00 | $0.175 | - |
-| GPT 5.2 Codex | $1.75 | $14.00 | $0.175 | - |
-| GPT 5.1 | $1.07 | $8.50 | $0.107 | - |
-| GPT 5.1 Codex | $1.07 | $8.50 | $0.107 | - |
-| GPT 5.1 Codex Max | $1.25 | $10.00 | $0.125 | - |
-| GPT 5.1 Codex Mini | $0.25 | $2.00 | $0.025 | - |
-| GPT 5 | $1.07 | $8.50 | $0.107 | - |
-| GPT 5 Codex | $1.07 | $8.50 | $0.107 | - |
-| GPT 5 Nano | $0.05 | $0.40 | $0.005 | - |
+| Model | Input | Output | Cached Read | Cached Write |
+| ----------------------------------- | --------------- | ----------------- | ---------------- | ------------ |
+| Big Pickle | Free | Free | Free | - |
+| Iceman Free | Free | Free | Free | - |
+| Inkling 2 Small Free | Free | Free | Free | - |
+| GLM-5.3-Flash Free | Free | Free | Free | - |
+| DeepSeek V4.1 Flash Free | Free | Free | Free | - |
+| Beam Free | Free | Free | Free | - |
+| Flint 40B Free | Free | Free | Free | - |
+| LongCat 2.5 Free | Free | Free | Free | - |
+| Hy4 flash Free | Free | Free | Free | - |
+| MiMo-V2.6-Flash Free | Free | Free | Free | - |
+| Nemotron 3.5 Lightning Free | Free | Free | Free | - |
+| Nemotron 3.5 Super VL Free | Free | Free | Free | - |
+| Jev 1.13 Free | Free | Free | - | - |
+| Jev 1.13 | $0.042 | Free | - | - |
+| Gemini Decision 1 | $0.10 | Free | - | - |
+| GPT 6 Luna Decision (≤ 272K tokens) | $0.10 | Free | $0.01 | $0.125 |
+| GPT 6 Luna Decision (> 272K tokens) | $0.20 | Free | $0.02 | $0.25 |
+| MiniMax M3 | $0.30 | $1.20 | $0.06 | - |
+| MiniMax M2.7 | $0.30 | $1.20 | $0.06 | - |
+| MiniMax M2.5 | $0.30 | $1.20 | $0.06 | - |
+| GLM 5.3 Flash | $0.15 | $0.50 | $0.03 | - |
+| GLM 5.3 | $1.40 | $4.40 | $0.26 | - |
+| GLM 5.2 | $1.40 | $4.40 | $0.26 | - |
+| GLM 5.1 | $1.40 | $4.40 | $0.26 | - |
+| GLM 5 | $1.00 | $3.20 | $0.20 | - |
+| Kimi K2.7 Code | $0.95 | $4.00 | $0.19 | - |
+| Kimi K3 | $3.00 | $15.00 | $0.30 | $3.00 |
+| Kimi K2.6 | $0.95 | $4.00 | $0.16 | - |
+| Kimi K2.5 | $0.60 | $3.00 | $0.10 | - |
+| Mistral Large 4 (50% off) | ~~$1.36~~ $0.68 | ~~$4.18~~ $2.09 | ~~$0.14~~ $0.07 | - |
+| Qwen3.8 Max | $2.00 | $6.00 | $0.25 | $2.50 |
+| Qwen3.8 Flash | $0.15 | $0.47 | $0.016 | $0.20 |
+| Qwen3.6 Plus | $0.50 | $3.00 | $0.05 | $0.625 |
+| Qwen3.5 Plus | $0.20 | $1.20 | $0.02 | $0.25 |
+| DeepSeek V4.1 Flash | $0.30 | $1.20 | $0.006 | - |
+| DeepSeek V4 Pro | $1.74 | $3.48 | $0.145 | - |
+| Claude Fable 5.2 | $8.00 | $40.00 | $0.20 | $10.00 |
+| Claude Fable 5.1 | $10.00 | $50.00 | $0.25 | $12.50 |
+| Claude Fable 5 | $10.00 | $50.00 | $1.00 | $12.50 |
+| Claude Opus 5.5 | $4.00 | $20.00 | $0.20 | $5.00 |
+| Claude Opus 5 | $5.00 | $25.00 | $0.50 | $6.25 |
+| Claude Opus 4.8 | $5.00 | $25.00 | $0.50 | $6.25 |
+| Claude Opus 4.7 | $5.00 | $25.00 | $0.50 | $6.25 |
+| Claude Opus 4.6 | $5.00 | $25.00 | $0.50 | $6.25 |
+| Claude Opus 4.5 | $5.00 | $25.00 | $0.50 | $6.25 |
+| Claude Sonnet 5.5 | $2.00 | $10.00 | $0.10 | $2.50 |
+| Claude Sonnet 5 | $2.00 | $10.00 | $0.20 | $2.50 |
+| Claude Sonnet 4.6 | $3.00 | $15.00 | $0.30 | $3.75 |
+| Claude Sonnet 4.5 (≤ 200K tokens) | $3.00 | $15.00 | $0.30 | $3.75 |
+| Claude Sonnet 4.5 (> 200K tokens) | $6.00 | $22.50 | $0.60 | $7.50 |
+| Claude Haiku 5.5 (≤ 100K tokens) | $0.10 | $0.50 | $0.01 | $0.125 |
+| Claude Haiku 5.5 (> 100K tokens) | $0.50 | $2.50 | $0.05 | $0.625 |
+| Claude Haiku 4.5 | $1.00 | $5.00 | $0.10 | $1.25 |
+| Gemini 4 Carbon (50% off) | ~~$4.00~~ $2.00 | ~~$20.00~~ $10.00 | ~~$0.20~~ $0.10 | - |
+| Gemini 4 Argon (50% off) | ~~$4.00~~ $2.00 | ~~$20.00~~ $10.00 | ~~$0.20~~ $0.10 | - |
+| Gemini 4 Hydrogen | $1.50 | $7.50 | $0.075 | - |
+| Gemini 3.8 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
+| Gemini 3.7 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
+| Gemini 3.6 Flash (50% off) | ~~$1.50~~ $0.75 | ~~$7.50~~ $3.75 | ~~$0.15~~ $0.075 | - |
+| Gemini 3.5 Flash | $1.50 | $9.00 | $0.15 | - |
+| Gemini 3.5 Flash Lite | $0.30 | $2.50 | $0.03 | - |
+| Grok 4.7 (≤ 200K tokens) | $2.00 | $6.00 | $0.50 | - |
+| Grok 4.7 (> 200K tokens) | $4.00 | $12.00 | $1.00 | - |
+| Grok 4.6 (≤ 200K tokens) | $2.00 | $6.00 | $0.50 | - |
+| Grok 4.6 (> 200K tokens) | $4.00 | $12.00 | $1.00 | - |
+| Grok 4.5 (≤ 200K tokens) | $2.00 | $6.00 | $0.30 | - |
+| Grok 4.5 (> 200K tokens) | $4.00 | $12.00 | $0.60 | - |
+| Grok Build 0.1 | $1.00 | $2.00 | $0.20 | - |
+| Muse Ember 1.0 (≤ 200K tokens) | $0.10 | $0.50 | $0.004 | - |
+| Muse Ember 1.0 (> 200K tokens) | $0.30 | $1.50 | $0.012 | - |
+| Muse Wonder 1.0 | $4.00 | $20.00 | $0.20 | - |
+| Muse Spark 1.3 | $1.25 | $4.25 | $0.15 | - |
+| Muse Spark 1.2 | $1.25 | $4.25 | $0.15 | - |
+| GPT 6.2 Astra (≤ 272K tokens) | $8.00 | $40.00 | $0.40 | $10.00 |
+| GPT 6.2 Astra (> 272K tokens) | $16.00 | $60.00 | $0.80 | $20.00 |
+| GPT 6.2 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.10 | $2.50 |
+| GPT 6.2 Sol (> 272K tokens) | $4.00 | $15.00 | $0.20 | $5.00 |
+| GPT 6 Astra (≤ 272K tokens) | $10.00 | $50.00 | $1.00 | $12.50 |
+| GPT 6 Astra (> 272K tokens) | $20.00 | $75.00 | $2.00 | $25.00 |
+| GPT 6 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.20 | $2.50 |
+| GPT 6 Sol (> 272K tokens) | $4.00 | $15.00 | $0.40 | $5.00 |
+| GPT 6.1 Sol (≤ 272K tokens) | $2.00 | $10.00 | $0.10 | $2.50 |
+| GPT 6.1 Sol (> 272K tokens) | $4.00 | $15.00 | $0.20 | $5.00 |
+| GPT 6 Luna (≤ 272K tokens) | $0.10 | $0.50 | $0.01 | $0.125 |
+| GPT 6 Luna (> 272K tokens) | $0.20 | $0.75 | $0.02 | $0.25 |
+| GPT 5.6 Sol (≤ 272K tokens) | $4.00 | $20.00 | $0.40 | $5.00 |
+| GPT 5.6 Sol (> 272K tokens) | $8.00 | $30.00 | $0.80 | $10.00 |
+| GPT 5.6 Terra (≤ 272K tokens) | $2.00 | $12.00 | $0.20 | $2.50 |
+| GPT 5.6 Terra (> 272K tokens) | $4.00 | $18.00 | $0.40 | $5.00 |
+| GPT 5.6 Luna (≤ 272K tokens) | $0.20 | $1.20 | $0.02 | $0.25 |
+| GPT 5.6 Luna (> 272K tokens) | $0.40 | $1.80 | $0.04 | $0.50 |
+| GPT 5.5 (≤ 272K tokens) | $5.00 | $30.00 | $0.50 | - |
+| GPT 5.5 (> 272K tokens) | $10.00 | $45.00 | $1.00 | - |
+| GPT 5.5 Pro | $30.00 | $180.00 | $30.00 | - |
+| GPT 5.4 (≤ 272K tokens) | $2.50 | $15.00 | $0.25 | - |
+| GPT 5.4 (> 272K tokens) | $5.00 | $22.50 | $0.50 | - |
+| GPT 5.4 Pro | $30.00 | $180.00 | $30.00 | - |
+| GPT 5.4 Mini | $0.75 | $4.50 | $0.075 | - |
+| GPT 5.4 Nano | $0.20 | $1.25 | $0.02 | - |
+| GPT 5.3 Codex Spark | $1.75 | $14.00 | $0.175 | - |
+| GPT 5.3 Codex | $1.75 | $14.00 | $0.175 | - |
+| GPT 5.2 | $1.75 | $14.00 | $0.175 | - |
+| GPT 5.2 Codex | $1.75 | $14.00 | $0.175 | - |
+| GPT 5.1 | $1.07 | $8.50 | $0.107 | - |
+| GPT 5.1 Codex | $1.07 | $8.50 | $0.107 | - |
+| GPT 5.1 Codex Max | $1.25 | $10.00 | $0.125 | - |
+| GPT 5.1 Codex Mini | $0.25 | $2.00 | $0.025 | - |
+| GPT 5 | $1.07 | $8.50 | $0.107 | - |
+| GPT 5 Codex | $1.07 | $8.50 | $0.107 | - |
+| GPT 5 Nano | $0.05 | $0.40 | $0.005 | - |
@@ -378,14 +380,13 @@ models to generate session titles.
A processing fee of 4.6% + $0.31 is added to each credit purchase to cover payment costs; we don't charge anything beyond that.
-### Image and voice pricing
+### Image pricing
| Model | Price | Notes |
| ---------------------- | --------------------------- | ---------------------------------------------------------------------------------- |
| GPT Image 2.5 Sunburst | $1.00 / image | Plus $8 / $30 per 1M input / output tokens, and $2 per 1M cached input tokens. |
| Nano Banana 2.1 | $1.50 / $7.50 / $30.00 per 1M tokens | Input / text output / image output. About $0.034 per 1K image, $0.050 per 2K, $0.113 per 4K. |
| Grok Imagine Image 2.0 | $0.04 / image | $0.01 per input image; quality and resolution can raise the output price to $0.05–$0.08. |
-| GPT-Live 1 | $0.05 / min | Session time, as OpenAI reports each whole minute; 15 seconds minimum. |
### Free models
diff --git a/services/site/src/docs/content/instructions.mdx b/services/site/src/docs/content/instructions.mdx
index 80e62b6122e3..cecc9447875c 100644
--- a/services/site/src/docs/content/instructions.mdx
+++ b/services/site/src/docs/content/instructions.mdx
@@ -38,9 +38,15 @@ Keep guidance that applies everywhere in the global file. Put repository-wide gu
If the workspace is outside the project root, only the global file is loaded. Set `OPENCODE_DISABLE_PROJECT_CONFIG=1` to skip project `AGENTS.md` discovery without disabling the global file.
-
- OpenCode V2 recognizes `AGENTS.md` only. It does not use `CLAUDE.md` as a fallback.
-
+### CLAUDE.md fallback
+
+In any directory without an `AGENTS.md`, OpenCode reads `CLAUDE.md` instead. Without a global
+`~/.config/opencode/AGENTS.md`, it reads `~/.claude/CLAUDE.md`. A directory's `AGENTS.md` always wins over its
+`CLAUDE.md`, so a symlink between the two loads once.
+
+Set `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT=1` to skip only `~/.claude/CLAUDE.md`, or `OPENCODE_DISABLE_CLAUDE_CODE=1` to
+skip every `CLAUDE.md` and `.claude` skills. The server reads both when it starts. For the background service, persist
+them with `opencode service set env` and run `opencode service restart`.
## Discovery
diff --git a/services/site/src/docs/content/migrate-v1.mdx b/services/site/src/docs/content/migrate-v1.mdx
index 85909f46f4c9..5eac2dd9a087 100644
--- a/services/site/src/docs/content/migrate-v1.mdx
+++ b/services/site/src/docs/content/migrate-v1.mdx
@@ -552,9 +552,11 @@ require a V2 rewrite. See [Skills](/skills).
Existing `AGENTS.md` files stay in place. V2 discovers the global `~/.config/opencode/AGENTS.md` and ambient `AGENTS.md`
files from the current directory up to home. For projects outside home, discovery stops at the project root.
-If a V1 setup relied on a `CLAUDE.md` fallback, move that guidance into the applicable `AGENTS.md`. V2 currently only
-discovers `AGENTS.md`; because non-API V1 behavior is intended to remain compatible, also file a compatibility issue with
-the affected project details. See [Instructions](/instructions).
+V2 keeps the V1 `CLAUDE.md` fallback: a directory without `AGENTS.md` uses its `CLAUDE.md`, and `~/.claude/CLAUDE.md`
+stands in for a missing global `AGENTS.md`. As before, `OPENCODE_DISABLE_CLAUDE_CODE_PROMPT` skips only
+`~/.claude/CLAUDE.md` and `OPENCODE_DISABLE_CLAUDE_CODE` skips every `CLAUDE.md`. Unlike V1, which stopped at the
+first file name found anywhere up the tree, V2 picks per directory, so an `AGENTS.md` at the root no longer hides a
+nested `CLAUDE.md`. See [Instructions](/instructions).
## Terminal client configuration