@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,547 @@
|
|
|
1
|
+
// Channel-owned agent tools. Exposed to OpenClaw's agent loop via
|
|
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
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
import { DEFAULT_ACCOUNT_ID } from "./config.js";
|
|
7
|
+
// Host errors arrive as structured { code, message } objects. Our catch
|
|
8
|
+
// blocks previously called String(err), which rendered them as
|
|
9
|
+
// "[object Object]" and hid the real reason for a rejected bridge request.
|
|
10
|
+
const formatBridgeError = (err) => {
|
|
11
|
+
if (err instanceof Error)
|
|
12
|
+
return err.message;
|
|
13
|
+
if (err && typeof err === "object") {
|
|
14
|
+
const record = err;
|
|
15
|
+
const parts = [];
|
|
16
|
+
if (record.code)
|
|
17
|
+
parts.push(record.code);
|
|
18
|
+
if (record.message)
|
|
19
|
+
parts.push(record.message);
|
|
20
|
+
if (parts.length > 0)
|
|
21
|
+
return parts.join(": ");
|
|
22
|
+
try {
|
|
23
|
+
return JSON.stringify(err);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// fall through
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return String(err);
|
|
30
|
+
};
|
|
31
|
+
const createSendVoiceMessageTool = () => ({
|
|
32
|
+
name: "mutiro_send_voice_message",
|
|
33
|
+
label: "Send Mutiro Voice Message",
|
|
34
|
+
description: "Send a text-to-speech voice message to a Mutiro user. The host synthesizes the audio; this does not upload a file. Use when the user asked for an audio reply or when voice is the right modality.",
|
|
35
|
+
parameters: Type.Object({
|
|
36
|
+
to_username: Type.String({
|
|
37
|
+
description: "Target Mutiro username. Leading '@' is optional.",
|
|
38
|
+
}),
|
|
39
|
+
speech: Type.String({
|
|
40
|
+
description: "Plain text to synthesize into speech. Keep it short and speakable.",
|
|
41
|
+
}),
|
|
42
|
+
language: Type.Optional(Type.String({
|
|
43
|
+
description: "Optional BCP-47 language code (e.g. en-US, pt-BR). Retargets the default voice.",
|
|
44
|
+
})),
|
|
45
|
+
conversation_id: Type.Optional(Type.String({
|
|
46
|
+
description: "Conversation id to thread the voice message under. Defaults to direct DM.",
|
|
47
|
+
})),
|
|
48
|
+
reply_to_message_id: Type.Optional(Type.String({
|
|
49
|
+
description: "Optional id of the message being replied to.",
|
|
50
|
+
})),
|
|
51
|
+
account_id: Type.Optional(Type.String({
|
|
52
|
+
description: "Mutiro account id to send from. Omit for the default account when only one is configured.",
|
|
53
|
+
})),
|
|
54
|
+
}),
|
|
55
|
+
execute: async (_toolCallId, rawArgs) => {
|
|
56
|
+
const args = (rawArgs ?? {});
|
|
57
|
+
const toUsername = (args.to_username ?? "").trim();
|
|
58
|
+
const speech = (args.speech ?? "").trim();
|
|
59
|
+
if (!toUsername) {
|
|
60
|
+
return {
|
|
61
|
+
content: [{ type: "text", text: "to_username is required." }],
|
|
62
|
+
details: { ok: false, reason: "missing_to_username" },
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (!speech) {
|
|
66
|
+
return {
|
|
67
|
+
content: [{ type: "text", text: "speech is required." }],
|
|
68
|
+
details: { ok: false, reason: "missing_speech" },
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const accountId = (args.account_id ?? "").trim() || DEFAULT_ACCOUNT_ID;
|
|
72
|
+
// Dynamic import keeps the heavy channel runtime off the hot import path
|
|
73
|
+
// (the agentTools factory runs during plugin registration; execute only
|
|
74
|
+
// runs when the agent actually calls the tool).
|
|
75
|
+
const { getMutiroBridgeSession } = await import("./channel.runtime.js");
|
|
76
|
+
const session = getMutiroBridgeSession(accountId);
|
|
77
|
+
if (!session) {
|
|
78
|
+
return {
|
|
79
|
+
content: [
|
|
80
|
+
{
|
|
81
|
+
type: "text",
|
|
82
|
+
text: `Mutiro bridge session for account "${accountId}" is not running.`,
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
details: { ok: false, reason: "no_active_session", accountId },
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const result = await session.outbound.sendVoice({
|
|
90
|
+
conversationId: args.conversation_id ?? "",
|
|
91
|
+
replyToMessageId: args.reply_to_message_id ?? "",
|
|
92
|
+
}, {
|
|
93
|
+
toUsername,
|
|
94
|
+
speech,
|
|
95
|
+
...(args.language ? { language: args.language } : {}),
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
content: [{ type: "text", text: "Voice message sent." }],
|
|
99
|
+
details: { ok: true, raw: result },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
const message = formatBridgeError(err);
|
|
104
|
+
return {
|
|
105
|
+
content: [{ type: "text", text: `Failed to send voice message: ${message}` }],
|
|
106
|
+
details: { ok: false, reason: "bridge_error", error: message },
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
// Valid A2UI v0.8 payloads. Shapes taken directly from
|
|
112
|
+
// @a2ui/web_core/src/v0_8/schemas/server_to_client_with_standard_catalog.json
|
|
113
|
+
// — the schema the Mutiro client renderer actually validates against:
|
|
114
|
+
// - components[].component is a SINGULAR wrapper with ONE key (the type)
|
|
115
|
+
// - Column.children is { explicitList: [id, id, ...] } (not a bare array)
|
|
116
|
+
// - Button references a child Text component by id in its `child` field;
|
|
117
|
+
// it does NOT have a `label` property
|
|
118
|
+
// - Text content is text.literalString (or text.path for data bindings)
|
|
119
|
+
// - Image.url follows the SAME shape as Text.text — an object with EITHER
|
|
120
|
+
// literalString OR path, never a bare string
|
|
121
|
+
// - dataModelUpdate.contents is an ARRAY of { key, valueString|valueNumber|
|
|
122
|
+
// valueBoolean|valueMap }, not a flat object
|
|
123
|
+
const CARD_EXAMPLE_BUTTON = [
|
|
124
|
+
JSON.stringify({
|
|
125
|
+
surfaceUpdate: {
|
|
126
|
+
surfaceId: "main",
|
|
127
|
+
components: [
|
|
128
|
+
{
|
|
129
|
+
id: "root",
|
|
130
|
+
component: { Column: { children: { explicitList: ["btn"] } } },
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
id: "btn",
|
|
134
|
+
component: {
|
|
135
|
+
Button: { child: "btn_label", action: { name: "say_hello" }, primary: true },
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "btn_label",
|
|
140
|
+
component: { Text: { text: { literalString: "olá" } } },
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
},
|
|
144
|
+
}),
|
|
145
|
+
JSON.stringify({ beginRendering: { surfaceId: "main", root: "root" } }),
|
|
146
|
+
].join("\n");
|
|
147
|
+
const CARD_EXAMPLE_IMAGE_LITERAL = [
|
|
148
|
+
JSON.stringify({
|
|
149
|
+
surfaceUpdate: {
|
|
150
|
+
surfaceId: "main",
|
|
151
|
+
components: [
|
|
152
|
+
{
|
|
153
|
+
id: "root",
|
|
154
|
+
component: { Column: { children: { explicitList: ["title", "pic"] } } },
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
id: "title",
|
|
158
|
+
component: { Text: { text: { literalString: "Google" } } },
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "pic",
|
|
162
|
+
component: {
|
|
163
|
+
Image: {
|
|
164
|
+
url: {
|
|
165
|
+
literalString: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png",
|
|
166
|
+
},
|
|
167
|
+
fit: "contain",
|
|
168
|
+
usageHint: "mediumFeature",
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
JSON.stringify({ beginRendering: { surfaceId: "main", root: "root" } }),
|
|
176
|
+
].join("\n");
|
|
177
|
+
// Same card as above but using a data-model path binding for the URL, to show
|
|
178
|
+
// the correct dataModelUpdate.contents array-of-typed-entries shape. Prefer
|
|
179
|
+
// literalString for fixed content; use path bindings only when the data will
|
|
180
|
+
// change (forms, templated lists).
|
|
181
|
+
const CARD_EXAMPLE_IMAGE_BINDING = [
|
|
182
|
+
JSON.stringify({
|
|
183
|
+
surfaceUpdate: {
|
|
184
|
+
surfaceId: "main",
|
|
185
|
+
components: [
|
|
186
|
+
{
|
|
187
|
+
id: "root",
|
|
188
|
+
component: { Column: { children: { explicitList: ["pic"] } } },
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: "pic",
|
|
192
|
+
component: {
|
|
193
|
+
Image: {
|
|
194
|
+
url: { path: "/poster" },
|
|
195
|
+
fit: "contain",
|
|
196
|
+
usageHint: "mediumFeature",
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
}),
|
|
203
|
+
JSON.stringify({
|
|
204
|
+
dataModelUpdate: {
|
|
205
|
+
surfaceId: "main",
|
|
206
|
+
contents: [
|
|
207
|
+
{
|
|
208
|
+
key: "poster",
|
|
209
|
+
valueString: "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png",
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
},
|
|
213
|
+
}),
|
|
214
|
+
JSON.stringify({ beginRendering: { surfaceId: "main", root: "root" } }),
|
|
215
|
+
].join("\n");
|
|
216
|
+
// Property names whose values must be the A2UI { literalString | path }
|
|
217
|
+
// envelope rather than a bare string. Common renderer-silent failure: the
|
|
218
|
+
// model writes `url: "https://..."` directly and the renderer just shows
|
|
219
|
+
// nothing because `url.literalString` / `url.path` are both undefined.
|
|
220
|
+
const LITERAL_OR_PATH_PROPERTIES_BY_COMPONENT_TYPE = {
|
|
221
|
+
Text: ["text"],
|
|
222
|
+
Heading: ["text"],
|
|
223
|
+
Image: ["url"],
|
|
224
|
+
Icon: ["name"],
|
|
225
|
+
};
|
|
226
|
+
const looksLikeBareString = (value) => typeof value === "string" && value.length > 0;
|
|
227
|
+
const isLiteralOrPathEnvelope = (value) => {
|
|
228
|
+
if (!value || typeof value !== "object")
|
|
229
|
+
return false;
|
|
230
|
+
const envelope = value;
|
|
231
|
+
return typeof envelope.literalString === "string" || typeof envelope.path === "string";
|
|
232
|
+
};
|
|
233
|
+
const validateComponentShape = (rawComp, lineNumber, componentIndex) => {
|
|
234
|
+
if (!rawComp || typeof rawComp !== "object") {
|
|
235
|
+
return `line ${lineNumber}: component at index ${componentIndex} is not an object`;
|
|
236
|
+
}
|
|
237
|
+
const comp = rawComp;
|
|
238
|
+
if (typeof comp.id !== "string" || !comp.id) {
|
|
239
|
+
return `line ${lineNumber}: component at index ${componentIndex} is missing a string "id"`;
|
|
240
|
+
}
|
|
241
|
+
if (comp.componentProperties !== undefined && comp.component === undefined) {
|
|
242
|
+
return `line ${lineNumber}: component "${comp.id}" uses "componentProperties" — the correct A2UI v0.8 field name is "component" (singular)`;
|
|
243
|
+
}
|
|
244
|
+
if (!comp.component || typeof comp.component !== "object") {
|
|
245
|
+
return `line ${lineNumber}: component "${comp.id}" is missing a "component" wrapper object`;
|
|
246
|
+
}
|
|
247
|
+
const typeKeys = Object.keys(comp.component);
|
|
248
|
+
if (typeKeys.length !== 1) {
|
|
249
|
+
return `line ${lineNumber}: component "${comp.id}".component must contain exactly one key (the type name, e.g. Text/Button/Image); got ${typeKeys.length} keys (${typeKeys.join(", ")})`;
|
|
250
|
+
}
|
|
251
|
+
const typeName = typeKeys[0];
|
|
252
|
+
const typeProps = comp.component[typeName];
|
|
253
|
+
const requiredLiteralOrPathProps = LITERAL_OR_PATH_PROPERTIES_BY_COMPONENT_TYPE[typeName];
|
|
254
|
+
if (requiredLiteralOrPathProps && typeProps && typeof typeProps === "object") {
|
|
255
|
+
const propsRecord = typeProps;
|
|
256
|
+
for (const propName of requiredLiteralOrPathProps) {
|
|
257
|
+
const value = propsRecord[propName];
|
|
258
|
+
if (value === undefined)
|
|
259
|
+
continue;
|
|
260
|
+
if (looksLikeBareString(value)) {
|
|
261
|
+
return `line ${lineNumber}: component "${comp.id}" (${typeName}).${propName} is a bare string — must be an object with either "literalString" or "path"`;
|
|
262
|
+
}
|
|
263
|
+
if (!isLiteralOrPathEnvelope(value)) {
|
|
264
|
+
return `line ${lineNumber}: component "${comp.id}" (${typeName}).${propName} must be an object with either "literalString" or "path"`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
};
|
|
270
|
+
const validateCardJsonl = (jsonl) => {
|
|
271
|
+
// Minimal structural guard so we reject obvious model mistakes with a clear
|
|
272
|
+
// error instead of letting the Mutiro client throw "undefined is not an
|
|
273
|
+
// object (evaluating 'message.components')" at the renderer.
|
|
274
|
+
let sawSurfaceUpdateWithComponents = false;
|
|
275
|
+
let sawBeginRendering = false;
|
|
276
|
+
const lines = jsonl.split(/\r?\n/).filter((line) => line.trim().length > 0);
|
|
277
|
+
for (const [index, raw] of lines.entries()) {
|
|
278
|
+
let parsed;
|
|
279
|
+
try {
|
|
280
|
+
parsed = JSON.parse(raw);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
return `line ${index + 1} is not valid JSON`;
|
|
284
|
+
}
|
|
285
|
+
if (!parsed || typeof parsed !== "object") {
|
|
286
|
+
return `line ${index + 1} is not a JSON object`;
|
|
287
|
+
}
|
|
288
|
+
const env = parsed;
|
|
289
|
+
if (env.surfaceUpdate) {
|
|
290
|
+
const update = env.surfaceUpdate;
|
|
291
|
+
if (!Array.isArray(update.components)) {
|
|
292
|
+
return `line ${index + 1}: surfaceUpdate is missing a "components" array`;
|
|
293
|
+
}
|
|
294
|
+
for (const [compIdx, rawComp] of update.components.entries()) {
|
|
295
|
+
const compError = validateComponentShape(rawComp, index + 1, compIdx);
|
|
296
|
+
if (compError)
|
|
297
|
+
return compError;
|
|
298
|
+
}
|
|
299
|
+
sawSurfaceUpdateWithComponents = true;
|
|
300
|
+
}
|
|
301
|
+
if (env.dataModelUpdate) {
|
|
302
|
+
const update = env.dataModelUpdate;
|
|
303
|
+
if (update.contents !== undefined && !Array.isArray(update.contents)) {
|
|
304
|
+
return `line ${index + 1}: dataModelUpdate.contents must be an array of { key, valueString|valueNumber|valueBoolean|valueMap } entries (got an object — likely a map instead of a typed-entry array)`;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (env.beginRendering) {
|
|
308
|
+
const begin = env.beginRendering;
|
|
309
|
+
if (typeof begin.root !== "string" || !begin.root) {
|
|
310
|
+
return `line ${index + 1}: beginRendering is missing a "root" component id`;
|
|
311
|
+
}
|
|
312
|
+
sawBeginRendering = true;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
if (!sawSurfaceUpdateWithComponents) {
|
|
316
|
+
return "jsonl must include at least one surfaceUpdate line with a components array";
|
|
317
|
+
}
|
|
318
|
+
if (!sawBeginRendering) {
|
|
319
|
+
return "jsonl must include a final beginRendering line referencing a root component id";
|
|
320
|
+
}
|
|
321
|
+
return null;
|
|
322
|
+
};
|
|
323
|
+
const createSendCardTool = () => ({
|
|
324
|
+
name: "mutiro_send_card",
|
|
325
|
+
label: "Send Mutiro Card",
|
|
326
|
+
description: [
|
|
327
|
+
"Send an interactive A2UI v0.8 card into a Mutiro conversation. The `jsonl` argument is one JSON object per line (same format as the `canvas` tool's `a2ui_push` action).",
|
|
328
|
+
"Envelope types: `surfaceUpdate`, optional `dataModelUpdate`, then `beginRendering`.",
|
|
329
|
+
"",
|
|
330
|
+
"Component shape (critical — wrong shape renders a blank card with no error):",
|
|
331
|
+
"- Each component has an `id` and a `component` object (SINGULAR; not `componentProperties`).",
|
|
332
|
+
"- `component` has EXACTLY one key: the type name (`Column`, `Row`, `Text`, `Button`, `Heading`, `Image`, `TextField`, `CheckBox`, etc.).",
|
|
333
|
+
"- `Column`/`Row` children go in `children.explicitList: [id, id]` (NOT a bare array).",
|
|
334
|
+
"- `Button` references a child Text component by id via the `child` field. It does NOT accept a `label` string directly.",
|
|
335
|
+
"- `Text` content is `text.literalString: '...'` (or `text.path: '/some/binding'` for data-model bindings).",
|
|
336
|
+
"- `Image` url uses the SAME shape as Text.text — `url.literalString: 'https://...'` OR `url.path: '/some/key'`. NEVER `url: 'https://...'` as a bare string.",
|
|
337
|
+
"- `Icon` name uses the same literalString/path shape.",
|
|
338
|
+
"- Every id referenced anywhere (children, Button.child, beginRendering.root) MUST exist as a component in the same `components` array.",
|
|
339
|
+
"",
|
|
340
|
+
"Literal vs path — prefer literal for fixed content, use path only for bindings:",
|
|
341
|
+
"- For a static image, a fixed heading, a one-off button — use `{ literalString: '...' }`. No dataModelUpdate needed.",
|
|
342
|
+
"- For templated lists, form inputs that bind back to the agent, or content that should update without rebuilding the surface — use `{ path: '/some/key' }` and ship a `dataModelUpdate` with matching entries.",
|
|
343
|
+
"",
|
|
344
|
+
"`dataModelUpdate.contents` is an ARRAY of typed entries, NOT a flat object. Each entry is `{ key, valueString }` (or `valueNumber`, `valueBoolean`, `valueMap`). Writing `contents: { poster: '...' }` leaves the model empty and every `path`-bound property resolves to undefined.",
|
|
345
|
+
"",
|
|
346
|
+
"Working example 1 — button with text (simplest interactive):",
|
|
347
|
+
CARD_EXAMPLE_BUTTON,
|
|
348
|
+
"",
|
|
349
|
+
"Working example 2 — image with literal URL (preferred for fixed images):",
|
|
350
|
+
CARD_EXAMPLE_IMAGE_LITERAL,
|
|
351
|
+
"",
|
|
352
|
+
"Working example 3 — image URL via data-model binding (only when binding is needed). Note the `contents` ARRAY shape:",
|
|
353
|
+
CARD_EXAMPLE_IMAGE_BINDING,
|
|
354
|
+
"",
|
|
355
|
+
"Minimum structural rules enforced by this tool:",
|
|
356
|
+
"- At least one `surfaceUpdate` line with a non-empty `components` array.",
|
|
357
|
+
"- Exactly one final `beginRendering` line with a `root` id that exists in the surface.",
|
|
358
|
+
"",
|
|
359
|
+
"If a card is needed, prefer a simple Column-of-Text for text-only output and only add interactive components (Button, TextField, CheckBox) when the user would actually interact with them.",
|
|
360
|
+
].join("\n"),
|
|
361
|
+
parameters: Type.Object({
|
|
362
|
+
jsonl: Type.String({
|
|
363
|
+
description: "A2UI JSONL payload. One JSON object per line. Typically: a `surfaceUpdate` with components, an optional `dataModelUpdate` for bindings, and a final `beginRendering` to commit.",
|
|
364
|
+
}),
|
|
365
|
+
conversation_id: Type.Optional(Type.String({
|
|
366
|
+
description: "Conversation id to deliver the card to. Defaults to the conversation the agent is currently replying in.",
|
|
367
|
+
})),
|
|
368
|
+
reply_to_message_id: Type.Optional(Type.String({
|
|
369
|
+
description: "Optional id of the message the card replies to.",
|
|
370
|
+
})),
|
|
371
|
+
card_id: Type.Optional(Type.String({
|
|
372
|
+
description: "Optional stable id. One is generated automatically if omitted.",
|
|
373
|
+
})),
|
|
374
|
+
version: Type.Optional(Type.String({
|
|
375
|
+
description: "A2UI protocol version. Defaults to 0.8.",
|
|
376
|
+
})),
|
|
377
|
+
account_id: Type.Optional(Type.String({
|
|
378
|
+
description: "Mutiro account id to send from. Omit for the default account when only one is configured.",
|
|
379
|
+
})),
|
|
380
|
+
}),
|
|
381
|
+
execute: async (_toolCallId, rawArgs) => {
|
|
382
|
+
const args = (rawArgs ?? {});
|
|
383
|
+
const jsonl = (args.jsonl ?? "").trim();
|
|
384
|
+
if (!jsonl) {
|
|
385
|
+
return {
|
|
386
|
+
content: [{ type: "text", text: "jsonl is required." }],
|
|
387
|
+
details: { ok: false, reason: "missing_jsonl" },
|
|
388
|
+
};
|
|
389
|
+
}
|
|
390
|
+
const validationError = validateCardJsonl(jsonl);
|
|
391
|
+
if (validationError) {
|
|
392
|
+
return {
|
|
393
|
+
content: [
|
|
394
|
+
{
|
|
395
|
+
type: "text",
|
|
396
|
+
text: `Card jsonl is malformed: ${validationError}. Please retry using the example in the tool description.`,
|
|
397
|
+
},
|
|
398
|
+
],
|
|
399
|
+
details: { ok: false, reason: "invalid_jsonl", error: validationError },
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
const accountId = (args.account_id ?? "").trim() || DEFAULT_ACCOUNT_ID;
|
|
403
|
+
const { getMutiroBridgeSession } = await import("./channel.runtime.js");
|
|
404
|
+
const session = getMutiroBridgeSession(accountId);
|
|
405
|
+
if (!session) {
|
|
406
|
+
return {
|
|
407
|
+
content: [
|
|
408
|
+
{
|
|
409
|
+
type: "text",
|
|
410
|
+
text: `Mutiro bridge session for account "${accountId}" is not running.`,
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
details: { ok: false, reason: "no_active_session", accountId },
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const result = await session.outbound.sendCardJsonl({
|
|
418
|
+
conversationId: args.conversation_id ?? "",
|
|
419
|
+
replyToMessageId: args.reply_to_message_id ?? "",
|
|
420
|
+
}, {
|
|
421
|
+
jsonl,
|
|
422
|
+
...(args.version ? { version: args.version } : {}),
|
|
423
|
+
...(args.card_id ? { cardId: args.card_id } : {}),
|
|
424
|
+
});
|
|
425
|
+
return {
|
|
426
|
+
content: [{ type: "text", text: "Card sent." }],
|
|
427
|
+
details: { ok: true, raw: result },
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
catch (err) {
|
|
431
|
+
const message = formatBridgeError(err);
|
|
432
|
+
return {
|
|
433
|
+
content: [{ type: "text", text: `Failed to send card: ${message}` }],
|
|
434
|
+
details: { ok: false, reason: "bridge_error", error: message },
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
});
|
|
439
|
+
const createForwardMessageTool = () => ({
|
|
440
|
+
name: "mutiro_forward_message",
|
|
441
|
+
label: "Forward Mutiro Message",
|
|
442
|
+
description: [
|
|
443
|
+
"Forward an existing Mutiro message to either a user or an existing conversation.",
|
|
444
|
+
"Use this when the user asks to share, resend, or forward a specific message they (or the agent) received earlier — not to paraphrase it.",
|
|
445
|
+
"",
|
|
446
|
+
"Required: `message_id` (id of the message being forwarded).",
|
|
447
|
+
"Destination — provide EXACTLY ONE of:",
|
|
448
|
+
"- `to_username`: forward to a user by handle (with or without leading '@'). The host creates or reuses a direct conversation. Use this when the user names a recipient by username.",
|
|
449
|
+
"- `target_conversation_id`: forward to an existing conversation (conv_<uuid>). Use this when the user names a specific conversation id.",
|
|
450
|
+
"Optional: `comment` — a note to include with the forwarded message.",
|
|
451
|
+
].join("\n"),
|
|
452
|
+
parameters: Type.Object({
|
|
453
|
+
message_id: Type.String({
|
|
454
|
+
description: "ID of the message to forward.",
|
|
455
|
+
}),
|
|
456
|
+
to_username: Type.Optional(Type.String({
|
|
457
|
+
description: "Destination username (with or without leading '@'). Provide this OR target_conversation_id, not both.",
|
|
458
|
+
})),
|
|
459
|
+
target_conversation_id: Type.Optional(Type.String({
|
|
460
|
+
description: "Destination conversation id (conv_<uuid>). Provide this OR to_username, not both.",
|
|
461
|
+
})),
|
|
462
|
+
comment: Type.Optional(Type.String({
|
|
463
|
+
description: "Optional note to include with the forwarded message.",
|
|
464
|
+
})),
|
|
465
|
+
account_id: Type.Optional(Type.String({
|
|
466
|
+
description: "Mutiro account id to send from. Omit for the default account when only one is configured.",
|
|
467
|
+
})),
|
|
468
|
+
}),
|
|
469
|
+
execute: async (_toolCallId, rawArgs) => {
|
|
470
|
+
const args = (rawArgs ?? {});
|
|
471
|
+
const messageId = (args.message_id ?? "").trim();
|
|
472
|
+
const toUsername = (args.to_username ?? "").trim().replace(/^@/, "");
|
|
473
|
+
const targetConversationId = (args.target_conversation_id ?? "").trim();
|
|
474
|
+
if (!messageId) {
|
|
475
|
+
return {
|
|
476
|
+
content: [{ type: "text", text: "message_id is required." }],
|
|
477
|
+
details: { ok: false, reason: "missing_message_id" },
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
if (!toUsername && !targetConversationId) {
|
|
481
|
+
return {
|
|
482
|
+
content: [
|
|
483
|
+
{
|
|
484
|
+
type: "text",
|
|
485
|
+
text: "Provide either to_username or target_conversation_id as the destination.",
|
|
486
|
+
},
|
|
487
|
+
],
|
|
488
|
+
details: { ok: false, reason: "missing_destination" },
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
if (toUsername && targetConversationId) {
|
|
492
|
+
return {
|
|
493
|
+
content: [
|
|
494
|
+
{
|
|
495
|
+
type: "text",
|
|
496
|
+
text: "Provide exactly one destination: to_username OR target_conversation_id, not both.",
|
|
497
|
+
},
|
|
498
|
+
],
|
|
499
|
+
details: { ok: false, reason: "conflicting_destination" },
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
const accountId = (args.account_id ?? "").trim() || DEFAULT_ACCOUNT_ID;
|
|
503
|
+
const { getMutiroBridgeSession } = await import("./channel.runtime.js");
|
|
504
|
+
const session = getMutiroBridgeSession(accountId);
|
|
505
|
+
if (!session) {
|
|
506
|
+
return {
|
|
507
|
+
content: [
|
|
508
|
+
{
|
|
509
|
+
type: "text",
|
|
510
|
+
text: `Mutiro bridge session for account "${accountId}" is not running.`,
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
details: { ok: false, reason: "no_active_session", accountId },
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
try {
|
|
517
|
+
const result = await session.outbound.forward({
|
|
518
|
+
messageId,
|
|
519
|
+
...(toUsername ? { toUsername } : { targetConversationId }),
|
|
520
|
+
...(args.comment ? { comment: args.comment } : {}),
|
|
521
|
+
});
|
|
522
|
+
const destination = toUsername ? `@${toUsername}` : targetConversationId;
|
|
523
|
+
return {
|
|
524
|
+
content: [
|
|
525
|
+
{
|
|
526
|
+
type: "text",
|
|
527
|
+
text: `Forwarded ${messageId} to ${destination}.`,
|
|
528
|
+
},
|
|
529
|
+
],
|
|
530
|
+
details: { ok: true, raw: result },
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
catch (err) {
|
|
534
|
+
const message = formatBridgeError(err);
|
|
535
|
+
return {
|
|
536
|
+
content: [{ type: "text", text: `Failed to forward message: ${message}` }],
|
|
537
|
+
details: { ok: false, reason: "bridge_error", error: message },
|
|
538
|
+
};
|
|
539
|
+
}
|
|
540
|
+
},
|
|
541
|
+
});
|
|
542
|
+
export const mutiroAgentTools = () => [
|
|
543
|
+
createSendVoiceMessageTool(),
|
|
544
|
+
createSendCardTool(),
|
|
545
|
+
createForwardMessageTool(),
|
|
546
|
+
];
|
|
547
|
+
//# sourceMappingURL=agent-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-tools.js","sourceRoot":"","sources":["../../src/agent-tools.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,sEAAsE;AACtE,sEAAsE;AACtE,oCAAoC;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,wEAAwE;AACxE,+DAA+D;AAC/D,2EAA2E;AAC3E,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAU,EAAE;IACjD,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC,OAAO,CAAC;IAC7C,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,GAA0C,CAAC;QAC1D,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,MAAM,CAAC,IAAI;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,MAAM,CAAC,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QAC/C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,eAAe;QACjB,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;AACrB,CAAC,CAAC;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