@tangle-network/agent-knowledge 1.5.2 → 1.7.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/AGENTS.md +2 -2
- package/README.md +41 -4
- package/dist/chunk-U6KQ4FS3.js +585 -0
- package/dist/chunk-U6KQ4FS3.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.ts +161 -0
- package/dist/memory/index.js +24 -0
- package/dist/memory/index.js.map +1 -0
- package/docs/architecture.md +3 -3
- package/package.json +15 -5
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { S as SourceRecord } from '../types-BEDGlXB-.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
|
|
4
|
+
type AgentMemoryKind = 'message' | 'entity' | 'fact' | 'preference' | 'observation' | 'reasoning-trace';
|
|
5
|
+
interface AgentMemoryScope {
|
|
6
|
+
tenantId?: string;
|
|
7
|
+
userId?: string;
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
namespace?: string;
|
|
10
|
+
tags?: Record<string, string>;
|
|
11
|
+
}
|
|
12
|
+
interface AgentMemoryHit {
|
|
13
|
+
id: string;
|
|
14
|
+
uri: string;
|
|
15
|
+
kind: AgentMemoryKind;
|
|
16
|
+
text: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
score?: number;
|
|
19
|
+
normalizedScore?: number;
|
|
20
|
+
confidence?: number;
|
|
21
|
+
createdAt?: string;
|
|
22
|
+
validUntil?: string;
|
|
23
|
+
lastVerifiedAt?: string;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
interface AgentMemoryContext {
|
|
27
|
+
query: string;
|
|
28
|
+
text: string;
|
|
29
|
+
hits: AgentMemoryHit[];
|
|
30
|
+
sourceRecords: SourceRecord[];
|
|
31
|
+
metadata?: Record<string, unknown>;
|
|
32
|
+
}
|
|
33
|
+
interface AgentMemorySearchOptions {
|
|
34
|
+
scope?: AgentMemoryScope;
|
|
35
|
+
limit?: number;
|
|
36
|
+
minScore?: number;
|
|
37
|
+
kinds?: AgentMemoryKind[];
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
}
|
|
40
|
+
interface AgentMemoryWriteInput {
|
|
41
|
+
kind: AgentMemoryKind;
|
|
42
|
+
text: string;
|
|
43
|
+
id?: string;
|
|
44
|
+
title?: string;
|
|
45
|
+
role?: 'system' | 'user' | 'assistant' | 'tool';
|
|
46
|
+
entityName?: string;
|
|
47
|
+
entityType?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
predicate?: string;
|
|
50
|
+
subject?: string;
|
|
51
|
+
object?: string;
|
|
52
|
+
confidence?: number;
|
|
53
|
+
scope?: AgentMemoryScope;
|
|
54
|
+
metadata?: Record<string, unknown>;
|
|
55
|
+
}
|
|
56
|
+
interface AgentMemoryWriteResult {
|
|
57
|
+
accepted: boolean;
|
|
58
|
+
id: string;
|
|
59
|
+
uri: string;
|
|
60
|
+
kind: AgentMemoryKind;
|
|
61
|
+
sourceRecord?: SourceRecord;
|
|
62
|
+
metadata?: Record<string, unknown>;
|
|
63
|
+
}
|
|
64
|
+
interface AgentMemoryAdapter {
|
|
65
|
+
readonly id: string;
|
|
66
|
+
search(query: string, options?: AgentMemorySearchOptions): Promise<AgentMemoryHit[]>;
|
|
67
|
+
getContext(query: string, options?: AgentMemorySearchOptions): Promise<AgentMemoryContext>;
|
|
68
|
+
write(input: AgentMemoryWriteInput): Promise<AgentMemoryWriteResult>;
|
|
69
|
+
flush?(): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare function defaultGetMemoryContext(adapter: Pick<AgentMemoryAdapter, 'search'>, query: string, options?: AgentMemorySearchOptions): Promise<AgentMemoryContext>;
|
|
73
|
+
declare function renderMemoryContext(hits: AgentMemoryHit[]): string;
|
|
74
|
+
|
|
75
|
+
interface Neo4jAgentMemoryAdapterOptions {
|
|
76
|
+
client: Record<string, unknown>;
|
|
77
|
+
id?: string;
|
|
78
|
+
}
|
|
79
|
+
declare function createNeo4jAgentMemoryAdapter(options: Neo4jAgentMemoryAdapterOptions): AgentMemoryAdapter;
|
|
80
|
+
|
|
81
|
+
declare const AgentMemoryKindSchema: z.ZodEnum<{
|
|
82
|
+
preference: "preference";
|
|
83
|
+
message: "message";
|
|
84
|
+
entity: "entity";
|
|
85
|
+
fact: "fact";
|
|
86
|
+
observation: "observation";
|
|
87
|
+
"reasoning-trace": "reasoning-trace";
|
|
88
|
+
}>;
|
|
89
|
+
declare const AgentMemoryScopeSchema: z.ZodObject<{
|
|
90
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
91
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
92
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
93
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
94
|
+
tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
declare const AgentMemoryHitSchema: z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
uri: z.ZodString;
|
|
99
|
+
kind: z.ZodEnum<{
|
|
100
|
+
preference: "preference";
|
|
101
|
+
message: "message";
|
|
102
|
+
entity: "entity";
|
|
103
|
+
fact: "fact";
|
|
104
|
+
observation: "observation";
|
|
105
|
+
"reasoning-trace": "reasoning-trace";
|
|
106
|
+
}>;
|
|
107
|
+
text: z.ZodString;
|
|
108
|
+
title: z.ZodOptional<z.ZodString>;
|
|
109
|
+
score: z.ZodOptional<z.ZodNumber>;
|
|
110
|
+
normalizedScore: z.ZodOptional<z.ZodNumber>;
|
|
111
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
112
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
113
|
+
validUntil: z.ZodOptional<z.ZodString>;
|
|
114
|
+
lastVerifiedAt: z.ZodOptional<z.ZodString>;
|
|
115
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
117
|
+
declare const AgentMemoryWriteInputSchema: z.ZodObject<{
|
|
118
|
+
kind: z.ZodEnum<{
|
|
119
|
+
preference: "preference";
|
|
120
|
+
message: "message";
|
|
121
|
+
entity: "entity";
|
|
122
|
+
fact: "fact";
|
|
123
|
+
observation: "observation";
|
|
124
|
+
"reasoning-trace": "reasoning-trace";
|
|
125
|
+
}>;
|
|
126
|
+
text: z.ZodString;
|
|
127
|
+
id: z.ZodOptional<z.ZodString>;
|
|
128
|
+
title: z.ZodOptional<z.ZodString>;
|
|
129
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
130
|
+
system: "system";
|
|
131
|
+
user: "user";
|
|
132
|
+
assistant: "assistant";
|
|
133
|
+
tool: "tool";
|
|
134
|
+
}>>;
|
|
135
|
+
entityName: z.ZodOptional<z.ZodString>;
|
|
136
|
+
entityType: z.ZodOptional<z.ZodString>;
|
|
137
|
+
category: z.ZodOptional<z.ZodString>;
|
|
138
|
+
predicate: z.ZodOptional<z.ZodString>;
|
|
139
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
140
|
+
object: z.ZodOptional<z.ZodString>;
|
|
141
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
142
|
+
scope: z.ZodOptional<z.ZodObject<{
|
|
143
|
+
tenantId: z.ZodOptional<z.ZodString>;
|
|
144
|
+
userId: z.ZodOptional<z.ZodString>;
|
|
145
|
+
sessionId: z.ZodOptional<z.ZodString>;
|
|
146
|
+
namespace: z.ZodOptional<z.ZodString>;
|
|
147
|
+
tags: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
148
|
+
}, z.core.$strip>>;
|
|
149
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
150
|
+
}, z.core.$strip>;
|
|
151
|
+
|
|
152
|
+
declare function memoryHitToSourceRecord(hit: AgentMemoryHit, options?: {
|
|
153
|
+
now?: () => Date;
|
|
154
|
+
scope?: AgentMemoryScope;
|
|
155
|
+
}): SourceRecord;
|
|
156
|
+
declare function memoryWriteResultToSourceRecord(result: AgentMemoryWriteResult, text: string, options?: {
|
|
157
|
+
now?: () => Date;
|
|
158
|
+
scope?: AgentMemoryScope;
|
|
159
|
+
}): SourceRecord;
|
|
160
|
+
|
|
161
|
+
export { type AgentMemoryAdapter, type AgentMemoryContext, type AgentMemoryHit, AgentMemoryHitSchema, type AgentMemoryKind, AgentMemoryKindSchema, type AgentMemoryScope, AgentMemoryScopeSchema, type AgentMemorySearchOptions, type AgentMemoryWriteInput, AgentMemoryWriteInputSchema, type AgentMemoryWriteResult, type Neo4jAgentMemoryAdapterOptions, createNeo4jAgentMemoryAdapter, defaultGetMemoryContext, memoryHitToSourceRecord, memoryWriteResultToSourceRecord, renderMemoryContext };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AgentMemoryHitSchema,
|
|
3
|
+
AgentMemoryKindSchema,
|
|
4
|
+
AgentMemoryScopeSchema,
|
|
5
|
+
AgentMemoryWriteInputSchema,
|
|
6
|
+
createNeo4jAgentMemoryAdapter,
|
|
7
|
+
defaultGetMemoryContext,
|
|
8
|
+
memoryHitToSourceRecord,
|
|
9
|
+
memoryWriteResultToSourceRecord,
|
|
10
|
+
renderMemoryContext
|
|
11
|
+
} from "../chunk-U6KQ4FS3.js";
|
|
12
|
+
import "../chunk-YMKHCTS2.js";
|
|
13
|
+
export {
|
|
14
|
+
AgentMemoryHitSchema,
|
|
15
|
+
AgentMemoryKindSchema,
|
|
16
|
+
AgentMemoryScopeSchema,
|
|
17
|
+
AgentMemoryWriteInputSchema,
|
|
18
|
+
createNeo4jAgentMemoryAdapter,
|
|
19
|
+
defaultGetMemoryContext,
|
|
20
|
+
memoryHitToSourceRecord,
|
|
21
|
+
memoryWriteResultToSourceRecord,
|
|
22
|
+
renderMemoryContext
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/docs/architecture.md
CHANGED
|
@@ -9,7 +9,7 @@ It does not try to be a vector database, a RAG framework, or a product-specific
|
|
|
9
9
|
- claims with source references
|
|
10
10
|
- deterministic indexing, graph construction, search, and lint
|
|
11
11
|
- safe LLM write proposals
|
|
12
|
-
- eval-gated
|
|
12
|
+
- eval-gated release confidence through `@tangle-network/agent-eval`
|
|
13
13
|
- visualization DTOs under the `/viz` subpath
|
|
14
14
|
- storage contracts with memory/filesystem reference adapters
|
|
15
15
|
- discovery worker/dispatcher contracts
|
|
@@ -18,7 +18,7 @@ It does not try to be a vector database, a RAG framework, or a product-specific
|
|
|
18
18
|
|
|
19
19
|
## Boundaries
|
|
20
20
|
|
|
21
|
-
`agent-eval` owns traces, ASI,
|
|
21
|
+
`agent-eval` owns traces, ASI, improvement loops, run records, and promotion gates.
|
|
22
22
|
|
|
23
23
|
`agent-knowledge` owns sources, claims, pages, graph/search/lint, and knowledge base candidates. It calls `agent-eval` instead of reimplementing evaluation.
|
|
24
24
|
|
|
@@ -34,7 +34,7 @@ Core does not own a D1 schema or fleet dispatcher. Apps wire `KbStore` and `Know
|
|
|
34
34
|
4. Validate paths, citations, links, and schema.
|
|
35
35
|
5. Index generated knowledge pages.
|
|
36
36
|
6. Search and graph-lint the knowledge base.
|
|
37
|
-
7. Evaluate candidate KB variants with `
|
|
37
|
+
7. Evaluate candidate KB variants with an `agent-eval` improvement loop, then fold the resulting run records into release confidence with `knowledgeReleaseReport`.
|
|
38
38
|
8. Promote only variants that pass downstream gates.
|
|
39
39
|
|
|
40
40
|
## CLI
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tangle-network/agent-knowledge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Source-grounded, eval-gated knowledge growth primitives for agents.",
|
|
5
5
|
"homepage": "https://github.com/tangle-network/agent-knowledge#readme",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,11 @@
|
|
|
29
29
|
"import": "./dist/cli.js",
|
|
30
30
|
"default": "./dist/cli.js"
|
|
31
31
|
},
|
|
32
|
+
"./memory": {
|
|
33
|
+
"types": "./dist/memory/index.d.ts",
|
|
34
|
+
"import": "./dist/memory/index.js",
|
|
35
|
+
"default": "./dist/memory/index.js"
|
|
36
|
+
},
|
|
32
37
|
"./sources": {
|
|
33
38
|
"types": "./dist/sources/index.d.ts",
|
|
34
39
|
"import": "./dist/sources/index.js",
|
|
@@ -63,13 +68,14 @@
|
|
|
63
68
|
"format": "biome format --write src tests"
|
|
64
69
|
},
|
|
65
70
|
"dependencies": {
|
|
66
|
-
"@tangle-network/agent-eval": "
|
|
67
|
-
"@tangle-network/agent-runtime": "^0.
|
|
71
|
+
"@tangle-network/agent-eval": ">=0.77.0 <0.80.0",
|
|
72
|
+
"@tangle-network/agent-runtime": "^0.44.0",
|
|
68
73
|
"zod": "^4.3.6"
|
|
69
74
|
},
|
|
70
75
|
"devDependencies": {
|
|
71
76
|
"@biomejs/biome": "^2.4.15",
|
|
72
|
-
"@
|
|
77
|
+
"@neo4j-labs/agent-memory": "0.4.0",
|
|
78
|
+
"@tangle-network/sandbox": "^0.4.0",
|
|
73
79
|
"@types/node": "^25.6.0",
|
|
74
80
|
"tsup": "^8.0.0",
|
|
75
81
|
"typescript": "^5.7.0",
|
|
@@ -77,7 +83,11 @@
|
|
|
77
83
|
},
|
|
78
84
|
"pnpm": {
|
|
79
85
|
"minimumReleaseAge": 4320,
|
|
80
|
-
"minimumReleaseAgeExclude": [
|
|
86
|
+
"minimumReleaseAgeExclude": [
|
|
87
|
+
"@tangle-network/agent-eval",
|
|
88
|
+
"@tangle-network/agent-runtime",
|
|
89
|
+
"@tangle-network/sandbox"
|
|
90
|
+
]
|
|
81
91
|
},
|
|
82
92
|
"engines": {
|
|
83
93
|
"node": ">=20"
|