Header menu logo Nao

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

sanitizeSegment s

Full Usage: sanitizeSegment s

Parameters:
    s : string

Returns: string

Make a single key segment safe to use as a folder name.

s : string
Returns: string

segments sessionKey

Full Usage: segments sessionKey

Parameters:
    sessionKey : string

Returns: string array

Split a session key into its sanitized, non-empty segments.

sessionKey : string
Returns: string array

sessionDir sessionsRoot sessionKey

Full Usage: sessionDir sessionsRoot sessionKey

Parameters:
    sessionsRoot : string
    sessionKey : string

Returns: string

Resolve a session key to its data directory under `sessionsRoot`, nesting each task-spawned sub-session beneath `tasks//sessions/`.

sessionsRoot : string
sessionKey : string
Returns: string

Type something to start searching.