@gholl-studio/pier-connector 0.3.15 → 0.3.16
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/inbound.ts +32 -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.3.
|
|
4
|
+
"version": "0.3.16",
|
|
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.ts",
|
package/src/inbound.ts
CHANGED
|
@@ -24,20 +24,20 @@ export async function handleInbound(
|
|
|
24
24
|
const agentIds = Array.isArray(agentsList) ? agentsList.map((a: any) => a.id) : Object.keys(agentsList);
|
|
25
25
|
logger.info(`[pier-connector][${robot.accountId}] Available agents in OpenClaw: ${JSON.stringify(agentIds)}`);
|
|
26
26
|
|
|
27
|
-
// 1. Resolve Account-Scoped Configuration
|
|
27
|
+
// 1. Resolve Account-Scoped Configuration (Standard Nested Structure)
|
|
28
28
|
const rootConfig = api.config || {};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* ★ Multi-Account Configuration Isolation: Build account-level ClawdbotConfig
|
|
32
|
-
*
|
|
33
|
-
* In multi-account scenarios, each account can have independent agent bindings.
|
|
34
|
-
* The SDK's resolveAgentRoute looks into cfg.channels.pier.
|
|
35
|
-
* By injecting the current robot's config here, we ensure the SDK finds
|
|
36
|
-
* the correct agentId for this specific account.
|
|
37
|
-
*/
|
|
38
29
|
const accountScopedCfg = {
|
|
39
30
|
...rootConfig,
|
|
40
|
-
channels: {
|
|
31
|
+
channels: {
|
|
32
|
+
...rootConfig.channels,
|
|
33
|
+
pier: {
|
|
34
|
+
...(rootConfig.channels?.pier || {}),
|
|
35
|
+
accounts: {
|
|
36
|
+
...(rootConfig.channels?.pier?.accounts || {}),
|
|
37
|
+
[robot.accountId]: robot.config
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// 2. Resolve Agent Route via SDK with Scoped Config
|
|
@@ -52,6 +52,14 @@ export async function handleInbound(
|
|
|
52
52
|
const routingSource = route.agentId ? 'sdk-scoped-route' : 'sdk-default-fallback';
|
|
53
53
|
|
|
54
54
|
logger.info(`[pier-connector] Routing account '${inbound.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
|
|
55
|
+
|
|
56
|
+
// Debug: Check Agent Identity
|
|
57
|
+
try {
|
|
58
|
+
const identity = (api.runtime as any).agent.resolveAgentIdentity(finalAgentId);
|
|
59
|
+
logger.info(`[pier-connector:debug] Identity resolution for ${finalAgentId}: ${JSON.stringify(identity)}`);
|
|
60
|
+
} catch (err: any) {
|
|
61
|
+
logger.warn(`[pier-connector:debug] Identity resolution failed for ${finalAgentId}: ${err.message}`);
|
|
62
|
+
}
|
|
55
63
|
|
|
56
64
|
const dynamicSessionKey = `pier-job-${jobId}`;
|
|
57
65
|
const metadata = robot.activeNodeJobs.get(jobId);
|
|
@@ -116,9 +124,11 @@ export async function handleInbound(
|
|
|
116
124
|
const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
|
|
117
125
|
deliver: async (payload: any, info: any) => {
|
|
118
126
|
const currentMeta = robot.activeNodeJobs.get(jobId);
|
|
119
|
-
const respondingAgent = payload.
|
|
127
|
+
const respondingAgent = payload.agentId || payload.btw?.agentId || payload.channelData?.agentId || 'unknown';
|
|
120
128
|
|
|
121
|
-
logger.info(`[pier-connector:trace] Outbound delivery triggered for job ${jobId}. Type: ${info?.kind}. Responding Agent: ${respondingAgent}
|
|
129
|
+
logger.info(`[pier-connector:trace] Outbound delivery triggered for job ${jobId}. Type: ${info?.kind}. Responding Agent: ${respondingAgent}.`);
|
|
130
|
+
logger.info(`[pier-connector:debug] FULL PAYLOAD: ${JSON.stringify(payload)}`);
|
|
131
|
+
|
|
122
132
|
if (payload.text && payload.text.length > 0) {
|
|
123
133
|
await pierChannel.outbound.sendText({
|
|
124
134
|
text: payload.text,
|
|
@@ -149,8 +159,15 @@ export async function handleInbound(
|
|
|
149
159
|
try {
|
|
150
160
|
logger.info(`[pier-connector:trace] Dispatching reply to agent ${finalAgentId}...`);
|
|
151
161
|
await api.runtime.channel.reply.dispatchReplyFromConfig({
|
|
152
|
-
ctx: ctxPayload,
|
|
153
|
-
|
|
162
|
+
ctx: ctxPayload,
|
|
163
|
+
cfg: accountScopedCfg,
|
|
164
|
+
dispatcher,
|
|
165
|
+
replyOptions: {
|
|
166
|
+
onModelSelected: (mCtx: any) => {
|
|
167
|
+
logger.info(`[pier-connector:debug] Model selected for ${jobId}: ${mCtx.provider}/${mCtx.model} (Think: ${mCtx.thinkLevel})`);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} as any);
|
|
154
171
|
logger.info(`[pier-connector:trace] dispatchReplyFromConfig completed for job ${jobId}`);
|
|
155
172
|
} catch (err: any) {
|
|
156
173
|
logger.error(`[pier-connector] ✖ Dispatch error for job ${jobId}: ${err.message}`);
|