Per-session workspace, tools only when workspace set

- Session has workspace field (absolute path, optional)
- ToolService stateless, receives workspace per call
- No workspace = no tools sent to API
- Removed hardcoded workspace from Program.cs
- Workspace field in session edit form
This commit is contained in:
Meleki committed 2026-02-26 22:26:53 +01:00
1 parent 002ef293f0
commit b752c99a64
9 files changed
+50 -40

No files matched your search

+6 -1
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
@@ -121,7 +122,11 @@ public static class ChatEndpoint
new { type = "text", text = systemPromptText }
};
var workspace = session.Workspace;
if (!string.IsNullOrEmpty(workspace))
Directory.CreateDirectory(workspace);
var anthropic = new AnthropicService(httpFactory, token, toolService, db);
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId);
await anthropic.StreamChat(res, modelId, systemPrompt, messages, chainId, workspace);
}
}
+2 -1
View File
@@ -50,8 +50,9 @@ public static class SessionEndpoint
var description = body.TryGetProperty("description", out var d) ? d.GetString() : null;
var image = body.TryGetProperty("image", out var img) ? img.GetString() : null;
var agentId = body.TryGetProperty("agentId", out var a) ? a.GetString() : null;
var workspace = body.TryGetProperty("workspace", out var w) ? w.GetString() : null;
var session = await db.CreateSession(name, description, image, agentId);
var session = await db.CreateSession(name, description, image, agentId, workspace);
await ctx.Response.WriteAsJsonAsync(session);
}