open-agents-ai 0.187.586 → 0.187.587
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/index.js +90 -2
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -591030,6 +591030,60 @@ function renderTelegramLiveProgressHTML(progressLines, accumulated) {
|
|
|
591030
591030
|
}
|
|
591031
591031
|
return progressLines.slice(-6).map((line) => line.trim()).filter(Boolean).join("\n");
|
|
591032
591032
|
}
|
|
591033
|
+
function telegramSyntheticHelpSignatures() {
|
|
591034
|
+
return [
|
|
591035
|
+
{ signature: "/help", description: "Show Telegram command help" },
|
|
591036
|
+
{ signature: "/start", description: "Show Telegram bridge status and authentication instructions" },
|
|
591037
|
+
{ signature: "/auth <code>", description: "Authenticate this Telegram user as bot admin using the TUI code" }
|
|
591038
|
+
];
|
|
591039
|
+
}
|
|
591040
|
+
function telegramHelpCommandAllowed(cmd, scope) {
|
|
591041
|
+
if (scope === "admin") return cmd.implementationStatus === "implemented";
|
|
591042
|
+
if (TELEGRAM_PUBLIC_HELP_COMMANDS.has(cmd.name)) return true;
|
|
591043
|
+
return cmd.surfaces.agentTool && !cmd.safety.secretBearing && !cmd.safety.destructive && !cmd.safety.profileGated;
|
|
591044
|
+
}
|
|
591045
|
+
function buildTelegramHelpHTML(scope, maxPublicCommands = 24) {
|
|
591046
|
+
const commands = listCommandRegistry({ includePlanned: false }).filter((cmd) => telegramHelpCommandAllowed(cmd, scope));
|
|
591047
|
+
const signatures = [
|
|
591048
|
+
...telegramSyntheticHelpSignatures(),
|
|
591049
|
+
...commands.flatMap((cmd) => cmd.signatures)
|
|
591050
|
+
];
|
|
591051
|
+
const seen = /* @__PURE__ */ new Set();
|
|
591052
|
+
const unique = signatures.filter((sig) => {
|
|
591053
|
+
if (seen.has(sig.signature)) return false;
|
|
591054
|
+
seen.add(sig.signature);
|
|
591055
|
+
return true;
|
|
591056
|
+
});
|
|
591057
|
+
const visible = scope === "public" ? unique.slice(0, maxPublicCommands) : unique;
|
|
591058
|
+
const lines = [
|
|
591059
|
+
`<b>Commands (${scope === "admin" ? "admin full scope" : "public secure scope"})</b>`,
|
|
591060
|
+
"",
|
|
591061
|
+
...visible.map(
|
|
591062
|
+
(sig) => `<code>${escapeTelegramHTML(sig.signature)}</code> - ${escapeTelegramHTML(sig.description)}`
|
|
591063
|
+
)
|
|
591064
|
+
];
|
|
591065
|
+
if (scope === "public" && unique.length > visible.length) {
|
|
591066
|
+
lines.push("");
|
|
591067
|
+
lines.push(`Public scope truncated to ${visible.length} safe commands. Authenticate as admin for full command help.`);
|
|
591068
|
+
}
|
|
591069
|
+
return lines.join("\n");
|
|
591070
|
+
}
|
|
591071
|
+
function splitTelegramHTMLMessage(html, maxLength = 3600) {
|
|
591072
|
+
const chunks = [];
|
|
591073
|
+
let current = "";
|
|
591074
|
+
for (const line of html.split("\n")) {
|
|
591075
|
+
const candidate = current ? `${current}
|
|
591076
|
+
${line}` : line;
|
|
591077
|
+
if (candidate.length > maxLength && current) {
|
|
591078
|
+
chunks.push(current);
|
|
591079
|
+
current = line;
|
|
591080
|
+
} else {
|
|
591081
|
+
current = candidate;
|
|
591082
|
+
}
|
|
591083
|
+
}
|
|
591084
|
+
if (current.trim()) chunks.push(current);
|
|
591085
|
+
return chunks.length > 0 ? chunks : [html];
|
|
591086
|
+
}
|
|
591033
591087
|
function normalizeTelegramChatId(value2) {
|
|
591034
591088
|
if (typeof value2 === "number" || typeof value2 === "string") return value2;
|
|
591035
591089
|
return 0;
|
|
@@ -591374,7 +591428,7 @@ function renderTelegramSubAgentError(username, error) {
|
|
|
591374
591428
|
process.stdout.write(` ${c3.dim("⎿")} ${c3.red("✘")} @${username}: ${c3.dim(preview)}
|
|
591375
591429
|
`);
|
|
591376
591430
|
}
|
|
591377
|
-
var TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_ACTION_INTENT_RE, TELEGRAM_CODEBASE_CONTEXT_RE, TELEGRAM_COMMANDISH_RE, TELEGRAM_CHAT_INTENT_RE, MEDIA_CACHE_TTL_MS, TelegramBridge;
|
|
591431
|
+
var TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_ACTION_INTENT_RE, TELEGRAM_CODEBASE_CONTEXT_RE, TELEGRAM_COMMANDISH_RE, TELEGRAM_CHAT_INTENT_RE, TELEGRAM_PUBLIC_HELP_COMMANDS, MEDIA_CACHE_TTL_MS, TelegramBridge;
|
|
591378
591432
|
var init_telegram_bridge = __esm({
|
|
591379
591433
|
"packages/cli/src/tui/telegram-bridge.ts"() {
|
|
591380
591434
|
"use strict";
|
|
@@ -591384,6 +591438,7 @@ var init_telegram_bridge = __esm({
|
|
|
591384
591438
|
init_render();
|
|
591385
591439
|
init_tool_policy();
|
|
591386
591440
|
init_media_routing();
|
|
591441
|
+
init_command_registry();
|
|
591387
591442
|
TELEGRAM_SAFETY_PROMPT = `
|
|
591388
591443
|
CRITICAL SAFETY NOTICE — PUBLIC TELEGRAM CHANNEL
|
|
591389
591444
|
|
|
@@ -591465,6 +591520,7 @@ Telegram response contract:
|
|
|
591465
591520
|
TELEGRAM_CODEBASE_CONTEXT_RE = /\b(repo|repository|codebase|workspace|working directory|file|files|folder|directory|src|source|test|tests|package|pnpm|npm|node|git|branch|commit|pr|pull request|issue|shell|terminal|cli|command|function|class|component|endpoint|api)\b/i;
|
|
591466
591521
|
TELEGRAM_COMMANDISH_RE = /(^|\s)(pnpm|npm|node|git|rg|grep|sed|cat|ls|cd|mkdir|rm|mv|cp|curl|docker|pytest|vitest|tsc)\b/i;
|
|
591467
591522
|
TELEGRAM_CHAT_INTENT_RE = /\b(hi|hello|hey|thanks|thank you|lol|haha|joke|how are you|what's up|whats up|can you hear|are you there|explain|what is|what are|why|how does|tell me|opinion|quick question)\b/i;
|
|
591523
|
+
TELEGRAM_PUBLIC_HELP_COMMANDS = /* @__PURE__ */ new Set(["help", "start", "auth", "call"]);
|
|
591468
591524
|
MEDIA_CACHE_TTL_MS = 30 * 60 * 1e3;
|
|
591469
591525
|
TelegramBridge = class {
|
|
591470
591526
|
constructor(botToken, onMessage, agentConfig, repoRoot, toolPolicyConfig) {
|
|
@@ -591632,6 +591688,15 @@ Telegram response contract:
|
|
|
591632
591688
|
if (!canonical || canonical === botless) return input;
|
|
591633
591689
|
return `/${canonical}${trimmed.slice(first2.length)}`;
|
|
591634
591690
|
}
|
|
591691
|
+
telegramSlashName(input) {
|
|
591692
|
+
const first2 = input.trim().split(/\s+/)[0] ?? "";
|
|
591693
|
+
if (!first2.startsWith("/")) return "";
|
|
591694
|
+
return first2.slice(1).split("@")[0]?.toLowerCase() ?? "";
|
|
591695
|
+
}
|
|
591696
|
+
isTelegramHelpCommand(input) {
|
|
591697
|
+
const name10 = this.telegramSlashName(input);
|
|
591698
|
+
return name10 === "help" || name10 === "h" || name10 === "commands" || name10 === "cmds";
|
|
591699
|
+
}
|
|
591635
591700
|
isKnownTelegramSlash(input) {
|
|
591636
591701
|
const first2 = input.trim().split(/\s+/)[0] ?? "";
|
|
591637
591702
|
const botless = first2.startsWith("/") ? first2.slice(1).split("@")[0]?.toLowerCase() : "";
|
|
@@ -591658,6 +591723,25 @@ Telegram response contract:
|
|
|
591658
591723
|
canUseChatActions(msg) {
|
|
591659
591724
|
return !msg.guestQueryId && (typeof msg.chatId === "number" || String(msg.chatId).startsWith("@"));
|
|
591660
591725
|
}
|
|
591726
|
+
async replyWithTelegramHelp(msg, isAdmin) {
|
|
591727
|
+
const scope = isAdmin ? "admin" : "public";
|
|
591728
|
+
const chunks = splitTelegramHTMLMessage(buildTelegramHelpHTML(scope));
|
|
591729
|
+
if (msg.guestQueryId) {
|
|
591730
|
+
await this.answerGuestQuery(msg.guestQueryId, chunks[0] ?? "", { parseMode: "HTML" });
|
|
591731
|
+
return;
|
|
591732
|
+
}
|
|
591733
|
+
for (let i2 = 0; i2 < chunks.length; i2++) {
|
|
591734
|
+
const chunk = chunks[i2];
|
|
591735
|
+
if (i2 === 0) {
|
|
591736
|
+
await this.replyToTelegramMessage(msg, chunk, {
|
|
591737
|
+
html: true,
|
|
591738
|
+
replyToMessageId: msg.chatType !== "private" ? msg.messageId : void 0
|
|
591739
|
+
});
|
|
591740
|
+
} else {
|
|
591741
|
+
await this.sendMessageHTML(msg.chatId, chunk);
|
|
591742
|
+
}
|
|
591743
|
+
}
|
|
591744
|
+
}
|
|
591661
591745
|
recordChatHistory(sessionKey, entry) {
|
|
591662
591746
|
const existing = this.chatHistory.get(sessionKey) ?? [];
|
|
591663
591747
|
existing.push({ ...entry, ts: entry.ts ?? Date.now() });
|
|
@@ -591938,11 +592022,15 @@ ${TELEGRAM_SAFETY_PROMPT}`);
|
|
|
591938
592022
|
if (msg.text.trim().startsWith("/") && await this.handleAdminAuthCommand({ ...msg, text: normalizedCommandText })) {
|
|
591939
592023
|
return;
|
|
591940
592024
|
}
|
|
592025
|
+
const isAdmin = this.isAdminUser(msg);
|
|
592026
|
+
if (msg.text.trim().startsWith("/") && this.isTelegramHelpCommand(normalizedCommandText)) {
|
|
592027
|
+
await this.replyWithTelegramHelp(msg, isAdmin);
|
|
592028
|
+
return;
|
|
592029
|
+
}
|
|
591941
592030
|
if (!this.agentConfig || !this.repoRoot) {
|
|
591942
592031
|
this.onMessage(msg);
|
|
591943
592032
|
return;
|
|
591944
592033
|
}
|
|
591945
|
-
const isAdmin = this.isAdminUser(msg);
|
|
591946
592034
|
const toolContext = this.resolveToolContext(msg, isAdmin);
|
|
591947
592035
|
const isAdminDM = toolContext === "telegram-admin-dm";
|
|
591948
592036
|
const sessionKey = this.sessionKeyForMessage(msg);
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "open-agents-ai",
|
|
3
|
-
"version": "0.187.
|
|
3
|
+
"version": "0.187.587",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "open-agents-ai",
|
|
9
|
-
"version": "0.187.
|
|
9
|
+
"version": "0.187.587",
|
|
10
10
|
"hasInstallScript": true,
|
|
11
11
|
"license": "CC-BY-NC-4.0",
|
|
12
12
|
"dependencies": {
|
package/package.json
CHANGED