@hasna/mementos 0.14.16 → 0.14.17

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/dist/cli/index.js CHANGED
@@ -25140,7 +25140,7 @@ function getPackageVersion2() {
25140
25140
  }
25141
25141
  }
25142
25142
  var program2 = new Command;
25143
- program2.name("mementos").description("Universal memory system for AI agents").version(getPackageVersion2()).option("--project <path>", "Project path for scoping").option("--json", "Output as JSON").option("--format <fmt>", "Output format: compact, json, csv, yaml").option("--agent <name>", "Agent name or ID").option("--session <id>", "Session ID");
25143
+ program2.name("mementos").description("Universal memory system for AI agents").version(getPackageVersion2()).option("-p, --project <path>", "Project path for scoping").option("-j, --json", "Output as JSON").option("-f, --format <fmt>", "Output format: compact, json, csv, yaml").option("-a, --agent <name>", "Agent name or ID").option("-s, --session <id>", "Session ID");
25144
25144
  registerInitCommand(program2);
25145
25145
  registerMemoryCommands(program2);
25146
25146
  registerInfoCommands(program2);
package/dist/mcp/index.js CHANGED
@@ -29704,6 +29704,19 @@ var server = new McpServer({
29704
29704
  When running with --dangerously-load-development-channels, mementos will proactively push relevant memories into your conversation via channel notifications. These appear as <channel source="mementos"> tags. They contain memories activated by your current task context \u2014 use them to inform your work. You don't need to call memory_inject when auto-inject is active.`
29705
29705
  });
29706
29706
  mcpServer = server;
29707
+ function hasFlag(...flags) {
29708
+ return process.argv.some((arg) => flags.includes(arg));
29709
+ }
29710
+ function printHelp() {
29711
+ process.stdout.write(`Usage: mementos-mcp [options]
29712
+
29713
+ Mementos MCP server (stdio transport)
29714
+
29715
+ Options:
29716
+ -h, --help Show help
29717
+ -V, --version Show version
29718
+ `);
29719
+ }
29707
29720
  registerMemoryTools(server);
29708
29721
  registerGraphTools(server);
29709
29722
  registerAgentTools(server);
@@ -29755,6 +29768,15 @@ async function ensureRestServerRunning() {
29755
29768
  }
29756
29769
  }
29757
29770
  async function main() {
29771
+ if (hasFlag("--help", "-h")) {
29772
+ printHelp();
29773
+ return;
29774
+ }
29775
+ if (hasFlag("--version", "-V")) {
29776
+ process.stdout.write(`${_pkg.version}
29777
+ `);
29778
+ return;
29779
+ }
29758
29780
  await ensureRestServerRunning();
29759
29781
  loadWebhooksFromDb();
29760
29782
  const transport = new StdioServerTransport;
@@ -17256,20 +17256,49 @@ addRoute("GET", "/api/chains/:sequence_group", (_req, _url, params) => {
17256
17256
 
17257
17257
  // src/server/index.ts
17258
17258
  var DEFAULT_PORT = 19428;
17259
+ function hasFlag(...flags) {
17260
+ return process.argv.some((arg) => flags.includes(arg));
17261
+ }
17262
+ function printHelp() {
17263
+ process.stdout.write(`Usage: mementos-serve [options]
17264
+
17265
+ Mementos REST API server.
17266
+
17267
+ Options:
17268
+ --port <number> Port to bind (default: 19428)
17269
+ -h, --help Show help
17270
+ -V, --version Show version
17271
+ `);
17272
+ }
17273
+ function parsePortNumber(raw, source) {
17274
+ if (!/^\d+$/.test(raw)) {
17275
+ throw new Error(`Invalid ${source} value "${raw}". Expected an integer between 1 and 65535.`);
17276
+ }
17277
+ const parsed = Number(raw);
17278
+ if (!Number.isInteger(parsed) || parsed < 1 || parsed > 65535) {
17279
+ throw new Error(`Invalid ${source} value "${raw}". Expected an integer between 1 and 65535.`);
17280
+ }
17281
+ return parsed;
17282
+ }
17259
17283
  function parsePort() {
17260
17284
  const envPort = process.env["PORT"];
17261
17285
  if (envPort) {
17262
- const p = parseInt(envPort, 10);
17263
- if (!Number.isNaN(p))
17264
- return p;
17286
+ return parsePortNumber(envPort, "PORT");
17265
17287
  }
17266
17288
  const portArg = process.argv.find((a) => a === "--port" || a.startsWith("--port="));
17267
17289
  if (portArg) {
17268
17290
  if (portArg.includes("=")) {
17269
- return parseInt(portArg.split("=")[1], 10) || DEFAULT_PORT;
17291
+ const raw2 = portArg.split("=")[1] ?? "";
17292
+ if (!raw2)
17293
+ throw new Error("Missing value for --port. Example: --port 19428");
17294
+ return parsePortNumber(raw2, "--port");
17270
17295
  }
17271
17296
  const idx = process.argv.indexOf(portArg);
17272
- return parseInt(process.argv[idx + 1], 10) || DEFAULT_PORT;
17297
+ const raw = process.argv[idx + 1];
17298
+ if (!raw || raw.startsWith("-")) {
17299
+ throw new Error("Missing value for --port. Example: --port 19428");
17300
+ }
17301
+ return parsePortNumber(raw, "--port");
17273
17302
  }
17274
17303
  return DEFAULT_PORT;
17275
17304
  }
@@ -17384,6 +17413,18 @@ function startServer(port) {
17384
17413
  console.log(`Mementos server listening on http://${hostname}:${port}`);
17385
17414
  }
17386
17415
  async function main() {
17416
+ if (hasFlag("--help", "-h")) {
17417
+ printHelp();
17418
+ return;
17419
+ }
17420
+ if (hasFlag("--version", "-V")) {
17421
+ const { createRequire: createRequire2 } = await import("module");
17422
+ const req = createRequire2(import.meta.url);
17423
+ const pkg = req("../../package.json");
17424
+ process.stdout.write(`${pkg.version}
17425
+ `);
17426
+ return;
17427
+ }
17387
17428
  const requestedPort = parsePort();
17388
17429
  const port = await findFreePort(requestedPort);
17389
17430
  if (port !== requestedPort) {
@@ -17391,7 +17432,11 @@ async function main() {
17391
17432
  }
17392
17433
  startServer(port);
17393
17434
  }
17394
- main();
17435
+ main().catch((error) => {
17436
+ const message = error instanceof Error ? error.message : String(error);
17437
+ console.error(`[mementos-serve] ${message}`);
17438
+ process.exit(1);
17439
+ });
17395
17440
  export {
17396
17441
  startServer
17397
17442
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/mementos",
3
- "version": "0.14.16",
3
+ "version": "0.14.17",
4
4
  "description": "Universal memory system for AI agents - CLI + MCP server + library API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -77,4 +77,4 @@
77
77
  "@types/react": "^18.3.18",
78
78
  "typescript": "^5.7.3"
79
79
  }
80
- }
80
+ }