fix(core): make namespace inventory optional

This commit is contained in:
Aiden Cline 2026-08-31 20:03:27 -05:00
parent e55f53b078
commit 3ac848636d
2 changed files with 3 additions and 3 deletions

View file

@ -51,7 +51,7 @@ type Tools = {
export type Inventory = {
readonly tools: ReadonlyMap<string, Info>
readonly namespaces: ReadonlyMap<string, ToolNamespace>
readonly namespaces?: ReadonlyMap<string, ToolNamespace>
}
// Invariant model-facing guidance; the changing tool catalog is delivered through Instructions.
@ -173,7 +173,7 @@ function runtime(
) {
// A path may carry namespace metadata, a callable tool, child tools, or all three.
const root: ToolNode = { children: new Map() }
for (const namespace of inventory.namespaces.values()) getNode(root, namespace.name).namespace = namespace
for (const namespace of inventory.namespaces?.values() ?? []) getNode(root, namespace.name).namespace = namespace
for (const [name, registration] of inventory.tools) {
const child = definition(registration)
getNode(root, qualifiedName(registration)).tool = Tool.make({

View file

@ -17,7 +17,7 @@ const context = {
}
const createCodeMode = (tools: ReadonlyMap<string, Info>) =>
CodeModeTool.create({ tools, namespaces: new Map() }, (_, tool, input, context) => execute(tool, input, context))
CodeModeTool.create({ tools }, (_, tool, input, context) => execute(tool, input, context))
test("execute describes invariant Code Mode behavior", () => {
expect(createCodeMode(new Map()).description).toBe(