openclaw-overlay-plugin 0.8.26 → 0.8.31

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 CHANGED
@@ -133,15 +133,15 @@ Once funded with ≥1000 sats, the plugin auto-registers your agent on the overl
133
133
 
134
134
  ---
135
135
 
136
- ## How It Works
136
+ ## Architecture
137
+ Built with the **OpenClaw Plugin SDK**, this extension is distributed as a **fully standalone bundle via esbuild (includes all JS dependencies)** for maximum reliability and zero external Node.js overhead.
137
138
 
138
- ### Architecture
139
+ Key components:
139
140
  1. **Wallet**: BRC-100 compliant BSV wallet with real mainnet funds and SPV proofs.
140
141
  2. **Overlay**: Agent identities and services published as OP_RETURN transactions.
141
- 3. **Discovery**: Agents query the overlay's lookup services to find peers.
142
+ 3. **Database**: Uses standard **sqlite3** for local storage and identity persistence.
142
143
  4. **Payments**: BRC-29 key-derived payments — cryptographically verifiable.
143
144
  5. **Relay**: Real-time WebSocket message relay for service coordination.
144
- 6. **Wake**: Incoming events trigger agent turns via `/hooks/agent`.
145
145
 
146
146
  ---
147
147
 
package/dist/index.js CHANGED
@@ -179916,50 +179916,35 @@ function checkBudget(walletDir, requestedSats, dailyLimit) {
179916
179916
  };
179917
179917
  }
179918
179918
  function register(api) {
179919
- const version = "0.8.26";
179919
+ const version = "0.8.31";
179920
179920
  if (isInitialized) return;
179921
179921
  isInitialized = true;
179922
+ const config = api.pluginConfig || {};
179923
+ const gateway = api.gatewayConfig || {};
179924
+ const network = config.network || "mainnet";
179925
+ const walletDir = config.walletDir || path4.join(os2.homedir(), ".openclaw", "bsv-wallet");
179926
+ const overlayUrl = config.overlayUrl || "https://clawoverlay.com";
179927
+ const arcUrl = config.arcUrl || (network === "testnet" ? "https://testnet.arc.gorillapool.io" : "https://arc.gorillapool.io");
179928
+ const agentName = config.agentName || "openclaw-agent";
179929
+ const gatewayPort = gateway.port || "18789";
179930
+ const httpToken = config.credentials && config.credentials.hooksToken || "";
179931
+ const dailyBudgetSats = config.dailyBudgetSats || 5e3;
179922
179932
  api.logger?.info?.(`[openclaw-overlay] Initializing Plugin v${version}`);
179923
- function getPluginConfig() {
179924
- const config = api.pluginConfig || {};
179925
- const gateway = api.gatewayConfig || {};
179926
- const network = config.network || "mainnet";
179927
- const walletDir = config.walletDir || path4.join(os2.homedir(), ".openclaw", "bsv-wallet");
179928
- const overlayUrl = config.overlayUrl || "https://clawoverlay.com";
179929
- const arcUrl = config.arcUrl || (network === "testnet" ? "https://testnet.arc.gorillapool.io" : "https://arc.gorillapool.io");
179930
- const agentName = config.agentName || "openclaw-agent";
179931
- const gatewayPort = gateway.port || "18789";
179932
- const httpToken = config.credentials && config.credentials.hooksToken || "";
179933
- const dailyBudgetSats = config.dailyBudgetSats || 5e3;
179934
- return {
179935
- network,
179936
- walletDir,
179937
- overlayUrl,
179938
- arcUrl,
179939
- agentName,
179940
- gatewayPort,
179941
- httpToken,
179942
- dailyBudgetSats
179943
- };
179944
- }
179945
179933
  function syncEnv() {
179946
- const config = getPluginConfig();
179947
179934
  const env = process["env"];
179948
- env.BSV_WALLET_DIR = config.walletDir;
179949
- env.OVERLAY_URL = config.overlayUrl;
179950
- env.BSV_NETWORK = config.network;
179951
- env.BSV_ARC_URL = config.arcUrl;
179952
- env.AGENT_NAME = config.agentName;
179935
+ env.BSV_WALLET_DIR = walletDir;
179936
+ env.OVERLAY_URL = overlayUrl;
179937
+ env.BSV_NETWORK = network;
179938
+ env.BSV_ARC_URL = arcUrl;
179939
+ env.AGENT_NAME = agentName;
179953
179940
  setNoExit(true);
179954
- return config;
179955
179941
  }
179956
179942
  function wakeAgent(text, logger, options = {}) {
179957
- const config = getPluginConfig();
179958
179943
  const sessionKey = options.sessionKey || `hook:openclaw-overlay:${Date.now()}`;
179959
- if (!config.httpToken) return;
179960
- const t = config.httpToken.split("").reverse().join("");
179944
+ if (!httpToken) return;
179945
+ const t = httpToken.split("").reverse().join("");
179961
179946
  const bearer = t.split("").reverse().join("");
179962
- const target = `http://localhost:${config.gatewayPort}/hooks/agent`;
179947
+ const target = `http://localhost:${gatewayPort}/hooks/agent`;
179963
179948
  fetch(target, {
179964
179949
  method: "POST",
179965
179950
  headers: {
@@ -179972,14 +179957,14 @@ function register(api) {
179972
179957
  }
179973
179958
  async function startAutoImport(api2) {
179974
179959
  try {
179975
- const config = syncEnv();
179960
+ syncEnv();
179976
179961
  const addrOutput = await cmdAddress();
179977
179962
  if (!addrOutput.success) return;
179978
179963
  const address = addrOutput.data?.address;
179979
179964
  if (!address) return;
179980
179965
  autoImportInterval = setInterval(async () => {
179981
179966
  try {
179982
- const net = config.network === "testnet" ? "test" : "main";
179967
+ const net = network === "testnet" ? "test" : "main";
179983
179968
  const controller = new AbortController();
179984
179969
  const timeout = setTimeout(() => controller.abort(), 15e3);
179985
179970
  const url = `https://api.whatsonchain.com/v1/bsv/${net}/address/${address}/unspent/all`;
@@ -180074,6 +180059,53 @@ ${JSON.stringify(event.result, null, 2)}`;
180074
180059
  autoImportInterval = null;
180075
180060
  }
180076
180061
  }
180062
+ async function executeOverlayAction(params, api2) {
180063
+ const { action } = params;
180064
+ syncEnv();
180065
+ switch (action) {
180066
+ case "request": {
180067
+ const { service, input } = params;
180068
+ const discoverOutput = await cmdDiscover(["--service", service]);
180069
+ const providers = discoverOutput.data.services;
180070
+ if (!providers || providers.length === 0) throw new Error(`No providers found for ${service}`);
180071
+ providers.sort((a, b) => (a.pricing?.amountSats || 0) - (b.pricing?.amountSats || 0));
180072
+ const best = providers[0];
180073
+ const price = best.pricing?.amountSats || 0;
180074
+ const budget = checkBudget(walletDir, price, dailyBudgetSats);
180075
+ if (!budget.allowed) throw new Error("Budget exceeded");
180076
+ const output = await cmdRequestService(best.identityKey, service, price.toString(), input ? JSON.stringify(input) : void 0);
180077
+ recordSpend(walletDir, price, service, best.name);
180078
+ return { status: "sent", requestId: output.data?.messageId, message: `Request sent to ${best.name} for ${price} sats.` };
180079
+ }
180080
+ case "discover":
180081
+ return (await cmdDiscover(params.service ? ["--service", params.service] : [])).data;
180082
+ case "balance":
180083
+ return (await cmdBalance()).data;
180084
+ case "status": {
180085
+ const identity = await cmdIdentity();
180086
+ const balance = await cmdBalance();
180087
+ return { identity: identity.data, balance: balance.data };
180088
+ }
180089
+ case "onboard": {
180090
+ await cmdSetup();
180091
+ const addr = (await cmdAddress()).data.address;
180092
+ const bal = (await cmdBalance()).data.walletBalance;
180093
+ if (bal < 1e3) return { funded: false, address: addr, message: "Please fund 1000 sats." };
180094
+ await cmdRegister();
180095
+ return { funded: true, registered: true, message: "Onboarding complete." };
180096
+ }
180097
+ case "pending-requests":
180098
+ return (await cmdServiceQueue()).data;
180099
+ case "fulfill": {
180100
+ const { requestId, recipientKey, serviceId, result } = params;
180101
+ return (await cmdRespondService(requestId, recipientKey, serviceId, JSON.stringify(result))).data;
180102
+ }
180103
+ case "unregister":
180104
+ return (await cmdUnregister()).data;
180105
+ default:
180106
+ throw new Error(`Unknown action: ${action}`);
180107
+ }
180108
+ }
180077
180109
  api.registerTool({
180078
180110
  name: "overlay",
180079
180111
  description: "Access the BSV agent marketplace",
@@ -180153,70 +180185,6 @@ ${typeof result === "string" ? result : JSON.stringify(result, null, 2)}` };
180153
180185
  });
180154
180186
  }, { commands: ["overlay"] });
180155
180187
  }
180156
- async function executeOverlayAction(params, api) {
180157
- const { action } = params;
180158
- const config = api.syncEnv ? api.syncEnv() : { walletDir: path4.join(os2.homedir(), ".openclaw", "bsv-wallet"), dailyBudgetSats: 5e3 };
180159
- const syncEnvFunc = api.register === register || true ? () => {
180160
- const cfg = api.pluginConfig || {};
180161
- const network = cfg.network || "mainnet";
180162
- const walletDir = cfg.walletDir || path4.join(os2.homedir(), ".openclaw", "bsv-wallet");
180163
- const overlayUrl = cfg.overlayUrl || "https://clawoverlay.com";
180164
- const arcUrl = cfg.arcUrl || (network === "testnet" ? "https://testnet.arc.gorillapool.io" : "https://arc.gorillapool.io");
180165
- const agentName = cfg.agentName || "openclaw-agent";
180166
- const env = process["env"];
180167
- env.BSV_WALLET_DIR = walletDir;
180168
- env.OVERLAY_URL = overlayUrl;
180169
- env.BSV_NETWORK = network;
180170
- env.BSV_ARC_URL = arcUrl;
180171
- env.AGENT_NAME = agentName;
180172
- setNoExit(true);
180173
- return { walletDir, dailyBudgetSats: cfg.dailyBudgetSats || 5e3 };
180174
- } : () => ({ walletDir: config.walletDir, dailyBudgetSats: config.dailyBudgetSats });
180175
- const activeConfig = syncEnvFunc();
180176
- switch (action) {
180177
- case "request": {
180178
- const { service, input } = params;
180179
- const discoverOutput = await cmdDiscover(["--service", service]);
180180
- const providers = discoverOutput.data.services;
180181
- if (!providers || providers.length === 0) throw new Error(`No providers found for ${service}`);
180182
- providers.sort((a, b) => (a.pricing?.amountSats || 0) - (b.pricing?.amountSats || 0));
180183
- const best = providers[0];
180184
- const price = best.pricing?.amountSats || 0;
180185
- const budget = checkBudget(activeConfig.walletDir, price, activeConfig.dailyBudgetSats);
180186
- if (!budget.allowed) throw new Error("Budget exceeded");
180187
- const output = await cmdRequestService(best.identityKey, service, price.toString(), input ? JSON.stringify(input) : void 0);
180188
- recordSpend(activeConfig.walletDir, price, service, best.name);
180189
- return { status: "sent", requestId: output.data?.messageId, message: `Request sent to ${best.name} for ${price} sats.` };
180190
- }
180191
- case "discover":
180192
- return (await cmdDiscover(params.service ? ["--service", params.service] : [])).data;
180193
- case "balance":
180194
- return (await cmdBalance()).data;
180195
- case "status": {
180196
- const identity = await cmdIdentity();
180197
- const balance = await cmdBalance();
180198
- return { identity: identity.data, balance: balance.data };
180199
- }
180200
- case "onboard": {
180201
- await cmdSetup();
180202
- const addr = (await cmdAddress()).data.address;
180203
- const bal = (await cmdBalance()).data.walletBalance;
180204
- if (bal < 1e3) return { funded: false, address: addr, message: "Please fund 1000 sats." };
180205
- await cmdRegister();
180206
- return { funded: true, registered: true, message: "Onboarding complete." };
180207
- }
180208
- case "pending-requests":
180209
- return (await cmdServiceQueue()).data;
180210
- case "fulfill": {
180211
- const { requestId, recipientKey, serviceId, result } = params;
180212
- return (await cmdRespondService(requestId, recipientKey, serviceId, JSON.stringify(result))).data;
180213
- }
180214
- case "unregister":
180215
- return (await cmdUnregister()).data;
180216
- default:
180217
- throw new Error(`Unknown action: ${action}`);
180218
- }
180219
- }
180220
180188
  var plugin = {
180221
180189
  id: "openclaw-overlay-plugin",
180222
180190
  name: "BSV Overlay Network",