aai-lark-bridge 0.1.1 → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lark Channel Bridge contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Command } from "commander";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "aai-lark-bridge",
7
- version: "0.1.1",
7
+ version: "0.1.2",
8
8
  description: "Lark AI Native Bridge - Lark\u57FA\u7840\u8BBE\u65BD\u5C42\u548CCLI\u96C6\u6210",
9
9
  type: "module",
10
10
  main: "./dist/index.js",
@@ -29,7 +29,7 @@ var package_default = {
29
29
  },
30
30
  dependencies: {
31
31
  "@clack/prompts": "^1.4.0",
32
- "@larksuite/channel": "^0.4.1",
32
+ "@larksuite/channel": "^0.7.1",
33
33
  commander: "^12.1.0",
34
34
  "cross-spawn": "^7.0.6",
35
35
  "graceful-fs": "^4.2.11",
@@ -2393,11 +2393,11 @@ async function migrateV1ToV2(opts = {}) {
2393
2393
  }
2394
2394
  }
2395
2395
  async function assertNoActiveOldProcesses(registryFiles) {
2396
- const active2 = [];
2396
+ const active3 = [];
2397
2397
  for (const path of registryFiles) {
2398
- active2.push(...await activeOldProcessesInFile(path));
2398
+ active3.push(...await activeOldProcessesInFile(path));
2399
2399
  }
2400
- const unique = uniqueActiveProcesses(active2);
2400
+ const unique = uniqueActiveProcesses(active3);
2401
2401
  if (unique.length > 0) {
2402
2402
  throw new ActiveBridgeMigrationConflictError(unique);
2403
2403
  }
@@ -2410,45 +2410,45 @@ async function activeOldProcessesInFile(path) {
2410
2410
  if (err.code === "ENOENT") return [];
2411
2411
  throw err;
2412
2412
  }
2413
- const active2 = [];
2413
+ const active3 = [];
2414
2414
  for (const entry of registry.entries ?? []) {
2415
2415
  if (typeof entry.pid !== "number") continue;
2416
2416
  if (entry.pid === process.pid) continue;
2417
2417
  if (isAlive2(entry.pid)) {
2418
- active2.push(activeProcessFromRegistryEntry(entry));
2418
+ active3.push(activeProcessFromRegistryEntry(entry));
2419
2419
  }
2420
2420
  }
2421
- return active2;
2421
+ return active3;
2422
2422
  }
2423
2423
  function activeProcessFromRegistryEntry(entry) {
2424
- const active2 = { pid: entry.pid };
2425
- if (typeof entry.id === "string") active2.id = entry.id;
2426
- if (typeof entry.appId === "string") active2.appId = entry.appId;
2427
- if (typeof entry.tenant === "string") active2.tenant = entry.tenant;
2428
- if (typeof entry.profileName === "string") active2.profileName = entry.profileName;
2429
- if (entry.agentKind === "claude" || entry.agentKind === "codex") active2.agentKind = entry.agentKind;
2430
- if (typeof entry.configPath === "string") active2.configPath = entry.configPath;
2431
- if (typeof entry.startedAt === "string") active2.startedAt = entry.startedAt;
2432
- if (typeof entry.version === "string") active2.version = entry.version;
2433
- if (typeof entry.botName === "string") active2.botName = entry.botName;
2434
- return active2;
2424
+ const active3 = { pid: entry.pid };
2425
+ if (typeof entry.id === "string") active3.id = entry.id;
2426
+ if (typeof entry.appId === "string") active3.appId = entry.appId;
2427
+ if (typeof entry.tenant === "string") active3.tenant = entry.tenant;
2428
+ if (typeof entry.profileName === "string") active3.profileName = entry.profileName;
2429
+ if (entry.agentKind === "claude" || entry.agentKind === "codex") active3.agentKind = entry.agentKind;
2430
+ if (typeof entry.configPath === "string") active3.configPath = entry.configPath;
2431
+ if (typeof entry.startedAt === "string") active3.startedAt = entry.startedAt;
2432
+ if (typeof entry.version === "string") active3.version = entry.version;
2433
+ if (typeof entry.botName === "string") active3.botName = entry.botName;
2434
+ return active3;
2435
2435
  }
2436
2436
  function uniqueActiveProcesses(processes) {
2437
2437
  const seen = /* @__PURE__ */ new Set();
2438
2438
  const unique = [];
2439
- for (const active2 of processes) {
2440
- const key = `${active2.pid}:${active2.id ?? ""}:${active2.configPath ?? ""}`;
2439
+ for (const active3 of processes) {
2440
+ const key = `${active3.pid}:${active3.id ?? ""}:${active3.configPath ?? ""}`;
2441
2441
  if (seen.has(key)) continue;
2442
2442
  seen.add(key);
2443
- unique.push(active2);
2443
+ unique.push(active3);
2444
2444
  }
2445
2445
  return unique;
2446
2446
  }
2447
2447
  function formatActiveProcesses(processes) {
2448
- return processes.map((active2) => {
2449
- const id = active2.id ? ` id ${active2.id}` : "";
2450
- const app = active2.appId ? ` app ${active2.appId}` : "";
2451
- return `pid ${active2.pid}${id}${app}`;
2448
+ return processes.map((active3) => {
2449
+ const id = active3.id ? ` id ${active3.id}` : "";
2450
+ const app = active3.appId ? ` app ${active3.appId}` : "";
2451
+ return `pid ${active3.pid}${id}${app}`;
2452
2452
  }).join(", ");
2453
2453
  }
2454
2454
  function isAlive2(pid) {
@@ -2712,8 +2712,8 @@ async function promptAndStopActiveBridgeMigrationConflict(err, options = {}) {
2712
2712
  }
2713
2713
  async function confirmStopActiveBridgeProcesses(processes) {
2714
2714
  console.log("\u68C0\u6D4B\u5230 bridge \u6B63\u5728\u8FD0\u884C\uFF0C\u8FC1\u79FB\u9700\u8981\u5148\u505C\u6B62\u8FD9\u4E9B\u8FDB\u7A0B:");
2715
- for (const active2 of processes) {
2716
- console.log(` - ${formatActiveBridgeProcess(active2)}`);
2715
+ for (const active3 of processes) {
2716
+ console.log(` - ${formatActiveBridgeProcess(active3)}`);
2717
2717
  }
2718
2718
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
2719
2719
  throw new Error("\u68C0\u6D4B\u5230 bridge \u6B63\u5728\u8FD0\u884C\uFF1B\u975E\u4EA4\u4E92\u6A21\u5F0F\u65E0\u6CD5\u786E\u8BA4\u505C\u6B62\uFF0C\u8BF7\u5148\u505C\u6B62\u540E\u91CD\u8BD5\u8FC1\u79FB");
@@ -2722,21 +2722,21 @@ async function confirmStopActiveBridgeProcesses(processes) {
2722
2722
  return answer === "y" || answer === "yes";
2723
2723
  }
2724
2724
  async function stopActiveBridgeProcesses(processes) {
2725
- for (const active2 of processes) {
2726
- console.log(`\u6B63\u5728\u505C\u6B62 ${formatActiveBridgeProcess(active2)}...`);
2727
- const result = await stopProcessEntry(active2);
2725
+ for (const active3 of processes) {
2726
+ console.log(`\u6B63\u5728\u505C\u6B62 ${formatActiveBridgeProcess(active3)}...`);
2727
+ const result = await stopProcessEntry(active3);
2728
2728
  if (result === "killed") {
2729
- console.log(`\u2713 \u5DF2\u5F3A\u5236\u505C\u6B62 pid ${active2.pid}`);
2729
+ console.log(`\u2713 \u5DF2\u5F3A\u5236\u505C\u6B62 pid ${active3.pid}`);
2730
2730
  } else {
2731
- console.log(`\u2713 \u5DF2\u505C\u6B62 pid ${active2.pid}`);
2731
+ console.log(`\u2713 \u5DF2\u505C\u6B62 pid ${active3.pid}`);
2732
2732
  }
2733
2733
  }
2734
2734
  }
2735
- function formatActiveBridgeProcess(active2) {
2736
- const label = active2.botName ? `bot ${active2.botName}` : active2.appId ? `app ${active2.appId}` : "bridge";
2737
- const id = active2.id ? ` id=${active2.id}` : "";
2738
- const profile2 = active2.profileName ? ` profile=${active2.profileName}` : "";
2739
- return `${label}${id}${profile2} pid=${active2.pid}`;
2735
+ function formatActiveBridgeProcess(active3) {
2736
+ const label = active3.botName ? `bot ${active3.botName}` : active3.appId ? `app ${active3.appId}` : "bridge";
2737
+ const id = active3.id ? ` id=${active3.id}` : "";
2738
+ const profile2 = active3.profileName ? ` profile=${active3.profileName}` : "";
2739
+ return `${label}${id}${profile2} pid=${active3.pid}`;
2740
2740
  }
2741
2741
  async function hasLegacyProfileConfig(path) {
2742
2742
  let raw;
@@ -3002,9 +3002,9 @@ async function isLogOnlyProfileState(rootDir, profile2) {
3002
3002
  return false;
3003
3003
  }
3004
3004
  }
3005
- function profileSort(a, b, active2) {
3006
- if (a === active2) return -1;
3007
- if (b === active2) return 1;
3005
+ function profileSort(a, b, active3) {
3006
+ if (a === active3) return -1;
3007
+ if (b === active3) return 1;
3008
3008
  return a.localeCompare(b);
3009
3009
  }
3010
3010
 
@@ -8094,11 +8094,11 @@ function renderToolGroup(tools, finalized) {
8094
8094
  if (latest) out.push(toolPanel(latest, true));
8095
8095
  return out;
8096
8096
  }
8097
- function reasoningPanel(content, active2) {
8098
- const title = active2 ? "\u{1F9E0} **\u601D\u8003\u4E2D**" : "\u{1F9E0} **\u601D\u8003\u5B8C\u6210\uFF0C\u70B9\u51FB\u67E5\u770B**";
8097
+ function reasoningPanel(content, active3) {
8098
+ const title = active3 ? "\u{1F9E0} **\u601D\u8003\u4E2D**" : "\u{1F9E0} **\u601D\u8003\u5B8C\u6210\uFF0C\u70B9\u51FB\u67E5\u770B**";
8099
8099
  return collapsiblePanel({
8100
8100
  title,
8101
- expanded: active2,
8101
+ expanded: active3,
8102
8102
  border: "grey",
8103
8103
  body: truncate3(content, REASONING_MAX)
8104
8104
  });
@@ -11605,14 +11605,14 @@ function forwardToAgent(deps, payload, formValue, scope, threadId, mode) {
11605
11605
  }
11606
11606
  function verifyBridgeToken(deps, payload, scope, action) {
11607
11607
  const token = typeof payload.bridge_token === "string" ? payload.bridge_token : "";
11608
- const active2 = deps.activeRuns.get(scope);
11609
- if (!deps.callbackAuth || !token || !active2) {
11608
+ const active3 = deps.activeRuns.get(scope);
11609
+ if (!deps.callbackAuth || !token || !active3) {
11610
11610
  log.info("cardAction", "skip-callback-auth-missing", { scope, action });
11611
11611
  log.warn("callback", "denied", { scope, action, reason: "missing-token-or-run" });
11612
11612
  return false;
11613
11613
  }
11614
11614
  const result = deps.callbackAuth.verify(token, {
11615
- runId: active2.run.runId,
11615
+ runId: active3.run.runId,
11616
11616
  scope,
11617
11617
  chatId: deps.evt.chatId,
11618
11618
  operatorOpenId: deps.evt.operator.openId,
@@ -11715,8 +11715,8 @@ var CallbackAuth = class {
11715
11715
  return { ok: true, payload };
11716
11716
  }
11717
11717
  signingKey() {
11718
- const active2 = this.keys.filter((key2) => !key2.retired);
11719
- const key = active2.at(-1);
11718
+ const active3 = this.keys.filter((key2) => !key2.retired);
11719
+ const key = active3.at(-1);
11720
11720
  if (!key) throw new Error("no active callback signing key");
11721
11721
  return key;
11722
11722
  }
@@ -13153,12 +13153,14 @@ var TIMER_STORM_GUARD_MS = 5e3;
13153
13153
  var HTTP_PROBE_TIMEOUT_MS = 5e3;
13154
13154
  var DEAD_THRESHOLD = 3;
13155
13155
  var NETWORK_DOWN_LOG_EVERY = 20;
13156
+ var MULTI_CHANNEL_TICKS = 2;
13156
13157
  function startKeepalive(deps) {
13157
- const { channel, domain, forceReconnect } = deps;
13158
+ const { channel, domain, forceReconnect, activeChannelCount: activeChannelCount2 } = deps;
13158
13159
  let lastTick = 0;
13159
13160
  let consecutiveDown = 0;
13160
13161
  let networkDownTicks = 0;
13161
13162
  let stopped = false;
13163
+ let multiChannelTicks = 0;
13162
13164
  const tick = async () => {
13163
13165
  if (stopped) return;
13164
13166
  const now = Date.now();
@@ -13174,6 +13176,15 @@ function startKeepalive(deps) {
13174
13176
  return;
13175
13177
  }
13176
13178
  lastTick = now;
13179
+ const channels = activeChannelCount2();
13180
+ if (channels > 1) {
13181
+ multiChannelTicks++;
13182
+ if (multiChannelTicks === MULTI_CHANNEL_TICKS) {
13183
+ log.warn("keepalive", "stranded-channels", { channels });
13184
+ }
13185
+ } else {
13186
+ multiChannelTicks = 0;
13187
+ }
13177
13188
  const status = channel.getConnectionStatus();
13178
13189
  if (!status) {
13179
13190
  return;
@@ -13510,6 +13521,25 @@ async function removeReaction(channel, messageId, reactionId) {
13510
13521
  }
13511
13522
  }
13512
13523
 
13524
+ // src/bridge/bot/channel-registry.ts
13525
+ var active2 = /* @__PURE__ */ new Map();
13526
+ function registerChannel(profile2) {
13527
+ const token = Symbol(profile2);
13528
+ const tokens = active2.get(profile2) ?? /* @__PURE__ */ new Set();
13529
+ tokens.add(token);
13530
+ active2.set(profile2, tokens);
13531
+ return token;
13532
+ }
13533
+ function unregisterChannel(profile2, token) {
13534
+ const tokens = active2.get(profile2);
13535
+ if (!tokens) return;
13536
+ tokens.delete(token);
13537
+ if (tokens.size === 0) active2.delete(profile2);
13538
+ }
13539
+ function activeChannelCount(profile2) {
13540
+ return active2.get(profile2)?.size ?? 0;
13541
+ }
13542
+
13513
13543
  // src/bridge/bot/cot.ts
13514
13544
  var ENDPOINTS2 = {
13515
13545
  feishu: "https://open.feishu.cn",
@@ -14050,8 +14080,18 @@ async function startChannel(deps) {
14050
14080
  });
14051
14081
  });
14052
14082
  let consecutiveReconnects = 0;
14083
+ let lastInboundAt = 0;
14084
+ const markInbound = (kind) => {
14085
+ const at = Date.now();
14086
+ log.info("ws", "inbound", {
14087
+ kind,
14088
+ ...lastInboundAt > 0 ? { gapMs: at - lastInboundAt } : { first: true }
14089
+ });
14090
+ lastInboundAt = at;
14091
+ };
14053
14092
  channel.on({
14054
14093
  message: async (msg) => {
14094
+ markInbound("message");
14055
14095
  await withTrace(
14056
14096
  { chatId: msg.chatId, msgId: msg.messageId },
14057
14097
  () => intakeMessage({
@@ -14072,9 +14112,11 @@ async function startChannel(deps) {
14072
14112
  ).catch((err) => log.fail("intake", err));
14073
14113
  },
14074
14114
  reject: (evt) => {
14115
+ markInbound("reject");
14075
14116
  log.info("intake", "reject", { chatId: evt.chatId, reason: evt.reason });
14076
14117
  },
14077
14118
  cardAction: async (evt) => {
14119
+ markInbound("card-action");
14078
14120
  await withTrace({ chatId: evt.chatId, msgId: evt.messageId }, async () => {
14079
14121
  await handleCardAction({
14080
14122
  channel,
@@ -14095,6 +14137,7 @@ async function startChannel(deps) {
14095
14137
  }).catch((err) => log.fail("cardAction", err));
14096
14138
  },
14097
14139
  comment: async (evt) => {
14140
+ markInbound("comment");
14098
14141
  await withTrace({ chatId: "comment" }, async () => {
14099
14142
  await handleCommentMention({
14100
14143
  channel,
@@ -14175,66 +14218,98 @@ async function startChannel(deps) {
14175
14218
  meetingManager.attachPush();
14176
14219
  controls.meeting = meetingManager;
14177
14220
  }
14178
- await channel.connect();
14179
- const ownerRefresh = createOwnerRefreshController({
14180
- controls,
14181
- source: channel,
14182
- appId: cfg.accounts.app.id
14183
- });
14184
- await ownerRefresh.start();
14185
- const knownChatsRefresh = startKnownChatsRefreshTimer(channel, controls);
14186
- const identity = channel.botIdentity;
14187
- if (identity?.openId) {
14188
- agent.setBotIdentity?.({
14189
- openId: identity.openId,
14190
- ...identity.name ? { name: identity.name } : {}
14221
+ const armed = [];
14222
+ try {
14223
+ await channel.connect();
14224
+ const channelToken = registerChannel(controls.profile);
14225
+ armed.push(() => unregisterChannel(controls.profile, channelToken));
14226
+ const ownerRefresh = createOwnerRefreshController({
14227
+ controls,
14228
+ source: channel,
14229
+ appId: cfg.accounts.app.id
14191
14230
  });
14192
- }
14193
- log.info("ws", "connected", {
14194
- bot: identity?.name ?? "unknown",
14195
- openId: identity?.openId ?? "-",
14196
- agent: `${agent.displayName} (${agent.id})`,
14197
- appId: cfg.accounts.app.id,
14198
- procId: controls.processId
14199
- });
14200
- console.log("\u6B63\u5728\u76D1\u542C\u6D88\u606F\u3002\u6309 Ctrl+C \u9000\u51FA\u3002\n");
14201
- const probeDomain = cfg.accounts.app.tenant === "lark" ? "https://open.larksuite.com" : "https://open.feishu.cn";
14202
- const keepalive = startKeepalive({
14203
- channel,
14204
- domain: probeDomain,
14205
- forceReconnect: () => controls.restart()
14206
- });
14207
- return {
14208
- channel,
14209
- disconnect: async () => {
14210
- activeRuns.pauseNewRuns("bridge-disconnect");
14211
- ownerRefresh.stop();
14212
- knownChatsRefresh.stop();
14213
- keepalive.stop();
14214
- meetingManager?.dispose();
14215
- controls.meeting = void 0;
14216
- pending.cancelAll();
14217
- const [disconnectResult, stopAllResult, ...flushResults] = await Promise.allSettled([
14218
- channel.disconnect(),
14219
- activeRuns.stopAll(),
14220
- sessions2.flush(),
14221
- sessionCatalog?.flush(),
14222
- callbackNonceStore?.flush(),
14223
- workspaces.flush()
14224
- ]);
14225
- if (stopAllResult.status === "rejected") {
14226
- log.fail("disconnect", stopAllResult.reason, { step: "stopAll" });
14227
- }
14228
- for (const [idx, result] of flushResults.entries()) {
14229
- if (result.status === "rejected") {
14230
- log.fail("disconnect", result.reason, { step: `flush-${idx}` });
14231
+ armed.push(() => ownerRefresh.stop());
14232
+ await ownerRefresh.start();
14233
+ const knownChatsRefresh = startKnownChatsRefreshTimer(channel, controls);
14234
+ armed.push(() => knownChatsRefresh.stop());
14235
+ const identity = channel.botIdentity;
14236
+ if (identity?.openId) {
14237
+ agent.setBotIdentity?.({
14238
+ openId: identity.openId,
14239
+ ...identity.name ? { name: identity.name } : {}
14240
+ });
14241
+ }
14242
+ log.info("ws", "connected", {
14243
+ bot: identity?.name ?? "unknown",
14244
+ openId: identity?.openId ?? "-",
14245
+ agent: `${agent.displayName} (${agent.id})`,
14246
+ appId: cfg.accounts.app.id,
14247
+ procId: controls.processId
14248
+ });
14249
+ console.log("\u6B63\u5728\u76D1\u542C\u6D88\u606F\u3002\u6309 Ctrl+C \u9000\u51FA\u3002\n");
14250
+ const probeDomain = cfg.accounts.app.tenant === "lark" ? "https://open.larksuite.com" : "https://open.feishu.cn";
14251
+ const keepalive = startKeepalive({
14252
+ channel,
14253
+ domain: probeDomain,
14254
+ forceReconnect: () => controls.restart(),
14255
+ activeChannelCount: () => activeChannelCount(controls.profile)
14256
+ });
14257
+ armed.push(() => keepalive.stop());
14258
+ return {
14259
+ channel,
14260
+ disconnect: async () => {
14261
+ activeRuns.pauseNewRuns("bridge-disconnect");
14262
+ unregisterChannel(controls.profile, channelToken);
14263
+ ownerRefresh.stop();
14264
+ knownChatsRefresh.stop();
14265
+ keepalive.stop();
14266
+ meetingManager?.dispose();
14267
+ controls.meeting = void 0;
14268
+ pending.cancelAll();
14269
+ const [disconnectResult, stopAllResult, ...flushResults] = await Promise.allSettled([
14270
+ channel.disconnect(),
14271
+ activeRuns.stopAll(),
14272
+ sessions2.flush(),
14273
+ sessionCatalog?.flush(),
14274
+ callbackNonceStore?.flush(),
14275
+ workspaces.flush()
14276
+ ]);
14277
+ if (stopAllResult.status === "rejected") {
14278
+ log.fail("disconnect", stopAllResult.reason, { step: "stopAll" });
14279
+ }
14280
+ for (const [idx, result] of flushResults.entries()) {
14281
+ if (result.status === "rejected") {
14282
+ log.fail("disconnect", result.reason, { step: `flush-${idx}` });
14283
+ }
14284
+ }
14285
+ if (disconnectResult.status === "rejected") {
14286
+ throw disconnectResult.reason;
14231
14287
  }
14232
14288
  }
14233
- if (disconnectResult.status === "rejected") {
14234
- throw disconnectResult.reason;
14289
+ };
14290
+ } catch (err) {
14291
+ for (const stop2 of armed.reverse()) {
14292
+ try {
14293
+ stop2();
14294
+ } catch {
14235
14295
  }
14236
14296
  }
14237
- };
14297
+ meetingManager?.dispose();
14298
+ controls.meeting = void 0;
14299
+ pending.cancelAll();
14300
+ await teardownChannel(channel);
14301
+ throw err;
14302
+ }
14303
+ }
14304
+ async function teardownChannel(channel) {
14305
+ try {
14306
+ await channel.disconnect();
14307
+ } catch {
14308
+ }
14309
+ try {
14310
+ channel.rawWsClient?.close({ force: true });
14311
+ } catch {
14312
+ }
14238
14313
  }
14239
14314
  function startKnownChatsRefreshTimer(channel, controls) {
14240
14315
  const intervalMs = 30 * 60 * 1e3;
@@ -17092,6 +17167,9 @@ var ManagedProfile = class {
17092
17167
  this.profileConfig = nextRuntime.profileConfig;
17093
17168
  this.agent = nextAgent;
17094
17169
  this.controls = nextControls;
17170
+ } catch (err) {
17171
+ log.warn("supervisor", "restart-failed", { profile: this.profile, err: String(err) });
17172
+ throw err;
17095
17173
  } finally {
17096
17174
  if (nextAppLock) await nextAppLock.release().catch(() => void 0);
17097
17175
  this.restarting = false;