@openacp/cli 2026.330.3 → 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-2HEFALTZ.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-XBZIHNKV.js → chunk-EWVXSTQK.js} +183 -49
- 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-UCIZM5SW.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-237WYH6H.js → chunk-SSLVNCEA.js} +3 -2
- 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 +259 -30
- 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-VEJCG5PY.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-DISPNDEK.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-AWSI4GML.js +0 -13
- package/dist/api-server-5VNYFWJE.js +0 -7
- package/dist/chunk-237WYH6H.js.map +0 -1
- 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-APS6UEFU.js.map +0 -1
- package/dist/chunk-BTJHGSLM.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-UCIZM5SW.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/chunk-XBZIHNKV.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-BPZY7SEB.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-VEJCG5PY.js.map +0 -1
- package/dist/setup-DISPNDEK.js.map +0 -1
- package/dist/telegram-L3YM6SQJ.js +0 -7
- package/dist/tunnel-HWJ27WDH.js +0 -7
- package/dist/tunnel-service-ZMO4THKE.js.map +0 -1
- /package/dist/{adapter-AWSI4GML.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-2HEFALTZ.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-BPZY7SEB.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-L3YM6SQJ.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();
|
|
@@ -5371,7 +5491,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5371
5491
|
);
|
|
5372
5492
|
this.bot.catch((err) => {
|
|
5373
5493
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
5374
|
-
|
|
5494
|
+
log13.error({ err: rootCause }, "Telegram bot error");
|
|
5375
5495
|
});
|
|
5376
5496
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
5377
5497
|
const maxRetries = 3;
|
|
@@ -5389,7 +5509,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5389
5509
|
if (rateLimitedMethods.includes(method)) {
|
|
5390
5510
|
this.sendQueue.onRateLimited();
|
|
5391
5511
|
}
|
|
5392
|
-
|
|
5512
|
+
log13.warn(
|
|
5393
5513
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
5394
5514
|
"Rate limited by Telegram, retrying"
|
|
5395
5515
|
);
|
|
@@ -5617,7 +5737,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5617
5737
|
this.setupRoutes();
|
|
5618
5738
|
this.bot.start({
|
|
5619
5739
|
allowed_updates: ["message", "callback_query"],
|
|
5620
|
-
onStart: () =>
|
|
5740
|
+
onStart: () => log13.info(
|
|
5621
5741
|
{ chatId: this.telegramConfig.chatId },
|
|
5622
5742
|
"Telegram bot started"
|
|
5623
5743
|
)
|
|
@@ -5641,10 +5761,10 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5641
5761
|
reply_markup: buildMenuKeyboard()
|
|
5642
5762
|
});
|
|
5643
5763
|
} catch (err) {
|
|
5644
|
-
|
|
5764
|
+
log13.warn({ err }, "Failed to send welcome message");
|
|
5645
5765
|
}
|
|
5646
5766
|
try {
|
|
5647
|
-
|
|
5767
|
+
log13.info("Spawning assistant session...");
|
|
5648
5768
|
const { session, ready } = await spawnAssistant(
|
|
5649
5769
|
this.core,
|
|
5650
5770
|
this,
|
|
@@ -5652,19 +5772,19 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5652
5772
|
);
|
|
5653
5773
|
this.assistantSession = session;
|
|
5654
5774
|
this.assistantInitializing = true;
|
|
5655
|
-
|
|
5775
|
+
log13.info(
|
|
5656
5776
|
{ sessionId: session.id },
|
|
5657
5777
|
"Assistant session ready, system prompt running in background"
|
|
5658
5778
|
);
|
|
5659
5779
|
ready.then(() => {
|
|
5660
5780
|
this.assistantInitializing = false;
|
|
5661
|
-
|
|
5781
|
+
log13.info(
|
|
5662
5782
|
{ sessionId: session.id },
|
|
5663
5783
|
"Assistant ready for user messages"
|
|
5664
5784
|
);
|
|
5665
5785
|
});
|
|
5666
5786
|
} catch (err) {
|
|
5667
|
-
|
|
5787
|
+
log13.error({ err }, "Failed to spawn assistant");
|
|
5668
5788
|
this.bot.api.sendMessage(
|
|
5669
5789
|
this.telegramConfig.chatId,
|
|
5670
5790
|
`\u26A0\uFE0F <b>Failed to start assistant session.</b>
|
|
@@ -5685,7 +5805,7 @@ var TelegramAdapter = class extends MessagingAdapter {
|
|
|
5685
5805
|
await this.assistantSession.destroy();
|
|
5686
5806
|
}
|
|
5687
5807
|
await this.bot.stop();
|
|
5688
|
-
|
|
5808
|
+
log13.info("Telegram bot stopped");
|
|
5689
5809
|
}
|
|
5690
5810
|
// --- CommandRegistry response rendering ---
|
|
5691
5811
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -5813,7 +5933,7 @@ ${lines.join("\n")}`;
|
|
|
5813
5933
|
ctx.replyWithChatAction("typing").catch(() => {
|
|
5814
5934
|
});
|
|
5815
5935
|
handleAssistantMessage(this.assistantSession, forwardText).catch(
|
|
5816
|
-
(err) =>
|
|
5936
|
+
(err) => log13.error({ err }, "Assistant error")
|
|
5817
5937
|
);
|
|
5818
5938
|
return;
|
|
5819
5939
|
}
|
|
@@ -5836,7 +5956,7 @@ ${lines.join("\n")}`;
|
|
|
5836
5956
|
threadId: String(threadId),
|
|
5837
5957
|
userId: String(ctx.from.id),
|
|
5838
5958
|
text: forwardText
|
|
5839
|
-
}).catch((err) =>
|
|
5959
|
+
}).catch((err) => log13.error({ err }, "handleMessage error"));
|
|
5840
5960
|
});
|
|
5841
5961
|
this.bot.on("message:photo", async (ctx) => {
|
|
5842
5962
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -5927,7 +6047,7 @@ ${lines.join("\n")}`;
|
|
|
5927
6047
|
if (session.archiving) return;
|
|
5928
6048
|
const threadId = Number(session.threadId);
|
|
5929
6049
|
if (!threadId || isNaN(threadId)) {
|
|
5930
|
-
|
|
6050
|
+
log13.warn(
|
|
5931
6051
|
{ sessionId, threadId: session.threadId },
|
|
5932
6052
|
"Session has no valid threadId, skipping message"
|
|
5933
6053
|
);
|
|
@@ -5943,7 +6063,7 @@ ${lines.join("\n")}`;
|
|
|
5943
6063
|
this._sessionThreadIds.delete(sessionId);
|
|
5944
6064
|
}
|
|
5945
6065
|
}).catch((err) => {
|
|
5946
|
-
|
|
6066
|
+
log13.warn({ err, sessionId }, "Dispatch queue error");
|
|
5947
6067
|
});
|
|
5948
6068
|
this._dispatchQueues.set(sessionId, next);
|
|
5949
6069
|
await next;
|
|
@@ -6065,7 +6185,7 @@ ${lines.join("\n")}`;
|
|
|
6065
6185
|
);
|
|
6066
6186
|
usageMsgId = result?.message_id;
|
|
6067
6187
|
} catch (err) {
|
|
6068
|
-
|
|
6188
|
+
log13.warn({ err, sessionId }, "Failed to send usage message");
|
|
6069
6189
|
}
|
|
6070
6190
|
if (this.notificationTopicId && sessionId !== this.assistantSession?.id) {
|
|
6071
6191
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -6093,7 +6213,7 @@ Task completed.
|
|
|
6093
6213
|
if (!content.attachment) return;
|
|
6094
6214
|
const { attachment } = content;
|
|
6095
6215
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
6096
|
-
|
|
6216
|
+
log13.warn(
|
|
6097
6217
|
{
|
|
6098
6218
|
sessionId,
|
|
6099
6219
|
fileName: attachment.fileName,
|
|
@@ -6137,7 +6257,7 @@ Task completed.
|
|
|
6137
6257
|
);
|
|
6138
6258
|
}
|
|
6139
6259
|
} catch (err) {
|
|
6140
|
-
|
|
6260
|
+
log13.error(
|
|
6141
6261
|
{ err, sessionId, fileName: attachment.fileName },
|
|
6142
6262
|
"Failed to send attachment"
|
|
6143
6263
|
);
|
|
@@ -6201,7 +6321,7 @@ Task completed.
|
|
|
6201
6321
|
}
|
|
6202
6322
|
async sendPermissionRequest(sessionId, request) {
|
|
6203
6323
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
6204
|
-
|
|
6324
|
+
log13.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
6205
6325
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
6206
6326
|
if (!session) return;
|
|
6207
6327
|
await this.sendQueue.enqueue(
|
|
@@ -6211,7 +6331,7 @@ Task completed.
|
|
|
6211
6331
|
async sendNotification(notification) {
|
|
6212
6332
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
6213
6333
|
if (notification.sessionId === this.assistantSession?.id) return;
|
|
6214
|
-
|
|
6334
|
+
log13.info(
|
|
6215
6335
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
6216
6336
|
"Notification sent"
|
|
6217
6337
|
);
|
|
@@ -6250,7 +6370,7 @@ Task completed.
|
|
|
6250
6370
|
}
|
|
6251
6371
|
async createSessionThread(sessionId, name) {
|
|
6252
6372
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
6253
|
-
|
|
6373
|
+
log13.info({ sessionId, name }, "Session topic created");
|
|
6254
6374
|
return String(
|
|
6255
6375
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
6256
6376
|
);
|
|
@@ -6275,7 +6395,7 @@ Task completed.
|
|
|
6275
6395
|
try {
|
|
6276
6396
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
6277
6397
|
} catch (err) {
|
|
6278
|
-
|
|
6398
|
+
log13.warn(
|
|
6279
6399
|
{ err, sessionId, topicId },
|
|
6280
6400
|
"Failed to delete forum topic (may already be deleted)"
|
|
6281
6401
|
);
|
|
@@ -6305,7 +6425,7 @@ Task completed.
|
|
|
6305
6425
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
6306
6426
|
return { buffer, filePath: file.file_path };
|
|
6307
6427
|
} catch (err) {
|
|
6308
|
-
|
|
6428
|
+
log13.error({ err }, "Failed to download file from Telegram");
|
|
6309
6429
|
return null;
|
|
6310
6430
|
}
|
|
6311
6431
|
}
|
|
@@ -6326,7 +6446,7 @@ Task completed.
|
|
|
6326
6446
|
try {
|
|
6327
6447
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
6328
6448
|
} catch (err) {
|
|
6329
|
-
|
|
6449
|
+
log13.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
6330
6450
|
fileName = "voice.ogg";
|
|
6331
6451
|
mimeType = "audio/ogg";
|
|
6332
6452
|
originalFilePath = void 0;
|
|
@@ -6357,11 +6477,20 @@ Task completed.
|
|
|
6357
6477
|
userId: String(userId),
|
|
6358
6478
|
text,
|
|
6359
6479
|
attachments: [att]
|
|
6360
|
-
}).catch((err) =>
|
|
6480
|
+
}).catch((err) => log13.error({ err }, "handleMessage error"));
|
|
6361
6481
|
}
|
|
6362
6482
|
async cleanupSkillCommands(sessionId) {
|
|
6363
6483
|
await this.skillManager.cleanup(sessionId);
|
|
6364
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
|
+
}
|
|
6365
6494
|
async stripTTSBlock(sessionId) {
|
|
6366
6495
|
await this.draftManager.stripPattern(sessionId, /\[TTS\][\s\S]*?\[\/TTS\]/g);
|
|
6367
6496
|
}
|
|
@@ -6402,9 +6531,14 @@ export {
|
|
|
6402
6531
|
formatToolTitle,
|
|
6403
6532
|
resolveToolIcon,
|
|
6404
6533
|
PRODUCT_GUIDE,
|
|
6534
|
+
ToolCardState,
|
|
6535
|
+
ToolStateMap,
|
|
6536
|
+
ThoughtBuffer,
|
|
6537
|
+
DisplaySpecBuilder,
|
|
6405
6538
|
SendQueue,
|
|
6406
6539
|
MessagingAdapter,
|
|
6407
6540
|
BaseRenderer,
|
|
6541
|
+
OutputModeResolver,
|
|
6408
6542
|
TelegramAdapter
|
|
6409
6543
|
};
|
|
6410
|
-
//# sourceMappingURL=chunk-
|
|
6544
|
+
//# sourceMappingURL=chunk-EWVXSTQK.js.map
|