@openacp/cli 2026.405.1 → 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 +286 -235
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +132 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -10811,6 +10811,10 @@ async function validateBotAdmin(token, chatId) {
|
|
|
10811
10811
|
};
|
|
10812
10812
|
}
|
|
10813
10813
|
const { status } = data.result;
|
|
10814
|
+
log16.info(
|
|
10815
|
+
{ status, can_manage_topics: data.result.can_manage_topics, raw_result: data.result },
|
|
10816
|
+
"validateBotAdmin: getChatMember raw result"
|
|
10817
|
+
);
|
|
10814
10818
|
if (status === "creator") {
|
|
10815
10819
|
return { ok: true, canManageTopics: true };
|
|
10816
10820
|
}
|
|
@@ -10827,6 +10831,7 @@ async function validateBotAdmin(token, chatId) {
|
|
|
10827
10831
|
}
|
|
10828
10832
|
async function checkTopicsPrerequisites(token, chatId) {
|
|
10829
10833
|
const issues = [];
|
|
10834
|
+
log16.info({ chatId }, "checkTopicsPrerequisites: starting checks");
|
|
10830
10835
|
try {
|
|
10831
10836
|
const res = await fetch(`https://api.telegram.org/bot${token}/getChat`, {
|
|
10832
10837
|
method: "POST",
|
|
@@ -10834,15 +10839,24 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
10834
10839
|
body: JSON.stringify({ chat_id: chatId })
|
|
10835
10840
|
});
|
|
10836
10841
|
const data = await res.json();
|
|
10842
|
+
log16.info(
|
|
10843
|
+
{ chatId, apiOk: data.ok, is_forum: data.result?.is_forum, type: data.result?.type, title: data.result?.title },
|
|
10844
|
+
"checkTopicsPrerequisites: getChat result"
|
|
10845
|
+
);
|
|
10837
10846
|
if (data.ok && data.result && !data.result.is_forum) {
|
|
10838
10847
|
issues.push(
|
|
10839
10848
|
'\u274C Topics are not enabled on this group.\n\u2192 Go to Group Settings \u2192 Edit \u2192 enable "Topics"'
|
|
10840
10849
|
);
|
|
10841
10850
|
}
|
|
10842
|
-
} catch {
|
|
10851
|
+
} catch (err) {
|
|
10852
|
+
log16.warn({ err, chatId }, "checkTopicsPrerequisites: getChat failed (network error)");
|
|
10843
10853
|
issues.push("\u274C Could not check if Topics are enabled (network error).");
|
|
10844
10854
|
}
|
|
10845
10855
|
const adminResult = await validateBotAdmin(token, chatId);
|
|
10856
|
+
log16.info(
|
|
10857
|
+
{ chatId, adminOk: adminResult.ok, canManageTopics: adminResult.ok ? adminResult.canManageTopics : void 0, error: !adminResult.ok ? adminResult.error : void 0 },
|
|
10858
|
+
"checkTopicsPrerequisites: validateBotAdmin result"
|
|
10859
|
+
);
|
|
10846
10860
|
if (!adminResult.ok) {
|
|
10847
10861
|
issues.push(
|
|
10848
10862
|
`\u274C Bot is not an admin.
|
|
@@ -10853,12 +10867,16 @@ async function checkTopicsPrerequisites(token, chatId) {
|
|
|
10853
10867
|
'\u274C Bot cannot manage topics.\n\u2192 In Admin settings, enable the "Manage Topics" permission'
|
|
10854
10868
|
);
|
|
10855
10869
|
}
|
|
10870
|
+
log16.info({ chatId, issueCount: issues.length, ok: issues.length === 0 }, "checkTopicsPrerequisites: result");
|
|
10856
10871
|
if (issues.length > 0) return { ok: false, issues };
|
|
10857
10872
|
return { ok: true };
|
|
10858
10873
|
}
|
|
10874
|
+
var log16;
|
|
10859
10875
|
var init_validators = __esm({
|
|
10860
10876
|
"src/plugins/telegram/validators.ts"() {
|
|
10861
10877
|
"use strict";
|
|
10878
|
+
init_log();
|
|
10879
|
+
log16 = createChildLogger({ module: "telegram-validators" });
|
|
10862
10880
|
}
|
|
10863
10881
|
});
|
|
10864
10882
|
|
|
@@ -11470,7 +11488,7 @@ function setupDangerousModeCallbacks(bot, core) {
|
|
|
11470
11488
|
}).catch(() => {
|
|
11471
11489
|
});
|
|
11472
11490
|
}
|
|
11473
|
-
|
|
11491
|
+
log17.info({ sessionId, wantOn }, "Bypass permissions toggled via button");
|
|
11474
11492
|
try {
|
|
11475
11493
|
await ctx.editMessageText(buildSessionStatusText(session), {
|
|
11476
11494
|
parse_mode: "HTML",
|
|
@@ -11493,7 +11511,7 @@ function setupDangerousModeCallbacks(bot, core) {
|
|
|
11493
11511
|
const newDangerousMode = !(record.clientOverrides?.bypassPermissions ?? record.dangerousMode ?? false);
|
|
11494
11512
|
core.sessionManager.patchRecord(sessionId, { clientOverrides: { bypassPermissions: newDangerousMode } }).catch(() => {
|
|
11495
11513
|
});
|
|
11496
|
-
|
|
11514
|
+
log17.info(
|
|
11497
11515
|
{ sessionId, dangerousMode: newDangerousMode },
|
|
11498
11516
|
"Bypass permissions toggled via button (store-only, session not in memory)"
|
|
11499
11517
|
);
|
|
@@ -11678,14 +11696,14 @@ async function handleRestart(ctx, core) {
|
|
|
11678
11696
|
await new Promise((r) => setTimeout(r, 500));
|
|
11679
11697
|
await core.requestRestart();
|
|
11680
11698
|
}
|
|
11681
|
-
var
|
|
11699
|
+
var log17, OUTPUT_MODE_LABELS;
|
|
11682
11700
|
var init_admin = __esm({
|
|
11683
11701
|
"src/plugins/telegram/commands/admin.ts"() {
|
|
11684
11702
|
"use strict";
|
|
11685
11703
|
init_bypass_detection();
|
|
11686
11704
|
init_formatting();
|
|
11687
11705
|
init_log();
|
|
11688
|
-
|
|
11706
|
+
log17 = createChildLogger({ module: "telegram-cmd-admin" });
|
|
11689
11707
|
OUTPUT_MODE_LABELS = {
|
|
11690
11708
|
low: "\u{1F507} Low",
|
|
11691
11709
|
medium: "\u{1F4CA} Medium",
|
|
@@ -11700,7 +11718,7 @@ function botFromCtx(ctx) {
|
|
|
11700
11718
|
return { api: ctx.api };
|
|
11701
11719
|
}
|
|
11702
11720
|
async function createSessionDirect(ctx, core, chatId, agentName, workspace, onControlMessage) {
|
|
11703
|
-
|
|
11721
|
+
log18.info({ userId: ctx.from?.id, agentName, workspace }, "New session command (direct)");
|
|
11704
11722
|
let threadId;
|
|
11705
11723
|
try {
|
|
11706
11724
|
const topicName = `\u{1F504} New Session`;
|
|
@@ -11727,7 +11745,7 @@ async function createSessionDirect(ctx, core, chatId, agentName, workspace, onCo
|
|
|
11727
11745
|
onControlMessage?.(session.id, controlMsg.message_id);
|
|
11728
11746
|
return threadId ?? null;
|
|
11729
11747
|
} catch (err) {
|
|
11730
|
-
|
|
11748
|
+
log18.error({ err }, "Session creation failed");
|
|
11731
11749
|
if (threadId) {
|
|
11732
11750
|
try {
|
|
11733
11751
|
await ctx.api.deleteForumTopic(chatId, threadId);
|
|
@@ -11922,7 +11940,7 @@ Agent: <code>${escapeHtml4(agentKey)}</code>
|
|
|
11922
11940
|
}
|
|
11923
11941
|
});
|
|
11924
11942
|
}
|
|
11925
|
-
var
|
|
11943
|
+
var log18, WS_CACHE_MAX, workspaceCache, nextWsId;
|
|
11926
11944
|
var init_new_session = __esm({
|
|
11927
11945
|
"src/plugins/telegram/commands/new-session.ts"() {
|
|
11928
11946
|
"use strict";
|
|
@@ -11930,7 +11948,7 @@ var init_new_session = __esm({
|
|
|
11930
11948
|
init_topics2();
|
|
11931
11949
|
init_log();
|
|
11932
11950
|
init_admin();
|
|
11933
|
-
|
|
11951
|
+
log18 = createChildLogger({ module: "telegram-cmd-new-session" });
|
|
11934
11952
|
WS_CACHE_MAX = 50;
|
|
11935
11953
|
workspaceCache = /* @__PURE__ */ new Map();
|
|
11936
11954
|
nextWsId = 0;
|
|
@@ -11994,7 +12012,7 @@ ${lines.join("\n")}${truncated}`,
|
|
|
11994
12012
|
{ parse_mode: "HTML", reply_markup: keyboard }
|
|
11995
12013
|
);
|
|
11996
12014
|
} catch (err) {
|
|
11997
|
-
|
|
12015
|
+
log19.error({ err }, "handleTopics error");
|
|
11998
12016
|
await ctx.reply("\u274C Failed to list sessions.", { parse_mode: "HTML" }).catch(() => {
|
|
11999
12017
|
});
|
|
12000
12018
|
}
|
|
@@ -12015,13 +12033,13 @@ async function handleCleanup(ctx, core, chatId, statuses) {
|
|
|
12015
12033
|
try {
|
|
12016
12034
|
await ctx.api.deleteForumTopic(chatId, topicId);
|
|
12017
12035
|
} catch (err) {
|
|
12018
|
-
|
|
12036
|
+
log19.warn({ err, sessionId: record.sessionId, topicId }, "Failed to delete forum topic during cleanup");
|
|
12019
12037
|
}
|
|
12020
12038
|
}
|
|
12021
12039
|
await core.sessionManager.removeRecord(record.sessionId);
|
|
12022
12040
|
deleted++;
|
|
12023
12041
|
} catch (err) {
|
|
12024
|
-
|
|
12042
|
+
log19.error({ err, sessionId: record.sessionId }, "Failed to cleanup session");
|
|
12025
12043
|
failed++;
|
|
12026
12044
|
}
|
|
12027
12045
|
}
|
|
@@ -12092,7 +12110,7 @@ async function handleCleanupEverythingConfirmed(ctx, core, chatId, systemTopicId
|
|
|
12092
12110
|
try {
|
|
12093
12111
|
await core.sessionManager.cancelSession(record.sessionId);
|
|
12094
12112
|
} catch (err) {
|
|
12095
|
-
|
|
12113
|
+
log19.warn({ err, sessionId: record.sessionId }, "Failed to cancel session during cleanup");
|
|
12096
12114
|
}
|
|
12097
12115
|
}
|
|
12098
12116
|
const topicId = record.platform?.topicId;
|
|
@@ -12100,13 +12118,13 @@ async function handleCleanupEverythingConfirmed(ctx, core, chatId, systemTopicId
|
|
|
12100
12118
|
try {
|
|
12101
12119
|
await ctx.api.deleteForumTopic(chatId, topicId);
|
|
12102
12120
|
} catch (err) {
|
|
12103
|
-
|
|
12121
|
+
log19.warn({ err, sessionId: record.sessionId, topicId }, "Failed to delete forum topic during cleanup");
|
|
12104
12122
|
}
|
|
12105
12123
|
}
|
|
12106
12124
|
await core.sessionManager.removeRecord(record.sessionId);
|
|
12107
12125
|
deleted++;
|
|
12108
12126
|
} catch (err) {
|
|
12109
|
-
|
|
12127
|
+
log19.error({ err, sessionId: record.sessionId }, "Failed to cleanup session");
|
|
12110
12128
|
failed++;
|
|
12111
12129
|
}
|
|
12112
12130
|
}
|
|
@@ -12174,13 +12192,13 @@ async function handleArchiveConfirm(ctx, core, chatId) {
|
|
|
12174
12192
|
}
|
|
12175
12193
|
}
|
|
12176
12194
|
}
|
|
12177
|
-
var
|
|
12195
|
+
var log19;
|
|
12178
12196
|
var init_session = __esm({
|
|
12179
12197
|
"src/plugins/telegram/commands/session.ts"() {
|
|
12180
12198
|
"use strict";
|
|
12181
12199
|
init_formatting();
|
|
12182
12200
|
init_log();
|
|
12183
|
-
|
|
12201
|
+
log19 = createChildLogger({ module: "telegram-cmd-session" });
|
|
12184
12202
|
}
|
|
12185
12203
|
});
|
|
12186
12204
|
|
|
@@ -12931,7 +12949,7 @@ var init_agents2 = __esm({
|
|
|
12931
12949
|
// src/plugins/telegram/commands/resume.ts
|
|
12932
12950
|
function setupResumeCallbacks(_bot, _core, _chatId, _onControlMessage) {
|
|
12933
12951
|
}
|
|
12934
|
-
var
|
|
12952
|
+
var log20;
|
|
12935
12953
|
var init_resume = __esm({
|
|
12936
12954
|
"src/plugins/telegram/commands/resume.ts"() {
|
|
12937
12955
|
"use strict";
|
|
@@ -12941,7 +12959,7 @@ var init_resume = __esm({
|
|
|
12941
12959
|
init_topics2();
|
|
12942
12960
|
init_admin();
|
|
12943
12961
|
init_log();
|
|
12944
|
-
|
|
12962
|
+
log20 = createChildLogger({ module: "telegram-cmd-resume" });
|
|
12945
12963
|
}
|
|
12946
12964
|
});
|
|
12947
12965
|
|
|
@@ -13125,7 +13143,7 @@ function setupSettingsCallbacks(bot, core, getAssistantSession) {
|
|
|
13125
13143
|
} catch {
|
|
13126
13144
|
}
|
|
13127
13145
|
} catch (err) {
|
|
13128
|
-
|
|
13146
|
+
log21.error({ err, fieldPath }, "Failed to toggle config");
|
|
13129
13147
|
try {
|
|
13130
13148
|
await ctx.answerCallbackQuery({ text: "\u274C Failed to update" });
|
|
13131
13149
|
} catch {
|
|
@@ -13206,7 +13224,7 @@ Tap to change:`, {
|
|
|
13206
13224
|
} catch {
|
|
13207
13225
|
}
|
|
13208
13226
|
} catch (err) {
|
|
13209
|
-
|
|
13227
|
+
log21.error({ err, fieldPath }, "Failed to set config");
|
|
13210
13228
|
try {
|
|
13211
13229
|
await ctx.answerCallbackQuery({ text: "\u274C Failed to update" });
|
|
13212
13230
|
} catch {
|
|
@@ -13264,13 +13282,13 @@ Tap to change:`, {
|
|
|
13264
13282
|
}
|
|
13265
13283
|
});
|
|
13266
13284
|
}
|
|
13267
|
-
var
|
|
13285
|
+
var log21;
|
|
13268
13286
|
var init_settings = __esm({
|
|
13269
13287
|
"src/plugins/telegram/commands/settings.ts"() {
|
|
13270
13288
|
"use strict";
|
|
13271
13289
|
init_config_registry();
|
|
13272
13290
|
init_log();
|
|
13273
|
-
|
|
13291
|
+
log21 = createChildLogger({ module: "telegram-settings" });
|
|
13274
13292
|
}
|
|
13275
13293
|
});
|
|
13276
13294
|
|
|
@@ -14149,7 +14167,7 @@ async function handleDoctor(ctx) {
|
|
|
14149
14167
|
reply_markup: keyboard
|
|
14150
14168
|
});
|
|
14151
14169
|
} catch (err) {
|
|
14152
|
-
|
|
14170
|
+
log22.error({ err }, "Doctor command failed");
|
|
14153
14171
|
await ctx.api.editMessageText(
|
|
14154
14172
|
ctx.chat.id,
|
|
14155
14173
|
statusMsg.message_id,
|
|
@@ -14198,7 +14216,7 @@ function setupDoctorCallbacks(bot) {
|
|
|
14198
14216
|
}
|
|
14199
14217
|
}
|
|
14200
14218
|
} catch (err) {
|
|
14201
|
-
|
|
14219
|
+
log22.error({ err, index }, "Doctor fix callback failed");
|
|
14202
14220
|
}
|
|
14203
14221
|
});
|
|
14204
14222
|
bot.callbackQuery("m:doctor", async (ctx) => {
|
|
@@ -14209,13 +14227,13 @@ function setupDoctorCallbacks(bot) {
|
|
|
14209
14227
|
await handleDoctor(ctx);
|
|
14210
14228
|
});
|
|
14211
14229
|
}
|
|
14212
|
-
var
|
|
14230
|
+
var log22, pendingFixesStore;
|
|
14213
14231
|
var init_doctor2 = __esm({
|
|
14214
14232
|
"src/plugins/telegram/commands/doctor.ts"() {
|
|
14215
14233
|
"use strict";
|
|
14216
14234
|
init_doctor();
|
|
14217
14235
|
init_log();
|
|
14218
|
-
|
|
14236
|
+
log22 = createChildLogger({ module: "telegram-cmd-doctor" });
|
|
14219
14237
|
pendingFixesStore = /* @__PURE__ */ new Map();
|
|
14220
14238
|
}
|
|
14221
14239
|
});
|
|
@@ -14274,13 +14292,13 @@ function setupTunnelCallbacks(bot, core) {
|
|
|
14274
14292
|
}
|
|
14275
14293
|
});
|
|
14276
14294
|
}
|
|
14277
|
-
var
|
|
14295
|
+
var log23;
|
|
14278
14296
|
var init_tunnel4 = __esm({
|
|
14279
14297
|
"src/plugins/telegram/commands/tunnel.ts"() {
|
|
14280
14298
|
"use strict";
|
|
14281
14299
|
init_formatting();
|
|
14282
14300
|
init_log();
|
|
14283
|
-
|
|
14301
|
+
log23 = createChildLogger({ module: "telegram-cmd-tunnel" });
|
|
14284
14302
|
}
|
|
14285
14303
|
});
|
|
14286
14304
|
|
|
@@ -14294,10 +14312,10 @@ async function executeSwitchAgent(ctx, core, sessionId, agentName) {
|
|
|
14294
14312
|
`Switched to <b>${escapeHtml4(agentName)}</b> (${status})`,
|
|
14295
14313
|
{ parse_mode: "HTML" }
|
|
14296
14314
|
);
|
|
14297
|
-
|
|
14315
|
+
log24.info({ sessionId, agentName, resumed }, "Agent switched via /switch");
|
|
14298
14316
|
} catch (err) {
|
|
14299
14317
|
await ctx.reply(`Failed to switch agent: ${escapeHtml4(String(err.message || err))}`);
|
|
14300
|
-
|
|
14318
|
+
log24.warn({ sessionId, agentName, err: err.message }, "Agent switch failed");
|
|
14301
14319
|
}
|
|
14302
14320
|
}
|
|
14303
14321
|
function setupSwitchCallbacks(bot, core) {
|
|
@@ -14342,13 +14360,13 @@ Switch to <b>${escapeHtml4(agentName)}</b> anyway?`,
|
|
|
14342
14360
|
await executeSwitchAgent(ctx, core, session.id, data);
|
|
14343
14361
|
});
|
|
14344
14362
|
}
|
|
14345
|
-
var
|
|
14363
|
+
var log24;
|
|
14346
14364
|
var init_switch = __esm({
|
|
14347
14365
|
"src/plugins/telegram/commands/switch.ts"() {
|
|
14348
14366
|
"use strict";
|
|
14349
14367
|
init_formatting();
|
|
14350
14368
|
init_log();
|
|
14351
|
-
|
|
14369
|
+
log24 = createChildLogger({ module: "telegram-cmd-switch" });
|
|
14352
14370
|
}
|
|
14353
14371
|
});
|
|
14354
14372
|
|
|
@@ -14560,7 +14578,10 @@ function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSessio
|
|
|
14560
14578
|
const menuRegistry = core.lifecycleManager?.serviceRegistry?.get("menu-registry");
|
|
14561
14579
|
if (!menuRegistry) return;
|
|
14562
14580
|
const item = menuRegistry.getItem(itemId);
|
|
14563
|
-
if (!item)
|
|
14581
|
+
if (!item) {
|
|
14582
|
+
log25.warn({ itemId }, "Menu item not found in registry");
|
|
14583
|
+
return;
|
|
14584
|
+
}
|
|
14564
14585
|
const topicId = ctx.callbackQuery.message?.message_thread_id;
|
|
14565
14586
|
const registry = core.lifecycleManager?.serviceRegistry?.get("command-registry");
|
|
14566
14587
|
switch (item.action.type) {
|
|
@@ -14644,7 +14665,7 @@ ${lines}`, { parse_mode: "HTML" }).catch(() => {
|
|
|
14644
14665
|
}
|
|
14645
14666
|
});
|
|
14646
14667
|
}
|
|
14647
|
-
var STATIC_COMMANDS;
|
|
14668
|
+
var log25, STATIC_COMMANDS;
|
|
14648
14669
|
var init_commands3 = __esm({
|
|
14649
14670
|
"src/plugins/telegram/commands/index.ts"() {
|
|
14650
14671
|
"use strict";
|
|
@@ -14657,6 +14678,7 @@ var init_commands3 = __esm({
|
|
|
14657
14678
|
init_tunnel4();
|
|
14658
14679
|
init_switch();
|
|
14659
14680
|
init_telegram_overrides();
|
|
14681
|
+
init_log();
|
|
14660
14682
|
init_menu();
|
|
14661
14683
|
init_menu();
|
|
14662
14684
|
init_telegram_overrides();
|
|
@@ -14668,6 +14690,7 @@ var init_commands3 = __esm({
|
|
|
14668
14690
|
init_settings();
|
|
14669
14691
|
init_doctor2();
|
|
14670
14692
|
init_resume();
|
|
14693
|
+
log25 = createChildLogger({ module: "telegram-menu-callbacks" });
|
|
14671
14694
|
STATIC_COMMANDS = [
|
|
14672
14695
|
{ command: "new", description: "Create new session" },
|
|
14673
14696
|
{ command: "newchat", description: "New chat, same agent & workspace" },
|
|
@@ -14703,14 +14726,14 @@ var init_commands3 = __esm({
|
|
|
14703
14726
|
// src/plugins/telegram/permissions.ts
|
|
14704
14727
|
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
14705
14728
|
import { nanoid as nanoid2 } from "nanoid";
|
|
14706
|
-
var
|
|
14729
|
+
var log26, PermissionHandler;
|
|
14707
14730
|
var init_permissions = __esm({
|
|
14708
14731
|
"src/plugins/telegram/permissions.ts"() {
|
|
14709
14732
|
"use strict";
|
|
14710
14733
|
init_formatting();
|
|
14711
14734
|
init_topics2();
|
|
14712
14735
|
init_log();
|
|
14713
|
-
|
|
14736
|
+
log26 = createChildLogger({ module: "telegram-permissions" });
|
|
14714
14737
|
PermissionHandler = class {
|
|
14715
14738
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
14716
14739
|
this.bot = bot;
|
|
@@ -14754,11 +14777,11 @@ ${escapeHtml4(request.description)}`,
|
|
|
14754
14777
|
});
|
|
14755
14778
|
}
|
|
14756
14779
|
setupCallbackHandler() {
|
|
14757
|
-
this.bot.on("callback_query:data", async (ctx) => {
|
|
14780
|
+
this.bot.on("callback_query:data", async (ctx, next) => {
|
|
14758
14781
|
const data = ctx.callbackQuery.data;
|
|
14759
|
-
if (!data.startsWith("p:")) return;
|
|
14782
|
+
if (!data.startsWith("p:")) return next();
|
|
14760
14783
|
const parts = data.split(":");
|
|
14761
|
-
if (parts.length < 3) return;
|
|
14784
|
+
if (parts.length < 3) return next();
|
|
14762
14785
|
const [, callbackKey, optionId] = parts;
|
|
14763
14786
|
const pending = this.pending.get(callbackKey);
|
|
14764
14787
|
if (!pending) {
|
|
@@ -14770,7 +14793,7 @@ ${escapeHtml4(request.description)}`,
|
|
|
14770
14793
|
}
|
|
14771
14794
|
const session = this.getSession(pending.sessionId);
|
|
14772
14795
|
const isAllow = pending.options.find((o) => o.id === optionId)?.isAllow ?? false;
|
|
14773
|
-
|
|
14796
|
+
log26.info({ requestId: pending.requestId, optionId, isAllow }, "Permission responded");
|
|
14774
14797
|
if (session?.permissionGate.requestId === pending.requestId) {
|
|
14775
14798
|
session.permissionGate.resolve(optionId);
|
|
14776
14799
|
}
|
|
@@ -15224,7 +15247,7 @@ var init_display_spec_builder = __esm({
|
|
|
15224
15247
|
});
|
|
15225
15248
|
|
|
15226
15249
|
// src/plugins/telegram/activity.ts
|
|
15227
|
-
var
|
|
15250
|
+
var log27, THINKING_REFRESH_MS, THINKING_MAX_MS, ThinkingIndicator, ToolCard, ActivityTracker;
|
|
15228
15251
|
var init_activity = __esm({
|
|
15229
15252
|
"src/plugins/telegram/activity.ts"() {
|
|
15230
15253
|
"use strict";
|
|
@@ -15234,7 +15257,7 @@ var init_activity = __esm({
|
|
|
15234
15257
|
init_stream_accumulator();
|
|
15235
15258
|
init_stream_accumulator();
|
|
15236
15259
|
init_display_spec_builder();
|
|
15237
|
-
|
|
15260
|
+
log27 = createChildLogger({ module: "telegram:activity" });
|
|
15238
15261
|
THINKING_REFRESH_MS = 15e3;
|
|
15239
15262
|
THINKING_MAX_MS = 3 * 60 * 1e3;
|
|
15240
15263
|
ThinkingIndicator = class {
|
|
@@ -15275,7 +15298,7 @@ var init_activity = __esm({
|
|
|
15275
15298
|
}
|
|
15276
15299
|
}
|
|
15277
15300
|
} catch (err) {
|
|
15278
|
-
|
|
15301
|
+
log27.warn({ err }, "ThinkingIndicator.show() failed");
|
|
15279
15302
|
} finally {
|
|
15280
15303
|
this.sending = false;
|
|
15281
15304
|
}
|
|
@@ -15443,7 +15466,7 @@ var init_activity = __esm({
|
|
|
15443
15466
|
this.tracer?.log("telegram", { action: "telegram:delete:overflow", sessionId: this.sessionId, msgId: staleId });
|
|
15444
15467
|
}
|
|
15445
15468
|
} catch (err) {
|
|
15446
|
-
|
|
15469
|
+
log27.warn({ err }, "[ToolCard] send/edit failed");
|
|
15447
15470
|
}
|
|
15448
15471
|
}
|
|
15449
15472
|
};
|
|
@@ -15547,7 +15570,7 @@ var init_activity = __esm({
|
|
|
15547
15570
|
const entry = this.toolStateMap.merge(id, status, rawInput, content, viewerLinks, diffStats);
|
|
15548
15571
|
if (!existed || !entry) return;
|
|
15549
15572
|
if (viewerLinks || entry.viewerLinks) {
|
|
15550
|
-
|
|
15573
|
+
log27.debug({ toolId: id, status, hasIncomingLinks: !!viewerLinks, hasEntryLinks: !!entry.viewerLinks, entryLinks: entry.viewerLinks }, "toolUpdate: viewer links trace");
|
|
15551
15574
|
}
|
|
15552
15575
|
const spec = this.specBuilder.buildToolSpec(entry, this._outputMode, this.sessionContext);
|
|
15553
15576
|
this.toolCard.updateFromSpec(spec);
|
|
@@ -15974,13 +15997,13 @@ var init_draft_manager = __esm({
|
|
|
15974
15997
|
});
|
|
15975
15998
|
|
|
15976
15999
|
// src/plugins/telegram/skill-command-manager.ts
|
|
15977
|
-
var
|
|
16000
|
+
var log28, SkillCommandManager;
|
|
15978
16001
|
var init_skill_command_manager = __esm({
|
|
15979
16002
|
"src/plugins/telegram/skill-command-manager.ts"() {
|
|
15980
16003
|
"use strict";
|
|
15981
16004
|
init_commands3();
|
|
15982
16005
|
init_log();
|
|
15983
|
-
|
|
16006
|
+
log28 = createChildLogger({ module: "skill-commands" });
|
|
15984
16007
|
SkillCommandManager = class {
|
|
15985
16008
|
// sessionId → pinned msgId
|
|
15986
16009
|
constructor(bot, chatId, sendQueue, sessionManager) {
|
|
@@ -16046,7 +16069,7 @@ var init_skill_command_manager = __esm({
|
|
|
16046
16069
|
disable_notification: true
|
|
16047
16070
|
});
|
|
16048
16071
|
} catch (err) {
|
|
16049
|
-
|
|
16072
|
+
log28.error({ err, sessionId }, "Failed to send skill commands");
|
|
16050
16073
|
}
|
|
16051
16074
|
}
|
|
16052
16075
|
async cleanup(sessionId) {
|
|
@@ -16440,7 +16463,7 @@ function patchedFetch(input2, init) {
|
|
|
16440
16463
|
}
|
|
16441
16464
|
return fetch(input2, init);
|
|
16442
16465
|
}
|
|
16443
|
-
var
|
|
16466
|
+
var log29, TelegramAdapter;
|
|
16444
16467
|
var init_adapter2 = __esm({
|
|
16445
16468
|
"src/plugins/telegram/adapter.ts"() {
|
|
16446
16469
|
"use strict";
|
|
@@ -16459,7 +16482,7 @@ var init_adapter2 = __esm({
|
|
|
16459
16482
|
init_messaging_adapter();
|
|
16460
16483
|
init_renderer2();
|
|
16461
16484
|
init_output_mode_resolver();
|
|
16462
|
-
|
|
16485
|
+
log29 = createChildLogger({ module: "telegram" });
|
|
16463
16486
|
TelegramAdapter = class extends MessagingAdapter {
|
|
16464
16487
|
name = "telegram";
|
|
16465
16488
|
renderer = new TelegramRenderer();
|
|
@@ -16494,6 +16517,8 @@ var init_adapter2 = __esm({
|
|
|
16494
16517
|
controlMsgIds = /* @__PURE__ */ new Map();
|
|
16495
16518
|
_threadReadyHandler;
|
|
16496
16519
|
_configChangedHandler;
|
|
16520
|
+
/** Mutable ref passed to callbacks before topics are ready; updated in-place by initTopicDependentFeatures */
|
|
16521
|
+
_systemTopicIds = { notificationTopicId: 0, assistantTopicId: 0 };
|
|
16497
16522
|
/** True once topics are initialized and Phase 2 is complete */
|
|
16498
16523
|
_topicsInitialized = false;
|
|
16499
16524
|
/** Background watcher timer — cancelled on stop() or when topics succeed */
|
|
@@ -16584,7 +16609,7 @@ var init_adapter2 = __esm({
|
|
|
16584
16609
|
);
|
|
16585
16610
|
this.bot.catch((err) => {
|
|
16586
16611
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
16587
|
-
|
|
16612
|
+
log29.error({ err: rootCause }, "Telegram bot error");
|
|
16588
16613
|
});
|
|
16589
16614
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
16590
16615
|
const maxRetries = 3;
|
|
@@ -16602,7 +16627,7 @@ var init_adapter2 = __esm({
|
|
|
16602
16627
|
if (rateLimitedMethods.includes(method)) {
|
|
16603
16628
|
this.sendQueue.onRateLimited();
|
|
16604
16629
|
}
|
|
16605
|
-
|
|
16630
|
+
log29.warn(
|
|
16606
16631
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
16607
16632
|
"Rate limited by Telegram, retrying"
|
|
16608
16633
|
);
|
|
@@ -16761,20 +16786,57 @@ var init_adapter2 = __esm({
|
|
|
16761
16786
|
setupVerbosityCallbacks(this.bot, this.core);
|
|
16762
16787
|
setupIntegrateCallbacks(this.bot, this.core);
|
|
16763
16788
|
this.permissionHandler.setupCallbackHandler();
|
|
16789
|
+
setupAllCallbacks(
|
|
16790
|
+
this.bot,
|
|
16791
|
+
this.core,
|
|
16792
|
+
this.telegramConfig.chatId,
|
|
16793
|
+
this._systemTopicIds,
|
|
16794
|
+
() => {
|
|
16795
|
+
const assistant = this.core.assistantManager?.get("telegram");
|
|
16796
|
+
if (!assistant) return void 0;
|
|
16797
|
+
return {
|
|
16798
|
+
topicId: this.assistantTopicId,
|
|
16799
|
+
enqueuePrompt: (p2) => {
|
|
16800
|
+
const pending = this.core.assistantManager?.consumePendingSystemPrompt("telegram");
|
|
16801
|
+
const text6 = pending ? `${pending}
|
|
16802
|
+
|
|
16803
|
+
---
|
|
16804
|
+
|
|
16805
|
+
User message:
|
|
16806
|
+
${p2}` : p2;
|
|
16807
|
+
return assistant.enqueuePrompt(text6);
|
|
16808
|
+
}
|
|
16809
|
+
};
|
|
16810
|
+
},
|
|
16811
|
+
(sessionId, msgId) => {
|
|
16812
|
+
this.storeControlMsgId(sessionId, msgId);
|
|
16813
|
+
}
|
|
16814
|
+
);
|
|
16815
|
+
this.setupRoutes();
|
|
16764
16816
|
this.bot.start({
|
|
16765
16817
|
allowed_updates: ["message", "callback_query"],
|
|
16766
|
-
onStart: () =>
|
|
16818
|
+
onStart: () => log29.info({ chatId: this.telegramConfig.chatId }, "Telegram bot started")
|
|
16767
16819
|
});
|
|
16820
|
+
log29.info(
|
|
16821
|
+
{
|
|
16822
|
+
chatId: this.telegramConfig.chatId,
|
|
16823
|
+
notificationTopicId: this.telegramConfig.notificationTopicId,
|
|
16824
|
+
assistantTopicId: this.telegramConfig.assistantTopicId
|
|
16825
|
+
},
|
|
16826
|
+
"Telegram adapter: starting prerequisite check (existing topic IDs shown)"
|
|
16827
|
+
);
|
|
16768
16828
|
const { checkTopicsPrerequisites: checkTopicsPrerequisites2 } = await Promise.resolve().then(() => (init_validators(), validators_exports));
|
|
16769
16829
|
const prereqResult = await checkTopicsPrerequisites2(
|
|
16770
16830
|
this.telegramConfig.botToken,
|
|
16771
16831
|
this.telegramConfig.chatId
|
|
16772
16832
|
);
|
|
16773
16833
|
if (prereqResult.ok) {
|
|
16834
|
+
log29.info("Telegram adapter: prerequisites OK, initializing topic-dependent features");
|
|
16774
16835
|
await this.initTopicDependentFeatures();
|
|
16775
16836
|
} else {
|
|
16837
|
+
log29.warn({ issues: prereqResult.issues }, "Telegram adapter: prerequisites NOT met, starting watcher");
|
|
16776
16838
|
for (const issue of prereqResult.issues) {
|
|
16777
|
-
|
|
16839
|
+
log29.warn({ issue }, "Telegram prerequisite not met");
|
|
16778
16840
|
}
|
|
16779
16841
|
this.startPrerequisiteWatcher(prereqResult.issues);
|
|
16780
16842
|
}
|
|
@@ -16790,7 +16852,7 @@ var init_adapter2 = __esm({
|
|
|
16790
16852
|
} catch (err) {
|
|
16791
16853
|
if (attempt === maxRetries) throw err;
|
|
16792
16854
|
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
16793
|
-
|
|
16855
|
+
log29.warn(
|
|
16794
16856
|
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
16795
16857
|
`${label} failed, retrying in ${delay}ms`
|
|
16796
16858
|
);
|
|
@@ -16810,11 +16872,15 @@ var init_adapter2 = __esm({
|
|
|
16810
16872
|
}),
|
|
16811
16873
|
"setMyCommands"
|
|
16812
16874
|
).catch((err) => {
|
|
16813
|
-
|
|
16875
|
+
log29.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
16814
16876
|
});
|
|
16815
16877
|
}
|
|
16816
16878
|
async initTopicDependentFeatures() {
|
|
16817
16879
|
if (this._topicsInitialized) return;
|
|
16880
|
+
log29.info(
|
|
16881
|
+
{ notificationTopicId: this.telegramConfig.notificationTopicId, assistantTopicId: this.telegramConfig.assistantTopicId },
|
|
16882
|
+
"initTopicDependentFeatures: starting (existing IDs in config)"
|
|
16883
|
+
);
|
|
16818
16884
|
const topics = await this.retryWithBackoff(
|
|
16819
16885
|
() => ensureTopics(
|
|
16820
16886
|
this.bot,
|
|
@@ -16834,34 +16900,11 @@ var init_adapter2 = __esm({
|
|
|
16834
16900
|
);
|
|
16835
16901
|
this.notificationTopicId = topics.notificationTopicId;
|
|
16836
16902
|
this.assistantTopicId = topics.assistantTopicId;
|
|
16837
|
-
|
|
16838
|
-
|
|
16839
|
-
|
|
16840
|
-
this.
|
|
16841
|
-
|
|
16842
|
-
notificationTopicId: this.notificationTopicId,
|
|
16843
|
-
assistantTopicId: this.assistantTopicId
|
|
16844
|
-
},
|
|
16845
|
-
() => {
|
|
16846
|
-
const assistant = this.core.assistantManager?.get("telegram");
|
|
16847
|
-
if (!assistant) return void 0;
|
|
16848
|
-
return {
|
|
16849
|
-
topicId: this.assistantTopicId,
|
|
16850
|
-
enqueuePrompt: (p2) => {
|
|
16851
|
-
const pending = this.core.assistantManager?.consumePendingSystemPrompt("telegram");
|
|
16852
|
-
const text6 = pending ? `${pending}
|
|
16853
|
-
|
|
16854
|
-
---
|
|
16855
|
-
|
|
16856
|
-
User message:
|
|
16857
|
-
${p2}` : p2;
|
|
16858
|
-
return assistant.enqueuePrompt(text6);
|
|
16859
|
-
}
|
|
16860
|
-
};
|
|
16861
|
-
},
|
|
16862
|
-
(sessionId, msgId) => {
|
|
16863
|
-
this.storeControlMsgId(sessionId, msgId);
|
|
16864
|
-
}
|
|
16903
|
+
this._systemTopicIds.notificationTopicId = topics.notificationTopicId;
|
|
16904
|
+
this._systemTopicIds.assistantTopicId = topics.assistantTopicId;
|
|
16905
|
+
log29.info(
|
|
16906
|
+
{ notificationTopicId: this.notificationTopicId, assistantTopicId: this.assistantTopicId },
|
|
16907
|
+
"initTopicDependentFeatures: topics ready"
|
|
16865
16908
|
);
|
|
16866
16909
|
this._threadReadyHandler = ({ sessionId, channelId, threadId }) => {
|
|
16867
16910
|
if (channelId !== "telegram") return;
|
|
@@ -16890,7 +16933,7 @@ ${p2}` : p2;
|
|
|
16890
16933
|
).then((msg) => {
|
|
16891
16934
|
if (msg) this.storeControlMsgId(sessionId, msg.message_id);
|
|
16892
16935
|
}).catch((err) => {
|
|
16893
|
-
|
|
16936
|
+
log29.warn({ err, sessionId }, "Failed to send initial messages for new session");
|
|
16894
16937
|
});
|
|
16895
16938
|
};
|
|
16896
16939
|
this.core.eventBus.on("session:threadReady", this._threadReadyHandler);
|
|
@@ -16899,7 +16942,7 @@ ${p2}` : p2;
|
|
|
16899
16942
|
});
|
|
16900
16943
|
};
|
|
16901
16944
|
this.core.eventBus.on("session:configChanged", this._configChangedHandler);
|
|
16902
|
-
this.
|
|
16945
|
+
log29.info({ assistantTopicId: this.assistantTopicId }, "initTopicDependentFeatures: sending welcome message");
|
|
16903
16946
|
try {
|
|
16904
16947
|
const config = this.core.configManager.get();
|
|
16905
16948
|
const agents = this.core.agentManager.getAvailableAgents();
|
|
@@ -16921,16 +16964,17 @@ ${p2}` : p2;
|
|
|
16921
16964
|
this.core.lifecycleManager?.serviceRegistry?.get("menu-registry")
|
|
16922
16965
|
)
|
|
16923
16966
|
});
|
|
16967
|
+
log29.info("initTopicDependentFeatures: welcome message sent");
|
|
16924
16968
|
} catch (err) {
|
|
16925
|
-
|
|
16969
|
+
log29.warn({ err }, "Failed to send welcome message");
|
|
16926
16970
|
}
|
|
16927
16971
|
try {
|
|
16928
16972
|
await this.core.assistantManager.spawn("telegram", String(this.assistantTopicId));
|
|
16929
16973
|
} catch (err) {
|
|
16930
|
-
|
|
16974
|
+
log29.error({ err }, "Failed to spawn assistant");
|
|
16931
16975
|
}
|
|
16932
16976
|
this._topicsInitialized = true;
|
|
16933
|
-
|
|
16977
|
+
log29.info("Telegram adapter fully initialized");
|
|
16934
16978
|
}
|
|
16935
16979
|
startPrerequisiteWatcher(issues) {
|
|
16936
16980
|
const setupMessage = `\u26A0\uFE0F <b>OpenACP needs setup before it can start.</b>
|
|
@@ -16941,7 +16985,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16941
16985
|
this.bot.api.sendMessage(this.telegramConfig.chatId, setupMessage, {
|
|
16942
16986
|
parse_mode: "HTML"
|
|
16943
16987
|
}).catch((err) => {
|
|
16944
|
-
|
|
16988
|
+
log29.warn({ err }, "Failed to send setup guidance to General topic");
|
|
16945
16989
|
});
|
|
16946
16990
|
const schedule = [5e3, 1e4, 3e4];
|
|
16947
16991
|
let attempt = 1;
|
|
@@ -16954,7 +16998,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16954
16998
|
);
|
|
16955
16999
|
if (result.ok) {
|
|
16956
17000
|
this._prerequisiteWatcher = null;
|
|
16957
|
-
|
|
17001
|
+
log29.info("Prerequisites met \u2014 completing Telegram adapter initialization");
|
|
16958
17002
|
try {
|
|
16959
17003
|
await this.initTopicDependentFeatures();
|
|
16960
17004
|
await this.bot.api.sendMessage(
|
|
@@ -16963,11 +17007,11 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16963
17007
|
{ parse_mode: "HTML" }
|
|
16964
17008
|
);
|
|
16965
17009
|
} catch (err) {
|
|
16966
|
-
|
|
17010
|
+
log29.error({ err }, "Failed to complete initialization after prerequisites met");
|
|
16967
17011
|
}
|
|
16968
17012
|
return;
|
|
16969
17013
|
}
|
|
16970
|
-
|
|
17014
|
+
log29.debug({ issues: result.issues }, "Prerequisites not yet met, retrying");
|
|
16971
17015
|
const delay = schedule[Math.min(attempt, schedule.length - 1)];
|
|
16972
17016
|
attempt++;
|
|
16973
17017
|
this._prerequisiteWatcher = setTimeout(retry, delay);
|
|
@@ -16993,7 +17037,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16993
17037
|
}
|
|
16994
17038
|
this.sendQueue.clear();
|
|
16995
17039
|
await this.bot.stop();
|
|
16996
|
-
|
|
17040
|
+
log29.info("Telegram bot stopped");
|
|
16997
17041
|
}
|
|
16998
17042
|
// --- CommandRegistry response rendering ---
|
|
16999
17043
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -17078,6 +17122,13 @@ ${lines.join("\n")}`;
|
|
|
17078
17122
|
}
|
|
17079
17123
|
setupRoutes() {
|
|
17080
17124
|
this.bot.on("message:text", async (ctx) => {
|
|
17125
|
+
if (!this._topicsInitialized) {
|
|
17126
|
+
await ctx.reply(
|
|
17127
|
+
"\u23F3 OpenACP is still setting up. Check the General topic for instructions."
|
|
17128
|
+
).catch(() => {
|
|
17129
|
+
});
|
|
17130
|
+
return;
|
|
17131
|
+
}
|
|
17081
17132
|
const threadId = ctx.message.message_thread_id;
|
|
17082
17133
|
const text6 = ctx.message.text;
|
|
17083
17134
|
if (!threadId) {
|
|
@@ -17110,7 +17161,7 @@ ${lines.join("\n")}`;
|
|
|
17110
17161
|
threadId: String(threadId),
|
|
17111
17162
|
userId: String(ctx.from.id),
|
|
17112
17163
|
text: forwardText
|
|
17113
|
-
}).catch((err) =>
|
|
17164
|
+
}).catch((err) => log29.error({ err }, "handleMessage error"));
|
|
17114
17165
|
});
|
|
17115
17166
|
this.bot.on("message:photo", async (ctx) => {
|
|
17116
17167
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -17199,7 +17250,7 @@ ${lines.join("\n")}`;
|
|
|
17199
17250
|
if (session.archiving) return;
|
|
17200
17251
|
const threadId = Number(session.threadId);
|
|
17201
17252
|
if (!threadId || isNaN(threadId)) {
|
|
17202
|
-
|
|
17253
|
+
log29.warn(
|
|
17203
17254
|
{ sessionId, threadId: session.threadId },
|
|
17204
17255
|
"Session has no valid threadId, skipping message"
|
|
17205
17256
|
);
|
|
@@ -17215,7 +17266,7 @@ ${lines.join("\n")}`;
|
|
|
17215
17266
|
this._sessionThreadIds.delete(sessionId);
|
|
17216
17267
|
}
|
|
17217
17268
|
}).catch((err) => {
|
|
17218
|
-
|
|
17269
|
+
log29.warn({ err, sessionId }, "Dispatch queue error");
|
|
17219
17270
|
});
|
|
17220
17271
|
this._dispatchQueues.set(sessionId, next);
|
|
17221
17272
|
await next;
|
|
@@ -17337,7 +17388,7 @@ ${lines.join("\n")}`;
|
|
|
17337
17388
|
);
|
|
17338
17389
|
usageMsgId = result?.message_id;
|
|
17339
17390
|
} catch (err) {
|
|
17340
|
-
|
|
17391
|
+
log29.warn({ err, sessionId }, "Failed to send usage message");
|
|
17341
17392
|
}
|
|
17342
17393
|
if (this.notificationTopicId && sessionId !== this.core.assistantManager?.get("telegram")?.id) {
|
|
17343
17394
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -17365,7 +17416,7 @@ Task completed.
|
|
|
17365
17416
|
if (!content.attachment) return;
|
|
17366
17417
|
const { attachment } = content;
|
|
17367
17418
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
17368
|
-
|
|
17419
|
+
log29.warn(
|
|
17369
17420
|
{
|
|
17370
17421
|
sessionId,
|
|
17371
17422
|
fileName: attachment.fileName,
|
|
@@ -17409,7 +17460,7 @@ Task completed.
|
|
|
17409
17460
|
);
|
|
17410
17461
|
}
|
|
17411
17462
|
} catch (err) {
|
|
17412
|
-
|
|
17463
|
+
log29.error(
|
|
17413
17464
|
{ err, sessionId, fileName: attachment.fileName },
|
|
17414
17465
|
"Failed to send attachment"
|
|
17415
17466
|
);
|
|
@@ -17508,7 +17559,7 @@ Task completed.
|
|
|
17508
17559
|
}
|
|
17509
17560
|
async sendPermissionRequest(sessionId, request) {
|
|
17510
17561
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
17511
|
-
|
|
17562
|
+
log29.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
17512
17563
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
17513
17564
|
if (!session) return;
|
|
17514
17565
|
await this.sendQueue.enqueue(
|
|
@@ -17518,7 +17569,7 @@ Task completed.
|
|
|
17518
17569
|
async sendNotification(notification) {
|
|
17519
17570
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
17520
17571
|
if (notification.sessionId === this.core.assistantManager?.get("telegram")?.id) return;
|
|
17521
|
-
|
|
17572
|
+
log29.info(
|
|
17522
17573
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
17523
17574
|
"Notification sent"
|
|
17524
17575
|
);
|
|
@@ -17557,7 +17608,7 @@ Task completed.
|
|
|
17557
17608
|
}
|
|
17558
17609
|
async createSessionThread(sessionId, name) {
|
|
17559
17610
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
17560
|
-
|
|
17611
|
+
log29.info({ sessionId, name }, "Session topic created");
|
|
17561
17612
|
return String(
|
|
17562
17613
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
17563
17614
|
);
|
|
@@ -17568,7 +17619,7 @@ Task completed.
|
|
|
17568
17619
|
if (!session) return;
|
|
17569
17620
|
const threadId = Number(session.threadId);
|
|
17570
17621
|
if (!threadId) {
|
|
17571
|
-
|
|
17622
|
+
log29.debug({ sessionId, newName }, "Cannot rename thread \u2014 threadId not set yet");
|
|
17572
17623
|
return;
|
|
17573
17624
|
}
|
|
17574
17625
|
await renameSessionTopic(
|
|
@@ -17587,7 +17638,7 @@ Task completed.
|
|
|
17587
17638
|
try {
|
|
17588
17639
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
17589
17640
|
} catch (err) {
|
|
17590
|
-
|
|
17641
|
+
log29.warn(
|
|
17591
17642
|
{ err, sessionId, topicId },
|
|
17592
17643
|
"Failed to delete forum topic (may already be deleted)"
|
|
17593
17644
|
);
|
|
@@ -17631,7 +17682,7 @@ Task completed.
|
|
|
17631
17682
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
17632
17683
|
return { buffer, filePath: file.file_path };
|
|
17633
17684
|
} catch (err) {
|
|
17634
|
-
|
|
17685
|
+
log29.error({ err }, "Failed to download file from Telegram");
|
|
17635
17686
|
return null;
|
|
17636
17687
|
}
|
|
17637
17688
|
}
|
|
@@ -17652,7 +17703,7 @@ Task completed.
|
|
|
17652
17703
|
try {
|
|
17653
17704
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
17654
17705
|
} catch (err) {
|
|
17655
|
-
|
|
17706
|
+
log29.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
17656
17707
|
fileName = "voice.ogg";
|
|
17657
17708
|
mimeType = "audio/ogg";
|
|
17658
17709
|
originalFilePath = void 0;
|
|
@@ -17684,7 +17735,7 @@ Task completed.
|
|
|
17684
17735
|
userId: String(userId),
|
|
17685
17736
|
text: text6,
|
|
17686
17737
|
attachments: [att]
|
|
17687
|
-
}).catch((err) =>
|
|
17738
|
+
}).catch((err) => log29.error({ err }, "handleMessage error"));
|
|
17688
17739
|
}
|
|
17689
17740
|
async cleanupSkillCommands(sessionId) {
|
|
17690
17741
|
this._pendingSkillCommands.delete(sessionId);
|
|
@@ -19063,7 +19114,7 @@ function resolveAgentCommand(cmd) {
|
|
|
19063
19114
|
}
|
|
19064
19115
|
return { command: cmd, args: [] };
|
|
19065
19116
|
}
|
|
19066
|
-
var
|
|
19117
|
+
var log31, AgentInstance;
|
|
19067
19118
|
var init_agent_instance = __esm({
|
|
19068
19119
|
"src/core/agents/agent-instance.ts"() {
|
|
19069
19120
|
"use strict";
|
|
@@ -19077,7 +19128,7 @@ var init_agent_instance = __esm({
|
|
|
19077
19128
|
init_mcp_manager();
|
|
19078
19129
|
init_debug_tracer();
|
|
19079
19130
|
init_log();
|
|
19080
|
-
|
|
19131
|
+
log31 = createChildLogger({ module: "agent-instance" });
|
|
19081
19132
|
AgentInstance = class _AgentInstance extends TypedEmitter {
|
|
19082
19133
|
connection;
|
|
19083
19134
|
child;
|
|
@@ -19107,7 +19158,7 @@ var init_agent_instance = __esm({
|
|
|
19107
19158
|
static async spawnSubprocess(agentDef, workingDirectory) {
|
|
19108
19159
|
const instance = new _AgentInstance(agentDef.name);
|
|
19109
19160
|
const resolved = resolveAgentCommand(agentDef.command);
|
|
19110
|
-
|
|
19161
|
+
log31.debug(
|
|
19111
19162
|
{
|
|
19112
19163
|
agentName: agentDef.name,
|
|
19113
19164
|
command: resolved.command,
|
|
@@ -19192,14 +19243,14 @@ var init_agent_instance = __esm({
|
|
|
19192
19243
|
}
|
|
19193
19244
|
});
|
|
19194
19245
|
if (initResponse.protocolVersion !== PROTOCOL_VERSION) {
|
|
19195
|
-
|
|
19246
|
+
log31.warn(
|
|
19196
19247
|
{ expected: PROTOCOL_VERSION, got: initResponse.protocolVersion },
|
|
19197
19248
|
"ACP protocol version mismatch \u2014 some features may not work correctly"
|
|
19198
19249
|
);
|
|
19199
19250
|
}
|
|
19200
19251
|
instance.promptCapabilities = initResponse.agentCapabilities?.promptCapabilities;
|
|
19201
19252
|
instance.agentCapabilities = initResponse.agentCapabilities;
|
|
19202
|
-
|
|
19253
|
+
log31.info(
|
|
19203
19254
|
{ promptCapabilities: instance.promptCapabilities ?? {} },
|
|
19204
19255
|
"Agent prompt capabilities"
|
|
19205
19256
|
);
|
|
@@ -19208,7 +19259,7 @@ var init_agent_instance = __esm({
|
|
|
19208
19259
|
setupCrashDetection() {
|
|
19209
19260
|
this.child.on("exit", (code, signal) => {
|
|
19210
19261
|
if (this._destroying) return;
|
|
19211
|
-
|
|
19262
|
+
log31.info(
|
|
19212
19263
|
{ sessionId: this.sessionId, exitCode: code, signal },
|
|
19213
19264
|
"Agent process exited"
|
|
19214
19265
|
);
|
|
@@ -19224,11 +19275,11 @@ ${stderr}`
|
|
|
19224
19275
|
}
|
|
19225
19276
|
});
|
|
19226
19277
|
this.connection.closed.then(() => {
|
|
19227
|
-
|
|
19278
|
+
log31.debug({ sessionId: this.sessionId }, "ACP connection closed");
|
|
19228
19279
|
});
|
|
19229
19280
|
}
|
|
19230
19281
|
static async spawn(agentDef, workingDirectory, mcpServers) {
|
|
19231
|
-
|
|
19282
|
+
log31.debug(
|
|
19232
19283
|
{ agentName: agentDef.name, command: agentDef.command },
|
|
19233
19284
|
"Spawning agent"
|
|
19234
19285
|
);
|
|
@@ -19242,12 +19293,12 @@ ${stderr}`
|
|
|
19242
19293
|
cwd: workingDirectory,
|
|
19243
19294
|
mcpServers: resolvedMcp
|
|
19244
19295
|
});
|
|
19245
|
-
|
|
19296
|
+
log31.info(response, "newSession response");
|
|
19246
19297
|
instance.sessionId = response.sessionId;
|
|
19247
19298
|
instance.initialSessionResponse = response;
|
|
19248
19299
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19249
19300
|
instance.setupCrashDetection();
|
|
19250
|
-
|
|
19301
|
+
log31.info(
|
|
19251
19302
|
{
|
|
19252
19303
|
sessionId: response.sessionId,
|
|
19253
19304
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19259,7 +19310,7 @@ ${stderr}`
|
|
|
19259
19310
|
return instance;
|
|
19260
19311
|
}
|
|
19261
19312
|
static async resume(agentDef, workingDirectory, agentSessionId, mcpServers) {
|
|
19262
|
-
|
|
19313
|
+
log31.debug({ agentName: agentDef.name, agentSessionId }, "Resuming agent");
|
|
19263
19314
|
const spawnStart = Date.now();
|
|
19264
19315
|
const instance = await _AgentInstance.spawnSubprocess(
|
|
19265
19316
|
agentDef,
|
|
@@ -19276,7 +19327,7 @@ ${stderr}`
|
|
|
19276
19327
|
instance.sessionId = agentSessionId;
|
|
19277
19328
|
instance.initialSessionResponse = response;
|
|
19278
19329
|
instance.debugTracer = createDebugTracer(agentSessionId, workingDirectory);
|
|
19279
|
-
|
|
19330
|
+
log31.info(
|
|
19280
19331
|
{
|
|
19281
19332
|
sessionId: agentSessionId,
|
|
19282
19333
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19292,7 +19343,7 @@ ${stderr}`
|
|
|
19292
19343
|
instance.sessionId = response.sessionId;
|
|
19293
19344
|
instance.initialSessionResponse = response;
|
|
19294
19345
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19295
|
-
|
|
19346
|
+
log31.info(
|
|
19296
19347
|
{
|
|
19297
19348
|
sessionId: response.sessionId,
|
|
19298
19349
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19302,7 +19353,7 @@ ${stderr}`
|
|
|
19302
19353
|
);
|
|
19303
19354
|
}
|
|
19304
19355
|
} catch (err) {
|
|
19305
|
-
|
|
19356
|
+
log31.warn(
|
|
19306
19357
|
{ err, agentSessionId },
|
|
19307
19358
|
"Resume failed, falling back to new session"
|
|
19308
19359
|
);
|
|
@@ -19313,7 +19364,7 @@ ${stderr}`
|
|
|
19313
19364
|
instance.sessionId = response.sessionId;
|
|
19314
19365
|
instance.initialSessionResponse = response;
|
|
19315
19366
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19316
|
-
|
|
19367
|
+
log31.info(
|
|
19317
19368
|
{ sessionId: response.sessionId, durationMs: Date.now() - spawnStart },
|
|
19318
19369
|
"Agent fallback spawn complete"
|
|
19319
19370
|
);
|
|
@@ -19618,7 +19669,7 @@ ${stderr}`
|
|
|
19618
19669
|
contentBlocks.push({ type: "audio", data: data.toString("base64"), mimeType: att.mimeType });
|
|
19619
19670
|
} else {
|
|
19620
19671
|
if ((att.type === "image" || att.type === "audio") && !tooLarge) {
|
|
19621
|
-
|
|
19672
|
+
log31.debug(
|
|
19622
19673
|
{ type: att.type, capabilities: this.promptCapabilities ?? {} },
|
|
19623
19674
|
"Agent does not support %s content, falling back to file path",
|
|
19624
19675
|
att.type
|
|
@@ -20636,14 +20687,14 @@ var init_session_manager = __esm({
|
|
|
20636
20687
|
});
|
|
20637
20688
|
|
|
20638
20689
|
// src/core/sessions/session-bridge.ts
|
|
20639
|
-
var
|
|
20690
|
+
var log32, SessionBridge;
|
|
20640
20691
|
var init_session_bridge = __esm({
|
|
20641
20692
|
"src/core/sessions/session-bridge.ts"() {
|
|
20642
20693
|
"use strict";
|
|
20643
20694
|
init_log();
|
|
20644
20695
|
init_bypass_detection();
|
|
20645
20696
|
init_turn_context();
|
|
20646
|
-
|
|
20697
|
+
log32 = createChildLogger({ module: "session-bridge" });
|
|
20647
20698
|
SessionBridge = class {
|
|
20648
20699
|
constructor(session, adapter, deps, adapterId) {
|
|
20649
20700
|
this.session = session;
|
|
@@ -20672,16 +20723,16 @@ var init_session_bridge = __esm({
|
|
|
20672
20723
|
if (!result) return;
|
|
20673
20724
|
this.tracer?.log("core", { step: "dispatch", sessionId, message: result.message });
|
|
20674
20725
|
this.adapter.sendMessage(sessionId, result.message).catch((err) => {
|
|
20675
|
-
|
|
20726
|
+
log32.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20676
20727
|
});
|
|
20677
20728
|
} else {
|
|
20678
20729
|
this.tracer?.log("core", { step: "dispatch", sessionId, message });
|
|
20679
20730
|
this.adapter.sendMessage(sessionId, message).catch((err) => {
|
|
20680
|
-
|
|
20731
|
+
log32.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20681
20732
|
});
|
|
20682
20733
|
}
|
|
20683
20734
|
} catch (err) {
|
|
20684
|
-
|
|
20735
|
+
log32.error({ err, sessionId }, "Error in sendMessage middleware");
|
|
20685
20736
|
}
|
|
20686
20737
|
}
|
|
20687
20738
|
/** Determine if this bridge should forward the given event based on turn routing. */
|
|
@@ -20723,7 +20774,7 @@ var init_session_bridge = __esm({
|
|
|
20723
20774
|
try {
|
|
20724
20775
|
await this.adapter.sendPermissionRequest(this.session.id, request);
|
|
20725
20776
|
} catch (err) {
|
|
20726
|
-
|
|
20777
|
+
log32.error({ err, sessionId: this.session.id, adapterId: this.adapterId }, "Failed to send permission request to adapter");
|
|
20727
20778
|
}
|
|
20728
20779
|
});
|
|
20729
20780
|
this.listen(this.session, "status_change", (from, to) => {
|
|
@@ -20803,14 +20854,14 @@ var init_session_bridge = __esm({
|
|
|
20803
20854
|
try {
|
|
20804
20855
|
this.handleAgentEvent(event);
|
|
20805
20856
|
} catch (err) {
|
|
20806
|
-
|
|
20857
|
+
log32.error({ err, sessionId: this.session.id }, "Error handling agent event (middleware fallback)");
|
|
20807
20858
|
}
|
|
20808
20859
|
}
|
|
20809
20860
|
} else {
|
|
20810
20861
|
try {
|
|
20811
20862
|
this.handleAgentEvent(event);
|
|
20812
20863
|
} catch (err) {
|
|
20813
|
-
|
|
20864
|
+
log32.error({ err, sessionId: this.session.id }, "Error handling agent event");
|
|
20814
20865
|
}
|
|
20815
20866
|
}
|
|
20816
20867
|
}
|
|
@@ -20874,7 +20925,7 @@ var init_session_bridge = __esm({
|
|
|
20874
20925
|
text: "",
|
|
20875
20926
|
attachment: att
|
|
20876
20927
|
});
|
|
20877
|
-
}).catch((err) =>
|
|
20928
|
+
}).catch((err) => log32.error({ err }, "Failed to save agent image"));
|
|
20878
20929
|
}
|
|
20879
20930
|
break;
|
|
20880
20931
|
}
|
|
@@ -20891,12 +20942,12 @@ var init_session_bridge = __esm({
|
|
|
20891
20942
|
text: "",
|
|
20892
20943
|
attachment: att
|
|
20893
20944
|
});
|
|
20894
|
-
}).catch((err) =>
|
|
20945
|
+
}).catch((err) => log32.error({ err }, "Failed to save agent audio"));
|
|
20895
20946
|
}
|
|
20896
20947
|
break;
|
|
20897
20948
|
}
|
|
20898
20949
|
case "commands_update":
|
|
20899
|
-
|
|
20950
|
+
log32.debug({ commands: event.commands }, "Commands available");
|
|
20900
20951
|
this.adapter.sendSkillCommands?.(this.session.id, event.commands);
|
|
20901
20952
|
break;
|
|
20902
20953
|
case "system_message":
|
|
@@ -20992,7 +21043,7 @@ var init_session_bridge = __esm({
|
|
|
20992
21043
|
if (isAgentBypass || isClientBypass) {
|
|
20993
21044
|
const allowOption = request.options.find((o) => o.isAllow);
|
|
20994
21045
|
if (allowOption) {
|
|
20995
|
-
|
|
21046
|
+
log32.info(
|
|
20996
21047
|
{ sessionId: this.session.id, requestId: request.id, optionId: allowOption.id, agentBypass: !!isAgentBypass, clientBypass: !!isClientBypass },
|
|
20997
21048
|
"Bypass mode: auto-approving permission"
|
|
20998
21049
|
);
|
|
@@ -21165,13 +21216,13 @@ function computeLineDiff(oldStr, newStr) {
|
|
|
21165
21216
|
removed: Math.max(0, oldLines.length - prefixLen - suffixLen)
|
|
21166
21217
|
};
|
|
21167
21218
|
}
|
|
21168
|
-
var
|
|
21219
|
+
var log33, BINARY_VIEWER_EXTENSIONS, MessageTransformer;
|
|
21169
21220
|
var init_message_transformer = __esm({
|
|
21170
21221
|
"src/core/message-transformer.ts"() {
|
|
21171
21222
|
"use strict";
|
|
21172
21223
|
init_extract_file_info();
|
|
21173
21224
|
init_log();
|
|
21174
|
-
|
|
21225
|
+
log33 = createChildLogger({ module: "message-transformer" });
|
|
21175
21226
|
BINARY_VIEWER_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
21176
21227
|
".wav",
|
|
21177
21228
|
".ogg",
|
|
@@ -21374,14 +21425,14 @@ var init_message_transformer = __esm({
|
|
|
21374
21425
|
}
|
|
21375
21426
|
}
|
|
21376
21427
|
if (!this.tunnelService || !sessionContext) {
|
|
21377
|
-
|
|
21428
|
+
log33.debug(
|
|
21378
21429
|
{ hasTunnel: !!this.tunnelService, hasCtx: !!sessionContext, kind },
|
|
21379
21430
|
"enrichWithViewerLinks: skipping (no tunnel or session context)"
|
|
21380
21431
|
);
|
|
21381
21432
|
return;
|
|
21382
21433
|
}
|
|
21383
21434
|
const name = "name" in event ? event.name || "" : "";
|
|
21384
|
-
|
|
21435
|
+
log33.debug(
|
|
21385
21436
|
{ name, kind, status: event.status, hasContent: !!event.content, hasRawInput: !!event.rawInput },
|
|
21386
21437
|
"enrichWithViewerLinks: inspecting event"
|
|
21387
21438
|
);
|
|
@@ -21393,7 +21444,7 @@ var init_message_transformer = __esm({
|
|
|
21393
21444
|
event.meta
|
|
21394
21445
|
);
|
|
21395
21446
|
if (!fileInfo) {
|
|
21396
|
-
|
|
21447
|
+
log33.debug(
|
|
21397
21448
|
{ name, kind, hasContent: !!event.content, hasRawInput: !!event.rawInput, hasMeta: !!event.meta },
|
|
21398
21449
|
"enrichWithViewerLinks: extractFileInfo returned null"
|
|
21399
21450
|
);
|
|
@@ -21401,15 +21452,15 @@ var init_message_transformer = __esm({
|
|
|
21401
21452
|
}
|
|
21402
21453
|
const fileExt = path45.extname(fileInfo.filePath).toLowerCase();
|
|
21403
21454
|
if (BINARY_VIEWER_EXTENSIONS.has(fileExt)) {
|
|
21404
|
-
|
|
21455
|
+
log33.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping binary file");
|
|
21405
21456
|
return;
|
|
21406
21457
|
}
|
|
21407
21458
|
const publicUrl = this.tunnelService.getPublicUrl();
|
|
21408
21459
|
if (publicUrl.startsWith("http://localhost") || publicUrl.startsWith("http://127.0.0.1")) {
|
|
21409
|
-
|
|
21460
|
+
log33.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping (no public tunnel URL)");
|
|
21410
21461
|
return;
|
|
21411
21462
|
}
|
|
21412
|
-
|
|
21463
|
+
log33.info(
|
|
21413
21464
|
{
|
|
21414
21465
|
name,
|
|
21415
21466
|
kind,
|
|
@@ -21455,12 +21506,12 @@ var init_message_transformer = __esm({
|
|
|
21455
21506
|
// src/core/sessions/session-store.ts
|
|
21456
21507
|
import fs42 from "fs";
|
|
21457
21508
|
import path46 from "path";
|
|
21458
|
-
var
|
|
21509
|
+
var log34, DEBOUNCE_MS3, JsonFileSessionStore;
|
|
21459
21510
|
var init_session_store = __esm({
|
|
21460
21511
|
"src/core/sessions/session-store.ts"() {
|
|
21461
21512
|
"use strict";
|
|
21462
21513
|
init_log();
|
|
21463
|
-
|
|
21514
|
+
log34 = createChildLogger({ module: "session-store" });
|
|
21464
21515
|
DEBOUNCE_MS3 = 2e3;
|
|
21465
21516
|
JsonFileSessionStore = class {
|
|
21466
21517
|
records = /* @__PURE__ */ new Map();
|
|
@@ -21554,7 +21605,7 @@ var init_session_store = __esm({
|
|
|
21554
21605
|
fs42.readFileSync(this.filePath, "utf-8")
|
|
21555
21606
|
);
|
|
21556
21607
|
if (raw.version !== 1) {
|
|
21557
|
-
|
|
21608
|
+
log34.warn(
|
|
21558
21609
|
{ version: raw.version },
|
|
21559
21610
|
"Unknown session store version, skipping load"
|
|
21560
21611
|
);
|
|
@@ -21563,9 +21614,9 @@ var init_session_store = __esm({
|
|
|
21563
21614
|
for (const [id, record] of Object.entries(raw.sessions)) {
|
|
21564
21615
|
this.records.set(id, this.migrateRecord(record));
|
|
21565
21616
|
}
|
|
21566
|
-
|
|
21617
|
+
log34.debug({ count: this.records.size }, "Loaded session records");
|
|
21567
21618
|
} catch (err) {
|
|
21568
|
-
|
|
21619
|
+
log34.error({ err }, "Failed to load session store, backing up corrupt file");
|
|
21569
21620
|
try {
|
|
21570
21621
|
fs42.renameSync(this.filePath, `${this.filePath}.bak`);
|
|
21571
21622
|
} catch {
|
|
@@ -21601,7 +21652,7 @@ var init_session_store = __esm({
|
|
|
21601
21652
|
}
|
|
21602
21653
|
}
|
|
21603
21654
|
if (removed > 0) {
|
|
21604
|
-
|
|
21655
|
+
log34.info({ removed }, "Cleaned up expired session records");
|
|
21605
21656
|
this.scheduleDiskWrite();
|
|
21606
21657
|
}
|
|
21607
21658
|
}
|
|
@@ -21616,13 +21667,13 @@ var init_session_store = __esm({
|
|
|
21616
21667
|
});
|
|
21617
21668
|
|
|
21618
21669
|
// src/core/sessions/session-factory.ts
|
|
21619
|
-
var
|
|
21670
|
+
var log35, SessionFactory;
|
|
21620
21671
|
var init_session_factory = __esm({
|
|
21621
21672
|
"src/core/sessions/session-factory.ts"() {
|
|
21622
21673
|
"use strict";
|
|
21623
21674
|
init_session2();
|
|
21624
21675
|
init_log();
|
|
21625
|
-
|
|
21676
|
+
log35 = createChildLogger({ module: "session-factory" });
|
|
21626
21677
|
SessionFactory = class {
|
|
21627
21678
|
constructor(agentManager, sessionManager, speechServiceAccessor, eventBus, instanceRoot) {
|
|
21628
21679
|
this.agentManager = agentManager;
|
|
@@ -21683,7 +21734,7 @@ var init_session_factory = __esm({
|
|
|
21683
21734
|
createParams.resumeAgentSessionId
|
|
21684
21735
|
);
|
|
21685
21736
|
} catch (resumeErr) {
|
|
21686
|
-
|
|
21737
|
+
log35.warn(
|
|
21687
21738
|
{ agentName: createParams.agentName, resumeErr },
|
|
21688
21739
|
"Agent session resume failed, falling back to fresh spawn"
|
|
21689
21740
|
);
|
|
@@ -21816,10 +21867,10 @@ var init_session_factory = __esm({
|
|
|
21816
21867
|
session.setAgentCapabilities(record.acpState.agentCapabilities);
|
|
21817
21868
|
}
|
|
21818
21869
|
}
|
|
21819
|
-
|
|
21870
|
+
log35.info({ sessionId }, "Lazy resume by ID successful");
|
|
21820
21871
|
return session;
|
|
21821
21872
|
} catch (err) {
|
|
21822
|
-
|
|
21873
|
+
log35.error({ err, sessionId }, "Lazy resume by ID failed");
|
|
21823
21874
|
return null;
|
|
21824
21875
|
} finally {
|
|
21825
21876
|
this.resumeLocks.delete(sessionId);
|
|
@@ -21839,18 +21890,18 @@ var init_session_factory = __esm({
|
|
|
21839
21890
|
(p2) => String(p2.topicId) === threadId || String(p2.threadId ?? "") === threadId
|
|
21840
21891
|
);
|
|
21841
21892
|
if (!record) {
|
|
21842
|
-
|
|
21893
|
+
log35.debug({ threadId, channelId }, "No session record found for thread");
|
|
21843
21894
|
return null;
|
|
21844
21895
|
}
|
|
21845
21896
|
if (record.status === "error" || record.status === "cancelled") {
|
|
21846
|
-
|
|
21897
|
+
log35.warn(
|
|
21847
21898
|
{ threadId, sessionId: record.sessionId, status: record.status },
|
|
21848
21899
|
"Session record found but skipped (status: %s) \u2014 use /new to start a fresh session",
|
|
21849
21900
|
record.status
|
|
21850
21901
|
);
|
|
21851
21902
|
return null;
|
|
21852
21903
|
}
|
|
21853
|
-
|
|
21904
|
+
log35.info({ threadId, sessionId: record.sessionId, status: record.status }, "Lazy resume: found record, attempting resume");
|
|
21854
21905
|
const resumePromise = (async () => {
|
|
21855
21906
|
try {
|
|
21856
21907
|
const session = await this.createFullSession({
|
|
@@ -21891,7 +21942,7 @@ var init_session_factory = __esm({
|
|
|
21891
21942
|
}
|
|
21892
21943
|
const resumeFalledBack = record.agentSessionId && session.agentSessionId !== record.agentSessionId;
|
|
21893
21944
|
if (resumeFalledBack) {
|
|
21894
|
-
|
|
21945
|
+
log35.info({ sessionId: session.id }, "Resume fell back to fresh spawn \u2014 injecting conversation history");
|
|
21895
21946
|
const contextManager = this.getContextManager?.();
|
|
21896
21947
|
if (contextManager) {
|
|
21897
21948
|
try {
|
|
@@ -21908,10 +21959,10 @@ var init_session_factory = __esm({
|
|
|
21908
21959
|
}
|
|
21909
21960
|
}
|
|
21910
21961
|
}
|
|
21911
|
-
|
|
21962
|
+
log35.info({ sessionId: session.id, threadId }, "Lazy resume successful");
|
|
21912
21963
|
return session;
|
|
21913
21964
|
} catch (err) {
|
|
21914
|
-
|
|
21965
|
+
log35.error({ err, record }, "Lazy resume failed");
|
|
21915
21966
|
const adapter = this.adapters?.get(channelId);
|
|
21916
21967
|
if (adapter) {
|
|
21917
21968
|
try {
|
|
@@ -21936,7 +21987,7 @@ var init_session_factory = __esm({
|
|
|
21936
21987
|
}
|
|
21937
21988
|
const config = this.configManager.get();
|
|
21938
21989
|
const resolvedAgent = agentName || config.defaultAgent;
|
|
21939
|
-
|
|
21990
|
+
log35.info({ channelId, agentName: resolvedAgent }, "New session request");
|
|
21940
21991
|
const agentDef = this.agentCatalog.resolve(resolvedAgent);
|
|
21941
21992
|
const resolvedWorkspace = this.configManager.resolveWorkspace(
|
|
21942
21993
|
workspacePath || agentDef?.workingDirectory
|
|
@@ -21985,7 +22036,7 @@ var init_session_factory = __esm({
|
|
|
21985
22036
|
params.contextOptions
|
|
21986
22037
|
);
|
|
21987
22038
|
} catch (err) {
|
|
21988
|
-
|
|
22039
|
+
log35.warn({ err }, "Context building failed, proceeding without context");
|
|
21989
22040
|
}
|
|
21990
22041
|
}
|
|
21991
22042
|
const session = await this.createFullSession({
|
|
@@ -22034,13 +22085,13 @@ var init_session_factory = __esm({
|
|
|
22034
22085
|
});
|
|
22035
22086
|
|
|
22036
22087
|
// src/core/agent-switch-handler.ts
|
|
22037
|
-
var
|
|
22088
|
+
var log36, AgentSwitchHandler;
|
|
22038
22089
|
var init_agent_switch_handler = __esm({
|
|
22039
22090
|
"src/core/agent-switch-handler.ts"() {
|
|
22040
22091
|
"use strict";
|
|
22041
22092
|
init_agent_registry();
|
|
22042
22093
|
init_log();
|
|
22043
|
-
|
|
22094
|
+
log36 = createChildLogger({ module: "agent-switch" });
|
|
22044
22095
|
AgentSwitchHandler = class {
|
|
22045
22096
|
constructor(deps) {
|
|
22046
22097
|
this.deps = deps;
|
|
@@ -22114,7 +22165,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22114
22165
|
resumed = true;
|
|
22115
22166
|
return instance2;
|
|
22116
22167
|
} catch {
|
|
22117
|
-
|
|
22168
|
+
log36.warn({ sessionId, toAgent }, "Resume failed, falling back to new agent with context injection");
|
|
22118
22169
|
}
|
|
22119
22170
|
}
|
|
22120
22171
|
const instance = await agentManager.spawn(toAgent, session.workingDirectory);
|
|
@@ -22183,10 +22234,10 @@ var init_agent_switch_handler = __esm({
|
|
|
22183
22234
|
createBridge(session, adapter, adapterId).connect();
|
|
22184
22235
|
}
|
|
22185
22236
|
}
|
|
22186
|
-
|
|
22237
|
+
log36.warn({ sessionId, fromAgent, toAgent, err }, "Agent switch failed, rolled back to previous agent");
|
|
22187
22238
|
} catch (rollbackErr) {
|
|
22188
22239
|
session.fail(`Switch failed and rollback failed: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`);
|
|
22189
|
-
|
|
22240
|
+
log36.error({ sessionId, fromAgent, toAgent, err, rollbackErr }, "Agent switch failed and rollback also failed");
|
|
22190
22241
|
}
|
|
22191
22242
|
throw err;
|
|
22192
22243
|
}
|
|
@@ -22196,7 +22247,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22196
22247
|
if (adapter) {
|
|
22197
22248
|
createBridge(session, adapter, adapterId).connect();
|
|
22198
22249
|
} else {
|
|
22199
|
-
|
|
22250
|
+
log36.warn({ sessionId, adapterId }, "Adapter not available during switch reconnect, skipping bridge");
|
|
22200
22251
|
}
|
|
22201
22252
|
}
|
|
22202
22253
|
}
|
|
@@ -22229,12 +22280,12 @@ import * as fs43 from "fs";
|
|
|
22229
22280
|
import * as path47 from "path";
|
|
22230
22281
|
import * as os20 from "os";
|
|
22231
22282
|
import { z as z10 } from "zod";
|
|
22232
|
-
var
|
|
22283
|
+
var log37, InstalledAgentSchema, AgentStoreSchema, AgentStore;
|
|
22233
22284
|
var init_agent_store = __esm({
|
|
22234
22285
|
"src/core/agents/agent-store.ts"() {
|
|
22235
22286
|
"use strict";
|
|
22236
22287
|
init_log();
|
|
22237
|
-
|
|
22288
|
+
log37 = createChildLogger({ module: "agent-store" });
|
|
22238
22289
|
InstalledAgentSchema = z10.object({
|
|
22239
22290
|
registryId: z10.string().nullable(),
|
|
22240
22291
|
name: z10.string(),
|
|
@@ -22268,11 +22319,11 @@ var init_agent_store = __esm({
|
|
|
22268
22319
|
if (result.success) {
|
|
22269
22320
|
this.data = result.data;
|
|
22270
22321
|
} else {
|
|
22271
|
-
|
|
22322
|
+
log37.warn({ errors: result.error.issues }, "Invalid agents.json, starting fresh");
|
|
22272
22323
|
this.data = { version: 1, installed: {} };
|
|
22273
22324
|
}
|
|
22274
22325
|
} catch (err) {
|
|
22275
|
-
|
|
22326
|
+
log37.warn({ err }, "Failed to read agents.json, starting fresh");
|
|
22276
22327
|
this.data = { version: 1, installed: {} };
|
|
22277
22328
|
}
|
|
22278
22329
|
}
|
|
@@ -22314,7 +22365,7 @@ __export(agent_catalog_exports, {
|
|
|
22314
22365
|
import * as fs44 from "fs";
|
|
22315
22366
|
import * as path48 from "path";
|
|
22316
22367
|
import * as os21 from "os";
|
|
22317
|
-
var
|
|
22368
|
+
var log38, REGISTRY_URL2, DEFAULT_TTL_HOURS, AgentCatalog;
|
|
22318
22369
|
var init_agent_catalog = __esm({
|
|
22319
22370
|
"src/core/agents/agent-catalog.ts"() {
|
|
22320
22371
|
"use strict";
|
|
@@ -22322,7 +22373,7 @@ var init_agent_catalog = __esm({
|
|
|
22322
22373
|
init_agent_installer();
|
|
22323
22374
|
init_agent_dependencies();
|
|
22324
22375
|
init_log();
|
|
22325
|
-
|
|
22376
|
+
log38 = createChildLogger({ module: "agent-catalog" });
|
|
22326
22377
|
REGISTRY_URL2 = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
|
|
22327
22378
|
DEFAULT_TTL_HOURS = 24;
|
|
22328
22379
|
AgentCatalog = class {
|
|
@@ -22343,7 +22394,7 @@ var init_agent_catalog = __esm({
|
|
|
22343
22394
|
// --- Registry ---
|
|
22344
22395
|
async fetchRegistry() {
|
|
22345
22396
|
try {
|
|
22346
|
-
|
|
22397
|
+
log38.info("Fetching agent registry from CDN...");
|
|
22347
22398
|
const response = await fetch(REGISTRY_URL2);
|
|
22348
22399
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
22349
22400
|
const data = await response.json();
|
|
@@ -22355,9 +22406,9 @@ var init_agent_catalog = __esm({
|
|
|
22355
22406
|
};
|
|
22356
22407
|
fs44.mkdirSync(path48.dirname(this.cachePath), { recursive: true });
|
|
22357
22408
|
fs44.writeFileSync(this.cachePath, JSON.stringify(cache, null, 2), { mode: 384 });
|
|
22358
|
-
|
|
22409
|
+
log38.info({ count: this.registryAgents.length }, "Registry updated");
|
|
22359
22410
|
} catch (err) {
|
|
22360
|
-
|
|
22411
|
+
log38.warn({ err }, "Failed to fetch registry, using cached data");
|
|
22361
22412
|
}
|
|
22362
22413
|
}
|
|
22363
22414
|
async refreshRegistryIfStale() {
|
|
@@ -22518,7 +22569,7 @@ var init_agent_catalog = __esm({
|
|
|
22518
22569
|
}
|
|
22519
22570
|
}
|
|
22520
22571
|
if (changed) {
|
|
22521
|
-
|
|
22572
|
+
log38.info("Enriched installed agents with registry data");
|
|
22522
22573
|
}
|
|
22523
22574
|
}
|
|
22524
22575
|
isCacheStale() {
|
|
@@ -22538,11 +22589,11 @@ var init_agent_catalog = __esm({
|
|
|
22538
22589
|
const raw = JSON.parse(fs44.readFileSync(this.cachePath, "utf-8"));
|
|
22539
22590
|
if (raw.data?.agents) {
|
|
22540
22591
|
this.registryAgents = raw.data.agents;
|
|
22541
|
-
|
|
22592
|
+
log38.debug({ count: this.registryAgents.length }, "Loaded registry from cache");
|
|
22542
22593
|
return;
|
|
22543
22594
|
}
|
|
22544
22595
|
} catch {
|
|
22545
|
-
|
|
22596
|
+
log38.warn("Failed to load registry cache");
|
|
22546
22597
|
}
|
|
22547
22598
|
}
|
|
22548
22599
|
try {
|
|
@@ -22555,13 +22606,13 @@ var init_agent_catalog = __esm({
|
|
|
22555
22606
|
if (fs44.existsSync(candidate)) {
|
|
22556
22607
|
const raw = JSON.parse(fs44.readFileSync(candidate, "utf-8"));
|
|
22557
22608
|
this.registryAgents = raw.agents ?? [];
|
|
22558
|
-
|
|
22609
|
+
log38.debug({ count: this.registryAgents.length }, "Loaded registry from bundled snapshot");
|
|
22559
22610
|
return;
|
|
22560
22611
|
}
|
|
22561
22612
|
}
|
|
22562
|
-
|
|
22613
|
+
log38.warn("No registry data available (no cache, no snapshot)");
|
|
22563
22614
|
} catch {
|
|
22564
|
-
|
|
22615
|
+
log38.warn("Failed to load bundled registry snapshot");
|
|
22565
22616
|
}
|
|
22566
22617
|
}
|
|
22567
22618
|
};
|
|
@@ -22947,7 +22998,7 @@ function createPluginContext(opts) {
|
|
|
22947
22998
|
}
|
|
22948
22999
|
};
|
|
22949
23000
|
const baseLog = opts.log ?? noopLog;
|
|
22950
|
-
const
|
|
23001
|
+
const log47 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
|
|
22951
23002
|
const storageImpl = new PluginStorageImpl(storagePath);
|
|
22952
23003
|
const storage = {
|
|
22953
23004
|
async get(key) {
|
|
@@ -22974,7 +23025,7 @@ function createPluginContext(opts) {
|
|
|
22974
23025
|
const ctx = {
|
|
22975
23026
|
pluginName,
|
|
22976
23027
|
pluginConfig,
|
|
22977
|
-
log:
|
|
23028
|
+
log: log47,
|
|
22978
23029
|
storage,
|
|
22979
23030
|
on(event, handler) {
|
|
22980
23031
|
requirePermission(permissions, "events:read", "on()");
|
|
@@ -23009,7 +23060,7 @@ function createPluginContext(opts) {
|
|
|
23009
23060
|
const registry = serviceRegistry.get("command-registry");
|
|
23010
23061
|
if (registry && typeof registry.register === "function") {
|
|
23011
23062
|
registry.register(def, pluginName);
|
|
23012
|
-
|
|
23063
|
+
log47.debug(`Command '/${def.name}' registered`);
|
|
23013
23064
|
}
|
|
23014
23065
|
},
|
|
23015
23066
|
async sendMessage(_sessionId, _content) {
|
|
@@ -23052,7 +23103,7 @@ function createPluginContext(opts) {
|
|
|
23052
23103
|
const registry = serviceRegistry.get("field-registry");
|
|
23053
23104
|
if (registry && typeof registry.register === "function") {
|
|
23054
23105
|
registry.register(pluginName, fields);
|
|
23055
|
-
|
|
23106
|
+
log47.debug(`Registered ${fields.length} editable field(s) for ${pluginName}`);
|
|
23056
23107
|
}
|
|
23057
23108
|
},
|
|
23058
23109
|
get sessions() {
|
|
@@ -23384,12 +23435,12 @@ var init_lifecycle_manager = __esm({
|
|
|
23384
23435
|
});
|
|
23385
23436
|
|
|
23386
23437
|
// src/core/menu-registry.ts
|
|
23387
|
-
var
|
|
23438
|
+
var log39, MenuRegistry;
|
|
23388
23439
|
var init_menu_registry = __esm({
|
|
23389
23440
|
"src/core/menu-registry.ts"() {
|
|
23390
23441
|
"use strict";
|
|
23391
23442
|
init_log();
|
|
23392
|
-
|
|
23443
|
+
log39 = createChildLogger({ module: "menu-registry" });
|
|
23393
23444
|
MenuRegistry = class {
|
|
23394
23445
|
items = /* @__PURE__ */ new Map();
|
|
23395
23446
|
register(item) {
|
|
@@ -23408,7 +23459,7 @@ var init_menu_registry = __esm({
|
|
|
23408
23459
|
try {
|
|
23409
23460
|
return item.visible();
|
|
23410
23461
|
} catch (err) {
|
|
23411
|
-
|
|
23462
|
+
log39.warn({ err, id: item.id }, "MenuItem visible() threw, hiding item");
|
|
23412
23463
|
return false;
|
|
23413
23464
|
}
|
|
23414
23465
|
}).sort((a, b) => a.priority - b.priority);
|
|
@@ -23481,13 +23532,13 @@ Talk to users like a helpful assistant, not a CLI manual.`;
|
|
|
23481
23532
|
});
|
|
23482
23533
|
|
|
23483
23534
|
// src/core/assistant/assistant-registry.ts
|
|
23484
|
-
var
|
|
23535
|
+
var log40, AssistantRegistry;
|
|
23485
23536
|
var init_assistant_registry = __esm({
|
|
23486
23537
|
"src/core/assistant/assistant-registry.ts"() {
|
|
23487
23538
|
"use strict";
|
|
23488
23539
|
init_log();
|
|
23489
23540
|
init_prompt_constants();
|
|
23490
|
-
|
|
23541
|
+
log40 = createChildLogger({ module: "assistant-registry" });
|
|
23491
23542
|
AssistantRegistry = class {
|
|
23492
23543
|
sections = /* @__PURE__ */ new Map();
|
|
23493
23544
|
_instanceRoot = "";
|
|
@@ -23497,7 +23548,7 @@ var init_assistant_registry = __esm({
|
|
|
23497
23548
|
}
|
|
23498
23549
|
register(section) {
|
|
23499
23550
|
if (this.sections.has(section.id)) {
|
|
23500
|
-
|
|
23551
|
+
log40.warn({ id: section.id }, "Assistant section overwritten");
|
|
23501
23552
|
}
|
|
23502
23553
|
this.sections.set(section.id, section);
|
|
23503
23554
|
}
|
|
@@ -23522,7 +23573,7 @@ ${context}`);
|
|
|
23522
23573
|
parts.push("```bash\n" + cmds + "\n```");
|
|
23523
23574
|
}
|
|
23524
23575
|
} catch (err) {
|
|
23525
|
-
|
|
23576
|
+
log40.warn({ err, sectionId: section.id }, "Assistant section buildContext() failed, skipping");
|
|
23526
23577
|
}
|
|
23527
23578
|
}
|
|
23528
23579
|
parts.push(buildAssistantGuidelines(this._instanceRoot));
|
|
@@ -23533,12 +23584,12 @@ ${context}`);
|
|
|
23533
23584
|
});
|
|
23534
23585
|
|
|
23535
23586
|
// src/core/assistant/assistant-manager.ts
|
|
23536
|
-
var
|
|
23587
|
+
var log41, AssistantManager;
|
|
23537
23588
|
var init_assistant_manager = __esm({
|
|
23538
23589
|
"src/core/assistant/assistant-manager.ts"() {
|
|
23539
23590
|
"use strict";
|
|
23540
23591
|
init_log();
|
|
23541
|
-
|
|
23592
|
+
log41 = createChildLogger({ module: "assistant-manager" });
|
|
23542
23593
|
AssistantManager = class {
|
|
23543
23594
|
constructor(core, registry) {
|
|
23544
23595
|
this.core = core;
|
|
@@ -23559,7 +23610,7 @@ var init_assistant_manager = __esm({
|
|
|
23559
23610
|
this.sessions.set(channelId, session);
|
|
23560
23611
|
const systemPrompt = this.registry.buildSystemPrompt(channelId);
|
|
23561
23612
|
this.pendingSystemPrompts.set(channelId, systemPrompt);
|
|
23562
|
-
|
|
23613
|
+
log41.info({ sessionId: session.id, channelId }, "Assistant spawned (system prompt deferred)");
|
|
23563
23614
|
return session;
|
|
23564
23615
|
}
|
|
23565
23616
|
get(channelId) {
|
|
@@ -23805,7 +23856,7 @@ var init_core_items = __esm({
|
|
|
23805
23856
|
import path51 from "path";
|
|
23806
23857
|
import os23 from "os";
|
|
23807
23858
|
import { nanoid as nanoid5 } from "nanoid";
|
|
23808
|
-
var
|
|
23859
|
+
var log42, OpenACPCore;
|
|
23809
23860
|
var init_core = __esm({
|
|
23810
23861
|
"src/core/core.ts"() {
|
|
23811
23862
|
"use strict";
|
|
@@ -23829,7 +23880,7 @@ var init_core = __esm({
|
|
|
23829
23880
|
init_middleware_chain();
|
|
23830
23881
|
init_error_tracker();
|
|
23831
23882
|
init_log();
|
|
23832
|
-
|
|
23883
|
+
log42 = createChildLogger({ module: "core" });
|
|
23833
23884
|
OpenACPCore = class {
|
|
23834
23885
|
configManager;
|
|
23835
23886
|
agentCatalog;
|
|
@@ -23944,7 +23995,7 @@ var init_core = __esm({
|
|
|
23944
23995
|
if (configPath === "logging.level" && typeof value === "string") {
|
|
23945
23996
|
const { setLogLevel: setLogLevel2 } = await Promise.resolve().then(() => (init_log(), log_exports));
|
|
23946
23997
|
setLogLevel2(value);
|
|
23947
|
-
|
|
23998
|
+
log42.info({ level: value }, "Log level changed at runtime");
|
|
23948
23999
|
}
|
|
23949
24000
|
if (configPath.startsWith("speech.")) {
|
|
23950
24001
|
const speechSvc = this.lifecycleManager.serviceRegistry.get("speech");
|
|
@@ -23968,7 +24019,7 @@ var init_core = __esm({
|
|
|
23968
24019
|
}
|
|
23969
24020
|
};
|
|
23970
24021
|
speechSvc.refreshProviders(newSpeechConfig);
|
|
23971
|
-
|
|
24022
|
+
log42.info("Speech service config updated at runtime (from plugin settings)");
|
|
23972
24023
|
}
|
|
23973
24024
|
}
|
|
23974
24025
|
}
|
|
@@ -23998,14 +24049,14 @@ var init_core = __esm({
|
|
|
23998
24049
|
}
|
|
23999
24050
|
async start() {
|
|
24000
24051
|
this.agentCatalog.refreshRegistryIfStale().catch((err) => {
|
|
24001
|
-
|
|
24052
|
+
log42.warn({ err }, "Background registry refresh failed");
|
|
24002
24053
|
});
|
|
24003
24054
|
const failures = [];
|
|
24004
24055
|
for (const [name, adapter] of this.adapters.entries()) {
|
|
24005
24056
|
try {
|
|
24006
24057
|
await adapter.start();
|
|
24007
24058
|
} catch (err) {
|
|
24008
|
-
|
|
24059
|
+
log42.error({ err, adapter: name }, `Adapter "${name}" failed to start`);
|
|
24009
24060
|
failures.push({ name, error: err });
|
|
24010
24061
|
}
|
|
24011
24062
|
}
|
|
@@ -24053,7 +24104,7 @@ var init_core = __esm({
|
|
|
24053
24104
|
}
|
|
24054
24105
|
// --- Message Routing ---
|
|
24055
24106
|
async handleMessage(message) {
|
|
24056
|
-
|
|
24107
|
+
log42.debug(
|
|
24057
24108
|
{
|
|
24058
24109
|
channelId: message.channelId,
|
|
24059
24110
|
threadId: message.threadId,
|
|
@@ -24072,7 +24123,7 @@ var init_core = __esm({
|
|
|
24072
24123
|
}
|
|
24073
24124
|
const access2 = await this.securityGuard.checkAccess(message);
|
|
24074
24125
|
if (!access2.allowed) {
|
|
24075
|
-
|
|
24126
|
+
log42.warn({ userId: message.userId, reason: access2.reason }, "Access denied");
|
|
24076
24127
|
if (access2.reason.includes("Session limit")) {
|
|
24077
24128
|
const adapter = this.adapters.get(message.channelId);
|
|
24078
24129
|
if (adapter) {
|
|
@@ -24086,7 +24137,7 @@ var init_core = __esm({
|
|
|
24086
24137
|
}
|
|
24087
24138
|
let session = await this.sessionFactory.getOrResume(message.channelId, message.threadId);
|
|
24088
24139
|
if (!session) {
|
|
24089
|
-
|
|
24140
|
+
log42.warn(
|
|
24090
24141
|
{ channelId: message.channelId, threadId: message.threadId },
|
|
24091
24142
|
"No session found for thread (in-memory miss + lazy resume returned null)"
|
|
24092
24143
|
);
|
|
@@ -24184,7 +24235,7 @@ ${text6}`;
|
|
|
24184
24235
|
const bridge = this.createBridge(session, adapter, session.channelId);
|
|
24185
24236
|
bridge.connect();
|
|
24186
24237
|
adapter.flushPendingSkillCommands?.(session.id).catch((err) => {
|
|
24187
|
-
|
|
24238
|
+
log42.warn({ err, sessionId: session.id }, "Failed to flush pending skill commands");
|
|
24188
24239
|
});
|
|
24189
24240
|
if (params.createThread && session.threadId) {
|
|
24190
24241
|
this.eventBus.emit("session:threadReady", {
|
|
@@ -24198,14 +24249,14 @@ ${text6}`;
|
|
|
24198
24249
|
session.agentInstance.onPermissionRequest = async (permRequest) => {
|
|
24199
24250
|
const allowOption = permRequest.options.find((o) => o.isAllow);
|
|
24200
24251
|
if (!allowOption) {
|
|
24201
|
-
|
|
24252
|
+
log42.warn(
|
|
24202
24253
|
{ sessionId: session.id, permissionId: permRequest.id, description: permRequest.description },
|
|
24203
24254
|
"Headless session has no allow option for permission request \u2014 skipping auto-approve, will time out"
|
|
24204
24255
|
);
|
|
24205
24256
|
return new Promise(() => {
|
|
24206
24257
|
});
|
|
24207
24258
|
}
|
|
24208
|
-
|
|
24259
|
+
log42.warn(
|
|
24209
24260
|
{ sessionId: session.id, permissionId: permRequest.id, option: allowOption.id },
|
|
24210
24261
|
`Auto-approving permission "${permRequest.description}" for headless session \u2014 no adapter connected`
|
|
24211
24262
|
);
|
|
@@ -24217,7 +24268,7 @@ ${text6}`;
|
|
|
24217
24268
|
notificationManager: this.notificationManager,
|
|
24218
24269
|
tunnelService: this._tunnelService
|
|
24219
24270
|
});
|
|
24220
|
-
|
|
24271
|
+
log42.info(
|
|
24221
24272
|
{ sessionId: session.id, agentName: params.agentName },
|
|
24222
24273
|
"Session created via pipeline"
|
|
24223
24274
|
);
|
|
@@ -25208,7 +25259,7 @@ function registerCategoryCommand(registry, core, category, commandName) {
|
|
|
25208
25259
|
core.eventBus.emit("session:configChanged", { sessionId: session.id });
|
|
25209
25260
|
return { type: "text", text: labels.successMsg(match.name, configOption.name) };
|
|
25210
25261
|
} catch (err) {
|
|
25211
|
-
|
|
25262
|
+
log43.error({ err, commandName, configId: configOption.id }, "setConfigOption failed");
|
|
25212
25263
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25213
25264
|
return { type: "error", message: `Could not change ${commandName}: ${msg}` };
|
|
25214
25265
|
}
|
|
@@ -25273,7 +25324,7 @@ function registerDangerousCommand(registry, core) {
|
|
|
25273
25324
|
text: wantOn ? "\u2620\uFE0F **Bypass Permissions enabled** \u2014 all permission requests will be auto-approved. The agent can run any action without asking." : "\u{1F510} **Bypass Permissions disabled** \u2014 you will be asked to approve risky actions."
|
|
25274
25325
|
};
|
|
25275
25326
|
} catch (err) {
|
|
25276
|
-
|
|
25327
|
+
log43.error({ err }, "setConfigOption failed (bypass toggle)");
|
|
25277
25328
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25278
25329
|
return { type: "error", message: `Could not toggle bypass: ${msg}` };
|
|
25279
25330
|
}
|
|
@@ -25297,14 +25348,14 @@ function registerConfigCommands(registry, _core) {
|
|
|
25297
25348
|
registerCategoryCommand(registry, core, "thought_level", "thought");
|
|
25298
25349
|
registerDangerousCommand(registry, core);
|
|
25299
25350
|
}
|
|
25300
|
-
var
|
|
25351
|
+
var log43, CATEGORY_LABELS;
|
|
25301
25352
|
var init_config6 = __esm({
|
|
25302
25353
|
"src/core/commands/config.ts"() {
|
|
25303
25354
|
"use strict";
|
|
25304
25355
|
init_log();
|
|
25305
25356
|
init_bypass_detection();
|
|
25306
25357
|
init_bypass_detection();
|
|
25307
|
-
|
|
25358
|
+
log43 = createChildLogger({ module: "commands/config" });
|
|
25308
25359
|
CATEGORY_LABELS = {
|
|
25309
25360
|
mode: {
|
|
25310
25361
|
menuTitle: (cur) => `Choose session mode (current: ${cur})`,
|
|
@@ -25716,7 +25767,7 @@ function installAutoStart(logDir2) {
|
|
|
25716
25767
|
fs46.mkdirSync(dir, { recursive: true });
|
|
25717
25768
|
fs46.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
25718
25769
|
execFileSync8("launchctl", ["load", LAUNCHD_PLIST_PATH], { stdio: "pipe" });
|
|
25719
|
-
|
|
25770
|
+
log44.info("LaunchAgent installed");
|
|
25720
25771
|
return { success: true };
|
|
25721
25772
|
}
|
|
25722
25773
|
if (process.platform === "linux") {
|
|
@@ -25726,13 +25777,13 @@ function installAutoStart(logDir2) {
|
|
|
25726
25777
|
fs46.writeFileSync(SYSTEMD_SERVICE_PATH, unit);
|
|
25727
25778
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25728
25779
|
execFileSync8("systemctl", ["--user", "enable", "openacp"], { stdio: "pipe" });
|
|
25729
|
-
|
|
25780
|
+
log44.info("systemd user service installed");
|
|
25730
25781
|
return { success: true };
|
|
25731
25782
|
}
|
|
25732
25783
|
return { success: false, error: "Unsupported platform" };
|
|
25733
25784
|
} catch (e) {
|
|
25734
25785
|
const msg = e.message;
|
|
25735
|
-
|
|
25786
|
+
log44.error({ err: msg }, "Failed to install auto-start");
|
|
25736
25787
|
return { success: false, error: msg };
|
|
25737
25788
|
}
|
|
25738
25789
|
}
|
|
@@ -25748,7 +25799,7 @@ function uninstallAutoStart() {
|
|
|
25748
25799
|
} catch {
|
|
25749
25800
|
}
|
|
25750
25801
|
fs46.unlinkSync(LAUNCHD_PLIST_PATH);
|
|
25751
|
-
|
|
25802
|
+
log44.info("LaunchAgent removed");
|
|
25752
25803
|
}
|
|
25753
25804
|
return { success: true };
|
|
25754
25805
|
}
|
|
@@ -25760,14 +25811,14 @@ function uninstallAutoStart() {
|
|
|
25760
25811
|
}
|
|
25761
25812
|
fs46.unlinkSync(SYSTEMD_SERVICE_PATH);
|
|
25762
25813
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25763
|
-
|
|
25814
|
+
log44.info("systemd user service removed");
|
|
25764
25815
|
}
|
|
25765
25816
|
return { success: true };
|
|
25766
25817
|
}
|
|
25767
25818
|
return { success: false, error: "Unsupported platform" };
|
|
25768
25819
|
} catch (e) {
|
|
25769
25820
|
const msg = e.message;
|
|
25770
|
-
|
|
25821
|
+
log44.error({ err: msg }, "Failed to uninstall auto-start");
|
|
25771
25822
|
return { success: false, error: msg };
|
|
25772
25823
|
}
|
|
25773
25824
|
}
|
|
@@ -25780,12 +25831,12 @@ function isAutoStartInstalled() {
|
|
|
25780
25831
|
}
|
|
25781
25832
|
return false;
|
|
25782
25833
|
}
|
|
25783
|
-
var
|
|
25834
|
+
var log44, LAUNCHD_LABEL, LAUNCHD_PLIST_PATH, SYSTEMD_SERVICE_PATH;
|
|
25784
25835
|
var init_autostart = __esm({
|
|
25785
25836
|
"src/cli/autostart.ts"() {
|
|
25786
25837
|
"use strict";
|
|
25787
25838
|
init_log();
|
|
25788
|
-
|
|
25839
|
+
log44 = createChildLogger({ module: "autostart" });
|
|
25789
25840
|
LAUNCHD_LABEL = "com.openacp.daemon";
|
|
25790
25841
|
LAUNCHD_PLIST_PATH = path52.join(os24.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
25791
25842
|
SYSTEMD_SERVICE_PATH = path52.join(os24.homedir(), ".config", "systemd", "user", "openacp.service");
|
|
@@ -25888,7 +25939,7 @@ async function setupIntegrations() {
|
|
|
25888
25939
|
if (integration) {
|
|
25889
25940
|
for (const item of integration.items) {
|
|
25890
25941
|
const result = await item.install();
|
|
25891
|
-
for (const
|
|
25942
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
25892
25943
|
}
|
|
25893
25944
|
}
|
|
25894
25945
|
console.log("Claude CLI integration installed.\n");
|
|
@@ -26830,14 +26881,14 @@ async function runPostUpgradeChecks(config) {
|
|
|
26830
26881
|
const { ensureCloudflared: ensureCloudflared2 } = await Promise.resolve().then(() => (init_install_cloudflared(), install_cloudflared_exports));
|
|
26831
26882
|
await ensureCloudflared2();
|
|
26832
26883
|
} catch (err) {
|
|
26833
|
-
|
|
26884
|
+
log46.warn(
|
|
26834
26885
|
{ err: err.message },
|
|
26835
26886
|
"Could not install cloudflared. Tunnel may not work."
|
|
26836
26887
|
);
|
|
26837
26888
|
}
|
|
26838
26889
|
} else {
|
|
26839
26890
|
if (!commandExists(tunnelProvider)) {
|
|
26840
|
-
|
|
26891
|
+
log46.warn(
|
|
26841
26892
|
`Tunnel provider "${tunnelProvider}" is not installed. Install it or switch to cloudflare (free, auto-installed).`
|
|
26842
26893
|
);
|
|
26843
26894
|
}
|
|
@@ -26851,7 +26902,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26851
26902
|
if (integration) {
|
|
26852
26903
|
const allInstalled = integration.items.every((item) => item.isInstalled());
|
|
26853
26904
|
if (!allInstalled) {
|
|
26854
|
-
|
|
26905
|
+
log46.info(
|
|
26855
26906
|
'Claude CLI integration not installed. Run "openacp integrate claude" for session transfer + tunnel skill.'
|
|
26856
26907
|
);
|
|
26857
26908
|
}
|
|
@@ -26861,7 +26912,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26861
26912
|
const { ensureJq: ensureJq2 } = await Promise.resolve().then(() => (init_install_jq(), install_jq_exports));
|
|
26862
26913
|
await ensureJq2();
|
|
26863
26914
|
} catch (err) {
|
|
26864
|
-
|
|
26915
|
+
log46.warn(
|
|
26865
26916
|
{ err: err.message },
|
|
26866
26917
|
"Could not install jq. Handoff hooks may not work."
|
|
26867
26918
|
);
|
|
@@ -26871,7 +26922,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26871
26922
|
} catch {
|
|
26872
26923
|
}
|
|
26873
26924
|
if (!commandExists("unzip")) {
|
|
26874
|
-
|
|
26925
|
+
log46.warn(
|
|
26875
26926
|
"unzip is not installed. Some agent installations (binary distribution) may fail. Install: brew install unzip (macOS) or apt install unzip (Linux)"
|
|
26876
26927
|
);
|
|
26877
26928
|
}
|
|
@@ -26884,20 +26935,20 @@ async function runPostUpgradeChecks(config) {
|
|
|
26884
26935
|
(a) => a.distribution === "uvx"
|
|
26885
26936
|
);
|
|
26886
26937
|
if (hasUvxAgent && !commandExists("uvx")) {
|
|
26887
|
-
|
|
26938
|
+
log46.warn(
|
|
26888
26939
|
"uvx is not installed but you have Python-based agents. Install: pip install uv"
|
|
26889
26940
|
);
|
|
26890
26941
|
}
|
|
26891
26942
|
} catch {
|
|
26892
26943
|
}
|
|
26893
26944
|
}
|
|
26894
|
-
var
|
|
26945
|
+
var log46;
|
|
26895
26946
|
var init_post_upgrade = __esm({
|
|
26896
26947
|
"src/cli/post-upgrade.ts"() {
|
|
26897
26948
|
"use strict";
|
|
26898
26949
|
init_log();
|
|
26899
26950
|
init_agent_dependencies();
|
|
26900
|
-
|
|
26951
|
+
log46 = createChildLogger({ module: "post-upgrade" });
|
|
26901
26952
|
}
|
|
26902
26953
|
});
|
|
26903
26954
|
|
|
@@ -30552,7 +30603,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30552
30603
|
if (uninstall) {
|
|
30553
30604
|
console.log(`Removing ${agent}/${item.id}...`);
|
|
30554
30605
|
const result = await item.uninstall();
|
|
30555
|
-
for (const
|
|
30606
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
30556
30607
|
if (result.success) {
|
|
30557
30608
|
console.log(` ${item.name} removed.`);
|
|
30558
30609
|
} else {
|
|
@@ -30562,7 +30613,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30562
30613
|
} else {
|
|
30563
30614
|
console.log(`Installing ${agent}/${item.id}...`);
|
|
30564
30615
|
const result = await item.install();
|
|
30565
|
-
for (const
|
|
30616
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
30566
30617
|
if (result.success) {
|
|
30567
30618
|
console.log(` ${item.name} installed.`);
|
|
30568
30619
|
} else {
|