fix: hoist $defs to the schema root for set_tasks
Refs like "#/$defs/AddTask" resolve from the document root, but Type.Cyclic nested the $defs inside tasks.items, so the moonshot-flavored gateway reported "$defs not found for reference". Hoist all $defs entries to the parameter schema root and strip the synthetic $id that would change fragment resolution. Update the regression test to pin the layout. Bump version to 0.2.3.
This commit is contained in:
+10
-6
@@ -31,14 +31,18 @@ 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", () => {
|
||||
test("set_tasks schema hoists $defs to the root with #/$defs/ refs", () => {
|
||||
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).
|
||||
const params = tools.get("set_tasks").parameters;
|
||||
const itemSchema = params.properties.tasks.items;
|
||||
// $defs must live at the document root: root-style refs resolve from there,
|
||||
// and moonshot-flavored validators reject nested definitions (Console Go).
|
||||
assert.ok(params.$defs.AddTask, "$defs hoisted to the parameter schema root");
|
||||
assert.equal(itemSchema.$defs, undefined, "no $defs nested inside tasks items");
|
||||
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.equal(params.$defs.AddTask.properties.children.items.$ref, "#/$defs/AddTask");
|
||||
assert.equal(params.$defs.AddTask.$id, undefined, "synthetic $id stripped");
|
||||
const serialized = JSON.stringify(params);
|
||||
assert.ok(!/"\$ref":"(?!\#)/.test(serialized), "no bare $ref values remain");
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user