@gholl-studio/pier-connector 0.2.44 → 0.2.46
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 +35 -23
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.46",
|
|
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
|
@@ -172,39 +172,51 @@ export default function register(api) {
|
|
|
172
172
|
|
|
173
173
|
logger.info(`[pier-connector:trace] resolveAgentRoute returned: route.agentId='${route?.agentId}', route.accountId='${route?.accountId}'`);
|
|
174
174
|
|
|
175
|
-
//
|
|
176
|
-
// 1. Explicit account-level agentId
|
|
177
|
-
// 2. Global bindings from openclaw.json
|
|
178
|
-
// 3. Exact name match (account ID == agent ID)
|
|
179
|
-
// 4. Default routing
|
|
175
|
+
// 1. Explicit account-level agentId from plugin config (if still used)
|
|
180
176
|
let finalAgentId = this.config.agentId;
|
|
181
177
|
let routingSource = 'account-config';
|
|
182
178
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
// 2. Robust manual parse (safeguard against OpenClaw core parsing bugs)
|
|
180
|
+
if (!finalAgentId && api.runtime?.config) {
|
|
181
|
+
const cfg = api.runtime.config;
|
|
182
|
+
const bs = Array.isArray(cfg.bindings) ? cfg.bindings : [];
|
|
183
|
+
const al = Array.isArray(cfg.agents?.list) ? cfg.agents.list : [];
|
|
184
|
+
|
|
185
|
+
logger.info(`[pier-connector:trace] Manual debug: bindings_count=${bs.length}, agents_count=${al.length}`);
|
|
187
186
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
187
|
+
// Check bindings
|
|
188
|
+
const manualBinding = bs.find(b =>
|
|
189
|
+
b.match?.channel === 'pier' &&
|
|
190
|
+
(b.match?.accountId === inbound.accountId || b.match?.account === inbound.accountId)
|
|
191
|
+
);
|
|
192
192
|
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
isAgentValid = !!rawAgents[inbound.accountId];
|
|
193
|
+
if (manualBinding && manualBinding.agentId && manualBinding.agentId !== 'main') {
|
|
194
|
+
finalAgentId = manualBinding.agentId;
|
|
195
|
+
routingSource = 'manual-global-bindings';
|
|
197
196
|
}
|
|
198
197
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
198
|
+
// Check agent list for name match (account ID == agent ID)
|
|
199
|
+
if (!finalAgentId) {
|
|
200
|
+
const nameMatch = al.find(a => a.id === inbound.accountId);
|
|
201
|
+
if (nameMatch) {
|
|
202
|
+
finalAgentId = inbound.accountId;
|
|
203
|
+
routingSource = 'manual-name-match';
|
|
204
|
+
}
|
|
205
205
|
}
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
// 3. Fallback to OpenClaw's resolveAgentRoute (only if still unresolved and not 'main')
|
|
209
|
+
if (!finalAgentId && route.agentId && route.agentId !== 'main' && route.agentId !== 'default') {
|
|
210
|
+
finalAgentId = route.agentId;
|
|
211
|
+
routingSource = 'sdk-global-bindings';
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// 4. Ultimate default
|
|
215
|
+
if (!finalAgentId) {
|
|
216
|
+
finalAgentId = route.agentId || 'main'; // Ultimate fallback
|
|
217
|
+
routingSource = route.agentId ? 'global-bindings-fallback' : 'default-routing';
|
|
218
|
+
}
|
|
219
|
+
|
|
208
220
|
logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
|
|
209
221
|
|
|
210
222
|
const dynamicSessionKey = `pier-job-${jobId}`;
|