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