mnemospark 1.5.1 → 1.6.0
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 +4 -11
- package/dist/cli.js +103 -32
- package/dist/cli.js.map +1 -1
- package/dist/index.js +103 -32
- package/dist/index.js.map +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,23 +31,15 @@ openclaw gateway start
|
|
|
31
31
|
> Plugin registration is done by `openclaw plugins install mnemospark`.
|
|
32
32
|
> The install also bundles the `skills/mnemospark` skill package so the main agent can delegate mnemospark workflows.
|
|
33
33
|
|
|
34
|
-
### 2)
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
npx mnemospark install --standard
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
This creates/reuses local wallet helper files under `~/.openclaw/mnemospark/`.
|
|
41
|
-
|
|
42
|
-
### 3) Restart gateway after updates
|
|
34
|
+
### 2) Restart gateway after updates
|
|
43
35
|
|
|
44
36
|
```bash
|
|
45
37
|
openclaw gateway restart
|
|
46
38
|
```
|
|
47
39
|
|
|
48
|
-
###
|
|
40
|
+
### 3) Use slash commands in OpenClaw chat
|
|
49
41
|
|
|
50
|
-
- `/mnemospark wallet` → wallet status; `/mnemospark wallet help` → commands
|
|
42
|
+
- `/mnemospark wallet` → wallet status; `/mnemospark wallet help` → commands; `/mnemospark wallet create` → new key (backs up existing default `wallet.key` if present)
|
|
51
43
|
- `/mnemospark cloud help` → storage command guide
|
|
52
44
|
|
|
53
45
|
---
|
|
@@ -85,6 +77,7 @@ Have ChatGPT or your favorite LLM evaluate the mnemospark codebase. Here's a [st
|
|
|
85
77
|
|
|
86
78
|
- `/mnemospark wallet` — address, balance, and key file path
|
|
87
79
|
- `/mnemospark wallet help` — command list and funding link
|
|
80
|
+
- `/mnemospark wallet create` — create a new wallet (and backup an existing default key file)
|
|
88
81
|
- `/mnemospark wallet export` — export private key for backup (sensitive)
|
|
89
82
|
|
|
90
83
|
---
|
package/dist/cli.js
CHANGED
|
@@ -2912,7 +2912,8 @@ async function startProxy(options) {
|
|
|
2912
2912
|
}
|
|
2913
2913
|
|
|
2914
2914
|
// src/auth.ts
|
|
2915
|
-
import {
|
|
2915
|
+
import { existsSync, readFileSync } from "fs";
|
|
2916
|
+
import { copyFile, writeFile as writeFile2, readFile as readFile2, mkdir as mkdir3 } from "fs/promises";
|
|
2916
2917
|
import { join as join5 } from "path";
|
|
2917
2918
|
import { homedir as homedir4 } from "os";
|
|
2918
2919
|
import { generatePrivateKey, privateKeyToAccount as privateKeyToAccount4 } from "viem/accounts";
|
|
@@ -2927,6 +2928,32 @@ var LEGACY_WALLET_DIR = join5(homedir4(), ".openclaw", "blockrun");
|
|
|
2927
2928
|
var LEGACY_WALLET_FILE = join5(LEGACY_WALLET_DIR, "wallet.key");
|
|
2928
2929
|
var WALLET_DIR = join5(homedir4(), ".openclaw", "mnemospark", "wallet");
|
|
2929
2930
|
var WALLET_FILE = join5(WALLET_DIR, "wallet.key");
|
|
2931
|
+
function resolveWalletKeyForSlashCommandsSync() {
|
|
2932
|
+
const envKey = process.env.MNEMOSPARK_WALLET_KEY?.trim();
|
|
2933
|
+
if (isValidWalletPrivateKey(envKey)) {
|
|
2934
|
+
const account = privateKeyToAccount4(envKey);
|
|
2935
|
+
return {
|
|
2936
|
+
walletKey: envKey,
|
|
2937
|
+
address: account.address,
|
|
2938
|
+
keyPathLabel: "MNEMOSPARK_WALLET_KEY (environment variable)"
|
|
2939
|
+
};
|
|
2940
|
+
}
|
|
2941
|
+
for (const path of [WALLET_FILE, LEGACY_WALLET_FILE]) {
|
|
2942
|
+
try {
|
|
2943
|
+
if (!existsSync(path)) {
|
|
2944
|
+
continue;
|
|
2945
|
+
}
|
|
2946
|
+
const raw = readFileSync(path, "utf-8").trim();
|
|
2947
|
+
if (!isValidWalletPrivateKey(raw)) {
|
|
2948
|
+
continue;
|
|
2949
|
+
}
|
|
2950
|
+
const account = privateKeyToAccount4(raw);
|
|
2951
|
+
return { walletKey: raw, address: account.address, keyPathLabel: path };
|
|
2952
|
+
} catch {
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
return null;
|
|
2956
|
+
}
|
|
2930
2957
|
async function loadSavedWallet() {
|
|
2931
2958
|
for (const path of [WALLET_FILE, LEGACY_WALLET_FILE]) {
|
|
2932
2959
|
try {
|
|
@@ -2964,6 +2991,33 @@ async function generateAndSaveWallet() {
|
|
|
2964
2991
|
}
|
|
2965
2992
|
return { key, address: account.address };
|
|
2966
2993
|
}
|
|
2994
|
+
function pickUniqueWalletKeyBackupPath(walletKeyPath) {
|
|
2995
|
+
const d = /* @__PURE__ */ new Date();
|
|
2996
|
+
const y = d.getFullYear();
|
|
2997
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
2998
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
2999
|
+
const base2 = `${walletKeyPath}.bak-${y}-${m}-${day}`;
|
|
3000
|
+
if (!existsSync(base2)) {
|
|
3001
|
+
return base2;
|
|
3002
|
+
}
|
|
3003
|
+
let n = 2;
|
|
3004
|
+
for (; ; ) {
|
|
3005
|
+
const candidate = `${base2}-${n}`;
|
|
3006
|
+
if (!existsSync(candidate)) {
|
|
3007
|
+
return candidate;
|
|
3008
|
+
}
|
|
3009
|
+
n += 1;
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
async function createMnemosparkWalletWithOptionalBackup() {
|
|
3013
|
+
let backupPath;
|
|
3014
|
+
if (existsSync(WALLET_FILE)) {
|
|
3015
|
+
backupPath = pickUniqueWalletKeyBackupPath(WALLET_FILE);
|
|
3016
|
+
await copyFile(WALLET_FILE, backupPath);
|
|
3017
|
+
}
|
|
3018
|
+
const { key, address } = await generateAndSaveWallet();
|
|
3019
|
+
return { backupPath, key, address };
|
|
3020
|
+
}
|
|
2967
3021
|
async function resolveOrGenerateWalletKey() {
|
|
2968
3022
|
const envKey = process.env.MNEMOSPARK_WALLET_KEY?.trim();
|
|
2969
3023
|
if (isValidWalletPrivateKey(envKey)) {
|
|
@@ -2990,10 +3044,6 @@ var pkg = require2(join6(__dirname, "..", "package.json"));
|
|
|
2990
3044
|
var VERSION = pkg.version;
|
|
2991
3045
|
var USER_AGENT = `mnemospark/${VERSION}`;
|
|
2992
3046
|
|
|
2993
|
-
// src/mnemospark-handler.ts
|
|
2994
|
-
import { existsSync, readFileSync } from "fs";
|
|
2995
|
-
import { privateKeyToAccount as privateKeyToAccount6 } from "viem/accounts";
|
|
2996
|
-
|
|
2997
3047
|
// src/cloud-help-onboarding.ts
|
|
2998
3048
|
var CLOUD_ONBOARDING_BLOCK_LINES = [
|
|
2999
3049
|
"",
|
|
@@ -4147,7 +4197,8 @@ function routeMnemosparkArgs(args) {
|
|
|
4147
4197
|
"\u2022 `/mnemospark help` \u2014 overview",
|
|
4148
4198
|
"\u2022 `/mnemospark cloud help` \u2014 cloud commands",
|
|
4149
4199
|
"\u2022 `/mnemospark wallet` \u2014 wallet status",
|
|
4150
|
-
"\u2022 `/mnemospark wallet help` \u2014 wallet commands"
|
|
4200
|
+
"\u2022 `/mnemospark wallet help` \u2014 wallet commands",
|
|
4201
|
+
"\u2022 `/mnemospark wallet create` \u2014 new wallet (backs up existing default key)"
|
|
4151
4202
|
].join("\n")
|
|
4152
4203
|
};
|
|
4153
4204
|
}
|
|
@@ -7607,6 +7658,7 @@ var MNEMOSPARK_ROOT_HELP_TEXT = [
|
|
|
7607
7658
|
"**Wallet status and funding link:**",
|
|
7608
7659
|
"\u2022 `/mnemospark wallet`",
|
|
7609
7660
|
"\u2022 `/mnemospark wallet help`",
|
|
7661
|
+
"\u2022 `/mnemospark wallet create`",
|
|
7610
7662
|
"",
|
|
7611
7663
|
"**Let your agent run mnemospark for you:**",
|
|
7612
7664
|
"",
|
|
@@ -7620,6 +7672,7 @@ var MNEMOSPARK_WALLET_HELP_TEXT = (address) => [
|
|
|
7620
7672
|
"**Commands:**",
|
|
7621
7673
|
"\u2022 `/mnemospark wallet` \u2014 Show address, balance, and key file path",
|
|
7622
7674
|
"\u2022 `/mnemospark wallet help` \u2014 This message",
|
|
7675
|
+
"\u2022 `/mnemospark wallet create` \u2014 Create a new wallet (and backup an existing wallet)",
|
|
7623
7676
|
"\u2022 `/mnemospark wallet export` \u2014 Export private key for backup (sensitive)",
|
|
7624
7677
|
"",
|
|
7625
7678
|
`**Fund with USDC on Base:** https://basescan.org/address/${address}`
|
|
@@ -7629,26 +7682,7 @@ function getDefaultCloudCommandHandler() {
|
|
|
7629
7682
|
defaultCloudCommandHandler ??= createCloudCommand().handler;
|
|
7630
7683
|
return defaultCloudCommandHandler;
|
|
7631
7684
|
}
|
|
7632
|
-
var NO_WALLET_FOUND_TEXT = "No mnemospark wallet found. Run `openclaw plugins install mnemospark
|
|
7633
|
-
function resolveWalletFileSync() {
|
|
7634
|
-
try {
|
|
7635
|
-
if (!existsSync(WALLET_FILE)) {
|
|
7636
|
-
return null;
|
|
7637
|
-
}
|
|
7638
|
-
const walletKey = readFileSync(WALLET_FILE, "utf-8").trim();
|
|
7639
|
-
if (!walletKey.startsWith("0x") || walletKey.length !== 66) {
|
|
7640
|
-
return null;
|
|
7641
|
-
}
|
|
7642
|
-
const account = privateKeyToAccount6(walletKey);
|
|
7643
|
-
const address = account.address.replace(/\s/g, "");
|
|
7644
|
-
if (!address) {
|
|
7645
|
-
return null;
|
|
7646
|
-
}
|
|
7647
|
-
return { walletKey, address };
|
|
7648
|
-
} catch {
|
|
7649
|
-
return null;
|
|
7650
|
-
}
|
|
7651
|
-
}
|
|
7685
|
+
var NO_WALLET_FOUND_TEXT = "No mnemospark wallet found. Run `openclaw plugins install mnemospark` or set MNEMOSPARK_WALLET_KEY.";
|
|
7652
7686
|
async function runMnemosparkSlashHandler(ctx, options) {
|
|
7653
7687
|
const route = routeMnemosparkArgs(ctx.args);
|
|
7654
7688
|
if (route.kind === "root-help") {
|
|
@@ -7694,6 +7728,15 @@ async function handleWalletSlash(rest) {
|
|
|
7694
7728
|
}
|
|
7695
7729
|
return buildWalletExportResponse();
|
|
7696
7730
|
}
|
|
7731
|
+
if (parsed.name === "create") {
|
|
7732
|
+
if (afterFirst.trim()) {
|
|
7733
|
+
return {
|
|
7734
|
+
text: "Unexpected extra arguments after `create`. Use `/mnemospark wallet create` alone.",
|
|
7735
|
+
isError: true
|
|
7736
|
+
};
|
|
7737
|
+
}
|
|
7738
|
+
return buildWalletCreateResponse();
|
|
7739
|
+
}
|
|
7697
7740
|
if (parsed.name === "status") {
|
|
7698
7741
|
return buildWalletStatusResponse();
|
|
7699
7742
|
}
|
|
@@ -7702,15 +7745,15 @@ async function handleWalletSlash(rest) {
|
|
|
7702
7745
|
isError: true
|
|
7703
7746
|
};
|
|
7704
7747
|
}
|
|
7705
|
-
async function buildWalletStatusResponse() {
|
|
7706
|
-
const wallet =
|
|
7748
|
+
async function buildWalletStatusResponse(walletOverride) {
|
|
7749
|
+
const wallet = walletOverride ?? resolveWalletKeyForSlashCommandsSync();
|
|
7707
7750
|
if (!wallet) {
|
|
7708
7751
|
return {
|
|
7709
7752
|
text: NO_WALLET_FOUND_TEXT,
|
|
7710
7753
|
isError: true
|
|
7711
7754
|
};
|
|
7712
7755
|
}
|
|
7713
|
-
const { address } = wallet;
|
|
7756
|
+
const { address, keyPathLabel } = wallet;
|
|
7714
7757
|
let balanceText = "Balance: (checking...)";
|
|
7715
7758
|
try {
|
|
7716
7759
|
const monitor = new BalanceMonitor(address);
|
|
@@ -7725,19 +7768,47 @@ async function buildWalletStatusResponse() {
|
|
|
7725
7768
|
"",
|
|
7726
7769
|
`**Address:** \`${address}\``,
|
|
7727
7770
|
`**${balanceText}**`,
|
|
7728
|
-
`**Key File:** \`${
|
|
7771
|
+
`**Key File:** \`${keyPathLabel}\``,
|
|
7729
7772
|
"",
|
|
7730
7773
|
"**Commands:**",
|
|
7731
7774
|
"\u2022 `/mnemospark wallet` \u2014 Show this status",
|
|
7732
7775
|
"\u2022 `/mnemospark wallet help` \u2014 Commands and funding link",
|
|
7776
|
+
"\u2022 `/mnemospark wallet create` \u2014 Create a new wallet (and backup an existing wallet)",
|
|
7733
7777
|
"\u2022 `/mnemospark wallet export` \u2014 Export private key for backup",
|
|
7734
7778
|
"",
|
|
7735
7779
|
`**Fund with USDC on Base:** https://basescan.org/address/${address}`
|
|
7736
7780
|
].join("\n")
|
|
7737
7781
|
};
|
|
7738
7782
|
}
|
|
7783
|
+
async function buildWalletCreateResponse() {
|
|
7784
|
+
let backupPath;
|
|
7785
|
+
let createdAddress = "";
|
|
7786
|
+
try {
|
|
7787
|
+
({ backupPath, address: createdAddress } = await createMnemosparkWalletWithOptionalBackup());
|
|
7788
|
+
} catch (err) {
|
|
7789
|
+
return {
|
|
7790
|
+
text: `Failed to create wallet: ${err instanceof Error ? err.message : String(err)}`,
|
|
7791
|
+
isError: true
|
|
7792
|
+
};
|
|
7793
|
+
}
|
|
7794
|
+
const statusResponse = await buildWalletStatusResponse({
|
|
7795
|
+
address: createdAddress,
|
|
7796
|
+
keyPathLabel: WALLET_FILE
|
|
7797
|
+
});
|
|
7798
|
+
if (statusResponse.isError) {
|
|
7799
|
+
return statusResponse;
|
|
7800
|
+
}
|
|
7801
|
+
const createMessageLines = backupPath ? [
|
|
7802
|
+
"\u2705 Existing wallet key was backed up before creating the new wallet.",
|
|
7803
|
+
`**Backup File:** \`${backupPath}\``
|
|
7804
|
+
] : ["\u2705 New wallet created."];
|
|
7805
|
+
return {
|
|
7806
|
+
...statusResponse,
|
|
7807
|
+
text: [...createMessageLines, "", statusResponse.text ?? ""].join("\n")
|
|
7808
|
+
};
|
|
7809
|
+
}
|
|
7739
7810
|
async function buildWalletHelpResponse() {
|
|
7740
|
-
const wallet =
|
|
7811
|
+
const wallet = resolveWalletKeyForSlashCommandsSync();
|
|
7741
7812
|
if (!wallet) {
|
|
7742
7813
|
return {
|
|
7743
7814
|
text: NO_WALLET_FOUND_TEXT,
|
|
@@ -7748,7 +7819,7 @@ async function buildWalletHelpResponse() {
|
|
|
7748
7819
|
return { text: MNEMOSPARK_WALLET_HELP_TEXT(address) };
|
|
7749
7820
|
}
|
|
7750
7821
|
async function buildWalletExportResponse() {
|
|
7751
|
-
const wallet =
|
|
7822
|
+
const wallet = resolveWalletKeyForSlashCommandsSync();
|
|
7752
7823
|
if (!wallet) {
|
|
7753
7824
|
return {
|
|
7754
7825
|
text: NO_WALLET_FOUND_TEXT,
|