Skip to content
Merged
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
.open-next/
.sentryclirc
drizzle.config.ts

# Dependencies
node_modules
Expand Down Expand Up @@ -40,4 +41,4 @@ yarn-error.log*
*.pem

.venv
__pycache__
__pycache__
41 changes: 37 additions & 4 deletions apps/browser-extension/entrypoints/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineBackground(() => {
browser.runtime.onInstalled.addListener(async (details) => {
browser.contextMenus.create({
id: CONTEXT_MENU_IDS.SAVE_TO_SUPERMEMORY,
title: "Save to supermemory",
title: "sync to supermemory",
contexts: ["selection", "page", "link"],
})

Expand Down Expand Up @@ -114,7 +114,9 @@ export default defineBackground(() => {

const payload: MemoryPayload = {
containerTags: [containerTag],
content: `${data.highlightedText}\n\n${data.html}\n\n${data?.url}`,
content:
data.content ||
`${data.highlightedText}\n\n${data.html}\n\n${data?.url}`,
metadata: { sm_source: "consumer" },
}

Expand Down Expand Up @@ -144,9 +146,9 @@ export default defineBackground(() => {
const response = responseData as {
results?: Array<{ memory?: string }>
}
let memories = ""
const memories: string[] = []
response.results?.forEach((result, index) => {
memories += `[${index + 1}] ${result.memory} `
memories.push(`${index + 1}. ${result.memory} \n`)
})
console.log("Memories:", memories)
await trackEvent(eventSource)
Expand Down Expand Up @@ -216,6 +218,37 @@ export default defineBackground(() => {
})()
return true
}

if (message.action === MESSAGE_TYPES.CAPTURE_PROMPT) {
;(async () => {
try {
const messageData = message.data as {
prompt: string
platform: string
source: string
}
console.log("=== PROMPT CAPTURED ===")
console.log(messageData)
console.log("========================")

const memoryData: MemoryData = {
content: messageData.prompt,
}

const result = await saveMemoryToSupermemory(
memoryData,
`prompt_capture_${messageData.platform}`,
)
sendResponse(result)
} catch (error) {
sendResponse({
success: false,
error: error instanceof Error ? error.message : "Unknown error",
})
}
})()
return true
}
},
)
})
Loading
Loading