fix: emit #/$defs/ refs in set_tasks schema

TypeBox Type.Cyclic generates bare local refs ("AddTask") which strict
moonshot-flavored JSON Schema gateways (Console Go upstream) reject with
HTTP 400. Rewrite all local $ref values to the #/$defs/ form after
building the schema, and add a regression test asserting the ref format.

Bump version to 0.2.2.
This commit is contained in:
lesetong
2026-08-10 00:45:54 +08:00
parent 2ff0a314ed
commit 7971cf1a09
3 changed files with 48 additions and 12 deletions
+11
View File
@@ -31,6 +31,17 @@ test("registers five focused tools without the old add_task alias", () => {
assert.deepEqual(Object.keys(tools.get("get_task").parameters.properties), ["ids"]);
});
test("set_tasks schema uses #/$defs/ refs accepted by strict providers", () => {
const { tools } = registeredTools();
const itemSchema = tools.get("set_tasks").parameters.properties.tasks.items;
// Every local $ref must be a URI reference; bare names ("AddTask") are
// rejected by moonshot-flavored schema validators (Console Go upstream).
assert.equal(itemSchema.$ref, "#/$defs/AddTask");
assert.equal(itemSchema.$defs.AddTask.properties.children.items.$ref, "#/$defs/AddTask");
const serialized = JSON.stringify(tools.get("set_tasks").parameters);
assert.ok(!/"\$ref":"(?!\#)/.test(serialized), "no bare $ref values remain");
});
test("set_tasks appends optional-description tasks and persists a complete snapshot", async () => {
const harness = registeredTools();
const result = await execute(harness.tools.get("set_tasks"), {