isValidStatus()
SignatureSessionView
SessionView — typed wrapper over Session[] with collection helpers. Provides discoverable query methods for common session lookups. Does NOT change the DataAccessor interface — consumers create views from Session[]. Signaturefrom()
Create a SessionView from a Session array.findActive()
Find the currently active session (if any).findById()
Find a session by ID.filterByStatus()
Filter sessions by one or more statuses.findByScope()
Find sessions matching a scope type and optional rootTaskId.sortByDate()
Sort sessions by a date field. Returns a new array (does not mutate).mostRecent()
Get the most recently started session.toArray()
Convert back to a plain Session array (shallow copy).[Symbol.iterator]()
Support for-of iteration.normalizeError(error, fallbackMessage)
Normalize any thrown value into a standardized error object. Handles: - Error instances (preserves stack trace info) - Strings (wraps in Error) - Objects with message property - null/undefined (provides fallback) Signature
Returns — Normalized error with consistent shape
Example
getErrorMessage(error, fallback)
Extract a human-readable message from any error value. Safe to use on unknown thrown values without type guards. Signature
Returns — The error message string
Example
formatError(error, context, includeStack)
Format error details for logging or display. Includes stack trace for Error instances when includeStack is true. Signature
Returns — Formatted error string
Example
isErrorType(error, codeOrName)
Check if an error represents a specific error type by code or name. Useful for conditional error handling based on error types. Signature
Returns — True if the error matches
Example
createErrorResult(error)
Create a standardized error result object. Common pattern for operations that return success: boolean, error?: string Signature
Returns — Error result object
Example
createSuccessResult()
Create a standardized success result object. SignatureisErrorResult(result)
Type guard for error results. Signature
Returns — True if the result is an error result
Example
isErrorCode()
Check if an exit code represents an error (1-99). SignatureisSuccessCode()
Check if an exit code represents success (0 or 100+). SignatureisNoChangeCode()
Check if an exit code indicates no change (idempotent operation). SignatureisRecoverableCode()
Check if an exit code is recoverable (retry may succeed). SignaturegetExitCodeName()
Human-readable name for an exit code. SignatureisLafsSuccess(envelope)
Type guard for success responses. Signature
Returns —
true if the envelope represents a successful operation.
Example
isLafsError(envelope)
Type guard for error responses. Signature
Returns —
true if the envelope represents a failed operation.
Example
isGatewayEnvelope(envelope)
Type guard for gateway responses (has _meta). Signature
Returns —
true if the response includes gateway metadata.
Example