PathPolicy
public final class PathPolicy
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()
返回 empty 结果。
Returns a policy that allows no absolute paths.
PathPolicyio/agentscope/harness/agent/workspace/PathPolicy.java:45–47of
public static PathPolicy of(Path first, Path... rest)
创建并返回实例。
Builds a policy from one or more roots.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
first | Path | 第一个(类型 `Path`)。The first. |
rest varargs | Path... | REST(类型 `Path...`)。The rest. |
PathPolicyio/agentscope/harness/agent/workspace/PathPolicy.java:53–62of
public static PathPolicy of(Collection<Path> roots)
创建并返回实例。
Builds a policy from a collection of roots.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
roots | Collection<Path> | roots(类型 `Collection`)。The roots. |
PathPolicyio/agentscope/harness/agent/workspace/PathPolicy.java:67–76roots
public List<Path> roots()
返回 roots 结果。
Returns the configured roots in insertion order.
List<Path>io/agentscope/harness/agent/workspace/PathPolicy.java:86–88isEmpty
public boolean isEmpty()
判断是否 isEmpty。
true when no roots are configured.
booleanio/agentscope/harness/agent/workspace/PathPolicy.java:91–93isAllowed
public boolean isAllowed(Path candidate)
判断是否已允许。
true when candidate is equal to or below one of the configured roots.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
candidate | Path | candidate(类型 `Path`)。The candidate. |
booleanio/agentscope/harness/agent/workspace/PathPolicy.java:99–110equals
public boolean equals(Object o)
设置该参数。
Performs the equals operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
o | Object | o(类型 `Object`)。The o. |
booleanio/agentscope/harness/agent/workspace/PathPolicy.java:112–115hashCode
public int hashCode()
返回 hashCode 结果。
Returns the hash code.
intio/agentscope/harness/agent/workspace/PathPolicy.java:117–120toString
public String toString()
返回 toString 结果。
Returns the to string.
Stringio/agentscope/harness/agent/workspace/PathPolicy.java:122–125