WorkspaceMapping
Category: Core
Source: workspace_mapping.dart
Describes how a host directory maps onto the working tree as seen inside a runtime.
For the host runtime, [hostCwd] and [runtimeCwd] are identical and no translation is needed. For Docker, [hostCwd] is the user's working directory and [runtimeCwd] is the bind-mount target inside the container (/workspace). For cloud runtimes, [hostCwd] is the local source the agent edits and [runtimeCwd] is the path inside the sandbox where the workspace lives.
Classes
WorkspaceMapping
Describes how a host directory maps onto the working tree as seen inside a runtime.
For the host runtime, [hostCwd] and [runtimeCwd] are identical and no translation is needed. For Docker, [hostCwd] is the user's working directory and [runtimeCwd] is the bind-mount target inside the container (/workspace). For cloud runtimes, [hostCwd] is the local source the agent edits and [runtimeCwd] is the path inside the sandbox where the workspace lives.
Constructor
WorkspaceMapping({
required this.hostCwd,
required this.runtimeCwd,
String? artifactsDir,
})factory WorkspaceMapping.host(String cwd)Convenience constructor for the no-translation case (host runtime).
WorkspaceMapping(hostCwd: cwd, runtimeCwd: cwd)Properties
| Property | Type | Description |
|---|---|---|
hostCwd | String | Absolute path on the host that holds the user's working tree. |
runtimeCwd | String | Absolute path inside the runtime where [hostCwd] is exposed. Conventionally '/workspace' for Docker and cloud runtimes; equal to [hostCwd] for the host runtime. |
artifactsDir | String | Where session artifacts (e.g. transcripts, end-of-session diffs) are written inside the runtime. Defaults to <runtimeCwd>/.glue/artifacts. |
isIdentity | bool get | True when [hostCwd] equals [runtimeCwd] — i.e. no path translation is needed because the runtime sees the same paths as the host. |
isIdentity | bool get | True when [hostCwd] equals [runtimeCwd] — i.e. no path translation is needed because the runtime sees the same paths as the host. |
Methods
String? toRuntimePath(String hostPath)
Translates a host path into the equivalent runtime path.
Returns null when [hostPath] is not under [hostCwd] — callers can use that to decide whether to reject the path or pass it through unchanged.
String toHostPath(String runtimePath)
Translates a runtime path back to the equivalent host path.
Paths that already look like host paths (e.g. when the runtime is the host itself) pass through unchanged. Paths that are not under [runtimeCwd] are returned as-is so callers can decide whether to reject or pass them through.