AS AgentScopeAPI 手册 / API Reference

PermissionEngine

public final class PermissionEngine
源码Source io/agentscope/core/permission/PermissionEngine.java:47–335

权限引擎,驱动智能体的推理、工具调用与会话执行。位于 io.agentscope.core.permission 包。核心成员包括 getContext、addRule、getAllowRules、getDenyRules、getAskRules、checkPermission。

Evaluates tool execution requests against configured permission rules.

Evaluation order:

  • Tool-level deny rules (highest priority).

  • Tool-level ask rules.

  • Tool-specific checks (bypass-immune): EXPLORE/ACCEPT_EDITS read-only handling, dangerous path checks, plus whatever the tool's own ToolBase#checkPermissions returns.

  • Tool-level allow rules.

  • PermissionMode#BYPASS fallback.

  • Default ASK (converted to DENY under PermissionMode#DONT_ASK).

The engine snapshots rules from the supplied PermissionContextState into its own mutable tables on construction; the original context is never mutated. Use #addRule to extend the engine's rule set at runtime.

构造器摘要Constructor Summary

构造器Constructor说明Description
public PermissionEngine(PermissionContextState context)
初始化 `PermissionEngine` 实例。
Creates an engine seeded from the given context's rules and mode.

方法摘要Method Summary

方法Method说明Description
public PermissionContextState getContext()
获取上下文。
Returns the underlying context (mode and working directories are read from it).
public void addRule(PermissionRule rule)
添加规则。
Adds a rule to the engine's internal rule set.
public Map<String, List<PermissionRule>> getAllowRules()
获取 `getAllowRules`。
Read-only view of the engine's current allow-rule table.
public Map<String, List<PermissionRule>> getDenyRules()
获取拒绝规则。
Read-only view of the engine's current deny-rule table.
public Map<String, List<PermissionRule>> getAskRules()
获取 `getAskRules`。
Read-only view of the engine's current ask-rule table.
public Mono<PermissionDecision> checkPermission(ToolBase tool, Map<String, Object> toolInput)
检查权限。
Resolves a permission decision for the given tool invocation.

构造器详情Constructor Detail

PermissionEngine

public PermissionEngine(PermissionContextState context)

初始化 PermissionEngine 实例。

Creates an engine seeded from the given context's rules and mode.

参数Parameters
名称Name类型Type说明Description
contextPermissionContextState上下文(类型 `PermissionContextState`)。permission context providing mode, working directories, and initial rules
源码Source io/agentscope/core/permission/PermissionEngine.java:59–64

方法详情Method Detail

getContext

public PermissionContextState getContext()

获取上下文。

Returns the underlying context (mode and working directories are read from it).

返回Returns PermissionContextState
返回PermissionContextState。the immutable context this engine was constructed with
源码Source io/agentscope/core/permission/PermissionEngine.java:82–84

addRule

public void addRule(PermissionRule rule)

添加规则。

Adds a rule to the engine's internal rule set.

参数Parameters
名称Name类型Type说明Description
rulePermissionRule规则(类型 `PermissionRule`)。the rule to add; must be non-null
源码Source io/agentscope/core/permission/PermissionEngine.java:94–106

getAllowRules

public Map<String, List<PermissionRule>> getAllowRules()

获取 getAllowRules。

Read-only view of the engine's current allow-rule table.

返回Returns Map<String, List<PermissionRule>>
返回映射。Returns map.
源码Source io/agentscope/core/permission/PermissionEngine.java:109–111

getDenyRules

public Map<String, List<PermissionRule>> getDenyRules()

获取拒绝规则。

Read-only view of the engine's current deny-rule table.

返回Returns Map<String, List<PermissionRule>>
返回映射。Returns map.
源码Source io/agentscope/core/permission/PermissionEngine.java:114–116

getAskRules

public Map<String, List<PermissionRule>> getAskRules()

获取 getAskRules。

Read-only view of the engine's current ask-rule table.

返回Returns Map<String, List<PermissionRule>>
返回映射。Returns map.
源码Source io/agentscope/core/permission/PermissionEngine.java:119–121

checkPermission

public Mono<PermissionDecision> checkPermission(ToolBase tool, Map<String, Object> toolInput)

检查权限。

Resolves a permission decision for the given tool invocation.

参数Parameters
名称Name类型Type说明Description
toolToolBase工具(类型 `ToolBase`)。the tool being called
toolInputMap<String, Object>输入映射工具将接收。the input map the tool will receive
返回Returns Mono<PermissionDecision>
返回Mono。a Mono emitting the resolved `PermissionDecision`
源码Source io/agentscope/core/permission/PermissionEngine.java:139–178
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.