@framers/agentos 0.15.55 → 0.15.57
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/cognition/memory/io/ChatGptImporter.d.ts +44 -5
- package/dist/cognition/memory/io/ChatGptImporter.d.ts.map +1 -1
- package/dist/cognition/memory/io/ChatGptImporter.js +101 -24
- package/dist/cognition/memory/io/ChatGptImporter.js.map +1 -1
- package/dist/cognition/memory/io/CsvImporter.d.ts +4 -1
- package/dist/cognition/memory/io/CsvImporter.d.ts.map +1 -1
- package/dist/cognition/memory/io/CsvImporter.js +10 -5
- package/dist/cognition/memory/io/CsvImporter.js.map +1 -1
- package/dist/cognition/memory/io/JsonImporter.d.ts +37 -6
- package/dist/cognition/memory/io/JsonImporter.d.ts.map +1 -1
- package/dist/cognition/memory/io/JsonImporter.js +88 -8
- package/dist/cognition/memory/io/JsonImporter.js.map +1 -1
- package/dist/cognition/memory/io/SqliteImporter.d.ts +31 -3
- package/dist/cognition/memory/io/SqliteImporter.d.ts.map +1 -1
- package/dist/cognition/memory/io/SqliteImporter.js +72 -18
- package/dist/cognition/memory/io/SqliteImporter.js.map +1 -1
- package/dist/cognition/memory/io/facade/types.d.ts +14 -10
- package/dist/cognition/memory/io/facade/types.d.ts.map +1 -1
- package/dist/cognition/memory/io/importScope.d.ts +62 -2
- package/dist/cognition/memory/io/importScope.d.ts.map +1 -1
- package/dist/cognition/memory/io/importScope.js +82 -2
- package/dist/cognition/memory/io/importScope.js.map +1 -1
- package/dist/orchestration/checkpoint/ICheckpointStore.d.ts +13 -1
- package/dist/orchestration/checkpoint/ICheckpointStore.d.ts.map +1 -1
- package/dist/orchestration/runtime/GraphRuntime.d.ts +18 -4
- package/dist/orchestration/runtime/GraphRuntime.d.ts.map +1 -1
- package/dist/orchestration/runtime/GraphRuntime.js +84 -19
- package/dist/orchestration/runtime/GraphRuntime.js.map +1 -1
- package/package.json +1 -1
|
@@ -7,10 +7,19 @@
|
|
|
7
7
|
* ## Import strategy
|
|
8
8
|
*
|
|
9
9
|
* For each conversation object in `conversations.json`:
|
|
10
|
-
* 1.
|
|
10
|
+
* 1. The conversation has one row in the `conversations` table, named after
|
|
11
|
+
* it: `cv_chatgpt_` and the SHA-256 of the export's id for it
|
|
12
|
+
* (`conversation_id`, else `id`), else of its title and creation time. A
|
|
13
|
+
* later import of the conversation finds the row by that name, through a
|
|
14
|
+
* rename and without a `create_time` when the export names it by an id; a
|
|
15
|
+
* conversation the export names by neither gets a row of its own at each
|
|
16
|
+
* import. When the export's update time is later than the row's, the row
|
|
17
|
+
* takes it and the conversation's title.
|
|
11
18
|
* 2. Every user/assistant message pair is encoded as an **episodic memory trace**
|
|
12
19
|
* whose content is `"[user]: {user_text}\n[assistant]: {assistant_text}"`.
|
|
13
20
|
* This preserves conversational context in a single retrievable unit.
|
|
21
|
+
* With deduplication on (the default), the trace is named after the brain
|
|
22
|
+
* and its text, `mt_chatgpt_` and their SHA-256.
|
|
14
23
|
* 3. System messages and tool messages are skipped (they are not episodic memories).
|
|
15
24
|
*
|
|
16
25
|
* ## ChatGPT export format
|
|
@@ -62,14 +71,39 @@ export declare class ChatGptImporter {
|
|
|
62
71
|
/**
|
|
63
72
|
* Import a single ChatGPT conversation object.
|
|
64
73
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* into episodic
|
|
74
|
+
* Writes the conversation's `conversations` row, or finds the one it has
|
|
75
|
+
* (see `_conversationRow`), and then iterates through the message mapping in
|
|
76
|
+
* tree order (BFS), pairing adjacent user/assistant messages into episodic
|
|
77
|
+
* memory traces whose metadata names that row.
|
|
68
78
|
*
|
|
69
79
|
* @param convo - Raw ChatGPT conversation object.
|
|
70
80
|
* @param result - Mutable result accumulator.
|
|
71
81
|
*/
|
|
72
82
|
private _importConversation;
|
|
83
|
+
/**
|
|
84
|
+
* The id of a conversation's `conversations` row. A conversation the export
|
|
85
|
+
* names by an id, or by no id but with a `create_time`, has a row named after
|
|
86
|
+
* it (`conversationRowName`), which a later import of it finds by that name:
|
|
87
|
+
* through a rename and without a `create_time` when the export names it by
|
|
88
|
+
* an id. The row is written with an insert that does nothing when the brain
|
|
89
|
+
* holds a row of that name, so two imports that write one conversation's row
|
|
90
|
+
* at the same time, in one process or in two, write one row and both file
|
|
91
|
+
* under it. A row of any other name is never taken, since nothing in it says
|
|
92
|
+
* which conversation it is: the conversation gets the row it names beside it,
|
|
93
|
+
* and the pairs filed under the other keep naming that one. A conversation the
|
|
94
|
+
* export names by neither has nothing to find it by: each import writes it a
|
|
95
|
+
* row of its own. The row then takes the conversation's title and the export's
|
|
96
|
+
* update time when that update time is later than the row's. The row's
|
|
97
|
+
* metadata records the export's id as `chatgpt_id`.
|
|
98
|
+
*
|
|
99
|
+
* @param exportId - The export's id for the conversation, when it names one.
|
|
100
|
+
* @param title - The conversation's title.
|
|
101
|
+
* @param exportedCreatedAt - Its creation time in ms, when the export gives one.
|
|
102
|
+
* @param createdAt - The creation time a new row takes, in ms.
|
|
103
|
+
* @param updatedAt - Its update time, in ms.
|
|
104
|
+
* @returns The row's id.
|
|
105
|
+
*/
|
|
106
|
+
private _conversationRow;
|
|
73
107
|
/**
|
|
74
108
|
* Insert a single episodic memory trace derived from a message pair.
|
|
75
109
|
*
|
|
@@ -79,7 +113,12 @@ export declare class ChatGptImporter {
|
|
|
79
113
|
* duplicate, whichever writer stored it. `import` first files the traces an
|
|
80
114
|
* older release wrote with `scope_id` `''` under the scope id their metadata
|
|
81
115
|
* names (`fillScopeIds`), so another scope id's trace is not taken for a
|
|
82
|
-
* duplicate.
|
|
116
|
+
* duplicate. With deduplication on, the trace is named after the brain and
|
|
117
|
+
* the pair's text, and written with an insert that does nothing when the
|
|
118
|
+
* brain holds a trace of that name, so two imports that store one pair at the
|
|
119
|
+
* same time, each after finding no duplicate of it, store one trace: the
|
|
120
|
+
* import whose insert wrote nothing counts the pair as a duplicate. With it
|
|
121
|
+
* off, each import stores the pair again, under a random id.
|
|
83
122
|
*
|
|
84
123
|
* @param content - The `[user]:...\n[assistant]:...` content string.
|
|
85
124
|
* @param createdAt - Unix timestamp (ms) of the user message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatGptImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/ChatGptImporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ChatGptImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/ChatGptImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAiFzD;;;;;;;;GAQG;AACH,qBAAa,eAAe;IAId,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC;;OAEG;gBAC0B,KAAK,EAAE,KAAK;IAMzC;;;;;;OAMG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IA6C/F;;;;;;;;;;OAUG;YACW,mBAAmB;IAoGjC;;;;;;;;;;;;;;;;;;;;;;OAsBG;YACW,gBAAgB;IAkC9B;;;;;;;;;;;;;;;;;;;;OAoBG;YACW,oBAAoB;CAuDnC"}
|
|
@@ -7,10 +7,19 @@
|
|
|
7
7
|
* ## Import strategy
|
|
8
8
|
*
|
|
9
9
|
* For each conversation object in `conversations.json`:
|
|
10
|
-
* 1.
|
|
10
|
+
* 1. The conversation has one row in the `conversations` table, named after
|
|
11
|
+
* it: `cv_chatgpt_` and the SHA-256 of the export's id for it
|
|
12
|
+
* (`conversation_id`, else `id`), else of its title and creation time. A
|
|
13
|
+
* later import of the conversation finds the row by that name, through a
|
|
14
|
+
* rename and without a `create_time` when the export names it by an id; a
|
|
15
|
+
* conversation the export names by neither gets a row of its own at each
|
|
16
|
+
* import. When the export's update time is later than the row's, the row
|
|
17
|
+
* takes it and the conversation's title.
|
|
11
18
|
* 2. Every user/assistant message pair is encoded as an **episodic memory trace**
|
|
12
19
|
* whose content is `"[user]: {user_text}\n[assistant]: {assistant_text}"`.
|
|
13
20
|
* This preserves conversational context in a single retrievable unit.
|
|
21
|
+
* With deduplication on (the default), the trace is named after the brain
|
|
22
|
+
* and its text, `mt_chatgpt_` and their SHA-256.
|
|
14
23
|
* 3. System messages and tool messages are skipped (they are not episodic memories).
|
|
15
24
|
*
|
|
16
25
|
* ## ChatGPT export format
|
|
@@ -38,6 +47,33 @@ import { sha256 } from '../core/util/crossPlatformCrypto.js';
|
|
|
38
47
|
import { v4 as uuidv4 } from 'uuid';
|
|
39
48
|
import { fillScopeIds } from '../retrieval/store/migrations/v2-to-v3.js';
|
|
40
49
|
import { duplicateTraceCondition, duplicateTraceParams } from './importScope.js';
|
|
50
|
+
/** The export's id for a conversation: its `conversation_id`, else its `id`, when either is a non-empty string. */
|
|
51
|
+
function exportedConversationId(convo) {
|
|
52
|
+
for (const value of [convo.conversation_id, convo.id]) {
|
|
53
|
+
if (typeof value === 'string' && value !== '')
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The name of a conversation's `conversations` row: `cv_chatgpt_` and the SHA-256 of what names the
|
|
60
|
+
* conversation, the export's id for it, else its title and creation time. Undefined for a conversation the
|
|
61
|
+
* export names by neither, an id or a creation time.
|
|
62
|
+
*/
|
|
63
|
+
async function conversationRowName(exportId, title, exportedCreatedAt) {
|
|
64
|
+
if (exportId !== undefined)
|
|
65
|
+
return `cv_chatgpt_${await sha256(JSON.stringify(['id', exportId]))}`;
|
|
66
|
+
if (exportedCreatedAt === undefined)
|
|
67
|
+
return undefined;
|
|
68
|
+
return `cv_chatgpt_${await sha256(JSON.stringify(['title', title, exportedCreatedAt]))}`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* An insert of one row into `table` that does nothing when the brain holds a row of its primary key
|
|
72
|
+
* `(brain_id, id)`, on SQLite and PostgreSQL; any other failure, such as a missing value, still fails it.
|
|
73
|
+
*/
|
|
74
|
+
function insertUnlessHeld(table, columns, values) {
|
|
75
|
+
return `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${values.join(', ')}) ON CONFLICT (brain_id, id) DO NOTHING`;
|
|
76
|
+
}
|
|
41
77
|
// ---------------------------------------------------------------------------
|
|
42
78
|
// ChatGptImporter
|
|
43
79
|
// ---------------------------------------------------------------------------
|
|
@@ -111,9 +147,10 @@ export class ChatGptImporter {
|
|
|
111
147
|
/**
|
|
112
148
|
* Import a single ChatGPT conversation object.
|
|
113
149
|
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* into episodic
|
|
150
|
+
* Writes the conversation's `conversations` row, or finds the one it has
|
|
151
|
+
* (see `_conversationRow`), and then iterates through the message mapping in
|
|
152
|
+
* tree order (BFS), pairing adjacent user/assistant messages into episodic
|
|
153
|
+
* memory traces whose metadata names that row.
|
|
117
154
|
*
|
|
118
155
|
* @param convo - Raw ChatGPT conversation object.
|
|
119
156
|
* @param result - Mutable result accumulator.
|
|
@@ -122,21 +159,12 @@ export class ChatGptImporter {
|
|
|
122
159
|
const title = convo.title ?? 'Untitled';
|
|
123
160
|
const createdAt = convo.create_time ? Math.round(convo.create_time * 1000) : Date.now();
|
|
124
161
|
const updatedAt = convo.update_time ? Math.round(convo.update_time * 1000) : createdAt;
|
|
125
|
-
|
|
126
|
-
const conversationId = `cv_${uuidv4()}`;
|
|
162
|
+
let conversationId;
|
|
127
163
|
try {
|
|
128
|
-
|
|
129
|
-
await this.brain.run(dialect.insertOrIgnore('conversations', ['brain_id', 'id', 'title', 'created_at', 'updated_at', 'metadata'], ['?', '?', '?', '?', '?', '?']), [
|
|
130
|
-
this.brain.brainId,
|
|
131
|
-
conversationId,
|
|
132
|
-
title,
|
|
133
|
-
createdAt,
|
|
134
|
-
updatedAt,
|
|
135
|
-
JSON.stringify({ source: 'chatgpt_export' }),
|
|
136
|
-
]);
|
|
164
|
+
conversationId = await this._conversationRow(exportedConversationId(convo), title, convo.create_time ? createdAt : undefined, createdAt, updatedAt);
|
|
137
165
|
}
|
|
138
166
|
catch (err) {
|
|
139
|
-
result.errors.push(`Conversation
|
|
167
|
+
result.errors.push(`Conversation row error for "${title}": ${String(err)}`);
|
|
140
168
|
return;
|
|
141
169
|
}
|
|
142
170
|
if (!convo.mapping)
|
|
@@ -201,6 +229,46 @@ export class ChatGptImporter {
|
|
|
201
229
|
}
|
|
202
230
|
}
|
|
203
231
|
}
|
|
232
|
+
/**
|
|
233
|
+
* The id of a conversation's `conversations` row. A conversation the export
|
|
234
|
+
* names by an id, or by no id but with a `create_time`, has a row named after
|
|
235
|
+
* it (`conversationRowName`), which a later import of it finds by that name:
|
|
236
|
+
* through a rename and without a `create_time` when the export names it by
|
|
237
|
+
* an id. The row is written with an insert that does nothing when the brain
|
|
238
|
+
* holds a row of that name, so two imports that write one conversation's row
|
|
239
|
+
* at the same time, in one process or in two, write one row and both file
|
|
240
|
+
* under it. A row of any other name is never taken, since nothing in it says
|
|
241
|
+
* which conversation it is: the conversation gets the row it names beside it,
|
|
242
|
+
* and the pairs filed under the other keep naming that one. A conversation the
|
|
243
|
+
* export names by neither has nothing to find it by: each import writes it a
|
|
244
|
+
* row of its own. The row then takes the conversation's title and the export's
|
|
245
|
+
* update time when that update time is later than the row's. The row's
|
|
246
|
+
* metadata records the export's id as `chatgpt_id`.
|
|
247
|
+
*
|
|
248
|
+
* @param exportId - The export's id for the conversation, when it names one.
|
|
249
|
+
* @param title - The conversation's title.
|
|
250
|
+
* @param exportedCreatedAt - Its creation time in ms, when the export gives one.
|
|
251
|
+
* @param createdAt - The creation time a new row takes, in ms.
|
|
252
|
+
* @param updatedAt - Its update time, in ms.
|
|
253
|
+
* @returns The row's id.
|
|
254
|
+
*/
|
|
255
|
+
async _conversationRow(exportId, title, exportedCreatedAt, createdAt, updatedAt) {
|
|
256
|
+
const brainId = this.brain.brainId;
|
|
257
|
+
const named = await conversationRowName(exportId, title, exportedCreatedAt);
|
|
258
|
+
const conversationId = named ?? `cv_${uuidv4()}`;
|
|
259
|
+
await this.brain.run(insertUnlessHeld('conversations', ['brain_id', 'id', 'title', 'created_at', 'updated_at', 'metadata'], ['?', '?', '?', '?', '?', '?']), [
|
|
260
|
+
brainId,
|
|
261
|
+
conversationId,
|
|
262
|
+
title,
|
|
263
|
+
createdAt,
|
|
264
|
+
updatedAt,
|
|
265
|
+
JSON.stringify(exportId === undefined ? { source: 'chatgpt_export' } : { source: 'chatgpt_export', chatgpt_id: exportId }),
|
|
266
|
+
]);
|
|
267
|
+
if (named !== undefined) {
|
|
268
|
+
await this.brain.run('UPDATE conversations SET updated_at = ?, title = ? WHERE brain_id = ? AND id = ? AND updated_at < ?', [updatedAt, title, brainId, conversationId, updatedAt]);
|
|
269
|
+
}
|
|
270
|
+
return conversationId;
|
|
271
|
+
}
|
|
204
272
|
/**
|
|
205
273
|
* Insert a single episodic memory trace derived from a message pair.
|
|
206
274
|
*
|
|
@@ -210,7 +278,12 @@ export class ChatGptImporter {
|
|
|
210
278
|
* duplicate, whichever writer stored it. `import` first files the traces an
|
|
211
279
|
* older release wrote with `scope_id` `''` under the scope id their metadata
|
|
212
280
|
* names (`fillScopeIds`), so another scope id's trace is not taken for a
|
|
213
|
-
* duplicate.
|
|
281
|
+
* duplicate. With deduplication on, the trace is named after the brain and
|
|
282
|
+
* the pair's text, and written with an insert that does nothing when the
|
|
283
|
+
* brain holds a trace of that name, so two imports that store one pair at the
|
|
284
|
+
* same time, each after finding no duplicate of it, store one trace: the
|
|
285
|
+
* import whose insert wrote nothing counts the pair as a duplicate. With it
|
|
286
|
+
* off, each import stores the pair again, under a random id.
|
|
214
287
|
*
|
|
215
288
|
* @param content - The `[user]:...\n[assistant]:...` content string.
|
|
216
289
|
* @param createdAt - Unix timestamp (ms) of the user message.
|
|
@@ -219,8 +292,9 @@ export class ChatGptImporter {
|
|
|
219
292
|
*/
|
|
220
293
|
async _insertEpisodicTrace(content, createdAt, conversationId, result, options) {
|
|
221
294
|
const hash = await sha256(content);
|
|
295
|
+
const dedup = options?.dedup ?? true;
|
|
222
296
|
// Dedup check.
|
|
223
|
-
if (
|
|
297
|
+
if (dedup) {
|
|
224
298
|
const existing = await this.brain.get(`SELECT id FROM memory_traces
|
|
225
299
|
WHERE brain_id = ? AND scope = 'user' AND scope_id = ''
|
|
226
300
|
AND ${duplicateTraceCondition(this.brain)}
|
|
@@ -231,12 +305,12 @@ export class ChatGptImporter {
|
|
|
231
305
|
}
|
|
232
306
|
}
|
|
233
307
|
try {
|
|
234
|
-
await this.brain.run(
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
308
|
+
const written = await this.brain.run(insertUnlessHeld('memory_traces', [
|
|
309
|
+
'brain_id', 'id', 'type', 'scope', 'content', 'embedding', 'strength', 'created_at', 'last_accessed',
|
|
310
|
+
'retrieval_count', 'tags', 'emotions', 'metadata', 'deleted', 'scope_id',
|
|
311
|
+
], ['?', '?', "'episodic'", "'user'", '?', 'NULL', '1.0', '?', 'NULL', '0', "'[]'", "'{}'", '?', '0', "''"]), [
|
|
238
312
|
this.brain.brainId,
|
|
239
|
-
`mt_${uuidv4()}`,
|
|
313
|
+
dedup ? `mt_chatgpt_${await sha256(JSON.stringify([this.brain.brainId, content]))}` : `mt_${uuidv4()}`,
|
|
240
314
|
content,
|
|
241
315
|
createdAt,
|
|
242
316
|
JSON.stringify({
|
|
@@ -245,7 +319,10 @@ export class ChatGptImporter {
|
|
|
245
319
|
conversation_id: conversationId,
|
|
246
320
|
}),
|
|
247
321
|
]);
|
|
248
|
-
|
|
322
|
+
if (written.changes > 0)
|
|
323
|
+
result.imported++;
|
|
324
|
+
else
|
|
325
|
+
result.skipped++;
|
|
249
326
|
}
|
|
250
327
|
catch (err) {
|
|
251
328
|
result.errors.push(`Trace insert error: ${String(err)}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatGptImporter.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/ChatGptImporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ChatGptImporter.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/ChatGptImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AA4CjF,mHAAmH;AACnH,SAAS,sBAAsB,CAAC,KAA0B;IACxD,KAAK,MAAM,KAAK,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;QACtD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;YAAE,OAAO,KAAK,CAAC;IAC9D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,mBAAmB,CAChC,QAA4B,EAC5B,KAAa,EACb,iBAAqC;IAErC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,cAAc,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;IAClG,IAAI,iBAAiB,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACtD,OAAO,cAAc,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,KAAK,EAA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,UAAU,EAAE,YAAY,EAAE,eAAe;gBACpG,iBAAiB,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU;aACzE,EACD,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CACzG,EACD;gBACE,IAAI,CAAC,KAAK,CAAC,OAAO;gBAClB,KAAK,CAAC,CAAC,CAAC,cAAc,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,MAAM,EAAE,EAAE;gBACtG,OAAO;gBACP,SAAS;gBACT,IAAI,CAAC,SAAS,CAAC;oBACb,WAAW,EAAE,IAAI;oBACjB,MAAM,EAAE,gBAAgB;oBACxB,eAAe,EAAE,cAAc;iBAChC,CAAC;aACH,CACF,CAAC;YAEF,IAAI,OAAO,CAAC,OAAO,GAAG,CAAC;gBAAE,MAAM,CAAC,QAAQ,EAAE,CAAC;;gBACtC,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,uBAAuB,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;CACF"}
|
|
@@ -27,7 +27,10 @@
|
|
|
27
27
|
* it. An imported row stores the hash in `metadata.import_hash`. A trace a
|
|
28
28
|
* release older than `memory_traces.scope_id` wrote holds `''` in that column
|
|
29
29
|
* whatever scope id its metadata names; the import files such traces under
|
|
30
|
-
* that scope id before its first duplicate check (`fillScopeIds`).
|
|
30
|
+
* that scope id before its first duplicate check (`fillScopeIds`). The import
|
|
31
|
+
* reads the rows whose `deleted` cell is blank or zero before the others
|
|
32
|
+
* (`liveRecordsFirst`), so a text the file holds both forgotten and live
|
|
33
|
+
* arrives live.
|
|
31
34
|
*
|
|
32
35
|
* @module memory/io/CsvImporter
|
|
33
36
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CsvImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/CsvImporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CsvImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/CsvImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIzD;;GAEG;AACH,qBAAa,WAAW;IACV,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,KAAK;IAEzC;;;;;OAKG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAe/F;;;;;OAKG;IACG,gBAAgB,CACpB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC;IAKxB;;;;;;OAMG;YACW,iBAAiB;YAmIjB,OAAO;YAIP,eAAe;IAW7B,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,SAAS;IAMjB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,UAAU;IAsBlB;;;OAGG;IACH,OAAO,CAAC,SAAS;CAsElB"}
|
|
@@ -27,13 +27,16 @@
|
|
|
27
27
|
* it. An imported row stores the hash in `metadata.import_hash`. A trace a
|
|
28
28
|
* release older than `memory_traces.scope_id` wrote holds `''` in that column
|
|
29
29
|
* whatever scope id its metadata names; the import files such traces under
|
|
30
|
-
* that scope id before its first duplicate check (`fillScopeIds`).
|
|
30
|
+
* that scope id before its first duplicate check (`fillScopeIds`). The import
|
|
31
|
+
* reads the rows whose `deleted` cell is blank or zero before the others
|
|
32
|
+
* (`liveRecordsFirst`), so a text the file holds both forgotten and live
|
|
33
|
+
* arrives live.
|
|
31
34
|
*
|
|
32
35
|
* @module memory/io/CsvImporter
|
|
33
36
|
*/
|
|
34
37
|
import { sha256 } from '../core/util/crossPlatformCrypto.js';
|
|
35
38
|
import { v4 as uuidv4 } from 'uuid';
|
|
36
|
-
import { duplicateTraceCondition, duplicateTraceParams, importedScopeId } from './importScope.js';
|
|
39
|
+
import { duplicateTraceCondition, duplicateTraceParams, importedScopeId, liveRecordsFirst } from './importScope.js';
|
|
37
40
|
import { fillScopeIds } from '../retrieval/store/migrations/v2-to-v3.js';
|
|
38
41
|
/**
|
|
39
42
|
* Imports a flat CSV file into a `Brain`.
|
|
@@ -103,6 +106,8 @@ export class CsvImporter {
|
|
|
103
106
|
const tagsIndex = indexOf('tags');
|
|
104
107
|
const metadataIndex = indexOf('metadata');
|
|
105
108
|
const scopeIdIndex = indexOf('scope_id');
|
|
109
|
+
// A row's `deleted` cell as the trace stores it: blank or not a number is 0, a live trace.
|
|
110
|
+
const deletedOf = (row) => this._toInteger(deletedIndex >= 0 ? row[deletedIndex] ?? '' : '') ?? 0;
|
|
106
111
|
const brainId = this.brain.brainId;
|
|
107
112
|
const checkSql = `SELECT id
|
|
108
113
|
FROM memory_traces
|
|
@@ -117,7 +122,8 @@ export class CsvImporter {
|
|
|
117
122
|
// A trace an older release wrote holds scope_id '': filed under its scope id first, it is found there.
|
|
118
123
|
if (options?.dedup ?? true)
|
|
119
124
|
await fillScopeIds(trx, brainId);
|
|
120
|
-
|
|
125
|
+
// The live rows first, so of two rows of one text, the forgotten one is the duplicate of the live one, never the reverse.
|
|
126
|
+
for (const row of liveRecordsFirst(dataRows, (candidate) => deletedOf(candidate) !== 0)) {
|
|
121
127
|
try {
|
|
122
128
|
const content = (row[contentIndex] ?? '').trim();
|
|
123
129
|
if (!content) {
|
|
@@ -161,7 +167,6 @@ export class CsvImporter {
|
|
|
161
167
|
const rawLastAccessed = lastAccessedIndex >= 0 ? row[lastAccessedIndex] ?? '' : '';
|
|
162
168
|
const rawRetrievalCount = retrievalCountIndex >= 0 ? row[retrievalCountIndex] ?? '' : '';
|
|
163
169
|
const rawStrength = strengthIndex >= 0 ? row[strengthIndex] ?? '' : '';
|
|
164
|
-
const rawDeleted = deletedIndex >= 0 ? row[deletedIndex] ?? '' : '';
|
|
165
170
|
const preferredId = this._readCell(row, idIndex) || `mt_${uuidv4()}`;
|
|
166
171
|
const traceId = await this._resolveTraceId(trx, preferredId);
|
|
167
172
|
await trx.run(insertSql, [
|
|
@@ -176,7 +181,7 @@ export class CsvImporter {
|
|
|
176
181
|
this._toInteger(rawRetrievalCount) ?? 0,
|
|
177
182
|
JSON.stringify(this._parseTags(tagsIndex >= 0 ? row[tagsIndex] ?? '' : '')),
|
|
178
183
|
JSON.stringify(metadata),
|
|
179
|
-
|
|
184
|
+
deletedOf(row),
|
|
180
185
|
scopeId,
|
|
181
186
|
]);
|
|
182
187
|
result.imported++;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CsvImporter.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/CsvImporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"CsvImporter.js","sourceRoot":"","sources":["../../../../src/cognition/memory/io/CsvImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAGpC,OAAO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;gBACjB,QAAQ,GAAG,IAAI,CAAC;gBAChB,SAAS;YACX,CAAC;YAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;gBACjB,SAAS,EAAE,CAAC;gBACZ,SAAS;YACX,CAAC;YAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI;oBAAE,CAAC,EAAE,CAAC;gBAC/B,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,SAAS;YACX,CAAC;YAED,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAClB,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,SAAS;YACX,CAAC;YAED,KAAK,IAAI,IAAI,CAAC;QAChB,CAAC;QAED,SAAS,EAAE,CAAC;QACZ,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACnB,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
* `{ dedup: false }` on the importer or `Memory.importFrom`. A trace a release
|
|
13
13
|
* older than `memory_traces.scope_id` wrote holds `''` in that column whatever
|
|
14
14
|
* scope id its metadata names; the import files such traces under that scope
|
|
15
|
-
* id before its first duplicate check (`fillScopeIds`).
|
|
15
|
+
* id before its first duplicate check (`fillScopeIds`). The import reads the
|
|
16
|
+
* file's live trace records before its forgotten ones (`liveRecordsFirst`), so
|
|
17
|
+
* a text the file holds both forgotten and live arrives live. A trace's
|
|
18
|
+
* memory-graph node comes in with its trace alone, under its trace's id
|
|
19
|
+
* (`memoryGraphNodeImport`): the node of a record merged into another trace is
|
|
20
|
+
* skipped, with the edges that name it.
|
|
16
21
|
*
|
|
17
22
|
* @module memory/io/JsonImporter
|
|
18
23
|
*/
|
|
@@ -46,8 +51,13 @@ export declare class JsonImporter {
|
|
|
46
51
|
* `content` is the record's, or whose metadata names the SHA-256 of that
|
|
47
52
|
* text as `import_hash` or `content_hash`, makes the record a duplicate,
|
|
48
53
|
* and it is skipped; a row of another scope id is not a duplicate.
|
|
49
|
-
* - For `knowledge_nodes`: SHA-256 of `label` + `type`.
|
|
50
|
-
*
|
|
54
|
+
* - For `knowledge_nodes`: SHA-256 of `label` + `type`. A memory-graph node
|
|
55
|
+
* (`type` `memory_graph`) is its trace's node instead: it is written
|
|
56
|
+
* under its trace's id for a trace the import wrote or matched under that
|
|
57
|
+
* id, is the duplicate of the node the brain holds under that id, or is
|
|
58
|
+
* skipped (see `memoryGraphNodeImport`).
|
|
59
|
+
* - For `knowledge_edges`: SHA-256 of `source_id` + `target_id` + `type`. An
|
|
60
|
+
* edge that names a memory-graph node the import skipped is skipped.
|
|
51
61
|
*
|
|
52
62
|
* @param sourcePath - Absolute path to the JSON file to import.
|
|
53
63
|
* @returns `ImportResult` with counts of imported, skipped, and errored items.
|
|
@@ -88,7 +98,10 @@ export declare class JsonImporter {
|
|
|
88
98
|
* Each trace is filed under its scope and scope id (see `importedScopeId`)
|
|
89
99
|
* and deduplicated inside them (see `duplicateTraceCondition`): if a trace of
|
|
90
100
|
* the same scope and scope id holds the record's text, or names its hash, the
|
|
91
|
-
* record is skipped and its id maps to that trace's.
|
|
101
|
+
* record is skipped and its id maps to that trace's. The live records are
|
|
102
|
+
* read before the forgotten ones (see `liveRecordsFirst`), so of two records
|
|
103
|
+
* of one text, the forgotten one is the duplicate of the live one, never the
|
|
104
|
+
* reverse.
|
|
92
105
|
*
|
|
93
106
|
* @param trx - Transactional storage adapter.
|
|
94
107
|
* @param traces - Array of serialised trace objects from the export.
|
|
@@ -98,18 +111,36 @@ export declare class JsonImporter {
|
|
|
98
111
|
/**
|
|
99
112
|
* Import knowledge node records into `knowledge_nodes`.
|
|
100
113
|
*
|
|
101
|
-
* Dedup key: SHA-256 of `label` concatenated with `type`.
|
|
114
|
+
* Dedup key: SHA-256 of `label` concatenated with `type`. A memory-graph
|
|
115
|
+
* node comes in with its trace alone, under its trace's id (see
|
|
116
|
+
* `_importMemoryGraphNode`).
|
|
102
117
|
*
|
|
103
118
|
* @param trx - Transactional storage adapter.
|
|
104
119
|
* @param nodes - Array of serialised node objects.
|
|
105
120
|
* @param result - Mutable `ImportResult` to accumulate counts.
|
|
106
121
|
*/
|
|
107
122
|
private _importNodes;
|
|
123
|
+
/**
|
|
124
|
+
* Import a memory-graph node record (`type` `memory_graph`), the node of the
|
|
125
|
+
* trace whose id it carries. It comes in with its trace alone and under that
|
|
126
|
+
* id (see `memoryGraphNodeImport`): written under that id, the duplicate of
|
|
127
|
+
* the node the brain holds under it, whose id the record's edges then name,
|
|
128
|
+
* or skipped, and then the edges that name it are skipped too.
|
|
129
|
+
*
|
|
130
|
+
* @param trx - Transactional storage adapter.
|
|
131
|
+
* @param n - The node record.
|
|
132
|
+
* @param result - Mutable `ImportResult` to accumulate counts.
|
|
133
|
+
* @param context - The import's id maps and the payload's trace ids.
|
|
134
|
+
* @param insertSql - The statement that inserts a knowledge node.
|
|
135
|
+
*/
|
|
136
|
+
private _importMemoryGraphNode;
|
|
108
137
|
/**
|
|
109
138
|
* Import knowledge edge records into `knowledge_edges`.
|
|
110
139
|
*
|
|
111
140
|
* Dedup key: SHA-256 of `source_id + target_id + type`.
|
|
112
|
-
* Edges referencing non-existent nodes are silently skipped (FK constraint)
|
|
141
|
+
* Edges referencing non-existent nodes are silently skipped (FK constraint),
|
|
142
|
+
* and an edge that names a memory-graph node the node import skipped is
|
|
143
|
+
* skipped.
|
|
113
144
|
*
|
|
114
145
|
* @param trx - Transactional storage adapter.
|
|
115
146
|
* @param edges - Array of serialised edge objects.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"JsonImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/JsonImporter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"JsonImporter.d.ts","sourceRoot":"","sources":["../../../../src/cognition/memory/io/JsonImporter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAuJzD;;;;;;;;;GASG;AACH,qBAAa,YAAY;IAIX,OAAO,CAAC,QAAQ,CAAC,KAAK;IAHlC;;OAEG;gBAC0B,KAAK,EAAE,KAAK;IAMzC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAgB/F;;;;;OAKG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,GACrC,OAAO,CAAC,YAAY,CAAC;IAKxB;;;;;;OAMG;YACW,aAAa;IAoD3B;;;;;;OAMG;YACW,OAAO;IAIrB;;;;OAIG;YACW,WAAW;IAmBzB;;;;;;;;;;;;;;OAcG;YACW,aAAa;IAqF3B;;;;;;;;;;OAUG;YACW,YAAY;IAoE1B;;;;;;;;;;;;OAYG;YACW,sBAAsB;IA6CpC;;;;;;;;;;;OAWG;YACW,YAAY;IAsE1B;;;;OAIG;YACW,gBAAgB;IA8C9B;;OAEG;YACW,aAAa;IA0D3B;;OAEG;YACW,aAAa;IAwD3B;;;;;OAKG;YACW,oBAAoB;IA4ClC;;OAEG;YACW,eAAe;YA8Cf,gBAAgB;CAY/B"}
|