Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c4bd3c5
Standardize neutral engine facts
jaywedgeworth22 Oct 13, 2026
46291d5
Unify engine rows and connection actions
jaywedgeworth22 Oct 13, 2026
a4c7ddf
Keep ASCII.dev Box in Computer settings
jaywedgeworth22 Oct 13, 2026
8fc016c
Use platform marks in capability rows
jaywedgeworth22 Oct 13, 2026
1514009
Test neutral engine facts
jaywedgeworth22 Oct 13, 2026
610c2d3
Test Box settings ownership
jaywedgeworth22 Oct 13, 2026
2fb0e8f
Test platform-mark capability rows
jaywedgeworth22 Oct 13, 2026
725f410
Remove obsolete engine callout import
jaywedgeworth22 Oct 13, 2026
5029319
Preserve capability mark literals
jaywedgeworth22 Oct 13, 2026
af4ff6a
Update model picker engine facts
jaywedgeworth22 Oct 13, 2026
274bec6
Keep capability rows and platform marks complete
jaywedgeworth22 Oct 13, 2026
81f3fc5
Expose OpenAI-compatible visibility rule
jaywedgeworth22 Oct 13, 2026
bb55100
Cover engine row visibility visually
jaywedgeworth22 Oct 13, 2026
38fa651
Add exact engine settings screenshots
jaywedgeworth22 Oct 13, 2026
16c1b70
Scope hidden OpenAI row assertion
jaywedgeworth22 Oct 13, 2026
ce10a1f
Add configured engine settings baseline
jaywedgeworth22 Oct 13, 2026
721a9f7
Scope Codex row assertion
jaywedgeworth22 Oct 13, 2026
6cb83cf
Add hidden engine settings baseline
jaywedgeworth22 Oct 13, 2026
5c3a81f
Keep local models out of engine facts
jaywedgeworth22 Oct 13, 2026
72b5661
Update Box placement contract
jaywedgeworth22 Oct 13, 2026
c04850c
Allow per-engine user model settings
jaywedgeworth22 Oct 13, 2026
e1afabb
Validate engine model additions
jaywedgeworth22 Oct 13, 2026
29040bb
Expose user-added engine models
jaywedgeworth22 Oct 13, 2026
114b09d
Add per-engine model entry form
jaywedgeworth22 Oct 13, 2026
fbaa8a5
fix(engines): validate model edits and cover endpoint visibility
jaywedgeworth22 Oct 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ function mergeConfigPatch(raw: Record<string, unknown>, checkedPatch: CheckedCon
export function patchInstanceConfig(
cfg: AppConfig,
instanceId: string,
patch: { cli?: string; fullAuto?: boolean; enabled?: boolean; key?: string; externalCredential?: boolean },
patch: { cli?: string; fullAuto?: boolean; enabled?: boolean; key?: string; externalCredential?: boolean; models?: Array<{ id: string; label: string }> },
): InstanceCliUpdate {
const next: AppConfig = structuredClone(cfg);
const map = instanceConfigs(next);
Expand Down Expand Up @@ -1853,6 +1853,14 @@ export function patchInstanceConfig(
}
}

if (patch.models !== undefined) {
if (patch.models.length) {
nextConfig.userModels = patch.models;
} else {
delete nextConfig.userModels;
}
}

if (patch.fullAuto !== undefined) {
if (patch.fullAuto) {
nextConfig.fullAuto = true;
Expand Down
18 changes: 18 additions & 0 deletions server/harness/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
// touching its siblings.
import { existsSync, mkdirSync, readFileSync } from "node:fs";
import { dirname } from "node:path";
import { z } from "zod";
import { instanceModelsSchema } from "../instance-models.ts";
import { writeFileAtomic } from "../atomic.ts";
import { usageQuotaPoller } from "../usage-quota.ts";
import { windowHeadlines, windowsLabelFromHeadlines } from "../../src/lib/quota-display.ts";
Expand Down Expand Up @@ -222,6 +224,14 @@ function fullAutoOfRaw(raw: unknown): boolean {
return (raw as { fullAuto?: unknown } | undefined)?.fullAuto === true;
}

const userModelConfigSchema = z.object({ userModels: instanceModelsSchema.optional() }).passthrough();

function userModelsOfRaw(raw: InstanceConfig["config"]): Array<{ id: string; label: string; custom: true }> {
const parsed = userModelConfigSchema.safeParse(raw);
if (!parsed.success) return [];
return (parsed.data.userModels ?? []).map((model) => ({ ...model, custom: true as const }));
}

export interface DescribedInstance {
instanceId: InstanceId;
driverKind: string;
Expand Down Expand Up @@ -383,6 +393,14 @@ export class ProviderRegistry {
enabled,
config,
});
const userModels = userModelsOfRaw(entry.config);
if (userModels.length) {
const byId = new Map(live.models.options.map((model) => [model.id, model]));
for (const model of userModels) {
byId.set(model.id, { ...byId.get(model.id), ...model });
}
live.models.options = [...byId.values()];
}
this.byId.set(instanceId, { instanceId, live });
return live;
} catch (e) {
Expand Down
9 changes: 8 additions & 1 deletion server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { isIP } from "node:net";
import { extname, join } from "node:path";

import { z } from "zod";
import { instanceModelsSchema } from "./instance-models.ts";
import { ScreenPollers } from "./screen-poller.ts";
import { ReplayBuffer, SLOW_CLIENT_BYTE_LIMIT, wants, writeToClient, type SseClient } from "./sse-broadcast.ts";
import { BOT_AVATAR_CROPS, botAvatarUrlFromStoredPath, botAvatarUrlSchema } from "../shared/bot-avatar.ts";
Expand Down Expand Up @@ -15598,14 +15599,20 @@ handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
return json(res, 415, { error: UNSUPPORTED_JSON_BODY });
}
const body = await readBody(req);
const patchOptions: { cli?: string; fullAuto?: boolean; enabled?: boolean; key?: string; externalCredential?: boolean } = {};
const patchOptions: { cli?: string; fullAuto?: boolean; enabled?: boolean; key?: string; externalCredential?: boolean; models?: Array<{ id: string; label: string }> } = {};

if (body?.cli !== undefined) {
if (typeof body.cli !== "string") return json(res, 400, { error: "cli must be a string" });
if (/[\n\r]/.test(body.cli)) return json(res, 400, { error: "cli must not contain newlines" });
patchOptions.cli = body.cli;
}

if (body?.models !== undefined) {
const parsedModels = instanceModelsSchema.safeParse(body.models);
if (!parsedModels.success) return json(res, 400, { error: "models must contain at most 100 unique IDs with valid labels" });
patchOptions.models = parsedModels.data;
}

if (body?.fullAuto !== undefined) {
if (typeof body.fullAuto !== "boolean") return json(res, 400, { error: "fullAuto must be a boolean" });
patchOptions.fullAuto = body.fullAuto;
Expand Down
21 changes: 21 additions & 0 deletions server/instance-models.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { describe, expect, it } from "vitest";
import { instanceModelsSchema } from "./instance-models.ts";

describe("instance model edits", () => {
it("trims and strips incoming fields, and accepts an explicit cleared catalog", () => {
expect(instanceModelsSchema.parse([{ id: " model/a ", label: " Model A ", unexpected: true }]))
.toEqual([{ id: "model/a", label: "Model A" }]);
expect(instanceModelsSchema.parse([])).toEqual([]);
});

it("rejects malformed, excessive, multiline, and duplicate entries", () => {
const valid = { id: "model/a", label: "Model A" };
const invalid = [null, {}, [null], [{ id: 1, label: "A" }],
[{ id: " ", label: "A" }], [{ id: "a", label: "" }],
[{ id: "a\nb", label: "A" }], [{ id: "a", label: "A\rB" }],
[{ id: "a".repeat(201), label: "A" }], [{ id: "a", label: "A".repeat(201) }],
[valid, { id: " model/a ", label: "Another label" }],
Array.from({ length: 101 }, (_, index) => ({ id: `model/${index}`, label: "A" }))];
for (const input of invalid) expect(instanceModelsSchema.safeParse(input).success).toBe(false);
});
});
17 changes: 17 additions & 0 deletions server/instance-models.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { z } from "zod";

const modelText = z.string().trim().min(1).max(200).regex(/^[^\r\n]+$/);

/** Parse model edits at the instance HTTP boundary before persisting them. */
export const instanceModelsSchema = z.array(z.object({
id: modelText,
label: modelText,
}).strip()).max(100).superRefine((models, context) => {
Comment thread
jaywedgeworth22 marked this conversation as resolved.
const seen = new Set<string>();
for (const [index, model] of models.entries()) {
if (seen.has(model.id)) {
context.addIssue({ code: "custom", path: [index, "id"], message: "Duplicate model ID" });
}
seen.add(model.id);
}
});
23 changes: 3 additions & 20 deletions src/components/BoxEngineCallout.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,9 @@ function expectNoCollapsingSentenceGaps(box: string): void {
}
}

describe("ASCII.dev Box engine callout — EnginesSettings row", () => {
const box = engineBox(ENGINES_SETTINGS_SRC, 'instance.driverKind === "boxAgent"');

it("names where the turn actually runs", () => {
expect(box).toMatch(/runs its turn on box\.ascii\.dev/);
expect(box).toMatch(/not on this computer/);
});

it("lists every capability the engine does not have", () => {
for (const missing of ["no team tools", "no peers to ask", "no approval cards", "no memory", "no skills"]) {
expect(box).toContain(missing);
}
});

it("tells the reader what to do instead", () => {
expect(box).toMatch(/Pick another engine/);
});

it("never lets a sentence gap collapse to one space under HTML whitespace rules", () => {
expect(() => expectNoCollapsingSentenceGaps(box)).not.toThrow();
describe("ASCII.dev Box placement", () => {
it("keeps Box out of Engine Settings because it belongs in Computer settings", () => {
expect(ENGINES_SETTINGS_SRC).not.toContain('instance.driverKind === "boxAgent"');
});
});

Expand Down
125 changes: 21 additions & 104 deletions src/components/EngineCallout.test.tsx
Original file line number Diff line number Diff line change
@@ -1,128 +1,45 @@
// EngineCallout shape tests — every known engine renders a collapsed
// "More Info" disclosure by default, and the headline, prose, and
// registry pricing pill when expanded. Replaces the legacy
// MiniMaxCallout.test.ts; the new copy is shared across all engines so
// the matrix and the callout cannot drift.
import { describe, expect, it } from "vitest";
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";

import { EngineCallout } from "./EngineCallout.tsx";
import {
CAPABILITY_LABELS,
ENGINE_CAPABILITIES,
ENGINE_DISPLAY_ORDER,
engineIdFromDriverKind,
} from "@/lib/engine-capabilities.tsx";

// EngineCallout emits JSON-style HTML where ASCII apostrophes and
// quotes are HTML-escaped by `react-dom/server`'s serializer. Comparing
// a raw headline that contains an apostrophe against the rendered
// markup via toContain() produces a false negative; this helper
// normalizes both sides before comparing. Curly quotes (U+2018 /
// U+2019) are passed through by the serializer, so only the ASCII
// entities need decoding. Pinned by the headline-render test.
function decodeHtmlEntities(text: string): string {
return text
.replace(/&#x27;/g, "'")
.replace(/&#39;/g, "'")
.replace(/&apos;/g, "'")
.replace(/&quot;/g, '"')
.replace(/&amp;/g, "&")
.replace(/&lt;/g, "<")
.replace(/&gt;/g, ">");
}
import { ENGINE_CAPABILITIES, ENGINE_DISPLAY_ORDER, engineIdFromDriverKind } from "@/lib/engine-capabilities.tsx";

describe("EngineCallout", () => {
it("renders collapsed by default for every engine id in the registry", () => {
it("shows the same neutral facts for every registered engine", () => {
for (const id of ENGINE_DISPLAY_ORDER) {
const entry = ENGINE_CAPABILITIES[id];
const html = renderToStaticMarkup(createElement(EngineCallout, { engineId: id }));
// The trigger is a neutral disclosure, not a repeated engine pitch.
const decoded = decodeHtmlEntities(html);
// And it is sized to its label, not stretched across the row. Checked as an
// exact class prefix: a bare `not.toContain("w-full")` would also match
// inside `max-w-full` and pass for the wrong reason.
expect(html).toContain("inline-flex w-auto max-w-full");
// The label is split across a <strong>, so compare the text, not markup.
const label = decodeHtmlEntities(html.replace(/<[^>]+>/g, " "))
.replace(/\s+/g, " ")
.trim();
expect(label).toContain("More Info");
expect(label).not.toContain("Why This Engine?");
expect(html).toContain(`aria-label="More Info about ${entry.displayName}"`);
expect(decoded).not.toContain(entry.whyThisEngine.headline);
// Collapsed: one-line summary — no prose paragraphs, no pricing line.
// Avoid /<p/ — Lucide's <path> would falsely match.
expect(html).not.toMatch(/<p[\s>]/);
expect(html).not.toContain("Billing:");
expect(html).toContain('aria-expanded="false"');
expect(html).toContain("aria-hidden");
// No dangling reference: the detail region is not rendered collapsed.
expect(html).not.toContain("aria-controls");
expect(html).toContain("Access:");
expect(html).toContain("Billing:");
expect(html).toContain("Models:");
expect(html).not.toContain("More Info");
expect(html).not.toContain(entry.whyThisEngine.headline);
expect(html).not.toContain("aria-expanded");
}
});

it("expands to show headline, prose, and pricing when defaultOpen is set", () => {
const entry = ENGINE_CAPABILITIES.minimax;
it("uses the live instance model ids when supplied", () => {
const html = renderToStaticMarkup(
createElement(EngineCallout, { engineId: "minimax", defaultOpen: true }),
);
expect(html).toContain('aria-expanded="true"');
expect(html).toMatch(/<p[\s>]/);
expect(html).toContain("Access: API");
expect(html).toContain("Billing: Subscription + API");
const decoded = decodeHtmlEntities(html);
expect(decoded).toContain(entry.whyThisEngine.headline);
expect(decoded).toContain(entry.whyThisEngine.prose[0]);
});

it("uses a unique aria-controls id per instanceId", () => {
const a = renderToStaticMarkup(
createElement(EngineCallout, {
engineId: "minimax",
instanceId: "mm-a",
defaultOpen: true,
engineId: "openai-compat",
models: ["vendor/model-a", "vendor/model-b"],
}),
);
const b = renderToStaticMarkup(
createElement(EngineCallout, {
engineId: "minimax",
instanceId: "mm-b",
defaultOpen: true,
}),
);
expect(a).toContain('aria-controls="engine-callout-detail-mm-a"');
expect(a).toContain('id="engine-callout-detail-mm-a"');
expect(b).toContain("engine-callout-detail-mm-b");
expect(a).not.toContain("engine-callout-detail-mm-b");
expect(html).toContain("vendor/model-a, vendor/model-b");
expect(html).not.toContain("meta-llama/llama-3.3-70b-instruct");
});

it("resolves driver-kind ids via engineIdFromDriverKind", () => {
const html = renderToStaticMarkup(
createElement(EngineCallout, { driverKind: "grokAgent", defaultOpen: true }),
);
const decoded = decodeHtmlEntities(html);
expect(decoded).toContain(ENGINE_CAPABILITIES.grok.whyThisEngine.headline);
it("keeps a long catalog compact while stating how many ids remain", () => {
const models = Array.from({ length: 8 }, (_, index) => `model-${index + 1}`);
const html = renderToStaticMarkup(createElement(EngineCallout, { engineId: "grok", models }));
expect(html).toContain("model-1, model-2, model-3, model-4, model-5, model-6 +2 more");
expect(html).not.toContain("model-7");
});

it("renders the fallback headline when expanded for an unknown engine id", () => {
const html = renderToStaticMarkup(
createElement(EngineCallout, { engineId: "nope", defaultOpen: true }),
);
expect(html).toContain("Engine not in the capability registry yet");
});

it("engineIdFromDriverKind strips the Agent suffix for known drivers", () => {
expect(engineIdFromDriverKind("grokAgent")).toBe("grok");
expect(engineIdFromDriverKind("claudeAgent")).toBe("claude");
it("resolves runtime driver kinds to registry ids", () => {
const html = renderToStaticMarkup(createElement(EngineCallout, { driverKind: "grokAgent" }));
expect(html).toContain("Access:");
expect(engineIdFromDriverKind("dshAgent")).toBe("deepseek-harness");
expect(engineIdFromDriverKind("cursorAgent")).toBe("cursor");
expect(engineIdFromDriverKind("antigravityAgent")).toBe("antigravity");
});

it("renders every capability label as expected prose container", () => {
expect(CAPABILITY_LABELS.files).toBe("Files");
expect(CAPABILITY_LABELS.crossBotCoordination).toBe("Cross-Bot Coordination");
});
});
Loading
Loading