Per-session workspace folder + structural identity reminder
- At the first interaction the session name locks and a personal folder is created under the workspace root (default ~/.strata-ctl/<slug>, configurable via workspace_root); slug is filesystem-safe and unique. Stored in sessions.folder (idempotent migration).
- build_request always prepends a structural identity reminder ('Il tuo nome è X. La tua cartella personale è Y.') before the session SP — not an editable setting; gives the agent awareness of its workspace. router_with_store takes the workspace root. 114 tests green; verified live (folder created, name locked).
This commit is contained in:
1 parent
0568b92e06
commit
c199953927
6 files changed
+148
-14
No files matched your search
+16
-1
@@ -29,22 +29,36 @@ pub fn router_with_auth(service: ChatService, auth: AuthConfig) -> Router {
|
||||
AppState {
|
||||
service,
|
||||
store: None,
|
||||
workspace_root: default_workspace_root(),
|
||||
},
|
||||
auth,
|
||||
)
|
||||
}
|
||||
|
||||
/// Build the router with the session store + web GUI enabled, plus auth.
|
||||
pub fn router_with_store(service: ChatService, store: Arc<dyn Store>, auth: AuthConfig) -> Router {
|
||||
/// `workspace_root` is the parent of the per-session personal folders.
|
||||
pub fn router_with_store(
|
||||
service: ChatService,
|
||||
store: Arc<dyn Store>,
|
||||
auth: AuthConfig,
|
||||
workspace_root: std::path::PathBuf,
|
||||
) -> Router {
|
||||
build_router(
|
||||
AppState {
|
||||
service,
|
||||
store: Some(store),
|
||||
workspace_root,
|
||||
},
|
||||
auth,
|
||||
)
|
||||
}
|
||||
|
||||
/// Default parent of the per-session workspace folders: `~/.strata-ctl`.
|
||||
fn default_workspace_root() -> std::path::PathBuf {
|
||||
let home = std::env::var("HOME").unwrap_or_default();
|
||||
std::path::PathBuf::from(home).join(".strata-ctl")
|
||||
}
|
||||
|
||||
fn build_router(state: AppState, auth: AuthConfig) -> Router {
|
||||
let mut r = Router::new()
|
||||
.route("/health", get(health))
|
||||
@@ -160,6 +174,7 @@ async fn auth_middleware(
|
||||
pub(crate) struct AppState {
|
||||
pub(crate) service: ChatService,
|
||||
pub(crate) store: Option<Arc<dyn Store>>,
|
||||
pub(crate) workspace_root: std::path::PathBuf,
|
||||
}
|
||||
|
||||
/// An OpenAI error with the HTTP status the code implies.
|
||||
|
||||
Reference in new issue
Block a user