openclaw-overlay-plugin 0.8.37 → 0.8.42

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
@@ -135351,6 +135351,8 @@ var BSVAgentWallet = class _BSVAgentWallet {
135351
135351
  log("Importing raw transaction");
135352
135352
  const result = await this._setup.wallet.internalizeAction({
135353
135353
  tx: hex,
135354
+ outputs: [],
135355
+ // Required field, empty array lets the wallet auto-detect relevant outputs
135354
135356
  description: "manual import"
135355
135357
  });
135356
135358
  return { success: result.accepted, txid: result.txid || "" };
@@ -136868,106 +136870,110 @@ function checkBudget(walletDir, requestedSats, dailyLimit) {
136868
136870
  spent: spending.totalSats
136869
136871
  };
136870
136872
  }
136871
- function register(api) {
136872
- const version = "0.8.37";
136873
- if (isInitialized) return;
136874
- isInitialized = true;
136875
- const config = api.pluginConfig || {};
136876
- const gateway = api.gatewayConfig || {};
136877
- const network = config.network || "mainnet";
136878
- const walletDir = config.walletDir || path4.join(os2.homedir(), ".openclaw", "bsv-wallet");
136879
- const overlayUrl = config.overlayUrl || "https://clawoverlay.com";
136880
- const arcUrl = config.arcUrl || (network === "testnet" ? "https://testnet.arc.gorillapool.io" : "https://arc.gorillapool.io");
136881
- const agentName = config.agentName || "openclaw-agent";
136882
- const gatewayPort = gateway.port || "18789";
136883
- const httpToken = config.credentials && config.credentials.hooksToken || "";
136884
- const dailyBudgetSats = config.dailyBudgetSats || 5e3;
136885
- api.logger?.info?.(`[openclaw-overlay] Initializing Plugin v${version}`);
136886
- function syncEnv() {
136887
- const env = process["env"];
136888
- env.BSV_WALLET_DIR = walletDir;
136889
- env.OVERLAY_URL = overlayUrl;
136890
- env.BSV_NETWORK = network;
136891
- env.BSV_ARC_URL = arcUrl;
136892
- env.AGENT_NAME = agentName;
136893
- setNoExit(true);
136894
- }
136895
- function wakeAgent(text, logger, options = {}) {
136896
- const sessionKey = options.sessionKey || `hook:openclaw-overlay:${Date.now()}`;
136897
- if (!httpToken) return;
136898
- const t = httpToken.split("").reverse().join("");
136899
- const bearer = t.split("").reverse().join("");
136900
- const target = `http://localhost:${gatewayPort}/hooks/agent`;
136901
- fetch(target, {
136902
- method: "POST",
136903
- headers: {
136904
- "Content-Type": "application/json",
136905
- "x-openclaw-token": bearer
136906
- },
136907
- body: JSON.stringify({ prompt: text, sessionKey })
136908
- }).catch(() => {
136909
- });
136910
- }
136911
- async function startAutoImport(api2) {
136912
- try {
136913
- syncEnv();
136914
- const addrOutput = await cmdAddress();
136915
- if (!addrOutput.success) return;
136916
- const address = addrOutput.data?.address;
136917
- if (!address) return;
136918
- autoImportInterval = setInterval(async () => {
136919
- try {
136920
- const net = network === "testnet" ? "test" : "main";
136921
- const controller = new AbortController();
136922
- const timeout = setTimeout(() => controller.abort(), 15e3);
136923
- const url = `https://api.whatsonchain.com/v1/bsv/${net}/address/${address}/unspent/all`;
136924
- const resp = await fetch(url, { signal: controller.signal });
136925
- clearTimeout(timeout);
136926
- if (!resp.ok) return;
136927
- const data = await resp.json();
136928
- const utxos = data.result || [];
136929
- for (const utxo of utxos) {
136930
- const key = `${utxo.tx_hash}:${utxo.tx_pos}`;
136931
- if (knownTxids.has(key)) continue;
136932
- if (utxo.value < 200) continue;
136933
- api2.logger?.info?.(`[openclaw-overlay] Auto-importing UTXO: ${utxo.tx_hash}:${utxo.tx_pos} (${utxo.value} sats)`);
136934
- try {
136935
- syncEnv();
136936
- const importOutput = await cmdImport(utxo.tx_hash, String(utxo.tx_pos));
136937
- if (importOutput.success) {
136938
- knownTxids.add(key);
136939
- api2.logger?.info?.(`[openclaw-overlay] Auto-imported ${utxo.value} sats from ${utxo.tx_hash}`);
136940
- wakeAgent(`\u{1F4B0} **Wallet Funded!**
136873
+ var plugin = {
136874
+ id: "openclaw-overlay-plugin",
136875
+ name: "BSV Overlay Network",
136876
+ description: "OpenClaw Overlay \u2014 decentralized agent marketplace with BSV micropayments",
136877
+ register(api) {
136878
+ const version = "0.8.42";
136879
+ if (isInitialized) return;
136880
+ isInitialized = true;
136881
+ const config = api.pluginConfig || {};
136882
+ const gateway = api.gatewayConfig || {};
136883
+ const network = config.network || "mainnet";
136884
+ const walletDir = config.walletDir || path4.join(os2.homedir(), ".openclaw", "bsv-wallet");
136885
+ const overlayUrl = config.overlayUrl || "https://clawoverlay.com";
136886
+ const arcUrl = config.arcUrl || (network === "testnet" ? "https://testnet.arc.gorillapool.io" : "https://arc.gorillapool.io");
136887
+ const agentName = config.agentName || "openclaw-agent";
136888
+ const gatewayPort = gateway.port || "18789";
136889
+ const httpToken = config.credentials && config.credentials.hooksToken || "";
136890
+ const dailyBudgetSats = config.dailyBudgetSats || 5e3;
136891
+ api.logger?.info?.(`[openclaw-overlay] Initializing Plugin v${version}`);
136892
+ function syncEnv() {
136893
+ const env = process["env"];
136894
+ env.BSV_WALLET_DIR = walletDir;
136895
+ env.OVERLAY_URL = overlayUrl;
136896
+ env.BSV_NETWORK = network;
136897
+ env.BSV_ARC_URL = arcUrl;
136898
+ env.AGENT_NAME = agentName;
136899
+ setNoExit(true);
136900
+ }
136901
+ function wakeAgent(text, logger, options = {}) {
136902
+ const sessionKey = options.sessionKey || `hook:openclaw-overlay:${Date.now()}`;
136903
+ if (!httpToken) return;
136904
+ const t = httpToken.split("").reverse().join("");
136905
+ const bearer = t.split("").reverse().join("");
136906
+ const target = `http://localhost:${gatewayPort}/hooks/agent`;
136907
+ fetch(target, {
136908
+ method: "POST",
136909
+ headers: {
136910
+ "Content-Type": "application/json",
136911
+ "x-openclaw-token": bearer
136912
+ },
136913
+ body: JSON.stringify({ prompt: text, sessionKey })
136914
+ }).catch(() => {
136915
+ });
136916
+ }
136917
+ async function startAutoImport(api2) {
136918
+ try {
136919
+ syncEnv();
136920
+ const addrOutput = await cmdAddress();
136921
+ if (!addrOutput.success) return;
136922
+ const address = addrOutput.data?.address;
136923
+ if (!address) return;
136924
+ autoImportInterval = setInterval(async () => {
136925
+ try {
136926
+ const net = network === "testnet" ? "test" : "main";
136927
+ const controller = new AbortController();
136928
+ const timeout = setTimeout(() => controller.abort(), 15e3);
136929
+ const url = `https://api.whatsonchain.com/v1/bsv/${net}/address/${address}/unspent/all`;
136930
+ const resp = await fetch(url, { signal: controller.signal });
136931
+ clearTimeout(timeout);
136932
+ if (!resp.ok) return;
136933
+ const data = await resp.json();
136934
+ const utxos = data.result || [];
136935
+ for (const utxo of utxos) {
136936
+ const key = `${utxo.tx_hash}:${utxo.tx_pos}`;
136937
+ if (knownTxids.has(key)) continue;
136938
+ if (utxo.value < 200) continue;
136939
+ api2.logger?.info?.(`[openclaw-overlay] Auto-importing UTXO: ${utxo.tx_hash}:${utxo.tx_pos} (${utxo.value} sats)`);
136940
+ try {
136941
+ syncEnv();
136942
+ const importOutput = await cmdImport(utxo.tx_hash, String(utxo.tx_pos));
136943
+ if (importOutput.success) {
136944
+ knownTxids.add(key);
136945
+ api2.logger?.info?.(`[openclaw-overlay] Auto-imported ${utxo.value} sats from ${utxo.tx_hash}`);
136946
+ wakeAgent(`\u{1F4B0} **Wallet Funded!**
136941
136947
 
136942
136948
  Auto-imported ${utxo.value} sats from transaction ${utxo.tx_hash.slice(0, 16)}...
136943
136949
 
136944
136950
  Notify the user their wallet has been funded.`, api2.logger, { sessionKey: "hook:openclaw-overlay:import" });
136951
+ }
136952
+ } catch (err) {
136953
+ knownTxids.add(key);
136945
136954
  }
136946
- } catch (err) {
136947
- knownTxids.add(key);
136948
136955
  }
136956
+ } catch (err) {
136949
136957
  }
136950
- } catch (err) {
136951
- }
136952
- }, 3e4);
136953
- } catch (err) {
136954
- api2.logger?.warn?.("[openclaw-overlay] Auto-import setup failed:", err.message);
136955
- }
136956
- }
136957
- async function startBackgroundService(api2) {
136958
- if (serviceRunning) return;
136959
- serviceRunning = true;
136960
- abortController = new AbortController();
136961
- requestCleanupInterval = setInterval(() => {
136962
- if (serviceRunning) wokenRequests.clear();
136963
- }, 5 * 60 * 1e3);
136964
- syncEnv();
136965
- cmdConnect((event) => {
136966
- if ((event.action === "queued-for-agent" || event.action === "already-queued") && event.serviceId) {
136967
- const rid = event.id || `${event.from}-${Date.now()}`;
136968
- if (wokenRequests.has(rid)) return;
136969
- wokenRequests.add(rid);
136970
- const wakeText = `\u26A1 Incoming overlay service request!
136958
+ }, 3e4);
136959
+ } catch (err) {
136960
+ api2.logger?.warn?.("[openclaw-overlay] Auto-import setup failed:", err.message);
136961
+ }
136962
+ }
136963
+ async function startBackgroundService(api2) {
136964
+ if (serviceRunning) return;
136965
+ serviceRunning = true;
136966
+ abortController = new AbortController();
136967
+ requestCleanupInterval = setInterval(() => {
136968
+ if (serviceRunning) wokenRequests.clear();
136969
+ }, 5 * 60 * 1e3);
136970
+ syncEnv();
136971
+ cmdConnect((event) => {
136972
+ if ((event.action === "queued-for-agent" || event.action === "already-queued") && event.serviceId) {
136973
+ const rid = event.id || `${event.from}-${Date.now()}`;
136974
+ if (wokenRequests.has(rid)) return;
136975
+ wokenRequests.add(rid);
136976
+ const wakeText = `\u26A1 Incoming overlay service request!
136971
136977
 
136972
136978
  Service: ${event.serviceId}
136973
136979
  From: ${event.from}
@@ -136977,10 +136983,10 @@ Fulfill it now:
136977
136983
  1. overlay({ action: "pending-requests" })
136978
136984
  2. Process the request
136979
136985
  3. overlay({ action: "fulfill", requestId: "${event.id}", recipientKey: "${event.from}", serviceId: "${event.serviceId}", result: { ... } })`;
136980
- wakeAgent(wakeText, api2.logger, { sessionKey: `hook:openclaw-overlay:${rid}` });
136981
- }
136982
- if (event.type === "service-response" && event.action === "received") {
136983
- const wakeText = `\u{1F4EC} Overlay service response received!
136986
+ wakeAgent(wakeText, api2.logger, { sessionKey: `hook:openclaw-overlay:${rid}` });
136987
+ }
136988
+ if (event.type === "service-response" && event.action === "received") {
136989
+ const wakeText = `\u{1F4EC} Overlay service response received!
136984
136990
 
136985
136991
  Service: ${event.serviceId}
136986
136992
  From: ${event.from}
@@ -136988,133 +136994,133 @@ Status: ${event.status}
136988
136994
 
136989
136995
  Full result:
136990
136996
  ${JSON.stringify(event.result, null, 2)}`;
136991
- wakeAgent(wakeText, api2.logger, { sessionKey: `hook:openclaw-overlay:resp-${event.requestId || Date.now()}` });
136992
- }
136993
- }, abortController.signal).catch((err) => {
136994
- if (serviceRunning && !abortController?.signal.aborted) {
136995
- api2.logger?.error?.(`[openclaw-overlay] WebSocket error: ${err.message}`);
136996
- }
136997
- });
136998
- }
136999
- function stopBackgroundService() {
137000
- serviceRunning = false;
137001
- if (abortController) {
137002
- abortController.abort();
137003
- abortController = null;
137004
- }
137005
- if (requestCleanupInterval) {
137006
- clearInterval(requestCleanupInterval);
137007
- requestCleanupInterval = null;
137008
- }
137009
- wokenRequests.clear();
137010
- if (autoImportInterval) {
137011
- clearInterval(autoImportInterval);
137012
- autoImportInterval = null;
137013
- }
137014
- }
137015
- async function executeOverlayAction(params, api2) {
137016
- const { action } = params;
137017
- syncEnv();
137018
- switch (action) {
137019
- case "request": {
137020
- const { service, input } = params;
137021
- const discoverOutput = await cmdDiscover(["--service", service]);
137022
- const providers = discoverOutput.data.services;
137023
- if (!providers || providers.length === 0) throw new Error(`No providers found for ${service}`);
137024
- providers.sort((a, b) => (a.pricing?.amountSats || 0) - (b.pricing?.amountSats || 0));
137025
- const best = providers[0];
137026
- const price = best.pricing?.amountSats || 0;
137027
- const budget = checkBudget(walletDir, price, dailyBudgetSats);
137028
- if (!budget.allowed) throw new Error("Budget exceeded");
137029
- const output = await cmdRequestService(best.identityKey, service, price.toString(), input ? JSON.stringify(input) : void 0);
137030
- recordSpend(walletDir, price, service, best.name);
137031
- return { status: "sent", requestId: output.data?.messageId, message: `Request sent to ${best.name} for ${price} sats.` };
137032
- }
137033
- case "discover":
137034
- return (await cmdDiscover(params.service ? ["--service", params.service] : [])).data;
137035
- case "balance":
137036
- return (await cmdBalance()).data;
137037
- case "status": {
137038
- const identity = await cmdIdentity();
137039
- const balance = await cmdBalance();
137040
- return { identity: identity.data, balance: balance.data };
137041
- }
137042
- case "onboard": {
137043
- await cmdSetup();
137044
- const addr = (await cmdAddress()).data.address;
137045
- const bal = (await cmdBalance()).data.walletBalance;
137046
- if (bal < 1e3) return { funded: false, address: addr, message: "Please fund 1000 sats." };
137047
- await cmdRegister();
137048
- return { funded: true, registered: true, message: "Onboarding complete." };
137049
- }
137050
- case "pending-requests":
137051
- return (await cmdServiceQueue()).data;
137052
- case "fulfill": {
137053
- const { requestId, recipientKey, serviceId, result } = params;
137054
- return (await cmdRespondService(requestId, recipientKey, serviceId, JSON.stringify(result))).data;
137055
- }
137056
- case "import_utxo": {
137057
- if (!params.txid) throw new Error("txid required");
137058
- const vout = params.vout !== void 0 ? parseInt(params.vout, 10) : 0;
137059
- const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137060
- const result = await wallet.importUtxo(params.txid, vout);
137061
- await wallet.destroy();
137062
- return { success: true, message: "UTXO imported" };
136997
+ wakeAgent(wakeText, api2.logger, { sessionKey: `hook:openclaw-overlay:resp-${event.requestId || Date.now()}` });
136998
+ }
136999
+ }, abortController.signal).catch((err) => {
137000
+ if (serviceRunning && !abortController?.signal.aborted) {
137001
+ api2.logger?.error?.(`[openclaw-overlay] WebSocket error: ${err.message}`);
137002
+ }
137003
+ });
137004
+ }
137005
+ function stopBackgroundService() {
137006
+ serviceRunning = false;
137007
+ if (abortController) {
137008
+ abortController.abort();
137009
+ abortController = null;
137063
137010
  }
137064
- case "import_raw_tx": {
137065
- if (!params.txhex) throw new Error("txhex required");
137066
- const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137067
- const result = await wallet.importRawTx(params.txhex);
137068
- await wallet.destroy();
137069
- return result;
137011
+ if (requestCleanupInterval) {
137012
+ clearInterval(requestCleanupInterval);
137013
+ requestCleanupInterval = null;
137070
137014
  }
137071
- case "unregister":
137072
- return (await cmdUnregister()).data;
137073
- default:
137074
- throw new Error(`Unknown action: ${action}`);
137075
- }
137076
- }
137077
- api.registerTool({
137078
- name: "overlay",
137079
- description: "Access the BSV agent marketplace",
137080
- parameters: {
137081
- type: "object",
137082
- properties: {
137083
- action: { type: "string", enum: ["request", "discover", "balance", "status", "pay", "onboard", "pending-requests", "fulfill", "unregister", "import_utxo", "import_raw_tx"] },
137084
- service: { type: "string" },
137085
- input: { type: "object" },
137086
- identityKey: { type: "string" },
137087
- sats: { type: "number" },
137088
- requestId: { type: "string" },
137089
- recipientKey: { type: "string" },
137090
- serviceId: { type: "string" },
137091
- result: { type: "object" },
137092
- txid: { type: "string" },
137093
- vout: { type: "number" },
137094
- txhex: { type: "string" }
137095
- },
137096
- required: ["action"]
137097
- },
137098
- async execute(_id, params) {
137099
- log3("Executing tool action: %s with params: %O", params.action, params);
137100
- try {
137101
- return await executeOverlayAction(params, api);
137102
- } catch (error) {
137103
- return { content: [{ type: "text", text: `Error: ${error.message}` }] };
137015
+ wokenRequests.clear();
137016
+ if (autoImportInterval) {
137017
+ clearInterval(autoImportInterval);
137018
+ autoImportInterval = null;
137104
137019
  }
137105
137020
  }
137106
- });
137107
- api.registerCommand({
137108
- name: "overlay",
137109
- description: "BSV Overlay Marketplace commands",
137110
- acceptsArgs: true,
137111
- handler: async (ctx) => {
137112
- try {
137113
- api.logger?.info?.(`[openclaw-overlay] Command received with args: ${JSON.stringify(ctx.args)} (type: ${typeof ctx.args})`);
137114
- const args = Array.isArray(ctx.args) ? ctx.args : typeof ctx.args === "string" ? ctx.args.split(" ").filter(Boolean) : [];
137115
- const action = args[0] || "status";
137116
- if (action === "help") {
137117
- return { text: `\u{1F30A} **Overlay Help**
137021
+ async function executeOverlayAction(params, api2) {
137022
+ const { action } = params;
137023
+ syncEnv();
137024
+ switch (action) {
137025
+ case "request": {
137026
+ const { service, input } = params;
137027
+ const discoverOutput = await cmdDiscover(["--service", service]);
137028
+ const providers = discoverOutput.data.services;
137029
+ if (!providers || providers.length === 0) throw new Error(`No providers found for ${service}`);
137030
+ providers.sort((a, b) => (a.pricing?.amountSats || 0) - (b.pricing?.amountSats || 0));
137031
+ const best = providers[0];
137032
+ const price = best.pricing?.amountSats || 0;
137033
+ const budget = checkBudget(walletDir, price, dailyBudgetSats);
137034
+ if (!budget.allowed) throw new Error("Budget exceeded");
137035
+ const output = await cmdRequestService(best.identityKey, service, price.toString(), input ? JSON.stringify(input) : void 0);
137036
+ recordSpend(walletDir, price, service, best.name);
137037
+ return { status: "sent", requestId: output.data?.messageId, message: `Request sent to ${best.name} for ${price} sats.` };
137038
+ }
137039
+ case "discover":
137040
+ return (await cmdDiscover(params.service ? ["--service", params.service] : [])).data;
137041
+ case "balance":
137042
+ return (await cmdBalance()).data;
137043
+ case "status": {
137044
+ const identity = await cmdIdentity();
137045
+ const balance = await cmdBalance();
137046
+ return { identity: identity.data, balance: balance.data };
137047
+ }
137048
+ case "onboard": {
137049
+ await cmdSetup();
137050
+ const addr = (await cmdAddress()).data.address;
137051
+ const bal = (await cmdBalance()).data.walletBalance;
137052
+ if (bal < 1e3) return { funded: false, address: addr, message: "Please fund 1000 sats." };
137053
+ await cmdRegister();
137054
+ return { funded: true, registered: true, message: "Onboarding complete." };
137055
+ }
137056
+ case "pending-requests":
137057
+ return (await cmdServiceQueue()).data;
137058
+ case "fulfill": {
137059
+ const { requestId, recipientKey, serviceId, result } = params;
137060
+ return (await cmdRespondService(requestId, recipientKey, serviceId, JSON.stringify(result))).data;
137061
+ }
137062
+ case "import_utxo": {
137063
+ if (!params.txid) throw new Error("txid required");
137064
+ const vout = params.vout !== void 0 ? parseInt(params.vout, 10) : 0;
137065
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137066
+ await wallet.importUtxo(params.txid, vout);
137067
+ await wallet.destroy();
137068
+ return { success: true, message: "UTXO imported" };
137069
+ }
137070
+ case "import_raw_tx": {
137071
+ if (!params.txhex) throw new Error("txhex required");
137072
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137073
+ const result = await wallet.importRawTx(params.txhex);
137074
+ await wallet.destroy();
137075
+ return result;
137076
+ }
137077
+ case "unregister":
137078
+ return (await cmdUnregister()).data;
137079
+ default:
137080
+ throw new Error(`Unknown action: ${action}`);
137081
+ }
137082
+ }
137083
+ api.registerTool({
137084
+ name: "overlay",
137085
+ description: "Access the BSV agent marketplace",
137086
+ parameters: {
137087
+ type: "object",
137088
+ properties: {
137089
+ action: { type: "string", enum: ["request", "discover", "balance", "status", "pay", "onboard", "pending-requests", "fulfill", "unregister", "import_utxo", "import_raw_tx"] },
137090
+ service: { type: "string" },
137091
+ input: { type: "object" },
137092
+ identityKey: { type: "string" },
137093
+ sats: { type: "number" },
137094
+ requestId: { type: "string" },
137095
+ recipientKey: { type: "string" },
137096
+ serviceId: { type: "string" },
137097
+ result: { type: "object" },
137098
+ txid: { type: "string" },
137099
+ vout: { type: "number" },
137100
+ txhex: { type: "string" }
137101
+ },
137102
+ required: ["action"]
137103
+ },
137104
+ async execute(_id, params) {
137105
+ log3("Executing tool action: %s with params: %O", params.action, params);
137106
+ try {
137107
+ return await executeOverlayAction(params, api);
137108
+ } catch (error) {
137109
+ return { content: [{ type: "text", text: `Error: ${error.message}` }] };
137110
+ }
137111
+ }
137112
+ });
137113
+ api.registerCommand({
137114
+ name: "overlay",
137115
+ description: "BSV Overlay Marketplace commands",
137116
+ acceptsArgs: true,
137117
+ handler: async (ctx) => {
137118
+ try {
137119
+ api.logger?.info?.(`[openclaw-overlay] Command received with args: ${JSON.stringify(ctx.args)} (type: ${typeof ctx.args})`);
137120
+ const args = Array.isArray(ctx.args) ? ctx.args : typeof ctx.args === "string" ? ctx.args.split(" ").filter(Boolean) : [];
137121
+ const action = args[0] || "status";
137122
+ if (action === "help") {
137123
+ return { text: `\u{1F30A} **Overlay Help**
137118
137124
 
137119
137125
  **Subcommands**:
137120
137126
  - \`status\`: Show identity and balance
@@ -137122,86 +137128,65 @@ ${JSON.stringify(event.result, null, 2)}`;
137122
137128
  - \`discover\`: Find other agents
137123
137129
  - \`import <txid> [vout]\`: Import a UTXO
137124
137130
  - \`import-tx <hex>\`: Import raw transaction` };
137125
- }
137126
- if (action === "import" && args[1]) {
137127
- const res = await executeOverlayAction({ action: "import_utxo", txid: args[1], vout: args[2] }, api);
137128
- return { text: `\u2705 UTXO imported successfully.` };
137129
- }
137130
- const result = await executeOverlayAction({ action }, api);
137131
- return { text: `**Overlay ${action.toUpperCase()}**
137131
+ }
137132
+ if (action === "import" && args[1]) {
137133
+ await executeOverlayAction({ action: "import_utxo", txid: args[1], vout: args[2] }, api);
137134
+ return { text: `\u2705 UTXO imported successfully.` };
137135
+ }
137136
+ const result = await executeOverlayAction({ action }, api);
137137
+ return { text: `**Overlay ${action.toUpperCase()}**
137132
137138
 
137133
137139
  ${JSON.stringify(result, null, 2)}` };
137134
- } catch (error) {
137135
- return { text: `\u274C Error: ${error.message}` };
137136
- }
137137
- }
137138
- });
137139
- api.registerOnboarding({
137140
- async finalize() {
137141
- const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137142
- const balance = await wallet.getBalance();
137143
- await wallet.destroy();
137144
- if (balance < 500) {
137145
- api.logger.warn(`[overlay] Wallet has low balance (${balance} sats). Some features may be limited until funded.`);
137146
- }
137147
- return { success: true };
137148
- }
137149
- });
137150
- api.registerService({
137151
- id: "openclaw-overlay-relay",
137152
- start: async () => {
137153
- try {
137154
- await initializeServiceSystem();
137155
- } catch {
137140
+ } catch (error) {
137141
+ return { text: `\u274C Error: ${error.message}` };
137142
+ }
137156
137143
  }
137157
- await startBackgroundService(api);
137158
- await startAutoImport(api);
137159
- },
137160
- stop: () => stopBackgroundService()
137161
- });
137162
- api.registerCli(({ program }) => {
137163
- const overlay = program.command("overlay").description("BSV Overlay Network management");
137164
- overlay.addHelpText("after", `
137165
- \u{1F310} Overlay Examples:
137166
- $ openclaw overlay status # Show your marketplace identity and balance
137167
- $ openclaw overlay balance # Show current wallet funds
137168
- $ openclaw overlay discover -s baemail # Discover agents providing the 'baemail' service
137169
-
137170
- \u{1F4A1} Tip: The overlay network is a decentralized marketplace.
137171
- You can find services by their type or specific agent names.
137172
- `);
137173
- overlay.command("status").description("Show identity and balance").action(async () => {
137174
- syncEnv();
137175
- const res = await cmdStatus();
137176
- console.log(JSON.stringify(res.data, null, 2));
137177
137144
  });
137178
- overlay.command("balance").description("Show current wallet balance").action(async () => {
137179
- syncEnv();
137180
- const res = await cmdBalance();
137181
- console.log(JSON.stringify(res.data, null, 2));
137145
+ api.registerOnboarding({
137146
+ async finalize() {
137147
+ const wallet = await BSVAgentWallet.load({ network, storageDir: walletDir });
137148
+ const balance = await wallet.getBalance();
137149
+ await wallet.destroy();
137150
+ if (balance < 500) api.logger.warn(`[overlay] Low balance: ${balance} sats.`);
137151
+ return { success: true };
137152
+ }
137182
137153
  });
137183
- overlay.command("discover").description("Find agents and services").option("-s, --service <type>", "Filter by service type").option("-a, --agent <name>", "Filter by agent name").action(async (options) => {
137184
- syncEnv();
137185
- const args = [];
137186
- if (options.service) args.push("--service", options.service);
137187
- if (options.agent) args.push("--agent", options.agent);
137188
- const res = await cmdDiscover(args);
137189
- console.log(JSON.stringify(res.data, null, 2));
137154
+ api.registerService({
137155
+ id: "openclaw-overlay-relay",
137156
+ start: async () => {
137157
+ try {
137158
+ await initializeServiceSystem();
137159
+ } catch {
137160
+ }
137161
+ await startBackgroundService(api);
137162
+ await startAutoImport(api);
137163
+ },
137164
+ stop: () => stopBackgroundService()
137190
137165
  });
137191
- }, { commands: ["overlay"] });
137192
- }
137193
- var plugin = {
137194
- id: "openclaw-overlay-plugin",
137195
- name: "BSV Overlay Network",
137196
- description: "OpenClaw Overlay \u2014 decentralized agent marketplace with BSV micropayments",
137197
- activate: register,
137198
- register
137166
+ api.registerCli(({ program }) => {
137167
+ const overlay = program.command("overlay").description("BSV Overlay Network management");
137168
+ overlay.addHelpText("after", `
137169
+ \u{1F310} Overlay Examples:
137170
+ $ openclaw overlay status
137171
+ $ openclaw overlay balance
137172
+ $ openclaw overlay discover -s baemail
137173
+ `);
137174
+ overlay.command("status").description("Show status").action(async () => {
137175
+ syncEnv();
137176
+ const res = await cmdStatus();
137177
+ console.log(JSON.stringify(res.data, null, 2));
137178
+ });
137179
+ overlay.command("balance").description("Show balance").action(async () => {
137180
+ syncEnv();
137181
+ const res = await cmdBalance();
137182
+ console.log(JSON.stringify(res.data, null, 2));
137183
+ });
137184
+ }, { commands: ["overlay"] });
137185
+ }
137199
137186
  };
137200
- var index_default = register;
137187
+ var index_default = plugin;
137201
137188
  export {
137202
- index_default as default,
137203
- plugin,
137204
- register
137189
+ index_default as default
137205
137190
  };
137206
137191
  /*! Bundled license information:
137207
137192