blun-king-cli 9.1.15 → 9.1.17
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/blun.mjs +17 -4
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge.mjs +23 -4
- package/telegram-plugin/dist/mcp-server.mjs +23 -4
package/blun.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// BLUN_BUILD_INPUT_SHA256:
|
|
2
|
+
// BLUN_BUILD_INPUT_SHA256:39e4b4359446de9a47446e631b853adaafc78c8097e76296c6826ec91ee9902d
|
|
3
3
|
import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
4
4
|
import { dirname as __cjsShimDirname } from 'node:path';
|
|
5
5
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
@@ -397833,7 +397833,6 @@ function slashBusyMessage(commandName, reason) {
|
|
|
397833
397833
|
}
|
|
397834
397834
|
//#endregion
|
|
397835
397835
|
//#region src/tui/commands/plugin-commands.ts
|
|
397836
|
-
const REMOVED_PLUGIN_COMMANDS = new Set(["telegram:access"]);
|
|
397837
397836
|
function pluginCommandName(pluginId, name) {
|
|
397838
397837
|
return `${pluginId}:${name}`;
|
|
397839
397838
|
}
|
|
@@ -397842,7 +397841,6 @@ function buildPluginSlashCommands(defs) {
|
|
|
397842
397841
|
const commands = [];
|
|
397843
397842
|
for (const def of defs) {
|
|
397844
397843
|
const commandName = pluginCommandName(def.pluginId, def.name);
|
|
397845
|
-
if (REMOVED_PLUGIN_COMMANDS.has(commandName)) continue;
|
|
397846
397844
|
commandMap.set(commandName, def.body);
|
|
397847
397845
|
commands.push({
|
|
397848
397846
|
name: commandName,
|
|
@@ -424714,10 +424712,25 @@ const INTERNAL_TAG_PREFIXES = [
|
|
|
424714
424712
|
"<|dsml|",
|
|
424715
424713
|
"</|dsml|"
|
|
424716
424714
|
];
|
|
424715
|
+
const RUNTIME_INSTRUCTION_OPEN = "Bevor du antwortest:";
|
|
424716
|
+
const RUNTIME_INSTRUCTION_CLOSE = "Die einzige Ausnahme: eine Zahl, die der Nutzer selbst in seiner Nachricht genannt hat - die darfst du uebernehmen und weiterverwenden.";
|
|
424717
424717
|
/** Remove model-only envelopes before assistant text reaches a transcript renderer. */
|
|
424718
424718
|
function sanitizeAssistantDisplayText(text, options = {}) {
|
|
424719
424719
|
const transient = options.transient === true;
|
|
424720
|
-
return stripIncompleteInternalSuffix(stripControlTokens(stripDsmlBlocks(stripSystemReminderBlocks(text, transient))), transient);
|
|
424720
|
+
return stripIncompleteInternalSuffix(stripControlTokens(stripDsmlBlocks(stripSystemReminderBlocks(stripEchoedRuntimeInstructions(text), transient))), transient);
|
|
424721
|
+
}
|
|
424722
|
+
function stripEchoedRuntimeInstructions(text) {
|
|
424723
|
+
let cursor = 0;
|
|
424724
|
+
let output = "";
|
|
424725
|
+
while (cursor < text.length) {
|
|
424726
|
+
const open = text.indexOf(RUNTIME_INSTRUCTION_OPEN, cursor);
|
|
424727
|
+
if (open < 0) break;
|
|
424728
|
+
output += text.slice(cursor, open);
|
|
424729
|
+
const close = text.indexOf(RUNTIME_INSTRUCTION_CLOSE, open + 20);
|
|
424730
|
+
if (close < 0) return output;
|
|
424731
|
+
cursor = close + 135;
|
|
424732
|
+
}
|
|
424733
|
+
return output + text.slice(cursor);
|
|
424721
424734
|
}
|
|
424722
424735
|
function stripSystemReminderBlocks(text, transient) {
|
|
424723
424736
|
let cursor = 0;
|
package/package.json
CHANGED
|
@@ -59318,13 +59318,32 @@ function defaultAccess() {
|
|
|
59318
59318
|
pending: {}
|
|
59319
59319
|
};
|
|
59320
59320
|
}
|
|
59321
|
+
function normalizeIdList(value) {
|
|
59322
|
+
if (!Array.isArray(value)) return [];
|
|
59323
|
+
return [...new Set(value.filter((entry) => typeof entry === "string" || typeof entry === "number").map((entry) => String(entry).trim()).filter((entry) => entry.length > 0))];
|
|
59324
|
+
}
|
|
59325
|
+
function normalizeGroups(value) {
|
|
59326
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
59327
|
+
const groups = {};
|
|
59328
|
+
for (const [chatId, rawPolicy] of Object.entries(value)) {
|
|
59329
|
+
if (rawPolicy === null || typeof rawPolicy !== "object" || Array.isArray(rawPolicy)) continue;
|
|
59330
|
+
const policy = rawPolicy;
|
|
59331
|
+
const alwaysAllowFrom = normalizeIdList(policy.alwaysAllowFrom);
|
|
59332
|
+
groups[chatId] = {
|
|
59333
|
+
requireMention: policy.requireMention !== false,
|
|
59334
|
+
allowFrom: normalizeIdList(policy.allowFrom),
|
|
59335
|
+
...alwaysAllowFrom.length > 0 ? { alwaysAllowFrom } : {}
|
|
59336
|
+
};
|
|
59337
|
+
}
|
|
59338
|
+
return groups;
|
|
59339
|
+
}
|
|
59321
59340
|
function readAccess() {
|
|
59322
59341
|
try {
|
|
59323
59342
|
const parsed = JSON.parse(readFileSync(accessFile(), "utf8"));
|
|
59324
59343
|
return {
|
|
59325
59344
|
dmPolicy: parsed.dmPolicy ?? "pairing",
|
|
59326
|
-
allowFrom: parsed.allowFrom
|
|
59327
|
-
groups: parsed.groups
|
|
59345
|
+
allowFrom: normalizeIdList(parsed.allowFrom),
|
|
59346
|
+
groups: normalizeGroups(parsed.groups),
|
|
59328
59347
|
pending: parsed.pending ?? {},
|
|
59329
59348
|
mentionPatterns: parsed.mentionPatterns,
|
|
59330
59349
|
ignorePatterns: parsed.ignorePatterns,
|
|
@@ -59333,8 +59352,8 @@ function readAccess() {
|
|
|
59333
59352
|
textChunkLimit: parsed.textChunkLimit,
|
|
59334
59353
|
chunkMode: parsed.chunkMode
|
|
59335
59354
|
};
|
|
59336
|
-
} catch (
|
|
59337
|
-
if (
|
|
59355
|
+
} catch (error) {
|
|
59356
|
+
if (error.code === "ENOENT") return defaultAccess();
|
|
59338
59357
|
try {
|
|
59339
59358
|
renameSync(accessFile(), `${accessFile()}.corrupt-${Date.now()}`);
|
|
59340
59359
|
} catch {}
|
|
@@ -73135,13 +73135,32 @@ function defaultAccess() {
|
|
|
73135
73135
|
pending: {}
|
|
73136
73136
|
};
|
|
73137
73137
|
}
|
|
73138
|
+
function normalizeIdList(value) {
|
|
73139
|
+
if (!Array.isArray(value)) return [];
|
|
73140
|
+
return [...new Set(value.filter((entry) => typeof entry === "string" || typeof entry === "number").map((entry) => String(entry).trim()).filter((entry) => entry.length > 0))];
|
|
73141
|
+
}
|
|
73142
|
+
function normalizeGroups(value) {
|
|
73143
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return {};
|
|
73144
|
+
const groups = {};
|
|
73145
|
+
for (const [chatId, rawPolicy] of Object.entries(value)) {
|
|
73146
|
+
if (rawPolicy === null || typeof rawPolicy !== "object" || Array.isArray(rawPolicy)) continue;
|
|
73147
|
+
const policy = rawPolicy;
|
|
73148
|
+
const alwaysAllowFrom = normalizeIdList(policy.alwaysAllowFrom);
|
|
73149
|
+
groups[chatId] = {
|
|
73150
|
+
requireMention: policy.requireMention !== false,
|
|
73151
|
+
allowFrom: normalizeIdList(policy.allowFrom),
|
|
73152
|
+
...alwaysAllowFrom.length > 0 ? { alwaysAllowFrom } : {}
|
|
73153
|
+
};
|
|
73154
|
+
}
|
|
73155
|
+
return groups;
|
|
73156
|
+
}
|
|
73138
73157
|
function readAccess() {
|
|
73139
73158
|
try {
|
|
73140
73159
|
const parsed = JSON.parse(readFileSync(accessFile(), "utf8"));
|
|
73141
73160
|
return {
|
|
73142
73161
|
dmPolicy: parsed.dmPolicy ?? "pairing",
|
|
73143
|
-
allowFrom: parsed.allowFrom
|
|
73144
|
-
groups: parsed.groups
|
|
73162
|
+
allowFrom: normalizeIdList(parsed.allowFrom),
|
|
73163
|
+
groups: normalizeGroups(parsed.groups),
|
|
73145
73164
|
pending: parsed.pending ?? {},
|
|
73146
73165
|
mentionPatterns: parsed.mentionPatterns,
|
|
73147
73166
|
ignorePatterns: parsed.ignorePatterns,
|
|
@@ -73150,8 +73169,8 @@ function readAccess() {
|
|
|
73150
73169
|
textChunkLimit: parsed.textChunkLimit,
|
|
73151
73170
|
chunkMode: parsed.chunkMode
|
|
73152
73171
|
};
|
|
73153
|
-
} catch (
|
|
73154
|
-
if (
|
|
73172
|
+
} catch (error) {
|
|
73173
|
+
if (error.code === "ENOENT") return defaultAccess();
|
|
73155
73174
|
try {
|
|
73156
73175
|
renameSync(accessFile(), `${accessFile()}.corrupt-${Date.now()}`);
|
|
73157
73176
|
} catch {}
|