@openacp/cli 2026.405.2 → 2026.406.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/dist/cli.js +192 -180
- package/dist/cli.js.map +1 -1
- package/dist/index.js +78 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8096,7 +8096,10 @@ function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSessio
|
|
|
8096
8096
|
const menuRegistry = core.lifecycleManager?.serviceRegistry?.get("menu-registry");
|
|
8097
8097
|
if (!menuRegistry) return;
|
|
8098
8098
|
const item = menuRegistry.getItem(itemId);
|
|
8099
|
-
if (!item)
|
|
8099
|
+
if (!item) {
|
|
8100
|
+
log30.warn({ itemId }, "Menu item not found in registry");
|
|
8101
|
+
return;
|
|
8102
|
+
}
|
|
8100
8103
|
const topicId = ctx.callbackQuery.message?.message_thread_id;
|
|
8101
8104
|
const registry = core.lifecycleManager?.serviceRegistry?.get("command-registry");
|
|
8102
8105
|
switch (item.action.type) {
|
|
@@ -8180,7 +8183,7 @@ ${lines}`, { parse_mode: "HTML" }).catch(() => {
|
|
|
8180
8183
|
}
|
|
8181
8184
|
});
|
|
8182
8185
|
}
|
|
8183
|
-
var STATIC_COMMANDS;
|
|
8186
|
+
var log30, STATIC_COMMANDS;
|
|
8184
8187
|
var init_commands = __esm({
|
|
8185
8188
|
"src/plugins/telegram/commands/index.ts"() {
|
|
8186
8189
|
"use strict";
|
|
@@ -8193,6 +8196,7 @@ var init_commands = __esm({
|
|
|
8193
8196
|
init_tunnel2();
|
|
8194
8197
|
init_switch();
|
|
8195
8198
|
init_telegram_overrides();
|
|
8199
|
+
init_log();
|
|
8196
8200
|
init_menu();
|
|
8197
8201
|
init_menu();
|
|
8198
8202
|
init_telegram_overrides();
|
|
@@ -8204,6 +8208,7 @@ var init_commands = __esm({
|
|
|
8204
8208
|
init_settings();
|
|
8205
8209
|
init_doctor2();
|
|
8206
8210
|
init_resume();
|
|
8211
|
+
log30 = createChildLogger({ module: "telegram-menu-callbacks" });
|
|
8207
8212
|
STATIC_COMMANDS = [
|
|
8208
8213
|
{ command: "new", description: "Create new session" },
|
|
8209
8214
|
{ command: "newchat", description: "New chat, same agent & workspace" },
|
|
@@ -8239,14 +8244,14 @@ var init_commands = __esm({
|
|
|
8239
8244
|
// src/plugins/telegram/permissions.ts
|
|
8240
8245
|
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
8241
8246
|
import { nanoid as nanoid4 } from "nanoid";
|
|
8242
|
-
var
|
|
8247
|
+
var log31, PermissionHandler;
|
|
8243
8248
|
var init_permissions = __esm({
|
|
8244
8249
|
"src/plugins/telegram/permissions.ts"() {
|
|
8245
8250
|
"use strict";
|
|
8246
8251
|
init_formatting();
|
|
8247
8252
|
init_topics();
|
|
8248
8253
|
init_log();
|
|
8249
|
-
|
|
8254
|
+
log31 = createChildLogger({ module: "telegram-permissions" });
|
|
8250
8255
|
PermissionHandler = class {
|
|
8251
8256
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
8252
8257
|
this.bot = bot;
|
|
@@ -8290,11 +8295,11 @@ ${escapeHtml(request.description)}`,
|
|
|
8290
8295
|
});
|
|
8291
8296
|
}
|
|
8292
8297
|
setupCallbackHandler() {
|
|
8293
|
-
this.bot.on("callback_query:data", async (ctx) => {
|
|
8298
|
+
this.bot.on("callback_query:data", async (ctx, next) => {
|
|
8294
8299
|
const data = ctx.callbackQuery.data;
|
|
8295
|
-
if (!data.startsWith("p:")) return;
|
|
8300
|
+
if (!data.startsWith("p:")) return next();
|
|
8296
8301
|
const parts = data.split(":");
|
|
8297
|
-
if (parts.length < 3) return;
|
|
8302
|
+
if (parts.length < 3) return next();
|
|
8298
8303
|
const [, callbackKey, optionId] = parts;
|
|
8299
8304
|
const pending = this.pending.get(callbackKey);
|
|
8300
8305
|
if (!pending) {
|
|
@@ -8306,7 +8311,7 @@ ${escapeHtml(request.description)}`,
|
|
|
8306
8311
|
}
|
|
8307
8312
|
const session = this.getSession(pending.sessionId);
|
|
8308
8313
|
const isAllow = pending.options.find((o) => o.id === optionId)?.isAllow ?? false;
|
|
8309
|
-
|
|
8314
|
+
log31.info({ requestId: pending.requestId, optionId, isAllow }, "Permission responded");
|
|
8310
8315
|
if (session?.permissionGate.requestId === pending.requestId) {
|
|
8311
8316
|
session.permissionGate.resolve(optionId);
|
|
8312
8317
|
}
|
|
@@ -8326,7 +8331,7 @@ ${escapeHtml(request.description)}`,
|
|
|
8326
8331
|
});
|
|
8327
8332
|
|
|
8328
8333
|
// src/plugins/telegram/activity.ts
|
|
8329
|
-
var
|
|
8334
|
+
var log32, THINKING_REFRESH_MS, THINKING_MAX_MS, ThinkingIndicator, ToolCard, ActivityTracker2;
|
|
8330
8335
|
var init_activity = __esm({
|
|
8331
8336
|
"src/plugins/telegram/activity.ts"() {
|
|
8332
8337
|
"use strict";
|
|
@@ -8336,7 +8341,7 @@ var init_activity = __esm({
|
|
|
8336
8341
|
init_stream_accumulator();
|
|
8337
8342
|
init_stream_accumulator();
|
|
8338
8343
|
init_display_spec_builder();
|
|
8339
|
-
|
|
8344
|
+
log32 = createChildLogger({ module: "telegram:activity" });
|
|
8340
8345
|
THINKING_REFRESH_MS = 15e3;
|
|
8341
8346
|
THINKING_MAX_MS = 3 * 60 * 1e3;
|
|
8342
8347
|
ThinkingIndicator = class {
|
|
@@ -8377,7 +8382,7 @@ var init_activity = __esm({
|
|
|
8377
8382
|
}
|
|
8378
8383
|
}
|
|
8379
8384
|
} catch (err) {
|
|
8380
|
-
|
|
8385
|
+
log32.warn({ err }, "ThinkingIndicator.show() failed");
|
|
8381
8386
|
} finally {
|
|
8382
8387
|
this.sending = false;
|
|
8383
8388
|
}
|
|
@@ -8545,7 +8550,7 @@ var init_activity = __esm({
|
|
|
8545
8550
|
this.tracer?.log("telegram", { action: "telegram:delete:overflow", sessionId: this.sessionId, msgId: staleId });
|
|
8546
8551
|
}
|
|
8547
8552
|
} catch (err) {
|
|
8548
|
-
|
|
8553
|
+
log32.warn({ err }, "[ToolCard] send/edit failed");
|
|
8549
8554
|
}
|
|
8550
8555
|
}
|
|
8551
8556
|
};
|
|
@@ -8649,7 +8654,7 @@ var init_activity = __esm({
|
|
|
8649
8654
|
const entry = this.toolStateMap.merge(id, status, rawInput, content, viewerLinks, diffStats);
|
|
8650
8655
|
if (!existed || !entry) return;
|
|
8651
8656
|
if (viewerLinks || entry.viewerLinks) {
|
|
8652
|
-
|
|
8657
|
+
log32.debug({ toolId: id, status, hasIncomingLinks: !!viewerLinks, hasEntryLinks: !!entry.viewerLinks, entryLinks: entry.viewerLinks }, "toolUpdate: viewer links trace");
|
|
8653
8658
|
}
|
|
8654
8659
|
const spec = this.specBuilder.buildToolSpec(entry, this._outputMode, this.sessionContext);
|
|
8655
8660
|
this.toolCard.updateFromSpec(spec);
|
|
@@ -8968,13 +8973,13 @@ var init_draft_manager = __esm({
|
|
|
8968
8973
|
});
|
|
8969
8974
|
|
|
8970
8975
|
// src/plugins/telegram/skill-command-manager.ts
|
|
8971
|
-
var
|
|
8976
|
+
var log33, SkillCommandManager;
|
|
8972
8977
|
var init_skill_command_manager = __esm({
|
|
8973
8978
|
"src/plugins/telegram/skill-command-manager.ts"() {
|
|
8974
8979
|
"use strict";
|
|
8975
8980
|
init_commands();
|
|
8976
8981
|
init_log();
|
|
8977
|
-
|
|
8982
|
+
log33 = createChildLogger({ module: "skill-commands" });
|
|
8978
8983
|
SkillCommandManager = class {
|
|
8979
8984
|
// sessionId → pinned msgId
|
|
8980
8985
|
constructor(bot, chatId, sendQueue, sessionManager) {
|
|
@@ -9040,7 +9045,7 @@ var init_skill_command_manager = __esm({
|
|
|
9040
9045
|
disable_notification: true
|
|
9041
9046
|
});
|
|
9042
9047
|
} catch (err) {
|
|
9043
|
-
|
|
9048
|
+
log33.error({ err, sessionId }, "Failed to send skill commands");
|
|
9044
9049
|
}
|
|
9045
9050
|
}
|
|
9046
9051
|
async cleanup(sessionId) {
|
|
@@ -9219,7 +9224,7 @@ async function validateBotAdmin(token, chatId) {
|
|
|
9219
9224
|
};
|
|
9220
9225
|
}
|
|
9221
9226
|
const { status } = data.result;
|
|
9222
|
-
|
|
9227
|
+
log34.info(
|
|
9223
9228
|
{ status, can_manage_topics: data.result.can_manage_topics, raw_result: data.result },
|
|
9224
9229
|
"validateBotAdmin: getChatMember raw result"
|
|
9225
9230
|
);
|
|
@@ -9239,7 +9244,7 @@ async function validateBotAdmin(token, chatId) {
|
|
|
9239
9244
|
}
|
|
9240
9245
|
async function checkTopicsPrerequisites(token, chatId) {
|
|
9241
9246
|
const issues = [];
|
|
9242
|
-
|
|
9247
|
+
log34.info({ chatId }, "checkTopicsPrerequisites: starting checks");
|
|
9243
9248
|
try {
|
|
9244
9249
|
const res = await fetch(`https://api.telegram.org/bot${token}/getChat`, {
|
|
9245
9250
|
method: "POST",
|
|
@@ -9247,7 +9252,7 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
9247
9252
|
body: JSON.stringify({ chat_id: chatId })
|
|
9248
9253
|
});
|
|
9249
9254
|
const data = await res.json();
|
|
9250
|
-
|
|
9255
|
+
log34.info(
|
|
9251
9256
|
{ chatId, apiOk: data.ok, is_forum: data.result?.is_forum, type: data.result?.type, title: data.result?.title },
|
|
9252
9257
|
"checkTopicsPrerequisites: getChat result"
|
|
9253
9258
|
);
|
|
@@ -9257,11 +9262,11 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
9257
9262
|
);
|
|
9258
9263
|
}
|
|
9259
9264
|
} catch (err) {
|
|
9260
|
-
|
|
9265
|
+
log34.warn({ err, chatId }, "checkTopicsPrerequisites: getChat failed (network error)");
|
|
9261
9266
|
issues.push("\u274C Could not check if Topics are enabled (network error).");
|
|
9262
9267
|
}
|
|
9263
9268
|
const adminResult = await validateBotAdmin(token, chatId);
|
|
9264
|
-
|
|
9269
|
+
log34.info(
|
|
9265
9270
|
{ chatId, adminOk: adminResult.ok, canManageTopics: adminResult.ok ? adminResult.canManageTopics : void 0, error: !adminResult.ok ? adminResult.error : void 0 },
|
|
9266
9271
|
"checkTopicsPrerequisites: validateBotAdmin result"
|
|
9267
9272
|
);
|
|
@@ -9275,16 +9280,16 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
9275
9280
|
'\u274C Bot cannot manage topics.\n\u2192 In Admin settings, enable the "Manage Topics" permission'
|
|
9276
9281
|
);
|
|
9277
9282
|
}
|
|
9278
|
-
|
|
9283
|
+
log34.info({ chatId, issueCount: issues.length, ok: issues.length === 0 }, "checkTopicsPrerequisites: result");
|
|
9279
9284
|
if (issues.length > 0) return { ok: false, issues };
|
|
9280
9285
|
return { ok: true };
|
|
9281
9286
|
}
|
|
9282
|
-
var
|
|
9287
|
+
var log34;
|
|
9283
9288
|
var init_validators = __esm({
|
|
9284
9289
|
"src/plugins/telegram/validators.ts"() {
|
|
9285
9290
|
"use strict";
|
|
9286
9291
|
init_log();
|
|
9287
|
-
|
|
9292
|
+
log34 = createChildLogger({ module: "telegram-validators" });
|
|
9288
9293
|
}
|
|
9289
9294
|
});
|
|
9290
9295
|
|
|
@@ -9303,7 +9308,7 @@ function patchedFetch(input2, init) {
|
|
|
9303
9308
|
}
|
|
9304
9309
|
return fetch(input2, init);
|
|
9305
9310
|
}
|
|
9306
|
-
var
|
|
9311
|
+
var log35, TelegramAdapter;
|
|
9307
9312
|
var init_adapter = __esm({
|
|
9308
9313
|
"src/plugins/telegram/adapter.ts"() {
|
|
9309
9314
|
"use strict";
|
|
@@ -9322,7 +9327,7 @@ var init_adapter = __esm({
|
|
|
9322
9327
|
init_messaging_adapter();
|
|
9323
9328
|
init_renderer2();
|
|
9324
9329
|
init_output_mode_resolver();
|
|
9325
|
-
|
|
9330
|
+
log35 = createChildLogger({ module: "telegram" });
|
|
9326
9331
|
TelegramAdapter = class extends MessagingAdapter {
|
|
9327
9332
|
name = "telegram";
|
|
9328
9333
|
renderer = new TelegramRenderer();
|
|
@@ -9449,7 +9454,7 @@ var init_adapter = __esm({
|
|
|
9449
9454
|
);
|
|
9450
9455
|
this.bot.catch((err) => {
|
|
9451
9456
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
9452
|
-
|
|
9457
|
+
log35.error({ err: rootCause }, "Telegram bot error");
|
|
9453
9458
|
});
|
|
9454
9459
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
9455
9460
|
const maxRetries = 3;
|
|
@@ -9467,7 +9472,7 @@ var init_adapter = __esm({
|
|
|
9467
9472
|
if (rateLimitedMethods.includes(method)) {
|
|
9468
9473
|
this.sendQueue.onRateLimited();
|
|
9469
9474
|
}
|
|
9470
|
-
|
|
9475
|
+
log35.warn(
|
|
9471
9476
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
9472
9477
|
"Rate limited by Telegram, retrying"
|
|
9473
9478
|
);
|
|
@@ -9655,9 +9660,9 @@ ${p}` : p;
|
|
|
9655
9660
|
this.setupRoutes();
|
|
9656
9661
|
this.bot.start({
|
|
9657
9662
|
allowed_updates: ["message", "callback_query"],
|
|
9658
|
-
onStart: () =>
|
|
9663
|
+
onStart: () => log35.info({ chatId: this.telegramConfig.chatId }, "Telegram bot started")
|
|
9659
9664
|
});
|
|
9660
|
-
|
|
9665
|
+
log35.info(
|
|
9661
9666
|
{
|
|
9662
9667
|
chatId: this.telegramConfig.chatId,
|
|
9663
9668
|
notificationTopicId: this.telegramConfig.notificationTopicId,
|
|
@@ -9671,12 +9676,12 @@ ${p}` : p;
|
|
|
9671
9676
|
this.telegramConfig.chatId
|
|
9672
9677
|
);
|
|
9673
9678
|
if (prereqResult.ok) {
|
|
9674
|
-
|
|
9679
|
+
log35.info("Telegram adapter: prerequisites OK, initializing topic-dependent features");
|
|
9675
9680
|
await this.initTopicDependentFeatures();
|
|
9676
9681
|
} else {
|
|
9677
|
-
|
|
9682
|
+
log35.warn({ issues: prereqResult.issues }, "Telegram adapter: prerequisites NOT met, starting watcher");
|
|
9678
9683
|
for (const issue of prereqResult.issues) {
|
|
9679
|
-
|
|
9684
|
+
log35.warn({ issue }, "Telegram prerequisite not met");
|
|
9680
9685
|
}
|
|
9681
9686
|
this.startPrerequisiteWatcher(prereqResult.issues);
|
|
9682
9687
|
}
|
|
@@ -9692,7 +9697,7 @@ ${p}` : p;
|
|
|
9692
9697
|
} catch (err) {
|
|
9693
9698
|
if (attempt === maxRetries) throw err;
|
|
9694
9699
|
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
9695
|
-
|
|
9700
|
+
log35.warn(
|
|
9696
9701
|
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
9697
9702
|
`${label} failed, retrying in ${delay}ms`
|
|
9698
9703
|
);
|
|
@@ -9712,12 +9717,12 @@ ${p}` : p;
|
|
|
9712
9717
|
}),
|
|
9713
9718
|
"setMyCommands"
|
|
9714
9719
|
).catch((err) => {
|
|
9715
|
-
|
|
9720
|
+
log35.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
9716
9721
|
});
|
|
9717
9722
|
}
|
|
9718
9723
|
async initTopicDependentFeatures() {
|
|
9719
9724
|
if (this._topicsInitialized) return;
|
|
9720
|
-
|
|
9725
|
+
log35.info(
|
|
9721
9726
|
{ notificationTopicId: this.telegramConfig.notificationTopicId, assistantTopicId: this.telegramConfig.assistantTopicId },
|
|
9722
9727
|
"initTopicDependentFeatures: starting (existing IDs in config)"
|
|
9723
9728
|
);
|
|
@@ -9742,7 +9747,7 @@ ${p}` : p;
|
|
|
9742
9747
|
this.assistantTopicId = topics.assistantTopicId;
|
|
9743
9748
|
this._systemTopicIds.notificationTopicId = topics.notificationTopicId;
|
|
9744
9749
|
this._systemTopicIds.assistantTopicId = topics.assistantTopicId;
|
|
9745
|
-
|
|
9750
|
+
log35.info(
|
|
9746
9751
|
{ notificationTopicId: this.notificationTopicId, assistantTopicId: this.assistantTopicId },
|
|
9747
9752
|
"initTopicDependentFeatures: topics ready"
|
|
9748
9753
|
);
|
|
@@ -9773,7 +9778,7 @@ ${p}` : p;
|
|
|
9773
9778
|
).then((msg) => {
|
|
9774
9779
|
if (msg) this.storeControlMsgId(sessionId, msg.message_id);
|
|
9775
9780
|
}).catch((err) => {
|
|
9776
|
-
|
|
9781
|
+
log35.warn({ err, sessionId }, "Failed to send initial messages for new session");
|
|
9777
9782
|
});
|
|
9778
9783
|
};
|
|
9779
9784
|
this.core.eventBus.on("session:threadReady", this._threadReadyHandler);
|
|
@@ -9782,7 +9787,7 @@ ${p}` : p;
|
|
|
9782
9787
|
});
|
|
9783
9788
|
};
|
|
9784
9789
|
this.core.eventBus.on("session:configChanged", this._configChangedHandler);
|
|
9785
|
-
|
|
9790
|
+
log35.info({ assistantTopicId: this.assistantTopicId }, "initTopicDependentFeatures: sending welcome message");
|
|
9786
9791
|
try {
|
|
9787
9792
|
const config = this.core.configManager.get();
|
|
9788
9793
|
const agents = this.core.agentManager.getAvailableAgents();
|
|
@@ -9804,17 +9809,17 @@ ${p}` : p;
|
|
|
9804
9809
|
this.core.lifecycleManager?.serviceRegistry?.get("menu-registry")
|
|
9805
9810
|
)
|
|
9806
9811
|
});
|
|
9807
|
-
|
|
9812
|
+
log35.info("initTopicDependentFeatures: welcome message sent");
|
|
9808
9813
|
} catch (err) {
|
|
9809
|
-
|
|
9814
|
+
log35.warn({ err }, "Failed to send welcome message");
|
|
9810
9815
|
}
|
|
9811
9816
|
try {
|
|
9812
9817
|
await this.core.assistantManager.spawn("telegram", String(this.assistantTopicId));
|
|
9813
9818
|
} catch (err) {
|
|
9814
|
-
|
|
9819
|
+
log35.error({ err }, "Failed to spawn assistant");
|
|
9815
9820
|
}
|
|
9816
9821
|
this._topicsInitialized = true;
|
|
9817
|
-
|
|
9822
|
+
log35.info("Telegram adapter fully initialized");
|
|
9818
9823
|
}
|
|
9819
9824
|
startPrerequisiteWatcher(issues) {
|
|
9820
9825
|
const setupMessage = `\u26A0\uFE0F <b>OpenACP needs setup before it can start.</b>
|
|
@@ -9825,7 +9830,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9825
9830
|
this.bot.api.sendMessage(this.telegramConfig.chatId, setupMessage, {
|
|
9826
9831
|
parse_mode: "HTML"
|
|
9827
9832
|
}).catch((err) => {
|
|
9828
|
-
|
|
9833
|
+
log35.warn({ err }, "Failed to send setup guidance to General topic");
|
|
9829
9834
|
});
|
|
9830
9835
|
const schedule = [5e3, 1e4, 3e4];
|
|
9831
9836
|
let attempt = 1;
|
|
@@ -9838,7 +9843,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9838
9843
|
);
|
|
9839
9844
|
if (result.ok) {
|
|
9840
9845
|
this._prerequisiteWatcher = null;
|
|
9841
|
-
|
|
9846
|
+
log35.info("Prerequisites met \u2014 completing Telegram adapter initialization");
|
|
9842
9847
|
try {
|
|
9843
9848
|
await this.initTopicDependentFeatures();
|
|
9844
9849
|
await this.bot.api.sendMessage(
|
|
@@ -9847,11 +9852,11 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9847
9852
|
{ parse_mode: "HTML" }
|
|
9848
9853
|
);
|
|
9849
9854
|
} catch (err) {
|
|
9850
|
-
|
|
9855
|
+
log35.error({ err }, "Failed to complete initialization after prerequisites met");
|
|
9851
9856
|
}
|
|
9852
9857
|
return;
|
|
9853
9858
|
}
|
|
9854
|
-
|
|
9859
|
+
log35.debug({ issues: result.issues }, "Prerequisites not yet met, retrying");
|
|
9855
9860
|
const delay = schedule[Math.min(attempt, schedule.length - 1)];
|
|
9856
9861
|
attempt++;
|
|
9857
9862
|
this._prerequisiteWatcher = setTimeout(retry, delay);
|
|
@@ -9877,7 +9882,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9877
9882
|
}
|
|
9878
9883
|
this.sendQueue.clear();
|
|
9879
9884
|
await this.bot.stop();
|
|
9880
|
-
|
|
9885
|
+
log35.info("Telegram bot stopped");
|
|
9881
9886
|
}
|
|
9882
9887
|
// --- CommandRegistry response rendering ---
|
|
9883
9888
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -9962,6 +9967,13 @@ ${lines.join("\n")}`;
|
|
|
9962
9967
|
}
|
|
9963
9968
|
setupRoutes() {
|
|
9964
9969
|
this.bot.on("message:text", async (ctx) => {
|
|
9970
|
+
if (!this._topicsInitialized) {
|
|
9971
|
+
await ctx.reply(
|
|
9972
|
+
"\u23F3 OpenACP is still setting up. Check the General topic for instructions."
|
|
9973
|
+
).catch(() => {
|
|
9974
|
+
});
|
|
9975
|
+
return;
|
|
9976
|
+
}
|
|
9965
9977
|
const threadId = ctx.message.message_thread_id;
|
|
9966
9978
|
const text3 = ctx.message.text;
|
|
9967
9979
|
if (!threadId) {
|
|
@@ -9994,7 +10006,7 @@ ${lines.join("\n")}`;
|
|
|
9994
10006
|
threadId: String(threadId),
|
|
9995
10007
|
userId: String(ctx.from.id),
|
|
9996
10008
|
text: forwardText
|
|
9997
|
-
}).catch((err) =>
|
|
10009
|
+
}).catch((err) => log35.error({ err }, "handleMessage error"));
|
|
9998
10010
|
});
|
|
9999
10011
|
this.bot.on("message:photo", async (ctx) => {
|
|
10000
10012
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -10083,7 +10095,7 @@ ${lines.join("\n")}`;
|
|
|
10083
10095
|
if (session.archiving) return;
|
|
10084
10096
|
const threadId = Number(session.threadId);
|
|
10085
10097
|
if (!threadId || isNaN(threadId)) {
|
|
10086
|
-
|
|
10098
|
+
log35.warn(
|
|
10087
10099
|
{ sessionId, threadId: session.threadId },
|
|
10088
10100
|
"Session has no valid threadId, skipping message"
|
|
10089
10101
|
);
|
|
@@ -10099,7 +10111,7 @@ ${lines.join("\n")}`;
|
|
|
10099
10111
|
this._sessionThreadIds.delete(sessionId);
|
|
10100
10112
|
}
|
|
10101
10113
|
}).catch((err) => {
|
|
10102
|
-
|
|
10114
|
+
log35.warn({ err, sessionId }, "Dispatch queue error");
|
|
10103
10115
|
});
|
|
10104
10116
|
this._dispatchQueues.set(sessionId, next);
|
|
10105
10117
|
await next;
|
|
@@ -10221,7 +10233,7 @@ ${lines.join("\n")}`;
|
|
|
10221
10233
|
);
|
|
10222
10234
|
usageMsgId = result?.message_id;
|
|
10223
10235
|
} catch (err) {
|
|
10224
|
-
|
|
10236
|
+
log35.warn({ err, sessionId }, "Failed to send usage message");
|
|
10225
10237
|
}
|
|
10226
10238
|
if (this.notificationTopicId && sessionId !== this.core.assistantManager?.get("telegram")?.id) {
|
|
10227
10239
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -10249,7 +10261,7 @@ Task completed.
|
|
|
10249
10261
|
if (!content.attachment) return;
|
|
10250
10262
|
const { attachment } = content;
|
|
10251
10263
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
10252
|
-
|
|
10264
|
+
log35.warn(
|
|
10253
10265
|
{
|
|
10254
10266
|
sessionId,
|
|
10255
10267
|
fileName: attachment.fileName,
|
|
@@ -10293,7 +10305,7 @@ Task completed.
|
|
|
10293
10305
|
);
|
|
10294
10306
|
}
|
|
10295
10307
|
} catch (err) {
|
|
10296
|
-
|
|
10308
|
+
log35.error(
|
|
10297
10309
|
{ err, sessionId, fileName: attachment.fileName },
|
|
10298
10310
|
"Failed to send attachment"
|
|
10299
10311
|
);
|
|
@@ -10392,7 +10404,7 @@ Task completed.
|
|
|
10392
10404
|
}
|
|
10393
10405
|
async sendPermissionRequest(sessionId, request) {
|
|
10394
10406
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
10395
|
-
|
|
10407
|
+
log35.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
10396
10408
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
10397
10409
|
if (!session) return;
|
|
10398
10410
|
await this.sendQueue.enqueue(
|
|
@@ -10402,7 +10414,7 @@ Task completed.
|
|
|
10402
10414
|
async sendNotification(notification) {
|
|
10403
10415
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
10404
10416
|
if (notification.sessionId === this.core.assistantManager?.get("telegram")?.id) return;
|
|
10405
|
-
|
|
10417
|
+
log35.info(
|
|
10406
10418
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
10407
10419
|
"Notification sent"
|
|
10408
10420
|
);
|
|
@@ -10441,7 +10453,7 @@ Task completed.
|
|
|
10441
10453
|
}
|
|
10442
10454
|
async createSessionThread(sessionId, name) {
|
|
10443
10455
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
10444
|
-
|
|
10456
|
+
log35.info({ sessionId, name }, "Session topic created");
|
|
10445
10457
|
return String(
|
|
10446
10458
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
10447
10459
|
);
|
|
@@ -10452,7 +10464,7 @@ Task completed.
|
|
|
10452
10464
|
if (!session) return;
|
|
10453
10465
|
const threadId = Number(session.threadId);
|
|
10454
10466
|
if (!threadId) {
|
|
10455
|
-
|
|
10467
|
+
log35.debug({ sessionId, newName }, "Cannot rename thread \u2014 threadId not set yet");
|
|
10456
10468
|
return;
|
|
10457
10469
|
}
|
|
10458
10470
|
await renameSessionTopic(
|
|
@@ -10471,7 +10483,7 @@ Task completed.
|
|
|
10471
10483
|
try {
|
|
10472
10484
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
10473
10485
|
} catch (err) {
|
|
10474
|
-
|
|
10486
|
+
log35.warn(
|
|
10475
10487
|
{ err, sessionId, topicId },
|
|
10476
10488
|
"Failed to delete forum topic (may already be deleted)"
|
|
10477
10489
|
);
|
|
@@ -10515,7 +10527,7 @@ Task completed.
|
|
|
10515
10527
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10516
10528
|
return { buffer, filePath: file.file_path };
|
|
10517
10529
|
} catch (err) {
|
|
10518
|
-
|
|
10530
|
+
log35.error({ err }, "Failed to download file from Telegram");
|
|
10519
10531
|
return null;
|
|
10520
10532
|
}
|
|
10521
10533
|
}
|
|
@@ -10536,7 +10548,7 @@ Task completed.
|
|
|
10536
10548
|
try {
|
|
10537
10549
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
10538
10550
|
} catch (err) {
|
|
10539
|
-
|
|
10551
|
+
log35.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
10540
10552
|
fileName = "voice.ogg";
|
|
10541
10553
|
mimeType = "audio/ogg";
|
|
10542
10554
|
originalFilePath = void 0;
|
|
@@ -10568,7 +10580,7 @@ Task completed.
|
|
|
10568
10580
|
userId: String(userId),
|
|
10569
10581
|
text: text3,
|
|
10570
10582
|
attachments: [att]
|
|
10571
|
-
}).catch((err) =>
|
|
10583
|
+
}).catch((err) => log35.error({ err }, "handleMessage error"));
|
|
10572
10584
|
}
|
|
10573
10585
|
async cleanupSkillCommands(sessionId) {
|
|
10574
10586
|
this._pendingSkillCommands.delete(sessionId);
|
|
@@ -14940,7 +14952,7 @@ function createPluginContext(opts) {
|
|
|
14940
14952
|
}
|
|
14941
14953
|
};
|
|
14942
14954
|
const baseLog = opts.log ?? noopLog;
|
|
14943
|
-
const
|
|
14955
|
+
const log36 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
|
|
14944
14956
|
const storageImpl = new PluginStorageImpl(storagePath);
|
|
14945
14957
|
const storage = {
|
|
14946
14958
|
async get(key) {
|
|
@@ -14967,7 +14979,7 @@ function createPluginContext(opts) {
|
|
|
14967
14979
|
const ctx = {
|
|
14968
14980
|
pluginName,
|
|
14969
14981
|
pluginConfig,
|
|
14970
|
-
log:
|
|
14982
|
+
log: log36,
|
|
14971
14983
|
storage,
|
|
14972
14984
|
on(event, handler) {
|
|
14973
14985
|
requirePermission(permissions, "events:read", "on()");
|
|
@@ -15002,7 +15014,7 @@ function createPluginContext(opts) {
|
|
|
15002
15014
|
const registry = serviceRegistry.get("command-registry");
|
|
15003
15015
|
if (registry && typeof registry.register === "function") {
|
|
15004
15016
|
registry.register(def, pluginName);
|
|
15005
|
-
|
|
15017
|
+
log36.debug(`Command '/${def.name}' registered`);
|
|
15006
15018
|
}
|
|
15007
15019
|
},
|
|
15008
15020
|
async sendMessage(_sessionId, _content) {
|
|
@@ -15045,7 +15057,7 @@ function createPluginContext(opts) {
|
|
|
15045
15057
|
const registry = serviceRegistry.get("field-registry");
|
|
15046
15058
|
if (registry && typeof registry.register === "function") {
|
|
15047
15059
|
registry.register(pluginName, fields);
|
|
15048
|
-
|
|
15060
|
+
log36.debug(`Registered ${fields.length} editable field(s) for ${pluginName}`);
|
|
15049
15061
|
}
|
|
15050
15062
|
},
|
|
15051
15063
|
get sessions() {
|