@ihazz/bitrix24 1.1.6 → 1.1.8
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/src/channel.d.ts +8 -1
- package/dist/src/channel.d.ts.map +1 -1
- package/dist/src/channel.js +270 -38
- package/dist/src/channel.js.map +1 -1
- package/dist/src/commands.d.ts +7 -4
- package/dist/src/commands.d.ts.map +1 -1
- package/dist/src/commands.js +57 -75
- package/dist/src/commands.js.map +1 -1
- package/dist/src/i18n.d.ts +34 -0
- package/dist/src/i18n.d.ts.map +1 -1
- package/dist/src/i18n.js +459 -0
- package/dist/src/i18n.js.map +1 -1
- package/dist/src/message-utils.d.ts.map +1 -1
- package/dist/src/message-utils.js +73 -7
- package/dist/src/message-utils.js.map +1 -1
- package/package.json +1 -1
- package/src/channel.ts +361 -45
- package/src/commands.ts +75 -81
- package/src/i18n.ts +525 -0
- package/src/message-utils.ts +94 -7
package/src/commands.ts
CHANGED
|
@@ -4,12 +4,21 @@
|
|
|
4
4
|
* Standard OpenClaw bot commands registered via imbot.v2.Command.register.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import {
|
|
8
|
+
commandDescription,
|
|
9
|
+
commandGroupLabel,
|
|
10
|
+
commandHelpTextLabels,
|
|
11
|
+
commandParams,
|
|
12
|
+
commandRegistrationParams,
|
|
13
|
+
commandRegistrationTitle,
|
|
14
|
+
modelsCommandReplyLabels,
|
|
15
|
+
} from './i18n.js';
|
|
16
|
+
import type { CommandGroup } from './i18n.js';
|
|
17
|
+
|
|
7
18
|
export interface BotCommandDef {
|
|
8
19
|
command: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
params?: string;
|
|
12
|
-
group: 'status' | 'session' | 'options' | 'management' | 'tools' | 'export';
|
|
20
|
+
hasParams?: boolean;
|
|
21
|
+
group: CommandGroup;
|
|
13
22
|
}
|
|
14
23
|
|
|
15
24
|
const SHORT_HELP_COMMANDS = new Set(['help', 'status', 'commands', 'new', 'models']);
|
|
@@ -17,94 +26,70 @@ const COMMAND_META_COLOR = '#6C788A';
|
|
|
17
26
|
const COMMAND_GROUP_ORDER = ['status', 'session', 'options', 'management', 'tools', 'export'] as const;
|
|
18
27
|
const MODELS_PROVIDER_LINE_RE = /^[•*-]\s+([^()\s]+)\s+\((\d+)\)$/i;
|
|
19
28
|
|
|
20
|
-
const COMMAND_GROUP_LABELS = {
|
|
21
|
-
ru: {
|
|
22
|
-
status: 'Справка и статус',
|
|
23
|
-
session: 'Сессия',
|
|
24
|
-
options: 'Параметры',
|
|
25
|
-
management: 'Управление',
|
|
26
|
-
tools: 'Инструменты',
|
|
27
|
-
export: 'Экспорт',
|
|
28
|
-
},
|
|
29
|
-
en: {
|
|
30
|
-
status: 'Help and status',
|
|
31
|
-
session: 'Session',
|
|
32
|
-
options: 'Options',
|
|
33
|
-
management: 'Management',
|
|
34
|
-
tools: 'Tools',
|
|
35
|
-
export: 'Export',
|
|
36
|
-
},
|
|
37
|
-
} as const;
|
|
38
|
-
|
|
39
29
|
/**
|
|
40
30
|
* Standard OpenClaw commands.
|
|
41
31
|
* Excludes: focus/unfocus/agents (Discord-specific), allowlist/bash (text-only scope).
|
|
42
32
|
*/
|
|
43
33
|
export const OPENCLAW_COMMANDS: BotCommandDef[] = [
|
|
44
34
|
// ── Status ──
|
|
45
|
-
{ command: 'help',
|
|
46
|
-
{ command: 'commands',
|
|
47
|
-
{ command: 'status',
|
|
48
|
-
{ command: 'context',
|
|
49
|
-
{ command: 'whoami',
|
|
50
|
-
{ command: 'usage',
|
|
35
|
+
{ command: 'help', group: 'status' },
|
|
36
|
+
{ command: 'commands', group: 'status' },
|
|
37
|
+
{ command: 'status', group: 'status' },
|
|
38
|
+
{ command: 'context', group: 'status' },
|
|
39
|
+
{ command: 'whoami', group: 'status' },
|
|
40
|
+
{ command: 'usage', hasParams: true, group: 'status' },
|
|
51
41
|
|
|
52
42
|
// ── Session ──
|
|
53
|
-
{ command: 'new',
|
|
54
|
-
{ command: 'reset',
|
|
55
|
-
{ command: 'stop',
|
|
56
|
-
{ command: 'compact',
|
|
57
|
-
{ command: 'session',
|
|
43
|
+
{ command: 'new', group: 'session' },
|
|
44
|
+
{ command: 'reset', group: 'session' },
|
|
45
|
+
{ command: 'stop', group: 'session' },
|
|
46
|
+
{ command: 'compact', hasParams: true, group: 'session' },
|
|
47
|
+
{ command: 'session', hasParams: true, group: 'session' },
|
|
58
48
|
|
|
59
49
|
// ── Options ──
|
|
60
|
-
{ command: 'model',
|
|
61
|
-
{ command: 'models',
|
|
62
|
-
{ command: 'think',
|
|
63
|
-
{ command: 'verbose',
|
|
64
|
-
{ command: 'reasoning',
|
|
65
|
-
{ command: 'elevated',
|
|
66
|
-
{ command: 'exec',
|
|
67
|
-
{ command: 'queue',
|
|
50
|
+
{ command: 'model', hasParams: true, group: 'options' },
|
|
51
|
+
{ command: 'models', hasParams: true, group: 'options' },
|
|
52
|
+
{ command: 'think', hasParams: true, group: 'options' },
|
|
53
|
+
{ command: 'verbose', hasParams: true, group: 'options' },
|
|
54
|
+
{ command: 'reasoning', hasParams: true, group: 'options' },
|
|
55
|
+
{ command: 'elevated', hasParams: true, group: 'options' },
|
|
56
|
+
{ command: 'exec', hasParams: true, group: 'options' },
|
|
57
|
+
{ command: 'queue', hasParams: true, group: 'options' },
|
|
68
58
|
|
|
69
59
|
// ── Management ──
|
|
70
|
-
{ command: 'config',
|
|
71
|
-
{ command: 'debug',
|
|
72
|
-
{ command: 'approve',
|
|
73
|
-
{ command: 'activation',
|
|
74
|
-
{ command: 'send',
|
|
75
|
-
{ command: 'subagents',
|
|
76
|
-
{ command: 'kill',
|
|
77
|
-
{ command: 'steer',
|
|
60
|
+
{ command: 'config', hasParams: true, group: 'management' },
|
|
61
|
+
{ command: 'debug', hasParams: true, group: 'management' },
|
|
62
|
+
{ command: 'approve', group: 'management' },
|
|
63
|
+
{ command: 'activation', hasParams: true, group: 'management' },
|
|
64
|
+
{ command: 'send', hasParams: true, group: 'management' },
|
|
65
|
+
{ command: 'subagents', group: 'management' },
|
|
66
|
+
{ command: 'kill', hasParams: true, group: 'management' },
|
|
67
|
+
{ command: 'steer', hasParams: true, group: 'management' },
|
|
78
68
|
|
|
79
69
|
// ── Tools ──
|
|
80
|
-
{ command: 'skill',
|
|
81
|
-
{ command: 'restart',
|
|
70
|
+
{ command: 'skill', hasParams: true, group: 'tools' },
|
|
71
|
+
{ command: 'restart', group: 'tools' },
|
|
82
72
|
|
|
83
73
|
// ── Export ──
|
|
84
|
-
{ command: 'export-session',
|
|
74
|
+
{ command: 'export-session', group: 'export' },
|
|
85
75
|
];
|
|
86
76
|
|
|
87
77
|
export function buildCommandsHelpText(
|
|
88
78
|
lang: string | undefined,
|
|
89
79
|
options?: { concise?: boolean },
|
|
90
80
|
): string {
|
|
91
|
-
const isRu = lang?.toLowerCase().startsWith('ru') ?? false;
|
|
92
81
|
const concise = options?.concise === true;
|
|
93
82
|
const defs = concise
|
|
94
83
|
? OPENCLAW_COMMANDS.filter((def) => SHORT_HELP_COMMANDS.has(def.command))
|
|
95
84
|
: OPENCLAW_COMMANDS;
|
|
96
|
-
const labels =
|
|
85
|
+
const labels = commandHelpTextLabels(lang);
|
|
97
86
|
const header = concise
|
|
98
|
-
?
|
|
99
|
-
:
|
|
87
|
+
? `[B]${labels.conciseHeader}[/B]`
|
|
88
|
+
: `[B]${labels.fullHeader}[/B]`;
|
|
100
89
|
const footer = concise
|
|
101
|
-
? (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
})}`
|
|
105
|
-
: `[COLOR=${COMMAND_META_COLOR}]Full list:[/COLOR] ${formatCommandTrigger({
|
|
106
|
-
command: 'commands',
|
|
107
|
-
})}`)
|
|
90
|
+
? `[COLOR=${COMMAND_META_COLOR}]${labels.fullListLabel}:[/COLOR] ${formatCommandTrigger({
|
|
91
|
+
command: 'commands',
|
|
92
|
+
})}`
|
|
108
93
|
: '';
|
|
109
94
|
|
|
110
95
|
const sections = COMMAND_GROUP_ORDER
|
|
@@ -114,12 +99,12 @@ export function buildCommandsHelpText(
|
|
|
114
99
|
return '';
|
|
115
100
|
}
|
|
116
101
|
|
|
117
|
-
const lines = groupDefs.map((def) => formatCommandEntry(def,
|
|
102
|
+
const lines = groupDefs.map((def) => formatCommandEntry(def, lang, labels.paramsLabel));
|
|
118
103
|
if (concise) {
|
|
119
104
|
return lines.join('\n');
|
|
120
105
|
}
|
|
121
106
|
|
|
122
|
-
return [`[B]${
|
|
107
|
+
return [`[B]${commandGroupLabel(lang, group)}[/B]`, ...lines].join('\n');
|
|
123
108
|
})
|
|
124
109
|
.filter(Boolean);
|
|
125
110
|
|
|
@@ -150,14 +135,10 @@ export function formatModelsCommandReply(
|
|
|
150
135
|
return null;
|
|
151
136
|
}
|
|
152
137
|
|
|
153
|
-
const
|
|
154
|
-
const header =
|
|
155
|
-
const showModelsLabel =
|
|
156
|
-
|
|
157
|
-
: `[COLOR=${COMMAND_META_COLOR}]Show provider models:[/COLOR]`;
|
|
158
|
-
const switchModelLabel = isRu
|
|
159
|
-
? `[COLOR=${COMMAND_META_COLOR}]Сменить модель:[/COLOR]`
|
|
160
|
-
: `[COLOR=${COMMAND_META_COLOR}]Switch model:[/COLOR]`;
|
|
138
|
+
const labels = modelsCommandReplyLabels(lang);
|
|
139
|
+
const header = `[B]${labels.header}[/B]`;
|
|
140
|
+
const showModelsLabel = `[COLOR=${COMMAND_META_COLOR}]${labels.showProviderModels}:[/COLOR]`;
|
|
141
|
+
const switchModelLabel = `[COLOR=${COMMAND_META_COLOR}]${labels.switchModel}:[/COLOR]`;
|
|
161
142
|
|
|
162
143
|
const providerLines = providers.map((provider) => {
|
|
163
144
|
return `• [send=/models ${provider.name}]${provider.name}[/send] [COLOR=${COMMAND_META_COLOR}](${provider.count})[/COLOR]`;
|
|
@@ -172,25 +153,38 @@ export function formatModelsCommandReply(
|
|
|
172
153
|
].join('\n');
|
|
173
154
|
}
|
|
174
155
|
|
|
175
|
-
function
|
|
176
|
-
|
|
177
|
-
|
|
156
|
+
export function getCommandRegistrationPayload(def: BotCommandDef): {
|
|
157
|
+
title: Record<string, string>;
|
|
158
|
+
params?: Record<string, string>;
|
|
159
|
+
} {
|
|
160
|
+
const title = commandRegistrationTitle(def.command);
|
|
161
|
+
const params = commandRegistrationParams(def.command);
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
title,
|
|
165
|
+
...(params ? { params } : {}),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function formatCommandEntry(def: BotCommandDef, lang: string | undefined, paramsLabel: string): string {
|
|
170
|
+
const description = commandDescription(lang, def.command);
|
|
171
|
+
const params = commandParams(lang, def.command);
|
|
178
172
|
const command = formatCommandTrigger(def);
|
|
179
173
|
|
|
180
|
-
if (!
|
|
174
|
+
if (!params) {
|
|
181
175
|
return `${command} — ${description}`;
|
|
182
176
|
}
|
|
183
177
|
|
|
184
178
|
return [
|
|
185
179
|
`${command} — ${description}`,
|
|
186
|
-
`[COLOR=${COMMAND_META_COLOR}]${paramsLabel}: ${
|
|
180
|
+
`[COLOR=${COMMAND_META_COLOR}]${paramsLabel}: ${params}[/COLOR]`,
|
|
187
181
|
].join('\n');
|
|
188
182
|
}
|
|
189
183
|
|
|
190
|
-
function formatCommandTrigger(def: Pick<BotCommandDef, 'command' | '
|
|
184
|
+
function formatCommandTrigger(def: Pick<BotCommandDef, 'command' | 'hasParams'>): string {
|
|
191
185
|
const visibleCommand = `/${def.command}`;
|
|
192
186
|
|
|
193
|
-
if (!def.
|
|
187
|
+
if (!def.hasParams) {
|
|
194
188
|
return `[send=/${def.command}]${visibleCommand}[/send]`;
|
|
195
189
|
}
|
|
196
190
|
|