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 -3
View File
@@ -101,6 +101,7 @@ public class DatabaseService
TryAddColumn(conn, "sessions", "agent_id", "TEXT");
TryAddColumn(conn, "sessions", "description", "TEXT");
TryAddColumn(conn, "sessions", "image", "TEXT");
TryAddColumn(conn, "sessions", "workspace", "TEXT");
TryAddColumn(conn, "sessions", "is_deleted", "INTEGER NOT NULL DEFAULT 0");
TryAddColumn(conn, "chains", "agent_id", "TEXT");
}
@@ -162,7 +163,7 @@ public class DatabaseService
// ── Sessions ──
public async Task<SessionRecord> CreateSession(string name = null, string description = null, string image = null, string agentId = null)
public async Task<SessionRecord> CreateSession(string name = null, string description = null, string image = null, string agentId = null, string workspace = null)
{
using var conn = CreateConnection();
var now = DateTime.UtcNow.ToString("o");
@@ -173,12 +174,13 @@ public class DatabaseService
Description = description,
Image = image,
AgentId = agentId,
Workspace = workspace,
CreatedAt = now,
UpdatedAt = now
};
await conn.ExecuteAsync(@"
INSERT INTO sessions (session_id, name, description, image, agent_id, created_at, updated_at)
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @CreatedAt, @UpdatedAt)
INSERT INTO sessions (session_id, name, description, image, agent_id, workspace, created_at, updated_at)
VALUES (@SessionId, @Name, @Description, @Image, @AgentId, @Workspace, @CreatedAt, @UpdatedAt)
", session);
return session;
}
@@ -217,6 +219,7 @@ public class DatabaseService
if (body.TryGetProperty("description", out var d)) { sets.Add("description = @desc"); p.Add("desc", d.GetString()); }
if (body.TryGetProperty("image", out var img)) { sets.Add("image = @image"); p.Add("image", img.GetString()); }
if (body.TryGetProperty("agentId", out var a)) { sets.Add("agent_id = @agentId2"); p.Add("agentId2", a.GetString()); }
if (body.TryGetProperty("workspace", out var w)) { sets.Add("workspace = @workspace"); p.Add("workspace", w.GetString()); }
await conn.ExecuteAsync($"UPDATE sessions SET {string.Join(", ", sets)} WHERE session_id = @sessionId", p);
}