AS AgentScopeAPI 手册 / API Reference

WorkspacePathNormalizer

public final class WorkspacePathNormalizer
源码Source 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)
static

创建并返回实例。

Creates a normalizer that strips the given prefix.

参数Parameters
名称Name类型Type说明Description
workspacePrefixString工作区 Prefix(类型 `String`)。the workspace root path for the active mode (e.g. `"/workspace"` for sandbox, or the host workspace absolute path for local)
返回Returns WorkspacePathNormalizer
返回WorkspacePathNormalizer。Returns workspace path normalizer.
源码Source io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:50–57

of

public static WorkspacePathNormalizer of(String... workspacePrefixes)
static

创建并返回实例。

Creates a normalizer that tries multiple prefixes in order.

参数Parameters
名称Name类型Type说明Description
workspacePrefixes varargsString...工作区 Prefixes(类型 `String...`)。The workspace prefixes.
返回Returns WorkspacePathNormalizer
返回WorkspacePathNormalizer。Returns workspace path normalizer.
源码Source io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:64–73

of

public static WorkspacePathNormalizer of(String workspacePrefix, NamespaceFactory namespaceFactory)
static

创建并返回实例。

Creates a normalizer that also strips the runtime namespace beneath the workspace prefix.

参数Parameters
名称Name类型Type说明Description
workspacePrefixString工作区 Prefix(类型 `String`)。the unscoped workspace root
namespaceFactoryNamespaceFactory当前运行时命名空间的工厂。factory for the current runtime namespace
返回Returns WorkspacePathNormalizer
返回WorkspacePathNormalizer。Returns workspace path normalizer.
源码Source io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:83–91

normalize

public String normalize(String path)
deprecated

设置该参数。

Normalize a path to workspace-relative form by stripping the active mode's prefix.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。the raw path (absolute or relative)
返回Returns String
返回字符串结果。workspace-relative path, or the original path if no registered prefix matched
源码Source io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:103–106

normalize

public String normalize(String path, RuntimeContext runtimeContext)

执行 normalize 方法。

Normalizes a path using the namespace for the supplied runtime context.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。the raw path (absolute or relative)
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。current operation context
返回Returns String
返回字符串结果。workspace-relative path, or the original path if no registered prefix matched
源码Source io/agentscope/harness/agent/workspace/WorkspacePathNormalizer.java:119–144
基于官方固定版本源码静态生成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.