@@ -39,15 +39,15 @@ type CollectedFiles = {
3939interface Registration {
4040 readonly tool : AnyTool
4141 readonly name : string
42- readonly group ?: string
42+ readonly namespace ?: string
4343}
4444
4545export const create = ( registrations : ReadonlyMap < string , Registration > ) => {
4646 const runtime = (
4747 invoke : ( name : string , registration : Registration , input : unknown ) => Effect . Effect < unknown , unknown > ,
4848 hooks ?: CodeMode . ToolCallHooks ,
4949 ) => {
50- const tools : Record < string , Tool . Definition < never > | Record < string , Tool . Definition < never > > > = { }
50+ const tools : Record < string , Tool . Definition < never > > = { }
5151 for ( const [ name , registration ] of registrations ) {
5252 const child = definition ( name , registration . tool )
5353 const value = Tool . make ( {
@@ -56,24 +56,8 @@ export const create = (registrations: ReadonlyMap<string, Registration>) => {
5656 output : child . outputSchema ,
5757 run : ( input ) => invoke ( name , registration , input ) ,
5858 } )
59- if ( registration . group === undefined ) {
60- const path = registration . name
61- if ( Object . hasOwn ( tools , path ) ) throw new TypeError ( `CodeMode tool namespace conflict: ${ path } ` )
62- tools [ path ] = value
63- continue
64- }
65- const path = registration . name
66- const namespace = registration . group
67- const group = tools [ namespace ]
68- if ( group && Tool . isDefinition ( group ) ) throw new TypeError ( `CodeMode tool namespace conflict: ${ namespace } ` )
69- if ( group ) {
70- if ( Object . hasOwn ( group , path ) ) throw new TypeError ( `CodeMode tool namespace conflict: ${ namespace } .${ path } ` )
71- group [ path ] = value
72- continue
73- }
74- const entries : Record < string , Tool . Definition < never > > = { }
75- entries [ path ] = value
76- tools [ namespace ] = entries
59+ const path = registration . namespace === undefined ? registration . name : `${ registration . namespace } .${ registration . name } `
60+ tools [ path ] = value
7761 }
7862 return CodeMode . make < typeof tools > ( { tools, ...hooks } )
7963 }
0 commit comments