@supermemory/tools
Advanced tools
@@ -1,2 +0,2 @@ | ||
| import{deduplicateMemories as e}from"../shared.js";import{convertProfileToMarkdown as t}from"./util.js";const n=e=>e?e.endsWith(`/`)?e.slice(0,-1):e:`https://api.supermemory.ai`,r=async(e,t,n)=>{let r=t?JSON.stringify({q:t,containerTag:e}):JSON.stringify({containerTag:e});try{let e=await fetch(`${n}/v4/profile`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${process.env.SUPERMEMORY_API_KEY}`},body:r});if(!e.ok){let t=await e.text().catch(()=>`Unknown error`);throw Error(`Supermemory profile search failed: ${e.status} ${e.statusText}. ${t}`)}return await e.json()}catch(e){throw e instanceof Error?e:Error(`Supermemory API request failed: ${e}`)}},i=async(n,i,a,o,s=`https://api.supermemory.ai`)=>{let c=n.prompt.some(e=>e.role===`system`),l=o===`profile`?``:n.prompt.slice().reverse().find(e=>e.role===`user`)?.content?.filter(e=>e.type===`text`)?.map(e=>e.type===`text`?e.text:``)?.join(` `)||``,u=await r(i,l,s),d=u.profile.static?.length||0,f=u.profile.dynamic?.length||0;a.info(`Memory search completed`,{containerTag:i,memoryCountStatic:d,memoryCountDynamic:f,queryText:l.substring(0,100)+(l.length>100?`...`:``),mode:o});let p=e({static:u.profile.static,dynamic:u.profile.dynamic,searchResults:u.searchResults.results});a.debug(`Memory deduplication completed`,{static:{original:d,deduplicated:p.static.length},dynamic:{original:f,deduplicated:p.dynamic.length},searchResults:{original:u.searchResults.results.length,deduplicated:p.searchResults.length}});let m=`User Supermemories: \n${o===`query`?``:t({profile:{static:p.static,dynamic:p.dynamic},searchResults:{results:[]}})}\n${o===`profile`?``:`Search results for user's recent message: \n${p.searchResults.map(e=>`- ${e}`).join(` | ||
| import{deduplicateMemories as e}from"../shared.js";import{convertProfileToMarkdown as t}from"./util.js";const n=e=>e?e.endsWith(`/`)?e.slice(0,-1):e:`https://api.supermemory.ai`,r=async(e,t,n)=>{let r=t?JSON.stringify({q:t,containerTag:e}):JSON.stringify({containerTag:e});try{let e=await fetch(`${n}/v4/profile`,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${process.env.SUPERMEMORY_API_KEY}`},body:r});if(!e.ok){let t=await e.text().catch(()=>`Unknown error`);throw Error(`Supermemory profile search failed: ${e.status} ${e.statusText}. ${t}`)}return await e.json()}catch(e){throw e instanceof Error?e:Error(`Supermemory API request failed: ${e}`)}},i=async(n,i,a,o,s=`https://api.supermemory.ai`)=>{let c=n.prompt.some(e=>e.role===`system`),l=o===`profile`?``:n.prompt.slice().reverse().find(e=>e.role===`user`)?.content?.filter(e=>e.type===`text`)?.map(e=>e.type===`text`?e.text:``)?.join(` `)||``,u=await r(i,l,s),d=u.profile.static?.length||0,f=u.profile.dynamic?.length||0;a.info(`Memory search completed`,{containerTag:i,memoryCountStatic:d,memoryCountDynamic:f,queryText:l.substring(0,100)+(l.length>100?`...`:``),mode:o});let p=e({static:u.profile.static,dynamic:u.profile.dynamic,searchResults:u.searchResults?.results});a.debug(`Memory deduplication completed`,{static:{original:d,deduplicated:p.static.length},dynamic:{original:f,deduplicated:p.dynamic.length},searchResults:{original:u.searchResults.results.length,deduplicated:p.searchResults?.length}});let m=`User Supermemories: \n${o===`query`?``:t({profile:{static:p.static,dynamic:p.dynamic},searchResults:{results:[]}})}\n${o===`profile`?``:`Search results for user's recent message: \n${p.searchResults.map(e=>`- ${e}`).join(` | ||
| `)}`}`.trim();return m&&a.debug(`Memory content preview`,{content:m,fullLength:m.length}),c?(a.debug(`Added memories to existing system prompt`),{...n,prompt:n.prompt.map(e=>e.role===`system`?{...e,content:`${e.content} \n ${m}`}:e)}):(a.debug(`System prompt does not exist, created system prompt with memories`),{...n,prompt:[{role:`system`,content:m},...n.prompt]})};export{i as addSystemPrompt,n as normalizeBaseUrl}; |
+1
-1
| { | ||
| "name": "@supermemory/tools", | ||
| "type": "module", | ||
| "version": "1.3.60", | ||
| "version": "1.3.61", | ||
| "description": "Memory tools for AI SDK and OpenAI function calling with supermemory", | ||
@@ -6,0 +6,0 @@ "scripts": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
61657
0