openclaw-remote 0.5.1 → 0.5.2
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/dist/index.js +43 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3007,50 +3007,51 @@ function createRemotePlugin() {
|
|
|
3007
3007
|
log?.info?.(`Webhook received: ${payload.event} for task ${payload.task_id} (agent: ${payload.agent_name})`);
|
|
3008
3008
|
const body = formatWebhookEvent(payload);
|
|
3009
3009
|
const sessionKey = `remote:${account.accountId}:${payload.task_id}`;
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3010
|
+
(async () => {
|
|
3011
|
+
try {
|
|
3012
|
+
const rt = getRemoteRuntime();
|
|
3013
|
+
const currentCfg = await rt.config.loadConfig();
|
|
3014
|
+
const msgCtx = rt.channel.reply.finalizeInboundContext({
|
|
3015
|
+
Body: body,
|
|
3016
|
+
RawBody: body,
|
|
3017
|
+
CommandBody: body,
|
|
3018
|
+
From: `remote:${payload.task_id}`,
|
|
3019
|
+
To: `remote:${account.accountId}`,
|
|
3020
|
+
SessionKey: sessionKey,
|
|
3021
|
+
AccountId: account.accountId,
|
|
3022
|
+
OriginatingChannel: CHANNEL_ID,
|
|
3023
|
+
OriginatingTo: `remote:${payload.task_id}`,
|
|
3024
|
+
ChatType: "direct",
|
|
3025
|
+
SenderName: payload.author_name || "Remote Board",
|
|
3026
|
+
SenderId: payload.task_id,
|
|
3027
|
+
Provider: CHANNEL_ID,
|
|
3028
|
+
Surface: CHANNEL_ID,
|
|
3029
|
+
ConversationLabel: payload.task_title || `Task ${payload.task_id}`,
|
|
3030
|
+
Timestamp: Date.now()
|
|
3031
|
+
});
|
|
3032
|
+
await rt.channel.reply.dispatchReplyWithBufferedBlockDispatcher({
|
|
3033
|
+
ctx: msgCtx,
|
|
3034
|
+
cfg: currentCfg,
|
|
3035
|
+
dispatcherOptions: {
|
|
3036
|
+
deliver: async (deliverPayload) => {
|
|
3037
|
+
if (deliverPayload.isReasoning) return;
|
|
3038
|
+
const text = deliverPayload?.text ?? deliverPayload?.body;
|
|
3039
|
+
if (text) {
|
|
3040
|
+
await postComment(account, payload.task_id, text);
|
|
3041
|
+
}
|
|
3042
|
+
},
|
|
3043
|
+
onReplyStart: () => {
|
|
3044
|
+
log?.info?.(`Agent reply started for task ${payload.task_id}`);
|
|
3040
3045
|
}
|
|
3041
|
-
},
|
|
3042
|
-
onReplyStart: () => {
|
|
3043
|
-
log?.info?.(`Agent reply started for task ${payload.task_id}`);
|
|
3044
3046
|
}
|
|
3045
|
-
}
|
|
3046
|
-
})
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
}
|
|
3053
|
-
return { status: 200, body: { ok: true } };
|
|
3047
|
+
});
|
|
3048
|
+
} catch (err) {
|
|
3049
|
+
log?.error?.(
|
|
3050
|
+
`Error dispatching webhook event: ${err instanceof Error ? err.message : String(err)}`
|
|
3051
|
+
);
|
|
3052
|
+
}
|
|
3053
|
+
})();
|
|
3054
|
+
return { status: 200, body: { ok: true, event: payload.event } };
|
|
3054
3055
|
};
|
|
3055
3056
|
const routeKey = `${accountId}:${account.webhookPath}`;
|
|
3056
3057
|
const prevUnregister = activeRouteUnregisters.get(routeKey);
|