@gholl-studio/pier-connector 0.2.28 → 0.2.29
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/package.json +1 -1
- package/src/index.js +21 -18
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
|
+
"version": "0.2.29",
|
|
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
|
@@ -308,6 +308,14 @@ export default function register(api) {
|
|
|
308
308
|
|
|
309
309
|
logger.info(`[pier-connector][${this.accountId}] \u{1F4AC} Chat: [${jobId}] ${msgPayload.sender_id}: "${truncate(content, 40)}"`);
|
|
310
310
|
if (msgPayload.id) processedMessages.add(msgPayload.id);
|
|
311
|
+
|
|
312
|
+
// Only the assigned robot should process chat messages
|
|
313
|
+
const jobMeta = this.activeNodeJobs.get(jobId);
|
|
314
|
+
if (!jobMeta || !jobMeta.isTargeted) {
|
|
315
|
+
msg.ack();
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
|
|
311
319
|
msg.ack();
|
|
312
320
|
|
|
313
321
|
await this.receiveIncoming({
|
|
@@ -338,7 +346,7 @@ export default function register(api) {
|
|
|
338
346
|
if (jobId) {
|
|
339
347
|
logger.info(`[pier-connector][${this.accountId}] ⏰ Received wakeup signal for job ${jobId}`);
|
|
340
348
|
if (!this.jobSubscriptions.has(jobId)) {
|
|
341
|
-
this.activeNodeJobs.set(jobId, { pierJobId: jobId });
|
|
349
|
+
this.activeNodeJobs.set(jobId, { pierJobId: jobId, isTargeted: true });
|
|
342
350
|
await this.subscribeToJobMessages(jobId);
|
|
343
351
|
}
|
|
344
352
|
msg.ack();
|
|
@@ -591,23 +599,18 @@ export default function register(api) {
|
|
|
591
599
|
try {
|
|
592
600
|
const replySubject = `chat.${jobId}`;
|
|
593
601
|
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
await robot.js.publish(replySubject, new TextEncoder().encode(JSON.stringify(chatPayload)));
|
|
607
|
-
logger.info(`[pier-connector][${accountId}] 💬 Agent reply published to NATS for job ${jobId} (Subject: ${replySubject})`);
|
|
608
|
-
} else {
|
|
609
|
-
logger.debug(`[pier-connector][${accountId}] 🤫 Pre-hiring radio silence for job ${jobId}`);
|
|
610
|
-
}
|
|
602
|
+
const chatPayload = {
|
|
603
|
+
id: crypto.randomUUID ? crypto.randomUUID() : (Math.random().toString(36).substring(2)),
|
|
604
|
+
job_id: jobId,
|
|
605
|
+
sender_id: robot.config.nodeId || 'anonymous',
|
|
606
|
+
sender_type: 'node',
|
|
607
|
+
content: text,
|
|
608
|
+
created_at: new Date().toISOString(),
|
|
609
|
+
auth_token: robot.config.secretKey
|
|
610
|
+
};
|
|
611
|
+
|
|
612
|
+
await robot.js.publish(replySubject, new TextEncoder().encode(JSON.stringify(chatPayload)));
|
|
613
|
+
logger.info(`[pier-connector][${accountId}] 💬 Agent reply published to NATS for job ${jobId} (Subject: ${replySubject})`);
|
|
611
614
|
} catch (err) {
|
|
612
615
|
logger.error(`[pier-connector][${accountId}] Failed to publish reply: ${err.message}`);
|
|
613
616
|
}
|