@johngalt5/bsv-overlay 0.2.14 → 0.2.15

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.
Files changed (2) hide show
  1. package/index.ts +9 -14
  2. package/package.json +1 -1
package/index.ts CHANGED
@@ -141,10 +141,16 @@ function stopAutoImport() {
141
141
  }
142
142
  }
143
143
 
144
+ // Discover the gateway WebSocket port from environment
145
+ function getGatewayWsUrl(): string {
146
+ const port = process.env.CLAWDBOT_GATEWAY_PORT || process.env.OPENCLAW_GATEWAY_PORT || '18789';
147
+ return `ws://127.0.0.1:${port}`;
148
+ }
149
+
144
150
  // Wake the agent via gateway WebSocket JSON-RPC (event-driven, zero polling)
145
151
  function wakeAgent(text: string, logger?: any) {
146
152
  try {
147
- const ws = new WebSocket('ws://127.0.0.1:18789');
153
+ const ws = new WebSocket(getGatewayWsUrl());
148
154
  const timeout = setTimeout(() => { try { ws.close(); } catch {} }, 5000);
149
155
  ws.on('open', () => {
150
156
  ws.send(JSON.stringify({
@@ -579,19 +585,8 @@ export default function register(api) {
579
585
  if (regOutput.success) {
580
586
  api.log?.info?.('[bsv-overlay] Auto-registered on overlay network! Waking agent for service selection...');
581
587
  // Wake the agent to present service selection to the user
582
- try {
583
- const wakeText = `🎉 BSV Overlay: Auto-registered on the network! Two things to set up:\n\n1. **Agent name**: Ask the user what name they want for their agent on the network. The current default is "${env.AGENT_NAME}". If they want a different name, they need to set it in the plugin config (agentName) and re-register.\n\n2. **Services**: Ask the user which services they want to advertise. Call overlay({ action: "register" }) to get the full list of available services with descriptions and suggested prices, then present them to the user. Let them choose which ones to enable. For each selected service, call overlay({ action: "advertise", serviceId: "...", name: "...", description: "...", priceSats: N }).`;
584
- await fetch('http://127.0.0.1:18789', {
585
- method: 'POST',
586
- headers: { 'Content-Type': 'application/json' },
587
- body: JSON.stringify({
588
- jsonrpc: '2.0',
589
- id: `overlay-service-select-${Date.now()}`,
590
- method: 'cron.wake',
591
- params: { mode: 'now', text: wakeText },
592
- }),
593
- });
594
- } catch {}
588
+ const wakeText = `🎉 BSV Overlay: Auto-registered on the network! Two things to set up:\n\n1. **Agent name**: Ask the user what name they want for their agent on the network. The current default is "${env.AGENT_NAME}". If they want a different name, they need to set it in the plugin config (agentName) and re-register.\n\n2. **Services**: Ask the user which services they want to advertise. Call overlay({ action: "register" }) to get the full list of available services with descriptions and suggested prices, then present them to the user. Let them choose which ones to enable. For each selected service, call overlay({ action: "advertise", serviceId: "...", name: "...", description: "...", priceSats: N }).`;
589
+ wakeAgent(wakeText, api.log);
595
590
  }
596
591
  }
597
592
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngalt5/bsv-overlay",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "Clawdbot BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
5
5
  "type": "module",
6
6
  "files": [