mnemosyne-core 2.1.1 → 2.1.3
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.
- package/README.md +2 -2
- package/WORKING_EXAMPLE.md +126 -0
- package/dist/cli/index.js +11 -9
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/index.mjs +11 -9
- package/dist/cli/index.mjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -5
- package/dist/index.mjs.map +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/index.mjs +1 -1
- package/dist/mcp/index.mjs.map +1 -1
- package/dist/sdk/index.d.mts +4 -0
- package/dist/sdk/index.d.ts +4 -0
- package/dist/sdk/index.js +4 -0
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/index.mjs +4 -0
- package/dist/sdk/index.mjs.map +1 -1
- package/dist/server/api.js +3 -3
- package/dist/server/api.js.map +1 -1
- package/dist/server/api.mjs +3 -3
- package/dist/server/api.mjs.map +1 -1
- package/dist/server/index.js +4 -4
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +4 -4
- package/dist/server/index.mjs.map +1 -1
- package/package.json +4 -2
package/dist/mcp/index.js
CHANGED
package/dist/mcp/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/index.ts","../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["export { McpServer } from \"./server.js\";\nexport { TOOLS } from \"./tools.js\";\nexport { McpSseTransport } from \"./sse.js\";\nexport { McpStdioTransport } from \"./stdio.js\";\nexport type { McpTool, JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n","/**\n * MCP Tool Definitions\n * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport type { McpTool } from \"./types.js\";\n\nexport const TOOLS: McpTool[] = [\n {\n name: \"nexus_list_projects\",\n description: \"List all projects in the Mnemosyne knowledge base.\",\n inputSchema: { type: \"object\", properties: {} },\n handler: (_args, store) => {\n return { projects: store.getProjects().map(p => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };\n },\n },\n {\n name: \"nexus_search\",\n description: \"Search atoms and blocks by keyword. Returns ranked results.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Project name or ID (optional)\" },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n handler: (args, store) => {\n const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : \"\";\n const results = store.search(projectId, args.query, args.limit || 10);\n return { query: args.query, count: results.length, results };\n },\n },\n {\n name: \"nexus_read_atom\",\n description: \"Read an atom by ID or title. Returns atom details, blocks, children, and bonds.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"Atom title (alternative to id)\" },\n project: { type: \"string\", description: \"Project name (required if searching by title)\" },\n },\n required: [],\n },\n handler: (args, store) => {\n let atom = args.id ? store.getAtom(args.id) : undefined;\n if (!atom && args.title && args.project) {\n const projectId = store.getProjectByName(args.project)?.id || args.project;\n atom = store.getAtomsByProject(projectId).find(a => a.title === args.title);\n }\n if (!atom) throw new Error(\"Atom not found\");\n const children = store.getAtomChildren(atom.id).map(a => ({ id: a.id, title: a.title, type: a.metadata?.type || \"text\" }));\n const blocks = store.getBlocksByAtom(atom.id);\n const bonds = store.getBondsByAtom(atom.id);\n return { atom, children, blocks, bonds };\n },\n },\n {\n name: \"nexus_create_atom\",\n description: \"Create a new atom in a project.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project name or ID\" },\n title: { type: \"string\", description: \"Atom title/path\" },\n type: { type: \"string\", description: \"Atom type (text, memory, stream, thought, task)\" },\n parent_id: { type: \"string\", description: \"Parent atom ID (optional)\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Tags (optional)\" },\n assistant_id: { type: \"string\", description: \"Creator assistant ID\" },\n },\n required: [\"project\", \"title\"],\n },\n handler: (args, store) => {\n const project = store.getProjectByName(args.project) || store.getProject(args.project);\n if (!project) throw new Error(\"Project not found\");\n const assistantId = args.assistant_id || \"mcp-assistant\";\n const atom = store.createAtom(project.id, args.title, args.type || \"text\", assistantId, {\n parentId: args.parent_id,\n tags: args.tags,\n });\n return { success: true, atom };\n },\n },\n {\n name: \"nexus_update_atom\",\n description: \"Update an atom's title or parent.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"New title\" },\n parent_id: { type: [\"string\", \"null\"], description: \"New parent ID or null for root\" },\n assistant_id: { type: \"string\", description: \"Updater assistant ID\" },\n },\n required: [\"id\"],\n },\n handler: (args, store) => {\n const assistantId = args.assistant_id || \"mcp-assistant\";\n if (args.parent_id !== undefined) {\n const updated = store.updateAtomParent(args.id, args.parent_id, assistantId);\n if (!updated) throw new Error(\"Invalid parent or atom not found\");\n }\n const updated = store.updateAtom(args.id, { title: args.title }, assistantId);\n return { success: true, atom: updated || store.getAtom(args.id) };\n },\n },\n {\n name: \"nexus_create_bond\",\n description: \"Create a bond (graph connection) between two atoms.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source_id: { type: \"string\", description: \"Source atom ID\" },\n target_id: { type: \"string\", description: \"Target atom ID\" },\n label: { type: \"string\", description: \"Bond label (default: connects)\" },\n color: { type: \"string\", description: \"Hex color (optional)\" },\n },\n required: [\"source_id\", \"target_id\"],\n },\n handler: (args, store) => {\n const bond = store.createBond(args.source_id, args.target_id, args.label || \"connects\", args.color);\n return { success: true, bond };\n },\n },\n {\n name: \"nexus_request_checkout\",\n description: \"Request an exclusive checkout (lock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant requesting checkout\" },\n reason: { type: \"string\", description: \"Reason for checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const result = store.checkout(args.atom_id, args.assistant_id, \"exclusive\", args.reason || \"\");\n return result;\n },\n },\n {\n name: \"nexus_release_checkout\",\n description: \"Release a checkout (unlock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant releasing checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const success = store.releaseCheckout(args.atom_id, args.assistant_id);\n return { success };\n },\n },\n {\n name: \"nexus_subscribe_to_atom\",\n description: \"Subscribe to real-time updates for an atom via WebSocket.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID to subscribe to\" },\n },\n required: [\"atom_id\"],\n },\n handler: (args, _store) => {\n return { success: true, wsEndpoint: \"ws://localhost:7321/ws\", atom_id: args.atom_id, message: \"Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }\" };\n },\n },\n {\n name: \"nexus_batch\",\n description: \"Execute multiple MCP tools in a single request. Reduces round-trip token waste.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operations: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n tool: { type: \"string\", description: \"Tool name to call\" },\n params: { type: \"object\", description: \"Parameters for the tool\" },\n },\n required: [\"tool\"],\n },\n description: \"Ordered list of tool calls\",\n },\n stop_on_error: { type: \"boolean\", description: \"If true, stop at first error. Default: false\", default: false },\n },\n required: [\"operations\"],\n },\n handler: (args, store) => {\n const operations = args.operations || [];\n const stopOnError = args.stop_on_error ?? false;\n const results: any[] = [];\n const toolMap = new Map<string, McpTool>();\n for (const t of TOOLS) toolMap.set(t.name, t);\n\n for (let i = 0; i < operations.length; i++) {\n const op = operations[i];\n const tool = toolMap.get(op.tool);\n if (!tool) {\n results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });\n if (stopOnError) break;\n continue;\n }\n try {\n const result = tool.handler(op.params || {}, store);\n results.push({ index: i, tool: op.tool, success: true, result });\n } catch (err: any) {\n results.push({ index: i, tool: op.tool, error: err.message });\n if (stopOnError) break;\n }\n }\n return { count: operations.length, completed: results.length, results };\n },\n },\n];\n","/**\n * MCP Server\n * JSON-RPC handler for Model Context Protocol.\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport { TOOLS } from \"./tools.js\";\nimport type { JsonRpcRequest, JsonRpcResponse, McpTool } from \"./types.js\";\n\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.1.0\";\n }\n }\n}\n\nexport class McpServer {\n private store: Store;\n private toolMap = new Map<string, McpTool>();\n\n constructor(store: Store) {\n this.store = store;\n for (const t of TOOLS) this.toolMap.set(t.name, t);\n }\n\n /**\n * Returns `null` for notifications (no response needed).\n */\n handleRequest(req: JsonRpcRequest): JsonRpcResponse | null {\n // Notifications have no id — do not send a response\n if (req.id === null || req.id === undefined) {\n return null;\n }\n\n try {\n switch (req.method) {\n case \"initialize\":\n return this.ok(req.id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {}, resources: {}, prompts: {} },\n serverInfo: { name: \"mnemosyne-mcp\", version: getVersion() },\n });\n\n case \"tools/list\":\n return this.ok(req.id, {\n tools: TOOLS.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),\n });\n\n case \"tools/call\": {\n const { name, arguments: args } = req.params || {};\n const tool = this.toolMap.get(name);\n if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);\n const result = tool.handler(args || {}, this.store);\n return this.ok(req.id, { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }] });\n }\n\n case \"resources/list\":\n return this.ok(req.id, { resources: [] });\n\n case \"prompts/list\":\n return this.ok(req.id, { prompts: [] });\n\n default:\n return this.err(req.id, -32601, `Method not found: ${req.method}`);\n }\n } catch (e: any) {\n return this.err(req.id, -32603, e.message);\n }\n }\n\n getManifest() {\n return {\n name: \"Mnemosyne\",\n version: getVersion(),\n description: \"Knowledge base MCP server for projects, atoms, blocks, and bonds.\",\n protocol: \"mcp\",\n transport: [\"stdio\", \"sse\"],\n endpoints: {\n sse: \"/mcp/sse\",\n messages: \"/mcp/messages\",\n },\n tools: TOOLS.map(t => ({ name: t.name, description: t.description })),\n };\n }\n\n private ok(id: string | number | null, result: any): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, result };\n }\n private err(id: string | number | null, code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n }\n}\n","/**\n * MCP SSE Transport\n * Server-Sent Events transport for MCP over HTTP.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest } from \"./types.js\";\n\ninterface SseSession {\n id: string;\n res: import(\"http\").ServerResponse;\n}\n\nexport class McpSseTransport {\n private server: McpServer;\n private sessions = new Map<string, SseSession>();\n private sessionCounter = 0;\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n handleSse(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse): void {\n const id = `sess_${++this.sessionCounter}_${Date.now()}`;\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n \"Connection\": \"keep-alive\",\n });\n this.sessions.set(id, { id, res });\n\n // Send endpoint event\n this.sendSse(id, \"endpoint\", \"/mcp/messages?session_id=\" + id);\n\n req.on(\"close\", () => this.sessions.delete(id));\n }\n\n handleMessage(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse, body: any): void {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n const sessionId = url.searchParams.get(\"session_id\") || \"\";\n\n const request = body as JsonRpcRequest;\n if (!request || request.jsonrpc !== \"2.0\") {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"invalid_jsonrpc\" }));\n return;\n }\n\n const response = this.server.handleRequest(request);\n // Notifications return null — send empty 200\n if (!response) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n return;\n }\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(response));\n\n // Also broadcast via SSE if the session is active\n if (sessionId) this.sendSse(sessionId, \"message\", JSON.stringify(response));\n }\n\n private sendSse(sessionId: string, event: string, data: string): void {\n const session = this.sessions.get(sessionId);\n if (!session) return;\n session.res.write(`event: ${event}\\ndata: ${data}\\n\\n`);\n }\n}\n","/**\n * MCP Stdio Transport\n * Line-delimited JSON-RPC over stdin/stdout.\n * This is what Claude Desktop uses to communicate with MCP servers.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n\nexport class McpStdioTransport {\n private server: McpServer;\n private buffer = \"\";\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n start(): void {\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n process.stdin.on(\"data\", (chunk: string) => {\n this.buffer += chunk;\n const lines = this.buffer.split(\"\\n\");\n this.buffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const request = JSON.parse(line) as JsonRpcRequest;\n const response = this.server.handleRequest(request);\n if (response) this.send(response);\n // Notifications return null — no output\n } catch (err: any) {\n this.send({ jsonrpc: \"2.0\", id: null, error: { code: -32700, message: \"Parse error: \" + err.message } });\n }\n }\n });\n\n process.stdin.on(\"end\", () => {\n process.exit(0);\n });\n }\n\n send(message: JsonRpcResponse):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AI;AACF,gBAAM,UAAU,KAAK,MAAM,IAAI;AAC/B,gBAAM,WAAW,KAAK,OAAO,cAAc,OAAO;AAClD,cAAI,SAAU,MAAK,KAAK,QAAQ;AAAA,QAElC,SAAS,KAAU;AACjB,eAAK,KAAK,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/index.ts","../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["export { McpServer } from \"./server.js\";\nexport { TOOLS } from \"./tools.js\";\nexport { McpSseTransport } from \"./sse.js\";\nexport { McpStdioTransport } from \"./stdio.js\";\nexport type { McpTool, JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n","/**\n * MCP Tool Definitions\n * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport type { McpTool } from \"./types.js\";\n\nexport const TOOLS: McpTool[] = [\n {\n name: \"nexus_list_projects\",\n description: \"List all projects in the Mnemosyne knowledge base.\",\n inputSchema: { type: \"object\", properties: {} },\n handler: (_args, store) => {\n return { projects: store.getProjects().map(p => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };\n },\n },\n {\n name: \"nexus_search\",\n description: \"Search atoms and blocks by keyword. Returns ranked results.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Project name or ID (optional)\" },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n handler: (args, store) => {\n const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : \"\";\n const results = store.search(projectId, args.query, args.limit || 10);\n return { query: args.query, count: results.length, results };\n },\n },\n {\n name: \"nexus_read_atom\",\n description: \"Read an atom by ID or title. Returns atom details, blocks, children, and bonds.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"Atom title (alternative to id)\" },\n project: { type: \"string\", description: \"Project name (required if searching by title)\" },\n },\n required: [],\n },\n handler: (args, store) => {\n let atom = args.id ? store.getAtom(args.id) : undefined;\n if (!atom && args.title && args.project) {\n const projectId = store.getProjectByName(args.project)?.id || args.project;\n atom = store.getAtomsByProject(projectId).find(a => a.title === args.title);\n }\n if (!atom) throw new Error(\"Atom not found\");\n const children = store.getAtomChildren(atom.id).map(a => ({ id: a.id, title: a.title, type: a.metadata?.type || \"text\" }));\n const blocks = store.getBlocksByAtom(atom.id);\n const bonds = store.getBondsByAtom(atom.id);\n return { atom, children, blocks, bonds };\n },\n },\n {\n name: \"nexus_create_atom\",\n description: \"Create a new atom in a project.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project name or ID\" },\n title: { type: \"string\", description: \"Atom title/path\" },\n type: { type: \"string\", description: \"Atom type (text, memory, stream, thought, task)\" },\n parent_id: { type: \"string\", description: \"Parent atom ID (optional)\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Tags (optional)\" },\n assistant_id: { type: \"string\", description: \"Creator assistant ID\" },\n },\n required: [\"project\", \"title\"],\n },\n handler: (args, store) => {\n const project = store.getProjectByName(args.project) || store.getProject(args.project);\n if (!project) throw new Error(\"Project not found\");\n const assistantId = args.assistant_id || \"mcp-assistant\";\n const atom = store.createAtom(project.id, args.title, args.type || \"text\", assistantId, {\n parentId: args.parent_id,\n tags: args.tags,\n });\n return { success: true, atom };\n },\n },\n {\n name: \"nexus_update_atom\",\n description: \"Update an atom's title or parent.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"New title\" },\n parent_id: { type: [\"string\", \"null\"], description: \"New parent ID or null for root\" },\n assistant_id: { type: \"string\", description: \"Updater assistant ID\" },\n },\n required: [\"id\"],\n },\n handler: (args, store) => {\n const assistantId = args.assistant_id || \"mcp-assistant\";\n if (args.parent_id !== undefined) {\n const updated = store.updateAtomParent(args.id, args.parent_id, assistantId);\n if (!updated) throw new Error(\"Invalid parent or atom not found\");\n }\n const updated = store.updateAtom(args.id, { title: args.title }, assistantId);\n return { success: true, atom: updated || store.getAtom(args.id) };\n },\n },\n {\n name: \"nexus_create_bond\",\n description: \"Create a bond (graph connection) between two atoms.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source_id: { type: \"string\", description: \"Source atom ID\" },\n target_id: { type: \"string\", description: \"Target atom ID\" },\n label: { type: \"string\", description: \"Bond label (default: connects)\" },\n color: { type: \"string\", description: \"Hex color (optional)\" },\n },\n required: [\"source_id\", \"target_id\"],\n },\n handler: (args, store) => {\n const bond = store.createBond(args.source_id, args.target_id, args.label || \"connects\", args.color);\n return { success: true, bond };\n },\n },\n {\n name: \"nexus_request_checkout\",\n description: \"Request an exclusive checkout (lock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant requesting checkout\" },\n reason: { type: \"string\", description: \"Reason for checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const result = store.checkout(args.atom_id, args.assistant_id, \"exclusive\", args.reason || \"\");\n return result;\n },\n },\n {\n name: \"nexus_release_checkout\",\n description: \"Release a checkout (unlock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant releasing checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const success = store.releaseCheckout(args.atom_id, args.assistant_id);\n return { success };\n },\n },\n {\n name: \"nexus_subscribe_to_atom\",\n description: \"Subscribe to real-time updates for an atom via WebSocket.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID to subscribe to\" },\n },\n required: [\"atom_id\"],\n },\n handler: (args, _store) => {\n return { success: true, wsEndpoint: \"ws://localhost:7321/ws\", atom_id: args.atom_id, message: \"Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }\" };\n },\n },\n {\n name: \"nexus_batch\",\n description: \"Execute multiple MCP tools in a single request. Reduces round-trip token waste.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operations: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n tool: { type: \"string\", description: \"Tool name to call\" },\n params: { type: \"object\", description: \"Parameters for the tool\" },\n },\n required: [\"tool\"],\n },\n description: \"Ordered list of tool calls\",\n },\n stop_on_error: { type: \"boolean\", description: \"If true, stop at first error. Default: false\", default: false },\n },\n required: [\"operations\"],\n },\n handler: (args, store) => {\n const operations = args.operations || [];\n const stopOnError = args.stop_on_error ?? false;\n const results: any[] = [];\n const toolMap = new Map<string, McpTool>();\n for (const t of TOOLS) toolMap.set(t.name, t);\n\n for (let i = 0; i < operations.length; i++) {\n const op = operations[i];\n const tool = toolMap.get(op.tool);\n if (!tool) {\n results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });\n if (stopOnError) break;\n continue;\n }\n try {\n const result = tool.handler(op.params || {}, store);\n results.push({ index: i, tool: op.tool, success: true, result });\n } catch (err: any) {\n results.push({ index: i, tool: op.tool, error: err.message });\n if (stopOnError) break;\n }\n }\n return { count: operations.length, completed: results.length, results };\n },\n },\n];\n","/**\n * MCP Server\n * JSON-RPC handler for Model Context Protocol.\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport { TOOLS } from \"./tools.js\";\nimport type { JsonRpcRequest, JsonRpcResponse, McpTool } from \"./types.js\";\n\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.1.3\";\n }\n }\n}\n\nexport class McpServer {\n private store: Store;\n private toolMap = new Map<string, McpTool>();\n\n constructor(store: Store) {\n this.store = store;\n for (const t of TOOLS) this.toolMap.set(t.name, t);\n }\n\n /**\n * Returns `null` for notifications (no response needed).\n */\n handleRequest(req: JsonRpcRequest): JsonRpcResponse | null {\n // Notifications have no id — do not send a response\n if (req.id === null || req.id === undefined) {\n return null;\n }\n\n try {\n switch (req.method) {\n case \"initialize\":\n return this.ok(req.id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {}, resources: {}, prompts: {} },\n serverInfo: { name: \"mnemosyne-mcp\", version: getVersion() },\n });\n\n case \"tools/list\":\n return this.ok(req.id, {\n tools: TOOLS.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),\n });\n\n case \"tools/call\": {\n const { name, arguments: args } = req.params || {};\n const tool = this.toolMap.get(name);\n if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);\n const result = tool.handler(args || {}, this.store);\n return this.ok(req.id, { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }] });\n }\n\n case \"resources/list\":\n return this.ok(req.id, { resources: [] });\n\n case \"prompts/list\":\n return this.ok(req.id, { prompts: [] });\n\n default:\n return this.err(req.id, -32601, `Method not found: ${req.method}`);\n }\n } catch (e: any) {\n return this.err(req.id, -32603, e.message);\n }\n }\n\n getManifest() {\n return {\n name: \"Mnemosyne\",\n version: getVersion(),\n description: \"Knowledge base MCP server for projects, atoms, blocks, and bonds.\",\n protocol: \"mcp\",\n transport: [\"stdio\", \"sse\"],\n endpoints: {\n sse: \"/mcp/sse\",\n messages: \"/mcp/messages\",\n },\n tools: TOOLS.map(t => ({ name: t.name, description: t.description })),\n };\n }\n\n private ok(id: string | number | null, result: any): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, result };\n }\n private err(id: string | number | null, code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n }\n}\n","/**\n * MCP SSE Transport\n * Server-Sent Events transport for MCP over HTTP.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest } from \"./types.js\";\n\ninterface SseSession {\n id: string;\n res: import(\"http\").ServerResponse;\n}\n\nexport class McpSseTransport {\n private server: McpServer;\n private sessions = new Map<string, SseSession>();\n private sessionCounter = 0;\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n handleSse(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse): void {\n const id = `sess_${++this.sessionCounter}_${Date.now()}`;\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n \"Connection\": \"keep-alive\",\n });\n this.sessions.set(id, { id, res });\n\n // Send endpoint event\n this.sendSse(id, \"endpoint\", \"/mcp/messages?session_id=\" + id);\n\n req.on(\"close\", () => this.sessions.delete(id));\n }\n\n handleMessage(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse, body: any): void {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n const sessionId = url.searchParams.get(\"session_id\") || \"\";\n\n const request = body as JsonRpcRequest;\n if (!request || request.jsonrpc !== \"2.0\") {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"invalid_jsonrpc\" }));\n return;\n }\n\n const response = this.server.handleRequest(request);\n // Notifications return null — send empty 200\n if (!response) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n return;\n }\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(response));\n\n // Also broadcast via SSE if the session is active\n if (sessionId) this.sendSse(sessionId, \"message\", JSON.stringify(response));\n }\n\n private sendSse(sessionId: string, event: string, data: string): void {\n const session = this.sessions.get(sessionId);\n if (!session) return;\n session.res.write(`event: ${event}\\ndata: ${data}\\n\\n`);\n }\n}\n","/**\n * MCP Stdio Transport\n * Line-delimited JSON-RPC over stdin/stdout.\n * This is what Claude Desktop uses to communicate with MCP servers.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n\nexport class McpStdioTransport {\n private server: McpServer;\n private buffer = \"\";\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n start(): void {\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n process.stdin.on(\"data\", (chunk: string) => {\n this.buffer += chunk;\n const lines = this.buffer.split(\"\\n\");\n this.buffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const request = JSON.parse(line) as JsonRpcRequest;\n const response = this.server.handleRequest(request);\n if (response) this.send(response);\n // Notifications return null — no output\n } catch (err: any) {\n this.send({ jsonrpc: \"2.0\", id: null, error: { code: -32700, message: \"Parse error: \" + err.message } });\n }\n }\n });\n\n process.stdin.on(\"end\", () => {\n process.exit(0);\n });\n }\n\n send(message: JsonRpcResponse): void {\n process.stdout.write(JSON.stringify(message) + \"\\n\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,QAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa,EAAE,MAAM,UAAU,YAAY,CAAC,EAAE;AAAA,IAC9C,SAAS,CAAC,OAAO,UAAU;AACzB,aAAO,EAAE,UAAU,MAAM,YAAY,EAAE,IAAI,QAAM,EAAE,IAAI,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AK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
package/dist/mcp/index.mjs
CHANGED
package/dist/mcp/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["/**\n * MCP Tool Definitions\n * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport type { McpTool } from \"./types.js\";\n\nexport const TOOLS: McpTool[] = [\n {\n name: \"nexus_list_projects\",\n description: \"List all projects in the Mnemosyne knowledge base.\",\n inputSchema: { type: \"object\", properties: {} },\n handler: (_args, store) => {\n return { projects: store.getProjects().map(p => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };\n },\n },\n {\n name: \"nexus_search\",\n description: \"Search atoms and blocks by keyword. Returns ranked results.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Project name or ID (optional)\" },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n handler: (args, store) => {\n const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : \"\";\n const results = store.search(projectId, args.query, args.limit || 10);\n return { query: args.query, count: results.length, results };\n },\n },\n {\n name: \"nexus_read_atom\",\n description: \"Read an atom by ID or title. Returns atom details, blocks, children, and bonds.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"Atom title (alternative to id)\" },\n project: { type: \"string\", description: \"Project name (required if searching by title)\" },\n },\n required: [],\n },\n handler: (args, store) => {\n let atom = args.id ? store.getAtom(args.id) : undefined;\n if (!atom && args.title && args.project) {\n const projectId = store.getProjectByName(args.project)?.id || args.project;\n atom = store.getAtomsByProject(projectId).find(a => a.title === args.title);\n }\n if (!atom) throw new Error(\"Atom not found\");\n const children = store.getAtomChildren(atom.id).map(a => ({ id: a.id, title: a.title, type: a.metadata?.type || \"text\" }));\n const blocks = store.getBlocksByAtom(atom.id);\n const bonds = store.getBondsByAtom(atom.id);\n return { atom, children, blocks, bonds };\n },\n },\n {\n name: \"nexus_create_atom\",\n description: \"Create a new atom in a project.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project name or ID\" },\n title: { type: \"string\", description: \"Atom title/path\" },\n type: { type: \"string\", description: \"Atom type (text, memory, stream, thought, task)\" },\n parent_id: { type: \"string\", description: \"Parent atom ID (optional)\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Tags (optional)\" },\n assistant_id: { type: \"string\", description: \"Creator assistant ID\" },\n },\n required: [\"project\", \"title\"],\n },\n handler: (args, store) => {\n const project = store.getProjectByName(args.project) || store.getProject(args.project);\n if (!project) throw new Error(\"Project not found\");\n const assistantId = args.assistant_id || \"mcp-assistant\";\n const atom = store.createAtom(project.id, args.title, args.type || \"text\", assistantId, {\n parentId: args.parent_id,\n tags: args.tags,\n });\n return { success: true, atom };\n },\n },\n {\n name: \"nexus_update_atom\",\n description: \"Update an atom's title or parent.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"New title\" },\n parent_id: { type: [\"string\", \"null\"], description: \"New parent ID or null for root\" },\n assistant_id: { type: \"string\", description: \"Updater assistant ID\" },\n },\n required: [\"id\"],\n },\n handler: (args, store) => {\n const assistantId = args.assistant_id || \"mcp-assistant\";\n if (args.parent_id !== undefined) {\n const updated = store.updateAtomParent(args.id, args.parent_id, assistantId);\n if (!updated) throw new Error(\"Invalid parent or atom not found\");\n }\n const updated = store.updateAtom(args.id, { title: args.title }, assistantId);\n return { success: true, atom: updated || store.getAtom(args.id) };\n },\n },\n {\n name: \"nexus_create_bond\",\n description: \"Create a bond (graph connection) between two atoms.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source_id: { type: \"string\", description: \"Source atom ID\" },\n target_id: { type: \"string\", description: \"Target atom ID\" },\n label: { type: \"string\", description: \"Bond label (default: connects)\" },\n color: { type: \"string\", description: \"Hex color (optional)\" },\n },\n required: [\"source_id\", \"target_id\"],\n },\n handler: (args, store) => {\n const bond = store.createBond(args.source_id, args.target_id, args.label || \"connects\", args.color);\n return { success: true, bond };\n },\n },\n {\n name: \"nexus_request_checkout\",\n description: \"Request an exclusive checkout (lock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant requesting checkout\" },\n reason: { type: \"string\", description: \"Reason for checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const result = store.checkout(args.atom_id, args.assistant_id, \"exclusive\", args.reason || \"\");\n return result;\n },\n },\n {\n name: \"nexus_release_checkout\",\n description: \"Release a checkout (unlock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant releasing checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const success = store.releaseCheckout(args.atom_id, args.assistant_id);\n return { success };\n },\n },\n {\n name: \"nexus_subscribe_to_atom\",\n description: \"Subscribe to real-time updates for an atom via WebSocket.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID to subscribe to\" },\n },\n required: [\"atom_id\"],\n },\n handler: (args, _store) => {\n return { success: true, wsEndpoint: \"ws://localhost:7321/ws\", atom_id: args.atom_id, message: \"Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }\" };\n },\n },\n {\n name: \"nexus_batch\",\n description: \"Execute multiple MCP tools in a single request. Reduces round-trip token waste.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operations: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n tool: { type: \"string\", description: \"Tool name to call\" },\n params: { type: \"object\", description: \"Parameters for the tool\" },\n },\n required: [\"tool\"],\n },\n description: \"Ordered list of tool calls\",\n },\n stop_on_error: { type: \"boolean\", description: \"If true, stop at first error. Default: false\", default: false },\n },\n required: [\"operations\"],\n },\n handler: (args, store) => {\n const operations = args.operations || [];\n const stopOnError = args.stop_on_error ?? false;\n const results: any[] = [];\n const toolMap = new Map<string, McpTool>();\n for (const t of TOOLS) toolMap.set(t.name, t);\n\n for (let i = 0; i < operations.length; i++) {\n const op = operations[i];\n const tool = toolMap.get(op.tool);\n if (!tool) {\n results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });\n if (stopOnError) break;\n continue;\n }\n try {\n const result = tool.handler(op.params || {}, store);\n results.push({ index: i, tool: op.tool, success: true, result });\n } catch (err: any) {\n results.push({ index: i, tool: op.tool, error: err.message });\n if (stopOnError) break;\n }\n }\n return { count: operations.length, completed: results.length, results };\n },\n },\n];\n","/**\n * MCP Server\n * JSON-RPC handler for Model Context Protocol.\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport { TOOLS } from \"./tools.js\";\nimport type { JsonRpcRequest, JsonRpcResponse, McpTool } from \"./types.js\";\n\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.1.0\";\n }\n }\n}\n\nexport class McpServer {\n private store: Store;\n private toolMap = new Map<string, McpTool>();\n\n constructor(store: Store) {\n this.store = store;\n for (const t of TOOLS) this.toolMap.set(t.name, t);\n }\n\n /**\n * Returns `null` for notifications (no response needed).\n */\n handleRequest(req: JsonRpcRequest): JsonRpcResponse | null {\n // Notifications have no id — do not send a response\n if (req.id === null || req.id === undefined) {\n return null;\n }\n\n try {\n switch (req.method) {\n case \"initialize\":\n return this.ok(req.id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {}, resources: {}, prompts: {} },\n serverInfo: { name: \"mnemosyne-mcp\", version: getVersion() },\n });\n\n case \"tools/list\":\n return this.ok(req.id, {\n tools: TOOLS.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),\n });\n\n case \"tools/call\": {\n const { name, arguments: args } = req.params || {};\n const tool = this.toolMap.get(name);\n if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);\n const result = tool.handler(args || {}, this.store);\n return this.ok(req.id, { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }] });\n }\n\n case \"resources/list\":\n return this.ok(req.id, { resources: [] });\n\n case \"prompts/list\":\n return this.ok(req.id, { prompts: [] });\n\n default:\n return this.err(req.id, -32601, `Method not found: ${req.method}`);\n }\n } catch (e: any) {\n return this.err(req.id, -32603, e.message);\n }\n }\n\n getManifest() {\n return {\n name: \"Mnemosyne\",\n version: getVersion(),\n description: \"Knowledge base MCP server for projects, atoms, blocks, and bonds.\",\n protocol: \"mcp\",\n transport: [\"stdio\", \"sse\"],\n endpoints: {\n sse: \"/mcp/sse\",\n messages: \"/mcp/messages\",\n },\n tools: TOOLS.map(t => ({ name: t.name, description: t.description })),\n };\n }\n\n private ok(id: string | number | null, result: any): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, result };\n }\n private err(id: string | number | null, code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n }\n}\n","/**\n * MCP SSE Transport\n * Server-Sent Events transport for MCP over HTTP.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest } from \"./types.js\";\n\ninterface SseSession {\n id: string;\n res: import(\"http\").ServerResponse;\n}\n\nexport class McpSseTransport {\n private server: McpServer;\n private sessions = new Map<string, SseSession>();\n private sessionCounter = 0;\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n handleSse(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse): void {\n const id = `sess_${++this.sessionCounter}_${Date.now()}`;\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n \"Connection\": \"keep-alive\",\n });\n this.sessions.set(id, { id, res });\n\n // Send endpoint event\n this.sendSse(id, \"endpoint\", \"/mcp/messages?session_id=\" + id);\n\n req.on(\"close\", () => this.sessions.delete(id));\n }\n\n handleMessage(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse, body: any): void {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n const sessionId = url.searchParams.get(\"session_id\") || \"\";\n\n const request = body as JsonRpcRequest;\n if (!request || request.jsonrpc !== \"2.0\") {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"invalid_jsonrpc\" }));\n return;\n }\n\n const response = this.server.handleRequest(request);\n // Notifications return null — send empty 200\n if (!response) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n return;\n }\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(response));\n\n // Also broadcast via SSE if the session is active\n if (sessionId) this.sendSse(sessionId, \"message\", JSON.stringify(response));\n }\n\n private sendSse(sessionId: string, event: string, data: string): void {\n const session = this.sessions.get(sessionId);\n if (!session) return;\n session.res.write(`event: ${event}\\ndata: ${data}\\n\\n`);\n }\n}\n","/**\n * MCP Stdio Transport\n * Line-delimited JSON-RPC over stdin/stdout.\n * This is what Claude Desktop uses to communicate with MCP servers.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n\nexport class McpStdioTransport {\n private server: McpServer;\n private buffer = \"\";\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n start(): void {\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n process.stdin.on(\"data\", (chunk: string) => {\n this.buffer += chunk;\n const lines = this.buffer.split(\"\\n\");\n this.buffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const request = JSON.parse(line) as JsonRpcRequest;\n const response = this.server.handleRequest(request);\n if (response) this.send(response);\n // Notifications return null — no output\n } catch (err: any) {\n this.send({ jsonrpc: \"2.0\", id: null, error: { code: -32700, message: \"Parse error: \" + err.message } });\n }\n }\n });\n\n process.stdin.on(\"end\", () => {\n process.exit(0);\n });\n }\n\n send(message: JsonRpcResponse): void {\n process.stdout.write(JSON.stringify(message) + \"\\n\");\n }\n}\n"],"mappings":";;;;;;;;AAQO,IAAM,QAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa,EAAE,MAAM,UAAU,YAAY,CAAC,EAAE;AAAA,IAC9C,SAAS,CAAC,OAAO,UAAU;AACzB,aAAO,EAAE,UAAU,MAAM,YAAY,EAAE,IAAI,QAAM,EAAE,IAAI,EAAE,IAAI,MAAM,EAAE,MAAM,aAAa,EAAE,aAAa,WAAW,MAAM,kBAAkB,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE;AAAA,IAC7J;AAAA,EACF;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa;AAAA,MACX,MAAM;AAAA,MACN,YAAY;AAAA,QACV,OAAO,EAAE,MAAM,UAAU,aAAa,eAAe;AAAA,QACrD,SAAS,EAAE,MAAM,UAAU,aAAa,gCAAgC;AAAA,QACxE,OAAO,EAAE,MAAM,UAAU,aAAa,2BAA2B;AAAA,MACnE;AAAA,MACA,UAAU,CAAC,OAAO;AAAA,IACpB;AAAA,IACA,SAAS,CAAC,MAAM,UAAU;AACxB,YAAM,YAAY,KAAK,UAAU,MAAM,iBAAiB,KAAK,O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ACrB;AAAA,EACA,SAAS;AAAA,EAEjB,YAAY,QAAmB;AAC7B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,QAAc;AACZ,YAAQ,MAAM,YAAY,MAAM;AAChC,YAAQ,MAAM,OAAO;AAErB,YAAQ,MAAM,GAAG,QAAQ,CAAC,UAAkB;AAC1C,WAAK,UAAU;AACf,YAAM,QAAQ,KAAK,OAAO,MAAM,IAAI;AACpC,WAAK,SAAS,MAAM,IAAI,KAAK;AAE7B,iBAAW,QAAQ,OAAO;AACxB,YAAI,CAAC,KAAK,KAAK,EAAG;AAClB,YAAI;AACF,gBAAM,UAAU,KAAK,MAAM,IAAI;AAC/B,gBAAM,WAAW,KAAK,OAAO,cAAc,OAAO;AAClD,cAAI,SAAU,MAAK,KAAK,QAAQ;AAAA,QAElC,SAAS,KAAU;AACjB,eAAK,KAAK,EAAE,SAAS,OAAO,IAAI,MAAM,OAAO,EAAE,MAAM,QAAQ,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
|
1
|
+
{"version":3,"sources":["../../src/mcp/tools.ts","../../src/mcp/server.ts","../../src/mcp/sse.ts","../../src/mcp/stdio.ts"],"sourcesContent":["/**\n * MCP Tool Definitions\n * All tools exposed to MCP clients (Claude Desktop, Cursor, etc.)\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport type { McpTool } from \"./types.js\";\n\nexport const TOOLS: McpTool[] = [\n {\n name: \"nexus_list_projects\",\n description: \"List all projects in the Mnemosyne knowledge base.\",\n inputSchema: { type: \"object\", properties: {} },\n handler: (_args, store) => {\n return { projects: store.getProjects().map(p => ({ id: p.id, name: p.name, description: p.description, atomCount: store.getAtomsByProject(p.id).length })) };\n },\n },\n {\n name: \"nexus_search\",\n description: \"Search atoms and blocks by keyword. Returns ranked results.\",\n inputSchema: {\n type: \"object\",\n properties: {\n query: { type: \"string\", description: \"Search query\" },\n project: { type: \"string\", description: \"Project name or ID (optional)\" },\n limit: { type: \"number\", description: \"Max results (default 10)\" },\n },\n required: [\"query\"],\n },\n handler: (args, store) => {\n const projectId = args.project ? store.getProjectByName(args.project)?.id || args.project : \"\";\n const results = store.search(projectId, args.query, args.limit || 10);\n return { query: args.query, count: results.length, results };\n },\n },\n {\n name: \"nexus_read_atom\",\n description: \"Read an atom by ID or title. Returns atom details, blocks, children, and bonds.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"Atom title (alternative to id)\" },\n project: { type: \"string\", description: \"Project name (required if searching by title)\" },\n },\n required: [],\n },\n handler: (args, store) => {\n let atom = args.id ? store.getAtom(args.id) : undefined;\n if (!atom && args.title && args.project) {\n const projectId = store.getProjectByName(args.project)?.id || args.project;\n atom = store.getAtomsByProject(projectId).find(a => a.title === args.title);\n }\n if (!atom) throw new Error(\"Atom not found\");\n const children = store.getAtomChildren(atom.id).map(a => ({ id: a.id, title: a.title, type: a.metadata?.type || \"text\" }));\n const blocks = store.getBlocksByAtom(atom.id);\n const bonds = store.getBondsByAtom(atom.id);\n return { atom, children, blocks, bonds };\n },\n },\n {\n name: \"nexus_create_atom\",\n description: \"Create a new atom in a project.\",\n inputSchema: {\n type: \"object\",\n properties: {\n project: { type: \"string\", description: \"Project name or ID\" },\n title: { type: \"string\", description: \"Atom title/path\" },\n type: { type: \"string\", description: \"Atom type (text, memory, stream, thought, task)\" },\n parent_id: { type: \"string\", description: \"Parent atom ID (optional)\" },\n tags: { type: \"array\", items: { type: \"string\" }, description: \"Tags (optional)\" },\n assistant_id: { type: \"string\", description: \"Creator assistant ID\" },\n },\n required: [\"project\", \"title\"],\n },\n handler: (args, store) => {\n const project = store.getProjectByName(args.project) || store.getProject(args.project);\n if (!project) throw new Error(\"Project not found\");\n const assistantId = args.assistant_id || \"mcp-assistant\";\n const atom = store.createAtom(project.id, args.title, args.type || \"text\", assistantId, {\n parentId: args.parent_id,\n tags: args.tags,\n });\n return { success: true, atom };\n },\n },\n {\n name: \"nexus_update_atom\",\n description: \"Update an atom's title or parent.\",\n inputSchema: {\n type: \"object\",\n properties: {\n id: { type: \"string\", description: \"Atom UUID\" },\n title: { type: \"string\", description: \"New title\" },\n parent_id: { type: [\"string\", \"null\"], description: \"New parent ID or null for root\" },\n assistant_id: { type: \"string\", description: \"Updater assistant ID\" },\n },\n required: [\"id\"],\n },\n handler: (args, store) => {\n const assistantId = args.assistant_id || \"mcp-assistant\";\n if (args.parent_id !== undefined) {\n const updated = store.updateAtomParent(args.id, args.parent_id, assistantId);\n if (!updated) throw new Error(\"Invalid parent or atom not found\");\n }\n const updated = store.updateAtom(args.id, { title: args.title }, assistantId);\n return { success: true, atom: updated || store.getAtom(args.id) };\n },\n },\n {\n name: \"nexus_create_bond\",\n description: \"Create a bond (graph connection) between two atoms.\",\n inputSchema: {\n type: \"object\",\n properties: {\n source_id: { type: \"string\", description: \"Source atom ID\" },\n target_id: { type: \"string\", description: \"Target atom ID\" },\n label: { type: \"string\", description: \"Bond label (default: connects)\" },\n color: { type: \"string\", description: \"Hex color (optional)\" },\n },\n required: [\"source_id\", \"target_id\"],\n },\n handler: (args, store) => {\n const bond = store.createBond(args.source_id, args.target_id, args.label || \"connects\", args.color);\n return { success: true, bond };\n },\n },\n {\n name: \"nexus_request_checkout\",\n description: \"Request an exclusive checkout (lock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant requesting checkout\" },\n reason: { type: \"string\", description: \"Reason for checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const result = store.checkout(args.atom_id, args.assistant_id, \"exclusive\", args.reason || \"\");\n return result;\n },\n },\n {\n name: \"nexus_release_checkout\",\n description: \"Release a checkout (unlock) on an atom.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID\" },\n assistant_id: { type: \"string\", description: \"Assistant releasing checkout\" },\n },\n required: [\"atom_id\", \"assistant_id\"],\n },\n handler: (args, store) => {\n const success = store.releaseCheckout(args.atom_id, args.assistant_id);\n return { success };\n },\n },\n {\n name: \"nexus_subscribe_to_atom\",\n description: \"Subscribe to real-time updates for an atom via WebSocket.\",\n inputSchema: {\n type: \"object\",\n properties: {\n atom_id: { type: \"string\", description: \"Atom UUID to subscribe to\" },\n },\n required: [\"atom_id\"],\n },\n handler: (args, _store) => {\n return { success: true, wsEndpoint: \"ws://localhost:7321/ws\", atom_id: args.atom_id, message: \"Connect via WebSocket and send { type: 'subscribe', atomId: '<id>' }\" };\n },\n },\n {\n name: \"nexus_batch\",\n description: \"Execute multiple MCP tools in a single request. Reduces round-trip token waste.\",\n inputSchema: {\n type: \"object\",\n properties: {\n operations: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n tool: { type: \"string\", description: \"Tool name to call\" },\n params: { type: \"object\", description: \"Parameters for the tool\" },\n },\n required: [\"tool\"],\n },\n description: \"Ordered list of tool calls\",\n },\n stop_on_error: { type: \"boolean\", description: \"If true, stop at first error. Default: false\", default: false },\n },\n required: [\"operations\"],\n },\n handler: (args, store) => {\n const operations = args.operations || [];\n const stopOnError = args.stop_on_error ?? false;\n const results: any[] = [];\n const toolMap = new Map<string, McpTool>();\n for (const t of TOOLS) toolMap.set(t.name, t);\n\n for (let i = 0; i < operations.length; i++) {\n const op = operations[i];\n const tool = toolMap.get(op.tool);\n if (!tool) {\n results.push({ index: i, tool: op.tool, error: `Tool not found: ${op.tool}` });\n if (stopOnError) break;\n continue;\n }\n try {\n const result = tool.handler(op.params || {}, store);\n results.push({ index: i, tool: op.tool, success: true, result });\n } catch (err: any) {\n results.push({ index: i, tool: op.tool, error: err.message });\n if (stopOnError) break;\n }\n }\n return { count: operations.length, completed: results.length, results };\n },\n },\n];\n","/**\n * MCP Server\n * JSON-RPC handler for Model Context Protocol.\n */\n\nimport type { Store } from \"../core/Store.js\";\nimport { TOOLS } from \"./tools.js\";\nimport type { JsonRpcRequest, JsonRpcResponse, McpTool } from \"./types.js\";\n\nfunction getVersion(): string {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(__dirname, \"../../package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n try {\n const { readFileSync } = require(\"fs\");\n const { resolve } = require(\"path\");\n const pkg = JSON.parse(readFileSync(resolve(process.cwd(), \"package.json\"), \"utf-8\"));\n return pkg.version;\n } catch {\n return \"2.1.3\";\n }\n }\n}\n\nexport class McpServer {\n private store: Store;\n private toolMap = new Map<string, McpTool>();\n\n constructor(store: Store) {\n this.store = store;\n for (const t of TOOLS) this.toolMap.set(t.name, t);\n }\n\n /**\n * Returns `null` for notifications (no response needed).\n */\n handleRequest(req: JsonRpcRequest): JsonRpcResponse | null {\n // Notifications have no id — do not send a response\n if (req.id === null || req.id === undefined) {\n return null;\n }\n\n try {\n switch (req.method) {\n case \"initialize\":\n return this.ok(req.id, {\n protocolVersion: \"2024-11-05\",\n capabilities: { tools: {}, resources: {}, prompts: {} },\n serverInfo: { name: \"mnemosyne-mcp\", version: getVersion() },\n });\n\n case \"tools/list\":\n return this.ok(req.id, {\n tools: TOOLS.map(t => ({ name: t.name, description: t.description, inputSchema: t.inputSchema })),\n });\n\n case \"tools/call\": {\n const { name, arguments: args } = req.params || {};\n const tool = this.toolMap.get(name);\n if (!tool) return this.err(req.id, -32601, `Tool not found: ${name}`);\n const result = tool.handler(args || {}, this.store);\n return this.ok(req.id, { content: [{ type: \"text\", text: JSON.stringify(result, null, 2) }] });\n }\n\n case \"resources/list\":\n return this.ok(req.id, { resources: [] });\n\n case \"prompts/list\":\n return this.ok(req.id, { prompts: [] });\n\n default:\n return this.err(req.id, -32601, `Method not found: ${req.method}`);\n }\n } catch (e: any) {\n return this.err(req.id, -32603, e.message);\n }\n }\n\n getManifest() {\n return {\n name: \"Mnemosyne\",\n version: getVersion(),\n description: \"Knowledge base MCP server for projects, atoms, blocks, and bonds.\",\n protocol: \"mcp\",\n transport: [\"stdio\", \"sse\"],\n endpoints: {\n sse: \"/mcp/sse\",\n messages: \"/mcp/messages\",\n },\n tools: TOOLS.map(t => ({ name: t.name, description: t.description })),\n };\n }\n\n private ok(id: string | number | null, result: any): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, result };\n }\n private err(id: string | number | null, code: number, message: string): JsonRpcResponse {\n return { jsonrpc: \"2.0\", id, error: { code, message } };\n }\n}\n","/**\n * MCP SSE Transport\n * Server-Sent Events transport for MCP over HTTP.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest } from \"./types.js\";\n\ninterface SseSession {\n id: string;\n res: import(\"http\").ServerResponse;\n}\n\nexport class McpSseTransport {\n private server: McpServer;\n private sessions = new Map<string, SseSession>();\n private sessionCounter = 0;\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n handleSse(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse): void {\n const id = `sess_${++this.sessionCounter}_${Date.now()}`;\n res.writeHead(200, {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n \"Connection\": \"keep-alive\",\n });\n this.sessions.set(id, { id, res });\n\n // Send endpoint event\n this.sendSse(id, \"endpoint\", \"/mcp/messages?session_id=\" + id);\n\n req.on(\"close\", () => this.sessions.delete(id));\n }\n\n handleMessage(req: import(\"http\").IncomingMessage, res: import(\"http\").ServerResponse, body: any): void {\n const url = new URL(req.url || \"/\", `http://${req.headers.host}`);\n const sessionId = url.searchParams.get(\"session_id\") || \"\";\n\n const request = body as JsonRpcRequest;\n if (!request || request.jsonrpc !== \"2.0\") {\n res.writeHead(400, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify({ error: \"invalid_jsonrpc\" }));\n return;\n }\n\n const response = this.server.handleRequest(request);\n // Notifications return null — send empty 200\n if (!response) {\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(\"{}\");\n return;\n }\n\n res.writeHead(200, { \"Content-Type\": \"application/json\" });\n res.end(JSON.stringify(response));\n\n // Also broadcast via SSE if the session is active\n if (sessionId) this.sendSse(sessionId, \"message\", JSON.stringify(response));\n }\n\n private sendSse(sessionId: string, event: string, data: string): void {\n const session = this.sessions.get(sessionId);\n if (!session) return;\n session.res.write(`event: ${event}\\ndata: ${data}\\n\\n`);\n }\n}\n","/**\n * MCP Stdio Transport\n * Line-delimited JSON-RPC over stdin/stdout.\n * This is what Claude Desktop uses to communicate with MCP servers.\n */\n\nimport type { McpServer } from \"./server.js\";\nimport type { JsonRpcRequest, JsonRpcResponse } from \"./types.js\";\n\nexport class McpStdioTransport {\n private server: McpServer;\n private buffer = \"\";\n\n constructor(server: McpServer) {\n this.server = server;\n }\n\n start(): void {\n process.stdin.setEncoding(\"utf8\");\n process.stdin.resume();\n\n process.stdin.on(\"data\", (chunk: string) => {\n this.buffer += chunk;\n const lines = this.buffer.split(\"\\n\");\n this.buffer = lines.pop() || \"\";\n\n for (const line of lines) {\n if (!line.trim()) continue;\n try {\n const request = JSON.parse(line) as JsonRpcRequest;\n const response = this.server.handleRequest(request);\n if (response) this.send(response);\n // Notifications return null — no output\n } catch (err: any) {\n this.send({ jsonrpc: \"2.0\", id: null, error: { code: -32700, message: \"Parse error: \" + err.message } });\n }\n }\n });\n\n process.stdin.on(\"end\", () => {\n process.exit(0);\n });\n }\n\n send(message: JsonRpcResponse): void {\n process.stdout.write(JSON.stringify(message) + \"\\n\");\n }\n}\n"],"mappings":";;;;;;;;AAQO,IAAM,QAAmB;AAAA,EAC9B;AAAA,IACE,MAAM;AAAA,IACN,aAAa;AAAA,IACb,aAAa,EAAE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,SAAS,kBAAkB,IAAI,QAAQ,EAAE,CAAC;AAAA,QACzG;AAAA,MACF;AAAA,IACF,CAAC;AAED,YAAQ,MAAM,GAAG,OAAO,MAAM;AAC5B,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACH;AAAA,EAEA,KAAK,SAAgC;AACnC,YAAQ,OAAO,MAAM,KAAK,UAAU,OAAO,IAAI,IAAI;AAAA,EACrD;AACF;","names":["updated"]}
|
package/dist/sdk/index.d.mts
CHANGED
|
@@ -161,6 +161,10 @@ declare class MnemosyneClient {
|
|
|
161
161
|
label?: string;
|
|
162
162
|
color?: string;
|
|
163
163
|
}): Promise<Bond>;
|
|
164
|
+
updateBond(id: string, data: {
|
|
165
|
+
label?: string;
|
|
166
|
+
color?: string;
|
|
167
|
+
}): Promise<Bond>;
|
|
164
168
|
deleteBond(id: string): Promise<void>;
|
|
165
169
|
searchSemantic(query: string, options?: {
|
|
166
170
|
projectId?: string;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -161,6 +161,10 @@ declare class MnemosyneClient {
|
|
|
161
161
|
label?: string;
|
|
162
162
|
color?: string;
|
|
163
163
|
}): Promise<Bond>;
|
|
164
|
+
updateBond(id: string, data: {
|
|
165
|
+
label?: string;
|
|
166
|
+
color?: string;
|
|
167
|
+
}): Promise<Bond>;
|
|
164
168
|
deleteBond(id: string): Promise<void>;
|
|
165
169
|
searchSemantic(query: string, options?: {
|
|
166
170
|
projectId?: string;
|
package/dist/sdk/index.js
CHANGED
|
@@ -134,6 +134,10 @@ var MnemosyneClient = class {
|
|
|
134
134
|
const res = await this.request("POST", `/api/v1/atoms/${atomId}/bonds`, data);
|
|
135
135
|
return res.bond;
|
|
136
136
|
}
|
|
137
|
+
async updateBond(id, data) {
|
|
138
|
+
const res = await this.request("PATCH", `/api/v1/bonds/${id}`, data);
|
|
139
|
+
return res.bond;
|
|
140
|
+
}
|
|
137
141
|
async deleteBond(id) {
|
|
138
142
|
await this.request("DELETE", `/api/v1/bonds/${id}`);
|
|
139
143
|
}
|
package/dist/sdk/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sdk/index.ts","../../src/sdk/client.ts"],"sourcesContent":["export { MnemosyneClient } from \"./client.js\";\nexport type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n} from \"./types.js\";\n","import type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n CheckoutResult,\n QueueStatus,\n} from \"./types.js\";\n\nexport interface ClientOptions {\n baseUrl: string;\n apiKey?: string;\n timeout?: number;\n}\n\nexport class MnemosyneClient {\n private baseUrl: string;\n private apiKey?: string;\n private timeout: number;\n\n constructor(options: ClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.timeout = options.timeout || 30000;\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, string | number | boolean | undefined>\n ): Promise<T> {\n const qs = query\n ? \"?\" +\n Object.entries(query)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join(\"&\")\n : \"\";\n const url = `${this.baseUrl}${path}${qs}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n let detail = \"\";\n try {\n const errJson = await res.json();\n detail = errJson.error || JSON.stringify(errJson);\n } catch {\n detail = await res.text().catch(() => res.statusText);\n }\n throw new Error(`HTTP ${res.status} on ${method} ${path}: ${detail || res.statusText}`);\n }\n\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n }\n\n // ── Health ─────────────────────────────────────────\n async health(): Promise<HealthStatus> {\n return this.request<HealthStatus>(\"GET\", \"/api/v1/health\");\n }\n\n // ── Projects ───────────────────────────────────────\n async listProjects(): Promise<Project[]> {\n const res = await this.request<{ projects: Project[] }>(\"GET\", \"/api/v1/projects\");\n return res.projects;\n }\n\n async getProject(id: string): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"GET\", `/api/v1/projects/${id}`);\n return res.project;\n }\n\n async createProject(data: { name: string; description?: string }): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"POST\", \"/api/v1/projects\", data);\n return res.project;\n }\n\n async deleteProject(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/projects/${id}`);\n }\n\n // ── Atoms ──────────────────────────────────────────\n async listAtoms(projectId?: string): Promise<Atom[]> {\n const res = await this.request<{ atoms: Atom[] }>(\"GET\", \"/api/v1/atoms\", undefined, { project_id: projectId });\n return res.atoms;\n }\n\n async getAtom(id: string): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"GET\", `/api/v1/atoms/${id}`);\n return res.atom;\n }\n\n async createAtom(data: {\n project_id: string;\n title: string;\n type?: string;\n parent_id?: string | null;\n tags?: string[];\n template?: string;\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n }): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"POST\", \"/api/v1/atoms\", data);\n return res.atom;\n }\n\n async updateAtom(\n id: string,\n data: {\n title?: string;\n summary?: string;\n tags?: string[];\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n parent_id?: string | null;\n }\n ): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"PATCH\", `/api/v1/atoms/${id}`, data);\n return res.atom;\n }\n\n async deleteAtom(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${id}`);\n }\n\n // ── Blocks ─────────────────────────────────────────\n async getBlocks(atomId: string): Promise<Block[]> {\n const res = await this.request<{ blocks: Block[] }>(\"GET\", `/api/v1/atoms/${atomId}`, undefined, { fields: \"blocks\" });\n return res.blocks || [];\n }\n\n async createBlock(\n atomId: string,\n data: { type: string; content: string; tags?: string[] }\n ): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"POST\", `/api/v1/atoms/${atomId}/blocks`, data);\n return res.block;\n }\n\n async updateBlock(id: string, data: { content?: string; type?: string; metadata?: Record<string, any> }): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"PATCH\", `/api/v1/blocks/${id}`, data);\n return res.block;\n }\n\n async deleteBlock(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/blocks/${id}`);\n }\n\n // ── Bonds ──────────────────────────────────────────\n async listBonds(atomId?: string): Promise<Bond[]> {\n if (atomId) {\n const res = await this.request<{ outgoing: Bond[]; incoming: Bond[] }>(\"GET\", `/api/v1/atoms/${atomId}/bonds`);\n return [...res.outgoing, ...res.incoming];\n }\n return this.request<Bond[]>(\"GET\", \"/api/v1/bonds\");\n }\n\n async createBond(atomId: string, data: { target_id: string; label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"POST\", `/api/v1/atoms/${atomId}/bonds`, data);\n return res.bond;\n }\n\n async deleteBond(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/bonds/${id}`);\n }\n\n // ── Search ─────────────────────────────────────────\n async searchSemantic(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchHybrid(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchKeyword(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: false,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n // ── Assistants ─────────────────────────────────────\n async listAssistants(): Promise<Assistant[]> {\n const res = await this.request<{ assistants: Assistant[] }>(\"GET\", \"/api/v1/assistants\");\n return res.assistants;\n }\n\n async getAssistant(id: string): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"GET\", `/api/v1/assistants/${id}`);\n return res.assistant;\n }\n\n async createAssistant(data: {\n id?: string;\n name: string;\n role: string;\n capabilities?: string[];\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n }): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"POST\", \"/api/v1/assistants/register\", data);\n return res.assistant;\n }\n\n async updateAssistant(\n id: string,\n data: {\n name?: string;\n role?: string;\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n capabilities?: string[];\n status?: string;\n }\n ): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"PATCH\", `/api/v1/assistants/${id}`, data);\n return res.assistant;\n }\n\n async deleteAssistant(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/assistants/${id}`);\n }\n\n // ── Checkout / Queue ───────────────────────────────\n async checkoutAtom(\n atomId: string,\n mode: \"exclusive\" | \"shared\" = \"exclusive\",\n reason?: string\n ): Promise<CheckoutResult> {\n return this.request<CheckoutResult>(\"POST\", `/api/v1/atoms/${atomId}/checkout`, { mode, reason });\n }\n\n async releaseCheckout(atomId: string): Promise<boolean> {\n const res = await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${atomId}/checkout`);\n return res.success;\n }\n\n async getQueueStatus(atomId: string): Promise<QueueStatus> {\n return this.request<QueueStatus>(\"GET\", `/api/v1/atoms/${atomId}/queue`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;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AAkC;AACtD,UAAM,MAAM,MAAM,KAAK,QAA8B,UAAU,iBAAiB,MAAM,WAAW;AACjG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,eAAe,QAAsC;AACzD,WAAO,KAAK,QAAqB,OAAO,iBAAiB,MAAM,QAAQ;AAAA,EACzE;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/index.ts","../../src/sdk/client.ts"],"sourcesContent":["export { MnemosyneClient } from \"./client.js\";\nexport type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n} from \"./types.js\";\n","import type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n CheckoutResult,\n QueueStatus,\n} from \"./types.js\";\n\nexport interface ClientOptions {\n baseUrl: string;\n apiKey?: string;\n timeout?: number;\n}\n\nexport class MnemosyneClient {\n private baseUrl: string;\n private apiKey?: string;\n private timeout: number;\n\n constructor(options: ClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.timeout = options.timeout || 30000;\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, string | number | boolean | undefined>\n ): Promise<T> {\n const qs = query\n ? \"?\" +\n Object.entries(query)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join(\"&\")\n : \"\";\n const url = `${this.baseUrl}${path}${qs}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n let detail = \"\";\n try {\n const errJson = await res.json();\n detail = errJson.error || JSON.stringify(errJson);\n } catch {\n detail = await res.text().catch(() => res.statusText);\n }\n throw new Error(`HTTP ${res.status} on ${method} ${path}: ${detail || res.statusText}`);\n }\n\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n }\n\n // ── Health ─────────────────────────────────────────\n async health(): Promise<HealthStatus> {\n return this.request<HealthStatus>(\"GET\", \"/api/v1/health\");\n }\n\n // ── Projects ───────────────────────────────────────\n async listProjects(): Promise<Project[]> {\n const res = await this.request<{ projects: Project[] }>(\"GET\", \"/api/v1/projects\");\n return res.projects;\n }\n\n async getProject(id: string): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"GET\", `/api/v1/projects/${id}`);\n return res.project;\n }\n\n async createProject(data: { name: string; description?: string }): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"POST\", \"/api/v1/projects\", data);\n return res.project;\n }\n\n async deleteProject(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/projects/${id}`);\n }\n\n // ── Atoms ──────────────────────────────────────────\n async listAtoms(projectId?: string): Promise<Atom[]> {\n const res = await this.request<{ atoms: Atom[] }>(\"GET\", \"/api/v1/atoms\", undefined, { project_id: projectId });\n return res.atoms;\n }\n\n async getAtom(id: string): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"GET\", `/api/v1/atoms/${id}`);\n return res.atom;\n }\n\n async createAtom(data: {\n project_id: string;\n title: string;\n type?: string;\n parent_id?: string | null;\n tags?: string[];\n template?: string;\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n }): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"POST\", \"/api/v1/atoms\", data);\n return res.atom;\n }\n\n async updateAtom(\n id: string,\n data: {\n title?: string;\n summary?: string;\n tags?: string[];\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n parent_id?: string | null;\n }\n ): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"PATCH\", `/api/v1/atoms/${id}`, data);\n return res.atom;\n }\n\n async deleteAtom(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${id}`);\n }\n\n // ── Blocks ─────────────────────────────────────────\n async getBlocks(atomId: string): Promise<Block[]> {\n const res = await this.request<{ blocks: Block[] }>(\"GET\", `/api/v1/atoms/${atomId}`, undefined, { fields: \"blocks\" });\n return res.blocks || [];\n }\n\n async createBlock(\n atomId: string,\n data: { type: string; content: string; tags?: string[] }\n ): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"POST\", `/api/v1/atoms/${atomId}/blocks`, data);\n return res.block;\n }\n\n async updateBlock(id: string, data: { content?: string; type?: string; metadata?: Record<string, any> }): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"PATCH\", `/api/v1/blocks/${id}`, data);\n return res.block;\n }\n\n async deleteBlock(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/blocks/${id}`);\n }\n\n // ── Bonds ──────────────────────────────────────────\n async listBonds(atomId?: string): Promise<Bond[]> {\n if (atomId) {\n const res = await this.request<{ outgoing: Bond[]; incoming: Bond[] }>(\"GET\", `/api/v1/atoms/${atomId}/bonds`);\n return [...res.outgoing, ...res.incoming];\n }\n return this.request<Bond[]>(\"GET\", \"/api/v1/bonds\");\n }\n\n async createBond(atomId: string, data: { target_id: string; label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"POST\", `/api/v1/atoms/${atomId}/bonds`, data);\n return res.bond;\n }\n\n async updateBond(id: string, data: { label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"PATCH\", `/api/v1/bonds/${id}`, data);\n return res.bond;\n }\n\n async deleteBond(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/bonds/${id}`);\n }\n\n // ── Search ─────────────────────────────────────────\n async searchSemantic(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchHybrid(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchKeyword(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: false,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n // ── Assistants ─────────────────────────────────────\n async listAssistants(): Promise<Assistant[]> {\n const res = await this.request<{ assistants: Assistant[] }>(\"GET\", \"/api/v1/assistants\");\n return res.assistants;\n }\n\n async getAssistant(id: string): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"GET\", `/api/v1/assistants/${id}`);\n return res.assistant;\n }\n\n async createAssistant(data: {\n id?: string;\n name: string;\n role: string;\n capabilities?: string[];\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n }): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"POST\", \"/api/v1/assistants/register\", data);\n return res.assistant;\n }\n\n async updateAssistant(\n id: string,\n data: {\n name?: string;\n role?: string;\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n capabilities?: string[];\n status?: string;\n }\n ): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"PATCH\", `/api/v1/assistants/${id}`, data);\n return res.assistant;\n }\n\n async deleteAssistant(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/assistants/${id}`);\n }\n\n // ── Checkout / Queue ───────────────────────────────\n async checkoutAtom(\n atomId: string,\n mode: \"exclusive\" | \"shared\" = \"exclusive\",\n reason?: string\n ): Promise<CheckoutResult> {\n return this.request<CheckoutResult>(\"POST\", `/api/v1/atoms/${atomId}/checkout`, { mode, reason });\n }\n\n async releaseCheckout(atomId: string): Promise<boolean> {\n const res = await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${atomId}/checkout`);\n return res.success;\n }\n\n async getQueueStatus(atomId: string): Promise<QueueStatus> {\n return this.request<QueueStatus>(\"GET\", `/api/v1/atoms/${atomId}/queue`);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACkBO,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,SAAwB;AAClC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA,EAEA,MAAc,QACZ,QACA,MACA,MACA,OACY;AACZ,UAAM,KAAK,QACP,MACA,OAAO,QAAQ,KAAK,EACjB,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,EACjC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,CAAC,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC,EAAE,EAC3E,KAAK,GAAG,IACX;AACJ,UAAM,MAAM,GAAG,KAAK,OAAO,GAAG,IAAI,GAAG,EAAE;AACvC,UAAM,aAAa,IAAI,gBAAgB;AACvC,UAAM,QAAQ,WAAW,MAAM,WAAW,MAAM,GAAG,KAAK,OAAO;AAE/D,QAAI;AACF,YAAM,UAAkC;AAAA,QACtC,QAAQ;AAAA,QACR,gBAAgB;AAAA,MAClB;AACA,UAAI,KAAK,OAAQ,SAAQ,eAAe,IAAI,UAAU,KAAK,MAAM;AAEjE,YAAM,MAAM,MAAM,MAAM,KAAK;AAAA,QAC3B;AAAA,QACA;AAAA,QACA,MAAM,OAAO,KAAK,UAAU,IAAI,IAAI;AAAA,QACpC,QAAQ,WAAW;AAAA,MACrB,CAAC;AAED,UAAI,CAAC,IAAI,IAAI;AACX,YAAI,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,IACA,MAUoB;AACpB,UAAM,MAAM,MAAM,KAAK,QAAkC,SAAS,sBAAsB,EAAE,IAAI,IAAI;AAClG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,gBAAgB,IAA2B;AAC/C,UAAM,KAAK,QAA8B,UAAU,sBAAsB,EAAE,EAAE;AAAA,EAC/E;AAAA;AAAA,EAGA,MAAM,aACJ,QACA,OAA+B,aAC/B,QACyB;AACzB,WAAO,KAAK,QAAwB,QAAQ,iBAAiB,MAAM,aAAa,EAAE,MAAM,OAAO,CAAC;AAAA,EAClG;AAAA,EAEA,MAAM,gBAAgB,QAAkC;AACtD,UAAM,MAAM,MAAM,KAAK,QAA8B,UAAU,iBAAiB,MAAM,WAAW;AACjG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,eAAe,QAAsC;AACzD,WAAO,KAAK,QAAqB,OAAO,iBAAiB,MAAM,QAAQ;AAAA,EACzE;AACF;","names":[]}
|
package/dist/sdk/index.mjs
CHANGED
|
@@ -108,6 +108,10 @@ var MnemosyneClient = class {
|
|
|
108
108
|
const res = await this.request("POST", `/api/v1/atoms/${atomId}/bonds`, data);
|
|
109
109
|
return res.bond;
|
|
110
110
|
}
|
|
111
|
+
async updateBond(id, data) {
|
|
112
|
+
const res = await this.request("PATCH", `/api/v1/bonds/${id}`, data);
|
|
113
|
+
return res.bond;
|
|
114
|
+
}
|
|
111
115
|
async deleteBond(id) {
|
|
112
116
|
await this.request("DELETE", `/api/v1/bonds/${id}`);
|
|
113
117
|
}
|
package/dist/sdk/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sdk/client.ts"],"sourcesContent":["import type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n CheckoutResult,\n QueueStatus,\n} from \"./types.js\";\n\nexport interface ClientOptions {\n baseUrl: string;\n apiKey?: string;\n timeout?: number;\n}\n\nexport class MnemosyneClient {\n private baseUrl: string;\n private apiKey?: string;\n private timeout: number;\n\n constructor(options: ClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.timeout = options.timeout || 30000;\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, string | number | boolean | undefined>\n ): Promise<T> {\n const qs = query\n ? \"?\" +\n Object.entries(query)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join(\"&\")\n : \"\";\n const url = `${this.baseUrl}${path}${qs}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n let detail = \"\";\n try {\n const errJson = await res.json();\n detail = errJson.error || JSON.stringify(errJson);\n } catch {\n detail = await res.text().catch(() => res.statusText);\n }\n throw new Error(`HTTP ${res.status} on ${method} ${path}: ${detail || res.statusText}`);\n }\n\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n }\n\n // ── Health ─────────────────────────────────────────\n async health(): Promise<HealthStatus> {\n return this.request<HealthStatus>(\"GET\", \"/api/v1/health\");\n }\n\n // ── Projects ───────────────────────────────────────\n async listProjects(): Promise<Project[]> {\n const res = await this.request<{ projects: Project[] }>(\"GET\", \"/api/v1/projects\");\n return res.projects;\n }\n\n async getProject(id: string): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"GET\", `/api/v1/projects/${id}`);\n return res.project;\n }\n\n async createProject(data: { name: string; description?: string }): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"POST\", \"/api/v1/projects\", data);\n return res.project;\n }\n\n async deleteProject(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/projects/${id}`);\n }\n\n // ── Atoms ──────────────────────────────────────────\n async listAtoms(projectId?: string): Promise<Atom[]> {\n const res = await this.request<{ atoms: Atom[] }>(\"GET\", \"/api/v1/atoms\", undefined, { project_id: projectId });\n return res.atoms;\n }\n\n async getAtom(id: string): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"GET\", `/api/v1/atoms/${id}`);\n return res.atom;\n }\n\n async createAtom(data: {\n project_id: string;\n title: string;\n type?: string;\n parent_id?: string | null;\n tags?: string[];\n template?: string;\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n }): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"POST\", \"/api/v1/atoms\", data);\n return res.atom;\n }\n\n async updateAtom(\n id: string,\n data: {\n title?: string;\n summary?: string;\n tags?: string[];\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n parent_id?: string | null;\n }\n ): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"PATCH\", `/api/v1/atoms/${id}`, data);\n return res.atom;\n }\n\n async deleteAtom(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${id}`);\n }\n\n // ── Blocks ─────────────────────────────────────────\n async getBlocks(atomId: string): Promise<Block[]> {\n const res = await this.request<{ blocks: Block[] }>(\"GET\", `/api/v1/atoms/${atomId}`, undefined, { fields: \"blocks\" });\n return res.blocks || [];\n }\n\n async createBlock(\n atomId: string,\n data: { type: string; content: string; tags?: string[] }\n ): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"POST\", `/api/v1/atoms/${atomId}/blocks`, data);\n return res.block;\n }\n\n async updateBlock(id: string, data: { content?: string; type?: string; metadata?: Record<string, any> }): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"PATCH\", `/api/v1/blocks/${id}`, data);\n return res.block;\n }\n\n async deleteBlock(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/blocks/${id}`);\n }\n\n // ── Bonds ──────────────────────────────────────────\n async listBonds(atomId?: string): Promise<Bond[]> {\n if (atomId) {\n const res = await this.request<{ outgoing: Bond[]; incoming: Bond[] }>(\"GET\", `/api/v1/atoms/${atomId}/bonds`);\n return [...res.outgoing, ...res.incoming];\n }\n return this.request<Bond[]>(\"GET\", \"/api/v1/bonds\");\n }\n\n async createBond(atomId: string, data: { target_id: string; label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"POST\", `/api/v1/atoms/${atomId}/bonds`, data);\n return res.bond;\n }\n\n async deleteBond(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/bonds/${id}`);\n }\n\n // ── Search ─────────────────────────────────────────\n async searchSemantic(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchHybrid(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchKeyword(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: false,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n // ── Assistants ─────────────────────────────────────\n async listAssistants(): Promise<Assistant[]> {\n const res = await this.request<{ assistants: Assistant[] }>(\"GET\", \"/api/v1/assistants\");\n return res.assistants;\n }\n\n async getAssistant(id: string): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"GET\", `/api/v1/assistants/${id}`);\n return res.assistant;\n }\n\n async createAssistant(data: {\n id?: string;\n name: string;\n role: string;\n capabilities?: string[];\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n }): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"POST\", \"/api/v1/assistants/register\", data);\n return res.assistant;\n }\n\n async updateAssistant(\n id: string,\n data: {\n name?: string;\n role?: string;\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n capabilities?: string[];\n status?: string;\n }\n ): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"PATCH\", `/api/v1/assistants/${id}`, data);\n return res.assistant;\n }\n\n async deleteAssistant(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/assistants/${id}`);\n }\n\n // ── Checkout / Queue ───────────────────────────────\n async checkoutAtom(\n atomId: string,\n mode: \"exclusive\" | \"shared\" = \"exclusive\",\n reason?: string\n ): Promise<CheckoutResult> {\n return this.request<CheckoutResult>(\"POST\", `/api/v1/atoms/${atomId}/checkout`, { mode, reason });\n }\n\n async releaseCheckout(atomId: string): Promise<boolean> {\n const res = await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${atomId}/checkout`);\n return res.success;\n }\n\n async getQueueStatus(atomId: string): Promise<QueueStatus> {\n return this.request<QueueStatus>(\"GET\", `/api/v1/atoms/${atomId}/queue`);\n }\n}\n"],"mappings":";AAkBO,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,SAAwB;AAClC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA,EAEA,MAAc,QACZ,QACA,MACA,MACA,OACY;AACZ,UAAM,KAAK,QACP,MACA,OAAO,QAAQ,KAAK,EACjB,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,EACjC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,mBAAmB,CAAC,CAAC,IAAI,mBAAmB,OAAO,CAAC,CAAC,CAAC,EAAE,EAC3E,KAAK,GA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M,iBAAuC;AAC3C,UAAM,MAAM,MAAM,KAAK,QAAqC,OAAO,oBAAoB;AACvF,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,aAAa,IAAgC;AACjD,UAAM,MAAM,MAAM,KAAK,QAAkC,OAAO,sBAAsB,EAAE,EAAE;AAC1F,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,gBAAgB,MASC;AACrB,UAAM,MAAM,MAAM,KAAK,QAAkC,QAAQ,+BAA+B,IAAI;AACpG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,gBACJ,IACA,MAUoB;AACpB,UAAM,MAAM,MAAM,KAAK,QAAkC,SAAS,sBAAsB,EAAE,IAAI,IAAI;AAClG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,gBAAgB,IAA2B;AAC/C,UAAM,KAAK,QAA8B,UAAU,sBAAsB,EAAE,EAAE;AAAA,EAC/E;AAAA;AAAA,EAGA,MAAM,aACJ,QACA,OAA+B,aAC/B,QACyB;AACzB,WAAO,KAAK,QAAwB,QAAQ,iBAAiB,MAAM,aAAa,EAAE,MAAM,OAAO,CAAC;AAAA,EAClG;AAAA,EAEA,MAAM,gBAAgB,QAAkC;AACtD,UAAM,MAAM,MAAM,KAAK,QAA8B,UAAU,iBAAiB,MAAM,WAAW;AACjG,WAAO,IAAI;AAAA,EACb;AAAA,EAEA,MAAM,eAAe,QAAsC;AACzD,WAAO,KAAK,QAAqB,OAAO,iBAAiB,MAAM,QAAQ;AAAA,EACzE;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/sdk/client.ts"],"sourcesContent":["import type {\n Atom,\n Block,\n Project,\n Assistant,\n Bond,\n SearchResult,\n HealthStatus,\n CheckoutResult,\n QueueStatus,\n} from \"./types.js\";\n\nexport interface ClientOptions {\n baseUrl: string;\n apiKey?: string;\n timeout?: number;\n}\n\nexport class MnemosyneClient {\n private baseUrl: string;\n private apiKey?: string;\n private timeout: number;\n\n constructor(options: ClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/$/, \"\");\n this.apiKey = options.apiKey;\n this.timeout = options.timeout || 30000;\n }\n\n private async request<T>(\n method: string,\n path: string,\n body?: unknown,\n query?: Record<string, string | number | boolean | undefined>\n ): Promise<T> {\n const qs = query\n ? \"?\" +\n Object.entries(query)\n .filter(([, v]) => v !== undefined)\n .map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)\n .join(\"&\")\n : \"\";\n const url = `${this.baseUrl}${path}${qs}`;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), this.timeout);\n\n try {\n const headers: Record<string, string> = {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n };\n if (this.apiKey) headers[\"Authorization\"] = `Bearer ${this.apiKey}`;\n\n const res = await fetch(url, {\n method,\n headers,\n body: body ? JSON.stringify(body) : undefined,\n signal: controller.signal,\n });\n\n if (!res.ok) {\n let detail = \"\";\n try {\n const errJson = await res.json();\n detail = errJson.error || JSON.stringify(errJson);\n } catch {\n detail = await res.text().catch(() => res.statusText);\n }\n throw new Error(`HTTP ${res.status} on ${method} ${path}: ${detail || res.statusText}`);\n }\n\n return (await res.json()) as T;\n } finally {\n clearTimeout(timer);\n }\n }\n\n // ── Health ─────────────────────────────────────────\n async health(): Promise<HealthStatus> {\n return this.request<HealthStatus>(\"GET\", \"/api/v1/health\");\n }\n\n // ── Projects ───────────────────────────────────────\n async listProjects(): Promise<Project[]> {\n const res = await this.request<{ projects: Project[] }>(\"GET\", \"/api/v1/projects\");\n return res.projects;\n }\n\n async getProject(id: string): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"GET\", `/api/v1/projects/${id}`);\n return res.project;\n }\n\n async createProject(data: { name: string; description?: string }): Promise<Project> {\n const res = await this.request<{ project: Project }>(\"POST\", \"/api/v1/projects\", data);\n return res.project;\n }\n\n async deleteProject(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/projects/${id}`);\n }\n\n // ── Atoms ──────────────────────────────────────────\n async listAtoms(projectId?: string): Promise<Atom[]> {\n const res = await this.request<{ atoms: Atom[] }>(\"GET\", \"/api/v1/atoms\", undefined, { project_id: projectId });\n return res.atoms;\n }\n\n async getAtom(id: string): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"GET\", `/api/v1/atoms/${id}`);\n return res.atom;\n }\n\n async createAtom(data: {\n project_id: string;\n title: string;\n type?: string;\n parent_id?: string | null;\n tags?: string[];\n template?: string;\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n }): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"POST\", \"/api/v1/atoms\", data);\n return res.atom;\n }\n\n async updateAtom(\n id: string,\n data: {\n title?: string;\n summary?: string;\n tags?: string[];\n status?: string;\n auto_path?: string;\n path_overridden?: boolean;\n parent_id?: string | null;\n }\n ): Promise<Atom> {\n const res = await this.request<{ atom: Atom }>(\"PATCH\", `/api/v1/atoms/${id}`, data);\n return res.atom;\n }\n\n async deleteAtom(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${id}`);\n }\n\n // ── Blocks ─────────────────────────────────────────\n async getBlocks(atomId: string): Promise<Block[]> {\n const res = await this.request<{ blocks: Block[] }>(\"GET\", `/api/v1/atoms/${atomId}`, undefined, { fields: \"blocks\" });\n return res.blocks || [];\n }\n\n async createBlock(\n atomId: string,\n data: { type: string; content: string; tags?: string[] }\n ): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"POST\", `/api/v1/atoms/${atomId}/blocks`, data);\n return res.block;\n }\n\n async updateBlock(id: string, data: { content?: string; type?: string; metadata?: Record<string, any> }): Promise<Block> {\n const res = await this.request<{ block: Block }>(\"PATCH\", `/api/v1/blocks/${id}`, data);\n return res.block;\n }\n\n async deleteBlock(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/blocks/${id}`);\n }\n\n // ── Bonds ──────────────────────────────────────────\n async listBonds(atomId?: string): Promise<Bond[]> {\n if (atomId) {\n const res = await this.request<{ outgoing: Bond[]; incoming: Bond[] }>(\"GET\", `/api/v1/atoms/${atomId}/bonds`);\n return [...res.outgoing, ...res.incoming];\n }\n return this.request<Bond[]>(\"GET\", \"/api/v1/bonds\");\n }\n\n async createBond(atomId: string, data: { target_id: string; label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"POST\", `/api/v1/atoms/${atomId}/bonds`, data);\n return res.bond;\n }\n\n async updateBond(id: string, data: { label?: string; color?: string }): Promise<Bond> {\n const res = await this.request<{ bond: Bond }>(\"PATCH\", `/api/v1/bonds/${id}`, data);\n return res.bond;\n }\n\n async deleteBond(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/bonds/${id}`);\n }\n\n // ── Search ─────────────────────────────────────────\n async searchSemantic(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchHybrid(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: true,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n async searchKeyword(query: string, options?: { projectId?: string; limit?: number }): Promise<SearchResult> {\n return this.request<SearchResult>(\"GET\", \"/api/v1/search\", undefined, {\n q: query,\n semantic: false,\n limit: options?.limit || 20,\n project_id: options?.projectId,\n });\n }\n\n // ── Assistants ─────────────────────────────────────\n async listAssistants(): Promise<Assistant[]> {\n const res = await this.request<{ assistants: Assistant[] }>(\"GET\", \"/api/v1/assistants\");\n return res.assistants;\n }\n\n async getAssistant(id: string): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"GET\", `/api/v1/assistants/${id}`);\n return res.assistant;\n }\n\n async createAssistant(data: {\n id?: string;\n name: string;\n role: string;\n capabilities?: string[];\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n }): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"POST\", \"/api/v1/assistants/register\", data);\n return res.assistant;\n }\n\n async updateAssistant(\n id: string,\n data: {\n name?: string;\n role?: string;\n description?: string;\n provider?: string;\n instructions?: string;\n config?: Record<string, any>;\n capabilities?: string[];\n status?: string;\n }\n ): Promise<Assistant> {\n const res = await this.request<{ assistant: Assistant }>(\"PATCH\", `/api/v1/assistants/${id}`, data);\n return res.assistant;\n }\n\n async deleteAssistant(id: string): Promise<void> {\n await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/assistants/${id}`);\n }\n\n // ── Checkout / Queue ───────────────────────────────\n async checkoutAtom(\n atomId: string,\n mode: \"exclusive\" | \"shared\" = \"exclusive\",\n reason?: string\n ): Promise<CheckoutResult> {\n return this.request<CheckoutResult>(\"POST\", `/api/v1/atoms/${atomId}/checkout`, { mode, reason });\n }\n\n async releaseCheckout(atomId: string): Promise<boolean> {\n const res = await this.request<{ success: boolean }>(\"DELETE\", `/api/v1/atoms/${atomId}/checkout`);\n return res.success;\n }\n\n async getQueueStatus(atomId: string): Promise<QueueStatus> {\n return this.request<QueueStatus>(\"GET\", `/api/v1/atoms/${atomId}/queue`);\n }\n}\n"],"mappings":";AAkBO,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,SAAwB;AAClC,SAAK,UAAU,QAAQ,QAAQ,QAAQ,OAAO,EAAE;AAChD,SAAK,SAAS,QAAQ;AACtB,SAAK,UAAU,QAAQ,WAAW;AAAA,EACpC;AAAA,EAEA,MAAc,QACZ,QACA,MACA,MACA,OACY;AACZ,UAAM,KAAK,QACP,MACA,OAAO,QAAQ,KAAK,EACjB,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,EACjC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,mBAAmB,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kg = JSON.parse(readFileSync4(resolve4(process.cwd(), "package.json"), "utf-8"));
|
|
347
347
|
return pkg.version;
|
|
348
348
|
} catch {
|
|
349
|
-
return "2.1.
|
|
349
|
+
return "2.1.3";
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
}
|
|
@@ -1370,7 +1370,7 @@ function getVersion2() {
|
|
|
1370
1370
|
const pkg = JSON.parse(readFileSync4(resolve4(process.cwd(), "package.json"), "utf-8"));
|
|
1371
1371
|
return pkg.version;
|
|
1372
1372
|
} catch {
|
|
1373
|
-
return "2.1.
|
|
1373
|
+
return "2.1.3";
|
|
1374
1374
|
}
|
|
1375
1375
|
}
|
|
1376
1376
|
}
|
|
@@ -1643,7 +1643,7 @@ var PKG_VERSION = (() => {
|
|
|
1643
1643
|
const pkg = JSON.parse(require("fs").readFileSync(require("path").resolve(__dirname, "../../package.json"), "utf-8"));
|
|
1644
1644
|
return pkg.version;
|
|
1645
1645
|
} catch {
|
|
1646
|
-
return "2.1.
|
|
1646
|
+
return "2.1.3";
|
|
1647
1647
|
}
|
|
1648
1648
|
})();
|
|
1649
1649
|
function handleHealth(store, pathname, method, res) {
|