@gholl-studio/pier-connector 0.2.18 → 0.2.20

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/index.js +44 -15
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.18",
4
+ "version": "0.2.20",
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
@@ -189,16 +189,32 @@ export default function register(api) {
189
189
  });
190
190
 
191
191
  const dynamicSessionKey = `pier-job-${jobId}`;
192
- const injectedPrompt = [
193
- "=========================================",
194
- "CRITICAL DIRECTIVE - PIER TRADING NETWORK",
195
- "=========================================",
196
- "You are an autonomous AI worker on Pier.",
197
- "1. You MUST USE the `pier_finish_task` tool to submit the final result when your work is complete.",
198
- "2. If you need to negotiate or clarify requirements with the employer, use `pier_chat`.",
199
- "3. Do not just wait in silence. Always officially finish the task if the employer's goal is met.",
200
- inbound.systemPrompt ? `\nEmployer Guidelines:\n${inbound.systemPrompt}` : ""
201
- ].join('\n');
192
+ const metadata = activeNodeJobs.get(jobId);
193
+ let injectedPrompt = "";
194
+
195
+ if (metadata && metadata.isTargeted === false) {
196
+ injectedPrompt = [
197
+ "=========================================",
198
+ "CRITICAL DIRECTIVE - OPEN BIDDING MARKETPLACE",
199
+ "=========================================",
200
+ "You are an autonomous AI worker on Pier. This job currently has NO assigned worker.",
201
+ "1. DO NOT directly solve the user's task or output the final answer right now.",
202
+ "2. You MUST USE the `pier_bid_task` tool to send a pitch/bid to the employer explaining why you are best equipped to solve this, and state your price.",
203
+ "3. Stop executing after submitting the bid.",
204
+ inbound.systemPrompt ? `\nEmployer Guidelines:\n${inbound.systemPrompt}` : ""
205
+ ].join('\n');
206
+ } else {
207
+ injectedPrompt = [
208
+ "=========================================",
209
+ "CRITICAL DIRECTIVE - PIER TRADING NETWORK",
210
+ "=========================================",
211
+ "You are an autonomous AI worker on Pier.",
212
+ "1. You MUST USE the `pier_finish_task` tool to submit the final result when your work is complete.",
213
+ "2. If you need to negotiate or clarify requirements with the employer, use `pier_chat`.",
214
+ "3. Do not just wait in silence. Always officially finish the task if the employer's goal is met.",
215
+ inbound.systemPrompt ? `\nEmployer Guidelines:\n${inbound.systemPrompt}` : ""
216
+ ].join('\n');
217
+ }
202
218
 
203
219
  const ctxPayload = api.runtime.channel.reply.finalizeInboundContext({
204
220
  Body: inbound.text,
@@ -363,7 +379,7 @@ export default function register(api) {
363
379
  sender_id: config.nodeId || 'anonymous',
364
380
  sender_type: 'node',
365
381
  content: text,
366
- timestamp: new Date().toISOString(),
382
+ created_at: new Date().toISOString(),
367
383
  auth_token: config.secretKey // Secure token for backend validation
368
384
  };
369
385
 
@@ -870,13 +886,26 @@ export default function register(api) {
870
886
  pierNatsMsg: msg,
871
887
  pierStartTime: performance.now(),
872
888
  pierMeta: job.meta,
873
- isRealtimeMsg: false
889
+ isRealtimeMsg: false,
890
+ isTargeted: isTargeted
874
891
  });
875
892
 
893
+ let finalText = job.task;
894
+ if (!isTargeted) {
895
+ finalText = `【PIER MARKETPLACE OPEN JOB】
896
+ Task description:
897
+ ${job.task}
898
+
899
+ === CRITICAL WARNING ===
900
+ You MUST NOT execute or solve this task directly! This is a public request for proposals.
901
+ You MUST reply by calling the \`pier_bid_task\` tool to submit a pitch explaining why you are best suited, and optionally your price.
902
+ Any direct answer will be considered a failure to follow protocol.`;
903
+ }
904
+
876
905
  const inbound = {
877
906
  accountId: config.accountId || 'default',
878
907
  senderId: `pier:${senderCore}`,
879
- text: job.task,
908
+ text: finalText,
880
909
  };
881
910
 
882
911
  // SUBSCRIBE to job-specific messages FIRST so we don't miss follow-ups
@@ -1076,7 +1105,7 @@ export default function register(api) {
1076
1105
  sender_id: config.nodeId,
1077
1106
  sender_type: 'node',
1078
1107
  content: params.text,
1079
- timestamp: new Date().toISOString(),
1108
+ created_at: new Date().toISOString(),
1080
1109
  auth_token: config.secretKey // Secure token for backend validation
1081
1110
  };
1082
1111
 
@@ -1127,7 +1156,7 @@ export default function register(api) {
1127
1156
  action,
1128
1157
  payload
1129
1158
  }),
1130
- timestamp: new Date().toISOString(),
1159
+ created_at: new Date().toISOString(),
1131
1160
  auth_token: config.secretKey, // auth handle in DB needs updating for user role simulation
1132
1161
  type: 'system_action',
1133
1162
  action: action