@gholl-studio/pier-connector 0.2.44 → 0.2.45
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 +18 -17
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.45",
|
|
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,31 +172,32 @@ 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
|
+
// Robust Fallback Strategy:
|
|
176
|
+
// 1. Explicit account-level agentId from plugin config (if still used)
|
|
180
177
|
let finalAgentId = this.config.agentId;
|
|
181
178
|
let routingSource = 'account-config';
|
|
182
179
|
|
|
180
|
+
// 2. Manually parse global bindings (safeguard against OpenClaw core parsing bugs)
|
|
181
|
+
if (!finalAgentId && api.runtime?.config?.bindings) {
|
|
182
|
+
const manualBinding = api.runtime.config.bindings.find(b =>
|
|
183
|
+
b.match?.channel === 'pier' && b.match?.accountId === inbound.accountId
|
|
184
|
+
);
|
|
185
|
+
if (manualBinding && manualBinding.agentId && manualBinding.agentId !== 'main') {
|
|
186
|
+
finalAgentId = manualBinding.agentId;
|
|
187
|
+
routingSource = 'manual-global-bindings';
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// 3. Fallback to OpenClaw's resolveAgentRoute (if manual parse didn't hit and it's not main)
|
|
183
192
|
if (!finalAgentId && route.agentId && route.agentId !== 'main' && route.agentId !== 'default') {
|
|
184
193
|
finalAgentId = route.agentId;
|
|
185
|
-
routingSource = 'global-bindings';
|
|
194
|
+
routingSource = 'sdk-global-bindings';
|
|
186
195
|
}
|
|
187
196
|
|
|
197
|
+
// 4. Exact name match (account ID == agent ID) by checking config directly
|
|
188
198
|
if (!finalAgentId) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
let isAgentValid = false;
|
|
192
|
-
|
|
193
|
-
if (Array.isArray(rawAgents)) {
|
|
194
|
-
isAgentValid = !!rawAgents.find(a => a.id === inbound.accountId);
|
|
195
|
-
} else if (rawAgents && typeof rawAgents === 'object') {
|
|
196
|
-
isAgentValid = !!rawAgents[inbound.accountId];
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (isAgentValid) {
|
|
199
|
+
const rawAgentsList = api.runtime?.config?.agents?.list;
|
|
200
|
+
if (Array.isArray(rawAgentsList) && rawAgentsList.find(a => a.id === inbound.accountId)) {
|
|
200
201
|
finalAgentId = inbound.accountId;
|
|
201
202
|
routingSource = 'name-match-fallback';
|
|
202
203
|
} else {
|