AS AgentScopeAPI 手册 / API Reference

PathPolicy

public final class PathPolicy
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:34–126

路径策略,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.workspace 包。核心成员包括 empty、of、roots、isEmpty、isAllowed、equals。

Immutable allow-list of host directories that LocalFsMode#ROOTED accepts for absolute paths. Each root is stored absolute-normalized so child-of checks are cheap.

The Claude-Code-style two-layer Local FS uses PathPolicy.of(project, workspace, additionalRoots) to bound the agent's reach without forcing it into a single hard sandbox.

Empty policy (#empty()) rejects every absolute path; use it only when the caller intends to fall back to relative-only access.

方法摘要Method Summary

方法Method说明Description
public static PathPolicy empty()
static
返回 `empty` 结果。
Returns a policy that allows no absolute paths.
public static PathPolicy of(Path first, Path... rest)
static
创建并返回实例。
Builds a policy from one or more roots.
public static PathPolicy of(Collection<Path> roots)
static
创建并返回实例。
Builds a policy from a collection of roots.
public List<Path> roots()
返回 `roots` 结果。
Returns the configured roots in insertion order.
public boolean isEmpty()
判断是否 `isEmpty`。
`true` when no roots are configured.
public boolean isAllowed(Path candidate)
判断是否已允许。
`true` when `candidate` is equal to or below one of the configured roots.
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
public int hashCode()
返回 `hashCode` 结果。
Returns the hash code.
public String toString()
返回 `toString` 结果。
Returns the to string.

方法详情Method Detail

empty

public static PathPolicy empty()
static

返回 empty 结果。

Returns a policy that allows no absolute paths.

返回Returns PathPolicy
返回PathPolicy。Returns path policy.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:45–47

of

public static PathPolicy of(Path first, Path... rest)
static

创建并返回实例。

Builds a policy from one or more roots.

参数Parameters
名称Name类型Type说明Description
firstPath第一个(类型 `Path`)。The first.
rest varargsPath...REST(类型 `Path...`)。The rest.
返回Returns PathPolicy
返回PathPolicy。Returns path policy.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:53–62

of

public static PathPolicy of(Collection<Path> roots)
static

创建并返回实例。

Builds a policy from a collection of roots.

参数Parameters
名称Name类型Type说明Description
rootsCollection<Path>roots(类型 `Collection`)。The roots.
返回Returns PathPolicy
返回PathPolicy。Returns path policy.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:67–76

roots

public List<Path> roots()

返回 roots 结果。

Returns the configured roots in insertion order.

返回Returns List<Path>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:86–88

isEmpty

public boolean isEmpty()

判断是否 isEmpty。

true when no roots are configured.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:91–93

isAllowed

public boolean isAllowed(Path candidate)

判断是否已允许。

true when candidate is equal to or below one of the configured roots.

参数Parameters
名称Name类型Type说明Description
candidatePathcandidate(类型 `Path`)。The candidate.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:99–110

equals

public boolean equals(Object o)

设置该参数。

Performs the equals operation.

参数Parameters
名称Name类型Type说明Description
oObjecto(类型 `Object`)。The o.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:112–115

hashCode

public int hashCode()

返回 hashCode 结果。

Returns the hash code.

返回Returns int
返回数值结果。Returns a numeric result.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:117–120

toString

public String toString()

返回 toString 结果。

Returns the to string.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/workspace/PathPolicy.java:122–125
基于官方固定版本源码静态生成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.