@@ -130,7 +130,7 @@ export type ToolOptions<
130130export const tool = <
131131 Parameters extends ToolSchema < any > = typeof Schema . Unknown ,
132132 Success extends ToolSchema < any > = typeof Schema . Unknown ,
133- Result extends Effect . Effect < Schema . Schema . Type < Success > , ToolFailure > = never ,
133+ Result extends Effect . Effect < Schema . Schema . Type < Success > , ToolFailure > | NoExecute = NoExecute ,
134134> (
135135 config : ToolOptions <
136136 Parameters ,
@@ -139,14 +139,22 @@ export const tool = <
139139 > ,
140140) => build ( config , config . execute )
141141
142- /** @internal Builds a tool for both clients from its options and an Effect `execute`; no `execute` infers `never`. */
143- export function build < Parameters extends ToolSchema < any > , Success extends ToolSchema < any > , Execute > (
144- config : ToolOptions < Parameters , Success , Execute > ,
145- execute : ToolExecute < Parameters , ToolSchema < unknown > > | undefined ,
146- ) : Execute extends ( ...args : never ) => never ? Tool < Parameters , Success > : ExecutableTool < Parameters , Success >
142+ declare const noExecute : unique symbol
143+ /** @internal The inferred `execute` result when `execute` is omitted; no function can return it. */
144+ export type NoExecute = { readonly [ noExecute ] : never }
145+
146+ /** @internal Builds a tool for both clients from its options and an Effect `execute`. */
147+ export function build < Parameters extends ToolSchema < any > , Success extends ToolSchema < any > , Result > (
148+ config : ToolOptions < Parameters , Success , ( ...args : never ) => Result > ,
149+ execute : ( ( params : Schema . Schema . Type < Parameters > , context ?: ToolExecuteContext ) => unknown ) | undefined ,
150+ ) : 0 extends 1 & Result // `any`
151+ ? ExecutableTool < Parameters , Success >
152+ : [ Result , NoExecute ] extends [ NoExecute , Result ]
153+ ? Tool < Parameters , Success >
154+ : ExecutableTool < Parameters , Success >
147155export function build (
148156 config : ToolOptions < ToolSchema < any > , ToolSchema < any > , unknown > ,
149- execute : ToolExecute < ToolSchema < any > , ToolSchema < any > > | undefined ,
157+ execute : ( ( params : any , context ?: ToolExecuteContext ) => any ) | undefined ,
150158) : Tool {
151159 const shared = {
152160 description : config . description ,
0 commit comments