@mutirolabs/openclaw-brain 0.2.0 → 0.2.1
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/CHANGELOG.md +20 -1
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/src/actions.js +40 -0
- package/dist/src/actions.js.map +1 -0
- package/dist/src/agent-tools.js +547 -0
- package/dist/src/agent-tools.js.map +1 -0
- package/dist/src/bridge-client.js +172 -0
- package/dist/src/bridge-client.js.map +1 -0
- package/dist/src/bridge-messages.js +226 -0
- package/dist/src/bridge-messages.js.map +1 -0
- package/dist/src/bridge-protocol.js +42 -0
- package/dist/src/bridge-protocol.js.map +1 -0
- package/dist/src/bridge-session.js +279 -0
- package/dist/src/bridge-session.js.map +1 -0
- package/dist/src/channel.js +167 -0
- package/dist/src/channel.js.map +1 -0
- package/dist/src/channel.runtime.js +422 -0
- package/dist/src/channel.runtime.js.map +1 -0
- package/dist/src/config.js +61 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/inbound.js +92 -0
- package/dist/src/inbound.js.map +1 -0
- package/dist/src/live-snapshot.js +151 -0
- package/dist/src/live-snapshot.js.map +1 -0
- package/dist/src/outbound.js +205 -0
- package/dist/src/outbound.js.map +1 -0
- package/dist/src/setup-surface.js +252 -0
- package/dist/src/setup-surface.js.map +1 -0
- package/dist/src/signal-forwarder.js +119 -0
- package/dist/src/signal-forwarder.js.map +1 -0
- package/package.json +5 -2
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
// Heavy runtime surface for the Mutiro channel plugin. Owns the registry of
|
|
2
|
+
// active BridgeSession instances keyed by account and serves inbound/outbound
|
|
3
|
+
// calls from the plugin's gateway and outbound adapters.
|
|
4
|
+
//
|
|
5
|
+
// Keeping this file separate from `channel.ts` means the light plugin entry
|
|
6
|
+
// does not pull the NDJSON + child_process machinery into gateway startup.
|
|
7
|
+
import { recordInboundSession } from "openclaw/plugin-sdk/conversation-runtime";
|
|
8
|
+
import { recordInboundSessionAndDispatchReply } from "openclaw/plugin-sdk/inbound-reply-dispatch";
|
|
9
|
+
import { dispatchReplyWithBufferedBlockDispatcher, finalizeInboundContext, } from "openclaw/plugin-sdk/reply-dispatch-runtime";
|
|
10
|
+
import { resolveAgentRoute } from "openclaw/plugin-sdk/routing";
|
|
11
|
+
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
|
|
12
|
+
import { startBridgeSession } from "./bridge-session.js";
|
|
13
|
+
import { normalizeOutputText } from "./bridge-messages.js";
|
|
14
|
+
const sessions = new Map();
|
|
15
|
+
// Crash-backoff state per account. Repeated crashes escalate the delay so we
|
|
16
|
+
// don't thrash the gateway's restart loop when the host is consistently
|
|
17
|
+
// failing (bad config, missing credential, host crash on boot, etc.). The
|
|
18
|
+
// streak resets when the last crash is older than `CRASH_STREAK_RESET_MS`,
|
|
19
|
+
// so a host that ran healthy for a while then crashed once starts over at
|
|
20
|
+
// the shortest backoff.
|
|
21
|
+
const CRASH_BACKOFF_MS = [1_000, 2_000, 5_000, 15_000, 60_000];
|
|
22
|
+
const CRASH_STREAK_RESET_MS = 5 * 60_000;
|
|
23
|
+
const crashState = new Map();
|
|
24
|
+
const sessionKey = (channel, accountId) => `${channel}:${accountId}`;
|
|
25
|
+
const requireSessionForAccount = (accountId) => {
|
|
26
|
+
const session = sessions.get(sessionKey("mutiro", accountId ?? "default"));
|
|
27
|
+
if (!session) {
|
|
28
|
+
throw new Error(`mutiro channel: no active bridge session for account "${accountId ?? "default"}". gateway.startAccount must run first.`);
|
|
29
|
+
}
|
|
30
|
+
return session;
|
|
31
|
+
};
|
|
32
|
+
// Public accessor used by agent tools that need to reach the active bridge
|
|
33
|
+
// session without throwing when the channel is not running yet.
|
|
34
|
+
export const getMutiroBridgeSession = (accountId) => sessions.get(sessionKey("mutiro", accountId ?? "default"));
|
|
35
|
+
/**
|
|
36
|
+
* Runs the agent against a delegated task prompt and returns the
|
|
37
|
+
* accumulated reply text. Used by `task.request`, which — unlike
|
|
38
|
+
* `message.observed` — expects the full reply text inside the
|
|
39
|
+
* `ChatBridgeTaskResult` envelope instead of on the outbound bridge.
|
|
40
|
+
*
|
|
41
|
+
* We reuse the same reply-dispatch path as buildDeliverBridge but swap
|
|
42
|
+
* the deliver callback: instead of shipping chunks via bridge.message.send
|
|
43
|
+
* we accumulate them into a buffer the caller returns to the host.
|
|
44
|
+
*
|
|
45
|
+
* Tool side-effects (mutiro_send_voice_message, mutiro_send_card, etc.)
|
|
46
|
+
* still fire normally through their own execute() paths — only the
|
|
47
|
+
* agent's plain reply text is captured for the task result.
|
|
48
|
+
*/
|
|
49
|
+
const buildResolveTaskRequest = (ctx) => async (params) => {
|
|
50
|
+
const senderUsername = (params.username ?? "").trim() || "system";
|
|
51
|
+
const route = resolveAgentRoute({
|
|
52
|
+
cfg: ctx.cfg,
|
|
53
|
+
channel: "mutiro",
|
|
54
|
+
accountId: params.accountId,
|
|
55
|
+
peer: { kind: "direct", id: senderUsername },
|
|
56
|
+
});
|
|
57
|
+
const storePath = resolveStorePath(ctx.cfg.session?.store, { agentId: route.agentId });
|
|
58
|
+
const messageSid = params.requestId ?? `task-${Date.now()}`;
|
|
59
|
+
const ctxPayload = finalizeInboundContext({
|
|
60
|
+
Body: params.prompt,
|
|
61
|
+
BodyForAgent: params.prompt,
|
|
62
|
+
RawBody: params.prompt,
|
|
63
|
+
CommandBody: params.prompt,
|
|
64
|
+
From: senderUsername,
|
|
65
|
+
To: params.conversationId,
|
|
66
|
+
SessionKey: route.sessionKey,
|
|
67
|
+
AccountId: route.accountId ?? params.accountId,
|
|
68
|
+
ChatType: "direct",
|
|
69
|
+
ConversationLabel: params.conversationId,
|
|
70
|
+
SenderId: senderUsername,
|
|
71
|
+
Provider: "mutiro",
|
|
72
|
+
Surface: "mutiro",
|
|
73
|
+
MessageSid: messageSid,
|
|
74
|
+
MessageSidFull: messageSid,
|
|
75
|
+
Timestamp: Date.now(),
|
|
76
|
+
OriginatingChannel: "mutiro",
|
|
77
|
+
OriginatingTo: params.conversationId,
|
|
78
|
+
});
|
|
79
|
+
const accumulator = [];
|
|
80
|
+
const dispatchPromise = recordInboundSessionAndDispatchReply({
|
|
81
|
+
cfg: ctx.cfg,
|
|
82
|
+
channel: "mutiro",
|
|
83
|
+
accountId: params.accountId,
|
|
84
|
+
agentId: route.agentId,
|
|
85
|
+
routeSessionKey: route.sessionKey,
|
|
86
|
+
storePath,
|
|
87
|
+
ctxPayload,
|
|
88
|
+
recordInboundSession,
|
|
89
|
+
dispatchReplyWithBufferedBlockDispatcher,
|
|
90
|
+
deliver: async (payload) => {
|
|
91
|
+
const chunk = String(payload.text ?? "");
|
|
92
|
+
if (chunk)
|
|
93
|
+
accumulator.push(chunk);
|
|
94
|
+
},
|
|
95
|
+
onRecordError: (err) => ctx.log?.warn?.(`mutiro: task record error: ${formatError(err)}`),
|
|
96
|
+
onDispatchError: (err, info) => ctx.log?.warn?.(`mutiro: task dispatch error (${info.kind}): ${formatError(err)}`),
|
|
97
|
+
});
|
|
98
|
+
// Honor timeout_ms: whichever finishes first, use what accumulated.
|
|
99
|
+
// If the dispatch ran past the deadline we return partial output and
|
|
100
|
+
// let the background promise drain; the host already has its answer.
|
|
101
|
+
if (params.timeoutMs && params.timeoutMs > 0) {
|
|
102
|
+
await Promise.race([
|
|
103
|
+
dispatchPromise,
|
|
104
|
+
new Promise((resolve) => setTimeout(resolve, params.timeoutMs)),
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
await dispatchPromise;
|
|
109
|
+
}
|
|
110
|
+
return normalizeOutputText(accumulator.join(""));
|
|
111
|
+
};
|
|
112
|
+
const buildDeliverBridge = (ctx) => async (inbound) => {
|
|
113
|
+
const session = requireSessionForAccount(inbound.accountId);
|
|
114
|
+
// Resolve the routing / session / ctxPayload pieces directly from the
|
|
115
|
+
// public plugin-sdk helpers rather than relying on `ctx.channelRuntime`
|
|
116
|
+
// to carry the full runtime surface (it does not for bundled channels).
|
|
117
|
+
const route = resolveAgentRoute({
|
|
118
|
+
cfg: ctx.cfg,
|
|
119
|
+
channel: "mutiro",
|
|
120
|
+
accountId: inbound.accountId,
|
|
121
|
+
peer: { kind: "direct", id: inbound.senderUsername },
|
|
122
|
+
});
|
|
123
|
+
const storePath = resolveStorePath(ctx.cfg.session?.store, { agentId: route.agentId });
|
|
124
|
+
const target = {
|
|
125
|
+
conversationId: inbound.conversationId,
|
|
126
|
+
replyToMessageId: inbound.messageId,
|
|
127
|
+
};
|
|
128
|
+
const { createSignalForwarder } = await import("./signal-forwarder.js");
|
|
129
|
+
const signals = createSignalForwarder(session, target);
|
|
130
|
+
// Fire a THINKING pulse immediately so the user sees feedback while
|
|
131
|
+
// dispatch warms up (model selection, memory loads, etc.). Subsequent
|
|
132
|
+
// on* callbacks replace it with more specific signals.
|
|
133
|
+
signals.thinking();
|
|
134
|
+
const mediaPaths = inbound.mediaPaths ?? [];
|
|
135
|
+
const mediaTypes = inbound.mediaTypes ?? [];
|
|
136
|
+
const ctxPayload = finalizeInboundContext({
|
|
137
|
+
Body: inbound.text,
|
|
138
|
+
BodyForAgent: inbound.text,
|
|
139
|
+
RawBody: inbound.text,
|
|
140
|
+
CommandBody: inbound.text,
|
|
141
|
+
From: inbound.senderUsername,
|
|
142
|
+
To: inbound.conversationId,
|
|
143
|
+
SessionKey: route.sessionKey,
|
|
144
|
+
AccountId: route.accountId ?? inbound.accountId,
|
|
145
|
+
ChatType: "direct",
|
|
146
|
+
ConversationLabel: inbound.conversationId,
|
|
147
|
+
SenderId: inbound.senderUsername,
|
|
148
|
+
Provider: "mutiro",
|
|
149
|
+
Surface: "mutiro",
|
|
150
|
+
MessageSid: inbound.messageId,
|
|
151
|
+
MessageSidFull: inbound.messageId,
|
|
152
|
+
Timestamp: Date.now(),
|
|
153
|
+
OriginatingChannel: "mutiro",
|
|
154
|
+
OriginatingTo: inbound.conversationId,
|
|
155
|
+
...(mediaPaths.length > 0
|
|
156
|
+
? {
|
|
157
|
+
MediaPath: mediaPaths[0],
|
|
158
|
+
MediaPaths: mediaPaths,
|
|
159
|
+
MediaType: mediaTypes[0],
|
|
160
|
+
MediaTypes: mediaTypes,
|
|
161
|
+
}
|
|
162
|
+
: {}),
|
|
163
|
+
});
|
|
164
|
+
await recordInboundSessionAndDispatchReply({
|
|
165
|
+
cfg: ctx.cfg,
|
|
166
|
+
channel: "mutiro",
|
|
167
|
+
accountId: inbound.accountId,
|
|
168
|
+
agentId: route.agentId,
|
|
169
|
+
routeSessionKey: route.sessionKey,
|
|
170
|
+
storePath,
|
|
171
|
+
ctxPayload,
|
|
172
|
+
recordInboundSession,
|
|
173
|
+
dispatchReplyWithBufferedBlockDispatcher,
|
|
174
|
+
deliver: async (payload) => {
|
|
175
|
+
const text = normalizeOutputText(String(payload.text ?? ""));
|
|
176
|
+
if (!text)
|
|
177
|
+
return;
|
|
178
|
+
await session.outbound.sendText(target, text);
|
|
179
|
+
},
|
|
180
|
+
// replyOptions taps OpenClaw's mid-turn hooks to forward progress
|
|
181
|
+
// into Mutiro's signal stream. Each on* callback maps to a specific
|
|
182
|
+
// SIGNAL_TYPE_* so the user sees "searching web", "remembering",
|
|
183
|
+
// "writing response" pills instead of a single static "thinking".
|
|
184
|
+
replyOptions: {
|
|
185
|
+
onAssistantMessageStart: () => signals.typing(),
|
|
186
|
+
onReasoningStream: () => signals.reasoning(),
|
|
187
|
+
onToolStart: (payload) => signals.toolStart(payload.name, payload.phase),
|
|
188
|
+
// onItemEvent carries richer detail than onToolStart — `title` is
|
|
189
|
+
// resolved from tool args (e.g. "read src/x.ts"). Refine only on
|
|
190
|
+
// the start phase; "end"/"update" would thrash the pill.
|
|
191
|
+
onItemEvent: (payload) => {
|
|
192
|
+
if (payload.phase && payload.phase !== "start")
|
|
193
|
+
return;
|
|
194
|
+
signals.itemStart({
|
|
195
|
+
name: payload.name,
|
|
196
|
+
title: payload.title,
|
|
197
|
+
phase: payload.phase,
|
|
198
|
+
});
|
|
199
|
+
},
|
|
200
|
+
onCompactionStart: () => signals.compactionStart(),
|
|
201
|
+
onCompactionEnd: () => signals.compactionEnd(),
|
|
202
|
+
onPlanUpdate: (payload) => signals.planUpdate(payload.title),
|
|
203
|
+
},
|
|
204
|
+
onRecordError: (err) => ctx.log?.warn?.(`mutiro: record session error: ${formatError(err)}`),
|
|
205
|
+
onDispatchError: (err, info) => ctx.log?.warn?.(`mutiro: dispatch error (${info.kind}): ${formatError(err)}`),
|
|
206
|
+
});
|
|
207
|
+
// Close the signal stream and the host-owned turn lifecycle.
|
|
208
|
+
// TURN_COMPLETE clears any lingering pill in the Mutiro UI; endTurn
|
|
209
|
+
// releases the host-side pending turn regardless of whether visible
|
|
210
|
+
// replies were emitted.
|
|
211
|
+
signals.turnComplete();
|
|
212
|
+
session.outbound.endTurn(target);
|
|
213
|
+
};
|
|
214
|
+
export const startMutiroAccount = async (ctx) => {
|
|
215
|
+
const key = sessionKey("mutiro", ctx.accountId);
|
|
216
|
+
const existing = sessions.get(key);
|
|
217
|
+
if (existing) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const { account } = ctx;
|
|
221
|
+
if (!account.configured || !account.config.agentDir) {
|
|
222
|
+
ctx.log?.warn?.(`mutiro: account "${ctx.accountId}" is not configured (missing agentDir)`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// The gateway expects startAccount to stay pending for the lifetime of the
|
|
226
|
+
// channel. Resolving early is interpreted as "channel exited" and triggers
|
|
227
|
+
// an auto-restart loop. We block on exit-or-abort via this deferred.
|
|
228
|
+
let settleLifecycle = () => { };
|
|
229
|
+
const lifecycle = new Promise((resolve) => {
|
|
230
|
+
settleLifecycle = resolve;
|
|
231
|
+
});
|
|
232
|
+
const session = await startBridgeSession({
|
|
233
|
+
accountId: ctx.accountId,
|
|
234
|
+
agentDir: account.config.agentDir,
|
|
235
|
+
clientName: account.config.clientName,
|
|
236
|
+
requestedOptionalCapabilities: account.config.requestedOptionalCapabilities,
|
|
237
|
+
deliver: buildDeliverBridge(ctx),
|
|
238
|
+
resolveTaskRequest: buildResolveTaskRequest(ctx),
|
|
239
|
+
resolveLiveSnapshot: async (params) => {
|
|
240
|
+
// Lazy-load the snapshot module so startup stays clean and the
|
|
241
|
+
// plugin-sdk/config-runtime surface is only touched when the host
|
|
242
|
+
// actually requests a live handoff (i.e. a voice call starts).
|
|
243
|
+
const { buildLiveSnapshot } = await import("./live-snapshot.js");
|
|
244
|
+
return buildLiveSnapshot({
|
|
245
|
+
cfg: ctx.cfg,
|
|
246
|
+
accountId: params.accountId,
|
|
247
|
+
conversationId: params.conversationId,
|
|
248
|
+
callerUsername: params.username,
|
|
249
|
+
callId: params.callId,
|
|
250
|
+
agentUsername: session?.getAgentUsername() ?? "",
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
logger: ctx.log
|
|
254
|
+
? {
|
|
255
|
+
info: ctx.log.info,
|
|
256
|
+
warn: ctx.log.warn,
|
|
257
|
+
error: ctx.log.error,
|
|
258
|
+
}
|
|
259
|
+
: undefined,
|
|
260
|
+
onHostExit: (code) => {
|
|
261
|
+
sessions.delete(key);
|
|
262
|
+
const now = Date.now();
|
|
263
|
+
const isAbort = ctx.abortSignal.aborted;
|
|
264
|
+
const isCleanExit = code === 0 || isAbort;
|
|
265
|
+
if (isCleanExit) {
|
|
266
|
+
crashState.delete(ctx.accountId);
|
|
267
|
+
ctx.log?.info?.(`mutiro: host (${ctx.accountId}) exited with code ${code}${isAbort ? " (abort)" : ""}`);
|
|
268
|
+
ctx.setStatus({
|
|
269
|
+
...ctx.getStatus(),
|
|
270
|
+
running: false,
|
|
271
|
+
connected: false,
|
|
272
|
+
lastDisconnect: { at: now, status: code ?? undefined },
|
|
273
|
+
});
|
|
274
|
+
settleLifecycle();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
// Unexpected exit: track the streak, compute backoff, and hold the
|
|
278
|
+
// lifecycle promise until the delay elapses. The gateway's restart
|
|
279
|
+
// loop won't fire until we settle, so this delay is the effective
|
|
280
|
+
// backoff without touching gateway internals.
|
|
281
|
+
const prior = crashState.get(ctx.accountId);
|
|
282
|
+
const streak = prior && now - prior.lastCrashAt < CRASH_STREAK_RESET_MS ? prior.count + 1 : 1;
|
|
283
|
+
crashState.set(ctx.accountId, { count: streak, lastCrashAt: now });
|
|
284
|
+
const delayMs = CRASH_BACKOFF_MS[Math.min(streak - 1, CRASH_BACKOFF_MS.length - 1)];
|
|
285
|
+
ctx.log?.warn?.(`mutiro: host (${ctx.accountId}) exited unexpectedly with code ${code}; ` +
|
|
286
|
+
`restarting in ${Math.round(delayMs / 1000)}s (attempt ${streak})`);
|
|
287
|
+
ctx.setStatus({
|
|
288
|
+
...ctx.getStatus(),
|
|
289
|
+
running: false,
|
|
290
|
+
connected: false,
|
|
291
|
+
restartPending: true,
|
|
292
|
+
reconnectAttempts: streak,
|
|
293
|
+
lastDisconnect: {
|
|
294
|
+
at: now,
|
|
295
|
+
status: code ?? undefined,
|
|
296
|
+
error: `exit_code=${code ?? "null"}`,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
setTimeout(() => {
|
|
300
|
+
settleLifecycle();
|
|
301
|
+
}, delayMs);
|
|
302
|
+
},
|
|
303
|
+
});
|
|
304
|
+
sessions.set(key, session);
|
|
305
|
+
ctx.setStatus({
|
|
306
|
+
...ctx.getStatus(),
|
|
307
|
+
running: true,
|
|
308
|
+
connected: true,
|
|
309
|
+
lastConnectedAt: Date.now(),
|
|
310
|
+
lastStartAt: Date.now(),
|
|
311
|
+
});
|
|
312
|
+
const onAbort = () => {
|
|
313
|
+
void stopSession(key).finally(settleLifecycle);
|
|
314
|
+
};
|
|
315
|
+
if (ctx.abortSignal.aborted) {
|
|
316
|
+
onAbort();
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
ctx.abortSignal.addEventListener("abort", onAbort, { once: true });
|
|
320
|
+
}
|
|
321
|
+
await lifecycle;
|
|
322
|
+
};
|
|
323
|
+
export const stopMutiroAccount = async (ctx) => {
|
|
324
|
+
await stopSession(sessionKey("mutiro", ctx.accountId));
|
|
325
|
+
ctx.setStatus({
|
|
326
|
+
...ctx.getStatus(),
|
|
327
|
+
running: false,
|
|
328
|
+
connected: false,
|
|
329
|
+
lastStopAt: Date.now(),
|
|
330
|
+
});
|
|
331
|
+
};
|
|
332
|
+
const stopSession = async (key) => {
|
|
333
|
+
const session = sessions.get(key);
|
|
334
|
+
if (!session)
|
|
335
|
+
return;
|
|
336
|
+
sessions.delete(key);
|
|
337
|
+
await session.shutdown();
|
|
338
|
+
};
|
|
339
|
+
export const sendMutiroText = async (ctx) => {
|
|
340
|
+
const session = requireSessionForAccount(ctx.accountId);
|
|
341
|
+
await session.outbound.sendText({
|
|
342
|
+
conversationId: ctx.to,
|
|
343
|
+
replyToMessageId: ctx.replyToId ?? ctx.threadId?.toString() ?? "",
|
|
344
|
+
}, ctx.text);
|
|
345
|
+
return {
|
|
346
|
+
channel: "mutiro",
|
|
347
|
+
messageId: ctx.replyToId ?? `mutiro-${Date.now()}`,
|
|
348
|
+
conversationId: ctx.to,
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
export const sendMutiroMedia = async (ctx) => {
|
|
352
|
+
if (!ctx.mediaUrl) {
|
|
353
|
+
throw new Error("sendMedia called without mediaUrl");
|
|
354
|
+
}
|
|
355
|
+
const session = requireSessionForAccount(ctx.accountId);
|
|
356
|
+
await session.outbound.sendFile({
|
|
357
|
+
conversationId: ctx.to,
|
|
358
|
+
replyToMessageId: ctx.replyToId ?? ctx.threadId?.toString() ?? "",
|
|
359
|
+
}, {
|
|
360
|
+
filePath: ctx.mediaUrl,
|
|
361
|
+
caption: ctx.text,
|
|
362
|
+
});
|
|
363
|
+
return {
|
|
364
|
+
channel: "mutiro",
|
|
365
|
+
messageId: ctx.replyToId ?? `mutiro-${Date.now()}`,
|
|
366
|
+
conversationId: ctx.to,
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
const formatError = (err) => err instanceof Error ? err.message : JSON.stringify(err);
|
|
370
|
+
// Dispatcher for ChannelMessageActionAdapter.handleAction. Declared here so
|
|
371
|
+
// the heavy runtime does the bridge work, and the light `actions.ts` file
|
|
372
|
+
// stays a pure control-plane adapter that loads this lazily.
|
|
373
|
+
export const handleMutiroMessageAction = async (params) => {
|
|
374
|
+
const session = requireSessionForAccount(params.accountId);
|
|
375
|
+
if (params.action === "react") {
|
|
376
|
+
const messageId = params.readStringArg(params.params, "messageId", "message_id", "to");
|
|
377
|
+
const emoji = params.readStringArg(params.params, "emoji", "reaction");
|
|
378
|
+
if (!messageId) {
|
|
379
|
+
return {
|
|
380
|
+
content: [{ type: "text", text: "react requires a messageId." }],
|
|
381
|
+
details: { ok: false, reason: "missing_message_id" },
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
if (!emoji) {
|
|
385
|
+
return {
|
|
386
|
+
content: [{ type: "text", text: "react requires an emoji." }],
|
|
387
|
+
details: { ok: false, reason: "missing_emoji" },
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
try {
|
|
391
|
+
const raw = await session.outbound.react({ messageId, emoji });
|
|
392
|
+
return {
|
|
393
|
+
content: [{ type: "text", text: `Reacted ${emoji} to ${messageId}.` }],
|
|
394
|
+
details: { ok: true, raw },
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
catch (err) {
|
|
398
|
+
const message = formatError(err);
|
|
399
|
+
return {
|
|
400
|
+
content: [{ type: "text", text: `Failed to react: ${message}` }],
|
|
401
|
+
details: { ok: false, reason: "bridge_error", error: message },
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return {
|
|
406
|
+
content: [
|
|
407
|
+
{
|
|
408
|
+
type: "text",
|
|
409
|
+
text: `Unsupported Mutiro message action: ${params.action}`,
|
|
410
|
+
},
|
|
411
|
+
],
|
|
412
|
+
details: { ok: false, reason: "unsupported_action", action: params.action },
|
|
413
|
+
};
|
|
414
|
+
};
|
|
415
|
+
// Barrel export consumed by the plugin entry via `loadBundledEntryExportSync`.
|
|
416
|
+
export const mutiroChannelRuntime = {
|
|
417
|
+
startMutiroAccount,
|
|
418
|
+
stopMutiroAccount,
|
|
419
|
+
sendMutiroText,
|
|
420
|
+
sendMutiroMedia,
|
|
421
|
+
};
|
|
422
|
+
//# sourceMappingURL=channel.runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"channel.runtime.js","sourceRoot":"","sources":["../../src/channel.runtime.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,8EAA8E;AAC9E,yDAAyD;AACzD,EAAE;AACF,4EAA4E;AAC5E,2EAA2E;AAI3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAChF,OAAO,EAAE,oCAAoC,EAAE,MAAM,4CAA4C,CAAC;AAClG,OAAO,EACL,wCAAwC,EACxC,sBAAsB,GACvB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAO7E,OAAO,EAAE,kBAAkB,EAAsB,MAAM,qBAAqB,CAAC;AAG7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAI3D,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;AAElD,6EAA6E;AAC7E,wEAAwE;AACxE,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,wBAAwB;AACxB,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAC/D,MAAM,qBAAqB,GAAG,CAAC,GAAG,MAAM,CAAC;AACzC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkD,CAAC;AAE7E,MAAM,UAAU,GAAG,CAAC,OAAe,EAAE,SAAiB,EAAE,EAAE,CAAC,GAAG,OAAO,IA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AAE,CAAC;YACb,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACjC,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,oBAAoB,OAAO,EAAE,EAAE,CAAC;gBACzE,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,EAAE;aAC/D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAe;gBACrB,IAAI,EAAE,sCAAsC,MAAM,CAAC,MAAM,EAAE;aAC5D;SACF;QACD,OAAO,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;KAC5E,CAAC;AACJ,CAAC,CAAC;AAEF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,kBAAkB;IAClB,iBAAiB;IACjB,cAAc;IACd,eAAe;CAChB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Mutiro channel configuration and per-account resolution.
|
|
2
|
+
//
|
|
3
|
+
// The channel supports one or more named accounts; each account pins a
|
|
4
|
+
// specific Mutiro agent directory that `mutiro agent host --mode=bridge`
|
|
5
|
+
// should run from. We reuse OpenClaw's `createScopedChannelConfigAdapter` so
|
|
6
|
+
// the account lifecycle (list/default/resolve) flows through the same shape
|
|
7
|
+
// the Plugin SDK already knows how to drive.
|
|
8
|
+
import { DEFAULT_ACCOUNT_ID } from "openclaw/plugin-sdk/account-id";
|
|
9
|
+
export { DEFAULT_ACCOUNT_ID };
|
|
10
|
+
const readMutiroSection = (cfg) => {
|
|
11
|
+
const channels = cfg.channels;
|
|
12
|
+
return channels?.mutiro;
|
|
13
|
+
};
|
|
14
|
+
const resolveAccountConfig = (cfg, accountId) => {
|
|
15
|
+
const section = readMutiroSection(cfg);
|
|
16
|
+
if (!section)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (accountId === DEFAULT_ACCOUNT_ID && section.agentDir) {
|
|
19
|
+
return {
|
|
20
|
+
agentDir: section.agentDir,
|
|
21
|
+
clientName: section.clientName,
|
|
22
|
+
requestedOptionalCapabilities: section.requestedOptionalCapabilities,
|
|
23
|
+
enabled: section.enabled,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return section.accounts?.[accountId];
|
|
27
|
+
};
|
|
28
|
+
export const listMutiroAccountIds = (cfg) => {
|
|
29
|
+
const section = readMutiroSection(cfg);
|
|
30
|
+
const named = Object.keys(section?.accounts ?? {});
|
|
31
|
+
if (named.length > 0)
|
|
32
|
+
return named;
|
|
33
|
+
return section?.agentDir ? [DEFAULT_ACCOUNT_ID] : [];
|
|
34
|
+
};
|
|
35
|
+
export const resolveDefaultMutiroAccountId = (cfg) => {
|
|
36
|
+
const ids = listMutiroAccountIds(cfg);
|
|
37
|
+
return ids[0] ?? DEFAULT_ACCOUNT_ID;
|
|
38
|
+
};
|
|
39
|
+
export const resolveMutiroAccount = (cfg, accountId) => {
|
|
40
|
+
const id = accountId || resolveDefaultMutiroAccountId(cfg);
|
|
41
|
+
const base = resolveAccountConfig(cfg, id) ?? { agentDir: "" };
|
|
42
|
+
const configured = Boolean(base.agentDir);
|
|
43
|
+
return {
|
|
44
|
+
accountId: id,
|
|
45
|
+
enabled: base.enabled !== false,
|
|
46
|
+
configured,
|
|
47
|
+
name: base.name,
|
|
48
|
+
config: base,
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
// Build the ChannelConfigAdapter directly. The helpers in
|
|
52
|
+
// `channel-config-helpers` expect allowlist and clear-base-field accessors
|
|
53
|
+
// that Mutiro does not use, so we wire the two required hooks manually.
|
|
54
|
+
export const mutiroConfigAdapter = {
|
|
55
|
+
listAccountIds: listMutiroAccountIds,
|
|
56
|
+
resolveAccount: resolveMutiroAccount,
|
|
57
|
+
defaultAccountId: resolveDefaultMutiroAccountId,
|
|
58
|
+
isEnabled: (account) => account.enabled,
|
|
59
|
+
isConfigured: (account) => account.configured,
|
|
60
|
+
};
|
|
61
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,EAAE;AACF,uEAAuE;AACvE,yEAAyE;AACzE,6EAA6E;AAC7E,4EAA4E;AAC5E,6CAA6C;AAE7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAGpE,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,MAAM,iBAAiB,GAAG,CAAC,GAAmB,EAAoC,EAAE;IAClF,MAAM,QAAQ,GAAI,GAA8C,CAAC,QAAQ,CAAC;IAC1E,OAAO,QAAQ,EAAE,MAA0C,CAAC;AAC9D,CAAC,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAC3B,GAAmB,EACnB,SAAiB,EACgB,EAAE;IACnC,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAE/B,IAAI,SAAS,KAAK,kBAAkB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzD,OAAO;YACL,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,6BAA6B,EAAE,OAAO,CAAC,6BAA6B;YACpE,OAAO,EAAE,OAAO,CAAC,OAAO;SACzB,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC,QAAQ,EAAE,CAAC,SAAS,CAAC,CAAC;AACvC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,GAAmB,EAAY,EAAE;IACpE,MAAM,OAAO,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACvC,M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8B,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU;CACrE,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Translates bridge observed messages into the inbound delivery the OpenClaw
|
|
2
|
+
// gateway expects from a channel plugin. The runtime installs a single inbound
|
|
3
|
+
// delivery callback during plugin startup; this module's job is to shape each
|
|
4
|
+
// observed bridge envelope into that callback's input.
|
|
5
|
+
import { saveMediaBuffer } from "openclaw/plugin-sdk/browser-setup-tools";
|
|
6
|
+
import { buildObservedTurn, isSelfEventMessage } from "./bridge-messages.js";
|
|
7
|
+
/**
|
|
8
|
+
* The bridge delivers image attachments inline as base64 under
|
|
9
|
+
* `envelope.payload.images`. We persist each one into OpenClaw's media
|
|
10
|
+
* directory via `saveMediaBuffer`, which stages under `~/.openclaw/media/`
|
|
11
|
+
* — the only root OpenClaw's sandbox staging policy accepts. Writing to
|
|
12
|
+
* `os.tmpdir()` silently fails staging and leaves the agent with only a
|
|
13
|
+
* text path reference, so the bytes never reach the model.
|
|
14
|
+
*/
|
|
15
|
+
const persistInlineImages = async (images) => {
|
|
16
|
+
if (!Array.isArray(images) || images.length === 0) {
|
|
17
|
+
return { paths: [], types: [] };
|
|
18
|
+
}
|
|
19
|
+
const paths = [];
|
|
20
|
+
const types = [];
|
|
21
|
+
for (const entry of images) {
|
|
22
|
+
if (!entry?.data)
|
|
23
|
+
continue;
|
|
24
|
+
try {
|
|
25
|
+
const saved = await saveMediaBuffer(Buffer.from(entry.data, "base64"), entry.mime_type, "inbound", undefined, entry.filename);
|
|
26
|
+
paths.push(saved.path);
|
|
27
|
+
types.push(saved.contentType ?? entry.mime_type ?? "application/octet-stream");
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Best-effort: skip a single bad attachment rather than aborting the turn.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return { paths, types };
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Shapes a bridge envelope into the OpenClaw inbound message the gateway
|
|
37
|
+
* delivers to core. Returns the observed turn it extracted (useful for the
|
|
38
|
+
* caller to key session state) or null when the envelope was self-authored or
|
|
39
|
+
* did not carry a deliverable message.
|
|
40
|
+
*/
|
|
41
|
+
export const deliverObservedEnvelope = async (envelope, route) => {
|
|
42
|
+
if (envelope.type === "event.message" && isSelfEventMessage(envelope, route.agentUsername)) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
// Reactions and other bare events are now delivered to OpenClaw like any
|
|
46
|
+
// other observation. The agent may choose to stay silent, which today
|
|
47
|
+
// surfaces "Agent couldn't generate a response" — acceptable trade-off
|
|
48
|
+
// for letting the agent actually see reactions happen. If OpenClaw grows
|
|
49
|
+
// a "silent turn is ok" dispatch option later, filter these through that.
|
|
50
|
+
const turn = buildObservedTurn(envelope);
|
|
51
|
+
if (!turn) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
const { paths, types } = await persistInlineImages(envelope.payload?.images);
|
|
55
|
+
// attachment_context is the host's narrative of downloaded attachments:
|
|
56
|
+
// [SYSTEM: Downloaded 1 file(s) to your workspace:
|
|
57
|
+
// • nf-2976.pdf → /Users/.../Downloads/nf-2976.pdf (PDF, 450 KB)]
|
|
58
|
+
// For PDFs/docs this is the ONLY pointer the agent gets — it needs the
|
|
59
|
+
// path to invoke `read` or a doc-extraction tool. We earlier stripped
|
|
60
|
+
// this string because the host's image probe produced noisy "0x0 pixels"
|
|
61
|
+
// metadata that fooled vision models. Image turns now route bytes
|
|
62
|
+
// through MediaPaths instead, so attachment_context is pure signal for
|
|
63
|
+
// non-image attachments. Append only when the message carries file-type
|
|
64
|
+
// parts; skip for image-only or text-only turns.
|
|
65
|
+
const hasFileParts = extractHasFileParts(envelope.payload?.message);
|
|
66
|
+
const contextText = (envelope.payload?.attachment_context ?? "").trim();
|
|
67
|
+
const bodyText = hasFileParts && contextText
|
|
68
|
+
? turn.text
|
|
69
|
+
? `${turn.text}\n\n${contextText}`
|
|
70
|
+
: contextText
|
|
71
|
+
: turn.text;
|
|
72
|
+
await route.deliver({
|
|
73
|
+
channelId: "mutiro",
|
|
74
|
+
accountId: route.accountId,
|
|
75
|
+
conversationId: turn.conversationId,
|
|
76
|
+
messageId: turn.messageId,
|
|
77
|
+
replyToMessageId: turn.replyToMessageId,
|
|
78
|
+
senderUsername: turn.senderUsername,
|
|
79
|
+
text: bodyText,
|
|
80
|
+
rawMessage: envelope.payload?.message,
|
|
81
|
+
attachmentContext: envelope.payload?.attachment_context,
|
|
82
|
+
...(paths.length > 0 ? { mediaPaths: paths, mediaTypes: types } : {}),
|
|
83
|
+
});
|
|
84
|
+
return turn;
|
|
85
|
+
};
|
|
86
|
+
const extractHasFileParts = (message) => {
|
|
87
|
+
if (!message)
|
|
88
|
+
return false;
|
|
89
|
+
const parts = Array.isArray(message.parts) ? message.parts : [];
|
|
90
|
+
return parts.some((part) => part?.type === "file");
|
|
91
|
+
};
|
|
92
|
+
//# sourceMappingURL=inbound.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inbound.js","sourceRoot":"","sources":["../../src/inbound.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,+EAA+E;AAC/E,8EAA8E;AAC9E,uDAAuD;AAEvD,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAG1E,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AA8B7E;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG,KAAK,EAC/B,MAAiC,EACc,EAAE;IACjD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAA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