@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/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
|
|
|
@@ -14703,14 +14721,14 @@ var init_commands3 = __esm({
|
|
|
14703
14721
|
// src/plugins/telegram/permissions.ts
|
|
14704
14722
|
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
14705
14723
|
import { nanoid as nanoid2 } from "nanoid";
|
|
14706
|
-
var
|
|
14724
|
+
var log25, PermissionHandler;
|
|
14707
14725
|
var init_permissions = __esm({
|
|
14708
14726
|
"src/plugins/telegram/permissions.ts"() {
|
|
14709
14727
|
"use strict";
|
|
14710
14728
|
init_formatting();
|
|
14711
14729
|
init_topics2();
|
|
14712
14730
|
init_log();
|
|
14713
|
-
|
|
14731
|
+
log25 = createChildLogger({ module: "telegram-permissions" });
|
|
14714
14732
|
PermissionHandler = class {
|
|
14715
14733
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
14716
14734
|
this.bot = bot;
|
|
@@ -14770,7 +14788,7 @@ ${escapeHtml4(request.description)}`,
|
|
|
14770
14788
|
}
|
|
14771
14789
|
const session = this.getSession(pending.sessionId);
|
|
14772
14790
|
const isAllow = pending.options.find((o) => o.id === optionId)?.isAllow ?? false;
|
|
14773
|
-
|
|
14791
|
+
log25.info({ requestId: pending.requestId, optionId, isAllow }, "Permission responded");
|
|
14774
14792
|
if (session?.permissionGate.requestId === pending.requestId) {
|
|
14775
14793
|
session.permissionGate.resolve(optionId);
|
|
14776
14794
|
}
|
|
@@ -15224,7 +15242,7 @@ var init_display_spec_builder = __esm({
|
|
|
15224
15242
|
});
|
|
15225
15243
|
|
|
15226
15244
|
// src/plugins/telegram/activity.ts
|
|
15227
|
-
var
|
|
15245
|
+
var log26, THINKING_REFRESH_MS, THINKING_MAX_MS, ThinkingIndicator, ToolCard, ActivityTracker;
|
|
15228
15246
|
var init_activity = __esm({
|
|
15229
15247
|
"src/plugins/telegram/activity.ts"() {
|
|
15230
15248
|
"use strict";
|
|
@@ -15234,7 +15252,7 @@ var init_activity = __esm({
|
|
|
15234
15252
|
init_stream_accumulator();
|
|
15235
15253
|
init_stream_accumulator();
|
|
15236
15254
|
init_display_spec_builder();
|
|
15237
|
-
|
|
15255
|
+
log26 = createChildLogger({ module: "telegram:activity" });
|
|
15238
15256
|
THINKING_REFRESH_MS = 15e3;
|
|
15239
15257
|
THINKING_MAX_MS = 3 * 60 * 1e3;
|
|
15240
15258
|
ThinkingIndicator = class {
|
|
@@ -15275,7 +15293,7 @@ var init_activity = __esm({
|
|
|
15275
15293
|
}
|
|
15276
15294
|
}
|
|
15277
15295
|
} catch (err) {
|
|
15278
|
-
|
|
15296
|
+
log26.warn({ err }, "ThinkingIndicator.show() failed");
|
|
15279
15297
|
} finally {
|
|
15280
15298
|
this.sending = false;
|
|
15281
15299
|
}
|
|
@@ -15443,7 +15461,7 @@ var init_activity = __esm({
|
|
|
15443
15461
|
this.tracer?.log("telegram", { action: "telegram:delete:overflow", sessionId: this.sessionId, msgId: staleId });
|
|
15444
15462
|
}
|
|
15445
15463
|
} catch (err) {
|
|
15446
|
-
|
|
15464
|
+
log26.warn({ err }, "[ToolCard] send/edit failed");
|
|
15447
15465
|
}
|
|
15448
15466
|
}
|
|
15449
15467
|
};
|
|
@@ -15547,7 +15565,7 @@ var init_activity = __esm({
|
|
|
15547
15565
|
const entry = this.toolStateMap.merge(id, status, rawInput, content, viewerLinks, diffStats);
|
|
15548
15566
|
if (!existed || !entry) return;
|
|
15549
15567
|
if (viewerLinks || entry.viewerLinks) {
|
|
15550
|
-
|
|
15568
|
+
log26.debug({ toolId: id, status, hasIncomingLinks: !!viewerLinks, hasEntryLinks: !!entry.viewerLinks, entryLinks: entry.viewerLinks }, "toolUpdate: viewer links trace");
|
|
15551
15569
|
}
|
|
15552
15570
|
const spec = this.specBuilder.buildToolSpec(entry, this._outputMode, this.sessionContext);
|
|
15553
15571
|
this.toolCard.updateFromSpec(spec);
|
|
@@ -15974,13 +15992,13 @@ var init_draft_manager = __esm({
|
|
|
15974
15992
|
});
|
|
15975
15993
|
|
|
15976
15994
|
// src/plugins/telegram/skill-command-manager.ts
|
|
15977
|
-
var
|
|
15995
|
+
var log27, SkillCommandManager;
|
|
15978
15996
|
var init_skill_command_manager = __esm({
|
|
15979
15997
|
"src/plugins/telegram/skill-command-manager.ts"() {
|
|
15980
15998
|
"use strict";
|
|
15981
15999
|
init_commands3();
|
|
15982
16000
|
init_log();
|
|
15983
|
-
|
|
16001
|
+
log27 = createChildLogger({ module: "skill-commands" });
|
|
15984
16002
|
SkillCommandManager = class {
|
|
15985
16003
|
// sessionId → pinned msgId
|
|
15986
16004
|
constructor(bot, chatId, sendQueue, sessionManager) {
|
|
@@ -16046,7 +16064,7 @@ var init_skill_command_manager = __esm({
|
|
|
16046
16064
|
disable_notification: true
|
|
16047
16065
|
});
|
|
16048
16066
|
} catch (err) {
|
|
16049
|
-
|
|
16067
|
+
log27.error({ err, sessionId }, "Failed to send skill commands");
|
|
16050
16068
|
}
|
|
16051
16069
|
}
|
|
16052
16070
|
async cleanup(sessionId) {
|
|
@@ -16440,7 +16458,7 @@ function patchedFetch(input2, init) {
|
|
|
16440
16458
|
}
|
|
16441
16459
|
return fetch(input2, init);
|
|
16442
16460
|
}
|
|
16443
|
-
var
|
|
16461
|
+
var log28, TelegramAdapter;
|
|
16444
16462
|
var init_adapter2 = __esm({
|
|
16445
16463
|
"src/plugins/telegram/adapter.ts"() {
|
|
16446
16464
|
"use strict";
|
|
@@ -16459,7 +16477,7 @@ var init_adapter2 = __esm({
|
|
|
16459
16477
|
init_messaging_adapter();
|
|
16460
16478
|
init_renderer2();
|
|
16461
16479
|
init_output_mode_resolver();
|
|
16462
|
-
|
|
16480
|
+
log28 = createChildLogger({ module: "telegram" });
|
|
16463
16481
|
TelegramAdapter = class extends MessagingAdapter {
|
|
16464
16482
|
name = "telegram";
|
|
16465
16483
|
renderer = new TelegramRenderer();
|
|
@@ -16494,6 +16512,8 @@ var init_adapter2 = __esm({
|
|
|
16494
16512
|
controlMsgIds = /* @__PURE__ */ new Map();
|
|
16495
16513
|
_threadReadyHandler;
|
|
16496
16514
|
_configChangedHandler;
|
|
16515
|
+
/** Mutable ref passed to callbacks before topics are ready; updated in-place by initTopicDependentFeatures */
|
|
16516
|
+
_systemTopicIds = { notificationTopicId: 0, assistantTopicId: 0 };
|
|
16497
16517
|
/** True once topics are initialized and Phase 2 is complete */
|
|
16498
16518
|
_topicsInitialized = false;
|
|
16499
16519
|
/** Background watcher timer — cancelled on stop() or when topics succeed */
|
|
@@ -16584,7 +16604,7 @@ var init_adapter2 = __esm({
|
|
|
16584
16604
|
);
|
|
16585
16605
|
this.bot.catch((err) => {
|
|
16586
16606
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
16587
|
-
|
|
16607
|
+
log28.error({ err: rootCause }, "Telegram bot error");
|
|
16588
16608
|
});
|
|
16589
16609
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
16590
16610
|
const maxRetries = 3;
|
|
@@ -16602,7 +16622,7 @@ var init_adapter2 = __esm({
|
|
|
16602
16622
|
if (rateLimitedMethods.includes(method)) {
|
|
16603
16623
|
this.sendQueue.onRateLimited();
|
|
16604
16624
|
}
|
|
16605
|
-
|
|
16625
|
+
log28.warn(
|
|
16606
16626
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
16607
16627
|
"Rate limited by Telegram, retrying"
|
|
16608
16628
|
);
|
|
@@ -16761,20 +16781,57 @@ var init_adapter2 = __esm({
|
|
|
16761
16781
|
setupVerbosityCallbacks(this.bot, this.core);
|
|
16762
16782
|
setupIntegrateCallbacks(this.bot, this.core);
|
|
16763
16783
|
this.permissionHandler.setupCallbackHandler();
|
|
16784
|
+
setupAllCallbacks(
|
|
16785
|
+
this.bot,
|
|
16786
|
+
this.core,
|
|
16787
|
+
this.telegramConfig.chatId,
|
|
16788
|
+
this._systemTopicIds,
|
|
16789
|
+
() => {
|
|
16790
|
+
const assistant = this.core.assistantManager?.get("telegram");
|
|
16791
|
+
if (!assistant) return void 0;
|
|
16792
|
+
return {
|
|
16793
|
+
topicId: this.assistantTopicId,
|
|
16794
|
+
enqueuePrompt: (p2) => {
|
|
16795
|
+
const pending = this.core.assistantManager?.consumePendingSystemPrompt("telegram");
|
|
16796
|
+
const text6 = pending ? `${pending}
|
|
16797
|
+
|
|
16798
|
+
---
|
|
16799
|
+
|
|
16800
|
+
User message:
|
|
16801
|
+
${p2}` : p2;
|
|
16802
|
+
return assistant.enqueuePrompt(text6);
|
|
16803
|
+
}
|
|
16804
|
+
};
|
|
16805
|
+
},
|
|
16806
|
+
(sessionId, msgId) => {
|
|
16807
|
+
this.storeControlMsgId(sessionId, msgId);
|
|
16808
|
+
}
|
|
16809
|
+
);
|
|
16810
|
+
this.setupRoutes();
|
|
16764
16811
|
this.bot.start({
|
|
16765
16812
|
allowed_updates: ["message", "callback_query"],
|
|
16766
|
-
onStart: () =>
|
|
16813
|
+
onStart: () => log28.info({ chatId: this.telegramConfig.chatId }, "Telegram bot started")
|
|
16767
16814
|
});
|
|
16815
|
+
log28.info(
|
|
16816
|
+
{
|
|
16817
|
+
chatId: this.telegramConfig.chatId,
|
|
16818
|
+
notificationTopicId: this.telegramConfig.notificationTopicId,
|
|
16819
|
+
assistantTopicId: this.telegramConfig.assistantTopicId
|
|
16820
|
+
},
|
|
16821
|
+
"Telegram adapter: starting prerequisite check (existing topic IDs shown)"
|
|
16822
|
+
);
|
|
16768
16823
|
const { checkTopicsPrerequisites: checkTopicsPrerequisites2 } = await Promise.resolve().then(() => (init_validators(), validators_exports));
|
|
16769
16824
|
const prereqResult = await checkTopicsPrerequisites2(
|
|
16770
16825
|
this.telegramConfig.botToken,
|
|
16771
16826
|
this.telegramConfig.chatId
|
|
16772
16827
|
);
|
|
16773
16828
|
if (prereqResult.ok) {
|
|
16829
|
+
log28.info("Telegram adapter: prerequisites OK, initializing topic-dependent features");
|
|
16774
16830
|
await this.initTopicDependentFeatures();
|
|
16775
16831
|
} else {
|
|
16832
|
+
log28.warn({ issues: prereqResult.issues }, "Telegram adapter: prerequisites NOT met, starting watcher");
|
|
16776
16833
|
for (const issue of prereqResult.issues) {
|
|
16777
|
-
|
|
16834
|
+
log28.warn({ issue }, "Telegram prerequisite not met");
|
|
16778
16835
|
}
|
|
16779
16836
|
this.startPrerequisiteWatcher(prereqResult.issues);
|
|
16780
16837
|
}
|
|
@@ -16790,7 +16847,7 @@ var init_adapter2 = __esm({
|
|
|
16790
16847
|
} catch (err) {
|
|
16791
16848
|
if (attempt === maxRetries) throw err;
|
|
16792
16849
|
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
16793
|
-
|
|
16850
|
+
log28.warn(
|
|
16794
16851
|
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
16795
16852
|
`${label} failed, retrying in ${delay}ms`
|
|
16796
16853
|
);
|
|
@@ -16810,11 +16867,15 @@ var init_adapter2 = __esm({
|
|
|
16810
16867
|
}),
|
|
16811
16868
|
"setMyCommands"
|
|
16812
16869
|
).catch((err) => {
|
|
16813
|
-
|
|
16870
|
+
log28.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
16814
16871
|
});
|
|
16815
16872
|
}
|
|
16816
16873
|
async initTopicDependentFeatures() {
|
|
16817
16874
|
if (this._topicsInitialized) return;
|
|
16875
|
+
log28.info(
|
|
16876
|
+
{ notificationTopicId: this.telegramConfig.notificationTopicId, assistantTopicId: this.telegramConfig.assistantTopicId },
|
|
16877
|
+
"initTopicDependentFeatures: starting (existing IDs in config)"
|
|
16878
|
+
);
|
|
16818
16879
|
const topics = await this.retryWithBackoff(
|
|
16819
16880
|
() => ensureTopics(
|
|
16820
16881
|
this.bot,
|
|
@@ -16834,34 +16895,11 @@ var init_adapter2 = __esm({
|
|
|
16834
16895
|
);
|
|
16835
16896
|
this.notificationTopicId = topics.notificationTopicId;
|
|
16836
16897
|
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
|
-
}
|
|
16898
|
+
this._systemTopicIds.notificationTopicId = topics.notificationTopicId;
|
|
16899
|
+
this._systemTopicIds.assistantTopicId = topics.assistantTopicId;
|
|
16900
|
+
log28.info(
|
|
16901
|
+
{ notificationTopicId: this.notificationTopicId, assistantTopicId: this.assistantTopicId },
|
|
16902
|
+
"initTopicDependentFeatures: topics ready"
|
|
16865
16903
|
);
|
|
16866
16904
|
this._threadReadyHandler = ({ sessionId, channelId, threadId }) => {
|
|
16867
16905
|
if (channelId !== "telegram") return;
|
|
@@ -16890,7 +16928,7 @@ ${p2}` : p2;
|
|
|
16890
16928
|
).then((msg) => {
|
|
16891
16929
|
if (msg) this.storeControlMsgId(sessionId, msg.message_id);
|
|
16892
16930
|
}).catch((err) => {
|
|
16893
|
-
|
|
16931
|
+
log28.warn({ err, sessionId }, "Failed to send initial messages for new session");
|
|
16894
16932
|
});
|
|
16895
16933
|
};
|
|
16896
16934
|
this.core.eventBus.on("session:threadReady", this._threadReadyHandler);
|
|
@@ -16899,7 +16937,7 @@ ${p2}` : p2;
|
|
|
16899
16937
|
});
|
|
16900
16938
|
};
|
|
16901
16939
|
this.core.eventBus.on("session:configChanged", this._configChangedHandler);
|
|
16902
|
-
this.
|
|
16940
|
+
log28.info({ assistantTopicId: this.assistantTopicId }, "initTopicDependentFeatures: sending welcome message");
|
|
16903
16941
|
try {
|
|
16904
16942
|
const config = this.core.configManager.get();
|
|
16905
16943
|
const agents = this.core.agentManager.getAvailableAgents();
|
|
@@ -16921,16 +16959,17 @@ ${p2}` : p2;
|
|
|
16921
16959
|
this.core.lifecycleManager?.serviceRegistry?.get("menu-registry")
|
|
16922
16960
|
)
|
|
16923
16961
|
});
|
|
16962
|
+
log28.info("initTopicDependentFeatures: welcome message sent");
|
|
16924
16963
|
} catch (err) {
|
|
16925
|
-
|
|
16964
|
+
log28.warn({ err }, "Failed to send welcome message");
|
|
16926
16965
|
}
|
|
16927
16966
|
try {
|
|
16928
16967
|
await this.core.assistantManager.spawn("telegram", String(this.assistantTopicId));
|
|
16929
16968
|
} catch (err) {
|
|
16930
|
-
|
|
16969
|
+
log28.error({ err }, "Failed to spawn assistant");
|
|
16931
16970
|
}
|
|
16932
16971
|
this._topicsInitialized = true;
|
|
16933
|
-
|
|
16972
|
+
log28.info("Telegram adapter fully initialized");
|
|
16934
16973
|
}
|
|
16935
16974
|
startPrerequisiteWatcher(issues) {
|
|
16936
16975
|
const setupMessage = `\u26A0\uFE0F <b>OpenACP needs setup before it can start.</b>
|
|
@@ -16941,7 +16980,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16941
16980
|
this.bot.api.sendMessage(this.telegramConfig.chatId, setupMessage, {
|
|
16942
16981
|
parse_mode: "HTML"
|
|
16943
16982
|
}).catch((err) => {
|
|
16944
|
-
|
|
16983
|
+
log28.warn({ err }, "Failed to send setup guidance to General topic");
|
|
16945
16984
|
});
|
|
16946
16985
|
const schedule = [5e3, 1e4, 3e4];
|
|
16947
16986
|
let attempt = 1;
|
|
@@ -16954,7 +16993,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16954
16993
|
);
|
|
16955
16994
|
if (result.ok) {
|
|
16956
16995
|
this._prerequisiteWatcher = null;
|
|
16957
|
-
|
|
16996
|
+
log28.info("Prerequisites met \u2014 completing Telegram adapter initialization");
|
|
16958
16997
|
try {
|
|
16959
16998
|
await this.initTopicDependentFeatures();
|
|
16960
16999
|
await this.bot.api.sendMessage(
|
|
@@ -16963,11 +17002,11 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16963
17002
|
{ parse_mode: "HTML" }
|
|
16964
17003
|
);
|
|
16965
17004
|
} catch (err) {
|
|
16966
|
-
|
|
17005
|
+
log28.error({ err }, "Failed to complete initialization after prerequisites met");
|
|
16967
17006
|
}
|
|
16968
17007
|
return;
|
|
16969
17008
|
}
|
|
16970
|
-
|
|
17009
|
+
log28.debug({ issues: result.issues }, "Prerequisites not yet met, retrying");
|
|
16971
17010
|
const delay = schedule[Math.min(attempt, schedule.length - 1)];
|
|
16972
17011
|
attempt++;
|
|
16973
17012
|
this._prerequisiteWatcher = setTimeout(retry, delay);
|
|
@@ -16993,7 +17032,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16993
17032
|
}
|
|
16994
17033
|
this.sendQueue.clear();
|
|
16995
17034
|
await this.bot.stop();
|
|
16996
|
-
|
|
17035
|
+
log28.info("Telegram bot stopped");
|
|
16997
17036
|
}
|
|
16998
17037
|
// --- CommandRegistry response rendering ---
|
|
16999
17038
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -17110,7 +17149,7 @@ ${lines.join("\n")}`;
|
|
|
17110
17149
|
threadId: String(threadId),
|
|
17111
17150
|
userId: String(ctx.from.id),
|
|
17112
17151
|
text: forwardText
|
|
17113
|
-
}).catch((err) =>
|
|
17152
|
+
}).catch((err) => log28.error({ err }, "handleMessage error"));
|
|
17114
17153
|
});
|
|
17115
17154
|
this.bot.on("message:photo", async (ctx) => {
|
|
17116
17155
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -17199,7 +17238,7 @@ ${lines.join("\n")}`;
|
|
|
17199
17238
|
if (session.archiving) return;
|
|
17200
17239
|
const threadId = Number(session.threadId);
|
|
17201
17240
|
if (!threadId || isNaN(threadId)) {
|
|
17202
|
-
|
|
17241
|
+
log28.warn(
|
|
17203
17242
|
{ sessionId, threadId: session.threadId },
|
|
17204
17243
|
"Session has no valid threadId, skipping message"
|
|
17205
17244
|
);
|
|
@@ -17215,7 +17254,7 @@ ${lines.join("\n")}`;
|
|
|
17215
17254
|
this._sessionThreadIds.delete(sessionId);
|
|
17216
17255
|
}
|
|
17217
17256
|
}).catch((err) => {
|
|
17218
|
-
|
|
17257
|
+
log28.warn({ err, sessionId }, "Dispatch queue error");
|
|
17219
17258
|
});
|
|
17220
17259
|
this._dispatchQueues.set(sessionId, next);
|
|
17221
17260
|
await next;
|
|
@@ -17337,7 +17376,7 @@ ${lines.join("\n")}`;
|
|
|
17337
17376
|
);
|
|
17338
17377
|
usageMsgId = result?.message_id;
|
|
17339
17378
|
} catch (err) {
|
|
17340
|
-
|
|
17379
|
+
log28.warn({ err, sessionId }, "Failed to send usage message");
|
|
17341
17380
|
}
|
|
17342
17381
|
if (this.notificationTopicId && sessionId !== this.core.assistantManager?.get("telegram")?.id) {
|
|
17343
17382
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -17365,7 +17404,7 @@ Task completed.
|
|
|
17365
17404
|
if (!content.attachment) return;
|
|
17366
17405
|
const { attachment } = content;
|
|
17367
17406
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
17368
|
-
|
|
17407
|
+
log28.warn(
|
|
17369
17408
|
{
|
|
17370
17409
|
sessionId,
|
|
17371
17410
|
fileName: attachment.fileName,
|
|
@@ -17409,7 +17448,7 @@ Task completed.
|
|
|
17409
17448
|
);
|
|
17410
17449
|
}
|
|
17411
17450
|
} catch (err) {
|
|
17412
|
-
|
|
17451
|
+
log28.error(
|
|
17413
17452
|
{ err, sessionId, fileName: attachment.fileName },
|
|
17414
17453
|
"Failed to send attachment"
|
|
17415
17454
|
);
|
|
@@ -17508,7 +17547,7 @@ Task completed.
|
|
|
17508
17547
|
}
|
|
17509
17548
|
async sendPermissionRequest(sessionId, request) {
|
|
17510
17549
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
17511
|
-
|
|
17550
|
+
log28.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
17512
17551
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
17513
17552
|
if (!session) return;
|
|
17514
17553
|
await this.sendQueue.enqueue(
|
|
@@ -17518,7 +17557,7 @@ Task completed.
|
|
|
17518
17557
|
async sendNotification(notification) {
|
|
17519
17558
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
17520
17559
|
if (notification.sessionId === this.core.assistantManager?.get("telegram")?.id) return;
|
|
17521
|
-
|
|
17560
|
+
log28.info(
|
|
17522
17561
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
17523
17562
|
"Notification sent"
|
|
17524
17563
|
);
|
|
@@ -17557,7 +17596,7 @@ Task completed.
|
|
|
17557
17596
|
}
|
|
17558
17597
|
async createSessionThread(sessionId, name) {
|
|
17559
17598
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
17560
|
-
|
|
17599
|
+
log28.info({ sessionId, name }, "Session topic created");
|
|
17561
17600
|
return String(
|
|
17562
17601
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
17563
17602
|
);
|
|
@@ -17568,7 +17607,7 @@ Task completed.
|
|
|
17568
17607
|
if (!session) return;
|
|
17569
17608
|
const threadId = Number(session.threadId);
|
|
17570
17609
|
if (!threadId) {
|
|
17571
|
-
|
|
17610
|
+
log28.debug({ sessionId, newName }, "Cannot rename thread \u2014 threadId not set yet");
|
|
17572
17611
|
return;
|
|
17573
17612
|
}
|
|
17574
17613
|
await renameSessionTopic(
|
|
@@ -17587,7 +17626,7 @@ Task completed.
|
|
|
17587
17626
|
try {
|
|
17588
17627
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
17589
17628
|
} catch (err) {
|
|
17590
|
-
|
|
17629
|
+
log28.warn(
|
|
17591
17630
|
{ err, sessionId, topicId },
|
|
17592
17631
|
"Failed to delete forum topic (may already be deleted)"
|
|
17593
17632
|
);
|
|
@@ -17631,7 +17670,7 @@ Task completed.
|
|
|
17631
17670
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
17632
17671
|
return { buffer, filePath: file.file_path };
|
|
17633
17672
|
} catch (err) {
|
|
17634
|
-
|
|
17673
|
+
log28.error({ err }, "Failed to download file from Telegram");
|
|
17635
17674
|
return null;
|
|
17636
17675
|
}
|
|
17637
17676
|
}
|
|
@@ -17652,7 +17691,7 @@ Task completed.
|
|
|
17652
17691
|
try {
|
|
17653
17692
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
17654
17693
|
} catch (err) {
|
|
17655
|
-
|
|
17694
|
+
log28.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
17656
17695
|
fileName = "voice.ogg";
|
|
17657
17696
|
mimeType = "audio/ogg";
|
|
17658
17697
|
originalFilePath = void 0;
|
|
@@ -17684,7 +17723,7 @@ Task completed.
|
|
|
17684
17723
|
userId: String(userId),
|
|
17685
17724
|
text: text6,
|
|
17686
17725
|
attachments: [att]
|
|
17687
|
-
}).catch((err) =>
|
|
17726
|
+
}).catch((err) => log28.error({ err }, "handleMessage error"));
|
|
17688
17727
|
}
|
|
17689
17728
|
async cleanupSkillCommands(sessionId) {
|
|
17690
17729
|
this._pendingSkillCommands.delete(sessionId);
|
|
@@ -19063,7 +19102,7 @@ function resolveAgentCommand(cmd) {
|
|
|
19063
19102
|
}
|
|
19064
19103
|
return { command: cmd, args: [] };
|
|
19065
19104
|
}
|
|
19066
|
-
var
|
|
19105
|
+
var log30, AgentInstance;
|
|
19067
19106
|
var init_agent_instance = __esm({
|
|
19068
19107
|
"src/core/agents/agent-instance.ts"() {
|
|
19069
19108
|
"use strict";
|
|
@@ -19077,7 +19116,7 @@ var init_agent_instance = __esm({
|
|
|
19077
19116
|
init_mcp_manager();
|
|
19078
19117
|
init_debug_tracer();
|
|
19079
19118
|
init_log();
|
|
19080
|
-
|
|
19119
|
+
log30 = createChildLogger({ module: "agent-instance" });
|
|
19081
19120
|
AgentInstance = class _AgentInstance extends TypedEmitter {
|
|
19082
19121
|
connection;
|
|
19083
19122
|
child;
|
|
@@ -19107,7 +19146,7 @@ var init_agent_instance = __esm({
|
|
|
19107
19146
|
static async spawnSubprocess(agentDef, workingDirectory) {
|
|
19108
19147
|
const instance = new _AgentInstance(agentDef.name);
|
|
19109
19148
|
const resolved = resolveAgentCommand(agentDef.command);
|
|
19110
|
-
|
|
19149
|
+
log30.debug(
|
|
19111
19150
|
{
|
|
19112
19151
|
agentName: agentDef.name,
|
|
19113
19152
|
command: resolved.command,
|
|
@@ -19192,14 +19231,14 @@ var init_agent_instance = __esm({
|
|
|
19192
19231
|
}
|
|
19193
19232
|
});
|
|
19194
19233
|
if (initResponse.protocolVersion !== PROTOCOL_VERSION) {
|
|
19195
|
-
|
|
19234
|
+
log30.warn(
|
|
19196
19235
|
{ expected: PROTOCOL_VERSION, got: initResponse.protocolVersion },
|
|
19197
19236
|
"ACP protocol version mismatch \u2014 some features may not work correctly"
|
|
19198
19237
|
);
|
|
19199
19238
|
}
|
|
19200
19239
|
instance.promptCapabilities = initResponse.agentCapabilities?.promptCapabilities;
|
|
19201
19240
|
instance.agentCapabilities = initResponse.agentCapabilities;
|
|
19202
|
-
|
|
19241
|
+
log30.info(
|
|
19203
19242
|
{ promptCapabilities: instance.promptCapabilities ?? {} },
|
|
19204
19243
|
"Agent prompt capabilities"
|
|
19205
19244
|
);
|
|
@@ -19208,7 +19247,7 @@ var init_agent_instance = __esm({
|
|
|
19208
19247
|
setupCrashDetection() {
|
|
19209
19248
|
this.child.on("exit", (code, signal) => {
|
|
19210
19249
|
if (this._destroying) return;
|
|
19211
|
-
|
|
19250
|
+
log30.info(
|
|
19212
19251
|
{ sessionId: this.sessionId, exitCode: code, signal },
|
|
19213
19252
|
"Agent process exited"
|
|
19214
19253
|
);
|
|
@@ -19224,11 +19263,11 @@ ${stderr}`
|
|
|
19224
19263
|
}
|
|
19225
19264
|
});
|
|
19226
19265
|
this.connection.closed.then(() => {
|
|
19227
|
-
|
|
19266
|
+
log30.debug({ sessionId: this.sessionId }, "ACP connection closed");
|
|
19228
19267
|
});
|
|
19229
19268
|
}
|
|
19230
19269
|
static async spawn(agentDef, workingDirectory, mcpServers) {
|
|
19231
|
-
|
|
19270
|
+
log30.debug(
|
|
19232
19271
|
{ agentName: agentDef.name, command: agentDef.command },
|
|
19233
19272
|
"Spawning agent"
|
|
19234
19273
|
);
|
|
@@ -19242,12 +19281,12 @@ ${stderr}`
|
|
|
19242
19281
|
cwd: workingDirectory,
|
|
19243
19282
|
mcpServers: resolvedMcp
|
|
19244
19283
|
});
|
|
19245
|
-
|
|
19284
|
+
log30.info(response, "newSession response");
|
|
19246
19285
|
instance.sessionId = response.sessionId;
|
|
19247
19286
|
instance.initialSessionResponse = response;
|
|
19248
19287
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19249
19288
|
instance.setupCrashDetection();
|
|
19250
|
-
|
|
19289
|
+
log30.info(
|
|
19251
19290
|
{
|
|
19252
19291
|
sessionId: response.sessionId,
|
|
19253
19292
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19259,7 +19298,7 @@ ${stderr}`
|
|
|
19259
19298
|
return instance;
|
|
19260
19299
|
}
|
|
19261
19300
|
static async resume(agentDef, workingDirectory, agentSessionId, mcpServers) {
|
|
19262
|
-
|
|
19301
|
+
log30.debug({ agentName: agentDef.name, agentSessionId }, "Resuming agent");
|
|
19263
19302
|
const spawnStart = Date.now();
|
|
19264
19303
|
const instance = await _AgentInstance.spawnSubprocess(
|
|
19265
19304
|
agentDef,
|
|
@@ -19276,7 +19315,7 @@ ${stderr}`
|
|
|
19276
19315
|
instance.sessionId = agentSessionId;
|
|
19277
19316
|
instance.initialSessionResponse = response;
|
|
19278
19317
|
instance.debugTracer = createDebugTracer(agentSessionId, workingDirectory);
|
|
19279
|
-
|
|
19318
|
+
log30.info(
|
|
19280
19319
|
{
|
|
19281
19320
|
sessionId: agentSessionId,
|
|
19282
19321
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19292,7 +19331,7 @@ ${stderr}`
|
|
|
19292
19331
|
instance.sessionId = response.sessionId;
|
|
19293
19332
|
instance.initialSessionResponse = response;
|
|
19294
19333
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19295
|
-
|
|
19334
|
+
log30.info(
|
|
19296
19335
|
{
|
|
19297
19336
|
sessionId: response.sessionId,
|
|
19298
19337
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19302,7 +19341,7 @@ ${stderr}`
|
|
|
19302
19341
|
);
|
|
19303
19342
|
}
|
|
19304
19343
|
} catch (err) {
|
|
19305
|
-
|
|
19344
|
+
log30.warn(
|
|
19306
19345
|
{ err, agentSessionId },
|
|
19307
19346
|
"Resume failed, falling back to new session"
|
|
19308
19347
|
);
|
|
@@ -19313,7 +19352,7 @@ ${stderr}`
|
|
|
19313
19352
|
instance.sessionId = response.sessionId;
|
|
19314
19353
|
instance.initialSessionResponse = response;
|
|
19315
19354
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19316
|
-
|
|
19355
|
+
log30.info(
|
|
19317
19356
|
{ sessionId: response.sessionId, durationMs: Date.now() - spawnStart },
|
|
19318
19357
|
"Agent fallback spawn complete"
|
|
19319
19358
|
);
|
|
@@ -19618,7 +19657,7 @@ ${stderr}`
|
|
|
19618
19657
|
contentBlocks.push({ type: "audio", data: data.toString("base64"), mimeType: att.mimeType });
|
|
19619
19658
|
} else {
|
|
19620
19659
|
if ((att.type === "image" || att.type === "audio") && !tooLarge) {
|
|
19621
|
-
|
|
19660
|
+
log30.debug(
|
|
19622
19661
|
{ type: att.type, capabilities: this.promptCapabilities ?? {} },
|
|
19623
19662
|
"Agent does not support %s content, falling back to file path",
|
|
19624
19663
|
att.type
|
|
@@ -20636,14 +20675,14 @@ var init_session_manager = __esm({
|
|
|
20636
20675
|
});
|
|
20637
20676
|
|
|
20638
20677
|
// src/core/sessions/session-bridge.ts
|
|
20639
|
-
var
|
|
20678
|
+
var log31, SessionBridge;
|
|
20640
20679
|
var init_session_bridge = __esm({
|
|
20641
20680
|
"src/core/sessions/session-bridge.ts"() {
|
|
20642
20681
|
"use strict";
|
|
20643
20682
|
init_log();
|
|
20644
20683
|
init_bypass_detection();
|
|
20645
20684
|
init_turn_context();
|
|
20646
|
-
|
|
20685
|
+
log31 = createChildLogger({ module: "session-bridge" });
|
|
20647
20686
|
SessionBridge = class {
|
|
20648
20687
|
constructor(session, adapter, deps, adapterId) {
|
|
20649
20688
|
this.session = session;
|
|
@@ -20672,16 +20711,16 @@ var init_session_bridge = __esm({
|
|
|
20672
20711
|
if (!result) return;
|
|
20673
20712
|
this.tracer?.log("core", { step: "dispatch", sessionId, message: result.message });
|
|
20674
20713
|
this.adapter.sendMessage(sessionId, result.message).catch((err) => {
|
|
20675
|
-
|
|
20714
|
+
log31.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20676
20715
|
});
|
|
20677
20716
|
} else {
|
|
20678
20717
|
this.tracer?.log("core", { step: "dispatch", sessionId, message });
|
|
20679
20718
|
this.adapter.sendMessage(sessionId, message).catch((err) => {
|
|
20680
|
-
|
|
20719
|
+
log31.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20681
20720
|
});
|
|
20682
20721
|
}
|
|
20683
20722
|
} catch (err) {
|
|
20684
|
-
|
|
20723
|
+
log31.error({ err, sessionId }, "Error in sendMessage middleware");
|
|
20685
20724
|
}
|
|
20686
20725
|
}
|
|
20687
20726
|
/** Determine if this bridge should forward the given event based on turn routing. */
|
|
@@ -20723,7 +20762,7 @@ var init_session_bridge = __esm({
|
|
|
20723
20762
|
try {
|
|
20724
20763
|
await this.adapter.sendPermissionRequest(this.session.id, request);
|
|
20725
20764
|
} catch (err) {
|
|
20726
|
-
|
|
20765
|
+
log31.error({ err, sessionId: this.session.id, adapterId: this.adapterId }, "Failed to send permission request to adapter");
|
|
20727
20766
|
}
|
|
20728
20767
|
});
|
|
20729
20768
|
this.listen(this.session, "status_change", (from, to) => {
|
|
@@ -20803,14 +20842,14 @@ var init_session_bridge = __esm({
|
|
|
20803
20842
|
try {
|
|
20804
20843
|
this.handleAgentEvent(event);
|
|
20805
20844
|
} catch (err) {
|
|
20806
|
-
|
|
20845
|
+
log31.error({ err, sessionId: this.session.id }, "Error handling agent event (middleware fallback)");
|
|
20807
20846
|
}
|
|
20808
20847
|
}
|
|
20809
20848
|
} else {
|
|
20810
20849
|
try {
|
|
20811
20850
|
this.handleAgentEvent(event);
|
|
20812
20851
|
} catch (err) {
|
|
20813
|
-
|
|
20852
|
+
log31.error({ err, sessionId: this.session.id }, "Error handling agent event");
|
|
20814
20853
|
}
|
|
20815
20854
|
}
|
|
20816
20855
|
}
|
|
@@ -20874,7 +20913,7 @@ var init_session_bridge = __esm({
|
|
|
20874
20913
|
text: "",
|
|
20875
20914
|
attachment: att
|
|
20876
20915
|
});
|
|
20877
|
-
}).catch((err) =>
|
|
20916
|
+
}).catch((err) => log31.error({ err }, "Failed to save agent image"));
|
|
20878
20917
|
}
|
|
20879
20918
|
break;
|
|
20880
20919
|
}
|
|
@@ -20891,12 +20930,12 @@ var init_session_bridge = __esm({
|
|
|
20891
20930
|
text: "",
|
|
20892
20931
|
attachment: att
|
|
20893
20932
|
});
|
|
20894
|
-
}).catch((err) =>
|
|
20933
|
+
}).catch((err) => log31.error({ err }, "Failed to save agent audio"));
|
|
20895
20934
|
}
|
|
20896
20935
|
break;
|
|
20897
20936
|
}
|
|
20898
20937
|
case "commands_update":
|
|
20899
|
-
|
|
20938
|
+
log31.debug({ commands: event.commands }, "Commands available");
|
|
20900
20939
|
this.adapter.sendSkillCommands?.(this.session.id, event.commands);
|
|
20901
20940
|
break;
|
|
20902
20941
|
case "system_message":
|
|
@@ -20992,7 +21031,7 @@ var init_session_bridge = __esm({
|
|
|
20992
21031
|
if (isAgentBypass || isClientBypass) {
|
|
20993
21032
|
const allowOption = request.options.find((o) => o.isAllow);
|
|
20994
21033
|
if (allowOption) {
|
|
20995
|
-
|
|
21034
|
+
log31.info(
|
|
20996
21035
|
{ sessionId: this.session.id, requestId: request.id, optionId: allowOption.id, agentBypass: !!isAgentBypass, clientBypass: !!isClientBypass },
|
|
20997
21036
|
"Bypass mode: auto-approving permission"
|
|
20998
21037
|
);
|
|
@@ -21165,13 +21204,13 @@ function computeLineDiff(oldStr, newStr) {
|
|
|
21165
21204
|
removed: Math.max(0, oldLines.length - prefixLen - suffixLen)
|
|
21166
21205
|
};
|
|
21167
21206
|
}
|
|
21168
|
-
var
|
|
21207
|
+
var log32, BINARY_VIEWER_EXTENSIONS, MessageTransformer;
|
|
21169
21208
|
var init_message_transformer = __esm({
|
|
21170
21209
|
"src/core/message-transformer.ts"() {
|
|
21171
21210
|
"use strict";
|
|
21172
21211
|
init_extract_file_info();
|
|
21173
21212
|
init_log();
|
|
21174
|
-
|
|
21213
|
+
log32 = createChildLogger({ module: "message-transformer" });
|
|
21175
21214
|
BINARY_VIEWER_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
21176
21215
|
".wav",
|
|
21177
21216
|
".ogg",
|
|
@@ -21374,14 +21413,14 @@ var init_message_transformer = __esm({
|
|
|
21374
21413
|
}
|
|
21375
21414
|
}
|
|
21376
21415
|
if (!this.tunnelService || !sessionContext) {
|
|
21377
|
-
|
|
21416
|
+
log32.debug(
|
|
21378
21417
|
{ hasTunnel: !!this.tunnelService, hasCtx: !!sessionContext, kind },
|
|
21379
21418
|
"enrichWithViewerLinks: skipping (no tunnel or session context)"
|
|
21380
21419
|
);
|
|
21381
21420
|
return;
|
|
21382
21421
|
}
|
|
21383
21422
|
const name = "name" in event ? event.name || "" : "";
|
|
21384
|
-
|
|
21423
|
+
log32.debug(
|
|
21385
21424
|
{ name, kind, status: event.status, hasContent: !!event.content, hasRawInput: !!event.rawInput },
|
|
21386
21425
|
"enrichWithViewerLinks: inspecting event"
|
|
21387
21426
|
);
|
|
@@ -21393,7 +21432,7 @@ var init_message_transformer = __esm({
|
|
|
21393
21432
|
event.meta
|
|
21394
21433
|
);
|
|
21395
21434
|
if (!fileInfo) {
|
|
21396
|
-
|
|
21435
|
+
log32.debug(
|
|
21397
21436
|
{ name, kind, hasContent: !!event.content, hasRawInput: !!event.rawInput, hasMeta: !!event.meta },
|
|
21398
21437
|
"enrichWithViewerLinks: extractFileInfo returned null"
|
|
21399
21438
|
);
|
|
@@ -21401,15 +21440,15 @@ var init_message_transformer = __esm({
|
|
|
21401
21440
|
}
|
|
21402
21441
|
const fileExt = path45.extname(fileInfo.filePath).toLowerCase();
|
|
21403
21442
|
if (BINARY_VIEWER_EXTENSIONS.has(fileExt)) {
|
|
21404
|
-
|
|
21443
|
+
log32.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping binary file");
|
|
21405
21444
|
return;
|
|
21406
21445
|
}
|
|
21407
21446
|
const publicUrl = this.tunnelService.getPublicUrl();
|
|
21408
21447
|
if (publicUrl.startsWith("http://localhost") || publicUrl.startsWith("http://127.0.0.1")) {
|
|
21409
|
-
|
|
21448
|
+
log32.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping (no public tunnel URL)");
|
|
21410
21449
|
return;
|
|
21411
21450
|
}
|
|
21412
|
-
|
|
21451
|
+
log32.info(
|
|
21413
21452
|
{
|
|
21414
21453
|
name,
|
|
21415
21454
|
kind,
|
|
@@ -21455,12 +21494,12 @@ var init_message_transformer = __esm({
|
|
|
21455
21494
|
// src/core/sessions/session-store.ts
|
|
21456
21495
|
import fs42 from "fs";
|
|
21457
21496
|
import path46 from "path";
|
|
21458
|
-
var
|
|
21497
|
+
var log33, DEBOUNCE_MS3, JsonFileSessionStore;
|
|
21459
21498
|
var init_session_store = __esm({
|
|
21460
21499
|
"src/core/sessions/session-store.ts"() {
|
|
21461
21500
|
"use strict";
|
|
21462
21501
|
init_log();
|
|
21463
|
-
|
|
21502
|
+
log33 = createChildLogger({ module: "session-store" });
|
|
21464
21503
|
DEBOUNCE_MS3 = 2e3;
|
|
21465
21504
|
JsonFileSessionStore = class {
|
|
21466
21505
|
records = /* @__PURE__ */ new Map();
|
|
@@ -21554,7 +21593,7 @@ var init_session_store = __esm({
|
|
|
21554
21593
|
fs42.readFileSync(this.filePath, "utf-8")
|
|
21555
21594
|
);
|
|
21556
21595
|
if (raw.version !== 1) {
|
|
21557
|
-
|
|
21596
|
+
log33.warn(
|
|
21558
21597
|
{ version: raw.version },
|
|
21559
21598
|
"Unknown session store version, skipping load"
|
|
21560
21599
|
);
|
|
@@ -21563,9 +21602,9 @@ var init_session_store = __esm({
|
|
|
21563
21602
|
for (const [id, record] of Object.entries(raw.sessions)) {
|
|
21564
21603
|
this.records.set(id, this.migrateRecord(record));
|
|
21565
21604
|
}
|
|
21566
|
-
|
|
21605
|
+
log33.debug({ count: this.records.size }, "Loaded session records");
|
|
21567
21606
|
} catch (err) {
|
|
21568
|
-
|
|
21607
|
+
log33.error({ err }, "Failed to load session store, backing up corrupt file");
|
|
21569
21608
|
try {
|
|
21570
21609
|
fs42.renameSync(this.filePath, `${this.filePath}.bak`);
|
|
21571
21610
|
} catch {
|
|
@@ -21601,7 +21640,7 @@ var init_session_store = __esm({
|
|
|
21601
21640
|
}
|
|
21602
21641
|
}
|
|
21603
21642
|
if (removed > 0) {
|
|
21604
|
-
|
|
21643
|
+
log33.info({ removed }, "Cleaned up expired session records");
|
|
21605
21644
|
this.scheduleDiskWrite();
|
|
21606
21645
|
}
|
|
21607
21646
|
}
|
|
@@ -21616,13 +21655,13 @@ var init_session_store = __esm({
|
|
|
21616
21655
|
});
|
|
21617
21656
|
|
|
21618
21657
|
// src/core/sessions/session-factory.ts
|
|
21619
|
-
var
|
|
21658
|
+
var log34, SessionFactory;
|
|
21620
21659
|
var init_session_factory = __esm({
|
|
21621
21660
|
"src/core/sessions/session-factory.ts"() {
|
|
21622
21661
|
"use strict";
|
|
21623
21662
|
init_session2();
|
|
21624
21663
|
init_log();
|
|
21625
|
-
|
|
21664
|
+
log34 = createChildLogger({ module: "session-factory" });
|
|
21626
21665
|
SessionFactory = class {
|
|
21627
21666
|
constructor(agentManager, sessionManager, speechServiceAccessor, eventBus, instanceRoot) {
|
|
21628
21667
|
this.agentManager = agentManager;
|
|
@@ -21683,7 +21722,7 @@ var init_session_factory = __esm({
|
|
|
21683
21722
|
createParams.resumeAgentSessionId
|
|
21684
21723
|
);
|
|
21685
21724
|
} catch (resumeErr) {
|
|
21686
|
-
|
|
21725
|
+
log34.warn(
|
|
21687
21726
|
{ agentName: createParams.agentName, resumeErr },
|
|
21688
21727
|
"Agent session resume failed, falling back to fresh spawn"
|
|
21689
21728
|
);
|
|
@@ -21816,10 +21855,10 @@ var init_session_factory = __esm({
|
|
|
21816
21855
|
session.setAgentCapabilities(record.acpState.agentCapabilities);
|
|
21817
21856
|
}
|
|
21818
21857
|
}
|
|
21819
|
-
|
|
21858
|
+
log34.info({ sessionId }, "Lazy resume by ID successful");
|
|
21820
21859
|
return session;
|
|
21821
21860
|
} catch (err) {
|
|
21822
|
-
|
|
21861
|
+
log34.error({ err, sessionId }, "Lazy resume by ID failed");
|
|
21823
21862
|
return null;
|
|
21824
21863
|
} finally {
|
|
21825
21864
|
this.resumeLocks.delete(sessionId);
|
|
@@ -21839,18 +21878,18 @@ var init_session_factory = __esm({
|
|
|
21839
21878
|
(p2) => String(p2.topicId) === threadId || String(p2.threadId ?? "") === threadId
|
|
21840
21879
|
);
|
|
21841
21880
|
if (!record) {
|
|
21842
|
-
|
|
21881
|
+
log34.debug({ threadId, channelId }, "No session record found for thread");
|
|
21843
21882
|
return null;
|
|
21844
21883
|
}
|
|
21845
21884
|
if (record.status === "error" || record.status === "cancelled") {
|
|
21846
|
-
|
|
21885
|
+
log34.warn(
|
|
21847
21886
|
{ threadId, sessionId: record.sessionId, status: record.status },
|
|
21848
21887
|
"Session record found but skipped (status: %s) \u2014 use /new to start a fresh session",
|
|
21849
21888
|
record.status
|
|
21850
21889
|
);
|
|
21851
21890
|
return null;
|
|
21852
21891
|
}
|
|
21853
|
-
|
|
21892
|
+
log34.info({ threadId, sessionId: record.sessionId, status: record.status }, "Lazy resume: found record, attempting resume");
|
|
21854
21893
|
const resumePromise = (async () => {
|
|
21855
21894
|
try {
|
|
21856
21895
|
const session = await this.createFullSession({
|
|
@@ -21891,7 +21930,7 @@ var init_session_factory = __esm({
|
|
|
21891
21930
|
}
|
|
21892
21931
|
const resumeFalledBack = record.agentSessionId && session.agentSessionId !== record.agentSessionId;
|
|
21893
21932
|
if (resumeFalledBack) {
|
|
21894
|
-
|
|
21933
|
+
log34.info({ sessionId: session.id }, "Resume fell back to fresh spawn \u2014 injecting conversation history");
|
|
21895
21934
|
const contextManager = this.getContextManager?.();
|
|
21896
21935
|
if (contextManager) {
|
|
21897
21936
|
try {
|
|
@@ -21908,10 +21947,10 @@ var init_session_factory = __esm({
|
|
|
21908
21947
|
}
|
|
21909
21948
|
}
|
|
21910
21949
|
}
|
|
21911
|
-
|
|
21950
|
+
log34.info({ sessionId: session.id, threadId }, "Lazy resume successful");
|
|
21912
21951
|
return session;
|
|
21913
21952
|
} catch (err) {
|
|
21914
|
-
|
|
21953
|
+
log34.error({ err, record }, "Lazy resume failed");
|
|
21915
21954
|
const adapter = this.adapters?.get(channelId);
|
|
21916
21955
|
if (adapter) {
|
|
21917
21956
|
try {
|
|
@@ -21936,7 +21975,7 @@ var init_session_factory = __esm({
|
|
|
21936
21975
|
}
|
|
21937
21976
|
const config = this.configManager.get();
|
|
21938
21977
|
const resolvedAgent = agentName || config.defaultAgent;
|
|
21939
|
-
|
|
21978
|
+
log34.info({ channelId, agentName: resolvedAgent }, "New session request");
|
|
21940
21979
|
const agentDef = this.agentCatalog.resolve(resolvedAgent);
|
|
21941
21980
|
const resolvedWorkspace = this.configManager.resolveWorkspace(
|
|
21942
21981
|
workspacePath || agentDef?.workingDirectory
|
|
@@ -21985,7 +22024,7 @@ var init_session_factory = __esm({
|
|
|
21985
22024
|
params.contextOptions
|
|
21986
22025
|
);
|
|
21987
22026
|
} catch (err) {
|
|
21988
|
-
|
|
22027
|
+
log34.warn({ err }, "Context building failed, proceeding without context");
|
|
21989
22028
|
}
|
|
21990
22029
|
}
|
|
21991
22030
|
const session = await this.createFullSession({
|
|
@@ -22034,13 +22073,13 @@ var init_session_factory = __esm({
|
|
|
22034
22073
|
});
|
|
22035
22074
|
|
|
22036
22075
|
// src/core/agent-switch-handler.ts
|
|
22037
|
-
var
|
|
22076
|
+
var log35, AgentSwitchHandler;
|
|
22038
22077
|
var init_agent_switch_handler = __esm({
|
|
22039
22078
|
"src/core/agent-switch-handler.ts"() {
|
|
22040
22079
|
"use strict";
|
|
22041
22080
|
init_agent_registry();
|
|
22042
22081
|
init_log();
|
|
22043
|
-
|
|
22082
|
+
log35 = createChildLogger({ module: "agent-switch" });
|
|
22044
22083
|
AgentSwitchHandler = class {
|
|
22045
22084
|
constructor(deps) {
|
|
22046
22085
|
this.deps = deps;
|
|
@@ -22114,7 +22153,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22114
22153
|
resumed = true;
|
|
22115
22154
|
return instance2;
|
|
22116
22155
|
} catch {
|
|
22117
|
-
|
|
22156
|
+
log35.warn({ sessionId, toAgent }, "Resume failed, falling back to new agent with context injection");
|
|
22118
22157
|
}
|
|
22119
22158
|
}
|
|
22120
22159
|
const instance = await agentManager.spawn(toAgent, session.workingDirectory);
|
|
@@ -22183,10 +22222,10 @@ var init_agent_switch_handler = __esm({
|
|
|
22183
22222
|
createBridge(session, adapter, adapterId).connect();
|
|
22184
22223
|
}
|
|
22185
22224
|
}
|
|
22186
|
-
|
|
22225
|
+
log35.warn({ sessionId, fromAgent, toAgent, err }, "Agent switch failed, rolled back to previous agent");
|
|
22187
22226
|
} catch (rollbackErr) {
|
|
22188
22227
|
session.fail(`Switch failed and rollback failed: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`);
|
|
22189
|
-
|
|
22228
|
+
log35.error({ sessionId, fromAgent, toAgent, err, rollbackErr }, "Agent switch failed and rollback also failed");
|
|
22190
22229
|
}
|
|
22191
22230
|
throw err;
|
|
22192
22231
|
}
|
|
@@ -22196,7 +22235,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22196
22235
|
if (adapter) {
|
|
22197
22236
|
createBridge(session, adapter, adapterId).connect();
|
|
22198
22237
|
} else {
|
|
22199
|
-
|
|
22238
|
+
log35.warn({ sessionId, adapterId }, "Adapter not available during switch reconnect, skipping bridge");
|
|
22200
22239
|
}
|
|
22201
22240
|
}
|
|
22202
22241
|
}
|
|
@@ -22229,12 +22268,12 @@ import * as fs43 from "fs";
|
|
|
22229
22268
|
import * as path47 from "path";
|
|
22230
22269
|
import * as os20 from "os";
|
|
22231
22270
|
import { z as z10 } from "zod";
|
|
22232
|
-
var
|
|
22271
|
+
var log36, InstalledAgentSchema, AgentStoreSchema, AgentStore;
|
|
22233
22272
|
var init_agent_store = __esm({
|
|
22234
22273
|
"src/core/agents/agent-store.ts"() {
|
|
22235
22274
|
"use strict";
|
|
22236
22275
|
init_log();
|
|
22237
|
-
|
|
22276
|
+
log36 = createChildLogger({ module: "agent-store" });
|
|
22238
22277
|
InstalledAgentSchema = z10.object({
|
|
22239
22278
|
registryId: z10.string().nullable(),
|
|
22240
22279
|
name: z10.string(),
|
|
@@ -22268,11 +22307,11 @@ var init_agent_store = __esm({
|
|
|
22268
22307
|
if (result.success) {
|
|
22269
22308
|
this.data = result.data;
|
|
22270
22309
|
} else {
|
|
22271
|
-
|
|
22310
|
+
log36.warn({ errors: result.error.issues }, "Invalid agents.json, starting fresh");
|
|
22272
22311
|
this.data = { version: 1, installed: {} };
|
|
22273
22312
|
}
|
|
22274
22313
|
} catch (err) {
|
|
22275
|
-
|
|
22314
|
+
log36.warn({ err }, "Failed to read agents.json, starting fresh");
|
|
22276
22315
|
this.data = { version: 1, installed: {} };
|
|
22277
22316
|
}
|
|
22278
22317
|
}
|
|
@@ -22314,7 +22353,7 @@ __export(agent_catalog_exports, {
|
|
|
22314
22353
|
import * as fs44 from "fs";
|
|
22315
22354
|
import * as path48 from "path";
|
|
22316
22355
|
import * as os21 from "os";
|
|
22317
|
-
var
|
|
22356
|
+
var log37, REGISTRY_URL2, DEFAULT_TTL_HOURS, AgentCatalog;
|
|
22318
22357
|
var init_agent_catalog = __esm({
|
|
22319
22358
|
"src/core/agents/agent-catalog.ts"() {
|
|
22320
22359
|
"use strict";
|
|
@@ -22322,7 +22361,7 @@ var init_agent_catalog = __esm({
|
|
|
22322
22361
|
init_agent_installer();
|
|
22323
22362
|
init_agent_dependencies();
|
|
22324
22363
|
init_log();
|
|
22325
|
-
|
|
22364
|
+
log37 = createChildLogger({ module: "agent-catalog" });
|
|
22326
22365
|
REGISTRY_URL2 = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
|
|
22327
22366
|
DEFAULT_TTL_HOURS = 24;
|
|
22328
22367
|
AgentCatalog = class {
|
|
@@ -22343,7 +22382,7 @@ var init_agent_catalog = __esm({
|
|
|
22343
22382
|
// --- Registry ---
|
|
22344
22383
|
async fetchRegistry() {
|
|
22345
22384
|
try {
|
|
22346
|
-
|
|
22385
|
+
log37.info("Fetching agent registry from CDN...");
|
|
22347
22386
|
const response = await fetch(REGISTRY_URL2);
|
|
22348
22387
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
22349
22388
|
const data = await response.json();
|
|
@@ -22355,9 +22394,9 @@ var init_agent_catalog = __esm({
|
|
|
22355
22394
|
};
|
|
22356
22395
|
fs44.mkdirSync(path48.dirname(this.cachePath), { recursive: true });
|
|
22357
22396
|
fs44.writeFileSync(this.cachePath, JSON.stringify(cache, null, 2), { mode: 384 });
|
|
22358
|
-
|
|
22397
|
+
log37.info({ count: this.registryAgents.length }, "Registry updated");
|
|
22359
22398
|
} catch (err) {
|
|
22360
|
-
|
|
22399
|
+
log37.warn({ err }, "Failed to fetch registry, using cached data");
|
|
22361
22400
|
}
|
|
22362
22401
|
}
|
|
22363
22402
|
async refreshRegistryIfStale() {
|
|
@@ -22518,7 +22557,7 @@ var init_agent_catalog = __esm({
|
|
|
22518
22557
|
}
|
|
22519
22558
|
}
|
|
22520
22559
|
if (changed) {
|
|
22521
|
-
|
|
22560
|
+
log37.info("Enriched installed agents with registry data");
|
|
22522
22561
|
}
|
|
22523
22562
|
}
|
|
22524
22563
|
isCacheStale() {
|
|
@@ -22538,11 +22577,11 @@ var init_agent_catalog = __esm({
|
|
|
22538
22577
|
const raw = JSON.parse(fs44.readFileSync(this.cachePath, "utf-8"));
|
|
22539
22578
|
if (raw.data?.agents) {
|
|
22540
22579
|
this.registryAgents = raw.data.agents;
|
|
22541
|
-
|
|
22580
|
+
log37.debug({ count: this.registryAgents.length }, "Loaded registry from cache");
|
|
22542
22581
|
return;
|
|
22543
22582
|
}
|
|
22544
22583
|
} catch {
|
|
22545
|
-
|
|
22584
|
+
log37.warn("Failed to load registry cache");
|
|
22546
22585
|
}
|
|
22547
22586
|
}
|
|
22548
22587
|
try {
|
|
@@ -22555,13 +22594,13 @@ var init_agent_catalog = __esm({
|
|
|
22555
22594
|
if (fs44.existsSync(candidate)) {
|
|
22556
22595
|
const raw = JSON.parse(fs44.readFileSync(candidate, "utf-8"));
|
|
22557
22596
|
this.registryAgents = raw.agents ?? [];
|
|
22558
|
-
|
|
22597
|
+
log37.debug({ count: this.registryAgents.length }, "Loaded registry from bundled snapshot");
|
|
22559
22598
|
return;
|
|
22560
22599
|
}
|
|
22561
22600
|
}
|
|
22562
|
-
|
|
22601
|
+
log37.warn("No registry data available (no cache, no snapshot)");
|
|
22563
22602
|
} catch {
|
|
22564
|
-
|
|
22603
|
+
log37.warn("Failed to load bundled registry snapshot");
|
|
22565
22604
|
}
|
|
22566
22605
|
}
|
|
22567
22606
|
};
|
|
@@ -22947,7 +22986,7 @@ function createPluginContext(opts) {
|
|
|
22947
22986
|
}
|
|
22948
22987
|
};
|
|
22949
22988
|
const baseLog = opts.log ?? noopLog;
|
|
22950
|
-
const
|
|
22989
|
+
const log46 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
|
|
22951
22990
|
const storageImpl = new PluginStorageImpl(storagePath);
|
|
22952
22991
|
const storage = {
|
|
22953
22992
|
async get(key) {
|
|
@@ -22974,7 +23013,7 @@ function createPluginContext(opts) {
|
|
|
22974
23013
|
const ctx = {
|
|
22975
23014
|
pluginName,
|
|
22976
23015
|
pluginConfig,
|
|
22977
|
-
log:
|
|
23016
|
+
log: log46,
|
|
22978
23017
|
storage,
|
|
22979
23018
|
on(event, handler) {
|
|
22980
23019
|
requirePermission(permissions, "events:read", "on()");
|
|
@@ -23009,7 +23048,7 @@ function createPluginContext(opts) {
|
|
|
23009
23048
|
const registry = serviceRegistry.get("command-registry");
|
|
23010
23049
|
if (registry && typeof registry.register === "function") {
|
|
23011
23050
|
registry.register(def, pluginName);
|
|
23012
|
-
|
|
23051
|
+
log46.debug(`Command '/${def.name}' registered`);
|
|
23013
23052
|
}
|
|
23014
23053
|
},
|
|
23015
23054
|
async sendMessage(_sessionId, _content) {
|
|
@@ -23052,7 +23091,7 @@ function createPluginContext(opts) {
|
|
|
23052
23091
|
const registry = serviceRegistry.get("field-registry");
|
|
23053
23092
|
if (registry && typeof registry.register === "function") {
|
|
23054
23093
|
registry.register(pluginName, fields);
|
|
23055
|
-
|
|
23094
|
+
log46.debug(`Registered ${fields.length} editable field(s) for ${pluginName}`);
|
|
23056
23095
|
}
|
|
23057
23096
|
},
|
|
23058
23097
|
get sessions() {
|
|
@@ -23384,12 +23423,12 @@ var init_lifecycle_manager = __esm({
|
|
|
23384
23423
|
});
|
|
23385
23424
|
|
|
23386
23425
|
// src/core/menu-registry.ts
|
|
23387
|
-
var
|
|
23426
|
+
var log38, MenuRegistry;
|
|
23388
23427
|
var init_menu_registry = __esm({
|
|
23389
23428
|
"src/core/menu-registry.ts"() {
|
|
23390
23429
|
"use strict";
|
|
23391
23430
|
init_log();
|
|
23392
|
-
|
|
23431
|
+
log38 = createChildLogger({ module: "menu-registry" });
|
|
23393
23432
|
MenuRegistry = class {
|
|
23394
23433
|
items = /* @__PURE__ */ new Map();
|
|
23395
23434
|
register(item) {
|
|
@@ -23408,7 +23447,7 @@ var init_menu_registry = __esm({
|
|
|
23408
23447
|
try {
|
|
23409
23448
|
return item.visible();
|
|
23410
23449
|
} catch (err) {
|
|
23411
|
-
|
|
23450
|
+
log38.warn({ err, id: item.id }, "MenuItem visible() threw, hiding item");
|
|
23412
23451
|
return false;
|
|
23413
23452
|
}
|
|
23414
23453
|
}).sort((a, b) => a.priority - b.priority);
|
|
@@ -23481,13 +23520,13 @@ Talk to users like a helpful assistant, not a CLI manual.`;
|
|
|
23481
23520
|
});
|
|
23482
23521
|
|
|
23483
23522
|
// src/core/assistant/assistant-registry.ts
|
|
23484
|
-
var
|
|
23523
|
+
var log39, AssistantRegistry;
|
|
23485
23524
|
var init_assistant_registry = __esm({
|
|
23486
23525
|
"src/core/assistant/assistant-registry.ts"() {
|
|
23487
23526
|
"use strict";
|
|
23488
23527
|
init_log();
|
|
23489
23528
|
init_prompt_constants();
|
|
23490
|
-
|
|
23529
|
+
log39 = createChildLogger({ module: "assistant-registry" });
|
|
23491
23530
|
AssistantRegistry = class {
|
|
23492
23531
|
sections = /* @__PURE__ */ new Map();
|
|
23493
23532
|
_instanceRoot = "";
|
|
@@ -23497,7 +23536,7 @@ var init_assistant_registry = __esm({
|
|
|
23497
23536
|
}
|
|
23498
23537
|
register(section) {
|
|
23499
23538
|
if (this.sections.has(section.id)) {
|
|
23500
|
-
|
|
23539
|
+
log39.warn({ id: section.id }, "Assistant section overwritten");
|
|
23501
23540
|
}
|
|
23502
23541
|
this.sections.set(section.id, section);
|
|
23503
23542
|
}
|
|
@@ -23522,7 +23561,7 @@ ${context}`);
|
|
|
23522
23561
|
parts.push("```bash\n" + cmds + "\n```");
|
|
23523
23562
|
}
|
|
23524
23563
|
} catch (err) {
|
|
23525
|
-
|
|
23564
|
+
log39.warn({ err, sectionId: section.id }, "Assistant section buildContext() failed, skipping");
|
|
23526
23565
|
}
|
|
23527
23566
|
}
|
|
23528
23567
|
parts.push(buildAssistantGuidelines(this._instanceRoot));
|
|
@@ -23533,12 +23572,12 @@ ${context}`);
|
|
|
23533
23572
|
});
|
|
23534
23573
|
|
|
23535
23574
|
// src/core/assistant/assistant-manager.ts
|
|
23536
|
-
var
|
|
23575
|
+
var log40, AssistantManager;
|
|
23537
23576
|
var init_assistant_manager = __esm({
|
|
23538
23577
|
"src/core/assistant/assistant-manager.ts"() {
|
|
23539
23578
|
"use strict";
|
|
23540
23579
|
init_log();
|
|
23541
|
-
|
|
23580
|
+
log40 = createChildLogger({ module: "assistant-manager" });
|
|
23542
23581
|
AssistantManager = class {
|
|
23543
23582
|
constructor(core, registry) {
|
|
23544
23583
|
this.core = core;
|
|
@@ -23559,7 +23598,7 @@ var init_assistant_manager = __esm({
|
|
|
23559
23598
|
this.sessions.set(channelId, session);
|
|
23560
23599
|
const systemPrompt = this.registry.buildSystemPrompt(channelId);
|
|
23561
23600
|
this.pendingSystemPrompts.set(channelId, systemPrompt);
|
|
23562
|
-
|
|
23601
|
+
log40.info({ sessionId: session.id, channelId }, "Assistant spawned (system prompt deferred)");
|
|
23563
23602
|
return session;
|
|
23564
23603
|
}
|
|
23565
23604
|
get(channelId) {
|
|
@@ -23805,7 +23844,7 @@ var init_core_items = __esm({
|
|
|
23805
23844
|
import path51 from "path";
|
|
23806
23845
|
import os23 from "os";
|
|
23807
23846
|
import { nanoid as nanoid5 } from "nanoid";
|
|
23808
|
-
var
|
|
23847
|
+
var log41, OpenACPCore;
|
|
23809
23848
|
var init_core = __esm({
|
|
23810
23849
|
"src/core/core.ts"() {
|
|
23811
23850
|
"use strict";
|
|
@@ -23829,7 +23868,7 @@ var init_core = __esm({
|
|
|
23829
23868
|
init_middleware_chain();
|
|
23830
23869
|
init_error_tracker();
|
|
23831
23870
|
init_log();
|
|
23832
|
-
|
|
23871
|
+
log41 = createChildLogger({ module: "core" });
|
|
23833
23872
|
OpenACPCore = class {
|
|
23834
23873
|
configManager;
|
|
23835
23874
|
agentCatalog;
|
|
@@ -23944,7 +23983,7 @@ var init_core = __esm({
|
|
|
23944
23983
|
if (configPath === "logging.level" && typeof value === "string") {
|
|
23945
23984
|
const { setLogLevel: setLogLevel2 } = await Promise.resolve().then(() => (init_log(), log_exports));
|
|
23946
23985
|
setLogLevel2(value);
|
|
23947
|
-
|
|
23986
|
+
log41.info({ level: value }, "Log level changed at runtime");
|
|
23948
23987
|
}
|
|
23949
23988
|
if (configPath.startsWith("speech.")) {
|
|
23950
23989
|
const speechSvc = this.lifecycleManager.serviceRegistry.get("speech");
|
|
@@ -23968,7 +24007,7 @@ var init_core = __esm({
|
|
|
23968
24007
|
}
|
|
23969
24008
|
};
|
|
23970
24009
|
speechSvc.refreshProviders(newSpeechConfig);
|
|
23971
|
-
|
|
24010
|
+
log41.info("Speech service config updated at runtime (from plugin settings)");
|
|
23972
24011
|
}
|
|
23973
24012
|
}
|
|
23974
24013
|
}
|
|
@@ -23998,14 +24037,14 @@ var init_core = __esm({
|
|
|
23998
24037
|
}
|
|
23999
24038
|
async start() {
|
|
24000
24039
|
this.agentCatalog.refreshRegistryIfStale().catch((err) => {
|
|
24001
|
-
|
|
24040
|
+
log41.warn({ err }, "Background registry refresh failed");
|
|
24002
24041
|
});
|
|
24003
24042
|
const failures = [];
|
|
24004
24043
|
for (const [name, adapter] of this.adapters.entries()) {
|
|
24005
24044
|
try {
|
|
24006
24045
|
await adapter.start();
|
|
24007
24046
|
} catch (err) {
|
|
24008
|
-
|
|
24047
|
+
log41.error({ err, adapter: name }, `Adapter "${name}" failed to start`);
|
|
24009
24048
|
failures.push({ name, error: err });
|
|
24010
24049
|
}
|
|
24011
24050
|
}
|
|
@@ -24053,7 +24092,7 @@ var init_core = __esm({
|
|
|
24053
24092
|
}
|
|
24054
24093
|
// --- Message Routing ---
|
|
24055
24094
|
async handleMessage(message) {
|
|
24056
|
-
|
|
24095
|
+
log41.debug(
|
|
24057
24096
|
{
|
|
24058
24097
|
channelId: message.channelId,
|
|
24059
24098
|
threadId: message.threadId,
|
|
@@ -24072,7 +24111,7 @@ var init_core = __esm({
|
|
|
24072
24111
|
}
|
|
24073
24112
|
const access2 = await this.securityGuard.checkAccess(message);
|
|
24074
24113
|
if (!access2.allowed) {
|
|
24075
|
-
|
|
24114
|
+
log41.warn({ userId: message.userId, reason: access2.reason }, "Access denied");
|
|
24076
24115
|
if (access2.reason.includes("Session limit")) {
|
|
24077
24116
|
const adapter = this.adapters.get(message.channelId);
|
|
24078
24117
|
if (adapter) {
|
|
@@ -24086,7 +24125,7 @@ var init_core = __esm({
|
|
|
24086
24125
|
}
|
|
24087
24126
|
let session = await this.sessionFactory.getOrResume(message.channelId, message.threadId);
|
|
24088
24127
|
if (!session) {
|
|
24089
|
-
|
|
24128
|
+
log41.warn(
|
|
24090
24129
|
{ channelId: message.channelId, threadId: message.threadId },
|
|
24091
24130
|
"No session found for thread (in-memory miss + lazy resume returned null)"
|
|
24092
24131
|
);
|
|
@@ -24184,7 +24223,7 @@ ${text6}`;
|
|
|
24184
24223
|
const bridge = this.createBridge(session, adapter, session.channelId);
|
|
24185
24224
|
bridge.connect();
|
|
24186
24225
|
adapter.flushPendingSkillCommands?.(session.id).catch((err) => {
|
|
24187
|
-
|
|
24226
|
+
log41.warn({ err, sessionId: session.id }, "Failed to flush pending skill commands");
|
|
24188
24227
|
});
|
|
24189
24228
|
if (params.createThread && session.threadId) {
|
|
24190
24229
|
this.eventBus.emit("session:threadReady", {
|
|
@@ -24198,14 +24237,14 @@ ${text6}`;
|
|
|
24198
24237
|
session.agentInstance.onPermissionRequest = async (permRequest) => {
|
|
24199
24238
|
const allowOption = permRequest.options.find((o) => o.isAllow);
|
|
24200
24239
|
if (!allowOption) {
|
|
24201
|
-
|
|
24240
|
+
log41.warn(
|
|
24202
24241
|
{ sessionId: session.id, permissionId: permRequest.id, description: permRequest.description },
|
|
24203
24242
|
"Headless session has no allow option for permission request \u2014 skipping auto-approve, will time out"
|
|
24204
24243
|
);
|
|
24205
24244
|
return new Promise(() => {
|
|
24206
24245
|
});
|
|
24207
24246
|
}
|
|
24208
|
-
|
|
24247
|
+
log41.warn(
|
|
24209
24248
|
{ sessionId: session.id, permissionId: permRequest.id, option: allowOption.id },
|
|
24210
24249
|
`Auto-approving permission "${permRequest.description}" for headless session \u2014 no adapter connected`
|
|
24211
24250
|
);
|
|
@@ -24217,7 +24256,7 @@ ${text6}`;
|
|
|
24217
24256
|
notificationManager: this.notificationManager,
|
|
24218
24257
|
tunnelService: this._tunnelService
|
|
24219
24258
|
});
|
|
24220
|
-
|
|
24259
|
+
log41.info(
|
|
24221
24260
|
{ sessionId: session.id, agentName: params.agentName },
|
|
24222
24261
|
"Session created via pipeline"
|
|
24223
24262
|
);
|
|
@@ -25208,7 +25247,7 @@ function registerCategoryCommand(registry, core, category, commandName) {
|
|
|
25208
25247
|
core.eventBus.emit("session:configChanged", { sessionId: session.id });
|
|
25209
25248
|
return { type: "text", text: labels.successMsg(match.name, configOption.name) };
|
|
25210
25249
|
} catch (err) {
|
|
25211
|
-
|
|
25250
|
+
log42.error({ err, commandName, configId: configOption.id }, "setConfigOption failed");
|
|
25212
25251
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25213
25252
|
return { type: "error", message: `Could not change ${commandName}: ${msg}` };
|
|
25214
25253
|
}
|
|
@@ -25273,7 +25312,7 @@ function registerDangerousCommand(registry, core) {
|
|
|
25273
25312
|
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
25313
|
};
|
|
25275
25314
|
} catch (err) {
|
|
25276
|
-
|
|
25315
|
+
log42.error({ err }, "setConfigOption failed (bypass toggle)");
|
|
25277
25316
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25278
25317
|
return { type: "error", message: `Could not toggle bypass: ${msg}` };
|
|
25279
25318
|
}
|
|
@@ -25297,14 +25336,14 @@ function registerConfigCommands(registry, _core) {
|
|
|
25297
25336
|
registerCategoryCommand(registry, core, "thought_level", "thought");
|
|
25298
25337
|
registerDangerousCommand(registry, core);
|
|
25299
25338
|
}
|
|
25300
|
-
var
|
|
25339
|
+
var log42, CATEGORY_LABELS;
|
|
25301
25340
|
var init_config6 = __esm({
|
|
25302
25341
|
"src/core/commands/config.ts"() {
|
|
25303
25342
|
"use strict";
|
|
25304
25343
|
init_log();
|
|
25305
25344
|
init_bypass_detection();
|
|
25306
25345
|
init_bypass_detection();
|
|
25307
|
-
|
|
25346
|
+
log42 = createChildLogger({ module: "commands/config" });
|
|
25308
25347
|
CATEGORY_LABELS = {
|
|
25309
25348
|
mode: {
|
|
25310
25349
|
menuTitle: (cur) => `Choose session mode (current: ${cur})`,
|
|
@@ -25716,7 +25755,7 @@ function installAutoStart(logDir2) {
|
|
|
25716
25755
|
fs46.mkdirSync(dir, { recursive: true });
|
|
25717
25756
|
fs46.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
25718
25757
|
execFileSync8("launchctl", ["load", LAUNCHD_PLIST_PATH], { stdio: "pipe" });
|
|
25719
|
-
|
|
25758
|
+
log43.info("LaunchAgent installed");
|
|
25720
25759
|
return { success: true };
|
|
25721
25760
|
}
|
|
25722
25761
|
if (process.platform === "linux") {
|
|
@@ -25726,13 +25765,13 @@ function installAutoStart(logDir2) {
|
|
|
25726
25765
|
fs46.writeFileSync(SYSTEMD_SERVICE_PATH, unit);
|
|
25727
25766
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25728
25767
|
execFileSync8("systemctl", ["--user", "enable", "openacp"], { stdio: "pipe" });
|
|
25729
|
-
|
|
25768
|
+
log43.info("systemd user service installed");
|
|
25730
25769
|
return { success: true };
|
|
25731
25770
|
}
|
|
25732
25771
|
return { success: false, error: "Unsupported platform" };
|
|
25733
25772
|
} catch (e) {
|
|
25734
25773
|
const msg = e.message;
|
|
25735
|
-
|
|
25774
|
+
log43.error({ err: msg }, "Failed to install auto-start");
|
|
25736
25775
|
return { success: false, error: msg };
|
|
25737
25776
|
}
|
|
25738
25777
|
}
|
|
@@ -25748,7 +25787,7 @@ function uninstallAutoStart() {
|
|
|
25748
25787
|
} catch {
|
|
25749
25788
|
}
|
|
25750
25789
|
fs46.unlinkSync(LAUNCHD_PLIST_PATH);
|
|
25751
|
-
|
|
25790
|
+
log43.info("LaunchAgent removed");
|
|
25752
25791
|
}
|
|
25753
25792
|
return { success: true };
|
|
25754
25793
|
}
|
|
@@ -25760,14 +25799,14 @@ function uninstallAutoStart() {
|
|
|
25760
25799
|
}
|
|
25761
25800
|
fs46.unlinkSync(SYSTEMD_SERVICE_PATH);
|
|
25762
25801
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25763
|
-
|
|
25802
|
+
log43.info("systemd user service removed");
|
|
25764
25803
|
}
|
|
25765
25804
|
return { success: true };
|
|
25766
25805
|
}
|
|
25767
25806
|
return { success: false, error: "Unsupported platform" };
|
|
25768
25807
|
} catch (e) {
|
|
25769
25808
|
const msg = e.message;
|
|
25770
|
-
|
|
25809
|
+
log43.error({ err: msg }, "Failed to uninstall auto-start");
|
|
25771
25810
|
return { success: false, error: msg };
|
|
25772
25811
|
}
|
|
25773
25812
|
}
|
|
@@ -25780,12 +25819,12 @@ function isAutoStartInstalled() {
|
|
|
25780
25819
|
}
|
|
25781
25820
|
return false;
|
|
25782
25821
|
}
|
|
25783
|
-
var
|
|
25822
|
+
var log43, LAUNCHD_LABEL, LAUNCHD_PLIST_PATH, SYSTEMD_SERVICE_PATH;
|
|
25784
25823
|
var init_autostart = __esm({
|
|
25785
25824
|
"src/cli/autostart.ts"() {
|
|
25786
25825
|
"use strict";
|
|
25787
25826
|
init_log();
|
|
25788
|
-
|
|
25827
|
+
log43 = createChildLogger({ module: "autostart" });
|
|
25789
25828
|
LAUNCHD_LABEL = "com.openacp.daemon";
|
|
25790
25829
|
LAUNCHD_PLIST_PATH = path52.join(os24.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
25791
25830
|
SYSTEMD_SERVICE_PATH = path52.join(os24.homedir(), ".config", "systemd", "user", "openacp.service");
|
|
@@ -25888,7 +25927,7 @@ async function setupIntegrations() {
|
|
|
25888
25927
|
if (integration) {
|
|
25889
25928
|
for (const item of integration.items) {
|
|
25890
25929
|
const result = await item.install();
|
|
25891
|
-
for (const
|
|
25930
|
+
for (const log46 of result.logs) console.log(` ${log46}`);
|
|
25892
25931
|
}
|
|
25893
25932
|
}
|
|
25894
25933
|
console.log("Claude CLI integration installed.\n");
|
|
@@ -26830,14 +26869,14 @@ async function runPostUpgradeChecks(config) {
|
|
|
26830
26869
|
const { ensureCloudflared: ensureCloudflared2 } = await Promise.resolve().then(() => (init_install_cloudflared(), install_cloudflared_exports));
|
|
26831
26870
|
await ensureCloudflared2();
|
|
26832
26871
|
} catch (err) {
|
|
26833
|
-
|
|
26872
|
+
log45.warn(
|
|
26834
26873
|
{ err: err.message },
|
|
26835
26874
|
"Could not install cloudflared. Tunnel may not work."
|
|
26836
26875
|
);
|
|
26837
26876
|
}
|
|
26838
26877
|
} else {
|
|
26839
26878
|
if (!commandExists(tunnelProvider)) {
|
|
26840
|
-
|
|
26879
|
+
log45.warn(
|
|
26841
26880
|
`Tunnel provider "${tunnelProvider}" is not installed. Install it or switch to cloudflare (free, auto-installed).`
|
|
26842
26881
|
);
|
|
26843
26882
|
}
|
|
@@ -26851,7 +26890,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26851
26890
|
if (integration) {
|
|
26852
26891
|
const allInstalled = integration.items.every((item) => item.isInstalled());
|
|
26853
26892
|
if (!allInstalled) {
|
|
26854
|
-
|
|
26893
|
+
log45.info(
|
|
26855
26894
|
'Claude CLI integration not installed. Run "openacp integrate claude" for session transfer + tunnel skill.'
|
|
26856
26895
|
);
|
|
26857
26896
|
}
|
|
@@ -26861,7 +26900,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26861
26900
|
const { ensureJq: ensureJq2 } = await Promise.resolve().then(() => (init_install_jq(), install_jq_exports));
|
|
26862
26901
|
await ensureJq2();
|
|
26863
26902
|
} catch (err) {
|
|
26864
|
-
|
|
26903
|
+
log45.warn(
|
|
26865
26904
|
{ err: err.message },
|
|
26866
26905
|
"Could not install jq. Handoff hooks may not work."
|
|
26867
26906
|
);
|
|
@@ -26871,7 +26910,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26871
26910
|
} catch {
|
|
26872
26911
|
}
|
|
26873
26912
|
if (!commandExists("unzip")) {
|
|
26874
|
-
|
|
26913
|
+
log45.warn(
|
|
26875
26914
|
"unzip is not installed. Some agent installations (binary distribution) may fail. Install: brew install unzip (macOS) or apt install unzip (Linux)"
|
|
26876
26915
|
);
|
|
26877
26916
|
}
|
|
@@ -26884,20 +26923,20 @@ async function runPostUpgradeChecks(config) {
|
|
|
26884
26923
|
(a) => a.distribution === "uvx"
|
|
26885
26924
|
);
|
|
26886
26925
|
if (hasUvxAgent && !commandExists("uvx")) {
|
|
26887
|
-
|
|
26926
|
+
log45.warn(
|
|
26888
26927
|
"uvx is not installed but you have Python-based agents. Install: pip install uv"
|
|
26889
26928
|
);
|
|
26890
26929
|
}
|
|
26891
26930
|
} catch {
|
|
26892
26931
|
}
|
|
26893
26932
|
}
|
|
26894
|
-
var
|
|
26933
|
+
var log45;
|
|
26895
26934
|
var init_post_upgrade = __esm({
|
|
26896
26935
|
"src/cli/post-upgrade.ts"() {
|
|
26897
26936
|
"use strict";
|
|
26898
26937
|
init_log();
|
|
26899
26938
|
init_agent_dependencies();
|
|
26900
|
-
|
|
26939
|
+
log45 = createChildLogger({ module: "post-upgrade" });
|
|
26901
26940
|
}
|
|
26902
26941
|
});
|
|
26903
26942
|
|
|
@@ -30552,7 +30591,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30552
30591
|
if (uninstall) {
|
|
30553
30592
|
console.log(`Removing ${agent}/${item.id}...`);
|
|
30554
30593
|
const result = await item.uninstall();
|
|
30555
|
-
for (const
|
|
30594
|
+
for (const log46 of result.logs) console.log(` ${log46}`);
|
|
30556
30595
|
if (result.success) {
|
|
30557
30596
|
console.log(` ${item.name} removed.`);
|
|
30558
30597
|
} else {
|
|
@@ -30562,7 +30601,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30562
30601
|
} else {
|
|
30563
30602
|
console.log(`Installing ${agent}/${item.id}...`);
|
|
30564
30603
|
const result = await item.install();
|
|
30565
|
-
for (const
|
|
30604
|
+
for (const log46 of result.logs) console.log(` ${log46}`);
|
|
30566
30605
|
if (result.success) {
|
|
30567
30606
|
console.log(` ${item.name} installed.`);
|
|
30568
30607
|
} else {
|