@openacp/cli 2026.405.2 → 2026.406.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +192 -180
- package/dist/cli.js.map +1 -1
- package/dist/index.js +78 -66
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -14578,7 +14578,10 @@ function setupAllCallbacks(bot, core, chatId, systemTopicIds, getAssistantSessio
|
|
|
14578
14578
|
const menuRegistry = core.lifecycleManager?.serviceRegistry?.get("menu-registry");
|
|
14579
14579
|
if (!menuRegistry) return;
|
|
14580
14580
|
const item = menuRegistry.getItem(itemId);
|
|
14581
|
-
if (!item)
|
|
14581
|
+
if (!item) {
|
|
14582
|
+
log25.warn({ itemId }, "Menu item not found in registry");
|
|
14583
|
+
return;
|
|
14584
|
+
}
|
|
14582
14585
|
const topicId = ctx.callbackQuery.message?.message_thread_id;
|
|
14583
14586
|
const registry = core.lifecycleManager?.serviceRegistry?.get("command-registry");
|
|
14584
14587
|
switch (item.action.type) {
|
|
@@ -14662,7 +14665,7 @@ ${lines}`, { parse_mode: "HTML" }).catch(() => {
|
|
|
14662
14665
|
}
|
|
14663
14666
|
});
|
|
14664
14667
|
}
|
|
14665
|
-
var STATIC_COMMANDS;
|
|
14668
|
+
var log25, STATIC_COMMANDS;
|
|
14666
14669
|
var init_commands3 = __esm({
|
|
14667
14670
|
"src/plugins/telegram/commands/index.ts"() {
|
|
14668
14671
|
"use strict";
|
|
@@ -14675,6 +14678,7 @@ var init_commands3 = __esm({
|
|
|
14675
14678
|
init_tunnel4();
|
|
14676
14679
|
init_switch();
|
|
14677
14680
|
init_telegram_overrides();
|
|
14681
|
+
init_log();
|
|
14678
14682
|
init_menu();
|
|
14679
14683
|
init_menu();
|
|
14680
14684
|
init_telegram_overrides();
|
|
@@ -14686,6 +14690,7 @@ var init_commands3 = __esm({
|
|
|
14686
14690
|
init_settings();
|
|
14687
14691
|
init_doctor2();
|
|
14688
14692
|
init_resume();
|
|
14693
|
+
log25 = createChildLogger({ module: "telegram-menu-callbacks" });
|
|
14689
14694
|
STATIC_COMMANDS = [
|
|
14690
14695
|
{ command: "new", description: "Create new session" },
|
|
14691
14696
|
{ command: "newchat", description: "New chat, same agent & workspace" },
|
|
@@ -14721,14 +14726,14 @@ var init_commands3 = __esm({
|
|
|
14721
14726
|
// src/plugins/telegram/permissions.ts
|
|
14722
14727
|
import { InlineKeyboard as InlineKeyboard11 } from "grammy";
|
|
14723
14728
|
import { nanoid as nanoid2 } from "nanoid";
|
|
14724
|
-
var
|
|
14729
|
+
var log26, PermissionHandler;
|
|
14725
14730
|
var init_permissions = __esm({
|
|
14726
14731
|
"src/plugins/telegram/permissions.ts"() {
|
|
14727
14732
|
"use strict";
|
|
14728
14733
|
init_formatting();
|
|
14729
14734
|
init_topics2();
|
|
14730
14735
|
init_log();
|
|
14731
|
-
|
|
14736
|
+
log26 = createChildLogger({ module: "telegram-permissions" });
|
|
14732
14737
|
PermissionHandler = class {
|
|
14733
14738
|
constructor(bot, chatId, getSession, sendNotification) {
|
|
14734
14739
|
this.bot = bot;
|
|
@@ -14772,11 +14777,11 @@ ${escapeHtml4(request.description)}`,
|
|
|
14772
14777
|
});
|
|
14773
14778
|
}
|
|
14774
14779
|
setupCallbackHandler() {
|
|
14775
|
-
this.bot.on("callback_query:data", async (ctx) => {
|
|
14780
|
+
this.bot.on("callback_query:data", async (ctx, next) => {
|
|
14776
14781
|
const data = ctx.callbackQuery.data;
|
|
14777
|
-
if (!data.startsWith("p:")) return;
|
|
14782
|
+
if (!data.startsWith("p:")) return next();
|
|
14778
14783
|
const parts = data.split(":");
|
|
14779
|
-
if (parts.length < 3) return;
|
|
14784
|
+
if (parts.length < 3) return next();
|
|
14780
14785
|
const [, callbackKey, optionId] = parts;
|
|
14781
14786
|
const pending = this.pending.get(callbackKey);
|
|
14782
14787
|
if (!pending) {
|
|
@@ -14788,7 +14793,7 @@ ${escapeHtml4(request.description)}`,
|
|
|
14788
14793
|
}
|
|
14789
14794
|
const session = this.getSession(pending.sessionId);
|
|
14790
14795
|
const isAllow = pending.options.find((o) => o.id === optionId)?.isAllow ?? false;
|
|
14791
|
-
|
|
14796
|
+
log26.info({ requestId: pending.requestId, optionId, isAllow }, "Permission responded");
|
|
14792
14797
|
if (session?.permissionGate.requestId === pending.requestId) {
|
|
14793
14798
|
session.permissionGate.resolve(optionId);
|
|
14794
14799
|
}
|
|
@@ -15242,7 +15247,7 @@ var init_display_spec_builder = __esm({
|
|
|
15242
15247
|
});
|
|
15243
15248
|
|
|
15244
15249
|
// src/plugins/telegram/activity.ts
|
|
15245
|
-
var
|
|
15250
|
+
var log27, THINKING_REFRESH_MS, THINKING_MAX_MS, ThinkingIndicator, ToolCard, ActivityTracker;
|
|
15246
15251
|
var init_activity = __esm({
|
|
15247
15252
|
"src/plugins/telegram/activity.ts"() {
|
|
15248
15253
|
"use strict";
|
|
@@ -15252,7 +15257,7 @@ var init_activity = __esm({
|
|
|
15252
15257
|
init_stream_accumulator();
|
|
15253
15258
|
init_stream_accumulator();
|
|
15254
15259
|
init_display_spec_builder();
|
|
15255
|
-
|
|
15260
|
+
log27 = createChildLogger({ module: "telegram:activity" });
|
|
15256
15261
|
THINKING_REFRESH_MS = 15e3;
|
|
15257
15262
|
THINKING_MAX_MS = 3 * 60 * 1e3;
|
|
15258
15263
|
ThinkingIndicator = class {
|
|
@@ -15293,7 +15298,7 @@ var init_activity = __esm({
|
|
|
15293
15298
|
}
|
|
15294
15299
|
}
|
|
15295
15300
|
} catch (err) {
|
|
15296
|
-
|
|
15301
|
+
log27.warn({ err }, "ThinkingIndicator.show() failed");
|
|
15297
15302
|
} finally {
|
|
15298
15303
|
this.sending = false;
|
|
15299
15304
|
}
|
|
@@ -15461,7 +15466,7 @@ var init_activity = __esm({
|
|
|
15461
15466
|
this.tracer?.log("telegram", { action: "telegram:delete:overflow", sessionId: this.sessionId, msgId: staleId });
|
|
15462
15467
|
}
|
|
15463
15468
|
} catch (err) {
|
|
15464
|
-
|
|
15469
|
+
log27.warn({ err }, "[ToolCard] send/edit failed");
|
|
15465
15470
|
}
|
|
15466
15471
|
}
|
|
15467
15472
|
};
|
|
@@ -15565,7 +15570,7 @@ var init_activity = __esm({
|
|
|
15565
15570
|
const entry = this.toolStateMap.merge(id, status, rawInput, content, viewerLinks, diffStats);
|
|
15566
15571
|
if (!existed || !entry) return;
|
|
15567
15572
|
if (viewerLinks || entry.viewerLinks) {
|
|
15568
|
-
|
|
15573
|
+
log27.debug({ toolId: id, status, hasIncomingLinks: !!viewerLinks, hasEntryLinks: !!entry.viewerLinks, entryLinks: entry.viewerLinks }, "toolUpdate: viewer links trace");
|
|
15569
15574
|
}
|
|
15570
15575
|
const spec = this.specBuilder.buildToolSpec(entry, this._outputMode, this.sessionContext);
|
|
15571
15576
|
this.toolCard.updateFromSpec(spec);
|
|
@@ -15992,13 +15997,13 @@ var init_draft_manager = __esm({
|
|
|
15992
15997
|
});
|
|
15993
15998
|
|
|
15994
15999
|
// src/plugins/telegram/skill-command-manager.ts
|
|
15995
|
-
var
|
|
16000
|
+
var log28, SkillCommandManager;
|
|
15996
16001
|
var init_skill_command_manager = __esm({
|
|
15997
16002
|
"src/plugins/telegram/skill-command-manager.ts"() {
|
|
15998
16003
|
"use strict";
|
|
15999
16004
|
init_commands3();
|
|
16000
16005
|
init_log();
|
|
16001
|
-
|
|
16006
|
+
log28 = createChildLogger({ module: "skill-commands" });
|
|
16002
16007
|
SkillCommandManager = class {
|
|
16003
16008
|
// sessionId → pinned msgId
|
|
16004
16009
|
constructor(bot, chatId, sendQueue, sessionManager) {
|
|
@@ -16064,7 +16069,7 @@ var init_skill_command_manager = __esm({
|
|
|
16064
16069
|
disable_notification: true
|
|
16065
16070
|
});
|
|
16066
16071
|
} catch (err) {
|
|
16067
|
-
|
|
16072
|
+
log28.error({ err, sessionId }, "Failed to send skill commands");
|
|
16068
16073
|
}
|
|
16069
16074
|
}
|
|
16070
16075
|
async cleanup(sessionId) {
|
|
@@ -16458,7 +16463,7 @@ function patchedFetch(input2, init) {
|
|
|
16458
16463
|
}
|
|
16459
16464
|
return fetch(input2, init);
|
|
16460
16465
|
}
|
|
16461
|
-
var
|
|
16466
|
+
var log29, TelegramAdapter;
|
|
16462
16467
|
var init_adapter2 = __esm({
|
|
16463
16468
|
"src/plugins/telegram/adapter.ts"() {
|
|
16464
16469
|
"use strict";
|
|
@@ -16477,7 +16482,7 @@ var init_adapter2 = __esm({
|
|
|
16477
16482
|
init_messaging_adapter();
|
|
16478
16483
|
init_renderer2();
|
|
16479
16484
|
init_output_mode_resolver();
|
|
16480
|
-
|
|
16485
|
+
log29 = createChildLogger({ module: "telegram" });
|
|
16481
16486
|
TelegramAdapter = class extends MessagingAdapter {
|
|
16482
16487
|
name = "telegram";
|
|
16483
16488
|
renderer = new TelegramRenderer();
|
|
@@ -16604,7 +16609,7 @@ var init_adapter2 = __esm({
|
|
|
16604
16609
|
);
|
|
16605
16610
|
this.bot.catch((err) => {
|
|
16606
16611
|
const rootCause = err.error instanceof Error ? err.error : err;
|
|
16607
|
-
|
|
16612
|
+
log29.error({ err: rootCause }, "Telegram bot error");
|
|
16608
16613
|
});
|
|
16609
16614
|
this.bot.api.config.use(async (prev, method, payload, signal) => {
|
|
16610
16615
|
const maxRetries = 3;
|
|
@@ -16622,7 +16627,7 @@ var init_adapter2 = __esm({
|
|
|
16622
16627
|
if (rateLimitedMethods.includes(method)) {
|
|
16623
16628
|
this.sendQueue.onRateLimited();
|
|
16624
16629
|
}
|
|
16625
|
-
|
|
16630
|
+
log29.warn(
|
|
16626
16631
|
{ method, retryAfter, attempt: attempt + 1 },
|
|
16627
16632
|
"Rate limited by Telegram, retrying"
|
|
16628
16633
|
);
|
|
@@ -16810,9 +16815,9 @@ ${p2}` : p2;
|
|
|
16810
16815
|
this.setupRoutes();
|
|
16811
16816
|
this.bot.start({
|
|
16812
16817
|
allowed_updates: ["message", "callback_query"],
|
|
16813
|
-
onStart: () =>
|
|
16818
|
+
onStart: () => log29.info({ chatId: this.telegramConfig.chatId }, "Telegram bot started")
|
|
16814
16819
|
});
|
|
16815
|
-
|
|
16820
|
+
log29.info(
|
|
16816
16821
|
{
|
|
16817
16822
|
chatId: this.telegramConfig.chatId,
|
|
16818
16823
|
notificationTopicId: this.telegramConfig.notificationTopicId,
|
|
@@ -16826,12 +16831,12 @@ ${p2}` : p2;
|
|
|
16826
16831
|
this.telegramConfig.chatId
|
|
16827
16832
|
);
|
|
16828
16833
|
if (prereqResult.ok) {
|
|
16829
|
-
|
|
16834
|
+
log29.info("Telegram adapter: prerequisites OK, initializing topic-dependent features");
|
|
16830
16835
|
await this.initTopicDependentFeatures();
|
|
16831
16836
|
} else {
|
|
16832
|
-
|
|
16837
|
+
log29.warn({ issues: prereqResult.issues }, "Telegram adapter: prerequisites NOT met, starting watcher");
|
|
16833
16838
|
for (const issue of prereqResult.issues) {
|
|
16834
|
-
|
|
16839
|
+
log29.warn({ issue }, "Telegram prerequisite not met");
|
|
16835
16840
|
}
|
|
16836
16841
|
this.startPrerequisiteWatcher(prereqResult.issues);
|
|
16837
16842
|
}
|
|
@@ -16847,7 +16852,7 @@ ${p2}` : p2;
|
|
|
16847
16852
|
} catch (err) {
|
|
16848
16853
|
if (attempt === maxRetries) throw err;
|
|
16849
16854
|
const delay = baseDelayMs * Math.pow(2, attempt - 1);
|
|
16850
|
-
|
|
16855
|
+
log29.warn(
|
|
16851
16856
|
{ err, attempt, maxRetries, delayMs: delay, operation: label },
|
|
16852
16857
|
`${label} failed, retrying in ${delay}ms`
|
|
16853
16858
|
);
|
|
@@ -16867,12 +16872,12 @@ ${p2}` : p2;
|
|
|
16867
16872
|
}),
|
|
16868
16873
|
"setMyCommands"
|
|
16869
16874
|
).catch((err) => {
|
|
16870
|
-
|
|
16875
|
+
log29.warn({ err }, "Failed to register Telegram commands after retries (non-critical)");
|
|
16871
16876
|
});
|
|
16872
16877
|
}
|
|
16873
16878
|
async initTopicDependentFeatures() {
|
|
16874
16879
|
if (this._topicsInitialized) return;
|
|
16875
|
-
|
|
16880
|
+
log29.info(
|
|
16876
16881
|
{ notificationTopicId: this.telegramConfig.notificationTopicId, assistantTopicId: this.telegramConfig.assistantTopicId },
|
|
16877
16882
|
"initTopicDependentFeatures: starting (existing IDs in config)"
|
|
16878
16883
|
);
|
|
@@ -16897,7 +16902,7 @@ ${p2}` : p2;
|
|
|
16897
16902
|
this.assistantTopicId = topics.assistantTopicId;
|
|
16898
16903
|
this._systemTopicIds.notificationTopicId = topics.notificationTopicId;
|
|
16899
16904
|
this._systemTopicIds.assistantTopicId = topics.assistantTopicId;
|
|
16900
|
-
|
|
16905
|
+
log29.info(
|
|
16901
16906
|
{ notificationTopicId: this.notificationTopicId, assistantTopicId: this.assistantTopicId },
|
|
16902
16907
|
"initTopicDependentFeatures: topics ready"
|
|
16903
16908
|
);
|
|
@@ -16928,7 +16933,7 @@ ${p2}` : p2;
|
|
|
16928
16933
|
).then((msg) => {
|
|
16929
16934
|
if (msg) this.storeControlMsgId(sessionId, msg.message_id);
|
|
16930
16935
|
}).catch((err) => {
|
|
16931
|
-
|
|
16936
|
+
log29.warn({ err, sessionId }, "Failed to send initial messages for new session");
|
|
16932
16937
|
});
|
|
16933
16938
|
};
|
|
16934
16939
|
this.core.eventBus.on("session:threadReady", this._threadReadyHandler);
|
|
@@ -16937,7 +16942,7 @@ ${p2}` : p2;
|
|
|
16937
16942
|
});
|
|
16938
16943
|
};
|
|
16939
16944
|
this.core.eventBus.on("session:configChanged", this._configChangedHandler);
|
|
16940
|
-
|
|
16945
|
+
log29.info({ assistantTopicId: this.assistantTopicId }, "initTopicDependentFeatures: sending welcome message");
|
|
16941
16946
|
try {
|
|
16942
16947
|
const config = this.core.configManager.get();
|
|
16943
16948
|
const agents = this.core.agentManager.getAvailableAgents();
|
|
@@ -16959,17 +16964,17 @@ ${p2}` : p2;
|
|
|
16959
16964
|
this.core.lifecycleManager?.serviceRegistry?.get("menu-registry")
|
|
16960
16965
|
)
|
|
16961
16966
|
});
|
|
16962
|
-
|
|
16967
|
+
log29.info("initTopicDependentFeatures: welcome message sent");
|
|
16963
16968
|
} catch (err) {
|
|
16964
|
-
|
|
16969
|
+
log29.warn({ err }, "Failed to send welcome message");
|
|
16965
16970
|
}
|
|
16966
16971
|
try {
|
|
16967
16972
|
await this.core.assistantManager.spawn("telegram", String(this.assistantTopicId));
|
|
16968
16973
|
} catch (err) {
|
|
16969
|
-
|
|
16974
|
+
log29.error({ err }, "Failed to spawn assistant");
|
|
16970
16975
|
}
|
|
16971
16976
|
this._topicsInitialized = true;
|
|
16972
|
-
|
|
16977
|
+
log29.info("Telegram adapter fully initialized");
|
|
16973
16978
|
}
|
|
16974
16979
|
startPrerequisiteWatcher(issues) {
|
|
16975
16980
|
const setupMessage = `\u26A0\uFE0F <b>OpenACP needs setup before it can start.</b>
|
|
@@ -16980,7 +16985,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16980
16985
|
this.bot.api.sendMessage(this.telegramConfig.chatId, setupMessage, {
|
|
16981
16986
|
parse_mode: "HTML"
|
|
16982
16987
|
}).catch((err) => {
|
|
16983
|
-
|
|
16988
|
+
log29.warn({ err }, "Failed to send setup guidance to General topic");
|
|
16984
16989
|
});
|
|
16985
16990
|
const schedule = [5e3, 1e4, 3e4];
|
|
16986
16991
|
let attempt = 1;
|
|
@@ -16993,7 +16998,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
16993
16998
|
);
|
|
16994
16999
|
if (result.ok) {
|
|
16995
17000
|
this._prerequisiteWatcher = null;
|
|
16996
|
-
|
|
17001
|
+
log29.info("Prerequisites met \u2014 completing Telegram adapter initialization");
|
|
16997
17002
|
try {
|
|
16998
17003
|
await this.initTopicDependentFeatures();
|
|
16999
17004
|
await this.bot.api.sendMessage(
|
|
@@ -17002,11 +17007,11 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
17002
17007
|
{ parse_mode: "HTML" }
|
|
17003
17008
|
);
|
|
17004
17009
|
} catch (err) {
|
|
17005
|
-
|
|
17010
|
+
log29.error({ err }, "Failed to complete initialization after prerequisites met");
|
|
17006
17011
|
}
|
|
17007
17012
|
return;
|
|
17008
17013
|
}
|
|
17009
|
-
|
|
17014
|
+
log29.debug({ issues: result.issues }, "Prerequisites not yet met, retrying");
|
|
17010
17015
|
const delay = schedule[Math.min(attempt, schedule.length - 1)];
|
|
17011
17016
|
attempt++;
|
|
17012
17017
|
this._prerequisiteWatcher = setTimeout(retry, delay);
|
|
@@ -17032,7 +17037,7 @@ OpenACP will automatically retry until this is resolved.`;
|
|
|
17032
17037
|
}
|
|
17033
17038
|
this.sendQueue.clear();
|
|
17034
17039
|
await this.bot.stop();
|
|
17035
|
-
|
|
17040
|
+
log29.info("Telegram bot stopped");
|
|
17036
17041
|
}
|
|
17037
17042
|
// --- CommandRegistry response rendering ---
|
|
17038
17043
|
async renderCommandResponse(response, chatId, topicId) {
|
|
@@ -17117,6 +17122,13 @@ ${lines.join("\n")}`;
|
|
|
17117
17122
|
}
|
|
17118
17123
|
setupRoutes() {
|
|
17119
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
|
+
}
|
|
17120
17132
|
const threadId = ctx.message.message_thread_id;
|
|
17121
17133
|
const text6 = ctx.message.text;
|
|
17122
17134
|
if (!threadId) {
|
|
@@ -17149,7 +17161,7 @@ ${lines.join("\n")}`;
|
|
|
17149
17161
|
threadId: String(threadId),
|
|
17150
17162
|
userId: String(ctx.from.id),
|
|
17151
17163
|
text: forwardText
|
|
17152
|
-
}).catch((err) =>
|
|
17164
|
+
}).catch((err) => log29.error({ err }, "handleMessage error"));
|
|
17153
17165
|
});
|
|
17154
17166
|
this.bot.on("message:photo", async (ctx) => {
|
|
17155
17167
|
const threadId = ctx.message.message_thread_id;
|
|
@@ -17238,7 +17250,7 @@ ${lines.join("\n")}`;
|
|
|
17238
17250
|
if (session.archiving) return;
|
|
17239
17251
|
const threadId = Number(session.threadId);
|
|
17240
17252
|
if (!threadId || isNaN(threadId)) {
|
|
17241
|
-
|
|
17253
|
+
log29.warn(
|
|
17242
17254
|
{ sessionId, threadId: session.threadId },
|
|
17243
17255
|
"Session has no valid threadId, skipping message"
|
|
17244
17256
|
);
|
|
@@ -17254,7 +17266,7 @@ ${lines.join("\n")}`;
|
|
|
17254
17266
|
this._sessionThreadIds.delete(sessionId);
|
|
17255
17267
|
}
|
|
17256
17268
|
}).catch((err) => {
|
|
17257
|
-
|
|
17269
|
+
log29.warn({ err, sessionId }, "Dispatch queue error");
|
|
17258
17270
|
});
|
|
17259
17271
|
this._dispatchQueues.set(sessionId, next);
|
|
17260
17272
|
await next;
|
|
@@ -17376,7 +17388,7 @@ ${lines.join("\n")}`;
|
|
|
17376
17388
|
);
|
|
17377
17389
|
usageMsgId = result?.message_id;
|
|
17378
17390
|
} catch (err) {
|
|
17379
|
-
|
|
17391
|
+
log29.warn({ err, sessionId }, "Failed to send usage message");
|
|
17380
17392
|
}
|
|
17381
17393
|
if (this.notificationTopicId && sessionId !== this.core.assistantManager?.get("telegram")?.id) {
|
|
17382
17394
|
const sess = this.core.sessionManager.getSession(sessionId);
|
|
@@ -17404,7 +17416,7 @@ Task completed.
|
|
|
17404
17416
|
if (!content.attachment) return;
|
|
17405
17417
|
const { attachment } = content;
|
|
17406
17418
|
if (attachment.size > 50 * 1024 * 1024) {
|
|
17407
|
-
|
|
17419
|
+
log29.warn(
|
|
17408
17420
|
{
|
|
17409
17421
|
sessionId,
|
|
17410
17422
|
fileName: attachment.fileName,
|
|
@@ -17448,7 +17460,7 @@ Task completed.
|
|
|
17448
17460
|
);
|
|
17449
17461
|
}
|
|
17450
17462
|
} catch (err) {
|
|
17451
|
-
|
|
17463
|
+
log29.error(
|
|
17452
17464
|
{ err, sessionId, fileName: attachment.fileName },
|
|
17453
17465
|
"Failed to send attachment"
|
|
17454
17466
|
);
|
|
@@ -17547,7 +17559,7 @@ Task completed.
|
|
|
17547
17559
|
}
|
|
17548
17560
|
async sendPermissionRequest(sessionId, request) {
|
|
17549
17561
|
this.getTracer(sessionId)?.log("telegram", { action: "permission:send", sessionId, requestId: request.id, description: request.description });
|
|
17550
|
-
|
|
17562
|
+
log29.info({ sessionId, requestId: request.id }, "Permission request sent");
|
|
17551
17563
|
const session = this.core.sessionManager.getSession(sessionId);
|
|
17552
17564
|
if (!session) return;
|
|
17553
17565
|
await this.sendQueue.enqueue(
|
|
@@ -17557,7 +17569,7 @@ Task completed.
|
|
|
17557
17569
|
async sendNotification(notification) {
|
|
17558
17570
|
this.getTracer(notification.sessionId)?.log("telegram", { action: "notification:send", sessionId: notification.sessionId, type: notification.type });
|
|
17559
17571
|
if (notification.sessionId === this.core.assistantManager?.get("telegram")?.id) return;
|
|
17560
|
-
|
|
17572
|
+
log29.info(
|
|
17561
17573
|
{ sessionId: notification.sessionId, type: notification.type },
|
|
17562
17574
|
"Notification sent"
|
|
17563
17575
|
);
|
|
@@ -17596,7 +17608,7 @@ Task completed.
|
|
|
17596
17608
|
}
|
|
17597
17609
|
async createSessionThread(sessionId, name) {
|
|
17598
17610
|
this.getTracer(sessionId)?.log("telegram", { action: "thread:create", sessionId, name });
|
|
17599
|
-
|
|
17611
|
+
log29.info({ sessionId, name }, "Session topic created");
|
|
17600
17612
|
return String(
|
|
17601
17613
|
await createSessionTopic(this.bot, this.telegramConfig.chatId, name)
|
|
17602
17614
|
);
|
|
@@ -17607,7 +17619,7 @@ Task completed.
|
|
|
17607
17619
|
if (!session) return;
|
|
17608
17620
|
const threadId = Number(session.threadId);
|
|
17609
17621
|
if (!threadId) {
|
|
17610
|
-
|
|
17622
|
+
log29.debug({ sessionId, newName }, "Cannot rename thread \u2014 threadId not set yet");
|
|
17611
17623
|
return;
|
|
17612
17624
|
}
|
|
17613
17625
|
await renameSessionTopic(
|
|
@@ -17626,7 +17638,7 @@ Task completed.
|
|
|
17626
17638
|
try {
|
|
17627
17639
|
await this.bot.api.deleteForumTopic(this.telegramConfig.chatId, topicId);
|
|
17628
17640
|
} catch (err) {
|
|
17629
|
-
|
|
17641
|
+
log29.warn(
|
|
17630
17642
|
{ err, sessionId, topicId },
|
|
17631
17643
|
"Failed to delete forum topic (may already be deleted)"
|
|
17632
17644
|
);
|
|
@@ -17670,7 +17682,7 @@ Task completed.
|
|
|
17670
17682
|
const buffer = Buffer.from(await response.arrayBuffer());
|
|
17671
17683
|
return { buffer, filePath: file.file_path };
|
|
17672
17684
|
} catch (err) {
|
|
17673
|
-
|
|
17685
|
+
log29.error({ err }, "Failed to download file from Telegram");
|
|
17674
17686
|
return null;
|
|
17675
17687
|
}
|
|
17676
17688
|
}
|
|
@@ -17691,7 +17703,7 @@ Task completed.
|
|
|
17691
17703
|
try {
|
|
17692
17704
|
buffer = await this.fileService.convertOggToWav(buffer);
|
|
17693
17705
|
} catch (err) {
|
|
17694
|
-
|
|
17706
|
+
log29.warn({ err }, "OGG\u2192WAV conversion failed, saving original OGG");
|
|
17695
17707
|
fileName = "voice.ogg";
|
|
17696
17708
|
mimeType = "audio/ogg";
|
|
17697
17709
|
originalFilePath = void 0;
|
|
@@ -17723,7 +17735,7 @@ Task completed.
|
|
|
17723
17735
|
userId: String(userId),
|
|
17724
17736
|
text: text6,
|
|
17725
17737
|
attachments: [att]
|
|
17726
|
-
}).catch((err) =>
|
|
17738
|
+
}).catch((err) => log29.error({ err }, "handleMessage error"));
|
|
17727
17739
|
}
|
|
17728
17740
|
async cleanupSkillCommands(sessionId) {
|
|
17729
17741
|
this._pendingSkillCommands.delete(sessionId);
|
|
@@ -19102,7 +19114,7 @@ function resolveAgentCommand(cmd) {
|
|
|
19102
19114
|
}
|
|
19103
19115
|
return { command: cmd, args: [] };
|
|
19104
19116
|
}
|
|
19105
|
-
var
|
|
19117
|
+
var log31, AgentInstance;
|
|
19106
19118
|
var init_agent_instance = __esm({
|
|
19107
19119
|
"src/core/agents/agent-instance.ts"() {
|
|
19108
19120
|
"use strict";
|
|
@@ -19116,7 +19128,7 @@ var init_agent_instance = __esm({
|
|
|
19116
19128
|
init_mcp_manager();
|
|
19117
19129
|
init_debug_tracer();
|
|
19118
19130
|
init_log();
|
|
19119
|
-
|
|
19131
|
+
log31 = createChildLogger({ module: "agent-instance" });
|
|
19120
19132
|
AgentInstance = class _AgentInstance extends TypedEmitter {
|
|
19121
19133
|
connection;
|
|
19122
19134
|
child;
|
|
@@ -19146,7 +19158,7 @@ var init_agent_instance = __esm({
|
|
|
19146
19158
|
static async spawnSubprocess(agentDef, workingDirectory) {
|
|
19147
19159
|
const instance = new _AgentInstance(agentDef.name);
|
|
19148
19160
|
const resolved = resolveAgentCommand(agentDef.command);
|
|
19149
|
-
|
|
19161
|
+
log31.debug(
|
|
19150
19162
|
{
|
|
19151
19163
|
agentName: agentDef.name,
|
|
19152
19164
|
command: resolved.command,
|
|
@@ -19231,14 +19243,14 @@ var init_agent_instance = __esm({
|
|
|
19231
19243
|
}
|
|
19232
19244
|
});
|
|
19233
19245
|
if (initResponse.protocolVersion !== PROTOCOL_VERSION) {
|
|
19234
|
-
|
|
19246
|
+
log31.warn(
|
|
19235
19247
|
{ expected: PROTOCOL_VERSION, got: initResponse.protocolVersion },
|
|
19236
19248
|
"ACP protocol version mismatch \u2014 some features may not work correctly"
|
|
19237
19249
|
);
|
|
19238
19250
|
}
|
|
19239
19251
|
instance.promptCapabilities = initResponse.agentCapabilities?.promptCapabilities;
|
|
19240
19252
|
instance.agentCapabilities = initResponse.agentCapabilities;
|
|
19241
|
-
|
|
19253
|
+
log31.info(
|
|
19242
19254
|
{ promptCapabilities: instance.promptCapabilities ?? {} },
|
|
19243
19255
|
"Agent prompt capabilities"
|
|
19244
19256
|
);
|
|
@@ -19247,7 +19259,7 @@ var init_agent_instance = __esm({
|
|
|
19247
19259
|
setupCrashDetection() {
|
|
19248
19260
|
this.child.on("exit", (code, signal) => {
|
|
19249
19261
|
if (this._destroying) return;
|
|
19250
|
-
|
|
19262
|
+
log31.info(
|
|
19251
19263
|
{ sessionId: this.sessionId, exitCode: code, signal },
|
|
19252
19264
|
"Agent process exited"
|
|
19253
19265
|
);
|
|
@@ -19263,11 +19275,11 @@ ${stderr}`
|
|
|
19263
19275
|
}
|
|
19264
19276
|
});
|
|
19265
19277
|
this.connection.closed.then(() => {
|
|
19266
|
-
|
|
19278
|
+
log31.debug({ sessionId: this.sessionId }, "ACP connection closed");
|
|
19267
19279
|
});
|
|
19268
19280
|
}
|
|
19269
19281
|
static async spawn(agentDef, workingDirectory, mcpServers) {
|
|
19270
|
-
|
|
19282
|
+
log31.debug(
|
|
19271
19283
|
{ agentName: agentDef.name, command: agentDef.command },
|
|
19272
19284
|
"Spawning agent"
|
|
19273
19285
|
);
|
|
@@ -19281,12 +19293,12 @@ ${stderr}`
|
|
|
19281
19293
|
cwd: workingDirectory,
|
|
19282
19294
|
mcpServers: resolvedMcp
|
|
19283
19295
|
});
|
|
19284
|
-
|
|
19296
|
+
log31.info(response, "newSession response");
|
|
19285
19297
|
instance.sessionId = response.sessionId;
|
|
19286
19298
|
instance.initialSessionResponse = response;
|
|
19287
19299
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19288
19300
|
instance.setupCrashDetection();
|
|
19289
|
-
|
|
19301
|
+
log31.info(
|
|
19290
19302
|
{
|
|
19291
19303
|
sessionId: response.sessionId,
|
|
19292
19304
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19298,7 +19310,7 @@ ${stderr}`
|
|
|
19298
19310
|
return instance;
|
|
19299
19311
|
}
|
|
19300
19312
|
static async resume(agentDef, workingDirectory, agentSessionId, mcpServers) {
|
|
19301
|
-
|
|
19313
|
+
log31.debug({ agentName: agentDef.name, agentSessionId }, "Resuming agent");
|
|
19302
19314
|
const spawnStart = Date.now();
|
|
19303
19315
|
const instance = await _AgentInstance.spawnSubprocess(
|
|
19304
19316
|
agentDef,
|
|
@@ -19315,7 +19327,7 @@ ${stderr}`
|
|
|
19315
19327
|
instance.sessionId = agentSessionId;
|
|
19316
19328
|
instance.initialSessionResponse = response;
|
|
19317
19329
|
instance.debugTracer = createDebugTracer(agentSessionId, workingDirectory);
|
|
19318
|
-
|
|
19330
|
+
log31.info(
|
|
19319
19331
|
{
|
|
19320
19332
|
sessionId: agentSessionId,
|
|
19321
19333
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19331,7 +19343,7 @@ ${stderr}`
|
|
|
19331
19343
|
instance.sessionId = response.sessionId;
|
|
19332
19344
|
instance.initialSessionResponse = response;
|
|
19333
19345
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19334
|
-
|
|
19346
|
+
log31.info(
|
|
19335
19347
|
{
|
|
19336
19348
|
sessionId: response.sessionId,
|
|
19337
19349
|
durationMs: Date.now() - spawnStart,
|
|
@@ -19341,7 +19353,7 @@ ${stderr}`
|
|
|
19341
19353
|
);
|
|
19342
19354
|
}
|
|
19343
19355
|
} catch (err) {
|
|
19344
|
-
|
|
19356
|
+
log31.warn(
|
|
19345
19357
|
{ err, agentSessionId },
|
|
19346
19358
|
"Resume failed, falling back to new session"
|
|
19347
19359
|
);
|
|
@@ -19352,7 +19364,7 @@ ${stderr}`
|
|
|
19352
19364
|
instance.sessionId = response.sessionId;
|
|
19353
19365
|
instance.initialSessionResponse = response;
|
|
19354
19366
|
instance.debugTracer = createDebugTracer(response.sessionId, workingDirectory);
|
|
19355
|
-
|
|
19367
|
+
log31.info(
|
|
19356
19368
|
{ sessionId: response.sessionId, durationMs: Date.now() - spawnStart },
|
|
19357
19369
|
"Agent fallback spawn complete"
|
|
19358
19370
|
);
|
|
@@ -19657,7 +19669,7 @@ ${stderr}`
|
|
|
19657
19669
|
contentBlocks.push({ type: "audio", data: data.toString("base64"), mimeType: att.mimeType });
|
|
19658
19670
|
} else {
|
|
19659
19671
|
if ((att.type === "image" || att.type === "audio") && !tooLarge) {
|
|
19660
|
-
|
|
19672
|
+
log31.debug(
|
|
19661
19673
|
{ type: att.type, capabilities: this.promptCapabilities ?? {} },
|
|
19662
19674
|
"Agent does not support %s content, falling back to file path",
|
|
19663
19675
|
att.type
|
|
@@ -20675,14 +20687,14 @@ var init_session_manager = __esm({
|
|
|
20675
20687
|
});
|
|
20676
20688
|
|
|
20677
20689
|
// src/core/sessions/session-bridge.ts
|
|
20678
|
-
var
|
|
20690
|
+
var log32, SessionBridge;
|
|
20679
20691
|
var init_session_bridge = __esm({
|
|
20680
20692
|
"src/core/sessions/session-bridge.ts"() {
|
|
20681
20693
|
"use strict";
|
|
20682
20694
|
init_log();
|
|
20683
20695
|
init_bypass_detection();
|
|
20684
20696
|
init_turn_context();
|
|
20685
|
-
|
|
20697
|
+
log32 = createChildLogger({ module: "session-bridge" });
|
|
20686
20698
|
SessionBridge = class {
|
|
20687
20699
|
constructor(session, adapter, deps, adapterId) {
|
|
20688
20700
|
this.session = session;
|
|
@@ -20711,16 +20723,16 @@ var init_session_bridge = __esm({
|
|
|
20711
20723
|
if (!result) return;
|
|
20712
20724
|
this.tracer?.log("core", { step: "dispatch", sessionId, message: result.message });
|
|
20713
20725
|
this.adapter.sendMessage(sessionId, result.message).catch((err) => {
|
|
20714
|
-
|
|
20726
|
+
log32.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20715
20727
|
});
|
|
20716
20728
|
} else {
|
|
20717
20729
|
this.tracer?.log("core", { step: "dispatch", sessionId, message });
|
|
20718
20730
|
this.adapter.sendMessage(sessionId, message).catch((err) => {
|
|
20719
|
-
|
|
20731
|
+
log32.error({ err, sessionId }, "Failed to send message to adapter");
|
|
20720
20732
|
});
|
|
20721
20733
|
}
|
|
20722
20734
|
} catch (err) {
|
|
20723
|
-
|
|
20735
|
+
log32.error({ err, sessionId }, "Error in sendMessage middleware");
|
|
20724
20736
|
}
|
|
20725
20737
|
}
|
|
20726
20738
|
/** Determine if this bridge should forward the given event based on turn routing. */
|
|
@@ -20762,7 +20774,7 @@ var init_session_bridge = __esm({
|
|
|
20762
20774
|
try {
|
|
20763
20775
|
await this.adapter.sendPermissionRequest(this.session.id, request);
|
|
20764
20776
|
} catch (err) {
|
|
20765
|
-
|
|
20777
|
+
log32.error({ err, sessionId: this.session.id, adapterId: this.adapterId }, "Failed to send permission request to adapter");
|
|
20766
20778
|
}
|
|
20767
20779
|
});
|
|
20768
20780
|
this.listen(this.session, "status_change", (from, to) => {
|
|
@@ -20842,14 +20854,14 @@ var init_session_bridge = __esm({
|
|
|
20842
20854
|
try {
|
|
20843
20855
|
this.handleAgentEvent(event);
|
|
20844
20856
|
} catch (err) {
|
|
20845
|
-
|
|
20857
|
+
log32.error({ err, sessionId: this.session.id }, "Error handling agent event (middleware fallback)");
|
|
20846
20858
|
}
|
|
20847
20859
|
}
|
|
20848
20860
|
} else {
|
|
20849
20861
|
try {
|
|
20850
20862
|
this.handleAgentEvent(event);
|
|
20851
20863
|
} catch (err) {
|
|
20852
|
-
|
|
20864
|
+
log32.error({ err, sessionId: this.session.id }, "Error handling agent event");
|
|
20853
20865
|
}
|
|
20854
20866
|
}
|
|
20855
20867
|
}
|
|
@@ -20913,7 +20925,7 @@ var init_session_bridge = __esm({
|
|
|
20913
20925
|
text: "",
|
|
20914
20926
|
attachment: att
|
|
20915
20927
|
});
|
|
20916
|
-
}).catch((err) =>
|
|
20928
|
+
}).catch((err) => log32.error({ err }, "Failed to save agent image"));
|
|
20917
20929
|
}
|
|
20918
20930
|
break;
|
|
20919
20931
|
}
|
|
@@ -20930,12 +20942,12 @@ var init_session_bridge = __esm({
|
|
|
20930
20942
|
text: "",
|
|
20931
20943
|
attachment: att
|
|
20932
20944
|
});
|
|
20933
|
-
}).catch((err) =>
|
|
20945
|
+
}).catch((err) => log32.error({ err }, "Failed to save agent audio"));
|
|
20934
20946
|
}
|
|
20935
20947
|
break;
|
|
20936
20948
|
}
|
|
20937
20949
|
case "commands_update":
|
|
20938
|
-
|
|
20950
|
+
log32.debug({ commands: event.commands }, "Commands available");
|
|
20939
20951
|
this.adapter.sendSkillCommands?.(this.session.id, event.commands);
|
|
20940
20952
|
break;
|
|
20941
20953
|
case "system_message":
|
|
@@ -21031,7 +21043,7 @@ var init_session_bridge = __esm({
|
|
|
21031
21043
|
if (isAgentBypass || isClientBypass) {
|
|
21032
21044
|
const allowOption = request.options.find((o) => o.isAllow);
|
|
21033
21045
|
if (allowOption) {
|
|
21034
|
-
|
|
21046
|
+
log32.info(
|
|
21035
21047
|
{ sessionId: this.session.id, requestId: request.id, optionId: allowOption.id, agentBypass: !!isAgentBypass, clientBypass: !!isClientBypass },
|
|
21036
21048
|
"Bypass mode: auto-approving permission"
|
|
21037
21049
|
);
|
|
@@ -21204,13 +21216,13 @@ function computeLineDiff(oldStr, newStr) {
|
|
|
21204
21216
|
removed: Math.max(0, oldLines.length - prefixLen - suffixLen)
|
|
21205
21217
|
};
|
|
21206
21218
|
}
|
|
21207
|
-
var
|
|
21219
|
+
var log33, BINARY_VIEWER_EXTENSIONS, MessageTransformer;
|
|
21208
21220
|
var init_message_transformer = __esm({
|
|
21209
21221
|
"src/core/message-transformer.ts"() {
|
|
21210
21222
|
"use strict";
|
|
21211
21223
|
init_extract_file_info();
|
|
21212
21224
|
init_log();
|
|
21213
|
-
|
|
21225
|
+
log33 = createChildLogger({ module: "message-transformer" });
|
|
21214
21226
|
BINARY_VIEWER_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
21215
21227
|
".wav",
|
|
21216
21228
|
".ogg",
|
|
@@ -21413,14 +21425,14 @@ var init_message_transformer = __esm({
|
|
|
21413
21425
|
}
|
|
21414
21426
|
}
|
|
21415
21427
|
if (!this.tunnelService || !sessionContext) {
|
|
21416
|
-
|
|
21428
|
+
log33.debug(
|
|
21417
21429
|
{ hasTunnel: !!this.tunnelService, hasCtx: !!sessionContext, kind },
|
|
21418
21430
|
"enrichWithViewerLinks: skipping (no tunnel or session context)"
|
|
21419
21431
|
);
|
|
21420
21432
|
return;
|
|
21421
21433
|
}
|
|
21422
21434
|
const name = "name" in event ? event.name || "" : "";
|
|
21423
|
-
|
|
21435
|
+
log33.debug(
|
|
21424
21436
|
{ name, kind, status: event.status, hasContent: !!event.content, hasRawInput: !!event.rawInput },
|
|
21425
21437
|
"enrichWithViewerLinks: inspecting event"
|
|
21426
21438
|
);
|
|
@@ -21432,7 +21444,7 @@ var init_message_transformer = __esm({
|
|
|
21432
21444
|
event.meta
|
|
21433
21445
|
);
|
|
21434
21446
|
if (!fileInfo) {
|
|
21435
|
-
|
|
21447
|
+
log33.debug(
|
|
21436
21448
|
{ name, kind, hasContent: !!event.content, hasRawInput: !!event.rawInput, hasMeta: !!event.meta },
|
|
21437
21449
|
"enrichWithViewerLinks: extractFileInfo returned null"
|
|
21438
21450
|
);
|
|
@@ -21440,15 +21452,15 @@ var init_message_transformer = __esm({
|
|
|
21440
21452
|
}
|
|
21441
21453
|
const fileExt = path45.extname(fileInfo.filePath).toLowerCase();
|
|
21442
21454
|
if (BINARY_VIEWER_EXTENSIONS.has(fileExt)) {
|
|
21443
|
-
|
|
21455
|
+
log33.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping binary file");
|
|
21444
21456
|
return;
|
|
21445
21457
|
}
|
|
21446
21458
|
const publicUrl = this.tunnelService.getPublicUrl();
|
|
21447
21459
|
if (publicUrl.startsWith("http://localhost") || publicUrl.startsWith("http://127.0.0.1")) {
|
|
21448
|
-
|
|
21460
|
+
log33.debug({ kind, filePath: fileInfo.filePath }, "enrichWithViewerLinks: skipping (no public tunnel URL)");
|
|
21449
21461
|
return;
|
|
21450
21462
|
}
|
|
21451
|
-
|
|
21463
|
+
log33.info(
|
|
21452
21464
|
{
|
|
21453
21465
|
name,
|
|
21454
21466
|
kind,
|
|
@@ -21494,12 +21506,12 @@ var init_message_transformer = __esm({
|
|
|
21494
21506
|
// src/core/sessions/session-store.ts
|
|
21495
21507
|
import fs42 from "fs";
|
|
21496
21508
|
import path46 from "path";
|
|
21497
|
-
var
|
|
21509
|
+
var log34, DEBOUNCE_MS3, JsonFileSessionStore;
|
|
21498
21510
|
var init_session_store = __esm({
|
|
21499
21511
|
"src/core/sessions/session-store.ts"() {
|
|
21500
21512
|
"use strict";
|
|
21501
21513
|
init_log();
|
|
21502
|
-
|
|
21514
|
+
log34 = createChildLogger({ module: "session-store" });
|
|
21503
21515
|
DEBOUNCE_MS3 = 2e3;
|
|
21504
21516
|
JsonFileSessionStore = class {
|
|
21505
21517
|
records = /* @__PURE__ */ new Map();
|
|
@@ -21593,7 +21605,7 @@ var init_session_store = __esm({
|
|
|
21593
21605
|
fs42.readFileSync(this.filePath, "utf-8")
|
|
21594
21606
|
);
|
|
21595
21607
|
if (raw.version !== 1) {
|
|
21596
|
-
|
|
21608
|
+
log34.warn(
|
|
21597
21609
|
{ version: raw.version },
|
|
21598
21610
|
"Unknown session store version, skipping load"
|
|
21599
21611
|
);
|
|
@@ -21602,9 +21614,9 @@ var init_session_store = __esm({
|
|
|
21602
21614
|
for (const [id, record] of Object.entries(raw.sessions)) {
|
|
21603
21615
|
this.records.set(id, this.migrateRecord(record));
|
|
21604
21616
|
}
|
|
21605
|
-
|
|
21617
|
+
log34.debug({ count: this.records.size }, "Loaded session records");
|
|
21606
21618
|
} catch (err) {
|
|
21607
|
-
|
|
21619
|
+
log34.error({ err }, "Failed to load session store, backing up corrupt file");
|
|
21608
21620
|
try {
|
|
21609
21621
|
fs42.renameSync(this.filePath, `${this.filePath}.bak`);
|
|
21610
21622
|
} catch {
|
|
@@ -21640,7 +21652,7 @@ var init_session_store = __esm({
|
|
|
21640
21652
|
}
|
|
21641
21653
|
}
|
|
21642
21654
|
if (removed > 0) {
|
|
21643
|
-
|
|
21655
|
+
log34.info({ removed }, "Cleaned up expired session records");
|
|
21644
21656
|
this.scheduleDiskWrite();
|
|
21645
21657
|
}
|
|
21646
21658
|
}
|
|
@@ -21655,13 +21667,13 @@ var init_session_store = __esm({
|
|
|
21655
21667
|
});
|
|
21656
21668
|
|
|
21657
21669
|
// src/core/sessions/session-factory.ts
|
|
21658
|
-
var
|
|
21670
|
+
var log35, SessionFactory;
|
|
21659
21671
|
var init_session_factory = __esm({
|
|
21660
21672
|
"src/core/sessions/session-factory.ts"() {
|
|
21661
21673
|
"use strict";
|
|
21662
21674
|
init_session2();
|
|
21663
21675
|
init_log();
|
|
21664
|
-
|
|
21676
|
+
log35 = createChildLogger({ module: "session-factory" });
|
|
21665
21677
|
SessionFactory = class {
|
|
21666
21678
|
constructor(agentManager, sessionManager, speechServiceAccessor, eventBus, instanceRoot) {
|
|
21667
21679
|
this.agentManager = agentManager;
|
|
@@ -21722,7 +21734,7 @@ var init_session_factory = __esm({
|
|
|
21722
21734
|
createParams.resumeAgentSessionId
|
|
21723
21735
|
);
|
|
21724
21736
|
} catch (resumeErr) {
|
|
21725
|
-
|
|
21737
|
+
log35.warn(
|
|
21726
21738
|
{ agentName: createParams.agentName, resumeErr },
|
|
21727
21739
|
"Agent session resume failed, falling back to fresh spawn"
|
|
21728
21740
|
);
|
|
@@ -21855,10 +21867,10 @@ var init_session_factory = __esm({
|
|
|
21855
21867
|
session.setAgentCapabilities(record.acpState.agentCapabilities);
|
|
21856
21868
|
}
|
|
21857
21869
|
}
|
|
21858
|
-
|
|
21870
|
+
log35.info({ sessionId }, "Lazy resume by ID successful");
|
|
21859
21871
|
return session;
|
|
21860
21872
|
} catch (err) {
|
|
21861
|
-
|
|
21873
|
+
log35.error({ err, sessionId }, "Lazy resume by ID failed");
|
|
21862
21874
|
return null;
|
|
21863
21875
|
} finally {
|
|
21864
21876
|
this.resumeLocks.delete(sessionId);
|
|
@@ -21878,18 +21890,18 @@ var init_session_factory = __esm({
|
|
|
21878
21890
|
(p2) => String(p2.topicId) === threadId || String(p2.threadId ?? "") === threadId
|
|
21879
21891
|
);
|
|
21880
21892
|
if (!record) {
|
|
21881
|
-
|
|
21893
|
+
log35.debug({ threadId, channelId }, "No session record found for thread");
|
|
21882
21894
|
return null;
|
|
21883
21895
|
}
|
|
21884
21896
|
if (record.status === "error" || record.status === "cancelled") {
|
|
21885
|
-
|
|
21897
|
+
log35.warn(
|
|
21886
21898
|
{ threadId, sessionId: record.sessionId, status: record.status },
|
|
21887
21899
|
"Session record found but skipped (status: %s) \u2014 use /new to start a fresh session",
|
|
21888
21900
|
record.status
|
|
21889
21901
|
);
|
|
21890
21902
|
return null;
|
|
21891
21903
|
}
|
|
21892
|
-
|
|
21904
|
+
log35.info({ threadId, sessionId: record.sessionId, status: record.status }, "Lazy resume: found record, attempting resume");
|
|
21893
21905
|
const resumePromise = (async () => {
|
|
21894
21906
|
try {
|
|
21895
21907
|
const session = await this.createFullSession({
|
|
@@ -21930,7 +21942,7 @@ var init_session_factory = __esm({
|
|
|
21930
21942
|
}
|
|
21931
21943
|
const resumeFalledBack = record.agentSessionId && session.agentSessionId !== record.agentSessionId;
|
|
21932
21944
|
if (resumeFalledBack) {
|
|
21933
|
-
|
|
21945
|
+
log35.info({ sessionId: session.id }, "Resume fell back to fresh spawn \u2014 injecting conversation history");
|
|
21934
21946
|
const contextManager = this.getContextManager?.();
|
|
21935
21947
|
if (contextManager) {
|
|
21936
21948
|
try {
|
|
@@ -21947,10 +21959,10 @@ var init_session_factory = __esm({
|
|
|
21947
21959
|
}
|
|
21948
21960
|
}
|
|
21949
21961
|
}
|
|
21950
|
-
|
|
21962
|
+
log35.info({ sessionId: session.id, threadId }, "Lazy resume successful");
|
|
21951
21963
|
return session;
|
|
21952
21964
|
} catch (err) {
|
|
21953
|
-
|
|
21965
|
+
log35.error({ err, record }, "Lazy resume failed");
|
|
21954
21966
|
const adapter = this.adapters?.get(channelId);
|
|
21955
21967
|
if (adapter) {
|
|
21956
21968
|
try {
|
|
@@ -21975,7 +21987,7 @@ var init_session_factory = __esm({
|
|
|
21975
21987
|
}
|
|
21976
21988
|
const config = this.configManager.get();
|
|
21977
21989
|
const resolvedAgent = agentName || config.defaultAgent;
|
|
21978
|
-
|
|
21990
|
+
log35.info({ channelId, agentName: resolvedAgent }, "New session request");
|
|
21979
21991
|
const agentDef = this.agentCatalog.resolve(resolvedAgent);
|
|
21980
21992
|
const resolvedWorkspace = this.configManager.resolveWorkspace(
|
|
21981
21993
|
workspacePath || agentDef?.workingDirectory
|
|
@@ -22024,7 +22036,7 @@ var init_session_factory = __esm({
|
|
|
22024
22036
|
params.contextOptions
|
|
22025
22037
|
);
|
|
22026
22038
|
} catch (err) {
|
|
22027
|
-
|
|
22039
|
+
log35.warn({ err }, "Context building failed, proceeding without context");
|
|
22028
22040
|
}
|
|
22029
22041
|
}
|
|
22030
22042
|
const session = await this.createFullSession({
|
|
@@ -22073,13 +22085,13 @@ var init_session_factory = __esm({
|
|
|
22073
22085
|
});
|
|
22074
22086
|
|
|
22075
22087
|
// src/core/agent-switch-handler.ts
|
|
22076
|
-
var
|
|
22088
|
+
var log36, AgentSwitchHandler;
|
|
22077
22089
|
var init_agent_switch_handler = __esm({
|
|
22078
22090
|
"src/core/agent-switch-handler.ts"() {
|
|
22079
22091
|
"use strict";
|
|
22080
22092
|
init_agent_registry();
|
|
22081
22093
|
init_log();
|
|
22082
|
-
|
|
22094
|
+
log36 = createChildLogger({ module: "agent-switch" });
|
|
22083
22095
|
AgentSwitchHandler = class {
|
|
22084
22096
|
constructor(deps) {
|
|
22085
22097
|
this.deps = deps;
|
|
@@ -22153,7 +22165,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22153
22165
|
resumed = true;
|
|
22154
22166
|
return instance2;
|
|
22155
22167
|
} catch {
|
|
22156
|
-
|
|
22168
|
+
log36.warn({ sessionId, toAgent }, "Resume failed, falling back to new agent with context injection");
|
|
22157
22169
|
}
|
|
22158
22170
|
}
|
|
22159
22171
|
const instance = await agentManager.spawn(toAgent, session.workingDirectory);
|
|
@@ -22222,10 +22234,10 @@ var init_agent_switch_handler = __esm({
|
|
|
22222
22234
|
createBridge(session, adapter, adapterId).connect();
|
|
22223
22235
|
}
|
|
22224
22236
|
}
|
|
22225
|
-
|
|
22237
|
+
log36.warn({ sessionId, fromAgent, toAgent, err }, "Agent switch failed, rolled back to previous agent");
|
|
22226
22238
|
} catch (rollbackErr) {
|
|
22227
22239
|
session.fail(`Switch failed and rollback failed: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`);
|
|
22228
|
-
|
|
22240
|
+
log36.error({ sessionId, fromAgent, toAgent, err, rollbackErr }, "Agent switch failed and rollback also failed");
|
|
22229
22241
|
}
|
|
22230
22242
|
throw err;
|
|
22231
22243
|
}
|
|
@@ -22235,7 +22247,7 @@ var init_agent_switch_handler = __esm({
|
|
|
22235
22247
|
if (adapter) {
|
|
22236
22248
|
createBridge(session, adapter, adapterId).connect();
|
|
22237
22249
|
} else {
|
|
22238
|
-
|
|
22250
|
+
log36.warn({ sessionId, adapterId }, "Adapter not available during switch reconnect, skipping bridge");
|
|
22239
22251
|
}
|
|
22240
22252
|
}
|
|
22241
22253
|
}
|
|
@@ -22268,12 +22280,12 @@ import * as fs43 from "fs";
|
|
|
22268
22280
|
import * as path47 from "path";
|
|
22269
22281
|
import * as os20 from "os";
|
|
22270
22282
|
import { z as z10 } from "zod";
|
|
22271
|
-
var
|
|
22283
|
+
var log37, InstalledAgentSchema, AgentStoreSchema, AgentStore;
|
|
22272
22284
|
var init_agent_store = __esm({
|
|
22273
22285
|
"src/core/agents/agent-store.ts"() {
|
|
22274
22286
|
"use strict";
|
|
22275
22287
|
init_log();
|
|
22276
|
-
|
|
22288
|
+
log37 = createChildLogger({ module: "agent-store" });
|
|
22277
22289
|
InstalledAgentSchema = z10.object({
|
|
22278
22290
|
registryId: z10.string().nullable(),
|
|
22279
22291
|
name: z10.string(),
|
|
@@ -22307,11 +22319,11 @@ var init_agent_store = __esm({
|
|
|
22307
22319
|
if (result.success) {
|
|
22308
22320
|
this.data = result.data;
|
|
22309
22321
|
} else {
|
|
22310
|
-
|
|
22322
|
+
log37.warn({ errors: result.error.issues }, "Invalid agents.json, starting fresh");
|
|
22311
22323
|
this.data = { version: 1, installed: {} };
|
|
22312
22324
|
}
|
|
22313
22325
|
} catch (err) {
|
|
22314
|
-
|
|
22326
|
+
log37.warn({ err }, "Failed to read agents.json, starting fresh");
|
|
22315
22327
|
this.data = { version: 1, installed: {} };
|
|
22316
22328
|
}
|
|
22317
22329
|
}
|
|
@@ -22353,7 +22365,7 @@ __export(agent_catalog_exports, {
|
|
|
22353
22365
|
import * as fs44 from "fs";
|
|
22354
22366
|
import * as path48 from "path";
|
|
22355
22367
|
import * as os21 from "os";
|
|
22356
|
-
var
|
|
22368
|
+
var log38, REGISTRY_URL2, DEFAULT_TTL_HOURS, AgentCatalog;
|
|
22357
22369
|
var init_agent_catalog = __esm({
|
|
22358
22370
|
"src/core/agents/agent-catalog.ts"() {
|
|
22359
22371
|
"use strict";
|
|
@@ -22361,7 +22373,7 @@ var init_agent_catalog = __esm({
|
|
|
22361
22373
|
init_agent_installer();
|
|
22362
22374
|
init_agent_dependencies();
|
|
22363
22375
|
init_log();
|
|
22364
|
-
|
|
22376
|
+
log38 = createChildLogger({ module: "agent-catalog" });
|
|
22365
22377
|
REGISTRY_URL2 = "https://cdn.agentclientprotocol.com/registry/v1/latest/registry.json";
|
|
22366
22378
|
DEFAULT_TTL_HOURS = 24;
|
|
22367
22379
|
AgentCatalog = class {
|
|
@@ -22382,7 +22394,7 @@ var init_agent_catalog = __esm({
|
|
|
22382
22394
|
// --- Registry ---
|
|
22383
22395
|
async fetchRegistry() {
|
|
22384
22396
|
try {
|
|
22385
|
-
|
|
22397
|
+
log38.info("Fetching agent registry from CDN...");
|
|
22386
22398
|
const response = await fetch(REGISTRY_URL2);
|
|
22387
22399
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
22388
22400
|
const data = await response.json();
|
|
@@ -22394,9 +22406,9 @@ var init_agent_catalog = __esm({
|
|
|
22394
22406
|
};
|
|
22395
22407
|
fs44.mkdirSync(path48.dirname(this.cachePath), { recursive: true });
|
|
22396
22408
|
fs44.writeFileSync(this.cachePath, JSON.stringify(cache, null, 2), { mode: 384 });
|
|
22397
|
-
|
|
22409
|
+
log38.info({ count: this.registryAgents.length }, "Registry updated");
|
|
22398
22410
|
} catch (err) {
|
|
22399
|
-
|
|
22411
|
+
log38.warn({ err }, "Failed to fetch registry, using cached data");
|
|
22400
22412
|
}
|
|
22401
22413
|
}
|
|
22402
22414
|
async refreshRegistryIfStale() {
|
|
@@ -22557,7 +22569,7 @@ var init_agent_catalog = __esm({
|
|
|
22557
22569
|
}
|
|
22558
22570
|
}
|
|
22559
22571
|
if (changed) {
|
|
22560
|
-
|
|
22572
|
+
log38.info("Enriched installed agents with registry data");
|
|
22561
22573
|
}
|
|
22562
22574
|
}
|
|
22563
22575
|
isCacheStale() {
|
|
@@ -22577,11 +22589,11 @@ var init_agent_catalog = __esm({
|
|
|
22577
22589
|
const raw = JSON.parse(fs44.readFileSync(this.cachePath, "utf-8"));
|
|
22578
22590
|
if (raw.data?.agents) {
|
|
22579
22591
|
this.registryAgents = raw.data.agents;
|
|
22580
|
-
|
|
22592
|
+
log38.debug({ count: this.registryAgents.length }, "Loaded registry from cache");
|
|
22581
22593
|
return;
|
|
22582
22594
|
}
|
|
22583
22595
|
} catch {
|
|
22584
|
-
|
|
22596
|
+
log38.warn("Failed to load registry cache");
|
|
22585
22597
|
}
|
|
22586
22598
|
}
|
|
22587
22599
|
try {
|
|
@@ -22594,13 +22606,13 @@ var init_agent_catalog = __esm({
|
|
|
22594
22606
|
if (fs44.existsSync(candidate)) {
|
|
22595
22607
|
const raw = JSON.parse(fs44.readFileSync(candidate, "utf-8"));
|
|
22596
22608
|
this.registryAgents = raw.agents ?? [];
|
|
22597
|
-
|
|
22609
|
+
log38.debug({ count: this.registryAgents.length }, "Loaded registry from bundled snapshot");
|
|
22598
22610
|
return;
|
|
22599
22611
|
}
|
|
22600
22612
|
}
|
|
22601
|
-
|
|
22613
|
+
log38.warn("No registry data available (no cache, no snapshot)");
|
|
22602
22614
|
} catch {
|
|
22603
|
-
|
|
22615
|
+
log38.warn("Failed to load bundled registry snapshot");
|
|
22604
22616
|
}
|
|
22605
22617
|
}
|
|
22606
22618
|
};
|
|
@@ -22986,7 +22998,7 @@ function createPluginContext(opts) {
|
|
|
22986
22998
|
}
|
|
22987
22999
|
};
|
|
22988
23000
|
const baseLog = opts.log ?? noopLog;
|
|
22989
|
-
const
|
|
23001
|
+
const log47 = typeof baseLog.child === "function" ? baseLog.child({ plugin: pluginName }) : baseLog;
|
|
22990
23002
|
const storageImpl = new PluginStorageImpl(storagePath);
|
|
22991
23003
|
const storage = {
|
|
22992
23004
|
async get(key) {
|
|
@@ -23013,7 +23025,7 @@ function createPluginContext(opts) {
|
|
|
23013
23025
|
const ctx = {
|
|
23014
23026
|
pluginName,
|
|
23015
23027
|
pluginConfig,
|
|
23016
|
-
log:
|
|
23028
|
+
log: log47,
|
|
23017
23029
|
storage,
|
|
23018
23030
|
on(event, handler) {
|
|
23019
23031
|
requirePermission(permissions, "events:read", "on()");
|
|
@@ -23048,7 +23060,7 @@ function createPluginContext(opts) {
|
|
|
23048
23060
|
const registry = serviceRegistry.get("command-registry");
|
|
23049
23061
|
if (registry && typeof registry.register === "function") {
|
|
23050
23062
|
registry.register(def, pluginName);
|
|
23051
|
-
|
|
23063
|
+
log47.debug(`Command '/${def.name}' registered`);
|
|
23052
23064
|
}
|
|
23053
23065
|
},
|
|
23054
23066
|
async sendMessage(_sessionId, _content) {
|
|
@@ -23091,7 +23103,7 @@ function createPluginContext(opts) {
|
|
|
23091
23103
|
const registry = serviceRegistry.get("field-registry");
|
|
23092
23104
|
if (registry && typeof registry.register === "function") {
|
|
23093
23105
|
registry.register(pluginName, fields);
|
|
23094
|
-
|
|
23106
|
+
log47.debug(`Registered ${fields.length} editable field(s) for ${pluginName}`);
|
|
23095
23107
|
}
|
|
23096
23108
|
},
|
|
23097
23109
|
get sessions() {
|
|
@@ -23423,12 +23435,12 @@ var init_lifecycle_manager = __esm({
|
|
|
23423
23435
|
});
|
|
23424
23436
|
|
|
23425
23437
|
// src/core/menu-registry.ts
|
|
23426
|
-
var
|
|
23438
|
+
var log39, MenuRegistry;
|
|
23427
23439
|
var init_menu_registry = __esm({
|
|
23428
23440
|
"src/core/menu-registry.ts"() {
|
|
23429
23441
|
"use strict";
|
|
23430
23442
|
init_log();
|
|
23431
|
-
|
|
23443
|
+
log39 = createChildLogger({ module: "menu-registry" });
|
|
23432
23444
|
MenuRegistry = class {
|
|
23433
23445
|
items = /* @__PURE__ */ new Map();
|
|
23434
23446
|
register(item) {
|
|
@@ -23447,7 +23459,7 @@ var init_menu_registry = __esm({
|
|
|
23447
23459
|
try {
|
|
23448
23460
|
return item.visible();
|
|
23449
23461
|
} catch (err) {
|
|
23450
|
-
|
|
23462
|
+
log39.warn({ err, id: item.id }, "MenuItem visible() threw, hiding item");
|
|
23451
23463
|
return false;
|
|
23452
23464
|
}
|
|
23453
23465
|
}).sort((a, b) => a.priority - b.priority);
|
|
@@ -23520,13 +23532,13 @@ Talk to users like a helpful assistant, not a CLI manual.`;
|
|
|
23520
23532
|
});
|
|
23521
23533
|
|
|
23522
23534
|
// src/core/assistant/assistant-registry.ts
|
|
23523
|
-
var
|
|
23535
|
+
var log40, AssistantRegistry;
|
|
23524
23536
|
var init_assistant_registry = __esm({
|
|
23525
23537
|
"src/core/assistant/assistant-registry.ts"() {
|
|
23526
23538
|
"use strict";
|
|
23527
23539
|
init_log();
|
|
23528
23540
|
init_prompt_constants();
|
|
23529
|
-
|
|
23541
|
+
log40 = createChildLogger({ module: "assistant-registry" });
|
|
23530
23542
|
AssistantRegistry = class {
|
|
23531
23543
|
sections = /* @__PURE__ */ new Map();
|
|
23532
23544
|
_instanceRoot = "";
|
|
@@ -23536,7 +23548,7 @@ var init_assistant_registry = __esm({
|
|
|
23536
23548
|
}
|
|
23537
23549
|
register(section) {
|
|
23538
23550
|
if (this.sections.has(section.id)) {
|
|
23539
|
-
|
|
23551
|
+
log40.warn({ id: section.id }, "Assistant section overwritten");
|
|
23540
23552
|
}
|
|
23541
23553
|
this.sections.set(section.id, section);
|
|
23542
23554
|
}
|
|
@@ -23561,7 +23573,7 @@ ${context}`);
|
|
|
23561
23573
|
parts.push("```bash\n" + cmds + "\n```");
|
|
23562
23574
|
}
|
|
23563
23575
|
} catch (err) {
|
|
23564
|
-
|
|
23576
|
+
log40.warn({ err, sectionId: section.id }, "Assistant section buildContext() failed, skipping");
|
|
23565
23577
|
}
|
|
23566
23578
|
}
|
|
23567
23579
|
parts.push(buildAssistantGuidelines(this._instanceRoot));
|
|
@@ -23572,12 +23584,12 @@ ${context}`);
|
|
|
23572
23584
|
});
|
|
23573
23585
|
|
|
23574
23586
|
// src/core/assistant/assistant-manager.ts
|
|
23575
|
-
var
|
|
23587
|
+
var log41, AssistantManager;
|
|
23576
23588
|
var init_assistant_manager = __esm({
|
|
23577
23589
|
"src/core/assistant/assistant-manager.ts"() {
|
|
23578
23590
|
"use strict";
|
|
23579
23591
|
init_log();
|
|
23580
|
-
|
|
23592
|
+
log41 = createChildLogger({ module: "assistant-manager" });
|
|
23581
23593
|
AssistantManager = class {
|
|
23582
23594
|
constructor(core, registry) {
|
|
23583
23595
|
this.core = core;
|
|
@@ -23598,7 +23610,7 @@ var init_assistant_manager = __esm({
|
|
|
23598
23610
|
this.sessions.set(channelId, session);
|
|
23599
23611
|
const systemPrompt = this.registry.buildSystemPrompt(channelId);
|
|
23600
23612
|
this.pendingSystemPrompts.set(channelId, systemPrompt);
|
|
23601
|
-
|
|
23613
|
+
log41.info({ sessionId: session.id, channelId }, "Assistant spawned (system prompt deferred)");
|
|
23602
23614
|
return session;
|
|
23603
23615
|
}
|
|
23604
23616
|
get(channelId) {
|
|
@@ -23844,7 +23856,7 @@ var init_core_items = __esm({
|
|
|
23844
23856
|
import path51 from "path";
|
|
23845
23857
|
import os23 from "os";
|
|
23846
23858
|
import { nanoid as nanoid5 } from "nanoid";
|
|
23847
|
-
var
|
|
23859
|
+
var log42, OpenACPCore;
|
|
23848
23860
|
var init_core = __esm({
|
|
23849
23861
|
"src/core/core.ts"() {
|
|
23850
23862
|
"use strict";
|
|
@@ -23868,7 +23880,7 @@ var init_core = __esm({
|
|
|
23868
23880
|
init_middleware_chain();
|
|
23869
23881
|
init_error_tracker();
|
|
23870
23882
|
init_log();
|
|
23871
|
-
|
|
23883
|
+
log42 = createChildLogger({ module: "core" });
|
|
23872
23884
|
OpenACPCore = class {
|
|
23873
23885
|
configManager;
|
|
23874
23886
|
agentCatalog;
|
|
@@ -23983,7 +23995,7 @@ var init_core = __esm({
|
|
|
23983
23995
|
if (configPath === "logging.level" && typeof value === "string") {
|
|
23984
23996
|
const { setLogLevel: setLogLevel2 } = await Promise.resolve().then(() => (init_log(), log_exports));
|
|
23985
23997
|
setLogLevel2(value);
|
|
23986
|
-
|
|
23998
|
+
log42.info({ level: value }, "Log level changed at runtime");
|
|
23987
23999
|
}
|
|
23988
24000
|
if (configPath.startsWith("speech.")) {
|
|
23989
24001
|
const speechSvc = this.lifecycleManager.serviceRegistry.get("speech");
|
|
@@ -24007,7 +24019,7 @@ var init_core = __esm({
|
|
|
24007
24019
|
}
|
|
24008
24020
|
};
|
|
24009
24021
|
speechSvc.refreshProviders(newSpeechConfig);
|
|
24010
|
-
|
|
24022
|
+
log42.info("Speech service config updated at runtime (from plugin settings)");
|
|
24011
24023
|
}
|
|
24012
24024
|
}
|
|
24013
24025
|
}
|
|
@@ -24037,14 +24049,14 @@ var init_core = __esm({
|
|
|
24037
24049
|
}
|
|
24038
24050
|
async start() {
|
|
24039
24051
|
this.agentCatalog.refreshRegistryIfStale().catch((err) => {
|
|
24040
|
-
|
|
24052
|
+
log42.warn({ err }, "Background registry refresh failed");
|
|
24041
24053
|
});
|
|
24042
24054
|
const failures = [];
|
|
24043
24055
|
for (const [name, adapter] of this.adapters.entries()) {
|
|
24044
24056
|
try {
|
|
24045
24057
|
await adapter.start();
|
|
24046
24058
|
} catch (err) {
|
|
24047
|
-
|
|
24059
|
+
log42.error({ err, adapter: name }, `Adapter "${name}" failed to start`);
|
|
24048
24060
|
failures.push({ name, error: err });
|
|
24049
24061
|
}
|
|
24050
24062
|
}
|
|
@@ -24092,7 +24104,7 @@ var init_core = __esm({
|
|
|
24092
24104
|
}
|
|
24093
24105
|
// --- Message Routing ---
|
|
24094
24106
|
async handleMessage(message) {
|
|
24095
|
-
|
|
24107
|
+
log42.debug(
|
|
24096
24108
|
{
|
|
24097
24109
|
channelId: message.channelId,
|
|
24098
24110
|
threadId: message.threadId,
|
|
@@ -24111,7 +24123,7 @@ var init_core = __esm({
|
|
|
24111
24123
|
}
|
|
24112
24124
|
const access2 = await this.securityGuard.checkAccess(message);
|
|
24113
24125
|
if (!access2.allowed) {
|
|
24114
|
-
|
|
24126
|
+
log42.warn({ userId: message.userId, reason: access2.reason }, "Access denied");
|
|
24115
24127
|
if (access2.reason.includes("Session limit")) {
|
|
24116
24128
|
const adapter = this.adapters.get(message.channelId);
|
|
24117
24129
|
if (adapter) {
|
|
@@ -24125,7 +24137,7 @@ var init_core = __esm({
|
|
|
24125
24137
|
}
|
|
24126
24138
|
let session = await this.sessionFactory.getOrResume(message.channelId, message.threadId);
|
|
24127
24139
|
if (!session) {
|
|
24128
|
-
|
|
24140
|
+
log42.warn(
|
|
24129
24141
|
{ channelId: message.channelId, threadId: message.threadId },
|
|
24130
24142
|
"No session found for thread (in-memory miss + lazy resume returned null)"
|
|
24131
24143
|
);
|
|
@@ -24223,7 +24235,7 @@ ${text6}`;
|
|
|
24223
24235
|
const bridge = this.createBridge(session, adapter, session.channelId);
|
|
24224
24236
|
bridge.connect();
|
|
24225
24237
|
adapter.flushPendingSkillCommands?.(session.id).catch((err) => {
|
|
24226
|
-
|
|
24238
|
+
log42.warn({ err, sessionId: session.id }, "Failed to flush pending skill commands");
|
|
24227
24239
|
});
|
|
24228
24240
|
if (params.createThread && session.threadId) {
|
|
24229
24241
|
this.eventBus.emit("session:threadReady", {
|
|
@@ -24237,14 +24249,14 @@ ${text6}`;
|
|
|
24237
24249
|
session.agentInstance.onPermissionRequest = async (permRequest) => {
|
|
24238
24250
|
const allowOption = permRequest.options.find((o) => o.isAllow);
|
|
24239
24251
|
if (!allowOption) {
|
|
24240
|
-
|
|
24252
|
+
log42.warn(
|
|
24241
24253
|
{ sessionId: session.id, permissionId: permRequest.id, description: permRequest.description },
|
|
24242
24254
|
"Headless session has no allow option for permission request \u2014 skipping auto-approve, will time out"
|
|
24243
24255
|
);
|
|
24244
24256
|
return new Promise(() => {
|
|
24245
24257
|
});
|
|
24246
24258
|
}
|
|
24247
|
-
|
|
24259
|
+
log42.warn(
|
|
24248
24260
|
{ sessionId: session.id, permissionId: permRequest.id, option: allowOption.id },
|
|
24249
24261
|
`Auto-approving permission "${permRequest.description}" for headless session \u2014 no adapter connected`
|
|
24250
24262
|
);
|
|
@@ -24256,7 +24268,7 @@ ${text6}`;
|
|
|
24256
24268
|
notificationManager: this.notificationManager,
|
|
24257
24269
|
tunnelService: this._tunnelService
|
|
24258
24270
|
});
|
|
24259
|
-
|
|
24271
|
+
log42.info(
|
|
24260
24272
|
{ sessionId: session.id, agentName: params.agentName },
|
|
24261
24273
|
"Session created via pipeline"
|
|
24262
24274
|
);
|
|
@@ -25247,7 +25259,7 @@ function registerCategoryCommand(registry, core, category, commandName) {
|
|
|
25247
25259
|
core.eventBus.emit("session:configChanged", { sessionId: session.id });
|
|
25248
25260
|
return { type: "text", text: labels.successMsg(match.name, configOption.name) };
|
|
25249
25261
|
} catch (err) {
|
|
25250
|
-
|
|
25262
|
+
log43.error({ err, commandName, configId: configOption.id }, "setConfigOption failed");
|
|
25251
25263
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25252
25264
|
return { type: "error", message: `Could not change ${commandName}: ${msg}` };
|
|
25253
25265
|
}
|
|
@@ -25312,7 +25324,7 @@ function registerDangerousCommand(registry, core) {
|
|
|
25312
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."
|
|
25313
25325
|
};
|
|
25314
25326
|
} catch (err) {
|
|
25315
|
-
|
|
25327
|
+
log43.error({ err }, "setConfigOption failed (bypass toggle)");
|
|
25316
25328
|
const msg = err instanceof Error ? err.message : typeof err === "object" && err !== null && typeof err.message === "string" ? err.message : String(err);
|
|
25317
25329
|
return { type: "error", message: `Could not toggle bypass: ${msg}` };
|
|
25318
25330
|
}
|
|
@@ -25336,14 +25348,14 @@ function registerConfigCommands(registry, _core) {
|
|
|
25336
25348
|
registerCategoryCommand(registry, core, "thought_level", "thought");
|
|
25337
25349
|
registerDangerousCommand(registry, core);
|
|
25338
25350
|
}
|
|
25339
|
-
var
|
|
25351
|
+
var log43, CATEGORY_LABELS;
|
|
25340
25352
|
var init_config6 = __esm({
|
|
25341
25353
|
"src/core/commands/config.ts"() {
|
|
25342
25354
|
"use strict";
|
|
25343
25355
|
init_log();
|
|
25344
25356
|
init_bypass_detection();
|
|
25345
25357
|
init_bypass_detection();
|
|
25346
|
-
|
|
25358
|
+
log43 = createChildLogger({ module: "commands/config" });
|
|
25347
25359
|
CATEGORY_LABELS = {
|
|
25348
25360
|
mode: {
|
|
25349
25361
|
menuTitle: (cur) => `Choose session mode (current: ${cur})`,
|
|
@@ -25755,7 +25767,7 @@ function installAutoStart(logDir2) {
|
|
|
25755
25767
|
fs46.mkdirSync(dir, { recursive: true });
|
|
25756
25768
|
fs46.writeFileSync(LAUNCHD_PLIST_PATH, plist);
|
|
25757
25769
|
execFileSync8("launchctl", ["load", LAUNCHD_PLIST_PATH], { stdio: "pipe" });
|
|
25758
|
-
|
|
25770
|
+
log44.info("LaunchAgent installed");
|
|
25759
25771
|
return { success: true };
|
|
25760
25772
|
}
|
|
25761
25773
|
if (process.platform === "linux") {
|
|
@@ -25765,13 +25777,13 @@ function installAutoStart(logDir2) {
|
|
|
25765
25777
|
fs46.writeFileSync(SYSTEMD_SERVICE_PATH, unit);
|
|
25766
25778
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25767
25779
|
execFileSync8("systemctl", ["--user", "enable", "openacp"], { stdio: "pipe" });
|
|
25768
|
-
|
|
25780
|
+
log44.info("systemd user service installed");
|
|
25769
25781
|
return { success: true };
|
|
25770
25782
|
}
|
|
25771
25783
|
return { success: false, error: "Unsupported platform" };
|
|
25772
25784
|
} catch (e) {
|
|
25773
25785
|
const msg = e.message;
|
|
25774
|
-
|
|
25786
|
+
log44.error({ err: msg }, "Failed to install auto-start");
|
|
25775
25787
|
return { success: false, error: msg };
|
|
25776
25788
|
}
|
|
25777
25789
|
}
|
|
@@ -25787,7 +25799,7 @@ function uninstallAutoStart() {
|
|
|
25787
25799
|
} catch {
|
|
25788
25800
|
}
|
|
25789
25801
|
fs46.unlinkSync(LAUNCHD_PLIST_PATH);
|
|
25790
|
-
|
|
25802
|
+
log44.info("LaunchAgent removed");
|
|
25791
25803
|
}
|
|
25792
25804
|
return { success: true };
|
|
25793
25805
|
}
|
|
@@ -25799,14 +25811,14 @@ function uninstallAutoStart() {
|
|
|
25799
25811
|
}
|
|
25800
25812
|
fs46.unlinkSync(SYSTEMD_SERVICE_PATH);
|
|
25801
25813
|
execFileSync8("systemctl", ["--user", "daemon-reload"], { stdio: "pipe" });
|
|
25802
|
-
|
|
25814
|
+
log44.info("systemd user service removed");
|
|
25803
25815
|
}
|
|
25804
25816
|
return { success: true };
|
|
25805
25817
|
}
|
|
25806
25818
|
return { success: false, error: "Unsupported platform" };
|
|
25807
25819
|
} catch (e) {
|
|
25808
25820
|
const msg = e.message;
|
|
25809
|
-
|
|
25821
|
+
log44.error({ err: msg }, "Failed to uninstall auto-start");
|
|
25810
25822
|
return { success: false, error: msg };
|
|
25811
25823
|
}
|
|
25812
25824
|
}
|
|
@@ -25819,12 +25831,12 @@ function isAutoStartInstalled() {
|
|
|
25819
25831
|
}
|
|
25820
25832
|
return false;
|
|
25821
25833
|
}
|
|
25822
|
-
var
|
|
25834
|
+
var log44, LAUNCHD_LABEL, LAUNCHD_PLIST_PATH, SYSTEMD_SERVICE_PATH;
|
|
25823
25835
|
var init_autostart = __esm({
|
|
25824
25836
|
"src/cli/autostart.ts"() {
|
|
25825
25837
|
"use strict";
|
|
25826
25838
|
init_log();
|
|
25827
|
-
|
|
25839
|
+
log44 = createChildLogger({ module: "autostart" });
|
|
25828
25840
|
LAUNCHD_LABEL = "com.openacp.daemon";
|
|
25829
25841
|
LAUNCHD_PLIST_PATH = path52.join(os24.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
25830
25842
|
SYSTEMD_SERVICE_PATH = path52.join(os24.homedir(), ".config", "systemd", "user", "openacp.service");
|
|
@@ -25927,7 +25939,7 @@ async function setupIntegrations() {
|
|
|
25927
25939
|
if (integration) {
|
|
25928
25940
|
for (const item of integration.items) {
|
|
25929
25941
|
const result = await item.install();
|
|
25930
|
-
for (const
|
|
25942
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
25931
25943
|
}
|
|
25932
25944
|
}
|
|
25933
25945
|
console.log("Claude CLI integration installed.\n");
|
|
@@ -26869,14 +26881,14 @@ async function runPostUpgradeChecks(config) {
|
|
|
26869
26881
|
const { ensureCloudflared: ensureCloudflared2 } = await Promise.resolve().then(() => (init_install_cloudflared(), install_cloudflared_exports));
|
|
26870
26882
|
await ensureCloudflared2();
|
|
26871
26883
|
} catch (err) {
|
|
26872
|
-
|
|
26884
|
+
log46.warn(
|
|
26873
26885
|
{ err: err.message },
|
|
26874
26886
|
"Could not install cloudflared. Tunnel may not work."
|
|
26875
26887
|
);
|
|
26876
26888
|
}
|
|
26877
26889
|
} else {
|
|
26878
26890
|
if (!commandExists(tunnelProvider)) {
|
|
26879
|
-
|
|
26891
|
+
log46.warn(
|
|
26880
26892
|
`Tunnel provider "${tunnelProvider}" is not installed. Install it or switch to cloudflare (free, auto-installed).`
|
|
26881
26893
|
);
|
|
26882
26894
|
}
|
|
@@ -26890,7 +26902,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26890
26902
|
if (integration) {
|
|
26891
26903
|
const allInstalled = integration.items.every((item) => item.isInstalled());
|
|
26892
26904
|
if (!allInstalled) {
|
|
26893
|
-
|
|
26905
|
+
log46.info(
|
|
26894
26906
|
'Claude CLI integration not installed. Run "openacp integrate claude" for session transfer + tunnel skill.'
|
|
26895
26907
|
);
|
|
26896
26908
|
}
|
|
@@ -26900,7 +26912,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26900
26912
|
const { ensureJq: ensureJq2 } = await Promise.resolve().then(() => (init_install_jq(), install_jq_exports));
|
|
26901
26913
|
await ensureJq2();
|
|
26902
26914
|
} catch (err) {
|
|
26903
|
-
|
|
26915
|
+
log46.warn(
|
|
26904
26916
|
{ err: err.message },
|
|
26905
26917
|
"Could not install jq. Handoff hooks may not work."
|
|
26906
26918
|
);
|
|
@@ -26910,7 +26922,7 @@ async function runPostUpgradeChecks(config) {
|
|
|
26910
26922
|
} catch {
|
|
26911
26923
|
}
|
|
26912
26924
|
if (!commandExists("unzip")) {
|
|
26913
|
-
|
|
26925
|
+
log46.warn(
|
|
26914
26926
|
"unzip is not installed. Some agent installations (binary distribution) may fail. Install: brew install unzip (macOS) or apt install unzip (Linux)"
|
|
26915
26927
|
);
|
|
26916
26928
|
}
|
|
@@ -26923,20 +26935,20 @@ async function runPostUpgradeChecks(config) {
|
|
|
26923
26935
|
(a) => a.distribution === "uvx"
|
|
26924
26936
|
);
|
|
26925
26937
|
if (hasUvxAgent && !commandExists("uvx")) {
|
|
26926
|
-
|
|
26938
|
+
log46.warn(
|
|
26927
26939
|
"uvx is not installed but you have Python-based agents. Install: pip install uv"
|
|
26928
26940
|
);
|
|
26929
26941
|
}
|
|
26930
26942
|
} catch {
|
|
26931
26943
|
}
|
|
26932
26944
|
}
|
|
26933
|
-
var
|
|
26945
|
+
var log46;
|
|
26934
26946
|
var init_post_upgrade = __esm({
|
|
26935
26947
|
"src/cli/post-upgrade.ts"() {
|
|
26936
26948
|
"use strict";
|
|
26937
26949
|
init_log();
|
|
26938
26950
|
init_agent_dependencies();
|
|
26939
|
-
|
|
26951
|
+
log46 = createChildLogger({ module: "post-upgrade" });
|
|
26940
26952
|
}
|
|
26941
26953
|
});
|
|
26942
26954
|
|
|
@@ -30591,7 +30603,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30591
30603
|
if (uninstall) {
|
|
30592
30604
|
console.log(`Removing ${agent}/${item.id}...`);
|
|
30593
30605
|
const result = await item.uninstall();
|
|
30594
|
-
for (const
|
|
30606
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
30595
30607
|
if (result.success) {
|
|
30596
30608
|
console.log(` ${item.name} removed.`);
|
|
30597
30609
|
} else {
|
|
@@ -30601,7 +30613,7 @@ agent-native handoff command such as /openacp:handoff.
|
|
|
30601
30613
|
} else {
|
|
30602
30614
|
console.log(`Installing ${agent}/${item.id}...`);
|
|
30603
30615
|
const result = await item.install();
|
|
30604
|
-
for (const
|
|
30616
|
+
for (const log47 of result.logs) console.log(` ${log47}`);
|
|
30605
30617
|
if (result.success) {
|
|
30606
30618
|
console.log(` ${item.name} installed.`);
|
|
30607
30619
|
} else {
|