@gholl-studio/pier-connector 0.3.25 → 0.3.26

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/robot.ts +6 -10
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gholl-studio/pier-connector",
3
3
  "author": "gholl",
4
- "version": "0.3.25",
4
+ "version": "0.3.26",
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.ts",
package/src/robot.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  */
5
5
 
6
6
  import { PierClient, protocol } from '@gholl-studio/pier-sdk';
7
- const { createRequestPayload, createResultPayload, createErrorPayload } = protocol;
8
- import { parseJob, safeRespond, truncate } from './job-handler.js';
7
+ const { createRequestPayload, createResultPayload, createErrorPayload, normalizeInboundPayload } = protocol;
8
+ import { safeRespond, truncate } from './job-handler.js';
9
9
  import { jetstream, jetstreamManager, AckPolicy, DeliverPolicy, type JetStreamClient, type JetStreamManager } from '@nats-io/jetstream';
10
10
  import type { PierAccountConfig, PierPluginApi, InboundMessage } from './types.js';
11
11
 
@@ -204,17 +204,13 @@ export class PierRobot {
204
204
  msg.ack();
205
205
 
206
206
  this.stats.received++;
207
- const parsed = parseJob(msg, this.logger);
207
+ // payload 已在上方 JSON.parse 完成,直接用 normalizeInboundPayload 转换
208
+ // 不能再调用 parseJob(msg),因为 msg 已 ack,且 JetStream consume msg 可能没有 string() 方法
209
+ const parsed = normalizeInboundPayload(payload);
208
210
  if (!parsed.ok) {
209
211
  this.stats.failed++;
210
212
  this.isBusy = false;
211
- safeRespond(msg, createErrorPayload({
212
- id: jobIdToClaim || 'unknown',
213
- errorCode: 'PARSE_ERROR',
214
- errorMessage: parsed.error,
215
- workerId: this.config.nodeId,
216
- walletAddress: this.config.walletAddress,
217
- }));
213
+ this.logger.error(`[pier-connector][${this.accountId}] ✖ Failed to parse job payload: ${parsed.error}`);
218
214
  return;
219
215
  }
220
216