GeezerVison is showing github.com — feat(core): discover LM Studio models by nexxeln · Pull Request #42607 · anomalyco/opencode
feat(core): discover LM Studio models
#42607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5f78183
feat(core): discover lm studio models
nexxeln Aug 14, 2026
2d953a6
fix(ai): harden websocket error contracts (#40695)
nexxeln Aug 14, 2026
de32afe
refactor(ai): add sequential websocket channel seam (#41045)
nexxeln Aug 14, 2026
c0ae362
refactor(ai): unify OpenAI Responses transport (#41048)
nexxeln Aug 14, 2026
810156d
refactor(core): expose session transport eligibility (#41558)
nexxeln Aug 14, 2026
a2a5303
feat(core): manage session websocket channels (#41564)
nexxeln Aug 14, 2026
445aacf
feat(ai): add Responses websocket continuation (#42596)
nexxeln Aug 14, 2026
638cb41
test(ai): harden websocket lifecycle coverage (#42600)
nexxeln Aug 14, 2026
e79f3e8
feat(tui): animate interrupt confirmation (#42602)
kitlangton Aug 14, 2026
923cb28
chore: generate
opencode-agent[bot] Aug 14, 2026
8ff5959
fix(core): expose discovered lm studio models
nexxeln Aug 14, 2026
737b6eb
chore: extract Drive and catalog (#42612)
kitlangton Aug 14, 2026
d6c299c
fix(ai): remove over-safe provider error handling (#42610)
opencode-agent[bot] Aug 14, 2026
2ca6d8e
chore: generate
opencode-agent[bot] Aug 14, 2026
23258ad
feat(tui): resize vertical tab rail (#42615)
kitlangton Aug 14, 2026
f462093
test(server): remove workerd spike (#42618)
kitlangton Aug 14, 2026
a609acb
fix(tui): refine tab marquee motion (#42617)
kitlangton Aug 14, 2026
6adbbc9
feat(core): discover lm studio models
nexxeln Aug 14, 2026
c02bdd3
fix(core): expose discovered lm studio models
nexxeln Aug 14, 2026
05478af
feat(core): configure lm studio discovery
nexxeln Aug 14, 2026
2c29464
chore: sync lmstudio provider branch
nexxeln Aug 14, 2026
File filter
Filter by extension
.mdx
(1)
.ts
(7)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
test(ai): harden websocket lifecycle coverage (
#42600 )
Loading branch information
Uh oh!
There was an error while loading. Please reload this page.
commit 638cb414c47f2e8b40a4239d550e4d9c2bb5c19b
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
import { AIError, TransportReason } from "../schema/index.js"
import type { ChannelCheckpoint, ChannelObservation, WebSocketChannelDriver } from "../route/transport/index.js"
import { Effect, Schema } from "effect"
import { Effect, Option, Schema } from "effect"
import * as ProviderShared from "./shared.js"
import { OpenResponses } from "./open-responses.js"
Expand Down
Expand Up
@@ -47,6 +47,11 @@ const canonical = (value: unknown): string => {
.join(",")}}`
}
const json = (value: unknown) => {
if (typeof value !== "string") return value
return Option.getOrElse(Schema.decodeUnknownOption(ProviderShared.Json)(value), () => value)
}
const comparable = (value: unknown) => {
if (!ProviderShared.isRecord(value)) return value
if (value.type === "message" && value.role === "assistant")
Expand All
@@ -60,12 +65,11 @@ const comparable = (value: unknown) => {
type: value.type,
call_id: value.call_id,
name: value.name,
arguments: value.arguments,
arguments: json( value.arguments) ,
}
if (value.type === "reasoning")
return {
type: value.type,
...(value.id === undefined ? {} : { id: value.id }),
summary: value.summary,
encrypted_content: value.encrypted_content,
}
Expand All
@@ -87,7 +91,8 @@ const incremental = (
if (canonical(invariant(request)) !== canonical(invariant(checkpoint.request))) return undefined
const baseline = [...previousInput, ...checkpoint.output]
if (input.length <= baseline.length) return undefined
if (!baseline.every((item, index) => canonical(comparable(item)) === canonical(input[index]))) return undefined
if (!baseline.every((item, index) => canonical(comparable(item)) === canonical(comparable(input[index]))))
return undefined
return input.slice(baseline.length)
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -413,7 +413,7 @@ describe("OpenAI Responses route", () => {
status: "completed",
call_id: "call_1",
name: "weather",
arguments: '{"city":"Paris"}',
arguments: '{ "city": "Paris" }',
},
}),
)
Expand Down
Expand Up
@@ -484,6 +484,53 @@ describe("OpenAI Responses route", () => {
}),
)
it.effect("continues store-false reasoning without replaying the output-only item ID", () =>
Effect.gen(function* () {
const firstInput = [{ role: "user", content: [{ type: "input_text", text: "Think" }] }]
const request = { type: "response.create", model: "gpt-5.2", store: false, input: firstInput }
const first = continuationDriver(request)
const create = yield* first.create(undefined)
yield* first.observe(
create,
ProviderShared.encodeJson({
type: "response.output_item.done",
item: {
type: "reasoning",
id: "rs_1",
summary: [{ type: "summary_text", text: "Thought" }],
encrypted_content: "encrypted",
},
}),
)
const saved = checkpoint(
yield* first.observe(
create,
ProviderShared.encodeJson({ type: "response.completed", response: { id: "resp_1" } }),
),
)
const next = continuationDriver({
...request,
input: [
...firstInput,
{
type: "reasoning",
summary: [{ type: "summary_text", text: "Thought" }],
encrypted_content: "encrypted",
},
{ role: "user", content: [{ type: "input_text", text: "Continue" }] },
],
})
const continued = yield* next.create(saved)
expect(continued.mode).toBe("incremental")
expect(ProviderShared.decodeJson(continued.message)).toMatchObject({
previous_response_id: "resp_1",
input: [{ role: "user", content: [{ type: "input_text", text: "Continue" }] }],
})
}),
)
it.effect("uses a full request when any non-input invariant changes", () =>
Effect.gen(function* () {
const request = {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -12,7 +12,7 @@ import {
} from "@opencode-ai/ai/route"
import { AIError, TransportReason, type TransportOperation } from "@opencode-ai/ai"
import { Hash } from "@opencode-ai/util/hash"
import { Cause, Clock, Context, Effect, Fiber, Layer, Queue, Scope, Semaphore, Stream } from "effect"
import { Cause, Clock, Context, Effect, Fiber, Layer, Metric, Queue, Scope, Semaphore, Stream } from "effect"
import { Socket } from "effect/unstable/socket"
import { makeLocationNode } from "@opencode-ai/util/effect/app-node"
import { SessionSchema } from "./schema.js"
Expand All
@@ -21,6 +21,12 @@ import { webSocketConstructor } from "../effect/app-node-platform.js"
const ROTATE_AFTER_MS = 55 * 60 * 1000
const INBOUND_CAPACITY = 128
const IDLE_TIMEOUT = "5 minutes"
const events = Metric.counter("opencode_session_websocket_events_total", {
description: "Session WebSocket lifecycle events",
incremental: true,
})
const metric = (event: string, attributes: Record<string, string> = {}) =>
Metric.update(events.pipe(Metric.withAttributes({ event, ...attributes })), 1)
type Delivery = "queued" | "connecting" | "ready" | "send-attempted" | "provider-observed" | "terminal"
Expand Down
Expand Up
@@ -144,6 +150,7 @@ export const makeLayer = (connector: WebSocketConnector) =>
}),
),
)
yield* metric("close")
})
const poison = Effect.fn("SessionModelTransport.poison")(function* (
Expand All
@@ -156,6 +163,11 @@ export const makeLayer = (connector: WebSocketConnector) =>
if (channel.closing) return
channel.closing = true
if (channel.active) Queue.failCauseUnsafe(channel.active.queue, Cause.fail(error))
yield* metric(
error.reason._tag === "Transport" && error.reason.code === "queue-overflow"
? "queue_overflow"
: "protocol_failure",
)
yield* channel.connection.close
})
Expand All
@@ -166,7 +178,9 @@ export const makeLayer = (connector: WebSocketConnector) =>
) {
return yield* Effect.uninterruptibleMask((restore) =>
Effect.gen(function* () {
const connection = yield* restore(connector.open(exchange.connect))
const connection = yield* restore(
connector.open(exchange.connect).pipe(Effect.withSpan("SessionModelTransport.connect")),
)
if (owner.closed) {
yield* connection.close
return yield* transportError("open", "Session WebSocket owner closed while connecting", {
Expand Down
Expand Up
@@ -237,6 +251,7 @@ export const makeLayer = (connector: WebSocketConnector) =>
sessionTransport: "websocket",
phase: "connect",
})
yield* metric("connect")
return channel
}),
)
Expand Down
Expand Up
@@ -278,6 +293,8 @@ export const makeLayer = (connector: WebSocketConnector) =>
phase: "connect",
reason: rotation,
})
yield* metric("rotation", { reason: rotation })
yield* metric("reconnect")
yield* closeChannel(owner, current)
}
Expand All
@@ -287,6 +304,7 @@ export const makeLayer = (connector: WebSocketConnector) =>
sessionTransport: "websocket",
phase: "connect",
})
if (owner.channel) yield* metric("reuse")
const channel = owner.channel
? owner.channel
: yield* open(owner, exchange, key).pipe(
Expand All
@@ -298,7 +316,11 @@ export const makeLayer = (connector: WebSocketConnector) =>
phase: "connect",
delivery: "not-sent",
code: error.reason._tag === "Transport" ? error.reason.code : error.reason._tag,
}).pipe(Effect.andThen(Effect.succeed(undefined))),
}).pipe(
Effect.andThen(metric("connect_failure")),
Effect.andThen(metric("fallback")),
Effect.andThen(Effect.succeed(undefined)),
),
),
)
if (!channel) return fallback(exchange)
Expand All
@@ -318,16 +340,22 @@ export const makeLayer = (connector: WebSocketConnector) =>
channel.active = active
lifecycle.delivery = "send-attempted"
const sent = yield* channel.connection.sendText(create.message).pipe(
Effect.withSpan("SessionModelTransport.send"),
Effect.onInterrupt(() => closeChannel(owner, channel)),
Effect.result,
)
if (sent._tag === "Failure") {
const failure = sent.failure
const notSent = failure.reason._tag === "Transport" && failure.reason.delivery === "not-sent"
yield* closeChannel(owner, channel)
if (notSent) return fallback(exchange)
if (notSent) {
yield* metric("fallback")
return fallback(exchange)
}
yield* metric("ambiguous_delivery")
return yield* annotate(failure, { phase: "send", delivery: "ambiguous" })
}
yield* metric("send")
let terminal: ChannelObservation | undefined
const token = {}
Expand All
@@ -353,6 +381,7 @@ export const makeLayer = (connector: WebSocketConnector) =>
terminal = observation
lifecycle.delivery = "terminal"
staged = observation.type === "completed" ? observation.checkpoint : undefined
if (staged) channel.pending = { token, checkpoint: staged }
if (observation.type !== "completed" || !staged) channel.checkpoint = undefined
}),
),
Expand All
@@ -364,11 +393,13 @@ export const makeLayer = (connector: WebSocketConnector) =>
const pending = yield* Queue.size(active.queue)
yield* Queue.shutdown(active.queue)
if (terminal && pending === 0) {
if (staged) channel.pending = { token, checkpoint: staged }
yield* metric("terminal", { type: terminal.type })
if (terminal.type === "rejected") yield* metric("rejection", { recovery: terminal.recovery })
if (terminal.type === "rejected" && terminal.recovery === "rotate-and-retry-full")
yield* closeChannel(owner, channel)
return
}
yield* metric("cancellation")
channel.checkpoint = undefined
channel.pending = undefined
const error = terminal
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1,71 @@
import { Buffer } from "node:buffer"
import { Effect } from "effect"
interface ConnectionData {
readonly id: number
}
export interface WebSocketServerState {
readonly headers: Array<Record<string, string>>
readonly messages: string[]
opens: number
closes: number
pongs: number
}
export interface WebSocketServerFixture {
readonly url: string
readonly state: WebSocketServerState
}
export interface WebSocketServerOptions {
readonly upgrade?: (request: Request) => boolean
readonly open?: (socket: Bun.ServerWebSocket<ConnectionData>) => void
readonly message?: (socket: Bun.ServerWebSocket<ConnectionData>, message: string | Buffer) => void
}
export const makeWebSocketServer = (options: WebSocketServerOptions = {}) =>
Effect.acquireRelease(
Effect.sync(() => {
const state: WebSocketServerState = { headers: [], messages: [], opens: 0, closes: 0, pongs: 0 }
let connection = 0
const server = Bun.serve<ConnectionData>({
hostname: "127.0.0.1",
port: 0,
fetch(request, server) {
state.headers.push(Object.fromEntries(request.headers.entries()))
if ((options.upgrade?.(request) ?? true) && server.upgrade(request, { data: { id: connection++ } }))
return undefined
return new Response("WebSocket upgrade required", {
status: 426,
headers: { "x-upgrade-rejected": "true" },
})
},
websocket: {
open(socket) {
state.opens++
options.open?.(socket)
},
message(socket, message) {
const text = typeof message === "string" ? message : message.toString()
state.messages.push(text)
options.message?.(socket, message)
},
close() {
state.closes++
},
pong() {
state.pongs++
},
},
})
return {
server,
fixture: {
url: `${server.url.toString().replace(/^http/, "ws")}responses`,
state,
} satisfies WebSocketServerFixture,
}
}),
({ server }) => Effect.promise(() => server.stop(true)),
).pipe(Effect.map((item) => item.fixture))
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.