AtPathExpansionMiddleware
public class AtPathExpansionMiddleware implements HarnessRuntimeMiddleware
io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:67–196At 路径 Expansion 中间件,在智能体执行流程中提供横切扩展。位于 io.agentscope.harness.agent.middleware 包,实现 HarnessRuntimeMiddleware。核心成员包括 onAgent、AtPathExpansionMiddleware。
Expands @path references in user messages by reading the referenced files through the
active AbstractFilesystem and appending an <attached_file> block at the end of
the message. Mirrors the Claude Code CLI's @file input syntax.
Dispatch by filesystem type (kept as in-line instanceof since there is exactly one
call site):
-
Local (
OverlayFilesystemwrappingLocalFilesystemWithShell) — attemptsfs.read; success triggers attachment, failure (typically because the path falls outside thePathPolicyallow-list) leaves the@pathtext untouched. -
Sandbox (
AbstractSandboxFilesystem, not wrapped in overlay) — treats the reference as a path inside the sandbox; host-path upload is out of scope for this stage. -
Remote (
CompositeFilesystem) — disabled. The agent is not co-located with the user so@pathhas no meaningful resolution; references are left as-is.
Recognises three reference shapes: absolute (@/abs/path), relative
(@./rel or @rel/foo), and home-anchored (@~/file). A bare @word
with no path-like character (slash, dot, tilde) is ignored to avoid swallowing handles such as
@alice.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public AtPathExpansionMiddleware(WorkspaceManager workspaceManager) | 初始化 `AtPathExpansionMiddleware` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next) | 处理智能体事件。 Performs the on agent operation. |
构造器详情Constructor Detail
AtPathExpansionMiddleware
public AtPathExpansionMiddleware(WorkspaceManager workspaceManager)
初始化 AtPathExpansionMiddleware 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceManager | WorkspaceManager | 工作区管理器(类型 `WorkspaceManager`)。The workspace manager. |
io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:90–92方法详情Method Detail
onAgent
public Flux<AgentEvent> onAgent(Agent agent, RuntimeContext ctx, AgentInput input, Function<AgentInput, Flux<AgentEvent>> next)
处理智能体事件。
Performs the on agent operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agent | Agent | 智能体(类型 `Agent`)。The agent. |
ctx | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The ctx. |
input | AgentInput | 输入消息(类型 `AgentInput`)。The input. |
next | Function<AgentInput, Flux<AgentEvent>> | 下一个(类型 `Function >`)。The next. |
Flux<AgentEvent>io/agentscope/harness/agent/middleware/AtPathExpansionMiddleware.java:94–121