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 +277 -293
- package/dist/index.js.map +2 -2
- package/dist/src/cli.js +2 -1
- package/dist/src/cli.js.map +2 -2
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
136873
|
-
|
|
136874
|
-
|
|
136875
|
-
|
|
136876
|
-
|
|
136877
|
-
|
|
136878
|
-
|
|
136879
|
-
|
|
136880
|
-
|
|
136881
|
-
|
|
136882
|
-
|
|
136883
|
-
|
|
136884
|
-
|
|
136885
|
-
|
|
136886
|
-
|
|
136887
|
-
|
|
136888
|
-
const
|
|
136889
|
-
|
|
136890
|
-
|
|
136891
|
-
|
|
136892
|
-
|
|
136893
|
-
|
|
136894
|
-
|
|
136895
|
-
|
|
136896
|
-
|
|
136897
|
-
|
|
136898
|
-
|
|
136899
|
-
|
|
136900
|
-
|
|
136901
|
-
|
|
136902
|
-
|
|
136903
|
-
|
|
136904
|
-
|
|
136905
|
-
|
|
136906
|
-
|
|
136907
|
-
|
|
136908
|
-
|
|
136909
|
-
|
|
136910
|
-
|
|
136911
|
-
|
|
136912
|
-
|
|
136913
|
-
|
|
136914
|
-
|
|
136915
|
-
|
|
136916
|
-
|
|
136917
|
-
|
|
136918
|
-
|
|
136919
|
-
|
|
136920
|
-
|
|
136921
|
-
|
|
136922
|
-
|
|
136923
|
-
|
|
136924
|
-
|
|
136925
|
-
|
|
136926
|
-
|
|
136927
|
-
|
|
136928
|
-
|
|
136929
|
-
|
|
136930
|
-
|
|
136931
|
-
|
|
136932
|
-
|
|
136933
|
-
|
|
136934
|
-
|
|
136935
|
-
|
|
136936
|
-
|
|
136937
|
-
|
|
136938
|
-
|
|
136939
|
-
|
|
136940
|
-
|
|
136941
|
-
|
|
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
|
-
}
|
|
136952
|
-
|
|
136953
|
-
|
|
136954
|
-
|
|
136955
|
-
|
|
136956
|
-
|
|
136957
|
-
|
|
136958
|
-
|
|
136959
|
-
|
|
136960
|
-
|
|
136961
|
-
|
|
136962
|
-
|
|
136963
|
-
|
|
136964
|
-
|
|
136965
|
-
|
|
136966
|
-
|
|
136967
|
-
|
|
136968
|
-
|
|
136969
|
-
|
|
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
|
-
|
|
136982
|
-
|
|
136983
|
-
|
|
136984
|
-
|
|
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
|
-
|
|
136993
|
-
|
|
136994
|
-
|
|
136995
|
-
|
|
136996
|
-
|
|
136997
|
-
|
|
136998
|
-
|
|
136999
|
-
|
|
137000
|
-
|
|
137001
|
-
|
|
137002
|
-
|
|
137003
|
-
|
|
137004
|
-
|
|
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
|
-
|
|
137066
|
-
|
|
137067
|
-
|
|
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
|
-
|
|
137073
|
-
|
|
137074
|
-
|
|
137075
|
-
|
|
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
|
-
|
|
137109
|
-
|
|
137110
|
-
|
|
137111
|
-
|
|
137112
|
-
|
|
137113
|
-
|
|
137114
|
-
|
|
137115
|
-
|
|
137116
|
-
|
|
137117
|
-
|
|
137118
|
-
|
|
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
|
-
|
|
137128
|
-
|
|
137129
|
-
|
|
137130
|
-
|
|
137131
|
-
|
|
137132
|
-
|
|
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
|
-
|
|
137136
|
-
|
|
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
|
-
|
|
137180
|
-
|
|
137181
|
-
|
|
137182
|
-
|
|
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
|
-
|
|
137185
|
-
|
|
137186
|
-
|
|
137187
|
-
|
|
137188
|
-
|
|
137189
|
-
|
|
137190
|
-
|
|
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
|
-
|
|
137193
|
-
|
|
137194
|
-
|
|
137195
|
-
|
|
137196
|
-
|
|
137197
|
-
|
|
137198
|
-
|
|
137199
|
-
|
|
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 =
|
|
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
|
|