pub struct WorkspaceServices { /* private fields */ }Expand description
The host-provided workspace capability bundle used by tool execution.
Implementations§
Source§impl WorkspaceServices
impl WorkspaceServices
Sourcepub fn with_remote_git(
self: Arc<Self>,
config: RemoteGitBackendConfig,
) -> Result<Arc<Self>>
pub fn with_remote_git( self: Arc<Self>, config: RemoteGitBackendConfig, ) -> Result<Arc<Self>>
Attach a remote git provider to an existing [WorkspaceServices].
Returns a new Arc<WorkspaceServices> with git and git_stash
wired to the remote backend. The original WorkspaceServices is
not mutated. git_worktree is intentionally reset to None —
worktrees are a local-filesystem concept that does not map cleanly
onto a remote service (see RFC §8). All other fields — including
local_root, the command runner, the search provider, the
optional file_system_ext (S3 CAS), and operation_timeout — are
preserved verbatim via
super::WorkspaceServices::with_git_provider.
Source§impl WorkspaceServices
impl WorkspaceServices
pub fn builder( workspace_ref: WorkspaceRef, file_system: Arc<dyn WorkspaceFileSystem>, ) -> WorkspaceServicesBuilder
pub fn local(root: impl Into<PathBuf>) -> Arc<Self> ⓘ
pub fn workspace_ref(&self) -> &WorkspaceRef
pub fn capabilities(&self) -> WorkspaceCapabilities
pub fn normalize_path(&self, input: &str) -> Result<WorkspacePath>
pub fn fs(&self) -> Arc<dyn WorkspaceFileSystem> ⓘ
Sourcepub fn fs_ext(&self) -> Option<Arc<dyn WorkspaceFileSystemExt>>
pub fn fs_ext(&self) -> Option<Arc<dyn WorkspaceFileSystemExt>>
Optional compare-and-swap file system extensions.
Returns Some when the backend supports version-aware writes (e.g.
S3 via ETag). Tools that perform read-modify-write cycles should
route through Self::read_for_edit and Self::write_for_edit
rather than touching this directly.
pub fn command_runner(&self) -> Option<Arc<dyn WorkspaceCommandRunner>>
pub fn search(&self) -> Option<Arc<dyn WorkspaceSearch>>
pub fn git(&self) -> Option<Arc<dyn WorkspaceGit>>
pub fn git_stash(&self) -> Option<Arc<dyn WorkspaceGitStashProvider>>
pub fn git_worktree(&self) -> Option<Arc<dyn WorkspaceGitWorktreeProvider>>
Sourcepub fn operation_timeout(&self) -> Option<Duration>
pub fn operation_timeout(&self) -> Option<Duration>
Default timeout applied to non-bash workspace operations.
None means no enforced timeout. Backends that may stall (remote,
browser, DFS) should set this so tools using Self::run_with_timeout
surface a timeout error instead of letting the agent loop hang.
Sourcepub async fn run_with_timeout<F, T, E>(
&self,
op: &'static str,
fut: F,
) -> Result<T, E>
pub async fn run_with_timeout<F, T, E>( &self, op: &'static str, fut: F, ) -> Result<T, E>
Run a workspace future under the configured operation timeout.
Tools that route through file system / search / git providers should wrap their calls with this helper so non-local backends never stall the agent loop indefinitely.
Polymorphic in the error type so the helper works equally well for
futures returning anyhow::Result<T> (the legacy callers — search,
git, etc.) and for futures returning WorkspaceResult<T> (the
migrated WorkspaceFileSystem callers). The E: From<anyhow::Error>
bound is satisfied by both anyhow::Error (trivially) and
WorkspaceError (via its #[from] Backend variant); a timeout
surfaces as that From conversion of an anyhow!(...) message.
Sourcepub async fn read_for_edit(
&self,
path: &WorkspacePath,
) -> WorkspaceResult<(String, Option<String>)>
pub async fn read_for_edit( &self, path: &WorkspacePath, ) -> WorkspaceResult<(String, Option<String>)>
Read a file for a subsequent modify-write cycle, requesting a version token when the backend supports compare-and-swap writes.
Returns (content, Some(version)) when Self::fs_ext is available
(e.g. on S3, where the version is the object ETag); (content, None)
otherwise. Pair with Self::write_for_edit.
Sourcepub async fn write_for_edit(
&self,
path: &WorkspacePath,
content: &str,
expected_version: Option<&str>,
) -> WorkspaceResult<WorkspaceWriteOutcome>
pub async fn write_for_edit( &self, path: &WorkspacePath, content: &str, expected_version: Option<&str>, ) -> WorkspaceResult<WorkspaceWriteOutcome>
Companion to Self::read_for_edit. Performs a compare-and-swap
write when both Self::fs_ext is available and a version token
was returned by the prior read; falls back to a plain write
otherwise. On version mismatch the returned error is the typed
WorkspaceError::VersionConflict variant; callers can also still
downcast anyhow::Error::downcast_ref::<WorkspaceVersionConflict>()
when the value has been lifted into an anyhow::Result.
pub fn local_root(&self) -> Option<&Path>
pub fn display_path(&self, path: &WorkspacePath) -> String
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WorkspaceServices
impl !RefUnwindSafe for WorkspaceServices
impl Send for WorkspaceServices
impl Sync for WorkspaceServices
impl Unpin for WorkspaceServices
impl UnsafeUnpin for WorkspaceServices
impl !UnwindSafe for WorkspaceServices
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more