@gholl-studio/pier-connector 0.2.34 → 0.2.36

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 +2 -2
  2. package/src/index.js +16 -6
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.34",
4
+ "version": "0.2.36",
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",
@@ -34,7 +34,7 @@
34
34
  ],
35
35
  "license": "MIT",
36
36
  "dependencies": {
37
- "@gholl-studio/pier-sdk": "^1.0.2",
37
+ "@gholl-studio/pier-sdk": "^1.0.3",
38
38
  "@nats-io/jetstream": "^3.3.1",
39
39
  "@nats-io/transport-node": "^3.0.0",
40
40
  "ethers": "^6.16.0",
package/src/index.js CHANGED
@@ -49,10 +49,17 @@ export default function register(api) {
49
49
  }];
50
50
  }
51
51
 
52
- return Object.entries(rawAccounts).map(([id, account]) => ({
52
+ const configs = Object.entries(rawAccounts).map(([id, account]) => ({
53
53
  accountId: id,
54
54
  ...mergedCfgFrom(legacyCfg, account)
55
55
  }));
56
+
57
+ logger.info(`[pier-connector] Loaded ${configs.length} account(s): ${configs.map(c => c.accountId).join(', ')}`);
58
+ configs.forEach(c => {
59
+ if (c.agentId) logger.info(`[pier-connector] Account '${c.accountId}' has explicit agentId binding: ${c.agentId}`);
60
+ });
61
+
62
+ return configs;
56
63
  }
57
64
 
58
65
  function mergedCfgFrom(legacy, account) {
@@ -155,12 +162,15 @@ export default function register(api) {
155
162
  }
156
163
 
157
164
  const route = api.runtime.channel.routing.resolveAgentRoute({
158
- cfg: api.config,
165
+ cfg: api.runtime.config,
159
166
  channel: 'pier',
160
167
  accountId: inbound.accountId,
161
168
  peer: { kind: 'direct', id: jobId }
162
169
  });
163
170
 
171
+ const finalAgentId = this.config.agentId || route.agentId;
172
+ logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${this.config.agentId ? 'account-config' : (route.agentId ? 'global-bindings' : 'default-routing')})`);
173
+
164
174
  const dynamicSessionKey = `pier-job-${jobId}`;
165
175
  const metadata = this.activeNodeJobs.get(jobId);
166
176
  let injectedPrompt = "";
@@ -217,8 +227,8 @@ export default function register(api) {
217
227
  });
218
228
 
219
229
  const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
220
- cfg: api.config,
221
- agentId: route.agentId,
230
+ cfg: api.runtime.config,
231
+ agentId: finalAgentId,
222
232
  deliver: async (payload) => {
223
233
  const currentMeta = this.activeNodeJobs.get(jobId);
224
234
  await pierChannel.outbound.sendText({
@@ -244,7 +254,7 @@ export default function register(api) {
244
254
 
245
255
  try {
246
256
  await api.runtime.channel.reply.dispatchReplyFromConfig({
247
- ctx: ctxPayload, cfg: api.config, dispatcher
257
+ ctx: ctxPayload, cfg: api.runtime.config, dispatcher
248
258
  });
249
259
  } finally {
250
260
  markDispatchIdle();
@@ -585,7 +595,7 @@ export default function register(api) {
585
595
  logger.debug(`[pier-connector][${accountId}] 🫨 Suppressing reply for non-assigned job ${jobId}`);
586
596
  } else {
587
597
  const chatPayload = {
588
- id: crypto.randomUUID ? crypto.randomUUID() : (Math.random().toString(36).substring(2)),
598
+ id: (typeof crypto !== 'undefined' && crypto.randomUUID) ? crypto.randomUUID() : (Math.random().toString(36).substring(2) + Date.now().toString(36)),
589
599
  job_id: jobId,
590
600
  sender_id: robot.config.nodeId || 'anonymous',
591
601
  sender_name: accountId,