@efengx/openclaw-channel-dragon 0.2.0 → 0.3.0
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 +19 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -69,9 +69,9 @@ async function startPolling(ctx) {
|
|
|
69
69
|
}
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const deliverToOpenClaw = async (content, sessionId = 'default', modelId) => {
|
|
72
|
+
const deliverToOpenClaw = async (content, sessionId = 'default', modelId, attachments) => {
|
|
73
73
|
const msg = String(content || '').trim();
|
|
74
|
-
if (!msg)
|
|
74
|
+
if (!msg && (!attachments || attachments.length === 0))
|
|
75
75
|
return;
|
|
76
76
|
// sessionKey format: channel:agentId:direct:peerId
|
|
77
77
|
// peerId can be the sessionId for multi-session support
|
|
@@ -96,7 +96,16 @@ async function startPolling(ctx) {
|
|
|
96
96
|
CommandAuthorized: true,
|
|
97
97
|
Timestamp: Date.now(),
|
|
98
98
|
Model: modelId,
|
|
99
|
+
Attachments: attachments, // Pass raw attachments for reference
|
|
99
100
|
},
|
|
101
|
+
// Building OpenClaw-native multi-modal blocks if images are present
|
|
102
|
+
customBlocks: (attachments || [])
|
|
103
|
+
.filter((a) => a.type === 'image')
|
|
104
|
+
.map((a) => ({
|
|
105
|
+
kind: 'image',
|
|
106
|
+
data: a.data, // Should be base64 or URL
|
|
107
|
+
mime: a.mime || 'image/png'
|
|
108
|
+
})),
|
|
100
109
|
cfg: ctx.cfg,
|
|
101
110
|
dispatcherOptions: {
|
|
102
111
|
deliver: async (payload) => {
|
|
@@ -147,9 +156,10 @@ async function startPolling(ctx) {
|
|
|
147
156
|
const connectOnce = async () => {
|
|
148
157
|
const sseUrl = `${orchestratorUrl}/api/agents/events`;
|
|
149
158
|
const handleSseText = async (chunkText, bufRef) => {
|
|
150
|
-
// Diagnostic: log first chunk of SSE
|
|
151
|
-
|
|
152
|
-
|
|
159
|
+
// Diagnostic: log first chunk of SSE if it's not a heartbeat comment
|
|
160
|
+
const isHeartbeat = chunkText.trim().startsWith(':');
|
|
161
|
+
if (!bufRef.buf && chunkText.trim() && !isHeartbeat) {
|
|
162
|
+
logger?.info?.(`dragon channel: SSE received first message chunk (len=${chunkText.length})`);
|
|
153
163
|
}
|
|
154
164
|
bufRef.buf += chunkText;
|
|
155
165
|
let idx;
|
|
@@ -170,8 +180,10 @@ async function startPolling(ctx) {
|
|
|
170
180
|
if (!evt || evt.agentId !== agentId)
|
|
171
181
|
continue;
|
|
172
182
|
if (evt.type === 'WORKBENCH_MESSAGE') {
|
|
173
|
-
|
|
174
|
-
|
|
183
|
+
const sendTs = evt.payload?.ts || 0;
|
|
184
|
+
const latency = sendTs ? (Date.now() - sendTs) : 'unknown';
|
|
185
|
+
logger?.info?.(`dragon channel: [LATENCY_CHECK] Received WORKBENCH_MESSAGE from SSE. PayloadLen=${evt?.payload?.content?.length}, NetLatency=${latency}ms`);
|
|
186
|
+
await deliverToOpenClaw(String(evt?.payload?.content || ''), String(evt?.payload?.sessionId || 'default'), evt?.payload?.modelId, evt?.payload?.attachments);
|
|
175
187
|
}
|
|
176
188
|
}
|
|
177
189
|
catch (e) {
|