SessionPaths Module
Single source of truth for mapping a session grain key to its on-disk directory.
A session key is a '/'-separated path:
"userId/sessionId" → a primary (top-level) session
"userId/sessionId/taskId" → the sub-session a task spawned
"userId/sessionId/taskId/taskId2" → a sub-session of that sub-session (recursive)
The first two segments name the primary session folder ("userId_sessionId"). Every
further segment is a task id, so its sub-session nests beneath the task that started it:
sessions/userId_sessionId/tasks//sessions//
keeping a task's own metadata (tasks//meta.json) and the session it spawned
(tasks//sessions/...) together under one folder. Every storage subsystem
(conversations, tasks, files, observability, feedback) resolves paths through this
module so all of a session's data shares one parent folder, nested identically.
Functions and values
| Function or value |
Description
|
Full Usage:
sanitizeSegment s
Parameters:
string
Returns: string
|
Make a single key segment safe to use as a folder name.
|
Full Usage:
segments sessionKey
Parameters:
string
Returns: string array
|
Split a session key into its sanitized, non-empty segments.
|
Full Usage:
sessionDir sessionsRoot sessionKey
Parameters:
string
sessionKey : string
Returns: string
|
Resolve a session key to its data directory under `sessionsRoot`, nesting each
task-spawned sub-session beneath `tasks/
|
Nao