@gholl-studio/pier-connector 0.3.1 → 0.3.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gholl-studio/pier-connector",
3
3
  "author": "gholl",
4
- "version": "0.3.1",
4
+ "version": "0.3.12",
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/cli.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ /**
4
+ * @file cli.ts
5
+ * @description Handles the plugin's CLI command registrations and setup interaction logic.
6
+ */
7
+
3
8
  import type { PierPluginApi } from './types.js';
4
9
 
5
10
  export function registerCli(api: PierPluginApi, stats: any) {
package/src/config.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file config.ts
3
+ * @description Defines the default configuration constants and fallback values for the Pier connector.
4
+ */
5
+
1
6
  /**
2
7
  * Default configuration constants for pier-connector.
3
8
  */
package/src/inbound.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file inbound.ts
3
+ * @description Manages inbound message processing, agent routing resolution, and session context propagation.
4
+ */
5
+
1
6
  import type { PierPluginApi, InboundMessage } from './types.js';
2
7
  import { truncate } from './job-handler.js';
3
8
 
@@ -101,8 +106,11 @@ export async function handleInbound(
101
106
  ].join('\n');
102
107
  }
103
108
 
109
+ logger.info(`[pier-connector:trace] Finalized inbound context for job ${jobId}. Target Agent: ${finalAgentId}, Session: ${dynamicSessionKey}`);
110
+
104
111
  const ctxPayload = api.runtime.channel.reply.finalizeInboundContext({
105
112
  AgentId: finalAgentId,
113
+ agentId: finalAgentId, // Redundant for compatibility
106
114
  Body: inbound.body,
107
115
  BodyForAgent: inbound.body,
108
116
  RawBody: inbound.body,
@@ -122,15 +130,19 @@ export async function handleInbound(
122
130
  MessageId: jobId,
123
131
  Metadata: {
124
132
  ...metadata,
133
+ agentId: finalAgentId, // Pinning in metadata
125
134
  accountId: robot.accountId,
126
135
  pierJobId: jobId,
127
136
  routingSource: routingSource
128
137
  }
129
138
  });
130
139
 
140
+ logger.info(`[pier-connector:trace] FULL DISPATCH CONTEXT for job ${jobId}: ${JSON.stringify(ctxPayload)}`);
141
+
131
142
  const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
132
143
  deliver: async (payload: any) => {
133
144
  const currentMeta = robot.activeNodeJobs.get(jobId);
145
+ logger.info(`[pier-connector:trace] Outbound delivery triggered for job ${jobId}. Text length: ${payload.text?.length || 0}`);
134
146
  await pierChannel.outbound.sendText({
135
147
  text: payload.text,
136
148
  to: `pier:${jobId}`,
@@ -146,16 +158,23 @@ export async function handleInbound(
146
158
  if (api.runtime.channel.session?.recordSessionMetaFromInbound) {
147
159
  try {
148
160
  const storePath = api.runtime.channel.session.resolveStorePath(dynamicSessionKey);
161
+ logger.info(`[pier-connector:trace] Recording session metadata at ${storePath}`);
149
162
  await api.runtime.channel.session.recordSessionMetaFromInbound({
150
163
  storePath, sessionKey: dynamicSessionKey, ctx: ctxPayload
151
164
  });
152
- } catch (err) {}
165
+ } catch (err: any) {
166
+ logger.error(`[pier-connector] ✖ Failed to record session metadata: ${err.message}`);
167
+ }
153
168
  }
154
169
 
155
170
  try {
171
+ logger.info(`[pier-connector:trace] Dispatching reply to agent ${finalAgentId}...`);
156
172
  await api.runtime.channel.reply.dispatchReplyFromConfig({
157
173
  ctx: ctxPayload, cfg: api.config, dispatcher
158
174
  });
175
+ logger.info(`[pier-connector:trace] dispatchReplyFromConfig completed for job ${jobId}`);
176
+ } catch (err: any) {
177
+ logger.error(`[pier-connector] ✖ Dispatch error for job ${jobId}: ${err.message}`);
159
178
  } finally {
160
179
  markDispatchIdle();
161
180
  }
package/src/index.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file index.ts
3
+ * @description Main entry point for the Pier Connector plugin. Orchestrates robots, tools, and channel registration.
4
+ */
5
+
1
6
  import { definePluginEntry } from 'openclaw/plugin-sdk/plugin-entry';
2
7
  import { protocol } from '@gholl-studio/pier-sdk';
3
8
  const { createRequestPayload } = protocol;
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file job-handler.ts
3
+ * @description Provides helper utilities for parsing Pier jobs, handling responses, and text manipulation.
4
+ */
5
+
1
6
  import { protocol } from '@gholl-studio/pier-sdk';
2
7
  const { normalizeInboundPayload } = protocol;
3
8
 
package/src/robot.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file robot.ts
3
+ * @description Implements the PierRobot class, managing NATS connectivity, heartbeat, and job lifecycle.
4
+ */
5
+
1
6
  import { PierClient, protocol } from '@gholl-studio/pier-sdk';
2
7
  const { createRequestPayload, createResultPayload, createErrorPayload } = protocol;
3
8
  import { parseJob, safeRespond, truncate } from './job-handler.js';
@@ -120,13 +125,15 @@ export class PierRobot {
120
125
  }
121
126
 
122
127
  msg.ack();
123
- await this.onInbound({
128
+ const inbound = {
124
129
  accountId: this.accountId,
125
130
  senderId: `pier:${msgPayload.sender_id}`,
126
131
  body: content,
127
132
  jobId: jobId
128
- }, jobId);
129
- } catch (err: any) { this.logger.error(`[pier-connector] Chat err: ${err.message}`); }
133
+ };
134
+ this.logger.info(`[pier-connector:trace] NATS Chat Message received on PierRobot instance accountId='${this.accountId}'. Passing to handleInbound...`);
135
+ await this.onInbound(inbound, jobId);
136
+ } catch (err: any) { this.logger.error(`[pier-connector][${this.accountId}] ✖ Failed to process chat message: ${err.message}`); }
130
137
  }
131
138
  })();
132
139
  } catch (err: any) {
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file pier-sdk.d.ts
3
+ * @description TypeScript declaration file for the @gholl-studio/pier-sdk to support plugin compilation.
4
+ */
5
+
1
6
  declare module '@gholl-studio/pier-sdk' {
2
7
  export class PierClient {
3
8
  constructor(config: { apiUrl: string; natsUrl?: string; logger?: any });
package/src/types.ts CHANGED
@@ -1,3 +1,8 @@
1
+ /**
2
+ * @file types.ts
3
+ * @description Centralized TypeScript interface and type definitions for the Pier connector plugin.
4
+ */
5
+
1
6
  import type { OpenClawPluginApi } from 'openclaw/plugin-sdk/plugin-entry';
2
7
 
3
8
  export interface PierAccountConfig {