@hviana/sema 0.1.5 → 0.1.7
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/AGENTS.md +6 -5
- package/CITATION.cff +49 -0
- package/HOW_IT_WORKS.md +11 -12
- package/README.md +7 -5
- package/dist/example/demo.js +25 -25
- package/dist/example/train_base.d.ts +19 -21
- package/dist/example/train_base.js +1700 -1952
- package/dist/src/alphabet.d.ts +3 -3
- package/dist/src/alphabet.js +24 -27
- package/dist/src/alu/src/alu.d.ts +169 -194
- package/dist/src/alu/src/alu.js +374 -414
- package/dist/src/alu/src/expr.d.ts +36 -43
- package/dist/src/alu/src/expr.js +252 -278
- package/dist/src/alu/src/index.d.ts +9 -98
- package/dist/src/alu/src/index.js +10 -64
- package/dist/src/alu/src/kernel-arith.d.ts +1 -5
- package/dist/src/alu/src/kernel-arith.js +195 -285
- package/dist/src/alu/src/kernel-bits.d.ts +1 -5
- package/dist/src/alu/src/kernel-bits.js +81 -115
- package/dist/src/alu/src/kernel-logic.js +33 -63
- package/dist/src/alu/src/kernel-nd.js +155 -195
- package/dist/src/alu/src/kernel-numeric.d.ts +16 -80
- package/dist/src/alu/src/kernel-numeric.js +259 -331
- package/dist/src/alu/src/operation.d.ts +112 -132
- package/dist/src/alu/src/operation.js +149 -163
- package/dist/src/alu/src/parser.d.ts +168 -175
- package/dist/src/alu/src/parser.js +382 -421
- package/dist/src/alu/src/resonance.d.ts +16 -25
- package/dist/src/alu/src/resonance.js +49 -56
- package/dist/src/alu/src/text.d.ts +3 -7
- package/dist/src/alu/src/text.js +31 -37
- package/dist/src/alu/src/value.d.ts +14 -14
- package/dist/src/alu/src/value.js +150 -160
- package/dist/src/alu/test/alu.test.js +543 -656
- package/dist/src/bytes.d.ts +1 -5
- package/dist/src/bytes.js +33 -40
- package/dist/src/config.d.ts +99 -102
- package/dist/src/config.js +78 -83
- package/dist/src/derive/src/deduction.d.ts +60 -62
- package/dist/src/derive/src/deduction.js +103 -109
- package/dist/src/derive/src/index.d.ts +1 -7
- package/dist/src/derive/src/priority-queue.d.ts +8 -8
- package/dist/src/derive/src/priority-queue.js +57 -61
- package/dist/src/derive/src/rewrite.d.ts +15 -18
- package/dist/src/derive/src/rewrite.js +59 -67
- package/dist/src/derive/src/trie.d.ts +56 -56
- package/dist/src/derive/src/trie.js +175 -179
- package/dist/src/derive/test/derive.test.js +96 -100
- package/dist/src/extension.d.ts +13 -16
- package/dist/src/geometry.d.ts +29 -43
- package/dist/src/geometry.js +324 -268
- package/dist/src/index.d.ts +2 -17
- package/dist/src/index.js +2 -12
- package/dist/src/ingest-cache.d.ts +25 -30
- package/dist/src/ingest-cache.js +108 -127
- package/dist/src/mind/articulation.d.ts +1 -5
- package/dist/src/mind/articulation.js +77 -112
- package/dist/src/mind/attention.d.ts +40 -108
- package/dist/src/mind/attention.js +754 -872
- package/dist/src/mind/canonical.d.ts +4 -19
- package/dist/src/mind/canonical.js +27 -31
- package/dist/src/mind/graph-search.d.ts +201 -225
- package/dist/src/mind/graph-search.js +742 -821
- package/dist/src/mind/index.d.ts +2 -10
- package/dist/src/mind/junction.d.ts +31 -58
- package/dist/src/mind/junction.js +172 -237
- package/dist/src/mind/learning.d.ts +16 -52
- package/dist/src/mind/learning.js +143 -165
- package/dist/src/mind/match.d.ts +20 -69
- package/dist/src/mind/match.js +259 -318
- package/dist/src/mind/mechanisms/alu.js +16 -16
- package/dist/src/mind/mechanisms/cast.d.ts +9 -13
- package/dist/src/mind/mechanisms/cast.js +363 -456
- package/dist/src/mind/mechanisms/confluence.d.ts +8 -12
- package/dist/src/mind/mechanisms/confluence.js +152 -183
- package/dist/src/mind/mechanisms/cover.d.ts +2 -8
- package/dist/src/mind/mechanisms/cover.js +148 -210
- package/dist/src/mind/mechanisms/extraction.d.ts +8 -34
- package/dist/src/mind/mechanisms/extraction.js +234 -288
- package/dist/src/mind/mechanisms/recall.d.ts +6 -10
- package/dist/src/mind/mechanisms/recall.js +141 -185
- package/dist/src/mind/mind.d.ts +194 -155
- package/dist/src/mind/mind.js +392 -289
- package/dist/src/mind/pipeline-mechanism.d.ts +112 -124
- package/dist/src/mind/pipeline-mechanism.js +161 -172
- package/dist/src/mind/pipeline.d.ts +4 -14
- package/dist/src/mind/pipeline.js +125 -189
- package/dist/src/mind/primitives.d.ts +20 -33
- package/dist/src/mind/primitives.js +124 -120
- package/dist/src/mind/rationale.d.ts +86 -98
- package/dist/src/mind/rationale.js +113 -121
- package/dist/src/mind/reasoning.d.ts +2 -13
- package/dist/src/mind/reasoning.js +129 -166
- package/dist/src/mind/recognition.d.ts +1 -4
- package/dist/src/mind/recognition.js +198 -210
- package/dist/src/mind/resonance.d.ts +5 -22
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +6 -25
- package/dist/src/mind/trace.js +50 -58
- package/dist/src/mind/traverse.d.ts +29 -58
- package/dist/src/mind/traverse.js +344 -356
- package/dist/src/mind/types.d.ts +122 -127
- package/dist/src/mind/types.js +60 -69
- package/dist/src/rabitq-ivf/src/database.d.ts +113 -0
- package/dist/src/rabitq-ivf/src/database.js +201 -0
- package/dist/src/rabitq-ivf/src/index.d.ts +7 -0
- package/dist/src/{rabitq-hnsw → rabitq-ivf}/src/index.js +1 -3
- package/dist/src/rabitq-ivf/src/ivf.d.ts +200 -0
- package/dist/src/rabitq-ivf/src/ivf.js +1165 -0
- package/dist/src/rabitq-ivf/src/prng.d.ts +19 -0
- package/dist/src/rabitq-ivf/src/prng.js +36 -0
- package/dist/src/rabitq-ivf/src/rabitq.d.ts +95 -0
- package/dist/src/rabitq-ivf/src/rabitq.js +283 -0
- package/dist/src/sema.d.ts +9 -13
- package/dist/src/sema.js +26 -40
- package/dist/src/store-sqlite.d.ts +171 -166
- package/dist/src/store-sqlite.js +768 -662
- package/dist/src/store.d.ts +597 -630
- package/dist/src/store.js +1434 -1581
- package/dist/src/vec.d.ts +5 -9
- package/dist/src/vec.js +61 -73
- package/example/train_base.ts +33 -15
- package/index.html +65 -0
- package/package.json +1 -1
- package/src/alu/README.md +1 -1
- package/src/alu/src/index.ts +1 -1
- package/src/config.ts +19 -27
- package/src/geometry.ts +93 -1
- package/src/index.ts +6 -11
- package/src/mind/attention.ts +11 -6
- package/src/mind/mechanisms/recall.ts +29 -13
- package/src/mind/mind.ts +250 -19
- package/src/mind/primitives.ts +43 -6
- package/src/mind/recognition.ts +26 -8
- package/src/mind/traverse.ts +47 -0
- package/src/mind/types.ts +20 -21
- package/src/rabitq-ivf/README.md +56 -0
- package/src/rabitq-ivf/src/database.ts +276 -0
- package/src/{rabitq-hnsw → rabitq-ivf}/src/index.ts +2 -5
- package/src/rabitq-ivf/src/ivf.ts +1330 -0
- package/src/{rabitq-hnsw → rabitq-ivf}/src/prng.ts +1 -1
- package/src/store-sqlite.ts +204 -9
- package/src/store.ts +27 -34
- package/test/08-storage.test.mjs +3 -3
- package/test/13-conversation.test.mjs +190 -20
- package/test/14-scaling.test.mjs +2 -2
- package/test/35-ivf.test.mjs +263 -0
- package/test/36-bloom.test.mjs +123 -0
- package/dist/src/rabitq-hnsw/src/database.d.ts +0 -202
- package/dist/src/rabitq-hnsw/src/database.js +0 -405
- package/dist/src/rabitq-hnsw/src/heap.d.ts +0 -22
- package/dist/src/rabitq-hnsw/src/heap.js +0 -94
- package/dist/src/rabitq-hnsw/src/hnsw.d.ts +0 -125
- package/dist/src/rabitq-hnsw/src/hnsw.js +0 -500
- package/dist/src/rabitq-hnsw/src/index.d.ts +0 -15
- package/dist/src/rabitq-hnsw/src/prng.d.ts +0 -19
- package/dist/src/rabitq-hnsw/src/prng.js +0 -38
- package/dist/src/rabitq-hnsw/src/rabitq.d.ts +0 -95
- package/dist/src/rabitq-hnsw/src/rabitq.js +0 -299
- package/dist/src/rabitq-hnsw/src/store.d.ts +0 -162
- package/dist/src/rabitq-hnsw/src/store.js +0 -916
- package/dist/src/rabitq-hnsw/test/hnsw.test.d.ts +0 -1
- package/dist/src/rabitq-hnsw/test/hnsw.test.js +0 -1197
- package/src/rabitq-hnsw/README.md +0 -303
- package/src/rabitq-hnsw/src/database.ts +0 -492
- package/src/rabitq-hnsw/src/heap.ts +0 -90
- package/src/rabitq-hnsw/src/hnsw.ts +0 -514
- package/src/rabitq-hnsw/src/store.ts +0 -994
- package/src/rabitq-hnsw/test/hnsw.test.ts +0 -1213
- /package/src/{rabitq-hnsw → rabitq-ivf}/src/rabitq.ts +0 -0
package/dist/src/mind/mind.d.ts
CHANGED
|
@@ -1,172 +1,211 @@
|
|
|
1
1
|
import { Vec } from "../vec.js";
|
|
2
2
|
import { Sema, Space } from "../sema.js";
|
|
3
3
|
import { Alphabet } from "../alphabet.js";
|
|
4
|
-
import { Grid } from "../geometry.js";
|
|
4
|
+
import { type FoldPyramid, Grid } from "../geometry.js";
|
|
5
5
|
import { BoundedMap, type Store } from "../store.js";
|
|
6
6
|
import { type MindConfig } from "../config.js";
|
|
7
7
|
import { GraphSearch, type Leaf, type Site } from "./graph-search.js";
|
|
8
8
|
import type { ComputedSpan, ExtensionHost } from "../extension.js";
|
|
9
9
|
export type { ComputedSpan, ExtensionHost };
|
|
10
10
|
import { type InspectRationale, Rationale } from "./rationale.js";
|
|
11
|
-
export type {
|
|
12
|
-
InspectRationale,
|
|
13
|
-
RationaleItem,
|
|
14
|
-
RationaleStep,
|
|
15
|
-
} from "./rationale.js";
|
|
11
|
+
export type { InspectRationale, RationaleItem, RationaleStep, } from "./rationale.js";
|
|
16
12
|
export type Input = string | Uint8Array | Grid | Grid[];
|
|
17
13
|
export interface Response {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
v: Vec | null;
|
|
15
|
+
bytes: Uint8Array;
|
|
16
|
+
/** How the answer was grounded (see {@link Provenance}). `"recall-echo"`
|
|
17
|
+
* marks the last-resort fallback that returned the nearest stored form's
|
|
18
|
+
* own bytes verbatim — an echo, NOT a grounded fact. Absent when there is
|
|
19
|
+
* no answer. */
|
|
20
|
+
provenance?: import("./pipeline.js").Provenance;
|
|
21
|
+
}
|
|
22
|
+
/** Serializable state of a conversation — can be saved and restored across
|
|
23
|
+
* sessions. The Mind never interprets the bytes; it only tracks their
|
|
24
|
+
* cumulative lengths so the caller can reconstruct turn boundaries later
|
|
25
|
+
* without inspecting content. */
|
|
26
|
+
export interface ConversationState {
|
|
27
|
+
/** The accumulated context bytes — raw concatenation of every turn's
|
|
28
|
+
* bytes in order. No separator is inserted; the boundary offsets
|
|
29
|
+
* ({@link boundaries}) tell the caller where each turn ends. */
|
|
30
|
+
context: Uint8Array;
|
|
31
|
+
/** Cumulative byte length after each completed turn. Sorted, strictly
|
|
32
|
+
* increasing, each {@code < context.length}. The first turn's length
|
|
33
|
+
* is `boundaries[0]`; the second turn starts at that offset, and so
|
|
34
|
+
* on. Empty for a single-turn or new conversation. */
|
|
35
|
+
boundaries: number[];
|
|
36
|
+
}
|
|
37
|
+
/** An active conversation handle. Opaque — interact through the Mind's
|
|
38
|
+
* conversation methods ({@link Mind.beginConversation},
|
|
39
|
+
* {@link Mind.respondTurn}, {@link Mind.endConversation}). */
|
|
40
|
+
export interface Conversation {
|
|
41
|
+
readonly id: number;
|
|
25
42
|
}
|
|
26
43
|
import type { AttentionRead, MindContext, Recognition } from "./types.js";
|
|
27
44
|
export interface MindOptions {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
host: import("../extension.js").ExtensionHost,
|
|
42
|
-
) => import("./pipeline-mechanism.js").PipelineMechanism)[];
|
|
45
|
+
seed?: number;
|
|
46
|
+
recallQueryK?: number;
|
|
47
|
+
haloQueryK?: number;
|
|
48
|
+
normalizeEpsilon?: number;
|
|
49
|
+
cosineEpsilon?: number;
|
|
50
|
+
geometry?: Partial<import("../config.js").GeometryConfig>;
|
|
51
|
+
alphabet?: Partial<import("../config.js").AlphabetConfig>;
|
|
52
|
+
storeConfig?: Partial<import("../config.js").StoreConfig>;
|
|
53
|
+
store?: Store;
|
|
54
|
+
/** Additional grounding mechanisms (appended after the built-in defaults). */
|
|
55
|
+
mechanisms?: import("./pipeline-mechanism.js").PipelineMechanism[];
|
|
56
|
+
/** Factories that receive the {@link ExtensionHost} and return mechanisms. */
|
|
57
|
+
mechanismFactories?: ((host: import("../extension.js").ExtensionHost) => import("./pipeline-mechanism.js").PipelineMechanism)[];
|
|
43
58
|
}
|
|
44
59
|
export declare class Mind implements MindContext {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
mode?: import("./types.js").DFMode
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
60
|
+
readonly space: Space;
|
|
61
|
+
readonly alphabet: Alphabet;
|
|
62
|
+
readonly store: Store;
|
|
63
|
+
readonly cfg: MindConfig;
|
|
64
|
+
/** The lightest-derivation engine over the Sema graph. */
|
|
65
|
+
readonly search: GraphSearch;
|
|
66
|
+
/** The grounding mechanisms iterated by {@link think}. */
|
|
67
|
+
readonly mechanisms: import("./pipeline-mechanism.js").PipelineMechanism[];
|
|
68
|
+
/** The live rationale tracer for the inference currently in flight, or null. */
|
|
69
|
+
trace: Rationale | null;
|
|
70
|
+
/** Memo of the consensus climb — content-keyed. See {@link MindContext.climbMemo}. */
|
|
71
|
+
climbMemo: Map<string, Map<string, AttentionRead>> | null;
|
|
72
|
+
/** Memo of recognise() — content-keyed. See {@link MindContext.recogniseMemo}. */
|
|
73
|
+
recogniseMemo: Map<string, Recognition> | null;
|
|
74
|
+
/** Memo of perceive() — content-keyed. See {@link MindContext.perceiveMemo}. */
|
|
75
|
+
perceiveMemo: Map<string, import("../sema.js").Sema> | null;
|
|
76
|
+
/** Subtree-resolution cache. See {@link MindContext._resolvedSubtrees}. */
|
|
77
|
+
_resolvedSubtrees: WeakMap<import("../sema.js").Sema, {
|
|
78
|
+
id: number;
|
|
79
|
+
len: number;
|
|
80
|
+
}> | null;
|
|
81
|
+
/** The perceived gist of the query currently being answered. Set by `think`
|
|
82
|
+
* before the graph search runs; `chooseNext` consults it as a gate (a null
|
|
83
|
+
* guide means no query is in flight, so structural walkers keep plain
|
|
84
|
+
* first-edge behaviour) and the reverse projection uses it for
|
|
85
|
+
* reverse-recall disambiguation via `chooseAmong`. */
|
|
86
|
+
_edgeGuide: Vec | null;
|
|
87
|
+
/** Per-response memo of {@link chooseNext} picks — ensures every mechanism
|
|
88
|
+
* of a single response follows the SAME continuation for each ambiguous
|
|
89
|
+
* context node. */
|
|
90
|
+
_edgeChoice: Map<number, number>;
|
|
91
|
+
/** Previous deposit's seen node ids for incremental change detection. */
|
|
92
|
+
_prevSeen: Set<number> | null;
|
|
93
|
+
/** Session cache of node-id → perceived gist for candidate scoring — see
|
|
94
|
+
* {@link MindContext._gistCache}. 32 MB ≈ 8K gists at D=1024; hub
|
|
95
|
+
* candidate sets (√N at most) fit comfortably and recur across queries. */
|
|
96
|
+
_gistCache: BoundedMap<number, Vec>;
|
|
97
|
+
_depositTrees: BoundedMap<string, FoldPyramid>;
|
|
98
|
+
_depositLens: Set<number>;
|
|
99
|
+
_internIds: WeakMap<Sema, number>;
|
|
100
|
+
private _nextConvId;
|
|
101
|
+
private _conversations;
|
|
102
|
+
/** Canonical node id of a byte span. Required by GraphSearchHost & MindContext. */
|
|
103
|
+
resolve(bytes: Uint8Array): number | null;
|
|
104
|
+
recogniseSpan(bytes: Uint8Array): {
|
|
105
|
+
sites: ReadonlyArray<Site>;
|
|
106
|
+
leaves: ReadonlyArray<Leaf>;
|
|
107
|
+
splits: ReadonlySet<number>;
|
|
108
|
+
};
|
|
109
|
+
/** Disambiguate among multiple learnt continuations of the same context node.
|
|
110
|
+
* Required by {@link GraphSearchHost} — the graph search calls this through the
|
|
111
|
+
* host interface when a recognised form has more than one outgoing edge.
|
|
112
|
+
* Delegates to the standalone {@link chooseNext} which picks the candidate
|
|
113
|
+
* with the most distributional evidence (highest `prevOf` count — the
|
|
114
|
+
* structural manifestation of its halo). When evidence is equal the
|
|
115
|
+
* first-inserted edge wins. */
|
|
116
|
+
chooseNext(node: number): number | undefined;
|
|
117
|
+
constructor(opts?: MindOptions);
|
|
118
|
+
constructor(cfg: MindConfig, store: Store, _fromStore: true);
|
|
119
|
+
/** Exposed for tests: the consensus climb over query sub-regions. */
|
|
120
|
+
climbAttention(query: Uint8Array, k: number, mode?: import("./types.js").DFMode): Promise<import("./types.js").Attention[]>;
|
|
121
|
+
/** Exposed for tests: climb the structural DAG from a node to its
|
|
122
|
+
* edge-bearing ancestor contexts. */
|
|
123
|
+
edgeAncestors(id: number, contextCount: number): import("./types.js").AncestorReach;
|
|
124
|
+
/** Exposed for tests: find the natural break point in a sorted vote list. */
|
|
125
|
+
naturalBreak(votes: number[]): number;
|
|
126
|
+
/** Perceive input into a content-defined tree. Deterministic — identical
|
|
127
|
+
* bytes always produce an identical tree. Public for ingest-cache. */
|
|
128
|
+
perceive(input: Input, leafAt?: (i: number) => number | null, lookup?: (ids: number[]) => number | null): Sema;
|
|
129
|
+
/** Open one response's transient state — the tracer and the per-response
|
|
130
|
+
* memos. Paired with {@link endResponse}; the ONE place this state is
|
|
131
|
+
* created, so adding a memo cannot forget its reset. */
|
|
132
|
+
private beginResponse;
|
|
133
|
+
/** Close one response's transient state — every per-response field, incl.
|
|
134
|
+
* the edge guide/choices `think` sets mid-flight. */
|
|
135
|
+
private endResponse;
|
|
136
|
+
/** Shared response core — the one path from bytes to voiced answer.
|
|
137
|
+
* `respond` calls this directly; `respondTurn` has its own path
|
|
138
|
+
* with conversation-persistent memos and incremental perception. */
|
|
139
|
+
private _respondImpl;
|
|
140
|
+
respond(input: Input, inspectRationale?: InspectRationale): Promise<Response>;
|
|
141
|
+
/** Text view of {@link respond}. NUL bytes (0x00) are stripped before
|
|
142
|
+
* decoding — they are structural padding in text answers. LOSSY for a
|
|
143
|
+
* binary answer that legitimately contains NULs: use {@link respond} and
|
|
144
|
+
* read `bytes` directly for binary/grid modalities. */
|
|
145
|
+
respondText(input: string, inspectRationale?: InspectRationale): Promise<string>;
|
|
146
|
+
/** Begin a new conversation, optionally restoring from a previously-saved
|
|
147
|
+
* {@link ConversationState}. The returned handle is required for
|
|
148
|
+
* {@link respondTurn} and {@link endConversation}.
|
|
149
|
+
*
|
|
150
|
+
* Conversations are independent — a Mind can manage several concurrently.
|
|
151
|
+
* Each tracks the fold pyramid (accumulated internal processing) and
|
|
152
|
+
* turn-boundary offsets; the geometry never inspects content to guess
|
|
153
|
+
* where one turn ends and the next begins. */
|
|
154
|
+
beginConversation(state?: ConversationState): Conversation;
|
|
155
|
+
/** End a conversation, releasing its internal resources (accumulated
|
|
156
|
+
* context, boundary offsets, and the fold-pyramid cache). Idempotent. */
|
|
157
|
+
endConversation(conv: Conversation): void;
|
|
158
|
+
/** The current serialisable state of an active conversation. Save this
|
|
159
|
+
* to resume the conversation later via {@link beginConversation}. */
|
|
160
|
+
conversationState(conv: Conversation): ConversationState | null;
|
|
161
|
+
/** Process one turn of a conversation.
|
|
162
|
+
*
|
|
163
|
+
* `turn` is the raw input for the latest turn — its bytes are appended
|
|
164
|
+
* to the accumulated context directly (raw concatenation). The Mind
|
|
165
|
+
* tracks the byte offset where each turn ends; no separator is ever
|
|
166
|
+
* inserted or inspected.
|
|
167
|
+
*
|
|
168
|
+
* Returns the response AND the updated {@link ConversationState} so the
|
|
169
|
+
* caller can persist it. The conversation handle's internal state is
|
|
170
|
+
* updated in place — the returned state is a snapshot for storage. */
|
|
171
|
+
respondTurn(conv: Conversation, turn: Input, inspectRationale?: InspectRationale): Promise<{
|
|
172
|
+
response: Response;
|
|
173
|
+
state: ConversationState;
|
|
174
|
+
}>;
|
|
175
|
+
/** Text view of {@link respondTurn}. See {@link respondText} for the
|
|
176
|
+
* NUL-stripping caveat. For binary or grid turns use {@link respondTurn}
|
|
177
|
+
* directly — this is a text-only convenience, like {@link respondText}. */
|
|
178
|
+
respondTurnText(conv: Conversation, turn: string, inspectRationale?: InspectRationale): Promise<{
|
|
179
|
+
response: string;
|
|
180
|
+
state: ConversationState;
|
|
181
|
+
}>;
|
|
182
|
+
embedding(input: Input): Promise<Vec | null>;
|
|
183
|
+
/** Kinship note: the vector arm below is a miniature of recall's tier 3
|
|
184
|
+
* (resonate → reach gate → read out the nearest form's bytes) — the
|
|
185
|
+
* read-out direction of the same operation, without recall's grounding
|
|
186
|
+
* ladder. If either side's acceptance rule changes, revisit the other. */
|
|
187
|
+
express(idOrV: number | Vec): Promise<Uint8Array>;
|
|
188
|
+
ingest(input: Input | (Input | [Input, Input])[], second?: Input): Promise<(Sema & {
|
|
189
|
+
id: number;
|
|
190
|
+
}) | undefined>;
|
|
191
|
+
private extensionHost;
|
|
192
|
+
private groundedContinuation;
|
|
193
|
+
/** Re-index structurally-important nodes whose gists were evicted from the
|
|
194
|
+
* pending cache before they reached the content index. See {@link
|
|
195
|
+
* Store.repairContentIndex} for the contract; this method wires the
|
|
196
|
+
* Mind's perception into the store's repair walk.
|
|
197
|
+
*
|
|
198
|
+
* Run this after training or at checkpoints to restore recall reach for
|
|
199
|
+
* nodes that bridge experiences but were never indexed. A pure interior
|
|
200
|
+
* node (no edges, no halo) is deliberately skipped — it is scaffolding,
|
|
201
|
+
* not an experience root or bridge, and regenerating its gist would waste
|
|
202
|
+
* I/O and index space for no recall benefit.
|
|
203
|
+
*
|
|
204
|
+
* @param minParents only repair nodes with ≥ this many structural parents
|
|
205
|
+
* (default 2 — structural bridges)
|
|
206
|
+
* @returns number of nodes added to the content index */
|
|
207
|
+
repairContentIndex(minParents?: number): Promise<number>;
|
|
208
|
+
save(): Promise<Uint8Array>;
|
|
209
|
+
static load(snapshot: Uint8Array, store: Store): Promise<Mind>;
|
|
210
|
+
static loadFromStore(store: Store): Promise<Mind>;
|
|
172
211
|
}
|