mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-05 08:06:19 +00:00
adds withSupermemory wrapper and input/output processors for
mastra agents:
- input processor fetches and injects memories into system prompt
before llm calls
- output processor saves conversations to supermemory after
responses
- supports profile, query, and full memory search modes
- includes custom prompt templates and requestcontext support
const agent = new Agent(withSupermemory(
{ id: "my-assistant", model: openai("gpt-4o"), instructions:
"..." },
"user-123",
{ mode: "full", addMemory: "always", threadId: "conv-456" }
))
includes docs as well
this pr also reworks how the tools package works into shared modules
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import type { Logger } from "./types"
|
|
|
|
/**
|
|
* Creates a logger instance that outputs to console when verbose mode is enabled.
|
|
*
|
|
* @param verbose - When true, logs are written to console; when false, logs are silently ignored
|
|
* @returns Logger instance with debug, info, warn, and error methods
|
|
*/
|
|
export const createLogger = (verbose: boolean): Logger => {
|
|
if (!verbose) {
|
|
return {
|
|
debug: () => {},
|
|
info: () => {},
|
|
warn: () => {},
|
|
error: () => {},
|
|
}
|
|
}
|
|
|
|
return {
|
|
debug: (message: string, data?: unknown) => {
|
|
console.log(
|
|
`[supermemory] ${message}`,
|
|
data ? JSON.stringify(data, null, 2) : "",
|
|
)
|
|
},
|
|
info: (message: string, data?: unknown) => {
|
|
console.log(
|
|
`[supermemory] ${message}`,
|
|
data ? JSON.stringify(data, null, 2) : "",
|
|
)
|
|
},
|
|
warn: (message: string, data?: unknown) => {
|
|
console.warn(
|
|
`[supermemory] ${message}`,
|
|
data ? JSON.stringify(data, null, 2) : "",
|
|
)
|
|
},
|
|
error: (message: string, data?: unknown) => {
|
|
console.error(
|
|
`[supermemory] ${message}`,
|
|
data ? JSON.stringify(data, null, 2) : "",
|
|
)
|
|
},
|
|
}
|
|
}
|