@openacp/cli 2026.405.1 → 2026.405.2
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 +269 -230
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +104 -65
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2774,6 +2774,8 @@ declare class TelegramAdapter extends MessagingAdapter {
|
|
|
2774
2774
|
private controlMsgIds;
|
|
2775
2775
|
private _threadReadyHandler?;
|
|
2776
2776
|
private _configChangedHandler?;
|
|
2777
|
+
/** Mutable ref passed to callbacks before topics are ready; updated in-place by initTopicDependentFeatures */
|
|
2778
|
+
private _systemTopicIds;
|
|
2777
2779
|
/** True once topics are initialized and Phase 2 is complete */
|
|
2778
2780
|
private _topicsInitialized;
|
|
2779
2781
|
/** Background watcher timer — cancelled on stop() or when topics succeed */
|
package/dist/index.js
CHANGED
|
@@ -9219,6 +9219,10 @@ async function validateBotAdmin(token, chatId) {
|
|
|
9219
9219
|
};
|
|
9220
9220
|
}
|
|
9221
9221
|
const { status } = data.result;
|
|
9222
|
+
log33.info(
|
|
9223
|
+
{ status, can_manage_topics: data.result.can_manage_topics, raw_result: data.result },
|
|
9224
|
+
"validateBotAdmin: getChatMember raw result"
|
|
9225
|
+
);
|
|
9222
9226
|
if (status === "creator") {
|
|
9223
9227
|
return { ok: true, canManageTopics: true };
|
|
9224
9228
|
}
|
|
@@ -9235,6 +9239,7 @@ async function validateBotAdmin(token, chatId) {
|
|
|
9235
9239
|
}
|
|
9236
9240
|
async function checkTopicsPrerequisites(token, chatId) {
|
|
9237
9241
|
const issues = [];
|
|
9242
|
+
log33.info({ chatId }, "checkTopicsPrerequisites: starting checks");
|
|
9238
9243
|
try {
|
|
9239
9244
|
const res = await fetch(`https://api.telegram.org/bot${token}/getChat`, {
|
|
9240
9245
|
method: "POST",
|
|
@@ -9242,15 +9247,24 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
9242
9247
|
body: JSON.stringify({ chat_id: chatId })
|
|
9243
9248
|
});
|
|
9244
9249
|
const data = await res.json();
|
|
9250
|
+
log33.info(
|
|
9251
|
+
{ chatId, apiOk: data.ok, is_forum: data.result?.is_forum, type: data.result?.type, title: data.result?.title },
|
|
9252
|
+
"checkTopicsPrerequisites: getChat result"
|
|
9253
|
+
);
|
|
9245
9254
|
if (data.ok && data.result && !data.result.is_forum) {
|
|
9246
9255
|
issues.push(
|
|
9247
9256
|
'\u274C Topics are not enabled on this group.\n\u2192 Go to Group Settings \u2192 Edit \u2192 enable "Topics"'
|
|
9248
9257
|
);
|
|
9249
9258
|
}
|
|
9250
|
-
} catch {
|
|
9259
|
+
} catch (err) {
|
|
9260
|
+
log33.warn({ err, chatId }, "checkTopicsPrerequisites: getChat failed (network error)");
|
|
9251
9261
|
issues.push("\u274C Could not check if Topics are enabled (network error).");
|
|
9252
9262
|
}
|
|
9253
9263
|
const adminResult = await validateBotAdmin(token, chatId);
|
|
9264
|
+
log33.info(
|
|
9265
|
+
{ chatId, adminOk: adminResult.ok, canManageTopics: adminResult.ok ? adminResult.canManageTopics : void 0, error: !adminResult.ok ? adminResult.error : void 0 },
|
|
9266
|
+
"checkTopicsPrerequisites: validateBotAdmin result"
|
|
9267
|
+
);
|
|
9254
9268
|
if (!adminResult.ok) {
|
|
9255
9269
|
issues.push(
|
|
9256
9270
|
`\u274C Bot is not an admin.
|
|
@@ -9261,12 +9275,16 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
9261
9275
|
'\u274C Bot cannot manage topics.\n\u2192 In Admin settings, enable the "Manage Topics" permission'
|
|
9262
9276
|
);
|
|
9263
9277
|
}
|
|
9278
|
+
log33.info({ chatId, issueCount: issues.length, ok: issues.length === 0 }, "checkTopicsPrerequisites: result");
|
|
9264
9279
|
if (issues.length > 0) return { ok: false, issues };
|
|
9265
9280
|
return { ok: true };
|
|
9266
9281
|
}
|
|
9282
|
+
var log33;
|
|
9267
9283
|
var init_validators = __esm({
|
|
9268
9284
|
"src/plugins/telegram/validators.ts"() {
|
|
9269
9285
|
"use strict";
|
|
9286
|
+
init_log();
|
|
9287
|
+
log33 = createChildLogger({ module: "telegram-validators" });
|
|
9270
9288
|
}
|
|
9271
9289
|
});
|
|
9272
9290
|
|
|
@@ -9285,7 +9303,7 @@ function patchedFetch(input2, init) {
|
|
|
9285
9303
|
}
|
|
9286
9304
|
return fetch(input2, init);
|
|
9287
9305
|
}
|
|
9288
|
-
var
|
|
9306
|
+
var log34, TelegramAdapter;
|
|
9289
9307
|
var init_adapter = __esm({
|
|
9290
9308
|
"src/plugins/telegram/adapter.ts"() {
|
|
9291
9309
|
"use strict";
|
|
@@ -9304,7 +9322,7 @@ var init_adapter = __esm({
|
|
|
9304
9322
|
init_messaging_adapter();
|
|
9305
9323
|
init_renderer2();
|
|
9306
9324
|
init_output_mode_resolver();
|
|
9307
|
-
|
|
9325
|
+
log34 = createChildLogger({ module: "telegram" });
|
|
9308
9326
|
TelegramAdapter = class extends MessagingAdapter {
|
|
9309
9327
|
name = "telegram";
|
|
9310
9328
|
renderer = new TelegramRenderer();
|
|
@@ -9339,6 +9357,8 @@ var init_adapter = __esm({
|
|
|
9339
9357
|
controlMsgIds = /* @__PURE__ */ new Map();
|
|
9340
9358
|
_threadReadyHandler;
|
|
9341
9359
|
_configChangedHandler;
|
|
9360
|
+
/** Mutable ref passed to callbacks before topics are ready; updated in-place by initTopicDependentFeatures */
|
|
9361
|
+
_systemTopicIds = { notificationTopicId: 0, assistantTopicId: 0 };
|
|
9342
9362
|
/** True once topics are initialized and Phase 2 is complete */
|
|
9343
9363
|
_topicsInitialized = false;
|
|
9344
9364
|
/** Background watcher timer — cancelled on stop() or when topics succeed */
|
|
@@ -9429,7 +9449,7 @@ var init_adapter = __esm({
|
|
|
9429
9449
|
);
|
|
9430
9450
|
this.bot.catch((err) => {
|
|
9431
9451
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
9432
|
-
|
|
9452
|
+
log34.error({ err: rootCause }, "Telegram bot error");
|
|
9433
9453
|
});
|
|
9434
9454
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
9435
9455
|
const maxRetries = 3;
|
|
@@ -9447,7 +9467,7 @@ var init_adapter = __esm({
|
|
|
9447
9467
|
if (rateLimitedMethods.includes(method)) {
|
|
9448
9468
|
this.sendQueue.onRateLimited();
|
|
9449
9469
|
}
|
|
9450
|
-
|
|
9470
|
+
log34.warn(
|
|
9451
9471
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
9452
9472
|
"Rate limited by Telegram, retrying"
|
|
9453
9473
|
);
|
|
@@ -9606,20 +9626,57 @@ var init_adapter = __esm({
|
|
|
9606
9626
|
setupVerbosityCallbacks(this.bot, this.core);
|
|
9607
9627
|
setupIntegrateCallbacks(this.bot, this.core);
|
|
9608
9628
|
this.permissionHandler.setupCallbackHandler();
|
|
9629
|
+
setupAllCallbacks(
|
|
9630
|
+
this.bot,
|
|
9631
|
+
this.core,
|
|
9632
|
+
this.telegramConfig.chatId,
|
|
9633
|
+
this._systemTopicIds,
|
|
9634
|
+
() => {
|
|
9635
|
+
const assistant = this.core.assistantManager?.get("telegram");
|
|
9636
|
+
if (!assistant) return void 0;
|
|
9637
|
+
return {
|
|
9638
|
+
topicId: this.assistantTopicId,
|
|
9639
|
+
enqueuePrompt: (p) => {
|
|
9640
|
+
const pending = this.core.assistantManager?.consumePendingSystemPrompt("telegram");
|
|
9641
|
+
const text3 = pending ? `${pending}
|
|
9642
|
+
|
|
9643
|
+
---
|
|
9644
|
+
|
|
9645
|
+
User message:
|
|
9646
|
+
${p}` : p;
|
|
9647
|
+
return assistant.enqueuePrompt(text3);
|
|
9648
|
+
}
|
|
9649
|
+
};
|
|
9650
|
+
},
|
|
9651
|
+
(sessionId, msgId) => {
|
|
9652
|
+
this.storeControlMsgId(sessionId, msgId);
|
|
9653
|
+
}
|
|
9654
|
+
);
|
|
9655
|
+
this.setupRoutes();
|
|
9609
9656
|
this.bot.start({
|
|
9610
9657
|
allowed_updates: ["message", "callback_query"],
|
|
9611
|
-
onStart: () =>
|
|
9658
|
+
onStart: () => log34.info({ chatId: this.telegramConfig.chatId }, "Telegram bot started")
|
|
9612
9659
|
});
|
|
9660
|
+
log34.info(
|
|
9661
|
+
{
|
|
9662
|
+
chatId: this.telegramConfig.chatId,
|
|
9663
|
+
notificationTopicId: this.telegramConfig.notificationTopicId,
|
|
9664
|
+
assistantTopicId: this.telegramConfig.assistantTopicId
|
|
9665
|
+
},
|
|
9666
|
+
"Telegram adapter: starting prerequisite check (existing topic IDs shown)"
|
|
9667
|
+
);
|
|
9613
9668
|
const { checkTopicsPrerequisites: checkTopicsPrerequisites2 } = await Promise.resolve().then(() => (init_validators(), validators_exports));
|
|
9614
9669
|
const prereqResult = await checkTopicsPrerequisites2(
|
|
9615
9670
|
this.telegramConfig.botToken,
|
|
9616
9671
|
this.telegramConfig.chatId
|
|
9617
9672
|
);
|
|
9618
9673
|
if (prereqResult.ok) {
|
|
9674
|
+
log34.info("Telegram adapter: prerequisites OK, initializing topic-dependent features");
|
|
9619
9675
|
await this.initTopicDependentFeatures();
|
|
9620
9676
|
} else {
|
|
9677
|
+
log34.warn({ issues: prereqResult.issues }, "Telegram adapter: prerequisites NOT met, starting watcher");
|
|
9621
9678
|
for (const issue of prereqResult.issues) {
|
|
9622
|
-
|
|
9679
|
+
log34.warn({ issue }, "Telegram prerequisite not met");
|
|
9623
9680
|
}
|
|
9624
9681
|
this.startPrerequisiteWatcher(prereqResult.issues);
|
|
9625
9682
|
}
|
|
@@ -9635,7 +9692,7 @@ var init_adapter = __esm({
|
|
|
9635
9692
|
} catch (err) {
|
|
9636
9693
|
if (attempt === maxRetries) throw err;
|
|
9637
9694
|
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
9638
|
-
|
|
9695
|
+
log34.warn(
|
|
9639
9696
|
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
9640
9697
|
`${label} failed, retrying in ${delay}ms`
|
|
9641
9698
|
);
|
|
@@ -9655,11 +9712,15 @@ var init_adapter = __esm({
|
|
|
9655
9712
|
}),
|
|
9656
9713
|
"setMyCommands"
|
|
9657
9714
|
).catch((err) => {
|
|
9658
|
-
|
|
9715
|
+
log34.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
9659
9716
|
});
|
|
9660
9717
|
}
|
|
9661
9718
|
async initTopicDependentFeatures() {
|
|
9662
9719
|
if (this._topicsInitialized) return;
|
|
9720
|
+
log34.info(
|
|
9721
|
+
{ notificationTopicId: this.telegramConfig.notificationTopicId, assistantTopicId: this.telegramConfig.assistantTopicId },
|
|
9722
|
+
"initTopicDependentFeatures: starting (existing IDs in config)"
|
|
9723
|
+
);
|
|
9663
9724
|
const topics = await this.retryWithBackoff(
|
|
9664
9725
|
() => ensureTopics(
|
|
9665
9726
|
this.bot,
|
|
@@ -9679,34 +9740,11 @@ var init_adapter = __esm({
|
|
|
9679
9740
|
);
|
|
9680
9741
|
this.notificationTopicId = topics.notificationTopicId;
|
|
9681
9742
|
this.assistantTopicId = topics.assistantTopicId;
|
|
9682
|
-
|
|
9683
|
-
|
|
9684
|
-
|
|
9685
|
-
this.
|
|
9686
|
-
|
|
9687
|
-
notificationTopicId: this.notificationTopicId,
|
|
9688
|
-
assistantTopicId: this.assistantTopicId
|
|
9689
|
-
},
|
|
9690
|
-
() => {
|
|
9691
|
-
const assistant = this.core.assistantManager?.get("telegram");
|
|
9692
|
-
if (!assistant) return void 0;
|
|
9693
|
-
return {
|
|
9694
|
-
topicId: this.assistantTopicId,
|
|
9695
|
-
enqueuePrompt: (p) => {
|
|
9696
|
-
const pending = this.core.assistantManager?.consumePendingSystemPrompt("telegram");
|
|
9697
|
-
const text3 = pending ? `${pending}
|
|
9698
|
-
|
|
9699
|
-
---
|
|
9700
|
-
|
|
9701
|
-
User message:
|
|
9702
|
-
${p}` : p;
|
|
9703
|
-
return assistant.enqueuePrompt(text3);
|
|
9704
|
-
}
|
|
9705
|
-
};
|
|
9706
|
-
},
|
|
9707
|
-
(sessionId, msgId) => {
|
|
9708
|
-
this.storeControlMsgId(sessionId, msgId);
|
|
9709
|
-
}
|
|
9743
|
+
this._systemTopicIds.notificationTopicId = topics.notificationTopicId;
|
|
9744
|
+
this._systemTopicIds.assistantTopicId = topics.assistantTopicId;
|
|
9745
|
+
log34.info(
|
|
9746
|
+
{ notificationTopicId: this.notificationTopicId, assistantTopicId: this.assistantTopicId },
|
|
9747
|
+
"initTopicDependentFeatures: topics ready"
|
|
9710
9748
|
);
|
|
9711
9749
|
this._threadReadyHandler = ({ sessionId, channelId, threadId }) => {
|
|
9712
9750
|
if (channelId !== "telegram") return;
|
|
@@ -9735,7 +9773,7 @@ ${p}` : p;
|
|
|
9735
9773
|
).then((msg) => {
|
|
9736
9774
|
if (msg) this.storeControlMsgId(sessionId, msg.message_id);
|
|
9737
9775
|
}).catch((err) => {
|
|
9738
|
-
|
|
9776
|
+
log34.warn({ err, sessionId }, "Failed to send initial messages for new session");
|
|
9739
9777
|
});
|
|
9740
9778
|
};
|
|
9741
9779
|
this.core.eventBus.on("session:threadReady", this._threadReadyHandler);
|
|
@@ -9744,7 +9782,7 @@ ${p}` : p;
|
|
|
9744
9782
|
});
|
|
9745
9783
|
};
|
|
9746
9784
|
this.core.eventBus.on("session:configChanged", this._configChangedHandler);
|
|
9747
|
-
this.
|
|
9785
|
+
log34.info({ assistantTopicId: this.assistantTopicId }, "initTopicDependentFeatures: sending welcome message");
|
|
9748
9786
|
try {
|
|
9749
9787
|
const config = this.core.configManager.get();
|
|
9750
9788
|
const agents = this.core.agentManager.getAvailableAgents();
|
|
@@ -9766,16 +9804,17 @@ ${p}` : p;
|
|
|
9766
9804
|
this.core.lifecycleManager?.serviceRegistry?.get("menu-registry")
|
|
9767
9805
|
)
|
|
9768
9806
|
});
|
|
9807
|
+
log34.info("initTopicDependentFeatures: welcome message sent");
|
|
9769
9808
|
} catch (err) {
|
|
9770
|
-
|
|
9809
|
+
log34.warn({ err }, "Failed to send welcome message");
|
|
9771
9810
|
}
|
|
9772
9811
|
try {
|
|
9773
9812
|
await this.core.assistantManager.spawn("telegram", String(this.assistantTopicId));
|
|
9774
9813
|
} catch (err) {
|
|
9775
|
-
|
|
9814
|
+
log34.error({ err }, "Failed to spawn assistant");
|
|
9776
9815
|
}
|
|
9777
9816
|
this._topicsInitialized = true;
|
|
9778
|
-
|
|
9817
|
+
log34.info("Telegram adapter fully initialized");
|
|
9779
9818
|
}
|
|
9780
9819
|
startPrerequisiteWatcher(issues) {
|
|
9781
9820
|
const setupMessage = `\u26A0\uFE0F <b>OpenACP needs setup before it can start.</b>
|
|
@@ -9786,7 +9825,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9786
9825
|
this.bot.api.sendMessage(this.telegramConfig.chatId, setupMessage, {
|
|
9787
9826
|
parse_mode: "HTML"
|
|
9788
9827
|
}).catch((err) => {
|
|
9789
|
-
|
|
9828
|
+
log34.warn({ err }, "Failed to send setup guidance to General topic");
|
|
9790
9829
|
});
|
|
9791
9830
|
const schedule = [5e3, 1e4, 3e4];
|
|
9792
9831
|
let attempt = 1;
|
|
@@ -9799,7 +9838,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9799
9838
|
);
|
|
9800
9839
|
if (result.ok) {
|
|
9801
9840
|
this._prerequisiteWatcher = null;
|
|
9802
|
-
|
|
9841
|
+
log34.info("Prerequisites met \u2014 completing Telegram adapter initialization");
|
|
9803
9842
|
try {
|
|
9804
9843
|
await this.initTopicDependentFeatures();
|
|
9805
9844
|
await this.bot.api.sendMessage(
|
|
@@ -9808,11 +9847,11 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9808
9847
|
{ parse_mode: "HTML" }
|
|
9809
9848
|
);
|
|
9810
9849
|
} catch (err) {
|
|
9811
|
-
|
|
9850
|
+
log34.error({ err }, "Failed to complete initialization after prerequisites met");
|
|
9812
9851
|
}
|
|
9813
9852
|
return;
|
|
9814
9853
|
}
|
|
9815
|
-
|
|
9854
|
+
log34.debug({ issues: result.issues }, "Prerequisites not yet met, retrying");
|
|
9816
9855
|
const delay = schedule[Math.min(attempt, schedule.length - 1)];
|
|
9817
9856
|
attempt++;
|
|
9818
9857
|
this._prerequisiteWatcher = setTimeout(retry, delay);
|
|
@@ -9838,7 +9877,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
9838
9877
|
}
|
|
9839
9878
|
this.sendQueue.clear();
|
|
9840
9879
|
await this.bot.stop();
|
|
9841
|
-
|
|
9880
|
+
log34.info("Telegram bot stopped");
|
|
9842
9881
|
}
|
|
9843
9882
|
// --- CommandRegistry response rendering ---
|
|
9844
9883
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -9955,7 +9994,7 @@ ${lines.join("\n")}`;
|
|
|
9955
9994
|
threadId: String(threadId),
|
|
9956
9995
|
userId: String(ctx.from.id),
|
|
9957
9996
|
text: forwardText
|
|
9958
|
-
}).catch((err) =>
|
|
9997
|
+
}).catch((err) => log34.error({ err }, "handleMessage error"));
|
|
9959
9998
|
});
|
|
9960
9999
|
this.bot.on("message:photo", async (ctx) => {
|
|
9961
10000
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -10044,7 +10083,7 @@ ${lines.join("\n")}`;
|
|
|
10044
10083
|
if (session.archiving) return;
|
|
10045
10084
|
const threadId = Number(session.threadId);
|
|
10046
10085
|
if (!threadId || isNaN(threadId)) {
|
|
10047
|
-
|
|
10086
|
+
log34.warn(
|
|
10048
10087
|
{ sessionId, threadId: session.threadId },
|
|
10049
10088
|
"Session has no valid threadId, skipping message"
|
|
10050
10089
|
);
|
|
@@ -10060,7 +10099,7 @@ ${lines.join("\n")}`;
|
|
|
10060
10099
|
this._sessionThreadIds.delete(sessionId);
|
|
10061
10100
|
}
|
|
10062
10101
|
}).catch((err) => {
|
|
10063
|
-
|
|
10102
|
+
log34.warn({ err, sessionId }, "Dispatch queue error");
|
|
10064
10103
|
});
|
|
10065
10104
|
this._dispatchQueues.set(sessionId, next);
|
|
10066
10105
|
await next;
|
|
@@ -10182,7 +10221,7 @@ ${lines.join("\n")}`;
|
|
|
10182
10221
|
);
|
|
10183
10222
|
usageMsgId = result?.message_id;
|
|
10184
10223
|
} catch (err) {
|
|
10185
|
-
|
|
10224
|
+
log34.warn({ err, sessionId }, "Failed to send usage message");
|
|
10186
10225
|
}
|
|
10187
10226
|
if (this.notificationTopicId && sessionId !== this.core.assistantManager?.get("telegram")?.id) {
|
|
10188
10227
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -10210,7 +10249,7 @@ Task completed.
|
|
|
10210
10249
|
if (!content.attachment) return;
|
|
10211
10250
|
const { attachment } = content;
|
|
10212
10251
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
10213
|
-
|
|
10252
|
+
log34.warn(
|
|
10214
10253
|
{
|
|
10215
10254
|
sessionId,
|
|
10216
10255
|
fileName: attachment.fileName,
|
|
@@ -10254,7 +10293,7 @@ Task completed.
|
|
|
10254
10293
|
);
|
|
10255
10294
|
}
|
|
10256
10295
|
} catch (err) {
|
|
10257
|
-
|
|
10296
|
+
log34.error(
|
|
10258
10297
|
{ err, sessionId, fileName: attachment.fileName },
|
|
10259
10298
|
"Failed to send attachment"
|
|
10260
10299
|
);
|
|
@@ -10353,7 +10392,7 @@ Task completed.
|
|
|
10353
10392
|
}
|
|
10354
10393
|
async sendPermissionRequest(sessionId, request) {
|
|
10355
10394
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
10356
|
-
|
|
10395
|
+
log34.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
10357
10396
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
10358
10397
|
if (!session) return;
|
|
10359
10398
|
await this.sendQueue.enqueue(
|
|
@@ -10363,7 +10402,7 @@ Task completed.
|
|
|
10363
10402
|
async sendNotification(notification) {
|
|
10364
10403
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
10365
10404
|
if (notification.sessionId === this.core.assistantManager?.get("telegram")?.id) return;
|
|
10366
|
-
|
|
10405
|
+
log34.info(
|
|
10367
10406
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
10368
10407
|
"Notification sent"
|
|
10369
10408
|
);
|
|
@@ -10402,7 +10441,7 @@ Task completed.
|
|
|
10402
10441
|
}
|
|
10403
10442
|
async createSessionThread(sessionId, name) {
|
|
10404
10443
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
10405
|
-
|
|
10444
|
+
log34.info({ sessionId, name }, "Session topic created");
|
|
10406
10445
|
return String(
|
|
10407
10446
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
10408
10447
|
);
|
|
@@ -10413,7 +10452,7 @@ Task completed.
|
|
|
10413
10452
|
if (!session) return;
|
|
10414
10453
|
const threadId = Number(session.threadId);
|
|
10415
10454
|
if (!threadId) {
|
|
10416
|
-
|
|
10455
|
+
log34.debug({ sessionId, newName }, "Cannot rename thread \u2014 threadId not set yet");
|
|
10417
10456
|
return;
|
|
10418
10457
|
}
|
|
10419
10458
|
await renameSessionTopic(
|
|
@@ -10432,7 +10471,7 @@ Task completed.
|
|
|
10432
10471
|
try {
|
|
10433
10472
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
10434
10473
|
} catch (err) {
|
|
10435
|
-
|
|
10474
|
+
log34.warn(
|
|
10436
10475
|
{ err, sessionId, topicId },
|
|
10437
10476
|
"Failed to delete forum topic (may already be deleted)"
|
|
10438
10477
|
);
|
|
@@ -10476,7 +10515,7 @@ Task completed.
|
|
|
10476
10515
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
10477
10516
|
return { buffer, filePath: file.file_path };
|
|
10478
10517
|
} catch (err) {
|
|
10479
|
-
|
|
10518
|
+
log34.error({ err }, "Failed to download file from Telegram");
|
|
10480
10519
|
return null;
|
|
10481
10520
|
}
|
|
10482
10521
|
}
|
|
@@ -10497,7 +10536,7 @@ Task completed.
|
|
|
10497
10536
|
try {
|
|
10498
10537
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
10499
10538
|
} catch (err) {
|
|
10500
|
-
|
|
10539
|
+
log34.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
10501
10540
|
fileName = "voice.ogg";
|
|
10502
10541
|
mimeType = "audio/ogg";
|
|
10503
10542
|
originalFilePath = void 0;
|
|
@@ -10529,7 +10568,7 @@ Task completed.
|
|
|
10529
10568
|
userId: String(userId),
|
|
10530
10569
|
text: text3,
|
|
10531
10570
|
attachments: [att]
|
|
10532
|
-
}).catch((err) =>
|
|
10571
|
+
}).catch((err) => log34.error({ err }, "handleMessage error"));
|
|
10533
10572
|
}
|
|
10534
10573
|
async cleanupSkillCommands(sessionId) {
|
|
10535
10574
|
this._pendingSkillCommands.delete(sessionId);
|
|
@@ -14901,7 +14940,7 @@ function createPluginContext(opts) {
|
|
|
14901
14940
|
}
|
|
14902
14941
|
};
|
|
14903
14942
|
const baseLog = opts.log ?? noopLog;
|
|
14904
|
-
const
|
|
14943
|
+
const log35 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
|
|
14905
14944
|
const storageImpl = new PluginStorageImpl(storagePath);
|
|
14906
14945
|
const storage = {
|
|
14907
14946
|
async get(key) {
|
|
@@ -14928,7 +14967,7 @@ function createPluginContext(opts) {
|
|
|
14928
14967
|
const ctx = {
|
|
14929
14968
|
pluginName,
|
|
14930
14969
|
pluginConfig,
|
|
14931
|
-
log:
|
|
14970
|
+
log: log35,
|
|
14932
14971
|
storage,
|
|
14933
14972
|
on(event, handler) {
|
|
14934
14973
|
requirePermission(permissions, "events:read", "on()");
|
|
@@ -14963,7 +15002,7 @@ function createPluginContext(opts) {
|
|
|
14963
15002
|
const registry = serviceRegistry.get("command-registry");
|
|
14964
15003
|
if (registry && typeof registry.register === "function") {
|
|
14965
15004
|
registry.register(def, pluginName);
|
|
14966
|
-
|
|
15005
|
+
log35.debug(`Command '/${def.name}' registered`);
|
|
14967
15006
|
}
|
|
14968
15007
|
},
|
|
14969
15008
|
async sendMessage(_sessionId, _content) {
|
|
@@ -15006,7 +15045,7 @@ function createPluginContext(opts) {
|
|
|
15006
15045
|
const registry = serviceRegistry.get("field-registry");
|
|
15007
15046
|
if (registry && typeof registry.register === "function") {
|
|
15008
15047
|
registry.register(pluginName, fields);
|
|
15009
|
-
|
|
15048
|
+
log35.debug(`Registered ${fields.length} editable field(s) for ${pluginName}`);
|
|
15010
15049
|
}
|
|
15011
15050
|
},
|
|
15012
15051
|
get sessions() {
|