agentscope.toolGlob
class Glob(ToolBase)
agentscope/tool/_builtin/_glob.py:45–365Glob,让智能体以受控方式调用外部能力。位于 agentscope.tool 包,继承自 ToolBase。核心成员包括 check_permissions、match_rule、generate_suggestions、call。
The glob tool for fast file pattern matching. Declared in agentscope.tool. Extends ToolBase.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(backend: BackendBase | None = None, glob_helper_path: str | None = None, middlewares: List[ToolMiddlewareB… | 初始化 `Glob` 实例。 Initialize the glob tool. |
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
name | str | 名称字段。 | 'Glob' |
description | str | `description` 字段。 | 'Fast file pattern matching tool that works with\nany codebase size.\n\nSupports glob patterns like "**/*.js" or "src/**/*.ts" and returns\nmatching file paths sorted by modification time (newest first).\n\nUse this tool when you need to find files by pattern across the\ncodebase.\n\nUse head_limit to cap the number of results returned.' |
input_schema | dict[str, Any] | 输入模式字段。 | {'type': 'object', 'properties': {'pattern': {'type': 'string', 'description': "The glob pattern to match against (e.g., '**/*.py', 'src/**/*.ts')"}, 'path': {'type': 'string', 'description': 'The base directory to search from (defaults to current working directory)'}, 'head_limit': {'type': 'integer', 'minimum': 0, 'description': 'Limit output to first N paths. Defaults to 250 when unspecified. Pass 0 for unlimited.'}, 'offset': {'type': 'integer', 'minimum': 0, 'default': 0, 'description': 'Number of matching files to skip before returning results'}}, 'required': ['pattern']} |
is_mcp | bool | 是 MCP字段。 | False |
is_read_only | bool | `is_read_only` 字段。 | True |
is_concurrency_safe | bool | `is_concurrency_safe` 字段。 | True |
is_external_tool | bool | 是外部工具字段。 | False |
is_state_injected | bool | `is_state_injected` 字段。 | False |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def check_permissions(tool_input: dict[str, Any], context: PermissionContext) -> PermissionDecisionasync | 检查权限。 Check permissions for glob pattern matching. |
async def match_rule(rule_content: str | None, tool_input: dict[str, Any]) -> boolasync | 执行 `match_rule` 方法。 Check if a permission rule matches the glob pattern or path. |
async def generate_suggestions(tool_input: dict[str, Any]) -> List[PermissionRule]async | 设置该参数。 Generate suggested permission rules for the glob search. |
async def call(pattern: str, path: str | None = None, head_limit: int | None = None, offset: int = 0) -> ToolChunkasync | 向智能体发送输入并返回最终回复。 Execute the glob pattern matching and return the results. |
构造器详情Constructor Detail
Glob
def __init__(backend: BackendBase | None = None, glob_helper_path: str | None = None, middlewares: List[ToolMiddlewareBase] | None = None) -> None
初始化 Glob 实例。
Initialize the glob tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
backend默认default None | BackendBase | None | backend(类型 `BackendBase | None`)。The sandbox backend to use. When `None`, a :class:`LocalBackend` is created automatically. |
glob_helper_path默认default None | str | None | glob helper 路径(类型 `str | None`)。Filesystem path (inside the backend's environment) to the `_glob_helper.py` script. When `None`, the path is resolved from the installed package resources (suitable for :class:`LocalBackend`). Remote backends (Docker, E2B) should pass the path where the script was deployed during workspace initialization. |
middlewares默认default None | List[ToolMiddlewareBase] | None | 中间件列表(类型 `List[ToolMiddlewareBase] | None`)。Tool middlewares wrapping the tool execution. |
agentscope/tool/_builtin/_glob.py:99–133属性详情Attribute Detail
name
str = 'Glob'名称字段。声明为 str。
The name field.
agentscope/tool/_builtin/_glob.py:48description
str = 'Fast file pattern matching tool that works with\nany codebase size.\n\nSupports glob patterns like "**/*.js" or "src/**/*.ts" and returns\nmatching file paths sorted by modification time (newest first).\n\nUse this tool when you need to find files by pattern across the\ncodebase.\n\nUse head_limit to cap the number of results returned.'description 字段。声明为 str。
The description field.
agentscope/tool/_builtin/_glob.py:51input_schema
dict[str, Any] = {'type': 'object', 'properties': {'pattern': {'type': 'string', 'description': "The glob pattern to match against (e.g., '**/*.py', 'src/**/*.ts')"}, 'path': {'type': 'string', 'description': 'The base directory to search from (defaults to current working directory)'}, 'head_limit': {'type': 'integer', 'minimum': 0, 'description': 'Limit output to first N paths. Defaults to 250 when unspecified. Pass 0 for unlimited.'}, 'offset': {'type': 'integer', 'minimum': 0, 'default': 0, 'description': 'Number of matching files to skip before returning results'}}, 'required': ['pattern']}输入模式字段。声明为 dict[str, Any]。
The input schema field.
agentscope/tool/_builtin/_glob.py:63is_mcp
bool = False是 MCP字段。声明为 bool。
The is mcp field.
agentscope/tool/_builtin/_glob.py:93is_read_only
bool = Trueis_read_only 字段。声明为 bool。
The is read only field.
agentscope/tool/_builtin/_glob.py:94is_concurrency_safe
bool = Trueis_concurrency_safe 字段。声明为 bool。
The is concurrency safe field.
agentscope/tool/_builtin/_glob.py:95is_external_tool
bool = False是外部工具字段。声明为 bool。
The is external tool field.
agentscope/tool/_builtin/_glob.py:96is_state_injected
bool = Falseis_state_injected 字段。声明为 bool。
The is state injected field.
agentscope/tool/_builtin/_glob.py:97方法详情Method Detail
check_permissions
async def check_permissions(tool_input: dict[str, Any], context: PermissionContext) -> PermissionDecision
检查权限。
Glob is a read-only tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tool_input | dict[str, Any] | 工具输入(类型 `dict[str, Any]`)。The tool input. |
context | PermissionContext | 上下文(类型 `PermissionContext`)。The context. |
agentscope/tool/_builtin/_glob.py:135–148match_rule
async def match_rule(rule_content: str | None, tool_input: dict[str, Any]) -> bool
执行 match_rule 方法。
Matches rule_content as a glob pattern against the "pattern" or "path" parameters.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
rule_content | str | None | 规则内容(类型 `str | None`)。Glob pattern to match (e.g., "src/**" to match searches in src), or None to match all invocations |
tool_input | dict[str, Any] | 工具输入(类型 `dict[str, Any]`)。The tool input data containing "pattern" and optional "path" |
agentscope/tool/_builtin/_glob.py:150–187generate_suggestions
async def generate_suggestions(tool_input: dict[str, Any]) -> List[PermissionRule]
设置该参数。
Suggests a rule based on the search path.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
tool_input | dict[str, Any] | 工具输入(类型 `dict[str, Any]`)。The tool input data containing optional "path" key |
agentscope/tool/_builtin/_glob.py:189–222call
async def call(pattern: str, path: str | None = None, head_limit: int | None = None, offset: int = 0) -> ToolChunk
向智能体发送输入并返回最终回复。
Invokes the standalone _glob_helper.py script via exec_shell.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
pattern | str | pattern(类型 `str`)。The glob pattern to match against (e.g. `**/*.py`). |
path默认default None | str | None | 路径(类型 `str | None`)。Base directory to search from. Defaults to the current working directory when `None`. |
head_limit默认default None | int | None | head 限制(类型 `int | None`)。Maximum number of matching paths to return. Defaults to `250`. Pass `0` for unlimited. |
offset默认default 0 | int | 偏移量(类型 `int`)。Number of matching paths to skip before returning results. Defaults to `0`. |
agentscope/tool/_builtin/_glob.py:224–365