mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-08-28 05:25:33 +00:00
Co-authored-by: Prasanna <106952318+Prasanna721@users.noreply.github.com> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: ved015 <vedant.04.mahajan@gmail.com> Co-authored-by: ved015 <ved015@users.noreply.github.com> Co-authored-by: Ishaan Gupta <ishaankone@gmail.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
54 lines
1.4 KiB
TypeScript
54 lines
1.4 KiB
TypeScript
import { z } from "zod"
|
|
import type { ViewMessage } from "../../shared/types"
|
|
import { appResultMeta, appToolMeta } from "../app-metadata"
|
|
import { effectiveContainerTagAccess } from "../auth/rbac"
|
|
import type { ToolDeps } from "./types"
|
|
|
|
export function register(deps: ToolDeps) {
|
|
deps.server.registerTool(
|
|
"guided-save",
|
|
{
|
|
title: "Add Memory",
|
|
description: "Save information to memory with an interactive form.",
|
|
inputSchema: z.object({
|
|
prefill: z.string().optional().describe("Optional content to prefill"),
|
|
}),
|
|
_meta: appToolMeta(),
|
|
},
|
|
async (args) => {
|
|
try {
|
|
const { prefill } = args
|
|
const viewId = crypto.randomUUID()
|
|
const [activeTag, tags, session] = await Promise.all([
|
|
deps.getActiveContainerTag(),
|
|
deps.getClient().listContainerTags(),
|
|
deps.getSession(),
|
|
])
|
|
const writableTags = effectiveContainerTagAccess(
|
|
tags.map((tag) => tag.containerTag),
|
|
session,
|
|
)
|
|
.filter((access) => access.permission === "write")
|
|
.map((access) => access.containerTag)
|
|
|
|
const sc: ViewMessage = {
|
|
view: "save",
|
|
viewId,
|
|
activeTag,
|
|
writableTags,
|
|
prefill,
|
|
}
|
|
|
|
return {
|
|
content: [
|
|
{ type: "text" as const, text: "Opening memory save form..." },
|
|
],
|
|
structuredContent: sc,
|
|
_meta: appResultMeta(viewId),
|
|
}
|
|
} catch (error) {
|
|
return deps.errorResult(error)
|
|
}
|
|
},
|
|
)
|
|
}
|