类 ToolBase
- 所有已实现的接口:
AgentTool
- 直接已知子类:
McpTool,SchemaOnlyTool
Concrete subclasses describe themselves via the builder (name, description, input schema,
safety flags) and may override checkPermissions(Map, PermissionContextState) to plug their
own self-check into the permission engine. The default implementation returns
PermissionDecision.passthrough(String), which lets the engine fall back to its rule
tables and mode-based defaults.
ToolBase implements AgentTool so instances plug directly into the existing
Toolkit dispatch. Tools that produce results outside the framework (external tools)
should mark externalTool=true; the ToolExecutor surfaces the call through a
ToolSuspendException instead of invoking it locally.
Builder usage:
super(ToolBase.builder()
.name("read")
.description("Read a file")
.inputSchema(schema)
.readOnly(true)
.concurrencySafe(true)
.build());
-
嵌套类概要
嵌套类 -
字段概要
字段修饰符和类型字段说明Sensitive directory names; segment-level matching applies to absolute paths.Sensitive files; subclasses may replace this list to widen or narrow protection. -
构造器概要
构造器限定符构造器说明protectedToolBase(ToolBase.Builder builder) Builder-based constructor (preferred).protectedToolBase(String name, String description, Map<String, Object> inputSchema, boolean readOnly, boolean concurrencySafe, boolean mcp, String mcpName, boolean externalTool, boolean stateInjected) Positional constructor used by built-in tools and any subclass that prefers explicit arguments overbuilder(). -
方法概要
修饰符和类型方法说明static ToolBase.Builderbuilder()reactor.core.publisher.Mono<ToolResultBlock> callAsync(ToolCallParam param) Default tool invocation.reactor.core.publisher.Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context) Tool self-check invoked by the permission engine whenallowRules/askRulesneither allow nor reject the call outright.generateSuggestions(Map<String, Object> toolInput) Default suggestion: a single tool-name-levelPermissionBehavior.ALLOWrule sourced from"suggested".final StringGets the description of the tool.final Stringfinal StringgetName()Gets the name of the tool.Gets the parameters schema for this tool in JSON Schema format.final booleanprotected booleanisDangerousPath(String filePath) final booleanfinal booleanisMcp()final booleanReturns whether this tool performs only read operations and never mutates state.final booleanbooleanDefault rule matcher: anullruleContentmatches every invocation; any non-null pattern is rejected so subclasses can layer their own semantics on top.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 io.agentscope.core.tool.AgentTool
getOutputSchema, getStrict
-
字段详细资料
-
dangerousFiles
Sensitive files; subclasses may replace this list to widen or narrow protection. -
dangerousDirectories
Sensitive directory names; segment-level matching applies to absolute paths.
-
-
构造器详细资料
-
ToolBase
Builder-based constructor (preferred). -
ToolBase
protected ToolBase(String name, String description, Map<String, Object> inputSchema, boolean readOnly, boolean concurrencySafe, boolean mcp, String mcpName, boolean externalTool, boolean stateInjected) Positional constructor used by built-in tools and any subclass that prefers explicit arguments overbuilder(). New code is encouraged to use the builder for clarity.
-
-
方法详细资料
-
getName
从接口复制的说明:AgentToolGets the name of the tool.The name should be unique within a toolkit and follow snake_case convention for compatibility with various LLM providers.
-
getDescription
从接口复制的说明:AgentToolGets the description of the tool.The description should clearly explain what the tool does, when it should be used, and what kind of results it returns. This helps the LLM decide when to invoke the tool.
- 指定者:
getDescription在接口中AgentTool- 返回:
- The tool description (never null)
-
getParameters
从接口复制的说明:AgentToolGets the parameters schema for this tool in JSON Schema format.The schema defines the structure of the input parameters that this tool accepts. It should include:
- type: "object"
- properties: Map of parameter names to their schemas
- required: List of required parameter names
- 指定者:
getParameters在接口中AgentTool- 返回:
- Map representing the JSON Schema for tool parameters (never null)
-
isConcurrencySafe
public final boolean isConcurrencySafe() -
isReadOnly
public final boolean isReadOnly()从接口复制的说明:AgentToolReturns whether this tool performs only read operations and never mutates state.Read-only tools are automatically permitted in restricted execution modes such as Plan Mode, where write operations require explicit approval.
- 指定者:
isReadOnly在接口中AgentTool- 返回:
trueif the tool is read-only;falseby default
-
isExternalTool
public final boolean isExternalTool() -
isStateInjected
public final boolean isStateInjected() -
isMcp
public final boolean isMcp() -
getMcpName
-
callAsync
Default tool invocation. External tools must not be invoked locally; non-external subclasses must override this method. -
checkPermissions
public reactor.core.publisher.Mono<PermissionDecision> checkPermissions(Map<String, Object> toolInput, PermissionContextState context) Tool self-check invoked by the permission engine whenallowRules/askRulesneither allow nor reject the call outright.The default implementation returns
PermissionDecision.passthrough(String), delegating the decision to the engine's rule tables and mode defaults. Tools with fine-grained semantics (Bash, file writers, MCP tools) should override this to surface their own ALLOW / ASK / DENY policy.- 参数:
toolInput- the parsed tool argumentscontext- current permission evaluation context- 返回:
- a Mono emitting the decision; never
null
-
matchRule
Default rule matcher: anullruleContentmatches every invocation; any non-null pattern is rejected so subclasses can layer their own semantics on top. -
generateSuggestions
Default suggestion: a single tool-name-levelPermissionBehavior.ALLOWrule sourced from"suggested". Subclasses with finer-grained context (file paths, command prefixes) override this to produce more specific patterns. -
isDangerousPath
- 返回:
truewhenfilePath's filename matches one ofdangerousFiles(case-insensitive), or when any segment matches one ofdangerousDirectories. Also resolves symlinks and re-checks the real path to prevent bypass via symlink pointing at a dangerous target.
-
builder
-