WorkspacePathNormalizer
public final class WorkspacePathNormalizer
io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:34–164工作区路径 Normalizer,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.workspace 包。核心成员包括 of、normalize。
Normalizes file paths to workspace-relative form by stripping the active mode's workspace prefix.
Only the prefix matching the current filesystem mode is registered, so there is no risk
of a sandbox prefix (/workspace/) accidentally matching a real host directory in
local mode, or vice versa.
Paths that don't match any registered prefix pass through unchanged, preserving the ability to access non-workspace files in modes that allow it.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public static WorkspacePathNormalizer of(String workspacePrefix)static | 创建并返回实例。 Creates a normalizer that strips the given prefix. |
public static WorkspacePathNormalizer of(String... workspacePrefixes)static | 创建并返回实例。 Creates a normalizer that tries multiple prefixes in order. |
public static WorkspacePathNormalizer of(String workspacePrefix, NamespaceFactory namespaceFactory)static | 创建并返回实例。 Creates a normalizer that also strips the runtime namespace beneath the workspace prefix. |
public String normalize(String path)deprecated | 设置该参数。 Normalize a path to workspace-relative form by stripping the active mode's prefix. |
public String normalize(String path, RuntimeContext runtimeContext) | 执行 `normalize` 方法。 Normalizes a path using the namespace for the supplied runtime context. |
方法详情Method Detail
of
public static WorkspacePathNormalizer of(String workspacePrefix)
创建并返回实例。
Creates a normalizer that strips the given prefix.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspacePrefix | String | 工作区 Prefix(类型 `String`)。the workspace root path for the active mode (e.g. `"/workspace"` for sandbox, or the host workspace absolute path for local) |
WorkspacePathNormalizerio/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:50–57of
public static WorkspacePathNormalizer of(String... workspacePrefixes)
创建并返回实例。
Creates a normalizer that tries multiple prefixes in order.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspacePrefixes varargs | String... | 工作区 Prefixes(类型 `String...`)。The workspace prefixes. |
WorkspacePathNormalizerio/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:64–73of
public static WorkspacePathNormalizer of(String workspacePrefix, NamespaceFactory namespaceFactory)
创建并返回实例。
Creates a normalizer that also strips the runtime namespace beneath the workspace prefix.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspacePrefix | String | 工作区 Prefix(类型 `String`)。the unscoped workspace root |
namespaceFactory | NamespaceFactory | 当前运行时命名空间的工厂。factory for the current runtime namespace |
WorkspacePathNormalizerio/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:83–91normalize
public String normalize(String path)
设置该参数。
Normalize a path to workspace-relative form by stripping the active mode's prefix.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。the raw path (absolute or relative) |
Stringio/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:103–106normalize
public String normalize(String path, RuntimeContext runtimeContext)
执行 normalize 方法。
Normalizes a path using the namespace for the supplied runtime context.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。the raw path (absolute or relative) |
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。current operation context |
Stringio/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:119–144