fix(acp): allow _lembas/configure model switch on serve --stdio (v2.0.0-beta.16)

This commit is contained in:
Homer committed 2026-11-26 21:32:48 +00:00
1 parent 50b70ed0cd
commit 009f97bd2c
4 files changed
+47 -10

No files matched your search

+9
View File
@@ -4,6 +4,15 @@ All notable changes to LLeMbas CLI. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
[Semantic Versioning](https://semver.org/).
## [2.0.0-beta.16] — 2026-11-26
### Fixed
- **IDE model switching on `lembas serve --stdio`** (`_lembas/configure`): no
longer requires a linked server instance connection when changing the active
session's model from an editor client (VS Code / VSCodium / Neovim), resolving
against the device's signed-in server models instead.
## [2.0.0-beta.15] — 2026-11-26
### Added
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "lembas-cli",
"version": "2.0.0-beta.15",
"version": "2.0.0-beta.16",
"description": "LLeMbas CLI: a terminal coding agent and project manager for a LLeMbas server — OpenTUI, memory, skills, MCP, git-native.",
"license": "MIT",
"private": true,
+22 -9
View File
@@ -870,15 +870,28 @@ export class AcpAgent {
const t = this.terminalFor(p)
if (t) return t.client.request("hub/configure", { sessionId: t.sessionId, model: this.refFor(p?.model), effort: p?.effort }, 30_000)
const s = this.get(p)
const ref = p?.model !== undefined ? this.chatModel(p.model) : undefined
if (ref && s.app.canonicalRef(ref) !== s.app.engine.model.ref) {
const conn = s.app.loaded.connections[this.instanceConnection!]
const id = s.app.canonicalRef(ref)
if (!conn) throw new RpcError(INVALID_PARAMS, `this device is not logged in to ${this.instanceConnection}, so it cannot run ${p.model}`)
if (Object.keys(conn.models).length && !conn.models[id]) throw new RpcError(INVALID_PARAMS, `${conn.webui?.name ?? this.instanceConnection} does not serve ${p.model} to this device`)
// The person's change is the directory's model from now (spec 3.9.0) — a schedule's session
// apart, which the app was told never to remember.
s.app.chooseModel(ref)
if (p?.model !== undefined) {
if (this.instanceConnection || this.limits) {
const ref = this.chatModel(p.model)
if (s.app.canonicalRef(ref) !== s.app.engine.model.ref) {
const conn = s.app.loaded.connections[this.instanceConnection!]
const id = s.app.canonicalRef(ref)
if (!conn) throw new RpcError(INVALID_PARAMS, `this device is not logged in to ${this.instanceConnection}, so it cannot run ${p.model}`)
if (Object.keys(conn.models).length && !conn.models[id]) throw new RpcError(INVALID_PARAMS, `${conn.webui?.name ?? this.instanceConnection} does not serve ${p.model} to this device`)
// The person's change is the directory's model from now (spec 3.9.0) — a schedule's session
// apart, which the app was told never to remember.
s.app.chooseModel(ref)
}
} else {
// Local stdio editor client: resolve against the device's own signed-in models.
const raw = typeof p.model === "string" ? p.model.trim() : ""
if (!raw) throw new RpcError(INVALID_PARAMS, "model must be a non-empty string")
try {
if (s.app.canonicalRef(raw) !== s.app.engine.model.ref) s.app.chooseModel(raw)
} catch (e) {
throw new RpcError(INVALID_PARAMS, (e as Error).message)
}
}
}
const effort = effortOf(p?.effort)
// A level the model does not offer is read as its start level; the answer says the one used.
+15
View File
@@ -861,3 +861,18 @@ test("a client that writes puts the text into its buffer and saves before answer
expect(readFileSync(file, "utf8")).toBe("a third\n")
expect(readFileSync(join(root, "b.txt"), "utf8")).toBe("new\n")
})
test("_lembas/configure on serve --stdio switches the session model without an instance device link", async () => {
fake = fakeProvider([{ chunks: [delta({ content: "switched" })] }])
config(fake.url)
const root = project()
const { c } = await editor()
const s: any = await c.request("session/new", { cwd: root })
expect(s._meta.lembas.model).toBe("f/m")
const res: any = await c.request("_lembas/configure", { sessionId: s.sessionId, model: "f/deep" })
expect(res.model).toBe("f/deep")
await c.request("session/prompt", { sessionId: s.sessionId, prompt: [{ type: "text", text: "hi" }] })
expect(fake.requests.at(-1).model).toBe("f/deep")
// Empty model string is rejected cleanly.
expect((await refusal(c.request("_lembas/configure", { sessionId: s.sessionId, model: " " }))).message).toContain("non-empty")
})