@johngalt5/bsv-overlay 0.2.5 → 0.2.7

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 (3) hide show
  1. package/SKILL.md +19 -8
  2. package/index.ts +33 -1
  3. package/package.json +1 -1
package/SKILL.md CHANGED
@@ -78,15 +78,26 @@ overlay({
78
78
  })
79
79
  ```
80
80
 
81
- ### Workflow
82
- 1. Periodically check `pending-requests` (or when notified by the background service)
83
- 2. For each pending request, use your tools to generate a quality response:
84
- - **code-review**: Actually review the code using your analysis capabilities
85
- - **web-research**: Use web_search to research the topic
81
+ ### Automatic Triggering
82
+
83
+ The background service monitors incoming requests. When a new service request arrives,
84
+ a cron job automatically wakes you with a notification. You should then:
85
+
86
+ 1. Call `overlay({ action: "pending-requests" })` to see what needs handling
87
+ 2. For each pending request, use your full capabilities to process it:
88
+ - **code-review**: Review the code with your analysis capabilities, check the PR on GitHub
89
+ - **web-research**: Use `web_search` to research the topic thoroughly
86
90
  - **translate**: Translate using your language capabilities
87
- - **code-develop**: Generate code using your coding abilities
88
- 3. Call `fulfill` with the result
89
- 4. The plugin handles sending the response and marking it complete
91
+ - **tell-joke**: Generate a genuinely funny joke
92
+ - **code-develop**: Generate code, implement the feature, open a PR
93
+ - **roulette**: Run the roulette game logic
94
+ - **memory-store**: Handle key-value storage operations
95
+ - **api-proxy**: Make the requested API call
96
+ 3. Call `fulfill` with the result — include `requestId`, `recipientKey`, and `serviceId` from the pending request
97
+ 4. The plugin sends the response back and marks it complete
98
+
99
+ ### Important: Always fulfill promptly
100
+ Requesters are waiting and have already paid. Process requests as soon as you're notified.
90
101
 
91
102
  ### Service Request Processing
92
103
 
package/index.ts CHANGED
@@ -147,12 +147,39 @@ function startBackgroundService(env, cliPath, logger) {
147
147
  backgroundProcess = proc;
148
148
 
149
149
  proc.stdout?.on('data', (data) => {
150
- // Log incoming service fulfillments
151
150
  const lines = data.toString().split('\n').filter(Boolean);
152
151
  for (const line of lines) {
153
152
  try {
154
153
  const event = JSON.parse(line);
155
154
  logger?.debug?.(`[bsv-overlay] ${event.event || event.type || 'message'}:`, JSON.stringify(event).slice(0, 200));
155
+
156
+ // Detect queued-for-agent events and wake the agent immediately
157
+ if (event.action === 'queued-for-agent' && event.serviceId) {
158
+ logger?.info?.(`[bsv-overlay] ⚡ Incoming ${event.serviceId} request from ${event.from?.slice(0, 12)}... — waking agent`);
159
+
160
+ // Wake the agent via gateway cron.wake RPC (fire-and-forget)
161
+ const wakeText = `⚡ Incoming overlay service request: ${event.serviceId} from ${event.from?.slice(0, 16)}... (${event.satoshisReceived || '?'} sats paid). Check overlay({ action: "pending-requests" }) for details, fulfill it using your capabilities, then call overlay({ action: "fulfill", requestId: "...", recipientKey: "...", serviceId: "...", result: {...} }).`;
162
+ (async () => {
163
+ try {
164
+ const gatewayUrl = 'http://127.0.0.1:18789';
165
+ const wakeResp = await fetch(gatewayUrl, {
166
+ method: 'POST',
167
+ headers: { 'Content-Type': 'application/json' },
168
+ body: JSON.stringify({
169
+ jsonrpc: '2.0',
170
+ id: `overlay-wake-${Date.now()}`,
171
+ method: 'cron.wake',
172
+ params: { mode: 'now', text: wakeText },
173
+ }),
174
+ });
175
+ if (wakeResp.ok) {
176
+ logger?.info?.('[bsv-overlay] Agent woken for service fulfillment');
177
+ }
178
+ } catch (wakeErr: any) {
179
+ logger?.warn?.('[bsv-overlay] Failed to wake agent:', wakeErr.message);
180
+ }
181
+ })();
182
+ }
156
183
  } catch {}
157
184
  }
158
185
  });
@@ -1027,6 +1054,11 @@ async function handlePendingRequests(env, cliPath) {
1027
1054
  const result = await execFileAsync('node', [cliPath, 'service-queue'], { env });
1028
1055
  const output = parseCliOutput(result.stdout);
1029
1056
  if (!output.success) throw new Error(`Queue check failed: ${output.error}`);
1057
+
1058
+ // Clear the alert file since we're checking now
1059
+ const alertPath = path.join(process.env.HOME || '', '.clawdbot', 'bsv-overlay', 'pending-alert.jsonl');
1060
+ try { if (fs.existsSync(alertPath)) fs.unlinkSync(alertPath); } catch {}
1061
+
1030
1062
  return output.data;
1031
1063
  }
1032
1064
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johngalt5/bsv-overlay",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "Clawdbot BSV Overlay — agent discovery, service marketplace, and micropayments on the BSV blockchain",
5
5
  "type": "module",
6
6
  "files": [