omp packages

pi-session-state0.1.1

Session-scoped, optionally branch-scoped JSON state over one SQLite file, for Pi extensions

eykettle Published 10 days ago MIT ~459 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

session-state extension

npm Conventional Commits License: MIT

English | 中文

[!note] AI-generated artifacts. May include low-quality code.

A Pi extension and a library for other extensions: it holds session-scoped persistent state in one SQLite file.

Features

  • Session scope and branch scope
  • A value can be any JSON; its structure is the integrator's to define
  • One writer per session at a time, while reads proceed in parallel
  • A crash-left lock ages out on its own, so a session is never sealed

For integrators

import { openSessionState } from "pi-session-state";

const state = openSessionState<Identity>({ pluginId: "role" });

The contract, the scopes, and the boundaries are in the API.

For users

The package registers two commands for inspection and reset:

Command What it does
/state:status who holds this session's lock row and whether that pid is alive (unknown when it cannot be told); how many state rows this session has, per extension
/state:force-refresh clear this session's lock row and drop this process's cache, then read from disk

The database defaults to {agent_dir}/sessions/states.sqlite and can be replaced from settings.json — see Storage.

Docs

Install

pi install npm:pi-session-state

Or clone it into Pi's user extension path (e.g. ~/.pi/agent/extensions):

git clone https://github.com/EyKettle/pi-session-state.git ~/.pi/agent/extensions/session-state
cd ~/.pi/agent/extensions/session-state
pnpm install

Pi loads the package through its pi.extensions entry. Reload Pi after installing.

Developed against Pi 1.1.0.

Develop

pnpm install
pnpm test
pnpm run typecheck