UNPKG

echonodesync

Version:

Autonomous, pluggable, secure memory bridge for agent/human/ritual ecosystems (DreamWeaver, EchoThreads, etc.)

25 lines (22 loc) 840 B
// MCP action: postMemory // Usage: await postMemoryAction({ key, value }) // Extracted from postMemory.js for agent-accessible invocation const fetch = require('node-fetch'); const { resolveApiUrl, resolveSecret } = require('./shared'); async function postMemoryAction({ key, value }) { if (!key || value === undefined) throw new Error('Missing key or value'); const BASE_URL = resolveApiUrl(); const SECRET = resolveSecret(); const url = `${BASE_URL}`; const headers = { 'Content-Type': 'application/json' }; if (SECRET) headers['Authorization'] = `Bearer ${SECRET}`; const res = await fetch(url, { method: 'POST', headers, body: JSON.stringify({ key, value }) }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = await res.json(); return data; } module.exports = { postMemoryAction };