lossless-core 0.1.1 → 0.1.3
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 +17 -0
- package/dist/index.d.mts +153 -12
- package/dist/index.mjs +3638 -2782
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -4
- package/skills/lossless-core/SKILL.md +91 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lossless-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "The Lossless Context Management engine: stores every message verbatim, swaps aged context for searchable pointers, and takes a host for the model calls it cannot make itself.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compaction",
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
"lcm",
|
|
9
9
|
"llm",
|
|
10
10
|
"memory",
|
|
11
|
-
"retrieval"
|
|
11
|
+
"retrieval",
|
|
12
|
+
"tanstack-intent"
|
|
12
13
|
],
|
|
13
14
|
"homepage": "https://github.com/stainless-code/lossless#readme",
|
|
14
15
|
"bugs": "https://github.com/stainless-code/lossless/issues",
|
|
@@ -21,7 +22,8 @@
|
|
|
21
22
|
},
|
|
22
23
|
"files": [
|
|
23
24
|
"dist",
|
|
24
|
-
"CHANGELOG.md"
|
|
25
|
+
"CHANGELOG.md",
|
|
26
|
+
"skills"
|
|
25
27
|
],
|
|
26
28
|
"type": "module",
|
|
27
29
|
"main": "./dist/index.mjs",
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
"scripts": {
|
|
36
38
|
"pack:watch": "vp pack --watch",
|
|
37
39
|
"prepack": "vp pack",
|
|
38
|
-
"prepublishOnly": "vp check && vp test"
|
|
40
|
+
"prepublishOnly": "vp check && vp test && intent validate"
|
|
39
41
|
},
|
|
40
42
|
"dependencies": {
|
|
41
43
|
"typebox": ">=1.4.3 <2"
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lossless-core
|
|
3
|
+
description: "Use when wiring a host to lossless-core or working on the engine itself: implement ModelHost or Reader, run a compaction, retrieval, or heal pass, or read the store directly with LcmStore."
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
type: core
|
|
7
|
+
library: "lossless-core"
|
|
8
|
+
library_version: "0.1.3"
|
|
9
|
+
sources:
|
|
10
|
+
- stainless-code/lossless:packages/core/src/host.ts
|
|
11
|
+
- stainless-code/lossless:packages/core/src/index.ts
|
|
12
|
+
- stainless-code/lossless:packages/core/README.md
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Lossless core
|
|
16
|
+
|
|
17
|
+
Use it when implementing a host adapter or touching the engine. Do not use it
|
|
18
|
+
for adapter commands: Pi subcommands live in the pi-lossless skill,
|
|
19
|
+
`lossless-*` commands in the opencode-lossless skill.
|
|
20
|
+
|
|
21
|
+
The engine behind `pi-lossless` and `opencode-lossless`: Lossless Context
|
|
22
|
+
Management for a long-running agent. Every message is stored verbatim,
|
|
23
|
+
aged context is replaced with searchable pointers, and the original text
|
|
24
|
+
stays readable by id, entry, or search.
|
|
25
|
+
|
|
26
|
+
## Minimal wiring
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { LcmStore, runCompaction, runHeal, runRetrieval } from "lossless-core";
|
|
30
|
+
import type { ModelHost, Reader } from "lossless-core";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Call shapes (full signatures in `src/index.ts`, port contracts in `src/host.ts`):
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const store = new LcmStore(dbPath);
|
|
37
|
+
await runCompaction(store, input, llm); // input: CompactionInput (span, budgets)
|
|
38
|
+
await runRetrieval(store, request, reader); // request: RetrievalRequest (scope, query)
|
|
39
|
+
await runHeal(store, { dryRun: true }, llm); // HealInput: maxNodes, maxCalls, dryRun plan mode
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The engine has no agent SDK dependency. A host supplies two ports and the
|
|
43
|
+
engine does the rest. Pi implements both; the OpenCode v2 adapter implements
|
|
44
|
+
`ModelHost` and runs retrieval in a host child session instead of `Reader`.
|
|
45
|
+
|
|
46
|
+
## What it does
|
|
47
|
+
|
|
48
|
+
- **Ingest.** Every message lands in SQLite with its entry id, role,
|
|
49
|
+
timestamp, and any file handle the host attached.
|
|
50
|
+
- **Compaction.** Past a swap ratio, a pass summarizes spans into leaf and
|
|
51
|
+
condensed nodes and leaves a pointer in place. Nothing is deleted.
|
|
52
|
+
- **Retrieval.** A reader answers by calling `lcm_grep`, `lcm_describe`,
|
|
53
|
+
and `lcm_expand`, so the answer cites what was read.
|
|
54
|
+
- **Repair.** `runHeal` re-derives a truncated summary and its ancestors
|
|
55
|
+
from the provenance rows they still point at.
|
|
56
|
+
- **Redaction.** Secret-shaped text is masked on the way to a model, never
|
|
57
|
+
at the door, so an export or read still returns what was stored.
|
|
58
|
+
|
|
59
|
+
## The two ports
|
|
60
|
+
|
|
61
|
+
`src/host.ts` documents both. `ModelHost` is what the engine calls a model
|
|
62
|
+
through: `session()`, `find()`, `complete()`, plus where notices go.
|
|
63
|
+
`Reader` is one retrieval conversation: `begin()` returns a `Reading`
|
|
64
|
+
whose `next()` appends results and returns the model reply.
|
|
65
|
+
|
|
66
|
+
| Type | Question it answers |
|
|
67
|
+
| ----------- | ----------------------------------------------------- |
|
|
68
|
+
| `ModelHost` | Which model, and what did it answer |
|
|
69
|
+
| `Reader` | What did the reader ask for, and what did it conclude |
|
|
70
|
+
|
|
71
|
+
## Boundary rule
|
|
72
|
+
|
|
73
|
+
No module under `src/` imports an agent SDK, a bare specifier other than
|
|
74
|
+
`node:*` and `typebox`, or a file outside the engine. The boundary test
|
|
75
|
+
fails any violation. Import the package root only.
|
|
76
|
+
|
|
77
|
+
## Common mistakes
|
|
78
|
+
|
|
79
|
+
- **Importing engine source deep paths** (`lossless-core/dist/...` or
|
|
80
|
+
relative `src/...` files) instead of the package root — the boundary test
|
|
81
|
+
fails deep imports; `import { LcmStore } from "lossless-core"` is the only entry.
|
|
82
|
+
- **Expecting a host SDK in the bundle** - the host always supplies
|
|
83
|
+
`ModelHost` (and `Reader`, unless the host runs retrieval itself, as the OpenCode adapter does); implement the port, never `npm install` an SDK.
|
|
84
|
+
- **Assuming compaction deletes** - pointers replace text in context,
|
|
85
|
+
the verbatim rows stay queryable via the recall views.
|
|
86
|
+
- **Redacting at write time** - masking happens on the model path only; a stored row is never rewritten.
|
|
87
|
+
|
|
88
|
+
## API surface
|
|
89
|
+
|
|
90
|
+
- `LcmStore`, `runCompaction`, `runRetrieval`, `runHeal` — exported from `src/index.ts`; pass and heal options live next to their runners.
|
|
91
|
+
- `ModelHost`, `Reader`, `Reading` (types, `src/host.ts`) — the two port contracts; implement these, never a host SDK.
|