lossless-core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/LICENSE +13 -0
- package/README.md +50 -0
- package/dist/index.d.mts +2019 -0
- package/dist/index.mjs +5179 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +46 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
This software is an original implementation of the Lossless Context Management
|
|
4
|
+
(LCM) architecture, specified in the paper "Lossless Context Management" by
|
|
5
|
+
Clint Ehrlich and Theodore Blackman, Voltropy PBC
|
|
6
|
+
(https://papers.voltropy.com/LCM). The paper is credited as the algorithmic
|
|
7
|
+
specification; all code in this repository was written from that spec.
|
|
8
|
+
|
|
9
|
+
The "smart zone" framing (quality degradation at a token budget, not the
|
|
10
|
+
window limit) is credited to Matt Pocock, AI Coding Dictionary
|
|
11
|
+
(https://www.aihero.dev/ai-coding-dictionary/smart-zone).
|
|
12
|
+
|
|
13
|
+
Copyright (c) 2026 stainless-code
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# lossless-core
|
|
2
|
+
|
|
3
|
+
The engine behind [pi-lossless](https://npmx.dev/package/pi-lossless): Lossless
|
|
4
|
+
Context Management for a long-running agent. It stores every message verbatim,
|
|
5
|
+
replaces aged context with searchable pointers, and keeps the original text
|
|
6
|
+
readable by id, entry, or search. The algorithm is
|
|
7
|
+
[Lossless Context Management](https://papers.voltropy.com/LCM), by Clint Ehrlich
|
|
8
|
+
and Theodore Blackman (Voltropy PBC).
|
|
9
|
+
|
|
10
|
+
It names no agent SDK. A host implements two ports, and the engine does the rest.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { LcmStore, runCompaction, runRetrieval } from "lossless-core";
|
|
14
|
+
import type { ModelHost, Reader } from "lossless-core";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## What it does
|
|
18
|
+
|
|
19
|
+
- **Ingest.** Every message lands in SQLite with its entry id, role, timestamp,
|
|
20
|
+
and any file handle the host attached.
|
|
21
|
+
- **Compaction.** When occupancy crosses a swap ratio, a pass summarizes spans
|
|
22
|
+
into leaf and condensed nodes and leaves a pointer in their place. Nothing is
|
|
23
|
+
deleted: the store still holds the verbatim text.
|
|
24
|
+
- **Retrieval.** A reader answers a question by calling `lcm_grep`,
|
|
25
|
+
`lcm_describe`, and `lcm_expand`, so the answer cites what was read.
|
|
26
|
+
- **Redaction.** Secret-shaped text is masked on its way to a model and never
|
|
27
|
+
at the door, so an export or a read can still return what was stored.
|
|
28
|
+
|
|
29
|
+
## The two ports
|
|
30
|
+
|
|
31
|
+
`ModelHost` is what the engine calls a model through: `session()`, `find()`,
|
|
32
|
+
`complete()`, plus where notices go. `Reader` is one retrieval conversation:
|
|
33
|
+
`begin()` returns a `Reading` whose `next()` appends results and returns the
|
|
34
|
+
model's reply.
|
|
35
|
+
|
|
36
|
+
| Type | Question it answers |
|
|
37
|
+
| ----------- | ----------------------------------------------------- |
|
|
38
|
+
| `ModelHost` | Which model, and what did it answer |
|
|
39
|
+
| `Reader` | What did the reader ask for, and what did it conclude |
|
|
40
|
+
|
|
41
|
+
`src/host.ts` documents both. The engine's boundary test fails any module under
|
|
42
|
+
`src/` that names an agent SDK, a bare specifier other than `node:*` and
|
|
43
|
+
`typebox`, or a file outside the engine.
|
|
44
|
+
|
|
45
|
+
## Where the rest lives
|
|
46
|
+
|
|
47
|
+
- [pi-lossless](https://npmx.dev/package/pi-lossless): the Pi adapter, and
|
|
48
|
+
every user-facing command.
|
|
49
|
+
- [The docs site](https://stainless-code.com/lossless/): how LCM behaves in a
|
|
50
|
+
session, the config keys, and the limits.
|