paperclip-plugin-supermemory-otomatik 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/ui/index.tsx", "../../src/manifest.ts"],
4
- "sourcesContent": ["import { useCallback, useEffect, useState, type CSSProperties, type DragEvent, type ChangeEvent, type FormEvent } from \"react\";\nimport {\n MarkdownBlock,\n useHostContext,\n useHostNavigation,\n usePluginAction,\n usePluginToast,\n type PluginSidebarProps,\n} from \"@paperclipai/plugin-sdk/ui\";\nimport { PLUGIN_ID } from \"../manifest.js\";\n\ntype AgentInfo = { id: string; name: string; role: string; status: string };\ntype ProjectInfo = { id: string; name: string; visibility?: string };\ntype SecretInfo = { id: string; name: string; key?: string; status?: string };\ntype SecretRef = { type: \"secret_ref\"; secretId: string };\ntype GrantForm = { key: string; agentId: string; tokenSecretId: string };\ntype GrantConfig = { agentId: string; tokenRef: SecretRef };\ntype PluginConfig = {\n gatewayUrl: string;\n localApiUrl: string;\n adminApiKeyRef?: SecretRef;\n agentGrants: GrantConfig[];\n};\ntype NamespaceAssignment = {\n id: string;\n companyId: string;\n scopeType: \"agent\" | \"project\";\n scopeId: string;\n label: string;\n namespace: string;\n authorizedAgentIds: string[];\n};\ntype MemoryDocument = {\n id: string;\n namespace: string;\n assignmentId: string;\n title: string;\n kind: \"text\" | \"url\" | \"file\";\n mimeType: string | null;\n fileName: string | null;\n sourceUrl: string | null;\n status: string;\n content?: string | null;\n createdAt: string;\n updatedAt: string;\n};\ntype Catalog = {\n assignments: NamespaceAssignment[];\n documents: MemoryDocument[];\n agents: AgentInfo[];\n projects: ProjectInfo[];\n configured: boolean;\n localApiUrl: string;\n};\ntype AgentAccess = { subjectType: \"agent\" | \"user\"; subjectId: string; subjectDisplayName?: string | null };\n\nconst DEFAULT_GATEWAY = \"http://127.0.0.1:6768/mcp\";\nconst DEFAULT_LOCAL_API = \"http://127.0.0.1:6767\";\nconst CONFIG_PATH = `/api/plugins/${encodeURIComponent(PLUGIN_ID)}/config`;\nconst BINARY_MAX_BYTES = 6 * 1024 * 1024;\nconst TEXT_EXTENSIONS = new Set([\"txt\", \"md\", \"markdown\", \"html\", \"htm\", \"json\", \"csv\"]);\nconst BINARY_TYPES = new Map<string, string>([\n [\"pdf\", \"application/pdf\"], [\"png\", \"image/png\"], [\"jpg\", \"image/jpeg\"], [\"jpeg\", \"image/jpeg\"],\n [\"gif\", \"image/gif\"], [\"webp\", \"image/webp\"],\n]);\n\nasync function hostFetchJson<T>(path: string, init: RequestInit = {}): Promise<T> {\n const headers = new Headers(init.headers ?? undefined);\n if (init.body && !(init.body instanceof FormData) && !headers.has(\"content-type\")) headers.set(\"content-type\", \"application/json\");\n const response = await fetch(path, { credentials: \"include\", ...init, headers });\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n let message = text || `Richiesta non riuscita (HTTP ${response.status}).`;\n try { message = String((JSON.parse(text) as { error?: string }).error ?? message); } catch { /* keep response text */ }\n throw new Error(message);\n }\n return await response.json() as T;\n}\n\nfunction secretId(value: unknown): string {\n return typeof value === \"object\" && value !== null && (value as { type?: unknown }).type === \"secret_ref\"\n && typeof (value as { secretId?: unknown }).secretId === \"string\" ? (value as { secretId: string }).secretId : \"\";\n}\n\nfunction displayError(value: unknown): string {\n if (value instanceof Error) return value.message;\n if (typeof value === \"string\") return value;\n if (value && typeof value === \"object\") {\n const error = value as { message?: unknown; code?: unknown; details?: unknown };\n if (typeof error.message === \"string\" && error.message.trim()) return error.message;\n if (typeof error.details === \"string\" && error.details.trim()) return error.details;\n if (typeof error.code === \"string\" && error.code.trim()) return `Operazione non riuscita (${error.code}).`;\n }\n return \"Operazione non riuscita. Riprova o controlla la configurazione del plugin.\";\n}\n\nfunction pluginConfig(configJson?: Record<string, unknown> | null): PluginConfig {\n const config = configJson ?? {};\n const grants: GrantConfig[] = Array.isArray(config.agentGrants) ? config.agentGrants.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") return [];\n const row = entry as Record<string, unknown>;\n if (typeof row.agentId !== \"string\" || !row.agentId) return [];\n const token = secretId(row.tokenRef);\n return token ? [{ agentId: row.agentId, tokenRef: { type: \"secret_ref\", secretId: token } }] : [];\n }) : [];\n const adminRef = secretId(config.adminApiKeyRef);\n return {\n gatewayUrl: typeof config.gatewayUrl === \"string\" ? config.gatewayUrl : DEFAULT_GATEWAY,\n localApiUrl: typeof config.localApiUrl === \"string\" ? config.localApiUrl : DEFAULT_LOCAL_API,\n ...(adminRef ? { adminApiKeyRef: { type: \"secret_ref\", secretId: adminRef } } : {}),\n agentGrants: grants,\n };\n}\n\nconst pageStyle: CSSProperties = { padding: 24, width: \"100%\", maxWidth: 1480, margin: \"0 auto\", color: \"var(--foreground)\" };\nconst panelStyle: CSSProperties = { border: \"1px solid var(--border)\", borderRadius: 10, background: \"var(--card, transparent)\" };\nconst mutedStyle: CSSProperties = { color: \"var(--muted-foreground)\" };\nconst inputStyle: CSSProperties = { width: \"100%\", border: \"1px solid var(--border)\", borderRadius: 7, background: \"var(--background)\", color: \"var(--foreground)\", padding: \"9px 11px\", minHeight: 38 };\nconst primaryButtonStyle: CSSProperties = { border: \"1px solid var(--primary)\", borderRadius: 7, background: \"var(--primary)\", color: \"var(--primary-foreground, white)\", padding: \"9px 14px\", fontWeight: 600, cursor: \"pointer\" };\nconst secondaryButtonStyle: CSSProperties = { border: \"1px solid var(--border)\", borderRadius: 7, background: \"transparent\", color: \"var(--foreground)\", padding: \"8px 12px\", cursor: \"pointer\" };\n\nexport function SupermemorySettingsPage() {\n const { companyId } = useHostContext();\n const [agents, setAgents] = useState<AgentInfo[]>([]);\n const [secrets, setSecrets] = useState<SecretInfo[]>([]);\n const [config, setConfig] = useState<PluginConfig>({ gatewayUrl: DEFAULT_GATEWAY, localApiUrl: DEFAULT_LOCAL_API, agentGrants: [] });\n const [grantRows, setGrantRows] = useState<GrantForm[]>([]);\n const [loading, setLoading] = useState(true);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState(false);\n\n useEffect(() => {\n let cancelled = false;\n if (!companyId) { setLoading(false); setError(\"Seleziona un\u2019organizzazione.\"); return; }\n setLoading(true);\n const load = async () => {\n const [configResponse, agentResponse, secretResponse] = await Promise.all([\n hostFetchJson<{ configJson?: Record<string, unknown> | null } | null>(`${CONFIG_PATH}?companyId=${encodeURIComponent(companyId)}`),\n hostFetchJson<AgentInfo[]>(`/api/companies/${encodeURIComponent(companyId)}/agents`),\n hostFetchJson<SecretInfo[]>(`/api/companies/${encodeURIComponent(companyId)}/secrets`),\n ]);\n if (cancelled) return;\n const loadedConfig = pluginConfig(configResponse?.configJson);\n setConfig(loadedConfig);\n setGrantRows(loadedConfig.agentGrants.map((grant, index) => ({ key: `grant-${index}-${grant.agentId}`, agentId: grant.agentId, tokenSecretId: secretId(grant.tokenRef) })));\n setAgents(agentResponse.filter((agent) => ![\"terminated\", \"pending_approval\"].includes(agent.status)));\n setSecrets(secretResponse.filter((secret) => secret.status !== \"deleted\"));\n setError(null);\n };\n void load().catch((cause: unknown) => { if (!cancelled) setError(displayError(cause)); })\n .finally(() => { if (!cancelled) setLoading(false); });\n return () => { cancelled = true; };\n }, [companyId]);\n\n function updateGrant(index: number, patch: Partial<GrantForm>) {\n const next = grantRows.map((row, rowIndex) => rowIndex === index ? { ...row, ...patch } : row);\n setGrantRows(next);\n }\n\n function addGrant() {\n setGrantRows((current) => [...current, { key: `grant-new-${Date.now()}`, agentId: \"\", tokenSecretId: \"\" }]);\n }\n\n function removeGrant(index: number) {\n setGrantRows((current) => current.filter((_, rowIndex) => rowIndex !== index));\n }\n\n async function save(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n if (!companyId) return;\n setSaving(true); setError(null); setSuccess(false);\n try {\n if (grantRows.some((row) => Boolean(row.agentId) !== Boolean(row.tokenSecretId))) throw new Error(\"Completa sia l\u2019agente sia il secret ACL per ogni riga.\");\n const cleaned = grantRows.filter((row) => row.agentId && row.tokenSecretId);\n if (cleaned.some((row, index) => cleaned.findIndex((candidate) => candidate.agentId === row.agentId) !== index)) {\n throw new Error(\"Ogni agente pu\u00F2 comparire una sola volta.\");\n }\n const nextConfig: Record<string, unknown> = {\n gatewayUrl: config.gatewayUrl.trim() || DEFAULT_GATEWAY,\n localApiUrl: config.localApiUrl.trim() || DEFAULT_LOCAL_API,\n agentGrants: cleaned.map((row) => ({ agentId: row.agentId, tokenRef: { type: \"secret_ref\", secretId: row.tokenSecretId } })),\n };\n if (config.adminApiKeyRef?.secretId) nextConfig.adminApiKeyRef = config.adminApiKeyRef;\n await hostFetchJson(CONFIG_PATH, { method: \"POST\", body: JSON.stringify({ companyId, configJson: nextConfig }) });\n setConfig(pluginConfig(nextConfig));\n setGrantRows(cleaned.map((row, index) => ({ key: `grant-${index}-${row.agentId}`, agentId: row.agentId, tokenSecretId: row.tokenSecretId })));\n setSuccess(true);\n } catch (cause) { setError(displayError(cause)); }\n finally { setSaving(false); }\n }\n\n if (loading) return <main style={pageStyle}><p>Caricamento configurazione\u2026</p></main>;\n return (\n <main style={{ ...pageStyle, maxWidth: 1000, display: \"grid\", gap: 22 }}>\n <header>\n <h1 style={{ fontSize: 25, margin: 0, fontWeight: 650 }}>Configurazione Supermemory</h1>\n <p style={{ ...mutedStyle, marginTop: 8, maxWidth: 760 }}>Scegli gli agenti Paperclip dall\u2019elenco e collega per ciascuno il suo secret ACL. Le chiavi restano nei Secrets Paperclip: non vengono mostrate n\u00E9 copiate nei prompt.</p>\n </header>\n {error ? <div role=\"alert\" style={{ ...panelStyle, padding: 12, borderColor: \"var(--destructive, #b91c1c)\" }}>{error}</div> : null}\n {success ? <div role=\"status\" style={{ ...panelStyle, padding: 12 }}>Configurazione salvata.</div> : null}\n <form onSubmit={save} style={{ display: \"grid\", gap: 18 }}>\n <section style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 14 }}>\n <h2 style={{ margin: 0, fontSize: 17 }}>Connessioni self-hosted</h2>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Gateway ACL Paperclip\n <input style={inputStyle} value={config.gatewayUrl} onChange={(event) => setConfig((current) => ({ ...current, gatewayUrl: event.target.value }))} />\n <span style={mutedStyle}>Default OTOMATIK: 127.0.0.1:6768/mcp</span>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>API Supermemory Local\n <input style={inputStyle} value={config.localApiUrl} onChange={(event) => setConfig((current) => ({ ...current, localApiUrl: event.target.value }))} />\n <span style={mutedStyle}>Default OTOMATIK: 127.0.0.1:6767. L\u2019endpoint deve rimanere su rete privata.</span>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Secret con la chiave master Supermemory Local\n <select style={inputStyle} value={config.adminApiKeyRef?.secretId ?? \"\"} onChange={(event) => setConfig((current) => ({\n ...current,\n ...(event.target.value ? { adminApiKeyRef: { type: \"secret_ref\", secretId: event.target.value } } : { adminApiKeyRef: undefined }),\n }))}>\n <option value=\"\">Non configurato</option>\n {secrets.map((secret) => <option key={secret.id} value={secret.id}>{secret.name}{secret.key ? ` \u00B7 ${secret.key}` : \"\"}</option>)}\n </select>\n <span style={mutedStyle}>Serve solo per la libreria Memory e le ricerche negli spazi assegnati. Crea o importa il secret da <a href=\"/company/settings/secrets\" style={{ textDecoration: \"underline\" }}>Secrets</a>.</span>\n </label>\n <p style={{ ...mutedStyle, margin: 0, fontSize: 12 }}>Il plugin risolve la chiave master solo nelle azioni di gestione autorizzate all\u2019Owner e nelle ricerche di agenti gi\u00E0 autorizzati. Non \u00E8 esposta agli agenti come valore.</p>\n </section>\n\n <section style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 14 }}>\n <div style={{ display: \"flex\", gap: 12, alignItems: \"center\", justifyContent: \"space-between\" }}>\n <div><h2 style={{ margin: 0, fontSize: 17 }}>Agenti autorizzati</h2><p style={{ ...mutedStyle, margin: \"5px 0 0\", fontSize: 13 }}>Il selettore mostra il nome dell\u2019agente; Paperclip conserva l\u2019ID corretto senza chiederti di copiarlo.</p></div>\n <button type=\"button\" style={secondaryButtonStyle} onClick={addGrant}>\uFF0B Aggiungi agente</button>\n </div>\n {grantRows.length === 0 ? <p style={{ ...mutedStyle, margin: 0 }}>Nessun agente autorizzato.</p> : grantRows.map((row, index) => (\n <div key={row.key} style={{ ...panelStyle, padding: 14, display: \"grid\", gridTemplateColumns: \"minmax(180px, 1fr) minmax(180px, 1fr) auto\", gap: 12, alignItems: \"end\" }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Agente Paperclip\n <select style={inputStyle} value={row.agentId} onChange={(event) => updateGrant(index, { agentId: event.target.value })}>\n <option value=\"\">Scegli un agente\u2026</option>\n {agents.map((agent) => <option key={agent.id} value={agent.id}>{agent.name} \u00B7 {agent.role}</option>)}\n </select>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Secret ACL individuale\n <select style={inputStyle} value={row.tokenSecretId} onChange={(event) => updateGrant(index, { tokenSecretId: event.target.value })}>\n <option value=\"\">Scegli un secret\u2026</option>\n {secrets.map((secret) => <option key={secret.id} value={secret.id}>{secret.name}{secret.key ? ` \u00B7 ${secret.key}` : \"\"}</option>)}\n </select>\n </label>\n <button type=\"button\" aria-label=\"Rimuovi agente\" style={secondaryButtonStyle} onClick={() => removeGrant(index)}>Rimuovi</button>\n </div>\n ))}\n <p style={{ ...mutedStyle, margin: 0, fontSize: 12 }}>Il token deve gi\u00E0 essere associato sul gateway a questo agente, alla stessa organizzazione Paperclip e al suo ruolo.</p>\n </section>\n <div><button type=\"submit\" style={primaryButtonStyle} disabled={saving}>{saving ? \"Salvataggio\u2026\" : \"Salva configurazione\"}</button></div>\n </form>\n </main>\n );\n}\n\nexport function MemorySidebarLink({ context }: PluginSidebarProps) {\n const navigation = useHostNavigation();\n if (!context.companyId) return null;\n const href = navigation.resolveHref(\"/memory\");\n const isActive = typeof window !== \"undefined\" && window.location.pathname === href;\n return (\n <a {...navigation.linkProps(\"/memory\")} aria-current={isActive ? \"page\" : undefined}\n className={`flex items-center gap-2.5 px-3 py-2 text-[13px] font-medium transition-colors ${isActive ? \"bg-accent text-foreground\" : \"text-foreground/80 hover:bg-accent/50 hover:text-foreground\"}`}>\n <svg viewBox=\"0 0 24 24\" className=\"h-4 w-4 shrink-0\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.8\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M9 3.5a3 3 0 0 0-3 3v.4a3 3 0 0 0-2.5 3v1.2a3 3 0 0 0 2.5 3v.4a3 3 0 0 0 3 3h1V3.5H9Z\" />\n <path d=\"M15 3.5a3 3 0 0 1 3 3v.4a3 3 0 0 1 2.5 3v1.2a3 3 0 0 1-2.5 3v.4a3 3 0 0 1-3 3h-1V3.5h1Z\" />\n <path d=\"M8 8h2m-2 5h2m4-5h2m-2 5h2\" />\n </svg>\n <span className=\"flex-1 truncate\">Memory</span>\n </a>\n );\n}\n\nfunction readAsBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => reject(new Error(\"Non riesco a leggere il file selezionato.\"));\n reader.onload = () => {\n const result = typeof reader.result === \"string\" ? reader.result : \"\";\n const comma = result.indexOf(\",\");\n if (comma < 0) reject(new Error(\"Formato file non valido.\"));\n else resolve(result.slice(comma + 1));\n };\n reader.readAsDataURL(file);\n });\n}\n\nexport function MemoryPage() {\n const { companyId } = useHostContext();\n const toast = usePluginToast();\n const loadCatalog = usePluginAction(\"memory-catalog\");\n const saveAssignment = usePluginAction(\"memory-assignment-save\");\n const disableAssignment = usePluginAction(\"memory-assignment-disable\");\n const readDocument = usePluginAction(\"memory-document-read\");\n const saveText = usePluginAction(\"memory-text-save\");\n const uploadFile = usePluginAction(\"memory-file-upload\");\n const deleteDocument = usePluginAction(\"memory-document-delete\");\n const navigation = useHostNavigation();\n const [catalog, setCatalog] = useState<Catalog | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [activeAssignmentId, setActiveAssignmentId] = useState(\"\");\n const [activeDocumentKey, setActiveDocumentKey] = useState(\"\");\n const [document, setDocument] = useState<MemoryDocument | null>(null);\n const [title, setTitle] = useState(\"\");\n const [content, setContent] = useState(\"\");\n const [mode, setMode] = useState<\"read\" | \"edit\" | \"raw\">(\"read\");\n const [dirty, setDirty] = useState(false);\n const [scopeType, setScopeType] = useState<\"agent\" | \"project\">(\"project\");\n const [scopeId, setScopeId] = useState(\"\");\n const [allowedAgentIds, setAllowedAgentIds] = useState<string[]>([]);\n const [showAssignment, setShowAssignment] = useState(false);\n const [showUrlForm, setShowUrlForm] = useState(false);\n const [urlInput, setUrlInput] = useState(\"\");\n\n const refreshCatalog = useCallback(async (keepAssignmentId?: string) => {\n if (!companyId) return;\n const data = await loadCatalog({ companyId }) as Catalog;\n setCatalog(data);\n setActiveAssignmentId((current) => {\n const next = keepAssignmentId ?? current;\n return data.assignments.some((assignment) => assignment.id === next) ? next : data.assignments[0]?.id ?? \"\";\n });\n }, [companyId, loadCatalog]);\n\n useEffect(() => {\n let cancelled = false;\n if (!companyId) { setLoading(false); setError(\"Seleziona un\u2019organizzazione Paperclip.\"); return; }\n setLoading(true);\n void loadCatalog({ companyId }).then((result) => {\n if (cancelled) return;\n const data = result as Catalog;\n setCatalog(data);\n setActiveAssignmentId(data.assignments[0]?.id ?? \"\");\n setError(null);\n }).catch((cause: unknown) => {\n if (cancelled) return;\n setError(displayError(cause));\n }).finally(() => { if (!cancelled) setLoading(false); });\n return () => { cancelled = true; };\n }, [companyId, loadCatalog]);\n\n const activeAssignment = catalog?.assignments.find((assignment) => assignment.id === activeAssignmentId) ?? null;\n const visibleDocuments = (catalog?.documents ?? []).filter((item) => item.assignmentId === activeAssignmentId);\n const selectedDocumentSummary = visibleDocuments.find((item) => `${item.assignmentId}:${item.id}` === activeDocumentKey) ?? null;\n\n useEffect(() => {\n let cancelled = false;\n if (activeDocumentKey === \"draft\") return;\n if (!companyId || !selectedDocumentSummary) {\n setDocument(null); setTitle(\"\"); setContent(\"\"); setDirty(false);\n return;\n }\n setBusy(true);\n void readDocument({ companyId, assignmentId: selectedDocumentSummary.assignmentId, namespace: selectedDocumentSummary.namespace, documentId: selectedDocumentSummary.id })\n .then((result) => {\n if (cancelled) return;\n const next = result as MemoryDocument;\n setDocument(next); setTitle(next.title); setContent(next.content ?? \"\"); setDirty(false); setMode(\"read\");\n }).catch((cause: unknown) => { if (!cancelled) setError(displayError(cause)); })\n .finally(() => { if (!cancelled) setBusy(false); });\n return () => { cancelled = true; };\n }, [companyId, activeDocumentKey, selectedDocumentSummary?.id, selectedDocumentSummary?.namespace, selectedDocumentSummary?.assignmentId, readDocument]);\n\n function startTextDocument() {\n if (!activeAssignment) return;\n setDocument({ id: \"\", namespace: activeAssignment.namespace, assignmentId: activeAssignment.id, title: \"Nuovo documento.md\", kind: \"text\", mimeType: \"text/markdown\", fileName: null, sourceUrl: null, status: \"draft\", content: \"\", createdAt: \"\", updatedAt: \"\" });\n setTitle(\"Nuovo documento.md\"); setContent(\"\"); setActiveDocumentKey(\"draft\"); setDirty(true); setMode(\"edit\");\n }\n\n function editField(setter: (value: string) => void, value: string) {\n setter(value); setDirty(true);\n }\n\n async function persistText(kind: \"text\" | \"url\" = \"text\", nextContent = content, nextTitle = title, documentId = document?.id || null): Promise<boolean> {\n if (!companyId || !activeAssignment) { setError(\"Seleziona un namespace prima di salvare.\"); return false; }\n setBusy(true); setError(null);\n try {\n const result = await saveText({ companyId, assignmentId: activeAssignment.id, documentId, title: nextTitle, content: nextContent, kind }) as { document: MemoryDocument };\n const saved = result.document;\n await refreshCatalog(activeAssignment.id);\n setDocument({ ...saved, content: nextContent }); setTitle(saved.title); setContent(nextContent); setActiveDocumentKey(`${activeAssignment.id}:${saved.id}`); setDirty(false); setMode(\"read\");\n toast({ tone: \"success\", title: \"Memoria salvata\", body: \"Supermemory ha messo il contenuto in coda per l\u2019indicizzazione.\" });\n return true;\n } catch (cause) { const message = displayError(cause); setError(message); toast({ tone: \"error\", title: \"Salvataggio non riuscito\", body: message }); }\n finally { setBusy(false); }\n return false;\n }\n\n async function handleFile(file: File) {\n if (!companyId || !activeAssignment) { setError(\"Crea o seleziona prima un namespace.\"); return; }\n const extension = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n setBusy(true); setError(null);\n try {\n if (TEXT_EXTENSIONS.has(extension)) {\n if (file.size > 1_000_000) throw new Error(\"Il testo non pu\u00F2 superare 1 MB.\");\n const fileText = await file.text();\n const result = await saveText({ companyId, assignmentId: activeAssignment.id, title: file.name, content: fileText, kind: \"text\" }) as { document: MemoryDocument };\n await refreshCatalog(activeAssignment.id);\n setActiveDocumentKey(`${activeAssignment.id}:${result.document.id}`);\n toast({ tone: \"success\", title: \"File aggiunto\", body: \"Supermemory ha messo il testo in coda per l\u2019indicizzazione.\" });\n return;\n }\n const expectedMime = BINARY_TYPES.get(extension);\n if (!expectedMime || expectedMime !== file.type) throw new Error(\"Formato non supportato. Local documenta PDF, PNG, JPG/JPEG, GIF e WebP, oltre ai file testuali .txt/.md/.html/.json/.csv.\");\n if (file.size > BINARY_MAX_BYTES) throw new Error(\"Il file binario non pu\u00F2 superare 6 MiB tramite il bridge Paperclip.\");\n const base64 = await readAsBase64(file);\n const result = await uploadFile({ companyId, assignmentId: activeAssignment.id, fileName: file.name, mimeType: file.type, base64 }) as { document: MemoryDocument };\n await refreshCatalog(activeAssignment.id);\n setActiveDocumentKey(`${activeAssignment.id}:${result.document.id}`);\n toast({ tone: \"success\", title: \"File caricato\", body: \"Supermemory ha messo il file in coda per l\u2019indicizzazione.\" });\n } catch (cause) { const message = displayError(cause); setError(message); toast({ tone: \"error\", title: \"Caricamento non riuscito\", body: message }); }\n finally { setBusy(false); }\n }\n\n function onFilesChange(event: ChangeEvent<HTMLInputElement>) {\n const file = event.target.files?.[0];\n if (file) void handleFile(file);\n event.target.value = \"\";\n }\n\n function onDrop(event: DragEvent<HTMLDivElement>) {\n event.preventDefault();\n if (!activeAssignment) { setError(\"Prima assegna o seleziona un namespace; poi puoi caricare il PDF.\"); return; }\n const file = event.dataTransfer.files.item(0);\n if (file) void handleFile(file);\n }\n\n async function addUrl(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n let parsed: URL;\n try { parsed = new URL(urlInput); } catch { setError(\"Inserisci un URL valido.\"); return; }\n const urlTitle = parsed.hostname + parsed.pathname;\n const saved = await persistText(\"url\", parsed.toString(), urlTitle.slice(0, 240), null);\n if (saved) { setShowUrlForm(false); setUrlInput(\"\"); }\n }\n\n async function saveAssignmentForm(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n if (!companyId || !catalog) return;\n setBusy(true); setError(null);\n const source = scopeType === \"agent\" ? catalog.agents.find((agent) => agent.id === scopeId) : catalog.projects.find((project) => project.id === scopeId);\n if (!source) { setBusy(false); setError(\"Seleziona un agente o un progetto.\"); return; }\n const authorized = scopeType === \"agent\" ? [scopeId] : allowedAgentIds;\n try {\n await saveAssignment({ companyId, scopeType, scopeId, label: source.name, authorizedAgentIds: authorized });\n await refreshCatalog();\n setShowAssignment(false); setScopeId(\"\"); setAllowedAgentIds([]);\n toast({ tone: \"success\", title: \"Namespace assegnato\", body: \"Lo spazio di memoria \u00E8 limitato all\u2019assegnazione e agli agenti indicati.\" });\n } catch (cause) { const message = displayError(cause); setError(message); }\n finally { setBusy(false); }\n }\n\n async function removeAssignment(assignment: NamespaceAssignment) {\n if (!companyId || !window.confirm(`Disattivare l\u2019accesso al namespace \u201C${assignment.label}\u201D? I documenti restano in Supermemory.`)) return;\n setBusy(true); setError(null);\n try { await disableAssignment({ companyId, assignmentId: assignment.id }); await refreshCatalog(); setActiveDocumentKey(\"\"); setDocument(null); }\n catch (cause) { setError(displayError(cause)); }\n finally { setBusy(false); }\n }\n\n async function removeDocument() {\n if (!companyId || !activeAssignment || !document?.id || !window.confirm(`Eliminare definitivamente \u201C${document.title}\u201D da Supermemory?`)) return;\n setBusy(true); setError(null);\n try { await deleteDocument({ companyId, assignmentId: activeAssignment.id, documentId: document.id }); await refreshCatalog(activeAssignment.id); setDocument(null); setActiveDocumentKey(\"\"); }\n catch (cause) { setError(displayError(cause)); }\n finally { setBusy(false); }\n }\n\n const namespacePreview = companyId && scopeId ? `paperclip_${companyId}_${scopeType}_${scopeId}` : \"Il namespace verr\u00E0 generato con ID organizzazione + target\";\n\n if (loading) return <main style={pageStyle}><p>Caricamento Memory\u2026</p></main>;\n if (error && !catalog) return (\n <main style={{ ...pageStyle, maxWidth: 760 }}>\n <h1 style={{ fontSize: 24 }}>Memory</h1>\n <div role=\"alert\" style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 10 }}>\n <strong>Accesso riservato all\u2019Owner dell\u2019organizzazione.</strong>\n <span style={mutedStyle}>{error}</span>\n <span style={mutedStyle}>I documenti e le assegnazioni non sono visibili agli altri membri dell\u2019organizzazione.</span>\n </div>\n </main>\n );\n\n return (\n <main style={pageStyle}>\n <header style={{ display: \"flex\", alignItems: \"start\", justifyContent: \"space-between\", gap: 16, marginBottom: 20 }}>\n <div>\n <h1 style={{ fontSize: 26, fontWeight: 650, margin: 0 }}>Memory</h1>\n <p style={{ ...mutedStyle, margin: \"6px 0 0\", maxWidth: 760 }}>Gestisci namespace e contenuti Supermemory per questa organizzazione. Questa libreria \u00E8 visibile solo agli Owner.</p>\n </div>\n <div style={{ display: \"flex\", gap: 8, flexWrap: \"wrap\", justifyContent: \"end\" }}>\n <button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowAssignment((value) => !value)}>\uFF0B Assegna namespace</button>\n <a {...navigation.linkProps(\"/company/settings/instance/plugins/paperclipai.supermemory\")} style={{ ...secondaryButtonStyle, textDecoration: \"none\" }}>Configurazione</a>\n </div>\n </header>\n\n {error ? <div role=\"alert\" style={{ ...panelStyle, padding: 12, marginBottom: 16, borderColor: \"var(--destructive, #b91c1c)\" }}>{error}</div> : null}\n {!catalog?.configured ? (\n <div style={{ ...panelStyle, padding: 14, marginBottom: 16 }}><strong>Chiave master non configurata.</strong><span style={{ ...mutedStyle, marginLeft: 6 }}>Le assegnazioni saranno salvate, ma l\u2019indicizzazione e la ricerca nei namespace restano disattivate finch\u00E9 non selezioni il secret Supermemory Local nella configurazione del plugin.</span></div>\n ) : null}\n\n {showAssignment ? (\n <form onSubmit={saveAssignmentForm} style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 13, marginBottom: 18 }}>\n <h2 style={{ fontSize: 17, margin: 0 }}>Assegna un namespace</h2>\n <div style={{ display: \"grid\", gridTemplateColumns: \"minmax(160px, 220px) minmax(220px, 1fr)\", gap: 12 }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Ambito\n <select style={inputStyle} value={scopeType} onChange={(event) => { setScopeType(event.target.value as \"agent\" | \"project\"); setScopeId(\"\"); setAllowedAgentIds([]); }}><option value=\"project\">Progetto</option><option value=\"agent\">Agente</option></select>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>{scopeType === \"project\" ? \"Progetto Paperclip\" : \"Agente Paperclip\"}\n <select style={inputStyle} value={scopeId} onChange={(event) => setScopeId(event.target.value)}>\n <option value=\"\">Scegli\u2026</option>\n {(scopeType === \"project\" ? catalog?.projects ?? [] : catalog?.agents ?? []).map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}\n </select>\n </label>\n </div>\n {scopeType === \"project\" ? <fieldset style={{ border: \"1px solid var(--border)\", borderRadius: 8, padding: 12 }}>\n <legend style={{ fontSize: 13, padding: \"0 5px\" }}>Agenti autorizzati a leggere questo namespace</legend>\n <p style={{ ...mutedStyle, fontSize: 12, margin: \"0 0 8px\" }}>Elenco esplicito usato dal plugin insieme al projectId del run. Seleziona solo agenti autorizzati sul progetto in Paperclip.</p>\n <div style={{ display: \"flex\", flexWrap: \"wrap\", gap: 8 }}>\n {(catalog?.agents ?? []).map((agent) => <label key={agent.id} style={{ display: \"inline-flex\", alignItems: \"center\", gap: 6, border: \"1px solid var(--border)\", borderRadius: 999, padding: \"5px 9px\", fontSize: 12 }}>\n <input type=\"checkbox\" checked={allowedAgentIds.includes(agent.id)} onChange={(event) => setAllowedAgentIds((current) => event.target.checked ? [...current, agent.id] : current.filter((id) => id !== agent.id))} />{agent.name}\n </label>)}\n </div>\n </fieldset> : null}\n <div style={{ ...mutedStyle, fontSize: 12 }}>Namespace isolato per questa organizzazione: <code style={{ overflowWrap: \"anywhere\" }}>{namespacePreview}</code>. Supermemory lo crea al primo contenuto.</div>\n <div style={{ display: \"flex\", gap: 8 }}><button style={primaryButtonStyle} disabled={busy}>{busy ? \"Salvataggio\u2026\" : \"Salva assegnazione\"}</button><button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowAssignment(false)}>Annulla</button></div>\n </form>\n ) : null}\n\n <section style={{ display: \"grid\", gridTemplateColumns: \"minmax(230px, 285px) minmax(0, 1fr)\", gap: 18, minHeight: 640 }}>\n <aside style={{ ...panelStyle, padding: 14, display: \"flex\", flexDirection: \"column\", minWidth: 0 }}>\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"space-between\", gap: 8, marginBottom: 10 }}>\n <h2 style={{ fontSize: 15, margin: 0 }}>Namespace e file</h2>\n <span style={{ ...mutedStyle, fontSize: 12 }}>{catalog?.assignments.length ?? 0}</span>\n </div>\n {!catalog?.assignments.length ? <div style={{ ...mutedStyle, fontSize: 13, padding: \"12px 2px\" }}>Nessun namespace. Usa \u201CAssegna namespace\u201D per iniziare.</div> : null}\n <div style={{ display: \"grid\", gap: 12, overflowY: \"auto\" }}>\n {(catalog?.assignments ?? []).map((assignment) => {\n const docs = catalog?.documents.filter((item) => item.assignmentId === assignment.id) ?? [];\n const selected = assignment.id === activeAssignmentId;\n return <div key={assignment.id} style={{ border: `1px solid ${selected ? \"var(--ring, var(--primary))\" : \"var(--border)\"}`, borderRadius: 8, overflow: \"hidden\" }}>\n <button type=\"button\" onClick={() => { setActiveAssignmentId(assignment.id); setActiveDocumentKey(\"\"); setDocument(null); }} style={{ width: \"100%\", textAlign: \"left\", background: selected ? \"var(--accent, rgba(127,127,127,.12))\" : \"transparent\", border: 0, color: \"var(--foreground)\", padding: 11, cursor: \"pointer\" }}>\n <strong style={{ display: \"block\", fontSize: 13 }}>{assignment.label}</strong>\n <span style={{ ...mutedStyle, display: \"block\", fontSize: 11, marginTop: 3 }}>{assignment.scopeType === \"project\" ? \"Progetto\" : \"Agente\"} \u00B7 {assignment.authorizedAgentIds.length} agenti</span>\n </button>\n {selected ? <div style={{ borderTop: \"1px solid var(--border)\", padding: 8, display: \"grid\", gap: 3 }}>\n {docs.map((item) => <button key={`${item.assignmentId}:${item.id}`} type=\"button\" onClick={() => setActiveDocumentKey(`${item.assignmentId}:${item.id}`)} style={{ display: \"flex\", gap: 7, alignItems: \"center\", border: 0, borderRadius: 5, padding: \"7px 5px\", textAlign: \"left\", background: activeDocumentKey === `${item.assignmentId}:${item.id}` ? \"var(--accent, rgba(127,127,127,.12))\" : \"transparent\", color: \"var(--foreground)\", cursor: \"pointer\", minWidth: 0 }}>\n <span aria-hidden=\"true\">{item.kind === \"url\" ? \"\u2197\" : item.kind === \"file\" ? \"\u25A7\" : \"\u25A4\"}</span><span style={{ overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", flex: 1, fontSize: 12 }}>{item.title}</span>\n </button>)}\n {!docs.length ? <span style={{ ...mutedStyle, fontSize: 11, padding: \"4px 5px\" }}>Nessun contenuto</span> : null}\n <button type=\"button\" onClick={() => void removeAssignment(assignment)} style={{ ...secondaryButtonStyle, padding: \"5px 7px\", fontSize: 11, marginTop: 5 }}>Disattiva assegnazione</button>\n </div> : null}\n </div>;\n })}\n </div>\n {activeAssignment ? <div style={{ borderTop: \"1px solid var(--border)\", paddingTop: 12, marginTop: \"auto\", display: \"grid\", gap: 7 }}>\n <button type=\"button\" style={secondaryButtonStyle} onClick={startTextDocument} disabled={busy}>\uFF0B Nuovo testo</button>\n <button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowUrlForm((current) => !current)} disabled={busy}>\uFF0B Aggiungi URL</button>\n <label style={{ ...secondaryButtonStyle, textAlign: \"center\", cursor: busy ? \"wait\" : \"pointer\" }}>\uFF0B Carica file\n <input type=\"file\" hidden disabled={busy} accept=\".pdf,.png,.jpg,.jpeg,.gif,.webp,.txt,.md,.markdown,.html,.htm,.json,.csv\" onChange={onFilesChange} />\n </label>\n </div> : null}\n </aside>\n\n <section style={{ ...panelStyle, minWidth: 0, display: \"flex\", flexDirection: \"column\", overflow: \"hidden\" }}>\n <div onDragOver={(event) => event.preventDefault()} onDrop={onDrop} style={{ padding: 16, borderBottom: \"1px solid var(--border)\", display: \"flex\", justifyContent: \"space-between\", alignItems: \"start\", gap: 14, flexWrap: \"wrap\" }}>\n <div style={{ minWidth: 0, flex: \"1 1 280px\" }}>\n <h2 style={{ fontSize: 16, margin: 0 }}>{activeAssignment?.label ?? \"Seleziona un namespace\"}</h2>\n {activeAssignment ? <code style={{ display: \"block\", marginTop: 5, fontSize: 11, color: \"var(--muted-foreground)\", overflowWrap: \"anywhere\" }}>{activeAssignment.namespace}</code> : null}\n </div>\n {document ? <div style={{ display: \"flex\", alignItems: \"center\", gap: 4, border: \"1px solid var(--border)\", borderRadius: 7, padding: 3 }}>\n {([\"read\", \"edit\", \"raw\"] as const).map((tab) => <button type=\"button\" key={tab} onClick={() => setMode(tab)} style={{ border: 0, borderRadius: 5, padding: \"6px 10px\", background: mode === tab ? \"var(--accent, rgba(127,127,127,.18))\" : \"transparent\", color: \"var(--foreground)\", cursor: \"pointer\", fontSize: 12 }}>{tab === \"read\" ? \"Leggi\" : tab === \"edit\" ? \"Modifica\" : \"Raw\"}</button>)}\n </div> : null}\n </div>\n\n {showUrlForm && activeAssignment ? <form onSubmit={addUrl} style={{ margin: 14, padding: 14, display: \"grid\", gap: 9, border: \"1px solid var(--border)\", borderRadius: 8 }}>\n <strong style={{ fontSize: 13 }}>Aggiungi pagina web</strong>\n <input style={inputStyle} type=\"url\" required placeholder=\"https://example.com/documentazione\" value={urlInput} onChange={(event) => setUrlInput(event.target.value)} />\n <span style={{ ...mutedStyle, fontSize: 12 }}>L\u2019URL viene passato a Supermemory Local. L\u2019estrazione web richiede Firecrawl configurato e invia la pagina al servizio Firecrawl.</span>\n <div style={{ display: \"flex\", gap: 8 }}><button style={primaryButtonStyle} disabled={busy}>Indicizza URL</button><button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowUrlForm(false)}>Annulla</button></div>\n </form> : null}\n\n {!activeAssignment ? (\n <div style={{ flex: 1, display: \"grid\", placeItems: \"center\", minHeight: 420, padding: 28 }}>\n <div style={{ width: \"min(100%, 600px)\", border: \"1px dashed var(--border)\", borderRadius: 12, padding: 28, textAlign: \"center\" }}>\n <strong>Prima assegna un namespace</strong>\n <p style={{ ...mutedStyle, fontSize: 13, lineHeight: 1.55 }}>Non c\u2019\u00E8 uno spazio di memoria attivo in questa organizzazione. Assegna un progetto o un agente; poi selezionalo e carica il PDF.</p>\n <button type=\"button\" style={primaryButtonStyle} onClick={() => setShowAssignment(true)}>\uFF0B Assegna namespace</button>\n </div>\n </div>\n ) : !document ? (\n <div onDragOver={(event) => event.preventDefault()} onDrop={onDrop} style={{ flex: 1, display: \"grid\", placeItems: \"center\", minHeight: 420, padding: 28 }}>\n <div style={{ width: \"min(100%, 600px)\", border: \"1px dashed var(--border)\", borderRadius: 12, padding: 28, textAlign: \"center\" }}>\n <div style={{ fontSize: 28, marginBottom: 10 }}>\u21E7</div>\n <strong>Trascina qui un file</strong>\n <p style={{ ...mutedStyle, fontSize: 13, lineHeight: 1.55 }}>Testo: TXT, Markdown, HTML, JSON e CSV (max 1 MB). File binari verificati per Supermemory Local: PDF, PNG, JPG/JPEG, GIF e WebP (max 6 MiB in questa interfaccia). Puoi anche aggiungere un URL pubblico.</p>\n <span style={{ ...mutedStyle, fontSize: 12 }}>Office, audio e video sono supportati da alcune versioni del servizio hosted, ma non sono documentati per il server Local installato.</span>\n </div>\n </div>\n ) : (\n <div style={{ flex: 1, minHeight: 400, padding: 18, display: \"flex\", flexDirection: \"column\", gap: 14, overflow: \"auto\" }}>\n <div style={{ display: \"grid\", gridTemplateColumns: \"minmax(0, 1fr) auto\", gap: 12, alignItems: \"end\" }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 12 }}>Titolo\n <input style={inputStyle} value={title} readOnly={mode === \"read\" || mode === \"raw\" || document.kind === \"file\"} onChange={(event) => editField(setTitle, event.target.value)} />\n </label>\n <span style={{ ...mutedStyle, fontSize: 11, whiteSpace: \"nowrap\" }}>{document.status === \"done\" ? \"Indicizzato\" : `Stato: ${document.status}`}</span>\n </div>\n {mode === \"read\" ? document.kind === \"file\" ? (\n <div style={{ ...panelStyle, padding: 18 }}><strong>File binario indicizzato</strong><p style={{ ...mutedStyle, marginBottom: 0 }}>Nome: {document.fileName ?? document.title}<br />Tipo: {document.mimeType ?? \"non specificato\"}<br />Supermemory conserva il file per la ricerca. Per sostituirlo, elimina questa voce e carica la versione aggiornata.</p></div>\n ) : document.kind === \"url\" ? <div style={{ ...panelStyle, padding: 18, overflowWrap: \"anywhere\" }}><strong>Pagina indicizzata</strong><p><a href={document.sourceUrl ?? content} target=\"_blank\" rel=\"noopener noreferrer\" style={{ textDecoration: \"underline\" }}>{document.sourceUrl ?? content}</a></p><p style={{ ...mutedStyle, marginBottom: 0 }}>Supermemory conserva l\u2019indice estratto; per aggiornare il contenuto salva di nuovo l\u2019URL.</p></div>\n : <div style={{ ...panelStyle, padding: 16, overflow: \"auto\" }}><MarkdownBlock content={content} /></div>\n : null}\n {mode === \"edit\" ? document.kind === \"file\" ? <div style={{ ...panelStyle, padding: 18 }}><strong>Il contenuto del file non \u00E8 modificabile in-place.</strong><p style={{ ...mutedStyle, marginBottom: 0 }}>Per aggiornarlo, elimina il documento e carica il nuovo file. Il file originale non \u00E8 recuperato dal catalogo Paperclip.</p></div>\n : <textarea style={{ ...inputStyle, minHeight: 380, resize: \"vertical\", fontFamily: \"var(--font-mono, ui-monospace, monospace)\", lineHeight: 1.6 }} value={content} onChange={(event) => editField(setContent, event.target.value)} />\n : null}\n {mode === \"raw\" ? <pre style={{ ...panelStyle, padding: 16, margin: 0, overflow: \"auto\", whiteSpace: \"pre-wrap\", overflowWrap: \"anywhere\", fontSize: 12 }}>{JSON.stringify({ ...document, title, content }, null, 2)}</pre> : null}\n <div style={{ display: \"flex\", gap: 8, justifyContent: \"space-between\", borderTop: \"1px solid var(--border)\", paddingTop: 12 }}>\n <button type=\"button\" style={{ ...secondaryButtonStyle, color: \"var(--destructive, #b91c1c)\" }} onClick={() => void removeDocument()} disabled={busy || !document.id}>Elimina documento</button>\n <div style={{ display: \"flex\", gap: 8 }}>\n {mode === \"edit\" ? <><button type=\"button\" style={secondaryButtonStyle} onClick={() => { setContent(document.content ?? \"\"); setTitle(document.title); setDirty(false); setMode(\"read\"); }}>Annulla</button><button type=\"button\" style={primaryButtonStyle} disabled={busy || !dirty} onClick={() => void persistText(document.kind === \"url\" ? \"url\" : \"text\")}>{busy ? \"Salvataggio\u2026\" : \"Salva modifiche\"}</button></> : null}\n </div>\n </div>\n </div>\n )}\n {busy ? <div aria-live=\"polite\" style={{ borderTop: \"1px solid var(--border)\", padding: \"8px 14px\", fontSize: 12, ...mutedStyle }}>Operazione in corso\u2026</div> : null}\n </section>\n </section>\n\n <footer style={{ ...mutedStyle, fontSize: 11, lineHeight: 1.6, marginTop: 12 }}>\n Le assegnazioni progetto sono controllate con <code>projectId</code> del run Paperclip e la allowlist degli agenti qui selezionati. Le informazioni restano separate per organizzazione. I namespace vengono creati da Supermemory al primo contenuto; disattivare un\u2019assegnazione revoca l\u2019accesso ma non cancella i documenti.\n </footer>\n </main>\n );\n}\n\nexport default { SupermemorySettingsPage, MemoryPage, MemorySidebarLink };\n", "import type { PaperclipPluginManifestV1 } from \"@paperclipai/plugin-sdk\";\n\nexport const PLUGIN_ID = \"paperclipai.supermemory\";\nexport const SEARCH_TOOL = \"search-approved-memory\";\nexport const SAVE_TOOL = \"submit-memory-candidate\";\nexport const MEMORY_SETTINGS_PAGE = \"supermemory-settings\";\nexport const MEMORY_PAGE = \"supermemory-memory\";\nexport const MEMORY_SIDEBAR = \"supermemory-sidebar\";\nexport const MEMORY_ROUTE = \"memory\";\n\nconst manifest: PaperclipPluginManifestV1 = {\n id: PLUGIN_ID,\n apiVersion: 1,\n version: \"0.2.2\",\n minimumHostVersion: \"2026.1023.0\",\n displayName: \"Supermemory (self-hosted)\",\n description: \"Memory tools and an Owner-managed memory library for self-hosted Supermemory, with company-, agent-, and project-scoped access.\",\n author: \"Otomatik\",\n categories: [\"connector\", \"automation\", \"ui\"],\n capabilities: [\n \"agent.tools.register\",\n \"agents.read\",\n \"projects.read\",\n \"access.members.read\",\n \"http.outbound\",\n \"instance.settings.register\",\n \"secrets.read-ref\",\n \"ui.page.register\",\n \"ui.sidebar.register\",\n ],\n entrypoints: {\n worker: \"./dist/worker.js\",\n ui: \"./dist/ui\",\n },\n instanceConfigSchema: {\n type: \"object\",\n properties: {\n gatewayUrl: {\n type: \"string\",\n title: \"Self-hosted ACL gateway URL\",\n description: \"Private Paperclip ACL gateway used by legacy company/team memory and reviewed memory candidates. Defaults to the OTOMATIK loopback endpoint.\",\n default: \"http://127.0.0.1:6768/mcp\",\n },\n localApiUrl: {\n type: \"string\",\n title: \"Supermemory Local API URL\",\n description: \"Private Supermemory Local API used by Owner-managed namespace content and explicit agent/project memory. Defaults to the OTOMATIK loopback endpoint.\",\n default: \"http://127.0.0.1:6767\",\n },\n adminApiKeyRef: {\n // Paperclip persists a secret-ref format as an object binding, even\n // though the format marker historically describes a string picker.\n type: [\"string\", \"object\"],\n format: \"secret-ref\",\n title: \"Owner-only Supermemory Local API key\",\n description: \"Paperclip secret containing the Supermemory Local master API key. The plugin resolves it only for Owner-checked management actions and authorized agent searches; never paste it into instructions or agent prompts.\",\n },\n agentGrants: {\n type: \"array\",\n title: \"Authorized agents\",\n description: \"Only listed Paperclip agents can use the memory tools. Each one uses its own ACL gateway token secret, already bound to the same agent, company, and role.\",\n items: {\n type: \"object\",\n title: \"Agent grant\",\n required: [\"agentId\", \"tokenRef\"],\n properties: {\n agentId: {\n type: \"string\",\n title: \"Paperclip agent\",\n minLength: 1,\n },\n tokenRef: {\n type: [\"string\", \"object\"],\n format: \"secret-ref\",\n title: \"This agent's ACL token secret\",\n description: \"Select the Paperclip company secret containing only this agent's Supermemory ACL token.\",\n },\n },\n },\n default: [],\n },\n },\n },\n tools: [\n {\n name: SEARCH_TOOL,\n displayName: \"Search approved Supermemory\",\n description: \"Search this agent's explicitly authorized company/team compartments and any assigned agent/project namespaces. Project memory is available only when the Paperclip run is in that project and the agent is on its explicit allowlist. Do not search for credentials or personal records.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", minLength: 1, maxLength: 300 },\n searchMode: { type: \"string\", enum: [\"hybrid\", \"memories\", \"chunks\"], default: \"hybrid\" },\n limit: { type: \"integer\", minimum: 1, maximum: 5, default: 3 },\n },\n required: [\"query\"],\n additionalProperties: false,\n },\n },\n {\n name: SAVE_TOOL,\n displayName: \"Submit a Supermemory candidate\",\n description: \"Submit one durable, non-sensitive fact or decision to this agent's role staging compartment for human review. This does not publish it to shared approved memory. Never submit credentials, personal data, customer cases, legal/health/workplace records, or full chat transcripts.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n content: { type: \"string\", minLength: 20, maxLength: 1200 },\n },\n required: [\"content\"],\n additionalProperties: false,\n },\n },\n ],\n ui: {\n slots: [\n {\n type: \"settingsPage\",\n id: MEMORY_SETTINGS_PAGE,\n displayName: \"Supermemory settings\",\n exportName: \"SupermemorySettingsPage\",\n },\n {\n type: \"page\",\n id: MEMORY_PAGE,\n displayName: \"Memory\",\n exportName: \"MemoryPage\",\n routePath: MEMORY_ROUTE,\n },\n {\n type: \"sidebar\",\n id: MEMORY_SIDEBAR,\n displayName: \"Memory\",\n exportName: \"MemorySidebarLink\",\n },\n ],\n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AAS,MAAM,KAAK,YAAY,SAAS,SAAS,QAAQ,QAAQ,MAAM,GAAI,iBAAO,sBAAiB,mBAAkB;AAAA,eAAS,IAAM,MAC9Z;AAAA,aACF;AAAA,WACF;AAAA,QAED,OAAO,oBAAC,SAAI,aAAU,UAAS,OAAO,EAAE,WAAW,2BAA2B,SAAS,YAAY,UAAU,IAAI,GAAG,WAAW,GAAG,uCAAoB,IAAS;AAAA,SAClK;AAAA,OACF;AAAA,IAEA,qBAAC,YAAO,OAAO,EAAE,GAAG,YAAY,UAAU,IAAI,YAAY,KAAK,WAAW,GAAG,GAAG;AAAA;AAAA,MAChC,oBAAC,UAAK,uBAAS;AAAA,MAAO;AAAA,OACtE;AAAA,KACF;AAEJ;AAEA,IAAO,gBAAQ,EAAE,yBAAyB,YAAY,kBAAkB;",
4
+ "sourcesContent": ["import { useCallback, useEffect, useState, type CSSProperties, type DragEvent, type ChangeEvent, type FormEvent } from \"react\";\nimport {\n MarkdownBlock,\n useHostContext,\n useHostNavigation,\n usePluginAction,\n usePluginToast,\n type PluginSidebarProps,\n} from \"@paperclipai/plugin-sdk/ui\";\nimport { PLUGIN_ID } from \"../manifest.js\";\n\ntype AgentInfo = { id: string; name: string; role: string; status: string };\ntype ProjectInfo = { id: string; name: string; visibility?: string };\ntype SecretInfo = { id: string; name: string; key?: string; status?: string };\ntype SecretRef = { type: \"secret_ref\"; secretId: string };\ntype GrantForm = { key: string; agentId: string; tokenSecretId: string };\ntype GrantConfig = { agentId: string; tokenRef: SecretRef };\ntype PluginConfig = {\n gatewayUrl: string;\n adminApiKeyRef?: SecretRef;\n agentGrants: GrantConfig[];\n};\ntype NamespaceAssignment = {\n id: string;\n companyId: string;\n scopeType: \"agent\" | \"project\";\n scopeId: string;\n label: string;\n namespace: string;\n authorizedAgentIds: string[];\n};\ntype MemoryDocument = {\n id: string;\n namespace: string;\n assignmentId: string;\n title: string;\n kind: \"text\" | \"url\" | \"file\";\n mimeType: string | null;\n fileName: string | null;\n sourceUrl: string | null;\n status: string;\n content?: string | null;\n createdAt: string;\n updatedAt: string;\n};\ntype Catalog = {\n assignments: NamespaceAssignment[];\n documents: MemoryDocument[];\n agents: AgentInfo[];\n projects: ProjectInfo[];\n configured: boolean;\n gatewayUrl: string;\n};\ntype AgentAccess = { subjectType: \"agent\" | \"user\"; subjectId: string; subjectDisplayName?: string | null };\n\nconst DEFAULT_GATEWAY = \"https://otomatik.tail77a9ab.ts.net:18443/mcp\";\nconst LEGACY_GATEWAYS = new Set([\"http://127.0.0.1:6768/mcp\", \"http://localhost:6768/mcp\"]);\nconst CONFIG_PATH = `/api/plugins/${encodeURIComponent(PLUGIN_ID)}/config`;\nconst BINARY_MAX_BYTES = 6 * 1024 * 1024;\nconst TEXT_EXTENSIONS = new Set([\"txt\", \"md\", \"markdown\", \"html\", \"htm\", \"json\", \"csv\"]);\nconst BINARY_TYPES = new Map<string, string>([\n [\"pdf\", \"application/pdf\"], [\"png\", \"image/png\"], [\"jpg\", \"image/jpeg\"], [\"jpeg\", \"image/jpeg\"],\n [\"gif\", \"image/gif\"], [\"webp\", \"image/webp\"],\n]);\n\nasync function hostFetchJson<T>(path: string, init: RequestInit = {}): Promise<T> {\n const headers = new Headers(init.headers ?? undefined);\n if (init.body && !(init.body instanceof FormData) && !headers.has(\"content-type\")) headers.set(\"content-type\", \"application/json\");\n const response = await fetch(path, { credentials: \"include\", ...init, headers });\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n let message = text || `Richiesta non riuscita (HTTP ${response.status}).`;\n try { message = String((JSON.parse(text) as { error?: string }).error ?? message); } catch { /* keep response text */ }\n throw new Error(message);\n }\n return await response.json() as T;\n}\n\nfunction secretId(value: unknown): string {\n return typeof value === \"object\" && value !== null && (value as { type?: unknown }).type === \"secret_ref\"\n && typeof (value as { secretId?: unknown }).secretId === \"string\" ? (value as { secretId: string }).secretId : \"\";\n}\n\nfunction displayError(value: unknown): string {\n if (value instanceof Error) return value.message;\n if (typeof value === \"string\") return value;\n if (value && typeof value === \"object\") {\n const error = value as { message?: unknown; code?: unknown; details?: unknown };\n if (typeof error.message === \"string\" && error.message.trim()) return error.message;\n if (typeof error.details === \"string\" && error.details.trim()) return error.details;\n if (typeof error.code === \"string\" && error.code.trim()) return `Operazione non riuscita (${error.code}).`;\n }\n return \"Operazione non riuscita. Riprova o controlla la configurazione del plugin.\";\n}\n\nfunction pluginConfig(configJson?: Record<string, unknown> | null): PluginConfig {\n const config = configJson ?? {};\n const grants: GrantConfig[] = Array.isArray(config.agentGrants) ? config.agentGrants.flatMap((entry) => {\n if (!entry || typeof entry !== \"object\") return [];\n const row = entry as Record<string, unknown>;\n if (typeof row.agentId !== \"string\" || !row.agentId) return [];\n const token = secretId(row.tokenRef);\n return token ? [{ agentId: row.agentId, tokenRef: { type: \"secret_ref\", secretId: token } }] : [];\n }) : [];\n const adminRef = secretId(config.adminApiKeyRef);\n return {\n gatewayUrl: typeof config.gatewayUrl === \"string\" && !LEGACY_GATEWAYS.has(config.gatewayUrl.trim()) ? config.gatewayUrl : DEFAULT_GATEWAY,\n ...(adminRef ? { adminApiKeyRef: { type: \"secret_ref\", secretId: adminRef } } : {}),\n agentGrants: grants,\n };\n}\n\nconst pageStyle: CSSProperties = { padding: 24, width: \"100%\", maxWidth: 1480, margin: \"0 auto\", color: \"var(--foreground)\" };\nconst panelStyle: CSSProperties = { border: \"1px solid var(--border)\", borderRadius: 10, background: \"var(--card, transparent)\" };\nconst mutedStyle: CSSProperties = { color: \"var(--muted-foreground)\" };\nconst inputStyle: CSSProperties = { width: \"100%\", border: \"1px solid var(--border)\", borderRadius: 7, background: \"var(--background)\", color: \"var(--foreground)\", padding: \"9px 11px\", minHeight: 38 };\nconst primaryButtonStyle: CSSProperties = { border: \"1px solid var(--primary)\", borderRadius: 7, background: \"var(--primary)\", color: \"var(--primary-foreground, white)\", padding: \"9px 14px\", fontWeight: 600, cursor: \"pointer\" };\nconst secondaryButtonStyle: CSSProperties = { border: \"1px solid var(--border)\", borderRadius: 7, background: \"transparent\", color: \"var(--foreground)\", padding: \"8px 12px\", cursor: \"pointer\" };\n\nexport function SupermemorySettingsPage() {\n const { companyId } = useHostContext();\n const [agents, setAgents] = useState<AgentInfo[]>([]);\n const [secrets, setSecrets] = useState<SecretInfo[]>([]);\n const [config, setConfig] = useState<PluginConfig>({ gatewayUrl: DEFAULT_GATEWAY, agentGrants: [] });\n const [grantRows, setGrantRows] = useState<GrantForm[]>([]);\n const [loading, setLoading] = useState(true);\n const [saving, setSaving] = useState(false);\n const [error, setError] = useState<string | null>(null);\n const [success, setSuccess] = useState(false);\n\n useEffect(() => {\n let cancelled = false;\n if (!companyId) { setLoading(false); setError(\"Seleziona un\u2019organizzazione.\"); return; }\n setLoading(true);\n const load = async () => {\n const [configResponse, agentResponse, secretResponse] = await Promise.all([\n hostFetchJson<{ configJson?: Record<string, unknown> | null } | null>(`${CONFIG_PATH}?companyId=${encodeURIComponent(companyId)}`),\n hostFetchJson<AgentInfo[]>(`/api/companies/${encodeURIComponent(companyId)}/agents`),\n hostFetchJson<SecretInfo[]>(`/api/companies/${encodeURIComponent(companyId)}/secrets`),\n ]);\n if (cancelled) return;\n const loadedConfig = pluginConfig(configResponse?.configJson);\n setConfig(loadedConfig);\n setGrantRows(loadedConfig.agentGrants.map((grant, index) => ({ key: `grant-${index}-${grant.agentId}`, agentId: grant.agentId, tokenSecretId: secretId(grant.tokenRef) })));\n setAgents(agentResponse.filter((agent) => ![\"terminated\", \"pending_approval\"].includes(agent.status)));\n setSecrets(secretResponse.filter((secret) => secret.status !== \"deleted\"));\n setError(null);\n };\n void load().catch((cause: unknown) => { if (!cancelled) setError(displayError(cause)); })\n .finally(() => { if (!cancelled) setLoading(false); });\n return () => { cancelled = true; };\n }, [companyId]);\n\n function updateGrant(index: number, patch: Partial<GrantForm>) {\n const next = grantRows.map((row, rowIndex) => rowIndex === index ? { ...row, ...patch } : row);\n setGrantRows(next);\n }\n\n function addGrant() {\n setGrantRows((current) => [...current, { key: `grant-new-${Date.now()}`, agentId: \"\", tokenSecretId: \"\" }]);\n }\n\n function removeGrant(index: number) {\n setGrantRows((current) => current.filter((_, rowIndex) => rowIndex !== index));\n }\n\n async function save(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n if (!companyId) return;\n setSaving(true); setError(null); setSuccess(false);\n try {\n if (grantRows.some((row) => Boolean(row.agentId) !== Boolean(row.tokenSecretId))) throw new Error(\"Completa sia l\u2019agente sia il secret ACL per ogni riga.\");\n const cleaned = grantRows.filter((row) => row.agentId && row.tokenSecretId);\n if (cleaned.some((row, index) => cleaned.findIndex((candidate) => candidate.agentId === row.agentId) !== index)) {\n throw new Error(\"Ogni agente pu\u00F2 comparire una sola volta.\");\n }\n const nextConfig: Record<string, unknown> = {\n gatewayUrl: config.gatewayUrl.trim() || DEFAULT_GATEWAY,\n agentGrants: cleaned.map((row) => ({ agentId: row.agentId, tokenRef: { type: \"secret_ref\", secretId: row.tokenSecretId } })),\n };\n if (config.adminApiKeyRef?.secretId) nextConfig.adminApiKeyRef = config.adminApiKeyRef;\n await hostFetchJson(CONFIG_PATH, { method: \"POST\", body: JSON.stringify({ companyId, configJson: nextConfig }) });\n setConfig(pluginConfig(nextConfig));\n setGrantRows(cleaned.map((row, index) => ({ key: `grant-${index}-${row.agentId}`, agentId: row.agentId, tokenSecretId: row.tokenSecretId })));\n setSuccess(true);\n } catch (cause) { setError(displayError(cause)); }\n finally { setSaving(false); }\n }\n\n if (loading) return <main style={pageStyle}><p>Caricamento configurazione\u2026</p></main>;\n return (\n <main style={{ ...pageStyle, maxWidth: 1000, display: \"grid\", gap: 22 }}>\n <header>\n <h1 style={{ fontSize: 25, margin: 0, fontWeight: 650 }}>Configurazione Supermemory</h1>\n <p style={{ ...mutedStyle, marginTop: 8, maxWidth: 760 }}>Scegli gli agenti Paperclip dall\u2019elenco e collega per ciascuno il suo secret ACL. Le chiavi restano nei Secrets Paperclip: non vengono mostrate n\u00E9 copiate nei prompt.</p>\n </header>\n {error ? <div role=\"alert\" style={{ ...panelStyle, padding: 12, borderColor: \"var(--destructive, #b91c1c)\" }}>{error}</div> : null}\n {success ? <div role=\"status\" style={{ ...panelStyle, padding: 12 }}>Configurazione salvata.</div> : null}\n <form onSubmit={save} style={{ display: \"grid\", gap: 18 }}>\n <section style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 14 }}>\n <h2 style={{ margin: 0, fontSize: 17 }}>Connessioni self-hosted</h2>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Gateway ACL Paperclip\n <input style={inputStyle} value={config.gatewayUrl} onChange={(event) => setConfig((current) => ({ ...current, gatewayUrl: event.target.value }))} />\n <span style={mutedStyle}>Default OTOMATIK: HTTPS Tailscale `otomatik.tail77a9ab.ts.net:18443`. L\u2019API Supermemory resta interna al server.</span>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Secret con la chiave master Supermemory Local\n <select style={inputStyle} value={config.adminApiKeyRef?.secretId ?? \"\"} onChange={(event) => setConfig((current) => ({\n ...current,\n ...(event.target.value ? { adminApiKeyRef: { type: \"secret_ref\", secretId: event.target.value } } : { adminApiKeyRef: undefined }),\n }))}>\n <option value=\"\">Non configurato</option>\n {secrets.map((secret) => <option key={secret.id} value={secret.id}>{secret.name}{secret.key ? ` \u00B7 ${secret.key}` : \"\"}</option>)}\n </select>\n <span style={mutedStyle}>Serve per autenticare il gateway nelle azioni Owner della libreria Memory e nelle ricerche di namespace assegnati. Crea o importa il secret da <a href=\"/company/settings/secrets\" style={{ textDecoration: \"underline\" }}>Secrets</a>.</span>\n </label>\n <p style={{ ...mutedStyle, margin: 0, fontSize: 12 }}>Il plugin risolve la chiave master solo nelle azioni di gestione autorizzate all\u2019Owner e nelle ricerche di agenti gi\u00E0 autorizzati. Non \u00E8 esposta agli agenti come valore.</p>\n </section>\n\n <section style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 14 }}>\n <div style={{ display: \"flex\", gap: 12, alignItems: \"center\", justifyContent: \"space-between\" }}>\n <div><h2 style={{ margin: 0, fontSize: 17 }}>Agenti autorizzati</h2><p style={{ ...mutedStyle, margin: \"5px 0 0\", fontSize: 13 }}>Il selettore mostra il nome dell\u2019agente; Paperclip conserva l\u2019ID corretto senza chiederti di copiarlo.</p></div>\n <button type=\"button\" style={secondaryButtonStyle} onClick={addGrant}>\uFF0B Aggiungi agente</button>\n </div>\n {grantRows.length === 0 ? <p style={{ ...mutedStyle, margin: 0 }}>Nessun agente autorizzato.</p> : grantRows.map((row, index) => (\n <div key={row.key} style={{ ...panelStyle, padding: 14, display: \"grid\", gridTemplateColumns: \"minmax(180px, 1fr) minmax(180px, 1fr) auto\", gap: 12, alignItems: \"end\" }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Agente Paperclip\n <select style={inputStyle} value={row.agentId} onChange={(event) => updateGrant(index, { agentId: event.target.value })}>\n <option value=\"\">Scegli un agente\u2026</option>\n {agents.map((agent) => <option key={agent.id} value={agent.id}>{agent.name} \u00B7 {agent.role}</option>)}\n </select>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Secret ACL individuale\n <select style={inputStyle} value={row.tokenSecretId} onChange={(event) => updateGrant(index, { tokenSecretId: event.target.value })}>\n <option value=\"\">Scegli un secret\u2026</option>\n {secrets.map((secret) => <option key={secret.id} value={secret.id}>{secret.name}{secret.key ? ` \u00B7 ${secret.key}` : \"\"}</option>)}\n </select>\n </label>\n <button type=\"button\" aria-label=\"Rimuovi agente\" style={secondaryButtonStyle} onClick={() => removeGrant(index)}>Rimuovi</button>\n </div>\n ))}\n <p style={{ ...mutedStyle, margin: 0, fontSize: 12 }}>Il token deve gi\u00E0 essere associato sul gateway a questo agente, alla stessa organizzazione Paperclip e al suo ruolo.</p>\n </section>\n <div><button type=\"submit\" style={primaryButtonStyle} disabled={saving}>{saving ? \"Salvataggio\u2026\" : \"Salva configurazione\"}</button></div>\n </form>\n </main>\n );\n}\n\nexport function MemorySidebarLink({ context }: PluginSidebarProps) {\n const navigation = useHostNavigation();\n if (!context.companyId) return null;\n const href = navigation.resolveHref(\"/memory\");\n const isActive = typeof window !== \"undefined\" && window.location.pathname === href;\n return (\n <a {...navigation.linkProps(\"/memory\")} aria-current={isActive ? \"page\" : undefined}\n className={`flex items-center gap-2.5 mx-2 rounded-lg px-2 py-1.5 pointer-coarse:py-1 text-(length:--text-compact) font-medium transition-colors ${isActive ? \"bg-sidebar-accent text-sidebar-accent-foreground\" : \"text-foreground/80 hover:bg-sidebar-accent hover:text-sidebar-accent-foreground\"}`}>\n <span data-plugin-sidebar-icon=\"true\" aria-hidden=\"true\" className=\"flex h-4 w-4 shrink-0 items-center justify-center\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <path d=\"M9 3.5a3 3 0 0 0-3 3v.4a3 3 0 0 0-2.5 3v1.2a3 3 0 0 0 2.5 3v.4a3 3 0 0 0 3 3h1V3.5H9Z\" />\n <path d=\"M15 3.5a3 3 0 0 1 3 3v.4a3 3 0 0 1 2.5 3v1.2a3 3 0 0 1-2.5 3v.4a3 3 0 0 1-3 3h-1V3.5h1Z\" />\n <path d=\"M8 8h2m-2 5h2m4-5h2m-2 5h2\" />\n </svg>\n </span>\n <span data-plugin-sidebar-label=\"true\" className=\"flex-1 truncate\">Memory</span>\n </a>\n );\n}\n\nfunction readAsBase64(file: File): Promise<string> {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onerror = () => reject(new Error(\"Non riesco a leggere il file selezionato.\"));\n reader.onload = () => {\n const result = typeof reader.result === \"string\" ? reader.result : \"\";\n const comma = result.indexOf(\",\");\n if (comma < 0) reject(new Error(\"Formato file non valido.\"));\n else resolve(result.slice(comma + 1));\n };\n reader.readAsDataURL(file);\n });\n}\n\nexport function MemoryPage() {\n const { companyId } = useHostContext();\n const toast = usePluginToast();\n const loadCatalog = usePluginAction(\"memory-catalog\");\n const saveAssignment = usePluginAction(\"memory-assignment-save\");\n const disableAssignment = usePluginAction(\"memory-assignment-disable\");\n const readDocument = usePluginAction(\"memory-document-read\");\n const saveText = usePluginAction(\"memory-text-save\");\n const uploadFile = usePluginAction(\"memory-file-upload\");\n const deleteDocument = usePluginAction(\"memory-document-delete\");\n const navigation = useHostNavigation();\n const [catalog, setCatalog] = useState<Catalog | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<string | null>(null);\n const [busy, setBusy] = useState(false);\n const [activeAssignmentId, setActiveAssignmentId] = useState(\"\");\n const [activeDocumentKey, setActiveDocumentKey] = useState(\"\");\n const [document, setDocument] = useState<MemoryDocument | null>(null);\n const [title, setTitle] = useState(\"\");\n const [content, setContent] = useState(\"\");\n const [mode, setMode] = useState<\"read\" | \"edit\" | \"raw\">(\"read\");\n const [dirty, setDirty] = useState(false);\n const [scopeType, setScopeType] = useState<\"agent\" | \"project\">(\"project\");\n const [scopeId, setScopeId] = useState(\"\");\n const [allowedAgentIds, setAllowedAgentIds] = useState<string[]>([]);\n const [showAssignment, setShowAssignment] = useState(false);\n const [showUrlForm, setShowUrlForm] = useState(false);\n const [urlInput, setUrlInput] = useState(\"\");\n\n const refreshCatalog = useCallback(async (keepAssignmentId?: string) => {\n if (!companyId) return;\n const data = await loadCatalog({ companyId }) as Catalog;\n setCatalog(data);\n setActiveAssignmentId((current) => {\n const next = keepAssignmentId ?? current;\n return data.assignments.some((assignment) => assignment.id === next) ? next : data.assignments[0]?.id ?? \"\";\n });\n }, [companyId, loadCatalog]);\n\n useEffect(() => {\n let cancelled = false;\n if (!companyId) { setLoading(false); setError(\"Seleziona un\u2019organizzazione Paperclip.\"); return; }\n setLoading(true);\n void loadCatalog({ companyId }).then((result) => {\n if (cancelled) return;\n const data = result as Catalog;\n setCatalog(data);\n setActiveAssignmentId(data.assignments[0]?.id ?? \"\");\n setError(null);\n }).catch((cause: unknown) => {\n if (cancelled) return;\n setError(displayError(cause));\n }).finally(() => { if (!cancelled) setLoading(false); });\n return () => { cancelled = true; };\n }, [companyId, loadCatalog]);\n\n const activeAssignment = catalog?.assignments.find((assignment) => assignment.id === activeAssignmentId) ?? null;\n const visibleDocuments = (catalog?.documents ?? []).filter((item) => item.assignmentId === activeAssignmentId);\n const selectedDocumentSummary = visibleDocuments.find((item) => `${item.assignmentId}:${item.id}` === activeDocumentKey) ?? null;\n\n useEffect(() => {\n let cancelled = false;\n if (activeDocumentKey === \"draft\") return;\n if (!companyId || !selectedDocumentSummary) {\n setDocument(null); setTitle(\"\"); setContent(\"\"); setDirty(false);\n return;\n }\n setBusy(true);\n void readDocument({ companyId, assignmentId: selectedDocumentSummary.assignmentId, namespace: selectedDocumentSummary.namespace, documentId: selectedDocumentSummary.id })\n .then((result) => {\n if (cancelled) return;\n const next = result as MemoryDocument;\n setDocument(next); setTitle(next.title); setContent(next.content ?? \"\"); setDirty(false); setMode(\"read\");\n }).catch((cause: unknown) => { if (!cancelled) setError(displayError(cause)); })\n .finally(() => { if (!cancelled) setBusy(false); });\n return () => { cancelled = true; };\n }, [companyId, activeDocumentKey, selectedDocumentSummary?.id, selectedDocumentSummary?.namespace, selectedDocumentSummary?.assignmentId, readDocument]);\n\n function startTextDocument() {\n if (!activeAssignment) return;\n setDocument({ id: \"\", namespace: activeAssignment.namespace, assignmentId: activeAssignment.id, title: \"Nuovo documento.md\", kind: \"text\", mimeType: \"text/markdown\", fileName: null, sourceUrl: null, status: \"draft\", content: \"\", createdAt: \"\", updatedAt: \"\" });\n setTitle(\"Nuovo documento.md\"); setContent(\"\"); setActiveDocumentKey(\"draft\"); setDirty(true); setMode(\"edit\");\n }\n\n function editField(setter: (value: string) => void, value: string) {\n setter(value); setDirty(true);\n }\n\n async function persistText(kind: \"text\" | \"url\" = \"text\", nextContent = content, nextTitle = title, documentId = document?.id || null): Promise<boolean> {\n if (!companyId || !activeAssignment) { setError(\"Seleziona un namespace prima di salvare.\"); return false; }\n setBusy(true); setError(null);\n try {\n const result = await saveText({ companyId, assignmentId: activeAssignment.id, documentId, title: nextTitle, content: nextContent, kind }) as { document: MemoryDocument };\n const saved = result.document;\n await refreshCatalog(activeAssignment.id);\n setDocument({ ...saved, content: nextContent }); setTitle(saved.title); setContent(nextContent); setActiveDocumentKey(`${activeAssignment.id}:${saved.id}`); setDirty(false); setMode(\"read\");\n toast({ tone: \"success\", title: \"Memoria salvata\", body: \"Supermemory ha messo il contenuto in coda per l\u2019indicizzazione.\" });\n return true;\n } catch (cause) { const message = displayError(cause); setError(message); toast({ tone: \"error\", title: \"Salvataggio non riuscito\", body: message }); }\n finally { setBusy(false); }\n return false;\n }\n\n async function handleFile(file: File) {\n if (!companyId || !activeAssignment) { setError(\"Crea o seleziona prima un namespace.\"); return; }\n const extension = file.name.split(\".\").pop()?.toLowerCase() ?? \"\";\n setBusy(true); setError(null);\n try {\n if (TEXT_EXTENSIONS.has(extension)) {\n if (file.size > 1_000_000) throw new Error(\"Il testo non pu\u00F2 superare 1 MB.\");\n const fileText = await file.text();\n const result = await saveText({ companyId, assignmentId: activeAssignment.id, title: file.name, content: fileText, kind: \"text\" }) as { document: MemoryDocument };\n await refreshCatalog(activeAssignment.id);\n setActiveDocumentKey(`${activeAssignment.id}:${result.document.id}`);\n toast({ tone: \"success\", title: \"File aggiunto\", body: \"Supermemory ha messo il testo in coda per l\u2019indicizzazione.\" });\n return;\n }\n const expectedMime = BINARY_TYPES.get(extension);\n if (!expectedMime || expectedMime !== file.type) throw new Error(\"Formato non supportato. Local documenta PDF, PNG, JPG/JPEG, GIF e WebP, oltre ai file testuali .txt/.md/.html/.json/.csv.\");\n if (file.size > BINARY_MAX_BYTES) throw new Error(\"Il file binario non pu\u00F2 superare 6 MiB tramite il bridge Paperclip.\");\n const base64 = await readAsBase64(file);\n const result = await uploadFile({ companyId, assignmentId: activeAssignment.id, fileName: file.name, mimeType: file.type, base64 }) as { document: MemoryDocument };\n await refreshCatalog(activeAssignment.id);\n setActiveDocumentKey(`${activeAssignment.id}:${result.document.id}`);\n toast({ tone: \"success\", title: \"File caricato\", body: \"Supermemory ha messo il file in coda per l\u2019indicizzazione.\" });\n } catch (cause) { const message = displayError(cause); setError(message); toast({ tone: \"error\", title: \"Caricamento non riuscito\", body: message }); }\n finally { setBusy(false); }\n }\n\n function onFilesChange(event: ChangeEvent<HTMLInputElement>) {\n const file = event.target.files?.[0];\n if (file) void handleFile(file);\n event.target.value = \"\";\n }\n\n function onDrop(event: DragEvent<HTMLDivElement>) {\n event.preventDefault();\n if (!activeAssignment) { setError(\"Prima assegna o seleziona un namespace; poi puoi caricare il PDF.\"); return; }\n const file = event.dataTransfer.files.item(0);\n if (file) void handleFile(file);\n }\n\n async function addUrl(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n let parsed: URL;\n try { parsed = new URL(urlInput); } catch { setError(\"Inserisci un URL valido.\"); return; }\n const urlTitle = parsed.hostname + parsed.pathname;\n const saved = await persistText(\"url\", parsed.toString(), urlTitle.slice(0, 240), null);\n if (saved) { setShowUrlForm(false); setUrlInput(\"\"); }\n }\n\n async function saveAssignmentForm(event: FormEvent<HTMLFormElement>) {\n event.preventDefault();\n if (!companyId || !catalog) return;\n setBusy(true); setError(null);\n const source = scopeType === \"agent\" ? catalog.agents.find((agent) => agent.id === scopeId) : catalog.projects.find((project) => project.id === scopeId);\n if (!source) { setBusy(false); setError(\"Seleziona un agente o un progetto.\"); return; }\n const authorized = scopeType === \"agent\" ? [scopeId] : allowedAgentIds;\n try {\n await saveAssignment({ companyId, scopeType, scopeId, label: source.name, authorizedAgentIds: authorized });\n await refreshCatalog();\n setShowAssignment(false); setScopeId(\"\"); setAllowedAgentIds([]);\n toast({ tone: \"success\", title: \"Namespace assegnato\", body: \"Lo spazio di memoria \u00E8 limitato all\u2019assegnazione e agli agenti indicati.\" });\n } catch (cause) { const message = displayError(cause); setError(message); }\n finally { setBusy(false); }\n }\n\n async function removeAssignment(assignment: NamespaceAssignment) {\n if (!companyId || !window.confirm(`Disattivare l\u2019accesso al namespace \u201C${assignment.label}\u201D? I documenti restano in Supermemory.`)) return;\n setBusy(true); setError(null);\n try { await disableAssignment({ companyId, assignmentId: assignment.id }); await refreshCatalog(); setActiveDocumentKey(\"\"); setDocument(null); }\n catch (cause) { setError(displayError(cause)); }\n finally { setBusy(false); }\n }\n\n async function removeDocument() {\n if (!companyId || !activeAssignment || !document?.id || !window.confirm(`Eliminare definitivamente \u201C${document.title}\u201D da Supermemory?`)) return;\n setBusy(true); setError(null);\n try { await deleteDocument({ companyId, assignmentId: activeAssignment.id, documentId: document.id }); await refreshCatalog(activeAssignment.id); setDocument(null); setActiveDocumentKey(\"\"); }\n catch (cause) { setError(displayError(cause)); }\n finally { setBusy(false); }\n }\n\n const namespacePreview = companyId && scopeId ? `paperclip_${companyId}_${scopeType}_${scopeId}` : \"Il namespace verr\u00E0 generato con ID organizzazione + target\";\n\n if (loading) return <main style={pageStyle}><p>Caricamento Memory\u2026</p></main>;\n if (error && !catalog) return (\n <main style={{ ...pageStyle, maxWidth: 760 }}>\n <h1 style={{ fontSize: 24 }}>Memory</h1>\n <div role=\"alert\" style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 10 }}>\n <strong>Accesso riservato all\u2019Owner dell\u2019organizzazione.</strong>\n <span style={mutedStyle}>{error}</span>\n <span style={mutedStyle}>I documenti e le assegnazioni non sono visibili agli altri membri dell\u2019organizzazione.</span>\n </div>\n </main>\n );\n\n return (\n <main style={pageStyle}>\n <header style={{ display: \"flex\", alignItems: \"start\", justifyContent: \"space-between\", gap: 16, marginBottom: 20 }}>\n <div>\n <h1 style={{ fontSize: 26, fontWeight: 650, margin: 0 }}>Memory</h1>\n <p style={{ ...mutedStyle, margin: \"6px 0 0\", maxWidth: 760 }}>Gestisci namespace e contenuti Supermemory per questa organizzazione. Questa libreria \u00E8 visibile solo agli Owner.</p>\n </div>\n <div style={{ display: \"flex\", gap: 8, flexWrap: \"wrap\", justifyContent: \"end\" }}>\n <button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowAssignment((value) => !value)}>\uFF0B Assegna namespace</button>\n <a {...navigation.linkProps(\"/company/settings/instance/plugins/paperclipai.supermemory\")} style={{ ...secondaryButtonStyle, textDecoration: \"none\" }}>Configurazione</a>\n </div>\n </header>\n\n {error ? <div role=\"alert\" style={{ ...panelStyle, padding: 12, marginBottom: 16, borderColor: \"var(--destructive, #b91c1c)\" }}>{error}</div> : null}\n {!catalog?.configured ? (\n <div style={{ ...panelStyle, padding: 14, marginBottom: 16 }}><strong>Chiave master non configurata.</strong><span style={{ ...mutedStyle, marginLeft: 6 }}>Le assegnazioni saranno salvate, ma l\u2019indicizzazione e la ricerca nei namespace restano disattivate finch\u00E9 non selezioni il secret Supermemory Local nella configurazione del plugin.</span></div>\n ) : null}\n\n {showAssignment ? (\n <form onSubmit={saveAssignmentForm} style={{ ...panelStyle, padding: 18, display: \"grid\", gap: 13, marginBottom: 18 }}>\n <h2 style={{ fontSize: 17, margin: 0 }}>Assegna un namespace</h2>\n <div style={{ display: \"grid\", gridTemplateColumns: \"minmax(160px, 220px) minmax(220px, 1fr)\", gap: 12 }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>Ambito\n <select style={inputStyle} value={scopeType} onChange={(event) => { setScopeType(event.target.value as \"agent\" | \"project\"); setScopeId(\"\"); setAllowedAgentIds([]); }}><option value=\"project\">Progetto</option><option value=\"agent\">Agente</option></select>\n </label>\n <label style={{ display: \"grid\", gap: 6, fontSize: 13 }}>{scopeType === \"project\" ? \"Progetto Paperclip\" : \"Agente Paperclip\"}\n <select style={inputStyle} value={scopeId} onChange={(event) => setScopeId(event.target.value)}>\n <option value=\"\">Scegli\u2026</option>\n {(scopeType === \"project\" ? catalog?.projects ?? [] : catalog?.agents ?? []).map((item) => <option key={item.id} value={item.id}>{item.name}</option>)}\n </select>\n </label>\n </div>\n {scopeType === \"project\" ? <fieldset style={{ border: \"1px solid var(--border)\", borderRadius: 8, padding: 12 }}>\n <legend style={{ fontSize: 13, padding: \"0 5px\" }}>Agenti autorizzati a leggere questo namespace</legend>\n <p style={{ ...mutedStyle, fontSize: 12, margin: \"0 0 8px\" }}>Elenco esplicito usato dal plugin insieme al projectId del run. Seleziona solo agenti autorizzati sul progetto in Paperclip.</p>\n <div style={{ display: \"flex\", flexWrap: \"wrap\", gap: 8 }}>\n {(catalog?.agents ?? []).map((agent) => <label key={agent.id} style={{ display: \"inline-flex\", alignItems: \"center\", gap: 6, border: \"1px solid var(--border)\", borderRadius: 999, padding: \"5px 9px\", fontSize: 12 }}>\n <input type=\"checkbox\" checked={allowedAgentIds.includes(agent.id)} onChange={(event) => setAllowedAgentIds((current) => event.target.checked ? [...current, agent.id] : current.filter((id) => id !== agent.id))} />{agent.name}\n </label>)}\n </div>\n </fieldset> : null}\n <div style={{ ...mutedStyle, fontSize: 12 }}>Namespace isolato per questa organizzazione: <code style={{ overflowWrap: \"anywhere\" }}>{namespacePreview}</code>. Supermemory lo crea al primo contenuto.</div>\n <div style={{ display: \"flex\", gap: 8 }}><button style={primaryButtonStyle} disabled={busy}>{busy ? \"Salvataggio\u2026\" : \"Salva assegnazione\"}</button><button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowAssignment(false)}>Annulla</button></div>\n </form>\n ) : null}\n\n <section style={{ display: \"grid\", gridTemplateColumns: \"minmax(230px, 285px) minmax(0, 1fr)\", gap: 18, minHeight: 640 }}>\n <aside style={{ ...panelStyle, padding: 14, display: \"flex\", flexDirection: \"column\", minWidth: 0 }}>\n <div style={{ display: \"flex\", alignItems: \"center\", justifyContent: \"space-between\", gap: 8, marginBottom: 10 }}>\n <h2 style={{ fontSize: 15, margin: 0 }}>Namespace e file</h2>\n <span style={{ ...mutedStyle, fontSize: 12 }}>{catalog?.assignments.length ?? 0}</span>\n </div>\n {!catalog?.assignments.length ? <div style={{ ...mutedStyle, fontSize: 13, padding: \"12px 2px\" }}>Nessun namespace. Usa \u201CAssegna namespace\u201D per iniziare.</div> : null}\n <div style={{ display: \"grid\", gap: 12, overflowY: \"auto\" }}>\n {(catalog?.assignments ?? []).map((assignment) => {\n const docs = catalog?.documents.filter((item) => item.assignmentId === assignment.id) ?? [];\n const selected = assignment.id === activeAssignmentId;\n return <div key={assignment.id} style={{ border: `1px solid ${selected ? \"var(--ring, var(--primary))\" : \"var(--border)\"}`, borderRadius: 8, overflow: \"hidden\" }}>\n <button type=\"button\" onClick={() => { setActiveAssignmentId(assignment.id); setActiveDocumentKey(\"\"); setDocument(null); }} style={{ width: \"100%\", textAlign: \"left\", background: selected ? \"var(--accent, rgba(127,127,127,.12))\" : \"transparent\", border: 0, color: \"var(--foreground)\", padding: 11, cursor: \"pointer\" }}>\n <strong style={{ display: \"block\", fontSize: 13 }}>{assignment.label}</strong>\n <span style={{ ...mutedStyle, display: \"block\", fontSize: 11, marginTop: 3 }}>{assignment.scopeType === \"project\" ? \"Progetto\" : \"Agente\"} \u00B7 {assignment.authorizedAgentIds.length} agenti</span>\n </button>\n {selected ? <div style={{ borderTop: \"1px solid var(--border)\", padding: 8, display: \"grid\", gap: 3 }}>\n {docs.map((item) => <button key={`${item.assignmentId}:${item.id}`} type=\"button\" onClick={() => setActiveDocumentKey(`${item.assignmentId}:${item.id}`)} style={{ display: \"flex\", gap: 7, alignItems: \"center\", border: 0, borderRadius: 5, padding: \"7px 5px\", textAlign: \"left\", background: activeDocumentKey === `${item.assignmentId}:${item.id}` ? \"var(--accent, rgba(127,127,127,.12))\" : \"transparent\", color: \"var(--foreground)\", cursor: \"pointer\", minWidth: 0 }}>\n <span aria-hidden=\"true\">{item.kind === \"url\" ? \"\u2197\" : item.kind === \"file\" ? \"\u25A7\" : \"\u25A4\"}</span><span style={{ overflow: \"hidden\", textOverflow: \"ellipsis\", whiteSpace: \"nowrap\", flex: 1, fontSize: 12 }}>{item.title}</span>\n </button>)}\n {!docs.length ? <span style={{ ...mutedStyle, fontSize: 11, padding: \"4px 5px\" }}>Nessun contenuto</span> : null}\n <button type=\"button\" onClick={() => void removeAssignment(assignment)} style={{ ...secondaryButtonStyle, padding: \"5px 7px\", fontSize: 11, marginTop: 5 }}>Disattiva assegnazione</button>\n </div> : null}\n </div>;\n })}\n </div>\n {activeAssignment ? <div style={{ borderTop: \"1px solid var(--border)\", paddingTop: 12, marginTop: \"auto\", display: \"grid\", gap: 7 }}>\n <button type=\"button\" style={secondaryButtonStyle} onClick={startTextDocument} disabled={busy}>\uFF0B Nuovo testo</button>\n <button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowUrlForm((current) => !current)} disabled={busy}>\uFF0B Aggiungi URL</button>\n <label style={{ ...secondaryButtonStyle, textAlign: \"center\", cursor: busy ? \"wait\" : \"pointer\" }}>\uFF0B Carica file\n <input type=\"file\" hidden disabled={busy} accept=\".pdf,.png,.jpg,.jpeg,.gif,.webp,.txt,.md,.markdown,.html,.htm,.json,.csv\" onChange={onFilesChange} />\n </label>\n </div> : null}\n </aside>\n\n <section style={{ ...panelStyle, minWidth: 0, display: \"flex\", flexDirection: \"column\", overflow: \"hidden\" }}>\n <div onDragOver={(event) => event.preventDefault()} onDrop={onDrop} style={{ padding: 16, borderBottom: \"1px solid var(--border)\", display: \"flex\", justifyContent: \"space-between\", alignItems: \"start\", gap: 14, flexWrap: \"wrap\" }}>\n <div style={{ minWidth: 0, flex: \"1 1 280px\" }}>\n <h2 style={{ fontSize: 16, margin: 0 }}>{activeAssignment?.label ?? \"Seleziona un namespace\"}</h2>\n {activeAssignment ? <code style={{ display: \"block\", marginTop: 5, fontSize: 11, color: \"var(--muted-foreground)\", overflowWrap: \"anywhere\" }}>{activeAssignment.namespace}</code> : null}\n </div>\n {document ? <div style={{ display: \"flex\", alignItems: \"center\", gap: 4, border: \"1px solid var(--border)\", borderRadius: 7, padding: 3 }}>\n {([\"read\", \"edit\", \"raw\"] as const).map((tab) => <button type=\"button\" key={tab} onClick={() => setMode(tab)} style={{ border: 0, borderRadius: 5, padding: \"6px 10px\", background: mode === tab ? \"var(--accent, rgba(127,127,127,.18))\" : \"transparent\", color: \"var(--foreground)\", cursor: \"pointer\", fontSize: 12 }}>{tab === \"read\" ? \"Leggi\" : tab === \"edit\" ? \"Modifica\" : \"Raw\"}</button>)}\n </div> : null}\n </div>\n\n {showUrlForm && activeAssignment ? <form onSubmit={addUrl} style={{ margin: 14, padding: 14, display: \"grid\", gap: 9, border: \"1px solid var(--border)\", borderRadius: 8 }}>\n <strong style={{ fontSize: 13 }}>Aggiungi pagina web</strong>\n <input style={inputStyle} type=\"url\" required placeholder=\"https://example.com/documentazione\" value={urlInput} onChange={(event) => setUrlInput(event.target.value)} />\n <span style={{ ...mutedStyle, fontSize: 12 }}>L\u2019URL viene passato a Supermemory Local. L\u2019estrazione web richiede Firecrawl configurato e invia la pagina al servizio Firecrawl.</span>\n <div style={{ display: \"flex\", gap: 8 }}><button style={primaryButtonStyle} disabled={busy}>Indicizza URL</button><button type=\"button\" style={secondaryButtonStyle} onClick={() => setShowUrlForm(false)}>Annulla</button></div>\n </form> : null}\n\n {!activeAssignment ? (\n <div style={{ flex: 1, display: \"grid\", placeItems: \"center\", minHeight: 420, padding: 28 }}>\n <div style={{ width: \"min(100%, 600px)\", border: \"1px dashed var(--border)\", borderRadius: 12, padding: 28, textAlign: \"center\" }}>\n <strong>Prima assegna un namespace</strong>\n <p style={{ ...mutedStyle, fontSize: 13, lineHeight: 1.55 }}>Non c\u2019\u00E8 uno spazio di memoria attivo in questa organizzazione. Assegna un progetto o un agente; poi selezionalo e carica il PDF.</p>\n <button type=\"button\" style={primaryButtonStyle} onClick={() => setShowAssignment(true)}>\uFF0B Assegna namespace</button>\n </div>\n </div>\n ) : !document ? (\n <div onDragOver={(event) => event.preventDefault()} onDrop={onDrop} style={{ flex: 1, display: \"grid\", placeItems: \"center\", minHeight: 420, padding: 28 }}>\n <div style={{ width: \"min(100%, 600px)\", border: \"1px dashed var(--border)\", borderRadius: 12, padding: 28, textAlign: \"center\" }}>\n <div style={{ fontSize: 28, marginBottom: 10 }}>\u21E7</div>\n <strong>Trascina qui un file</strong>\n <p style={{ ...mutedStyle, fontSize: 13, lineHeight: 1.55 }}>Testo: TXT, Markdown, HTML, JSON e CSV (max 1 MB). File binari verificati per Supermemory Local: PDF, PNG, JPG/JPEG, GIF e WebP (max 6 MiB in questa interfaccia). Puoi anche aggiungere un URL pubblico.</p>\n <span style={{ ...mutedStyle, fontSize: 12 }}>Office, audio e video sono supportati da alcune versioni del servizio hosted, ma non sono documentati per il server Local installato.</span>\n </div>\n </div>\n ) : (\n <div style={{ flex: 1, minHeight: 400, padding: 18, display: \"flex\", flexDirection: \"column\", gap: 14, overflow: \"auto\" }}>\n <div style={{ display: \"grid\", gridTemplateColumns: \"minmax(0, 1fr) auto\", gap: 12, alignItems: \"end\" }}>\n <label style={{ display: \"grid\", gap: 6, fontSize: 12 }}>Titolo\n <input style={inputStyle} value={title} readOnly={mode === \"read\" || mode === \"raw\" || document.kind === \"file\"} onChange={(event) => editField(setTitle, event.target.value)} />\n </label>\n <span style={{ ...mutedStyle, fontSize: 11, whiteSpace: \"nowrap\" }}>{document.status === \"done\" ? \"Indicizzato\" : `Stato: ${document.status}`}</span>\n </div>\n {mode === \"read\" ? document.kind === \"file\" ? (\n <div style={{ ...panelStyle, padding: 18 }}><strong>File binario indicizzato</strong><p style={{ ...mutedStyle, marginBottom: 0 }}>Nome: {document.fileName ?? document.title}<br />Tipo: {document.mimeType ?? \"non specificato\"}<br />Supermemory conserva il file per la ricerca. Per sostituirlo, elimina questa voce e carica la versione aggiornata.</p></div>\n ) : document.kind === \"url\" ? <div style={{ ...panelStyle, padding: 18, overflowWrap: \"anywhere\" }}><strong>Pagina indicizzata</strong><p><a href={document.sourceUrl ?? content} target=\"_blank\" rel=\"noopener noreferrer\" style={{ textDecoration: \"underline\" }}>{document.sourceUrl ?? content}</a></p><p style={{ ...mutedStyle, marginBottom: 0 }}>Supermemory conserva l\u2019indice estratto; per aggiornare il contenuto salva di nuovo l\u2019URL.</p></div>\n : <div style={{ ...panelStyle, padding: 16, overflow: \"auto\" }}><MarkdownBlock content={content} /></div>\n : null}\n {mode === \"edit\" ? document.kind === \"file\" ? <div style={{ ...panelStyle, padding: 18 }}><strong>Il contenuto del file non \u00E8 modificabile in-place.</strong><p style={{ ...mutedStyle, marginBottom: 0 }}>Per aggiornarlo, elimina il documento e carica il nuovo file. Il file originale non \u00E8 recuperato dal catalogo Paperclip.</p></div>\n : <textarea style={{ ...inputStyle, minHeight: 380, resize: \"vertical\", fontFamily: \"var(--font-mono, ui-monospace, monospace)\", lineHeight: 1.6 }} value={content} onChange={(event) => editField(setContent, event.target.value)} />\n : null}\n {mode === \"raw\" ? <pre style={{ ...panelStyle, padding: 16, margin: 0, overflow: \"auto\", whiteSpace: \"pre-wrap\", overflowWrap: \"anywhere\", fontSize: 12 }}>{JSON.stringify({ ...document, title, content }, null, 2)}</pre> : null}\n <div style={{ display: \"flex\", gap: 8, justifyContent: \"space-between\", borderTop: \"1px solid var(--border)\", paddingTop: 12 }}>\n <button type=\"button\" style={{ ...secondaryButtonStyle, color: \"var(--destructive, #b91c1c)\" }} onClick={() => void removeDocument()} disabled={busy || !document.id}>Elimina documento</button>\n <div style={{ display: \"flex\", gap: 8 }}>\n {mode === \"edit\" ? <><button type=\"button\" style={secondaryButtonStyle} onClick={() => { setContent(document.content ?? \"\"); setTitle(document.title); setDirty(false); setMode(\"read\"); }}>Annulla</button><button type=\"button\" style={primaryButtonStyle} disabled={busy || !dirty} onClick={() => void persistText(document.kind === \"url\" ? \"url\" : \"text\")}>{busy ? \"Salvataggio\u2026\" : \"Salva modifiche\"}</button></> : null}\n </div>\n </div>\n </div>\n )}\n {busy ? <div aria-live=\"polite\" style={{ borderTop: \"1px solid var(--border)\", padding: \"8px 14px\", fontSize: 12, ...mutedStyle }}>Operazione in corso\u2026</div> : null}\n </section>\n </section>\n\n <footer style={{ ...mutedStyle, fontSize: 11, lineHeight: 1.6, marginTop: 12 }}>\n Le assegnazioni progetto sono controllate con <code>projectId</code> del run Paperclip e la allowlist degli agenti qui selezionati. Le informazioni restano separate per organizzazione. I namespace vengono creati da Supermemory al primo contenuto; disattivare un\u2019assegnazione revoca l\u2019accesso ma non cancella i documenti.\n </footer>\n </main>\n );\n}\n\nexport default { SupermemorySettingsPage, MemoryPage, MemorySidebarLink };\n", "import type { PaperclipPluginManifestV1 } from \"@paperclipai/plugin-sdk\";\n\nexport const PLUGIN_ID = \"paperclipai.supermemory\";\nexport const SEARCH_TOOL = \"search-approved-memory\";\nexport const SAVE_TOOL = \"submit-memory-candidate\";\nexport const MEMORY_SETTINGS_PAGE = \"supermemory-settings\";\nexport const MEMORY_PAGE = \"supermemory-memory\";\nexport const MEMORY_SIDEBAR = \"supermemory-sidebar\";\nexport const MEMORY_ROUTE = \"memory\";\n\nconst manifest: PaperclipPluginManifestV1 = {\n id: PLUGIN_ID,\n apiVersion: 1,\n version: \"0.2.3\",\n minimumHostVersion: \"2026.1023.0\",\n displayName: \"Supermemory (self-hosted)\",\n description: \"Memory tools and an Owner-managed memory library for self-hosted Supermemory, with company-, agent-, and project-scoped access.\",\n author: \"Otomatik\",\n categories: [\"connector\", \"automation\", \"ui\"],\n capabilities: [\n \"agent.tools.register\",\n \"agents.read\",\n \"projects.read\",\n \"access.members.read\",\n \"http.outbound\",\n \"instance.settings.register\",\n \"secrets.read-ref\",\n \"ui.page.register\",\n \"ui.sidebar.register\",\n ],\n entrypoints: {\n worker: \"./dist/worker.js\",\n ui: \"./dist/ui\",\n },\n instanceConfigSchema: {\n type: \"object\",\n properties: {\n gatewayUrl: {\n type: \"string\",\n title: \"Gateway Supermemory su Tailscale HTTPS\",\n description: \"URL HTTPS tailnet del gateway ACL e delle operazioni Owner. Esempio OTOMATIK: https://otomatik.tail77a9ab.ts.net:18443/mcp. Supermemory Local resta privato sul server.\",\n default: \"https://otomatik.tail77a9ab.ts.net:18443/mcp\",\n },\n localApiUrl: {\n type: \"string\",\n title: \"Legacy Supermemory Local API URL\",\n description: \"Legacy value retained for existing configurations; ignored since plugin 0.2.3. The Local API is reached only by the server-side gateway.\",\n },\n adminApiKeyRef: {\n // Paperclip persists a secret-ref format as an object binding, even\n // though the format marker historically describes a string picker.\n type: [\"string\", \"object\"],\n format: \"secret-ref\",\n title: \"Secret con la chiave master Supermemory Local\",\n description: \"Usata come credenziale per le route Owner del gateway Tailscale. Viene risolta solo dopo il controllo Owner o per una ricerca con namespace assegnato esplicitamente; non viene esposta nei prompt.\",\n },\n agentGrants: {\n type: \"array\",\n title: \"Authorized agents\",\n description: \"Only listed Paperclip agents can use the memory tools. Each one uses its own ACL gateway token secret, already bound to the same agent, company, and role.\",\n items: {\n type: \"object\",\n title: \"Agent grant\",\n required: [\"agentId\", \"tokenRef\"],\n properties: {\n agentId: {\n type: \"string\",\n title: \"Paperclip agent\",\n minLength: 1,\n },\n tokenRef: {\n type: [\"string\", \"object\"],\n format: \"secret-ref\",\n title: \"This agent's ACL token secret\",\n description: \"Select the Paperclip company secret containing only this agent's Supermemory ACL token.\",\n },\n },\n },\n default: [],\n },\n },\n },\n tools: [\n {\n name: SEARCH_TOOL,\n displayName: \"Search approved Supermemory\",\n description: \"Search this agent's explicitly authorized company/team compartments and any assigned agent/project namespaces. Project memory is available only when the Paperclip run is in that project and the agent is on its explicit allowlist. Do not search for credentials or personal records.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", minLength: 1, maxLength: 300 },\n searchMode: { type: \"string\", enum: [\"hybrid\", \"memories\", \"chunks\"], default: \"hybrid\" },\n limit: { type: \"integer\", minimum: 1, maximum: 5, default: 3 },\n },\n required: [\"query\"],\n additionalProperties: false,\n },\n },\n {\n name: SAVE_TOOL,\n displayName: \"Submit a Supermemory candidate\",\n description: \"Submit one durable, non-sensitive fact or decision to this agent's role staging compartment for human review. This does not publish it to shared approved memory. Never submit credentials, personal data, customer cases, legal/health/workplace records, or full chat transcripts.\",\n parametersSchema: {\n type: \"object\",\n properties: {\n content: { type: \"string\", minLength: 20, maxLength: 1200 },\n },\n required: [\"content\"],\n additionalProperties: false,\n },\n },\n ],\n ui: {\n slots: [\n {\n type: \"settingsPage\",\n id: MEMORY_SETTINGS_PAGE,\n displayName: \"Supermemory settings\",\n exportName: \"SupermemorySettingsPage\",\n },\n {\n type: \"page\",\n id: MEMORY_PAGE,\n displayName: \"Memory\",\n exportName: \"MemoryPage\",\n routePath: MEMORY_ROUTE,\n },\n {\n type: \"sidebar\",\n id: MEMORY_SIDEBAR,\n displayName: \"Memory\",\n exportName: \"MemorySidebarLink\",\n },\n ],\n },\n};\n\nexport default manifest;\n"],
5
+ "mappings": ";AAAA,SAAS,aAAa,WAAW,gBAAsF;AACvH;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;ACNA,IAAM,YAAY;;;AD2LqB,SA0aT,UA1aS,KAGxC,YAHwC;AAtI9C,IAAM,kBAAkB;AACxB,IAAM,kBAAkB,oBAAI,IAAI,CAAC,6BAA6B,2BAA2B,CAAC;AAC1F,IAAM,cAAc,gBAAgB,mBAAmB,SAAS,CAAC;AACjE,IAAM,mBAAmB,IAAI,OAAO;AACpC,IAAM,kBAAkB,oBAAI,IAAI,CAAC,OAAO,MAAM,YAAY,QAAQ,OAAO,QAAQ,KAAK,CAAC;AACvF,IAAM,eAAe,oBAAI,IAAoB;AAAA,EAC3C,CAAC,OAAO,iBAAiB;AAAA,EAAG,CAAC,OAAO,WAAW;AAAA,EAAG,CAAC,OAAO,YAAY;AAAA,EAAG,CAAC,QAAQ,YAAY;AAAA,EAC9F,CAAC,OAAO,WAAW;AAAA,EAAG,CAAC,QAAQ,YAAY;AAC7C,CAAC;AAED,eAAe,cAAiB,MAAc,OAAoB,CAAC,GAAe;AAChF,QAAM,UAAU,IAAI,QAAQ,KAAK,WAAW,MAAS;AACrD,MAAI,KAAK,QAAQ,EAAE,KAAK,gBAAgB,aAAa,CAAC,QAAQ,IAAI,cAAc,EAAG,SAAQ,IAAI,gBAAgB,kBAAkB;AACjI,QAAM,WAAW,MAAM,MAAM,MAAM,EAAE,aAAa,WAAW,GAA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,oBAAoB,UAAU,QAAQ,CAAC,OAAO,SAAS,MAAM,KAAK,YAAY,SAAS,SAAS,QAAQ,QAAQ,MAAM,GAAI,iBAAO,sBAAiB,mBAAkB;AAAA,eAAS,IAAM,MAC9Z;AAAA,aACF;AAAA,WACF;AAAA,QAED,OAAO,oBAAC,SAAI,aAAU,UAAS,OAAO,EAAE,WAAW,2BAA2B,SAAS,YAAY,UAAU,IAAI,GAAG,WAAW,GAAG,uCAAoB,IAAS;AAAA,SAClK;AAAA,OACF;AAAA,IAEA,qBAAC,YAAO,OAAO,EAAE,GAAG,YAAY,UAAU,IAAI,YAAY,KAAK,WAAW,GAAG,GAAG;AAAA;AAAA,MAChC,oBAAC,UAAK,uBAAS;AAAA,MAAO;AAAA,OACtE;AAAA,KACF;AAEJ;AAEA,IAAO,gBAAQ,EAAE,yBAAyB,YAAY,kBAAkB;",
6
6
  "names": ["result"]
7
7
  }
package/dist/worker.js CHANGED
@@ -44251,30 +44251,23 @@ function isPrivateHost(hostname3) {
44251
44251
  return host === "localhost" || host === "::1" || host === "paperclip-supermemory-acl-gateway" || host.endsWith(".localhost") || host.endsWith(".local") || host.endsWith(".internal") || isPrivateIpv4(host) || host.includes(":") && (host.startsWith("fc") || host.startsWith("fd") || host.startsWith("fe80:"));
44252
44252
  }
44253
44253
  function gatewayEndpoint(config2) {
44254
- const raw = typeof config2.gatewayUrl === "string" && config2.gatewayUrl.trim() ? config2.gatewayUrl.trim() : "http://127.0.0.1:6768/mcp";
44254
+ const configured = typeof config2.gatewayUrl === "string" ? config2.gatewayUrl.trim() : "";
44255
+ const legacyLocal = ["http://127.0.0.1:6768/mcp", "http://localhost:6768/mcp"].includes(configured);
44256
+ const raw = !configured || legacyLocal ? "https://otomatik.tail77a9ab.ts.net:18443/mcp" : configured;
44255
44257
  let url2;
44256
44258
  try {
44257
44259
  url2 = new URL(raw);
44258
44260
  } catch {
44259
44261
  throw new Error("The Supermemory ACL gateway URL is invalid.");
44260
44262
  }
44261
- if (!isPrivateHost(url2.hostname) || !["http:", "https:"].includes(url2.protocol) || url2.port !== "6768" || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/mcp") {
44262
- throw new Error("The Supermemory ACL gateway must be a private host on port 6768 with path /mcp; public endpoints are refused.");
44263
+ const hostname3 = url2.hostname.toLowerCase();
44264
+ if (url2.protocol !== "https:" || !hostname3.endsWith(".ts.net") || !/^[a-z0-9.-]+$/.test(hostname3) || !["", "443", "18443"].includes(url2.port) || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/mcp") {
44265
+ throw new Error("Il gateway deve usare HTTPS con un nome Tailscale *.ts.net, porta 443 o 18443 e percorso /mcp.");
44263
44266
  }
44264
44267
  return url2.toString();
44265
44268
  }
44266
- function localApiBase(config2) {
44267
- const raw = typeof config2.localApiUrl === "string" && config2.localApiUrl.trim() ? config2.localApiUrl.trim() : "http://127.0.0.1:6767";
44268
- let url2;
44269
- try {
44270
- url2 = new URL(raw);
44271
- } catch {
44272
- throw new Error("The Supermemory Local API URL is invalid.");
44273
- }
44274
- if (!isPrivateHost(url2.hostname) || !["http:", "https:"].includes(url2.protocol) || url2.port !== "6767" || url2.username || url2.password || url2.search || url2.hash || url2.pathname !== "/" && url2.pathname !== "") {
44275
- throw new Error("The Supermemory Local API must be a private host on port 6767, without a path or credentials.");
44276
- }
44277
- return url2.origin;
44269
+ function gatewayOrigin(config2) {
44270
+ return new URL(gatewayEndpoint(config2)).origin;
44278
44271
  }
44279
44272
  function assignmentNamespace(companyId, scopeType, scopeId) {
44280
44273
  return `paperclip_${companyId}_${scopeType}_${scopeId}`;
@@ -44305,7 +44298,7 @@ async function resolveAdminKey(ctx, config2, companyId) {
44305
44298
  const key = await ctx.secrets.resolve(config2.adminApiKeyRef, { companyId, configPath: "adminApiKeyRef" });
44306
44299
  return key && key.length >= 24 ? key : null;
44307
44300
  }
44308
- async function localRequest(ctx, base, key, path2, init = {}) {
44301
+ async function ownerGatewayRequest(ctx, base, key, path2, init = {}) {
44309
44302
  let response;
44310
44303
  try {
44311
44304
  response = await ctx.http.fetch(`${base}${path2}`, {
@@ -44318,13 +44311,12 @@ async function localRequest(ctx, base, key, path2, init = {}) {
44318
44311
  }
44319
44312
  });
44320
44313
  } catch {
44321
- throw new Error("Supermemory Local non \xE8 raggiungibile dal server Paperclip.");
44314
+ throw new Error("Il gateway Supermemory su Tailscale HTTPS non \xE8 raggiungibile dal server Paperclip.");
44322
44315
  }
44323
44316
  if (!response.ok) {
44324
44317
  const status = response.status;
44325
- if (status === 401 || status === 403) throw new Error("La chiave Supermemory Local non \xE8 valida o non autorizzata.");
44326
- const detail = await response.text().catch(() => "");
44327
- throw new Error(`Supermemory Local ha rifiutato l\u2019operazione (HTTP ${status})${detail ? `: ${detail.slice(0, 220)}` : ""}.`);
44318
+ if (status === 401 || status === 403) throw new Error("La chiave master Supermemory Local non \xE8 valida o il gateway non l\u2019ha autorizzata.");
44319
+ throw new Error(`Il gateway Supermemory ha rifiutato l\u2019operazione (HTTP ${status}).`);
44328
44320
  }
44329
44321
  try {
44330
44322
  return await response.json();
@@ -44333,7 +44325,7 @@ async function localRequest(ctx, base, key, path2, init = {}) {
44333
44325
  }
44334
44326
  }
44335
44327
  function localNamespacePath(namespace, suffix) {
44336
- return `/ns/${encodeURIComponent(namespace)}${suffix}`;
44328
+ return `/owner/ns/${encodeURIComponent(namespace)}${suffix}`;
44337
44329
  }
44338
44330
  async function callGateway(ctx, endpoint, token, name, args) {
44339
44331
  const gatewayTool = name === SEARCH_TOOL ? "supermemory_search" : "supermemory_save_candidate";
@@ -44409,10 +44401,10 @@ async function runMemoryTool(ctx, name, rawParams, runCtx) {
44409
44401
  assignedMemoryUnavailable: "The Owner must configure the Supermemory Local API key secret before agent/project namespace assignments can be searched."
44410
44402
  }).slice(0, 2e4)
44411
44403
  };
44412
- const base = localApiBase(config2);
44404
+ const base = gatewayOrigin(config2);
44413
44405
  const scopedResults = await Promise.all(assigned.map(async (assignment) => {
44414
44406
  try {
44415
- const value = await localRequest(ctx, base, adminKey, localNamespacePath(assignment.namespace, "/search"), {
44407
+ const value = await ownerGatewayRequest(ctx, base, adminKey, localNamespacePath(assignment.namespace, "/search"), {
44416
44408
  method: "POST",
44417
44409
  headers: { "content-type": "application/json" },
44418
44410
  body: JSON.stringify({ query, searchMode: mode, limit })
@@ -44448,7 +44440,7 @@ async function adminConfig(ctx, companyId) {
44448
44440
  const config2 = await ctx.config.get(companyId);
44449
44441
  const key = await resolveAdminKey(ctx, config2, companyId);
44450
44442
  if (!key) throw new Error("Configura il secret Paperclip con la chiave API master di Supermemory Local in Impostazioni \u2192 Plugin \u2192 Supermemory.");
44451
- return { config: config2, key, base: localApiBase(config2) };
44443
+ return { config: config2, key, base: gatewayOrigin(config2) };
44452
44444
  }
44453
44445
  async function requireAssignment(ctx, companyId, assignmentId) {
44454
44446
  const assignments = await assignmentsFor(ctx, companyId);
@@ -44489,7 +44481,7 @@ async function listCatalog(ctx, companyId) {
44489
44481
  agents: agents.filter((agent) => !["terminated", "pending_approval"].includes(agent.status)).map((agent) => ({ id: agent.id, name: agent.name, role: String(agent.role), status: agent.status })),
44490
44482
  projects: projects.filter((project) => !project.archivedAt).map((project) => ({ id: project.id, name: project.name, visibility: project.visibility ?? "open" })),
44491
44483
  configured: Boolean(secretReference(config2.adminApiKeyRef)),
44492
- localApiUrl: localApiBase(config2)
44484
+ gatewayUrl: gatewayEndpoint(config2)
44493
44485
  };
44494
44486
  }
44495
44487
  function documentExternalId(namespace, docId) {
@@ -44552,21 +44544,11 @@ function requireTextContent(value) {
44552
44544
  }
44553
44545
  async function remoteTextDocument(ctx, base, key, assignment, docId, title, content) {
44554
44546
  const path2 = docId ? localNamespacePath(assignment.namespace, `/document/${encodeURIComponent(docId)}`) : localNamespacePath(assignment.namespace, "/document");
44555
- const response = await ctx.http.fetch(`${base}${path2}`, {
44547
+ const result = await ownerGatewayRequest(ctx, base, key, path2, {
44556
44548
  method: docId ? "PATCH" : "POST",
44557
- signal: AbortSignal.timeout(25e3),
44558
- headers: { authorization: `Bearer ${key}`, accept: "application/json", "content-type": "application/json" },
44549
+ headers: { "content-type": "application/json" },
44559
44550
  body: JSON.stringify({ ...docId ? {} : { id: `pc_${randomUUID()}` }, content, metadata: { title, source: "paperclip-memory-plugin" }, taskType: "superrag" })
44560
44551
  });
44561
- if (!response.ok) {
44562
- if (response.status === 401 || response.status === 403) throw new Error("La chiave Supermemory Local non \xE8 valida o non pu\xF2 scrivere in questo namespace.");
44563
- throw new Error(`Supermemory Local ha rifiutato il documento (HTTP ${response.status}).`);
44564
- }
44565
- let result = null;
44566
- try {
44567
- result = await response.json();
44568
- } catch {
44569
- }
44570
44552
  const parsed = isRecord(result) ? result : {};
44571
44553
  const id = typeof parsed.id === "string" ? parsed.id : docId;
44572
44554
  if (!id) throw new Error("Supermemory Local non ha restituito l\u2019ID del documento.");
@@ -44702,19 +44684,15 @@ var plugin = definePlugin({
44702
44684
  const bytes = Buffer.from(base643, "base64");
44703
44685
  if (!bytes.byteLength || bytes.byteLength > MAX_BINARY_BYTES) throw new Error("Il file deve contenere dati e non superare 6 MiB (limite del bridge Paperclip per questo upload).");
44704
44686
  if (!/^[A-Za-z0-9+/]*={0,2}$/.test(base643) || bytes.toString("base64").replace(/=+$/, "") !== base643.replace(/=+$/, "")) throw new Error("Contenuto file base64 non valido.");
44705
- const form = new FormData();
44706
- form.append("file", new File([bytes], fileName, { type: mimeType }));
44707
- form.append("metadata", JSON.stringify({ title: fileName, source: "paperclip-memory-plugin", taskType: "superrag" }));
44708
- form.append("taskType", "superrag");
44709
- if (mimeType.startsWith("image/")) {
44710
- form.append("fileType", "image");
44711
- form.append("mimeType", mimeType);
44712
- }
44713
- const result = await localRequest(ctx, base, key, localNamespacePath(assignment.namespace, "/document/file"), { method: "POST", body: form });
44687
+ const result = await ownerGatewayRequest(ctx, base, key, localNamespacePath(assignment.namespace, "/document/file"), {
44688
+ method: "POST",
44689
+ headers: { "content-type": "application/json" },
44690
+ body: JSON.stringify({ fileName, mimeType, base64: base643 })
44691
+ });
44714
44692
  const payload = isRecord(result) ? result : {};
44715
44693
  const nested = isRecord(payload.document) ? payload.document : {};
44716
44694
  const documentId = typeof payload.id === "string" ? payload.id : typeof nested.id === "string" ? nested.id : "";
44717
- if (!documentId) throw new Error("Supermemory Local non ha restituito l\u2019ID del file caricato.");
44695
+ if (!documentId) throw new Error("Il gateway Supermemory non ha restituito l\u2019ID del file caricato.");
44718
44696
  const now = (/* @__PURE__ */ new Date()).toISOString();
44719
44697
  const data = {
44720
44698
  id: documentId,
@@ -44741,7 +44719,7 @@ var plugin = definePlugin({
44741
44719
  if (!documentId) throw new Error("ID documento non valido.");
44742
44720
  const record2 = await sourceDocument(ctx, companyId, assignment.namespace, documentId);
44743
44721
  const { base, key } = await adminConfig(ctx, companyId);
44744
- await localRequest(ctx, base, key, localNamespacePath(assignment.namespace, "/document"), {
44722
+ await ownerGatewayRequest(ctx, base, key, localNamespacePath(assignment.namespace, "/document"), {
44745
44723
  method: "DELETE",
44746
44724
  headers: { "content-type": "application/json" },
44747
44725
  body: JSON.stringify({ ids: [documentId] })