@gholl-studio/pier-connector 0.2.45 → 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 +26 -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.
|
|
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,38 +172,49 @@ 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
|
-
// Robust Fallback Strategy:
|
|
176
175
|
// 1. Explicit account-level agentId from plugin config (if still used)
|
|
177
176
|
let finalAgentId = this.config.agentId;
|
|
178
177
|
let routingSource = 'account-config';
|
|
179
178
|
|
|
180
|
-
// 2.
|
|
181
|
-
if (!finalAgentId && api.runtime?.config
|
|
182
|
-
const
|
|
183
|
-
|
|
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}`);
|
|
186
|
+
|
|
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)
|
|
184
191
|
);
|
|
192
|
+
|
|
185
193
|
if (manualBinding && manualBinding.agentId && manualBinding.agentId !== 'main') {
|
|
186
194
|
finalAgentId = manualBinding.agentId;
|
|
187
195
|
routingSource = 'manual-global-bindings';
|
|
188
196
|
}
|
|
197
|
+
|
|
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
|
+
}
|
|
189
206
|
}
|
|
190
207
|
|
|
191
|
-
// 3. Fallback to OpenClaw's resolveAgentRoute (if
|
|
208
|
+
// 3. Fallback to OpenClaw's resolveAgentRoute (only if still unresolved and not 'main')
|
|
192
209
|
if (!finalAgentId && route.agentId && route.agentId !== 'main' && route.agentId !== 'default') {
|
|
193
210
|
finalAgentId = route.agentId;
|
|
194
211
|
routingSource = 'sdk-global-bindings';
|
|
195
212
|
}
|
|
196
213
|
|
|
197
|
-
// 4.
|
|
214
|
+
// 4. Ultimate default
|
|
198
215
|
if (!finalAgentId) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
finalAgentId = inbound.accountId;
|
|
202
|
-
routingSource = 'name-match-fallback';
|
|
203
|
-
} else {
|
|
204
|
-
finalAgentId = route.agentId || 'main'; // Ultimate fallback
|
|
205
|
-
routingSource = route.agentId ? 'global-bindings-fallback' : 'default-routing';
|
|
206
|
-
}
|
|
216
|
+
finalAgentId = route.agentId || 'main'; // Ultimate fallback
|
|
217
|
+
routingSource = route.agentId ? 'global-bindings-fallback' : 'default-routing';
|
|
207
218
|
}
|
|
208
219
|
|
|
209
220
|
logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
|