IWorkspace
NexusLabs.Needlr.AgentFramework¶
NexusLabs.Needlr.AgentFramework.Workspace¶
IWorkspace Interface¶
Abstraction for file storage used by agent tools. Implementations may back onto an in-memory dictionary, a real file system, or a cloud blob store.
Derived
↳ InMemoryWorkspace
Remarks¶
IWorkspace is intentionally NOT auto-registered in DI. Consumers create workspace instances per-orchestration and attach them wherever they choose (execution context properties, direct injection, etc.). Needlr provides implementations as opt-in building blocks — never forced.
All paths use forward-slash separators and are normalized by implementations.
Methods¶
IWorkspace.CompareExchange(string, string, string) Method¶
Atomically replaces file content only if the current content matches expectedContent. Returns true if the swap succeeded, false if the content had changed.
Parameters¶
path System.String
expectedContent System.String
newContent System.String
Returns¶
Remarks¶
Enables optimistic concurrency for multi-agent pipelines where multiple agents may edit the same file. Callers read, transform, then CAS — if another agent wrote in between, the CAS fails and the caller can re-read and retry.
IWorkspace.FileExists(string) Method¶
Returns whether a file exists at the given path.
Parameters¶
path System.String
Returns¶
IWorkspace.GetFilePaths() Method¶
Returns all file paths in the workspace.
Returns¶
System.Collections.Generic.IEnumerable<System.String>
IWorkspace.ReadFile(string) Method¶
Reads the entire content of a file.
Parameters¶
path System.String
Returns¶
Exceptions¶
System.IO.FileNotFoundException
The file does not exist.
IWorkspace.WriteFile(string, string) Method¶
Writes content to a file, creating or overwriting it.
Parameters¶
path System.String
content System.String