clawgram 2.8.1 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channel.js +27 -8
- package/dist/reactions.js +36 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
package/dist/channel.js
CHANGED
|
@@ -67,6 +67,14 @@ const helpers_1 = require("./helpers");
|
|
|
67
67
|
const proxy_config_1 = require("./proxy-config");
|
|
68
68
|
const constants_1 = require("./constants");
|
|
69
69
|
const actionLog = (0, core_1.createSubsystemLogger)("channels/clawgram");
|
|
70
|
+
/** Reads the configured reaction level for an account, tolerating a missing config. */
|
|
71
|
+
function readAccountReactionLevel(cfg, accountId) {
|
|
72
|
+
const resolvedAccountId = (0, helpers_1.resolveConfiguredAccountId)(cfg, accountId);
|
|
73
|
+
if (!resolvedAccountId) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
return cfg?.channels?.[constants_1.CHANNEL_ID]?.accounts?.[resolvedAccountId]?.reactionLevel;
|
|
77
|
+
}
|
|
70
78
|
/**
|
|
71
79
|
* Read scope as configured for the account. Left `undefined` when the key is
|
|
72
80
|
* absent so `isChatReadable` can tell "not configured" from "configured empty" —
|
|
@@ -258,14 +266,25 @@ const createChannelPlugin = (runtimes, pluginRuntime) => {
|
|
|
258
266
|
// enabled for <label>", and the label is the platform people see.
|
|
259
267
|
return level ? { level, channelLabel: "Telegram" } : undefined;
|
|
260
268
|
},
|
|
261
|
-
messageToolHints: () =>
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
|
|
268
|
-
|
|
269
|
+
messageToolHints: ({ cfg, accountId } = {}) => {
|
|
270
|
+
const level = (0, reactions_1.resolveAgentReactionGuidance)(readAccountReactionLevel(cfg, accountId));
|
|
271
|
+
// Logged for the same reason reactionGuidance is: this path is the
|
|
272
|
+
// workaround for core skipping that hook, so "did our text reach the
|
|
273
|
+
// prompt" has to be answerable from the log rather than by inference.
|
|
274
|
+
actionLog.info("clawgram messageToolHints", {
|
|
275
|
+
accountId: accountId ?? null,
|
|
276
|
+
reactionLevel: level ?? null,
|
|
277
|
+
});
|
|
278
|
+
return [
|
|
279
|
+
"Use clawgram to send Telegram replies from the connected personal account.",
|
|
280
|
+
"When replying in the current Telegram chat, omit `to`/`target` and clawgram will send to the current conversation automatically.",
|
|
281
|
+
"Explicit targets may be @username, numeric Telegram user id, phone/contact resolvable by Telegram, group chat ids, or clawgram:<target>.",
|
|
282
|
+
"For Telegram forum topics, send to the group chat id and pass the topic id separately as `threadId`.",
|
|
283
|
+
"Use the `react` action to acknowledge a message with an emoji instead of sending a reply; pass an empty `emoji` (or `remove: true`) to take the reaction back.",
|
|
284
|
+
"Use the `chatInfo` action to learn what a chat is — title, type, member count, description, pinned message — instead of guessing from its id.",
|
|
285
|
+
...(0, reactions_1.buildReactionHintLines)(level),
|
|
286
|
+
];
|
|
287
|
+
},
|
|
269
288
|
messageToolCapabilities: () => [
|
|
270
289
|
"clawgram can reply in the current Telegram conversation when no explicit target is provided.",
|
|
271
290
|
"clawgram can send text messages to direct chats and groups from the connected personal account.",
|
package/dist/reactions.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* tested without a Telegram connection.
|
|
12
12
|
*/
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.buildReactionHintLines = buildReactionHintLines;
|
|
14
15
|
exports.resolveAgentReactionGuidance = resolveAgentReactionGuidance;
|
|
15
16
|
exports.parseReactionParams = parseReactionParams;
|
|
16
17
|
/**
|
|
@@ -33,6 +34,41 @@ exports.parseReactionParams = parseReactionParams;
|
|
|
33
34
|
* An invalid value yields no guidance rather than a guess: a typo turning a
|
|
34
35
|
* work chat chatty is worse than a typo turning it quiet.
|
|
35
36
|
*/
|
|
37
|
+
/**
|
|
38
|
+
* The reaction guidance as prompt lines, carried by `messageToolHints`.
|
|
39
|
+
*
|
|
40
|
+
* Core has its own `## Reactions` section, but it only builds it when
|
|
41
|
+
* `params.config` is truthy in the prompt assembler — a condition our channel
|
|
42
|
+
* never satisfied: the hook logged zero invocations across live turns while
|
|
43
|
+
* the neighbouring `messageToolHints`, guarded only by the channel being
|
|
44
|
+
* resolved, is called every time.
|
|
45
|
+
*
|
|
46
|
+
* That condition lives in the minified `openclaw` dependency, so it is not
|
|
47
|
+
* ours to fix; patching `node_modules` would evaporate on the next update.
|
|
48
|
+
* The hints path is ours, reaches the same prompt, and does not depend on
|
|
49
|
+
* that diagnosis being right — if the hints arrive, so does the text.
|
|
50
|
+
*
|
|
51
|
+
* Wording follows core's own so behaviour stays the same if it ever starts
|
|
52
|
+
* calling the hook and both appear.
|
|
53
|
+
*/
|
|
54
|
+
function buildReactionHintLines(level) {
|
|
55
|
+
if (!level) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const shared = [
|
|
59
|
+
"Use the `react` action for this: it leaves an emoji on a message without sending one.",
|
|
60
|
+
"A reaction is not a reply — you can react and still return NO_REPLY, and that is the point when someone names you but needs no answer.",
|
|
61
|
+
];
|
|
62
|
+
return level === "minimal"
|
|
63
|
+
? [
|
|
64
|
+
"Reactions are enabled for Telegram in MINIMAL mode. React ONLY when truly relevant: acknowledge an important request or confirmation, or show genuine sentiment sparingly. Do not react to routine messages or to your own replies. Guideline: at most 1 reaction per 5-10 exchanges.",
|
|
65
|
+
...shared,
|
|
66
|
+
]
|
|
67
|
+
: [
|
|
68
|
+
"Reactions are enabled for Telegram in EXTENSIVE mode. React liberally: acknowledge messages with a fitting emoji, show sentiment and personality, react to humour, notable events or good news, and use a reaction to confirm agreement. Guideline: react whenever it feels natural.",
|
|
69
|
+
...shared,
|
|
70
|
+
];
|
|
71
|
+
}
|
|
36
72
|
function resolveAgentReactionGuidance(value) {
|
|
37
73
|
if (value === undefined || value === null) {
|
|
38
74
|
return "minimal";
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "clawgram",
|
|
3
3
|
"name": "Clawgram",
|
|
4
4
|
"description": "Clawgram — personal Telegram (MTProto userbot) channel for OpenClaw. Your AI assistant reads and responds as you.",
|
|
5
|
-
"version": "2.
|
|
5
|
+
"version": "2.9.0",
|
|
6
6
|
"configSchema": {
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": false,
|
package/package.json
CHANGED