Reflective工具

Builds a BaseTool from a Tool-annotated Java method, on the JVM only, for javac-only modules; prefer the KSP @Tool path whenever the code is built with the Kotlin compiler, which processes .java sources too. It reads the same Tool/Param annotations, including Tool.requireConfirmation, relying on Param.name/Param.required because Java retains neither parameter names nor nullability; every parameter needs Param except one Context or ToolContext and one experimental Publisher<LiveRequest> (or Publisher<? extends LiveRequest>), which carries ToolContext.liveRequests. Like a KSP tool, the method runs in the calling coroutine and keeps its context (such as MDC), so run blocking methods on a dispatcher meant for blocking work, such as PublisherRunner.runAsync's default; a returned Reactive Streams Publisher acts as a returned Flow does (see BaseTool.run).

函数

Link copied to clipboard
fun fromMethod(instance: Any, method: Method): BaseTool

构建一个…… BaseTool 从某个明确的(或具体的)来源/对象开始…… 方法 在……的时候;当……发生时 实例.

fun fromMethod(instance: Any, methodName: String): BaseTool

构建一个…… BaseTool from the 工具- 带注释的方法(方法名称已给出) methodName 在……的时候;当……发生时 实例.