Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { supermemoryClient } from "./services/client.js";
import { formatContextForPrompt } from "./services/context.js";
import { getTags } from "./services/tags.js";
import { stripPrivateContent, isFullyPrivate } from "./services/privacy.js";
import { createCompactionHook, type CompactionContext } from "./services/compaction.js";
import { createCompactionHook, generatePartId, type CompactionContext } from "./services/compaction.js";

import { isConfigured, CONFIG } from "./config.js";
import { log } from "./services/logger.js";
Expand Down Expand Up @@ -112,7 +112,7 @@ export const SupermemoryPlugin: Plugin = async (ctx: PluginInput) => {
if (detectMemoryKeyword(userMessage)) {
log("chat.message: memory keyword detected");
const nudgePart: Part = {
id: `supermemory-nudge-${Date.now()}`,
id: generatePartId(),
sessionID: input.sessionID,
messageID: output.message.id,
type: "text",
Expand Down Expand Up @@ -157,7 +157,7 @@ export const SupermemoryPlugin: Plugin = async (ctx: PluginInput) => {

if (memoryContext) {
const contextPart: Part = {
id: `supermemory-context-${Date.now()}`,
id: generatePartId(),
sessionID: input.sessionID,
messageID: output.message.id,
type: "text",
Expand Down
2 changes: 1 addition & 1 deletion src/services/compaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function generateMessageId(): string {
return `msg_${timestamp}${random}`;
}

function generatePartId(): string {
export function generatePartId(): string {
const timestamp = Date.now().toString(16);
const random = Math.random().toString(36).substring(2, 10);
return `prt_${timestamp}${random}`;
Expand Down