@mutirolabs/openclaw-brain 0.1.1 → 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 +70 -3
- package/README.md +44 -217
- 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/docs/assets/mutiro-openclaw-ui.png +0 -0
- package/docs/guides/manage-allowlist.md +3 -3
- package/docs/guides/use-openclaw-as-brain.md +15 -15
- package/index.ts +1 -1
- package/openclaw.plugin.json +5 -3
- package/package.json +9 -7
- package/src/agent-tools.ts +3 -3
- package/src/bridge-client.ts +1 -2
- package/src/bridge-messages.ts +2 -2
- package/src/bridge-protocol.ts +2 -2
- package/src/bridge-session.ts +2 -2
- package/src/channel.runtime.ts +54 -3
- package/src/channel.ts +61 -2
- package/src/outbound.ts +5 -7
- package/src/setup-surface.ts +39 -11
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// Bridges OpenClaw's mid-turn reply-dispatch hooks into Mutiro's
|
|
2
|
+
// signal.emit envelopes so the user sees a live "typing / searching /
|
|
3
|
+
// remembering" indicator while the agent works. Fire-and-forget: signals
|
|
4
|
+
// are transient UI chrome, not messages. No correlation required.
|
|
5
|
+
//
|
|
6
|
+
// Maps OpenClaw callbacks (from GetReplyOptions) to Mutiro's signal
|
|
7
|
+
// vocabulary (SIGNAL_TYPE_* in spec/protobuf/shared/signal.proto).
|
|
8
|
+
const REASONING_DEBOUNCE_MS = 500;
|
|
9
|
+
const TOOL_DETAIL_MAX_CHARS = 120;
|
|
10
|
+
const TOOL_SIGNAL_MAP = {
|
|
11
|
+
// Web
|
|
12
|
+
web_search: { signal: "SIGNAL_TYPE_WEB_SEARCHING", intent: "Searching web" },
|
|
13
|
+
web_fetch: { signal: "SIGNAL_TYPE_WEB_FETCHING", intent: "Fetching" },
|
|
14
|
+
fetch: { signal: "SIGNAL_TYPE_WEB_FETCHING", intent: "Fetching" },
|
|
15
|
+
// Memory / recall
|
|
16
|
+
recall: { signal: "SIGNAL_TYPE_RECALLING", intent: "Recalling" },
|
|
17
|
+
memory_search: { signal: "SIGNAL_TYPE_RECALLING", intent: "Searching memory" },
|
|
18
|
+
memory: { signal: "SIGNAL_TYPE_READING_MEMORY", intent: "Reading memory" },
|
|
19
|
+
memory_remember: { signal: "SIGNAL_TYPE_WRITING_MEMORY", intent: "Saving memory" },
|
|
20
|
+
memory_write: { signal: "SIGNAL_TYPE_WRITING_MEMORY", intent: "Saving memory" },
|
|
21
|
+
// Media
|
|
22
|
+
image_generate: { signal: "SIGNAL_TYPE_CREATING_IMAGE", intent: "Creating image" },
|
|
23
|
+
image: { signal: "SIGNAL_TYPE_CREATING_IMAGE", intent: "Working with image" },
|
|
24
|
+
// Scheduling / planning
|
|
25
|
+
cron: { signal: "SIGNAL_TYPE_SCHEDULING", intent: "Scheduling" },
|
|
26
|
+
update_plan: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Updating plan" },
|
|
27
|
+
// Mutiro-native channel tools
|
|
28
|
+
mutiro_send_voice_message: { signal: "SIGNAL_TYPE_SENDING_VOICE", intent: "Sending voice" },
|
|
29
|
+
mutiro_send_card: { signal: "SIGNAL_TYPE_ATTACHING_FILE", intent: "Preparing card" },
|
|
30
|
+
mutiro_forward_message: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Forwarding message" },
|
|
31
|
+
// File operations (coding profile). Mutiro has no dedicated SIGNAL_TYPE_*
|
|
32
|
+
// for file I/O; use CUSTOM + readable intent so the user still sees the
|
|
33
|
+
// action. Phase (e.g. the path being touched) is appended when present.
|
|
34
|
+
read: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Reading file" },
|
|
35
|
+
write: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Writing file" },
|
|
36
|
+
edit: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Editing file" },
|
|
37
|
+
apply_patch: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Applying patch" },
|
|
38
|
+
// Shell / process
|
|
39
|
+
exec: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Running command" },
|
|
40
|
+
bash: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Running command" },
|
|
41
|
+
process: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Managing process" },
|
|
42
|
+
// UI surfaces
|
|
43
|
+
canvas: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Updating canvas" },
|
|
44
|
+
browser: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Browsing" },
|
|
45
|
+
// Sessions / control plane
|
|
46
|
+
sessions_list: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Listing sessions" },
|
|
47
|
+
sessions_history: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Reading history" },
|
|
48
|
+
sessions_send: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Sending to session" },
|
|
49
|
+
session_status: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Checking status" },
|
|
50
|
+
message: { signal: "SIGNAL_TYPE_CUSTOM", intent: "Messaging" },
|
|
51
|
+
};
|
|
52
|
+
const truncateDetail = (raw) => {
|
|
53
|
+
const collapsed = raw.replace(/\s+/g, " ").trim();
|
|
54
|
+
if (collapsed.length <= TOOL_DETAIL_MAX_CHARS)
|
|
55
|
+
return collapsed;
|
|
56
|
+
return `${collapsed.slice(0, TOOL_DETAIL_MAX_CHARS - 1).trimEnd()}…`;
|
|
57
|
+
};
|
|
58
|
+
export const createSignalForwarder = (session, target) => {
|
|
59
|
+
let lastReasoningAt = 0;
|
|
60
|
+
const emit = (signalType, detail) => {
|
|
61
|
+
session.outbound.emitSignal(target, signalType, detail ?? "");
|
|
62
|
+
};
|
|
63
|
+
return {
|
|
64
|
+
thinking: () => emit("SIGNAL_TYPE_THINKING", "Processing…"),
|
|
65
|
+
typing: () => emit("SIGNAL_TYPE_TYPING", "Writing response…"),
|
|
66
|
+
reasoning: () => {
|
|
67
|
+
// onReasoningStream fires per-token; throttle so we ship at most one
|
|
68
|
+
// REASONING pulse every REASONING_DEBOUNCE_MS to avoid spamming the
|
|
69
|
+
// host + Mutiro clients.
|
|
70
|
+
const now = Date.now();
|
|
71
|
+
if (now - lastReasoningAt < REASONING_DEBOUNCE_MS)
|
|
72
|
+
return;
|
|
73
|
+
lastReasoningAt = now;
|
|
74
|
+
emit("SIGNAL_TYPE_REASONING", "Thinking…");
|
|
75
|
+
},
|
|
76
|
+
toolStart: (name, _phase) => {
|
|
77
|
+
const trimmedName = (name ?? "").trim();
|
|
78
|
+
if (!trimmedName) {
|
|
79
|
+
emit("SIGNAL_TYPE_TOOL_RUNNING");
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
// `onToolStart.phase` is a lifecycle marker ("start"/"update"/"end"),
|
|
83
|
+
// not semantic payload — ignore it. Tools with args (read, write,
|
|
84
|
+
// exec, etc.) fire a follow-up `onItemEvent` whose `title` carries
|
|
85
|
+
// the real detail (e.g. "read src/x.ts"); itemEvent() refines the
|
|
86
|
+
// pill to that value. For tools that never emit an item event, the
|
|
87
|
+
// intent label alone is still meaningful.
|
|
88
|
+
const spec = TOOL_SIGNAL_MAP[trimmedName];
|
|
89
|
+
const intent = spec?.intent ?? trimmedName;
|
|
90
|
+
emit(spec?.signal ?? "SIGNAL_TYPE_CUSTOM", truncateDetail(intent));
|
|
91
|
+
},
|
|
92
|
+
itemStart: (params) => {
|
|
93
|
+
// Higher-fidelity source than toolStart: title resolves tool args
|
|
94
|
+
// into a display ("read src/x.ts", "exec pytest -k foo", etc.) via
|
|
95
|
+
// OpenClaw's inferToolMetaFromArgs. When we have both the tool
|
|
96
|
+
// signal type AND the rich title, emit with the specific signal
|
|
97
|
+
// type so the UI still shows the right pill style.
|
|
98
|
+
const name = (params.name ?? "").trim();
|
|
99
|
+
const title = (params.title ?? "").trim();
|
|
100
|
+
if (!name && !title)
|
|
101
|
+
return;
|
|
102
|
+
const spec = name ? TOOL_SIGNAL_MAP[name] : undefined;
|
|
103
|
+
const detail = truncateDetail(title || spec?.intent || name);
|
|
104
|
+
emit(spec?.signal ?? "SIGNAL_TYPE_CUSTOM", detail);
|
|
105
|
+
},
|
|
106
|
+
compactionStart: () => emit("SIGNAL_TYPE_REMEMBERING", "Organizing context…"),
|
|
107
|
+
compactionEnd: () => {
|
|
108
|
+
// No explicit clear — the next signal (or TURN_COMPLETE) replaces the
|
|
109
|
+
// visible pill on Mutiro clients.
|
|
110
|
+
},
|
|
111
|
+
planUpdate: (title) => {
|
|
112
|
+
const detail = (title ?? "").trim();
|
|
113
|
+
emit("SIGNAL_TYPE_CUSTOM", detail ? `Planning: ${truncateDetail(detail)}` : "Planning…");
|
|
114
|
+
},
|
|
115
|
+
custom: (detail) => emit("SIGNAL_TYPE_CUSTOM", truncateDetail(detail)),
|
|
116
|
+
turnComplete: () => emit("SIGNAL_TYPE_TURN_COMPLETE"),
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
//# sourceMappingURL=signal-forwarder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signal-forwarder.js","sourceRoot":"","sources":["../../src/signal-forwarder.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,sEAAsE;AACtE,yEAAyE;AACzE,kEAAkE;AAClE,EAAE;AACF,oEAAoE;AACpE,mEAAmE;AAKnE,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAQlC,MAAM,eAAe,GAAmC;IACtD,MAAM;IACN,UAAU,EAAE,EAAE,MAAM,EAAE,2BAA2B,EAAE,MAAM,EAAE,eAAe,EAAE;IAC5E,SAAS,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,EAAE,UAAU,EAAE;IACrE,KAAK,EAAE,EAAE,MAAM,EAAE,0BAA0B,EAAE,MAAM,EAAE,UAAU,EAAE;IAEjE,kBAAkB;IAClB,MAAM,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,WAAW,EAAE;IAChE,aAAa,EAAE,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,EAAE,kBAAkB,EAAE;IAC9E,MAAM,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAC1E,eAAe,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,eAAe,EAAE;IAClF,YAAY,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,eAAe,EAAE;IAE/E,QAAQ;IACR,cAAc,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,gBAAgB,EAAE;IAClF,KAAK,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,oBAAoB,EAAE;IAE7E,wBAAwB;IACxB,IAAI,EAAE,EAAE,MAAM,EAAE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,CAAC,CAAC;YAC7D,IAAI,CAAC,IAAI,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACrD,CAAC;QACD,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,yBAAyB,EAAE,qBAAqB,CAAC;QAC7E,aAAa,EAAE,GAAG,EAAE;YAClB,sEAAsE;YACtE,kCAAkC;QACpC,CAAC;QACD,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;YACpB,MAAM,MAAM,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;YACpC,IAAI,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC,aAAa,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAC3F,CAAC;QACD,MAAM,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,CAAC,oBAAoB,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;QACtE,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,2BAA2B,CAAC;KACtD,CAAC;AACJ,CAAC,CAAC"}
|
|
Binary file
|
|
@@ -15,9 +15,9 @@ Copy the prompt below into your AI assistant (Claude, Cursor, Windsurf, or simil
|
|
|
15
15
|
|
|
16
16
|
````
|
|
17
17
|
You are helping me manage who can message my Mutiro agent. My agent is driven
|
|
18
|
-
by OpenClaw
|
|
19
|
-
allowlist is the authoritative gate — denied users are
|
|
20
|
-
The OpenClaw allowFrom is a second filter on top.
|
|
18
|
+
by OpenClaw via the Mutiro Channel extension, so there are two allowlists.
|
|
19
|
+
The Mutiro backend allowlist is the authoritative gate — denied users are
|
|
20
|
+
blocked at the server. The OpenClaw `allowFrom` is a second filter on top.
|
|
21
21
|
|
|
22
22
|
Be proactive — inspect current state before changing anything, and confirm
|
|
23
23
|
destructive changes (especially `set` calls that replace the whole list).
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Use OpenClaw as the Brain for Your Mutiro Agent
|
|
2
2
|
|
|
3
|
-
Copy the prompt below into your AI assistant (Claude, Cursor, Windsurf, or similar) and it will walk you through pointing [OpenClaw](https://openclaw.ai) at a [Mutiro](https://mutiro.com) agent
|
|
3
|
+
Copy the prompt below into your AI assistant (Claude, Cursor, Windsurf, or similar) and it will walk you through pointing [OpenClaw](https://openclaw.ai) at a [Mutiro](https://mutiro.com) agent via the Mutiro Channel extension. Mutiro stays the messaging platform; OpenClaw becomes the brain.
|
|
4
4
|
|
|
5
5
|
## The Prompt
|
|
6
6
|
|
|
7
7
|
````
|
|
8
|
-
You are helping me run an existing Mutiro agent with OpenClaw as its brain
|
|
8
|
+
You are helping me run an existing Mutiro agent with OpenClaw as its brain, connected through the Mutiro Channel extension for OpenClaw. Mutiro keeps the agent identity, connectivity, messaging, auth, and media plumbing. OpenClaw becomes the thinking layer and drives outbound replies through the Mutiro Channel.
|
|
9
9
|
|
|
10
10
|
Walk me through this step by step. Be proactive — run commands, check outputs, and make smart decisions based on what you find. Don't ask me things you can figure out by running a command. Only pause to ask when you genuinely need my input (like which LLM provider to use or what personality I want). When you need my input, ask me directly and wait for my response.
|
|
11
11
|
|
|
@@ -17,7 +17,7 @@ Walk me through this step by step. Be proactive — run commands, check outputs,
|
|
|
17
17
|
|
|
18
18
|
This guide assumes I already have a working Mutiro agent directory. If I don't, stop and point me at the Mutiro create-agent guide first:
|
|
19
19
|
|
|
20
|
-
> https://www.mutiro.com/docs/guides/create-agent
|
|
20
|
+
> https://www.mutiro.com/docs/guides/create-agent
|
|
21
21
|
|
|
22
22
|
Check what's already set up:
|
|
23
23
|
|
|
@@ -84,9 +84,9 @@ openclaw doctor
|
|
|
84
84
|
|
|
85
85
|
---
|
|
86
86
|
|
|
87
|
-
### Step 4: Install the
|
|
87
|
+
### Step 4: Install the Mutiro Channel extension
|
|
88
88
|
|
|
89
|
-
This
|
|
89
|
+
This extension is the piece that lets OpenClaw drive a Mutiro agent. It spawns `mutiro agent host --mode=bridge` as a subprocess and translates the Mutiro Channel protocol into OpenClaw inbound messages and outbound send/react/forward/voice/card calls.
|
|
90
90
|
|
|
91
91
|
Install from the published package:
|
|
92
92
|
|
|
@@ -105,15 +105,15 @@ cd ~/src/openclaw-brain
|
|
|
105
105
|
openclaw plugins install --dangerously-force-unsafe-install "file:$(pwd)"
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
-
**About `--dangerously-force-unsafe-install`**: this
|
|
109
|
-
spawns `mutiro agent host --mode=bridge` as a subprocess — that is the
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
explicit acknowledgement. Before you pass it, confirm you are
|
|
113
|
-
from the signed [`mutirolabs/openclaw-brain`](https://github.com/mutirolabs/openclaw-brain)
|
|
108
|
+
**About `--dangerously-force-unsafe-install`**: this extension legitimately
|
|
109
|
+
spawns `mutiro agent host --mode=bridge` as a subprocess — that is how the
|
|
110
|
+
Mutiro Channel carries traffic. OpenClaw's install scanner correctly flags
|
|
111
|
+
any extension that uses `child_process` as sensitive and requires this flag
|
|
112
|
+
as an explicit acknowledgement. Before you pass it, confirm you are
|
|
113
|
+
installing from the signed [`mutirolabs/openclaw-brain`](https://github.com/mutirolabs/openclaw-brain)
|
|
114
114
|
source (or the `@mutirolabs/openclaw-brain` npm package). Review the
|
|
115
115
|
`spawn` call at [`src/bridge-client.ts`](https://github.com/mutirolabs/openclaw-brain/blob/main/src/bridge-client.ts)
|
|
116
|
-
if you want to see exactly what the
|
|
116
|
+
if you want to see exactly what the extension executes.
|
|
117
117
|
|
|
118
118
|
Verify OpenClaw sees the channel:
|
|
119
119
|
|
|
@@ -320,9 +320,9 @@ Restart with `openclaw gateway run` after any config change.
|
|
|
320
320
|
|
|
321
321
|
### Step 12: Signals and Live Call Handoff
|
|
322
322
|
|
|
323
|
-
OpenClaw's tool activity is forwarded to Mutiro as
|
|
323
|
+
OpenClaw's tool activity is forwarded to Mutiro as channel signals, so Mutiro surfaces "thinking", "web searching", "recalling", "sending voice", etc. in real time while the agent works. The extension maps 26 OpenClaw tool names to Mutiro `SignalType` enums; anything outside the map falls back to `SIGNAL_TYPE_CUSTOM` with a detail label.
|
|
324
324
|
|
|
325
|
-
For live voice calls, Mutiro sends `task.request` with a compact observed-turn payload and expects a plain-text result. The
|
|
325
|
+
For live voice calls, Mutiro sends `task.request` with a compact observed-turn payload and expects a plain-text result. The extension accumulates the agent's reply text and returns it as the task result. It also answers `session.snapshot` from recent messages cached per-conversation so Mutiro can bootstrap the live lane.
|
|
326
326
|
|
|
327
327
|
Voice call **summaries** flow as normal `message.observed` envelopes tagged `live_call`. OpenClaw treats them as regular inbound turns — nothing extra to configure.
|
|
328
328
|
|
|
@@ -396,6 +396,6 @@ Help me review OpenClaw's `tools.profile` / `tools.alsoAllow` and the Mutiro `al
|
|
|
396
396
|
**Docs:**
|
|
397
397
|
- OpenClaw: https://openclaw.ai
|
|
398
398
|
- Mutiro: https://mutiro.com
|
|
399
|
-
- Create a Mutiro agent: https://www.mutiro.com/docs/guides/create-agent
|
|
399
|
+
- Create a Mutiro agent: https://www.mutiro.com/docs/guides/create-agent
|
|
400
400
|
- openclaw-brain repo: https://github.com/mutirolabs/openclaw-brain
|
|
401
401
|
````
|
package/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ import { defineBundledChannelEntry } from "openclaw/plugin-sdk/channel-entry-con
|
|
|
12
12
|
export default defineBundledChannelEntry({
|
|
13
13
|
id: "mutiro",
|
|
14
14
|
name: "Mutiro",
|
|
15
|
-
description: "Mutiro
|
|
15
|
+
description: "The official Mutiro Channel extension for OpenClaw.",
|
|
16
16
|
importMetaUrl: import.meta.url,
|
|
17
17
|
plugin: {
|
|
18
18
|
specifier: "./src/channel.js",
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"id": "mutiro",
|
|
3
3
|
"channels": ["mutiro"],
|
|
4
|
-
"channelEnvVars": {
|
|
5
|
-
"mutiro": ["MUTIRO_AGENT_API_KEY"]
|
|
6
|
-
},
|
|
7
4
|
"configSchema": {
|
|
8
5
|
"type": "object",
|
|
9
6
|
"additionalProperties": false,
|
|
@@ -24,6 +21,11 @@
|
|
|
24
21
|
"enabled": {
|
|
25
22
|
"type": "boolean"
|
|
26
23
|
},
|
|
24
|
+
"replyToMode": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"enum": ["off", "first", "all", "batched"],
|
|
27
|
+
"description": "How the agent's outbound messages thread under the inbound one. Default: \"first\" (quote the inbound on the first agent reply, then free-standing follow-ups)."
|
|
28
|
+
},
|
|
27
29
|
"accounts": {
|
|
28
30
|
"type": "object",
|
|
29
31
|
"additionalProperties": {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mutirolabs/openclaw-brain",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "The official Mutiro Channel extension for OpenClaw. OpenClaw is the brain; Mutiro is the messaging surface, identity, and state.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"repository": {
|
|
@@ -14,21 +14,23 @@
|
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
16
|
"check": "tsc -p tsconfig.json --noEmit",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
17
19
|
"gateway": "openclaw gateway run",
|
|
18
|
-
"prepublishOnly": "npm run check"
|
|
20
|
+
"prepublishOnly": "npm run check && npm run build"
|
|
19
21
|
},
|
|
20
22
|
"publishConfig": {
|
|
21
23
|
"access": "public"
|
|
22
24
|
},
|
|
23
25
|
"keywords": [
|
|
24
26
|
"mutiro",
|
|
25
|
-
"chatbridge",
|
|
26
27
|
"openclaw",
|
|
27
28
|
"channel",
|
|
28
|
-
"
|
|
29
|
+
"extension",
|
|
29
30
|
"agent"
|
|
30
31
|
],
|
|
31
32
|
"files": [
|
|
33
|
+
"dist",
|
|
32
34
|
"index.ts",
|
|
33
35
|
"src",
|
|
34
36
|
"docs",
|
|
@@ -63,10 +65,10 @@
|
|
|
63
65
|
"channel": {
|
|
64
66
|
"id": "mutiro",
|
|
65
67
|
"label": "Mutiro",
|
|
66
|
-
"selectionLabel": "Mutiro
|
|
68
|
+
"selectionLabel": "Mutiro",
|
|
67
69
|
"docsPath": "/channels/mutiro",
|
|
68
70
|
"docsLabel": "mutiro",
|
|
69
|
-
"blurb": "
|
|
71
|
+
"blurb": "Official Mutiro Channel for OpenClaw. Point at a Mutiro agent directory to enable.",
|
|
70
72
|
"order": 80,
|
|
71
73
|
"quickstartAllowFrom": true
|
|
72
74
|
},
|
package/src/agent-tools.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Channel-owned agent tools. Exposed to OpenClaw's agent loop via
|
|
2
|
-
// `ChannelPlugin.agentTools`. The first one
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// `ChannelPlugin.agentTools`. The first one is a text-to-speech voice
|
|
3
|
+
// message delivered through the bridge's `message.send_voice` command
|
|
4
|
+
// (host-side TTS, not client-side).
|
|
5
5
|
|
|
6
6
|
import { Type } from "@sinclair/typebox";
|
|
7
7
|
import type { ChannelAgentTool } from "openclaw/plugin-sdk/channel-contract";
|
package/src/bridge-client.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// NDJSON envelope codec + subprocess manager for the Mutiro chatbridge.
|
|
2
|
-
//
|
|
3
|
-
// transport-shaped so the rest of the plugin can treat the bridge as a
|
|
2
|
+
// Kept transport-shaped so the rest of the plugin can treat the bridge as a
|
|
4
3
|
// request/response channel regardless of which brain is on the other side.
|
|
5
4
|
|
|
6
5
|
import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
|
package/src/bridge-messages.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Message normalization helpers
|
|
2
|
-
//
|
|
1
|
+
// Message normalization helpers for inbound bridge envelopes. The host
|
|
2
|
+
// delivers `envelope.payload.message` as a pre-normalized bag of parts;
|
|
3
3
|
// these helpers turn that into plain text for the brain and into structured
|
|
4
4
|
// ObservedTurn records for downstream dispatch.
|
|
5
5
|
|
package/src/bridge-protocol.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// NDJSON protocol constants used by the Mutiro chatbridge envelope.
|
|
2
|
-
//
|
|
3
|
-
//
|
|
2
|
+
// These type URLs and helpers mirror the Mutiro bridge's protobuf surface
|
|
3
|
+
// envelope-for-envelope.
|
|
4
4
|
|
|
5
5
|
export const PROTOCOL_VERSION = "mutiro.agent.bridge.v1";
|
|
6
6
|
|
package/src/bridge-session.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Long-lived bridge session: owns the subprocess, performs the handshake,
|
|
2
2
|
// dispatches inbound envelopes, and keeps a narrow per-conversation cache for
|
|
3
|
-
// `session.snapshot`.
|
|
4
|
-
//
|
|
3
|
+
// `session.snapshot`. Structured so the OpenClaw plugin runtime can
|
|
4
|
+
// start/stop one session per configured Mutiro account.
|
|
5
5
|
|
|
6
6
|
import type { ChildProcessWithoutNullStreams } from "node:child_process";
|
|
7
7
|
|
package/src/channel.runtime.ts
CHANGED
|
@@ -30,6 +30,16 @@ type StartContext = ChannelGatewayContext<ResolvedMutiroAccount>;
|
|
|
30
30
|
|
|
31
31
|
const sessions = new Map<string, BridgeSession>();
|
|
32
32
|
|
|
33
|
+
// Crash-backoff state per account. Repeated crashes escalate the delay so we
|
|
34
|
+
// don't thrash the gateway's restart loop when the host is consistently
|
|
35
|
+
// failing (bad config, missing credential, host crash on boot, etc.). The
|
|
36
|
+
// streak resets when the last crash is older than `CRASH_STREAK_RESET_MS`,
|
|
37
|
+
// so a host that ran healthy for a while then crashed once starts over at
|
|
38
|
+
// the shortest backoff.
|
|
39
|
+
const CRASH_BACKOFF_MS = [1_000, 2_000, 5_000, 15_000, 60_000];
|
|
40
|
+
const CRASH_STREAK_RESET_MS = 5 * 60_000;
|
|
41
|
+
const crashState = new Map<string, { count: number; lastCrashAt: number }>();
|
|
42
|
+
|
|
33
43
|
const sessionKey = (channel: string, accountId: string) => `${channel}:${accountId}`;
|
|
34
44
|
|
|
35
45
|
const requireSessionForAccount = (accountId: string | null | undefined): BridgeSession => {
|
|
@@ -299,14 +309,55 @@ export const startMutiroAccount = async (ctx: StartContext) => {
|
|
|
299
309
|
: undefined,
|
|
300
310
|
onHostExit: (code) => {
|
|
301
311
|
sessions.delete(key);
|
|
302
|
-
|
|
312
|
+
const now = Date.now();
|
|
313
|
+
const isAbort = ctx.abortSignal.aborted;
|
|
314
|
+
const isCleanExit = code === 0 || isAbort;
|
|
315
|
+
|
|
316
|
+
if (isCleanExit) {
|
|
317
|
+
crashState.delete(ctx.accountId);
|
|
318
|
+
ctx.log?.info?.(
|
|
319
|
+
`mutiro: host (${ctx.accountId}) exited with code ${code}${isAbort ? " (abort)" : ""}`,
|
|
320
|
+
);
|
|
321
|
+
ctx.setStatus({
|
|
322
|
+
...ctx.getStatus(),
|
|
323
|
+
running: false,
|
|
324
|
+
connected: false,
|
|
325
|
+
lastDisconnect: { at: now, status: code ?? undefined },
|
|
326
|
+
});
|
|
327
|
+
settleLifecycle();
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Unexpected exit: track the streak, compute backoff, and hold the
|
|
332
|
+
// lifecycle promise until the delay elapses. The gateway's restart
|
|
333
|
+
// loop won't fire until we settle, so this delay is the effective
|
|
334
|
+
// backoff without touching gateway internals.
|
|
335
|
+
const prior = crashState.get(ctx.accountId);
|
|
336
|
+
const streak =
|
|
337
|
+
prior && now - prior.lastCrashAt < CRASH_STREAK_RESET_MS ? prior.count + 1 : 1;
|
|
338
|
+
crashState.set(ctx.accountId, { count: streak, lastCrashAt: now });
|
|
339
|
+
|
|
340
|
+
const delayMs = CRASH_BACKOFF_MS[Math.min(streak - 1, CRASH_BACKOFF_MS.length - 1)];
|
|
341
|
+
ctx.log?.warn?.(
|
|
342
|
+
`mutiro: host (${ctx.accountId}) exited unexpectedly with code ${code}; ` +
|
|
343
|
+
`restarting in ${Math.round(delayMs / 1000)}s (attempt ${streak})`,
|
|
344
|
+
);
|
|
303
345
|
ctx.setStatus({
|
|
304
346
|
...ctx.getStatus(),
|
|
305
347
|
running: false,
|
|
306
348
|
connected: false,
|
|
307
|
-
|
|
349
|
+
restartPending: true,
|
|
350
|
+
reconnectAttempts: streak,
|
|
351
|
+
lastDisconnect: {
|
|
352
|
+
at: now,
|
|
353
|
+
status: code ?? undefined,
|
|
354
|
+
error: `exit_code=${code ?? "null"}`,
|
|
355
|
+
},
|
|
308
356
|
});
|
|
309
|
-
|
|
357
|
+
|
|
358
|
+
setTimeout(() => {
|
|
359
|
+
settleLifecycle();
|
|
360
|
+
}, delayMs);
|
|
310
361
|
},
|
|
311
362
|
});
|
|
312
363
|
|
package/src/channel.ts
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
import type {
|
|
9
9
|
ChannelOutboundAdapter,
|
|
10
10
|
ChannelPlugin,
|
|
11
|
+
OpenClawConfig,
|
|
11
12
|
} from "openclaw/plugin-sdk/core";
|
|
12
13
|
import { createChatChannelPlugin } from "openclaw/plugin-sdk/core";
|
|
13
14
|
import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
|
|
14
15
|
|
|
16
|
+
type ReplyToMode = "off" | "first" | "all" | "batched";
|
|
17
|
+
|
|
15
18
|
import { mutiroMessageActions } from "./actions.js";
|
|
16
19
|
import { mutiroAgentTools } from "./agent-tools.js";
|
|
17
20
|
import { mutiroConfigAdapter, type ResolvedMutiroAccount } from "./config.js";
|
|
@@ -43,6 +46,23 @@ const outbound: ChannelOutboundAdapter = {
|
|
|
43
46
|
},
|
|
44
47
|
};
|
|
45
48
|
|
|
49
|
+
// Read `channels.mutiro.replyToMode` as an override; otherwise default to
|
|
50
|
+
// `"first"` so the agent's first reply in a turn threads under the inbound
|
|
51
|
+
// message. Mutiro clients render reply-to as a visible quoted pill, so this
|
|
52
|
+
// anchors context nicely in groups without being noisy in DMs. Set
|
|
53
|
+
// `channels.mutiro.replyToMode` to `"off"`, `"all"`, or `"batched"` in the
|
|
54
|
+
// OpenClaw config to override.
|
|
55
|
+
const resolveMutiroReplyToMode = ({ cfg }: { cfg: OpenClawConfig }): ReplyToMode => {
|
|
56
|
+
const section = (cfg as { channels?: Record<string, unknown> }).channels?.mutiro as
|
|
57
|
+
| { replyToMode?: unknown }
|
|
58
|
+
| undefined;
|
|
59
|
+
const configured = section?.replyToMode;
|
|
60
|
+
if (configured === "off" || configured === "first" || configured === "all" || configured === "batched") {
|
|
61
|
+
return configured;
|
|
62
|
+
}
|
|
63
|
+
return "first";
|
|
64
|
+
};
|
|
65
|
+
|
|
46
66
|
export const mutiroPlugin: ChannelPlugin<ResolvedMutiroAccount> = createChatChannelPlugin<
|
|
47
67
|
ResolvedMutiroAccount
|
|
48
68
|
>({
|
|
@@ -51,10 +71,10 @@ export const mutiroPlugin: ChannelPlugin<ResolvedMutiroAccount> = createChatChan
|
|
|
51
71
|
meta: {
|
|
52
72
|
id: "mutiro",
|
|
53
73
|
label: "Mutiro",
|
|
54
|
-
selectionLabel: "Mutiro
|
|
74
|
+
selectionLabel: "Mutiro",
|
|
55
75
|
docsPath: "/channels/mutiro",
|
|
56
76
|
docsLabel: "mutiro",
|
|
57
|
-
blurb: "
|
|
77
|
+
blurb: "Official Mutiro Channel for OpenClaw. Point at a Mutiro agent directory to enable.",
|
|
58
78
|
order: 80,
|
|
59
79
|
quickstartAllowFrom: true,
|
|
60
80
|
markdownCapable: true,
|
|
@@ -125,6 +145,45 @@ export const mutiroPlugin: ChannelPlugin<ResolvedMutiroAccount> = createChatChan
|
|
|
125
145
|
await runtime.stopMutiroAccount(ctx);
|
|
126
146
|
},
|
|
127
147
|
},
|
|
148
|
+
|
|
149
|
+
// Status adapter: answers `openclaw channels status mutiro`. The runtime
|
|
150
|
+
// already updates `running` / `connected` / `lastConnectedAt` /
|
|
151
|
+
// `reconnectAttempts` via `ctx.setStatus()` when the bridge subprocess
|
|
152
|
+
// starts, handshakes, exits, or is in backoff. Here we just enrich the
|
|
153
|
+
// snapshot with Mutiro-specific context (agent workspace path, bridge
|
|
154
|
+
// mode, derived health string).
|
|
155
|
+
status: {
|
|
156
|
+
buildAccountSnapshot: ({ account, runtime }) => {
|
|
157
|
+
const base = runtime ?? { accountId: account.accountId };
|
|
158
|
+
const running = base.running ?? false;
|
|
159
|
+
const connected = base.connected ?? false;
|
|
160
|
+
const restartPending = base.restartPending ?? false;
|
|
161
|
+
const healthState = !running
|
|
162
|
+
? restartPending
|
|
163
|
+
? "restarting"
|
|
164
|
+
: "stopped"
|
|
165
|
+
: connected
|
|
166
|
+
? "healthy"
|
|
167
|
+
: "connecting";
|
|
168
|
+
return {
|
|
169
|
+
...base,
|
|
170
|
+
accountId: account.accountId,
|
|
171
|
+
configured: account.configured,
|
|
172
|
+
enabled: account.enabled,
|
|
173
|
+
mode: "bridge",
|
|
174
|
+
healthState,
|
|
175
|
+
dbPath: account.config.agentDir ?? null,
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
// Threading adapter: Mutiro natively supports `reply_to_message_id`, so wire
|
|
181
|
+
// OpenClaw's reply-dispatch into it. `allowExplicitReplyTagsWhenOff` keeps
|
|
182
|
+
// agent-directed reply markers working even when the user has disabled
|
|
183
|
+
// automatic reply-threading.
|
|
184
|
+
threading: {
|
|
185
|
+
resolveReplyToMode: resolveMutiroReplyToMode,
|
|
186
|
+
allowExplicitReplyTagsWhenOff: true,
|
|
128
187
|
},
|
|
129
188
|
outbound,
|
|
130
189
|
});
|
package/src/outbound.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Outbound adapter that translates OpenClaw reply-dispatch calls into
|
|
2
|
-
// bridge-local commands
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// ChannelOutboundAdapter is the consumer instead of a Pi tool runtime.
|
|
2
|
+
// bridge-local commands: send_message, send_voice_message, send_card,
|
|
3
|
+
// react_to_message, send_file_message, forward_message, recall,
|
|
4
|
+
// recall_get. Shaped around OpenClaw's ChannelOutboundAdapter contract.
|
|
6
5
|
|
|
7
6
|
import * as path from "node:path";
|
|
8
7
|
|
|
@@ -112,9 +111,8 @@ const buildCardJson = (
|
|
|
112
111
|
|
|
113
112
|
return {
|
|
114
113
|
// Field names must match Mutiro's CardPart protobuf schema (see
|
|
115
|
-
// spec/protobuf/shared/messaging.proto).
|
|
116
|
-
//
|
|
117
|
-
// decoder rejects as unknown fields.
|
|
114
|
+
// spec/protobuf/shared/messaging.proto). The host's strict JSON-to-proto
|
|
115
|
+
// decoder rejects unknown field names like `json_data` / `version`.
|
|
118
116
|
a2ui_json: lines.join("\n"),
|
|
119
117
|
schema_version: "0.8",
|
|
120
118
|
card_id: cardId || `openclaw-card-${Math.random().toString(36).slice(2, 10)}`,
|
package/src/setup-surface.ts
CHANGED
|
@@ -26,7 +26,7 @@ import { listMutiroAccountIds, resolveMutiroAccount } from "./config.js";
|
|
|
26
26
|
|
|
27
27
|
const channel = "mutiro" as const;
|
|
28
28
|
const INSTALL_URL = "https://mutiro.com/downloads/install.sh";
|
|
29
|
-
const CREATE_AGENT_GUIDE = "https://www.mutiro.com/docs/guides/create-agent
|
|
29
|
+
const CREATE_AGENT_GUIDE = "https://www.mutiro.com/docs/guides/create-agent";
|
|
30
30
|
|
|
31
31
|
const MUTIRO_INTRO_LINES = [
|
|
32
32
|
"Point OpenClaw at an existing Mutiro agent directory.",
|
|
@@ -167,7 +167,7 @@ export const mutiroSetupWizard: ChannelSetupWizard = {
|
|
|
167
167
|
resolveExtraStatusLines: ({ cfg }) => [`Accounts: ${listMutiroAccountIds(cfg).length || 0}`],
|
|
168
168
|
}),
|
|
169
169
|
introNote: {
|
|
170
|
-
title: "Mutiro
|
|
170
|
+
title: "Mutiro Channel setup",
|
|
171
171
|
lines: MUTIRO_INTRO_LINES,
|
|
172
172
|
},
|
|
173
173
|
prepare: async ({ prompter }) => {
|
|
@@ -225,25 +225,53 @@ export const mutiroSetupWizard: ChannelSetupWizard = {
|
|
|
225
225
|
const dir = resolveMutiroAccount(cfg, accountId).config.agentDir;
|
|
226
226
|
if (!dir) return undefined;
|
|
227
227
|
|
|
228
|
+
const issues: string[] = [];
|
|
229
|
+
|
|
228
230
|
const whoami = await runPluginCommandWithTimeout({
|
|
229
231
|
argv: ["mutiro", "auth", "whoami"],
|
|
230
232
|
timeoutMs: 5_000,
|
|
231
233
|
cwd: dir,
|
|
232
234
|
});
|
|
233
|
-
|
|
234
235
|
if (whoami.code !== 0) {
|
|
235
|
-
|
|
236
|
+
issues.push(
|
|
236
237
|
[
|
|
237
|
-
"
|
|
238
|
-
"",
|
|
239
|
-
"Finish Mutiro-side setup before starting the gateway:",
|
|
238
|
+
"Mutiro auth not confirmed. Log in before starting the gateway:",
|
|
240
239
|
` cd ${dir}`,
|
|
241
240
|
" mutiro auth login <email>",
|
|
242
|
-
"",
|
|
243
|
-
"Also make sure the built-in Mutiro brain is NOT running for this agent —",
|
|
244
|
-
"running two brains at once will fight over the same conversations:",
|
|
245
|
-
" mutiro agent doctor",
|
|
246
241
|
].join("\n"),
|
|
242
|
+
);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Built-in brain check: `mutiro agent host status` exits 0 when a host
|
|
246
|
+
// process is already running for this agent. Starting OpenClaw's gateway
|
|
247
|
+
// on top of a running host would put two brains on one agent and make
|
|
248
|
+
// them race on every turn. `host doctor` (setup validation) is separate
|
|
249
|
+
// from `host status` (runtime liveness) — we want the latter here.
|
|
250
|
+
const hostStatus = await runPluginCommandWithTimeout({
|
|
251
|
+
argv: ["mutiro", "agent", "host", "status"],
|
|
252
|
+
timeoutMs: 5_000,
|
|
253
|
+
cwd: dir,
|
|
254
|
+
});
|
|
255
|
+
if (hostStatus.code === 0) {
|
|
256
|
+
issues.push(
|
|
257
|
+
[
|
|
258
|
+
"A Mutiro agent host is already running for this agent.",
|
|
259
|
+
"Stop it before starting OpenClaw — two brains on one agent will",
|
|
260
|
+
"race on every turn:",
|
|
261
|
+
" pkill -f 'mutiro agent host' # or stop whichever process started it",
|
|
262
|
+
].join("\n"),
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
if (issues.length > 0) {
|
|
267
|
+
await prompter.note(
|
|
268
|
+
[
|
|
269
|
+
"Readiness checks flagged the following:",
|
|
270
|
+
"",
|
|
271
|
+
...issues.flatMap((issue) => [issue, ""]),
|
|
272
|
+
]
|
|
273
|
+
.join("\n")
|
|
274
|
+
.trimEnd(),
|
|
247
275
|
"Mutiro agent readiness",
|
|
248
276
|
);
|
|
249
277
|
}
|