bazilion 0.54.0 → 0.55.0

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.
Files changed (152) hide show
  1. package/dist/cli.js +10 -5
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +356 -69
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/web/client/assets/AddProviderDialog-DfFOaCjC.js +1 -0
  6. package/dist/web/client/assets/AgentTemplateParts-IMJmAQjN.js +1 -0
  7. package/dist/web/client/assets/{Button-UiegBKOK.js → Button-bTJUy9Qf.js} +1 -1
  8. package/dist/web/client/assets/{ConfigPage-CUbHBhzx.js → ConfigPage-CzLHZa5o.js} +1 -1
  9. package/dist/web/client/assets/ConfirmDialog-Cu_evkgc.js +1 -0
  10. package/dist/web/client/assets/ConnectionsView-D7Fmutl2.js +1 -0
  11. package/dist/web/client/assets/{ManagePage-BJWZd1ts.js → ManagePage-BfvlCrmz.js} +1 -1
  12. package/dist/web/client/assets/{SectionTabs-ViZKm3-B.js → SectionTabs-D7kPQGoh.js} +1 -1
  13. package/dist/web/client/assets/{Segmented-MYKKTuZO.js → Segmented-oPkAHPO1.js} +1 -1
  14. package/dist/web/client/assets/SkillsParts-BuTxcCam.js +1 -0
  15. package/dist/web/client/assets/SpawnTeamModal-B1UnOvtp.js +1 -0
  16. package/dist/web/client/assets/TeamForm-DbzxtRjj.js +1 -0
  17. package/dist/web/client/assets/TeamThread-jpsWq6vI.js +1 -0
  18. package/dist/web/client/assets/UnsavedChangesGuard-BfyU9v9i.js +1 -0
  19. package/dist/web/client/assets/_id-BCNBLF-2.js +1 -0
  20. package/dist/web/client/assets/_id-D8_H79U2.js +1 -0
  21. package/dist/web/client/assets/access-CDWe1Kwy.js +1 -0
  22. package/dist/web/client/assets/{agent-actions-BgE9fKHH.js → agent-actions-CUee6aJq.js} +1 -1
  23. package/dist/web/client/assets/agents-sE686DTf.js +1 -0
  24. package/dist/web/client/assets/agents-yrur1NDa.js +1 -0
  25. package/dist/web/client/assets/arrow-right-U66krZnr.js +1 -0
  26. package/dist/web/client/assets/attention-DYEHDfmx.js +1 -0
  27. package/dist/web/client/assets/{bot-Bb--PFVU.js → bot-BCone8es.js} +1 -1
  28. package/dist/web/client/assets/chevron-right-CuqJFXTe.js +1 -0
  29. package/dist/web/client/assets/config-BHv886pr.js +1 -0
  30. package/dist/web/client/assets/createLucideIcon-jxSFpY0Q.js +1 -0
  31. package/dist/web/client/assets/{download-C4t9l5wR.js → download-Dy88XavQ.js} +1 -1
  32. package/dist/web/client/assets/{file-text-DzbjpYrV.js → file-text-DPsZ8-h9.js} +1 -1
  33. package/dist/web/client/assets/{images-DSYgPKM7.js → images-QBh_rL8b.js} +1 -1
  34. package/dist/web/client/assets/index-GOthyyE-.js +14 -0
  35. package/dist/web/client/assets/{key-round-BpK4-E3T.js → key-round-C-I8fAG0.js} +1 -1
  36. package/dist/web/client/assets/{list-checks-JNXcmws9.js → list-checks-C9Q-bjEi.js} +1 -1
  37. package/dist/web/client/assets/{login-DcQJk5-U.js → login-Dhe15Uuc.js} +1 -1
  38. package/dist/web/client/assets/{manage-SRGSx8n2.js → manage-BaIU5zKy.js} +1 -1
  39. package/dist/web/client/assets/mcp-A_Eo7x3q.js +1 -0
  40. package/dist/web/client/assets/{message-square-DM2MP9vF.js → message-square-Bwf9cHOx.js} +1 -1
  41. package/dist/web/client/assets/{network-BJ4iPjQO.js → network-B3FA93gC.js} +1 -1
  42. package/dist/web/client/assets/{parts-LZxl9Gvc.js → parts-CpIfn_BH.js} +1 -1
  43. package/dist/web/client/assets/plus-CQPjc8uR.js +1 -0
  44. package/dist/web/client/assets/routes-CTg_yjbY.js +85 -0
  45. package/dist/web/client/assets/skills-CLjtYtkA.js +1 -0
  46. package/dist/web/client/assets/{square-terminal-Dmm6cV-G.js → square-terminal-DaNLwvEs.js} +1 -1
  47. package/dist/web/client/assets/style-mjEbxhf5.js +7 -0
  48. package/dist/web/client/assets/styles-DzcEC3Rd.css +2 -0
  49. package/dist/web/client/assets/{system-zQ0NnQML.js → system-CrTSr5_t.js} +1 -1
  50. package/dist/web/client/assets/teams-Bhje5n2h.js +1 -0
  51. package/dist/web/client/assets/teams-Cbgw0Qhv.js +1 -0
  52. package/dist/web/client/assets/telegram-HtUczmaA.js +1 -0
  53. package/dist/web/client/assets/tools-BpjFvmoX.js +1 -0
  54. package/dist/web/client/assets/use-resource-BnvgCpBi.js +1 -0
  55. package/dist/web/client/assets/{users-round-BJrym3FG.js → users-round-BElBVSnw.js} +1 -1
  56. package/dist/web/client/assets/welcome-D47LKWYO.js +1 -0
  57. package/dist/web/client/assets/{wrench-GbE1M1RJ.js → wrench-DotqSqSm.js} +1 -1
  58. package/dist/web/server/assets/{AddProviderDialog-Nc5mc_P6.js → AddProviderDialog-BbpuvC2a.js} +2 -2
  59. package/dist/web/server/assets/{AgentTemplateParts-DZK_r3nQ.js → AgentTemplateParts-Ce7snK3m.js} +1 -1
  60. package/dist/web/server/assets/{ConfigPage-CxzL-gTm.js → ConfigPage-qP9ejjuw.js} +1 -1
  61. package/dist/web/server/assets/{ConfirmDialog-4xeCXKHe.js → ConfirmDialog-Z-uYbE9B.js} +1 -1
  62. package/dist/web/server/assets/{ConnectionsView-B02FjNsM.js → ConnectionsView-CLIV7V5D.js} +7 -7
  63. package/dist/web/server/assets/{ManagePage-BfCWE8Lj.js → ManagePage-BR9FwVZM.js} +1 -1
  64. package/dist/web/server/assets/{Rail-3gbidhyv.js → Rail-b6EbjBB-.js} +6 -6
  65. package/dist/web/server/assets/{SkillsParts-D58l8voo.js → SkillsParts-DWpdydCJ.js} +1 -1
  66. package/dist/web/server/assets/{SpawnDialog-MJWwppgC.js → SpawnDialog-3wNx0W1R.js} +212 -9
  67. package/dist/web/server/assets/{SpawnTeamModal-RjzAeX_Q.js → SpawnTeamModal-C-YMvoaB.js} +1 -1
  68. package/dist/web/server/assets/{TeamForm-DdOgIMiV.js → TeamForm-CL45gBdt.js} +1 -1
  69. package/dist/web/server/assets/{TeamThread-D-PvO3fu.js → TeamThread-CVVH6kKj.js} +3 -3
  70. package/dist/web/server/assets/{UnsavedChangesGuard-Bb5frygQ.js → UnsavedChangesGuard-CXK75QQp.js} +1 -1
  71. package/dist/web/server/assets/{_id-BPjVkcNb.js → _id-2I4CSMQj.js} +6 -6
  72. package/dist/web/server/assets/{_id-C1_l6oSR.js → _id-8zsImuGa.js} +7 -7
  73. package/dist/web/server/assets/{_id-BUfy-GwH.js → _id-BpfoPuTv.js} +2 -2
  74. package/dist/web/server/assets/{_id-CHvYQhWt.js → _id-d2OwovYV.js} +2 -2
  75. package/dist/web/server/assets/_tanstack-start-manifest_v-kkY_s_uR.js +256 -0
  76. package/dist/web/server/assets/{access-CNfvQ3NB.js → access-CwZ27Wsl.js} +4 -4
  77. package/dist/web/server/assets/{access-Cm_izIIC.js → access-CyUoElTP.js} +2 -2
  78. package/dist/web/server/assets/{agent-actions-COnfW5AU.js → agent-actions-C07Cp5Ue.js} +1 -1
  79. package/dist/web/server/assets/{agents-D0hfGIMK.js → agents-CwzhpDPm.js} +5 -5
  80. package/dist/web/server/assets/{agents-DzpqlIuJ.js → agents-DCWEoaxY.js} +2 -2
  81. package/dist/web/server/assets/{agents-C7UmTjfO.js → agents-DTub-rJk.js} +2 -2
  82. package/dist/web/server/assets/{agents-NOkh61dV.js → agents-vuXrAv1j.js} +5 -5
  83. package/dist/web/server/assets/{attention-Cx9ZWPOO.js → attention-BqCnJ1hg.js} +3 -2
  84. package/dist/web/server/assets/{attention-CgWhXjX7.js → attention-Dki8rmGZ.js} +1 -0
  85. package/dist/web/server/assets/{attention-CRvxt22X.js → attention-DwGaur_w.js} +21 -8
  86. package/dist/web/server/assets/{config-B5CS8juO.js → config-B9dJiji_.js} +2 -2
  87. package/dist/web/server/assets/{config-D117117T.js → config-D3MR2VjE.js} +6 -6
  88. package/dist/web/server/assets/{createSsrRpc-CwTd0zrB.js → createSsrRpc-qesavJv-.js} +1 -1
  89. package/dist/web/server/assets/{login-va4EtvA8.js → login-CRd1yTH5.js} +1 -1
  90. package/dist/web/server/assets/{login-IF0Gbsuq.js → login-ZN6KV8n-.js} +2 -2
  91. package/dist/web/server/assets/{mcp-C96PBxpb.js → mcp-BQ15a9dG.js} +4 -4
  92. package/dist/web/server/assets/{mcp-Bm9U6x7N.js → mcp-CYQuYWGX.js} +2 -2
  93. package/dist/web/server/assets/{page-title-CwcbXMhx.js → page-title-CVY-c2Pd.js} +6 -3
  94. package/dist/web/server/assets/{router-8Iq19GOz.js → router-CPdWGKQ5.js} +192 -60
  95. package/dist/web/server/assets/{routes-Kwam6JmS.js → routes-BPloBDc8.js} +9 -6
  96. package/dist/web/server/assets/{routes-BLo-fWbQ.js → routes-Dw1K3TQw.js} +132 -31
  97. package/dist/web/server/assets/{routes-BXvYYFrN.js → routes-xDPesCQu.js} +2 -2
  98. package/dist/web/server/assets/{skills-BqCnA-74.js → skills-6VSpEORe.js} +2 -2
  99. package/dist/web/server/assets/{skills-DSezIdDc.js → skills-D0xrNc2_.js} +5 -5
  100. package/dist/web/server/assets/{style-C2hIPY_Y.js → style-aMybyKzc.js} +1 -1
  101. package/dist/web/server/assets/{system-CcLCmkIC.js → system-B5sPgdQW.js} +2 -2
  102. package/dist/web/server/assets/{system-E0VePdzO.js → system-CXmiWyDG.js} +3 -3
  103. package/dist/web/server/assets/{teams-DScFp8mK.js → teams-ClRBVSYU.js} +2 -2
  104. package/dist/web/server/assets/{teams-DxA-vnzY.js → teams-Dq4RCxis.js} +2 -2
  105. package/dist/web/server/assets/{teams-CQVV18D3.js → teams-iXiCnN2i.js} +5 -5
  106. package/dist/web/server/assets/{teams-CdCmBJIj.js → teams-yF3I_Zjq.js} +5 -5
  107. package/dist/web/server/assets/{telegram-DR7xijeS.js → telegram-D9U9c1MN.js} +2 -2
  108. package/dist/web/server/assets/{telegram-DJ8s_91Y.js → telegram-DwEgyR1x.js} +5 -5
  109. package/dist/web/server/assets/{tools-CsH9DI-4.js → tools-DflVIdDd.js} +2 -2
  110. package/dist/web/server/assets/{tools-V6kezUpL.js → tools-VPIKjr3y.js} +3 -3
  111. package/dist/web/server/assets/{use-resource-CjcJwn7F.js → use-resource-CbHGYti0.js} +1 -1
  112. package/dist/web/server/assets/{welcome-BpmcD-ia.js → welcome-7DrYZVs6.js} +2 -2
  113. package/dist/web/server/assets/{welcome-Ya8TkL4v.js → welcome-966nOyyK.js} +6 -6
  114. package/dist/web/server/server.js +4 -4
  115. package/dist/web-server.js +4 -0
  116. package/dist/web-server.js.map +1 -1
  117. package/dist/worker.js +17 -13
  118. package/dist/worker.js.map +1 -1
  119. package/package.json +4 -4
  120. package/dist/web/client/assets/AddProviderDialog-CkwSq3C7.js +0 -1
  121. package/dist/web/client/assets/AgentTemplateParts-CEn_4qVs.js +0 -1
  122. package/dist/web/client/assets/ConfirmDialog-VqBOFZEp.js +0 -1
  123. package/dist/web/client/assets/ConnectionsView-ByARMcWP.js +0 -1
  124. package/dist/web/client/assets/SkillsParts-UvNK5SYP.js +0 -1
  125. package/dist/web/client/assets/SpawnTeamModal-DG5UbJNK.js +0 -1
  126. package/dist/web/client/assets/TeamForm-DGlxWv4e.js +0 -1
  127. package/dist/web/client/assets/TeamThread-mkwODO0S.js +0 -1
  128. package/dist/web/client/assets/UnsavedChangesGuard-BmdwLH99.js +0 -1
  129. package/dist/web/client/assets/_id-CvcxNmBH.js +0 -1
  130. package/dist/web/client/assets/_id-UyBk7gRl.js +0 -1
  131. package/dist/web/client/assets/access-C8d8vaQ6.js +0 -1
  132. package/dist/web/client/assets/agents-CgtzqBpD.js +0 -1
  133. package/dist/web/client/assets/agents-D7W4BT8r.js +0 -1
  134. package/dist/web/client/assets/arrow-right-D0HKRb7U.js +0 -1
  135. package/dist/web/client/assets/attention-D9mQWoKt.js +0 -1
  136. package/dist/web/client/assets/chevron-right-bs0TUSl2.js +0 -1
  137. package/dist/web/client/assets/config-Dw6GWf38.js +0 -1
  138. package/dist/web/client/assets/createLucideIcon-DkniuEtD.js +0 -1
  139. package/dist/web/client/assets/index-YW0gXPfk.js +0 -14
  140. package/dist/web/client/assets/mcp-BUWu4TvS.js +0 -1
  141. package/dist/web/client/assets/plus-CLGNN5QX.js +0 -1
  142. package/dist/web/client/assets/routes-BxIIyGho.js +0 -85
  143. package/dist/web/client/assets/skills-C7DzIwFJ.js +0 -1
  144. package/dist/web/client/assets/style-CA2GAk9b.js +0 -7
  145. package/dist/web/client/assets/styles-C3CDSGAr.css +0 -2
  146. package/dist/web/client/assets/teams-BEIJHObN.js +0 -1
  147. package/dist/web/client/assets/teams-DlOc7Ods.js +0 -1
  148. package/dist/web/client/assets/telegram-DKHq5DpE.js +0 -1
  149. package/dist/web/client/assets/tools-BKIpLaiC.js +0 -1
  150. package/dist/web/client/assets/use-resource-CQaIZbpy.js +0 -1
  151. package/dist/web/client/assets/welcome-CyS4Hrd-.js +0 -1
  152. package/dist/web/server/assets/_tanstack-start-manifest_v-CR3jm1nY.js +0 -256
package/dist/daemon.js CHANGED
@@ -3112,13 +3112,17 @@ function projectAttention(db, options = {}, waiting = []) {
3112
3112
  }
3113
3113
  function attentionSummary(db, waiting = []) {
3114
3114
  const projected = projectAttention(db, { state: "open", limit: 1e5 }, waiting);
3115
+ return summarizeAttention(projected.items, projected.degraded);
3116
+ }
3117
+ function summarizeAttention(items, degraded) {
3118
+ const open2 = items.filter((item) => item.acknowledgedAt === null);
3115
3119
  const bySeverity = { action_required: 0, error: 0, warning: 0 };
3116
3120
  const byKind = Object.fromEntries(ATTENTION_KINDS.map((kind) => [kind, 0]));
3117
- for (const item of projected.items) {
3121
+ for (const item of open2) {
3118
3122
  bySeverity[item.severity]++;
3119
3123
  byKind[item.kind]++;
3120
3124
  }
3121
- return { openTotal: projected.items.length, bySeverity, byKind, degraded: projected.degraded };
3125
+ return { openTotal: open2.length, bySeverity, byKind, degraded };
3122
3126
  }
3123
3127
  function acknowledgeAttention(db, key2, acknowledged) {
3124
3128
  const parsed = parseAttentionKey(key2);
@@ -4202,7 +4206,7 @@ var PROVIDERS = [
4202
4206
  // Credentials come from the OAuth flow (/api/auth/openai), not from fields.
4203
4207
  fields: [],
4204
4208
  popular: true,
4205
- suggested: ["gpt-6.1-sol", "gpt-6-luna"]
4209
+ suggested: ["gpt-6.2-sol", "gpt-6-luna"]
4206
4210
  },
4207
4211
  {
4208
4212
  ...apiKey("openai", "OpenAI", "OPENAI_API_KEY", {
@@ -4210,7 +4214,7 @@ var PROVIDERS = [
4210
4214
  placeholder: "sk-..."
4211
4215
  }),
4212
4216
  popular: true,
4213
- suggested: ["gpt-6.1-sol", "gpt-6-luna"]
4217
+ suggested: ["gpt-6.2-sol", "gpt-6-luna"]
4214
4218
  },
4215
4219
  {
4216
4220
  id: "anthropic",
@@ -4347,20 +4351,24 @@ var PROVIDERS = [
4347
4351
  apiKey("minimax-cn", "MiniMax (CN)", "MINIMAX_CN_API_KEY", {
4348
4352
  hint: "MiniMax M2/M3 family via the China endpoint"
4349
4353
  }),
4350
- apiKey("qwen-token-plan", "Qwen Token Plan", "QWEN_TOKEN_PLAN_API_KEY", {
4351
- hint: "Coding-model subscription endpoint in Singapore"
4352
- }),
4353
- apiKey("qwen-token-plan-cn", "Qwen Token Plan (CN)", "QWEN_TOKEN_PLAN_CN_API_KEY", {
4354
- hint: "Coding-model subscription endpoint in China"
4354
+ // Each plan has its own key; Pi also reads the older shared QWEN_TOKEN_PLAN_API_KEY.
4355
+ apiKey("qwen-token-plan", "Qwen Token Plan Team", "QWEN_TOKEN_PLAN_TEAM_API_KEY", {
4356
+ hint: "Team coding-model subscription \xB7 international endpoint"
4355
4357
  }),
4356
- apiKey("qwen-token-plan-individual", "Qwen Token Plan (Individual)", "QWEN_TOKEN_PLAN_API_KEY", {
4357
- hint: "Individual subscription models via the international endpoint"
4358
+ apiKey("qwen-token-plan-cn", "Qwen Token Plan Team (CN)", "QWEN_TOKEN_PLAN_TEAM_CN_API_KEY", {
4359
+ hint: "Team coding-model subscription \xB7 China endpoint"
4358
4360
  }),
4361
+ apiKey(
4362
+ "qwen-token-plan-individual",
4363
+ "Qwen Token Plan Individual",
4364
+ "QWEN_TOKEN_PLAN_INDIVIDUAL_API_KEY",
4365
+ { hint: "Individual subscription \xB7 international endpoint" }
4366
+ ),
4359
4367
  apiKey(
4360
4368
  "qwen-token-plan-individual-cn",
4361
- "Qwen Token Plan (Individual, CN)",
4362
- "QWEN_TOKEN_PLAN_CN_API_KEY",
4363
- { hint: "Individual subscription models via the China endpoint" }
4369
+ "Qwen Token Plan Individual (CN)",
4370
+ "QWEN_TOKEN_PLAN_INDIVIDUAL_CN_API_KEY",
4371
+ { hint: "Individual subscription \xB7 China endpoint" }
4364
4372
  ),
4365
4373
  apiKey("xiaomi", "Xiaomi MiMo", "XIAOMI_API_KEY", {
4366
4374
  hint: "API billing endpoint \xB7 platform.xiaomimimo.com"
@@ -4480,7 +4488,7 @@ var PROVIDERS = [
4480
4488
  displayName: "llama.cpp",
4481
4489
  hint: "Local inference \xB7 llama.cpp llama-server (OpenAI-compat /v1 endpoint)",
4482
4490
  urlEnv: "LLAMACPP_URL",
4483
- url: "http://127.0.0.1:8080/v1",
4491
+ url: "http://127.0.0.1:9931/v1",
4484
4492
  keyEnv: "LLAMACPP_API_KEY",
4485
4493
  local: { key: "no-key", authHeader: true },
4486
4494
  keyField: {
@@ -6301,6 +6309,17 @@ function isSetupOpen(path) {
6301
6309
  }
6302
6310
  return false;
6303
6311
  }
6312
+ function credentialCheck(c) {
6313
+ const bearer = extractBearer(c.req.header("authorization"));
6314
+ const sessionCookie = getCookie(
6315
+ c,
6316
+ publicOriginConfig(process.env.BAZILION_PUBLIC_ORIGIN).sessionCookie
6317
+ );
6318
+ return () => {
6319
+ if (bearer) return authenticateToken(bearer) !== null;
6320
+ return Boolean(sessionCookie && webSessions_exports.authenticate(getCtx().db, sessionCookie));
6321
+ };
6322
+ }
6304
6323
  async function authMiddleware(c, next) {
6305
6324
  const path = c.req.path;
6306
6325
  if (PUBLIC_PATHS.has(path)) {
@@ -6549,6 +6568,16 @@ function remove10(db, id) {
6549
6568
  return db.raw.run("DELETE FROM agent_results WHERE id = ?", [id]).changes === 1;
6550
6569
  }
6551
6570
 
6571
+ // ../daemon/src/lib/live-signal.ts
6572
+ var listeners = /* @__PURE__ */ new Set();
6573
+ function signalLiveChange() {
6574
+ for (const listener of listeners) listener();
6575
+ }
6576
+ function onLiveChange(listener) {
6577
+ listeners.add(listener);
6578
+ return () => listeners.delete(listener);
6579
+ }
6580
+
6552
6581
  // ../daemon/src/lib/agent-cancel.ts
6553
6582
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("bazilion.agent-cancel.registry");
6554
6583
  var AgentTurnActiveError = class extends DomainError {
@@ -6574,6 +6603,7 @@ function registerAgent(agentId, controller) {
6574
6603
  throw new AgentTurnActiveError(agentId);
6575
6604
  }
6576
6605
  registry().active.set(agentId, controller);
6606
+ signalLiveChange();
6577
6607
  }
6578
6608
  function unregisterAgent(agentId) {
6579
6609
  const state2 = registry();
@@ -6581,6 +6611,7 @@ function unregisterAgent(agentId) {
6581
6611
  const waiters = state2.idleWaiters.get(agentId);
6582
6612
  state2.idleWaiters.delete(agentId);
6583
6613
  for (const resolve9 of waiters ?? []) resolve9();
6614
+ signalLiveChange();
6584
6615
  }
6585
6616
  function cancelAgent(agentId) {
6586
6617
  const { active } = registry();
@@ -6630,7 +6661,7 @@ function isShuttingDownError(error) {
6630
6661
  }
6631
6662
 
6632
6663
  // ../daemon/src/lib/bash-approval.ts
6633
- var DEFAULT_TIMEOUT_MS = 12e4;
6664
+ var DEFAULT_TIMEOUT_MS = 5 * 6e4;
6634
6665
  var CommandApprovalRegistry = class {
6635
6666
  #pending = /* @__PURE__ */ new Map();
6636
6667
  #timeoutMs;
@@ -6657,26 +6688,34 @@ var CommandApprovalRegistry = class {
6657
6688
  }
6658
6689
  if (this.#pending.has(approval.id))
6659
6690
  throw new Error(`duplicate shell approval id: ${approval.id}`);
6660
- const settled = new Promise((resolve9) => {
6661
- const settle = (status2) => {
6662
- this.#pending.delete(approval.id);
6663
- clearTimeout(timer);
6664
- signal?.removeEventListener("abort", onAbort);
6665
- const result = logged({ ...approval, status: status2 });
6666
- resolve9(result);
6667
- return result;
6668
- };
6669
- const onAbort = () => settle("cancelled");
6670
- const timer = setTimeout(() => settle("expired"), this.#timeoutMs);
6671
- timer.unref();
6672
- signal?.addEventListener("abort", onAbort, { once: true });
6673
- this.#pending.set(approval.id, { approval, settle });
6674
- });
6691
+ const { promise: settled, resolve: resolve9 } = Promise.withResolvers();
6692
+ const settle = (status2) => {
6693
+ this.#pending.delete(approval.id);
6694
+ clearTimeout(timer);
6695
+ signal?.removeEventListener("abort", onAbort);
6696
+ const result = logged({ ...approval, status: status2 });
6697
+ resolve9(result);
6698
+ signalLiveChange();
6699
+ return result;
6700
+ };
6701
+ const onAbort = () => settle("cancelled");
6702
+ const timer = setTimeout(() => settle("expired"), this.#timeoutMs);
6703
+ timer.unref();
6704
+ signal?.addEventListener("abort", onAbort, { once: true });
6705
+ this.#pending.set(approval.id, { approval, settle, settled });
6706
+ signalLiveChange();
6675
6707
  return { approval, settled };
6676
6708
  }
6677
6709
  list(agentId) {
6678
6710
  return Array.from(this.#pending.values(), (entry) => entry.approval).filter((approval) => agentId === void 0 || approval.agentId === agentId).sort((a, b) => a.expiresAt - b.expiresAt || a.id.localeCompare(b.id));
6679
6711
  }
6712
+ get(id) {
6713
+ return this.#pending.get(id)?.approval;
6714
+ }
6715
+ /** The outcome of a pending approval; undefined once it has settled. */
6716
+ settled(id) {
6717
+ return this.#pending.get(id)?.settled;
6718
+ }
6680
6719
  /** Answer a pending approval; undefined when there is none (unknown, or already settled). */
6681
6720
  respond(id, decision) {
6682
6721
  return this.#pending.get(id)?.settle(decision === "allow" ? "allowed" : "denied");
@@ -6780,9 +6819,11 @@ var QuestionRegistry = class {
6780
6819
  clearTimeout(timer);
6781
6820
  signal?.removeEventListener("abort", cancel3);
6782
6821
  resolve9({ questionId: question.id, question: prompt, ...outcome });
6822
+ signalLiveChange();
6783
6823
  return true;
6784
6824
  };
6785
6825
  this.#pending.set(question.id, { question, result: promise, finish: finish3 });
6826
+ signalLiveChange();
6786
6827
  signal?.addEventListener("abort", cancel3, { once: true });
6787
6828
  return { question, result: promise };
6788
6829
  }
@@ -6841,9 +6882,11 @@ function stepTarget(rawArguments) {
6841
6882
  function noteTurnFrame(agentId, frame) {
6842
6883
  if (frame.kind !== "event" || frame.event.type !== "tool_call") return;
6843
6884
  steps().set(agentId, { tool: frame.event.name, target: stepTarget(frame.event.arguments) });
6885
+ signalLiveChange();
6844
6886
  }
6845
6887
  function noteTurnEnd(agentId) {
6846
6888
  steps().delete(agentId);
6889
+ signalLiveChange();
6847
6890
  }
6848
6891
  function lastActivityAt(db, paths, agentId) {
6849
6892
  const conversationId = selectedId(db, agentId);
@@ -6861,6 +6904,7 @@ function readActivity(db, paths) {
6861
6904
  const approvals = commandApprovalRegistry.list();
6862
6905
  return list(db).map((agent) => {
6863
6906
  const working = isActiveAgent(agent.id);
6907
+ const pending = pendingCount(db, agent.id);
6864
6908
  const produced = saved.get(agent.id);
6865
6909
  return {
6866
6910
  agentId: agent.id,
@@ -6869,7 +6913,8 @@ function readActivity(db, paths) {
6869
6913
  step: working ? steps().get(agent.id) ?? null : null,
6870
6914
  questions: questions.filter((question) => question.agentId === agent.id).length,
6871
6915
  approvals: approvals.filter((approval) => approval.agentId === agent.id).length,
6872
- queuePaused: isPaused(db, agent.id) && pendingCount(db, agent.id) > 0,
6916
+ queuePaused: isPaused(db, agent.id) && pending > 0,
6917
+ followUps: pending,
6873
6918
  lastActivityAt: lastActivityAt(db, paths, agent.id),
6874
6919
  results: produced?.count ?? 0,
6875
6920
  lastResultAt: produced?.lastAt ?? null
@@ -10958,19 +11003,6 @@ function setTelegramLive(live) {
10958
11003
  current = live;
10959
11004
  }
10960
11005
 
10961
- // ../daemon/src/lib/telegram/loop-guard.ts
10962
- var MAX_LINES = 30;
10963
- var WINDOW_MS = 6e4;
10964
- var _outbound = /* @__PURE__ */ new Map();
10965
- function allowTelegramOutboundNoise(agentId) {
10966
- const now = Date.now();
10967
- const hits = (_outbound.get(agentId) ?? []).filter((at) => now - at < WINDOW_MS);
10968
- const allowed = hits.length < MAX_LINES;
10969
- if (allowed) hits.push(now);
10970
- _outbound.set(agentId, hits);
10971
- return allowed;
10972
- }
10973
-
10974
11006
  // ../daemon/src/lib/telegram/markdown.ts
10975
11007
  import { marked } from "marked";
10976
11008
 
@@ -11259,11 +11291,107 @@ function sleep2(ms) {
11259
11291
  return new Promise((r) => setTimeout(r, ms));
11260
11292
  }
11261
11293
 
11294
+ // ../daemon/src/lib/telegram/approvals.ts
11295
+ var APPROVAL_TELEGRAM_DELAY_MS = 3e4;
11296
+ var CALLBACK = /^ba:([0-9a-f-]{36}):(a|d)$/;
11297
+ var COMMAND_CHARS = 1500;
11298
+ function promptBody(agentName, approval) {
11299
+ const risks = [...new Set(approval.risks.map((risk) => risk.message))].join(" ");
11300
+ return [
11301
+ `\u26A0\uFE0F ${agentName} wants to run a command that needs your approval:`,
11302
+ clip2(approval.command, COMMAND_CHARS),
11303
+ risks ? `Why it asks: ${clip2(risks, 500)}` : ""
11304
+ ].filter(Boolean).join("\n\n");
11305
+ }
11306
+ function outcomeLine(status2) {
11307
+ switch (status2) {
11308
+ case "allowed":
11309
+ return "Allowed once.";
11310
+ case "denied":
11311
+ return "Denied.";
11312
+ case "expired":
11313
+ return "No answer in time: denied.";
11314
+ default:
11315
+ return "The turn ended before an answer.";
11316
+ }
11317
+ }
11318
+ function scheduleApprovalPrompt(approval, delayMs = APPROVAL_TELEGRAM_DELAY_MS) {
11319
+ if (approval.status !== "pending") return;
11320
+ const timer = setTimeout(() => void sendApprovalPrompt(approval), delayMs);
11321
+ timer.unref();
11322
+ void commandApprovalRegistry.settled(approval.id)?.finally(() => clearTimeout(timer));
11323
+ }
11324
+ async function sendApprovalPrompt(approval) {
11325
+ const settled = commandApprovalRegistry.settled(approval.id);
11326
+ const live = telegramLive();
11327
+ if (!commandApprovalRegistry.get(approval.id) || !settled || !live) return false;
11328
+ const agent = agents_exports.get(live.db, approval.agentId);
11329
+ const topicId = agent ? agents_exports.getTelegramTopicId(live.db, agent.id) : null;
11330
+ if (!agent || topicId === null) return false;
11331
+ const body = promptBody(agent.name, approval);
11332
+ const keyboard = {
11333
+ inline_keyboard: [
11334
+ [
11335
+ { text: "Allow once", callback_data: `ba:${approval.id}:a` },
11336
+ { text: "Deny", callback_data: `ba:${approval.id}:d` }
11337
+ ]
11338
+ ]
11339
+ };
11340
+ const sent = await enqueueOutbound(
11341
+ live.chatId,
11342
+ () => live.api.sendMessage(live.chatId, body, {
11343
+ message_thread_id: topicId,
11344
+ reply_markup: keyboard
11345
+ })
11346
+ ).catch(() => null);
11347
+ if (!sent) return false;
11348
+ void settled.then((result) => {
11349
+ const current2 = telegramLive();
11350
+ if (!current2 || current2.chatId !== live.chatId) return;
11351
+ return enqueueOutbound(
11352
+ current2.chatId,
11353
+ () => current2.api.editMessageText(
11354
+ current2.chatId,
11355
+ sent.message_id,
11356
+ `${body}
11357
+
11358
+ ${outcomeLine(result.status)}`,
11359
+ { reply_markup: { inline_keyboard: [] } }
11360
+ )
11361
+ );
11362
+ }).catch(() => void 0);
11363
+ return true;
11364
+ }
11365
+ function approvalCallback(data) {
11366
+ const match = data?.match(CALLBACK);
11367
+ if (!match?.[1] || !match[2]) return null;
11368
+ return { approvalId: match[1], decision: match[2] === "a" ? "allow" : "deny" };
11369
+ }
11370
+ function decideFromTelegram(db, userId, approvalId, decision) {
11371
+ if (get12(db, userId)?.role !== "owner") return "Only the owner can decide on a command.";
11372
+ const settled = commandApprovalRegistry.respond(approvalId, decision);
11373
+ if (!settled) return "That command is no longer waiting.";
11374
+ return settled.status === "allowed" ? "Allowed once." : "Denied.";
11375
+ }
11376
+
11377
+ // ../daemon/src/lib/telegram/loop-guard.ts
11378
+ var MAX_LINES = 30;
11379
+ var WINDOW_MS = 6e4;
11380
+ var _outbound = /* @__PURE__ */ new Map();
11381
+ function allowTelegramOutboundNoise(agentId) {
11382
+ const now = Date.now();
11383
+ const hits = (_outbound.get(agentId) ?? []).filter((at) => now - at < WINDOW_MS);
11384
+ const allowed = hits.length < MAX_LINES;
11385
+ if (allowed) hits.push(now);
11386
+ _outbound.set(agentId, hits);
11387
+ return allowed;
11388
+ }
11389
+
11262
11390
  // ../daemon/src/lib/telegram/questions.ts
11263
- var CALLBACK = /^bq:([0-9a-f-]{36}):(\d|s)$/;
11391
+ var CALLBACK2 = /^bq:([0-9a-f-]{36}):(\d|s)$/;
11264
11392
  var FOOTER = "Tap a choice, or reply to this message with your own answer.";
11265
11393
  var prompts = /* @__PURE__ */ new Map();
11266
- function promptBody(question) {
11394
+ function promptBody2(question) {
11267
11395
  const { prompt, choices, recommendedIndex } = question.question;
11268
11396
  const options = choices.map(
11269
11397
  (choice, index) => `${index + 1}. ${choice.label}${index === recommendedIndex ? " (recommended)" : ""}${choice.description ? ` \u2014 ${choice.description}` : ""}`
@@ -11273,7 +11401,7 @@ function promptBody(question) {
11273
11401
 
11274
11402
  ${clip2(options, TELEGRAM_SAFE_BUDGET / 2)}`;
11275
11403
  }
11276
- function outcomeLine(result) {
11404
+ function outcomeLine2(result) {
11277
11405
  if (result.kind === "answer")
11278
11406
  return result.answer.kind === "choice" ? `Answered: ${result.question.choices[result.answer.index]?.label ?? ""}` : `Answered: ${clip2(result.answer.text, 500)}`;
11279
11407
  if (result.reason === "skipped") return "Skipped.";
@@ -11282,7 +11410,7 @@ function outcomeLine(result) {
11282
11410
  async function sendQuestionPrompt(live, topicId, question) {
11283
11411
  const settled = questionRegistry.settled(question.id);
11284
11412
  if (!settled) return;
11285
- const body = promptBody(question);
11413
+ const body = promptBody2(question);
11286
11414
  const keyboard = {
11287
11415
  inline_keyboard: [
11288
11416
  ...question.question.choices.map((choice, index) => [
@@ -11308,7 +11436,7 @@ ${FOOTER}`, {
11308
11436
  prompts.delete(sent.message_id);
11309
11437
  const current2 = telegramLive();
11310
11438
  if (!current2 || current2.chatId !== live.chatId) return;
11311
- const outcome = outcomeLine(result);
11439
+ const outcome = outcomeLine2(result);
11312
11440
  const text4 = `${clip2(body, TELEGRAM_SAFE_BUDGET - outcome.length - 2)}
11313
11441
 
11314
11442
  ${outcome}`;
@@ -11321,7 +11449,7 @@ ${outcome}`;
11321
11449
  }).catch(() => void 0);
11322
11450
  }
11323
11451
  function questionCallback(data) {
11324
- const match = data?.match(CALLBACK);
11452
+ const match = data?.match(CALLBACK2);
11325
11453
  if (!match?.[1] || !match[2]) return null;
11326
11454
  return {
11327
11455
  questionId: match[1],
@@ -11377,6 +11505,10 @@ async function mirrorAgentTurnFrame(agentId, frame) {
11377
11505
  if (frame.kind === "event" && frame.event.type === "file") {
11378
11506
  await mirrorFile(live, topicId, agent.id, frame.event);
11379
11507
  }
11508
+ if (frame.kind === "event" && frame.event.type === "command_approval") {
11509
+ scheduleApprovalPrompt(frame.event.approval);
11510
+ return;
11511
+ }
11380
11512
  if (frame.kind === "event" && frame.event.type === "agent_question") {
11381
11513
  await sendQuestionPrompt(live, topicId, frame.event.question).catch(
11382
11514
  () => logMirrorAdapterFailure("telegram_mirror_question_failed", agent.id)
@@ -13269,18 +13401,21 @@ attentionRouter.get("/summary", (c) => {
13269
13401
  const db = getCtx().db;
13270
13402
  return c.json(attentionSummary(db, waitingAttention(db)));
13271
13403
  });
13272
- attentionRouter.post(
13273
- "/acknowledge-all",
13274
- (c) => c.json({ acknowledged: acknowledgeAllAttention(getCtx().db) })
13275
- );
13276
- attentionRouter.post(
13277
- "/:key/acknowledge",
13278
- (c) => c.json({ item: acknowledgeAttention(getCtx().db, c.req.param("key"), true) })
13279
- );
13280
- attentionRouter.delete(
13281
- "/:key/acknowledgement",
13282
- (c) => c.json({ item: acknowledgeAttention(getCtx().db, c.req.param("key"), false) })
13283
- );
13404
+ attentionRouter.post("/acknowledge-all", (c) => {
13405
+ const acknowledged = acknowledgeAllAttention(getCtx().db);
13406
+ signalLiveChange();
13407
+ return c.json({ acknowledged });
13408
+ });
13409
+ attentionRouter.post("/:key/acknowledge", (c) => {
13410
+ const item = acknowledgeAttention(getCtx().db, c.req.param("key"), true);
13411
+ signalLiveChange();
13412
+ return c.json({ item });
13413
+ });
13414
+ attentionRouter.delete("/:key/acknowledgement", (c) => {
13415
+ const item = acknowledgeAttention(getCtx().db, c.req.param("key"), false);
13416
+ signalLiveChange();
13417
+ return c.json({ item });
13418
+ });
13284
13419
 
13285
13420
  // ../daemon/src/routes/auth-login.ts
13286
13421
  import { deleteCookie, setCookie } from "hono/cookie";
@@ -14596,6 +14731,135 @@ conversationsRouter.patch("/:agentId/conversations/:id", async (c) => {
14596
14731
  });
14597
14732
  });
14598
14733
 
14734
+ // ../daemon/src/routes/events.ts
14735
+ import { streamSSE } from "hono/streaming";
14736
+
14737
+ // ../daemon/src/lib/live.ts
14738
+ import { createHash as createHash6 } from "node:crypto";
14739
+ var CHECK_MS = 1e3;
14740
+ var ATTENTION_EVERY = 5;
14741
+ var SETTLE_MS = 25;
14742
+ function readLiveActivity() {
14743
+ const { db, paths } = getCtx();
14744
+ return { type: "activity", agents: readActivity(db, paths) };
14745
+ }
14746
+ function readLiveAttention() {
14747
+ const { db } = getCtx();
14748
+ const waiting = waitingAttention(db);
14749
+ const all = projectAttention(db, { state: "all", limit: 1e5 }, waiting);
14750
+ const revision = createHash6("sha256").update(
14751
+ all.items.map((item) => `${item.key}|${item.updatedAt}|${item.acknowledgedAt ?? ""}`).join("\n")
14752
+ ).update(JSON.stringify(all.degraded)).digest("hex").slice(0, 16);
14753
+ return {
14754
+ type: "attention",
14755
+ summary: summarizeAttention(all.items, all.degraded),
14756
+ revision,
14757
+ waiting: all.items.filter((item) => waiting.some((entry) => entry.key === item.key))
14758
+ };
14759
+ }
14760
+ var LiveFeed = class {
14761
+ #listeners = /* @__PURE__ */ new Set();
14762
+ #last = /* @__PURE__ */ new Map();
14763
+ #timer;
14764
+ #settle;
14765
+ #ticks = 0;
14766
+ #unsignal;
14767
+ /** Listen; the current state is sent first. Returns the function that stops listening. */
14768
+ subscribe(listener) {
14769
+ this.#listeners.add(listener);
14770
+ for (const event of this.#read()) listener(event);
14771
+ if (this.#listeners.size === 1) this.#start();
14772
+ return () => {
14773
+ this.#listeners.delete(listener);
14774
+ if (this.#listeners.size === 0) this.#stop();
14775
+ };
14776
+ }
14777
+ get listeners() {
14778
+ return this.#listeners.size;
14779
+ }
14780
+ #start() {
14781
+ this.#timer = setInterval(() => {
14782
+ this.#ticks++;
14783
+ this.#check(this.#ticks % ATTENTION_EVERY === 0);
14784
+ }, CHECK_MS);
14785
+ this.#timer.unref();
14786
+ this.#unsignal = onLiveChange(() => {
14787
+ this.#settle ??= setTimeout(() => {
14788
+ this.#settle = void 0;
14789
+ this.#check(true);
14790
+ }, SETTLE_MS);
14791
+ });
14792
+ }
14793
+ #stop() {
14794
+ clearInterval(this.#timer);
14795
+ clearTimeout(this.#settle);
14796
+ this.#timer = void 0;
14797
+ this.#settle = void 0;
14798
+ this.#unsignal?.();
14799
+ this.#unsignal = void 0;
14800
+ this.#last.clear();
14801
+ }
14802
+ #read(attention = true) {
14803
+ const events = [];
14804
+ try {
14805
+ events.push(readLiveActivity());
14806
+ } catch (error) {
14807
+ console.warn(`live feed: activity: ${error instanceof Error ? error.message : error}`);
14808
+ }
14809
+ if (!attention) return events;
14810
+ try {
14811
+ events.push(readLiveAttention());
14812
+ } catch (error) {
14813
+ console.warn(`live feed: attention: ${error instanceof Error ? error.message : error}`);
14814
+ }
14815
+ return events;
14816
+ }
14817
+ #check(attention) {
14818
+ if (this.#listeners.size === 0) return;
14819
+ for (const event of this.#read(attention)) {
14820
+ const json = JSON.stringify(event);
14821
+ if (this.#last.get(event.type) === json) continue;
14822
+ this.#last.set(event.type, json);
14823
+ for (const listener of this.#listeners) listener(event);
14824
+ }
14825
+ }
14826
+ };
14827
+ var FEED_KEY = /* @__PURE__ */ Symbol.for("bazilion.live.feed");
14828
+ function liveFeed() {
14829
+ const holder = globalThis;
14830
+ holder[FEED_KEY] ??= new LiveFeed();
14831
+ return holder[FEED_KEY];
14832
+ }
14833
+
14834
+ // ../daemon/src/routes/events.ts
14835
+ var keepaliveMs = 2e4;
14836
+ var eventsRouter = newRouter();
14837
+ eventsRouter.get("/", (c) => {
14838
+ const stillValid = credentialCheck(c);
14839
+ c.header("cache-control", "no-store");
14840
+ c.header("x-accel-buffering", "no");
14841
+ return streamSSE(c, async (stream) => {
14842
+ let id = 0;
14843
+ const unsubscribe = liveFeed().subscribe((event) => {
14844
+ void stream.writeSSE({ event: event.type, data: JSON.stringify(event), id: String(++id) });
14845
+ });
14846
+ let keepalive;
14847
+ try {
14848
+ await new Promise((resolve9) => {
14849
+ stream.onAbort(resolve9);
14850
+ c.req.raw.signal.addEventListener("abort", () => resolve9(), { once: true });
14851
+ keepalive = setInterval(() => {
14852
+ if (stillValid()) void stream.write(": keepalive\n\n");
14853
+ else resolve9();
14854
+ }, keepaliveMs);
14855
+ });
14856
+ } finally {
14857
+ clearInterval(keepalive);
14858
+ unsubscribe();
14859
+ }
14860
+ });
14861
+ });
14862
+
14599
14863
  // ../daemon/src/routes/mcp.ts
14600
14864
  init_pool();
14601
14865
  var mcpRouter = newRouter();
@@ -15949,7 +16213,7 @@ teamPolicyRouter.post("/:id/policy/save-as-template", async (c) => {
15949
16213
  });
15950
16214
 
15951
16215
  // ../daemon/src/lib/git/context-directory.ts
15952
- import { createHash as createHash6 } from "node:crypto";
16216
+ import { createHash as createHash7 } from "node:crypto";
15953
16217
  import {
15954
16218
  closeSync as closeSync6,
15955
16219
  constants as constants7,
@@ -15961,7 +16225,7 @@ import {
15961
16225
  realpathSync as realpathSync7
15962
16226
  } from "node:fs";
15963
16227
  import { join as join36 } from "node:path";
15964
- var hash = (value) => createHash6("sha256").update(value).digest("hex");
16228
+ var hash = (value) => createHash7("sha256").update(value).digest("hex");
15965
16229
  var ContextReadError = class extends Error {
15966
16230
  code;
15967
16231
  constructor(code) {
@@ -16017,11 +16281,23 @@ var ContextDirectory = class _ContextDirectory {
16017
16281
  }
16018
16282
  }
16019
16283
  get path() {
16020
- return FD_PATHS ? `/proc/self/fd/${this.fd}` : this.canonicalPath;
16284
+ return FD_PATHS ? `/proc/self/fd/${this.fd}` : this.checkedPath();
16021
16285
  }
16022
16286
  /** The worktree path handed to an external Git process (descriptor-pinned on Linux). */
16023
16287
  get gitWorktreePath() {
16024
- return FD_PATHS ? `/proc/${process.pid}/fd/${this.fd}` : this.canonicalPath;
16288
+ return FD_PATHS ? `/proc/${process.pid}/fd/${this.fd}` : this.checkedPath();
16289
+ }
16290
+ /** The canonical path, once it is seen to name the directory that was opened. */
16291
+ checkedPath() {
16292
+ let stat;
16293
+ try {
16294
+ stat = lstatSync6(this.canonicalPath, { bigint: true });
16295
+ } catch {
16296
+ throw new ContextReadError("root_changed");
16297
+ }
16298
+ if (!stat.isDirectory() || identity(stat) !== identity(this.originalIdentity))
16299
+ throw new ContextReadError("root_changed");
16300
+ return this.canonicalPath;
16025
16301
  }
16026
16302
  /** Every public method is synchronous, so one check on entry covers the whole call. */
16027
16303
  assertOpen() {
@@ -16040,16 +16316,18 @@ var ContextDirectory = class _ContextDirectory {
16040
16316
  entry(name) {
16041
16317
  component(name);
16042
16318
  this.assertOpen();
16319
+ const path = join36(this.path, name);
16043
16320
  try {
16044
- return lstatSync6(join36(this.path, name));
16321
+ return lstatSync6(path);
16045
16322
  } catch (error) {
16046
16323
  if (error.code === "ENOENT") return null;
16047
16324
  throw new ContextReadError("unreadable");
16048
16325
  }
16049
16326
  }
16050
16327
  observe(name) {
16328
+ const path = join36(this.path, name);
16051
16329
  try {
16052
- return lstatSync6(join36(this.path, name), { bigint: true });
16330
+ return lstatSync6(path, { bigint: true });
16053
16331
  } catch (error) {
16054
16332
  if (error.code === "ENOENT") return null;
16055
16333
  throw new ContextReadError("unreadable");
@@ -16105,6 +16383,7 @@ var ContextDirectory = class _ContextDirectory {
16105
16383
  }
16106
16384
  if (size > maxBytes || BigInt(size) !== before.size || stamp(fstatSync6(fd, { bigint: true })) !== stamp(before))
16107
16385
  throw new ContextReadError("source_changed");
16386
+ if (!FD_PATHS) this.checkedPath();
16108
16387
  this.observedFiles.set(name, stamp(before));
16109
16388
  return buffer.subarray(0, size);
16110
16389
  } catch (error) {
@@ -18265,6 +18544,13 @@ async function routeCallback(deps, q) {
18265
18544
  await deps.api.answerCallbackQuery(q.id, { text: answerFromTelegram(answer.questionId, answer.answer) }).catch(() => void 0);
18266
18545
  return { kind: "question_answer" };
18267
18546
  }
18547
+ const decision = approvalCallback(data);
18548
+ if (decision) {
18549
+ await deps.api.answerCallbackQuery(q.id, {
18550
+ text: decideFromTelegram(deps.db, q.from.id, decision.approvalId, decision.decision)
18551
+ }).catch(() => void 0);
18552
+ return { kind: "approval_decision" };
18553
+ }
18268
18554
  if (data.startsWith(SPAWN_TEAM_CALLBACK_PREFIX)) {
18269
18555
  await deps.api.answerCallbackQuery(q.id, {}).catch(() => void 0);
18270
18556
  const templateId = data.slice(SPAWN_TEAM_CALLBACK_PREFIX.length);
@@ -19062,6 +19348,7 @@ function createApp() {
19062
19348
  app2.route("/api/results", resultsRouter);
19063
19349
  app2.route("/api/attention", attentionRouter);
19064
19350
  app2.route("/api/activity", activityRouter);
19351
+ app2.route("/api/events", eventsRouter);
19065
19352
  app2.route("/api/notifications", notificationsRouter);
19066
19353
  app2.route("/api/shell-approvals", shellApprovalsRouter);
19067
19354
  app2.route("/api/profiles", profilesRouter);