@gholl-studio/pier-connector 0.2.35 → 0.2.37
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 +1 -1
- package/src/index.js +36 -2
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.
|
|
4
|
+
"version": "0.2.37",
|
|
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
|
@@ -49,10 +49,17 @@ export default function register(api) {
|
|
|
49
49
|
}];
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
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) {
|
|
@@ -161,6 +168,33 @@ export default function register(api) {
|
|
|
161
168
|
peer: { kind: 'direct', id: jobId }
|
|
162
169
|
});
|
|
163
170
|
|
|
171
|
+
// Smart Fallback Strategy:
|
|
172
|
+
// 1. Explicit account-level agentId
|
|
173
|
+
// 2. Global bindings from openclaw.json
|
|
174
|
+
// 3. Exact name match (account ID == agent ID)
|
|
175
|
+
// 4. Default routing
|
|
176
|
+
let finalAgentId = this.config.agentId;
|
|
177
|
+
let routingSource = 'account-config';
|
|
178
|
+
|
|
179
|
+
if (!finalAgentId && route.agentId && route.agentId !== 'main' && route.agentId !== 'default') {
|
|
180
|
+
finalAgentId = route.agentId;
|
|
181
|
+
routingSource = 'global-bindings';
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (!finalAgentId) {
|
|
185
|
+
// Check if accountId matches an existing agent slug/ID
|
|
186
|
+
const agents = (api.runtime && typeof api.runtime.getAgents === 'function') ? await api.runtime.getAgents() : {};
|
|
187
|
+
if (agents && agents[inbound.accountId]) {
|
|
188
|
+
finalAgentId = inbound.accountId;
|
|
189
|
+
routingSource = 'name-match-fallback';
|
|
190
|
+
} else {
|
|
191
|
+
finalAgentId = route.agentId || 'main'; // Ultimate fallback
|
|
192
|
+
routingSource = route.agentId ? 'global-bindings-fallback' : 'default-routing';
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
|
|
197
|
+
|
|
164
198
|
const dynamicSessionKey = `pier-job-${jobId}`;
|
|
165
199
|
const metadata = this.activeNodeJobs.get(jobId);
|
|
166
200
|
let injectedPrompt = "";
|
|
@@ -218,7 +252,7 @@ export default function register(api) {
|
|
|
218
252
|
|
|
219
253
|
const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
|
|
220
254
|
cfg: api.runtime.config,
|
|
221
|
-
agentId:
|
|
255
|
+
agentId: finalAgentId,
|
|
222
256
|
deliver: async (payload) => {
|
|
223
257
|
const currentMeta = this.activeNodeJobs.get(jobId);
|
|
224
258
|
await pierChannel.outbound.sendText({
|