Skip to main content

WorkspaceServices

Struct WorkspaceServices 

Source
pub struct WorkspaceServices { /* private fields */ }
Expand description

The host-provided workspace capability bundle used by tool execution.

Implementations§

Source§

impl WorkspaceServices

Source

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

Source

pub fn builder( workspace_ref: WorkspaceRef, file_system: Arc<dyn WorkspaceFileSystem>, ) -> WorkspaceServicesBuilder

Source

pub fn local(root: impl Into<PathBuf>) -> Arc<Self>

Source

pub fn workspace_ref(&self) -> &WorkspaceRef

Source

pub fn capabilities(&self) -> WorkspaceCapabilities

Source

pub fn normalize_path(&self, input: &str) -> Result<WorkspacePath>

Source

pub fn fs(&self) -> Arc<dyn WorkspaceFileSystem>

Source

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.

Source

pub fn command_runner(&self) -> Option<Arc<dyn WorkspaceCommandRunner>>

Source

pub fn search(&self) -> Option<Arc<dyn WorkspaceSearch>>

Source

pub fn git(&self) -> Option<Arc<dyn WorkspaceGit>>

Source

pub fn git_stash(&self) -> Option<Arc<dyn WorkspaceGitStashProvider>>

Source

pub fn git_worktree(&self) -> Option<Arc<dyn WorkspaceGitWorktreeProvider>>

Source

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.

Source

pub async fn run_with_timeout<F, T, E>( &self, op: &'static str, fut: F, ) -> Result<T, E>
where F: Future<Output = Result<T, E>>, E: From<Error>,

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.

Source

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.

Source

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.

Source

pub fn local_root(&self) -> Option<&Path>

Source

pub fn display_path(&self, path: &WorkspacePath) -> String

Trait Implementations§

Source§

impl Debug for WorkspaceServices

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ParallelSend for T

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,