@plur-ai/core 0.7.7 → 0.8.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/dist/chunk-GRDNBUIJ.js +452 -0
- package/dist/{chunk-KMVQYBNP.js → chunk-MY4XVDCE.js} +1 -192
- package/dist/chunk-UETCDULF.js +196 -0
- package/dist/{embeddings-2IODIQAF.js → embeddings-EX7QPXJS.js} +2 -1
- package/dist/index.d.ts +693 -193
- package/dist/index.js +1320 -420
- package/dist/learn-async-VXBH3TYE.js +184 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
|
|
3
|
+
interface HistoryEvent {
|
|
4
|
+
event: 'engram_created' | 'engram_updated' | 'engram_merged' | 'feedback_received' | 'engram_retired' | 'engram_promoted' | 'failure_reported' | 'procedure_evolved';
|
|
5
|
+
engram_id: string;
|
|
6
|
+
timestamp: string;
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Append a history event to the JSONL file for the current month.
|
|
11
|
+
* Files are stored in {root}/history/YYYY-MM.jsonl.
|
|
12
|
+
* Auto-creates the history directory and file on first write.
|
|
13
|
+
*/
|
|
14
|
+
declare function appendHistory(root: string, event: HistoryEvent): void;
|
|
15
|
+
/**
|
|
16
|
+
* Read history events from a specific month's JSONL file.
|
|
17
|
+
* Returns empty array if file doesn't exist.
|
|
18
|
+
*/
|
|
19
|
+
declare function readHistory(root: string, yearMonth: string): HistoryEvent[];
|
|
20
|
+
/**
|
|
21
|
+
* List all available history months (YYYY-MM format).
|
|
22
|
+
*/
|
|
23
|
+
declare function listHistoryMonths(root: string): string[];
|
|
24
|
+
/**
|
|
25
|
+
* Read all history events for a specific engram, across all months.
|
|
26
|
+
* Returns events sorted chronologically.
|
|
27
|
+
*/
|
|
28
|
+
declare function readHistoryForEngram(root: string, engramId: string): HistoryEvent[];
|
|
29
|
+
/**
|
|
30
|
+
* Generate a unique event ID for history entries.
|
|
31
|
+
*/
|
|
32
|
+
declare function generateEventId(): string;
|
|
33
|
+
|
|
3
34
|
declare const KnowledgeAnchorSchema: z.ZodObject<{
|
|
4
35
|
path: z.ZodString;
|
|
5
36
|
relevance: z.ZodDefault<z.ZodEnum<["primary", "supporting", "example"]>>;
|
|
@@ -35,6 +66,16 @@ declare const AssociationSchema: z.ZodObject<{
|
|
|
35
66
|
strength: number;
|
|
36
67
|
updated_at?: string | undefined;
|
|
37
68
|
}>;
|
|
69
|
+
declare const PreviousVersionRefSchema: z.ZodObject<{
|
|
70
|
+
event_id: z.ZodString;
|
|
71
|
+
changed_at: z.ZodString;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
event_id: string;
|
|
74
|
+
changed_at: string;
|
|
75
|
+
}, {
|
|
76
|
+
event_id: string;
|
|
77
|
+
changed_at: string;
|
|
78
|
+
}>;
|
|
38
79
|
declare const EngramSchema: z.ZodObject<{
|
|
39
80
|
id: z.ZodString;
|
|
40
81
|
version: z.ZodDefault<z.ZodNumber>;
|
|
@@ -57,10 +98,10 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
57
98
|
cognitive_level: z.ZodEnum<["remember", "understand", "apply", "analyze", "evaluate", "create"]>;
|
|
58
99
|
}, "strip", z.ZodTypeAny, {
|
|
59
100
|
memory_class: "procedural" | "semantic" | "episodic" | "metacognitive";
|
|
60
|
-
cognitive_level: "
|
|
101
|
+
cognitive_level: "apply" | "remember" | "evaluate" | "understand" | "analyze" | "create";
|
|
61
102
|
}, {
|
|
62
103
|
memory_class: "procedural" | "semantic" | "episodic" | "metacognitive";
|
|
63
|
-
cognitive_level: "
|
|
104
|
+
cognitive_level: "apply" | "remember" | "evaluate" | "understand" | "analyze" | "create";
|
|
64
105
|
}>>;
|
|
65
106
|
domain: z.ZodOptional<z.ZodString>;
|
|
66
107
|
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -262,6 +303,23 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
262
303
|
structured_data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
263
304
|
/** Polarity classification: 'do' for directives, 'dont' for prohibitions, null for unclassified. */
|
|
264
305
|
polarity: z.ZodDefault<z.ZodNullable<z.ZodEnum<["do", "dont"]>>>;
|
|
306
|
+
content_hash: z.ZodOptional<z.ZodString>;
|
|
307
|
+
commitment: z.ZodOptional<z.ZodEnum<["exploring", "leaning", "decided", "locked"]>>;
|
|
308
|
+
locked_at: z.ZodOptional<z.ZodString>;
|
|
309
|
+
locked_reason: z.ZodOptional<z.ZodString>;
|
|
310
|
+
engram_version: z.ZodDefault<z.ZodNumber>;
|
|
311
|
+
previous_version_ref: z.ZodOptional<z.ZodObject<{
|
|
312
|
+
event_id: z.ZodString;
|
|
313
|
+
changed_at: z.ZodString;
|
|
314
|
+
}, "strip", z.ZodTypeAny, {
|
|
315
|
+
event_id: string;
|
|
316
|
+
changed_at: string;
|
|
317
|
+
}, {
|
|
318
|
+
event_id: string;
|
|
319
|
+
changed_at: string;
|
|
320
|
+
}>>;
|
|
321
|
+
episode_ids: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
322
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
265
323
|
}, "strip", z.ZodTypeAny, {
|
|
266
324
|
type: "behavioral" | "architectural" | "procedural" | "terminological";
|
|
267
325
|
status: "active" | "dormant" | "retired" | "candidate";
|
|
@@ -301,6 +359,8 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
301
359
|
neutral: number;
|
|
302
360
|
};
|
|
303
361
|
polarity: "do" | "dont" | null;
|
|
362
|
+
engram_version: number;
|
|
363
|
+
episode_ids: string[];
|
|
304
364
|
rationale?: string | undefined;
|
|
305
365
|
contraindications?: string[] | undefined;
|
|
306
366
|
source?: string | undefined;
|
|
@@ -313,7 +373,7 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
313
373
|
} | undefined;
|
|
314
374
|
knowledge_type?: {
|
|
315
375
|
memory_class: "procedural" | "semantic" | "episodic" | "metacognitive";
|
|
316
|
-
cognitive_level: "
|
|
376
|
+
cognitive_level: "apply" | "remember" | "evaluate" | "understand" | "analyze" | "create";
|
|
317
377
|
} | undefined;
|
|
318
378
|
domain?: string | undefined;
|
|
319
379
|
relations?: {
|
|
@@ -356,6 +416,15 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
356
416
|
fitness_score?: number | undefined;
|
|
357
417
|
} | undefined;
|
|
358
418
|
structured_data?: Record<string, unknown> | undefined;
|
|
419
|
+
content_hash?: string | undefined;
|
|
420
|
+
commitment?: "locked" | "decided" | "leaning" | "exploring" | undefined;
|
|
421
|
+
locked_at?: string | undefined;
|
|
422
|
+
locked_reason?: string | undefined;
|
|
423
|
+
previous_version_ref?: {
|
|
424
|
+
event_id: string;
|
|
425
|
+
changed_at: string;
|
|
426
|
+
} | undefined;
|
|
427
|
+
summary?: string | undefined;
|
|
359
428
|
}, {
|
|
360
429
|
type: "behavioral" | "architectural" | "procedural" | "terminological";
|
|
361
430
|
status: "active" | "dormant" | "retired" | "candidate";
|
|
@@ -381,7 +450,7 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
381
450
|
} | undefined;
|
|
382
451
|
knowledge_type?: {
|
|
383
452
|
memory_class: "procedural" | "semantic" | "episodic" | "metacognitive";
|
|
384
|
-
cognitive_level: "
|
|
453
|
+
cognitive_level: "apply" | "remember" | "evaluate" | "understand" | "analyze" | "create";
|
|
385
454
|
} | undefined;
|
|
386
455
|
domain?: string | undefined;
|
|
387
456
|
tags?: string[] | undefined;
|
|
@@ -450,197 +519,22 @@ declare const EngramSchema: z.ZodObject<{
|
|
|
450
519
|
} | undefined;
|
|
451
520
|
structured_data?: Record<string, unknown> | undefined;
|
|
452
521
|
polarity?: "do" | "dont" | null | undefined;
|
|
522
|
+
content_hash?: string | undefined;
|
|
523
|
+
commitment?: "locked" | "decided" | "leaning" | "exploring" | undefined;
|
|
524
|
+
locked_at?: string | undefined;
|
|
525
|
+
locked_reason?: string | undefined;
|
|
526
|
+
engram_version?: number | undefined;
|
|
527
|
+
previous_version_ref?: {
|
|
528
|
+
event_id: string;
|
|
529
|
+
changed_at: string;
|
|
530
|
+
} | undefined;
|
|
531
|
+
episode_ids?: string[] | undefined;
|
|
532
|
+
summary?: string | undefined;
|
|
453
533
|
}>;
|
|
454
534
|
type Engram = z.infer<typeof EngramSchema>;
|
|
455
535
|
type KnowledgeAnchor = z.infer<typeof KnowledgeAnchorSchema>;
|
|
456
536
|
type Association = z.infer<typeof AssociationSchema>;
|
|
457
|
-
|
|
458
|
-
declare const PackManifestSchema: z.ZodObject<{
|
|
459
|
-
name: z.ZodString;
|
|
460
|
-
version: z.ZodString;
|
|
461
|
-
description: z.ZodOptional<z.ZodString>;
|
|
462
|
-
creator: z.ZodOptional<z.ZodString>;
|
|
463
|
-
license: z.ZodDefault<z.ZodString>;
|
|
464
|
-
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
465
|
-
metadata: z.ZodOptional<z.ZodObject<{
|
|
466
|
-
id: z.ZodOptional<z.ZodString>;
|
|
467
|
-
injection_policy: z.ZodDefault<z.ZodEnum<["on_match", "on_request", "always"]>>;
|
|
468
|
-
match_terms: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
469
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
470
|
-
engram_count: z.ZodOptional<z.ZodNumber>;
|
|
471
|
-
}, "strip", z.ZodTypeAny, {
|
|
472
|
-
injection_policy: "on_match" | "on_request" | "always";
|
|
473
|
-
match_terms: string[];
|
|
474
|
-
id?: string | undefined;
|
|
475
|
-
domain?: string | undefined;
|
|
476
|
-
engram_count?: number | undefined;
|
|
477
|
-
}, {
|
|
478
|
-
id?: string | undefined;
|
|
479
|
-
domain?: string | undefined;
|
|
480
|
-
injection_policy?: "on_match" | "on_request" | "always" | undefined;
|
|
481
|
-
match_terms?: string[] | undefined;
|
|
482
|
-
engram_count?: number | undefined;
|
|
483
|
-
}>>;
|
|
484
|
-
'x-datacore': z.ZodOptional<z.ZodObject<{
|
|
485
|
-
id: z.ZodString;
|
|
486
|
-
injection_policy: z.ZodEnum<["on_match", "on_request"]>;
|
|
487
|
-
match_terms: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
488
|
-
domain: z.ZodOptional<z.ZodString>;
|
|
489
|
-
engram_count: z.ZodNumber;
|
|
490
|
-
}, "strip", z.ZodTypeAny, {
|
|
491
|
-
id: string;
|
|
492
|
-
injection_policy: "on_match" | "on_request";
|
|
493
|
-
match_terms: string[];
|
|
494
|
-
engram_count: number;
|
|
495
|
-
domain?: string | undefined;
|
|
496
|
-
}, {
|
|
497
|
-
id: string;
|
|
498
|
-
injection_policy: "on_match" | "on_request";
|
|
499
|
-
engram_count: number;
|
|
500
|
-
domain?: string | undefined;
|
|
501
|
-
match_terms?: string[] | undefined;
|
|
502
|
-
}>>;
|
|
503
|
-
}, "strip", z.ZodTypeAny, {
|
|
504
|
-
version: string;
|
|
505
|
-
tags: string[];
|
|
506
|
-
license: string;
|
|
507
|
-
name: string;
|
|
508
|
-
description?: string | undefined;
|
|
509
|
-
creator?: string | undefined;
|
|
510
|
-
metadata?: {
|
|
511
|
-
injection_policy: "on_match" | "on_request" | "always";
|
|
512
|
-
match_terms: string[];
|
|
513
|
-
id?: string | undefined;
|
|
514
|
-
domain?: string | undefined;
|
|
515
|
-
engram_count?: number | undefined;
|
|
516
|
-
} | undefined;
|
|
517
|
-
'x-datacore'?: {
|
|
518
|
-
id: string;
|
|
519
|
-
injection_policy: "on_match" | "on_request";
|
|
520
|
-
match_terms: string[];
|
|
521
|
-
engram_count: number;
|
|
522
|
-
domain?: string | undefined;
|
|
523
|
-
} | undefined;
|
|
524
|
-
}, {
|
|
525
|
-
version: string;
|
|
526
|
-
name: string;
|
|
527
|
-
tags?: string[] | undefined;
|
|
528
|
-
license?: string | undefined;
|
|
529
|
-
description?: string | undefined;
|
|
530
|
-
creator?: string | undefined;
|
|
531
|
-
metadata?: {
|
|
532
|
-
id?: string | undefined;
|
|
533
|
-
domain?: string | undefined;
|
|
534
|
-
injection_policy?: "on_match" | "on_request" | "always" | undefined;
|
|
535
|
-
match_terms?: string[] | undefined;
|
|
536
|
-
engram_count?: number | undefined;
|
|
537
|
-
} | undefined;
|
|
538
|
-
'x-datacore'?: {
|
|
539
|
-
id: string;
|
|
540
|
-
injection_policy: "on_match" | "on_request";
|
|
541
|
-
engram_count: number;
|
|
542
|
-
domain?: string | undefined;
|
|
543
|
-
match_terms?: string[] | undefined;
|
|
544
|
-
} | undefined;
|
|
545
|
-
}>;
|
|
546
|
-
type PackManifest = z.infer<typeof PackManifestSchema>;
|
|
547
|
-
|
|
548
|
-
interface RegistryEntry {
|
|
549
|
-
name: string;
|
|
550
|
-
installed_at: string;
|
|
551
|
-
source: string;
|
|
552
|
-
integrity: string;
|
|
553
|
-
version?: string;
|
|
554
|
-
creator?: string;
|
|
555
|
-
}
|
|
556
|
-
interface PreviewResult {
|
|
557
|
-
manifest: PackManifest;
|
|
558
|
-
engram_count: number;
|
|
559
|
-
engrams: Array<{
|
|
560
|
-
id: string;
|
|
561
|
-
type: string;
|
|
562
|
-
statement: string;
|
|
563
|
-
domain?: string;
|
|
564
|
-
tags: string[];
|
|
565
|
-
}>;
|
|
566
|
-
security: PrivacyScanResult;
|
|
567
|
-
warnings: string[];
|
|
568
|
-
}
|
|
569
|
-
declare function previewPack(source: string): PreviewResult;
|
|
570
|
-
interface InstallResult {
|
|
571
|
-
installed: number;
|
|
572
|
-
name: string;
|
|
573
|
-
conflicts: ConflictItem[];
|
|
574
|
-
security: PrivacyScanResult;
|
|
575
|
-
registry: RegistryEntry;
|
|
576
|
-
}
|
|
577
|
-
interface ConflictItem {
|
|
578
|
-
pack_engram_id: string;
|
|
579
|
-
pack_statement: string;
|
|
580
|
-
existing_engram_id: string;
|
|
581
|
-
existing_statement: string;
|
|
582
|
-
type: 'contradiction' | 'duplicate';
|
|
583
|
-
}
|
|
584
|
-
declare function installPack(packsDir: string, source: string, existingEngrams?: Engram[]): InstallResult;
|
|
585
|
-
interface UninstallResult {
|
|
586
|
-
name: string;
|
|
587
|
-
removed: boolean;
|
|
588
|
-
engram_count: number;
|
|
589
|
-
}
|
|
590
|
-
declare function uninstallPack(packsDir: string, name: string): UninstallResult;
|
|
591
|
-
interface PackInfo {
|
|
592
|
-
name: string;
|
|
593
|
-
path: string;
|
|
594
|
-
engram_count: number;
|
|
595
|
-
manifest?: PackManifest;
|
|
596
|
-
integrity?: string;
|
|
597
|
-
installed_at?: string;
|
|
598
|
-
source?: string;
|
|
599
|
-
integrity_ok?: boolean;
|
|
600
|
-
}
|
|
601
|
-
declare function listPacks(packsDir: string): PackInfo[];
|
|
602
|
-
interface ExportOptions {
|
|
603
|
-
name: string;
|
|
604
|
-
version: string;
|
|
605
|
-
description?: string;
|
|
606
|
-
creator?: string;
|
|
607
|
-
domain?: string;
|
|
608
|
-
scope?: string;
|
|
609
|
-
tags?: string[];
|
|
610
|
-
type?: string;
|
|
611
|
-
}
|
|
612
|
-
interface PrivacyScanResult {
|
|
613
|
-
clean: boolean;
|
|
614
|
-
issues: PrivacyIssue[];
|
|
615
|
-
}
|
|
616
|
-
interface PrivacyIssue {
|
|
617
|
-
engram_id: string;
|
|
618
|
-
type: 'secret' | 'private_visibility' | 'personal_path' | 'email' | 'ip_address';
|
|
619
|
-
detail: string;
|
|
620
|
-
}
|
|
621
|
-
interface ExportResult {
|
|
622
|
-
path: string;
|
|
623
|
-
engram_count: number;
|
|
624
|
-
privacy: PrivacyScanResult;
|
|
625
|
-
match_terms: string[];
|
|
626
|
-
integrity: string;
|
|
627
|
-
}
|
|
628
|
-
declare function exportPack(engrams: Engram[], outputDir: string, manifest: ExportOptions): ExportResult;
|
|
629
|
-
|
|
630
|
-
interface SyncStatus {
|
|
631
|
-
initialized: boolean;
|
|
632
|
-
remote: string | null;
|
|
633
|
-
dirty: boolean;
|
|
634
|
-
branch: string | null;
|
|
635
|
-
ahead: number;
|
|
636
|
-
behind: number;
|
|
637
|
-
}
|
|
638
|
-
interface SyncResult {
|
|
639
|
-
action: 'initialized' | 'committed' | 'synced' | 'up-to-date';
|
|
640
|
-
message: string;
|
|
641
|
-
remote: string | null;
|
|
642
|
-
files_changed: number;
|
|
643
|
-
}
|
|
537
|
+
type PreviousVersionRef = z.infer<typeof PreviousVersionRefSchema>;
|
|
644
538
|
|
|
645
539
|
declare const EpisodeSchema: z.ZodObject<{
|
|
646
540
|
id: z.ZodString;
|
|
@@ -706,8 +600,32 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
706
600
|
spread_budget?: number | undefined;
|
|
707
601
|
co_access?: boolean | undefined;
|
|
708
602
|
}>>>;
|
|
603
|
+
dedup: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
604
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
605
|
+
threshold: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
606
|
+
mode: z.ZodOptional<z.ZodDefault<z.ZodEnum<["llm", "cosine", "off"]>>>;
|
|
607
|
+
}, "strip", z.ZodTypeAny, {
|
|
608
|
+
enabled?: boolean | undefined;
|
|
609
|
+
threshold?: number | undefined;
|
|
610
|
+
mode?: "llm" | "cosine" | "off" | undefined;
|
|
611
|
+
}, {
|
|
612
|
+
enabled?: boolean | undefined;
|
|
613
|
+
threshold?: number | undefined;
|
|
614
|
+
mode?: "llm" | "cosine" | "off" | undefined;
|
|
615
|
+
}>>>;
|
|
616
|
+
decay_baseline: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
709
617
|
allow_secrets: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
710
618
|
index: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
619
|
+
storage: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
620
|
+
backend: z.ZodOptional<z.ZodDefault<z.ZodEnum<["yaml", "sqlite"]>>>;
|
|
621
|
+
path: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
622
|
+
}, "strip", z.ZodTypeAny, {
|
|
623
|
+
path?: string | undefined;
|
|
624
|
+
backend?: "yaml" | "sqlite" | undefined;
|
|
625
|
+
}, {
|
|
626
|
+
path?: string | undefined;
|
|
627
|
+
backend?: "yaml" | "sqlite" | undefined;
|
|
628
|
+
}>>>;
|
|
711
629
|
stores: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
712
630
|
path: z.ZodString;
|
|
713
631
|
scope: z.ZodString;
|
|
@@ -724,6 +642,30 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
724
642
|
shared?: boolean | undefined;
|
|
725
643
|
readonly?: boolean | undefined;
|
|
726
644
|
}>, "many">>>;
|
|
645
|
+
llm: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
646
|
+
dedup_tier: z.ZodOptional<z.ZodDefault<z.ZodEnum<["fast", "balanced", "thorough"]>>>;
|
|
647
|
+
profile_tier: z.ZodOptional<z.ZodDefault<z.ZodEnum<["fast", "balanced", "thorough"]>>>;
|
|
648
|
+
meta_tier: z.ZodOptional<z.ZodDefault<z.ZodEnum<["fast", "balanced", "thorough"]>>>;
|
|
649
|
+
}, "strip", z.ZodTypeAny, {
|
|
650
|
+
dedup_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
651
|
+
profile_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
652
|
+
meta_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
653
|
+
}, {
|
|
654
|
+
dedup_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
655
|
+
profile_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
656
|
+
meta_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
657
|
+
}>>>;
|
|
658
|
+
profile: z.ZodOptional<z.ZodDefault<z.ZodObject<{
|
|
659
|
+
enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
660
|
+
cache_ttl_hours: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
|
|
661
|
+
}, "strip", z.ZodTypeAny, {
|
|
662
|
+
enabled?: boolean | undefined;
|
|
663
|
+
cache_ttl_hours?: number | undefined;
|
|
664
|
+
}, {
|
|
665
|
+
enabled?: boolean | undefined;
|
|
666
|
+
cache_ttl_hours?: number | undefined;
|
|
667
|
+
}>>>;
|
|
668
|
+
registry_url: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
727
669
|
}, "strip", z.ZodTypeAny, {
|
|
728
670
|
auto_learn?: boolean | undefined;
|
|
729
671
|
auto_capture?: boolean | undefined;
|
|
@@ -736,14 +678,34 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
736
678
|
spread_budget: number;
|
|
737
679
|
co_access: boolean;
|
|
738
680
|
} | undefined;
|
|
681
|
+
llm?: {
|
|
682
|
+
dedup_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
683
|
+
profile_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
684
|
+
meta_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
685
|
+
} | undefined;
|
|
686
|
+
dedup?: {
|
|
687
|
+
enabled?: boolean | undefined;
|
|
688
|
+
threshold?: number | undefined;
|
|
689
|
+
mode?: "llm" | "cosine" | "off" | undefined;
|
|
690
|
+
} | undefined;
|
|
691
|
+
decay_baseline?: string | undefined;
|
|
739
692
|
allow_secrets?: boolean | undefined;
|
|
740
693
|
index?: boolean | undefined;
|
|
694
|
+
storage?: {
|
|
695
|
+
path?: string | undefined;
|
|
696
|
+
backend?: "yaml" | "sqlite" | undefined;
|
|
697
|
+
} | undefined;
|
|
741
698
|
stores?: {
|
|
742
699
|
path: string;
|
|
743
700
|
scope: string;
|
|
744
701
|
shared: boolean;
|
|
745
702
|
readonly: boolean;
|
|
746
703
|
}[] | undefined;
|
|
704
|
+
profile?: {
|
|
705
|
+
enabled?: boolean | undefined;
|
|
706
|
+
cache_ttl_hours?: number | undefined;
|
|
707
|
+
} | undefined;
|
|
708
|
+
registry_url?: string | undefined;
|
|
747
709
|
}, {
|
|
748
710
|
auto_learn?: boolean | undefined;
|
|
749
711
|
auto_capture?: boolean | undefined;
|
|
@@ -756,17 +718,127 @@ declare const PlurConfigSchema: z.ZodObject<{
|
|
|
756
718
|
spread_budget?: number | undefined;
|
|
757
719
|
co_access?: boolean | undefined;
|
|
758
720
|
} | undefined;
|
|
721
|
+
llm?: {
|
|
722
|
+
dedup_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
723
|
+
profile_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
724
|
+
meta_tier?: "fast" | "balanced" | "thorough" | undefined;
|
|
725
|
+
} | undefined;
|
|
726
|
+
dedup?: {
|
|
727
|
+
enabled?: boolean | undefined;
|
|
728
|
+
threshold?: number | undefined;
|
|
729
|
+
mode?: "llm" | "cosine" | "off" | undefined;
|
|
730
|
+
} | undefined;
|
|
731
|
+
decay_baseline?: string | undefined;
|
|
759
732
|
allow_secrets?: boolean | undefined;
|
|
760
733
|
index?: boolean | undefined;
|
|
734
|
+
storage?: {
|
|
735
|
+
path?: string | undefined;
|
|
736
|
+
backend?: "yaml" | "sqlite" | undefined;
|
|
737
|
+
} | undefined;
|
|
761
738
|
stores?: {
|
|
762
739
|
path: string;
|
|
763
740
|
scope: string;
|
|
764
741
|
shared?: boolean | undefined;
|
|
765
742
|
readonly?: boolean | undefined;
|
|
766
743
|
}[] | undefined;
|
|
744
|
+
profile?: {
|
|
745
|
+
enabled?: boolean | undefined;
|
|
746
|
+
cache_ttl_hours?: number | undefined;
|
|
747
|
+
} | undefined;
|
|
748
|
+
registry_url?: string | undefined;
|
|
767
749
|
}>;
|
|
768
750
|
type PlurConfig = z.infer<typeof PlurConfigSchema>;
|
|
769
751
|
|
|
752
|
+
declare const PackManifestSchema: z.ZodObject<{
|
|
753
|
+
name: z.ZodString;
|
|
754
|
+
version: z.ZodString;
|
|
755
|
+
description: z.ZodOptional<z.ZodString>;
|
|
756
|
+
creator: z.ZodOptional<z.ZodString>;
|
|
757
|
+
license: z.ZodDefault<z.ZodString>;
|
|
758
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
759
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
760
|
+
id: z.ZodOptional<z.ZodString>;
|
|
761
|
+
injection_policy: z.ZodDefault<z.ZodEnum<["on_match", "on_request", "always"]>>;
|
|
762
|
+
match_terms: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
763
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
764
|
+
engram_count: z.ZodOptional<z.ZodNumber>;
|
|
765
|
+
}, "strip", z.ZodTypeAny, {
|
|
766
|
+
injection_policy: "on_match" | "on_request" | "always";
|
|
767
|
+
match_terms: string[];
|
|
768
|
+
id?: string | undefined;
|
|
769
|
+
domain?: string | undefined;
|
|
770
|
+
engram_count?: number | undefined;
|
|
771
|
+
}, {
|
|
772
|
+
id?: string | undefined;
|
|
773
|
+
domain?: string | undefined;
|
|
774
|
+
injection_policy?: "on_match" | "on_request" | "always" | undefined;
|
|
775
|
+
match_terms?: string[] | undefined;
|
|
776
|
+
engram_count?: number | undefined;
|
|
777
|
+
}>>;
|
|
778
|
+
'x-datacore': z.ZodOptional<z.ZodObject<{
|
|
779
|
+
id: z.ZodString;
|
|
780
|
+
injection_policy: z.ZodEnum<["on_match", "on_request"]>;
|
|
781
|
+
match_terms: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
782
|
+
domain: z.ZodOptional<z.ZodString>;
|
|
783
|
+
engram_count: z.ZodNumber;
|
|
784
|
+
}, "strip", z.ZodTypeAny, {
|
|
785
|
+
id: string;
|
|
786
|
+
injection_policy: "on_match" | "on_request";
|
|
787
|
+
match_terms: string[];
|
|
788
|
+
engram_count: number;
|
|
789
|
+
domain?: string | undefined;
|
|
790
|
+
}, {
|
|
791
|
+
id: string;
|
|
792
|
+
injection_policy: "on_match" | "on_request";
|
|
793
|
+
engram_count: number;
|
|
794
|
+
domain?: string | undefined;
|
|
795
|
+
match_terms?: string[] | undefined;
|
|
796
|
+
}>>;
|
|
797
|
+
}, "strip", z.ZodTypeAny, {
|
|
798
|
+
version: string;
|
|
799
|
+
tags: string[];
|
|
800
|
+
license: string;
|
|
801
|
+
name: string;
|
|
802
|
+
description?: string | undefined;
|
|
803
|
+
creator?: string | undefined;
|
|
804
|
+
metadata?: {
|
|
805
|
+
injection_policy: "on_match" | "on_request" | "always";
|
|
806
|
+
match_terms: string[];
|
|
807
|
+
id?: string | undefined;
|
|
808
|
+
domain?: string | undefined;
|
|
809
|
+
engram_count?: number | undefined;
|
|
810
|
+
} | undefined;
|
|
811
|
+
'x-datacore'?: {
|
|
812
|
+
id: string;
|
|
813
|
+
injection_policy: "on_match" | "on_request";
|
|
814
|
+
match_terms: string[];
|
|
815
|
+
engram_count: number;
|
|
816
|
+
domain?: string | undefined;
|
|
817
|
+
} | undefined;
|
|
818
|
+
}, {
|
|
819
|
+
version: string;
|
|
820
|
+
name: string;
|
|
821
|
+
tags?: string[] | undefined;
|
|
822
|
+
license?: string | undefined;
|
|
823
|
+
description?: string | undefined;
|
|
824
|
+
creator?: string | undefined;
|
|
825
|
+
metadata?: {
|
|
826
|
+
id?: string | undefined;
|
|
827
|
+
domain?: string | undefined;
|
|
828
|
+
injection_policy?: "on_match" | "on_request" | "always" | undefined;
|
|
829
|
+
match_terms?: string[] | undefined;
|
|
830
|
+
engram_count?: number | undefined;
|
|
831
|
+
} | undefined;
|
|
832
|
+
'x-datacore'?: {
|
|
833
|
+
id: string;
|
|
834
|
+
injection_policy: "on_match" | "on_request";
|
|
835
|
+
engram_count: number;
|
|
836
|
+
domain?: string | undefined;
|
|
837
|
+
match_terms?: string[] | undefined;
|
|
838
|
+
} | undefined;
|
|
839
|
+
}>;
|
|
840
|
+
type PackManifest = z.infer<typeof PackManifestSchema>;
|
|
841
|
+
|
|
770
842
|
interface LearnContext {
|
|
771
843
|
type?: 'behavioral' | 'terminological' | 'procedural' | 'architectural';
|
|
772
844
|
scope?: string;
|
|
@@ -786,12 +858,53 @@ interface LearnContext {
|
|
|
786
858
|
};
|
|
787
859
|
abstract?: string | null;
|
|
788
860
|
derived_from?: string | null;
|
|
861
|
+
/** Commitment level. Defaults to 'leaning' for new engrams. */
|
|
862
|
+
commitment?: 'exploring' | 'leaning' | 'decided' | 'locked';
|
|
863
|
+
/** Reason for locking (required when commitment='locked'). */
|
|
864
|
+
locked_reason?: string;
|
|
865
|
+
/** Explicit memory_class override (SP2 Idea 3). Auto-set from type if not provided. */
|
|
866
|
+
memory_class?: 'semantic' | 'episodic' | 'procedural' | 'metacognitive';
|
|
867
|
+
/** Current session episode ID for episodic anchoring (SP2 Idea 24). */
|
|
868
|
+
session_episode_id?: string;
|
|
869
|
+
}
|
|
870
|
+
/** Extended context for async learn with LLM dedup. */
|
|
871
|
+
interface LearnAsyncContext extends LearnContext {
|
|
872
|
+
llm?: LlmFunction;
|
|
873
|
+
budget?: RecallBudget;
|
|
874
|
+
caller_session_id?: string;
|
|
875
|
+
}
|
|
876
|
+
type DedupDecision = 'ADD' | 'UPDATE' | 'MERGE' | 'NOOP';
|
|
877
|
+
interface DedupConfig {
|
|
878
|
+
enabled?: boolean;
|
|
879
|
+
threshold?: number;
|
|
880
|
+
mode?: 'llm' | 'cosine' | 'off';
|
|
881
|
+
}
|
|
882
|
+
interface LearnAsyncResult {
|
|
883
|
+
engram: Engram;
|
|
884
|
+
decision: DedupDecision;
|
|
885
|
+
existing_id?: string;
|
|
886
|
+
tensions?: string[];
|
|
887
|
+
}
|
|
888
|
+
interface LearnBatchResult {
|
|
889
|
+
results: LearnAsyncResult[];
|
|
890
|
+
stats: {
|
|
891
|
+
added: number;
|
|
892
|
+
updated: number;
|
|
893
|
+
merged: number;
|
|
894
|
+
noops: number;
|
|
895
|
+
};
|
|
789
896
|
}
|
|
790
897
|
/**
|
|
791
898
|
* Function that calls an LLM. Model-agnostic — consumer provides this.
|
|
792
899
|
* Takes a prompt, returns the LLM's text response.
|
|
793
900
|
*/
|
|
794
901
|
type LlmFunction = (prompt: string) => Promise<string>;
|
|
902
|
+
/** Budget constraints for bounded sub-agent expansion (Idea 16). */
|
|
903
|
+
interface RecallBudget {
|
|
904
|
+
max_tokens?: number;
|
|
905
|
+
max_results?: number;
|
|
906
|
+
ttl_seconds?: number;
|
|
907
|
+
}
|
|
795
908
|
interface RecallOptions {
|
|
796
909
|
scope?: string;
|
|
797
910
|
domain?: string;
|
|
@@ -801,6 +914,13 @@ interface RecallOptions {
|
|
|
801
914
|
mode?: 'fast' | 'agentic';
|
|
802
915
|
/** LLM function for agentic mode. Required when mode='agentic'. */
|
|
803
916
|
llm?: LlmFunction;
|
|
917
|
+
budget?: RecallBudget;
|
|
918
|
+
caller_session_id?: string;
|
|
919
|
+
}
|
|
920
|
+
interface BoundedRecallResult {
|
|
921
|
+
results: Engram[];
|
|
922
|
+
truncated: boolean;
|
|
923
|
+
strategy_used?: string;
|
|
804
924
|
}
|
|
805
925
|
interface InjectOptions {
|
|
806
926
|
budget?: number;
|
|
@@ -829,6 +949,110 @@ interface TimelineQuery {
|
|
|
829
949
|
search?: string;
|
|
830
950
|
}
|
|
831
951
|
|
|
952
|
+
type SearchStrategy = 'bm25' | 'hybrid' | 'expanded' | 'agentic';
|
|
953
|
+
interface AutoSearchResult {
|
|
954
|
+
results: Engram[];
|
|
955
|
+
strategy_used: SearchStrategy;
|
|
956
|
+
}
|
|
957
|
+
declare function recallAuto(engrams: Engram[], query: string, limit: number, storagePath?: string, llm?: LlmFunction): Promise<AutoSearchResult>;
|
|
958
|
+
|
|
959
|
+
interface RegistryEntry {
|
|
960
|
+
name: string;
|
|
961
|
+
installed_at: string;
|
|
962
|
+
source: string;
|
|
963
|
+
integrity: string;
|
|
964
|
+
version?: string;
|
|
965
|
+
creator?: string;
|
|
966
|
+
}
|
|
967
|
+
interface PreviewResult {
|
|
968
|
+
manifest: PackManifest;
|
|
969
|
+
engram_count: number;
|
|
970
|
+
engrams: Array<{
|
|
971
|
+
id: string;
|
|
972
|
+
type: string;
|
|
973
|
+
statement: string;
|
|
974
|
+
domain?: string;
|
|
975
|
+
tags: string[];
|
|
976
|
+
}>;
|
|
977
|
+
security: PrivacyScanResult;
|
|
978
|
+
warnings: string[];
|
|
979
|
+
}
|
|
980
|
+
declare function previewPack(source: string): PreviewResult;
|
|
981
|
+
interface InstallResult {
|
|
982
|
+
installed: number;
|
|
983
|
+
name: string;
|
|
984
|
+
conflicts: ConflictItem[];
|
|
985
|
+
security: PrivacyScanResult;
|
|
986
|
+
registry: RegistryEntry;
|
|
987
|
+
}
|
|
988
|
+
interface ConflictItem {
|
|
989
|
+
pack_engram_id: string;
|
|
990
|
+
pack_statement: string;
|
|
991
|
+
existing_engram_id: string;
|
|
992
|
+
existing_statement: string;
|
|
993
|
+
type: 'contradiction' | 'duplicate';
|
|
994
|
+
}
|
|
995
|
+
declare function installPack(packsDir: string, source: string, existingEngrams?: Engram[]): InstallResult;
|
|
996
|
+
interface UninstallResult {
|
|
997
|
+
name: string;
|
|
998
|
+
removed: boolean;
|
|
999
|
+
engram_count: number;
|
|
1000
|
+
}
|
|
1001
|
+
declare function uninstallPack(packsDir: string, name: string): UninstallResult;
|
|
1002
|
+
interface PackInfo {
|
|
1003
|
+
name: string;
|
|
1004
|
+
path: string;
|
|
1005
|
+
engram_count: number;
|
|
1006
|
+
manifest?: PackManifest;
|
|
1007
|
+
integrity?: string;
|
|
1008
|
+
installed_at?: string;
|
|
1009
|
+
source?: string;
|
|
1010
|
+
integrity_ok?: boolean;
|
|
1011
|
+
}
|
|
1012
|
+
declare function listPacks(packsDir: string): PackInfo[];
|
|
1013
|
+
interface ExportOptions {
|
|
1014
|
+
name: string;
|
|
1015
|
+
version: string;
|
|
1016
|
+
description?: string;
|
|
1017
|
+
creator?: string;
|
|
1018
|
+
domain?: string;
|
|
1019
|
+
scope?: string;
|
|
1020
|
+
tags?: string[];
|
|
1021
|
+
type?: string;
|
|
1022
|
+
}
|
|
1023
|
+
interface PrivacyScanResult {
|
|
1024
|
+
clean: boolean;
|
|
1025
|
+
issues: PrivacyIssue[];
|
|
1026
|
+
}
|
|
1027
|
+
interface PrivacyIssue {
|
|
1028
|
+
engram_id: string;
|
|
1029
|
+
type: 'secret' | 'private_visibility' | 'personal_path' | 'email' | 'ip_address';
|
|
1030
|
+
detail: string;
|
|
1031
|
+
}
|
|
1032
|
+
interface ExportResult {
|
|
1033
|
+
path: string;
|
|
1034
|
+
engram_count: number;
|
|
1035
|
+
privacy: PrivacyScanResult;
|
|
1036
|
+
match_terms: string[];
|
|
1037
|
+
integrity: string;
|
|
1038
|
+
}
|
|
1039
|
+
declare function exportPack(engrams: Engram[], outputDir: string, manifest: ExportOptions): ExportResult;
|
|
1040
|
+
|
|
1041
|
+
interface SyncStatus {
|
|
1042
|
+
initialized: boolean;
|
|
1043
|
+
remote: string | null;
|
|
1044
|
+
dirty: boolean;
|
|
1045
|
+
branch: string | null;
|
|
1046
|
+
ahead: number;
|
|
1047
|
+
behind: number;
|
|
1048
|
+
}
|
|
1049
|
+
interface SyncResult {
|
|
1050
|
+
action: 'initialized' | 'committed' | 'synced' | 'up-to-date';
|
|
1051
|
+
message: string;
|
|
1052
|
+
remote: string | null;
|
|
1053
|
+
files_changed: number;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
832
1056
|
interface TypedRole {
|
|
833
1057
|
role: string;
|
|
834
1058
|
domain_instance: string;
|
|
@@ -1286,6 +1510,143 @@ declare function generateGuardrails(): string;
|
|
|
1286
1510
|
/** Build searchable text from all engram fields */
|
|
1287
1511
|
declare function engramSearchText(engram: Engram): string;
|
|
1288
1512
|
|
|
1513
|
+
/**
|
|
1514
|
+
* Fresh tail boost (Idea 13)
|
|
1515
|
+
*
|
|
1516
|
+
* Engrams created in last 7 days get a retrieval_strength boost.
|
|
1517
|
+
* Day 0: +0.2, Day 7: +0.0 (linear decay)
|
|
1518
|
+
*
|
|
1519
|
+
* ONLY applies to commitment='exploring' or 'leaning' (F14).
|
|
1520
|
+
* Decided/locked engrams don't need the boost (already high priority).
|
|
1521
|
+
*
|
|
1522
|
+
* Applied at scoring time, NOT stored on the engram.
|
|
1523
|
+
*/
|
|
1524
|
+
declare function freshTailBoost(createdAt: string, commitment?: string, now?: Date): number;
|
|
1525
|
+
|
|
1526
|
+
declare function needsSummary(statement: string, cognitiveLevel?: string): boolean;
|
|
1527
|
+
declare function generateSummary(statement: string): string;
|
|
1528
|
+
declare function autoSummary(statement: string, cognitiveLevel?: string): string | undefined;
|
|
1529
|
+
|
|
1530
|
+
type ModelTier = 'fast' | 'balanced' | 'thorough';
|
|
1531
|
+
interface LlmTierConfig {
|
|
1532
|
+
dedup_tier?: ModelTier;
|
|
1533
|
+
profile_tier?: ModelTier;
|
|
1534
|
+
meta_tier?: ModelTier;
|
|
1535
|
+
}
|
|
1536
|
+
declare function selectModel(tier: ModelTier, customMap?: Partial<Record<ModelTier, string>>): string;
|
|
1537
|
+
declare function resolveOperationTier(operation: 'dedup' | 'profile' | 'meta', config?: LlmTierConfig): ModelTier;
|
|
1538
|
+
declare function selectModelForOperation(operation: 'dedup' | 'profile' | 'meta', config?: LlmTierConfig, customMap?: Partial<Record<ModelTier, string>>): string;
|
|
1539
|
+
|
|
1540
|
+
interface ProfileCache {
|
|
1541
|
+
profile: string;
|
|
1542
|
+
generated_at: string;
|
|
1543
|
+
engram_count: number;
|
|
1544
|
+
dirty: boolean;
|
|
1545
|
+
}
|
|
1546
|
+
declare function loadProfileCache(storagePath: string): ProfileCache | null;
|
|
1547
|
+
declare function saveProfileCache(storagePath: string, cache: ProfileCache): void;
|
|
1548
|
+
declare function markProfileDirty(storagePath: string): void;
|
|
1549
|
+
declare function profileNeedsRegeneration(cache: ProfileCache | null, cacheTtlHours?: number): boolean;
|
|
1550
|
+
declare function generateProfile(engrams: Engram[], llm: LlmFunction, storagePath: string, cacheTtlHours?: number): Promise<string | null>;
|
|
1551
|
+
declare function getProfileForInjection(storagePath: string): string | null;
|
|
1552
|
+
|
|
1553
|
+
type ScoredEngram = Engram & {
|
|
1554
|
+
keyword_match: number;
|
|
1555
|
+
raw_score: number;
|
|
1556
|
+
score: number;
|
|
1557
|
+
};
|
|
1558
|
+
type AgentEngram = Omit<ScoredEngram, 'associations'>;
|
|
1559
|
+
type WireEngram = Omit<AgentEngram, 'keyword_match' | 'raw_score' | 'score'> & {
|
|
1560
|
+
confidence_score: number;
|
|
1561
|
+
};
|
|
1562
|
+
/** Injection layer for progressive disclosure (Idea 10) */
|
|
1563
|
+
type InjectionLayer = 1 | 2 | 3;
|
|
1564
|
+
declare function formatLayer1(engram: WireEngram): string;
|
|
1565
|
+
declare function formatLayer2(engram: WireEngram): string;
|
|
1566
|
+
declare function formatLayer3(engram: WireEngram): string;
|
|
1567
|
+
declare function assignLayer(bucket: 'directives' | 'constraints' | 'consider'): InjectionLayer;
|
|
1568
|
+
declare function formatWithLayer(engrams: WireEngram[], layer: InjectionLayer): string;
|
|
1569
|
+
|
|
1570
|
+
/**
|
|
1571
|
+
* Normalize a statement for hash comparison:
|
|
1572
|
+
* - lowercase
|
|
1573
|
+
* - collapse whitespace
|
|
1574
|
+
* - strip punctuation
|
|
1575
|
+
*/
|
|
1576
|
+
declare function normalizeStatement(statement: string): string;
|
|
1577
|
+
/**
|
|
1578
|
+
* Compute SHA256 content hash of a normalized statement.
|
|
1579
|
+
* Used for fast exact-duplicate detection (Idea 29).
|
|
1580
|
+
*/
|
|
1581
|
+
declare function computeContentHash(statement: string): string;
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Build the LLM prompt for deduplication decision (Ideas 1 + 2 + 19).
|
|
1585
|
+
* Asks the LLM to compare new statement against existing candidates and decide:
|
|
1586
|
+
* ADD, UPDATE, MERGE, or NOOP — plus richness comparison and tension detection.
|
|
1587
|
+
*/
|
|
1588
|
+
declare function buildDedupPrompt(newStatement: string, candidates: Array<{
|
|
1589
|
+
id: string;
|
|
1590
|
+
statement: string;
|
|
1591
|
+
type: string;
|
|
1592
|
+
domain?: string;
|
|
1593
|
+
}>): string;
|
|
1594
|
+
/**
|
|
1595
|
+
* Build a batch dedup prompt for multiple candidates at once (learnBatch).
|
|
1596
|
+
*/
|
|
1597
|
+
declare function buildBatchDedupPrompt(statements: string[], existingEngrams: Array<{
|
|
1598
|
+
id: string;
|
|
1599
|
+
statement: string;
|
|
1600
|
+
type: string;
|
|
1601
|
+
domain?: string;
|
|
1602
|
+
}>): string;
|
|
1603
|
+
/**
|
|
1604
|
+
* Parse the LLM response from a dedup prompt.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function parseDedupResponse(response: string): {
|
|
1607
|
+
decision: DedupDecision;
|
|
1608
|
+
target_id: string | null;
|
|
1609
|
+
conflicts: string[];
|
|
1610
|
+
reason: string;
|
|
1611
|
+
};
|
|
1612
|
+
|
|
1613
|
+
interface Migration {
|
|
1614
|
+
id: string;
|
|
1615
|
+
description: string;
|
|
1616
|
+
up(engrams: Engram[]): Engram[];
|
|
1617
|
+
down(engrams: Engram[]): Engram[];
|
|
1618
|
+
}
|
|
1619
|
+
|
|
1620
|
+
/** All registered migrations, ordered by ID. */
|
|
1621
|
+
declare const ALL_MIGRATIONS: Migration[];
|
|
1622
|
+
/** Current schema version after all migrations have run. */
|
|
1623
|
+
declare const CURRENT_SCHEMA_VERSION: number;
|
|
1624
|
+
interface MigrationResult {
|
|
1625
|
+
applied: string[];
|
|
1626
|
+
schema_version: number;
|
|
1627
|
+
backup_path: string | null;
|
|
1628
|
+
}
|
|
1629
|
+
/** Read schema_version from config.yaml. Defaults to 0 if not present. */
|
|
1630
|
+
declare function getSchemaVersion(configPath: string): number;
|
|
1631
|
+
/** Write schema_version to config.yaml, preserving other fields. */
|
|
1632
|
+
declare function setSchemaVersion(configPath: string, version: number): void;
|
|
1633
|
+
/**
|
|
1634
|
+
* Run pending migrations on engrams.yaml.
|
|
1635
|
+
* - Checks schema_version in config
|
|
1636
|
+
* - Creates backup before running
|
|
1637
|
+
* - Applies each pending migration in order
|
|
1638
|
+
* - Rolls back to backup if any migration fails
|
|
1639
|
+
* - Updates schema_version after success
|
|
1640
|
+
*/
|
|
1641
|
+
declare function runMigrations(engramsPath: string, configPath: string, options?: {
|
|
1642
|
+
dryRun?: boolean;
|
|
1643
|
+
}): MigrationResult;
|
|
1644
|
+
/**
|
|
1645
|
+
* Roll back migrations to a target version.
|
|
1646
|
+
* Applies down() for each migration in reverse from current to target.
|
|
1647
|
+
*/
|
|
1648
|
+
declare function rollbackMigrations(engramsPath: string, configPath: string, targetVersion: number): MigrationResult;
|
|
1649
|
+
|
|
1289
1650
|
interface SecretMatch {
|
|
1290
1651
|
pattern: string;
|
|
1291
1652
|
match: string;
|
|
@@ -1332,6 +1693,98 @@ declare class IndexedStorage {
|
|
|
1332
1693
|
close(): void;
|
|
1333
1694
|
}
|
|
1334
1695
|
|
|
1696
|
+
/**
|
|
1697
|
+
* Abstract storage interface for engram persistence.
|
|
1698
|
+
* Search/retrieval stays in fts.ts, embeddings.ts, hybrid-search.ts.
|
|
1699
|
+
* The store is about persistence only.
|
|
1700
|
+
*/
|
|
1701
|
+
|
|
1702
|
+
interface EngramStore {
|
|
1703
|
+
/** Load all engrams from the store. */
|
|
1704
|
+
load(): Promise<Engram[]>;
|
|
1705
|
+
/** Replace all engrams in the store (full save). */
|
|
1706
|
+
save(engrams: Engram[]): Promise<void>;
|
|
1707
|
+
/** Append a single engram. For YAML, this does load+append+save. */
|
|
1708
|
+
append(engram: Engram): Promise<void>;
|
|
1709
|
+
/** Get a single engram by ID. Returns null if not found. */
|
|
1710
|
+
getById(id: string): Promise<Engram | null>;
|
|
1711
|
+
/** Remove an engram by ID. Returns true if found and removed. */
|
|
1712
|
+
remove(id: string): Promise<boolean>;
|
|
1713
|
+
/** Count engrams, optionally filtered by status. */
|
|
1714
|
+
count(filter?: {
|
|
1715
|
+
status?: string;
|
|
1716
|
+
}): Promise<number>;
|
|
1717
|
+
/** Close any open resources (e.g., database connections). */
|
|
1718
|
+
close(): Promise<void>;
|
|
1719
|
+
}
|
|
1720
|
+
/** Backend type identifier. */
|
|
1721
|
+
type StorageBackend = 'yaml' | 'sqlite';
|
|
1722
|
+
|
|
1723
|
+
declare class YamlStore implements EngramStore {
|
|
1724
|
+
private filePath;
|
|
1725
|
+
constructor(filePath: string);
|
|
1726
|
+
load(): Promise<Engram[]>;
|
|
1727
|
+
save(engrams: Engram[]): Promise<void>;
|
|
1728
|
+
append(engram: Engram): Promise<void>;
|
|
1729
|
+
getById(id: string): Promise<Engram | null>;
|
|
1730
|
+
remove(id: string): Promise<boolean>;
|
|
1731
|
+
count(filter?: {
|
|
1732
|
+
status?: string;
|
|
1733
|
+
}): Promise<number>;
|
|
1734
|
+
close(): Promise<void>;
|
|
1735
|
+
/** Raw load without validation — for internal mutate-and-save operations. */
|
|
1736
|
+
private _loadRaw;
|
|
1737
|
+
}
|
|
1738
|
+
|
|
1739
|
+
declare class SqliteStore implements EngramStore {
|
|
1740
|
+
private dbPath;
|
|
1741
|
+
private db;
|
|
1742
|
+
constructor(dbPath: string);
|
|
1743
|
+
private getDb;
|
|
1744
|
+
load(): Promise<Engram[]>;
|
|
1745
|
+
save(engrams: Engram[]): Promise<void>;
|
|
1746
|
+
append(engram: Engram): Promise<void>;
|
|
1747
|
+
getById(id: string): Promise<Engram | null>;
|
|
1748
|
+
remove(id: string): Promise<boolean>;
|
|
1749
|
+
count(filter?: {
|
|
1750
|
+
status?: string;
|
|
1751
|
+
}): Promise<number>;
|
|
1752
|
+
close(): Promise<void>;
|
|
1753
|
+
/** Import engrams from an array (e.g., from YAML migration). */
|
|
1754
|
+
importFrom(engrams: Engram[]): Promise<void>;
|
|
1755
|
+
/** Export all engrams as an array (e.g., for YAML migration). */
|
|
1756
|
+
exportAll(): Promise<Engram[]>;
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1759
|
+
interface StorageConfig {
|
|
1760
|
+
backend: StorageBackend;
|
|
1761
|
+
path: string;
|
|
1762
|
+
}
|
|
1763
|
+
/**
|
|
1764
|
+
* Create an EngramStore based on the storage configuration.
|
|
1765
|
+
* Default: YamlStore at {path}/engrams.yaml
|
|
1766
|
+
*/
|
|
1767
|
+
declare function createStore(config: StorageConfig): EngramStore;
|
|
1768
|
+
/**
|
|
1769
|
+
* Migrate data from one backend to another.
|
|
1770
|
+
* Loads all engrams from source, saves to target.
|
|
1771
|
+
*/
|
|
1772
|
+
declare function migrateStore(from: EngramStore, to: EngramStore): Promise<number>;
|
|
1773
|
+
|
|
1774
|
+
interface AsyncLockOptions {
|
|
1775
|
+
maxRetries?: number;
|
|
1776
|
+
baseDelay?: number;
|
|
1777
|
+
staleThreshold?: number;
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Async file-based exclusive lock using O_EXCL.
|
|
1781
|
+
* Retries with exponential backoff (async sleep, not busy-wait).
|
|
1782
|
+
*/
|
|
1783
|
+
declare function withAsyncLock<T>(filePath: string, fn: () => Promise<T>, options?: AsyncLockOptions): Promise<T>;
|
|
1784
|
+
|
|
1785
|
+
/** Atomic write: write to temp file then rename (prevents corruption on crash). */
|
|
1786
|
+
declare function asyncAtomicWrite(filePath: string, content: string): Promise<void>;
|
|
1787
|
+
|
|
1335
1788
|
/**
|
|
1336
1789
|
* Non-blocking version check against npm registry.
|
|
1337
1790
|
* Caches result in memory — one fetch per process lifetime.
|
|
@@ -1373,12 +1826,19 @@ interface StatusResult {
|
|
|
1373
1826
|
pack_count: number;
|
|
1374
1827
|
storage_root: string;
|
|
1375
1828
|
config: PlurConfig;
|
|
1829
|
+
locked_count?: number;
|
|
1830
|
+
tension_count?: number;
|
|
1831
|
+
versioned_engram_count?: number;
|
|
1376
1832
|
}
|
|
1833
|
+
/** Commitment level scoring multipliers for injection priority (Idea 6). */
|
|
1834
|
+
declare const COMMITMENT_MULTIPLIER: Record<string, number>;
|
|
1377
1835
|
declare class Plur {
|
|
1378
1836
|
private paths;
|
|
1379
1837
|
private config;
|
|
1380
1838
|
private indexedStorage;
|
|
1381
1839
|
private _engramCache;
|
|
1840
|
+
private _llmFailureCount;
|
|
1841
|
+
private _llmDisabledUntil;
|
|
1382
1842
|
constructor(options?: {
|
|
1383
1843
|
path?: string;
|
|
1384
1844
|
});
|
|
@@ -1392,8 +1852,24 @@ declare class Plur {
|
|
|
1392
1852
|
private _loadCached;
|
|
1393
1853
|
/** Find which store owns an engram by ID. For namespaced IDs, strips prefix to find in store. */
|
|
1394
1854
|
private _findEngramStore;
|
|
1395
|
-
/**
|
|
1855
|
+
/** Content hash fast-path dedup. */
|
|
1856
|
+
private _hashDedup;
|
|
1857
|
+
private _isLlmDedupAvailable;
|
|
1858
|
+
private _recordLlmFailure;
|
|
1859
|
+
private _recordLlmSuccess;
|
|
1860
|
+
/** Create engram with content hash + commitment + cognitive level.
|
|
1861
|
+
* Fast-path hash dedup returns existing on exact match.
|
|
1862
|
+
*/
|
|
1396
1863
|
learn(statement: string, context?: LearnContext): Engram;
|
|
1864
|
+
/** Build deps for learn-async module. */
|
|
1865
|
+
private _learnAsyncDeps;
|
|
1866
|
+
/** Async learn with LLM-driven deduplication (Ideas 1+2+19). */
|
|
1867
|
+
learnAsync(statement: string, context?: LearnAsyncContext): Promise<LearnAsyncResult>;
|
|
1868
|
+
/** Batch learn with LLM dedup. */
|
|
1869
|
+
learnBatch(statements: Array<{
|
|
1870
|
+
statement: string;
|
|
1871
|
+
context?: LearnAsyncContext;
|
|
1872
|
+
}>, llm?: LlmFunction): Promise<LearnBatchResult>;
|
|
1397
1873
|
/**
|
|
1398
1874
|
* Search engrams, filter by scope/domain/strength, reactivate accessed.
|
|
1399
1875
|
* Supports two modes:
|
|
@@ -1414,6 +1890,7 @@ declare class Plur {
|
|
|
1414
1890
|
recallExpanded(query: string, options: RecallOptions & {
|
|
1415
1891
|
llm: LlmFunction;
|
|
1416
1892
|
}): Promise<Engram[]>;
|
|
1893
|
+
recallAutoSearch(query: string, options?: RecallOptions): Promise<AutoSearchResult>;
|
|
1417
1894
|
/** Get a single engram by ID, regardless of status. Searches primary + all stores. */
|
|
1418
1895
|
getById(id: string): Engram | null;
|
|
1419
1896
|
/** List all active engrams, optionally filtered by scope/domain. No search — returns all matches. */
|
|
@@ -1474,10 +1951,33 @@ declare class Plur {
|
|
|
1474
1951
|
}): ReturnType<typeof exportPack>;
|
|
1475
1952
|
/** List all installed packs (with integrity hashes). */
|
|
1476
1953
|
listPacks(): ReturnType<typeof listPacks>;
|
|
1954
|
+
/** Get the PLUR storage root path. */
|
|
1955
|
+
getStorageRoot(): string;
|
|
1477
1956
|
/** Sync engrams to git. Initializes repo on first call, commits + push/pull on subsequent calls. */
|
|
1478
1957
|
sync(remote?: string): SyncResult;
|
|
1479
1958
|
/** Get git sync status without making changes. */
|
|
1480
1959
|
syncStatus(): SyncStatus;
|
|
1960
|
+
/**
|
|
1961
|
+
* Promote an episode to an episodic engram (SP2 Idea 3).
|
|
1962
|
+
* Creates a new engram with memory_class='episodic' from an episode's summary.
|
|
1963
|
+
*/
|
|
1964
|
+
episodeToEngram(episodeId: string, context?: Omit<LearnContext, 'memory_class'>): Engram;
|
|
1965
|
+
/**
|
|
1966
|
+
* Get history events for a specific engram (SP2 Idea 7).
|
|
1967
|
+
* Returns all events across all months for the given engram ID.
|
|
1968
|
+
*/
|
|
1969
|
+
getEngramHistory(engramId: string): HistoryEvent[];
|
|
1970
|
+
/**
|
|
1971
|
+
* Report a failure for a procedural engram (SP2 Idea 18).
|
|
1972
|
+
* If LLM is provided, generates an improved procedure and updates the engram.
|
|
1973
|
+
* Without LLM, logs the failure without rewriting.
|
|
1974
|
+
* Returns the updated engram and the failure episode.
|
|
1975
|
+
*/
|
|
1976
|
+
reportFailure(engramId: string, failureContext: string, llm?: LlmFunction): Promise<{
|
|
1977
|
+
engram: Engram;
|
|
1978
|
+
episode: Episode;
|
|
1979
|
+
evolved: boolean;
|
|
1980
|
+
}>;
|
|
1481
1981
|
/** Return system health info. */
|
|
1482
1982
|
status(): StatusResult;
|
|
1483
1983
|
/** Register an additional engram store. */
|
|
@@ -1495,4 +1995,4 @@ declare class Plur {
|
|
|
1495
1995
|
}>;
|
|
1496
1996
|
}
|
|
1497
1997
|
|
|
1498
|
-
export { type AlignmentResult, type Association, type CaptureContext, type DomainCoverage, DomainCoverageSchema, type Engram, type EngramCluster, type Episode, type EvidenceEntry, EvidenceEntrySchema, type ExtractOptions, type ExtractionResult, type Falsification, FalsificationSchema, type HierarchyPosition, HierarchyPositionSchema, IndexedStorage, type IngestCandidate, type IngestOptions, type InjectOptions, type InjectionResult, type KnowledgeAnchor, type LearnContext, type LlmFunction, type MemberAlignment, type MetaConfidence, MetaConfidenceSchema, type MetaField, MetaFieldSchema, PLATITUDE_PATTERNS, type PackManifest, Plur, type PlurConfig, type PlurPaths, type PreviewResult, type PrivacyIssue, type PrivacyScanResult, type RecallOptions, type RegistryEntry, type RelationalAnalysis, type RelationalTriple, SessionBreadcrumbs, type StatusResult, type StoreEntry, type StructuralTemplate, StructuralTemplateSchema, type SyncResult, type SyncStatus, type TimelineQuery, type TypedRole, type ValidationResult, type VersionCheckResult, alignCluster, analyzeStructure, checkForUpdate, classifyPolarity, clearVersionCache, clusterByStructure, computeConfidence, computeMetaConfidence, confidenceBand, detectPlurStorage, detectSecrets, engramSearchText, extractMetaEngrams, formulateMetaEngram, generateGuardrails, getCachedUpdateCheck, isPlatitude, organizeHierarchy, tokenSimilarity, validateMetaEngram };
|
|
1998
|
+
export { ALL_MIGRATIONS, type AlignmentResult, type Association, type AutoSearchResult, type BoundedRecallResult, COMMITMENT_MULTIPLIER, CURRENT_SCHEMA_VERSION, type CaptureContext, 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, 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, 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, tokenSimilarity, validateMetaEngram, withAsyncLock };
|