@symerian/symi 2.6.42 → 2.7.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.
Files changed (204) hide show
  1. package/dist/{acp-cli-CrEIx-c7.js → acp-cli-B2f0qBiM.js} +2 -2
  2. package/dist/{acp-cli-BLUeUUA5.js → acp-cli-D-9rzaOI.js} +2 -2
  3. package/dist/{agents-DDRDszOI.js → agents-Z8ruJPz2.js} +5 -5
  4. package/dist/{agents.config-BEVb1Pyx.js → agents.config-B9BZoM2m.js} +1 -1
  5. package/dist/{agents.config-BKCY6F2A.js → agents.config-C951ocyh.js} +1 -1
  6. package/dist/{audio-preflight-DD18zIZd.js → audio-preflight-HILy3i0m.js} +4 -4
  7. package/dist/{audit-DB9YkTVX.js → audit-BgdM9XZl.js} +2 -2
  8. package/dist/{audit-BjI_Yyr5.js → audit-xSagQWH8.js} +2 -2
  9. package/dist/{auth-choice-D2xXwBeN.js → auth-choice-BmYi6pBy.js} +2 -2
  10. package/dist/{auth-choice-BbzReh6k.js → auth-choice-D_VfXxhG.js} +2 -2
  11. package/dist/{banner-DqqRwplt.js → banner-Bucr6qZ5.js} +1 -1
  12. package/dist/{browser-cli-kDUw45Y0.js → browser-cli-Bc_JVdTj.js} +3 -3
  13. package/dist/{browser-cli-Ctn9do4z.js → browser-cli-Dr0yx7-7.js} +3 -3
  14. package/dist/build-info.json +3 -3
  15. package/dist/bundled/boot-md/handler.js +1 -1
  16. package/dist/bundled/session-memory/handler.js +1 -1
  17. package/dist/{call-DwpGquzW.js → call-CX0cs106.js} +1 -1
  18. package/dist/{call-DKi-hnaF.js → call-DeCQ2DhS.js} +1 -1
  19. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  20. package/dist/{channel-options-DQcpDVCx.js → channel-options-BMDryXHq.js} +1 -1
  21. package/dist/{channel-options-DcazVJQf.js → channel-options-z8-WeZyO.js} +1 -1
  22. package/dist/{channel-web-u5yMYO4j.js → channel-web-D_YxZAHT.js} +1 -1
  23. package/dist/{channels-cli-C3iJE8eg.js → channels-cli-397NgC51.js} +7 -7
  24. package/dist/{channels-cli-Bog4Kn3X.js → channels-cli-CV7_JUru.js} +7 -7
  25. package/dist/{chrome-BxwUEWrH.js → chrome-CiOKaTN-.js} +7 -7
  26. package/dist/cli/daemon-cli.js +1 -1
  27. package/dist/{cli-eBtEEHLK.js → cli-4XU7pNlM.js} +4 -4
  28. package/dist/{cli-QybdZdE7.js → cli-Dq95udFO.js} +4 -4
  29. package/dist/{client-jI1oE0_k.js → client-B8xmq-Pw.js} +13 -1
  30. package/dist/{client-T3qcxXru.js → client-qUlxXXVJ.js} +13 -1
  31. package/dist/{command-registry-BWnZSpbL.js → command-registry-Cx9T7GYx.js} +10 -10
  32. package/dist/{completion-cli-BhJFXaVU.js → completion-cli-WlSuySPZ.js} +1 -1
  33. package/dist/{completion-cli-CUKm7Hb6.js → completion-cli-cyVjlhls.js} +2 -2
  34. package/dist/{config-cli-B796xZBe.js → config-cli-CMymzmrI.js} +1 -1
  35. package/dist/{config-cli-CjnQyv45.js → config-cli-EdmbBExA.js} +1 -1
  36. package/dist/{configure-D3wIQ0yI.js → configure-DRMAIBBf.js} +6 -6
  37. package/dist/{configure-DUqT7Dyn.js → configure-DkFujfiY.js} +6 -6
  38. package/dist/control-ui/css/style.css +165 -0
  39. package/dist/control-ui/js/app.js +39 -0
  40. package/dist/control-ui/js/gateway.js +2 -0
  41. package/dist/control-ui/js/history.js +220 -85
  42. package/dist/control-ui/js/settings.js +71 -8
  43. package/dist/{cron-cli-DCpsXkrw.js → cron-cli-BHxfvWeT.js} +3 -3
  44. package/dist/{cron-cli-QCTdVZuP.js → cron-cli-DacyI1Pw.js} +3 -3
  45. package/dist/{daemon-cli-DSDcmWOi.js → daemon-cli-BLhFbih0.js} +2 -2
  46. package/dist/{daemon-cli-DhJYEAoL.js → daemon-cli-BxKtiouf.js} +2 -2
  47. package/dist/daemon-cli.js +12 -0
  48. package/dist/{deliver-DtuY4Wgl.js → deliver-D6IcPfbt.js} +1 -1
  49. package/dist/{devices-cli-BNG-fvdl.js → devices-cli-1kiO08aL.js} +2 -2
  50. package/dist/{devices-cli-x3jIP4Ih.js → devices-cli-B8Q8AzbX.js} +2 -2
  51. package/dist/{doctor-completion-DBE1IVKj.js → doctor-completion-BDzhB9pE.js} +1 -1
  52. package/dist/{doctor-completion-D3oUNFQM.js → doctor-completion-CfeROjIz.js} +1 -1
  53. package/dist/entry.js +1 -1
  54. package/dist/{exec-approvals-cli-CmndFjEA.js → exec-approvals-cli-BRx2oxs5.js} +4 -4
  55. package/dist/{exec-approvals-cli-BSgxsdMt.js → exec-approvals-cli-Cj6Z-vxL.js} +4 -4
  56. package/dist/extensionAPI.js +6 -6
  57. package/dist/{gateway-cli-BguO9yV4.js → gateway-cli-C-G0QrTd.js} +185 -81
  58. package/dist/{gateway-cli-Dc1RT_b9.js → gateway-cli-Cpn7JyAw.js} +185 -81
  59. package/dist/{gateway-rpc-BMdVa3QV.js → gateway-rpc-BWTK7g8B.js} +1 -1
  60. package/dist/{gateway-rpc-5fREQe9Q.js → gateway-rpc-WM-HXUbl.js} +1 -1
  61. package/dist/{glass-ui-ws-DoIZyE9O.js → glass-ui-ws-BI81Lh6Z.js} +32 -13
  62. package/dist/{glass-ui-ws-D0UYleBF.js → glass-ui-ws-jAbqZVc9.js} +32 -13
  63. package/dist/{health-D3w4YMlC.js → health-B1nih5LD.js} +2 -2
  64. package/dist/{health-cVvZdeDu.js → health-CsTxt66a.js} +2 -2
  65. package/dist/{hooks-cli-te5hzOAB.js → hooks-cli-BhxMFkKe.js} +5 -5
  66. package/dist/{hooks-cli-DZIbjfOA.js → hooks-cli-CIlvtt2M.js} +5 -5
  67. package/dist/{image-lp19FlzF.js → image-D7Fl08gG.js} +1 -1
  68. package/dist/index.js +9 -9
  69. package/dist/llm-slug-generator.js +1 -1
  70. package/dist/{logs-cli-DtlrLf7u.js → logs-cli-BZV7dq_U.js} +3 -3
  71. package/dist/{logs-cli-CfGj-dOg.js → logs-cli-DyCcDkRs.js} +3 -3
  72. package/dist/{models-BCfPhQ4m.js → models-DhMe2rzL.js} +3 -3
  73. package/dist/{models-cli-BFAtjNIF.js → models-cli-DKM5sCQM.js} +5 -5
  74. package/dist/{models-cli-Cj2CwbPw.js → models-cli-Dewg24W2.js} +6 -6
  75. package/dist/{node-cli-DnfDOh1d.js → node-cli-4eMRkmrw.js} +1 -1
  76. package/dist/{node-cli-eHn9-YfJ.js → node-cli-Dfs0UmnJ.js} +1 -1
  77. package/dist/{nodes-cli-Ct4M7JOe.js → nodes-cli-BKb61OjH.js} +3 -3
  78. package/dist/{nodes-cli-Ci3oxw8k.js → nodes-cli-DxfP9DIz.js} +3 -3
  79. package/dist/{onboard-BMq8qc1m.js → onboard-Dw_nX2RD.js} +3 -3
  80. package/dist/{onboard-channels-B5wgcffj.js → onboard-channels-8ynJSZL6.js} +1 -1
  81. package/dist/{onboard-channels-CiOun4k1.js → onboard-channels-ChxtmhFY.js} +1 -1
  82. package/dist/{onboard-helpers-DFvWPFhU.js → onboard-helpers-CueJ7O_B.js} +1 -1
  83. package/dist/{onboard-helpers-BBtPmJEe.js → onboard-helpers-PpGrZIGw.js} +1 -1
  84. package/dist/{onboard-remote-BURDxwoE.js → onboard-remote-Cd9kIiSG.js} +1 -1
  85. package/dist/{onboard-remote-D-B4EiOE.js → onboard-remote-DCdpB2HH.js} +1 -1
  86. package/dist/{onboard-skills-BDCzVjxb.js → onboard-skills-CC2CV5Er.js} +1 -1
  87. package/dist/{onboard-skills-CbzgBT1W.js → onboard-skills-DRICcBwa.js} +1 -1
  88. package/dist/{onboard-VcdBF5TB.js → onboard-yrgbC1mu.js} +3 -3
  89. package/dist/{onboarding-Dp7p6zKa.js → onboarding-BJcYsOFw.js} +7 -7
  90. package/dist/{onboarding-CGNpTyg2.js → onboarding-e-RSXpUi.js} +7 -7
  91. package/dist/{onboarding.finalize-B6DOu8vp.js → onboarding.finalize-CKNdiZEZ.js} +9 -9
  92. package/dist/{onboarding.finalize-CrsE5P43.js → onboarding.finalize-DenYTWUu.js} +10 -10
  93. package/dist/{onboarding.gateway-config-DKwJ5bWd.js → onboarding.gateway-config-DTWQ-Bqq.js} +3 -3
  94. package/dist/{onboarding.gateway-config-B9zGPfCl.js → onboarding.gateway-config-Dj68bVBt.js} +3 -3
  95. package/dist/{pi-embedded-DQe8vBwU.js → pi-embedded-BzS693I1.js} +72 -21
  96. package/dist/{pi-embedded-helpers-Dij3O6ox.js → pi-embedded-helpers-DXAoe1Bx.js} +4 -4
  97. package/dist/{plugin-registry-BzIbwU3K.js → plugin-registry-Bzz7mUyl.js} +1 -1
  98. package/dist/{plugin-registry-D3TUplW8.js → plugin-registry-SUa2FFIj.js} +1 -1
  99. package/dist/plugin-sdk/{channel-web-B6m8UOCl.js → channel-web-DRabhx1e.js} +1 -1
  100. package/dist/plugin-sdk/gateway/protocol/index.d.ts +13 -2
  101. package/dist/plugin-sdk/gateway/protocol/schema/sessions.d.ts +11 -0
  102. package/dist/plugin-sdk/gateway/protocol/schema/types.d.ts +4 -1
  103. package/dist/plugin-sdk/index.js +2 -2
  104. package/dist/plugin-sdk/{reply-CGoJQT_s.js → reply-Cw3shPk2.js} +58 -7
  105. package/dist/plugin-sdk/{web-CJjSOTnI.js → web-CH43nBP0.js} +2 -2
  106. package/dist/{plugins-cli-BD1Jb2Ml.js → plugins-cli-DwtoU3xk.js} +5 -5
  107. package/dist/{plugins-cli-DFyRjAtJ.js → plugins-cli-qG50__1A.js} +5 -5
  108. package/dist/{program-context-45vPEw2G.js → program-context-CZwy-bh6.js} +29 -29
  109. package/dist/{program-qGm2M9PG.js → program-mZOVTSdQ.js} +10 -10
  110. package/dist/{prompt-select-styled-DRIS9jSv.js → prompt-select-styled-BZnuv8jI.js} +6 -6
  111. package/dist/{prompt-select-styled-DRraJGwA.js → prompt-select-styled-CtNg5KGU.js} +6 -6
  112. package/dist/{provider-auth-helpers-BNOWsjW5.js → provider-auth-helpers-CEYCb2mJ.js} +1 -1
  113. package/dist/{provider-auth-helpers-BREVjR7R.js → provider-auth-helpers-D60nbSLq.js} +1 -1
  114. package/dist/{push-apns-CYC70eKy.js → push-apns-B5txhDVi.js} +1 -1
  115. package/dist/{push-apns-CObVeJLC.js → push-apns-CoG1P_P0.js} +1 -1
  116. package/dist/{pw-ai-BO5cSmwD.js → pw-ai-CANiWpMA.js} +1 -1
  117. package/dist/{register.agent-DzzY8jON.js → register.agent-BY_Df_Me.js} +9 -9
  118. package/dist/{register.agent-DRrHvYcz.js → register.agent-CopGIf9e.js} +8 -8
  119. package/dist/{register.configure-DlXkwkNR.js → register.configure-Bu_XKu7Z.js} +11 -11
  120. package/dist/{register.configure-BxtTIFTa.js → register.configure-CoYQhQBT.js} +11 -11
  121. package/dist/{register.maintenance-LEf8Q_5p.js → register.maintenance-BtqQ3hDN.js} +11 -11
  122. package/dist/{register.maintenance-CXLXouZV.js → register.maintenance-VqCqhB7y.js} +10 -10
  123. package/dist/{register.message-DsPa-xHV.js → register.message-DZCCEK01.js} +5 -5
  124. package/dist/{register.message-C4ifV9vG.js → register.message-dd1xYBZT.js} +5 -5
  125. package/dist/{register.onboard-CrY4PxLP.js → register.onboard-B6EL1d-C.js} +7 -7
  126. package/dist/{register.onboard-DLRPa_4B.js → register.onboard-lzwHKufI.js} +7 -7
  127. package/dist/{register.setup-fBG_dJfi.js → register.setup-BJsr5_qp.js} +7 -7
  128. package/dist/{register.setup-By37g1vN.js → register.setup-D_b_HW5D.js} +7 -7
  129. package/dist/{register.status-health-sessions-DG7KGnD0.js → register.status-health-sessions-Dvj4mlom.js} +7 -7
  130. package/dist/{register.status-health-sessions-Ckw86-gn.js → register.status-health-sessions-jeiqtgl7.js} +7 -7
  131. package/dist/{register.subclis-C_xKLugM.js → register.subclis-DdPRkz29.js} +20 -20
  132. package/dist/{reply-DyjXROKp.js → reply-XaXqDK9F.js} +49 -10
  133. package/dist/{rpc-Co5PQ3IJ.js → rpc-N1nf_c1A.js} +1 -1
  134. package/dist/{rpc-D0FiEinj.js → rpc-QHo-8pCM.js} +1 -1
  135. package/dist/{run-main-Cg3ecTbO.js → run-main-MhL-xG3_.js} +17 -17
  136. package/dist/{runner-Ct0suQrd.js → runner-BS9gGL5i.js} +1 -1
  137. package/dist/{security-cli-D5BWzqEJ.js → security-cli-B-4J6enu.js} +3 -3
  138. package/dist/{security-cli-CG1uSlRK.js → security-cli-CSMUEGPK.js} +3 -3
  139. package/dist/{server-methods-CWcLut3F.js → server-methods-0ksPFnev.js} +471 -88
  140. package/dist/{server-methods-CW8eFTGD.js → server-methods-Bu1RjLe6.js} +471 -88
  141. package/dist/{server-node-events-C2h9OPo7.js → server-node-events-DCbzFyQF.js} +5 -5
  142. package/dist/{server-node-events-CDB0u8PP.js → server-node-events-DZAN3hWE.js} +5 -5
  143. package/dist/{status-B2Qt-5kL.js → status-CiHkFbIh.js} +1 -1
  144. package/dist/{status-ZPW5EACm.js → status-DOTlXdcN.js} +5 -5
  145. package/dist/{status-CMx3GAax.js → status-IWqSLXLR.js} +1 -1
  146. package/dist/{status-DfPfMVNZ.js → status-qkmUAeWo.js} +5 -5
  147. package/dist/{subagent-registry-DQHg3jUV.js → subagent-registry-DCoU9xIE.js} +49 -10
  148. package/dist/{system-cli-DFZNGx0i.js → system-cli-DY7ov1OT.js} +3 -3
  149. package/dist/{system-cli-Z7uzO8qd.js → system-cli-LFURKpwS.js} +3 -3
  150. package/dist/{tui-DjPsMdL6.js → tui-BH7JwqvB.js} +2 -2
  151. package/dist/{tui-DrATGNms.js → tui-C_5HG495.js} +2 -2
  152. package/dist/{tui-cli-D19-MCXt.js → tui-cli-B65PKZMj.js} +3 -3
  153. package/dist/{tui-cli-pWD_NrUR.js → tui-cli-CJnfmuxq.js} +3 -3
  154. package/dist/{unified-runner-DvOFqcrw.js → unified-runner-CApgXtVC.js} +58 -7
  155. package/dist/{update-cli-Df9rh_aN.js → update-cli-Bi6iMCXr.js} +11 -11
  156. package/dist/{update-cli-DBasZeVl.js → update-cli-BjQ3o9gQ.js} +12 -12
  157. package/dist/{update-runner-DVa6cMqp.js → update-runner-BhVsdpxm.js} +1 -1
  158. package/dist/{update-runner-BRKFzAwV.js → update-runner-FhW6n-Nv.js} +1 -1
  159. package/dist/{web-Dd05xbUr.js → web-ConlA_Ch.js} +4 -4
  160. package/dist/{web-Cw3bFAiP.js → web-CthDLVSz.js} +1 -1
  161. package/dist/{web-CGh5tw__.js → web-Db_-ahjX.js} +6 -6
  162. package/dist/{web-KiuDkd0x.js → web-Dpb_tv_j.js} +5 -5
  163. package/extensions/bluebubbles/package.json +1 -1
  164. package/extensions/copilot-proxy/package.json +1 -1
  165. package/extensions/diagnostics-otel/package.json +1 -1
  166. package/extensions/discord/package.json +1 -1
  167. package/extensions/feishu/package.json +1 -1
  168. package/extensions/google-antigravity-auth/package.json +1 -1
  169. package/extensions/google-gemini-cli-auth/package.json +1 -1
  170. package/extensions/googlechat/package.json +1 -1
  171. package/extensions/imessage/package.json +1 -1
  172. package/extensions/irc/package.json +1 -1
  173. package/extensions/learning-loop/package.json +1 -1
  174. package/extensions/line/package.json +1 -1
  175. package/extensions/llm-task/package.json +1 -1
  176. package/extensions/matrix/CHANGELOG.md +12 -0
  177. package/extensions/matrix/package.json +1 -1
  178. package/extensions/mattermost/package.json +1 -1
  179. package/extensions/memory-core/package.json +1 -1
  180. package/extensions/memory-lancedb/package.json +1 -1
  181. package/extensions/minimax-portal-auth/package.json +1 -1
  182. package/extensions/msteams/CHANGELOG.md +12 -0
  183. package/extensions/msteams/package.json +1 -1
  184. package/extensions/nextcloud-talk/package.json +1 -1
  185. package/extensions/nostr/CHANGELOG.md +12 -0
  186. package/extensions/nostr/package.json +1 -1
  187. package/extensions/open-prose/package.json +1 -1
  188. package/extensions/outlook/package.json +1 -1
  189. package/extensions/pipeline/package.json +1 -1
  190. package/extensions/signal/package.json +1 -1
  191. package/extensions/slack/package.json +1 -1
  192. package/extensions/telegram/package.json +1 -1
  193. package/extensions/tlon/package.json +1 -1
  194. package/extensions/twitch/CHANGELOG.md +12 -0
  195. package/extensions/twitch/package.json +1 -1
  196. package/extensions/voice-call/CHANGELOG.md +12 -0
  197. package/extensions/voice-call/package.json +1 -1
  198. package/extensions/whatsapp/package.json +1 -1
  199. package/extensions/zalo/CHANGELOG.md +12 -0
  200. package/extensions/zalo/package.json +1 -1
  201. package/extensions/zalouser/CHANGELOG.md +12 -0
  202. package/extensions/zalouser/package.json +1 -1
  203. package/package.json +1 -1
  204. package/skills/long-task/scripts/detach-task.sh +91 -14
@@ -1,7 +1,7 @@
1
1
  import { g as resolveStateDir, t as CONFIG_PATH } from "./paths-Cqn-zk3M.js";
2
2
  import { D as isPlainObject, U as getResolvedLoggerSettings, r as clamp, y as resolveUserPath } from "./utils-B-0b9bGM.js";
3
3
  import { a as normalizeElevatedLevel, c as normalizeUsageDisplay, d as supportsXHighThinking, n as formatXHighModelHint, o as normalizeReasoningLevel, s as normalizeThinkLevel, t as formatThinkingLevels } from "./thinking-EAliFiVK.js";
4
- import { $n as OPENAI_TTS_MODELS, Bn as registerAgentRunContext, Bt as abortEmbeddedPiRun, C as ensureOutboundSessionEntry, Et as agentCommand, Ft as normalizeSendPolicy, G as normalizeCronJobPatch, Gn as resolveTtsApiKey, H as writeRestartSentinel, Hn as getTtsProvider, Ht as waitForEmbeddedPiRunEnd, It as resolveSendPolicy, Jn as resolveTtsPrefsPath, Kn as resolveTtsAutoMode, L as formatDoctorNonInteractiveHint, Mn as listSubagentRunsForRequester, Mt as resolveOutboundTarget, N as scheduleGatewaySigusr1Restart, Ot as resolveAgentDeliveryPlan, Pr as resolveAgentTimeoutMs, Qn as textToSpeech, Rt as createOutboundSendDeps, Sr as isSystemEventContextChanged, Tn as stopSubagentsForRequester, Un as isTtsEnabled, Vn as resolveUserTimezone, W as normalizeCronJobCreate, Wn as isTtsProviderConfigured, Xn as setTtsEnabled, Yn as resolveTtsProviderOrder, Zn as setTtsProvider, _ as loadCombinedSessionStoreForGateway, at as persistBrowserProxyFiles, b as resolveGatewaySessionStoreTarget, br as parseVerboseOverride, c as clearSessionQueues, er as OPENAI_TTS_VOICES, ft as loadSymiPlugins, g as listSessionsFromStore, gt as loadProviderUsageSummary, h as listAgentsForGateway, in as unbindThreadBindingsBySessionKey, it as applyBrowserProxyPaths, jn as listDescendantRunsForRequester, kt as resolveAgentOutboundTarget, mn as createReplyDispatcher, mt as normalizeGroupActivation, n as BARE_SESSION_RESET_PROMPT, p as canonicalizeSpawnedByForAgent, pn as dispatchInboundMessage, qn as resolveTtsConfig, v as loadSessionEntry, vr as applyModelOverrideToSessionEntry, w as resolveOutboundSessionRoute, wn as isAbortTrigger, x as resolveSessionModelRef, xn as formatZonedTimestamp, xr as enqueueSystemEvent, y as pruneLegacyStoreKeys, yr as applyVerboseOverride, zn as onAgentEvent } from "./reply-DyjXROKp.js";
4
+ import { $n as OPENAI_TTS_MODELS, Bn as registerAgentRunContext, Bt as abortEmbeddedPiRun, C as ensureOutboundSessionEntry, Et as agentCommand, Ft as normalizeSendPolicy, G as normalizeCronJobPatch, Gn as resolveTtsApiKey, H as writeRestartSentinel, Hn as getTtsProvider, Ht as waitForEmbeddedPiRunEnd, It as resolveSendPolicy, Jn as resolveTtsPrefsPath, Kn as resolveTtsAutoMode, L as formatDoctorNonInteractiveHint, Mn as listSubagentRunsForRequester, Mt as resolveOutboundTarget, N as scheduleGatewaySigusr1Restart, Ot as resolveAgentDeliveryPlan, Pr as resolveAgentTimeoutMs, Qn as textToSpeech, Rt as createOutboundSendDeps, Sr as isSystemEventContextChanged, Tn as stopSubagentsForRequester, Un as isTtsEnabled, Vn as resolveUserTimezone, W as normalizeCronJobCreate, Wn as isTtsProviderConfigured, Xn as setTtsEnabled, Yn as resolveTtsProviderOrder, Zn as setTtsProvider, _ as loadCombinedSessionStoreForGateway, at as persistBrowserProxyFiles, b as resolveGatewaySessionStoreTarget, br as parseVerboseOverride, c as clearSessionQueues, er as OPENAI_TTS_VOICES, ft as loadSymiPlugins, g as listSessionsFromStore, gt as loadProviderUsageSummary, h as listAgentsForGateway, in as unbindThreadBindingsBySessionKey, it as applyBrowserProxyPaths, jn as listDescendantRunsForRequester, kt as resolveAgentOutboundTarget, mn as createReplyDispatcher, mt as normalizeGroupActivation, n as BARE_SESSION_RESET_PROMPT, p as canonicalizeSpawnedByForAgent, pn as dispatchInboundMessage, qn as resolveTtsConfig, v as loadSessionEntry, vr as applyModelOverrideToSessionEntry, w as resolveOutboundSessionRoute, wn as isAbortTrigger, x as resolveSessionModelRef, xn as formatZonedTimestamp, xr as enqueueSystemEvent, y as pruneLegacyStoreKeys, yr as applyVerboseOverride, zn as onAgentEvent } from "./reply-XaXqDK9F.js";
5
5
  import { S as parseAgentSessionKey, l as resolveAgentIdFromSessionKey, m as DEFAULT_ACCOUNT_ID, o as classifySessionKeyShape, s as normalizeAgentId, t as DEFAULT_AGENT_ID, x as isSubagentSessionKey } from "./session-key-DCt45XZa.js";
6
6
  import { t as resolveSymiPackageRoot } from "./symi-root-CrGJbkzf.js";
7
7
  import { C as createInternalHookEvent, T as triggerInternalHook, d as getActivePluginRegistry, r as DEFAULT_CHAT_CHANNEL, t as CHANNEL_IDS } from "./registry-Cja8eT7G.js";
@@ -20,15 +20,15 @@ import { i as normalizeInputProvenance } from "./input-provenance-BzbXHcaD.js";
20
20
  import { n as createBrowserRouteDispatcher } from "./with-timeout-CtVdu_1U.js";
21
21
  import { C as getGlobalHookRunner, o as normalizeReplyPayloadsForDelivery, t as deliverOutboundPayloads } from "./deliver-B4KZ6-oZ.js";
22
22
  import { a as resolveAgentIdentity, t as createReplyPrefixOptions } from "./reply-prefix-CE2YmmsD.js";
23
- import { $ as validateNodePairRejectParams, A as validateCronStatusParams, B as validateExecApprovalsGetParams, Bt as rejectDevicePairing, C as validateConfigSetParams, Ct as validateWakeParams, D as validateCronRemoveParams, Dt as validateWizardNextParams, E as validateCronListParams, Et as validateWizardCancelParams, F as validateDevicePairRemoveParams, G as validateModelsListParams, Gt as summarizeDeviceTokens, H as validateExecApprovalsNodeSetParams, I as validateDeviceTokenRevokeParams, It as approveDevicePairing, J as validateNodeInvokeParams, K as validateNodeDescribeParams, L as validateDeviceTokenRotateParams, M as validateDevicePairApproveParams, Mt as errorShape, N as validateDevicePairListParams, O as validateCronRunParams, Ot as validateWizardStartParams, P as validateDevicePairRejectParams, Pt as parseSessionLabel, Q as validateNodePairListParams, S as validateConfigSchemaParams, St as validateUpdateRunParams, T as validateCronAddParams, Tt as validateWebLoginWaitParams, U as validateExecApprovalsSetParams, Ut as revokeDeviceToken, V as validateExecApprovalsNodeGetParams, Vt as removePairedDevice, W as validateLogsTailParams, Wt as rotateDeviceToken, X as validateNodeListParams, Y as validateNodeInvokeResultParams, Z as validateNodePairApproveParams, _ as validateChatInjectParams, _t as validateSkillsInstallParams, a as validateAgentWaitParams, b as validateConfigGetParams, bt as validateTalkConfigParams, c as validateAgentsFilesGetParams, ct as validateSessionsDeleteParams, d as validateAgentsListParams, dt as validateSessionsPreviewParams, et as validateNodePairRequestParams, f as validateAgentsUpdateParams, ft as validateSessionsResetParams, g as validateChatHistoryParams, gt as validateSkillsBinsParams, h as validateChatAbortParams, ht as validateSessionsUsageParams, i as validateAgentParams, it as validatePushTestParams, j as validateCronUpdateParams, jt as ErrorCodes, k as validateCronRunsParams, kt as validateWizardStatusParams, l as validateAgentsFilesListParams, lt as validateSessionsListParams, m as validateChannelsStatusParams, mt as validateSessionsRestoreParams, n as formatValidationErrors, nt as validateNodeRenameParams, o as validateAgentsCreateParams, ot as validateSendParams, p as validateChannelsLogoutParams, pt as validateSessionsResolveParams, q as validateNodeEventParams, r as validateAgentIdentityParams, rt as validatePollParams, s as validateAgentsDeleteParams, st as validateSessionsCompactParams, tt as validateNodePairVerifyParams, u as validateAgentsFilesSetParams, ut as validateSessionsPatchParams, v as validateChatSendParams, vt as validateSkillsStatusParams, wt as validateWebLoginStartParams, x as validateConfigPatchParams, xt as validateTalkModeParams, y as validateConfigApplyParams, yt as validateSkillsUpdateParams, zt as listDevicePairing } from "./client-jI1oE0_k.js";
24
- import { l as authorizeOperatorScopesForMethod, s as ADMIN_SCOPE$2, u as isNodeRoleMethod } from "./call-DwpGquzW.js";
23
+ import { $ as validateNodePairRejectParams, A as validateCronStatusParams, At as validateWizardNextParams, B as validateExecApprovalsGetParams, C as validateConfigSetParams, Ct as validateTalkConfigParams, D as validateCronRemoveParams, Dt as validateWebLoginStartParams, E as validateCronListParams, Et as validateWakeParams, F as validateDevicePairRemoveParams, Ft as errorShape, G as validateModelsListParams, H as validateExecApprovalsNodeSetParams, Ht as listDevicePairing, I as validateDeviceTokenRevokeParams, J as validateNodeInvokeParams, Jt as summarizeDeviceTokens, K as validateNodeDescribeParams, Kt as revokeDeviceToken, L as validateDeviceTokenRotateParams, Lt as parseSessionLabel, M as validateDevicePairApproveParams, Mt as validateWizardStatusParams, N as validateDevicePairListParams, O as validateCronRunParams, Ot as validateWebLoginWaitParams, P as validateDevicePairRejectParams, Pt as ErrorCodes, Q as validateNodePairListParams, S as validateConfigSchemaParams, St as validateSkillsUpdateParams, T as validateCronAddParams, Tt as validateUpdateRunParams, U as validateExecApprovalsSetParams, Ut as rejectDevicePairing, V as validateExecApprovalsNodeGetParams, W as validateLogsTailParams, Wt as removePairedDevice, X as validateNodeListParams, Y as validateNodeInvokeResultParams, Z as validateNodePairApproveParams, _ as validateChatInjectParams, _t as validateSessionsRestoreParams, a as validateAgentWaitParams, b as validateConfigGetParams, bt as validateSkillsInstallParams, c as validateAgentsFilesGetParams, ct as validateSessionsCompactParams, d as validateAgentsListParams, dt as validateSessionsFavoriteFileParams, et as validateNodePairRequestParams, f as validateAgentsUpdateParams, ft as validateSessionsListParams, g as validateChatHistoryParams, gt as validateSessionsResolveParams, h as validateChatAbortParams, ht as validateSessionsResetParams, i as validateAgentParams, it as validatePushTestParams, j as validateCronUpdateParams, jt as validateWizardStartParams, k as validateCronRunsParams, kt as validateWizardCancelParams, l as validateAgentsFilesListParams, lt as validateSessionsDeleteFileParams, m as validateChannelsStatusParams, mt as validateSessionsPreviewParams, n as formatValidationErrors, nt as validateNodeRenameParams, o as validateAgentsCreateParams, ot as validateSendParams, p as validateChannelsLogoutParams, pt as validateSessionsPatchParams, q as validateNodeEventParams, qt as rotateDeviceToken, r as validateAgentIdentityParams, rt as validatePollParams, s as validateAgentsDeleteParams, st as validateSessionsAdoptFileParams, tt as validateNodePairVerifyParams, u as validateAgentsFilesSetParams, ut as validateSessionsDeleteParams, v as validateChatSendParams, vt as validateSessionsUsageParams, wt as validateTalkModeParams, x as validateConfigPatchParams, xt as validateSkillsStatusParams, y as validateConfigApplyParams, yt as validateSkillsBinsParams, zt as approveDevicePairing } from "./client-B8xmq-Pw.js";
24
+ import { l as authorizeOperatorScopesForMethod, s as ADMIN_SCOPE$2, u as isNodeRoleMethod } from "./call-CX0cs106.js";
25
25
  import { c as writeJsonAtomic, o as createAsyncLock, s as readJsonFile } from "./pairing-token-CX3NN_qj.js";
26
26
  import { n as normalizePollInput } from "./polls-DhH5YkzN.js";
27
27
  import { t as getChannelActivity } from "./channel-activity-BOiuJS3t.js";
28
28
  import { _ as requestNodePairing, g as renamePairedNode, h as rejectNodePairing, m as listNodePairing, o as getRemoteSkillEligibility, p as approveNodePairing, y as verifyNodeToken } from "./skill-commands-Cxw-jNxU.js";
29
29
  import { t as listAgentWorkspaceDirs } from "./workspace-dirs-GpkFi6Kw.js";
30
30
  import { i as loadSessionUsageTimeSeries, n as loadCostUsageSummary, r as loadSessionCostSummary, t as discoverAllSessions } from "./session-cost-usage-BXAI7CNH.js";
31
- import { w as resolveAssistantAvatarUrl } from "./onboard-helpers-DFvWPFhU.js";
31
+ import { w as resolveAssistantAvatarUrl } from "./onboard-helpers-CueJ7O_B.js";
32
32
  import { a as mergeExecApprovalsSocketDefaults, c as readExecApprovalsSnapshot, p as saveExecApprovals, r as ensureExecApprovals, s as normalizeExecApprovals } from "./exec-approvals-DXM2pQYL.js";
33
33
  import { n as createBrowserControlContext, r as startBrowserControlServiceFromConfig } from "./control-service-BYKXzY4f.js";
34
34
  import { i as parseAbsoluteTimeMs } from "./stagger-CvFURHzt.js";
@@ -38,15 +38,15 @@ import { t as buildWorkspaceSkillStatus } from "./skills-status-C3ptXwnh.js";
38
38
  import { t as WizardCancelledError } from "./prompts-CfOu9uZi.js";
39
39
  import { t as resolveChannelDefaultAccountId } from "./helpers-DnjQ73f_.js";
40
40
  import { t as buildChannelAccountSnapshot } from "./status-klsFDD3M.js";
41
- import { o as isNodeCommandAllowed, s as resolveNodeCommandAllowlist } from "./audit-DB9YkTVX.js";
42
- import { n as getStatusSummary } from "./status-ZPW5EACm.js";
43
- import { s as setHeartbeatsEnabled } from "./health-D3w4YMlC.js";
41
+ import { o as isNodeCommandAllowed, s as resolveNodeCommandAllowlist } from "./audit-BgdM9XZl.js";
42
+ import { n as getStatusSummary } from "./status-DOTlXdcN.js";
43
+ import { s as setHeartbeatsEnabled } from "./health-B1nih5LD.js";
44
44
  import { m as normalizeUpdateChannel } from "./update-check-7EzEjSzb.js";
45
- import { a as sendApnsAlert, c as parseMessageWithAttachments, i as resolveApnsAuthConfigFromEnv, l as formatForLog, n as normalizeApnsEnvironment, o as sendApnsBackgroundWake, s as normalizeRpcAttachmentsToChatAttachments, t as loadApnsRegistration } from "./push-apns-CObVeJLC.js";
46
- import { a as pruneAgentConfig, i as loadAgentIdentity, r as findAgentEntryIndex, t as applyAgentConfig } from "./agents.config-BEVb1Pyx.js";
45
+ import { a as sendApnsAlert, c as parseMessageWithAttachments, i as resolveApnsAuthConfigFromEnv, l as formatForLog, n as normalizeApnsEnvironment, o as sendApnsBackgroundWake, s as normalizeRpcAttachmentsToChatAttachments, t as loadApnsRegistration } from "./push-apns-CoG1P_P0.js";
46
+ import { a as pruneAgentConfig, i as loadAgentIdentity, r as findAgentEntryIndex, t as applyAgentConfig } from "./agents.config-B9BZoM2m.js";
47
47
  import { t as resolveSystemRunCommand } from "./system-run-command-B_qw8CXP.js";
48
48
  import { t as installSkill } from "./skills-install-CWVdJkLn.js";
49
- import { t as runGatewayUpdate } from "./update-runner-BRKFzAwV.js";
49
+ import { t as runGatewayUpdate } from "./update-runner-FhW6n-Nv.js";
50
50
  import * as fs$2 from "node:fs";
51
51
  import fs from "node:fs";
52
52
  import * as os$1 from "node:os";
@@ -1178,6 +1178,144 @@ function timestampOptsFromConfig(cfg) {
1178
1178
  return { timezone: resolveUserTimezone(cfg.agents?.defaults?.userTimezone) };
1179
1179
  }
1180
1180
 
1181
+ //#endregion
1182
+ //#region src/config/sessions/favorites.ts
1183
+ /**
1184
+ * Session favourites sidecar.
1185
+ *
1186
+ * Stores a set of "favourited" session files at
1187
+ * `<sessionsDir>/favorites.json`. Keyed by **filename** (basename), not
1188
+ * sessionId, because archived files (`.reset.<ts>` / `.deleted.<ts>`) can
1189
+ * share a UUID with an active `<uuid>.jsonl`. Filename is the unique
1190
+ * reference that survives restore/adopt/rename operations — we explicitly
1191
+ * rename the entry in the sidecar when the underlying file is renamed.
1192
+ *
1193
+ * Writes go through a tmp-file + rename cycle to preserve the old contents
1194
+ * if a write fails mid-flight. Reads are synchronous and cheap (the file
1195
+ * is small); no in-memory cache is maintained because the list endpoint
1196
+ * re-reads on every HTTP request anyway.
1197
+ *
1198
+ * @module
1199
+ */
1200
+ const FAVORITES_FILE_NAME = "favorites.json";
1201
+ const EMPTY_FILE = {
1202
+ version: 1,
1203
+ files: []
1204
+ };
1205
+ function resolveFavoritesPath(agentId) {
1206
+ return path.join(resolveSessionTranscriptsDirForAgent(agentId), FAVORITES_FILE_NAME);
1207
+ }
1208
+ function readFavoritesFile(favPath) {
1209
+ if (!fs.existsSync(favPath)) return { ...EMPTY_FILE };
1210
+ try {
1211
+ const raw = fs.readFileSync(favPath, "utf-8");
1212
+ const parsed = JSON.parse(raw);
1213
+ return {
1214
+ version: 1,
1215
+ files: Array.isArray(parsed?.files) ? parsed.files.filter((f) => typeof f === "string" && f.length > 0) : []
1216
+ };
1217
+ } catch {
1218
+ return { ...EMPTY_FILE };
1219
+ }
1220
+ }
1221
+ function writeFavoritesFileAtomic(favPath, file) {
1222
+ fs.mkdirSync(path.dirname(favPath), { recursive: true });
1223
+ const tmp = `${favPath}.${process.pid}.${randomUUID()}.tmp`;
1224
+ try {
1225
+ fs.writeFileSync(tmp, JSON.stringify(file, null, 2), {
1226
+ mode: 384,
1227
+ encoding: "utf-8"
1228
+ });
1229
+ fs.renameSync(tmp, favPath);
1230
+ } catch (err) {
1231
+ try {
1232
+ fs.rmSync(tmp, { force: true });
1233
+ } catch {}
1234
+ throw err;
1235
+ }
1236
+ }
1237
+ /**
1238
+ * Load the set of favourited filenames for an agent. Returns an empty set if
1239
+ * the sidecar file is missing or corrupt. Never throws.
1240
+ */
1241
+ function loadFavoritesSet(agentId) {
1242
+ try {
1243
+ const file = readFavoritesFile(resolveFavoritesPath(agentId));
1244
+ return new Set(file.files);
1245
+ } catch {
1246
+ return /* @__PURE__ */ new Set();
1247
+ }
1248
+ }
1249
+ /**
1250
+ * Set the favourited flag for a file. If `favorited` is true and the file is
1251
+ * already present, or false and already absent, this is a no-op. Returns the
1252
+ * new favourited state (so callers can echo it back in an RPC response).
1253
+ */
1254
+ function setFavorite(file, favorited, agentId) {
1255
+ const favPath = resolveFavoritesPath(agentId);
1256
+ const current = readFavoritesFile(favPath);
1257
+ const set = new Set(current.files);
1258
+ const had = set.has(file);
1259
+ if (favorited && !had) set.add(file);
1260
+ else if (!favorited && had) set.delete(file);
1261
+ else return favorited;
1262
+ writeFavoritesFileAtomic(favPath, {
1263
+ version: 1,
1264
+ files: [...set].toSorted()
1265
+ });
1266
+ return favorited;
1267
+ }
1268
+ /**
1269
+ * Rename a favourites entry. Called by adoptFile/restore when a file on disk
1270
+ * is renamed (e.g. `<uuid>.jsonl.reset.<ts>` → `<uuid>.jsonl`). If `oldFile`
1271
+ * wasn't favourited, this is a no-op. If both `oldFile` and `newFile` are
1272
+ * favourited (unlikely but possible), the `oldFile` entry is simply dropped.
1273
+ */
1274
+ function renameFavoriteEntry(oldFile, newFile, agentId) {
1275
+ const favPath = resolveFavoritesPath(agentId);
1276
+ const current = readFavoritesFile(favPath);
1277
+ const set = new Set(current.files);
1278
+ if (!set.has(oldFile)) return;
1279
+ set.delete(oldFile);
1280
+ set.add(newFile);
1281
+ writeFavoritesFileAtomic(favPath, {
1282
+ version: 1,
1283
+ files: [...set].toSorted()
1284
+ });
1285
+ }
1286
+ /**
1287
+ * Drop an entry from the sidecar regardless of current state. Used when a
1288
+ * file is permanently deleted so we don't keep a stale favourite pointing at
1289
+ * something that no longer exists. No-op if absent.
1290
+ */
1291
+ function dropFavoriteEntry(file, agentId) {
1292
+ const favPath = resolveFavoritesPath(agentId);
1293
+ const current = readFavoritesFile(favPath);
1294
+ if (!current.files.includes(file)) return;
1295
+ writeFavoritesFileAtomic(favPath, {
1296
+ version: 1,
1297
+ files: current.files.filter((f) => f !== file).toSorted()
1298
+ });
1299
+ }
1300
+ /**
1301
+ * Reconcile the sidecar against an authoritative set of filenames that still
1302
+ * exist on disk. Drops any favourites whose files are missing. Safe to call
1303
+ * on every list operation — the write only happens when something changes.
1304
+ * Returns the reconciled set.
1305
+ */
1306
+ function reconcileFavorites(existingFiles, agentId) {
1307
+ const existingSet = new Set(existingFiles);
1308
+ const favPath = resolveFavoritesPath(agentId);
1309
+ const current = readFavoritesFile(favPath);
1310
+ const keep = current.files.filter((f) => existingSet.has(f));
1311
+ if (keep.length === current.files.length) return new Set(current.files);
1312
+ writeFavoritesFileAtomic(favPath, {
1313
+ version: 1,
1314
+ files: keep.toSorted()
1315
+ });
1316
+ return new Set(keep);
1317
+ }
1318
+
1181
1319
  //#endregion
1182
1320
  //#region src/gateway/sessions-patch.ts
1183
1321
  function invalid(message) {
@@ -1611,6 +1749,237 @@ async function emitSessionUnboundLifecycleEvent(params) {
1611
1749
  outcome: params.reason === "session-reset" ? "reset" : "deleted"
1612
1750
  }, { childSessionKey: params.targetSessionKey });
1613
1751
  }
1752
+ /**
1753
+ * Per-session in-flight lock shared by `sessions.restore` and
1754
+ * `sessions.adoptFile`. Prevents two concurrent adoption calls for the same
1755
+ * session key from corrupting each other (e.g. one archives the active
1756
+ * transcript while the other is mid-rename). Keyed by canonical session key.
1757
+ */
1758
+ const restoreInFlight = /* @__PURE__ */ new Set();
1759
+ /**
1760
+ * Classify a target file basename into the adoption mode we need to take.
1761
+ * - `archived`: a `.reset.<ts>` / `.deleted.<ts>` transcript that must be
1762
+ * renamed back to `<sessionId>.jsonl`.
1763
+ * - `active`: a plain `<sessionId>.jsonl` that may already be owned by
1764
+ * another session key in the registry; we adopt it by dropping the other
1765
+ * key's entry (if any) and pointing ours at it. No filesystem rename.
1766
+ */
1767
+ function classifyTargetFile(basename) {
1768
+ if (/\.jsonl\.reset\./.test(basename)) return {
1769
+ kind: "archived",
1770
+ reason: "reset"
1771
+ };
1772
+ if (/\.jsonl\.deleted\./.test(basename)) return {
1773
+ kind: "archived",
1774
+ reason: "deleted"
1775
+ };
1776
+ if (/^[A-Za-z0-9][\w.-]*\.jsonl$/.test(basename)) return { kind: "active" };
1777
+ return null;
1778
+ }
1779
+ async function performAdoptFile(params) {
1780
+ const { key } = params;
1781
+ const targetBasename = path.basename(params.targetFile);
1782
+ if (targetBasename !== params.targetFile || targetBasename.includes("..") || targetBasename.length === 0) return {
1783
+ ok: false,
1784
+ errorCode: "INVALID_REQUEST",
1785
+ errorMessage: "Invalid target file name."
1786
+ };
1787
+ const classification = classifyTargetFile(targetBasename);
1788
+ if (!classification) return {
1789
+ ok: false,
1790
+ errorCode: "INVALID_REQUEST",
1791
+ errorMessage: "Target file is not a recognised session transcript."
1792
+ };
1793
+ const { cfg, target, storePath } = resolveGatewaySessionTargetFromKey(key);
1794
+ const sessionsDir = path.dirname(storePath);
1795
+ const targetPath = path.join(sessionsDir, targetBasename);
1796
+ if (!fs.existsSync(targetPath)) return {
1797
+ ok: false,
1798
+ errorCode: "INVALID_REQUEST",
1799
+ errorMessage: `Target file not found: ${targetBasename}`
1800
+ };
1801
+ let restoredSessionId;
1802
+ try {
1803
+ const firstLine = fs.readFileSync(targetPath, "utf8").split("\n")[0] ?? "";
1804
+ const header = JSON.parse(firstLine);
1805
+ if (!header.id || header.type !== "session") throw new Error("invalid session header");
1806
+ restoredSessionId = header.id;
1807
+ } catch {
1808
+ return {
1809
+ ok: false,
1810
+ errorCode: "INVALID_REQUEST",
1811
+ errorMessage: "Target file is not a valid session transcript."
1812
+ };
1813
+ }
1814
+ const lockKey = target.canonicalKey ?? key;
1815
+ if (restoreInFlight.has(lockKey)) return {
1816
+ ok: false,
1817
+ errorCode: "UNAVAILABLE",
1818
+ errorMessage: `Adopt already in progress for session ${lockKey}; try again in a moment.`
1819
+ };
1820
+ restoreInFlight.add(lockKey);
1821
+ const rollback = [];
1822
+ try {
1823
+ const { entry: currentEntry } = loadSessionEntry(key);
1824
+ const cleanupError = await ensureSessionRuntimeCleanup({
1825
+ cfg,
1826
+ key,
1827
+ target,
1828
+ sessionId: currentEntry?.sessionId
1829
+ });
1830
+ if (cleanupError) return {
1831
+ ok: false,
1832
+ errorCode: "UNAVAILABLE",
1833
+ errorMessage: cleanupError.message ?? "runtime cleanup failed"
1834
+ };
1835
+ if (currentEntry?.sessionId === restoredSessionId && classification.kind === "active") return {
1836
+ ok: true,
1837
+ sessionId: restoredSessionId,
1838
+ canonicalKey: target.canonicalKey,
1839
+ entry: currentEntry,
1840
+ restoredFileName: targetBasename,
1841
+ droppedSourceKeys: []
1842
+ };
1843
+ const archivedPaths = archiveSessionTranscriptsForSession({
1844
+ sessionId: currentEntry?.sessionId,
1845
+ storePath,
1846
+ sessionFile: currentEntry?.sessionFile,
1847
+ agentId: target.agentId,
1848
+ reason: "reset"
1849
+ });
1850
+ for (const archived of archivedPaths) {
1851
+ const archivedBasename = path.basename(archived);
1852
+ const originalBasename = archivedBasename.replace(/\.reset\.[^/]+$/, "");
1853
+ rollback.push({
1854
+ desc: `un-archive ${archivedBasename}`,
1855
+ fn: () => {
1856
+ renameArchivedBackToOriginal(archived, "reset");
1857
+ if (originalBasename && originalBasename !== archivedBasename) renameFavoriteEntry(archivedBasename, originalBasename, target.agentId);
1858
+ }
1859
+ });
1860
+ if (originalBasename && originalBasename !== archivedBasename) renameFavoriteEntry(originalBasename, archivedBasename, target.agentId);
1861
+ }
1862
+ const restoredFileName = `${restoredSessionId}.jsonl`;
1863
+ const restoredPath = path.join(sessionsDir, restoredFileName);
1864
+ if (classification.kind === "archived" && targetPath !== restoredPath) {
1865
+ fs.renameSync(targetPath, restoredPath);
1866
+ rollback.push({
1867
+ desc: `re-archive ${restoredPath} to ${targetPath}`,
1868
+ fn: () => {
1869
+ try {
1870
+ fs.renameSync(restoredPath, targetPath);
1871
+ } catch (err) {
1872
+ console.warn(`[sessions.adoptFile] rollback: rename ${restoredPath} → ${targetPath} failed: ${String(err)}`);
1873
+ }
1874
+ renameFavoriteEntry(restoredFileName, targetBasename, target.agentId);
1875
+ }
1876
+ });
1877
+ renameFavoriteEntry(targetBasename, restoredFileName, target.agentId);
1878
+ }
1879
+ const droppedSourceKeys = [];
1880
+ let droppedSourceEntries = [];
1881
+ const next = await updateSessionStore(storePath, (store) => {
1882
+ const { primaryKey } = migrateAndPruneSessionStoreKey({
1883
+ cfg,
1884
+ key,
1885
+ store
1886
+ });
1887
+ if (classification.kind === "active") for (const [otherKey, otherEntry] of Object.entries(store)) {
1888
+ if (otherKey === primaryKey) continue;
1889
+ if (otherEntry?.sessionId === restoredSessionId) {
1890
+ droppedSourceEntries.push({
1891
+ key: otherKey,
1892
+ entry: otherEntry
1893
+ });
1894
+ droppedSourceKeys.push(otherKey);
1895
+ delete store[otherKey];
1896
+ }
1897
+ }
1898
+ const existingEntry = store[primaryKey];
1899
+ const nextEntry = {
1900
+ sessionId: restoredSessionId,
1901
+ sessionFile: restoredPath,
1902
+ updatedAt: Date.now(),
1903
+ systemSent: false,
1904
+ abortedLastRun: false,
1905
+ thinkingLevel: existingEntry?.thinkingLevel,
1906
+ verboseLevel: existingEntry?.verboseLevel,
1907
+ reasoningLevel: existingEntry?.reasoningLevel,
1908
+ responseUsage: existingEntry?.responseUsage,
1909
+ model: existingEntry?.model,
1910
+ contextTokens: existingEntry?.contextTokens,
1911
+ sendPolicy: existingEntry?.sendPolicy,
1912
+ label: existingEntry?.label,
1913
+ origin: snapshotSessionOrigin(existingEntry),
1914
+ lastChannel: existingEntry?.lastChannel,
1915
+ lastTo: existingEntry?.lastTo,
1916
+ skillsSnapshot: existingEntry?.skillsSnapshot,
1917
+ inputTokens: 0,
1918
+ outputTokens: 0,
1919
+ totalTokens: 0,
1920
+ totalTokensFresh: true
1921
+ };
1922
+ store[primaryKey] = nextEntry;
1923
+ return nextEntry;
1924
+ });
1925
+ if (droppedSourceEntries.length > 0) {
1926
+ const restoreEntries = droppedSourceEntries.slice();
1927
+ rollback.push({
1928
+ desc: `restore ${restoreEntries.length} source registry entry/entries`,
1929
+ fn: () => {
1930
+ updateSessionStore(storePath, (store) => {
1931
+ for (const { key: k, entry: e } of restoreEntries) store[k] = e;
1932
+ }).catch((err) => {
1933
+ console.warn(`[sessions.adoptFile] rollback: could not restore source entries: ${String(err)}`);
1934
+ });
1935
+ }
1936
+ });
1937
+ }
1938
+ rollback.length = 0;
1939
+ return {
1940
+ ok: true,
1941
+ sessionId: restoredSessionId,
1942
+ canonicalKey: target.canonicalKey,
1943
+ entry: next,
1944
+ restoredFileName,
1945
+ droppedSourceKeys
1946
+ };
1947
+ } catch (err) {
1948
+ console.warn(`[sessions.adoptFile] failed for ${lockKey}; running ${rollback.length} rollback step(s): ${String(err)}`);
1949
+ for (let i = rollback.length - 1; i >= 0; i--) {
1950
+ const step = rollback[i];
1951
+ if (step) step.fn();
1952
+ }
1953
+ return {
1954
+ ok: false,
1955
+ errorCode: "UNAVAILABLE",
1956
+ errorMessage: `Adopt failed: ${err instanceof Error ? err.message : String(err)}`
1957
+ };
1958
+ } finally {
1959
+ restoreInFlight.delete(lockKey);
1960
+ }
1961
+ }
1962
+ /**
1963
+ * Best-effort inverse of `archiveFileOnDisk(file, "reset")` — renames
1964
+ * `<file>.reset.<timestamp>` back to `<file>`. Used by the sessions.restore
1965
+ * rollback path when a later step fails after the current transcript was
1966
+ * archived. Swallows all errors and logs; the goal is to recover as much
1967
+ * state as possible, not to guarantee success.
1968
+ */
1969
+ function renameArchivedBackToOriginal(archivedPath, reason) {
1970
+ const marker = `.${reason}.`;
1971
+ const idx = archivedPath.lastIndexOf(marker);
1972
+ if (idx <= 0) {
1973
+ console.warn(`[sessions.restore] cannot parse archived path for rollback: ${archivedPath}`);
1974
+ return;
1975
+ }
1976
+ const originalPath = archivedPath.slice(0, idx);
1977
+ try {
1978
+ fs.renameSync(archivedPath, originalPath);
1979
+ } catch (err) {
1980
+ console.warn(`[sessions.restore] rollback failed: could not rename ${archivedPath} back to ${originalPath}: ${String(err)}`);
1981
+ }
1982
+ }
1614
1983
  async function ensureSessionRuntimeCleanup(params) {
1615
1984
  const queueKeys = new Set(params.target.storeKeys);
1616
1985
  queueKeys.add(params.target.canonicalKey);
@@ -1837,92 +2206,106 @@ const sessionsHandlers = {
1837
2206
  const p = params;
1838
2207
  const key = requireSessionKey(p.key, respond);
1839
2208
  if (!key) return;
1840
- const targetBasename = path.basename(p.targetFile);
1841
- if (targetBasename !== p.targetFile || targetBasename.includes("..")) {
1842
- respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, "Invalid target file name."));
1843
- return;
1844
- }
1845
- const { cfg, target, storePath } = resolveGatewaySessionTargetFromKey(key);
1846
- const sessionsDir = path.dirname(storePath);
1847
- const targetPath = path.join(sessionsDir, targetBasename);
1848
- if (!fs.existsSync(targetPath)) {
1849
- respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, `Target file not found: ${targetBasename}`));
1850
- return;
1851
- }
1852
- let restoredSessionId;
1853
- try {
1854
- const firstLine = fs.readFileSync(targetPath, "utf8").split("\n")[0];
1855
- const header = JSON.parse(firstLine);
1856
- if (!header.id || header.type !== "session") throw new Error("invalid session header");
1857
- restoredSessionId = header.id;
1858
- } catch {
1859
- respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, "Target file is not a valid session transcript."));
2209
+ const outcome = await performAdoptFile({
2210
+ key,
2211
+ targetFile: p.targetFile
2212
+ });
2213
+ if (!outcome.ok) {
2214
+ respond(false, void 0, errorShape(ErrorCodes[outcome.errorCode], outcome.errorMessage));
1860
2215
  return;
1861
2216
  }
1862
- const { entry } = loadSessionEntry(key);
1863
- const sessionId = entry?.sessionId;
1864
- const cleanupError = await ensureSessionRuntimeCleanup({
1865
- cfg,
2217
+ respond(true, {
2218
+ ok: true,
2219
+ key: outcome.canonicalKey,
2220
+ sessionId: outcome.sessionId,
2221
+ entry: outcome.entry
2222
+ }, void 0);
2223
+ },
2224
+ "sessions.adoptFile": async ({ params, respond }) => {
2225
+ if (!assertValidParams(params, validateSessionsAdoptFileParams, "sessions.adoptFile", respond)) return;
2226
+ const p = params;
2227
+ const key = requireSessionKey(p.key, respond);
2228
+ if (!key) return;
2229
+ const outcome = await performAdoptFile({
1866
2230
  key,
1867
- target,
1868
- sessionId
2231
+ targetFile: p.targetFile
1869
2232
  });
1870
- if (cleanupError) {
1871
- respond(false, void 0, cleanupError);
2233
+ if (!outcome.ok) {
2234
+ respond(false, void 0, errorShape(ErrorCodes[outcome.errorCode], outcome.errorMessage));
1872
2235
  return;
1873
2236
  }
1874
- const oldSessionId = entry?.sessionId;
1875
- const oldSessionFile = entry?.sessionFile;
1876
- archiveSessionTranscriptsForSession({
1877
- sessionId: oldSessionId,
1878
- storePath,
1879
- sessionFile: oldSessionFile,
1880
- agentId: target.agentId,
1881
- reason: "reset"
1882
- });
1883
- const restoredFileName = `${restoredSessionId}.jsonl`;
1884
- const restoredPath = path.join(sessionsDir, restoredFileName);
1885
- if (targetPath !== restoredPath) fs.renameSync(targetPath, restoredPath);
1886
- const next = await updateSessionStore(storePath, (store) => {
1887
- const { primaryKey } = migrateAndPruneSessionStoreKey({
1888
- cfg,
1889
- key,
1890
- store
1891
- });
1892
- const existingEntry = store[primaryKey];
1893
- const nextEntry = {
1894
- sessionId: restoredSessionId,
1895
- sessionFile: restoredPath,
1896
- updatedAt: Date.now(),
1897
- systemSent: false,
1898
- abortedLastRun: false,
1899
- thinkingLevel: existingEntry?.thinkingLevel,
1900
- verboseLevel: existingEntry?.verboseLevel,
1901
- reasoningLevel: existingEntry?.reasoningLevel,
1902
- responseUsage: existingEntry?.responseUsage,
1903
- model: existingEntry?.model,
1904
- contextTokens: existingEntry?.contextTokens,
1905
- sendPolicy: existingEntry?.sendPolicy,
1906
- label: existingEntry?.label,
1907
- origin: snapshotSessionOrigin(existingEntry),
1908
- lastChannel: existingEntry?.lastChannel,
1909
- lastTo: existingEntry?.lastTo,
1910
- skillsSnapshot: existingEntry?.skillsSnapshot,
1911
- inputTokens: 0,
1912
- outputTokens: 0,
1913
- totalTokens: 0,
1914
- totalTokensFresh: true
1915
- };
1916
- store[primaryKey] = nextEntry;
1917
- return nextEntry;
1918
- });
1919
2237
  respond(true, {
1920
2238
  ok: true,
1921
- key: target.canonicalKey,
1922
- sessionId: restoredSessionId,
1923
- entry: next
2239
+ key: outcome.canonicalKey,
2240
+ sessionId: outcome.sessionId,
2241
+ entry: outcome.entry,
2242
+ file: outcome.restoredFileName,
2243
+ droppedSourceKeys: outcome.droppedSourceKeys
1924
2244
  }, void 0);
1925
2245
  },
2246
+ "sessions.favoriteFile": ({ params, respond }) => {
2247
+ if (!assertValidParams(params, validateSessionsFavoriteFileParams, "sessions.favoriteFile", respond)) return;
2248
+ const p = params;
2249
+ const file = path.basename(p.file);
2250
+ if (file !== p.file || file.includes("..") || file.length === 0) {
2251
+ respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, "Invalid file name."));
2252
+ return;
2253
+ }
2254
+ const agentId = resolveDefaultAgentId(loadConfig());
2255
+ const sessionsDir = resolveSessionTranscriptsDirForAgent(agentId);
2256
+ const abs = path.join(sessionsDir, file);
2257
+ if (!fs.existsSync(abs)) {
2258
+ respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, `Session file not found: ${file}`));
2259
+ return;
2260
+ }
2261
+ try {
2262
+ respond(true, {
2263
+ ok: true,
2264
+ file,
2265
+ favorited: setFavorite(file, p.favorited, agentId)
2266
+ }, void 0);
2267
+ } catch (err) {
2268
+ respond(false, void 0, errorShape(ErrorCodes.UNAVAILABLE, `Favorite write failed: ${err instanceof Error ? err.message : String(err)}`));
2269
+ }
2270
+ },
2271
+ "sessions.deleteFile": async ({ params, respond }) => {
2272
+ if (!assertValidParams(params, validateSessionsDeleteFileParams, "sessions.deleteFile", respond)) return;
2273
+ const p = params;
2274
+ const file = path.basename(p.file);
2275
+ if (file !== p.file || file.includes("..") || file.length === 0) {
2276
+ respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, "Invalid file name."));
2277
+ return;
2278
+ }
2279
+ const cfg = loadConfig();
2280
+ const agentId = resolveDefaultAgentId(cfg);
2281
+ const sessionsDir = resolveSessionTranscriptsDirForAgent(agentId);
2282
+ const abs = path.join(sessionsDir, file);
2283
+ if (!fs.existsSync(abs)) {
2284
+ respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, `Session file not found: ${file}`));
2285
+ return;
2286
+ }
2287
+ const { store } = loadCombinedSessionStoreForGateway(cfg);
2288
+ if (classifyTargetFile(file)?.kind === "active") {
2289
+ const sessionId = file.match(/^(.+)\.jsonl$/)?.[1];
2290
+ if (sessionId) {
2291
+ const referrer = Object.entries(store).find(([, entry]) => entry?.sessionId === sessionId)?.[0];
2292
+ if (referrer) {
2293
+ respond(false, void 0, errorShape(ErrorCodes.INVALID_REQUEST, `File is still bound to session key ${referrer}; use sessions.delete on that key to archive it first.`));
2294
+ return;
2295
+ }
2296
+ }
2297
+ }
2298
+ try {
2299
+ fs.unlinkSync(abs);
2300
+ dropFavoriteEntry(file, agentId);
2301
+ respond(true, {
2302
+ ok: true,
2303
+ file
2304
+ }, void 0);
2305
+ } catch (err) {
2306
+ respond(false, void 0, errorShape(ErrorCodes.UNAVAILABLE, `Delete failed: ${err instanceof Error ? err.message : String(err)}`));
2307
+ }
2308
+ },
1926
2309
  "sessions.delete": async ({ params, respond, client, isWebchatConnect }) => {
1927
2310
  if (!assertValidParams(params, validateSessionsDeleteParams, "sessions.delete", respond)) return;
1928
2311
  const p = params;
@@ -6944,7 +7327,7 @@ const nodeHandlers = {
6944
7327
  const p = params;
6945
7328
  const payloadJSON = typeof p.payloadJSON === "string" ? p.payloadJSON : p.payload !== void 0 ? JSON.stringify(p.payload) : null;
6946
7329
  await respondUnavailableOnThrow(respond, async () => {
6947
- const { handleNodeEvent } = await import("./server-node-events-CDB0u8PP.js");
7330
+ const { handleNodeEvent } = await import("./server-node-events-DZAN3hWE.js");
6948
7331
  const nodeId = client?.connect?.device?.id ?? client?.connect?.client?.id ?? "node";
6949
7332
  await handleNodeEvent({
6950
7333
  deps: context.deps,
@@ -9009,4 +9392,4 @@ async function handleGatewayRequest(opts) {
9009
9392
  }
9010
9393
 
9011
9394
  //#endregion
9012
- export { getHandshakeTimeoutMs as _, DEFAULT_ASSISTANT_IDENTITY as a, resolveCronRunLogPath as b, upsertPresence as c, DEDUPE_MAX as d, DEDUPE_TTL_MS as f, TICK_INTERVAL_MS as g, MAX_PAYLOAD_BYTES as h, safeParseJson as i, formatError as l, MAX_BUFFERED_BYTES as m, handleGatewayRequest as n, resolveAssistantIdentity as o, HEALTH_REFRESH_INTERVAL_MS as p, broadcastPresenceSnapshot as r, listSystemPresence as s, coreGatewayHandlers as t, loadVoiceWakeConfig as u, abortChatRunById as v, startGatewayConfigReloader as x, appendCronRunLog as y };
9395
+ export { startGatewayConfigReloader as C, resolveCronRunLogPath as S, MAX_PAYLOAD_BYTES as _, loadFavoritesSet as a, abortChatRunById as b, resolveAssistantIdentity as c, formatError as d, loadVoiceWakeConfig as f, MAX_BUFFERED_BYTES as g, HEALTH_REFRESH_INTERVAL_MS as h, safeParseJson as i, listSystemPresence as l, DEDUPE_TTL_MS as m, handleGatewayRequest as n, reconcileFavorites as o, DEDUPE_MAX as p, broadcastPresenceSnapshot as r, DEFAULT_ASSISTANT_IDENTITY as s, coreGatewayHandlers as t, upsertPresence as u, TICK_INTERVAL_MS as v, appendCronRunLog as x, getHandshakeTimeoutMs as y };
@@ -11,11 +11,11 @@ import "./frontmatter-B8duUx_6.js";
11
11
  import "./skills-hAdgFdrv.js";
12
12
  import "./manifest-registry-Czr39pxG.js";
13
13
  import { i as loadConfig } from "./config-BNTB6qj8.js";
14
- import "./client-T3qcxXru.js";
15
- import "./call-DKi-hnaF.js";
14
+ import "./client-qUlxXXVJ.js";
15
+ import "./call-DeCQ2DhS.js";
16
16
  import "./message-channel-C9dERklz.js";
17
17
  import "./pairing-token-Byh6drgn.js";
18
- import { Cn as enqueueSystemEvent, T as createOutboundSendDeps, dn as requestHeartbeatNow, dt as resolveOutboundTarget, x as agentCommand } from "./subagent-registry-DQHg3jUV.js";
18
+ import { Cn as enqueueSystemEvent, T as createOutboundSendDeps, dn as requestHeartbeatNow, dt as resolveOutboundTarget, x as agentCommand } from "./subagent-registry-DCoU9xIE.js";
19
19
  import { d as updateSessionStore } from "./sessions-Cfa6JEB3.js";
20
20
  import "./tokens-Csntmwwn.js";
21
21
  import { r as normalizeChannelId } from "./plugins-CwSlLxM8.js";
@@ -95,11 +95,11 @@ import "./cli-utils-CCaEbxAz.js";
95
95
  import "./help-format-B0pWGnZs.js";
96
96
  import "./progress-BAHiAaDW.js";
97
97
  import "./replies-Bo49QlAg.js";
98
- import "./onboard-helpers-BBtPmJEe.js";
98
+ import "./onboard-helpers-PpGrZIGw.js";
99
99
  import "./prompt-style-DwCXob2h.js";
100
100
  import "./pairing-labels-D1HDboV2.js";
101
101
  import "./pi-tools.policy-DxNwL7Dl.js";
102
- import { c as parseMessageWithAttachments, l as formatForLog, r as registerApnsToken, s as normalizeRpcAttachmentsToChatAttachments } from "./push-apns-CYC70eKy.js";
102
+ import { c as parseMessageWithAttachments, l as formatForLog, r as registerApnsToken, s as normalizeRpcAttachmentsToChatAttachments } from "./push-apns-B5txhDVi.js";
103
103
  import { randomUUID } from "node:crypto";
104
104
 
105
105
  //#region src/gateway/server-node-events.ts