@plur-ai/core 0.9.3 → 0.9.5
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/README.md +1 -1
- package/dist/{chunk-3ZPTRZE3.js → chunk-EQPTF4JZ.js} +11 -1
- package/dist/{chunk-IGGMRXAB.js → chunk-ZY4R3VEG.js} +52 -12
- package/dist/embeddings-3EXLC3EH.js +21 -0
- package/dist/index.d.ts +397 -13
- package/dist/index.js +556 -53
- package/dist/{learn-async-R5KZ5EWF.js → learn-async-IISWD7HC.js} +1 -2
- package/package.json +1 -1
- package/dist/chunk-2ZDO52B4.js +0 -52
- package/dist/embeddings-ZRT6IRPA.js +0 -14
- package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
- package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
- package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
- package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
- package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
- package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
- package/dist/transformers.node-PH5YK5EA.js +0 -46777
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ Next session starts → relevant ones injected → agent remembers
|
|
|
56
56
|
You rate the result → engram strengthens → quality improves
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Search is fully local: BM25 over enriched text + BGE-small-en-v1.5 embeddings + Reciprocal Rank Fusion.
|
|
59
|
+
Search is fully local: BM25 over enriched text + BGE-small-en-v1.5 embeddings + Reciprocal Rank Fusion. Zero API calls, zero per-query cost. [Benchmark methodology →](https://plur.ai/benchmark.html)
|
|
60
60
|
|
|
61
61
|
## Search modes
|
|
62
62
|
|
|
@@ -183,7 +183,17 @@ var EngramSchema = z.object({
|
|
|
183
183
|
previous_version_ref: PreviousVersionRefSchema.optional(),
|
|
184
184
|
episode_ids: z.array(z.string()).default([]),
|
|
185
185
|
// === SP3: Retrieval & Injection fields ===
|
|
186
|
-
summary: z.string().max(80).optional()
|
|
186
|
+
summary: z.string().max(80).optional(),
|
|
187
|
+
/**
|
|
188
|
+
* Always-load flag. Pinned engrams bypass the term-hits gate in scoreEngram
|
|
189
|
+
* and are eligible for injection on every session start, regardless of
|
|
190
|
+
* keyword overlap with the user's task. Use sparingly: meta-rules,
|
|
191
|
+
* cross-cutting safety conventions, and core operating principles only.
|
|
192
|
+
* Pinned engrams still respect the token budget — they bypass per-pack and
|
|
193
|
+
* per-domain fairness caps in fillTokenBudget so always-load behavior is
|
|
194
|
+
* honored even if a single pack contributes many.
|
|
195
|
+
*/
|
|
196
|
+
pinned: z.boolean().optional()
|
|
187
197
|
});
|
|
188
198
|
var EngramSchemaPassthrough = EngramSchema.passthrough();
|
|
189
199
|
|
|
@@ -113,21 +113,57 @@ import { existsSync, readFileSync, mkdirSync } from "fs";
|
|
|
113
113
|
import { join } from "path";
|
|
114
114
|
import { createHash } from "crypto";
|
|
115
115
|
var embedPipeline = null;
|
|
116
|
+
var lastLoadError = null;
|
|
116
117
|
var transformersUnavailable = false;
|
|
118
|
+
function readDisabledFromEnv(env) {
|
|
119
|
+
const raw = env.PLUR_DISABLE_EMBEDDINGS;
|
|
120
|
+
if (!raw) return null;
|
|
121
|
+
const normalized = raw.trim().toLowerCase();
|
|
122
|
+
if (normalized === "1" || normalized === "true" || normalized === "yes") {
|
|
123
|
+
return "embeddings disabled by PLUR_DISABLE_EMBEDDINGS env var";
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
var ENV_DISABLED_REASON = readDisabledFromEnv(process.env);
|
|
128
|
+
var embeddingsDisabled = ENV_DISABLED_REASON !== null;
|
|
129
|
+
var disabledReason = ENV_DISABLED_REASON;
|
|
130
|
+
function embedderStatus() {
|
|
131
|
+
return {
|
|
132
|
+
available: !embeddingsDisabled && !transformersUnavailable,
|
|
133
|
+
loaded: embedPipeline !== null,
|
|
134
|
+
lastError: lastLoadError,
|
|
135
|
+
disabled: embeddingsDisabled,
|
|
136
|
+
disabledReason
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
function setEmbeddingsEnabled(enabled, reason) {
|
|
140
|
+
embeddingsDisabled = !enabled;
|
|
141
|
+
disabledReason = enabled ? null : reason ?? "embeddings disabled by config";
|
|
142
|
+
if (!enabled) {
|
|
143
|
+
embedPipeline = null;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
function resetEmbedder() {
|
|
147
|
+
transformersUnavailable = false;
|
|
148
|
+
lastLoadError = null;
|
|
149
|
+
embedPipeline = null;
|
|
150
|
+
}
|
|
117
151
|
async function getEmbedder() {
|
|
118
|
-
if (
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
152
|
+
if (embeddingsDisabled) return null;
|
|
153
|
+
if (embedPipeline) return embedPipeline;
|
|
154
|
+
try {
|
|
155
|
+
const { pipeline } = await import("@huggingface/transformers");
|
|
156
|
+
embedPipeline = await pipeline("feature-extraction", "Xenova/bge-small-en-v1.5", {
|
|
157
|
+
dtype: "fp32"
|
|
158
|
+
});
|
|
159
|
+
transformersUnavailable = false;
|
|
160
|
+
lastLoadError = null;
|
|
161
|
+
return embedPipeline;
|
|
162
|
+
} catch (err) {
|
|
163
|
+
transformersUnavailable = true;
|
|
164
|
+
lastLoadError = err instanceof Error ? err.message : String(err);
|
|
165
|
+
return null;
|
|
129
166
|
}
|
|
130
|
-
return embedPipeline;
|
|
131
167
|
}
|
|
132
168
|
async function embed(text) {
|
|
133
169
|
const embedder = await getEmbedder();
|
|
@@ -226,6 +262,10 @@ export {
|
|
|
226
262
|
computeIdf,
|
|
227
263
|
ftsScore,
|
|
228
264
|
searchEngrams,
|
|
265
|
+
readDisabledFromEnv,
|
|
266
|
+
embedderStatus,
|
|
267
|
+
setEmbeddingsEnabled,
|
|
268
|
+
resetEmbedder,
|
|
229
269
|
embed,
|
|
230
270
|
cosineSimilarity,
|
|
231
271
|
embeddingSearch,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cosineSimilarity,
|
|
3
|
+
embed,
|
|
4
|
+
embedderStatus,
|
|
5
|
+
embeddingSearch,
|
|
6
|
+
embeddingSearchWithScores,
|
|
7
|
+
readDisabledFromEnv,
|
|
8
|
+
resetEmbedder,
|
|
9
|
+
setEmbeddingsEnabled
|
|
10
|
+
} from "./chunk-ZY4R3VEG.js";
|
|
11
|
+
import "./chunk-PRK3B7WR.js";
|
|
12
|
+
export {
|
|
13
|
+
cosineSimilarity,
|
|
14
|
+
embed,
|
|
15
|
+
embedderStatus,
|
|
16
|
+
embeddingSearch,
|
|
17
|
+
embeddingSearchWithScores,
|
|
18
|
+
readDisabledFromEnv,
|
|
19
|
+
resetEmbedder,
|
|
20
|
+
setEmbeddingsEnabled
|
|
21
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -320,6 +320,16 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
320
320
|
}>>;
|
|
321
321
|
episode_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
322
322
|
summary: z.ZodOptional<z.ZodString>;
|
|
323
|
+
/**
|
|
324
|
+
* Always-load flag. Pinned engrams bypass the term-hits gate in scoreEngram
|
|
325
|
+
* and are eligible for injection on every session start, regardless of
|
|
326
|
+
* keyword overlap with the user's task. Use sparingly: meta-rules,
|
|
327
|
+
* cross-cutting safety conventions, and core operating principles only.
|
|
328
|
+
* Pinned engrams still respect the token budget — they bypass per-pack and
|
|
329
|
+
* per-domain fairness caps in fillTokenBudget so always-load behavior is
|
|
330
|
+
* honored even if a single pack contributes many.
|
|
331
|
+
*/
|
|
332
|
+
pinned: z.ZodOptional<z.ZodBoolean>;
|
|
323
333
|
}, "strip", z.ZodTypeAny, {
|
|
324
334
|
type: "behavioral" | "architectural" | "procedural" | "terminological";
|
|
325
335
|
status: "active" | "dormant" | "retired" | "candidate";
|
|
@@ -425,6 +435,7 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
425
435
|
changed_at: string;
|
|
426
436
|
} | undefined;
|
|
427
437
|
summary?: string | undefined;
|
|
438
|
+
pinned?: boolean | undefined;
|
|
428
439
|
}, {
|
|
429
440
|
type: "behavioral" | "architectural" | "procedural" | "terminological";
|
|
430
441
|
status: "active" | "dormant" | "retired" | "candidate";
|
|
@@ -530,6 +541,7 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
530
541
|
} | undefined;
|
|
531
542
|
episode_ids?: string[] | undefined;
|
|
532
543
|
summary?: string | undefined;
|
|
544
|
+
pinned?: boolean | undefined;
|
|
533
545
|
}>;
|
|
534
546
|
type Engram = z.infer<typeof EngramSchema>;
|
|
535
547
|
type KnowledgeAnchor = z.infer<typeof KnowledgeAnchorSchema>;
|
|
@@ -567,12 +579,35 @@ declare function applyBatchDecay(engrams: Engram[], historyRoot: string, options
|
|
|
567
579
|
modified: Engram[];
|
|
568
580
|
};
|
|
569
581
|
|
|
582
|
+
interface EmbedderStatus {
|
|
583
|
+
available: boolean;
|
|
584
|
+
loaded: boolean;
|
|
585
|
+
lastError: string | null;
|
|
586
|
+
/** True when embeddings are explicitly disabled by user (env var or config). */
|
|
587
|
+
disabled: boolean;
|
|
588
|
+
/** Human-readable reason when disabled is true; null otherwise. */
|
|
589
|
+
disabledReason: string | null;
|
|
590
|
+
}
|
|
570
591
|
/** Result with cosine similarity score attached. */
|
|
571
592
|
interface SimilarityResult {
|
|
572
593
|
engram: Engram;
|
|
573
594
|
score: number;
|
|
574
595
|
}
|
|
575
596
|
|
|
597
|
+
/** Result of a hybrid search call with diagnostic metadata. */
|
|
598
|
+
interface HybridSearchResult {
|
|
599
|
+
engrams: Engram[];
|
|
600
|
+
/**
|
|
601
|
+
* - "hybrid": both BM25 and embeddings contributed (full operation).
|
|
602
|
+
* - "hybrid-degraded": embeddings were configured to load but failed —
|
|
603
|
+
* ran BM25-only as a fallback. Indicates a fault to surface to the user.
|
|
604
|
+
* - "bm25-only": embeddings are explicitly disabled (env var or
|
|
605
|
+
* config.yaml); ran BM25 by design. Not a fault, no remediation needed.
|
|
606
|
+
*/
|
|
607
|
+
mode: 'hybrid' | 'hybrid-degraded' | 'bm25-only';
|
|
608
|
+
embedderError: string | null;
|
|
609
|
+
}
|
|
610
|
+
|
|
576
611
|
declare const EpisodeSchema: z.ZodObject<{
|
|
577
612
|
id: z.ZodString;
|
|
578
613
|
summary: z.ZodString;
|
|
@@ -600,19 +635,45 @@ declare const EpisodeSchema: z.ZodObject<{
|
|
|
600
635
|
}>;
|
|
601
636
|
type Episode = z.infer<typeof EpisodeSchema>;
|
|
602
637
|
|
|
603
|
-
|
|
604
|
-
|
|
638
|
+
/**
|
|
639
|
+
* A store can be either:
|
|
640
|
+
* - filesystem (path) — historical default; YAML or SQLite
|
|
641
|
+
* - remote (url + token) — speaks to a PLUR Enterprise server over HTTP
|
|
642
|
+
* Exactly one of path/url must be present.
|
|
643
|
+
*/
|
|
644
|
+
declare const StoreEntrySchema: z.ZodEffects<z.ZodObject<{
|
|
645
|
+
path: z.ZodOptional<z.ZodString>;
|
|
646
|
+
url: z.ZodOptional<z.ZodString>;
|
|
647
|
+
token: z.ZodOptional<z.ZodString>;
|
|
605
648
|
scope: z.ZodString;
|
|
606
649
|
shared: z.ZodDefault<z.ZodBoolean>;
|
|
607
650
|
readonly: z.ZodDefault<z.ZodBoolean>;
|
|
608
651
|
}, "strip", z.ZodTypeAny, {
|
|
609
|
-
path: string;
|
|
610
652
|
scope: string;
|
|
611
653
|
shared: boolean;
|
|
612
654
|
readonly: boolean;
|
|
655
|
+
path?: string | undefined;
|
|
656
|
+
url?: string | undefined;
|
|
657
|
+
token?: string | undefined;
|
|
658
|
+
}, {
|
|
659
|
+
scope: string;
|
|
660
|
+
path?: string | undefined;
|
|
661
|
+
url?: string | undefined;
|
|
662
|
+
token?: string | undefined;
|
|
663
|
+
shared?: boolean | undefined;
|
|
664
|
+
readonly?: boolean | undefined;
|
|
665
|
+
}>, {
|
|
666
|
+
scope: string;
|
|
667
|
+
shared: boolean;
|
|
668
|
+
readonly: boolean;
|
|
669
|
+
path?: string | undefined;
|
|
670
|
+
url?: string | undefined;
|
|
671
|
+
token?: string | undefined;
|
|
613
672
|
}, {
|
|
614
|
-
path: string;
|
|
615
673
|
scope: string;
|
|
674
|
+
path?: string | undefined;
|
|
675
|
+
url?: string | undefined;
|
|
676
|
+
token?: string | undefined;
|
|
616
677
|
shared?: boolean | undefined;
|
|
617
678
|
readonly?: boolean | undefined;
|
|
618
679
|
}>;
|
|
@@ -663,19 +724,46 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
663
724
|
path?: string | undefined;
|
|
664
725
|
backend?: "yaml" | "sqlite" | undefined;
|
|
665
726
|
}>>>;
|
|
666
|
-
|
|
667
|
-
|
|
727
|
+
embeddings: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
728
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
729
|
+
}, "strip", z.ZodTypeAny, {
|
|
730
|
+
enabled?: boolean | undefined;
|
|
731
|
+
}, {
|
|
732
|
+
enabled?: boolean | undefined;
|
|
733
|
+
}>>>;
|
|
734
|
+
stores: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodEffects<z.ZodObject<{
|
|
735
|
+
path: z.ZodOptional<z.ZodString>;
|
|
736
|
+
url: z.ZodOptional<z.ZodString>;
|
|
737
|
+
token: z.ZodOptional<z.ZodString>;
|
|
668
738
|
scope: z.ZodString;
|
|
669
739
|
shared: z.ZodDefault<z.ZodBoolean>;
|
|
670
740
|
readonly: z.ZodDefault<z.ZodBoolean>;
|
|
671
741
|
}, "strip", z.ZodTypeAny, {
|
|
672
|
-
path: string;
|
|
673
742
|
scope: string;
|
|
674
743
|
shared: boolean;
|
|
675
744
|
readonly: boolean;
|
|
745
|
+
path?: string | undefined;
|
|
746
|
+
url?: string | undefined;
|
|
747
|
+
token?: string | undefined;
|
|
748
|
+
}, {
|
|
749
|
+
scope: string;
|
|
750
|
+
path?: string | undefined;
|
|
751
|
+
url?: string | undefined;
|
|
752
|
+
token?: string | undefined;
|
|
753
|
+
shared?: boolean | undefined;
|
|
754
|
+
readonly?: boolean | undefined;
|
|
755
|
+
}>, {
|
|
756
|
+
scope: string;
|
|
757
|
+
shared: boolean;
|
|
758
|
+
readonly: boolean;
|
|
759
|
+
path?: string | undefined;
|
|
760
|
+
url?: string | undefined;
|
|
761
|
+
token?: string | undefined;
|
|
676
762
|
}, {
|
|
677
|
-
path: string;
|
|
678
763
|
scope: string;
|
|
764
|
+
path?: string | undefined;
|
|
765
|
+
url?: string | undefined;
|
|
766
|
+
token?: string | undefined;
|
|
679
767
|
shared?: boolean | undefined;
|
|
680
768
|
readonly?: boolean | undefined;
|
|
681
769
|
}>, "many">>>;
|
|
@@ -732,11 +820,16 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
732
820
|
path?: string | undefined;
|
|
733
821
|
backend?: "yaml" | "sqlite" | undefined;
|
|
734
822
|
} | undefined;
|
|
823
|
+
embeddings?: {
|
|
824
|
+
enabled?: boolean | undefined;
|
|
825
|
+
} | undefined;
|
|
735
826
|
stores?: {
|
|
736
|
-
path: string;
|
|
737
827
|
scope: string;
|
|
738
828
|
shared: boolean;
|
|
739
829
|
readonly: boolean;
|
|
830
|
+
path?: string | undefined;
|
|
831
|
+
url?: string | undefined;
|
|
832
|
+
token?: string | undefined;
|
|
740
833
|
}[] | undefined;
|
|
741
834
|
profile?: {
|
|
742
835
|
enabled?: boolean | undefined;
|
|
@@ -772,9 +865,14 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
772
865
|
path?: string | undefined;
|
|
773
866
|
backend?: "yaml" | "sqlite" | undefined;
|
|
774
867
|
} | undefined;
|
|
868
|
+
embeddings?: {
|
|
869
|
+
enabled?: boolean | undefined;
|
|
870
|
+
} | undefined;
|
|
775
871
|
stores?: {
|
|
776
|
-
path: string;
|
|
777
872
|
scope: string;
|
|
873
|
+
path?: string | undefined;
|
|
874
|
+
url?: string | undefined;
|
|
875
|
+
token?: string | undefined;
|
|
778
876
|
shared?: boolean | undefined;
|
|
779
877
|
readonly?: boolean | undefined;
|
|
780
878
|
}[] | undefined;
|
|
@@ -903,6 +1001,8 @@ interface LearnContext {
|
|
|
903
1001
|
memory_class?: 'semantic' | 'episodic' | 'procedural' | 'metacognitive';
|
|
904
1002
|
/** Current session episode ID for episodic anchoring (SP2 Idea 24). */
|
|
905
1003
|
session_episode_id?: string;
|
|
1004
|
+
/** Always-load flag — bypass keyword-relevance gate during injection. */
|
|
1005
|
+
pinned?: boolean;
|
|
906
1006
|
}
|
|
907
1007
|
/** Extended context for async learn with LLM dedup. */
|
|
908
1008
|
interface LearnAsyncContext extends LearnContext {
|
|
@@ -1846,6 +1946,244 @@ declare function getCachedUpdateCheck(packageName: string): VersionCheckResult |
|
|
|
1846
1946
|
/** Clear cache (for testing). */
|
|
1847
1947
|
declare function clearVersionCache(): void;
|
|
1848
1948
|
|
|
1949
|
+
declare const CAPSULE_MAGIC: Buffer<ArrayBuffer>;
|
|
1950
|
+
declare const CAPSULE_MAGIC_HEX = "50 4c 55 52";
|
|
1951
|
+
declare const FORMAT_VERSION_V1 = 1;
|
|
1952
|
+
declare const SUPPORTED_FORMAT_VERSIONS: readonly [1];
|
|
1953
|
+
declare const CAPSULE_FLAGS: {
|
|
1954
|
+
readonly SIGNED: number;
|
|
1955
|
+
readonly COMPRESSED: number;
|
|
1956
|
+
};
|
|
1957
|
+
declare const CAPSULE_FLAG_RESERVED_MASK = 65532;
|
|
1958
|
+
declare const PREAMBLE_LEN = 12;
|
|
1959
|
+
declare const CAPSULE_SIZE_LIMITS: {
|
|
1960
|
+
readonly SOFT_BYTES: number;
|
|
1961
|
+
readonly HARD_BYTES: number;
|
|
1962
|
+
};
|
|
1963
|
+
declare const ED25519_SIG_LEN = 64;
|
|
1964
|
+
declare const ManifestSummarySchema: z.ZodObject<{
|
|
1965
|
+
name: z.ZodString;
|
|
1966
|
+
version: z.ZodString;
|
|
1967
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
1968
|
+
engram_count: z.ZodNumber;
|
|
1969
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
1970
|
+
license: z.ZodDefault<z.ZodString>;
|
|
1971
|
+
}, "strip", z.ZodTypeAny, {
|
|
1972
|
+
version: string;
|
|
1973
|
+
license: string;
|
|
1974
|
+
name: string;
|
|
1975
|
+
engram_count: number;
|
|
1976
|
+
domain?: string | undefined;
|
|
1977
|
+
creator?: string | undefined;
|
|
1978
|
+
}, {
|
|
1979
|
+
version: string;
|
|
1980
|
+
name: string;
|
|
1981
|
+
engram_count: number;
|
|
1982
|
+
domain?: string | undefined;
|
|
1983
|
+
license?: string | undefined;
|
|
1984
|
+
creator?: string | undefined;
|
|
1985
|
+
}>;
|
|
1986
|
+
type ManifestSummary = z.infer<typeof ManifestSummarySchema>;
|
|
1987
|
+
declare const PayloadDescriptorSchema: z.ZodObject<{
|
|
1988
|
+
compression: z.ZodEnum<["gzip", "none"]>;
|
|
1989
|
+
size_compressed: z.ZodNumber;
|
|
1990
|
+
size_uncompressed: z.ZodNumber;
|
|
1991
|
+
sha256: z.ZodString;
|
|
1992
|
+
}, "strip", z.ZodTypeAny, {
|
|
1993
|
+
sha256: string;
|
|
1994
|
+
compression: "none" | "gzip";
|
|
1995
|
+
size_compressed: number;
|
|
1996
|
+
size_uncompressed: number;
|
|
1997
|
+
}, {
|
|
1998
|
+
sha256: string;
|
|
1999
|
+
compression: "none" | "gzip";
|
|
2000
|
+
size_compressed: number;
|
|
2001
|
+
size_uncompressed: number;
|
|
2002
|
+
}>;
|
|
2003
|
+
type PayloadDescriptor = z.infer<typeof PayloadDescriptorSchema>;
|
|
2004
|
+
declare const ProducerSchema: z.ZodObject<{
|
|
2005
|
+
tool: z.ZodString;
|
|
2006
|
+
version: z.ZodString;
|
|
2007
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
2008
|
+
}, "strip", z.ZodTypeAny, {
|
|
2009
|
+
version: string;
|
|
2010
|
+
tool: string;
|
|
2011
|
+
agent_id?: string | undefined;
|
|
2012
|
+
}, {
|
|
2013
|
+
version: string;
|
|
2014
|
+
tool: string;
|
|
2015
|
+
agent_id?: string | undefined;
|
|
2016
|
+
}>;
|
|
2017
|
+
type Producer = z.infer<typeof ProducerSchema>;
|
|
2018
|
+
declare const SignerSchema: z.ZodObject<{
|
|
2019
|
+
algo: z.ZodLiteral<"ed25519">;
|
|
2020
|
+
public_key: z.ZodString;
|
|
2021
|
+
key_id: z.ZodOptional<z.ZodString>;
|
|
2022
|
+
}, "strip", z.ZodTypeAny, {
|
|
2023
|
+
algo: "ed25519";
|
|
2024
|
+
public_key: string;
|
|
2025
|
+
key_id?: string | undefined;
|
|
2026
|
+
}, {
|
|
2027
|
+
algo: "ed25519";
|
|
2028
|
+
public_key: string;
|
|
2029
|
+
key_id?: string | undefined;
|
|
2030
|
+
}>;
|
|
2031
|
+
type Signer = z.infer<typeof SignerSchema>;
|
|
2032
|
+
declare const CapsuleHeaderSchema: z.ZodObject<{
|
|
2033
|
+
schema: z.ZodLiteral<"plur.capsule/1">;
|
|
2034
|
+
product_type: z.ZodEnum<["engram-pack", "skill"]>;
|
|
2035
|
+
manifest_summary: z.ZodObject<{
|
|
2036
|
+
name: z.ZodString;
|
|
2037
|
+
version: z.ZodString;
|
|
2038
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
2039
|
+
engram_count: z.ZodNumber;
|
|
2040
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
2041
|
+
license: z.ZodDefault<z.ZodString>;
|
|
2042
|
+
}, "strip", z.ZodTypeAny, {
|
|
2043
|
+
version: string;
|
|
2044
|
+
license: string;
|
|
2045
|
+
name: string;
|
|
2046
|
+
engram_count: number;
|
|
2047
|
+
domain?: string | undefined;
|
|
2048
|
+
creator?: string | undefined;
|
|
2049
|
+
}, {
|
|
2050
|
+
version: string;
|
|
2051
|
+
name: string;
|
|
2052
|
+
engram_count: number;
|
|
2053
|
+
domain?: string | undefined;
|
|
2054
|
+
license?: string | undefined;
|
|
2055
|
+
creator?: string | undefined;
|
|
2056
|
+
}>;
|
|
2057
|
+
payload: z.ZodObject<{
|
|
2058
|
+
compression: z.ZodEnum<["gzip", "none"]>;
|
|
2059
|
+
size_compressed: z.ZodNumber;
|
|
2060
|
+
size_uncompressed: z.ZodNumber;
|
|
2061
|
+
sha256: z.ZodString;
|
|
2062
|
+
}, "strip", z.ZodTypeAny, {
|
|
2063
|
+
sha256: string;
|
|
2064
|
+
compression: "none" | "gzip";
|
|
2065
|
+
size_compressed: number;
|
|
2066
|
+
size_uncompressed: number;
|
|
2067
|
+
}, {
|
|
2068
|
+
sha256: string;
|
|
2069
|
+
compression: "none" | "gzip";
|
|
2070
|
+
size_compressed: number;
|
|
2071
|
+
size_uncompressed: number;
|
|
2072
|
+
}>;
|
|
2073
|
+
created_at: z.ZodString;
|
|
2074
|
+
producer: z.ZodObject<{
|
|
2075
|
+
tool: z.ZodString;
|
|
2076
|
+
version: z.ZodString;
|
|
2077
|
+
agent_id: z.ZodOptional<z.ZodString>;
|
|
2078
|
+
}, "strip", z.ZodTypeAny, {
|
|
2079
|
+
version: string;
|
|
2080
|
+
tool: string;
|
|
2081
|
+
agent_id?: string | undefined;
|
|
2082
|
+
}, {
|
|
2083
|
+
version: string;
|
|
2084
|
+
tool: string;
|
|
2085
|
+
agent_id?: string | undefined;
|
|
2086
|
+
}>;
|
|
2087
|
+
signer: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
2088
|
+
algo: z.ZodLiteral<"ed25519">;
|
|
2089
|
+
public_key: z.ZodString;
|
|
2090
|
+
key_id: z.ZodOptional<z.ZodString>;
|
|
2091
|
+
}, "strip", z.ZodTypeAny, {
|
|
2092
|
+
algo: "ed25519";
|
|
2093
|
+
public_key: string;
|
|
2094
|
+
key_id?: string | undefined;
|
|
2095
|
+
}, {
|
|
2096
|
+
algo: "ed25519";
|
|
2097
|
+
public_key: string;
|
|
2098
|
+
key_id?: string | undefined;
|
|
2099
|
+
}>>>;
|
|
2100
|
+
}, "strip", z.ZodTypeAny, {
|
|
2101
|
+
schema: "plur.capsule/1";
|
|
2102
|
+
product_type: "engram-pack" | "skill";
|
|
2103
|
+
manifest_summary: {
|
|
2104
|
+
version: string;
|
|
2105
|
+
license: string;
|
|
2106
|
+
name: string;
|
|
2107
|
+
engram_count: number;
|
|
2108
|
+
domain?: string | undefined;
|
|
2109
|
+
creator?: string | undefined;
|
|
2110
|
+
};
|
|
2111
|
+
payload: {
|
|
2112
|
+
sha256: string;
|
|
2113
|
+
compression: "none" | "gzip";
|
|
2114
|
+
size_compressed: number;
|
|
2115
|
+
size_uncompressed: number;
|
|
2116
|
+
};
|
|
2117
|
+
created_at: string;
|
|
2118
|
+
producer: {
|
|
2119
|
+
version: string;
|
|
2120
|
+
tool: string;
|
|
2121
|
+
agent_id?: string | undefined;
|
|
2122
|
+
};
|
|
2123
|
+
signer: {
|
|
2124
|
+
algo: "ed25519";
|
|
2125
|
+
public_key: string;
|
|
2126
|
+
key_id?: string | undefined;
|
|
2127
|
+
} | null;
|
|
2128
|
+
}, {
|
|
2129
|
+
schema: "plur.capsule/1";
|
|
2130
|
+
product_type: "engram-pack" | "skill";
|
|
2131
|
+
manifest_summary: {
|
|
2132
|
+
version: string;
|
|
2133
|
+
name: string;
|
|
2134
|
+
engram_count: number;
|
|
2135
|
+
domain?: string | undefined;
|
|
2136
|
+
license?: string | undefined;
|
|
2137
|
+
creator?: string | undefined;
|
|
2138
|
+
};
|
|
2139
|
+
payload: {
|
|
2140
|
+
sha256: string;
|
|
2141
|
+
compression: "none" | "gzip";
|
|
2142
|
+
size_compressed: number;
|
|
2143
|
+
size_uncompressed: number;
|
|
2144
|
+
};
|
|
2145
|
+
created_at: string;
|
|
2146
|
+
producer: {
|
|
2147
|
+
version: string;
|
|
2148
|
+
tool: string;
|
|
2149
|
+
agent_id?: string | undefined;
|
|
2150
|
+
};
|
|
2151
|
+
signer?: {
|
|
2152
|
+
algo: "ed25519";
|
|
2153
|
+
public_key: string;
|
|
2154
|
+
key_id?: string | undefined;
|
|
2155
|
+
} | null | undefined;
|
|
2156
|
+
}>;
|
|
2157
|
+
type CapsuleHeader = z.infer<typeof CapsuleHeaderSchema>;
|
|
2158
|
+
interface CapsulePreamble {
|
|
2159
|
+
formatVersion: number;
|
|
2160
|
+
flags: number;
|
|
2161
|
+
headerLen: number;
|
|
2162
|
+
}
|
|
2163
|
+
declare function parseCapsulePreamble(buf: Buffer): CapsulePreamble;
|
|
2164
|
+
declare function serializeCapsulePreamble(p: CapsulePreamble): Buffer;
|
|
2165
|
+
declare function hasFlag(flags: number, flag: number): boolean;
|
|
2166
|
+
|
|
2167
|
+
interface WriteCapsuleOptions {
|
|
2168
|
+
payload: Buffer;
|
|
2169
|
+
manifestSummary: ManifestSummary;
|
|
2170
|
+
producer: Producer;
|
|
2171
|
+
productType?: 'engram-pack' | 'skill';
|
|
2172
|
+
compression?: 'gzip' | 'none';
|
|
2173
|
+
sizeUncompressed?: number;
|
|
2174
|
+
createdAt?: string;
|
|
2175
|
+
signer?: Signer | null;
|
|
2176
|
+
signature?: Buffer;
|
|
2177
|
+
}
|
|
2178
|
+
interface ReadCapsuleResult {
|
|
2179
|
+
header: CapsuleHeader;
|
|
2180
|
+
payload: Buffer;
|
|
2181
|
+
signature: Buffer | null;
|
|
2182
|
+
}
|
|
2183
|
+
declare function writeCapsule(opts: WriteCapsuleOptions): Buffer;
|
|
2184
|
+
declare function readCapsule(buf: Buffer): ReadCapsuleResult;
|
|
2185
|
+
declare function verifyCapsuleIntegrity(buf: Buffer): boolean;
|
|
2186
|
+
|
|
1849
2187
|
interface IngestOptions {
|
|
1850
2188
|
source?: string;
|
|
1851
2189
|
extract_only?: boolean;
|
|
@@ -1887,6 +2225,21 @@ declare class Plur {
|
|
|
1887
2225
|
private _loadAllEngrams;
|
|
1888
2226
|
/** Load engrams from a path with mtime-based caching */
|
|
1889
2227
|
private _loadCached;
|
|
2228
|
+
/**
|
|
2229
|
+
* Per-instance pool of RemoteStore drivers, keyed by url+scope.
|
|
2230
|
+
* RemoteStore holds its own internal TTL cache so repeated load()
|
|
2231
|
+
* within ttlMs returns the same array without a network call.
|
|
2232
|
+
*
|
|
2233
|
+
* Note `_loadAllEngrams` is sync but RemoteStore.load() is async.
|
|
2234
|
+
* We bridge that by returning whatever's in the driver's cache
|
|
2235
|
+
* synchronously and triggering a background refresh on cache miss.
|
|
2236
|
+
* The first call after server start returns [] for that store; the
|
|
2237
|
+
* call after the first refresh sees the data. For our pilot this
|
|
2238
|
+
* is acceptable — recall is expected to be tried more than once
|
|
2239
|
+
* in any real session.
|
|
2240
|
+
*/
|
|
2241
|
+
private _remoteStores;
|
|
2242
|
+
private _loadRemoteCached;
|
|
1890
2243
|
/**
|
|
1891
2244
|
* Write engrams to disk and invalidate the cache for that path.
|
|
1892
2245
|
*
|
|
@@ -1935,6 +2288,16 @@ declare class Plur {
|
|
|
1935
2288
|
recallSemantic(query: string, options?: Omit<RecallOptions, 'mode' | 'llm'>): Promise<Engram[]>;
|
|
1936
2289
|
/** Hybrid search: BM25 + embeddings merged via Reciprocal Rank Fusion. Async, no API calls. */
|
|
1937
2290
|
recallHybrid(query: string, options?: Omit<RecallOptions, 'mode' | 'llm'>): Promise<Engram[]>;
|
|
2291
|
+
/**
|
|
2292
|
+
* Hybrid search with diagnostic metadata — returns both the engrams and
|
|
2293
|
+
* whether embeddings actually contributed (mode: "hybrid" vs "hybrid-degraded").
|
|
2294
|
+
* Use this when you want to surface degraded-mode warnings to users.
|
|
2295
|
+
*/
|
|
2296
|
+
recallHybridWithMeta(query: string, options?: Omit<RecallOptions, 'mode' | 'llm'>): Promise<HybridSearchResult>;
|
|
2297
|
+
/** Inspect embedder availability without forcing a load. */
|
|
2298
|
+
embedderStatus(): EmbedderStatus;
|
|
2299
|
+
/** Reset cached embedder failure state — next call will retry the model load. */
|
|
2300
|
+
resetEmbedder(): void;
|
|
1938
2301
|
/** Embedding search returning {engram, score}[] with cosine similarity scores. Async, no API calls. */
|
|
1939
2302
|
similaritySearch(query: string, options?: {
|
|
1940
2303
|
limit?: number;
|
|
@@ -1972,6 +2335,13 @@ declare class Plur {
|
|
|
1972
2335
|
};
|
|
1973
2336
|
/** Update an existing engram in the store by ID. Returns true if found and updated. */
|
|
1974
2337
|
updateEngram(updated: Engram): boolean;
|
|
2338
|
+
/**
|
|
2339
|
+
* Toggle the always-load (pinned) flag for an engram.
|
|
2340
|
+
* Returns the updated engram on success, null if not found.
|
|
2341
|
+
*/
|
|
2342
|
+
setPinned(id: string, pinned: boolean): Engram | null;
|
|
2343
|
+
/** List engrams that have pinned: true. */
|
|
2344
|
+
listPinned(): Engram[];
|
|
1975
2345
|
/** Set engram status to 'retired'. Supports primary and store engrams. */
|
|
1976
2346
|
forget(id: string, reason?: string): void;
|
|
1977
2347
|
/** Remove retired engrams from storage. Returns count of removed and remaining. */
|
|
@@ -2045,10 +2415,23 @@ declare class Plur {
|
|
|
2045
2415
|
}>;
|
|
2046
2416
|
/** Return system health info. */
|
|
2047
2417
|
status(): StatusResult;
|
|
2048
|
-
/**
|
|
2418
|
+
/**
|
|
2419
|
+
* Register an additional engram store.
|
|
2420
|
+
*
|
|
2421
|
+
* Two shapes — exactly one of `pathOrUrl` semantics applies:
|
|
2422
|
+
* - filesystem (default): pass a path. `options.url` undefined.
|
|
2423
|
+
* - remote (PLUR Enterprise / any compatible REST API):
|
|
2424
|
+
* pass any string for the first arg (it goes into a slot we
|
|
2425
|
+
* never read), set `options.url` + `options.token`.
|
|
2426
|
+
*
|
|
2427
|
+
* Backwards compatible: existing call sites that pass a filesystem
|
|
2428
|
+
* path keep working.
|
|
2429
|
+
*/
|
|
2049
2430
|
addStore(storePath: string, scope: string, options?: {
|
|
2050
2431
|
shared?: boolean;
|
|
2051
2432
|
readonly?: boolean;
|
|
2433
|
+
url?: string;
|
|
2434
|
+
token?: string;
|
|
2052
2435
|
}): void;
|
|
2053
2436
|
/**
|
|
2054
2437
|
* Auto-discover .plur/engrams.yaml in CWD and parent dirs (up to git root).
|
|
@@ -2061,7 +2444,8 @@ declare class Plur {
|
|
|
2061
2444
|
}>;
|
|
2062
2445
|
/** List all configured stores. */
|
|
2063
2446
|
listStores(): Array<{
|
|
2064
|
-
path
|
|
2447
|
+
path?: string;
|
|
2448
|
+
url?: string;
|
|
2065
2449
|
scope: string;
|
|
2066
2450
|
shared: boolean;
|
|
2067
2451
|
readonly: boolean;
|
|
@@ -2069,4 +2453,4 @@ declare class Plur {
|
|
|
2069
2453
|
}>;
|
|
2070
2454
|
}
|
|
2071
2455
|
|
|
2072
|
-
export { ALL_MIGRATIONS, type AlignmentResult, type Association, type AutoSearchResult, type BatchDecayOptions, type BatchDecayResult, type BoundedRecallResult, COMMITMENT_MULTIPLIER, CURRENT_SCHEMA_VERSION, type CaptureContext, type DecayTransition, type DedupConfig, type DedupDecision, type DomainCoverage, DomainCoverageSchema, type Engram, type EngramCluster, type EngramStore, type Episode, type EvidenceEntry, EvidenceEntrySchema, type ExtractOptions, type ExtractionResult, type Falsification, FalsificationSchema, type HierarchyPosition, HierarchyPositionSchema, type HistoryEvent, IndexedStorage, type IngestCandidate, type IngestOptions, type InjectOptions, type InjectionLayer, type InjectionResult, type KnowledgeAnchor, type LearnAsyncContext, type LearnAsyncResult, type LearnBatchResult, type LearnContext, type LlmFunction, type LlmTierConfig, type MemberAlignment, type MetaConfidence, MetaConfidenceSchema, type MetaField, MetaFieldSchema, type Migration, type MigrationResult, type ModelTier, PLATITUDE_PATTERNS, type PackManifest, Plur, type PlurConfig, type PlurPaths, type PreviewResult, type PreviousVersionRef, type PrivacyIssue, type PrivacyScanResult, type ProfileCache, type RecallBudget, type RecallOptions, type RegistryEntry, type RelationalAnalysis, type RelationalTriple, type SearchStrategy, SessionBreadcrumbs, type SimilarityResult, SqliteStore, type StatusResult, type StorageBackend, type StorageConfig, type StoreEntry, type StructuralTemplate, StructuralTemplateSchema, type SyncResult, type SyncStatus, type TimelineQuery, type TypedRole, type ValidationResult, type VersionCheckResult, YamlStore, alignCluster, analyzeStructure, appendHistory, applyBatchDecay, assignLayer, asyncAtomicWrite, autoSummary, buildBatchDedupPrompt, buildDedupPrompt, checkForUpdate, classifyPolarity, clearVersionCache, clusterByStructure, computeConfidence, computeContentHash, computeMetaConfidence, confidenceBand, createStore, detectPlurStorage, detectSecrets, engramSearchText, extractMetaEngrams, formatLayer1, formatLayer2, formatLayer3, formatWithLayer, formulateMetaEngram, freshTailBoost, generateEventId, generateGuardrails, generateProfile, generateSummary, getCachedUpdateCheck, getProfileForInjection, getSchemaVersion, isPlatitude, listHistoryMonths, loadProfileCache, markProfileDirty, migrateStore, needsSummary, normalizeStatement, organizeHierarchy, parseDedupResponse, profileNeedsRegeneration, readHistory, readHistoryForEngram, recallAuto, resolveOperationTier, rollbackMigrations, runMigrations, saveProfileCache, selectModel, selectModelForOperation, setSchemaVersion, strengthToStatus, tokenSimilarity, validateMetaEngram, withAsyncLock };
|
|
2456
|
+
export { ALL_MIGRATIONS, type AlignmentResult, type Association, type AutoSearchResult, type BatchDecayOptions, type BatchDecayResult, type BoundedRecallResult, CAPSULE_FLAGS, CAPSULE_FLAG_RESERVED_MASK, CAPSULE_MAGIC, CAPSULE_MAGIC_HEX, CAPSULE_SIZE_LIMITS, COMMITMENT_MULTIPLIER, CURRENT_SCHEMA_VERSION, type CapsuleHeader, CapsuleHeaderSchema, type CapsulePreamble, type CaptureContext, type DecayTransition, type DedupConfig, type DedupDecision, type DomainCoverage, DomainCoverageSchema, ED25519_SIG_LEN, type Engram, type EngramCluster, type EngramStore, type Episode, type EvidenceEntry, EvidenceEntrySchema, type ExtractOptions, type ExtractionResult, FORMAT_VERSION_V1, type Falsification, FalsificationSchema, type HierarchyPosition, HierarchyPositionSchema, type HistoryEvent, IndexedStorage, type IngestCandidate, type IngestOptions, type InjectOptions, type InjectionLayer, type InjectionResult, type KnowledgeAnchor, type LearnAsyncContext, type LearnAsyncResult, type LearnBatchResult, type LearnContext, type LlmFunction, type LlmTierConfig, type ManifestSummary, ManifestSummarySchema, type MemberAlignment, type MetaConfidence, MetaConfidenceSchema, type MetaField, MetaFieldSchema, type Migration, type MigrationResult, type ModelTier, PLATITUDE_PATTERNS, PREAMBLE_LEN, type PackManifest, type PayloadDescriptor, PayloadDescriptorSchema, Plur, type PlurConfig, type PlurPaths, type PreviewResult, type PreviousVersionRef, type PrivacyIssue, type PrivacyScanResult, type Producer, ProducerSchema, type ProfileCache, type ReadCapsuleResult, type RecallBudget, type RecallOptions, type RegistryEntry, type RelationalAnalysis, type RelationalTriple, SUPPORTED_FORMAT_VERSIONS, type SearchStrategy, SessionBreadcrumbs, type Signer, SignerSchema, type SimilarityResult, SqliteStore, type StatusResult, type StorageBackend, type StorageConfig, type StoreEntry, type StructuralTemplate, StructuralTemplateSchema, type SyncResult, type SyncStatus, type TimelineQuery, type TypedRole, type ValidationResult, type VersionCheckResult, type WriteCapsuleOptions, YamlStore, alignCluster, analyzeStructure, appendHistory, applyBatchDecay, assignLayer, asyncAtomicWrite, autoSummary, buildBatchDedupPrompt, buildDedupPrompt, checkForUpdate, classifyPolarity, clearVersionCache, clusterByStructure, computeConfidence, computeContentHash, computeMetaConfidence, confidenceBand, createStore, detectPlurStorage, detectSecrets, engramSearchText, extractMetaEngrams, formatLayer1, formatLayer2, formatLayer3, formatWithLayer, formulateMetaEngram, freshTailBoost, generateEventId, generateGuardrails, generateProfile, generateSummary, getCachedUpdateCheck, getProfileForInjection, getSchemaVersion, hasFlag, isPlatitude, listHistoryMonths, loadProfileCache, markProfileDirty, migrateStore, needsSummary, normalizeStatement, organizeHierarchy, parseCapsulePreamble, parseDedupResponse, profileNeedsRegeneration, readCapsule, readHistory, readHistoryForEngram, recallAuto, resolveOperationTier, rollbackMigrations, runMigrations, saveProfileCache, selectModel, selectModelForOperation, serializeCapsulePreamble, setSchemaVersion, strengthToStatus, tokenSimilarity, validateMetaEngram, verifyCapsuleIntegrity, withAsyncLock, writeCapsule };
|