mnemospark 2026.4.10 → 2026.4.11

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/index.js CHANGED
@@ -8281,51 +8281,59 @@ function isCompletionMode() {
8281
8281
  const args = process.argv;
8282
8282
  return args.some((arg, i) => arg === "completion" && i >= 1 && i <= 3);
8283
8283
  }
8284
- function isGatewayMode() {
8285
- const args = process.argv;
8286
- return args.includes("gateway");
8287
- }
8288
8284
  var activeProxyHandle = null;
8289
- async function startProxyInBackground(api) {
8290
- const { key: walletKey, address, source } = await resolveOrGenerateWalletKey();
8291
- if (source === "generated") {
8292
- api.logger.info(`Generated new wallet: ${address}`);
8293
- } else if (source === "saved") {
8294
- api.logger.info(`Using saved wallet: ${address}`);
8295
- } else {
8296
- api.logger.info(`Using wallet from MNEMOSPARK_WALLET_KEY: ${address}`);
8285
+ var startPromise = null;
8286
+ async function ensureProxyStarted(api) {
8287
+ if (activeProxyHandle) {
8288
+ return;
8297
8289
  }
8298
- const proxy = await startProxy({
8299
- walletKey,
8300
- onReady: (port) => {
8301
- api.logger.info(`mnemospark proxy listening on port ${port}`);
8302
- },
8303
- onError: (error) => {
8304
- api.logger.error(`mnemospark proxy error: ${error.message}`);
8305
- },
8306
- onLowBalance: (info) => {
8307
- api.logger.warn(`[!] Low balance: ${info.balanceUSD}. Fund wallet: ${info.walletAddress}`);
8308
- },
8309
- onInsufficientFunds: (info) => {
8310
- api.logger.error(
8311
- `[!] Insufficient funds. Balance: ${info.balanceUSD}, Needed: ${info.requiredUSD}. Fund wallet: ${info.walletAddress}`
8312
- );
8313
- }
8314
- });
8315
- activeProxyHandle = proxy;
8316
- api.logger.info("mnemospark ready");
8317
- const startupMonitor = new BalanceMonitor(address);
8318
- startupMonitor.checkBalance().then((balance) => {
8319
- if (balance.isEmpty) {
8320
- api.logger.info(`Wallet: ${address} | Balance: $0.00`);
8321
- } else if (balance.isLow) {
8322
- api.logger.info(`Wallet: ${address} | Balance: ${balance.balanceUSD} (low)`);
8290
+ if (startPromise) {
8291
+ return startPromise;
8292
+ }
8293
+ startPromise = (async () => {
8294
+ const { key: walletKey, address, source } = await resolveOrGenerateWalletKey();
8295
+ if (source === "generated") {
8296
+ api.logger.info(`Generated new wallet: ${address}`);
8297
+ } else if (source === "saved") {
8298
+ api.logger.info(`Using saved wallet: ${address}`);
8323
8299
  } else {
8324
- api.logger.info(`Wallet: ${address} | Balance: ${balance.balanceUSD}`);
8300
+ api.logger.info(`Using wallet from MNEMOSPARK_WALLET_KEY: ${address}`);
8325
8301
  }
8326
- }).catch(() => {
8327
- api.logger.info(`Wallet: ${address} | Balance: (checking...)`);
8302
+ const proxy = await startProxy({
8303
+ walletKey,
8304
+ onReady: (port) => {
8305
+ api.logger.info(`mnemospark proxy listening on port ${port}`);
8306
+ },
8307
+ onError: (error) => {
8308
+ api.logger.error(`mnemospark proxy error: ${error.message}`);
8309
+ },
8310
+ onLowBalance: (info) => {
8311
+ api.logger.warn(`[!] Low balance: ${info.balanceUSD}. Fund wallet: ${info.walletAddress}`);
8312
+ },
8313
+ onInsufficientFunds: (info) => {
8314
+ api.logger.error(
8315
+ `[!] Insufficient funds. Balance: ${info.balanceUSD}, Needed: ${info.requiredUSD}. Fund wallet: ${info.walletAddress}`
8316
+ );
8317
+ }
8318
+ });
8319
+ activeProxyHandle = proxy;
8320
+ api.logger.info("mnemospark ready");
8321
+ const startupMonitor = new BalanceMonitor(address);
8322
+ startupMonitor.checkBalance().then((balance) => {
8323
+ if (balance.isEmpty) {
8324
+ api.logger.info(`Wallet: ${address} | Balance: $0.00`);
8325
+ } else if (balance.isLow) {
8326
+ api.logger.info(`Wallet: ${address} | Balance: ${balance.balanceUSD} (low)`);
8327
+ } else {
8328
+ api.logger.info(`Wallet: ${address} | Balance: ${balance.balanceUSD}`);
8329
+ }
8330
+ }).catch(() => {
8331
+ api.logger.info(`Wallet: ${address} | Balance: (checking...)`);
8332
+ });
8333
+ })().finally(() => {
8334
+ startPromise = null;
8328
8335
  });
8336
+ return startPromise;
8329
8337
  }
8330
8338
  var plugin = {
8331
8339
  id: "mnemospark",
@@ -8371,7 +8379,15 @@ var plugin = {
8371
8379
  }
8372
8380
  api.registerService({
8373
8381
  id: "mnemospark-proxy",
8374
- start: () => {
8382
+ start: async () => {
8383
+ try {
8384
+ await ensureProxyStarted(api);
8385
+ } catch (err) {
8386
+ api.logger.error(
8387
+ `Failed to start mnemospark proxy: ${err instanceof Error ? err.message : String(err)}`
8388
+ );
8389
+ throw err;
8390
+ }
8375
8391
  },
8376
8392
  stop: async () => {
8377
8393
  if (activeProxyHandle) {
@@ -8388,14 +8404,6 @@ var plugin = {
8388
8404
  }
8389
8405
  }
8390
8406
  });
8391
- if (!isGatewayMode()) {
8392
- return;
8393
- }
8394
- startProxyInBackground(api).catch((err) => {
8395
- api.logger.error(
8396
- `Failed to start mnemospark proxy: ${err instanceof Error ? err.message : String(err)}`
8397
- );
8398
- });
8399
8407
  }
8400
8408
  };
8401
8409
  var index_default = plugin;