@gholl-studio/pier-connector 0.3.25 → 0.3.27
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 +2 -2
- package/src/robot.ts +8 -12
- package/src/types/pier-sdk.d.ts +0 -25
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.
|
|
4
|
+
"version": "0.3.27",
|
|
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",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
],
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@gholl-studio/pier-sdk": "^1.0
|
|
43
|
+
"@gholl-studio/pier-sdk": "^1.1.0",
|
|
44
44
|
"@nats-io/jetstream": "^3.3.1",
|
|
45
45
|
"@nats-io/transport-node": "^3.0.0",
|
|
46
46
|
"ethers": "^6.16.0",
|
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 {
|
|
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,21 +204,17 @@ export class PierRobot {
|
|
|
204
204
|
msg.ack();
|
|
205
205
|
|
|
206
206
|
this.stats.received++;
|
|
207
|
-
|
|
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
|
-
|
|
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
|
|
|
221
|
-
const
|
|
217
|
+
const job = parsed.job!;
|
|
222
218
|
const senderCore = job.meta?.sender ?? 'anonymous';
|
|
223
219
|
|
|
224
220
|
this.activeNodeJobs.set(job.id, {
|
|
@@ -229,7 +225,7 @@ export class PierRobot {
|
|
|
229
225
|
isTargeted: isTargeted
|
|
230
226
|
});
|
|
231
227
|
|
|
232
|
-
let finalText = job.task;
|
|
228
|
+
let finalText = job.task || '';
|
|
233
229
|
if (!isTargeted) {
|
|
234
230
|
finalText = `【PIER MARKETPLACE OPEN JOB】\nJob ID: ${job.id}\nTask: ${job.task}\n\n=== CRITICAL ===\nYou MUST use \`pier_bid_task\` to bid. Do not solve directly.`;
|
|
235
231
|
} else {
|
package/src/types/pier-sdk.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file pier-sdk.d.ts
|
|
3
|
-
* @description TypeScript declaration file for the @gholl-studio/pier-sdk to support plugin compilation.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
declare module '@gholl-studio/pier-sdk' {
|
|
7
|
-
export class PierClient {
|
|
8
|
-
constructor(config: { apiUrl: string; natsUrl?: string; logger?: any });
|
|
9
|
-
connectNats(): Promise<any>;
|
|
10
|
-
getNatsConnection(): Promise<any>;
|
|
11
|
-
heartbeat(nodeId: string, secretKey: string, capabilities: string[]): Promise<any>;
|
|
12
|
-
claimJob(jobId: string, nodeId: string, secretKey: string): Promise<any>;
|
|
13
|
-
autoRegister(privateKey: string, hostName: string): Promise<{ nodeId: string; secretKey: string; walletAddress: string }>;
|
|
14
|
-
getUserProfile(secretKey: string): Promise<any>;
|
|
15
|
-
drainNats(): Promise<void>;
|
|
16
|
-
nats: { url: string };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const protocol: {
|
|
20
|
-
normalizeInboundPayload(payload: any): { ok: boolean; job?: any; error?: string };
|
|
21
|
-
createRequestPayload(data: any): any;
|
|
22
|
-
createResultPayload(data: any): any;
|
|
23
|
-
createErrorPayload(data: any): any;
|
|
24
|
-
};
|
|
25
|
-
}
|