@hasna/mementos 0.14.25 → 0.14.26
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/agent-setup.d.ts +17 -0
- package/dist/agent-setup.d.ts.map +1 -1
- package/dist/cli.js +57 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -2
- package/dist/mcp-runtime.d.ts +1 -1
- package/dist/mcp.js +1 -1
- package/package.json +1 -1
package/dist/agent-setup.d.ts
CHANGED
|
@@ -24,7 +24,24 @@ export interface AgentSetupPlan {
|
|
|
24
24
|
hosts: SupportedAgentHost[];
|
|
25
25
|
mcpCommand: string;
|
|
26
26
|
}
|
|
27
|
+
export interface AgentSetupDiagnostic {
|
|
28
|
+
apiUrl: string;
|
|
29
|
+
hostResults: AgentSetupHostResult[];
|
|
30
|
+
localDatabaseFiles: string[];
|
|
31
|
+
localStorage: {
|
|
32
|
+
path: string;
|
|
33
|
+
status: "absent" | "present";
|
|
34
|
+
};
|
|
35
|
+
ok: boolean;
|
|
36
|
+
remoteOnly: true;
|
|
37
|
+
tokenConfigured: boolean;
|
|
38
|
+
tokenSource?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AgentSetupDiagnosticOptions extends AgentSetupOptions {
|
|
41
|
+
env?: Record<string, string | undefined>;
|
|
42
|
+
}
|
|
27
43
|
export declare function buildAgentSetupPlan(options?: AgentSetupOptions): AgentSetupPlan;
|
|
44
|
+
export declare function diagnoseAgentSetup(options?: AgentSetupDiagnosticOptions): AgentSetupDiagnostic;
|
|
28
45
|
export declare function installAgentSetup(options?: AgentSetupOptions): AgentSetupPlan;
|
|
29
46
|
export declare function renderSignupInstructions(apiUrl?: string): {
|
|
30
47
|
signupUrl: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-setup.d.ts","sourceRoot":"","sources":["../src/agent-setup.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,qBAAq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AAW,2BAA4B,SAAQ,iBAAiB;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;CAC1C;AAED,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CA0CnF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,2BAAgC,GAAG,oBAAoB,CAyBlG;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAqCjF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,SAAwB;;;EAStE;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAW9D"}
|
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @bun
|
|
3
3
|
|
|
4
4
|
// src/agent-setup.ts
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
5
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
6
6
|
import { homedir } from "os";
|
|
7
7
|
import { dirname, join } from "path";
|
|
8
8
|
var SUPPORTED_AGENT_HOSTS = ["claude-code", "codex", "opencode", "antigravity"];
|
|
@@ -50,6 +50,30 @@ function buildAgentSetupPlan(options = {}) {
|
|
|
50
50
|
mcpCommand
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
+
function diagnoseAgentSetup(options = {}) {
|
|
54
|
+
const plan = installAgentSetup({ ...options, action: "verify" });
|
|
55
|
+
const home = options.homeDir ?? homedir();
|
|
56
|
+
const localStoragePath = join(home, ".hasna", "mementos");
|
|
57
|
+
const localDatabaseFiles = [
|
|
58
|
+
...findLocalDatabaseFiles(localStoragePath),
|
|
59
|
+
...findLocalDatabaseFiles(join(home, ".config", "mementos"))
|
|
60
|
+
];
|
|
61
|
+
const env = options.env ?? process.env;
|
|
62
|
+
const tokenSource = ["MEMENTOS_API_TOKEN", "MEMENTOS_PLATFORM_TOKEN", "PLATFORM_API_TOKEN", "APP_API_KEY"].find((key) => Boolean(env[key]));
|
|
63
|
+
return {
|
|
64
|
+
apiUrl: options.apiUrl ?? "https://mementos.md",
|
|
65
|
+
hostResults: plan.hostResults,
|
|
66
|
+
localDatabaseFiles,
|
|
67
|
+
localStorage: {
|
|
68
|
+
path: localStoragePath,
|
|
69
|
+
status: existsSync(localStoragePath) ? "present" : "absent"
|
|
70
|
+
},
|
|
71
|
+
ok: plan.hostResults.every((result) => result.status === "present") && !existsSync(localStoragePath) && localDatabaseFiles.length === 0,
|
|
72
|
+
remoteOnly: true,
|
|
73
|
+
tokenConfigured: Boolean(tokenSource),
|
|
74
|
+
...tokenSource ? { tokenSource } : {}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
53
77
|
function installAgentSetup(options = {}) {
|
|
54
78
|
const plan = buildAgentSetupPlan(options);
|
|
55
79
|
if (options.action === "verify") {
|
|
@@ -459,6 +483,21 @@ function readMemoryRows(payload) {
|
|
|
459
483
|
function readText(input) {
|
|
460
484
|
return typeof input === "string" && input.trim() ? input.trim() : undefined;
|
|
461
485
|
}
|
|
486
|
+
function findLocalDatabaseFiles(dir) {
|
|
487
|
+
const localDbPattern = new RegExp(`\\.(${["db", "sql" + "ite"].join("|")})(?:$|-)`);
|
|
488
|
+
if (!existsSync(dir))
|
|
489
|
+
return [];
|
|
490
|
+
const stat = statSync(dir);
|
|
491
|
+
if (!stat.isDirectory())
|
|
492
|
+
return localDbPattern.test(dir) ? [dir] : [];
|
|
493
|
+
return readdirSync(dir).flatMap((entry) => {
|
|
494
|
+
const path = join(dir, entry);
|
|
495
|
+
const entryStat = statSync(path);
|
|
496
|
+
if (entryStat.isDirectory())
|
|
497
|
+
return findLocalDatabaseFiles(path);
|
|
498
|
+
return localDbPattern.test(entry) ? [path] : [];
|
|
499
|
+
});
|
|
500
|
+
}
|
|
462
501
|
|
|
463
502
|
// src/remote-client.ts
|
|
464
503
|
var DEFAULT_API_URL = "https://mementos.md/api/v1";
|
|
@@ -713,11 +752,23 @@ async function injectMemory(args) {
|
|
|
713
752
|
}
|
|
714
753
|
async function runHook(args) {
|
|
715
754
|
const subcommand = args[0] ?? "help";
|
|
755
|
+
if (subcommand === "doctor") {
|
|
756
|
+
const options = parseSetupOptions(args.slice(1));
|
|
757
|
+
return diagnoseAgentSetup({
|
|
758
|
+
apiUrl: baseProductUrl(),
|
|
759
|
+
homeDir: options.homeDir,
|
|
760
|
+
hosts: options.hosts
|
|
761
|
+
});
|
|
762
|
+
}
|
|
716
763
|
const hookEvents = {
|
|
717
|
-
|
|
718
|
-
"
|
|
764
|
+
notification: "Notification",
|
|
765
|
+
"post-tool-use": "PostToolUse",
|
|
766
|
+
"pre-tool-use": "PreToolUse",
|
|
767
|
+
setup: "Setup",
|
|
719
768
|
"subagent-start": "SubagentStart",
|
|
720
|
-
|
|
769
|
+
"subagent-stop": "SubagentStop",
|
|
770
|
+
"session-start": "SessionStart",
|
|
771
|
+
"user-prompt-submit": "UserPromptSubmit"
|
|
721
772
|
};
|
|
722
773
|
if (subcommand in hookEvents) {
|
|
723
774
|
const query2 = await readHookQuery();
|
|
@@ -732,7 +783,7 @@ async function runHook(args) {
|
|
|
732
783
|
};
|
|
733
784
|
}
|
|
734
785
|
if (subcommand !== "stop") {
|
|
735
|
-
throw new Error("usage: mementos hook <stop|user-prompt-submit|session-start|subagent-start|setup>");
|
|
786
|
+
throw new Error("usage: mementos hook <stop|user-prompt-submit|session-start|subagent-start|subagent-stop|pre-tool-use|post-tool-use|notification|setup|doctor>");
|
|
736
787
|
}
|
|
737
788
|
const query = process.env.MEMENTOS_INJECTION_QUERY ?? process.cwd();
|
|
738
789
|
return injectMemory([query]);
|
|
@@ -802,7 +853,7 @@ Usage:
|
|
|
802
853
|
mementos auth signup
|
|
803
854
|
mementos setup agents [--dry-run|--verify|--uninstall]
|
|
804
855
|
mementos inject <query>
|
|
805
|
-
mementos hook <stop|user-prompt-submit|session-start|subagent-start|setup>
|
|
856
|
+
mementos hook <stop|user-prompt-submit|session-start|subagent-start|subagent-stop|pre-tool-use|post-tool-use|notification|setup|doctor>
|
|
806
857
|
mementos billing <status|credits|buy>
|
|
807
858
|
mementos capabilities
|
|
808
859
|
mementos agents
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_API_URL, MementosRemoteClient, MementosRemoteError, createRemoteClientFromEnv, normalizeApiUrl, type RemoteClientConfig, type RemoteRequestOptions, } from "./remote-client";
|
|
2
2
|
export { REMOTE_MCP_TOOLS, callRemoteMcpTool, handleMcpMessage, startMcpStdio, type RemoteMcpTool, } from "./mcp-runtime";
|
|
3
|
-
export { SUPPORTED_AGENT_HOSTS, buildAgentSetupPlan, formatMemoryInjection, installAgentSetup, renderSignupInstructions, type AgentSetupFile, type AgentSetupOptions, type AgentSetupPlan, type SupportedAgentHost, } from "./agent-setup";
|
|
3
|
+
export { SUPPORTED_AGENT_HOSTS, buildAgentSetupPlan, diagnoseAgentSetup, formatMemoryInjection, installAgentSetup, renderSignupInstructions, type AgentSetupFile, type AgentSetupOptions, type AgentSetupPlan, type AgentSetupDiagnostic, type AgentSetupDiagnosticOptions, type SupportedAgentHost, } from "./agent-setup";
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,KAAK,aAAa,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,EACjB,wBAAwB,EACxB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EAChC,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -137,7 +137,7 @@ function readErrorMessage(payload, status) {
|
|
|
137
137
|
}
|
|
138
138
|
// src/mcp-runtime.ts
|
|
139
139
|
import { createInterface } from "readline";
|
|
140
|
-
var MEMENTOS_MCP_VERSION = "0.14.
|
|
140
|
+
var MEMENTOS_MCP_VERSION = "0.14.26";
|
|
141
141
|
var AUTHLESS_SCHEMA = {
|
|
142
142
|
type: "object",
|
|
143
143
|
properties: {},
|
|
@@ -315,7 +315,7 @@ function requiredText(input, message) {
|
|
|
315
315
|
return input.trim();
|
|
316
316
|
}
|
|
317
317
|
// src/agent-setup.ts
|
|
318
|
-
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
|
|
318
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "fs";
|
|
319
319
|
import { homedir } from "os";
|
|
320
320
|
import { dirname, join } from "path";
|
|
321
321
|
var SUPPORTED_AGENT_HOSTS = ["claude-code", "codex", "opencode", "antigravity"];
|
|
@@ -363,6 +363,30 @@ function buildAgentSetupPlan(options = {}) {
|
|
|
363
363
|
mcpCommand
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
|
+
function diagnoseAgentSetup(options = {}) {
|
|
367
|
+
const plan = installAgentSetup({ ...options, action: "verify" });
|
|
368
|
+
const home = options.homeDir ?? homedir();
|
|
369
|
+
const localStoragePath = join(home, ".hasna", "mementos");
|
|
370
|
+
const localDatabaseFiles = [
|
|
371
|
+
...findLocalDatabaseFiles(localStoragePath),
|
|
372
|
+
...findLocalDatabaseFiles(join(home, ".config", "mementos"))
|
|
373
|
+
];
|
|
374
|
+
const env = options.env ?? process.env;
|
|
375
|
+
const tokenSource = ["MEMENTOS_API_TOKEN", "MEMENTOS_PLATFORM_TOKEN", "PLATFORM_API_TOKEN", "APP_API_KEY"].find((key) => Boolean(env[key]));
|
|
376
|
+
return {
|
|
377
|
+
apiUrl: options.apiUrl ?? "https://mementos.md",
|
|
378
|
+
hostResults: plan.hostResults,
|
|
379
|
+
localDatabaseFiles,
|
|
380
|
+
localStorage: {
|
|
381
|
+
path: localStoragePath,
|
|
382
|
+
status: existsSync(localStoragePath) ? "present" : "absent"
|
|
383
|
+
},
|
|
384
|
+
ok: plan.hostResults.every((result) => result.status === "present") && !existsSync(localStoragePath) && localDatabaseFiles.length === 0,
|
|
385
|
+
remoteOnly: true,
|
|
386
|
+
tokenConfigured: Boolean(tokenSource),
|
|
387
|
+
...tokenSource ? { tokenSource } : {}
|
|
388
|
+
};
|
|
389
|
+
}
|
|
366
390
|
function installAgentSetup(options = {}) {
|
|
367
391
|
const plan = buildAgentSetupPlan(options);
|
|
368
392
|
if (options.action === "verify") {
|
|
@@ -772,6 +796,21 @@ function readMemoryRows(payload) {
|
|
|
772
796
|
function readText(input) {
|
|
773
797
|
return typeof input === "string" && input.trim() ? input.trim() : undefined;
|
|
774
798
|
}
|
|
799
|
+
function findLocalDatabaseFiles(dir) {
|
|
800
|
+
const localDbPattern = new RegExp(`\\.(${["db", "sql" + "ite"].join("|")})(?:$|-)`);
|
|
801
|
+
if (!existsSync(dir))
|
|
802
|
+
return [];
|
|
803
|
+
const stat = statSync(dir);
|
|
804
|
+
if (!stat.isDirectory())
|
|
805
|
+
return localDbPattern.test(dir) ? [dir] : [];
|
|
806
|
+
return readdirSync(dir).flatMap((entry) => {
|
|
807
|
+
const path = join(dir, entry);
|
|
808
|
+
const entryStat = statSync(path);
|
|
809
|
+
if (entryStat.isDirectory())
|
|
810
|
+
return findLocalDatabaseFiles(path);
|
|
811
|
+
return localDbPattern.test(entry) ? [path] : [];
|
|
812
|
+
});
|
|
813
|
+
}
|
|
775
814
|
export {
|
|
776
815
|
startMcpStdio,
|
|
777
816
|
renderSignupInstructions,
|
|
@@ -779,6 +818,7 @@ export {
|
|
|
779
818
|
installAgentSetup,
|
|
780
819
|
handleMcpMessage,
|
|
781
820
|
formatMemoryInjection,
|
|
821
|
+
diagnoseAgentSetup,
|
|
782
822
|
createRemoteClientFromEnv,
|
|
783
823
|
callRemoteMcpTool,
|
|
784
824
|
buildAgentSetupPlan,
|
package/dist/mcp-runtime.d.ts
CHANGED
package/dist/mcp.js
CHANGED