Custom connections are gone: the CLI talks to the LLeMbas server it is logged in to
LLeMbas CLI 2.0 is LLeMbas-server-specific (CLI rule 2). Removed: the anthropic, gemini, ollama and responses clients, context discovery and llama-swap unloading (discover.ts), the Connection schema with its dialect, auth, key_cmd, discover, unload_url and one_model_at_a_time, the model `fallback` (it only ever moved to another server), effort_map and cache, and the multi-connection refs. Kept: openai-chat, http, sse, think, effort, tokens and all of src/lembas. - connections.yaml holds the login (`type: webui`, as lembas login writes it). A custom entry from 1.x is read past with a warning that says how to log in, so an old file still starts; with several logins left, the latest is used and the others named. - A model's ref is the id the server serves it under; the older forms (`<login>/<id>`, `<login>/<model>`) still resolve and config.yaml is rewritten once. Without a login there is no model, and the error (and the first-run screen, now the sign-in alone) says `lembas login <address>`. - A login to another server signs this machine out of the previous one. - The window is the server's word (no discovery); a capacity group comes from the server's `capacity.group` alone; embeddings use the server's /v1/embeddings. - `lembas models` lists the server's models; install.sh's starter files, the README and the JSON schemas say the same. Tests: every fixture is a login now (the fake server lists models, answers other GETs with 404, and can hand one model to another script, as a server with several backends); the dialect suites and the cross-connection tests are gone with their code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
80 files changed
+587
-2575
No files matched your search
+3
-21
@@ -5,10 +5,7 @@ import { join } from "node:path"
|
||||
import { createApp } from "../src/app.ts"
|
||||
import type { AskReply, Event } from "../src/bus/index.ts"
|
||||
import { paths } from "../src/config/paths.ts"
|
||||
import { discoverContext } from "../src/provider/discover.ts"
|
||||
import { resetLearned } from "../src/provider/learned.ts"
|
||||
import { OpenAIChatClient } from "../src/provider/openai-chat.ts"
|
||||
import type { ResolvedModel } from "../src/provider/types.ts"
|
||||
import { contextBreakdown, renderBreakdown } from "../src/session/context.ts"
|
||||
import { delta, fakeProvider, toolCall, usage, type Fake } from "./fake-provider.ts"
|
||||
|
||||
@@ -18,7 +15,6 @@ afterEach(() => {
|
||||
resetLearned()
|
||||
})
|
||||
|
||||
const rm = (url: string, id: string): ResolvedModel => ({ ref: `c/${id}`, connectionName: "c", id, spec: {}, connection: { dialect: "openai-chat", base_url: url, models: {} } })
|
||||
|
||||
function app(yaml: string, script: Parameters<typeof fakeProvider>[0], config = "") {
|
||||
fake = fakeProvider(script)
|
||||
@@ -31,24 +27,10 @@ function app(yaml: string, script: Parameters<typeof fakeProvider>[0], config =
|
||||
}
|
||||
|
||||
describe("context", () => {
|
||||
test("discovery: the model list first, then llama-server /props through llama-swap's passthrough", async () => {
|
||||
fake = fakeProvider([])
|
||||
expect(await discoverContext(rm(fake.url, "m1"), new OpenAIChatClient(rm(fake.url, "m1")))).toBe(32768)
|
||||
expect(await discoverContext(rm(fake.url, "swapped"), new OpenAIChatClient(rm(fake.url, "swapped")))).toBe(16384)
|
||||
expect(fake.calls.map((c) => c.path)).toContain("/upstream/swapped/props")
|
||||
})
|
||||
|
||||
test("switching to another connection calls the old one's unload_url", async () => {
|
||||
const a = app(`connections:\n f:\n dialect: openai-chat\n base_url: URL\n unload_url: URL/../unload\n unload_method: GET\n models: { m: {} }\n g:\n dialect: openai-chat\n base_url: URL\n models: { n: {} }\n`, [])
|
||||
a.switchModel("g/n")
|
||||
await Bun.sleep(100)
|
||||
expect(fake!.calls.some((c) => c.path.endsWith("/unload"))).toBe(true)
|
||||
})
|
||||
|
||||
test("past auto_at: nothing already sent is cut; the conversation is compacted, with a table of the reads", async () => {
|
||||
// window 16000, auto_at 0.6 → limit 9600. Harness spec 3.0.0 (context.md): old tool outputs are
|
||||
// never pruned in place — that would make the server read everything after them again.
|
||||
const a = app(`connections:\n f:\n dialect: openai-chat\n base_url: URL\n models: { m: { context: 16000 } }\n`, [
|
||||
const a = app(`connections:\n f:\n type: webui\n url: URL\n models: { f/m: { context: 16000 } }\n`, [
|
||||
{ chunks: [toolCall(0, "c1", "read", '{"path":"big.txt"}'), usage(1000, 10)] },
|
||||
{ chunks: [toolCall(0, "c2", "read", '{"path":"big2.txt"}'), usage(6600, 10)] },
|
||||
{ chunks: [delta({ content: "## Summary\nRead two files." })] },
|
||||
@@ -75,7 +57,7 @@ describe("context", () => {
|
||||
})
|
||||
|
||||
test("too full: compacted mid-task, then told to carry on", async () => {
|
||||
const a = app(`connections:\n f:\n dialect: openai-chat\n base_url: URL\n models: { m: { context: 4000 } }\n`, [
|
||||
const a = app(`connections:\n f:\n type: webui\n url: URL\n models: { f/m: { context: 4000 } }\n`, [
|
||||
{ chunks: [delta({ content: "y".repeat(8000) }), toolCall(0, "c1", "list", "{}"), usage(3900, 2000)] },
|
||||
{ chunks: [delta({ content: "## What we are doing\nA long task." })] },
|
||||
{ chunks: [delta({ content: "carried on" }), usage(500, 5)] },
|
||||
@@ -93,7 +75,7 @@ describe("context", () => {
|
||||
})
|
||||
|
||||
test("/context: parts of the system prompt, tools, the conversation, against the window", async () => {
|
||||
const a = app(`connections:\n f:\n dialect: openai-chat\n base_url: URL\n models: { m: { context: 32768 } }\n`, [{ chunks: [toolCall(0, "c1", "read", '{"path":"big.txt"}'), usage(1500, 20)] }, { chunks: [delta({ content: "ok" }), usage(3100, 5)] }])
|
||||
const a = app(`connections:\n f:\n type: webui\n url: URL\n models: { f/m: { context: 32768 } }\n`, [{ chunks: [toolCall(0, "c1", "read", '{"path":"big.txt"}'), usage(1500, 20)] }, { chunks: [delta({ content: "ok" }), usage(3100, 5)] }])
|
||||
await a.engine.prompt("read it")
|
||||
const system = a.engine.o.system(a.engine.mode, a.engine.model)
|
||||
const text = renderBreakdown(contextBreakdown(a.engine, system, [], undefined, a.engine.o.tools))
|
||||
|
||||
Reference in new issue
Block a user