@openacp/cli 2026.330.2 → 2026.331.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/README.md +17 -0
- package/dist/adapter-ELG3VRZ3.js +14 -0
- package/dist/{agent-catalog-SZQQERV7.js → agent-catalog-UYD26QDK.js} +3 -3
- package/dist/{api-client-XTLRRFPX.js → api-client-PEMHYL5U.js} +2 -2
- package/dist/{api-server-JLBDKCU4.js → api-server-DATG2KBR.js} +3 -3
- package/dist/api-server-L5Z7XACW.js +7 -0
- package/dist/chunk-23SRIVG4.js +50 -0
- package/dist/chunk-23SRIVG4.js.map +1 -0
- package/dist/{chunk-YIGBJFJL.js → chunk-7GXEMMEV.js} +15 -15
- package/dist/{chunk-QWVHCTCA.js → chunk-7U6IZIJP.js} +37 -23
- package/dist/chunk-7U6IZIJP.js.map +1 -0
- package/dist/{chunk-FCTC7KDT.js → chunk-7YIKTRSM.js} +14 -10
- package/dist/chunk-7YIKTRSM.js.map +1 -0
- package/dist/{chunk-MITTQMGZ.js → chunk-BYCJQPMN.js} +5 -5
- package/dist/chunk-BYCJQPMN.js.map +1 -0
- package/dist/{chunk-5ZNBNIK3.js → chunk-EWVXSTQK.js} +193 -53
- package/dist/chunk-EWVXSTQK.js.map +1 -0
- package/dist/{chunk-UWH7KIAA.js → chunk-FPKQYCQS.js} +88 -13
- package/dist/chunk-FPKQYCQS.js.map +1 -0
- package/dist/{chunk-GEOXPGCO.js → chunk-K6UY5M75.js} +12 -9
- package/dist/chunk-K6UY5M75.js.map +1 -0
- package/dist/{chunk-KDU3ZEWT.js → chunk-KGAQW6F4.js} +12 -3
- package/dist/chunk-KGAQW6F4.js.map +1 -0
- package/dist/{chunk-7RKPIM3E.js → chunk-LRV56K2M.js} +205 -16
- package/dist/chunk-LRV56K2M.js.map +1 -0
- package/dist/{chunk-V2YZWYXT.js → chunk-MDJHCCFS.js} +18 -17
- package/dist/chunk-MDJHCCFS.js.map +1 -0
- package/dist/chunk-NHD5XDD2.js +686 -0
- package/dist/chunk-NHD5XDD2.js.map +1 -0
- package/dist/{chunk-APS6UEFU.js → chunk-NJX75BLK.js} +1 -1
- package/dist/chunk-NJX75BLK.js.map +1 -0
- package/dist/{chunk-5HKQCYOI.js → chunk-NOEAJNTK.js} +14 -3
- package/dist/chunk-NOEAJNTK.js.map +1 -0
- package/dist/chunk-ON7HB5O7.js +58 -0
- package/dist/chunk-ON7HB5O7.js.map +1 -0
- package/dist/{chunk-5OCGO27U.js → chunk-OSBZXY2W.js} +2 -1
- package/dist/chunk-OSBZXY2W.js.map +1 -0
- package/dist/{chunk-PA6MNBG4.js → chunk-P3HHJANC.js} +32 -13
- package/dist/chunk-P3HHJANC.js.map +1 -0
- package/dist/{chunk-BTJHGSLM.js → chunk-R2YLDQLI.js} +9 -10
- package/dist/chunk-R2YLDQLI.js.map +1 -0
- package/dist/{chunk-CFUJGWOP.js → chunk-SSLVNCEA.js} +27 -3
- package/dist/chunk-SSLVNCEA.js.map +1 -0
- package/dist/{chunk-MPGEHTGE.js → chunk-TGP34LQN.js} +9 -7
- package/dist/chunk-TGP34LQN.js.map +1 -0
- package/dist/{chunk-TMVTSWVH.js → chunk-VUSCVRJL.js} +2 -1
- package/dist/chunk-VUSCVRJL.js.map +1 -0
- package/dist/chunk-XRJUS6FE.js +53 -0
- package/dist/chunk-XRJUS6FE.js.map +1 -0
- package/dist/{chunk-W4LK6WJP.js → chunk-YZCKSNRN.js} +24 -17
- package/dist/chunk-YZCKSNRN.js.map +1 -0
- package/dist/{chunk-3NAFXVQM.js → chunk-ZIRH6QWW.js} +7 -5
- package/dist/chunk-ZIRH6QWW.js.map +1 -0
- package/dist/cli.d.ts +11 -0
- package/dist/cli.js +334 -140
- package/dist/cli.js.map +1 -1
- package/dist/config-X4UP7H6R.js +13 -0
- package/dist/config-editor-7BENRVG5.js +11 -0
- package/dist/{config-registry-ZXAIJNYB.js → config-registry-M3FFWEVM.js} +3 -2
- package/dist/context-FVGCU5TI.js +9 -0
- package/dist/core-plugins-JSY2I44L.js +25 -0
- package/dist/{daemon-XFEMMJSZ.js → daemon-UOSRDEXW.js} +8 -3
- package/dist/doctor-6DLACBR4.js +10 -0
- package/dist/{file-service-HHB3JQIO.js → file-service-FQQYME7M.js} +2 -2
- package/dist/index.d.ts +265 -32
- package/dist/index.js +44 -33
- package/dist/index.js.map +1 -1
- package/dist/{install-cloudflared-JRJ4BSOM.js → install-cloudflared-LNS5L5FR.js} +5 -4
- package/dist/install-cloudflared-LNS5L5FR.js.map +1 -0
- package/dist/{install-context-EHYV5WRY.js → install-context-KZO5FR4D.js} +4 -3
- package/dist/install-context-KZO5FR4D.js.map +1 -0
- package/dist/{install-jq-ISTGT263.js → install-jq-SN4IA5K4.js} +3 -3
- package/dist/instance-context-FLCE7VZ4.js +13 -0
- package/dist/instance-registry-SW5FWKHO.js +7 -0
- package/dist/{main-L2M4NTJY.js → main-D7M2AKRM.js} +91 -48
- package/dist/main-D7M2AKRM.js.map +1 -0
- package/dist/{plugin-create-EHL76ZZG.js → plugin-create-HFKS23JY.js} +4 -2
- package/dist/{plugin-create-EHL76ZZG.js.map → plugin-create-HFKS23JY.js.map} +1 -1
- package/dist/{post-upgrade-Y26S2ZQ7.js → post-upgrade-F4YPMTUT.js} +6 -6
- package/dist/{security-2BA265LN.js → security-O4XGN2CM.js} +2 -2
- package/dist/{setup-E6BNEYCS.js → setup-44WLBIOT.js} +209 -22
- package/dist/setup-44WLBIOT.js.map +1 -0
- package/dist/{speech-SG62JYIF.js → speech-GHTSWDAN.js} +2 -2
- package/dist/telegram-D7ASLVEB.js +7 -0
- package/dist/telegram-D7ASLVEB.js.map +1 -0
- package/dist/tunnel-ALJDPFDQ.js +10 -0
- package/dist/tunnel-ALJDPFDQ.js.map +1 -0
- package/dist/{tunnel-service-ZMO4THKE.js → tunnel-service-TBAHDXMF.js} +41 -547
- package/dist/tunnel-service-TBAHDXMF.js.map +1 -0
- package/package.json +1 -1
- package/dist/adapter-4U6MC5ZS.js +0 -13
- package/dist/api-server-5VNYFWJE.js +0 -7
- package/dist/chunk-3NAFXVQM.js.map +0 -1
- package/dist/chunk-4WXALZA3.js +0 -45
- package/dist/chunk-4WXALZA3.js.map +0 -1
- package/dist/chunk-5HKQCYOI.js.map +0 -1
- package/dist/chunk-5OCGO27U.js.map +0 -1
- package/dist/chunk-5ZNBNIK3.js.map +0 -1
- package/dist/chunk-7RKPIM3E.js.map +0 -1
- package/dist/chunk-APS6UEFU.js.map +0 -1
- package/dist/chunk-BTJHGSLM.js.map +0 -1
- package/dist/chunk-CFUJGWOP.js.map +0 -1
- package/dist/chunk-FCTC7KDT.js.map +0 -1
- package/dist/chunk-GEOXPGCO.js.map +0 -1
- package/dist/chunk-KDU3ZEWT.js.map +0 -1
- package/dist/chunk-MITTQMGZ.js.map +0 -1
- package/dist/chunk-MPGEHTGE.js.map +0 -1
- package/dist/chunk-PA6MNBG4.js.map +0 -1
- package/dist/chunk-QWVHCTCA.js.map +0 -1
- package/dist/chunk-TMVTSWVH.js.map +0 -1
- package/dist/chunk-UWH7KIAA.js.map +0 -1
- package/dist/chunk-V2YZWYXT.js.map +0 -1
- package/dist/chunk-W4LK6WJP.js.map +0 -1
- package/dist/config-KN6NKKPF.js +0 -20
- package/dist/config-editor-76RVZS4B.js +0 -10
- package/dist/context-NXXW62NJ.js +0 -9
- package/dist/core-plugins-OCHKGCIZ.js +0 -22
- package/dist/doctor-AV6AUO22.js +0 -9
- package/dist/install-cloudflared-JRJ4BSOM.js.map +0 -1
- package/dist/install-context-EHYV5WRY.js.map +0 -1
- package/dist/main-L2M4NTJY.js.map +0 -1
- package/dist/setup-E6BNEYCS.js.map +0 -1
- package/dist/telegram-EAVRDNFU.js +0 -7
- package/dist/tunnel-HWJ27WDH.js +0 -7
- package/dist/tunnel-service-ZMO4THKE.js.map +0 -1
- /package/dist/{adapter-4U6MC5ZS.js.map → adapter-ELG3VRZ3.js.map} +0 -0
- /package/dist/{agent-catalog-SZQQERV7.js.map → agent-catalog-UYD26QDK.js.map} +0 -0
- /package/dist/{api-client-XTLRRFPX.js.map → api-client-PEMHYL5U.js.map} +0 -0
- /package/dist/{api-server-5VNYFWJE.js.map → api-server-DATG2KBR.js.map} +0 -0
- /package/dist/{api-server-JLBDKCU4.js.map → api-server-L5Z7XACW.js.map} +0 -0
- /package/dist/{chunk-YIGBJFJL.js.map → chunk-7GXEMMEV.js.map} +0 -0
- /package/dist/{config-KN6NKKPF.js.map → config-X4UP7H6R.js.map} +0 -0
- /package/dist/{config-editor-76RVZS4B.js.map → config-editor-7BENRVG5.js.map} +0 -0
- /package/dist/{config-registry-ZXAIJNYB.js.map → config-registry-M3FFWEVM.js.map} +0 -0
- /package/dist/{context-NXXW62NJ.js.map → context-FVGCU5TI.js.map} +0 -0
- /package/dist/{core-plugins-OCHKGCIZ.js.map → core-plugins-JSY2I44L.js.map} +0 -0
- /package/dist/{daemon-XFEMMJSZ.js.map → daemon-UOSRDEXW.js.map} +0 -0
- /package/dist/{doctor-AV6AUO22.js.map → doctor-6DLACBR4.js.map} +0 -0
- /package/dist/{file-service-HHB3JQIO.js.map → file-service-FQQYME7M.js.map} +0 -0
- /package/dist/{install-jq-ISTGT263.js.map → install-jq-SN4IA5K4.js.map} +0 -0
- /package/dist/{security-2BA265LN.js.map → instance-context-FLCE7VZ4.js.map} +0 -0
- /package/dist/{speech-SG62JYIF.js.map → instance-registry-SW5FWKHO.js.map} +0 -0
- /package/dist/{post-upgrade-Y26S2ZQ7.js.map → post-upgrade-F4YPMTUT.js.map} +0 -0
- /package/dist/{telegram-EAVRDNFU.js.map → security-O4XGN2CM.js.map} +0 -0
- /package/dist/{tunnel-HWJ27WDH.js.map → speech-GHTSWDAN.js.map} +0 -0
|
@@ -7,17 +7,17 @@ import {
|
|
|
7
7
|
} from "./chunk-AFKX424Q.js";
|
|
8
8
|
import {
|
|
9
9
|
DoctorEngine
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
CheckpointReader,
|
|
13
|
-
DEFAULT_MAX_TOKENS
|
|
14
|
-
} from "./chunk-APS6UEFU.js";
|
|
10
|
+
} from "./chunk-K6UY5M75.js";
|
|
15
11
|
import {
|
|
16
12
|
getConfigValue,
|
|
17
13
|
getSafeFields,
|
|
18
14
|
isHotReloadable,
|
|
19
15
|
resolveOptions
|
|
20
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-NOEAJNTK.js";
|
|
17
|
+
import {
|
|
18
|
+
CheckpointReader,
|
|
19
|
+
DEFAULT_MAX_TOKENS
|
|
20
|
+
} from "./chunk-NJX75BLK.js";
|
|
21
21
|
import {
|
|
22
22
|
createChildLogger
|
|
23
23
|
} from "./chunk-R6KZYF7D.js";
|
|
@@ -2828,6 +2828,123 @@ function setupTunnelCallbacks(bot, core) {
|
|
|
2828
2828
|
});
|
|
2829
2829
|
}
|
|
2830
2830
|
|
|
2831
|
+
// src/plugins/telegram/commands/switch.ts
|
|
2832
|
+
import { InlineKeyboard as InlineKeyboard10 } from "grammy";
|
|
2833
|
+
var log8 = createChildLogger({ module: "telegram-cmd-switch" });
|
|
2834
|
+
async function handleSwitch(ctx, core) {
|
|
2835
|
+
const threadId = ctx.message?.message_thread_id;
|
|
2836
|
+
if (!threadId) return;
|
|
2837
|
+
const session = await core.getOrResumeSession("telegram", String(threadId));
|
|
2838
|
+
if (!session) {
|
|
2839
|
+
await ctx.reply("No active session in this topic.");
|
|
2840
|
+
return;
|
|
2841
|
+
}
|
|
2842
|
+
const rawMatch = ctx.match;
|
|
2843
|
+
const raw = (typeof rawMatch === "string" ? rawMatch : "").trim();
|
|
2844
|
+
if (raw.startsWith("label ")) {
|
|
2845
|
+
const value = raw.slice(6).trim().toLowerCase();
|
|
2846
|
+
if (value === "on" || value === "off") {
|
|
2847
|
+
await core.configManager.save(
|
|
2848
|
+
{ agentSwitch: { labelHistory: value === "on" } },
|
|
2849
|
+
"agentSwitch.labelHistory"
|
|
2850
|
+
);
|
|
2851
|
+
await ctx.reply(`Agent label in history: ${value}`);
|
|
2852
|
+
} else {
|
|
2853
|
+
await ctx.reply("Usage: /switch label on|off");
|
|
2854
|
+
}
|
|
2855
|
+
return;
|
|
2856
|
+
}
|
|
2857
|
+
if (!raw) {
|
|
2858
|
+
const agents = core.agentManager.getAvailableAgents();
|
|
2859
|
+
const currentAgent = session.agentName;
|
|
2860
|
+
const options = agents.filter((a) => a.name !== currentAgent);
|
|
2861
|
+
if (options.length === 0) {
|
|
2862
|
+
await ctx.reply("No other agents available.");
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
const keyboard = new InlineKeyboard10();
|
|
2866
|
+
for (const agent of options) {
|
|
2867
|
+
keyboard.text(agent.name, `sw:${agent.name}`).row();
|
|
2868
|
+
}
|
|
2869
|
+
await ctx.reply(
|
|
2870
|
+
`<b>Switch Agent</b>
|
|
2871
|
+
Current: <code>${escapeHtml(currentAgent)}</code>
|
|
2872
|
+
|
|
2873
|
+
Select an agent:`,
|
|
2874
|
+
{ parse_mode: "HTML", reply_markup: keyboard }
|
|
2875
|
+
);
|
|
2876
|
+
return;
|
|
2877
|
+
}
|
|
2878
|
+
if (session.promptRunning) {
|
|
2879
|
+
const keyboard = new InlineKeyboard10();
|
|
2880
|
+
keyboard.text("Yes, switch now", `swc:${raw}`).text("Cancel", "swc:cancel");
|
|
2881
|
+
await ctx.reply(
|
|
2882
|
+
`A prompt is currently running. Switching will interrupt it.
|
|
2883
|
+
|
|
2884
|
+
Switch to <b>${escapeHtml(raw)}</b> anyway?`,
|
|
2885
|
+
{ parse_mode: "HTML", reply_markup: keyboard }
|
|
2886
|
+
);
|
|
2887
|
+
return;
|
|
2888
|
+
}
|
|
2889
|
+
await executeSwitchAgent(ctx, core, session.id, raw);
|
|
2890
|
+
}
|
|
2891
|
+
async function executeSwitchAgent(ctx, core, sessionId, agentName) {
|
|
2892
|
+
try {
|
|
2893
|
+
const { resumed } = await core.switchSessionAgent(sessionId, agentName);
|
|
2894
|
+
const status = resumed ? "resumed" : "new session";
|
|
2895
|
+
await ctx.reply(
|
|
2896
|
+
`Switched to <b>${escapeHtml(agentName)}</b> (${status})`,
|
|
2897
|
+
{ parse_mode: "HTML" }
|
|
2898
|
+
);
|
|
2899
|
+
log8.info({ sessionId, agentName, resumed }, "Agent switched via /switch");
|
|
2900
|
+
} catch (err) {
|
|
2901
|
+
await ctx.reply(`Failed to switch agent: ${escapeHtml(String(err.message || err))}`);
|
|
2902
|
+
log8.warn({ sessionId, agentName, err: err.message }, "Agent switch failed");
|
|
2903
|
+
}
|
|
2904
|
+
}
|
|
2905
|
+
function setupSwitchCallbacks(bot, core) {
|
|
2906
|
+
bot.callbackQuery(/^sw:/, async (ctx) => {
|
|
2907
|
+
const agentName = ctx.callbackQuery.data.replace("sw:", "");
|
|
2908
|
+
await ctx.answerCallbackQuery();
|
|
2909
|
+
const threadId = ctx.callbackQuery.message?.message_thread_id;
|
|
2910
|
+
if (!threadId) return;
|
|
2911
|
+
const session = await core.getOrResumeSession("telegram", String(threadId));
|
|
2912
|
+
if (!session) {
|
|
2913
|
+
await ctx.reply("No active session in this topic.");
|
|
2914
|
+
return;
|
|
2915
|
+
}
|
|
2916
|
+
if (session.promptRunning) {
|
|
2917
|
+
const keyboard = new InlineKeyboard10();
|
|
2918
|
+
keyboard.text("Yes, switch now", `swc:${agentName}`).text("Cancel", "swc:cancel");
|
|
2919
|
+
await ctx.reply(
|
|
2920
|
+
`A prompt is currently running. Switching will interrupt it.
|
|
2921
|
+
|
|
2922
|
+
Switch to <b>${escapeHtml(agentName)}</b> anyway?`,
|
|
2923
|
+
{ parse_mode: "HTML", reply_markup: keyboard }
|
|
2924
|
+
);
|
|
2925
|
+
return;
|
|
2926
|
+
}
|
|
2927
|
+
await executeSwitchAgent(ctx, core, session.id, agentName);
|
|
2928
|
+
});
|
|
2929
|
+
bot.callbackQuery(/^swc:/, async (ctx) => {
|
|
2930
|
+
const data = ctx.callbackQuery.data.replace("swc:", "");
|
|
2931
|
+
await ctx.answerCallbackQuery();
|
|
2932
|
+
if (data === "cancel") {
|
|
2933
|
+
await ctx.editMessageText("Switch cancelled.");
|
|
2934
|
+
return;
|
|
2935
|
+
}
|
|
2936
|
+
const threadId = ctx.callbackQuery.message?.message_thread_id;
|
|
2937
|
+
if (!threadId) return;
|
|
2938
|
+
const session = await core.getOrResumeSession("telegram", String(threadId));
|
|
2939
|
+
if (!session) {
|
|
2940
|
+
await ctx.reply("No active session in this topic.");
|
|
2941
|
+
return;
|
|
2942
|
+
}
|
|
2943
|
+
await session.abortPrompt();
|
|
2944
|
+
await executeSwitchAgent(ctx, core, session.id, data);
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2831
2948
|
// src/plugins/telegram/commands/index.ts
|
|
2832
2949
|
function setupCommands(bot, core, chatId, assistant) {
|
|
2833
2950
|
bot.command("new", (ctx) => handleNew(ctx, core, chatId, assistant));
|
|
@@ -2853,6 +2970,7 @@ function setupCommands(bot, core, chatId, assistant) {
|
|
|
2853
2970
|
bot.command("verbosity", (ctx) => handleVerbosity(ctx, core));
|
|
2854
2971
|
bot.command("outputmode", (ctx) => handleOutputMode(ctx, core));
|
|
2855
2972
|
bot.command("resume", (ctx) => handleResume(ctx, core, chatId, assistant));
|
|
2973
|
+
bot.command("switch", (ctx) => handleSwitch(ctx, core));
|
|
2856
2974
|
}
|
|
2857
2975
|
function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSession) {
|
|
2858
2976
|
setupNewSessionCallbacks(bot, core, chatId);
|
|
@@ -2861,6 +2979,7 @@ function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSessio
|
|
|
2861
2979
|
setupSettingsCallbacks(bot, core, getAssistantSession ?? (() => void 0));
|
|
2862
2980
|
setupDoctorCallbacks(bot);
|
|
2863
2981
|
setupTunnelCallbacks(bot, core);
|
|
2982
|
+
setupSwitchCallbacks(bot, core);
|
|
2864
2983
|
bot.callbackQuery(/^ag:/, (ctx) => handleAgentCallback(ctx, core));
|
|
2865
2984
|
bot.callbackQuery(/^na:/, async (ctx) => {
|
|
2866
2985
|
const agentKey = ctx.callbackQuery.data.replace("na:", "");
|
|
@@ -2941,13 +3060,14 @@ var STATIC_COMMANDS = [
|
|
|
2941
3060
|
{ command: "text_to_speech", description: "Toggle Text to Speech (/text_to_speech on, /text_to_speech off)" },
|
|
2942
3061
|
{ command: "verbosity", description: "Deprecated: use /outputmode instead" },
|
|
2943
3062
|
{ command: "outputmode", description: "Control output display level (low/medium/high)" },
|
|
2944
|
-
{ command: "resume", description: "Resume with conversation history from Entire checkpoints" }
|
|
3063
|
+
{ command: "resume", description: "Resume with conversation history from Entire checkpoints" },
|
|
3064
|
+
{ command: "switch", description: "Switch agent in current session" }
|
|
2945
3065
|
];
|
|
2946
3066
|
|
|
2947
3067
|
// src/plugins/telegram/permissions.ts
|
|
2948
|
-
import { InlineKeyboard as
|
|
3068
|
+
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
2949
3069
|
import { nanoid } from "nanoid";
|
|
2950
|
-
var
|
|
3070
|
+
var log9 = createChildLogger({ module: "telegram-permissions" });
|
|
2951
3071
|
var PermissionHandler = class {
|
|
2952
3072
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
2953
3073
|
this.bot = bot;
|
|
@@ -2964,7 +3084,7 @@ var PermissionHandler = class {
|
|
|
2964
3084
|
requestId: request.id,
|
|
2965
3085
|
options: request.options.map((o) => ({ id: o.id, isAllow: o.isAllow }))
|
|
2966
3086
|
});
|
|
2967
|
-
const keyboard = new
|
|
3087
|
+
const keyboard = new InlineKeyboard11();
|
|
2968
3088
|
for (const option of request.options) {
|
|
2969
3089
|
const emoji = option.isAllow ? "\u2705" : "\u274C";
|
|
2970
3090
|
keyboard.text(`${emoji} ${option.label}`, `p:${callbackKey}:${option.id}`);
|
|
@@ -3007,7 +3127,7 @@ ${escapeHtml(request.description)}`,
|
|
|
3007
3127
|
}
|
|
3008
3128
|
const session = this.getSession(pending.sessionId);
|
|
3009
3129
|
const isAllow = pending.options.find((o) => o.id === optionId)?.isAllow ?? false;
|
|
3010
|
-
|
|
3130
|
+
log9.info({ requestId: pending.requestId, optionId, isAllow }, "Permission responded");
|
|
3011
3131
|
if (session?.permissionGate.requestId === pending.requestId) {
|
|
3012
3132
|
session.permissionGate.resolve(optionId);
|
|
3013
3133
|
}
|
|
@@ -3443,10 +3563,10 @@ Session logs auto-cleanup: 30 days (configurable via \`logging.sessionLogRetenti
|
|
|
3443
3563
|
`;
|
|
3444
3564
|
|
|
3445
3565
|
// src/plugins/telegram/assistant.ts
|
|
3446
|
-
var
|
|
3566
|
+
var log10 = createChildLogger({ module: "telegram-assistant" });
|
|
3447
3567
|
async function spawnAssistant(core, adapter, assistantTopicId) {
|
|
3448
3568
|
const config = core.configManager.get();
|
|
3449
|
-
|
|
3569
|
+
log10.info({ agent: config.defaultAgent }, "Creating assistant session...");
|
|
3450
3570
|
const session = await core.createSession({
|
|
3451
3571
|
channelId: "telegram",
|
|
3452
3572
|
agentName: config.defaultAgent,
|
|
@@ -3455,7 +3575,7 @@ async function spawnAssistant(core, adapter, assistantTopicId) {
|
|
|
3455
3575
|
// Prevent auto-naming from triggering after system prompt
|
|
3456
3576
|
});
|
|
3457
3577
|
session.threadId = String(assistantTopicId);
|
|
3458
|
-
|
|
3578
|
+
log10.info({ sessionId: session.id }, "Assistant agent spawned");
|
|
3459
3579
|
const allRecords = core.sessionManager.listRecords();
|
|
3460
3580
|
const activeCount = allRecords.filter((r) => r.status === "active" || r.status === "initializing").length;
|
|
3461
3581
|
const statusCounts = /* @__PURE__ */ new Map();
|
|
@@ -3476,9 +3596,9 @@ async function spawnAssistant(core, adapter, assistantTopicId) {
|
|
|
3476
3596
|
};
|
|
3477
3597
|
const systemPrompt = buildAssistantSystemPrompt(ctx);
|
|
3478
3598
|
const ready = session.enqueuePrompt(systemPrompt).then(() => {
|
|
3479
|
-
|
|
3599
|
+
log10.info({ sessionId: session.id }, "Assistant system prompt completed");
|
|
3480
3600
|
}).catch((err) => {
|
|
3481
|
-
|
|
3601
|
+
log10.warn({ err }, "Assistant system prompt failed");
|
|
3482
3602
|
});
|
|
3483
3603
|
return { session, ready };
|
|
3484
3604
|
}
|
|
@@ -3973,7 +4093,7 @@ var DisplaySpecBuilder = class {
|
|
|
3973
4093
|
};
|
|
3974
4094
|
|
|
3975
4095
|
// src/plugins/telegram/activity.ts
|
|
3976
|
-
var
|
|
4096
|
+
var log11 = createChildLogger({ module: "telegram:activity" });
|
|
3977
4097
|
var THINKING_REFRESH_MS = 15e3;
|
|
3978
4098
|
var THINKING_MAX_MS = 3 * 60 * 1e3;
|
|
3979
4099
|
var ThinkingIndicator = class {
|
|
@@ -4014,7 +4134,7 @@ var ThinkingIndicator = class {
|
|
|
4014
4134
|
}
|
|
4015
4135
|
}
|
|
4016
4136
|
} catch (err) {
|
|
4017
|
-
|
|
4137
|
+
log11.warn({ err }, "ThinkingIndicator.show() failed");
|
|
4018
4138
|
} finally {
|
|
4019
4139
|
this.sending = false;
|
|
4020
4140
|
}
|
|
@@ -4173,7 +4293,7 @@ var ToolCard = class {
|
|
|
4173
4293
|
}
|
|
4174
4294
|
}
|
|
4175
4295
|
} catch (err) {
|
|
4176
|
-
|
|
4296
|
+
log11.warn({ err }, "[ToolCard] send/edit failed");
|
|
4177
4297
|
}
|
|
4178
4298
|
}
|
|
4179
4299
|
};
|
|
@@ -4277,7 +4397,7 @@ var ActivityTracker = class {
|
|
|
4277
4397
|
const entry = this.toolStateMap.merge(id, status, rawInput, content, viewerLinks, diffStats);
|
|
4278
4398
|
if (!existed || !entry) return;
|
|
4279
4399
|
if (viewerLinks || entry.viewerLinks) {
|
|
4280
|
-
|
|
4400
|
+
log11.debug({ toolId: id, status, hasIncomingLinks: !!viewerLinks, hasEntryLinks: !!entry.viewerLinks, entryLinks: entry.viewerLinks }, "toolUpdate: viewer links trace");
|
|
4281
4401
|
}
|
|
4282
4402
|
const spec = this.specBuilder.buildToolSpec(entry, this._outputMode, this.sessionContext);
|
|
4283
4403
|
this.toolCard.updateFromSpec(spec);
|
|
@@ -4414,7 +4534,7 @@ var SendQueue = class {
|
|
|
4414
4534
|
|
|
4415
4535
|
// src/plugins/telegram/action-detect.ts
|
|
4416
4536
|
import { nanoid as nanoid2 } from "nanoid";
|
|
4417
|
-
import { InlineKeyboard as
|
|
4537
|
+
import { InlineKeyboard as InlineKeyboard12 } from "grammy";
|
|
4418
4538
|
var CMD_NEW_RE = /\/new(?:\s+([^\s\u0080-\uFFFF]+)(?:\s+([^\s\u0080-\uFFFF]+))?)?/;
|
|
4419
4539
|
var CMD_CANCEL_RE = /\/cancel\b/;
|
|
4420
4540
|
var KW_NEW_RE = /(?:create|new)\s+session/i;
|
|
@@ -4461,7 +4581,7 @@ function removeAction(id) {
|
|
|
4461
4581
|
actionMap.delete(id);
|
|
4462
4582
|
}
|
|
4463
4583
|
function buildActionKeyboard(actionId, action) {
|
|
4464
|
-
const keyboard = new
|
|
4584
|
+
const keyboard = new InlineKeyboard12();
|
|
4465
4585
|
if (action.action === "new_session") {
|
|
4466
4586
|
keyboard.text("\u2705 Create session", `a:${actionId}`);
|
|
4467
4587
|
keyboard.text("\u274C Cancel", `a:dismiss:${actionId}`);
|
|
@@ -4853,7 +4973,7 @@ var DraftManager = class {
|
|
|
4853
4973
|
};
|
|
4854
4974
|
|
|
4855
4975
|
// src/plugins/telegram/skill-command-manager.ts
|
|
4856
|
-
var
|
|
4976
|
+
var log12 = createChildLogger({ module: "skill-commands" });
|
|
4857
4977
|
var SkillCommandManager = class {
|
|
4858
4978
|
// sessionId → pinned msgId
|
|
4859
4979
|
constructor(bot, chatId, sendQueue, sessionManager) {
|
|
@@ -4919,7 +5039,7 @@ var SkillCommandManager = class {
|
|
|
4919
5039
|
disable_notification: true
|
|
4920
5040
|
});
|
|
4921
5041
|
} catch (err) {
|
|
4922
|
-
|
|
5042
|
+
log12.error({ err, sessionId }, "Failed to send skill commands");
|
|
4923
5043
|
}
|
|
4924
5044
|
}
|
|
4925
5045
|
async cleanup(sessionId) {
|
|
@@ -5263,7 +5383,7 @@ var OutputModeResolver = class {
|
|
|
5263
5383
|
};
|
|
5264
5384
|
|
|
5265
5385
|
// src/plugins/telegram/adapter.ts
|
|
5266
|
-
var
|
|
5386
|
+
var log13 = createChildLogger({ module: "telegram" });
|
|
5267
5387
|
function patchedFetch(input, init) {
|
|
5268
5388
|
if (init?.signal && !(init.signal instanceof AbortSignal)) {
|
|
5269
5389
|
const nativeController = new AbortController();
|
|
@@ -5291,6 +5411,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5291
5411
|
core;
|
|
5292
5412
|
bot;
|
|
5293
5413
|
telegramConfig;
|
|
5414
|
+
saveTopicIds;
|
|
5294
5415
|
permissionHandler;
|
|
5295
5416
|
assistantSession = null;
|
|
5296
5417
|
assistantInitializing = false;
|
|
@@ -5339,7 +5460,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5339
5460
|
}
|
|
5340
5461
|
return tracker;
|
|
5341
5462
|
}
|
|
5342
|
-
constructor(core, config) {
|
|
5463
|
+
constructor(core, config, saveTopicIds) {
|
|
5343
5464
|
super({ configManager: core.configManager }, {
|
|
5344
5465
|
...config,
|
|
5345
5466
|
maxMessageLength: 4096,
|
|
@@ -5347,6 +5468,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5347
5468
|
});
|
|
5348
5469
|
this.core = core;
|
|
5349
5470
|
this.telegramConfig = config;
|
|
5471
|
+
this.saveTopicIds = saveTopicIds;
|
|
5350
5472
|
}
|
|
5351
5473
|
async start() {
|
|
5352
5474
|
this.bot = new Bot(this.telegramConfig.botToken, {
|
|
@@ -5369,7 +5491,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5369
5491
|
);
|
|
5370
5492
|
this.bot.catch((err) => {
|
|
5371
5493
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
5372
|
-
|
|
5494
|
+
log13.error({ err: rootCause }, "Telegram bot error");
|
|
5373
5495
|
});
|
|
5374
5496
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
5375
5497
|
const maxRetries = 3;
|
|
@@ -5387,7 +5509,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5387
5509
|
if (rateLimitedMethods.includes(method)) {
|
|
5388
5510
|
this.sendQueue.onRateLimited();
|
|
5389
5511
|
}
|
|
5390
|
-
|
|
5512
|
+
log13.warn(
|
|
5391
5513
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
5392
5514
|
"Rate limited by Telegram, retrying"
|
|
5393
5515
|
);
|
|
@@ -5418,9 +5540,13 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5418
5540
|
this.telegramConfig.chatId,
|
|
5419
5541
|
this.telegramConfig,
|
|
5420
5542
|
async (updates) => {
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
}
|
|
5543
|
+
if (this.saveTopicIds) {
|
|
5544
|
+
await this.saveTopicIds(updates);
|
|
5545
|
+
} else {
|
|
5546
|
+
await this.core.configManager.save({
|
|
5547
|
+
channels: { telegram: updates }
|
|
5548
|
+
});
|
|
5549
|
+
}
|
|
5424
5550
|
}
|
|
5425
5551
|
);
|
|
5426
5552
|
this.notificationTopicId = topics.notificationTopicId;
|
|
@@ -5611,7 +5737,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5611
5737
|
this.setupRoutes();
|
|
5612
5738
|
this.bot.start({
|
|
5613
5739
|
allowed_updates: ["message", "callback_query"],
|
|
5614
|
-
onStart: () =>
|
|
5740
|
+
onStart: () => log13.info(
|
|
5615
5741
|
{ chatId: this.telegramConfig.chatId },
|
|
5616
5742
|
"Telegram bot started"
|
|
5617
5743
|
)
|
|
@@ -5635,10 +5761,10 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5635
5761
|
reply_markup: buildMenuKeyboard()
|
|
5636
5762
|
});
|
|
5637
5763
|
} catch (err) {
|
|
5638
|
-
|
|
5764
|
+
log13.warn({ err }, "Failed to send welcome message");
|
|
5639
5765
|
}
|
|
5640
5766
|
try {
|
|
5641
|
-
|
|
5767
|
+
log13.info("Spawning assistant session...");
|
|
5642
5768
|
const { session, ready } = await spawnAssistant(
|
|
5643
5769
|
this.core,
|
|
5644
5770
|
this,
|
|
@@ -5646,19 +5772,19 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5646
5772
|
);
|
|
5647
5773
|
this.assistantSession = session;
|
|
5648
5774
|
this.assistantInitializing = true;
|
|
5649
|
-
|
|
5775
|
+
log13.info(
|
|
5650
5776
|
{ sessionId: session.id },
|
|
5651
5777
|
"Assistant session ready, system prompt running in background"
|
|
5652
5778
|
);
|
|
5653
5779
|
ready.then(() => {
|
|
5654
5780
|
this.assistantInitializing = false;
|
|
5655
|
-
|
|
5781
|
+
log13.info(
|
|
5656
5782
|
{ sessionId: session.id },
|
|
5657
5783
|
"Assistant ready for user messages"
|
|
5658
5784
|
);
|
|
5659
5785
|
});
|
|
5660
5786
|
} catch (err) {
|
|
5661
|
-
|
|
5787
|
+
log13.error({ err }, "Failed to spawn assistant");
|
|
5662
5788
|
this.bot.api.sendMessage(
|
|
5663
5789
|
this.telegramConfig.chatId,
|
|
5664
5790
|
`\u26A0\uFE0F <b>Failed to start assistant session.</b>
|
|
@@ -5679,7 +5805,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5679
5805
|
await this.assistantSession.destroy();
|
|
5680
5806
|
}
|
|
5681
5807
|
await this.bot.stop();
|
|
5682
|
-
|
|
5808
|
+
log13.info("Telegram bot stopped");
|
|
5683
5809
|
}
|
|
5684
5810
|
// --- CommandRegistry response rendering ---
|
|
5685
5811
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -5807,7 +5933,7 @@ ${lines.join("\n")}`;
|
|
|
5807
5933
|
ctx.replyWithChatAction("typing").catch(() => {
|
|
5808
5934
|
});
|
|
5809
5935
|
handleAssistantMessage(this.assistantSession, forwardText).catch(
|
|
5810
|
-
(err) =>
|
|
5936
|
+
(err) => log13.error({ err }, "Assistant error")
|
|
5811
5937
|
);
|
|
5812
5938
|
return;
|
|
5813
5939
|
}
|
|
@@ -5830,7 +5956,7 @@ ${lines.join("\n")}`;
|
|
|
5830
5956
|
threadId: String(threadId),
|
|
5831
5957
|
userId: String(ctx.from.id),
|
|
5832
5958
|
text: forwardText
|
|
5833
|
-
}).catch((err) =>
|
|
5959
|
+
}).catch((err) => log13.error({ err }, "handleMessage error"));
|
|
5834
5960
|
});
|
|
5835
5961
|
this.bot.on("message:photo", async (ctx) => {
|
|
5836
5962
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -5921,7 +6047,7 @@ ${lines.join("\n")}`;
|
|
|
5921
6047
|
if (session.archiving) return;
|
|
5922
6048
|
const threadId = Number(session.threadId);
|
|
5923
6049
|
if (!threadId || isNaN(threadId)) {
|
|
5924
|
-
|
|
6050
|
+
log13.warn(
|
|
5925
6051
|
{ sessionId, threadId: session.threadId },
|
|
5926
6052
|
"Session has no valid threadId, skipping message"
|
|
5927
6053
|
);
|
|
@@ -5937,7 +6063,7 @@ ${lines.join("\n")}`;
|
|
|
5937
6063
|
this._sessionThreadIds.delete(sessionId);
|
|
5938
6064
|
}
|
|
5939
6065
|
}).catch((err) => {
|
|
5940
|
-
|
|
6066
|
+
log13.warn({ err, sessionId }, "Dispatch queue error");
|
|
5941
6067
|
});
|
|
5942
6068
|
this._dispatchQueues.set(sessionId, next);
|
|
5943
6069
|
await next;
|
|
@@ -6059,7 +6185,7 @@ ${lines.join("\n")}`;
|
|
|
6059
6185
|
);
|
|
6060
6186
|
usageMsgId = result?.message_id;
|
|
6061
6187
|
} catch (err) {
|
|
6062
|
-
|
|
6188
|
+
log13.warn({ err, sessionId }, "Failed to send usage message");
|
|
6063
6189
|
}
|
|
6064
6190
|
if (this.notificationTopicId && sessionId !== this.assistantSession?.id) {
|
|
6065
6191
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -6087,7 +6213,7 @@ Task completed.
|
|
|
6087
6213
|
if (!content.attachment) return;
|
|
6088
6214
|
const { attachment } = content;
|
|
6089
6215
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
6090
|
-
|
|
6216
|
+
log13.warn(
|
|
6091
6217
|
{
|
|
6092
6218
|
sessionId,
|
|
6093
6219
|
fileName: attachment.fileName,
|
|
@@ -6131,7 +6257,7 @@ Task completed.
|
|
|
6131
6257
|
);
|
|
6132
6258
|
}
|
|
6133
6259
|
} catch (err) {
|
|
6134
|
-
|
|
6260
|
+
log13.error(
|
|
6135
6261
|
{ err, sessionId, fileName: attachment.fileName },
|
|
6136
6262
|
"Failed to send attachment"
|
|
6137
6263
|
);
|
|
@@ -6195,7 +6321,7 @@ Task completed.
|
|
|
6195
6321
|
}
|
|
6196
6322
|
async sendPermissionRequest(sessionId, request) {
|
|
6197
6323
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
6198
|
-
|
|
6324
|
+
log13.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
6199
6325
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
6200
6326
|
if (!session) return;
|
|
6201
6327
|
await this.sendQueue.enqueue(
|
|
@@ -6205,7 +6331,7 @@ Task completed.
|
|
|
6205
6331
|
async sendNotification(notification) {
|
|
6206
6332
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
6207
6333
|
if (notification.sessionId === this.assistantSession?.id) return;
|
|
6208
|
-
|
|
6334
|
+
log13.info(
|
|
6209
6335
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
6210
6336
|
"Notification sent"
|
|
6211
6337
|
);
|
|
@@ -6244,7 +6370,7 @@ Task completed.
|
|
|
6244
6370
|
}
|
|
6245
6371
|
async createSessionThread(sessionId, name) {
|
|
6246
6372
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
6247
|
-
|
|
6373
|
+
log13.info({ sessionId, name }, "Session topic created");
|
|
6248
6374
|
return String(
|
|
6249
6375
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
6250
6376
|
);
|
|
@@ -6269,7 +6395,7 @@ Task completed.
|
|
|
6269
6395
|
try {
|
|
6270
6396
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
6271
6397
|
} catch (err) {
|
|
6272
|
-
|
|
6398
|
+
log13.warn(
|
|
6273
6399
|
{ err, sessionId, topicId },
|
|
6274
6400
|
"Failed to delete forum topic (may already be deleted)"
|
|
6275
6401
|
);
|
|
@@ -6299,7 +6425,7 @@ Task completed.
|
|
|
6299
6425
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
6300
6426
|
return { buffer, filePath: file.file_path };
|
|
6301
6427
|
} catch (err) {
|
|
6302
|
-
|
|
6428
|
+
log13.error({ err }, "Failed to download file from Telegram");
|
|
6303
6429
|
return null;
|
|
6304
6430
|
}
|
|
6305
6431
|
}
|
|
@@ -6320,7 +6446,7 @@ Task completed.
|
|
|
6320
6446
|
try {
|
|
6321
6447
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
6322
6448
|
} catch (err) {
|
|
6323
|
-
|
|
6449
|
+
log13.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
6324
6450
|
fileName = "voice.ogg";
|
|
6325
6451
|
mimeType = "audio/ogg";
|
|
6326
6452
|
originalFilePath = void 0;
|
|
@@ -6351,11 +6477,20 @@ Task completed.
|
|
|
6351
6477
|
userId: String(userId),
|
|
6352
6478
|
text,
|
|
6353
6479
|
attachments: [att]
|
|
6354
|
-
}).catch((err) =>
|
|
6480
|
+
}).catch((err) => log13.error({ err }, "handleMessage error"));
|
|
6355
6481
|
}
|
|
6356
6482
|
async cleanupSkillCommands(sessionId) {
|
|
6357
6483
|
await this.skillManager.cleanup(sessionId);
|
|
6358
6484
|
}
|
|
6485
|
+
async cleanupSessionState(sessionId) {
|
|
6486
|
+
await this.draftManager.finalize(sessionId, this.assistantSession?.id);
|
|
6487
|
+
this.draftManager.cleanup(sessionId);
|
|
6488
|
+
const tracker = this.sessionTrackers.get(sessionId);
|
|
6489
|
+
if (tracker) {
|
|
6490
|
+
tracker.destroy();
|
|
6491
|
+
this.sessionTrackers.delete(sessionId);
|
|
6492
|
+
}
|
|
6493
|
+
}
|
|
6359
6494
|
async stripTTSBlock(sessionId) {
|
|
6360
6495
|
await this.draftManager.stripPattern(sessionId, /\[TTS\][\s\S]*?\[\/TTS\]/g);
|
|
6361
6496
|
}
|
|
@@ -6396,9 +6531,14 @@ export {
|
|
|
6396
6531
|
formatToolTitle,
|
|
6397
6532
|
resolveToolIcon,
|
|
6398
6533
|
PRODUCT_GUIDE,
|
|
6534
|
+
ToolCardState,
|
|
6535
|
+
ToolStateMap,
|
|
6536
|
+
ThoughtBuffer,
|
|
6537
|
+
DisplaySpecBuilder,
|
|
6399
6538
|
SendQueue,
|
|
6400
6539
|
MessagingAdapter,
|
|
6401
6540
|
BaseRenderer,
|
|
6541
|
+
OutputModeResolver,
|
|
6402
6542
|
TelegramAdapter
|
|
6403
6543
|
};
|
|
6404
|
-
//# sourceMappingURL=chunk-
|
|
6544
|
+
//# sourceMappingURL=chunk-EWVXSTQK.js.map
|