MCPcopy Create free account
hub / github.com/MemTensor/MemOS / insertChunk

Method insertChunk

packages/memos-core/src/storage/sqlite.ts:1141–1164  ·  view source on GitHub ↗
(chunk: Chunk)

Source from the content-addressed store, hash-verified

1139 // ─── Write ───
1140
1141 insertChunk(chunk: Chunk): void {
1142 const stmt = this.db.prepare(`
1143 INSERT OR REPLACE INTO chunks (id, session_key, turn_id, seq, role, content, kind, summary, task_id, content_hash, owner, dedup_status, dedup_target, dedup_reason, created_at, updated_at)
1144 VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
1145 `);
1146 stmt.run(
1147 chunk.id,
1148 chunk.sessionKey,
1149 chunk.turnId,
1150 chunk.seq,
1151 chunk.role,
1152 chunk.content,
1153 chunk.kind,
1154 chunk.summary,
1155 chunk.taskId,
1156 contentHash(chunk.content),
1157 chunk.owner ?? "agent:main",
1158 chunk.dedupStatus ?? "active",
1159 chunk.dedupTarget ?? null,
1160 chunk.dedupReason ?? null,
1161 chunk.createdAt,
1162 chunk.updatedAt,
1163 );
1164 }
1165
1166 markDedupStatus(chunkId: string, status: "duplicate" | "merged", targetChunkId: string | null, reason: string): void {
1167 this.db.prepare(

Callers 3

storeChunkMethod · 0.45
runMigrationMethod · 0.45
importAgentMethod · 0.45

Calls 3

prepareMethod · 0.80
contentHashFunction · 0.70
runMethod · 0.65

Tested by

no test coverage detected