This commit is contained in:
+38
-8
@@ -52,6 +52,7 @@ async function host(
|
||||
> = {},
|
||||
configuredMcpTools: string[] = [],
|
||||
directory = "/test",
|
||||
workspaceID?: string,
|
||||
) {
|
||||
const agents = new Map<string, DeepMutable<Agent.Info>>();
|
||||
const build: DeepMutable<Agent.Info> = Agent.Info.default(Agent.ID.make("build"));
|
||||
@@ -131,13 +132,11 @@ async function host(
|
||||
// SAFETY: This test host implements the native APIs used by setup; unrelated context
|
||||
// services are deliberately absent so unexpected new dependencies fail the test.
|
||||
const context = {
|
||||
location: { directory },
|
||||
location: { directory, workspaceID },
|
||||
options,
|
||||
catalog: {
|
||||
model: {
|
||||
async list() {
|
||||
return { data: models };
|
||||
},
|
||||
model: {
|
||||
async list() {
|
||||
return { data: models };
|
||||
},
|
||||
},
|
||||
event: {
|
||||
@@ -249,7 +248,16 @@ async function host(
|
||||
async refresh(next: ModelInfo[]) {
|
||||
models = next;
|
||||
reloaded = Promise.withResolvers<void>();
|
||||
events.enqueue({ type: "catalog.updated" });
|
||||
events.enqueue({ type: "model.updated" });
|
||||
await reloaded.promise;
|
||||
},
|
||||
publishModels(next: ModelInfo[], location?: { directory: string; workspaceID?: string }) {
|
||||
models = next;
|
||||
if (location) events.enqueue({ type: "model.updated", location });
|
||||
else events.enqueue({ type: "model.updated" });
|
||||
},
|
||||
async waitForReload() {
|
||||
reloaded = Promise.withResolvers<void>();
|
||||
await reloaded.promise;
|
||||
},
|
||||
async changeBuildPermissions(permissions: Agent.Info["permissions"]) {
|
||||
@@ -668,7 +676,12 @@ test("coordinator defaults expose their effort variant without relying on it for
|
||||
expect(custom.agents.get("coordinate")?.request.settings.reasoningEffort).toBe("xhigh");
|
||||
});
|
||||
|
||||
test("catalog updates activate late models and remove unavailable agents", async () => {
|
||||
test("the current host model API filters discovery and reloads changed availability", async () => {
|
||||
const disabled = { ...reasoningModel("gpt-5.6-luna"), enabled: false };
|
||||
const other = { ...reasoningModel("gpt-5.6-sol"), providerID: Provider.ID.make("other") };
|
||||
expect((await host([disabled, other, ...allModels.slice(1)])).agents.has("coordinate")).toBe(
|
||||
false,
|
||||
);
|
||||
const result = await host([]);
|
||||
await result.refresh(allModels);
|
||||
expect(String(result.agents.get("coordinate")?.model?.id)).toBe("gpt-6-astra");
|
||||
@@ -718,6 +731,23 @@ test("events from another location do not reload this location's agents", async
|
||||
).toBe("ask");
|
||||
});
|
||||
|
||||
test("model updates require an exact workspace match within the same directory", async () => {
|
||||
const result = await host([], { provider: "test" }, {}, [], "/test", "workspace-a");
|
||||
|
||||
result.publishModels(allModels, { directory: "/test" });
|
||||
await Bun.sleep(0);
|
||||
expect(result.agents.has("coordinate")).toBe(false);
|
||||
|
||||
result.publishModels(allModels, { directory: "/test", workspaceID: "workspace-b" });
|
||||
await Bun.sleep(0);
|
||||
expect(result.agents.has("coordinate")).toBe(false);
|
||||
|
||||
const reloaded = result.waitForReload();
|
||||
result.publishModels(allModels, { directory: "/test", workspaceID: "workspace-a" });
|
||||
await reloaded;
|
||||
expect(result.agents.has("coordinate")).toBe(true);
|
||||
});
|
||||
|
||||
test("todo lists persist within one session without leaking to another", async () => {
|
||||
const result = await host();
|
||||
const todos = [{ id: "1", content: "Implement", status: "in_progress", priority: "high" }];
|
||||
|
||||
Reference in New Issue
Block a user