Skip to main content
Functions and classes exported by this package.

isValidStatus()

Signature

SessionView

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[]. Signature
Methods

from()

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
Parameters 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
Parameters 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
Parameters 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
Parameters 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
Parameters Returns — Error result object Example

createSuccessResult()

Create a standardized success result object. Signature
Returns — Success result object Example

isErrorResult(result)

Type guard for error results. Signature
Parameters Returns — True if the result is an error result Example

isErrorCode()

Check if an exit code represents an error (1-99). Signature

isSuccessCode()

Check if an exit code represents success (0 or 100+). Signature

isNoChangeCode()

Check if an exit code indicates no change (idempotent operation). Signature

isRecoverableCode()

Check if an exit code is recoverable (retry may succeed). Signature

getExitCodeName()

Human-readable name for an exit code. Signature

isLafsSuccess(envelope)

Type guard for success responses. Signature
Parameters Returnstrue if the envelope represents a successful operation. Example

isLafsError(envelope)

Type guard for error responses. Signature
Parameters Returnstrue if the envelope represents a failed operation. Example

isGatewayEnvelope(envelope)

Type guard for gateway responses (has _meta). Signature
Parameters Returnstrue if the response includes gateway metadata. Example