@gholl-studio/pier-connector 0.2.4 → 0.2.6

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/package.json +1 -1
  2. package/src/index.js +25 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gholl-studio/pier-connector",
3
3
  "author": "gholl",
4
- "version": "0.2.4",
4
+ "version": "0.2.6",
5
5
  "description": "OpenClaw plugin that connects to the Pier job marketplace. Automatically fetches, executes, and reports distributed tasks for rewards.",
6
6
  "type": "module",
7
7
  "main": "src/index.js",
package/src/index.js CHANGED
@@ -478,6 +478,29 @@ export default function register(api) {
478
478
  const publicSubject = config.subject;
479
479
  const privateSubject = `jobs.node.${config.nodeId}`;
480
480
 
481
+ // 5a. Restore active job subscriptions (BUG-32)
482
+ try {
483
+ logger.info(`[pier-connector] 🔍 Checking for active jobs to restore for node ${config.nodeId}...`);
484
+ const jobsResp = await fetch(`${config.apiBase}/jobs?assigned_node_id=${config.nodeId}&limit=50`);
485
+ if (jobsResp.ok) {
486
+ const jobsList = await jobsResp.json();
487
+ const activeJobs = (jobsList || []).filter(j => j.status === 'PENDING' || j.status === 'PROCESSING');
488
+ if (activeJobs.length > 0) {
489
+ logger.info(`[pier-connector] ♻️ Restoring ${activeJobs.length} active job subscriptions...`);
490
+ for (const job of activeJobs) {
491
+ if (!jobSubscriptions.has(job.id)) {
492
+ activeNodeJobs.set(job.id, { pierJobId: job.id });
493
+ await subscribeToJobMessages(job.id);
494
+ }
495
+ }
496
+ } else {
497
+ logger.info('[pier-connector] No active jobs found to restore.');
498
+ }
499
+ }
500
+ } catch (err) {
501
+ logger.warn(`[pier-connector] ⚠️ Failed to restore active jobs: ${err.message}`);
502
+ }
503
+
481
504
  // Public pool with load balancing via JetStream Durable Consumer
482
505
  if (publicSubject) {
483
506
  const durableName = `pier_marketplace_${config.queueGroup || 'default'}`;
@@ -639,8 +662,8 @@ export default function register(api) {
639
662
  continue;
640
663
  }
641
664
 
642
- // Send read receipt back
643
- if (js && msgPayload.id) {
665
+ // Send read receipt back (ONLY for actual messages from users, BUG-31)
666
+ if (js && msgPayload.id && !msgPayload.type && msgPayload.sender_id !== config.nodeId) {
644
667
  try {
645
668
  const replySubject = `jobs.job.${jobId}.msg`;
646
669
  await js.publish(replySubject, new TextEncoder().encode(JSON.stringify({