@hasna/mementos 0.14.29 → 0.14.31
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 +24 -0
- package/dist/bridge.d.ts +50 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/cli.js +355 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +201 -2
- package/dist/mcp-runtime.d.ts +1 -1
- package/dist/mcp-runtime.d.ts.map +1 -1
- package/dist/mcp.js +14 -2
- package/dist/remote-client.d.ts +2 -0
- package/dist/remote-client.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,3 +47,27 @@ integration snippets. OpenCode and Antigravity receive the same MCP registration
|
|
|
47
47
|
plus host instruction files that tell the agent to use `memory.search`,
|
|
48
48
|
`memory.save`, and `mementos inject` as the hosted fallback path when native
|
|
49
49
|
hooks are unavailable.
|
|
50
|
+
|
|
51
|
+
## Brain workers
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
mementos brain workers
|
|
55
|
+
mementos brain fire "summarize this session" --worker memory --worker recap --persist --project platform-mementos
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Brain runs are hosted Cerebras-backed jobs queued through mementos.md billing
|
|
59
|
+
and run history. The CLI only sends the request to the hosted API; it does not
|
|
60
|
+
run local workers or keep local memory.
|
|
61
|
+
|
|
62
|
+
## Bridge
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mementos bridge status
|
|
66
|
+
mementos bridge start --agent <name>
|
|
67
|
+
mementos bridge stop
|
|
68
|
+
mementos bridge install
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The bridge is remote-only. It keeps PID/log/service metadata under user config
|
|
72
|
+
paths and heartbeats the hosted agent when `--agent` or `MEMENTOS_AGENT_NAME` is
|
|
73
|
+
set; it does not own a local memory store.
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface BridgeOptions {
|
|
2
|
+
agentName?: string;
|
|
3
|
+
apiUrl?: string;
|
|
4
|
+
homeDir?: string;
|
|
5
|
+
intervalMs?: number;
|
|
6
|
+
platform?: NodeJS.Platform;
|
|
7
|
+
}
|
|
8
|
+
export interface BridgeStartOptions extends BridgeOptions {
|
|
9
|
+
command?: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface BridgeServiceOptions extends BridgeOptions {
|
|
12
|
+
command?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface BridgePaths {
|
|
15
|
+
baseDir: string;
|
|
16
|
+
logFile: string;
|
|
17
|
+
pidFile: string;
|
|
18
|
+
serviceFile: string;
|
|
19
|
+
}
|
|
20
|
+
export interface BridgeStatus {
|
|
21
|
+
agentName?: string;
|
|
22
|
+
apiUrl: string;
|
|
23
|
+
localDatabase: false;
|
|
24
|
+
logFile: string;
|
|
25
|
+
pid?: number;
|
|
26
|
+
pidFile: string;
|
|
27
|
+
remoteOnly: true;
|
|
28
|
+
running: boolean;
|
|
29
|
+
startedAt?: string;
|
|
30
|
+
}
|
|
31
|
+
export interface BridgeServiceResult {
|
|
32
|
+
path: string;
|
|
33
|
+
remoteOnly: true;
|
|
34
|
+
status: "installed" | "removed" | "absent";
|
|
35
|
+
}
|
|
36
|
+
export declare function buildBridgePaths(homeDir?: string, platform?: NodeJS.Platform): BridgePaths;
|
|
37
|
+
export declare function getBridgeStatus(options?: BridgeOptions): BridgeStatus;
|
|
38
|
+
export declare function startBridge(options?: BridgeStartOptions): BridgeStatus;
|
|
39
|
+
export declare function stopBridge(options?: BridgeOptions): BridgeServiceResult;
|
|
40
|
+
export declare function installBridgeService(options?: BridgeServiceOptions): BridgeServiceResult;
|
|
41
|
+
export declare function uninstallBridgeService(options?: BridgeOptions): BridgeServiceResult;
|
|
42
|
+
export declare function readBridgeLogs(options?: BridgeOptions & {
|
|
43
|
+
lines?: number;
|
|
44
|
+
}): string[];
|
|
45
|
+
export declare function writeBridgePid(options: BridgeOptions & {
|
|
46
|
+
pid: number;
|
|
47
|
+
startedAt: string;
|
|
48
|
+
}): void;
|
|
49
|
+
export declare function clearBridgePid(options?: BridgeOptions): void;
|
|
50
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,IAAI,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;CAC5C;AASD,wBAAgB,gBAAgB,CAAC,OAAO,SAAY,EAAE,QAAQ,GAAE,MAAM,CAAC,QAA2B,GAAG,WAAW,CAU/G;AAED,wBAAgB,eAAe,CAAC,OAAO,GAAE,aAAkB,GAAG,YAAY,CAYzE;AAED,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,YAAY,CA8B1E;AAED,wBAAgB,UAAU,CAAC,OAAO,GAAE,aAAkB,GAAG,mBAAmB,CAO3E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,oBAAyB,GAAG,mBAAmB,CAW5F;AAED,wBAAgB,sBAAsB,CAAC,OAAO,GAAE,aAAkB,GAAG,mBAAmB,CAKvF;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,aAAa,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,MAAM,EAAE,CAOzF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAShG;AAED,wBAAgB,cAAc,CAAC,OAAO,GAAE,aAAkB,GAAG,IAAI,CAEhE"}
|
package/dist/cli.js
CHANGED
|
@@ -573,6 +573,185 @@ function findLocalDatabaseFiles(dir) {
|
|
|
573
573
|
});
|
|
574
574
|
}
|
|
575
575
|
|
|
576
|
+
// src/bridge.ts
|
|
577
|
+
import { spawn } from "child_process";
|
|
578
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
579
|
+
import { homedir as homedir2 } from "os";
|
|
580
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
581
|
+
function buildBridgePaths(homeDir = homedir2(), platform = process.platform) {
|
|
582
|
+
const baseDir = join2(homeDir, ".config", "mementos", "bridge");
|
|
583
|
+
return {
|
|
584
|
+
baseDir,
|
|
585
|
+
logFile: join2(baseDir, "bridge.log"),
|
|
586
|
+
pidFile: join2(baseDir, "bridge.pid.json"),
|
|
587
|
+
serviceFile: platform === "darwin" ? join2(homeDir, "Library", "LaunchAgents", "md.mementos.bridge.plist") : join2(homeDir, ".config", "systemd", "user", "mementos-bridge.service")
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
function getBridgeStatus(options = {}) {
|
|
591
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
592
|
+
const pidFile = readBridgePid(paths.pidFile);
|
|
593
|
+
if (pidFile && !isRunning(pidFile.pid)) {
|
|
594
|
+
rmSync2(paths.pidFile, { force: true });
|
|
595
|
+
return baseStatus(paths, options, false);
|
|
596
|
+
}
|
|
597
|
+
return {
|
|
598
|
+
...baseStatus(paths, options, Boolean(pidFile)),
|
|
599
|
+
...pidFile?.agentName ? { agentName: pidFile.agentName } : {},
|
|
600
|
+
...pidFile ? { pid: pidFile.pid, startedAt: pidFile.startedAt } : {}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function startBridge(options = {}) {
|
|
604
|
+
const current = getBridgeStatus(options);
|
|
605
|
+
if (current.running)
|
|
606
|
+
return current;
|
|
607
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
608
|
+
mkdirSync2(paths.baseDir, { recursive: true });
|
|
609
|
+
const out = openSync(paths.logFile, "a");
|
|
610
|
+
const err = openSync(paths.logFile, "a");
|
|
611
|
+
const command = options.command ?? [process.execPath, process.argv[1] ?? "mementos", "bridge", "run"];
|
|
612
|
+
const child = spawn(command[0] ?? "mementos", command.slice(1), {
|
|
613
|
+
detached: true,
|
|
614
|
+
env: {
|
|
615
|
+
...process.env,
|
|
616
|
+
...options.agentName ? { MEMENTOS_AGENT_NAME: options.agentName } : {},
|
|
617
|
+
...options.apiUrl ? { MEMENTOS_API_URL: options.apiUrl } : {},
|
|
618
|
+
...options.homeDir ? { MEMENTOS_BRIDGE_HOME: options.homeDir } : {},
|
|
619
|
+
...options.intervalMs ? { MEMENTOS_BRIDGE_INTERVAL_MS: String(options.intervalMs) } : {}
|
|
620
|
+
},
|
|
621
|
+
stdio: ["ignore", out, err]
|
|
622
|
+
});
|
|
623
|
+
child.unref();
|
|
624
|
+
writeBridgePid({
|
|
625
|
+
agentName: options.agentName,
|
|
626
|
+
apiUrl: options.apiUrl,
|
|
627
|
+
homeDir: options.homeDir,
|
|
628
|
+
pid: child.pid ?? 0,
|
|
629
|
+
startedAt: new Date().toISOString()
|
|
630
|
+
});
|
|
631
|
+
return getBridgeStatus(options);
|
|
632
|
+
}
|
|
633
|
+
function stopBridge(options = {}) {
|
|
634
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
635
|
+
const pidFile = readBridgePid(paths.pidFile);
|
|
636
|
+
if (!pidFile)
|
|
637
|
+
return { path: paths.pidFile, remoteOnly: true, status: "absent" };
|
|
638
|
+
if (isRunning(pidFile.pid))
|
|
639
|
+
process.kill(pidFile.pid, "SIGTERM");
|
|
640
|
+
clearBridgePid(options);
|
|
641
|
+
return { path: paths.pidFile, remoteOnly: true, status: "removed" };
|
|
642
|
+
}
|
|
643
|
+
function installBridgeService(options = {}) {
|
|
644
|
+
const platform = options.platform ?? process.platform;
|
|
645
|
+
const paths = buildBridgePaths(options.homeDir, platform);
|
|
646
|
+
mkdirSync2(dirname2(paths.serviceFile), { recursive: true });
|
|
647
|
+
const command = options.command ?? "mementos bridge run";
|
|
648
|
+
const apiUrl = options.apiUrl ?? "https://mementos.md/api/v1";
|
|
649
|
+
const content = platform === "darwin" ? renderLaunchdService(command, apiUrl, options.agentName) : renderSystemdService(command, apiUrl, options.agentName);
|
|
650
|
+
writeFileSync2(paths.serviceFile, content, { mode: 420 });
|
|
651
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "installed" };
|
|
652
|
+
}
|
|
653
|
+
function uninstallBridgeService(options = {}) {
|
|
654
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
655
|
+
if (!existsSync2(paths.serviceFile))
|
|
656
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "absent" };
|
|
657
|
+
rmSync2(paths.serviceFile, { force: true });
|
|
658
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "removed" };
|
|
659
|
+
}
|
|
660
|
+
function readBridgeLogs(options = {}) {
|
|
661
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
662
|
+
if (!existsSync2(paths.logFile))
|
|
663
|
+
return [];
|
|
664
|
+
return readFileSync2(paths.logFile, "utf8").split(`
|
|
665
|
+
`).filter(Boolean).slice(-(options.lines ?? 40));
|
|
666
|
+
}
|
|
667
|
+
function writeBridgePid(options) {
|
|
668
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
669
|
+
mkdirSync2(paths.baseDir, { recursive: true });
|
|
670
|
+
writeFileSync2(paths.pidFile, `${JSON.stringify({
|
|
671
|
+
...options.agentName ? { agentName: options.agentName } : {},
|
|
672
|
+
...options.apiUrl ? { apiUrl: options.apiUrl } : {},
|
|
673
|
+
pid: options.pid,
|
|
674
|
+
startedAt: options.startedAt
|
|
675
|
+
}, null, 2)}
|
|
676
|
+
`, { mode: 420 });
|
|
677
|
+
}
|
|
678
|
+
function clearBridgePid(options = {}) {
|
|
679
|
+
rmSync2(buildBridgePaths(options.homeDir, options.platform).pidFile, { force: true });
|
|
680
|
+
}
|
|
681
|
+
function baseStatus(paths, options, running) {
|
|
682
|
+
return {
|
|
683
|
+
...options.agentName ? { agentName: options.agentName } : {},
|
|
684
|
+
apiUrl: options.apiUrl ?? "https://mementos.md/api/v1",
|
|
685
|
+
localDatabase: false,
|
|
686
|
+
logFile: paths.logFile,
|
|
687
|
+
pidFile: paths.pidFile,
|
|
688
|
+
remoteOnly: true,
|
|
689
|
+
running
|
|
690
|
+
};
|
|
691
|
+
}
|
|
692
|
+
function readBridgePid(path) {
|
|
693
|
+
if (!existsSync2(path))
|
|
694
|
+
return;
|
|
695
|
+
try {
|
|
696
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
697
|
+
return Number.isInteger(parsed.pid) && parsed.pid > 0 ? parsed : undefined;
|
|
698
|
+
} catch {
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
function isRunning(pid) {
|
|
703
|
+
try {
|
|
704
|
+
process.kill(pid, 0);
|
|
705
|
+
return true;
|
|
706
|
+
} catch {
|
|
707
|
+
return false;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
function renderSystemdService(command, apiUrl, agentName) {
|
|
711
|
+
return `[Unit]
|
|
712
|
+
Description=mementos.md remote bridge
|
|
713
|
+
|
|
714
|
+
[Service]
|
|
715
|
+
Type=simple
|
|
716
|
+
Environment=MEMENTOS_API_URL=${apiUrl}
|
|
717
|
+
${agentName ? `Environment=MEMENTOS_AGENT_NAME=${agentName}
|
|
718
|
+
` : ""}ExecStart=${command}
|
|
719
|
+
Restart=on-failure
|
|
720
|
+
|
|
721
|
+
[Install]
|
|
722
|
+
WantedBy=default.target
|
|
723
|
+
`;
|
|
724
|
+
}
|
|
725
|
+
function renderLaunchdService(command, apiUrl, agentName) {
|
|
726
|
+
const args = command.split(/\s+/).map((part) => ` <string>${escapeXml(part)}</string>`).join(`
|
|
727
|
+
`);
|
|
728
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
729
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
730
|
+
<plist version="1.0">
|
|
731
|
+
<dict>
|
|
732
|
+
<key>Label</key>
|
|
733
|
+
<string>md.mementos.bridge</string>
|
|
734
|
+
<key>ProgramArguments</key>
|
|
735
|
+
<array>
|
|
736
|
+
${args}
|
|
737
|
+
</array>
|
|
738
|
+
<key>EnvironmentVariables</key>
|
|
739
|
+
<dict>
|
|
740
|
+
<key>MEMENTOS_API_URL</key>
|
|
741
|
+
<string>${escapeXml(apiUrl)}</string>
|
|
742
|
+
${agentName ? ` <key>MEMENTOS_AGENT_NAME</key>
|
|
743
|
+
<string>${escapeXml(agentName)}</string>
|
|
744
|
+
` : ""} </dict>
|
|
745
|
+
<key>RunAtLoad</key>
|
|
746
|
+
<true/>
|
|
747
|
+
</dict>
|
|
748
|
+
</plist>
|
|
749
|
+
`;
|
|
750
|
+
}
|
|
751
|
+
function escapeXml(value) {
|
|
752
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
753
|
+
}
|
|
754
|
+
|
|
576
755
|
// src/remote-client.ts
|
|
577
756
|
var DEFAULT_API_URL = "https://mementos.md/api/v1";
|
|
578
757
|
|
|
@@ -644,6 +823,12 @@ class MementosRemoteClient {
|
|
|
644
823
|
createRun(slug, input = {}) {
|
|
645
824
|
return this.request(`/runs/${encodeURIComponent(slug)}`, { method: "POST", body: input });
|
|
646
825
|
}
|
|
826
|
+
listBrainWorkers() {
|
|
827
|
+
return this.request("/brain/workers");
|
|
828
|
+
}
|
|
829
|
+
fireBrain(input = {}) {
|
|
830
|
+
return this.request("/brain/fire", { method: "POST", body: input });
|
|
831
|
+
}
|
|
647
832
|
getRun(id) {
|
|
648
833
|
return this.request(`/runs/${encodeURIComponent(id)}`);
|
|
649
834
|
}
|
|
@@ -753,8 +938,12 @@ async function run(name, args) {
|
|
|
753
938
|
return injectMemory(args);
|
|
754
939
|
case "hook":
|
|
755
940
|
return runHook(args);
|
|
941
|
+
case "bridge":
|
|
942
|
+
return runBridge(args);
|
|
756
943
|
case "billing":
|
|
757
944
|
return runBilling(args);
|
|
945
|
+
case "brain":
|
|
946
|
+
return runBrain(args);
|
|
758
947
|
case "inbox":
|
|
759
948
|
return runInbox(args);
|
|
760
949
|
case "capabilities":
|
|
@@ -778,6 +967,37 @@ async function run(name, args) {
|
|
|
778
967
|
${helpText()}`);
|
|
779
968
|
}
|
|
780
969
|
}
|
|
970
|
+
async function runBridge(args) {
|
|
971
|
+
const subcommand = args[0] ?? "status";
|
|
972
|
+
const options = parseBridgeOptions(args.slice(1));
|
|
973
|
+
const bridgeOptions = {
|
|
974
|
+
agentName: options.agentName ?? process.env.MEMENTOS_AGENT_NAME,
|
|
975
|
+
apiUrl: baseApiUrl().endsWith("/api/v1") ? baseApiUrl() : `${baseApiUrl()}/api/v1`,
|
|
976
|
+
homeDir: options.homeDir ?? process.env.MEMENTOS_BRIDGE_HOME,
|
|
977
|
+
intervalMs: options.intervalMs ?? readPositiveInteger(process.env.MEMENTOS_BRIDGE_INTERVAL_MS)
|
|
978
|
+
};
|
|
979
|
+
switch (subcommand) {
|
|
980
|
+
case "start":
|
|
981
|
+
return startBridge(bridgeOptions);
|
|
982
|
+
case "status":
|
|
983
|
+
return getBridgeStatus(bridgeOptions);
|
|
984
|
+
case "stop":
|
|
985
|
+
return stopBridge(bridgeOptions);
|
|
986
|
+
case "install":
|
|
987
|
+
return installBridgeService({
|
|
988
|
+
...bridgeOptions,
|
|
989
|
+
command: "mementos bridge run"
|
|
990
|
+
});
|
|
991
|
+
case "uninstall":
|
|
992
|
+
return uninstallBridgeService(bridgeOptions);
|
|
993
|
+
case "logs":
|
|
994
|
+
return { lines: readBridgeLogs({ ...bridgeOptions, lines: options.lines }) };
|
|
995
|
+
case "run":
|
|
996
|
+
return runBridgeDaemon(bridgeOptions, Boolean(options.once));
|
|
997
|
+
default:
|
|
998
|
+
throw new Error("usage: mementos bridge <start|status|stop|install|uninstall|logs|run>");
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
781
1001
|
async function runInbox(args) {
|
|
782
1002
|
const subcommand = args[0] ?? "list";
|
|
783
1003
|
switch (subcommand) {
|
|
@@ -803,6 +1023,44 @@ async function runInbox(args) {
|
|
|
803
1023
|
throw new Error("usage: mementos inbox <send|list|claim>");
|
|
804
1024
|
}
|
|
805
1025
|
}
|
|
1026
|
+
async function runBridgeDaemon(options, once) {
|
|
1027
|
+
writeBridgePid({
|
|
1028
|
+
agentName: options.agentName,
|
|
1029
|
+
apiUrl: options.apiUrl,
|
|
1030
|
+
homeDir: options.homeDir,
|
|
1031
|
+
pid: process.pid,
|
|
1032
|
+
startedAt: new Date().toISOString()
|
|
1033
|
+
});
|
|
1034
|
+
const cleanup = () => clearBridgePid(options);
|
|
1035
|
+
process.once("SIGINT", () => {
|
|
1036
|
+
cleanup();
|
|
1037
|
+
process.exit(0);
|
|
1038
|
+
});
|
|
1039
|
+
process.once("SIGTERM", () => {
|
|
1040
|
+
cleanup();
|
|
1041
|
+
process.exit(0);
|
|
1042
|
+
});
|
|
1043
|
+
try {
|
|
1044
|
+
const intervalMs = options.intervalMs ?? 30000;
|
|
1045
|
+
do {
|
|
1046
|
+
if (options.agentName) {
|
|
1047
|
+
await client.heartbeatAgent({
|
|
1048
|
+
name: options.agentName,
|
|
1049
|
+
source: "mementos-bridge"
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
if (once)
|
|
1053
|
+
break;
|
|
1054
|
+
await sleep(intervalMs);
|
|
1055
|
+
} while (true);
|
|
1056
|
+
if (once)
|
|
1057
|
+
cleanup();
|
|
1058
|
+
return getBridgeStatus(options);
|
|
1059
|
+
} finally {
|
|
1060
|
+
if (once)
|
|
1061
|
+
cleanup();
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
806
1064
|
async function runBilling(args) {
|
|
807
1065
|
const subcommand = args[0] ?? "status";
|
|
808
1066
|
switch (subcommand) {
|
|
@@ -820,6 +1078,20 @@ async function runBilling(args) {
|
|
|
820
1078
|
throw new Error("usage: mementos billing <status|credits|buy>");
|
|
821
1079
|
}
|
|
822
1080
|
}
|
|
1081
|
+
async function runBrain(args) {
|
|
1082
|
+
const subcommand = args[0] ?? "workers";
|
|
1083
|
+
switch (subcommand) {
|
|
1084
|
+
case "workers":
|
|
1085
|
+
case "list":
|
|
1086
|
+
return client.listBrainWorkers();
|
|
1087
|
+
case "fire": {
|
|
1088
|
+
const input = parseBrainFireOptions(args.slice(1));
|
|
1089
|
+
return client.fireBrain(input);
|
|
1090
|
+
}
|
|
1091
|
+
default:
|
|
1092
|
+
throw new Error("usage: mementos brain <workers|fire>");
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
823
1095
|
async function runAuth(args) {
|
|
824
1096
|
const subcommand = args[0] ?? "help";
|
|
825
1097
|
if (subcommand !== "signup" && subcommand !== "login") {
|
|
@@ -1017,6 +1289,26 @@ function parseSetupOptions(args) {
|
|
|
1017
1289
|
}
|
|
1018
1290
|
return options;
|
|
1019
1291
|
}
|
|
1292
|
+
function parseBridgeOptions(args) {
|
|
1293
|
+
const options = {};
|
|
1294
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
1295
|
+
const arg = args[index];
|
|
1296
|
+
if (arg === "--agent" || arg === "--agent-name") {
|
|
1297
|
+
options.agentName = args[++index];
|
|
1298
|
+
} else if (arg === "--home") {
|
|
1299
|
+
options.homeDir = args[++index];
|
|
1300
|
+
} else if (arg === "--interval-ms") {
|
|
1301
|
+
options.intervalMs = readPositiveInteger(args[++index]);
|
|
1302
|
+
} else if (arg === "--lines") {
|
|
1303
|
+
options.lines = readPositiveInteger(args[++index]);
|
|
1304
|
+
} else if (arg === "--once") {
|
|
1305
|
+
options.once = true;
|
|
1306
|
+
} else {
|
|
1307
|
+
throw new Error(`Unknown bridge option: ${arg}`);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
return options;
|
|
1311
|
+
}
|
|
1020
1312
|
function parseInboxOptions(args) {
|
|
1021
1313
|
const options = {};
|
|
1022
1314
|
for (let index = 0;index < args.length; index += 1) {
|
|
@@ -1039,6 +1331,46 @@ function parseInboxOptions(args) {
|
|
|
1039
1331
|
}
|
|
1040
1332
|
return options;
|
|
1041
1333
|
}
|
|
1334
|
+
function parseBrainFireOptions(args) {
|
|
1335
|
+
const options = {};
|
|
1336
|
+
const workers = [];
|
|
1337
|
+
const text = [];
|
|
1338
|
+
for (let index = 0;index < args.length; index += 1) {
|
|
1339
|
+
const arg = args[index];
|
|
1340
|
+
if (arg === "--input" || arg === "--prompt" || arg === "--message") {
|
|
1341
|
+
options.input = args[++index] ?? "";
|
|
1342
|
+
} else if (arg === "--worker") {
|
|
1343
|
+
const worker = args[++index];
|
|
1344
|
+
if (worker)
|
|
1345
|
+
workers.push(worker);
|
|
1346
|
+
} else if (arg === "--workers") {
|
|
1347
|
+
workers.push(...splitCsv(args[++index] ?? ""));
|
|
1348
|
+
} else if (arg === "--persist") {
|
|
1349
|
+
options.persist = true;
|
|
1350
|
+
} else if (arg === "--project") {
|
|
1351
|
+
options.projectKey = args[++index];
|
|
1352
|
+
} else if (arg === "--session") {
|
|
1353
|
+
options.sessionId = args[++index];
|
|
1354
|
+
} else if (arg === "--max-workers") {
|
|
1355
|
+
options.maxWorkers = readRequiredPositiveInteger(args[++index], "--max-workers");
|
|
1356
|
+
} else if (arg === "--max-input-chars") {
|
|
1357
|
+
options.maxInputChars = readRequiredPositiveInteger(args[++index], "--max-input-chars");
|
|
1358
|
+
} else if (arg === "--max-output-tokens") {
|
|
1359
|
+
options.maxOutputTokens = readRequiredPositiveInteger(args[++index], "--max-output-tokens");
|
|
1360
|
+
} else if (arg.startsWith("--")) {
|
|
1361
|
+
throw new Error(`Unknown brain option: ${arg}`);
|
|
1362
|
+
} else {
|
|
1363
|
+
text.push(arg);
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
const input = readHookText(options.input) ?? text.join(" ").trim();
|
|
1367
|
+
if (!input)
|
|
1368
|
+
throw new Error("usage: mementos brain fire <input> [--worker <id>] [--persist] [--project <key>] [--session <id>]");
|
|
1369
|
+
options.input = input;
|
|
1370
|
+
if (workers.length > 0)
|
|
1371
|
+
options.workers = workers;
|
|
1372
|
+
return Object.fromEntries(Object.entries(options).filter(([, value]) => value !== undefined && value !== ""));
|
|
1373
|
+
}
|
|
1042
1374
|
function parseHosts(input) {
|
|
1043
1375
|
const requested = input.split(",").map((host) => host.trim()).filter(Boolean);
|
|
1044
1376
|
const unknown = requested.filter((host) => !SUPPORTED_AGENT_HOSTS.includes(host));
|
|
@@ -1049,6 +1381,27 @@ function parseHosts(input) {
|
|
|
1049
1381
|
function baseProductUrl() {
|
|
1050
1382
|
return (process.env.MEMENTOS_API_URL ?? DEFAULT_API_URL).replace(/\/api\/v1\/?$/, "").replace(/\/+$/, "");
|
|
1051
1383
|
}
|
|
1384
|
+
function baseApiUrl() {
|
|
1385
|
+
return (process.env.MEMENTOS_API_URL ?? DEFAULT_API_URL).replace(/\/+$/, "");
|
|
1386
|
+
}
|
|
1387
|
+
function readPositiveInteger(input) {
|
|
1388
|
+
if (!input)
|
|
1389
|
+
return;
|
|
1390
|
+
const value = Number(input);
|
|
1391
|
+
return Number.isInteger(value) && value > 0 ? value : undefined;
|
|
1392
|
+
}
|
|
1393
|
+
function readRequiredPositiveInteger(input, label) {
|
|
1394
|
+
const value = readPositiveInteger(input);
|
|
1395
|
+
if (!value)
|
|
1396
|
+
throw new Error(`${label} must be a positive integer`);
|
|
1397
|
+
return value;
|
|
1398
|
+
}
|
|
1399
|
+
function splitCsv(input) {
|
|
1400
|
+
return input.split(",").map((item) => item.trim()).filter(Boolean);
|
|
1401
|
+
}
|
|
1402
|
+
function sleep(ms) {
|
|
1403
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1404
|
+
}
|
|
1052
1405
|
function readTextPayload(payload) {
|
|
1053
1406
|
if (typeof payload !== "object" || payload === null)
|
|
1054
1407
|
return;
|
|
@@ -1063,8 +1416,10 @@ Usage:
|
|
|
1063
1416
|
mementos setup agents [--dry-run|--verify|--uninstall]
|
|
1064
1417
|
mementos inject <query>
|
|
1065
1418
|
mementos hook <stop|user-prompt-submit|session-start|subagent-start|subagent-stop|pre-tool-use|post-tool-use|notification|setup|doctor>
|
|
1419
|
+
mementos bridge <start|status|stop|install|uninstall|logs|run>
|
|
1066
1420
|
mementos inbox <send|list|claim>
|
|
1067
1421
|
mementos billing <status|credits|buy>
|
|
1422
|
+
mementos brain <workers|fire>
|
|
1068
1423
|
mementos capabilities
|
|
1069
1424
|
mementos agents
|
|
1070
1425
|
mementos usage
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
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
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
|
+
export { buildBridgePaths, clearBridgePid, getBridgeStatus, installBridgeService, readBridgeLogs, startBridge, stopBridge, uninstallBridgeService, writeBridgePid, type BridgeOptions, type BridgePaths, type BridgeServiceOptions, type BridgeServiceResult, type BridgeStartOptions, type BridgeStatus, } from "./bridge";
|
|
4
5
|
//# 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,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"}
|
|
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;AACvB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,oBAAoB,EACpB,cAAc,EACd,WAAW,EACX,UAAU,EACV,sBAAsB,EACtB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,YAAY,GAClB,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -70,6 +70,12 @@ class MementosRemoteClient {
|
|
|
70
70
|
createRun(slug, input = {}) {
|
|
71
71
|
return this.request(`/runs/${encodeURIComponent(slug)}`, { method: "POST", body: input });
|
|
72
72
|
}
|
|
73
|
+
listBrainWorkers() {
|
|
74
|
+
return this.request("/brain/workers");
|
|
75
|
+
}
|
|
76
|
+
fireBrain(input = {}) {
|
|
77
|
+
return this.request("/brain/fire", { method: "POST", body: input });
|
|
78
|
+
}
|
|
73
79
|
getRun(id) {
|
|
74
80
|
return this.request(`/runs/${encodeURIComponent(id)}`);
|
|
75
81
|
}
|
|
@@ -146,7 +152,7 @@ function readErrorMessage(payload, status) {
|
|
|
146
152
|
}
|
|
147
153
|
// src/mcp-runtime.ts
|
|
148
154
|
import { createInterface } from "readline";
|
|
149
|
-
var MEMENTOS_MCP_VERSION = "0.14.
|
|
155
|
+
var MEMENTOS_MCP_VERSION = "0.14.31";
|
|
150
156
|
var AUTHLESS_SCHEMA = {
|
|
151
157
|
type: "object",
|
|
152
158
|
properties: {},
|
|
@@ -245,11 +251,17 @@ var REMOTE_MCP_TOOLS = [
|
|
|
245
251
|
return client.createRun(slug, body);
|
|
246
252
|
}
|
|
247
253
|
},
|
|
254
|
+
{
|
|
255
|
+
name: "brain.workers",
|
|
256
|
+
description: "List hosted mementos.md Cerebras brain workers.",
|
|
257
|
+
inputSchema: AUTHLESS_SCHEMA,
|
|
258
|
+
run: (_input, client) => client.listBrainWorkers()
|
|
259
|
+
},
|
|
248
260
|
{
|
|
249
261
|
name: "brain.fire",
|
|
250
262
|
description: "Queue hosted mementos.md Cerebras brain workers.",
|
|
251
263
|
inputSchema: OPEN_SCHEMA,
|
|
252
|
-
run: (input, client) => client.
|
|
264
|
+
run: (input, client) => client.fireBrain(input)
|
|
253
265
|
},
|
|
254
266
|
{
|
|
255
267
|
name: "runs.get",
|
|
@@ -915,16 +927,203 @@ function findLocalDatabaseFiles(dir) {
|
|
|
915
927
|
return localDbPattern.test(entry) ? [path] : [];
|
|
916
928
|
});
|
|
917
929
|
}
|
|
930
|
+
// src/bridge.ts
|
|
931
|
+
import { spawn } from "child_process";
|
|
932
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, openSync, readFileSync as readFileSync2, rmSync as rmSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
933
|
+
import { homedir as homedir2 } from "os";
|
|
934
|
+
import { dirname as dirname2, join as join2 } from "path";
|
|
935
|
+
function buildBridgePaths(homeDir = homedir2(), platform = process.platform) {
|
|
936
|
+
const baseDir = join2(homeDir, ".config", "mementos", "bridge");
|
|
937
|
+
return {
|
|
938
|
+
baseDir,
|
|
939
|
+
logFile: join2(baseDir, "bridge.log"),
|
|
940
|
+
pidFile: join2(baseDir, "bridge.pid.json"),
|
|
941
|
+
serviceFile: platform === "darwin" ? join2(homeDir, "Library", "LaunchAgents", "md.mementos.bridge.plist") : join2(homeDir, ".config", "systemd", "user", "mementos-bridge.service")
|
|
942
|
+
};
|
|
943
|
+
}
|
|
944
|
+
function getBridgeStatus(options = {}) {
|
|
945
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
946
|
+
const pidFile = readBridgePid(paths.pidFile);
|
|
947
|
+
if (pidFile && !isRunning(pidFile.pid)) {
|
|
948
|
+
rmSync2(paths.pidFile, { force: true });
|
|
949
|
+
return baseStatus(paths, options, false);
|
|
950
|
+
}
|
|
951
|
+
return {
|
|
952
|
+
...baseStatus(paths, options, Boolean(pidFile)),
|
|
953
|
+
...pidFile?.agentName ? { agentName: pidFile.agentName } : {},
|
|
954
|
+
...pidFile ? { pid: pidFile.pid, startedAt: pidFile.startedAt } : {}
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
function startBridge(options = {}) {
|
|
958
|
+
const current = getBridgeStatus(options);
|
|
959
|
+
if (current.running)
|
|
960
|
+
return current;
|
|
961
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
962
|
+
mkdirSync2(paths.baseDir, { recursive: true });
|
|
963
|
+
const out = openSync(paths.logFile, "a");
|
|
964
|
+
const err = openSync(paths.logFile, "a");
|
|
965
|
+
const command = options.command ?? [process.execPath, process.argv[1] ?? "mementos", "bridge", "run"];
|
|
966
|
+
const child = spawn(command[0] ?? "mementos", command.slice(1), {
|
|
967
|
+
detached: true,
|
|
968
|
+
env: {
|
|
969
|
+
...process.env,
|
|
970
|
+
...options.agentName ? { MEMENTOS_AGENT_NAME: options.agentName } : {},
|
|
971
|
+
...options.apiUrl ? { MEMENTOS_API_URL: options.apiUrl } : {},
|
|
972
|
+
...options.homeDir ? { MEMENTOS_BRIDGE_HOME: options.homeDir } : {},
|
|
973
|
+
...options.intervalMs ? { MEMENTOS_BRIDGE_INTERVAL_MS: String(options.intervalMs) } : {}
|
|
974
|
+
},
|
|
975
|
+
stdio: ["ignore", out, err]
|
|
976
|
+
});
|
|
977
|
+
child.unref();
|
|
978
|
+
writeBridgePid({
|
|
979
|
+
agentName: options.agentName,
|
|
980
|
+
apiUrl: options.apiUrl,
|
|
981
|
+
homeDir: options.homeDir,
|
|
982
|
+
pid: child.pid ?? 0,
|
|
983
|
+
startedAt: new Date().toISOString()
|
|
984
|
+
});
|
|
985
|
+
return getBridgeStatus(options);
|
|
986
|
+
}
|
|
987
|
+
function stopBridge(options = {}) {
|
|
988
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
989
|
+
const pidFile = readBridgePid(paths.pidFile);
|
|
990
|
+
if (!pidFile)
|
|
991
|
+
return { path: paths.pidFile, remoteOnly: true, status: "absent" };
|
|
992
|
+
if (isRunning(pidFile.pid))
|
|
993
|
+
process.kill(pidFile.pid, "SIGTERM");
|
|
994
|
+
clearBridgePid(options);
|
|
995
|
+
return { path: paths.pidFile, remoteOnly: true, status: "removed" };
|
|
996
|
+
}
|
|
997
|
+
function installBridgeService(options = {}) {
|
|
998
|
+
const platform = options.platform ?? process.platform;
|
|
999
|
+
const paths = buildBridgePaths(options.homeDir, platform);
|
|
1000
|
+
mkdirSync2(dirname2(paths.serviceFile), { recursive: true });
|
|
1001
|
+
const command = options.command ?? "mementos bridge run";
|
|
1002
|
+
const apiUrl = options.apiUrl ?? "https://mementos.md/api/v1";
|
|
1003
|
+
const content = platform === "darwin" ? renderLaunchdService(command, apiUrl, options.agentName) : renderSystemdService(command, apiUrl, options.agentName);
|
|
1004
|
+
writeFileSync2(paths.serviceFile, content, { mode: 420 });
|
|
1005
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "installed" };
|
|
1006
|
+
}
|
|
1007
|
+
function uninstallBridgeService(options = {}) {
|
|
1008
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
1009
|
+
if (!existsSync2(paths.serviceFile))
|
|
1010
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "absent" };
|
|
1011
|
+
rmSync2(paths.serviceFile, { force: true });
|
|
1012
|
+
return { path: paths.serviceFile, remoteOnly: true, status: "removed" };
|
|
1013
|
+
}
|
|
1014
|
+
function readBridgeLogs(options = {}) {
|
|
1015
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
1016
|
+
if (!existsSync2(paths.logFile))
|
|
1017
|
+
return [];
|
|
1018
|
+
return readFileSync2(paths.logFile, "utf8").split(`
|
|
1019
|
+
`).filter(Boolean).slice(-(options.lines ?? 40));
|
|
1020
|
+
}
|
|
1021
|
+
function writeBridgePid(options) {
|
|
1022
|
+
const paths = buildBridgePaths(options.homeDir, options.platform);
|
|
1023
|
+
mkdirSync2(paths.baseDir, { recursive: true });
|
|
1024
|
+
writeFileSync2(paths.pidFile, `${JSON.stringify({
|
|
1025
|
+
...options.agentName ? { agentName: options.agentName } : {},
|
|
1026
|
+
...options.apiUrl ? { apiUrl: options.apiUrl } : {},
|
|
1027
|
+
pid: options.pid,
|
|
1028
|
+
startedAt: options.startedAt
|
|
1029
|
+
}, null, 2)}
|
|
1030
|
+
`, { mode: 420 });
|
|
1031
|
+
}
|
|
1032
|
+
function clearBridgePid(options = {}) {
|
|
1033
|
+
rmSync2(buildBridgePaths(options.homeDir, options.platform).pidFile, { force: true });
|
|
1034
|
+
}
|
|
1035
|
+
function baseStatus(paths, options, running) {
|
|
1036
|
+
return {
|
|
1037
|
+
...options.agentName ? { agentName: options.agentName } : {},
|
|
1038
|
+
apiUrl: options.apiUrl ?? "https://mementos.md/api/v1",
|
|
1039
|
+
localDatabase: false,
|
|
1040
|
+
logFile: paths.logFile,
|
|
1041
|
+
pidFile: paths.pidFile,
|
|
1042
|
+
remoteOnly: true,
|
|
1043
|
+
running
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function readBridgePid(path) {
|
|
1047
|
+
if (!existsSync2(path))
|
|
1048
|
+
return;
|
|
1049
|
+
try {
|
|
1050
|
+
const parsed = JSON.parse(readFileSync2(path, "utf8"));
|
|
1051
|
+
return Number.isInteger(parsed.pid) && parsed.pid > 0 ? parsed : undefined;
|
|
1052
|
+
} catch {
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
function isRunning(pid) {
|
|
1057
|
+
try {
|
|
1058
|
+
process.kill(pid, 0);
|
|
1059
|
+
return true;
|
|
1060
|
+
} catch {
|
|
1061
|
+
return false;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
function renderSystemdService(command, apiUrl, agentName) {
|
|
1065
|
+
return `[Unit]
|
|
1066
|
+
Description=mementos.md remote bridge
|
|
1067
|
+
|
|
1068
|
+
[Service]
|
|
1069
|
+
Type=simple
|
|
1070
|
+
Environment=MEMENTOS_API_URL=${apiUrl}
|
|
1071
|
+
${agentName ? `Environment=MEMENTOS_AGENT_NAME=${agentName}
|
|
1072
|
+
` : ""}ExecStart=${command}
|
|
1073
|
+
Restart=on-failure
|
|
1074
|
+
|
|
1075
|
+
[Install]
|
|
1076
|
+
WantedBy=default.target
|
|
1077
|
+
`;
|
|
1078
|
+
}
|
|
1079
|
+
function renderLaunchdService(command, apiUrl, agentName) {
|
|
1080
|
+
const args = command.split(/\s+/).map((part) => ` <string>${escapeXml(part)}</string>`).join(`
|
|
1081
|
+
`);
|
|
1082
|
+
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
1083
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
1084
|
+
<plist version="1.0">
|
|
1085
|
+
<dict>
|
|
1086
|
+
<key>Label</key>
|
|
1087
|
+
<string>md.mementos.bridge</string>
|
|
1088
|
+
<key>ProgramArguments</key>
|
|
1089
|
+
<array>
|
|
1090
|
+
${args}
|
|
1091
|
+
</array>
|
|
1092
|
+
<key>EnvironmentVariables</key>
|
|
1093
|
+
<dict>
|
|
1094
|
+
<key>MEMENTOS_API_URL</key>
|
|
1095
|
+
<string>${escapeXml(apiUrl)}</string>
|
|
1096
|
+
${agentName ? ` <key>MEMENTOS_AGENT_NAME</key>
|
|
1097
|
+
<string>${escapeXml(agentName)}</string>
|
|
1098
|
+
` : ""} </dict>
|
|
1099
|
+
<key>RunAtLoad</key>
|
|
1100
|
+
<true/>
|
|
1101
|
+
</dict>
|
|
1102
|
+
</plist>
|
|
1103
|
+
`;
|
|
1104
|
+
}
|
|
1105
|
+
function escapeXml(value) {
|
|
1106
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1107
|
+
}
|
|
918
1108
|
export {
|
|
1109
|
+
writeBridgePid,
|
|
1110
|
+
uninstallBridgeService,
|
|
1111
|
+
stopBridge,
|
|
919
1112
|
startMcpStdio,
|
|
1113
|
+
startBridge,
|
|
920
1114
|
renderSignupInstructions,
|
|
1115
|
+
readBridgeLogs,
|
|
921
1116
|
normalizeApiUrl,
|
|
1117
|
+
installBridgeService,
|
|
922
1118
|
installAgentSetup,
|
|
923
1119
|
handleMcpMessage,
|
|
1120
|
+
getBridgeStatus,
|
|
924
1121
|
formatMemoryInjection,
|
|
925
1122
|
diagnoseAgentSetup,
|
|
926
1123
|
createRemoteClientFromEnv,
|
|
1124
|
+
clearBridgePid,
|
|
927
1125
|
callRemoteMcpTool,
|
|
1126
|
+
buildBridgePaths,
|
|
928
1127
|
buildAgentSetupPlan,
|
|
929
1128
|
SUPPORTED_AGENT_HOSTS,
|
|
930
1129
|
REMOTE_MCP_TOOLS,
|
package/dist/mcp-runtime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-runtime.d.ts","sourceR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,QAUjE"}
|
package/dist/mcp.js
CHANGED
|
@@ -75,6 +75,12 @@ class MementosRemoteClient {
|
|
|
75
75
|
createRun(slug, input = {}) {
|
|
76
76
|
return this.request(`/runs/${encodeURIComponent(slug)}`, { method: "POST", body: input });
|
|
77
77
|
}
|
|
78
|
+
listBrainWorkers() {
|
|
79
|
+
return this.request("/brain/workers");
|
|
80
|
+
}
|
|
81
|
+
fireBrain(input = {}) {
|
|
82
|
+
return this.request("/brain/fire", { method: "POST", body: input });
|
|
83
|
+
}
|
|
78
84
|
getRun(id) {
|
|
79
85
|
return this.request(`/runs/${encodeURIComponent(id)}`);
|
|
80
86
|
}
|
|
@@ -151,7 +157,7 @@ function readErrorMessage(payload, status) {
|
|
|
151
157
|
}
|
|
152
158
|
|
|
153
159
|
// src/mcp-runtime.ts
|
|
154
|
-
var MEMENTOS_MCP_VERSION = "0.14.
|
|
160
|
+
var MEMENTOS_MCP_VERSION = "0.14.31";
|
|
155
161
|
var AUTHLESS_SCHEMA = {
|
|
156
162
|
type: "object",
|
|
157
163
|
properties: {},
|
|
@@ -250,11 +256,17 @@ var REMOTE_MCP_TOOLS = [
|
|
|
250
256
|
return client.createRun(slug, body);
|
|
251
257
|
}
|
|
252
258
|
},
|
|
259
|
+
{
|
|
260
|
+
name: "brain.workers",
|
|
261
|
+
description: "List hosted mementos.md Cerebras brain workers.",
|
|
262
|
+
inputSchema: AUTHLESS_SCHEMA,
|
|
263
|
+
run: (_input, client) => client.listBrainWorkers()
|
|
264
|
+
},
|
|
253
265
|
{
|
|
254
266
|
name: "brain.fire",
|
|
255
267
|
description: "Queue hosted mementos.md Cerebras brain workers.",
|
|
256
268
|
inputSchema: OPEN_SCHEMA,
|
|
257
|
-
run: (input, client) => client.
|
|
269
|
+
run: (input, client) => client.fireBrain(input)
|
|
258
270
|
},
|
|
259
271
|
{
|
|
260
272
|
name: "runs.get",
|
package/dist/remote-client.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export declare class MementosRemoteClient {
|
|
|
37
37
|
memoryUsage(): Promise<unknown>;
|
|
38
38
|
listRuns(input?: Record<string, unknown>): Promise<unknown>;
|
|
39
39
|
createRun(slug: string, input?: Record<string, unknown>): Promise<unknown>;
|
|
40
|
+
listBrainWorkers(): Promise<unknown>;
|
|
41
|
+
fireBrain(input?: Record<string, unknown>): Promise<unknown>;
|
|
40
42
|
getRun(id: string): Promise<unknown>;
|
|
41
43
|
listApprovals(): Promise<unknown>;
|
|
42
44
|
billingStatus(): Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remote-client.d.ts","sourceRoot":"","sources":["../src/remote-client.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,+BAA+B,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAC7C,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,GAAG,WAAW,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE5F,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO;CAM/D;AAED,qBAAa,oBAAoB;IAC/B,QAAQ,CAAC,MAAM,EAAE,MA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