Description

Read workspace file

Reads a project/document file from the workspace (output, then config). Do NOT use for user facts — use retrieve_memory or get_memory_at_path.

Included in Version 8

Dynamically extracted tool implementation.
How to register WorkspaceToolscsharp
registry.Register(new AgentTool(            "read_workspace_file",            "Reads a project/document file from the workspace (output, then config). Do NOT use for user facts — use retrieve_memory or get_memory_at_path.",            args => ReadWorkspaceFile(args),            new            {                type = "object",                properties = new                {                    path = new { type = "string", description = "Relative path of the file to read." }                },                required = new[] { "path" }            },            ToolCategory.Self        ));
Helper classes for WorkspaceToolscsharp
    private string ReadWorkspaceFile(string argumentsJson)    {        if (Workspace is null)            return "Error: Workspace is not initialized.";        try        {            using var doc = JsonDocument.Parse(argumentsJson);            var root = doc.RootElement;            if (!root.TryGetProperty("path", out var pathProp))            {                return "Error: Missing path property.";            }            string relativePath = pathProp.GetString() ?? "";            if (string.IsNullOrWhiteSpace(relativePath))            {                return "Error: Path cannot be empty.";            }            if (IsMemoryNamespacePath(relativePath))            {                return ReadViaMemory(relativePath);            }            string? safeOutputPath = GetSafePath(Workspace.OutputFolder, relativePath);            if (safeOutputPath is not null && File.Exists(safeOutputPath))            {                return File.ReadAllText(safeOutputPath, System.Text.Encoding.UTF8);            }            string? safeConfigPath = GetSafePath(Workspace.ConfigFolder, relativePath);            if (safeConfigPath is not null && File.Exists(safeConfigPath))            {                return File.ReadAllText(safeConfigPath, System.Text.Encoding.UTF8);            }            return $"Error: File '{relativePath}' not found in output or config folders.";        }        catch (Exception ex)        {            return $"Error reading file: {ex.Message}";        }    }