@graphorin/memory 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/LICENSE +21 -0
- package/README.md +401 -0
- package/dist/conflict/index.d.ts +3 -0
- package/dist/conflict/index.js +7 -0
- package/dist/conflict/locale-packs/en.js +262 -0
- package/dist/conflict/locale-packs/en.js.map +1 -0
- package/dist/conflict/locale-packs/index.js +4 -0
- package/dist/conflict/locale-packs/types.d.ts +103 -0
- package/dist/conflict/locale-packs/types.d.ts.map +1 -0
- package/dist/conflict/locale-packs/types.js +55 -0
- package/dist/conflict/locale-packs/types.js.map +1 -0
- package/dist/conflict/pipeline.d.ts +35 -0
- package/dist/conflict/pipeline.d.ts.map +1 -0
- package/dist/conflict/pipeline.js +257 -0
- package/dist/conflict/pipeline.js.map +1 -0
- package/dist/conflict/stages/helpers.js +66 -0
- package/dist/conflict/stages/helpers.js.map +1 -0
- package/dist/conflict/stages/stage1-exact-dedup.js +21 -0
- package/dist/conflict/stages/stage1-exact-dedup.js.map +1 -0
- package/dist/conflict/stages/stage2-embedding-three-zone.js +37 -0
- package/dist/conflict/stages/stage2-embedding-three-zone.js.map +1 -0
- package/dist/conflict/stages/stage3-heuristic-regex.js +45 -0
- package/dist/conflict/stages/stage3-heuristic-regex.js.map +1 -0
- package/dist/conflict/stages/stage4-subject-predicate.js +31 -0
- package/dist/conflict/stages/stage4-subject-predicate.js.map +1 -0
- package/dist/conflict/stages/stage5-defer-to-deep.js +22 -0
- package/dist/conflict/stages/stage5-defer-to-deep.js.map +1 -0
- package/dist/conflict/types.d.ts +222 -0
- package/dist/conflict/types.d.ts.map +1 -0
- package/dist/conflict/types.js +50 -0
- package/dist/conflict/types.js.map +1 -0
- package/dist/consolidator/budget.d.ts +1 -0
- package/dist/consolidator/budget.js +214 -0
- package/dist/consolidator/budget.js.map +1 -0
- package/dist/consolidator/decay.d.ts +35 -0
- package/dist/consolidator/decay.d.ts.map +1 -0
- package/dist/consolidator/decay.js +91 -0
- package/dist/consolidator/decay.js.map +1 -0
- package/dist/consolidator/dlq.js +58 -0
- package/dist/consolidator/dlq.js.map +1 -0
- package/dist/consolidator/errors.d.ts +54 -0
- package/dist/consolidator/errors.d.ts.map +1 -0
- package/dist/consolidator/errors.js +67 -0
- package/dist/consolidator/errors.js.map +1 -0
- package/dist/consolidator/idempotency.d.ts +1 -0
- package/dist/consolidator/idempotency.js +22 -0
- package/dist/consolidator/idempotency.js.map +1 -0
- package/dist/consolidator/index.d.ts +34 -0
- package/dist/consolidator/index.d.ts.map +1 -0
- package/dist/consolidator/index.js +163 -0
- package/dist/consolidator/index.js.map +1 -0
- package/dist/consolidator/lock.d.ts +2 -0
- package/dist/consolidator/lock.js +89 -0
- package/dist/consolidator/lock.js.map +1 -0
- package/dist/consolidator/noise-filter.d.ts +2 -0
- package/dist/consolidator/noise-filter.js +173 -0
- package/dist/consolidator/noise-filter.js.map +1 -0
- package/dist/consolidator/phases/deep.d.ts +4 -0
- package/dist/consolidator/phases/deep.js +198 -0
- package/dist/consolidator/phases/deep.js.map +1 -0
- package/dist/consolidator/phases/induce.d.ts +154 -0
- package/dist/consolidator/phases/induce.d.ts.map +1 -0
- package/dist/consolidator/phases/induce.js +253 -0
- package/dist/consolidator/phases/induce.js.map +1 -0
- package/dist/consolidator/phases/light.d.ts +4 -0
- package/dist/consolidator/phases/light.js +99 -0
- package/dist/consolidator/phases/light.js.map +1 -0
- package/dist/consolidator/phases/reflect.js +287 -0
- package/dist/consolidator/phases/reflect.js.map +1 -0
- package/dist/consolidator/phases/standard.d.ts +8 -0
- package/dist/consolidator/phases/standard.js +499 -0
- package/dist/consolidator/phases/standard.js.map +1 -0
- package/dist/consolidator/reconcile.js +192 -0
- package/dist/consolidator/reconcile.js.map +1 -0
- package/dist/consolidator/runtime.d.ts +62 -0
- package/dist/consolidator/runtime.d.ts.map +1 -0
- package/dist/consolidator/runtime.js +580 -0
- package/dist/consolidator/runtime.js.map +1 -0
- package/dist/consolidator/scheduler.d.ts +111 -0
- package/dist/consolidator/scheduler.d.ts.map +1 -0
- package/dist/consolidator/scheduler.js +71 -0
- package/dist/consolidator/scheduler.js.map +1 -0
- package/dist/consolidator/triggers.d.ts +40 -0
- package/dist/consolidator/triggers.d.ts.map +1 -0
- package/dist/consolidator/triggers.js +94 -0
- package/dist/consolidator/triggers.js.map +1 -0
- package/dist/consolidator/types.d.ts +397 -0
- package/dist/consolidator/types.d.ts.map +1 -0
- package/dist/consolidator/types.js +117 -0
- package/dist/consolidator/types.js.map +1 -0
- package/dist/context-engine/annotations.d.ts +118 -0
- package/dist/context-engine/annotations.d.ts.map +1 -0
- package/dist/context-engine/annotations.js +102 -0
- package/dist/context-engine/annotations.js.map +1 -0
- package/dist/context-engine/auto-recall.d.ts +52 -0
- package/dist/context-engine/auto-recall.d.ts.map +1 -0
- package/dist/context-engine/auto-recall.js +41 -0
- package/dist/context-engine/auto-recall.js.map +1 -0
- package/dist/context-engine/compaction/clear-tool-results.d.ts +55 -0
- package/dist/context-engine/compaction/clear-tool-results.d.ts.map +1 -0
- package/dist/context-engine/compaction/clear-tool-results.js +97 -0
- package/dist/context-engine/compaction/clear-tool-results.js.map +1 -0
- package/dist/context-engine/compaction/compactor.d.ts +52 -0
- package/dist/context-engine/compaction/compactor.d.ts.map +1 -0
- package/dist/context-engine/compaction/compactor.js +196 -0
- package/dist/context-engine/compaction/compactor.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts +15 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.js +27 -0
- package/dist/context-engine/compaction/hooks/reanchor-persona-block.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts +18 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js +47 -0
- package/dist/context-engine/compaction/hooks/reanchor-pinned-facts.js.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts +15 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.d.ts.map +1 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.js +32 -0
- package/dist/context-engine/compaction/hooks/reanchor-project-rules.js.map +1 -0
- package/dist/context-engine/compaction/hooks/types.d.ts +42 -0
- package/dist/context-engine/compaction/hooks/types.d.ts.map +1 -0
- package/dist/context-engine/compaction/index.d.ts +9 -0
- package/dist/context-engine/compaction/index.js +9 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts +84 -0
- package/dist/context-engine/compaction/templates/summary-9-section.d.ts.map +1 -0
- package/dist/context-engine/compaction/templates/summary-9-section.js +84 -0
- package/dist/context-engine/compaction/templates/summary-9-section.js.map +1 -0
- package/dist/context-engine/compaction/thresholds.d.ts +68 -0
- package/dist/context-engine/compaction/thresholds.d.ts.map +1 -0
- package/dist/context-engine/compaction/thresholds.js +63 -0
- package/dist/context-engine/compaction/thresholds.js.map +1 -0
- package/dist/context-engine/compaction/types.d.ts +202 -0
- package/dist/context-engine/compaction/types.d.ts.map +1 -0
- package/dist/context-engine/engine.d.ts +258 -0
- package/dist/context-engine/engine.d.ts.map +1 -0
- package/dist/context-engine/engine.js +424 -0
- package/dist/context-engine/engine.js.map +1 -0
- package/dist/context-engine/index.d.ts +68 -0
- package/dist/context-engine/index.d.ts.map +1 -0
- package/dist/context-engine/index.js +24 -0
- package/dist/context-engine/locale-packs/en.d.ts +14 -0
- package/dist/context-engine/locale-packs/en.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/en.js +87 -0
- package/dist/context-engine/locale-packs/en.js.map +1 -0
- package/dist/context-engine/locale-packs/index.js +4 -0
- package/dist/context-engine/locale-packs/resolver.d.ts +41 -0
- package/dist/context-engine/locale-packs/resolver.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/resolver.js +119 -0
- package/dist/context-engine/locale-packs/resolver.js.map +1 -0
- package/dist/context-engine/locale-packs/types.d.ts +119 -0
- package/dist/context-engine/locale-packs/types.d.ts.map +1 -0
- package/dist/context-engine/locale-packs/types.js +24 -0
- package/dist/context-engine/locale-packs/types.js.map +1 -0
- package/dist/context-engine/metadata.d.ts +40 -0
- package/dist/context-engine/metadata.d.ts.map +1 -0
- package/dist/context-engine/metadata.js +66 -0
- package/dist/context-engine/metadata.js.map +1 -0
- package/dist/context-engine/preambles/inbound-en.d.ts +20 -0
- package/dist/context-engine/preambles/inbound-en.d.ts.map +1 -0
- package/dist/context-engine/preambles/inbound-en.js +23 -0
- package/dist/context-engine/preambles/inbound-en.js.map +1 -0
- package/dist/context-engine/privacy-filter.d.ts +108 -0
- package/dist/context-engine/privacy-filter.d.ts.map +1 -0
- package/dist/context-engine/privacy-filter.js +113 -0
- package/dist/context-engine/privacy-filter.js.map +1 -0
- package/dist/context-engine/templates/base-en.d.ts +19 -0
- package/dist/context-engine/templates/base-en.d.ts.map +1 -0
- package/dist/context-engine/templates/base-en.js +22 -0
- package/dist/context-engine/templates/base-en.js.map +1 -0
- package/dist/context-engine/templates/composer.d.ts +55 -0
- package/dist/context-engine/templates/composer.d.ts.map +1 -0
- package/dist/context-engine/templates/composer.js +51 -0
- package/dist/context-engine/templates/composer.js.map +1 -0
- package/dist/context-engine/token-budget.d.ts +99 -0
- package/dist/context-engine/token-budget.d.ts.map +1 -0
- package/dist/context-engine/token-budget.js +211 -0
- package/dist/context-engine/token-budget.js.map +1 -0
- package/dist/context-engine/token-counter.d.ts +54 -0
- package/dist/context-engine/token-counter.d.ts.map +1 -0
- package/dist/context-engine/token-counter.js +81 -0
- package/dist/context-engine/token-counter.js.map +1 -0
- package/dist/errors/index.d.ts +171 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +206 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/facade.d.ts +278 -0
- package/dist/facade.d.ts.map +1 -0
- package/dist/facade.js +265 -0
- package/dist/facade.js.map +1 -0
- package/dist/graph/entity-resolver.d.ts +135 -0
- package/dist/graph/entity-resolver.d.ts.map +1 -0
- package/dist/graph/entity-resolver.js +202 -0
- package/dist/graph/entity-resolver.js.map +1 -0
- package/dist/graph/index.d.ts +1 -0
- package/dist/index.d.ts +103 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/contextualize.d.ts +14 -0
- package/dist/internal/contextualize.d.ts.map +1 -0
- package/dist/internal/contextualize.js +110 -0
- package/dist/internal/contextualize.js.map +1 -0
- package/dist/internal/embedder-binding.js +50 -0
- package/dist/internal/embedder-binding.js.map +1 -0
- package/dist/internal/id.js +24 -0
- package/dist/internal/id.js.map +1 -0
- package/dist/internal/injection-heuristics.js +64 -0
- package/dist/internal/injection-heuristics.js.map +1 -0
- package/dist/internal/spans.js +35 -0
- package/dist/internal/spans.js.map +1 -0
- package/dist/internal/storage-adapter.d.ts +742 -0
- package/dist/internal/storage-adapter.d.ts.map +1 -0
- package/dist/migration/embedder-migration.d.ts +124 -0
- package/dist/migration/embedder-migration.d.ts.map +1 -0
- package/dist/migration/embedder-migration.js +109 -0
- package/dist/migration/embedder-migration.js.map +1 -0
- package/dist/migration/index.d.ts +2 -0
- package/dist/migration/index.js +3 -0
- package/dist/search/explain.d.ts +74 -0
- package/dist/search/explain.d.ts.map +1 -0
- package/dist/search/explain.js +50 -0
- package/dist/search/explain.js.map +1 -0
- package/dist/search/index.d.ts +6 -0
- package/dist/search/index.js +6 -0
- package/dist/search/iterative.d.ts +223 -0
- package/dist/search/iterative.d.ts.map +1 -0
- package/dist/search/iterative.js +330 -0
- package/dist/search/iterative.js.map +1 -0
- package/dist/search/query-transform.d.ts +112 -0
- package/dist/search/query-transform.d.ts.map +1 -0
- package/dist/search/query-transform.js +184 -0
- package/dist/search/query-transform.js.map +1 -0
- package/dist/search/rrf.d.ts +95 -0
- package/dist/search/rrf.d.ts.map +1 -0
- package/dist/search/rrf.js +166 -0
- package/dist/search/rrf.js.map +1 -0
- package/dist/search/types.d.ts +50 -0
- package/dist/search/types.d.ts.map +1 -0
- package/dist/tiers/episodic-memory.d.ts +142 -0
- package/dist/tiers/episodic-memory.d.ts.map +1 -0
- package/dist/tiers/episodic-memory.js +254 -0
- package/dist/tiers/episodic-memory.js.map +1 -0
- package/dist/tiers/index.d.ts +8 -0
- package/dist/tiers/index.js +9 -0
- package/dist/tiers/insight-memory.d.ts +71 -0
- package/dist/tiers/insight-memory.d.ts.map +1 -0
- package/dist/tiers/insight-memory.js +133 -0
- package/dist/tiers/insight-memory.js.map +1 -0
- package/dist/tiers/procedural-memory.d.ts +147 -0
- package/dist/tiers/procedural-memory.d.ts.map +1 -0
- package/dist/tiers/procedural-memory.js +267 -0
- package/dist/tiers/procedural-memory.js.map +1 -0
- package/dist/tiers/semantic-memory.d.ts +461 -0
- package/dist/tiers/semantic-memory.d.ts.map +1 -0
- package/dist/tiers/semantic-memory.js +631 -0
- package/dist/tiers/semantic-memory.js.map +1 -0
- package/dist/tiers/session-memory.d.ts +117 -0
- package/dist/tiers/session-memory.d.ts.map +1 -0
- package/dist/tiers/session-memory.js +163 -0
- package/dist/tiers/session-memory.js.map +1 -0
- package/dist/tiers/shared-memory.d.ts +29 -0
- package/dist/tiers/shared-memory.d.ts.map +1 -0
- package/dist/tiers/shared-memory.js +58 -0
- package/dist/tiers/shared-memory.js.map +1 -0
- package/dist/tiers/working-memory.d.ts +129 -0
- package/dist/tiers/working-memory.d.ts.map +1 -0
- package/dist/tiers/working-memory.js +229 -0
- package/dist/tiers/working-memory.js.map +1 -0
- package/dist/tools/block-tools.d.ts +98 -0
- package/dist/tools/block-tools.d.ts.map +1 -0
- package/dist/tools/block-tools.js +114 -0
- package/dist/tools/block-tools.js.map +1 -0
- package/dist/tools/fact-tools.d.ts +294 -0
- package/dist/tools/fact-tools.d.ts.map +1 -0
- package/dist/tools/fact-tools.js +293 -0
- package/dist/tools/fact-tools.js.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +36 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/recall-tools.d.ts +209 -0
- package/dist/tools/recall-tools.d.ts.map +1 -0
- package/dist/tools/recall-tools.js +170 -0
- package/dist/tools/recall-tools.js.map +1 -0
- package/dist/tools/types.d.ts +40 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/package.json +119 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { MemoryToolDeps } from "./types.js";
|
|
2
|
+
import { Tool } from "@graphorin/core";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
//#region src/tools/fact-tools.d.ts
|
|
6
|
+
declare const factRememberInputSchema: z.ZodObject<{
|
|
7
|
+
text: z.ZodString;
|
|
8
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
9
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
sensitivity: z.ZodOptional<z.ZodEnum<["public", "internal", "secret"]>>;
|
|
11
|
+
validFrom: z.ZodOptional<z.ZodString>;
|
|
12
|
+
validTo: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
text: string;
|
|
15
|
+
sensitivity?: "public" | "internal" | "secret" | undefined;
|
|
16
|
+
tags?: string[] | undefined;
|
|
17
|
+
confidence?: number | undefined;
|
|
18
|
+
validFrom?: string | undefined;
|
|
19
|
+
validTo?: string | undefined;
|
|
20
|
+
}, {
|
|
21
|
+
text: string;
|
|
22
|
+
sensitivity?: "public" | "internal" | "secret" | undefined;
|
|
23
|
+
tags?: string[] | undefined;
|
|
24
|
+
confidence?: number | undefined;
|
|
25
|
+
validFrom?: string | undefined;
|
|
26
|
+
validTo?: string | undefined;
|
|
27
|
+
}>;
|
|
28
|
+
declare const factRememberOutputSchema: z.ZodObject<{
|
|
29
|
+
factId: z.ZodString;
|
|
30
|
+
/**
|
|
31
|
+
* MRET-3: `true` when the write landed in quarantine (hidden from
|
|
32
|
+
* default recall until validated). A synthesized consolidator write or
|
|
33
|
+
* a candidate that tripped the injection heuristics quarantines.
|
|
34
|
+
*/
|
|
35
|
+
quarantined: z.ZodBoolean;
|
|
36
|
+
/** Why it was quarantined, when it was. */
|
|
37
|
+
quarantineReason: z.ZodOptional<z.ZodEnum<["injection", "synthesized"]>>;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
factId: string;
|
|
40
|
+
quarantined: boolean;
|
|
41
|
+
quarantineReason?: "injection" | "synthesized" | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
factId: string;
|
|
44
|
+
quarantined: boolean;
|
|
45
|
+
quarantineReason?: "injection" | "synthesized" | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
type FactRememberInput = z.infer<typeof factRememberInputSchema>;
|
|
48
|
+
type FactRememberOutput = z.infer<typeof factRememberOutputSchema>;
|
|
49
|
+
declare const factSearchInputSchema: z.ZodObject<{
|
|
50
|
+
query: z.ZodString;
|
|
51
|
+
topK: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
53
|
+
asOf: z.ZodOptional<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
query: string;
|
|
56
|
+
topK?: number | undefined;
|
|
57
|
+
asOf?: string | undefined;
|
|
58
|
+
tags?: string[] | undefined;
|
|
59
|
+
}, {
|
|
60
|
+
query: string;
|
|
61
|
+
topK?: number | undefined;
|
|
62
|
+
asOf?: string | undefined;
|
|
63
|
+
tags?: string[] | undefined;
|
|
64
|
+
}>;
|
|
65
|
+
declare const factSearchOutputSchema: z.ZodObject<{
|
|
66
|
+
hits: z.ZodArray<z.ZodObject<{
|
|
67
|
+
factId: z.ZodString;
|
|
68
|
+
text: z.ZodString;
|
|
69
|
+
score: z.ZodNumber;
|
|
70
|
+
sensitivity: z.ZodEnum<["public", "internal", "secret"]>;
|
|
71
|
+
provenance: z.ZodOptional<z.ZodEnum<["user", "tool", "extraction", "reflection", "induction", "imported"]>>;
|
|
72
|
+
}, "strip", z.ZodTypeAny, {
|
|
73
|
+
score: number;
|
|
74
|
+
factId: string;
|
|
75
|
+
text: string;
|
|
76
|
+
sensitivity: "public" | "internal" | "secret";
|
|
77
|
+
provenance?: "user" | "tool" | "extraction" | "reflection" | "induction" | "imported" | undefined;
|
|
78
|
+
}, {
|
|
79
|
+
score: number;
|
|
80
|
+
factId: string;
|
|
81
|
+
text: string;
|
|
82
|
+
sensitivity: "public" | "internal" | "secret";
|
|
83
|
+
provenance?: "user" | "tool" | "extraction" | "reflection" | "induction" | "imported" | undefined;
|
|
84
|
+
}>, "many">;
|
|
85
|
+
}, "strip", z.ZodTypeAny, {
|
|
86
|
+
hits: {
|
|
87
|
+
score: number;
|
|
88
|
+
factId: string;
|
|
89
|
+
text: string;
|
|
90
|
+
sensitivity: "public" | "internal" | "secret";
|
|
91
|
+
provenance?: "user" | "tool" | "extraction" | "reflection" | "induction" | "imported" | undefined;
|
|
92
|
+
}[];
|
|
93
|
+
}, {
|
|
94
|
+
hits: {
|
|
95
|
+
score: number;
|
|
96
|
+
factId: string;
|
|
97
|
+
text: string;
|
|
98
|
+
sensitivity: "public" | "internal" | "secret";
|
|
99
|
+
provenance?: "user" | "tool" | "extraction" | "reflection" | "induction" | "imported" | undefined;
|
|
100
|
+
}[];
|
|
101
|
+
}>;
|
|
102
|
+
type FactSearchInput = z.infer<typeof factSearchInputSchema>;
|
|
103
|
+
type FactSearchOutput = z.infer<typeof factSearchOutputSchema>;
|
|
104
|
+
declare const factSupersedeInputSchema: z.ZodObject<{
|
|
105
|
+
oldId: z.ZodString;
|
|
106
|
+
newText: z.ZodString;
|
|
107
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
newText: string;
|
|
110
|
+
oldId: string;
|
|
111
|
+
reason?: string | undefined;
|
|
112
|
+
}, {
|
|
113
|
+
newText: string;
|
|
114
|
+
oldId: string;
|
|
115
|
+
reason?: string | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
declare const factSupersedeOutputSchema: z.ZodObject<{
|
|
118
|
+
oldId: z.ZodString;
|
|
119
|
+
newId: z.ZodString;
|
|
120
|
+
}, "strip", z.ZodTypeAny, {
|
|
121
|
+
oldId: string;
|
|
122
|
+
newId: string;
|
|
123
|
+
}, {
|
|
124
|
+
oldId: string;
|
|
125
|
+
newId: string;
|
|
126
|
+
}>;
|
|
127
|
+
type FactSupersedeInput = z.infer<typeof factSupersedeInputSchema>;
|
|
128
|
+
type FactSupersedeOutput = z.infer<typeof factSupersedeOutputSchema>;
|
|
129
|
+
declare const factForgetInputSchema: z.ZodObject<{
|
|
130
|
+
factId: z.ZodString;
|
|
131
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
132
|
+
}, "strip", z.ZodTypeAny, {
|
|
133
|
+
factId: string;
|
|
134
|
+
reason?: string | undefined;
|
|
135
|
+
}, {
|
|
136
|
+
factId: string;
|
|
137
|
+
reason?: string | undefined;
|
|
138
|
+
}>;
|
|
139
|
+
declare const factForgetOutputSchema: z.ZodObject<{
|
|
140
|
+
factId: z.ZodString;
|
|
141
|
+
forgotten: z.ZodBoolean;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
factId: string;
|
|
144
|
+
forgotten: boolean;
|
|
145
|
+
}, {
|
|
146
|
+
factId: string;
|
|
147
|
+
forgotten: boolean;
|
|
148
|
+
}>;
|
|
149
|
+
type FactForgetInput = z.infer<typeof factForgetInputSchema>;
|
|
150
|
+
type FactForgetOutput = z.infer<typeof factForgetOutputSchema>;
|
|
151
|
+
declare const factHistoryInputSchema: z.ZodObject<{
|
|
152
|
+
factId: z.ZodString;
|
|
153
|
+
}, "strip", z.ZodTypeAny, {
|
|
154
|
+
factId: string;
|
|
155
|
+
}, {
|
|
156
|
+
factId: string;
|
|
157
|
+
}>;
|
|
158
|
+
declare const factHistoryOutputSchema: z.ZodObject<{
|
|
159
|
+
chain: z.ZodArray<z.ZodObject<{
|
|
160
|
+
factId: z.ZodString;
|
|
161
|
+
text: z.ZodString;
|
|
162
|
+
validFrom: z.ZodOptional<z.ZodString>;
|
|
163
|
+
validTo: z.ZodOptional<z.ZodString>;
|
|
164
|
+
supersedes: z.ZodOptional<z.ZodString>;
|
|
165
|
+
supersededBy: z.ZodOptional<z.ZodString>;
|
|
166
|
+
sensitivity: z.ZodEnum<["public", "internal", "secret"]>;
|
|
167
|
+
}, "strip", z.ZodTypeAny, {
|
|
168
|
+
factId: string;
|
|
169
|
+
text: string;
|
|
170
|
+
sensitivity: "public" | "internal" | "secret";
|
|
171
|
+
validFrom?: string | undefined;
|
|
172
|
+
validTo?: string | undefined;
|
|
173
|
+
supersedes?: string | undefined;
|
|
174
|
+
supersededBy?: string | undefined;
|
|
175
|
+
}, {
|
|
176
|
+
factId: string;
|
|
177
|
+
text: string;
|
|
178
|
+
sensitivity: "public" | "internal" | "secret";
|
|
179
|
+
validFrom?: string | undefined;
|
|
180
|
+
validTo?: string | undefined;
|
|
181
|
+
supersedes?: string | undefined;
|
|
182
|
+
supersededBy?: string | undefined;
|
|
183
|
+
}>, "many">;
|
|
184
|
+
}, "strip", z.ZodTypeAny, {
|
|
185
|
+
chain: {
|
|
186
|
+
factId: string;
|
|
187
|
+
text: string;
|
|
188
|
+
sensitivity: "public" | "internal" | "secret";
|
|
189
|
+
validFrom?: string | undefined;
|
|
190
|
+
validTo?: string | undefined;
|
|
191
|
+
supersedes?: string | undefined;
|
|
192
|
+
supersededBy?: string | undefined;
|
|
193
|
+
}[];
|
|
194
|
+
}, {
|
|
195
|
+
chain: {
|
|
196
|
+
factId: string;
|
|
197
|
+
text: string;
|
|
198
|
+
sensitivity: "public" | "internal" | "secret";
|
|
199
|
+
validFrom?: string | undefined;
|
|
200
|
+
validTo?: string | undefined;
|
|
201
|
+
supersedes?: string | undefined;
|
|
202
|
+
supersededBy?: string | undefined;
|
|
203
|
+
}[];
|
|
204
|
+
}>;
|
|
205
|
+
type FactHistoryInput = z.infer<typeof factHistoryInputSchema>;
|
|
206
|
+
type FactHistoryOutput = z.infer<typeof factHistoryOutputSchema>;
|
|
207
|
+
declare const factValidateInputSchema: z.ZodObject<{
|
|
208
|
+
factId: z.ZodString;
|
|
209
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
factId: string;
|
|
212
|
+
reason?: string | undefined;
|
|
213
|
+
}, {
|
|
214
|
+
factId: string;
|
|
215
|
+
reason?: string | undefined;
|
|
216
|
+
}>;
|
|
217
|
+
declare const factValidateOutputSchema: z.ZodObject<{
|
|
218
|
+
factId: z.ZodString;
|
|
219
|
+
validated: z.ZodBoolean;
|
|
220
|
+
}, "strip", z.ZodTypeAny, {
|
|
221
|
+
factId: string;
|
|
222
|
+
validated: boolean;
|
|
223
|
+
}, {
|
|
224
|
+
factId: string;
|
|
225
|
+
validated: boolean;
|
|
226
|
+
}>;
|
|
227
|
+
type FactValidateInput = z.infer<typeof factValidateInputSchema>;
|
|
228
|
+
type FactValidateOutput = z.infer<typeof factValidateOutputSchema>;
|
|
229
|
+
/**
|
|
230
|
+
* `fact_remember` — persist a single semantic fact. The minimum-viable
|
|
231
|
+
* pipeline writes the fact straight through with MD5 deduplication;
|
|
232
|
+
* Phase 10b extends the body with the multi-stage conflict resolution.
|
|
233
|
+
*
|
|
234
|
+
* @stable
|
|
235
|
+
*/
|
|
236
|
+
declare function createFactRememberTool(deps: MemoryToolDeps): Tool<FactRememberInput, FactRememberOutput>;
|
|
237
|
+
/**
|
|
238
|
+
* `fact_search` — hybrid (vector + FTS5) search over the user's
|
|
239
|
+
* semantic memory. Results merged through the configured reranker.
|
|
240
|
+
*
|
|
241
|
+
* @stable
|
|
242
|
+
*/
|
|
243
|
+
declare function createFactSearchTool(deps: MemoryToolDeps): Tool<FactSearchInput, FactSearchOutput>;
|
|
244
|
+
/**
|
|
245
|
+
* `fact_supersede` — soft-supersede an old fact by storing a new one
|
|
246
|
+
* that replaces it. The old fact is kept for replay but ranked below
|
|
247
|
+
* the new one.
|
|
248
|
+
*
|
|
249
|
+
* @stable
|
|
250
|
+
*/
|
|
251
|
+
declare function createFactSupersedeTool(deps: MemoryToolDeps): Tool<FactSupersedeInput, FactSupersedeOutput>;
|
|
252
|
+
/**
|
|
253
|
+
* `fact_forget` — soft-delete a fact (kept for replay; never hard-
|
|
254
|
+
* deleted at this layer).
|
|
255
|
+
*
|
|
256
|
+
* @stable
|
|
257
|
+
*/
|
|
258
|
+
declare function createFactForgetTool(deps: MemoryToolDeps): Tool<FactForgetInput, FactForgetOutput>;
|
|
259
|
+
/**
|
|
260
|
+
* `fact_history` — trace how a fact changed over time. Returns the
|
|
261
|
+
* full bi-temporal supersede chain the given fact belongs to, oldest →
|
|
262
|
+
* newest, including superseded entries, so the agent can answer "what
|
|
263
|
+
* did the user say before" / "how did this change". Read-only. P0-2.
|
|
264
|
+
*
|
|
265
|
+
* @stable
|
|
266
|
+
*/
|
|
267
|
+
declare function createFactHistoryTool(deps: MemoryToolDeps): Tool<FactHistoryInput, FactHistoryOutput>;
|
|
268
|
+
/**
|
|
269
|
+
* `fact_validate` — promote a quarantined fact to active (P1-4). The
|
|
270
|
+
* validation path that admits a synthesized (consolidator / reflection)
|
|
271
|
+
* memory into action-driving recall once it has been reviewed; the
|
|
272
|
+
* promotion is audited in `memory_history`.
|
|
273
|
+
*
|
|
274
|
+
* MRET-3 / MST-1 — two gates close the one-turn memory-poisoning chain
|
|
275
|
+
* (`fact_remember(poison)` → `fact_validate(id)` → active recall):
|
|
276
|
+
*
|
|
277
|
+
* 1. `needsApproval: true` — the run suspends for a human decision
|
|
278
|
+
* before this tool ever executes, so the agent cannot silently
|
|
279
|
+
* promote any quarantined fact.
|
|
280
|
+
* 2. The underlying `SemanticMemory.validate(...)` re-checks the fact's
|
|
281
|
+
* text against the injection heuristics and **refuses** (no `force`
|
|
282
|
+
* is passed here) — an injection-flagged memory cannot be promoted by
|
|
283
|
+
* the agent at all. Only an operator, via the programmatic API with
|
|
284
|
+
* `{ force: true }`, can override after review.
|
|
285
|
+
*
|
|
286
|
+
* Synthesized-but-clean consolidator writes promote normally once
|
|
287
|
+
* approved.
|
|
288
|
+
*
|
|
289
|
+
* @stable
|
|
290
|
+
*/
|
|
291
|
+
declare function createFactValidateTool(deps: MemoryToolDeps): Tool<FactValidateInput, FactValidateOutput>;
|
|
292
|
+
//#endregion
|
|
293
|
+
export { createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool };
|
|
294
|
+
//# sourceMappingURL=fact-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fact-tools.d.ts","names":[],"sources":["../../src/tools/fact-tools.ts"],"sourcesContent":[],"mappings":";;;;;cAeM,yBAAuB,CAAA,CAAA;;EAAvB,IAAA,eAAA,WAOJ,YAAA,EAAA,MAAA,CAAA,CAAA;;;;;;;;;;;;;;EAP2B,WAAA,CAAA,EAAA,QAAA,GAAA,UAAA,GAAA,QAAA,GAAA,SAAA;EAAA,IAAA,CAAA,EAAA,MAAA,EAAA,GAAA,SAAA;EAQvB,UAAA,CAAA,EAAA,MAAA,GAAA,SAUJ;;;;cAVI,0BAAwB,CAAA,CAAA;;EAAA;;AAAA;AAYE;AACC;;;;;;;;;;EAEN,WAAA,EAAA,OAAA;EAAA,gBAAA,CAAA,EAAA,WAAA,GAAA,aAAA,GAAA,SAAA;AAAA,CAAA,CAAA;KAHtB,iBAAA,GAAoB,CAAA,CAAE,aAAa;KACnC,kBAAA,GAAqB,CAAA,CAAE,aAAa;cAEnC,uBAAqB,CAAA,CAAA;;;;;;;;EAMC,IAAA,CAAA,EAAA,MAAA,GAAA,SAAA;EAAA,IAAA,CAAA,EAAA,MAAA,EAAA,GAAA,SAAA;AAAA,CAAA,EAA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AA,WAAA,CAAA,CAAA,QAAA,EAAA,UAAA,EAAA,QAAA,CAAA,CAAA;EAAI,CAAA,EAAA,OAAA,cAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KArOF,gBAAA,GAAmB,CAAA,CAAE,aAAa;KAClC,iBAAA,GAAoB,CAAA,CAAE,aAAa;cAElC,yBAAuB,CAAA,CAAA;;;;;;;;;;cAIvB,0BAAwB,CAAA,CAAA;;;;;;;;;;KAKzB,iBAAA,GAAoB,CAAA,CAAE,aAAa;KACnC,kBAAA,GAAqB,CAAA,CAAE,aAAa;;;;;;;;iBASzB,sBAAA,OACR,iBACL,KAAK,mBAAmB;;;;;;;iBAyCX,oBAAA,OACR,iBACL,KAAK,iBAAiB;;;;;;;;iBA0CT,uBAAA,OACR,iBACL,KAAK,oBAAoB;;;;;;;iBA+BZ,oBAAA,OACR,iBACL,KAAK,iBAAiB;;;;;;;;;iBA4BT,qBAAA,OACR,iBACL,KAAK,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;iBAqDV,sBAAA,OACR,iBACL,KAAK,mBAAmB"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { tool } from "@graphorin/tools";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/tools/fact-tools.ts
|
|
5
|
+
const sensitivityEnum = z.enum([
|
|
6
|
+
"public",
|
|
7
|
+
"internal",
|
|
8
|
+
"secret"
|
|
9
|
+
]);
|
|
10
|
+
const provenanceEnum = z.enum([
|
|
11
|
+
"user",
|
|
12
|
+
"tool",
|
|
13
|
+
"extraction",
|
|
14
|
+
"reflection",
|
|
15
|
+
"induction",
|
|
16
|
+
"imported"
|
|
17
|
+
]);
|
|
18
|
+
const factRememberInputSchema = z.object({
|
|
19
|
+
text: z.string().min(1).max(8192),
|
|
20
|
+
tags: z.array(z.string().min(1).max(64)).max(32).optional(),
|
|
21
|
+
confidence: z.number().min(0).max(1).optional(),
|
|
22
|
+
sensitivity: sensitivityEnum.optional(),
|
|
23
|
+
validFrom: z.string().datetime().optional(),
|
|
24
|
+
validTo: z.string().datetime().optional()
|
|
25
|
+
});
|
|
26
|
+
const factRememberOutputSchema = z.object({
|
|
27
|
+
factId: z.string(),
|
|
28
|
+
quarantined: z.boolean(),
|
|
29
|
+
quarantineReason: z.enum(["injection", "synthesized"]).optional()
|
|
30
|
+
});
|
|
31
|
+
const factSearchInputSchema = z.object({
|
|
32
|
+
query: z.string().min(1).max(1024),
|
|
33
|
+
topK: z.number().int().positive().max(50).optional(),
|
|
34
|
+
tags: z.array(z.string().min(1)).max(16).optional(),
|
|
35
|
+
asOf: z.string().datetime().optional()
|
|
36
|
+
});
|
|
37
|
+
const factSearchOutputSchema = z.object({ hits: z.array(z.object({
|
|
38
|
+
factId: z.string(),
|
|
39
|
+
text: z.string(),
|
|
40
|
+
score: z.number(),
|
|
41
|
+
sensitivity: sensitivityEnum,
|
|
42
|
+
provenance: provenanceEnum.optional()
|
|
43
|
+
})) });
|
|
44
|
+
const factSupersedeInputSchema = z.object({
|
|
45
|
+
oldId: z.string().min(1),
|
|
46
|
+
newText: z.string().min(1).max(8192),
|
|
47
|
+
reason: z.string().max(512).optional()
|
|
48
|
+
});
|
|
49
|
+
const factSupersedeOutputSchema = z.object({
|
|
50
|
+
oldId: z.string(),
|
|
51
|
+
newId: z.string()
|
|
52
|
+
});
|
|
53
|
+
const factForgetInputSchema = z.object({
|
|
54
|
+
factId: z.string().min(1),
|
|
55
|
+
reason: z.string().max(512).optional()
|
|
56
|
+
});
|
|
57
|
+
const factForgetOutputSchema = z.object({
|
|
58
|
+
factId: z.string(),
|
|
59
|
+
forgotten: z.boolean()
|
|
60
|
+
});
|
|
61
|
+
const factHistoryInputSchema = z.object({ factId: z.string().min(1) });
|
|
62
|
+
const factHistoryOutputSchema = z.object({ chain: z.array(z.object({
|
|
63
|
+
factId: z.string(),
|
|
64
|
+
text: z.string(),
|
|
65
|
+
validFrom: z.string().optional(),
|
|
66
|
+
validTo: z.string().optional(),
|
|
67
|
+
supersedes: z.string().optional(),
|
|
68
|
+
supersededBy: z.string().optional(),
|
|
69
|
+
sensitivity: sensitivityEnum
|
|
70
|
+
})) });
|
|
71
|
+
const factValidateInputSchema = z.object({
|
|
72
|
+
factId: z.string().min(1),
|
|
73
|
+
reason: z.string().max(512).optional()
|
|
74
|
+
});
|
|
75
|
+
const factValidateOutputSchema = z.object({
|
|
76
|
+
factId: z.string(),
|
|
77
|
+
validated: z.boolean()
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* `fact_remember` — persist a single semantic fact. The minimum-viable
|
|
81
|
+
* pipeline writes the fact straight through with MD5 deduplication;
|
|
82
|
+
* Phase 10b extends the body with the multi-stage conflict resolution.
|
|
83
|
+
*
|
|
84
|
+
* @stable
|
|
85
|
+
*/
|
|
86
|
+
function createFactRememberTool(deps) {
|
|
87
|
+
return tool({
|
|
88
|
+
name: "fact_remember",
|
|
89
|
+
description: "Persist an atomic factual statement about the user, the world, or the current session. Prefer one fact per call; the system applies dedup + conflict resolution downstream. Pass `validFrom` / `validTo` for bi-temporal facts and `sensitivity` to control redaction.",
|
|
90
|
+
inputSchema: factRememberInputSchema,
|
|
91
|
+
outputSchema: factRememberOutputSchema,
|
|
92
|
+
sideEffectClass: "side-effecting",
|
|
93
|
+
sandboxPolicy: "none",
|
|
94
|
+
sensitivity: "internal",
|
|
95
|
+
memoryGuardTier: "memory-aware",
|
|
96
|
+
tags: ["memory", "semantic"],
|
|
97
|
+
async execute(input, ctx) {
|
|
98
|
+
const scope = await deps.resolveScope(ctx);
|
|
99
|
+
const outcome = await deps.semantic.rememberWithDecision(scope, {
|
|
100
|
+
text: input.text,
|
|
101
|
+
...input.tags !== void 0 ? { tags: input.tags } : {},
|
|
102
|
+
...input.confidence !== void 0 ? { confidence: input.confidence } : {},
|
|
103
|
+
...input.sensitivity !== void 0 ? { sensitivity: input.sensitivity } : {},
|
|
104
|
+
...input.validFrom !== void 0 ? { validFrom: input.validFrom } : {},
|
|
105
|
+
...input.validTo !== void 0 ? { validTo: input.validTo } : {}
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
factId: outcome.fact.id,
|
|
109
|
+
quarantined: outcome.fact.status === "quarantined",
|
|
110
|
+
...outcome.quarantineReason !== void 0 ? { quarantineReason: outcome.quarantineReason } : {}
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* `fact_search` — hybrid (vector + FTS5) search over the user's
|
|
117
|
+
* semantic memory. Results merged through the configured reranker.
|
|
118
|
+
*
|
|
119
|
+
* @stable
|
|
120
|
+
*/
|
|
121
|
+
function createFactSearchTool(deps) {
|
|
122
|
+
return tool({
|
|
123
|
+
name: "fact_search",
|
|
124
|
+
description: "Search the user's long-term factual memory by natural-language query. Returns up to `topK` matched facts with their score and sensitivity. Use this BEFORE asking the user a question they may have answered earlier. Pass `asOf` (ISO-8601) to read memory as it was at a past instant — point-in-time / 'what was true on date X' — instead of the current state.",
|
|
125
|
+
inputSchema: factSearchInputSchema,
|
|
126
|
+
outputSchema: factSearchOutputSchema,
|
|
127
|
+
sideEffectClass: "read-only",
|
|
128
|
+
sandboxPolicy: "none",
|
|
129
|
+
sensitivity: "internal",
|
|
130
|
+
memoryGuardTier: "pure",
|
|
131
|
+
tags: ["memory", "semantic"],
|
|
132
|
+
async execute(input, ctx) {
|
|
133
|
+
const scope = await deps.resolveScope(ctx);
|
|
134
|
+
return { hits: (await deps.semantic.search(scope, input.query, {
|
|
135
|
+
...input.topK !== void 0 ? { topK: input.topK } : {},
|
|
136
|
+
...input.tags !== void 0 && input.tags.length > 0 ? { tags: input.tags } : {},
|
|
137
|
+
...input.asOf !== void 0 ? { asOf: input.asOf } : {},
|
|
138
|
+
signal: ctx.signal
|
|
139
|
+
})).map((hit) => ({
|
|
140
|
+
factId: hit.record.id,
|
|
141
|
+
text: hit.record.text,
|
|
142
|
+
score: hit.score,
|
|
143
|
+
sensitivity: hit.record.sensitivity,
|
|
144
|
+
...hit.record.provenance !== void 0 ? { provenance: hit.record.provenance } : {}
|
|
145
|
+
})) };
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* `fact_supersede` — soft-supersede an old fact by storing a new one
|
|
151
|
+
* that replaces it. The old fact is kept for replay but ranked below
|
|
152
|
+
* the new one.
|
|
153
|
+
*
|
|
154
|
+
* @stable
|
|
155
|
+
*/
|
|
156
|
+
function createFactSupersedeTool(deps) {
|
|
157
|
+
return tool({
|
|
158
|
+
name: "fact_supersede",
|
|
159
|
+
description: "Mark an old fact superseded by a new one. Use this when the user's situation changed (moved cities, updated a goal, switched a preference) — the old fact is preserved for replay but no longer surfaced as current.",
|
|
160
|
+
inputSchema: factSupersedeInputSchema,
|
|
161
|
+
outputSchema: factSupersedeOutputSchema,
|
|
162
|
+
sideEffectClass: "side-effecting",
|
|
163
|
+
sandboxPolicy: "none",
|
|
164
|
+
sensitivity: "internal",
|
|
165
|
+
memoryGuardTier: "memory-aware",
|
|
166
|
+
tags: ["memory", "semantic"],
|
|
167
|
+
async execute(input, ctx) {
|
|
168
|
+
const scope = await deps.resolveScope(ctx);
|
|
169
|
+
const result = await deps.semantic.supersede(scope, input.oldId, { text: input.newText }, input.reason);
|
|
170
|
+
return {
|
|
171
|
+
oldId: result.old,
|
|
172
|
+
newId: result.new.id
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* `fact_forget` — soft-delete a fact (kept for replay; never hard-
|
|
179
|
+
* deleted at this layer).
|
|
180
|
+
*
|
|
181
|
+
* @stable
|
|
182
|
+
*/
|
|
183
|
+
function createFactForgetTool(deps) {
|
|
184
|
+
return tool({
|
|
185
|
+
name: "fact_forget",
|
|
186
|
+
description: "Soft-delete a fact. The record is preserved for replay but no longer surfaced by fact_search. Use only for explicit user-driven removal (privacy / user request).",
|
|
187
|
+
inputSchema: factForgetInputSchema,
|
|
188
|
+
outputSchema: factForgetOutputSchema,
|
|
189
|
+
sideEffectClass: "side-effecting",
|
|
190
|
+
sandboxPolicy: "none",
|
|
191
|
+
sensitivity: "internal",
|
|
192
|
+
memoryGuardTier: "memory-aware",
|
|
193
|
+
tags: ["memory", "semantic"],
|
|
194
|
+
async execute(input, ctx) {
|
|
195
|
+
const scope = await deps.resolveScope(ctx);
|
|
196
|
+
await deps.semantic.forget(scope, input.factId, input.reason);
|
|
197
|
+
return {
|
|
198
|
+
factId: input.factId,
|
|
199
|
+
forgotten: true
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* `fact_history` — trace how a fact changed over time. Returns the
|
|
206
|
+
* full bi-temporal supersede chain the given fact belongs to, oldest →
|
|
207
|
+
* newest, including superseded entries, so the agent can answer "what
|
|
208
|
+
* did the user say before" / "how did this change". Read-only. P0-2.
|
|
209
|
+
*
|
|
210
|
+
* @stable
|
|
211
|
+
*/
|
|
212
|
+
function createFactHistoryTool(deps) {
|
|
213
|
+
return tool({
|
|
214
|
+
name: "fact_history",
|
|
215
|
+
description: "Trace how a fact changed over time. Given a factId, returns its full bi-temporal supersede chain (oldest → newest), including superseded entries, with each entry's validFrom/validTo. Use this to answer 'how did this change' or 'what was the previous value'.",
|
|
216
|
+
inputSchema: factHistoryInputSchema,
|
|
217
|
+
outputSchema: factHistoryOutputSchema,
|
|
218
|
+
sideEffectClass: "read-only",
|
|
219
|
+
sandboxPolicy: "none",
|
|
220
|
+
sensitivity: "internal",
|
|
221
|
+
memoryGuardTier: "pure",
|
|
222
|
+
tags: [
|
|
223
|
+
"memory",
|
|
224
|
+
"semantic",
|
|
225
|
+
"temporal"
|
|
226
|
+
],
|
|
227
|
+
async execute(input, ctx) {
|
|
228
|
+
const scope = await deps.resolveScope(ctx);
|
|
229
|
+
return { chain: (await deps.semantic.history(scope, input.factId)).map((f) => ({
|
|
230
|
+
factId: f.id,
|
|
231
|
+
text: f.text,
|
|
232
|
+
...f.validFrom !== void 0 ? { validFrom: f.validFrom } : {},
|
|
233
|
+
...f.validTo !== void 0 ? { validTo: f.validTo } : {},
|
|
234
|
+
...f.supersedes !== void 0 ? { supersedes: f.supersedes } : {},
|
|
235
|
+
...f.supersededBy !== void 0 ? { supersededBy: f.supersededBy } : {},
|
|
236
|
+
sensitivity: f.sensitivity
|
|
237
|
+
})) };
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* `fact_validate` — promote a quarantined fact to active (P1-4). The
|
|
243
|
+
* validation path that admits a synthesized (consolidator / reflection)
|
|
244
|
+
* memory into action-driving recall once it has been reviewed; the
|
|
245
|
+
* promotion is audited in `memory_history`.
|
|
246
|
+
*
|
|
247
|
+
* MRET-3 / MST-1 — two gates close the one-turn memory-poisoning chain
|
|
248
|
+
* (`fact_remember(poison)` → `fact_validate(id)` → active recall):
|
|
249
|
+
*
|
|
250
|
+
* 1. `needsApproval: true` — the run suspends for a human decision
|
|
251
|
+
* before this tool ever executes, so the agent cannot silently
|
|
252
|
+
* promote any quarantined fact.
|
|
253
|
+
* 2. The underlying `SemanticMemory.validate(...)` re-checks the fact's
|
|
254
|
+
* text against the injection heuristics and **refuses** (no `force`
|
|
255
|
+
* is passed here) — an injection-flagged memory cannot be promoted by
|
|
256
|
+
* the agent at all. Only an operator, via the programmatic API with
|
|
257
|
+
* `{ force: true }`, can override after review.
|
|
258
|
+
*
|
|
259
|
+
* Synthesized-but-clean consolidator writes promote normally once
|
|
260
|
+
* approved.
|
|
261
|
+
*
|
|
262
|
+
* @stable
|
|
263
|
+
*/
|
|
264
|
+
function createFactValidateTool(deps) {
|
|
265
|
+
return tool({
|
|
266
|
+
name: "fact_validate",
|
|
267
|
+
description: "Promote a quarantined fact to active so it becomes eligible for normal recall. Quarantined facts are memories the system synthesized or flagged as risky; validating one is a deliberate, human-approved admission and never a routine step. This action requires approval, and facts flagged as prompt-injection cannot be promoted here — they are an operator-only decision.",
|
|
268
|
+
inputSchema: factValidateInputSchema,
|
|
269
|
+
outputSchema: factValidateOutputSchema,
|
|
270
|
+
needsApproval: true,
|
|
271
|
+
sideEffectClass: "side-effecting",
|
|
272
|
+
sandboxPolicy: "none",
|
|
273
|
+
sensitivity: "internal",
|
|
274
|
+
memoryGuardTier: "memory-aware",
|
|
275
|
+
tags: [
|
|
276
|
+
"memory",
|
|
277
|
+
"semantic",
|
|
278
|
+
"safety"
|
|
279
|
+
],
|
|
280
|
+
async execute(input, ctx) {
|
|
281
|
+
const scope = await deps.resolveScope(ctx);
|
|
282
|
+
await deps.semantic.validate(scope, input.factId, input.reason);
|
|
283
|
+
return {
|
|
284
|
+
factId: input.factId,
|
|
285
|
+
validated: true
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
//#endregion
|
|
292
|
+
export { createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool };
|
|
293
|
+
//# sourceMappingURL=fact-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fact-tools.js","names":[],"sources":["../../src/tools/fact-tools.ts"],"sourcesContent":["import type { Tool } from '@graphorin/core';\nimport { tool } from '@graphorin/tools';\nimport { z } from 'zod';\nimport type { MemoryToolDeps } from './types.js';\n\nconst sensitivityEnum = z.enum(['public', 'internal', 'secret']);\nconst provenanceEnum = z.enum([\n 'user',\n 'tool',\n 'extraction',\n 'reflection',\n 'induction',\n 'imported',\n]);\n\nconst factRememberInputSchema = z.object({\n text: z.string().min(1).max(8192),\n tags: z.array(z.string().min(1).max(64)).max(32).optional(),\n confidence: z.number().min(0).max(1).optional(),\n sensitivity: sensitivityEnum.optional(),\n validFrom: z.string().datetime().optional(),\n validTo: z.string().datetime().optional(),\n});\nconst factRememberOutputSchema = z.object({\n factId: z.string(),\n /**\n * MRET-3: `true` when the write landed in quarantine (hidden from\n * default recall until validated). A synthesized consolidator write or\n * a candidate that tripped the injection heuristics quarantines.\n */\n quarantined: z.boolean(),\n /** Why it was quarantined, when it was. */\n quarantineReason: z.enum(['injection', 'synthesized']).optional(),\n});\n\ntype FactRememberInput = z.infer<typeof factRememberInputSchema>;\ntype FactRememberOutput = z.infer<typeof factRememberOutputSchema>;\n\nconst factSearchInputSchema = z.object({\n query: z.string().min(1).max(1024),\n topK: z.number().int().positive().max(50).optional(),\n tags: z.array(z.string().min(1)).max(16).optional(),\n asOf: z.string().datetime().optional(),\n});\nconst factSearchOutputSchema = z.object({\n hits: z.array(\n z.object({\n factId: z.string(),\n text: z.string(),\n score: z.number(),\n sensitivity: sensitivityEnum,\n provenance: provenanceEnum.optional(),\n }),\n ),\n});\n\ntype FactSearchInput = z.infer<typeof factSearchInputSchema>;\ntype FactSearchOutput = z.infer<typeof factSearchOutputSchema>;\n\nconst factSupersedeInputSchema = z.object({\n oldId: z.string().min(1),\n newText: z.string().min(1).max(8192),\n reason: z.string().max(512).optional(),\n});\nconst factSupersedeOutputSchema = z.object({\n oldId: z.string(),\n newId: z.string(),\n});\n\ntype FactSupersedeInput = z.infer<typeof factSupersedeInputSchema>;\ntype FactSupersedeOutput = z.infer<typeof factSupersedeOutputSchema>;\n\nconst factForgetInputSchema = z.object({\n factId: z.string().min(1),\n reason: z.string().max(512).optional(),\n});\nconst factForgetOutputSchema = z.object({\n factId: z.string(),\n forgotten: z.boolean(),\n});\n\ntype FactForgetInput = z.infer<typeof factForgetInputSchema>;\ntype FactForgetOutput = z.infer<typeof factForgetOutputSchema>;\n\nconst factHistoryInputSchema = z.object({\n factId: z.string().min(1),\n});\nconst factHistoryOutputSchema = z.object({\n chain: z.array(\n z.object({\n factId: z.string(),\n text: z.string(),\n validFrom: z.string().optional(),\n validTo: z.string().optional(),\n supersedes: z.string().optional(),\n supersededBy: z.string().optional(),\n sensitivity: sensitivityEnum,\n }),\n ),\n});\n\ntype FactHistoryInput = z.infer<typeof factHistoryInputSchema>;\ntype FactHistoryOutput = z.infer<typeof factHistoryOutputSchema>;\n\nconst factValidateInputSchema = z.object({\n factId: z.string().min(1),\n reason: z.string().max(512).optional(),\n});\nconst factValidateOutputSchema = z.object({\n factId: z.string(),\n validated: z.boolean(),\n});\n\ntype FactValidateInput = z.infer<typeof factValidateInputSchema>;\ntype FactValidateOutput = z.infer<typeof factValidateOutputSchema>;\n\n/**\n * `fact_remember` — persist a single semantic fact. The minimum-viable\n * pipeline writes the fact straight through with MD5 deduplication;\n * Phase 10b extends the body with the multi-stage conflict resolution.\n *\n * @stable\n */\nexport function createFactRememberTool(\n deps: MemoryToolDeps,\n): Tool<FactRememberInput, FactRememberOutput> {\n return tool<FactRememberInput, FactRememberOutput>({\n name: 'fact_remember',\n description:\n 'Persist an atomic factual statement about the user, the world, or the current session. Prefer one fact per call; the system applies dedup + conflict resolution downstream. Pass `validFrom` / `validTo` for bi-temporal facts and `sensitivity` to control redaction.',\n inputSchema: factRememberInputSchema,\n outputSchema: factRememberOutputSchema,\n sideEffectClass: 'side-effecting',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'memory-aware',\n tags: ['memory', 'semantic'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n const outcome = await deps.semantic.rememberWithDecision(scope, {\n text: input.text,\n ...(input.tags !== undefined ? { tags: input.tags } : {}),\n ...(input.confidence !== undefined ? { confidence: input.confidence } : {}),\n ...(input.sensitivity !== undefined ? { sensitivity: input.sensitivity } : {}),\n ...(input.validFrom !== undefined ? { validFrom: input.validFrom } : {}),\n ...(input.validTo !== undefined ? { validTo: input.validTo } : {}),\n });\n // MRET-3: tell the caller when the write was quarantined so a\n // poisoned fact cannot masquerade as a normally-stored one.\n return {\n factId: outcome.fact.id,\n quarantined: outcome.fact.status === 'quarantined',\n ...(outcome.quarantineReason !== undefined\n ? { quarantineReason: outcome.quarantineReason }\n : {}),\n };\n },\n });\n}\n\n/**\n * `fact_search` — hybrid (vector + FTS5) search over the user's\n * semantic memory. Results merged through the configured reranker.\n *\n * @stable\n */\nexport function createFactSearchTool(\n deps: MemoryToolDeps,\n): Tool<FactSearchInput, FactSearchOutput> {\n return tool<FactSearchInput, FactSearchOutput>({\n name: 'fact_search',\n description:\n \"Search the user's long-term factual memory by natural-language query. Returns up to `topK` matched facts with their score and sensitivity. Use this BEFORE asking the user a question they may have answered earlier. Pass `asOf` (ISO-8601) to read memory as it was at a past instant — point-in-time / 'what was true on date X' — instead of the current state.\",\n inputSchema: factSearchInputSchema,\n outputSchema: factSearchOutputSchema,\n sideEffectClass: 'read-only',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'pure',\n tags: ['memory', 'semantic'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n const hits = await deps.semantic.search(scope, input.query, {\n ...(input.topK !== undefined ? { topK: input.topK } : {}),\n // MRET-4: forward the tags filter — it was accepted by the\n // schema and silently dropped here.\n ...(input.tags !== undefined && input.tags.length > 0 ? { tags: input.tags } : {}),\n ...(input.asOf !== undefined ? { asOf: input.asOf } : {}),\n signal: ctx.signal,\n });\n return {\n hits: hits.map((hit) => ({\n factId: hit.record.id,\n text: hit.record.text,\n score: hit.score,\n sensitivity: hit.record.sensitivity,\n ...(hit.record.provenance !== undefined ? { provenance: hit.record.provenance } : {}),\n })),\n };\n },\n });\n}\n\n/**\n * `fact_supersede` — soft-supersede an old fact by storing a new one\n * that replaces it. The old fact is kept for replay but ranked below\n * the new one.\n *\n * @stable\n */\nexport function createFactSupersedeTool(\n deps: MemoryToolDeps,\n): Tool<FactSupersedeInput, FactSupersedeOutput> {\n return tool<FactSupersedeInput, FactSupersedeOutput>({\n name: 'fact_supersede',\n description:\n \"Mark an old fact superseded by a new one. Use this when the user's situation changed (moved cities, updated a goal, switched a preference) — the old fact is preserved for replay but no longer surfaced as current.\",\n inputSchema: factSupersedeInputSchema,\n outputSchema: factSupersedeOutputSchema,\n sideEffectClass: 'side-effecting',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'memory-aware',\n tags: ['memory', 'semantic'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n const result = await deps.semantic.supersede(\n scope,\n input.oldId,\n { text: input.newText },\n input.reason,\n );\n return { oldId: result.old, newId: result.new.id };\n },\n });\n}\n\n/**\n * `fact_forget` — soft-delete a fact (kept for replay; never hard-\n * deleted at this layer).\n *\n * @stable\n */\nexport function createFactForgetTool(\n deps: MemoryToolDeps,\n): Tool<FactForgetInput, FactForgetOutput> {\n return tool<FactForgetInput, FactForgetOutput>({\n name: 'fact_forget',\n description:\n 'Soft-delete a fact. The record is preserved for replay but no longer surfaced by fact_search. Use only for explicit user-driven removal (privacy / user request).',\n inputSchema: factForgetInputSchema,\n outputSchema: factForgetOutputSchema,\n sideEffectClass: 'side-effecting',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'memory-aware',\n tags: ['memory', 'semantic'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n await deps.semantic.forget(scope, input.factId, input.reason);\n return { factId: input.factId, forgotten: true };\n },\n });\n}\n\n/**\n * `fact_history` — trace how a fact changed over time. Returns the\n * full bi-temporal supersede chain the given fact belongs to, oldest →\n * newest, including superseded entries, so the agent can answer \"what\n * did the user say before\" / \"how did this change\". Read-only. P0-2.\n *\n * @stable\n */\nexport function createFactHistoryTool(\n deps: MemoryToolDeps,\n): Tool<FactHistoryInput, FactHistoryOutput> {\n return tool<FactHistoryInput, FactHistoryOutput>({\n name: 'fact_history',\n description:\n \"Trace how a fact changed over time. Given a factId, returns its full bi-temporal supersede chain (oldest → newest), including superseded entries, with each entry's validFrom/validTo. Use this to answer 'how did this change' or 'what was the previous value'.\",\n inputSchema: factHistoryInputSchema,\n outputSchema: factHistoryOutputSchema,\n sideEffectClass: 'read-only',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'pure',\n tags: ['memory', 'semantic', 'temporal'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n const chain = await deps.semantic.history(scope, input.factId);\n return {\n chain: chain.map((f) => ({\n factId: f.id,\n text: f.text,\n ...(f.validFrom !== undefined ? { validFrom: f.validFrom } : {}),\n ...(f.validTo !== undefined ? { validTo: f.validTo } : {}),\n ...(f.supersedes !== undefined ? { supersedes: f.supersedes } : {}),\n ...(f.supersededBy !== undefined ? { supersededBy: f.supersededBy } : {}),\n sensitivity: f.sensitivity,\n })),\n };\n },\n });\n}\n\n/**\n * `fact_validate` — promote a quarantined fact to active (P1-4). The\n * validation path that admits a synthesized (consolidator / reflection)\n * memory into action-driving recall once it has been reviewed; the\n * promotion is audited in `memory_history`.\n *\n * MRET-3 / MST-1 — two gates close the one-turn memory-poisoning chain\n * (`fact_remember(poison)` → `fact_validate(id)` → active recall):\n *\n * 1. `needsApproval: true` — the run suspends for a human decision\n * before this tool ever executes, so the agent cannot silently\n * promote any quarantined fact.\n * 2. The underlying `SemanticMemory.validate(...)` re-checks the fact's\n * text against the injection heuristics and **refuses** (no `force`\n * is passed here) — an injection-flagged memory cannot be promoted by\n * the agent at all. Only an operator, via the programmatic API with\n * `{ force: true }`, can override after review.\n *\n * Synthesized-but-clean consolidator writes promote normally once\n * approved.\n *\n * @stable\n */\nexport function createFactValidateTool(\n deps: MemoryToolDeps,\n): Tool<FactValidateInput, FactValidateOutput> {\n return tool<FactValidateInput, FactValidateOutput>({\n name: 'fact_validate',\n description:\n 'Promote a quarantined fact to active so it becomes eligible for normal recall. Quarantined facts are memories the system synthesized or flagged as risky; validating one is a deliberate, human-approved admission and never a routine step. This action requires approval, and facts flagged as prompt-injection cannot be promoted here — they are an operator-only decision.',\n inputSchema: factValidateInputSchema,\n outputSchema: factValidateOutputSchema,\n // MRET-3: the only real gate on a model-callable tool — suspend the\n // run for a human decision before promoting anything out of quarantine.\n needsApproval: true,\n sideEffectClass: 'side-effecting',\n sandboxPolicy: 'none',\n sensitivity: 'internal',\n memoryGuardTier: 'memory-aware',\n tags: ['memory', 'semantic', 'safety'],\n async execute(input, ctx) {\n const scope = await deps.resolveScope(ctx);\n // No `force`: the agent path can never promote an injection-flagged\n // fact (validate throws QuarantinePromotionRefusedError for those).\n await deps.semantic.validate(scope, input.factId, input.reason);\n return { factId: input.factId, validated: true };\n },\n });\n}\n"],"mappings":";;;;AAKA,MAAM,kBAAkB,EAAE,KAAK;CAAC;CAAU;CAAY;CAAS,CAAC;AAChE,MAAM,iBAAiB,EAAE,KAAK;CAC5B;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAEF,MAAM,0BAA0B,EAAE,OAAO;CACvC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;CACjC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,UAAU;CAC3D,YAAY,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,UAAU;CAC/C,aAAa,gBAAgB,UAAU;CACvC,WAAW,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC3C,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,UAAU;CAC1C,CAAC;AACF,MAAM,2BAA2B,EAAE,OAAO;CACxC,QAAQ,EAAE,QAAQ;CAMlB,aAAa,EAAE,SAAS;CAExB,kBAAkB,EAAE,KAAK,CAAC,aAAa,cAAc,CAAC,CAAC,UAAU;CAClE,CAAC;AAKF,MAAM,wBAAwB,EAAE,OAAO;CACrC,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,KAAK;CAClC,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,GAAG,CAAC,UAAU;CACpD,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,GAAG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MAAM,QAAQ,MAAM,OAAO;AAC/D,UAAO;IAAE,QAAQ,MAAM;IAAQ,WAAW;IAAM;;EAEnD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MemoryToolDeps, ScopeResolver } from "./types.js";
|
|
2
|
+
import { createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool } from "./block-tools.js";
|
|
3
|
+
import { createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool } from "./fact-tools.js";
|
|
4
|
+
import { createConversationSearchTool, createDeepRecallTool, createRecallEpisodesTool } from "./recall-tools.js";
|
|
5
|
+
import { Tool } from "@graphorin/core";
|
|
6
|
+
|
|
7
|
+
//#region src/tools/index.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Options for {@link buildMemoryTools}.
|
|
11
|
+
*
|
|
12
|
+
* @stable
|
|
13
|
+
*/
|
|
14
|
+
interface BuildMemoryToolsOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Append the gated `deep_recall` tool (P2-4) as a twelfth tool. The
|
|
17
|
+
* facade sets this only when `iterativeRetrieval` is configured, so the
|
|
18
|
+
* default tool surface stays at the canonical eleven. Default `false`.
|
|
19
|
+
*/
|
|
20
|
+
readonly includeDeepRecall?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Build the canonical eleven-memory-tool array. Order is stable —
|
|
24
|
+
* consumers can rely on the indices for snapshot tests. `fact_history`
|
|
25
|
+
* (P0-2) and `fact_validate` (P1-4) are appended last so the original
|
|
26
|
+
* nine indices are unchanged. With `{ includeDeepRecall: true }` the
|
|
27
|
+
* gated `deep_recall` tool (P2-4) is appended as a twelfth, after the
|
|
28
|
+
* stable eleven.
|
|
29
|
+
*
|
|
30
|
+
* @stable
|
|
31
|
+
*/
|
|
32
|
+
declare function buildMemoryTools(deps: MemoryToolDeps, options?: BuildMemoryToolsOptions): ReadonlyArray<Tool>;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { BuildMemoryToolsOptions, type MemoryToolDeps, type ScopeResolver, buildMemoryTools, createBlockAppendTool, createBlockReplaceTool, createBlockRethinkTool, createConversationSearchTool, createDeepRecallTool, createFactForgetTool, createFactHistoryTool, createFactRememberTool, createFactSearchTool, createFactSupersedeTool, createFactValidateTool, createRecallEpisodesTool };
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;UAyDiB,uBAAA;;;;;;;;;;;;;;;;;;iBAmBD,gBAAA,OACR,0BACG,0BACR,cAAc"}
|