@tangle-network/agent-knowledge 1.6.0 → 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/README.md +37 -0
- package/dist/chunk-U6KQ4FS3.js +585 -0
- package/dist/chunk-U6KQ4FS3.js.map +1 -0
- package/dist/index.d.ts +1 -0
- 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/package.json +7 -1
|
@@ -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/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",
|
|
@@ -69,6 +74,7 @@
|
|
|
69
74
|
},
|
|
70
75
|
"devDependencies": {
|
|
71
76
|
"@biomejs/biome": "^2.4.15",
|
|
77
|
+
"@neo4j-labs/agent-memory": "0.4.0",
|
|
72
78
|
"@tangle-network/sandbox": "^0.4.0",
|
|
73
79
|
"@types/node": "^25.6.0",
|
|
74
80
|
"tsup": "^8.0.0",
|