Skip to content

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

dart
WorkspaceMapping({
    required this.hostCwd,
    required this.runtimeCwd,
    String? artifactsDir,
  })
dart
factory WorkspaceMapping.host(String cwd)

Convenience constructor for the no-translation case (host runtime).

dart
WorkspaceMapping(hostCwd: cwd, runtimeCwd: cwd)

Properties

PropertyTypeDescription
hostCwdStringAbsolute path on the host that holds the user's working tree.
runtimeCwdStringAbsolute path inside the runtime where [hostCwd] is exposed. Conventionally '/workspace' for Docker and cloud runtimes; equal to [hostCwd] for the host runtime.
artifactsDirStringWhere session artifacts (e.g. transcripts, end-of-session diffs) are written inside the runtime. Defaults to <runtimeCwd>/.glue/artifacts.
isIdentitybool getTrue when [hostCwd] equals [runtimeCwd] — i.e. no path translation is needed because the runtime sees the same paths as the host.
isIdentitybool getTrue 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.

String toString()

Released under the MIT License.