@gholl-studio/pier-connector 0.3.16 → 0.3.18
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 +38 -20
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.18",
|
|
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,19 +24,19 @@ 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 (Flat Structure for SDK)
|
|
28
|
+
/**
|
|
29
|
+
* ★ Multi-Account Configuration Isolation:
|
|
30
|
+
* SDK helpers like resolveAgentRoute expect the channel config at the top level
|
|
31
|
+
* of cfg.channels.<channelName>. Replacing it with the robot's merged config
|
|
32
|
+
* ensures the SDK sees the correct agentId/dmPolicy for this specific account.
|
|
33
|
+
*/
|
|
28
34
|
const rootConfig = api.config || {};
|
|
29
35
|
const accountScopedCfg = {
|
|
30
36
|
...rootConfig,
|
|
31
37
|
channels: {
|
|
32
38
|
...rootConfig.channels,
|
|
33
|
-
pier:
|
|
34
|
-
...(rootConfig.channels?.pier || {}),
|
|
35
|
-
accounts: {
|
|
36
|
-
...(rootConfig.channels?.pier?.accounts || {}),
|
|
37
|
-
[robot.accountId]: robot.config
|
|
38
|
-
}
|
|
39
|
-
}
|
|
39
|
+
pier: robot.config
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
@@ -44,21 +44,37 @@ export async function handleInbound(
|
|
|
44
44
|
const route = api.runtime.channel.routing.resolveAgentRoute({
|
|
45
45
|
cfg: accountScopedCfg,
|
|
46
46
|
channel: 'pier',
|
|
47
|
-
accountId:
|
|
47
|
+
accountId: robot.accountId,
|
|
48
48
|
peer: { kind: 'direct', id: jobId }
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
const finalAgentId = route.agentId || 'main';
|
|
52
52
|
const routingSource = route.agentId ? 'sdk-scoped-route' : 'sdk-default-fallback';
|
|
53
53
|
|
|
54
|
-
logger.info(`[pier-connector] Routing account '${
|
|
54
|
+
logger.info(`[pier-connector] Routing account '${robot.accountId}' -> agent '${finalAgentId}' (Source: ${routingSource})`);
|
|
55
55
|
|
|
56
|
-
// Debug: Check Agent Identity
|
|
56
|
+
// Debug: Check Agent Identity & Detailed Config
|
|
57
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)}`);
|
|
58
|
+
const identity = (api.runtime as any).agent.resolveAgentIdentity(accountScopedCfg, finalAgentId);
|
|
59
|
+
logger.info(`[pier-connector:debug] Identity resolution [0.3.18] for ${finalAgentId}: ${JSON.stringify(identity)}`);
|
|
60
|
+
|
|
61
|
+
// Deep Config Inspection
|
|
62
|
+
const agentsList = (accountScopedCfg as any)?.agents?.list || [];
|
|
63
|
+
const targetedAgent = agentsList.find((a: any) => a.id === finalAgentId);
|
|
64
|
+
if (targetedAgent) {
|
|
65
|
+
logger.info(`[pier-connector:debug] FULL AGENT CONFIG for ${finalAgentId}: ${JSON.stringify({
|
|
66
|
+
id: targetedAgent.id,
|
|
67
|
+
name: targetedAgent.name,
|
|
68
|
+
agentDir: targetedAgent.agentDir,
|
|
69
|
+
workspace: targetedAgent.workspace,
|
|
70
|
+
runtime: targetedAgent.runtime,
|
|
71
|
+
model: targetedAgent.model
|
|
72
|
+
})}`);
|
|
73
|
+
} else {
|
|
74
|
+
logger.warn(`[pier-connector:debug] Agent ${finalAgentId} NOT FOUND in agents.list of scoped config!`);
|
|
75
|
+
}
|
|
60
76
|
} catch (err: any) {
|
|
61
|
-
logger.warn(`[pier-connector:debug] Identity resolution
|
|
77
|
+
logger.warn(`[pier-connector:debug] Identity resolution crash for ${finalAgentId}: ${err.message}`);
|
|
62
78
|
}
|
|
63
79
|
|
|
64
80
|
const dynamicSessionKey = `pier-job-${jobId}`;
|
|
@@ -95,13 +111,13 @@ export async function handleInbound(
|
|
|
95
111
|
Body: inbound.body,
|
|
96
112
|
BodyForAgent: inbound.body,
|
|
97
113
|
RawBody: inbound.body,
|
|
98
|
-
From: inbound.senderId,
|
|
114
|
+
From: inbound.senderId, // Fix: senderId already includes "pier:" prefix
|
|
99
115
|
To: `chat:${jobId}`,
|
|
100
116
|
SessionKey: dynamicSessionKey,
|
|
101
|
-
AccountId:
|
|
117
|
+
AccountId: robot.accountId,
|
|
102
118
|
ChatType: 'direct',
|
|
103
119
|
SenderId: inbound.senderId,
|
|
104
|
-
SenderName:
|
|
120
|
+
SenderName: inbound.senderId, // Use senderId as name if unknown
|
|
105
121
|
Provider: 'pier',
|
|
106
122
|
Surface: 'pier',
|
|
107
123
|
OriginatingChannel: 'pier',
|
|
@@ -114,6 +130,7 @@ export async function handleInbound(
|
|
|
114
130
|
Metadata: {
|
|
115
131
|
...metadata,
|
|
116
132
|
accountId: robot.accountId,
|
|
133
|
+
agentId: finalAgentId, // Explicitly tell SDK which agent we want
|
|
117
134
|
pierJobId: jobId,
|
|
118
135
|
routingSource: routingSource
|
|
119
136
|
}
|
|
@@ -124,9 +141,10 @@ export async function handleInbound(
|
|
|
124
141
|
const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
|
|
125
142
|
deliver: async (payload: any, info: any) => {
|
|
126
143
|
const currentMeta = robot.activeNodeJobs.get(jobId);
|
|
127
|
-
const
|
|
144
|
+
const rawResponder = payload.agentId || payload.btw?.agentId || payload.channelData?.agentId;
|
|
145
|
+
const resAgent = rawResponder || finalAgentId;
|
|
128
146
|
|
|
129
|
-
logger.info(`[pier-connector:trace] Outbound delivery
|
|
147
|
+
logger.info(`[pier-connector:trace] Outbound delivery for ${jobId}. Mode: ${info?.kind}. Responder: ${resAgent} (Raw: ${rawResponder || 'none'}).`);
|
|
130
148
|
logger.info(`[pier-connector:debug] FULL PAYLOAD: ${JSON.stringify(payload)}`);
|
|
131
149
|
|
|
132
150
|
if (payload.text && payload.text.length > 0) {
|
|
@@ -137,7 +155,7 @@ export async function handleInbound(
|
|
|
137
155
|
...currentMeta,
|
|
138
156
|
accountId: robot.accountId,
|
|
139
157
|
pierJobId: jobId,
|
|
140
|
-
respondingAgentId:
|
|
158
|
+
respondingAgentId: resAgent
|
|
141
159
|
},
|
|
142
160
|
});
|
|
143
161
|
}
|