@gholl-studio/pier-connector 0.2.0 → 0.2.2
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 +27 -9
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.2",
|
|
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
|
@@ -597,7 +597,7 @@ export default function register(api) {
|
|
|
597
597
|
const cInfo = await jsm.consumers.add(streamName, {
|
|
598
598
|
durable_name: durableName,
|
|
599
599
|
filter_subject: msgSubject,
|
|
600
|
-
deliver_policy: DeliverPolicy.New, //
|
|
600
|
+
deliver_policy: DeliverPolicy.New, // Reverted to New to stop message storms (BUG-27)
|
|
601
601
|
ack_policy: AckPolicy.Explicit,
|
|
602
602
|
ack_wait: 30000,
|
|
603
603
|
});
|
|
@@ -607,8 +607,9 @@ export default function register(api) {
|
|
|
607
607
|
jobSubscriptions.set(jobId, iter);
|
|
608
608
|
|
|
609
609
|
(async () => {
|
|
610
|
-
logger.info(`[pier-connector] 👂 Monitoring
|
|
610
|
+
logger.info(`[pier-connector] 👂 Monitoring chat subject ${msgSubject} (Durable: ${durableName})`);
|
|
611
611
|
|
|
612
|
+
let isProcessing = false;
|
|
612
613
|
for await (const msg of iter) {
|
|
613
614
|
try {
|
|
614
615
|
const rawMsg = new TextDecoder().decode(msg.data);
|
|
@@ -647,9 +648,21 @@ export default function register(api) {
|
|
|
647
648
|
}
|
|
648
649
|
|
|
649
650
|
const content = msgPayload.content;
|
|
650
|
-
logger.info(`[pier-connector] 📥 Incoming message for ${jobId}: "${truncate(content, 40)}"`);
|
|
651
|
-
|
|
652
651
|
const senderCore = msgPayload.sender_id;
|
|
652
|
+
|
|
653
|
+
if (!content) {
|
|
654
|
+
logger.warn(`[pier-connector] ⚠️ Skipping message from ${senderCore} for ${jobId}: Empty content`);
|
|
655
|
+
msg.ack();
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
if (isProcessing) {
|
|
660
|
+
logger.warn(`[pier-connector] ⏳ Throttling: Agent already processing for job ${jobId}`);
|
|
661
|
+
msg.nak();
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
logger.info(`[pier-connector] 📥 Incoming chat: [${jobId}] sender=${senderCore} "${truncate(content, 40)}"`);
|
|
653
666
|
|
|
654
667
|
activeNodeJobs.set(jobId, {
|
|
655
668
|
pierJobId: jobId,
|
|
@@ -657,11 +670,16 @@ export default function register(api) {
|
|
|
657
670
|
});
|
|
658
671
|
|
|
659
672
|
// Trigger agent
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
673
|
+
try {
|
|
674
|
+
isProcessing = true;
|
|
675
|
+
await receiveIncoming({
|
|
676
|
+
accountId: config.accountId || 'default',
|
|
677
|
+
senderId: `pier:${senderCore}`,
|
|
678
|
+
text: content,
|
|
679
|
+
}, jobId);
|
|
680
|
+
} finally {
|
|
681
|
+
isProcessing = false;
|
|
682
|
+
}
|
|
665
683
|
|
|
666
684
|
msg.ack();
|
|
667
685
|
} catch (err) {
|