@gholl-studio/pier-connector 0.3.13 → 0.3.15
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 +26 -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.3.
|
|
4
|
+
"version": "0.3.15",
|
|
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
|
@@ -19,6 +19,11 @@ export async function handleInbound(
|
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// 0. Log Online/Configured Agents
|
|
23
|
+
const agentsList = (api.config as any)?.agents?.list || [];
|
|
24
|
+
const agentIds = Array.isArray(agentsList) ? agentsList.map((a: any) => a.id) : Object.keys(agentsList);
|
|
25
|
+
logger.info(`[pier-connector][${robot.accountId}] Available agents in OpenClaw: ${JSON.stringify(agentIds)}`);
|
|
26
|
+
|
|
22
27
|
// 1. Resolve Account-Scoped Configuration
|
|
23
28
|
const rootConfig = api.config || {};
|
|
24
29
|
|
|
@@ -79,28 +84,27 @@ export async function handleInbound(
|
|
|
79
84
|
logger.info(`[pier-connector:trace] Finalized inbound context for job ${jobId}. Target Agent: ${finalAgentId}, Session: ${dynamicSessionKey}`);
|
|
80
85
|
|
|
81
86
|
const ctxPayload = api.runtime.channel.reply.finalizeInboundContext({
|
|
82
|
-
AgentId: finalAgentId,
|
|
83
|
-
agentId: finalAgentId, // Redundant for compatibility
|
|
84
87
|
Body: inbound.body,
|
|
85
88
|
BodyForAgent: inbound.body,
|
|
86
89
|
RawBody: inbound.body,
|
|
87
90
|
From: inbound.senderId,
|
|
88
|
-
To: `
|
|
91
|
+
To: `chat:${jobId}`,
|
|
89
92
|
SessionKey: dynamicSessionKey,
|
|
90
93
|
AccountId: inbound.accountId,
|
|
91
94
|
ChatType: 'direct',
|
|
92
95
|
SenderId: inbound.senderId,
|
|
96
|
+
SenderName: robot.accountId,
|
|
93
97
|
Provider: 'pier',
|
|
94
98
|
Surface: 'pier',
|
|
95
99
|
OriginatingChannel: 'pier',
|
|
96
|
-
OriginatingTo: `
|
|
100
|
+
OriginatingTo: `chat:${jobId}`,
|
|
97
101
|
WasMentioned: true,
|
|
98
102
|
CommandAuthorized: true,
|
|
99
103
|
SystemPrompt: injectedPrompt,
|
|
100
104
|
MessageId: jobId,
|
|
105
|
+
MessageSid: jobId,
|
|
101
106
|
Metadata: {
|
|
102
107
|
...metadata,
|
|
103
|
-
agentId: finalAgentId, // Pinning in metadata
|
|
104
108
|
accountId: robot.accountId,
|
|
105
109
|
pierJobId: jobId,
|
|
106
110
|
routingSource: routingSource
|
|
@@ -110,18 +114,23 @@ export async function handleInbound(
|
|
|
110
114
|
logger.info(`[pier-connector:trace] FULL DISPATCH CONTEXT for job ${jobId}: ${JSON.stringify(ctxPayload)}`);
|
|
111
115
|
|
|
112
116
|
const { dispatcher, markDispatchIdle } = api.runtime.channel.reply.createReplyDispatcherWithTyping({
|
|
113
|
-
deliver: async (payload: any) => {
|
|
117
|
+
deliver: async (payload: any, info: any) => {
|
|
114
118
|
const currentMeta = robot.activeNodeJobs.get(jobId);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
const respondingAgent = payload.channelData?.agentId || payload.agentId || 'unknown';
|
|
120
|
+
|
|
121
|
+
logger.info(`[pier-connector:trace] Outbound delivery triggered for job ${jobId}. Type: ${info?.kind}. Responding Agent: ${respondingAgent}. Text length: ${payload.text?.length || 0}`);
|
|
122
|
+
if (payload.text && payload.text.length > 0) {
|
|
123
|
+
await pierChannel.outbound.sendText({
|
|
124
|
+
text: payload.text,
|
|
125
|
+
to: `pier:${jobId}`,
|
|
126
|
+
metadata: {
|
|
127
|
+
...currentMeta,
|
|
128
|
+
accountId: robot.accountId,
|
|
129
|
+
pierJobId: jobId,
|
|
130
|
+
respondingAgentId: respondingAgent
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
}
|
|
125
134
|
}
|
|
126
135
|
});
|
|
127
136
|
|
|
@@ -140,7 +149,7 @@ export async function handleInbound(
|
|
|
140
149
|
try {
|
|
141
150
|
logger.info(`[pier-connector:trace] Dispatching reply to agent ${finalAgentId}...`);
|
|
142
151
|
await api.runtime.channel.reply.dispatchReplyFromConfig({
|
|
143
|
-
ctx: ctxPayload, cfg:
|
|
152
|
+
ctx: ctxPayload, cfg: accountScopedCfg, dispatcher
|
|
144
153
|
});
|
|
145
154
|
logger.info(`[pier-connector:trace] dispatchReplyFromConfig completed for job ${jobId}`);
|
|
146
155
|
} catch (err: any) {
|