@theokit/sdk-memory 0.6.0 → 0.6.2
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 +19 -0
- package/dist/index.cjs +174 -1138
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -1107
- package/dist/index.js.map +1 -1
- package/dist/internal/active-memory/active-memory-cache.d.ts +1 -66
- package/dist/internal/active-memory/active-memory-cache.d.ts.map +1 -1
- package/dist/internal/active-memory/active-memory-types.d.ts +1 -54
- package/dist/internal/active-memory/active-memory-types.d.ts.map +1 -1
- package/dist/internal/adapter-http-error.d.ts.map +1 -1
- package/dist/internal/dreaming/dreaming-phases.d.ts +5 -53
- package/dist/internal/dreaming/dreaming-phases.d.ts.map +1 -1
- package/dist/internal/dreaming/dreaming-run.d.ts +3 -83
- package/dist/internal/dreaming/dreaming-run.d.ts.map +1 -1
- package/dist/internal/index/index-db.d.ts +1 -67
- package/dist/internal/index/index-db.d.ts.map +1 -1
- package/dist/internal/index/index-manager-dispatch.d.ts +1 -35
- package/dist/internal/index/index-manager-dispatch.d.ts.map +1 -1
- package/dist/internal/index/index-manager.d.ts +1 -130
- package/dist/internal/index/index-manager.d.ts.map +1 -1
- package/dist/internal/index/index-schema.d.ts +1 -29
- package/dist/internal/index/index-schema.d.ts.map +1 -1
- package/dist/internal/index/lance-index.d.ts +1 -91
- package/dist/internal/index/lance-index.d.ts.map +1 -1
- package/dist/internal/index/lance-memory-adapter.d.ts +16 -115
- package/dist/internal/index/lance-memory-adapter.d.ts.map +1 -1
- package/dist/internal/index/memory-index.d.ts +3 -12
- package/dist/internal/index/memory-index.d.ts.map +1 -1
- package/dist/internal/index/migrate-sqlite-to-lance.d.ts +1 -65
- package/dist/internal/index/migrate-sqlite-to-lance.d.ts.map +1 -1
- package/dist/internal/index/migration.d.ts +1 -35
- package/dist/internal/index/migration.d.ts.map +1 -1
- package/dist/internal/index/sqlite-vec-loader.d.ts +2 -59
- package/dist/internal/index/sqlite-vec-loader.d.ts.map +1 -1
- package/dist/internal/index/vec-index.d.ts +1 -131
- package/dist/internal/index/vec-index.d.ts.map +1 -1
- package/dist/internal/store/chunk-markdown.d.ts +1 -82
- package/dist/internal/store/chunk-markdown.d.ts.map +1 -1
- package/dist/internal/store/reader.d.ts +1 -86
- package/dist/internal/store/reader.d.ts.map +1 -1
- package/package.json +3 -3
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* **Iter 53 rollup-plugin-dts workaround** (mirrors iter 48
|
|
3
|
-
* MemorySearchHit pattern). The canonical sdk-core copy imports
|
|
4
|
-
* `MemoryChunk` from `../types.js`. In sdk-memory the same type lives
|
|
5
|
-
* in sibling `./memory-types.js` (moved iter 52) but rollup-dts
|
|
6
|
-
* treeshakes it out of the dist .d.ts because no PUBLIC type
|
|
7
|
-
* references it transitively yet — the public `chunkMarkdown(text):
|
|
8
|
-
* MemoryChunk[]` signature would be the first transitive reachable
|
|
9
|
-
* consumer, BUT rollup-dts processes files in an order that asks for
|
|
10
|
-
* the import resolution BEFORE chunk-markdown.ts itself becomes the
|
|
11
|
-
* reachable consumer. Result: "MemoryChunk is not exported by
|
|
12
|
-
* src/internal/memory-types.ts" build error.
|
|
13
|
-
*
|
|
14
|
-
* Fix: declare a byte-identical mirror of MemoryChunk inline. When a
|
|
15
|
-
* future move turns MemoryChunk into a publicly-reachable type
|
|
16
|
-
* through a different path (e.g. `index-db.ts` or `IndexManager`
|
|
17
|
-
* methods that return arrays of it), this mirror MUST be deleted +
|
|
18
|
-
* the canonical import restored to maintain single source of truth.
|
|
19
|
-
*
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
interface MemoryChunk {
|
|
23
|
-
/** 1-indexed starting line in the source file. */
|
|
24
|
-
startLine: number;
|
|
25
|
-
/** 1-indexed ending line (inclusive). */
|
|
26
|
-
endLine: number;
|
|
27
|
-
/** Slice of markdown source text. */
|
|
28
|
-
text: string;
|
|
29
|
-
/** sha256 of `text`; stable across runs for identical inputs. */
|
|
30
|
-
hash: string;
|
|
31
|
-
/** Optional nearest heading text (without the `#` markers). */
|
|
32
|
-
heading?: string;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Split a markdown document into semantically meaningful chunks (ADR D1 of
|
|
36
|
-
* memory-system-peer-project-parity).
|
|
37
|
-
*
|
|
38
|
-
* Algorithm:
|
|
39
|
-
* 1. Walk lines tracking the current heading (latest `^#+ ` line).
|
|
40
|
-
* 2. Split chunks at the next heading boundary AND on blank-line paragraph
|
|
41
|
-
* boundaries.
|
|
42
|
-
* 3. If a single paragraph exceeds `maxChars`, split it at the nearest
|
|
43
|
-
* whitespace ≤ maxChars (word-aligned per edge-case review EC-6) —
|
|
44
|
-
* never mid-word.
|
|
45
|
-
*
|
|
46
|
-
* Mirrors peer-project's `chunkMarkdown` from
|
|
47
|
-
* `packages/memory-host-sdk/src/host/chunk-markdown.ts`.
|
|
48
|
-
*
|
|
49
|
-
* Iter 53 (Stage 3 source-move #10): hybrid copy from sdk-core's
|
|
50
|
-
* `internal/memory/storage/chunk-markdown.ts`. sdk-core retains its
|
|
51
|
-
* copy for v1.x back-compat; sdk-memory ships the canonical copy that
|
|
52
|
-
* future `storage/markdown-store`, `migration`, `index-db`, and
|
|
53
|
-
* `index-manager` moves will target as siblings. The `MemoryChunk`
|
|
54
|
-
* type comes from sibling `./memory-types.js` (moved iter 52).
|
|
55
|
-
*
|
|
56
|
-
* @internal
|
|
57
|
-
*/
|
|
58
|
-
export interface ChunkMarkdownOptions {
|
|
59
|
-
/** Maximum chars per chunk. Default 800. */
|
|
60
|
-
maxChars?: number;
|
|
61
|
-
/** Minimum chars per chunk (avoids splintering tiny lines). Default 80. */
|
|
62
|
-
minChars?: number;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Split markdown into the chunks that get embedded and searched.
|
|
66
|
-
*
|
|
67
|
-
* Boundaries are structural rather than fixed-width: a chunk ends at the next
|
|
68
|
-
* heading, or at a blank line. Each chunk carries the nearest preceding heading,
|
|
69
|
-
* so a hit can be cited with the section it came from. A run of text longer than
|
|
70
|
-
* `maxChars` is then cut at the last whitespace within 200 characters of the
|
|
71
|
-
* limit, falling back to a hard cut when a single token is longer than that.
|
|
72
|
-
*
|
|
73
|
-
* Returns `[]` for empty input. `minChars` on the options is currently not read
|
|
74
|
-
* — small paragraphs are emitted as their own chunks regardless.
|
|
75
|
-
*
|
|
76
|
-
* Line numbers are 1-indexed and inclusive at both ends. They are exact for
|
|
77
|
-
* normal chunks; for a paragraph that had to be split by length, the numbers are
|
|
78
|
-
* derived from newline counts within the slice and mark the span the slice came
|
|
79
|
-
* from rather than a precise per-slice range.
|
|
80
|
-
*/
|
|
81
|
-
export declare function chunkMarkdown(text: string, options?: ChunkMarkdownOptions): MemoryChunk[];
|
|
82
|
-
export {};
|
|
1
|
+
export { type ChunkMarkdownOptions, chunkMarkdown } from "@theokit/sdk/internal/memory-store";
|
|
83
2
|
//# sourceMappingURL=chunk-markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk-markdown.d.ts","sourceRoot":"","sources":["../../../src/internal/store/chunk-markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk-markdown.d.ts","sourceRoot":"","sources":["../../../src/internal/store/chunk-markdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC"}
|
|
@@ -1,87 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* **Iter 55 rollup-plugin-dts workaround** (mirrors iter 48/53 pattern).
|
|
3
|
-
* The canonical sdk-core copy imports `MemoryReadResult` from
|
|
4
|
-
* `../types.js`. In sdk-memory the same type lives in sibling
|
|
5
|
-
* `./memory-types.js` (moved iter 52) but rollup-dts treeshakes it
|
|
6
|
-
* out of the dist .d.ts because no PUBLIC type reaches it
|
|
7
|
-
* transitively yet — `readMemoryFileBounded`'s return type would be
|
|
8
|
-
* the consumer BUT rollup-dts processes the import resolution before
|
|
9
|
-
* reader.ts itself becomes bundled into the public emit. Same class
|
|
10
|
-
* of bug as iter 48 (MemorySearchHit) + iter 53 (MemoryChunk).
|
|
11
|
-
*
|
|
12
|
-
* Fix: declare a byte-identical mirror of MemoryReadResult inline.
|
|
13
|
-
* When a future move (e.g. tools.ts wrapping readMemoryFileBounded
|
|
14
|
-
* as a public LLM tool, or IndexManager surface emitting these)
|
|
15
|
-
* gives MemoryReadResult a different publicly-reachable path, this
|
|
16
|
-
* mirror MUST be deleted + the canonical import restored to maintain
|
|
17
|
-
* single source of truth.
|
|
18
|
-
*
|
|
19
|
-
* @internal
|
|
20
|
-
*/
|
|
21
|
-
interface MemoryReadResult {
|
|
22
|
-
path: string;
|
|
23
|
-
/** Requested starting line (1-indexed, defaults to 1). */
|
|
24
|
-
from: number;
|
|
25
|
-
/** Number of lines actually returned (may be less than `lines` near EOF). */
|
|
26
|
-
linesReturned: number;
|
|
27
|
-
/** Total lines in the file (after the read). */
|
|
28
|
-
totalLines: number;
|
|
29
|
-
/** True when content remains after the returned slice, i.e. `remainingLines > 0`. */
|
|
30
|
-
truncated: boolean;
|
|
31
|
-
/** Lines past the returned slice that remain in the file. */
|
|
32
|
-
remainingLines: number;
|
|
33
|
-
/** Slice text (joined with `\n`). */
|
|
34
|
-
text: string;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Bounded read with truncation info (ADR D5 — `memory_get` foundation).
|
|
38
|
-
*
|
|
39
|
-
* Mirrors peer-project's `buildMemoryReadResult` semantics:
|
|
40
|
-
* - `from` is 1-indexed.
|
|
41
|
-
* - `lines` defaults to 200 (`DEFAULT_MEMORY_READ_LINES`).
|
|
42
|
-
* - Returns up to EOF when the requested slice extends past file end.
|
|
43
|
-
* - Sets `truncated: true` whenever content remains past the returned slice,
|
|
44
|
-
* whether or not the slice was shorter than requested. (At EOF, `false`.)
|
|
45
|
-
*
|
|
46
|
-
* Iter 55 (Stage 3 source-move #12): hybrid copy from sdk-core's
|
|
47
|
-
* `internal/memory/storage/reader.ts`. sdk-core retains its copy for
|
|
48
|
-
* v1.x `memory_get` back-compat; sdk-memory ships the canonical copy
|
|
49
|
-
* that future `tools.ts` move (memory_get LLM tool wraps this) will
|
|
50
|
-
* target as a sibling. `MemoryReadResult` comes from sibling
|
|
51
|
-
* `./memory-types.js` (moved iter 52).
|
|
52
|
-
*
|
|
53
|
-
* @internal
|
|
54
|
-
*/
|
|
55
|
-
export declare const DEFAULT_MEMORY_READ_LINES = 200;
|
|
56
|
-
/**
|
|
57
|
-
* Inputs for {@link readMemoryFileBounded}. `relPath` is resolved against `cwd`,
|
|
58
|
-
* and this function performs no containment check of its own — a `relPath`
|
|
59
|
-
* containing `..` escapes. The `memory_get` tool validates containment before
|
|
60
|
-
* calling in.
|
|
61
|
-
*
|
|
62
|
-
* `from` is 1-indexed and clamped to at least 1; `lines` defaults to 200 and is
|
|
63
|
-
* clamped to at least 1.
|
|
64
|
-
*/
|
|
65
|
-
export interface ReadFileOptions {
|
|
66
|
-
cwd: string;
|
|
67
|
-
relPath: string;
|
|
68
|
-
from?: number;
|
|
69
|
-
lines?: number;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Read a bounded slice of a text file and report what was left behind.
|
|
73
|
-
*
|
|
74
|
-
* A single trailing newline is not counted as a line, so `totalLines` matches
|
|
75
|
-
* what an editor shows. `from` past the end of the file is not an error: it
|
|
76
|
-
* returns an empty slice with `linesReturned: 0`.
|
|
77
|
-
*
|
|
78
|
-
* `truncated` means content remains after the returned slice — it is exactly
|
|
79
|
-
* `remainingLines > 0`. It does not mean fewer lines were returned than
|
|
80
|
-
* requested: a full 200-line slice of a 1000-line file is `truncated: true`,
|
|
81
|
-
* and a short slice that reached the end is `truncated: false`.
|
|
82
|
-
*
|
|
83
|
-
* Rejects with the underlying filesystem error when the file cannot be read.
|
|
84
|
-
*/
|
|
85
|
-
export declare function readMemoryFileBounded(opts: ReadFileOptions): Promise<MemoryReadResult>;
|
|
86
|
-
export {};
|
|
1
|
+
export { DEFAULT_MEMORY_READ_LINES, type ReadFileOptions, readMemoryFileBounded, } from "@theokit/sdk/internal/memory-store";
|
|
87
2
|
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/internal/store/reader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../../src/internal/store/reader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,KAAK,eAAe,EACpB,qBAAqB,GACtB,MAAM,oCAAoC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/sdk-memory",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Memory subsystem for @theokit/sdk — MemoryProvider impls (markdown file store today; LanceDB + embeddings + circuit breaker next iters). Consumes the kernel-facing port from sdk-core.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/usetheokit/theokit-sdk#readme",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"better-sqlite3": "^12.0.0",
|
|
42
42
|
"sqlite-vec": ">=0.1.0",
|
|
43
43
|
"@lancedb/lancedb": ">=0.20.0",
|
|
44
|
-
"@theokit/sdk": "^5.
|
|
44
|
+
"@theokit/sdk": "^5.21.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"better-sqlite3": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/better-sqlite3": "^7.6.13",
|
|
62
62
|
"better-sqlite3": "^12.10.0",
|
|
63
63
|
"sqlite-vec": "^0.1.6",
|
|
64
|
-
"@theokit/sdk": "5.
|
|
64
|
+
"@theokit/sdk": "5.21.0"
|
|
65
65
|
},
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"provenance": true,
|