agent-log-viewer 1.1.0 → 1.2.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 (640) hide show
  1. package/bin/cli.mjs +4 -0
  2. package/bin/server-runtime.test.ts +63 -12
  3. package/dist/mcp-server.mjs +14033 -7722
  4. package/dist/runtime-host.mjs +17096 -7307
  5. package/dist/standalone/.next/BUILD_ID +1 -1
  6. package/dist/standalone/.next/app-path-routes-manifest.json +24 -19
  7. package/dist/standalone/.next/build-manifest.json +3 -3
  8. package/dist/standalone/.next/prerender-manifest.json +4 -4
  9. package/dist/standalone/.next/react-loadable-manifest.json +1 -1
  10. package/dist/standalone/.next/required-server-files.json +1 -1
  11. package/dist/standalone/.next/routes-manifest.json +30 -0
  12. package/dist/standalone/.next/server/account-migration-controller-worker.js +1 -1
  13. package/dist/standalone/.next/server/app/_global-error/page.js +2 -2
  14. package/dist/standalone/.next/server/app/_global-error/page.js.nft.json +1 -1
  15. package/dist/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
  16. package/dist/standalone/.next/server/app/_global-error.html +1 -1
  17. package/dist/standalone/.next/server/app/_global-error.rsc +1 -1
  18. package/dist/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  19. package/dist/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  20. package/dist/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  21. package/dist/standalone/.next/server/app/_not-found/page.js +1 -1
  22. package/dist/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  23. package/dist/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  24. package/dist/standalone/.next/server/app/_not-found.html +1 -1
  25. package/dist/standalone/.next/server/app/_not-found.rsc +2 -2
  26. package/dist/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  27. package/dist/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +2 -2
  28. package/dist/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  29. package/dist/standalone/.next/server/app/api/access/route.js +1 -1
  30. package/dist/standalone/.next/server/app/api/access/route.js.nft.json +1 -1
  31. package/dist/standalone/.next/server/app/api/account-migrations/[intentId]/route.js +1 -1
  32. package/dist/standalone/.next/server/app/api/account-migrations/[intentId]/route.js.nft.json +1 -1
  33. package/dist/standalone/.next/server/app/api/account-project-bindings/route.js +1 -1
  34. package/dist/standalone/.next/server/app/api/account-project-bindings/route.js.nft.json +1 -1
  35. package/dist/standalone/.next/server/app/api/accounts/claude/[id]/status/route.js +1 -1
  36. package/dist/standalone/.next/server/app/api/accounts/claude/[id]/status/route.js.nft.json +1 -1
  37. package/dist/standalone/.next/server/app/api/accounts/claude/active/route.js +1 -1
  38. package/dist/standalone/.next/server/app/api/accounts/claude/active/route.js.nft.json +1 -1
  39. package/dist/standalone/.next/server/app/api/accounts/claude/limits/route.js +1 -1
  40. package/dist/standalone/.next/server/app/api/accounts/claude/limits/route.js.nft.json +1 -1
  41. package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/input/route.js +1 -1
  42. package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/input/route.js.nft.json +1 -1
  43. package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/route.js +1 -1
  44. package/dist/standalone/.next/server/app/api/accounts/claude/login/[operationId]/route.js.nft.json +1 -1
  45. package/dist/standalone/.next/server/app/api/accounts/claude/policy/route.js +1 -1
  46. package/dist/standalone/.next/server/app/api/accounts/claude/policy/route.js.nft.json +1 -1
  47. package/dist/standalone/.next/server/app/api/accounts/claude/route.js +1 -1
  48. package/dist/standalone/.next/server/app/api/accounts/claude/route.js.nft.json +1 -1
  49. package/dist/standalone/.next/server/app/api/accounts/claude/terminal/route.js +1 -1
  50. package/dist/standalone/.next/server/app/api/accounts/claude/terminal/route.js.nft.json +1 -1
  51. package/dist/standalone/.next/server/app/api/accounts/codex/active/route.js +1 -1
  52. package/dist/standalone/.next/server/app/api/accounts/codex/active/route.js.nft.json +1 -1
  53. package/dist/standalone/.next/server/app/api/accounts/codex/limits/route.js +1 -1
  54. package/dist/standalone/.next/server/app/api/accounts/codex/limits/route.js.nft.json +1 -1
  55. package/dist/standalone/.next/server/app/api/accounts/codex/policy/route.js +1 -1
  56. package/dist/standalone/.next/server/app/api/accounts/codex/policy/route.js.nft.json +1 -1
  57. package/dist/standalone/.next/server/app/api/accounts/codex/reset-credits/route.js +2 -2
  58. package/dist/standalone/.next/server/app/api/accounts/codex/reset-credits/route.js.nft.json +1 -1
  59. package/dist/standalone/.next/server/app/api/accounts/codex/route.js +1 -1
  60. package/dist/standalone/.next/server/app/api/accounts/codex/route.js.nft.json +1 -1
  61. package/dist/standalone/.next/server/app/api/accounts/codex/terminal/route.js +1 -1
  62. package/dist/standalone/.next/server/app/api/accounts/codex/terminal/route.js.nft.json +1 -1
  63. package/dist/standalone/.next/server/app/api/accounts/route.js +1 -1
  64. package/dist/standalone/.next/server/app/api/accounts/route.js.nft.json +1 -1
  65. package/dist/standalone/.next/server/app/api/agent/route.js +1 -1
  66. package/dist/standalone/.next/server/app/api/agent/route.js.nft.json +1 -1
  67. package/dist/standalone/.next/server/app/api/agent/snapshot/route.js +1 -1
  68. package/dist/standalone/.next/server/app/api/agent/snapshot/route.js.nft.json +1 -1
  69. package/dist/standalone/.next/server/app/api/answer/route.js +1 -2
  70. package/dist/standalone/.next/server/app/api/answer/route.js.nft.json +1 -1
  71. package/dist/standalone/.next/server/app/api/artifact/route.js +1 -1
  72. package/dist/standalone/.next/server/app/api/artifact/route.js.nft.json +1 -1
  73. package/dist/standalone/.next/server/app/api/attach-command/route.js +1 -1
  74. package/dist/standalone/.next/server/app/api/attach-command/route.js.nft.json +1 -1
  75. package/dist/standalone/.next/server/app/api/attention/[id]/route.js +1 -1
  76. package/dist/standalone/.next/server/app/api/attention/[id]/route.js.nft.json +1 -1
  77. package/dist/standalone/.next/server/app/api/attention/route.js +1 -1
  78. package/dist/standalone/.next/server/app/api/attention/route.js.nft.json +1 -1
  79. package/dist/standalone/.next/server/app/api/board/route.js +1 -1
  80. package/dist/standalone/.next/server/app/api/board/route.js.nft.json +1 -1
  81. package/dist/standalone/.next/server/app/api/bridge/route.js +1 -2
  82. package/dist/standalone/.next/server/app/api/bridge/route.js.nft.json +1 -1
  83. package/dist/standalone/.next/server/app/api/conversation-host/route.js +1 -1
  84. package/dist/standalone/.next/server/app/api/conversation-host/route.js.nft.json +1 -1
  85. package/dist/standalone/.next/server/app/api/conversation-host/targets/route.js +1 -1
  86. package/dist/standalone/.next/server/app/api/conversation-host/targets/route.js.nft.json +1 -1
  87. package/dist/standalone/.next/server/app/api/conversations/[conversationId]/migration/route.js +1 -1
  88. package/dist/standalone/.next/server/app/api/conversations/[conversationId]/migration/route.js.nft.json +1 -1
  89. package/dist/standalone/.next/server/app/api/conversations/route.js +1 -1
  90. package/dist/standalone/.next/server/app/api/conversations/route.js.nft.json +1 -1
  91. package/dist/standalone/.next/server/app/api/files/route.js +3 -2
  92. package/dist/standalone/.next/server/app/api/files/route.js.nft.json +1 -1
  93. package/dist/standalone/.next/server/app/api/flows/[id]/route.js +1 -1
  94. package/dist/standalone/.next/server/app/api/flows/[id]/route.js.nft.json +1 -1
  95. package/dist/standalone/.next/server/app/api/flows/route.js +1 -1
  96. package/dist/standalone/.next/server/app/api/flows/route.js.nft.json +1 -1
  97. package/dist/standalone/.next/server/app/api/image/route.js +1 -1
  98. package/dist/standalone/.next/server/app/api/image/route.js.nft.json +1 -1
  99. package/dist/standalone/.next/server/app/api/inbox/route.js +2 -2
  100. package/dist/standalone/.next/server/app/api/inbox/route.js.nft.json +1 -1
  101. package/dist/standalone/.next/server/app/api/lifecycle/reaper/route.js +1 -1
  102. package/dist/standalone/.next/server/app/api/lifecycle/reaper/route.js.nft.json +1 -1
  103. package/dist/standalone/.next/server/app/api/limits/history/route.js +1 -1
  104. package/dist/standalone/.next/server/app/api/limits/history/route.js.nft.json +1 -1
  105. package/dist/standalone/.next/server/app/api/limits/route.js +1 -1
  106. package/dist/standalone/.next/server/app/api/limits/route.js.nft.json +1 -1
  107. package/dist/standalone/.next/server/app/api/log/preflight/route.js +1 -1
  108. package/dist/standalone/.next/server/app/api/log/preflight/route.js.nft.json +1 -1
  109. package/dist/standalone/.next/server/app/api/log/project-delete/route.js +1 -1
  110. package/dist/standalone/.next/server/app/api/log/project-delete/route.js.nft.json +1 -1
  111. package/dist/standalone/.next/server/app/api/log/provenance/route.js +107 -1
  112. package/dist/standalone/.next/server/app/api/log/provenance/route.js.nft.json +1 -1
  113. package/dist/standalone/.next/server/app/api/log/route.js +1 -1
  114. package/dist/standalone/.next/server/app/api/log/route.js.nft.json +1 -1
  115. package/dist/standalone/.next/server/app/api/log/suggestions/route.js +2 -4
  116. package/dist/standalone/.next/server/app/api/log/suggestions/route.js.nft.json +1 -1
  117. package/dist/standalone/.next/server/app/api/logs/route.js +1 -1
  118. package/dist/standalone/.next/server/app/api/logs/route.js.nft.json +1 -1
  119. package/dist/standalone/.next/server/app/api/logs/stream/route.js +2 -2
  120. package/dist/standalone/.next/server/app/api/logs/stream/route.js.nft.json +1 -1
  121. package/dist/standalone/.next/server/app/api/monitor/runs/route.js +3 -3
  122. package/dist/standalone/.next/server/app/api/monitor/runs/route.js.nft.json +1 -1
  123. package/dist/standalone/.next/server/app/api/monitor/seat-tick/route.js +23 -0
  124. package/dist/standalone/.next/server/app/api/monitor/seat-tick/route.js.nft.json +1 -0
  125. package/dist/standalone/.next/server/app/api/monitor/seat-tick/route_client-reference-manifest.js +1 -0
  126. package/dist/standalone/.next/server/app/api/monitor/seat-tick/settings/route.js +2 -0
  127. package/dist/standalone/.next/server/app/api/monitor/seat-tick/settings/route.js.nft.json +1 -0
  128. package/dist/standalone/.next/server/app/api/monitor/seat-tick/settings/route_client-reference-manifest.js +1 -0
  129. package/dist/standalone/.next/server/app/api/orchestrator/rotate/route.js +1 -1
  130. package/dist/standalone/.next/server/app/api/orchestrator/rotate/route.js.nft.json +1 -1
  131. package/dist/standalone/.next/server/app/api/orchestrator/seat/route.js +1 -1
  132. package/dist/standalone/.next/server/app/api/orchestrator/seat/route.js.nft.json +1 -1
  133. package/dist/standalone/.next/server/app/api/orchestrator/seat/status/route.js +1 -3
  134. package/dist/standalone/.next/server/app/api/orchestrator/seat/status/route.js.nft.json +1 -1
  135. package/dist/standalone/.next/server/app/api/pipelines/[id]/route.js +1 -1
  136. package/dist/standalone/.next/server/app/api/pipelines/[id]/route.js.nft.json +1 -1
  137. package/dist/standalone/.next/server/app/api/pipelines/preflight/route.js +1 -1
  138. package/dist/standalone/.next/server/app/api/pipelines/preflight/route.js.nft.json +1 -1
  139. package/dist/standalone/.next/server/app/api/pipelines/route.js +1 -2
  140. package/dist/standalone/.next/server/app/api/pipelines/route.js.nft.json +1 -1
  141. package/dist/standalone/.next/server/app/api/pipelines/tick/route.js +2 -2
  142. package/dist/standalone/.next/server/app/api/pipelines/tick/route.js.nft.json +1 -1
  143. package/dist/standalone/.next/server/app/api/proc/route.js +1 -1
  144. package/dist/standalone/.next/server/app/api/proc/route.js.nft.json +1 -1
  145. package/dist/standalone/.next/server/app/api/projects/create/route.js +2 -2
  146. package/dist/standalone/.next/server/app/api/projects/create/route.js.nft.json +1 -1
  147. package/dist/standalone/.next/server/app/api/projects/crown/route.js +1 -1
  148. package/dist/standalone/.next/server/app/api/projects/crown/route.js.nft.json +1 -1
  149. package/dist/standalone/.next/server/app/api/projects/directories/route.js +1 -1
  150. package/dist/standalone/.next/server/app/api/projects/directories/route.js.nft.json +1 -1
  151. package/dist/standalone/.next/server/app/api/push/route.js +2 -2
  152. package/dist/standalone/.next/server/app/api/push/route.js.nft.json +1 -1
  153. package/dist/standalone/.next/server/app/api/resources/route.js +1 -1
  154. package/dist/standalone/.next/server/app/api/resources/route.js.nft.json +1 -1
  155. package/dist/standalone/.next/server/app/api/roles/route.js +2 -2
  156. package/dist/standalone/.next/server/app/api/roles/route.js.nft.json +1 -1
  157. package/dist/standalone/.next/server/app/api/runtime/answer/route.js +1 -1
  158. package/dist/standalone/.next/server/app/api/runtime/answer/route.js.nft.json +1 -1
  159. package/dist/standalone/.next/server/app/api/runtime/deployments/[deploymentId]/route.js +1 -1
  160. package/dist/standalone/.next/server/app/api/runtime/deployments/[deploymentId]/route.js.nft.json +1 -1
  161. package/dist/standalone/.next/server/app/api/runtime/deployments/capabilities/v1/route.js +1 -1
  162. package/dist/standalone/.next/server/app/api/runtime/deployments/capabilities/v1/route.js.nft.json +1 -1
  163. package/dist/standalone/.next/server/app/api/runtime/deployments/route.js +1 -1
  164. package/dist/standalone/.next/server/app/api/runtime/deployments/route.js.nft.json +1 -1
  165. package/dist/standalone/.next/server/app/api/runtime/hosts/route.js +1 -1
  166. package/dist/standalone/.next/server/app/api/runtime/hosts/route.js.nft.json +1 -1
  167. package/dist/standalone/.next/server/app/api/runtime/inject/route.js +1 -0
  168. package/dist/standalone/.next/server/app/api/runtime/inject/route.js.nft.json +1 -0
  169. package/dist/standalone/.next/server/app/api/runtime/inject/route_client-reference-manifest.js +1 -0
  170. package/dist/standalone/.next/server/app/api/runtime/interrupt/route.js +1 -1
  171. package/dist/standalone/.next/server/app/api/runtime/interrupt/route.js.nft.json +1 -1
  172. package/dist/standalone/.next/server/app/api/runtime/operations/[operationId]/route.js +1 -1
  173. package/dist/standalone/.next/server/app/api/runtime/operations/[operationId]/route.js.nft.json +1 -1
  174. package/dist/standalone/.next/server/app/api/runtime/operations/route.js +1 -1
  175. package/dist/standalone/.next/server/app/api/runtime/operations/route.js.nft.json +1 -1
  176. package/dist/standalone/.next/server/app/api/runtime/queue/route.js +1 -0
  177. package/dist/standalone/.next/server/app/api/runtime/queue/route.js.nft.json +1 -0
  178. package/dist/standalone/.next/server/app/api/runtime/queue/route_client-reference-manifest.js +1 -0
  179. package/dist/standalone/.next/server/app/api/runtime/realtime/route.js +1 -2
  180. package/dist/standalone/.next/server/app/api/runtime/realtime/route.js.nft.json +1 -1
  181. package/dist/standalone/.next/server/app/api/runtime/send/route.js +1 -1
  182. package/dist/standalone/.next/server/app/api/runtime/send/route.js.nft.json +1 -1
  183. package/dist/standalone/.next/server/app/api/runtime/snapshot/route.js +1 -1
  184. package/dist/standalone/.next/server/app/api/runtime/snapshot/route.js.nft.json +1 -1
  185. package/dist/standalone/.next/server/app/api/runtime/spawn/route.js +1 -1
  186. package/dist/standalone/.next/server/app/api/runtime/spawn/route.js.nft.json +1 -1
  187. package/dist/standalone/.next/server/app/api/runtime/steer/route.js +1 -1
  188. package/dist/standalone/.next/server/app/api/runtime/steer/route.js.nft.json +1 -1
  189. package/dist/standalone/.next/server/app/api/runtime/stream/route.js +2 -2
  190. package/dist/standalone/.next/server/app/api/runtime/stream/route.js.nft.json +1 -1
  191. package/dist/standalone/.next/server/app/api/search/transcripts/route.js +2 -2
  192. package/dist/standalone/.next/server/app/api/search/transcripts/route.js.nft.json +1 -1
  193. package/dist/standalone/.next/server/app/api/session/route.js +1 -1
  194. package/dist/standalone/.next/server/app/api/session/route.js.nft.json +1 -1
  195. package/dist/standalone/.next/server/app/api/session/supersedence/route.js +1 -1
  196. package/dist/standalone/.next/server/app/api/session/supersedence/route.js.nft.json +1 -1
  197. package/dist/standalone/.next/server/app/api/session/title/route.js +1 -1
  198. package/dist/standalone/.next/server/app/api/session/title/route.js.nft.json +1 -1
  199. package/dist/standalone/.next/server/app/api/spawn/policy/route.js +3 -3
  200. package/dist/standalone/.next/server/app/api/spawn/policy/route.js.nft.json +1 -1
  201. package/dist/standalone/.next/server/app/api/spawn/route.js +1 -2
  202. package/dist/standalone/.next/server/app/api/spawn/route.js.nft.json +1 -1
  203. package/dist/standalone/.next/server/app/api/spawn/validate/route.js +1 -0
  204. package/dist/standalone/.next/server/app/api/spawn/validate/route.js.nft.json +1 -0
  205. package/dist/standalone/.next/server/app/api/spawn/validate/route_client-reference-manifest.js +1 -0
  206. package/dist/standalone/.next/server/app/api/staging/route.js +2 -2
  207. package/dist/standalone/.next/server/app/api/staging/route.js.nft.json +1 -1
  208. package/dist/standalone/.next/server/app/api/task-attachments/route.js +2 -2
  209. package/dist/standalone/.next/server/app/api/task-attachments/route.js.nft.json +1 -1
  210. package/dist/standalone/.next/server/app/api/tasks/[id]/assignment/route.js +1 -1
  211. package/dist/standalone/.next/server/app/api/tasks/[id]/assignment/route.js.nft.json +1 -1
  212. package/dist/standalone/.next/server/app/api/tasks/[id]/route.js +1 -1
  213. package/dist/standalone/.next/server/app/api/tasks/[id]/route.js.nft.json +1 -1
  214. package/dist/standalone/.next/server/app/api/tasks/[id]/send/route.js +1 -2
  215. package/dist/standalone/.next/server/app/api/tasks/[id]/send/route.js.nft.json +1 -1
  216. package/dist/standalone/.next/server/app/api/tasks/[id]/spawn/route.js +1 -2
  217. package/dist/standalone/.next/server/app/api/tasks/[id]/spawn/route.js.nft.json +1 -1
  218. package/dist/standalone/.next/server/app/api/tasks/curator/route.js +1 -1
  219. package/dist/standalone/.next/server/app/api/tasks/curator/route.js.nft.json +1 -1
  220. package/dist/standalone/.next/server/app/api/tasks/route.js +1 -1
  221. package/dist/standalone/.next/server/app/api/tasks/route.js.nft.json +1 -1
  222. package/dist/standalone/.next/server/app/api/telegram/reports/route.js +1 -1
  223. package/dist/standalone/.next/server/app/api/telegram/reports/route.js.nft.json +1 -1
  224. package/dist/standalone/.next/server/app/api/telegram/route.js +1 -1
  225. package/dist/standalone/.next/server/app/api/telegram/route.js.nft.json +1 -1
  226. package/dist/standalone/.next/server/app/api/timeline/route.js +1 -1
  227. package/dist/standalone/.next/server/app/api/timeline/route.js.nft.json +1 -1
  228. package/dist/standalone/.next/server/app/api/tmux/route.js +1 -1
  229. package/dist/standalone/.next/server/app/api/tmux/route.js.nft.json +1 -1
  230. package/dist/standalone/.next/server/app/api/tmux/targets/route.js +1 -1
  231. package/dist/standalone/.next/server/app/api/tmux/targets/route.js.nft.json +1 -1
  232. package/dist/standalone/.next/server/app/api/transcribe/backend/route.js +2 -2
  233. package/dist/standalone/.next/server/app/api/transcribe/backend/route.js.nft.json +1 -1
  234. package/dist/standalone/.next/server/app/api/transcribe/route.js +2 -2
  235. package/dist/standalone/.next/server/app/api/transcribe/route.js.nft.json +1 -1
  236. package/dist/standalone/.next/server/app/api/transcribe/token/route.js +2 -2
  237. package/dist/standalone/.next/server/app/api/transcribe/token/route.js.nft.json +1 -1
  238. package/dist/standalone/.next/server/app/api/tts/backend/route.js +1 -1
  239. package/dist/standalone/.next/server/app/api/tts/backend/route.js.nft.json +1 -1
  240. package/dist/standalone/.next/server/app/api/tts/route.js +3 -3
  241. package/dist/standalone/.next/server/app/api/tts/route.js.nft.json +1 -1
  242. package/dist/standalone/.next/server/app/api/view/presence/route.js +1 -1
  243. package/dist/standalone/.next/server/app/api/view/presence/route.js.nft.json +1 -1
  244. package/dist/standalone/.next/server/app/api/workflows/[id]/route.js +1 -1
  245. package/dist/standalone/.next/server/app/api/workflows/[id]/route.js.nft.json +1 -1
  246. package/dist/standalone/.next/server/app/api/workflows/route.js +1 -1
  247. package/dist/standalone/.next/server/app/api/workflows/route.js.nft.json +1 -1
  248. package/dist/standalone/.next/server/app/favicon.ico/route.js +1 -1
  249. package/dist/standalone/.next/server/app/favicon.ico/route.js.nft.json +1 -1
  250. package/dist/standalone/.next/server/app/index.html +1 -1
  251. package/dist/standalone/.next/server/app/index.rsc +3 -3
  252. package/dist/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +3 -3
  253. package/dist/standalone/.next/server/app/index.segments/_full.segment.rsc +3 -3
  254. package/dist/standalone/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  255. package/dist/standalone/.next/server/app/page.js +59 -30
  256. package/dist/standalone/.next/server/app/page.js.nft.json +1 -1
  257. package/dist/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  258. package/dist/standalone/.next/server/app-paths-manifest.json +24 -19
  259. package/dist/standalone/.next/server/chunks/107.js +1 -1
  260. package/dist/standalone/.next/server/chunks/1100.js +29 -10
  261. package/dist/standalone/.next/server/chunks/1406.js +399 -0
  262. package/dist/standalone/.next/server/chunks/1585.js +108 -0
  263. package/dist/standalone/.next/server/chunks/160.js +4 -4
  264. package/dist/standalone/.next/server/chunks/1617.js +2 -2
  265. package/dist/standalone/.next/server/chunks/1849.js +1 -0
  266. package/dist/standalone/.next/server/chunks/1888.js +1 -1
  267. package/dist/standalone/.next/server/chunks/193.js +1 -0
  268. package/dist/standalone/.next/server/chunks/1952.js +1 -0
  269. package/dist/standalone/.next/server/chunks/2150.js +1 -1
  270. package/dist/standalone/.next/server/chunks/2549.js +1 -1
  271. package/dist/standalone/.next/server/chunks/2555.js +1 -0
  272. package/dist/standalone/.next/server/chunks/2647.js +1 -1
  273. package/dist/standalone/.next/server/chunks/2744.js +3 -0
  274. package/dist/standalone/.next/server/chunks/2857.js +1 -0
  275. package/dist/standalone/.next/server/chunks/286.js +22 -0
  276. package/dist/standalone/.next/server/chunks/2914.js +24 -0
  277. package/dist/standalone/.next/server/chunks/3034.js +1 -0
  278. package/dist/standalone/.next/server/chunks/3086.js +1 -1
  279. package/dist/standalone/.next/server/chunks/3131.js +1 -0
  280. package/dist/standalone/.next/server/chunks/3214.js +1 -1
  281. package/dist/standalone/.next/server/chunks/3302.js +1 -2
  282. package/dist/standalone/.next/server/chunks/3407.js +1 -0
  283. package/dist/standalone/.next/server/chunks/3422.js +1 -0
  284. package/dist/standalone/.next/server/chunks/3558.js +1 -0
  285. package/dist/standalone/.next/server/chunks/3570.js +81 -0
  286. package/dist/standalone/.next/server/chunks/3587.js +1 -1
  287. package/dist/standalone/.next/server/chunks/3743.js +76 -24
  288. package/dist/standalone/.next/server/chunks/3830.js +1 -1
  289. package/dist/standalone/.next/server/chunks/3896.js +1 -0
  290. package/dist/standalone/.next/server/chunks/4037.js +1 -0
  291. package/dist/standalone/.next/server/chunks/4127.js +1 -1
  292. package/dist/standalone/.next/server/chunks/4509.js +1 -1
  293. package/dist/standalone/.next/server/chunks/4637.js +62 -0
  294. package/dist/standalone/.next/server/chunks/4651.js +1 -1
  295. package/dist/standalone/.next/server/chunks/4783.js +1 -0
  296. package/dist/standalone/.next/server/chunks/4972.js +3 -3
  297. package/dist/standalone/.next/server/chunks/{4756.js → 4995.js} +3 -5
  298. package/dist/standalone/.next/server/chunks/5408.js +1 -1
  299. package/dist/standalone/.next/server/chunks/5480.js +1 -1
  300. package/dist/standalone/.next/server/chunks/5545.js +1 -1
  301. package/dist/standalone/.next/server/chunks/568.js +1 -2
  302. package/dist/standalone/.next/server/chunks/5682.js +1 -0
  303. package/dist/standalone/.next/server/chunks/5771.js +1 -0
  304. package/dist/standalone/.next/server/chunks/5847.js +1 -0
  305. package/dist/standalone/.next/server/chunks/6023.js +1 -0
  306. package/dist/standalone/.next/server/chunks/606.js +126 -0
  307. package/dist/standalone/.next/server/chunks/6277.js +81 -0
  308. package/dist/standalone/.next/server/chunks/6289.js +2 -0
  309. package/dist/standalone/.next/server/chunks/644.js +81 -0
  310. package/dist/standalone/.next/server/chunks/6453.js +1 -0
  311. package/dist/standalone/.next/server/chunks/6522.js +1 -0
  312. package/dist/standalone/.next/server/chunks/6665.js +1 -1
  313. package/dist/standalone/.next/server/chunks/6809.js +3 -0
  314. package/dist/standalone/.next/server/chunks/6826.js +1 -1
  315. package/dist/standalone/.next/server/chunks/6926.js +1 -1
  316. package/dist/standalone/.next/server/chunks/{1920.js → 6942.js} +1 -1
  317. package/dist/standalone/.next/server/chunks/6978.js +1 -0
  318. package/dist/standalone/.next/server/chunks/7008.js +114 -9
  319. package/dist/standalone/.next/server/chunks/7192.js +1 -0
  320. package/dist/standalone/.next/server/chunks/7238.js +2 -0
  321. package/dist/standalone/.next/server/chunks/7644.js +3 -3
  322. package/dist/standalone/.next/server/chunks/7722.js +1 -1
  323. package/dist/standalone/.next/server/chunks/781.js +55 -0
  324. package/dist/standalone/.next/server/chunks/7826.js +62 -0
  325. package/dist/standalone/.next/server/chunks/8027.js +11 -1
  326. package/dist/standalone/.next/server/chunks/8444.js +1 -1
  327. package/dist/standalone/.next/server/chunks/8465.js +2 -2
  328. package/dist/standalone/.next/server/chunks/8512.js +1 -0
  329. package/dist/standalone/.next/server/chunks/8513.js +2 -0
  330. package/dist/standalone/.next/server/chunks/8617.js +1 -1
  331. package/dist/standalone/.next/server/chunks/8817.js +1 -1
  332. package/dist/standalone/.next/server/chunks/8966.js +2 -2
  333. package/dist/standalone/.next/server/chunks/8991.js +1 -1
  334. package/dist/standalone/.next/server/chunks/8996.js +1 -1
  335. package/dist/standalone/.next/server/chunks/9296.js +104 -0
  336. package/dist/standalone/.next/server/chunks/{7139.js → 9298.js} +2 -2
  337. package/dist/standalone/.next/server/chunks/9307.js +1 -1
  338. package/dist/standalone/.next/server/chunks/9360.js +199 -0
  339. package/dist/standalone/.next/server/chunks/9403.js +1 -1
  340. package/dist/standalone/.next/server/chunks/9517.js +1 -1
  341. package/dist/standalone/.next/server/chunks/9554.js +47 -0
  342. package/dist/standalone/.next/server/chunks/9676.js +1 -62
  343. package/dist/standalone/.next/server/chunks/9822.js +11 -1
  344. package/dist/standalone/.next/server/chunks/9901.js +1 -62
  345. package/dist/standalone/.next/server/chunks/9940.js +3 -3
  346. package/dist/standalone/.next/server/chunks/9998.js +1 -1
  347. package/dist/standalone/.next/server/file-scanner-worker.js +3 -3
  348. package/dist/standalone/.next/server/files-response-worker.js +6 -6
  349. package/dist/standalone/.next/server/functions-config-manifest.json +5 -0
  350. package/dist/standalone/.next/server/instrumentation.js +1 -1
  351. package/dist/standalone/.next/server/middleware-build-manifest.js +1 -1
  352. package/dist/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
  353. package/dist/standalone/.next/server/middleware.js +4 -4
  354. package/dist/standalone/.next/server/pages/404.html +1 -1
  355. package/dist/standalone/.next/server/pages/500.html +1 -1
  356. package/dist/standalone/.next/server/resource-collector-worker.js +1 -1
  357. package/dist/standalone/.next/server/server-reference-manifest.json +1 -1
  358. package/dist/standalone/.next/server/wakatime-sync-worker.js +2 -2
  359. package/dist/standalone/.next/static/836HTp-5V8cZC5YWFVOCk/_buildManifest.js +1 -0
  360. package/dist/standalone/.next/static/chunks/{3794-d1854fdd0e41dc44.js → 3794-0ef35fddac53cd9a.js} +1 -1
  361. package/dist/standalone/.next/static/chunks/7333-cf17cea2a91e7b4b.js +1 -0
  362. package/dist/standalone/.next/static/chunks/app/_global-error/page-60a25d1c4cbf0128.js +1 -0
  363. package/dist/standalone/.next/static/chunks/app/api/access/route-60a25d1c4cbf0128.js +1 -0
  364. package/dist/standalone/.next/static/chunks/app/api/account-migrations/[intentId]/route-60a25d1c4cbf0128.js +1 -0
  365. package/dist/standalone/.next/static/chunks/app/api/account-project-bindings/route-60a25d1c4cbf0128.js +1 -0
  366. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/[id]/status/route-60a25d1c4cbf0128.js +1 -0
  367. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/active/route-60a25d1c4cbf0128.js +1 -0
  368. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/limits/route-60a25d1c4cbf0128.js +1 -0
  369. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/input/route-60a25d1c4cbf0128.js +1 -0
  370. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/route-60a25d1c4cbf0128.js +1 -0
  371. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/policy/route-60a25d1c4cbf0128.js +1 -0
  372. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/route-60a25d1c4cbf0128.js +1 -0
  373. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/terminal/route-60a25d1c4cbf0128.js +1 -0
  374. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/active/route-60a25d1c4cbf0128.js +1 -0
  375. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/limits/route-60a25d1c4cbf0128.js +1 -0
  376. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/policy/route-60a25d1c4cbf0128.js +1 -0
  377. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/reset-credits/route-60a25d1c4cbf0128.js +1 -0
  378. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/route-60a25d1c4cbf0128.js +1 -0
  379. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/terminal/route-60a25d1c4cbf0128.js +1 -0
  380. package/dist/standalone/.next/static/chunks/app/api/accounts/route-60a25d1c4cbf0128.js +1 -0
  381. package/dist/standalone/.next/static/chunks/app/api/agent/route-60a25d1c4cbf0128.js +1 -0
  382. package/dist/standalone/.next/static/chunks/app/api/agent/snapshot/route-60a25d1c4cbf0128.js +1 -0
  383. package/dist/standalone/.next/static/chunks/app/api/answer/route-60a25d1c4cbf0128.js +1 -0
  384. package/dist/standalone/.next/static/chunks/app/api/artifact/route-60a25d1c4cbf0128.js +1 -0
  385. package/dist/standalone/.next/static/chunks/app/api/attach-command/route-60a25d1c4cbf0128.js +1 -0
  386. package/dist/standalone/.next/static/chunks/app/api/attention/[id]/route-60a25d1c4cbf0128.js +1 -0
  387. package/dist/standalone/.next/static/chunks/app/api/attention/route-60a25d1c4cbf0128.js +1 -0
  388. package/dist/standalone/.next/static/chunks/app/api/board/route-60a25d1c4cbf0128.js +1 -0
  389. package/dist/standalone/.next/static/chunks/app/api/bridge/route-60a25d1c4cbf0128.js +1 -0
  390. package/dist/standalone/.next/static/chunks/app/api/conversation-host/route-60a25d1c4cbf0128.js +1 -0
  391. package/dist/standalone/.next/static/chunks/app/api/conversation-host/targets/route-60a25d1c4cbf0128.js +1 -0
  392. package/dist/standalone/.next/static/chunks/app/api/conversations/[conversationId]/migration/route-60a25d1c4cbf0128.js +1 -0
  393. package/dist/standalone/.next/static/chunks/app/api/conversations/route-60a25d1c4cbf0128.js +1 -0
  394. package/dist/standalone/.next/static/chunks/app/api/files/route-60a25d1c4cbf0128.js +1 -0
  395. package/dist/standalone/.next/static/chunks/app/api/flows/[id]/route-60a25d1c4cbf0128.js +1 -0
  396. package/dist/standalone/.next/static/chunks/app/api/flows/route-60a25d1c4cbf0128.js +1 -0
  397. package/dist/standalone/.next/static/chunks/app/api/image/route-60a25d1c4cbf0128.js +1 -0
  398. package/dist/standalone/.next/static/chunks/app/api/inbox/route-60a25d1c4cbf0128.js +1 -0
  399. package/dist/standalone/.next/static/chunks/app/api/lifecycle/reaper/route-60a25d1c4cbf0128.js +1 -0
  400. package/dist/standalone/.next/static/chunks/app/api/limits/history/route-60a25d1c4cbf0128.js +1 -0
  401. package/dist/standalone/.next/static/chunks/app/api/limits/route-60a25d1c4cbf0128.js +1 -0
  402. package/dist/standalone/.next/static/chunks/app/api/log/preflight/route-60a25d1c4cbf0128.js +1 -0
  403. package/dist/standalone/.next/static/chunks/app/api/log/project-delete/route-60a25d1c4cbf0128.js +1 -0
  404. package/dist/standalone/.next/static/chunks/app/api/log/provenance/route-60a25d1c4cbf0128.js +1 -0
  405. package/dist/standalone/.next/static/chunks/app/api/log/route-60a25d1c4cbf0128.js +1 -0
  406. package/dist/standalone/.next/static/chunks/app/api/log/suggestions/route-60a25d1c4cbf0128.js +1 -0
  407. package/dist/standalone/.next/static/chunks/app/api/logs/route-60a25d1c4cbf0128.js +1 -0
  408. package/dist/standalone/.next/static/chunks/app/api/logs/stream/route-60a25d1c4cbf0128.js +1 -0
  409. package/dist/standalone/.next/static/chunks/app/api/monitor/runs/route-60a25d1c4cbf0128.js +1 -0
  410. package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/route-60a25d1c4cbf0128.js +1 -0
  411. package/dist/standalone/.next/static/chunks/app/api/monitor/seat-tick/settings/route-60a25d1c4cbf0128.js +1 -0
  412. package/dist/standalone/.next/static/chunks/app/api/orchestrator/rotate/route-60a25d1c4cbf0128.js +1 -0
  413. package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/route-60a25d1c4cbf0128.js +1 -0
  414. package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/status/route-60a25d1c4cbf0128.js +1 -0
  415. package/dist/standalone/.next/static/chunks/app/api/pipelines/[id]/route-60a25d1c4cbf0128.js +1 -0
  416. package/dist/standalone/.next/static/chunks/app/api/pipelines/preflight/route-60a25d1c4cbf0128.js +1 -0
  417. package/dist/standalone/.next/static/chunks/app/api/pipelines/route-60a25d1c4cbf0128.js +1 -0
  418. package/dist/standalone/.next/static/chunks/app/api/pipelines/tick/route-60a25d1c4cbf0128.js +1 -0
  419. package/dist/standalone/.next/static/chunks/app/api/proc/route-60a25d1c4cbf0128.js +1 -0
  420. package/dist/standalone/.next/static/chunks/app/api/projects/create/route-60a25d1c4cbf0128.js +1 -0
  421. package/dist/standalone/.next/static/chunks/app/api/projects/crown/route-60a25d1c4cbf0128.js +1 -0
  422. package/dist/standalone/.next/static/chunks/app/api/projects/directories/route-60a25d1c4cbf0128.js +1 -0
  423. package/dist/standalone/.next/static/chunks/app/api/push/route-60a25d1c4cbf0128.js +1 -0
  424. package/dist/standalone/.next/static/chunks/app/api/resources/route-60a25d1c4cbf0128.js +1 -0
  425. package/dist/standalone/.next/static/chunks/app/api/roles/route-60a25d1c4cbf0128.js +1 -0
  426. package/dist/standalone/.next/static/chunks/app/api/runtime/answer/route-60a25d1c4cbf0128.js +1 -0
  427. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/[deploymentId]/route-60a25d1c4cbf0128.js +1 -0
  428. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/capabilities/v1/route-60a25d1c4cbf0128.js +1 -0
  429. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/route-60a25d1c4cbf0128.js +1 -0
  430. package/dist/standalone/.next/static/chunks/app/api/runtime/hosts/route-60a25d1c4cbf0128.js +1 -0
  431. package/dist/standalone/.next/static/chunks/app/api/runtime/inject/route-60a25d1c4cbf0128.js +1 -0
  432. package/dist/standalone/.next/static/chunks/app/api/runtime/interrupt/route-60a25d1c4cbf0128.js +1 -0
  433. package/dist/standalone/.next/static/chunks/app/api/runtime/operations/[operationId]/route-60a25d1c4cbf0128.js +1 -0
  434. package/dist/standalone/.next/static/chunks/app/api/runtime/operations/route-60a25d1c4cbf0128.js +1 -0
  435. package/dist/standalone/.next/static/chunks/app/api/runtime/queue/route-60a25d1c4cbf0128.js +1 -0
  436. package/dist/standalone/.next/static/chunks/app/api/runtime/realtime/route-60a25d1c4cbf0128.js +1 -0
  437. package/dist/standalone/.next/static/chunks/app/api/runtime/send/route-60a25d1c4cbf0128.js +1 -0
  438. package/dist/standalone/.next/static/chunks/app/api/runtime/snapshot/route-60a25d1c4cbf0128.js +1 -0
  439. package/dist/standalone/.next/static/chunks/app/api/runtime/spawn/route-60a25d1c4cbf0128.js +1 -0
  440. package/dist/standalone/.next/static/chunks/app/api/runtime/steer/route-60a25d1c4cbf0128.js +1 -0
  441. package/dist/standalone/.next/static/chunks/app/api/runtime/stream/route-60a25d1c4cbf0128.js +1 -0
  442. package/dist/standalone/.next/static/chunks/app/api/search/transcripts/route-60a25d1c4cbf0128.js +1 -0
  443. package/dist/standalone/.next/static/chunks/app/api/session/route-60a25d1c4cbf0128.js +1 -0
  444. package/dist/standalone/.next/static/chunks/app/api/session/supersedence/route-60a25d1c4cbf0128.js +1 -0
  445. package/dist/standalone/.next/static/chunks/app/api/session/title/route-60a25d1c4cbf0128.js +1 -0
  446. package/dist/standalone/.next/static/chunks/app/api/spawn/policy/route-60a25d1c4cbf0128.js +1 -0
  447. package/dist/standalone/.next/static/chunks/app/api/spawn/route-60a25d1c4cbf0128.js +1 -0
  448. package/dist/standalone/.next/static/chunks/app/api/spawn/validate/route-60a25d1c4cbf0128.js +1 -0
  449. package/dist/standalone/.next/static/chunks/app/api/staging/route-60a25d1c4cbf0128.js +1 -0
  450. package/dist/standalone/.next/static/chunks/app/api/task-attachments/route-60a25d1c4cbf0128.js +1 -0
  451. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/assignment/route-60a25d1c4cbf0128.js +1 -0
  452. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/route-60a25d1c4cbf0128.js +1 -0
  453. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/send/route-60a25d1c4cbf0128.js +1 -0
  454. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/spawn/route-60a25d1c4cbf0128.js +1 -0
  455. package/dist/standalone/.next/static/chunks/app/api/tasks/curator/route-60a25d1c4cbf0128.js +1 -0
  456. package/dist/standalone/.next/static/chunks/app/api/tasks/route-60a25d1c4cbf0128.js +1 -0
  457. package/dist/standalone/.next/static/chunks/app/api/telegram/reports/route-60a25d1c4cbf0128.js +1 -0
  458. package/dist/standalone/.next/static/chunks/app/api/telegram/route-60a25d1c4cbf0128.js +1 -0
  459. package/dist/standalone/.next/static/chunks/app/api/timeline/route-60a25d1c4cbf0128.js +1 -0
  460. package/dist/standalone/.next/static/chunks/app/api/tmux/route-60a25d1c4cbf0128.js +1 -0
  461. package/dist/standalone/.next/static/chunks/app/api/tmux/targets/route-60a25d1c4cbf0128.js +1 -0
  462. package/dist/standalone/.next/static/chunks/app/api/transcribe/backend/route-60a25d1c4cbf0128.js +1 -0
  463. package/dist/standalone/.next/static/chunks/app/api/transcribe/route-60a25d1c4cbf0128.js +1 -0
  464. package/dist/standalone/.next/static/chunks/app/api/transcribe/token/route-60a25d1c4cbf0128.js +1 -0
  465. package/dist/standalone/.next/static/chunks/app/api/tts/backend/route-60a25d1c4cbf0128.js +1 -0
  466. package/dist/standalone/.next/static/chunks/app/api/tts/route-60a25d1c4cbf0128.js +1 -0
  467. package/dist/standalone/.next/static/chunks/app/api/view/presence/route-60a25d1c4cbf0128.js +1 -0
  468. package/dist/standalone/.next/static/chunks/app/api/workflows/[id]/route-60a25d1c4cbf0128.js +1 -0
  469. package/dist/standalone/.next/static/chunks/app/api/workflows/route-60a25d1c4cbf0128.js +1 -0
  470. package/dist/standalone/.next/static/chunks/app/page-1cde2db61f461960.js +125 -0
  471. package/dist/standalone/.next/static/chunks/{main-8691b7dc3557ef3f.js → main-7e65147ff5ce0866.js} +1 -1
  472. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-60a25d1c4cbf0128.js +1 -0
  473. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-60a25d1c4cbf0128.js +1 -0
  474. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-60a25d1c4cbf0128.js +1 -0
  475. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-60a25d1c4cbf0128.js +1 -0
  476. package/dist/standalone/.next/static/css/b25c03e915fd256b.css +1 -0
  477. package/dist/standalone/AGENTS.md +30 -0
  478. package/dist/standalone/node_modules/@next/env/package.json +1 -1
  479. package/dist/standalone/node_modules/next/dist/build/swc/index.js +1 -1
  480. package/dist/standalone/node_modules/next/dist/build/webpack-config.js +3 -3
  481. package/dist/standalone/node_modules/next/dist/compiled/next-server/app-page-experimental.runtime.prod.js +1 -1
  482. package/dist/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo-experimental.runtime.prod.js +1 -1
  483. package/dist/standalone/node_modules/next/dist/compiled/next-server/app-page-turbo.runtime.prod.js +1 -1
  484. package/dist/standalone/node_modules/next/dist/compiled/next-server/app-page.runtime.prod.js +1 -1
  485. package/dist/standalone/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js +1 -1
  486. package/dist/standalone/node_modules/next/dist/compiled/next-server/pages-turbo.runtime.prod.js +5 -5
  487. package/dist/standalone/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js +5 -5
  488. package/dist/standalone/node_modules/next/dist/lib/patch-incorrect-lockfile.js +3 -3
  489. package/dist/standalone/node_modules/next/dist/server/config.js +1 -1
  490. package/dist/standalone/node_modules/next/dist/server/dev/hot-reloader-turbopack.js +2 -2
  491. package/dist/standalone/node_modules/next/dist/server/dev/hot-reloader-webpack.js +1 -1
  492. package/dist/standalone/node_modules/next/dist/server/image-optimizer.js +2 -2
  493. package/dist/standalone/node_modules/next/dist/server/lib/app-info-log.js +1 -1
  494. package/dist/standalone/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js +17 -4
  495. package/dist/standalone/node_modules/next/dist/server/lib/start-server.js +1 -1
  496. package/dist/standalone/node_modules/next/dist/shared/lib/router/utils/escape-path-delimiters.js +1 -1
  497. package/dist/standalone/node_modules/next/dist/telemetry/anonymous-meta.js +1 -1
  498. package/dist/standalone/node_modules/next/dist/telemetry/events/swc-load-failure.js +1 -1
  499. package/dist/standalone/node_modules/next/dist/telemetry/events/version.js +2 -2
  500. package/dist/standalone/node_modules/next/package.json +10 -10
  501. package/dist/standalone/package.json +5 -5
  502. package/dist/standalone/server.bun.js +1 -1
  503. package/dist/standalone/src/lib/viewerInstrumentation.ts +824 -0
  504. package/package.json +5 -5
  505. package/dist/standalone/.next/server/chunks/112.js +0 -1
  506. package/dist/standalone/.next/server/chunks/2190.js +0 -1
  507. package/dist/standalone/.next/server/chunks/2318.js +0 -2
  508. package/dist/standalone/.next/server/chunks/2371.js +0 -1
  509. package/dist/standalone/.next/server/chunks/2500.js +0 -55
  510. package/dist/standalone/.next/server/chunks/2799.js +0 -1
  511. package/dist/standalone/.next/server/chunks/2870.js +0 -104
  512. package/dist/standalone/.next/server/chunks/3598.js +0 -81
  513. package/dist/standalone/.next/server/chunks/3740.js +0 -126
  514. package/dist/standalone/.next/server/chunks/3953.js +0 -1
  515. package/dist/standalone/.next/server/chunks/411.js +0 -1
  516. package/dist/standalone/.next/server/chunks/4191.js +0 -1
  517. package/dist/standalone/.next/server/chunks/461.js +0 -1
  518. package/dist/standalone/.next/server/chunks/4968.js +0 -2
  519. package/dist/standalone/.next/server/chunks/6333.js +0 -47
  520. package/dist/standalone/.next/server/chunks/6839.js +0 -81
  521. package/dist/standalone/.next/server/chunks/7045.js +0 -319
  522. package/dist/standalone/.next/server/chunks/7159.js +0 -1
  523. package/dist/standalone/.next/server/chunks/8176.js +0 -1
  524. package/dist/standalone/.next/server/chunks/8263.js +0 -81
  525. package/dist/standalone/.next/server/chunks/8392.js +0 -126
  526. package/dist/standalone/.next/server/chunks/9120.js +0 -78
  527. package/dist/standalone/.next/server/chunks/9507.js +0 -1
  528. package/dist/standalone/.next/static/6jhPk8sOUI3wRf_j1l5vY/_buildManifest.js +0 -1
  529. package/dist/standalone/.next/static/chunks/3021-9ced2d55bf2cbf77.js +0 -1
  530. package/dist/standalone/.next/static/chunks/app/_global-error/page-3e358516d279299e.js +0 -1
  531. package/dist/standalone/.next/static/chunks/app/api/access/route-3e358516d279299e.js +0 -1
  532. package/dist/standalone/.next/static/chunks/app/api/account-migrations/[intentId]/route-3e358516d279299e.js +0 -1
  533. package/dist/standalone/.next/static/chunks/app/api/account-project-bindings/route-3e358516d279299e.js +0 -1
  534. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/[id]/status/route-3e358516d279299e.js +0 -1
  535. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/active/route-3e358516d279299e.js +0 -1
  536. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/limits/route-3e358516d279299e.js +0 -1
  537. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/input/route-3e358516d279299e.js +0 -1
  538. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/login/[operationId]/route-3e358516d279299e.js +0 -1
  539. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/policy/route-3e358516d279299e.js +0 -1
  540. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/route-3e358516d279299e.js +0 -1
  541. package/dist/standalone/.next/static/chunks/app/api/accounts/claude/terminal/route-3e358516d279299e.js +0 -1
  542. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/active/route-3e358516d279299e.js +0 -1
  543. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/limits/route-3e358516d279299e.js +0 -1
  544. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/policy/route-3e358516d279299e.js +0 -1
  545. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/reset-credits/route-3e358516d279299e.js +0 -1
  546. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/route-3e358516d279299e.js +0 -1
  547. package/dist/standalone/.next/static/chunks/app/api/accounts/codex/terminal/route-3e358516d279299e.js +0 -1
  548. package/dist/standalone/.next/static/chunks/app/api/accounts/route-3e358516d279299e.js +0 -1
  549. package/dist/standalone/.next/static/chunks/app/api/agent/route-3e358516d279299e.js +0 -1
  550. package/dist/standalone/.next/static/chunks/app/api/agent/snapshot/route-3e358516d279299e.js +0 -1
  551. package/dist/standalone/.next/static/chunks/app/api/answer/route-3e358516d279299e.js +0 -1
  552. package/dist/standalone/.next/static/chunks/app/api/artifact/route-3e358516d279299e.js +0 -1
  553. package/dist/standalone/.next/static/chunks/app/api/attach-command/route-3e358516d279299e.js +0 -1
  554. package/dist/standalone/.next/static/chunks/app/api/attention/[id]/route-3e358516d279299e.js +0 -1
  555. package/dist/standalone/.next/static/chunks/app/api/attention/route-3e358516d279299e.js +0 -1
  556. package/dist/standalone/.next/static/chunks/app/api/board/route-3e358516d279299e.js +0 -1
  557. package/dist/standalone/.next/static/chunks/app/api/bridge/route-3e358516d279299e.js +0 -1
  558. package/dist/standalone/.next/static/chunks/app/api/conversation-host/route-3e358516d279299e.js +0 -1
  559. package/dist/standalone/.next/static/chunks/app/api/conversation-host/targets/route-3e358516d279299e.js +0 -1
  560. package/dist/standalone/.next/static/chunks/app/api/conversations/[conversationId]/migration/route-3e358516d279299e.js +0 -1
  561. package/dist/standalone/.next/static/chunks/app/api/conversations/route-3e358516d279299e.js +0 -1
  562. package/dist/standalone/.next/static/chunks/app/api/files/route-3e358516d279299e.js +0 -1
  563. package/dist/standalone/.next/static/chunks/app/api/flows/[id]/route-3e358516d279299e.js +0 -1
  564. package/dist/standalone/.next/static/chunks/app/api/flows/route-3e358516d279299e.js +0 -1
  565. package/dist/standalone/.next/static/chunks/app/api/image/route-3e358516d279299e.js +0 -1
  566. package/dist/standalone/.next/static/chunks/app/api/inbox/route-3e358516d279299e.js +0 -1
  567. package/dist/standalone/.next/static/chunks/app/api/lifecycle/reaper/route-3e358516d279299e.js +0 -1
  568. package/dist/standalone/.next/static/chunks/app/api/limits/history/route-3e358516d279299e.js +0 -1
  569. package/dist/standalone/.next/static/chunks/app/api/limits/route-3e358516d279299e.js +0 -1
  570. package/dist/standalone/.next/static/chunks/app/api/log/preflight/route-3e358516d279299e.js +0 -1
  571. package/dist/standalone/.next/static/chunks/app/api/log/project-delete/route-3e358516d279299e.js +0 -1
  572. package/dist/standalone/.next/static/chunks/app/api/log/provenance/route-3e358516d279299e.js +0 -1
  573. package/dist/standalone/.next/static/chunks/app/api/log/route-3e358516d279299e.js +0 -1
  574. package/dist/standalone/.next/static/chunks/app/api/log/suggestions/route-3e358516d279299e.js +0 -1
  575. package/dist/standalone/.next/static/chunks/app/api/logs/route-3e358516d279299e.js +0 -1
  576. package/dist/standalone/.next/static/chunks/app/api/logs/stream/route-3e358516d279299e.js +0 -1
  577. package/dist/standalone/.next/static/chunks/app/api/monitor/runs/route-3e358516d279299e.js +0 -1
  578. package/dist/standalone/.next/static/chunks/app/api/orchestrator/rotate/route-3e358516d279299e.js +0 -1
  579. package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/route-3e358516d279299e.js +0 -1
  580. package/dist/standalone/.next/static/chunks/app/api/orchestrator/seat/status/route-3e358516d279299e.js +0 -1
  581. package/dist/standalone/.next/static/chunks/app/api/pipelines/[id]/route-3e358516d279299e.js +0 -1
  582. package/dist/standalone/.next/static/chunks/app/api/pipelines/preflight/route-3e358516d279299e.js +0 -1
  583. package/dist/standalone/.next/static/chunks/app/api/pipelines/route-3e358516d279299e.js +0 -1
  584. package/dist/standalone/.next/static/chunks/app/api/pipelines/tick/route-3e358516d279299e.js +0 -1
  585. package/dist/standalone/.next/static/chunks/app/api/proc/route-3e358516d279299e.js +0 -1
  586. package/dist/standalone/.next/static/chunks/app/api/projects/create/route-3e358516d279299e.js +0 -1
  587. package/dist/standalone/.next/static/chunks/app/api/projects/crown/route-3e358516d279299e.js +0 -1
  588. package/dist/standalone/.next/static/chunks/app/api/projects/directories/route-3e358516d279299e.js +0 -1
  589. package/dist/standalone/.next/static/chunks/app/api/push/route-3e358516d279299e.js +0 -1
  590. package/dist/standalone/.next/static/chunks/app/api/resources/route-3e358516d279299e.js +0 -1
  591. package/dist/standalone/.next/static/chunks/app/api/roles/route-3e358516d279299e.js +0 -1
  592. package/dist/standalone/.next/static/chunks/app/api/runtime/answer/route-3e358516d279299e.js +0 -1
  593. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/[deploymentId]/route-3e358516d279299e.js +0 -1
  594. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/capabilities/v1/route-3e358516d279299e.js +0 -1
  595. package/dist/standalone/.next/static/chunks/app/api/runtime/deployments/route-3e358516d279299e.js +0 -1
  596. package/dist/standalone/.next/static/chunks/app/api/runtime/hosts/route-3e358516d279299e.js +0 -1
  597. package/dist/standalone/.next/static/chunks/app/api/runtime/interrupt/route-3e358516d279299e.js +0 -1
  598. package/dist/standalone/.next/static/chunks/app/api/runtime/operations/[operationId]/route-3e358516d279299e.js +0 -1
  599. package/dist/standalone/.next/static/chunks/app/api/runtime/operations/route-3e358516d279299e.js +0 -1
  600. package/dist/standalone/.next/static/chunks/app/api/runtime/realtime/route-3e358516d279299e.js +0 -1
  601. package/dist/standalone/.next/static/chunks/app/api/runtime/send/route-3e358516d279299e.js +0 -1
  602. package/dist/standalone/.next/static/chunks/app/api/runtime/snapshot/route-3e358516d279299e.js +0 -1
  603. package/dist/standalone/.next/static/chunks/app/api/runtime/spawn/route-3e358516d279299e.js +0 -1
  604. package/dist/standalone/.next/static/chunks/app/api/runtime/steer/route-3e358516d279299e.js +0 -1
  605. package/dist/standalone/.next/static/chunks/app/api/runtime/stream/route-3e358516d279299e.js +0 -1
  606. package/dist/standalone/.next/static/chunks/app/api/search/transcripts/route-3e358516d279299e.js +0 -1
  607. package/dist/standalone/.next/static/chunks/app/api/session/route-3e358516d279299e.js +0 -1
  608. package/dist/standalone/.next/static/chunks/app/api/session/supersedence/route-3e358516d279299e.js +0 -1
  609. package/dist/standalone/.next/static/chunks/app/api/session/title/route-3e358516d279299e.js +0 -1
  610. package/dist/standalone/.next/static/chunks/app/api/spawn/policy/route-3e358516d279299e.js +0 -1
  611. package/dist/standalone/.next/static/chunks/app/api/spawn/route-3e358516d279299e.js +0 -1
  612. package/dist/standalone/.next/static/chunks/app/api/staging/route-3e358516d279299e.js +0 -1
  613. package/dist/standalone/.next/static/chunks/app/api/task-attachments/route-3e358516d279299e.js +0 -1
  614. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/assignment/route-3e358516d279299e.js +0 -1
  615. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/route-3e358516d279299e.js +0 -1
  616. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/send/route-3e358516d279299e.js +0 -1
  617. package/dist/standalone/.next/static/chunks/app/api/tasks/[id]/spawn/route-3e358516d279299e.js +0 -1
  618. package/dist/standalone/.next/static/chunks/app/api/tasks/curator/route-3e358516d279299e.js +0 -1
  619. package/dist/standalone/.next/static/chunks/app/api/tasks/route-3e358516d279299e.js +0 -1
  620. package/dist/standalone/.next/static/chunks/app/api/telegram/reports/route-3e358516d279299e.js +0 -1
  621. package/dist/standalone/.next/static/chunks/app/api/telegram/route-3e358516d279299e.js +0 -1
  622. package/dist/standalone/.next/static/chunks/app/api/timeline/route-3e358516d279299e.js +0 -1
  623. package/dist/standalone/.next/static/chunks/app/api/tmux/route-3e358516d279299e.js +0 -1
  624. package/dist/standalone/.next/static/chunks/app/api/tmux/targets/route-3e358516d279299e.js +0 -1
  625. package/dist/standalone/.next/static/chunks/app/api/transcribe/backend/route-3e358516d279299e.js +0 -1
  626. package/dist/standalone/.next/static/chunks/app/api/transcribe/route-3e358516d279299e.js +0 -1
  627. package/dist/standalone/.next/static/chunks/app/api/transcribe/token/route-3e358516d279299e.js +0 -1
  628. package/dist/standalone/.next/static/chunks/app/api/tts/backend/route-3e358516d279299e.js +0 -1
  629. package/dist/standalone/.next/static/chunks/app/api/tts/route-3e358516d279299e.js +0 -1
  630. package/dist/standalone/.next/static/chunks/app/api/view/presence/route-3e358516d279299e.js +0 -1
  631. package/dist/standalone/.next/static/chunks/app/api/workflows/[id]/route-3e358516d279299e.js +0 -1
  632. package/dist/standalone/.next/static/chunks/app/api/workflows/route-3e358516d279299e.js +0 -1
  633. package/dist/standalone/.next/static/chunks/app/page-dbe7cb010b4941d6.js +0 -96
  634. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/app-error-3e358516d279299e.js +0 -1
  635. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/forbidden-3e358516d279299e.js +0 -1
  636. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/not-found-3e358516d279299e.js +0 -1
  637. package/dist/standalone/.next/static/chunks/next/dist/client/components/builtin/unauthorized-3e358516d279299e.js +0 -1
  638. package/dist/standalone/.next/static/css/282596e2aaee1aa4.css +0 -1
  639. package/dist/standalone/src/lib/inboxFiles.ts +0 -203
  640. /package/dist/standalone/.next/static/{6jhPk8sOUI3wRf_j1l5vY → 836HTp-5V8cZC5YWFVOCk}/_ssgManifest.js +0 -0
@@ -1,5 +1,5 @@
1
1
  "use strict";exports.id=8817,exports.ids=[8817],exports.modules={22018:(a,b,c)=>{c.d(b,{y:()=>d});function d(a){return void 0!==a.default?a.default:"integer"===a.kind?a.min??1:"select"===a.kind?a.options?.[0]??"":""}},43237:(a,b,c)=>{c.d(b,{Lh:()=>e,j0:()=>g,pV:()=>f});var d=c(643);function e(){return new Promise(a=>setImmediate(a))}async function f(a,b,c={}){let g=Math.max(1,Math.floor(c.batchSize??16)),h=Math.max(1,c.timeBudgetMs??32),i=d.performance.now(),j=0;for(let c=0;c<a.length;c+=1)await b(a[c],c),j+=1,!(c+1>=a.length)&&(j<g&&d.performance.now()-i<h||(await e(),i=d.performance.now(),j=0))}async function g(a,b,c={}){let d=Array(a.length);return await f(a,async(a,c)=>{d[c]=await b(a,c)},c),d}},97386:(a,b,c)=>{c.d(b,{aW:()=>l,OH:()=>n,fy:()=>m,s8:()=>o,X2:()=>k,hB:()=>j});var d=c(22619),e=c(51888);let f={engine:"claude",model:"opus",effort:"high"},g={engine:"codex",model:"gpt-5.6-terra",effort:"low"};var h=c(22018),i=c(22371);function j(a,b){var c;let d="builder"===a.id&&"frontend"===b.domain?"\n\nUI/frontend implementation guidance: follow the approved interaction and visual contract, preserve accessible semantics, responsive behavior, and English/Ukrainian parity.":"";return c=a.promptScaffold,c.replace(/\{\{([A-Za-z][A-Za-z0-9]*)\}\}/g,(a,c)=>String(b[c]??"")).replace(/^(Repository|Issue query|Urgent list):\s*\n/gm,"")+d}function k(a){return a.safetyFences.length?`
2
2
 
3
3
  Safety fences:
4
- ${a.safetyFences.map(a=>`- ${a}`).join("\n")}`:""}function l(a,b){return"builder"!==a.id?a.config:"frontend"===b.domain?f:"apply-fixes"===b.mode?g:a.config}function m(a,b={},c={},f=(0,i.pQ)()){let g=f.find(b=>b.id===a);if(!g)return{ok:!1,error:`unknown role: ${a} (allowed: ${f.map(a=>a.id).join(", ")})`};let n=function(a,b,{requireRequired:c=!0}={}){if(void 0!==b&&(!b||"object"!=typeof b||Array.isArray(b)))return{ok:!1,error:"roleParams must be an object"};let d=b??{},e=new Map(a.parameters.map(a=>[a.key,a]));for(let b of Object.keys(d))if(!e.has(b)){let c=a.parameters.map(a=>a.key).join(", ")||"none";return{ok:!1,error:`unknown role parameter: ${b} (${a.id} accepts: ${c})`}}let f={};for(let b of a.parameters){let a=d[b.key];if(void 0===a||""===a){if(b.required&&c)return{ok:!1,error:`missing required role parameter: ${b.key}`};f[b.key]=(0,h.y)(b);continue}if("integer"===b.kind){if(!Number.isInteger(a)||"number"!=typeof a||void 0!==b.min&&a<b.min||void 0!==b.max&&a>b.max)return{ok:!1,error:`invalid role parameter: ${b.key}`};f[b.key]=a;continue}let e=function(a){if("string"!=typeof a)return null;let b=a.trim();return b&&b.length<=2e3?b:null}(a);if(!e||"select"===b.kind&&!b.options?.includes(e))return{ok:!1,error:`invalid role parameter: ${b.key}`};f[b.key]=e}return{ok:!0,value:f}}(g,b);if(!n.ok)return n;let o=function(a,b,c){let f={...l(a,b),...c};if("claude"!==f.engine&&"codex"!==f.engine)return{ok:!1,error:"engine must be claude or codex"};let g=(0,e.RC)(f.engine,f.model);if("error"in g)return{ok:!1,error:g.error};f.model=g.model;let h=(0,d.ve)(f.engine,f.model);return h.includes(f.effort)?{ok:!0,value:f}:{ok:!1,error:`effort for ${f.engine} must be one of: ${h.join(", ")}`}}(g,n.value,c);return o.ok?{ok:!0,value:{definition:g,config:o.value,params:n.value,prompt:j(g,n.value)+k(g),requiresDeploymentConfirmation:"deployer"===g.id}}:o}function n(){return(0,i.pQ)()}function o(a){if(void 0===a.role||null===a.role||""===a.role)return{ok:!0,value:null};if("string"!=typeof a.role)return{ok:!1,error:"role must be a string"};let b=m(a.role,a.roleParams);if(!b.ok)return b;let c={};if(void 0!==a.engine){if("claude"!==a.engine&&"codex"!==a.engine)return{ok:!1,error:"engine must be claude or codex"};if(a.engine!==b.value.config.engine&&void 0===a.model)return{ok:!1,error:"model is required when overriding a role engine"};c.engine=a.engine}"string"==typeof a.model&&a.model.trim()&&(c.model=a.model.trim()),"string"==typeof a.effort&&a.effort.trim()&&(c.effort=a.effort.trim());let d=m(a.role,a.roleParams,c);return d.ok?d.value.requiresDeploymentConfirmation&&"deploy"!==a.confirm?{ok:!1,error:"deployer requires confirm: deploy"}:{ok:!0,value:{config:d.value.config,scaffold:d.value.prompt,role:d.value.definition.id}}:d}},98817:(a,b,c)=>{c.r(b),c.d(b,{FLOWS_SCHEMA_VERSION:()=>x,SEEDED_PRESETS:()=>w,atomicWriteText:()=>B,checkpointFlowRollbackMirrorForDemotion:()=>W,checkpointFlowRollbackMirrorForDemotionAsync:()=>X,configuredReviewerFallback:()=>v,findingsPathFor:()=>al,flowArtifactsDir:()=>ak,flowStateCollectionSeed:()=>P,loadFlow:()=>N,loadFlows:()=>M,loadFlowsForTick:()=>Q,loadPresets:()=>ai,mergeSeededPresets:()=>F,normalizeFindings:()=>ap,outputPathFor:()=>am,patchFlowRows:()=>af,planFlowStateMigration:()=>T,reconcileFlowConversationOwnership:()=>_,reconcileFlowConversationOwnershipCooperatively:()=>aa,saveFlowRows:()=>ae,saveFlows:()=>ad,savePresets:()=>aj,seededPresetsFromRoles:()=>u,stderrPathFor:()=>an,stdoutPathFor:()=>ao,withFlowMutation:()=>ag,withFlowSnapshot:()=>ah});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(70160),l=c(43237),m=c(14928),n=c(49048),o=c(38751),p=c(97386),q=c(22371);let r=()=>(0,j.BQ)("flows.json"),s=()=>(0,j.BQ)("review-loop-presets.json");function t(a,b,c={}){if("builder"!==b)return{...a.find(a=>a.id===b).config};let d=(0,p.fy)(b,c,{},a);return d.ok?{...d.value.config}:{...n.W.find(a=>a.id===b).config}}function u(){let a=(0,q.e3)(),b=t(a,"builder"),c=t(a,"builder",{mode:"apply-fixes",domain:"general"}),d=t(a,"reviewer"),e=t(a,"architect");return[{name:"Astra medium → Astra xhigh",implementer:b,reviewer:d},{name:"Terra low → Astra xhigh",implementer:c,reviewer:d},{name:"Astra medium → Opus 5",implementer:b,reviewer:e},{name:"Opus 5 → Astra xhigh",implementer:e,reviewer:d},{name:"Sonnet → Astra xhigh",implementer:{engine:"claude",model:"sonnet",effort:"high"},reviewer:d}].map(a=>({...a,managed:"role-registry"}))}function v(){return t((0,q.e3)(),"architect")}let w=u(),x=3,y=/^(?:claude|codex):[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,z=/^(?:default|unknown|managed:[0-9a-f]{12})$/;function A(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,JSON.stringify(b,null,2)+"\n","utf8"),g().renameSync(c,a)}function B(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,b,"utf8"),g().renameSync(c,a)}function C(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"string"==typeof a.id&&"implement-review-loop"===a.template&&"string"==typeof a.cwd&&"string"==typeof a.implementerPath&&"string"==typeof a.baseRef&&(void 0===a.headRef||null===a.headRef||"string"==typeof a.headRef)&&(void 0===a.targetSha||null===a.targetSha||"string"==typeof a.targetSha)&&(void 0===a.spec||"string"==typeof a.spec)&&(void 0===a.reviewerSandbox||"full"===a.reviewerSandbox||"restricted"===a.reviewerSandbox)&&(void 0===a.hostClaim||null===a.hostClaim||y.test(a.hostClaim.sessionKey)&&z.test(a.hostClaim.accountRef))&&Array.isArray(a.rounds)}function D(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"string"==typeof a.name&&E(a.implementer)&&E(a.reviewer)&&(void 0===a.managed||"role-registry"===a.managed)}function E(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&("claude"===a.engine||"codex"===a.engine)&&(null===a.model||"string"==typeof a.model)&&(null===a.effort||"string"==typeof a.effort)}function F(a,b=u()){let c=new Set(a.map(a=>a.name));return[...b.filter(a=>!c.has(a.name)),...a]}let G=null,H=new Map,I=new WeakMap;function J(a){return I.set(a,new Map(a.map(a=>[a.id,JSON.stringify(a)]))),a}function K(){return V().signature()}function L(a){return a.map(a=>({...a,hostClaim:a.hostClaim?{...a.hostClaim}:null,rounds:a.rounds.map(a=>({...a}))}))}function M(){let a=K();if(G?.signature===a)return J(L(G.flows));let b=V().snapshot(),c=K();return a===c&&(G={signature:c,flows:b}),J(L(b))}function N(a){return V().get(a)}function O(a){return!["approved","done_comment","needs_decision","closed"].includes(a.state)}function P(){return{collection:"flows",schemaVersion:x,migrationId:"flows-json-v1",loadRecords:S,key:a=>a.id,controllerActive:O}}function Q(){return V().snapshotForController()}function R(a){return a?{...a,resetKnown:a.resetKnown??!0}:null}function S(){let a=function(){let a;try{a=g().readFileSync(r(),"utf8")}catch(a){if("ENOENT"===a.code)return null;throw Error("could not read legacy flow state",{cause:a})}try{return JSON.parse(a)}catch(a){throw Error("legacy flow state contains malformed JSON",{cause:a})}}();if(null===a)return[];if(!a||"object"!=typeof a||Array.isArray(a))throw Error("legacy flow state must be an object");if(!Array.isArray(a.flows)||!a.flows.every(C))throw Error("legacy flow state contains malformed records");return a.flows.map(a=>({...a,project:(0,o.G$)(a.project),revision:a.revision??0,targetSha:a.targetSha??null,implementerConversationId:a.implementerConversationId??null,reviewerFallback:void 0===a.reviewerFallback&&"codex"===a.roles.reviewer.engine?v():a.reviewerFallback??null,pausedState:a.pausedState??null,kickoffDelivery:a.kickoffDelivery??null,hostClaim:a.hostClaim??null,rounds:a.rounds.map(a=>({...a,reviewerConversationId:a.reviewerConversationId??null,reviewerRole:a.reviewerRole??null,attemptedAccounts:a.attemptedAccounts??[],autoRetryCount:a.autoRetryCount??0,sessionId:a.sessionId??null,reviewerPid:a.reviewerPid??null,reviewerIdentity:a.reviewerIdentity??null,reviewHeadSha:a.reviewHeadSha??null,spawnStartedAt:a.spawnStartedAt??null,launchId:a.launchId??null,launchLeaseUntil:a.launchLeaseUntil??null,relayStartedAt:a.relayStartedAt??null,relayRetryCount:a.relayRetryCount??0,relayDeliveryAttempt:a.relayDeliveryAttempt??0,relayDeliveryTransport:a.relayDeliveryTransport??null,relayRetryAt:a.relayRetryAt??null,relayRetryRequiresIdempotency:a.relayRetryRequiresIdempotency??!1,relayDelivery:a.relayDelivery??null,relayPendingSettlement:a.relayPendingSettlement??null,relayHold:R(a.relayHold),terminalAt:a.terminalAt??null,error:a.error??null}))}))}function T(){let a=S();return{records:a.length,keys:a.map(a=>a.id)}}function U(a){return C(a)?{...a,project:(0,o.G$)(a.project),revision:a.revision??0,targetSha:a.targetSha??null,implementerConversationId:a.implementerConversationId??null,reviewerFallback:void 0===a.reviewerFallback&&"codex"===a.roles.reviewer.engine?v():a.reviewerFallback??null,pausedState:a.pausedState??null,kickoffDelivery:a.kickoffDelivery??null,hostClaim:a.hostClaim??null,rounds:a.rounds.map(a=>({...a,reviewerConversationId:a.reviewerConversationId??null,reviewerRole:a.reviewerRole??null,attemptedAccounts:a.attemptedAccounts??[],autoRetryCount:a.autoRetryCount??0,sessionId:a.sessionId??null,reviewerPid:a.reviewerPid??null,reviewerIdentity:a.reviewerIdentity??null,reviewHeadSha:a.reviewHeadSha??null,spawnStartedAt:a.spawnStartedAt??null,launchId:a.launchId??null,launchLeaseUntil:a.launchLeaseUntil??null,relayStartedAt:a.relayStartedAt??null,relayRetryCount:a.relayRetryCount??0,relayDeliveryAttempt:a.relayDeliveryAttempt??0,relayDeliveryTransport:a.relayDeliveryTransport??null,relayRetryAt:a.relayRetryAt??null,relayRetryRequiresIdempotency:a.relayRetryRequiresIdempotency??!1,relayDelivery:a.relayDelivery??null,relayPendingSettlement:a.relayPendingSettlement??null,relayHold:R(a.relayHold),terminalAt:a.terminalAt??null,error:a.error??null}))}:null}function V(){let a=(0,j.BQ)("state.sqlite"),b=H.get(a);if(b)return b;(0,m.t0)(a,[P()]);let c=new m.UY(a,{collection:"flows",schemaVersion:x,busyMessage:"flow state is busy",key:a=>a.id,decode:U,clone:a=>L([a])[0],controllerActive:O,strictDecode:!0,decodeError:a=>Error("flow SQLite state contains a malformed row",{cause:a})});return H.set(a,c),c}function W(){return V().checkpointMirrorForDemotion((a,b)=>{A(r(),{schemaVersion:x,_sqliteRevision:b,flows:a})})}async function X(){return V().checkpointMirrorForDemotionAsync((a,b)=>{A(r(),{schemaVersion:x,_sqliteRevision:b,flows:a})})}function Y(a,b){if(a.implementerConversationId?.startsWith("conversation_")){let c=b.conversation(a.implementerConversationId)?.generations.at(-1)?.path;return!!c&&c!==a.implementerPath&&(a.implementerPath=c,!0)}let c=b.conversationForPath(a.implementerPath);if(!c)return!1;a.implementerConversationId=c.id;let d=c.generations.at(-1)?.path;return d&&(a.implementerPath=d),!0}function Z(a,b){if(a.reviewerConversationId?.startsWith("conversation_")){let c=b.conversation(a.reviewerConversationId)?.generations.at(-1)?.path;return!!c&&c!==a.reviewerPath&&(a.reviewerPath=c,!0)}if(!a.reviewerPath)return!1;let c=b.conversationForPath(a.reviewerPath);if(!c)return!1;a.reviewerConversationId=c.id;let d=c.generations.at(-1)?.path;return d&&(a.reviewerPath=d),!0}function $(a,b,c){return a===c.path&&(b??null)===c.conversationId}function _(a=(0,k.agentRegistry)()){let b=M(),c=!1;for(let d of b)for(let b of(c=Y(d,a)||c,d.rounds))c=Z(b,a)||c;c&&ad(b)}async function aa(a=(0,k.agentRegistry)()){let b=M(),c=[];await (0,l.pV)(b,async b=>{let d={path:b.implementerPath,conversationId:b.implementerConversationId??null},e=Y(b,a),f=[];await (0,l.pV)(b.rounds,b=>{let c={path:b.reviewerPath,conversationId:b.reviewerConversationId??null};Z(b,a)&&f.push({n:b.n,before:c,after:{path:b.reviewerPath,conversationId:b.reviewerConversationId??null}})}),(e||f.length>0)&&c.push({id:b.id,implementer:e?{before:d,after:{path:b.implementerPath,conversationId:b.implementerConversationId??null}}:null,rounds:f})}),function(a){if(0===a.length)return;let b=M(),c=new Map(b.map(a=>[a.id,a])),d=!1;for(let b of a){let a=c.get(b.id);if(a)for(let c of(b.implementer&&$(a.implementerPath,a.implementerConversationId,b.implementer.before)&&(a.implementerPath=b.implementer.after.path,a.implementerConversationId=b.implementer.after.conversationId,d=!0),b.rounds)){let b=a.rounds.find(a=>a.n===c.n);b&&$(b.reviewerPath,b.reviewerConversationId,c.before)&&(b.reviewerPath=c.after.path,b.reviewerConversationId=c.after.conversationId,d=!0)}}d&&ad(b)}(c)}function ab(a){let b={...a};return delete b.revision,JSON.stringify(b)}function ac(a){for(let b of a){let a=V().get(b.id)??void 0;if(a&&void 0!==b.revision&&b.revision<(a.revision??0)){for(let a of Object.keys(b))delete b[a];Object.assign(b,structuredClone(a));continue}b.revision=a&&ab(a)===ab(b)?a.revision??0:(a?.revision??0)+1}}function ad(a){let b=I.get(a);if(!b){V().replaceSync(a,{beforePersist:ac}),J(a);return}let c=new Set(a.map(a=>a.id)),d=a.filter(a=>b.get(a.id)!==JSON.stringify(a)),e=[...b.keys()].filter(a=>!c.has(a));V().patchSync(()=>(ac(d),{records:d,deleteKeys:e.filter(a=>{let c=V().get(a);return null!==c&&JSON.stringify(c)===b.get(a)})})),J(a)}function ae(a){0!==a.length&&V().replaceSync(a,{mergeOmitted:!0,beforePersist:ac})}function af(a,b){let c=[...new Set(a)];if(0===c.length)return;let d=V();d.patchSync(()=>{let a=b(c.flatMap(a=>{let b=d.get(a);return b?[b]:[]}));return ac(a),{records:a}})}async function ag(a){return await V().mutate(a,({dirtyRecords:a})=>ac(a))}function ah(a){return V().withSnapshotSync(a)}function ai(){let a=function(a){try{return JSON.parse(g().readFileSync(a,"utf8"))}catch{return null}}(s()),b=Array.isArray(a?.presets)?a.presets.filter(D):[],c=F(b);return JSON.stringify(c)!==JSON.stringify(b)&&aj(c),c}function aj(a){A(s(),{presets:a})}function ak(a){return i().join((0,j.BQ)("flows"),a)}function al(a,b){return i().join(ak(a),`round-${b}-review.md`)}function am(a,b){return i().join(ak(a),`round-${b}-last-message.md`)}function an(a,b){return i().join(ak(a),`round-${b}-stderr.txt`)}function ao(a,b){return i().join(ak(a),`round-${b}-stdout.log`)}function ap(a,b){let c=b.replace(/^\s*VERDICT:\s*(APPROVE|REQUEST_CHANGES|COMMENT)\s*$/im,"").trim();return`VERDICT: ${a}
4
+ ${a.safetyFences.map(a=>`- ${a}`).join("\n")}`:""}function l(a,b){return"builder"!==a.id?a.config:"frontend"===b.domain?f:"apply-fixes"===b.mode?g:a.config}function m(a,b={},c={},f=(0,i.pQ)()){let g=f.find(b=>b.id===a);if(!g)return{ok:!1,error:`unknown role: ${a} (allowed: ${f.map(a=>a.id).join(", ")})`};let n=function(a,b,{requireRequired:c=!0}={}){if(void 0!==b&&(!b||"object"!=typeof b||Array.isArray(b)))return{ok:!1,error:"roleParams must be an object"};let d=b??{},e=new Map(a.parameters.map(a=>[a.key,a]));for(let b of Object.keys(d))if(!e.has(b)){let c=a.parameters.map(a=>a.key).join(", ")||"none";return{ok:!1,error:`unknown role parameter: ${b} (${a.id} accepts: ${c})`}}let f={};for(let b of a.parameters){let a=d[b.key];if(void 0===a||""===a){if(b.required&&c)return{ok:!1,error:`missing required role parameter: ${b.key}`};f[b.key]=(0,h.y)(b);continue}if("integer"===b.kind){if(!Number.isInteger(a)||"number"!=typeof a||void 0!==b.min&&a<b.min||void 0!==b.max&&a>b.max)return{ok:!1,error:`invalid role parameter: ${b.key}`};f[b.key]=a;continue}let e=function(a){if("string"!=typeof a)return null;let b=a.trim();return b&&b.length<=2e3?b:null}(a);if(!e||"select"===b.kind&&!b.options?.includes(e))return{ok:!1,error:`invalid role parameter: ${b.key}`};f[b.key]=e}return{ok:!0,value:f}}(g,b);if(!n.ok)return n;let o=function(a,b,c){let f={...l(a,b),...c};if("claude"!==f.engine&&"codex"!==f.engine)return{ok:!1,error:"engine must be claude or codex"};let g=(0,e.RC)(f.engine,f.model);if("error"in g)return{ok:!1,error:g.error};f.model=g.model;let h=(0,d.ve)(f.engine,f.model);return h.includes(f.effort)?{ok:!0,value:f}:{ok:!1,error:`effort for ${f.engine} must be one of: ${h.join(", ")}`}}(g,n.value,c);return o.ok?{ok:!0,value:{definition:g,config:o.value,params:n.value,prompt:j(g,n.value)+k(g),requiresDeploymentConfirmation:"deployer"===g.id}}:o}function n(){return(0,i.pQ)()}function o(a){if(void 0===a.role||null===a.role||""===a.role)return{ok:!0,value:null};if("string"!=typeof a.role)return{ok:!1,error:"role must be a string"};let b=m(a.role,a.roleParams);if(!b.ok)return b;let c={};if(void 0!==a.engine){if("claude"!==a.engine&&"codex"!==a.engine)return{ok:!1,error:"engine must be claude or codex"};if(a.engine!==b.value.config.engine&&void 0===a.model)return{ok:!1,error:"model is required when overriding a role engine"};c.engine=a.engine}"string"==typeof a.model&&a.model.trim()&&(c.model=a.model.trim()),"string"==typeof a.effort&&a.effort.trim()&&(c.effort=a.effort.trim());let d=m(a.role,a.roleParams,c);return d.ok?d.value.requiresDeploymentConfirmation&&"deploy"!==a.confirm?{ok:!1,error:"deployer requires confirm: deploy"}:{ok:!0,value:{config:d.value.config,scaffold:d.value.prompt,role:d.value.definition.id}}:d}},98817:(a,b,c)=>{c.r(b),c.d(b,{FLOWS_SCHEMA_VERSION:()=>x,SEEDED_PRESETS:()=>w,atomicWriteText:()=>B,checkpointFlowRollbackMirrorForDemotion:()=>W,checkpointFlowRollbackMirrorForDemotionAsync:()=>X,configuredReviewerFallback:()=>v,findingsPathFor:()=>al,flowArtifactsDir:()=>ak,flowStateCollectionSeed:()=>P,loadFlow:()=>N,loadFlows:()=>M,loadFlowsForTick:()=>Q,loadPresets:()=>ai,mergeSeededPresets:()=>F,normalizeFindings:()=>ap,outputPathFor:()=>am,patchFlowRows:()=>af,planFlowStateMigration:()=>T,reconcileFlowConversationOwnership:()=>_,reconcileFlowConversationOwnershipCooperatively:()=>aa,saveFlowRows:()=>ae,saveFlows:()=>ad,savePresets:()=>aj,seededPresetsFromRoles:()=>u,stderrPathFor:()=>an,stdoutPathFor:()=>ao,withFlowMutation:()=>ag,withFlowSnapshot:()=>ah});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(70160),l=c(43237),m=c(14928),n=c(49048),o=c(38751),p=c(97386),q=c(22371);let r=()=>(0,j.BQ)("flows.json"),s=()=>(0,j.BQ)("review-loop-presets.json");function t(a,b,c={}){if("builder"!==b)return{...a.find(a=>a.id===b).config};let d=(0,p.fy)(b,c,{},a);return d.ok?{...d.value.config}:{...n.W.find(a=>a.id===b).config}}function u(){let a=(0,q.e3)(),b=t(a,"builder"),c=t(a,"builder",{mode:"apply-fixes",domain:"general"}),d=t(a,"reviewer"),e=t(a,"architect");return[{name:"Astra medium → Astra xhigh",implementer:b,reviewer:d},{name:"Terra low → Astra xhigh",implementer:c,reviewer:d},{name:"Astra medium → Opus 5",implementer:b,reviewer:e},{name:"Opus 5 → Astra xhigh",implementer:e,reviewer:d},{name:"Sonnet → Astra xhigh",implementer:{engine:"claude",model:"sonnet",effort:"high"},reviewer:d}].map(a=>({...a,managed:"role-registry"}))}function v(){return t((0,q.e3)(),"architect")}let w=u(),x=3,y=/^(?:claude|codex):[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/,z=/^(?:default|unknown|managed:[0-9a-f]{12})$/;function A(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,JSON.stringify(b,null,2)+"\n","utf8"),g().renameSync(c,a)}function B(a,b){g().mkdirSync(i().dirname(a),{recursive:!0});let c=i().join(i().dirname(a),`.${i().basename(a)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,b,"utf8"),g().renameSync(c,a)}function C(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"string"==typeof a.id&&"implement-review-loop"===a.template&&"string"==typeof a.cwd&&"string"==typeof a.implementerPath&&"string"==typeof a.baseRef&&(void 0===a.headRef||null===a.headRef||"string"==typeof a.headRef)&&(void 0===a.requireRemoteHead||"boolean"==typeof a.requireRemoteHead)&&(void 0===a.targetSha||null===a.targetSha||"string"==typeof a.targetSha)&&(void 0===a.spec||"string"==typeof a.spec)&&(void 0===a.reviewerSandbox||"full"===a.reviewerSandbox||"restricted"===a.reviewerSandbox)&&(void 0===a.hostClaim||null===a.hostClaim||y.test(a.hostClaim.sessionKey)&&z.test(a.hostClaim.accountRef))&&Array.isArray(a.rounds)}function D(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&"string"==typeof a.name&&E(a.implementer)&&E(a.reviewer)&&(void 0===a.managed||"role-registry"===a.managed)}function E(a){return!(!a||"object"!=typeof a||Array.isArray(a))&&("claude"===a.engine||"codex"===a.engine)&&(null===a.model||"string"==typeof a.model)&&(null===a.effort||"string"==typeof a.effort)}function F(a,b=u()){let c=new Set(a.map(a=>a.name));return[...b.filter(a=>!c.has(a.name)),...a]}let G=null,H=new Map,I=new WeakMap;function J(a){return I.set(a,new Map(a.map(a=>[a.id,JSON.stringify(a)]))),a}function K(){return V().signature()}function L(a){return a.map(a=>({...a,hostClaim:a.hostClaim?{...a.hostClaim}:null,rounds:a.rounds.map(a=>({...a}))}))}function M(){let a=K();if(G?.signature===a)return J(L(G.flows));let b=V().snapshot(),c=K();return a===c&&(G={signature:c,flows:b}),J(L(b))}function N(a){return V().get(a)}function O(a){return!["approved","done_comment","needs_decision","closed"].includes(a.state)}function P(){return{collection:"flows",schemaVersion:x,migrationId:"flows-json-v1",loadRecords:S,key:a=>a.id,controllerActive:O}}function Q(){return V().snapshotForController()}function R(a){return a?{...a,resetKnown:a.resetKnown??!0}:null}function S(){let a=function(){let a;try{a=g().readFileSync(r(),"utf8")}catch(a){if("ENOENT"===a.code)return null;throw Error("could not read legacy flow state",{cause:a})}try{return JSON.parse(a)}catch(a){throw Error("legacy flow state contains malformed JSON",{cause:a})}}();if(null===a)return[];if(!a||"object"!=typeof a||Array.isArray(a))throw Error("legacy flow state must be an object");if(!Array.isArray(a.flows)||!a.flows.every(C))throw Error("legacy flow state contains malformed records");return a.flows.map(a=>({...a,project:(0,o.G$)(a.project),revision:a.revision??0,targetSha:a.targetSha??null,implementerConversationId:a.implementerConversationId??null,reviewerFallback:void 0===a.reviewerFallback&&"codex"===a.roles.reviewer.engine?v():a.reviewerFallback??null,pausedState:a.pausedState??null,kickoffDelivery:a.kickoffDelivery??null,hostClaim:a.hostClaim??null,rounds:a.rounds.map(a=>({...a,reviewerConversationId:a.reviewerConversationId??null,reviewerRole:a.reviewerRole??null,attemptedAccounts:a.attemptedAccounts??[],autoRetryCount:a.autoRetryCount??0,sessionId:a.sessionId??null,reviewerPid:a.reviewerPid??null,reviewerIdentity:a.reviewerIdentity??null,reviewHeadSha:a.reviewHeadSha??null,spawnStartedAt:a.spawnStartedAt??null,launchId:a.launchId??null,launchLeaseUntil:a.launchLeaseUntil??null,relayStartedAt:a.relayStartedAt??null,relayRetryCount:a.relayRetryCount??0,relayDeliveryAttempt:a.relayDeliveryAttempt??0,relayDeliveryTransport:a.relayDeliveryTransport??null,relayRetryAt:a.relayRetryAt??null,relayRetryRequiresIdempotency:a.relayRetryRequiresIdempotency??!1,relayDelivery:a.relayDelivery??null,relayPendingSettlement:a.relayPendingSettlement??null,relayHold:R(a.relayHold),terminalAt:a.terminalAt??null,error:a.error??null}))}))}function T(){let a=S();return{records:a.length,keys:a.map(a=>a.id)}}function U(a){return C(a)?{...a,project:(0,o.G$)(a.project),revision:a.revision??0,targetSha:a.targetSha??null,implementerConversationId:a.implementerConversationId??null,reviewerFallback:void 0===a.reviewerFallback&&"codex"===a.roles.reviewer.engine?v():a.reviewerFallback??null,pausedState:a.pausedState??null,kickoffDelivery:a.kickoffDelivery??null,hostClaim:a.hostClaim??null,rounds:a.rounds.map(a=>({...a,reviewerConversationId:a.reviewerConversationId??null,reviewerRole:a.reviewerRole??null,attemptedAccounts:a.attemptedAccounts??[],autoRetryCount:a.autoRetryCount??0,sessionId:a.sessionId??null,reviewerPid:a.reviewerPid??null,reviewerIdentity:a.reviewerIdentity??null,reviewHeadSha:a.reviewHeadSha??null,spawnStartedAt:a.spawnStartedAt??null,launchId:a.launchId??null,launchLeaseUntil:a.launchLeaseUntil??null,relayStartedAt:a.relayStartedAt??null,relayRetryCount:a.relayRetryCount??0,relayDeliveryAttempt:a.relayDeliveryAttempt??0,relayDeliveryTransport:a.relayDeliveryTransport??null,relayRetryAt:a.relayRetryAt??null,relayRetryRequiresIdempotency:a.relayRetryRequiresIdempotency??!1,relayDelivery:a.relayDelivery??null,relayPendingSettlement:a.relayPendingSettlement??null,relayHold:R(a.relayHold),terminalAt:a.terminalAt??null,error:a.error??null}))}:null}function V(){let a=(0,j.BQ)("state.sqlite"),b=H.get(a);if(b)return b;(0,m.t0)(a,[P()]);let c=new m.UY(a,{collection:"flows",schemaVersion:x,busyMessage:"flow state is busy",key:a=>a.id,decode:U,clone:a=>L([a])[0],controllerActive:O,strictDecode:!0,decodeError:a=>Error("flow SQLite state contains a malformed row",{cause:a})});return H.set(a,c),c}function W(){return V().checkpointMirrorForDemotion((a,b)=>{A(r(),{schemaVersion:x,_sqliteRevision:b,flows:a})})}async function X(){return V().checkpointMirrorForDemotionAsync((a,b)=>{A(r(),{schemaVersion:x,_sqliteRevision:b,flows:a})})}function Y(a,b){if(a.implementerConversationId?.startsWith("conversation_")){let c=b.conversation(a.implementerConversationId)?.generations.at(-1)?.path;return!!c&&c!==a.implementerPath&&(a.implementerPath=c,!0)}let c=b.conversationForPath(a.implementerPath);if(!c)return!1;a.implementerConversationId=c.id;let d=c.generations.at(-1)?.path;return d&&(a.implementerPath=d),!0}function Z(a,b){if(a.reviewerConversationId?.startsWith("conversation_")){let c=b.conversation(a.reviewerConversationId)?.generations.at(-1)?.path;return!!c&&c!==a.reviewerPath&&(a.reviewerPath=c,!0)}if(!a.reviewerPath)return!1;let c=b.conversationForPath(a.reviewerPath);if(!c)return!1;a.reviewerConversationId=c.id;let d=c.generations.at(-1)?.path;return d&&(a.reviewerPath=d),!0}function $(a,b,c){return a===c.path&&(b??null)===c.conversationId}function _(a=(0,k.agentRegistry)()){let b=M(),c=!1;for(let d of b)for(let b of(c=Y(d,a)||c,d.rounds))c=Z(b,a)||c;c&&ad(b)}async function aa(a=(0,k.agentRegistry)()){let b=M(),c=[];await (0,l.pV)(b,async b=>{let d={path:b.implementerPath,conversationId:b.implementerConversationId??null},e=Y(b,a),f=[];await (0,l.pV)(b.rounds,b=>{let c={path:b.reviewerPath,conversationId:b.reviewerConversationId??null};Z(b,a)&&f.push({n:b.n,before:c,after:{path:b.reviewerPath,conversationId:b.reviewerConversationId??null}})}),(e||f.length>0)&&c.push({id:b.id,implementer:e?{before:d,after:{path:b.implementerPath,conversationId:b.implementerConversationId??null}}:null,rounds:f})}),function(a){if(0===a.length)return;let b=M(),c=new Map(b.map(a=>[a.id,a])),d=!1;for(let b of a){let a=c.get(b.id);if(a)for(let c of(b.implementer&&$(a.implementerPath,a.implementerConversationId,b.implementer.before)&&(a.implementerPath=b.implementer.after.path,a.implementerConversationId=b.implementer.after.conversationId,d=!0),b.rounds)){let b=a.rounds.find(a=>a.n===c.n);b&&$(b.reviewerPath,b.reviewerConversationId,c.before)&&(b.reviewerPath=c.after.path,b.reviewerConversationId=c.after.conversationId,d=!0)}}d&&ad(b)}(c)}function ab(a){let b={...a};return delete b.revision,JSON.stringify(b)}function ac(a){for(let b of a){let a=V().get(b.id)??void 0;if(a&&void 0!==b.revision&&b.revision<(a.revision??0)){for(let a of Object.keys(b))delete b[a];Object.assign(b,structuredClone(a));continue}b.revision=a&&ab(a)===ab(b)?a.revision??0:(a?.revision??0)+1}}function ad(a){let b=I.get(a);if(!b){V().replaceSync(a,{beforePersist:ac}),J(a);return}let c=new Set(a.map(a=>a.id)),d=a.filter(a=>b.get(a.id)!==JSON.stringify(a)),e=[...b.keys()].filter(a=>!c.has(a));V().patchSync(()=>(ac(d),{records:d,deleteKeys:e.filter(a=>{let c=V().get(a);return null!==c&&JSON.stringify(c)===b.get(a)})})),J(a)}function ae(a){0!==a.length&&V().replaceSync(a,{mergeOmitted:!0,beforePersist:ac})}function af(a,b){let c=[...new Set(a)];if(0===c.length)return;let d=V();d.patchSync(()=>{let a=b(c.flatMap(a=>{let b=d.get(a);return b?[b]:[]}));return ac(a),{records:a}})}async function ag(a){return await V().mutate(a,({dirtyRecords:a})=>ac(a))}function ah(a){return V().withSnapshotSync(a)}function ai(){let a=function(a){try{return JSON.parse(g().readFileSync(a,"utf8"))}catch{return null}}(s()),b=Array.isArray(a?.presets)?a.presets.filter(D):[],c=F(b);return JSON.stringify(c)!==JSON.stringify(b)&&aj(c),c}function aj(a){A(s(),{presets:a})}function ak(a){return i().join((0,j.BQ)("flows"),a)}function al(a,b){return i().join(ak(a),`round-${b}-review.md`)}function am(a,b){return i().join(ak(a),`round-${b}-last-message.md`)}function an(a,b){return i().join(ak(a),`round-${b}-stderr.txt`)}function ao(a,b){return i().join(ak(a),`round-${b}-stdout.log`)}function ap(a,b){let c=b.replace(/^\s*VERDICT:\s*(APPROVE|REQUEST_CHANGES|COMMENT)\s*$/im,"").trim();return`VERDICT: ${a}
5
5
  ${c?"\n"+c+"\n":"\n"}`}}};
@@ -1,3 +1,3 @@
1
1
  "use strict";exports.id=8966,exports.ids=[8966],exports.modules={63006:(a,b,c)=>{c.d(b,{Pb:()=>s,TK:()=>r,vt:()=>p});var d=c(31421),e=c(77598),f=c.n(e),g=c(73024),h=c.n(g),i=c(48161),j=c.n(i),k=c(76760),l=c.n(k);let m={platform:process.platform,security:(a,b)=>{let c=(0,d.spawnSync)("/usr/bin/security",a,{input:b,encoding:"utf8",timeout:2e3,maxBuffer:1048576,stdio:[void 0===b?"ignore":"pipe","pipe","pipe"]});return{status:c.error?null:c.status,stdout:c.stdout??""}}};function n(a){let b=process.env.CLAUDE_CODE_CUSTOM_OAUTH_URL?"-custom-oauth":"",c=f().createHash("sha256").update(a.normalize("NFC")).digest("hex").slice(0,8);return`Claude Code${b}-credentials-${c}`}function o(){let a;try{a=process.env.USER||j().userInfo().username}catch{a="claude-code-user"}return/^[a-zA-Z0-9._-]+$/.test(a)?a:"claude-code-user"}function p(a){try{let b=h().lstatSync(l().join(a,".credentials.json"));return b.isFile()&&!b.isSymbolicLink()&&b.uid===(process.getuid?.()??b.uid)&&(63&b.mode)==0?"safe":"unsafe"}catch(a){return"ENOENT"===a.code?"absent":"unknown"}}function q(a,b){try{let c=JSON.parse(a);if(!c||"object"!=typeof c||Array.isArray(c)||"keychain"===b&&("string"!=typeof c.claudeAiOauth?.accessToken||!c.claudeAiOauth.accessToken))return{state:"unknown"};return{state:"present",source:b,document:c}}catch{return{state:"unknown"}}}function r(a,b=m){let c,d=p(a);if("unsafe"===d||"unknown"===d)return{state:d};if("darwin"===b.platform){let c=b.security(["find-generic-password","-a",o(),"-w","-s",n(a)]);if(0===c.status)return q(c.stdout.trim(),"keychain");if(44!==c.status)return{state:"unknown"}}if("absent"===d)return{state:"absent"};try{c=h().openSync(l().join(a,".credentials.json"),h().constants.O_RDONLY|h().constants.O_NOFOLLOW);let b=h().fstatSync(c);if(!b.isFile()||b.uid!==(process.getuid?.()??b.uid)||(63&b.mode)!=0)return{state:"unsafe"};return q(h().readFileSync(c,"utf8"),"file")}catch{return{state:"unknown"}}finally{void 0!==c&&h().closeSync(c)}}function s(a,b,c,d=m){let e=r(a,d);if("present"!==e.state||e.source!==b.source||JSON.stringify(e.document)!==JSON.stringify(b.document))return!1;let g=JSON.stringify(c);if("keychain"===b.source){let b=`add-generic-password -U -a "${o()}" -s "${n(a)}" -X "${Buffer.from(g).toString("hex")}"
2
- `;if(Buffer.byteLength(b)>4032||0!==d.security(["-i"],b).status)return!1;let c=r(a,d);return"present"===c.state&&"keychain"===c.source&&JSON.stringify(c.document)===g}let i=l().join(a,".credentials.json"),j=l().join(a,`.credentials.${f().randomUUID()}.tmp`);try{let b=h().openSync(j,"wx",384);try{h().writeFileSync(b,g),h().fsyncSync(b)}finally{h().closeSync(b)}if("safe"!==p(a))return!1;h().renameSync(j,i);let c=h().openSync(a,"r");try{h().fsyncSync(c)}finally{h().closeSync(c)}return!0}catch{return!1}finally{h().rmSync(j,{force:!0})}}},78966:(a,b,c)=>{c.d(b,{F$:()=>$,Fn:()=>N,Hy:()=>y,No:()=>O,OG:()=>V,OL:()=>w,UV:()=>u,Xx:()=>v,ZK:()=>W,fM:()=>X,fg:()=>ac,k8:()=>_,kK:()=>P,o1:()=>C,o3:()=>x,ob:()=>Q,pW:()=>S,qX:()=>T,ss:()=>R,x0:()=>ab,y3:()=>U});var d=c(73024),e=c.n(d),f=c(48161),g=c.n(f),h=c(76760),i=c.n(h),j=c(91724),k=c(63006),l=c(92806),m=c(22962),n=c(81334);let o=/^[a-z0-9][a-z0-9-]{0,31}$/,p="default",q=["skills","commands","agents"],r=["settings.json"],s=new Set([".credentials.json",".claude.json","projects","history.jsonl","session-env","shell-snapshots","file-history","todos","cache","debug","backups","paste-cache","plugins","mcp.json","settings.local.json"]),t=null;class u extends Error{constructor(a){super(`unknown Claude account: ${a}`),this.name="UnknownClaudeAccountError"}}class v extends Error{constructor(){super("account label must contain visible text and be at most 80 characters"),this.name="InvalidClaudeAccountLabelError"}}class w extends Error{constructor(){super("Claude account registry is corrupt; repair or remove it before changing accounts"),this.name="CorruptClaudeAccountsError"}}class x extends Error{constructor(){super("managed Claude home failed safety checks"),this.name="UnsafeClaudeHomeError"}}function y(){return i().resolve(process.env.LLV_CLAUDE_HOME||i().join(g().homedir(),".claude"))}function z(){return i().join(i().dirname((0,j.Pn)()),"accounts","claude")}function A(){return(0,j.BQ)("claude-accounts.json")}function B(){return i().join(i().dirname((0,j.Pn)()),"shared","claude")}function C(){return i().join(B(),"projects")}function D(a){let b=i().join(a,"projects");try{if(!e().lstatSync(b).isSymbolicLink())return b;let a=C();if(e().realpathSync(b)===e().realpathSync(a))return a}catch{}return b}function E(a){return i().join(z(),a)}function F(){return{version:1,active:p,accounts:[],retired:[]}}function G(a,b=!1){if(!o.test(a)||a===p)return!1;let c=i().resolve(z()),d=i().resolve(E(a));if(i().dirname(d)!==c)return!1;try{var f;let a=e().lstatSync(c),b=e().lstatSync(d);if(!a.isDirectory()||a.isSymbolicLink()||!b.isDirectory()||b.isSymbolicLink()||(f=b.mode,(63&f)!=0||(511&f)!=448))return!1;return i().dirname(e().realpathSync(d))===e().realpathSync(c)}catch{return!b}}function H(){let a,b=A(),c=`${b}:${function(a){try{let b=e().statSync(a);return`${b.mtimeMs}:${b.size}`}catch{return"missing"}}(b)}`;if(t?.key===c)return t.loaded;try{a=e().existsSync(b)?function(a){if(!a||"object"!=typeof a||1!==a.version||"string"!=typeof a.active||!Array.isArray(a.accounts)||void 0!==a.retired&&!Array.isArray(a.retired))return{registry:F(),corrupt:!0};let b=new Set,c=!1,d=[];for(let e of a.accounts){if(!(e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.label&&"managed"===e.kind&&"number"==typeof e.createdAt&&G(e.id))||b.has(e.id)){c=!0;continue}b.add(e.id),d.push(e)}let e=[];for(let d of a.retired??[]){if(!(d&&"object"==typeof d&&"string"==typeof d.id&&"string"==typeof d.label&&"number"==typeof d.retiredAt&&G(d.id))||b.has(d.id)){c=!0;continue}b.add(d.id),e.push(d)}return{registry:{version:1,active:a.active,accounts:d,retired:e},corrupt:c}}(JSON.parse(e().readFileSync(b,"utf8"))):{registry:F(),corrupt:!1}}catch{a={registry:F(),corrupt:!0}}return t={key:c,loaded:a},a}function I(){let a=H();if(a.corrupt)throw new w;return a.registry}function J(a){return(0,m.oV)(()=>{let b=`${A()}.lock`,c=Date.now();for(e().mkdirSync(i().dirname(b),{recursive:!0,mode:448});;)try{let c=e().openSync(b,"wx",384);try{return e().writeFileSync(c,`${process.pid}
3
- `,"utf8"),a()}finally{e().closeSync(c),e().rmSync(b,{force:!0})}}catch(a){if("EEXIST"!==a.code)throw a;try{if(Date.now()-e().statSync(b).mtimeMs>3e4){e().rmSync(b,{force:!0});continue}}catch{continue}if(Date.now()-c>=5e3)throw Error("Claude account registry is busy; retry shortly");Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,10)}})}function K(a){let b=A();e().mkdirSync(i().dirname(b),{recursive:!0,mode:448});let c=i().join(i().dirname(b),`.${i().basename(b)}.${process.pid}.${Date.now()}.tmp`);try{e().writeFileSync(c,JSON.stringify(a,null,2)+"\n",{mode:384});let d=e().openSync(c,"r");try{e().fsyncSync(d)}finally{e().closeSync(d)}e().renameSync(c,b);let f=e().openSync(i().dirname(b),"r");try{e().fsyncSync(f)}finally{e().closeSync(f)}t=null}finally{e().rmSync(c,{force:!0})}}function L(a){let b=(0,k.TK)(a);return{authPresent:"present"===b.state,credentialState:b.state}}function M(a){let b=E(a.id);return{...a,home:b,projectsDir:D(b),...L(b)}}function N(){let a;return[{id:p,label:"Main",kind:"legacy",home:a=y(),projectsDir:D(a),...L(a),createdAt:0},...H().registry.accounts.map(M)]}function O(){let a=H().registry.active;return N().some(b=>b.id===a)?a:p}function P(){return H().corrupt}function Q(a){let b=N().find(b=>b.id===(a??O()));if(!b)throw new u(a??"");if("managed"===b.kind&&(!G(b.id,!0)||!function(a,b=!1){let c=(0,k.vt)(a);return"safe"===c||!b&&"absent"===c}(b.home)))throw new x;return{id:b.id,kind:b.kind,home:b.home,projectsDir:b.projectsDir}}function R(a){J(()=>{t=null;let b=I();if(!N().some(b=>b.id===a))throw new u(a);K({...b,active:a})})}function S(){return[...new Set([...N().map(a=>a.projectsDir),...H().registry.retired.map(a=>D(E(a.id)))])]}function T(a,b){let c;try{c=e().realpathSync(a)}catch{return{kind:"unreadable"}}let d=N(),f=null;try{f=e().realpathSync(C())}catch{}for(let a of d)try{let b=e().realpathSync(a.projectsDir);if(null!==f&&b===f)continue;if(c.startsWith(b+i().sep))return{kind:"owned",accountId:a.id,home:a.home,source:"path"}}catch{}let g=b?d.find(a=>a.id===b):void 0;if(g)return{kind:"owned",accountId:g.id,home:g.home,source:"recorded"};if(null!==f&&c.startsWith(f+i().sep)){let a=O(),b=d.find(b=>b.id===a)??d[0];if(b)return{kind:"owned",accountId:b.id,home:b.home,source:"shared-store"}}return{kind:"foreign"}}function U(a){let b=T(a);return"owned"===b.kind&&"path"===b.source?b.home:null}function V(a){let b=C(),c=i().resolve(a);if(c===b||c.startsWith(b+i().sep))return null;for(let a of N().map(a=>a.home)){let d=i().join(a,"projects");if(!c.startsWith(d+i().sep))continue;let f=i().join(b,i().relative(d,c));try{if(e().statSync(f).isFile())return f}catch{}break}return null}function W(){let a=i().join(B(),"settings.json");return e().existsSync(a)?a:null}function X(a){let b=a.trim();if(!b||b.length>80||/[\u0000-\u001f\u007f]/.test(b))throw new v;return J(()=>{t=null;let a=I(),c=function(a,b){let c=a.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"account";for(let a=0;;a+=1){let d=a?`-${a}`:"",f=`${c.slice(0,32-d.length)}${d}`;if(o.test(f)&&f!==p&&!b.has(f)&&!e().existsSync(E(f)))return f}}(b,new Set([...N().map(a=>a.id),...a.retired.map(a=>a.id)])),d=E(c),f=!1;if("absent"!==(0,k.TK)(d).state)throw new x;try{e().mkdirSync(i().dirname(d),{recursive:!0,mode:448}),e().chmodSync(i().dirname(d),448),e().mkdirSync(d,{mode:448}),e().chmodSync(d,448),f=!0;let g=function(){let a=B(),b=`${a}.tmp-${process.pid}-${Date.now()}`,c={files:0,bytes:0};e().rmSync(b,{recursive:!0,force:!0}),e().mkdirSync(b,{recursive:!0,mode:448});try{for(let a of[...q,...r]){let d=i().join(y(),a);e().existsSync(d)&&function a(b,c,d){let f=e().lstatSync(b);if(!f.isSymbolicLink()&&(f.isDirectory()||f.isFile())){if(f.isFile()){if(++d.files>2e3||(d.bytes+=f.size)>0x1000000)throw Error("Claude capability snapshot exceeds safety limit");e().mkdirSync(i().dirname(c),{recursive:!0,mode:448}),e().copyFileSync(b,c),e().chmodSync(c,384);return}for(let f of(e().mkdirSync(c,{recursive:!0,mode:448}),e().readdirSync(b,{withFileTypes:!0})))s.has(f.name)||a(i().join(b,f.name),i().join(c,f.name),d)}}(d,i().join(b,a),c)}return e().mkdirSync(i().dirname(a),{recursive:!0,mode:448}),e().chmodSync(i().dirname(a),448),e().rmSync(a,{recursive:!0,force:!0}),e().renameSync(b,a),e().chmodSync(a,448),a}catch(a){throw e().rmSync(b,{recursive:!0,force:!0}),a}}();for(let a of q){let b=i().join(g,a);e().existsSync(b)&&e().symlinkSync(b,i().join(d,a))}e().mkdirSync(i().join(d,"projects"),{mode:448});let h={id:c,label:b,kind:"managed",createdAt:Date.now()};return K({...a,accounts:[...a.accounts,h]}),M(h)}catch(a){if(f)try{(0,n.jK)("claude",c,d)||console.warn("[claude accounts] failed-account home cleanup is incomplete")}catch(a){if(console.warn("[claude accounts] preserving failed-account home after history cleanup refusal"),a instanceof n.s4)throw a}throw a}})}function Y(a){return a.artifacts.filter(a=>a.history).every(a=>a.path.startsWith(`projects${i().sep}`))}let Z=[".lock"];function $(a){return J(()=>{t=null;let b=I(),c=b.accounts.find(b=>b.id===a);if(!c)throw new u(a);let d=E(a),f=(0,n.Ew)(d);if(f&&!G(a,!0))throw new x;let g=f?(0,n.Ck)("claude",a,d):null;if(g&&!Y(g))throw new n.s4({...g,error:{path:".",message:"history falls outside the retained projects archive"}});let h=g?.artifacts.some(a=>a.history)??!1,i=f?(0,n.Vq)("claude",a,d,h?"projects":null):null,j=b.retired.filter(b=>b.id!==a);try{K({...b,active:b.active===a?p:b.active,accounts:b.accounts.filter(b=>b.id!==a),retired:[...j,{id:a,label:c.label,retiredAt:Date.now()}]})}catch(a){throw i&&(0,n.zJ)(i),a}let k=!1;if(i){try{(0,n.GJ)("claude",a,i)}catch(a){try{K(b)}finally{(0,n.zJ)(i)}throw a}let c=!1;try{c=(0,n.HH)("claude",a,i)}catch(a){if(a instanceof n.s4){try{K(b)}finally{(0,n.zJ)(i)}throw a}}if(c){if((0,n.Ep)(i),!h)try{e().rmdirSync(d)}catch(a){"ENOENT"!==a.code&&(k=!0)}}else{k=!0;try{(0,n.zJ)(i)}catch{console.warn("[claude accounts] staged home cleanup requires manual recovery")}}}if(!h)try{(0,n.Ew)(d)&&(k=!0)}catch{k=!0}return{cleanupPending:(0,n.N5)(z(),a,Z).unresolved.length>0||k}})}function _(){return J(()=>{let a;t=null;let b=I(),c=new Set(b.accounts.map(a=>a.id)),d=new Set(b.retired.map(a=>a.id));try{a=e().readdirSync(z(),{withFileTypes:!0})}catch(a){if("ENOENT"===a.code)return{removed:[],unresolved:[]};throw a}let f=[],g=[],h={},i=a=>{let b=(0,n.N5)(z(),a,Z);for(let a of b.removed)f.includes(a)||g.includes(a)||f.push(a);for(let a of b.unresolved){let b=f.indexOf(a);b>=0&&f.splice(b,1),g.includes(a)||g.push(a)}};for(let b of a){let a;if(b.name.endsWith(".lock")){let a=b.name.slice(0,-5);if(!o.test(a)||a===p){g.push(b.name);continue}if(c.has(a))continue;if((0,n.Du)("claude",a).length>0){g.push(b.name);continue}i(a);continue}if(!c.has(b.name)){if((0,n.Du)("claude",b.name).length>0||!b.isDirectory()||!G(b.name,!0)){g.push(b.name);continue}try{a=(0,n.Ck)("claude",b.name,E(b.name))}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name);continue}if(d.has(b.name)){if(!a.artifacts.some(a=>a.history)){try{(0,n.jK)("claude",b.name,E(b.name))?f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}continue}if(!Y(a)){h[b.name]=a,g.push(b.name);continue}try{let a=(0,n.F1)("claude",b.name,E(b.name),"projects");a.complete?a.changed&&f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}continue}if(a.artifacts.some(a=>a.history)){h[b.name]=a,g.push(b.name);continue}try{(0,n.jK)("claude",b.name,E(b.name))?f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}}}for(let a of e().readdirSync(z(),{withFileTypes:!0})){if(!a.name.endsWith(".lock"))continue;let b=a.name.slice(0,-5);if(!o.test(b)||b===p){g.includes(a.name)||g.push(a.name);continue}c.has(b)||0!==(0,n.Du)("claude",b).length?c.has(b)||g.includes(a.name)||g.push(a.name):i(b)}return{removed:f.sort(),unresolved:g.sort(),...Object.keys(h).length>0?{history:h}:{}}})}let aa=["CLAUDE_SECURESTORAGE_CONFIG_DIR","ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN","ANTHROPIC_BASE_URL","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","GOOGLE_APPLICATION_CREDENTIALS","VERTEXAI_PROJECT","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"];function ab(a,b=process.env){let c={...(0,l.Fd)(b),CLAUDE_CONFIG_DIR:a};for(let a of aa)delete c[a];return c}function ac(a){return N().some(b=>"managed"===b.kind&&b.home===a&&G(b.id,!0))}}};
2
+ `;if(Buffer.byteLength(b)>4032||0!==d.security(["-i"],b).status)return!1;let c=r(a,d);return"present"===c.state&&"keychain"===c.source&&JSON.stringify(c.document)===g}let i=l().join(a,".credentials.json"),j=l().join(a,`.credentials.${f().randomUUID()}.tmp`);try{let b=h().openSync(j,"wx",384);try{h().writeFileSync(b,g),h().fsyncSync(b)}finally{h().closeSync(b)}if("safe"!==p(a))return!1;h().renameSync(j,i);let c=h().openSync(a,"r");try{h().fsyncSync(c)}finally{h().closeSync(c)}return!0}catch{return!1}finally{h().rmSync(j,{force:!0})}}},78966:(a,b,c)=>{c.d(b,{F$:()=>af,Fn:()=>P,Hy:()=>y,No:()=>Q,OG:()=>X,OL:()=>w,UV:()=>u,Xx:()=>v,ZK:()=>Y,fM:()=>Z,fg:()=>aj,k8:()=>ag,kK:()=>R,o1:()=>C,o3:()=>x,ob:()=>S,pW:()=>U,qX:()=>V,ss:()=>T,x0:()=>ai,y3:()=>W});var d=c(73024),e=c.n(d),f=c(48161),g=c.n(f),h=c(76760),i=c.n(h),j=c(91724),k=c(63006),l=c(92806),m=c(22962),n=c(81334);let o=/^[a-z0-9][a-z0-9-]{0,31}$/,p="default",q=["skills","commands","agents"],r=["settings.json"],s=new Set([".credentials.json",".claude.json","projects","history.jsonl","session-env","shell-snapshots","file-history","todos","cache","debug","backups","paste-cache","plugins","mcp.json","settings.local.json"]),t=null;class u extends Error{constructor(a){super(`unknown Claude account: ${a}`),this.name="UnknownClaudeAccountError"}}class v extends Error{constructor(){super("account label must contain visible text and be at most 80 characters"),this.name="InvalidClaudeAccountLabelError"}}class w extends Error{constructor(){super("Claude account registry is corrupt; repair or remove it before changing accounts"),this.name="CorruptClaudeAccountsError"}}class x extends Error{constructor(){super("managed Claude home failed safety checks"),this.name="UnsafeClaudeHomeError"}}function y(){return i().resolve(process.env.LLV_CLAUDE_HOME||i().join(g().homedir(),".claude"))}function z(){return i().join(i().dirname((0,j.Pn)()),"accounts","claude")}function A(){return(0,j.BQ)("claude-accounts.json")}function B(){return i().join(i().dirname((0,j.Pn)()),"shared","claude")}function C(){return i().join(B(),"projects")}function D(a){let b=i().join(a,"projects");try{if(!e().lstatSync(b).isSymbolicLink())return b;let a=C();if(e().realpathSync(b)===e().realpathSync(a))return a}catch{}return b}function E(a){return i().join(z(),a)}function F(){return{version:1,active:p,accounts:[],retired:[],removals:[]}}function G(a,b=!1){if(!o.test(a)||a===p)return!1;let c=i().resolve(z()),d=i().resolve(E(a));if(i().dirname(d)!==c)return!1;try{var f;let a=e().lstatSync(c),b=e().lstatSync(d);if(!a.isDirectory()||a.isSymbolicLink()||!b.isDirectory()||b.isSymbolicLink()||(f=b.mode,(63&f)!=0||(511&f)!=448))return!1;return i().dirname(e().realpathSync(d))===e().realpathSync(c)}catch{return!b}}function H(){let a,b=A(),c=`${b}:${function(a){try{let b=e().statSync(a);return`${b.mtimeMs}:${b.size}`}catch{return"missing"}}(b)}`;if(t?.key===c)return t.loaded;try{a=e().existsSync(b)?function(a){if(!a||"object"!=typeof a||1!==a.version||"string"!=typeof a.active||!Array.isArray(a.accounts)||void 0!==a.retired&&!Array.isArray(a.retired))return{registry:F(),corrupt:!0};let b=new Set,c=!1,d=[];for(let e of a.accounts){if(!(e&&"object"==typeof e&&"string"==typeof e.id&&"string"==typeof e.label&&"managed"===e.kind&&"number"==typeof e.createdAt&&G(e.id))||b.has(e.id)){c=!0;continue}b.add(e.id),d.push(e)}let e=[];for(let d of a.retired??[]){if(!(d&&"object"==typeof d&&"string"==typeof d.id&&"string"==typeof d.label&&"number"==typeof d.retiredAt&&(void 0===d.archived||!0===d.archived)&&G(d.id))||b.has(d.id)){c=!0;continue}b.add(d.id),e.push(d)}let f=(0,n.yK)(a.removals,a=>o.test(a)&&a!==p);return f?{registry:{version:1,active:a.active,accounts:d,retired:e,removals:f},corrupt:c}:{registry:F(),corrupt:!0}}(JSON.parse(e().readFileSync(b,"utf8"))):{registry:F(),corrupt:!1}}catch{a={registry:F(),corrupt:!0}}return t={key:c,loaded:a},a}function I(){let a=H();if(a.corrupt)throw new w;return a.registry}function J(){return`${A()}.lock`}function K(a){try{let b=Number.parseInt(e().readFileSync(a,"utf8"),10);if(!Number.isSafeInteger(b)||b<=0||b===process.pid)return!1;return process.kill(b,0),!1}catch(a){return"ESRCH"===a.code}}function L(a){return(0,m.oV)(()=>{let b=J(),c=Date.now();for(e().mkdirSync(i().dirname(b),{recursive:!0,mode:448});;)try{let c=e().openSync(b,"wx",384);try{return e().writeFileSync(c,`${process.pid}
3
+ `,"utf8"),a()}finally{e().closeSync(c),e().rmSync(b,{force:!0})}}catch(a){if("EEXIST"!==a.code)throw a;try{if(K(b)||Date.now()-e().statSync(b).mtimeMs>3e4){e().rmSync(b,{force:!0});continue}}catch{continue}if(Date.now()-c>=5e3)throw Error("Claude account registry is busy; retry shortly");Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,10)}})}function M(a){let b=A();e().mkdirSync(i().dirname(b),{recursive:!0,mode:448});let c=i().join(i().dirname(b),`.${i().basename(b)}.${process.pid}.${Date.now()}.tmp`);try{e().writeFileSync(c,JSON.stringify(a,null,2)+"\n",{mode:384});let d=e().openSync(c,"r");try{e().fsyncSync(d)}finally{e().closeSync(d)}e().renameSync(c,b);let f=e().openSync(i().dirname(b),"r");try{e().fsyncSync(f)}finally{e().closeSync(f)}t=null}finally{e().rmSync(c,{force:!0})}}function N(a){let b=(0,k.TK)(a);return{authPresent:"present"===b.state,credentialState:b.state}}function O(a){let b=E(a.id);return{...a,home:b,projectsDir:D(b),...N(b)}}function P(){let a;return!function(){if(ae)return;let a=H();if(a.corrupt||0===a.registry.removals.length){ae=!0;return}if(!e().existsSync(J())||K(J()))try{L(()=>ad()),ae=!0}catch{}}(),[{id:p,label:"Main",kind:"legacy",home:a=y(),projectsDir:D(a),...N(a),createdAt:0},...H().registry.accounts.map(O)]}function Q(){let a=H().registry.active;return P().some(b=>b.id===a)?a:p}function R(){return H().corrupt}function S(a){let b=P().find(b=>b.id===(a??Q()));if(!b)throw new u(a??"");if("managed"===b.kind&&(!G(b.id,!0)||!function(a,b=!1){let c=(0,k.vt)(a);return"safe"===c||!b&&"absent"===c}(b.home)))throw new x;return{id:b.id,kind:b.kind,home:b.home,projectsDir:b.projectsDir}}function T(a){L(()=>{t=null;let b=I();if(!P().some(b=>b.id===a))throw new u(a);M({...b,active:a})})}function U(){return[...new Set([...P().map(a=>a.projectsDir),...H().registry.retired.map(a=>D(a.archived?(0,n.Zi)("claude",a.id):E(a.id)))])]}function V(a,b){let c;try{c=e().realpathSync(a)}catch{return{kind:"unreadable"}}let d=P(),f=null;try{f=e().realpathSync(C())}catch{}for(let a of d)try{let b=e().realpathSync(a.projectsDir);if(null!==f&&b===f)continue;if(c.startsWith(b+i().sep))return{kind:"owned",accountId:a.id,home:a.home,source:"path"}}catch{}let g=b?d.find(a=>a.id===b):void 0;if(g)return{kind:"owned",accountId:g.id,home:g.home,source:"recorded"};if(null!==f&&c.startsWith(f+i().sep)){let a=Q(),b=d.find(b=>b.id===a)??d[0];if(b)return{kind:"owned",accountId:b.id,home:b.home,source:"shared-store"}}return{kind:"foreign"}}function W(a){let b=V(a);return"owned"===b.kind&&"path"===b.source?b.home:null}function X(a){let b=C(),c=i().resolve(a);if(c===b||c.startsWith(b+i().sep))return null;for(let a of P().map(a=>a.home)){let d=i().join(a,"projects");if(!c.startsWith(d+i().sep))continue;let f=i().join(b,i().relative(d,c));try{if(e().statSync(f).isFile())return f}catch{}break}return null}function Y(){let a=i().join(B(),"settings.json");return e().existsSync(a)?a:null}function Z(a){let b=a.trim();if(!b||b.length>80||/[\u0000-\u001f\u007f]/.test(b))throw new v;return L(()=>{t=null;let a=I(),c=function(a,b){let c=a.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,32)||"account";for(let a=0;;a+=1){let d=a?`-${a}`:"",f=`${c.slice(0,32-d.length)}${d}`;if(o.test(f)&&f!==p&&!b.has(f)&&!e().existsSync(E(f))&&!e().existsSync((0,n.Zi)("claude",f)))return f}}(b,new Set([...P().map(a=>a.id),...a.retired.map(a=>a.id)])),d=E(c),f=!1;if("absent"!==(0,k.TK)(d).state)throw new x;try{e().mkdirSync(i().dirname(d),{recursive:!0,mode:448}),e().chmodSync(i().dirname(d),448),e().mkdirSync(d,{mode:448}),e().chmodSync(d,448),f=!0;let g=function(){let a=B(),b=`${a}.tmp-${process.pid}-${Date.now()}`,c={files:0,bytes:0};e().rmSync(b,{recursive:!0,force:!0}),e().mkdirSync(b,{recursive:!0,mode:448});try{for(let a of[...q,...r]){let d=i().join(y(),a);e().existsSync(d)&&function a(b,c,d){let f=e().lstatSync(b);if(!f.isSymbolicLink()&&(f.isDirectory()||f.isFile())){if(f.isFile()){if(++d.files>2e3||(d.bytes+=f.size)>0x1000000)throw Error("Claude capability snapshot exceeds safety limit");e().mkdirSync(i().dirname(c),{recursive:!0,mode:448}),e().copyFileSync(b,c),e().chmodSync(c,384);return}for(let f of(e().mkdirSync(c,{recursive:!0,mode:448}),e().readdirSync(b,{withFileTypes:!0})))s.has(f.name)||a(i().join(b,f.name),i().join(c,f.name),d)}}(d,i().join(b,a),c)}for(let c of(e().mkdirSync(i().dirname(a),{recursive:!0,mode:448}),e().chmodSync(i().dirname(a),448),e().mkdirSync(a,{recursive:!0,mode:448}),e().chmodSync(a,448),[...q,...r])){let d=i().join(a,c);e().rmSync(d,{recursive:!0,force:!0}),e().existsSync(i().join(b,c))&&e().renameSync(i().join(b,c),d)}return a}finally{e().rmSync(b,{recursive:!0,force:!0})}}();for(let a of q){let b=i().join(g,a);e().existsSync(b)&&e().symlinkSync(b,i().join(d,a))}e().mkdirSync(i().join(d,"projects"),{mode:448});let h={id:c,label:b,kind:"managed",createdAt:Date.now()};return M({...a,accounts:[...a.accounts,h]}),O(h)}catch(a){if(f)try{(0,n.jK)("claude",c,d)||console.warn("[claude accounts] failed-account home cleanup is incomplete")}catch(a){if(console.warn("[claude accounts] preserving failed-account home after history cleanup refusal"),a instanceof n.s4)throw a}throw a}})}let $=[".lock"];function _(a){return(0,n.N5)(z(),a,$).unresolved.length>0}function aa(a,b){let c=[a];try{let b=e().realpathSync(a);b!==a&&c.push(b)}catch{}let d=C(),f=D(a)===d;return c.flatMap(a=>[...f?[{from:i().join(a,"projects"),to:d}]:[],{from:a,to:b}])}function ab(a,b,c){t=null;let d=I();M({...d,removals:(0,n.XU)(d.removals,a,b,c)})}function ac(a,b){let c=a.accounts.find(a=>a.id===b)?.label??b;return{...a,active:a.active===b?p:a.active,accounts:a.accounts.filter(a=>a.id!==b),retired:[...a.retired.filter(a=>a.id!==b),{id:b,label:c,retiredAt:Date.now(),archived:!0}],removals:(0,n.XU)(a.removals,b,"scrubbing")}}function ad(){t=null;let a=I(),b=[],c=[];for(let d of a.removals){if((0,n.nr)("claude",d.id))continue;let e=null;try{e=(0,n.nH)({engine:"claude",accountId:d.id,home:E(d.id),entry:d,listed:a.accounts.some(a=>a.id===d.id),commitRetired:()=>{t=null,M(ac(I(),d.id))},clearJournal:()=>ab(d.id,null)})}catch{}"retired"===e&&_(d.id),(e?b:c).push(d.id)}return{recovered:b,unresolved:c}}let ae=!1;function af(a){return L(()=>{ad(),t=null;let b=I();if(!b.accounts.find(b=>b.id===a))throw new u(a);let c={...b,removals:(0,n.XU)(b.removals,a,null)},d=(0,n.ne)({engine:"claude",accountId:a,home:E(a),homeIsSafe:()=>G(a,!0),unsafeHome:()=>new x,rewrites:aa,registry:{journal:(b,c)=>ab(a,b,c),commitRetired:()=>M(ac(c,a)),restore:()=>M(c)}});return{...d,cleanupPending:_(a)||d.cleanupPending}})}function ag(){return L(()=>{let a;ad(),t=null;let b=I(),c=new Set(b.accounts.map(a=>a.id)),d=new Set(b.retired.map(a=>a.id));try{a=e().readdirSync(z(),{withFileTypes:!0})}catch(a){if("ENOENT"===a.code)return{removed:[],unresolved:[]};throw a}let f=[],g=[],h={},j=a=>{let b=(0,n.N5)(z(),a,$);for(let a of b.removed)f.includes(a)||g.includes(a)||f.push(a);for(let a of b.unresolved){let b=f.indexOf(a);b>=0&&f.splice(b,1),g.includes(a)||g.push(a)}};for(let b of a){let a;if(b.name.endsWith(".lock")){let a=b.name.slice(0,-5);if(!o.test(a)||a===p){g.push(b.name);continue}if(c.has(a))continue;if((0,n.Du)("claude",a).length>0){g.push(b.name);continue}j(a);continue}if(!c.has(b.name)){if((0,n.Du)("claude",b.name).length>0||!b.isDirectory()||!G(b.name,!0)){g.push(b.name);continue}try{a=(0,n.Ck)("claude",b.name,E(b.name))}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name);continue}if(d.has(b.name)){if(!a.artifacts.some(a=>a.history)){try{(0,n.jK)("claude",b.name,E(b.name))?f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}continue}if(!a.artifacts.filter(a=>a.history).every(a=>a.path.startsWith(`projects${i().sep}`))){h[b.name]=a,g.push(b.name);continue}try{let a=(0,n.F1)("claude",b.name,E(b.name),"projects");a.complete?a.changed&&f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}continue}if(a.artifacts.some(a=>a.history)){h[b.name]=a,g.push(b.name);continue}try{(0,n.jK)("claude",b.name,E(b.name))?f.push(b.name):g.push(b.name)}catch(a){a instanceof n.s4&&(h[b.name]=a.report),g.push(b.name)}}}for(let a of e().readdirSync(z(),{withFileTypes:!0})){if(!a.name.endsWith(".lock"))continue;let b=a.name.slice(0,-5);if(!o.test(b)||b===p){g.includes(a.name)||g.push(a.name);continue}c.has(b)||0!==(0,n.Du)("claude",b).length?c.has(b)||g.includes(a.name)||g.push(a.name):j(b)}return{removed:f.sort(),unresolved:g.sort(),...Object.keys(h).length>0?{history:h}:{}}})}let ah=["CLAUDE_SECURESTORAGE_CONFIG_DIR","ANTHROPIC_API_KEY","ANTHROPIC_AUTH_TOKEN","CLAUDE_CODE_OAUTH_TOKEN","ANTHROPIC_BASE_URL","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","GOOGLE_APPLICATION_CREDENTIALS","VERTEXAI_PROJECT","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX"];function ai(a,b=process.env){let c={...(0,l.Fd)(b),CLAUDE_CONFIG_DIR:a};for(let a of ah)delete c[a];return c}function aj(a){return P().some(b=>"managed"===b.kind&&b.home===a&&G(b.id,!0))}}};
@@ -1 +1 @@
1
- "use strict";exports.id=8991,exports.ids=[8991],exports.modules={551:(a,b,c)=>{c.d(b,{V5:()=>e,yv:()=>h});let d=["-agents-tools-"];function e(a,b){if(b?.trim())return b.trim();if("project_unresolved"===a)return"Unresolved project";for(let b of d)if(a.startsWith(b)&&a.length>b.length)return a.slice(b.length);return a.replace(/^-+/,"")||a}let f=new Set(["orchestrator","reviewer","builder","architect","cleaner","prod-auditor","deployer","verifier"]);function g(a){let b,c=/^You are (?:the |an? )?([^.,:]{1,60}?)[.,:]/.exec(a);if(!c||!a.slice(c[0].length).trim())return null;let d=c[1].trim(),e=null,g=d.indexOf(" in ");if(g>0){let a=d.slice(g+4).trim();d=d.slice(0,g).trim();let b=/^(\S+) mode$/.exec(a);b&&!b[1].includes("{")&&(e=b[1])}let h=(b=d.split(" ").filter(Boolean).at(-1)??"",/^[A-Z][A-Za-z-]{1,24}$/.test(b)?b:f.has(b.toLowerCase())?b[0].toUpperCase()+b.slice(1):null);return h?e?`${h} — ${e}`:h:null}function h(a){for(let b of a){if("claude"!==b.engine&&"codex"!==b.engine)continue;if(void 0!==b.autoTitle){let a=g(b.autoTitle);a&&(b.autoTitle=a);continue}let a=g(b.title);a&&(b.title=a)}}},48991:(a,b,c)=>{c.d(b,{Xn:()=>p,HR:()=>r});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h);c(80457),c(551);var j=c(91724);let k=(0,j.BQ)("push-keys.json"),l=(0,j.BQ)("push-subscriptions.json");(0,j.BQ)("push-sent.json");let m=Promise.resolve();function n(a,b){try{return JSON.parse(g().readFileSync(a,"utf8"))}catch{return b}}function o(a,b){try{return g().mkdirSync(i().dirname(a),{recursive:!0}),g().writeFileSync(a,JSON.stringify(b,null,2)),!0}catch{return!1}}function p(){var a;let b=n(k,null);if(b?.publicKey&&b.privateKey)return b;let c=e().generateKeyPairSync("ec",{namedCurve:"prime256v1"}),d={publicKey:(a=c.publicKey.export({type:"spki",format:"der"}).subarray(-65),Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),privateKey:c.privateKey.export({type:"pkcs8",format:"pem"}).toString()};return o(k,d),d}async function q(a){if(!a.endpoint)return;let b=n(l,[]).filter(b=>b.endpoint!==a.endpoint);b.push(a),o(l,b)}async function r(a){m=m.then(()=>q(a),()=>q(a)),await m.catch(()=>void 0)}},80457:(a,b,c)=>{new TextEncoder,new TextDecoder}};
1
+ "use strict";exports.id=8991,exports.ids=[8991],exports.modules={551:(a,b,c)=>{c.d(b,{V5:()=>e,yv:()=>h});let d=["-agents-tools-"];function e(a,b){if(b?.trim())return b.trim();if("project_unresolved"===a)return"Unresolved project";for(let b of d)if(a.startsWith(b)&&a.length>b.length)return a.slice(b.length);return a.replace(/^-+/,"")||a}let f=new Set(["orchestrator","reviewer","builder","architect","cleaner","prod-auditor","deployer","verifier"]);function g(a){let b,c=/^You are (?:the |an? )?([^.,:]{1,60}?)[.,:]/.exec(a);if(!c||!a.slice(c[0].length).trim())return null;let d=c[1].trim(),e=null,g=d.indexOf(" in ");if(g>0){let a=d.slice(g+4).trim();d=d.slice(0,g).trim();let b=/^(\S+) mode$/.exec(a);b&&!b[1].includes("{")&&(e=b[1])}let h=(b=d.split(" ").filter(Boolean).at(-1)??"",/^[A-Z][A-Za-z-]{1,24}$/.test(b)?b:f.has(b.toLowerCase())?b[0].toUpperCase()+b.slice(1):null);return h?e?`${h} — ${e}`:h:null}function h(a){for(let b of a){if("claude"!==b.engine&&"codex"!==b.engine)continue;if(void 0!==b.autoTitle){let a=g(b.autoTitle);a&&(b.autoTitle=a);continue}let a=g(b.title);a&&(b.title=a)}}},16810:(a,b,c)=>{c.d(b,{H8:()=>h,Zo:()=>f,dN:()=>g,tB:()=>i});let d=globalThis;function e(a){return!!a.migratedTo}function f(a){return a.conversationId?"#c="+encodeURIComponent(a.conversationId):"#f="+encodeURIComponent(a.path)}function g(a,b){let c=null,d=null;for(let f of a)if(f.conversationId===b){if(f.path.startsWith("spawn:")){c=c??f;continue}if(d=d??f,!e(f))return f}return d??c}function h(a,b){let c=new Set,d=a;for(;void 0!==b[d]&&!c.has(d);)c.add(d),d=b[d];return d}function i(a){return a.some(e)?a.filter(a=>!e(a)):a}d.__llvFileIndexes??=new WeakMap},33330:(a,b,c)=>{c.d(b,{$_:()=>e,FC:()=>l,Io:()=>f,J5:()=>k,TI:()=>n,Wf:()=>m,jk:()=>h,np:()=>g,pW:()=>j,pw:()=>d,vb:()=>o});let d=1,e=1,f="orchestrator",g=500,h=7200,i=["status","completed","failed","blocked","review_verdict","question"],j="confirmation_request";function k(a){return"string"==typeof a&&i.includes(a)||a===j}function l(a){return"blocked"===a||"question"===a}function m(a){if(!a||"manager"===a.kind)return null;let b="gateway"===a.kind?"voice gateway":a.role??"agent";return a.conversationId?`${b} ${a.conversationId}`:b}let n=5,o=3e4},48991:(a,b,c)=>{c.d(b,{M$:()=>B,Xn:()=>w,HR:()=>y});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(33330);function k(a){let b=Date.parse(a);return Number.isFinite(b)?b/1e3:null}c(80457),c(551);var l=c(16810),m=c(91724);let n=(0,m.BQ)("push-keys.json"),o=(0,m.BQ)("push-subscriptions.json"),p=(0,m.BQ)("push-sent.json"),q=Promise.resolve();function r(a){return Buffer.from(a).toString("base64").replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function s(a){let b=a+"=".repeat((4-a.length%4)%4);return Buffer.from(b.replace(/-/g,"+").replace(/_/g,"/"),"base64")}function t(a,b){try{return JSON.parse(g().readFileSync(a,"utf8"))}catch{return b}}function u(a,b){try{return g().mkdirSync(i().dirname(a),{recursive:!0}),g().writeFileSync(a,JSON.stringify(b,null,2)),!0}catch{return!1}}function v(a,b,c){let d=[],f=Buffer.alloc(0),g=1;for(;Buffer.concat(d).length<c;)f=e().createHmac("sha256",a).update(f).update(b).update(Buffer.from([g])).digest(),d.push(f),g+=1;return Buffer.concat(d).subarray(0,c)}function w(){let a=t(n,null);if(a?.publicKey&&a.privateKey)return a;let b=e().generateKeyPairSync("ec",{namedCurve:"prime256v1"}),c={publicKey:r(b.publicKey.export({type:"spki",format:"der"}).subarray(-65)),privateKey:b.privateKey.export({type:"pkcs8",format:"pem"}).toString()};return u(n,c),c}async function x(a){if(!a.endpoint)return;let b=t(o,[]).filter(b=>b.endpoint!==a.endpoint);b.push(a),u(o,b)}async function y(a){q=q.then(()=>x(a),()=>x(a)),await q.catch(()=>void 0)}async function z(a,b){try{var c;let d,f,g,h,i,j=function(a,b){let c=a.keys?.p256dh,d=a.keys?.auth;if(!c||!d)return null;let f=s(c),g=s(d),h=e().randomBytes(16),i=e().createECDH("prime256v1"),j=i.generateKeys(),k=i.computeSecret(f),l=e().createHmac("sha256",g).update(k).digest(),m=v(l,Buffer.concat([Buffer.from("WebPush: info\0"),f,j]),32),n=e().createHmac("sha256",h).update(m).digest(),o=v(n,"Content-Encoding: aes128gcm\0",16),p=v(n,"Content-Encoding: nonce\0",12),q=Buffer.concat([Buffer.from(JSON.stringify(b),"utf8"),Buffer.from([2])]),r=e().createCipheriv("aes-128-gcm",o,p),t=Buffer.concat([r.update(q),r.final(),r.getAuthTag()]),u=Buffer.alloc(21);return h.copy(u,0),u.writeUInt32BE(4096,16),u.writeUInt8(j.length,20),Buffer.concat([u,j,t])}(a,b);if(!j)return"failed";let k=new Uint8Array(j.byteLength);k.set(j);let l=(c=new URL(a.endpoint).origin,d=w(),f=r(JSON.stringify({typ:"JWT",alg:"ES256"})),g=r(JSON.stringify({aud:c,exp:Math.floor(Date.now()/1e3)+43200,sub:"mailto:agent-log-viewer@localhost"})),(h=e().createSign("SHA256")).update(`${f}.${g}`),h.end(),i=h.sign({key:d.privateKey,dsaEncoding:"ieee-p1363"}),`${f}.${g}.${r(i)}`),m=new AbortController,n=setTimeout(()=>m.abort(),3e3),o=await fetch(a.endpoint,{method:"POST",signal:m.signal,headers:{authorization:`vapid t=${l}, k=${w().publicKey}`,"content-encoding":"aes128gcm","content-type":"application/octet-stream",ttl:"60",urgency:"normal"},body:k.buffer}).catch(()=>null);if(clearTimeout(n),!o)return"failed";if(o.status>=200&&o.status<300)return"sent";if(404===o.status||410===o.status)return"dead";return"failed"}catch{return"failed"}}async function A(a){let b;if(a.waitingInput&&Date.now()/1e3-a.waitingInput.since<60||!a.pendingQuestion&&!a.waitingInput)return;let c=function(a,b=Date.now()/1e3){let c=function(a,b){let c=a.bridgeAsk;if(!c)return null;let d=k(c.at);return null===d?null:b-d<=j.jk?c:null}(a,b);if(c)return c.id;if(a.pendingQuestion)return a.pendingQuestion.toolUseId;if(a.rateLimit)return`${a.path}:rate-limited:${a.rateLimit.resetAt??"unknown"}`;if(a.waitingInput)return`${a.path}:waiting:${Math.floor(a.waitingInput.since)}`;let d=function(a,b){let c=a.stuckDelivery;if(!c)return null;let d=k(c.since);return null===d?null:b-d>=300?d:null}(a,b);return null!==d?`${a.path}:delivery:${Math.floor(d)}`:"stalled"===a.activity&&"running"===a.proc&&b-a.mtime<=7200?`${a.path}:stalled:${Math.floor(a.mtime)}`:null}(a);if(!c)return;let d=new Set(t(p,[]));if(d.has(c))return;let e=t(o,[]);if(!e.length)return;let f=[],g=!1,h=!1,i=(b=a.pendingQuestion?.kind==="plan"?"plan awaiting approval":a.pendingQuestion?.questions?.[0]?.header||a.waitingInput?.menu?.question.slice(0,120)||(a.waitingInput?"waiting for an answer":"question"),{title:`${a.title||"Agent"} \xb7 ${a.engine}`,body:b,url:`/${(0,l.Zo)(a)}#question`});for(let a of e){let b=await z(a,i);"sent"===b?(g=!0,f.push(a)):"failed"===b?f.push(a):h=!0}g&&(d.add(c),u(p,[...d].slice(-500))),h&&u(o,f)}async function B(a){q=q.then(()=>A(a),()=>A(a)),await q.catch(()=>void 0)}},80457:(a,b,c)=>{c.d(b,{rN:()=>function a(b){let c=b&&"object"==typeof b&&!Array.isArray(b)?b:null;if(!c)return null==b||""===b?{}:a({input:b});let d={},g=0;for(let[a,b]of Object.entries(c)){let c;if(g>=12)break;if("string"==typeof b)c=f(b,256);else if("number"==typeof b||"boolean"==typeof b||null===b)c=b;else{let a;if(void 0===b)continue;try{a=JSON.stringify(b)??""}catch{a=""}if(!a)continue;c=f(a,256)}d[a]=c,g+=1}let h=Object.entries(d);for(;h.length&&e(JSON.stringify(Object.fromEntries(h)))>2048;)h=h.slice(0,-1);return Object.fromEntries(h)}});let d=new TextEncoder;new TextDecoder;let e=a=>d.encode(a).length;function f(a,b){let c=[...a];return c.length>b?c.slice(0,b-1).join("")+"…":a}}};
@@ -1 +1 @@
1
- "use strict";exports.id=8996,exports.ids=[8996],exports.modules={8960:(a,b,c)=>{c.d(b,{I1:()=>j,L1:()=>k,MJ:()=>m,Om:()=>n,ap:()=>l});var d=c(9735),e=c(97609),f=c(41085);function g(a,b,c){let d=a.limits?.[b];if(!d)return null;let e=d.observedAt??a.observedAt;return{value:d,observedAt:e,stale:a.stale||null!==e&&c-e>1200,source:d.source??a.source}}function h(a,b,c,d){var f;let g;if(a.value.usedPercent<100)return!1;if(null!==a.value.resetsAt)return a.value.resetsAt>d;if(null===a.observedAt)return!0;let h="number"==typeof a.value.windowMinutes?a.value.windowMinutes:"weekly"===c?e.rX:e.Gn;return!(d-a.observedAt>=60*h)&&(f=a.observedAt,!(g=b?.value)||null===g.resetsAt||"number"!=typeof g.windowMinutes||!(g.resetsAt-60*g.windowMinutes>f))}function i(a,b,c,d){if(!a)return b;if(!b)return a;let e=h(a,b,c,d);return e!==h(b,a,c,d)?e?a:b:null===a.observedAt?null===b.observedAt?a:b:null===b.observedAt?a:b.observedAt>a.observedAt?b:a}function j(a,b,c){let d=i(a?g(a,"session",c):null,b?g(b,"session",c):null,"session",c),e=i(a?g(a,"weekly",c):null,b?g(b,"weekly",c):null,"weekly",c),f=i(a?g(a,"flagship",c):null,b?g(b,"flagship",c):null,"weekly",c),h=[a,b].filter(a=>!!a?.limits?.plan).sort((a,b)=>(b.observedAt??-1/0)-(a.observedAt??-1/0));return{session:d,weekly:e,flagship:f&&"string"==typeof f.value.tier?f:null,plan:h[0]?.limits?.plan??null}}function k(a){if(!a.session&&!a.weekly&&!a.flagship)return null;let b=[a.session?.observedAt,a.weekly?.observedAt,a.flagship?.observedAt].filter(a=>null!=a);return{session:a.session?{...a.session.value,observedAt:a.session.observedAt,source:a.session.source}:null,weekly:a.weekly?{...a.weekly.value,observedAt:a.weekly.observedAt,source:a.weekly.source}:null,flagship:a.flagship?{...a.flagship.value,observedAt:a.flagship.observedAt,source:a.flagship.source}:null,plan:a.plan,capturedAt:b.length?Math.min(...b):null}}function l(a,b){return a.session?.source===b||a.weekly?.source===b||a.flagship?.source===b}function m(a,b=Date.now()){if(!a)return null;let c=Date.parse(a.observedAt),e=Date.parse(a.authCheckedAt),f=(0,d.Wz)({engine:a.engine,accountId:a.accountId,authenticated:a.authenticated,limits:a.limits,provenance:a.provenance,observedAt:c,authCheckedAt:e},b);if(f?.percent!==0||!a.limits)return null;let g=["session","weekly","flagship"].flatMap(b=>{let c=a.limits?.[b];return c&&c.usedPercent>=100?[{window:"flagship"===b?"weekly":b,resetAt:c.resetsAt}]:[]});if(!g.length)return null;let h=g.filter(a=>null===a.resetAt||1e3*a.resetAt>b);if(!h.length)return null;let i=h.find(a=>null===a.resetAt)??h.sort((a,b)=>b.resetAt-a.resetAt)[0];return{source:"account",accountId:a.accountId,window:i.window,resetAt:null!==i.resetAt&&1e3*i.resetAt>b?i.resetAt:null}}function n(a,b,c,d=Date.now(),e=()=>null,g=()=>!1){let h=new Map;for(let a of Object.values(c.conversations))for(let b of a.generations)h.set(b.path,{conversationId:a.id,engine:a.engine,accountId:b.accountId});let i=new Map;for(let a of Object.values(c.entries??{})){let b=h.get(a.artifactPath);b&&a.accountId&&["starting","live","idle","handoff"].includes(a.status)&&g(a)&&i.set(a.artifactPath,{engine:b.engine,accountId:a.accountId})}let j={claude:new Map,codex:new Map},k=a.map(a=>{var b,g,k;let l,n=h.get(a.path),o=i.get(a.path),p=o?.accountId??n?.accountId??null,q=o?.engine??n?.engine,r=q&&p?c.quotaObservations[q][p]:void 0,s=o&&a.authoritativeTurn?.state==="busy"?(b=o.engine,g=o.accountId,(l=j[b]).has(g)||l.set(g,(0,f.pG)(e(b,g),d)),l.get(g)??null):null,t=o||"running"===a.proc?m(r,d):null,u=(k=a.rateLimit,k?{source:"pane",accountId:p??k.accountId,window:t?.window??k.window,resetAt:t?.resetAt??k.resetAt}:t),v={...a};return delete v.providerThrottle,{...v,conversationId:a.conversationId??n?.conversationId,rateLimit:u,...s?{providerThrottle:s}:{}}}),l=new Map(k.map(a=>[a.path,a])),o=new Set(["waiting_ready","relaying","fixing"]);return{files:k,flows:b.map(a=>{let b=l.get(a.implementerPath),c=b?.conversationId??a.implementerConversationId??null,d="relaying"===a.state?a.rounds.at(-1)?.relayHold:null;if(d){let b=Date.parse(d.until),e=Number.isFinite(b)?Math.floor(b/1e3):null,f=!1!==d.resetKnown;return{...a,block:{reason:"rate_limited",conversationId:c,accountId:d.accountId,resetAt:f?e:null,...f?{}:{recheckAt:e}}}}let e=b?.rateLimit;return e&&o.has(a.state)?{...a,block:{reason:"rate_limited",conversationId:c,accountId:e.accountId,resetAt:e.resetAt}}:a.block?{...a,block:null}:a})}}},9735:(a,b,c)=>{c.d(b,{B1:()=>f,Wz:()=>g,f7:()=>e});var d=c(4837);let e=25,f=3e5;function g(a,b=Date.now(),c={}){var e,h;if(!Number.isFinite(b)||!Number.isFinite(a.observedAt)||void 0!==a.authCheckedAt&&!Number.isFinite(a.authCheckedAt))return null;let i=b-a.observedAt,j=b-(a.authCheckedAt??a.observedAt);if(!a.authenticated||"live"!==a.provenance.source||i<0||j<0||i>f||j>f||!a.limits)return null;let k=(e=a.engine,h=c.model,"claude"===e&&(0,d.ll)(h)?["session","weekly","flagship"]:["session","weekly"]).map(b=>({window:b,value:a.limits?.[b]})).filter(a=>null!==a.value&&void 0!==a.value);return k.some(({value:a})=>!Number.isFinite(a.usedPercent)||a.usedPercent<0||a.usedPercent>100||null!==a.resetsAt&&(!Number.isSafeInteger(a.resetsAt)||a.resetsAt<0))?null:k.length?k.map(({window:a,value:b})=>({window:a,percent:100-b.usedPercent})).sort((a,b)=>a.percent-b.percent||a.window.localeCompare(b.window))[0]??null:null}},30096:(a,b,c)=>{c.d(b,{e4:()=>e,sb:()=>f,u1:()=>d});let d="oauth-rate-limited",e="oauth-reauthentication-required",f=512},41085:(a,b,c)=>{c.d(b,{B4:()=>i,Lm:()=>e,p5:()=>g,pG:()=>h});var d=c(30096);let e=6e4;function f(a){if(a?.reason!==d.u1||!a.retryAt)return null;let b=Date.parse(a.retryAt);return Number.isFinite(b)?b:null}function g(a,b=Date.now(),c=e){let d=f(a);return null===d||b>d+(Number.isFinite(c)?Math.max(0,c):e)?null:new Date(d).toISOString()}function h(a,b=Date.now(),c=e){let d=g(a,b,c);return d?{reason:"provider_throttled",retryAt:d}:null}function i(a,b=Date.now()){let c=f(a);return null===c||b>=c?null:{reason:"provider_throttled",retryAt:new Date(c).toISOString()}}},58996:(a,b,c)=>{c.d(b,{io:()=>G,nn:()=>L,wW:()=>F,Ke:()=>Y,Ki:()=>O,BU:()=>K});var d=c(63006),e=c(73024),f=c.n(e),g=c(76760),h=c.n(g),i=c(41617),j=c(78966),k=c(68797),l=c(3253),m=c(91724);let n={session:18e3,weekly:604800};function o(a){return Math.max(0,Math.min(100,a))}var p=c(97609);let q=["session","weekly"];function r(){return(0,m.BQ)("limits-history.json")}function s(a,b,c){return`${a}|${b}|${c}`}function t(){return{version:1,since:null,series:{}}}function u(a){return!!a&&"object"==typeof a&&"number"==typeof a.t&&Number.isFinite(a.t)&&"number"==typeof a.remaining&&Number.isFinite(a.remaining)}function v(){try{let a=JSON.parse(f().readFileSync(r(),"utf8"));if(1!==a.version||!a.series||"object"!=typeof a.series)return t();let b={};for(let[c,d]of Object.entries(a.series))Array.isArray(d)&&(b[c]=d.filter(u));return{version:1,since:"string"==typeof a.since?a.since:null,series:b}}catch{return t()}}var w=c(8960),x=c(30096);function y(){return(0,m.BQ)("limits-cache.json")}let z="app-server-initialize-timeout",A=globalThis;function B(){return{version:2,engines:{claude:{},codex:{}}}}function C(){return A.__llvLimitsCache||(A.__llvLimitsCache=function(){try{let a=JSON.parse(f().readFileSync(y(),"utf8"));if(2===a.version&&a.engines&&"object"==typeof a.engines){let b=B();for(let c of["claude","codex"]){let d=a.engines[c];if(d&&"object"==typeof d)for(let[a,e]of Object.entries(d)){let d=function(a){if(!a||"object"!=typeof a||"number"!=typeof a.at||void 0===a.data||!a.provenance)return null;let b=a.provenance;return"live"!==b.source&&"transcript"!==b.source&&"cache"!==b.source&&"unavailable"!==b.source||"string"!=typeof b.reason&&null!==b.reason||"string"!=typeof b.staleSince&&null!==b.staleSince||void 0!==b.retryAt&&"string"!=typeof b.retryAt&&null!==b.retryAt||void 0!==a.baseData&&null!==a.baseData&&"object"!=typeof a.baseData||void 0!==a.retryAt&&null!==a.retryAt&&"number"!=typeof a.retryAt||void 0!==a.consecutive429s&&(!Number.isInteger(a.consecutive429s)||a.consecutive429s<0)||void 0!==a.consecutiveInitializeTimeouts&&(!Number.isInteger(a.consecutiveInitializeTimeouts)||a.consecutiveInitializeTimeouts<0)?null:a}(e);d&&(b.engines[c][a]="codex"===c?{...d,data:(0,p.Zc)(d.data),...void 0===d.baseData?{}:{baseData:(0,p.Zc)(d.baseData)}}:d)}}return b}if("number"==typeof a.at&&"string"==typeof a.accountId&&a.data?.codex){let b=!function(a){if(!a||"object"!=typeof a)return!1;let b=a=>!!a&&("live"===a.source||"transcript"===a.source||"cache"===a.source||"unavailable"===a.source)&&("string"==typeof a.reason||null===a.reason)&&("string"==typeof a.staleSince||null===a.staleSince)&&(void 0===a.retryAt||"string"==typeof a.retryAt||null===a.retryAt);return b(a.claude)&&b(a.codex)}(a.data.provenance)?{source:"cache",reason:"legacy cache provenance unavailable",staleSince:a.data.staleSince??null}:a.data.provenance.codex;return{version:2,engines:{claude:{},codex:{[a.accountId]:{at:a.at,data:(0,p.Zc)(a.data.codex),provenance:b}}}}}}catch{}return B()}()),A.__llvLimitsCache}function D(a){try{f().mkdirSync(h().dirname(y()),{recursive:!0});let b=b=>Object.entries(a.engines[b]).sort(([,a],[,b])=>b.at-a.at)[0]??null,c=b("claude"),d=b("codex"),e=d?{at:d[1].at,accountId:d[0],data:{claude:c?.[1].data??null,codex:d[1].data,claudeAccountId:c?.[0]??null,codexAccountId:d[0],provenance:{claude:c?.[1].provenance??{source:"unavailable",reason:"no cached Claude limits",staleSince:null},codex:d[1].provenance},staleSince:c?.[1].provenance.staleSince??d[1].provenance.staleSince}}:{};f().writeFileSync(y(),JSON.stringify({...a,...e},null,2)+"\n","utf8")}catch(a){console.warn("[limits] failed to persist cache",a)}}function E(a,b){return C().engines[a][b]??null}function F(a,b){let c=C().engines[a];b in c&&(delete c[b],D(C()))}function G(a,b){let c=E(a,b)?.provenance;return c?{...c}:null}function H(a){return{data:a.data,meta:a.provenance,retryAt:a.retryAt??null,consecutive429s:a.consecutive429s??0,consecutiveInitializeTimeouts:a.consecutiveInitializeTimeouts??0}}function I(a,b){return!!a&&(a.retryAt?b<a.retryAt:b-a.at<3e4)}function J(a,b,c,d,e){let g=E(a,b);if(I(g,c))return Promise.resolve(H(g));let i=`${a}:${b}`,j=(A.__llvLimitsInflight||(A.__llvLimitsInflight=new Map),A.__llvLimitsInflight),k=j.get(i);if(k)return k;let m=(async()=>{var g;let i=E(a,b);if(I(i,c))return H(i);let j=await e(),k=d(),m=function(a,b,c,d){let e=a.backoffReason===z||a.reason===z,f=e?(b?.consecutiveInitializeTimeouts??0)+1:0,g=Math.min(6e4*2**Math.max(0,f-1),9e5);if(a.data){let b=e?d+g:null;return{data:a.data,...a.baseData?{baseData:a.baseData}:{},meta:{source:a.source,reason:a.reason,staleSince:a.reason?c:null,retryAt:b?new Date(b).toISOString():null},retryAt:b,consecutive429s:0,consecutiveInitializeTimeouts:f}}let h=a.reason===x.u1?(b?.consecutive429s??0)+1:0,i=Math.max(d+(f>0?g:h>0?Math.min(6e4*2**(h-1),9e5):6e4),a.retryAt??0),j=b?.baseData!==void 0?b.baseData:b?.data??null,k=j?T(j,a.rejectedAt):null;if(k&&U(k,d/1e3))return{data:k,meta:{source:"transcript",reason:a.reason,staleSince:null,retryAt:new Date(i).toISOString()},retryAt:i,consecutive429s:h,consecutiveInitializeTimeouts:f,baseData:j};let l={source:j?"cache":"unavailable",reason:a.reason,staleSince:b?.provenance.staleSince??c,retryAt:new Date(i).toISOString()};return{data:j,meta:l,retryAt:i,consecutive429s:h,consecutiveInitializeTimeouts:f}}(j,i,new Date(k).toISOString(),k);for(let[b,c]of[[a,m.meta]])c.reason&&console.warn(`[limits] ${b} fallback: ${(g=c.reason,(0,l.XR)(g))}`);if(C().engines[a][b]={at:c,data:m.data,baseData:void 0!==m.baseData?m.baseData:m.data,provenance:m.meta,retryAt:m.retryAt,consecutive429s:m.consecutive429s,consecutiveInitializeTimeouts:m.consecutiveInitializeTimeouts},D(C()),m.data&&("live"===m.meta.source||"transcript"===m.meta.source))try{!function(a,b,c,d=Date.now()){let e=Math.round(d/1e3),g=v(),i=!1;for(let d of q){let f=c[d];if(!f||"number"!=typeof f.usedPercent)continue;let h=s(a,b,d),j=g.series[h]??(g.series[h]=[]),k=j[j.length-1];if(k&&e-k.t<300)continue;j.push({t:e,remaining:o(100-f.usedPercent)});let l=e-691200,m=j.filter(a=>a.t>=l);m.length>4e3&&(m=m.slice(m.length-4e3)),g.series[h]=m,i=!0}if(i){g.since||(g.since=new Date(d).toISOString());try{f().mkdirSync(h().dirname(r()),{recursive:!0}),f().writeFileSync(r(),JSON.stringify(g,null,2)+"\n","utf8")}catch(a){console.warn("[limits] failed to persist history",a)}}}(a,b,m.data)}catch(a){console.warn("[limits] failed to record burndown sample",a)}return m})();j.set(i,m);let n=()=>{j.get(i)===m&&j.delete(i)};return m.then(n,n),m}async function K(a={}){let b=a.now??Date.now,c=b(),d=(0,j.ob)(),e=(0,i.O$)(),[f,g]=await Promise.all([J("claude",d.id,c,b,()=>L(h().join(d.home,".credentials.json"),b)),J("codex",e.id,c,b,()=>O({account:e,liveReader:a.codexLiveReader,now:b}))]);return{claude:f.data,codex:g.data,claudeAccountId:d.id,codexAccountId:e.id,provenance:{claude:f.meta,codex:g.meta},staleSince:f.meta.staleSince??g.meta.staleSince}}async function L(a,b=Date.now,c=8e3){let e="",f=null,g=(0,d.TK)(h().dirname(a));if("present"!==g.state)return{data:null,reason:"absent"===g.state?"credentials absent":"credential store unavailable",source:"unavailable"};let i=g.document.claudeAiOauth;if("string"==typeof i?.accessToken&&(e=i.accessToken),"string"==typeof i?.subscriptionType&&(f=i.subscriptionType),!e)return{data:null,reason:"credentials missing access token",source:"unavailable"};try{let a,d,g=await fetch("https://api.anthropic.com/api/oauth/usage",{headers:{authorization:"Bearer "+e,"anthropic-beta":"oauth-2025-04-20"},signal:AbortSignal.timeout(c)});if(429===g.status)return{data:null,reason:x.u1,source:"unavailable",retryAt:function(a,b){if(!a)return;let c=Number(a);if(Number.isFinite(c)&&c>=0)return b+1e3*c;let d=Date.parse(a);if(Number.isFinite(d))return Math.max(b,d)}(g.headers.get("retry-after"),b())};if(401===g.status)return{data:null,reason:x.e4,source:"unavailable"};if(!g.ok)return{data:null,reason:`oauth usage status ${g.status}`,source:"unavailable"};let h=await g.json(),i={session:M(h.five_hour,p.Gn),weekly:M(h.seven_day,p.rX),flagship:(a=h[N],(d=M(a&&"object"==typeof a?a:void 0,p.rX))?{...d,tier:N.slice(10)}:null),plan:f,capturedAt:null};if(!i.session&&!i.weekly)return{data:null,reason:"oauth usage response had no windows",source:"unavailable"};return{data:i,reason:null,source:"live"}}catch(a){return{data:null,reason:`oauth usage fetch failed: ${a instanceof Error?a.message:String(a)}`,source:"unavailable"}}}function M(a,b){if(!a||"number"!=typeof a.utilization)return null;let c="string"==typeof a.resets_at?Date.parse(a.resets_at):NaN;return{usedPercent:a.utilization,resetsAt:Number.isFinite(c)?Math.round(c/1e3):null,windowMinutes:b}}let N="seven_day_opus";async function O(a={}){let b=a.account??(0,i.O$)(),c=a.now??Date.now,d=function(a=(0,i.O$)().sessionsDir){let b=0,c=null,d=null;for(let e of function(a){let b=new Set(function(a){let b=Q(h().join(h().dirname(a),"history.jsonl"),196608);if(!b)return[];let c=[],d=new Set;for(let e of b.split("\n").reverse())if(e.includes('"session_id"'))try{let b=JSON.parse(e);if("string"!=typeof b.session_id||d.has(b.session_id))continue;d.add(b.session_id);let f=function(a,b){let c=/^([0-9a-f]{8})-([0-9a-f]{4})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.exec(b);if(!c)return null;let d=Number.parseInt(c[1]+c[2],16);if(!Number.isFinite(d))return null;let e=new Date(d);return Number.isNaN(e.getTime())?null:h().join(a,String(e.getFullYear()),String(e.getMonth()+1).padStart(2,"0"),String(e.getDate()).padStart(2,"0"))}(a,b.session_id);if(!f)continue;let g=P(f).find(a=>a.endsWith(`${b.session_id}.jsonl`));if(g&&c.push(h().join(f,g)),d.size>=12)break}catch{}return c}(a));for(let c of function(a){let b=[];for(let c of P(a))for(let d of P(h().join(a,c)))for(let e of P(h().join(a,c,d)))if(b.push(h().join(a,c,d,e)),b.length>=8)return b;return b}(a))for(let a of P(c).filter(a=>a.endsWith(".jsonl")).slice(0,12))b.add(h().join(c,a));let c=[];for(let a of b)try{c.push({p:a,m:f().statSync(a).mtimeMs})}catch{}return c.sort((a,b)=>b.m-a.m||b.p.localeCompare(a.p)).slice(0,12).map(a=>a.p)}(a)){b+=1;let a=function(a){let b=Q(a,196608);if(!b)return{data:null,rejectedAt:null};let c=b.split("\n"),d=null,e=null;for(let a=c.length-1;a>=0;a--){let b=c[a];if(b.includes('"rate_limits"')||b.includes('"usage_limit'))try{let a=JSON.parse(b),c="string"==typeof a.timestamp?Date.parse(a.timestamp):NaN,f=Number.isFinite(c)?c/1e3:null;if(R(a.payload?.codex_error_info)||R(a.payload?.error?.codex_error_info)){null!==f&&(null===e||f>e)&&(e=f);continue}let g=a.payload?.rate_limits;if(!g)continue;let h=(0,p.v9)(V(g.primary,f),V(g.secondary,f),f);if(!h.session&&!h.weekly)continue;(!d||null===d.capturedAt||null!==f&&f>d.capturedAt)&&(d={session:h.session,weekly:h.weekly,plan:"string"==typeof g.plan_type?g.plan_type:null,capturedAt:f})}catch{}}return{data:d,rejectedAt:e}}(e);null!==a.rejectedAt&&(null===d||a.rejectedAt>d)&&(d=a.rejectedAt),a.data&&(!c||null===c.capturedAt||null!==a.data.capturedAt&&a.data.capturedAt>c.capturedAt)&&(c=a.data)}if(c){let a=null!==d&&(null===c.capturedAt||d>=c.capturedAt)?d:null;return{data:c,reason:null,source:"transcript",rejectedAt:a}}return null!==d?{data:null,reason:"usage-limit-exceeded",source:"transcript",rejectedAt:d}:{data:null,reason:0===b?"no codex session files":`no rate_limits event in newest ${b} session files`,source:"unavailable"}}(b.sessionsDir);try{let e=await (a.liveReader??(a=>(0,k.VD)().readRateLimits(a)))(b),f=c()/1e3,g=function(a,b=Math.round(Date.now()/1e3)){let c=a=>a?{usedPercent:a.usedPercent,resetsAt:a.resetsAt,windowMinutes:a.windowDurationMins}:null,d=(0,p.v9)(c(a.primary),c(a.secondary),b);return{session:d.session,weekly:d.weekly,plan:a.planType,capturedAt:b}}(e,f),h=d.data?T(d.data,d.rejectedAt):null,i=h&&d.data?S(d.data)?.value.resetsAt:null,j=S(g)?.value.resetsAt,l="number"==typeof d.rejectedAt&&"number"==typeof i&&d.rejectedAt<i&&"number"==typeof j&&j>i?null:h??T(g,d.rejectedAt),m=l??d.data;if(!m)return{data:g,reason:null,source:"live"};let n=a=>(0,w.I1)({limits:g,observedAt:g.capturedAt,stale:!1,source:"live"},{limits:a,observedAt:a.capturedAt,stale:!1,source:"transcript"},f),o=n(m),q=(0,w.ap)(o,"transcript"),r=l?d.data?(0,w.L1)(n(d.data)):g:null;return{data:(0,w.L1)(o),...r?{baseData:r}:{},reason:q?"transcript-reconciled":null,source:q?"transcript":"live"}}catch(f){let a=(0,l.XR)(f instanceof Error?f.message:String(f)),e=/request timed out:\s*initialize\b/i.test(a);if(console.warn(`[limits] Codex app-server probe for ${b.id} failed: ${a}`),d.data){let a=T(d.data,d.rejectedAt),b=a&&U(a,c()/1e3)?a:d.data;return{data:b,...b===a?{baseData:d.data}:{},reason:"transcript-fallback",source:"transcript",...e?{backoffReason:z}:{}}}if(null!==d.rejectedAt&&void 0!==d.rejectedAt)return{...d,...e?{backoffReason:z}:{}};return{data:null,reason:e?z:"app-server-unavailable",source:"unavailable"}}}function P(a){try{return f().readdirSync(a).sort().reverse()}catch{return[]}}function Q(a,b){let c;try{c=f().openSync(a,"r")}catch{return null}try{let a=f().fstatSync(c).size,d=Math.min(a,b),e=Buffer.alloc(d);return f().readSync(c,e,0,d,a-d),e.toString("utf8")}catch{return null}finally{f().closeSync(c)}}function R(a){return"usage_limit"===a||"usage_limit_exceeded"===a}function S(a){return["session","weekly"].flatMap(b=>a[b]?[{key:b,value:a[b]}]:[]).sort((a,b)=>b.value.usedPercent-a.value.usedPercent||a.key.localeCompare(b.key))[0]??null}function T(a,b){return null==b||!function(a,b){let c=S(a)?.value;if(!c)return!1;if(null===c.resetsAt)return!0;if("number"!=typeof c.windowMinutes)return b<=c.resetsAt;let d=60*c.windowMinutes;return b>=c.resetsAt-d&&b<c.resetsAt+d}(a,b)?null:function(a,b){let c=S(a);if(!c)return a;let d=null!==c.value.resetsAt&&c.value.resetsAt<=b?null:c.value.resetsAt,e={...a,[c.key]:{...c.value,usedPercent:100,resetsAt:d,observedAt:b,source:"transcript"}},f=[e.session?.observedAt,e.weekly?.observedAt].filter(a=>null!=a);return{...e,capturedAt:f.length?Math.min(...f):b}}(a,b)}function U(a,b){let c=S(a);if(!c||c.value.usedPercent<100)return!1;let d=c.value;if(null!==d.resetsAt)return d.resetsAt>b;if(null===d.observedAt||void 0===d.observedAt)return!0;let e="number"==typeof d.windowMinutes?d.windowMinutes:"weekly"===c.key?p.rX:p.Gn;return b-d.observedAt<60*e}function V(a,b){if(!a||"number"!=typeof a.used_percent)return null;let c=null;return"number"==typeof a.resets_at?c=a.resets_at:"number"==typeof a.resets_in_seconds&&null!==b&&(c=b+a.resets_in_seconds),{usedPercent:a.used_percent,resetsAt:c,windowMinutes:"number"==typeof a.window_minutes?a.window_minutes:null,observedAt:b}}function W(a){return a&&"number"==typeof a.windowMinutes&&a.windowMinutes>0?Math.round(60*a.windowMinutes):null}function X(a,b,c,d,e){let f=!!(c?.session||c?.weekly),g=(e,g,h,i)=>{var j;let k,l,m,p,q=c?.[e]??null,r=W(q)??h??n[e];return f&&!q&&0===g.length?{windowStart:null,resetsAt:null,windowSeconds:r,samples:[],windowUnreported:!0}:(j=function(a,b,c,d=Math.round(Date.now()/1e3)){let e=v().series[s(a,b,c)]??[],f=d-691200;return e.filter(a=>a.t>=f)}(a,b,e,d),l=null!==(k=q?.resetsAt??i??null)?k-r:null,m=function(...a){let b=new Map;for(let c of a)for(let a of c)Number.isFinite(a.t)&&Number.isFinite(a.remaining)&&b.set(a.t,o(a.remaining));return[...b.entries()].map(([a,b])=>({t:a,remaining:b})).sort((a,b)=>a.t-b.t)}(j,g,q&&"number"==typeof q.usedPercent?[{t:d,remaining:o(100-q.usedPercent)}]:[]),p=null!==l?m.filter(a=>a.t>=l):m,{windowStart:l,resetsAt:k,windowSeconds:r,samples:p})};return{session:g("session",e?.session??[],e?.sessionWindowSeconds??null,e?.sessionResetsAt??null),weekly:g("weekly",e?.weekly??[],e?.weeklyWindowSeconds??null,e?.weeklyResetsAt??null)}}async function Y(a={}){let b=await K(a),c=Math.round(Date.now()/1e3),d=b.claudeAccountId?X("claude",b.claudeAccountId,b.claude,c,null):null,e=null;if(b.codexAccountId){let a=function(a,b){let c=[],d=[],e=new Set,g=-1/0,i=null,j=null,k=null,l=null;for(let{p:m,m:n}of function*(a){let b=0;for(let c of P(a))for(let d of P(h().join(a,c)))for(let e of P(h().join(a,c,d))){let g=h().join(a,c,d,e),i=[];for(let a of P(g)){if(!a.endsWith(".jsonl"))continue;let b=h().join(g,a);try{i.push({p:b,m:f().statSync(b).mtimeMs})}catch{}}for(let a of(i.sort((a,b)=>b.m-a.m),i))if(yield a,++b>=400)return}}(a)){if(n/1e3<b)continue;let a=function(a){try{if(f().statSync(a).size>8388608)return Q(a,8388608);return f().readFileSync(a,"utf8")}catch{return Q(a,8388608)}}(m);if(a){for(let f of a.split("\n"))if(f.includes('"rate_limits"'))try{let a=JSON.parse(f),h=a.payload?.rate_limits;if(!h)continue;let m="string"==typeof a.timestamp?Date.parse(a.timestamp):NaN;if(!Number.isFinite(m))continue;let n=Math.round(m/1e3);if(n<b||e.has(n))continue;let q=(0,p.v9)(V(h.primary,n),V(h.secondary,n),n);if(!q.session&&!q.weekly)continue;e.add(n),q.session&&c.push({t:n,remaining:o(100-q.session.usedPercent)}),q.weekly&&d.push({t:n,remaining:o(100-q.weekly.usedPercent)}),n>g&&(g=n,q.session&&(k=q.session.resetsAt,i=W(q.session)),q.weekly&&(l=q.weekly.resetsAt,j=W(q.weekly)))}catch{}}}return c.sort((a,b)=>a.t-b.t),d.sort((a,b)=>a.t-b.t),{session:c,weekly:d,sessionWindowSeconds:i,weeklyWindowSeconds:j,sessionResetsAt:k,weeklyResetsAt:l}}((0,i.O$)().sessionsDir,c-691200);e=X("codex",b.codexAccountId,b.codex,c,a)}return{claude:d,codex:e,claudeAccountId:b.claudeAccountId,codexAccountId:b.codexAccountId,historySince:v().since}}},97609:(a,b,c)=>{c.d(b,{Gn:()=>d,Zc:()=>h,rX:()=>e,v9:()=>g});let d=300,e=10080;function f(a,b){return null==a.windowMinutes&&null!==b&&null!=a.resetsAt&&a.resetsAt-b>60*d+1800}function g(a,b,c=null){let d={session:null,weekly:null},e=[];for(let[c,f]of[["session",a],["weekly",b]]){var h;if(!f)continue;let a="number"!=typeof(h=f.windowMinutes)||!Number.isFinite(h)||h<=0?null:h<=1440?"session":"weekly";a&&!d[a]?d[a]=f:e.push({slot:c,window:f})}for(let{slot:a,window:b}of e){let e="session"===a&&f(b,c)?"weekly":a;d[e]||(d[e]=b)}return d}function h(a){return a?.session&&!a.weekly&&f(a.session,a.capturedAt)?{...a,session:null,weekly:a.session}:a}}};
1
+ "use strict";exports.id=8996,exports.ids=[8996],exports.modules={8960:(a,b,c)=>{c.d(b,{I1:()=>m,L1:()=>n,MJ:()=>p,Om:()=>q,ap:()=>o});var d=c(4837),e=c(9735),f=c(97609),g=c(41085),h=c(30096);function i(a,b,c){return j(a,a.limits?.[b]??null,c)}function j(a,b,c){if(!b)return null;let d=b.observedAt??a.observedAt;return{value:b,observedAt:d,stale:a.stale||null!==d&&c-d>1200,source:b.source??a.source}}function k(a,b,c,d){var e;let g;if(a.value.usedPercent<100)return!1;if(null!==a.value.resetsAt)return a.value.resetsAt>d;if(null===a.observedAt)return!0;let h="number"==typeof a.value.windowMinutes?a.value.windowMinutes:"weekly"===c?f.rX:f.Gn;return!(d-a.observedAt>=60*h)&&(e=a.observedAt,!(g=b?.value)||null===g.resetsAt||"number"!=typeof g.windowMinutes||!(g.resetsAt-60*g.windowMinutes>e))}function l(a,b,c,d){if(!a)return b;if(!b)return a;let e=k(a,b,c,d);return e!==k(b,a,c,d)?e?a:b:null===a.observedAt?null===b.observedAt?a:b:null===b.observedAt?a:b.observedAt>a.observedAt?b:a}function m(a,b,c){let e=l(a?i(a,"session",c):null,b?i(b,"session",c):null,"session",c),f=l(a?i(a,"weekly",c):null,b?i(b,"weekly",c):null,"weekly",c),g=[...new Set([a,b].flatMap(a=>(0,h.dZ)(a?.limits).map(a=>a.tier)))].sort().flatMap(d=>{let e=a=>{let b=(0,h.dZ)(a?.limits).find(a=>a.tier===d)??null;return a&&b?j(a,b,c):null},f=l(e(a),e(b),"weekly",c);return f&&"string"==typeof f.value.tier?[f]:[]}).sort((a,b)=>(0,d.aE)(a.value.tier,a.value.label).localeCompare((0,d.aE)(b.value.tier,b.value.label))),k=[a,b].filter(a=>!!a?.limits?.plan).sort((a,b)=>(b.observedAt??-1/0)-(a.observedAt??-1/0));return{session:e,weekly:f,tiers:g,plan:k[0]?.limits?.plan??null}}function n(a){if(!a.session&&!a.weekly&&!a.tiers.length)return null;let b=[a.session?.observedAt,a.weekly?.observedAt,...a.tiers.map(a=>a.observedAt)].filter(a=>null!=a);return{session:a.session?{...a.session.value,observedAt:a.session.observedAt,source:a.session.source}:null,weekly:a.weekly?{...a.weekly.value,observedAt:a.weekly.observedAt,source:a.weekly.source}:null,tiers:a.tiers.map(a=>({...a.value,observedAt:a.observedAt,source:a.source})),plan:a.plan,capturedAt:b.length?Math.min(...b):null}}function o(a,b){return a.session?.source===b||a.weekly?.source===b||a.tiers.some(a=>a.source===b)}function p(a,b=Date.now(),c){if(!a)return null;let d=Date.parse(a.observedAt),f=Date.parse(a.authCheckedAt),g=(0,e.Wz)({engine:a.engine,accountId:a.accountId,authenticated:a.authenticated,limits:a.limits,provenance:a.provenance,observedAt:d,authCheckedAt:f},b,{model:c});if(g?.percent!==0||!a.limits)return null;let h=(0,e.cQ)(a.engine,a.limits,c).flatMap(({window:a,value:b})=>b&&b.usedPercent>=100?[{window:"session"===a?"session":"weekly",resetAt:b.resetsAt}]:[]);if(!h.length)return null;let i=h.filter(a=>null===a.resetAt||1e3*a.resetAt>b);if(!i.length)return null;let j=i.find(a=>null===a.resetAt)??i.sort((a,b)=>b.resetAt-a.resetAt)[0];return{source:"account",accountId:a.accountId,window:j.window,resetAt:null!==j.resetAt&&1e3*j.resetAt>b?j.resetAt:null}}function q(a,b,c,d=Date.now(),e=()=>null,f=()=>!1){let h=new Map;for(let a of Object.values(c.conversations))for(let b of a.generations)h.set(b.path,{conversationId:a.id,engine:a.engine,accountId:b.accountId});let i=new Map;for(let a of Object.values(c.entries??{})){let b=h.get(a.artifactPath);b&&a.accountId&&["starting","live","idle","handoff"].includes(a.status)&&f(a)&&i.set(a.artifactPath,{engine:b.engine,accountId:a.accountId})}let j={claude:new Map,codex:new Map},k=a.map(a=>{var b,f,k;let l,m=h.get(a.path),n=i.get(a.path),o=n?.accountId??m?.accountId??null,q=n?.engine??m?.engine,r=q&&o?c.quotaObservations[q][o]:void 0,s=n&&a.authoritativeTurn?.state==="busy"?(b=n.engine,f=n.accountId,(l=j[b]).has(f)||l.set(f,(0,g.pG)(e(b,f),d)),l.get(f)??null):null,t=n||"running"===a.proc?p(r,d,a.model):null,u=(k=a.rateLimit,k?{source:"pane",accountId:o??k.accountId,window:t?.window??k.window,resetAt:t?.resetAt??k.resetAt}:t),v={...a};return delete v.providerThrottle,{...v,conversationId:a.conversationId??m?.conversationId,rateLimit:u,...s?{providerThrottle:s}:{}}}),l=new Map(k.map(a=>[a.path,a])),m=new Set(["waiting_ready","relaying","fixing"]);return{files:k,flows:b.map(a=>{let b=l.get(a.implementerPath),c=b?.conversationId??a.implementerConversationId??null,d="relaying"===a.state?a.rounds.at(-1)?.relayHold:null;if(d){let b=Date.parse(d.until),e=Number.isFinite(b)?Math.floor(b/1e3):null,f=!1!==d.resetKnown;return{...a,block:{reason:"rate_limited",conversationId:c,accountId:d.accountId,resetAt:f?e:null,...f?{}:{recheckAt:e}}}}let e=b?.rateLimit;return e&&m.has(a.state)?{...a,block:{reason:"rate_limited",conversationId:c,accountId:e.accountId,resetAt:e.resetAt}}:a.block?{...a,block:null}:a})}}},41085:(a,b,c)=>{c.d(b,{B4:()=>i,Lm:()=>e,p5:()=>g,pG:()=>h});var d=c(30096);let e=6e4;function f(a){if(a?.reason!==d.u1||!a.retryAt)return null;let b=Date.parse(a.retryAt);return Number.isFinite(b)?b:null}function g(a,b=Date.now(),c=e){let d=f(a);return null===d||b>d+(Number.isFinite(c)?Math.max(0,c):e)?null:new Date(d).toISOString()}function h(a,b=Date.now(),c=e){let d=g(a,b,c);return d?{reason:"provider_throttled",retryAt:d}:null}function i(a,b=Date.now()){let c=f(a);return null===c||b>=c?null:{reason:"provider_throttled",retryAt:new Date(c).toISOString()}}},58996:(a,b,c)=>{c.d(b,{Nj:()=>Q,io:()=>I,nn:()=>R,wW:()=>H,Ke:()=>ai,WB:()=>P,Ki:()=>$,BU:()=>N});var d=c(63006),e=c(4837),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(41617),k=c(78966),l=c(68797),m=c(3253),n=c(91724);let o={session:18e3,weekly:604800};function p(a){return Math.max(0,Math.min(100,a))}var q=c(97609);let r=["session","weekly"];function s(){return(0,n.BQ)("limits-history.json")}function t(a,b,c){return`${a}|${b}|${c}`}function u(){return{version:1,since:null,series:{}}}function v(a){return!!a&&"object"==typeof a&&"number"==typeof a.t&&Number.isFinite(a.t)&&"number"==typeof a.remaining&&Number.isFinite(a.remaining)}function w(){try{let a=JSON.parse(g().readFileSync(s(),"utf8"));if(1!==a.version||!a.series||"object"!=typeof a.series)return u();let b={};for(let[c,d]of Object.entries(a.series))Array.isArray(d)&&(b[c]=d.filter(v));return{version:1,since:"string"==typeof a.since?a.since:null,series:b}}catch{return u()}}var x=c(8960),y=c(30096);function z(){return(0,n.BQ)("limits-cache.json")}let A="app-server-initialize-timeout",B=globalThis;function C(){return{version:2,engines:{claude:{},codex:{}}}}function D(){try{return g().statSync(z()).mtimeMs}catch{return -1}}function E(){let a=B.__llvLimitsCache,b=B.__llvLimitsCacheDisk;if(a&&(b?.of!==a||b.mtimeMs===D()))return a;let c=function(){try{let a=JSON.parse(g().readFileSync(z(),"utf8"));if(2===a.version&&a.engines&&"object"==typeof a.engines){let b=C();for(let c of["claude","codex"]){let d=a.engines[c];if(d&&"object"==typeof d)for(let[a,e]of Object.entries(d)){let d=function(a){if(!a||"object"!=typeof a||"number"!=typeof a.at||void 0===a.data||!a.provenance)return null;let b=a.provenance;if("live"!==b.source&&"transcript"!==b.source&&"cache"!==b.source&&"unavailable"!==b.source||"string"!=typeof b.reason&&null!==b.reason||"string"!=typeof b.staleSince&&null!==b.staleSince||void 0!==b.retryAt&&"string"!=typeof b.retryAt&&null!==b.retryAt||void 0!==a.baseData&&null!==a.baseData&&"object"!=typeof a.baseData||void 0!==a.retryAt&&null!==a.retryAt&&"number"!=typeof a.retryAt||void 0!==a.consecutive429s&&(!Number.isInteger(a.consecutive429s)||a.consecutive429s<0)||void 0!==a.consecutiveInitializeTimeouts&&(!Number.isInteger(a.consecutiveInitializeTimeouts)||a.consecutiveInitializeTimeouts<0)||void 0!==a.parser&&!Number.isInteger(a.parser))return null;let c=a=>a?{...a,tiers:(0,y.dZ)(a)}:a;return{...a,data:c(a.data),...void 0===a.baseData?{}:{baseData:c(a.baseData)}}}(e);d&&(b.engines[c][a]="codex"===c?{...d,data:(0,q.Zc)(d.data),...void 0===d.baseData?{}:{baseData:(0,q.Zc)(d.baseData)}}:2===d.parser?d:{...d,at:0,retryAt:null,consecutive429s:0,parser:2})}}return b}if("number"==typeof a.at&&"string"==typeof a.accountId&&a.data?.codex){let b=!function(a){if(!a||"object"!=typeof a)return!1;let b=a=>!!a&&("live"===a.source||"transcript"===a.source||"cache"===a.source||"unavailable"===a.source)&&("string"==typeof a.reason||null===a.reason)&&("string"==typeof a.staleSince||null===a.staleSince)&&(void 0===a.retryAt||"string"==typeof a.retryAt||null===a.retryAt);return b(a.claude)&&b(a.codex)}(a.data.provenance)?{source:"cache",reason:"legacy cache provenance unavailable",staleSince:a.data.staleSince??null}:a.data.provenance.codex;return{version:2,engines:{claude:{},codex:{[a.accountId]:{at:a.at,data:(0,q.Zc)(a.data.codex),provenance:b}}}}}}catch{}return C()}();return B.__llvLimitsCache=c,B.__llvLimitsCacheDisk={of:c,mtimeMs:D()},c}function F(a){try{g().mkdirSync(i().dirname(z()),{recursive:!0});let b=b=>Object.entries(a.engines[b]).sort(([,a],[,b])=>b.at-a.at)[0]??null,c=b("claude"),d=b("codex"),e=d?{at:d[1].at,accountId:d[0],data:{claude:c?.[1].data??null,codex:d[1].data,claudeAccountId:c?.[0]??null,codexAccountId:d[0],provenance:{claude:c?.[1].provenance??{source:"unavailable",reason:"no cached Claude limits",staleSince:null},codex:d[1].provenance},staleSince:c?.[1].provenance.staleSince??d[1].provenance.staleSince}}:{},f=`${z()}.${process.pid}.tmp`;g().writeFileSync(f,JSON.stringify({...a,...e},null,2)+"\n","utf8"),g().renameSync(f,z()),(B.__llvLimitsCacheDisk?.of===a||B.__llvLimitsCache===a)&&(B.__llvLimitsCacheDisk={of:a,mtimeMs:D()})}catch(a){console.warn("[limits] failed to persist cache",a)}}function G(a,b){return E().engines[a][b]??null}function H(a,b){let c=E().engines[a];b in c&&(delete c[b],F(E()))}function I(a,b){let c=G(a,b)?.provenance;return c?{...c}:null}function J(a){if(!a.data)return null;if(void 0!==a.observedAt)return a.observedAt;let b=a.provenance.staleSince?Date.parse(a.provenance.staleSince):NaN;return"cache"===a.provenance.source&&Number.isFinite(b)?b:a.at}function K(a){return{data:a.data,observedAt:J(a),meta:a.provenance,retryAt:a.retryAt??null,consecutive429s:a.consecutive429s??0,consecutiveInitializeTimeouts:a.consecutiveInitializeTimeouts??0}}function L(a,b,c){return!!a&&(a.retryAt?b<a.retryAt:b-a.at<c)}function M(a,b,c,d,e,f={}){let h=f.windowMs??3e4,j=G(a,b);if(!f.force&&L(j,c,h))return Promise.resolve(K(j));let k=`${a}:${b}`,l=(B.__llvLimitsInflight||(B.__llvLimitsInflight=new Map),B.__llvLimitsInflight),n=l.get(k);if(n)return n;let o=(async()=>{var j;let k=G(a,b);if(!f.force&&L(k,c,h))return K(k);let l=await e(),n=d(),o=function(a,b,c,d){let e=a.backoffReason===A||a.reason===A,f=e?(b?.consecutiveInitializeTimeouts??0)+1:0,g=Math.min(6e4*2**Math.max(0,f-1),9e5);if(a.data){let b=e?d+g:null;return{data:a.data,observedAt:d,...a.baseData?{baseData:a.baseData}:{},meta:{source:a.source,reason:a.reason,staleSince:a.reason?c:null,retryAt:b?new Date(b).toISOString():null},retryAt:b,consecutive429s:0,consecutiveInitializeTimeouts:f}}let h=a.reason===y.u1?(b?.consecutive429s??0)+1:0,i=Math.max(d+(f>0?g:h>0?Math.min(6e4*2**(h-1),9e5):6e4),a.retryAt??0),j=b?.baseData!==void 0?b.baseData:b?.data??null,k=j?ad(j,a.rejectedAt):null;if(k&&ae(k,d/1e3))return{data:k,observedAt:b?J(b):null,meta:{source:"transcript",reason:a.reason,staleSince:null,retryAt:new Date(i).toISOString()},retryAt:i,consecutive429s:h,consecutiveInitializeTimeouts:f,baseData:j};let l={source:j?"cache":"unavailable",reason:a.reason,staleSince:b?.provenance.staleSince??c,retryAt:new Date(i).toISOString()};return{data:j,observedAt:j&&b?J(b):null,meta:l,retryAt:i,consecutive429s:h,consecutiveInitializeTimeouts:f}}(l,k,new Date(n).toISOString(),n);for(let[b,c]of[[a,o.meta]])c.reason&&console.warn(`[limits] ${b} fallback: ${(j=c.reason,(0,m.XR)(j))}`);if(E().engines[a][b]={at:c,data:o.data,baseData:void 0!==o.baseData?o.baseData:o.data,provenance:o.meta,retryAt:o.retryAt,consecutive429s:o.consecutive429s,consecutiveInitializeTimeouts:o.consecutiveInitializeTimeouts,..."claude"===a?{parser:2}:{},...null!==o.observedAt?{observedAt:o.observedAt}:{}},F(E()),o.data&&("live"===o.meta.source||"transcript"===o.meta.source))try{!function(a,b,c,d=Date.now()){let e=Math.round(d/1e3),f=w(),h=!1;for(let d of r){let g=c[d];if(!g||"number"!=typeof g.usedPercent)continue;let i=t(a,b,d),j=f.series[i]??(f.series[i]=[]),k=j[j.length-1];if(k&&e-k.t<300)continue;j.push({t:e,remaining:p(100-g.usedPercent)});let l=e-691200,m=j.filter(a=>a.t>=l);m.length>4e3&&(m=m.slice(m.length-4e3)),f.series[i]=m,h=!0}if(h){f.since||(f.since=new Date(d).toISOString());try{g().mkdirSync(i().dirname(s()),{recursive:!0});let a=`${s()}.${process.pid}.tmp`;g().writeFileSync(a,JSON.stringify(f,null,2)+"\n","utf8"),g().renameSync(a,s())}catch(a){console.warn("[limits] failed to persist history",a)}}}(a,b,o.data)}catch(a){console.warn("[limits] failed to record burndown sample",a)}return o})();l.set(k,o);let q=()=>{l.get(k)===o&&l.delete(k)};return o.then(q,q),o}async function N(a={}){let b=a.now??Date.now,c=b(),d=(0,k.ob)(),e=(0,j.O$)(),[f,g]=await Promise.all([O(d,c,b),M("codex",e.id,c,b,()=>$({account:e,liveReader:a.codexLiveReader,now:b}))]);return{claude:f.data,codex:g.data,claudeAccountId:d.id,codexAccountId:e.id,provenance:{claude:f.meta,codex:g.meta},staleSince:f.meta.staleSince??g.meta.staleSince}}function O(a,b,c,d=!1){return M("claude",a.id,b,c,()=>R(i().join(a.home,".credentials.json"),c),{windowMs:5e4,force:d})}async function P(a,b={}){let c=b.now??Date.now,d=await O(a,c(),c,b.force);return{data:d.data,provenance:d.meta,observedAt:d.observedAt}}function Q(a,b,c,d=Date.now()){let e=G("claude",a),f=e?J(e):null;if(!Number.isFinite(c)||null!==f&&f>=c)return!1;let g=!!(e?.retryAt&&d<e.retryAt);return E().engines.claude[a]={at:c,data:b,baseData:b,provenance:g?{source:"cache",reason:e.provenance.reason,staleSince:new Date(c).toISOString(),retryAt:e.provenance.retryAt??null}:{source:"live",reason:null,staleSince:null,retryAt:null},retryAt:g?e.retryAt:null,consecutive429s:g?e.consecutive429s??0:0,consecutiveInitializeTimeouts:0,parser:2,observedAt:c},F(E()),!0}async function R(a,b=Date.now,c=8e3){let f="",g=null,h=(0,d.TK)(i().dirname(a));if("present"!==h.state)return{data:null,reason:"absent"===h.state?"credentials absent":"credential store unavailable",source:"unavailable"};let j=h.document.claudeAiOauth;if("string"==typeof j?.accessToken&&(f=j.accessToken),"string"==typeof j?.subscriptionType&&(g=j.subscriptionType),!f)return{data:null,reason:"credentials missing access token",source:"unavailable"};try{let a=await fetch("https://api.anthropic.com/api/oauth/usage",{headers:{authorization:"Bearer "+f,"anthropic-beta":"oauth-2025-04-20"},signal:AbortSignal.timeout(c)});if(429===a.status)return{data:null,reason:y.u1,source:"unavailable",retryAt:function(a,b){if(!a)return;let c=Number(a);if(Number.isFinite(c)&&c>=0)return b+1e3*c;let d=Date.parse(a);if(Number.isFinite(d))return Math.max(b,d)}(a.headers.get("retry-after"),b())};if(401===a.status)return{data:null,reason:y.e4,source:"unavailable"};if(!a.ok)return{data:null,reason:`oauth usage status ${a.status}`,source:"unavailable"};let d=await a.json(),h={session:S(d.five_hour,q.Gn),weekly:S(d.seven_day,q.rX),tiers:function(a){let b=new Map,c=new Map;for(let d of Object.keys(a)){if(U.has(d)||W(d))continue;let e=a[d],f=S(e&&"object"==typeof e?e:void 0,q.rX);if(!f)continue;let g=d.startsWith(T)?d.slice(T.length):d;g&&(b.set(g,{...f,tier:g}),c.set(d,g))}let d=new Set([...c.keys(),...c.values()]),f=new Map;for(let g of Array.isArray(a.limits)?a.limits:[]){let a=function(a,b){let c=Z(a);if(!c)return null;let d=(function a(b,c=0){return"string"==typeof b?[b]:c>=3||!b||"object"!=typeof b?[]:(Array.isArray(b)?b:Object.values(b)).flatMap(b=>a(b,c+1))})(c).map(a=>a.trim()).filter(a=>Y.test(a));if(d.some(a=>U.has(a)||W(a)))return null;let f=[...new Set(d.filter(a=>b.has(a)))],g=Z(c.scope),h=Z(g?.model),i=function(a,b){for(let c of a)if(c)for(let a of X){let d=c[a];if("string"!=typeof d)continue;let e=d.trim();if(e&&!b.has(e)&&!Y.test(e))return e}return null}([h,c],b),j=[...[h?.id,h?.display_name,g?.model,c.model,c.model_id].filter(a=>"string"==typeof a),...i?i.split(/[\s,/|()\[\]]+/):[]].map(a=>(0,e.OV)(a)).find(a=>null!==a)??null;return f.length||j?{buckets:f,family:j,label:i,window:function(a){let b="number"==typeof a.percent?a.percent:"number"==typeof a.utilization?a.utilization:null;if(null===b||!Number.isFinite(b))return null;let c="string"==typeof a.resets_at?Date.parse(a.resets_at):NaN,d=[a.group,a.kind].some(a=>"string"==typeof a&&a.startsWith("session"));return{usedPercent:b,resetsAt:Number.isFinite(c)?Math.round(c/1e3):null,windowMinutes:d?q.Gn:q.rX}}(c)}:null}(g,d);if(!a)continue;let h=a.buckets.map(a=>c.get(a)??a).find(a=>b.has(a))??null,i=a.window??(h?b.get(h):null),j=a.family??h;if(!i||!j)continue;let k={usedPercent:i.usedPercent,resetsAt:i.resetsAt,windowMinutes:i.windowMinutes,tier:j,...a.label?{label:a.label}:{}},l=f.get(j);(!l||k.usedPercent>l.usedPercent)&&f.set(j,k)}return(f.size?[...f.values()]:[...b.values()]).sort((a,b)=>(0,e.aE)(a.tier,a.label).localeCompare((0,e.aE)(b.tier,b.label)))}(d),plan:g,capturedAt:null};if(!h.session&&!h.weekly)return{data:null,reason:"oauth usage response had no windows",source:"unavailable"};return{data:h,reason:null,source:"live"}}catch(a){return{data:null,reason:`oauth usage fetch failed: ${a instanceof Error?a.message:String(a)}`,source:"unavailable"}}}function S(a,b){if(!a||"number"!=typeof a.utilization)return null;let c="string"==typeof a.resets_at?Date.parse(a.resets_at):NaN;return{usedPercent:a.utilization,resetsAt:Number.isFinite(c)?Math.round(c/1e3):null,windowMinutes:b}}let T="seven_day_",U=new Set(["five_hour","seven_day"]),V=["overage","oauth_apps","cowork","omelette","extra_usage","spend","breakdown"];function W(a){return V.some(b=>a.includes(b))}let X=["display_name","displayName","label","title","name"],Y=/^[a-z0-9_.:-]+$/;function Z(a){return a&&"object"==typeof a&&!Array.isArray(a)?a:null}async function $(a={}){let b=a.account??(0,j.O$)(),c=a.now??Date.now,d=function(a=(0,j.O$)().sessionsDir){let b=0,c=null,d=null;for(let e of function(a){let b=new Set(function(a){let b=aa(i().join(i().dirname(a),"history.jsonl"),196608);if(!b)return[];let c=[],d=new Set;for(let e of b.split("\n").reverse())if(e.includes('"session_id"'))try{let b=JSON.parse(e);if("string"!=typeof b.session_id||d.has(b.session_id))continue;d.add(b.session_id);let f=function(a,b){let c=/^([0-9a-f]{8})-([0-9a-f]{4})-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.exec(b);if(!c)return null;let d=Number.parseInt(c[1]+c[2],16);if(!Number.isFinite(d))return null;let e=new Date(d);return Number.isNaN(e.getTime())?null:i().join(a,String(e.getFullYear()),String(e.getMonth()+1).padStart(2,"0"),String(e.getDate()).padStart(2,"0"))}(a,b.session_id);if(!f)continue;let g=_(f).find(a=>a.endsWith(`${b.session_id}.jsonl`));if(g&&c.push(i().join(f,g)),d.size>=12)break}catch{}return c}(a));for(let c of function(a){let b=[];for(let c of _(a))for(let d of _(i().join(a,c)))for(let e of _(i().join(a,c,d)))if(b.push(i().join(a,c,d,e)),b.length>=8)return b;return b}(a))for(let a of _(c).filter(a=>a.endsWith(".jsonl")).slice(0,12))b.add(i().join(c,a));let c=[];for(let a of b)try{c.push({p:a,m:g().statSync(a).mtimeMs})}catch{}return c.sort((a,b)=>b.m-a.m||b.p.localeCompare(a.p)).slice(0,12).map(a=>a.p)}(a)){b+=1;let a=function(a){let b=aa(a,196608);if(!b)return{data:null,rejectedAt:null};let c=b.split("\n"),d=null,e=null;for(let a=c.length-1;a>=0;a--){let b=c[a];if(b.includes('"rate_limits"')||b.includes('"usage_limit'))try{let a=JSON.parse(b),c="string"==typeof a.timestamp?Date.parse(a.timestamp):NaN,f=Number.isFinite(c)?c/1e3:null;if(ab(a.payload?.codex_error_info)||ab(a.payload?.error?.codex_error_info)){null!==f&&(null===e||f>e)&&(e=f);continue}let g=a.payload?.rate_limits;if(!g)continue;let h=(0,q.v9)(af(g.primary,f),af(g.secondary,f),f);if(!h.session&&!h.weekly)continue;(!d||null===d.capturedAt||null!==f&&f>d.capturedAt)&&(d={session:h.session,weekly:h.weekly,plan:"string"==typeof g.plan_type?g.plan_type:null,capturedAt:f})}catch{}}return{data:d,rejectedAt:e}}(e);null!==a.rejectedAt&&(null===d||a.rejectedAt>d)&&(d=a.rejectedAt),a.data&&(!c||null===c.capturedAt||null!==a.data.capturedAt&&a.data.capturedAt>c.capturedAt)&&(c=a.data)}if(c){let a=null!==d&&(null===c.capturedAt||d>=c.capturedAt)?d:null;return{data:c,reason:null,source:"transcript",rejectedAt:a}}return null!==d?{data:null,reason:"usage-limit-exceeded",source:"transcript",rejectedAt:d}:{data:null,reason:0===b?"no codex session files":`no rate_limits event in newest ${b} session files`,source:"unavailable"}}(b.sessionsDir);try{let e=await (a.liveReader??(a=>(0,l.VD)().readRateLimits(a)))(b),f=c()/1e3,g=function(a,b=Math.round(Date.now()/1e3)){let c=a=>a?{usedPercent:a.usedPercent,resetsAt:a.resetsAt,windowMinutes:a.windowDurationMins}:null,d=(0,q.v9)(c(a.primary),c(a.secondary),b);return{session:d.session,weekly:d.weekly,plan:a.planType,capturedAt:b}}(e,f),h=d.data?ad(d.data,d.rejectedAt):null,i=h&&d.data?ac(d.data)?.value.resetsAt:null,j=ac(g)?.value.resetsAt,k="number"==typeof d.rejectedAt&&"number"==typeof i&&d.rejectedAt<i&&"number"==typeof j&&j>i?null:h??ad(g,d.rejectedAt),m=k??d.data;if(!m)return{data:g,reason:null,source:"live"};let n=a=>(0,x.I1)({limits:g,observedAt:g.capturedAt,stale:!1,source:"live"},{limits:a,observedAt:a.capturedAt,stale:!1,source:"transcript"},f),o=n(m),p=(0,x.ap)(o,"transcript"),r=k?d.data?(0,x.L1)(n(d.data)):g:null;return{data:(0,x.L1)(o),...r?{baseData:r}:{},reason:p?"transcript-reconciled":null,source:p?"transcript":"live"}}catch(f){let a=(0,m.XR)(f instanceof Error?f.message:String(f)),e=/request timed out:\s*initialize\b/i.test(a);if(console.warn(`[limits] Codex app-server probe for ${b.id} failed: ${a}`),d.data){let a=ad(d.data,d.rejectedAt),b=a&&ae(a,c()/1e3)?a:d.data;return{data:b,...b===a?{baseData:d.data}:{},reason:"transcript-fallback",source:"transcript",...e?{backoffReason:A}:{}}}if(null!==d.rejectedAt&&void 0!==d.rejectedAt)return{...d,...e?{backoffReason:A}:{}};return{data:null,reason:e?A:"app-server-unavailable",source:"unavailable"}}}function _(a){try{return g().readdirSync(a).sort().reverse()}catch{return[]}}function aa(a,b){let c;try{c=g().openSync(a,"r")}catch{return null}try{let a=g().fstatSync(c).size,d=Math.min(a,b),e=Buffer.alloc(d);return g().readSync(c,e,0,d,a-d),e.toString("utf8")}catch{return null}finally{g().closeSync(c)}}function ab(a){return"usage_limit"===a||"usage_limit_exceeded"===a}function ac(a){return["session","weekly"].flatMap(b=>a[b]?[{key:b,value:a[b]}]:[]).sort((a,b)=>b.value.usedPercent-a.value.usedPercent||a.key.localeCompare(b.key))[0]??null}function ad(a,b){return null==b||!function(a,b){let c=ac(a)?.value;if(!c)return!1;if(null===c.resetsAt)return!0;if("number"!=typeof c.windowMinutes)return b<=c.resetsAt;let d=60*c.windowMinutes;return b>=c.resetsAt-d&&b<c.resetsAt+d}(a,b)?null:function(a,b){let c=ac(a);if(!c)return a;let d=null!==c.value.resetsAt&&c.value.resetsAt<=b?null:c.value.resetsAt,e={...a,[c.key]:{...c.value,usedPercent:100,resetsAt:d,observedAt:b,source:"transcript"}},f=[e.session?.observedAt,e.weekly?.observedAt].filter(a=>null!=a);return{...e,capturedAt:f.length?Math.min(...f):b}}(a,b)}function ae(a,b){let c=ac(a);if(!c||c.value.usedPercent<100)return!1;let d=c.value;if(null!==d.resetsAt)return d.resetsAt>b;if(null===d.observedAt||void 0===d.observedAt)return!0;let e="number"==typeof d.windowMinutes?d.windowMinutes:"weekly"===c.key?q.rX:q.Gn;return b-d.observedAt<60*e}function af(a,b){if(!a||"number"!=typeof a.used_percent)return null;let c=null;return"number"==typeof a.resets_at?c=a.resets_at:"number"==typeof a.resets_in_seconds&&null!==b&&(c=b+a.resets_in_seconds),{usedPercent:a.used_percent,resetsAt:c,windowMinutes:"number"==typeof a.window_minutes?a.window_minutes:null,observedAt:b}}function ag(a){return a&&"number"==typeof a.windowMinutes&&a.windowMinutes>0?Math.round(60*a.windowMinutes):null}function ah(a,b,c,d,e){let f=!!(c?.session||c?.weekly),g=(e,g,h,i)=>{var j;let k,l,m,n,q=c?.[e]??null,r=ag(q)??h??o[e];return f&&!q&&0===g.length?{windowStart:null,resetsAt:null,windowSeconds:r,samples:[],windowUnreported:!0}:(j=function(a,b,c,d=Math.round(Date.now()/1e3)){let e=w().series[t(a,b,c)]??[],f=d-691200;return e.filter(a=>a.t>=f)}(a,b,e,d),l=null!==(k=q?.resetsAt??i??null)?k-r:null,m=function(...a){let b=new Map;for(let c of a)for(let a of c)Number.isFinite(a.t)&&Number.isFinite(a.remaining)&&b.set(a.t,p(a.remaining));return[...b.entries()].map(([a,b])=>({t:a,remaining:b})).sort((a,b)=>a.t-b.t)}(j,g,q&&"number"==typeof q.usedPercent?[{t:d,remaining:p(100-q.usedPercent)}]:[]),n=null!==l?m.filter(a=>a.t>=l):m,{windowStart:l,resetsAt:k,windowSeconds:r,samples:n})};return{session:g("session",e?.session??[],e?.sessionWindowSeconds??null,e?.sessionResetsAt??null),weekly:g("weekly",e?.weekly??[],e?.weeklyWindowSeconds??null,e?.weeklyResetsAt??null)}}async function ai(a={}){let b=await N(a),c=Math.round(Date.now()/1e3),d=b.claudeAccountId?ah("claude",b.claudeAccountId,b.claude,c,null):null,e=null;if(b.codexAccountId){let a=function(a,b){let c=[],d=[],e=new Set,f=-1/0,h=null,j=null,k=null,l=null;for(let{p:m,m:n}of function*(a){let b=0;for(let c of _(a))for(let d of _(i().join(a,c)))for(let e of _(i().join(a,c,d))){let f=i().join(a,c,d,e),h=[];for(let a of _(f)){if(!a.endsWith(".jsonl"))continue;let b=i().join(f,a);try{h.push({p:b,m:g().statSync(b).mtimeMs})}catch{}}for(let a of(h.sort((a,b)=>b.m-a.m),h))if(yield a,++b>=400)return}}(a)){if(n/1e3<b)continue;let a=function(a){try{if(g().statSync(a).size>8388608)return aa(a,8388608);return g().readFileSync(a,"utf8")}catch{return aa(a,8388608)}}(m);if(a){for(let g of a.split("\n"))if(g.includes('"rate_limits"'))try{let a=JSON.parse(g),i=a.payload?.rate_limits;if(!i)continue;let m="string"==typeof a.timestamp?Date.parse(a.timestamp):NaN;if(!Number.isFinite(m))continue;let n=Math.round(m/1e3);if(n<b||e.has(n))continue;let o=(0,q.v9)(af(i.primary,n),af(i.secondary,n),n);if(!o.session&&!o.weekly)continue;e.add(n),o.session&&c.push({t:n,remaining:p(100-o.session.usedPercent)}),o.weekly&&d.push({t:n,remaining:p(100-o.weekly.usedPercent)}),n>f&&(f=n,o.session&&(k=o.session.resetsAt,h=ag(o.session)),o.weekly&&(l=o.weekly.resetsAt,j=ag(o.weekly)))}catch{}}}return c.sort((a,b)=>a.t-b.t),d.sort((a,b)=>a.t-b.t),{session:c,weekly:d,sessionWindowSeconds:h,weeklyWindowSeconds:j,sessionResetsAt:k,weeklyResetsAt:l}}((0,j.O$)().sessionsDir,c-691200);e=ah("codex",b.codexAccountId,b.codex,c,a)}return{claude:d,codex:e,claudeAccountId:b.claudeAccountId,codexAccountId:b.codexAccountId,historySince:w().since}}},97609:(a,b,c)=>{c.d(b,{Gn:()=>d,Zc:()=>h,rX:()=>e,v9:()=>g});let d=300,e=10080;function f(a,b){return null==a.windowMinutes&&null!==b&&null!=a.resetsAt&&a.resetsAt-b>60*d+1800}function g(a,b,c=null){let d={session:null,weekly:null},e=[];for(let[c,f]of[["session",a],["weekly",b]]){var h;if(!f)continue;let a="number"!=typeof(h=f.windowMinutes)||!Number.isFinite(h)||h<=0?null:h<=1440?"session":"weekly";a&&!d[a]?d[a]=f:e.push({slot:c,window:f})}for(let{slot:a,window:b}of e){let e="session"===a&&f(b,c)?"weekly":a;d[e]||(d[e]=b)}return d}function h(a){return a?.session&&!a.weekly&&f(a.session,a.capturedAt)?{...a,session:null,weekly:a.session}:a}}};
@@ -0,0 +1,104 @@
1
+ "use strict";exports.id=9296,exports.ids=[6277,9296],exports.modules={26277:(a,b,c)=>{c.d(b,{Gs:()=>C,Kn:()=>w,gY:()=>x,h3:()=>q,jd:()=>v,kt:()=>E,ue:()=>D,vx:()=>y,w5:()=>z});var d=c(31421);c(77598);var e=c(73024),f=c.n(e),g=c(48161),h=c.n(g),i=c(76760),j=c.n(i),k=c(27146),l=c(89204),m=c(55541),n=c(19777);Object.freeze({repo:"https://github.com/chigwell/telegram-mcp",release:"v3.2.22",commit:"a61294362226bd93052f5a40b4a1b1269a99ce69",license:"Apache-2.0"});let o="127.0.0.1";function p(){let a=Number(process.env.LLV_TELEGRAM_MCP_PORT);return Number.isInteger(a)&&a>0&&a<65536?a:8809}function q(){return`http://${o}:${p()}/mcp`}function r(a,...b){if(a)return a;let c=j().join(process.cwd(),...b);if(f().existsSync(c))return c;let d=j().join(process.cwd(),"..","..",...b);return f().existsSync(d)?d:c}function s(){return r(process.env.LLV_TELEGRAM_VENDOR_DIR,"vendor","telegram-mcp")}function t(){return(0,k.BQ)("telegram","venv")}function u(){return(0,k.BQ)("telegram","vendor-src")}function v(){return process.env.LLV_TELEGRAM_PYTHON||j().join(t(),"bin","python")}function w(){return r(process.env.LLV_TELEGRAM_SERVER_BRIDGE,"bin","telegram-mcp-server.py")}function x(){return r(process.env.LLV_TELEGRAM_SESSION_READER,"bin","telegram-session-reader.mjs")}let y=Object.freeze(["wait_for_settled_message"]);function z(){let a=process.env.LLV_TELEGRAM_API_ID,b=process.env.LLV_TELEGRAM_API_HASH;if(a&&b)return{apiId:a,apiHash:b};try{let a=JSON.parse(f().readFileSync((0,k.ks)("telegram.json"),"utf8"));if("string"==typeof a.apiId&&a.apiId&&"string"==typeof a.apiHash&&a.apiHash)return{apiId:a.apiId,apiHash:a.apiHash}}catch{}return null}function A(){return f().existsSync(j().join(t(),".llv-provisioned"))&&f().existsSync(v())&&f().existsSync(j().join(u(),"pyproject.toml"))}let B=null;function C(){return A()?Promise.resolve(!0):B||(B=(async()=>((0,n._q)(!0),await (0,l.pM)((0,k.BQ)("telegram","connector-provision"),"Telegram connector provisioning is busy",async()=>{var a;return!!A()||await (a={command:process.execPath,args:[r(process.env.LLV_TELEGRAM_PROVISIONER,"bin","provision-telegram-connector.mjs")],cwd:s(),env:{...F(),LLV_STATE_DIR:(0,k.Pn)(),LLV_TELEGRAM_VENDOR_DIR:s(),LLV_TELEGRAM_PYTHON:v()}},new Promise(b=>{let c;try{c=(0,d.spawn)(a.command,a.args,{cwd:a.cwd,env:a.env,stdio:"ignore"})}catch{b(!1);return}c.once("error",()=>b(!1)),c.once("exit",a=>b(0===a))}))&&A()})))().catch(()=>!1).finally(()=>{B=null}))}function D(a){let b=u(),c=(0,m.WG)();return{command:v(),args:[w()],cwd:b,env:{...F(),...c,TELEGRAM_API_ID:a.credentials.apiId,TELEGRAM_API_HASH:a.credentials.apiHash,TELEGRAM_SESSION_STRING:a.sessionString,TELEGRAM_EXPOSED_TOOLS:"read-only",TELEGRAM_EVENT_FEED:"1",TELEGRAM_EVENT_FEED_FILE:(0,n.ZI)(a.credentialRef),LLV_TELEGRAM_EXCLUDED_TOOLS:y.join(","),LLV_TELEGRAM_MCP_TOKEN:a.connectorToken,LLV_TELEGRAM_VENDOR_DIR:b,MCP_TRANSPORT:"http",MCP_HOST:o,MCP_PORT:String(p())}}}function E(a,b){return{command:v(),args:[r(process.env.LLV_TELEGRAM_BRIDGE,"bin","telegram-login-bridge.py"),a],cwd:h().homedir(),env:{...F(),TELEGRAM_API_ID:b.apiId,TELEGRAM_API_HASH:b.apiHash}}}function F(){let a={};for(let b of["PATH","HOME","LANG","LC_ALL","TMPDIR"])void 0!==process.env[b]&&(a[b]=process.env[b]);return a}},50261:(a,b,c)=>{c.r(b),c.d(b,{STRUCTURED_HOST_RETIREMENT_CLAUSES:()=>F,STRUCTURED_HOST_RETIREMENT_INTERVAL_MS:()=>A,reconcileStructuredHostRetirement:()=>$,runStructuredHostRetirementSweep:()=>Z,startStructuredHostRetirement:()=>aa,stopStructuredHostRetirement:()=>ab,structuredHostRetirementBatch:()=>B,structuredHostRetirementGraceMs:()=>N,structuredHostRetirementIdleMs:()=>M,structuredHostRetirementJournalRecord:()=>U,structuredHostRetirementVerdict:()=>L});var d=c(73024),e=c.n(d),f=c(76760),g=c.n(f),h=c(70160),i=c(88623),j=c(27146),k=c(29307),l=c(55686),m=c(1198),n=c(76385),o=c(39584),p=c(89317),q=c(26296);function r(a){return[...a].sort((a,b)=>a.seq-b.seq)}function s(a,b){return[...new Set(a.filter(a=>a.conversationId===b).flatMap(a=>a.replayedDeliveryIds))]}class t{constructor(a,b=()=>new Date().toISOString()){this.store=a,this.clock=b}loadState(){return{rows:this.store.load(),history:this.store.loadHistory?.()??[],drainingGenerations:this.store.loadDrainingGenerations?.()??[]}}mutate(a){let b=b=>{let c=new Map(b.rows.map(a=>[a.operationId,a])),d=a(c,b);return b.rows.splice(0,b.rows.length,...c.values()),d};if(this.store.transaction)return this.store.transaction(b);let c=this.loadState(),d=b(c);return this.store.save(c.rows),this.store.saveHistory?.(c.history),this.store.saveDrainingGenerations?.(c.drainingGenerations),d}rows(){return this.store.load().map(a=>structuredClone(a))}history(){return(this.store.loadHistory?.()??[]).map(a=>structuredClone(a))}row(a){let b=this.loadState(),c=[...b.rows,...b.history].find(b=>b.operationId===a);return c?structuredClone(c):null}enqueue(a){let b=this.clock();this.mutate((c,d)=>{for(let e of a){if(c.has(e.operationId)||d.history.some(a=>a.operationId===e.operationId))continue;let a=[...c.values()].find(a=>a.conversationId===e.conversationId);if(a){if("pending"===a.status||"draining"===a.status)continue;c.delete(a.operationId),d.history.push(structuredClone(a))}c.set(e.operationId,{...e,pendingDeliveries:a?function(a,b){let c=new Set(a.replayedDeliveryIds),d=r(b).filter(a=>!c.has(a.deliveryId)),e=new Set(d.map(a=>a.deliveryId));return[...r(a.pendingDeliveries).filter(a=>!c.has(a.deliveryId)).filter(a=>!e.has(a.deliveryId)),...d].map((a,b)=>({...a,seq:b+1}))}(a,e.pendingDeliveries):r(e.pendingDeliveries),status:"pending",predecessorGeneration:null,successorGeneration:null,replayedDeliveryIds:s(d.history,e.conversationId),interruptionOutcome:null,lastError:null,enqueuedAt:b,updatedAt:b})}})}beginDrain(a){let b=this.clock();this.mutate((c,d)=>{for(let e of(d.drainingGenerations.includes(a)||d.drainingGenerations.push(a),c.values()))e.hostGeneration===a&&("pending"===e.status||"claimed"===e.status)&&(e.status="draining",e.updatedAt=b)})}isAdmittingNewHosts(a){return!this.loadState().drainingGenerations.includes(a)}admitMessage(a,b){return this.mutate(c=>{let d=c.get(a);return!!d&&"terminal"!==d.status&&(!!d.pendingDeliveries.some(a=>a.deliveryId===b.deliveryId)||(d.pendingDeliveries=r([...d.pendingDeliveries,b]),d.updatedAt=this.clock(),!0))})}refreshTurnState(a,b,c){return this.mutate(d=>{let e=d.get(a);return!!e&&e.hostGeneration===b&&("pending"===e.status||"draining"===e.status)&&("terminal"!==e.turnState||"terminal"===c)&&(e.turnState=c,e.updatedAt=this.clock(),!0)})}claim(a,b){return this.mutate(c=>{var d;let e=c.get(a);if(!e)return{ok:!1,row:null,replay:[],reason:"not-found"};let f=r(e.pendingDeliveries).filter(a=>!e.replayedDeliveryIds.includes(a.deliveryId));return e.successorGeneration===b.toGeneration&&("claimed"===e.status||"terminal"===e.status)?{ok:!0,row:structuredClone(e),replay:f}:e.hostGeneration!==b.fromGeneration?{ok:!1,row:structuredClone(e),replay:[],reason:"generation-fence"}:(e.predecessorGeneration=b.fromGeneration,e.successorGeneration=b.toGeneration,e.hostGeneration=b.toGeneration,e.status="terminal"===e.turnState?"terminal":"claimed",e.interruptionOutcome="terminal"===(d=e.turnState)?"completed":"busy"===d?"interrupted":null,e.updatedAt=this.clock(),{ok:!0,row:structuredClone(e),replay:f})})}acknowledgeReplay(a,b,c){return this.mutate(d=>{let e=d.get(a);if(!e||e.successorGeneration!==b||"claimed"!==e.status&&"terminal"!==e.status)return!1;let f=new Set(e.pendingDeliveries.map(a=>a.deliveryId));return!c.some(a=>!f.has(a))&&(e.replayedDeliveryIds=[...new Set([...e.replayedDeliveryIds,...c])],e.updatedAt=this.clock(),!0)})}failCandidate(a){let b=this.clock();this.mutate((c,d)=>{let e=new Set(d.drainingGenerations);for(let f of c.values()){if(f.successorGeneration!==a)continue;let c=f.predecessorGeneration;f.hostGeneration=c??f.hostGeneration,f.status=c&&e.has(c)?"draining":"pending",f.predecessorGeneration=null,f.successorGeneration=null,f.replayedDeliveryIds=s(d.history,f.conversationId),f.interruptionOutcome=null,f.updatedAt=b}})}markRetryableFailure(a,b){this.mutate(c=>{let d=c.get(a);d&&(d.status="failed",d.lastError=b,d.updatedAt=this.clock())})}retirable(a){for(let b of this.store.load())if(b.hostGeneration===a&&("pending"===b.status||"draining"===b.status))return!1;return!0}}class u{constructor(a){this.filename=a,e().mkdirSync(g().dirname(a),{recursive:!0,mode:448});const b=process.getBuiltinModule?.("bun:sqlite");if(!b)throw Error("SQLite handoff queue requires the Bun runtime");this.db=new b.Database(a,{create:!0,strict:!0}),this.db.exec("PRAGMA busy_timeout = 5000; PRAGMA journal_mode = WAL; PRAGMA synchronous = FULL;"),this.db.exec(`
2
+ CREATE TABLE IF NOT EXISTS handoff_rows (
3
+ operation_id TEXT PRIMARY KEY,
4
+ conversation_id TEXT,
5
+ row_order INTEGER NOT NULL,
6
+ value_json TEXT NOT NULL
7
+ );
8
+ CREATE TABLE IF NOT EXISTS handoff_history (
9
+ operation_id TEXT PRIMARY KEY,
10
+ conversation_id TEXT NOT NULL,
11
+ row_order INTEGER NOT NULL,
12
+ value_json TEXT NOT NULL
13
+ );
14
+ CREATE TABLE IF NOT EXISTS handoff_draining_generations (
15
+ generation TEXT PRIMARY KEY,
16
+ row_order INTEGER NOT NULL
17
+ );
18
+ `),this.db.exec("BEGIN IMMEDIATE");try{this.db.query("PRAGMA table_info(handoff_rows)").all().some(a=>"conversation_id"===a.name)||this.db.exec("ALTER TABLE handoff_rows ADD COLUMN conversation_id TEXT"),this.db.exec("COMMIT")}catch(a){throw this.db.exec("ROLLBACK"),a}this.migrateActiveRows(),this.db.exec(`
19
+ CREATE UNIQUE INDEX IF NOT EXISTS handoff_one_active_conversation
20
+ ON handoff_rows(conversation_id)
21
+ WHERE conversation_id IS NOT NULL;
22
+ `);try{e().chmodSync(a,384)}catch{}}load(){return this.db.query("SELECT value_json FROM handoff_rows ORDER BY row_order ASC").all().map(a=>JSON.parse(a.value_json))}loadHistory(){return this.db.query("SELECT value_json FROM handoff_history ORDER BY row_order ASC").all().map(a=>JSON.parse(a.value_json))}loadDrainingGenerations(){return this.db.query("SELECT generation FROM handoff_draining_generations ORDER BY row_order ASC").all().map(a=>a.generation)}writeRows(a){let b=this.db.query("INSERT INTO handoff_rows(operation_id, conversation_id, row_order, value_json) VALUES (?, ?, ?, ?)");this.db.exec("DELETE FROM handoff_rows"),a.forEach((a,c)=>b.run(a.operationId,a.conversationId,c,JSON.stringify(a)))}writeHistory(a){let b=this.db.query("INSERT INTO handoff_history(operation_id, conversation_id, row_order, value_json) VALUES (?, ?, ?, ?)");this.db.exec("DELETE FROM handoff_history"),a.forEach((a,c)=>b.run(a.operationId,a.conversationId,c,JSON.stringify(a)))}writeDrainingGenerations(a){let b=this.db.query("INSERT INTO handoff_draining_generations(generation, row_order) VALUES (?, ?)");this.db.exec("DELETE FROM handoff_draining_generations"),[...new Set(a)].forEach((a,c)=>b.run(a,c))}migrateActiveRows(){this.db.exec("BEGIN IMMEDIATE");try{let a=new Map,b=this.loadHistory(),c=new Map(b.map(a=>[a.operationId,a])),d=new Set(this.loadDrainingGenerations()),e=this.load();for(let a of[...b,...e])"draining"===a.status&&d.add(a.hostGeneration);for(let b of e){let d=a.get(b.conversationId);d&&c.set(d.operationId,d),a.set(b.conversationId,b)}this.writeRows([...a.values()]),this.writeHistory([...c.values()]),this.writeDrainingGenerations([...d]),this.db.exec("COMMIT")}catch(a){throw this.db.exec("ROLLBACK"),a}}save(a){this.db.exec("BEGIN IMMEDIATE");try{this.writeRows(a),this.db.exec("COMMIT")}catch(a){throw this.db.exec("ROLLBACK"),a}}saveHistory(a){this.db.exec("BEGIN IMMEDIATE");try{this.writeHistory(a),this.db.exec("COMMIT")}catch(a){throw this.db.exec("ROLLBACK"),a}}saveDrainingGenerations(a){this.db.exec("BEGIN IMMEDIATE");try{this.writeDrainingGenerations(a),this.db.exec("COMMIT")}catch(a){throw this.db.exec("ROLLBACK"),a}}transaction(a){this.db.exec("BEGIN IMMEDIATE");try{let b={rows:this.load(),history:this.loadHistory(),drainingGenerations:this.loadDrainingGenerations()},c=a(b);return this.writeRows(b.rows),this.writeHistory(b.history),this.writeDrainingGenerations(b.drainingGenerations),this.db.exec("COMMIT"),c}catch(a){throw this.db.exec("ROLLBACK"),a}}}let v=null;var w=c(41687),x=c(2749),y=c(81339),z=c(30131);let A=3e5;function B(a,b=A){return Math.max(1,Math.min(8,Math.floor(.5*b/Math.max(1,a+1e4))))}let C=new Set(["completed","failed","conflicted"]),D=new Set(["held","assigned","delivery-uncertain"]),E=new Set(["idle","dead"]),F=["seat-free","turn-settled","attention-settled","host-idle-or-dead","no-active-flags","handoff-queue-drained","no-open-operation","events-flushed","no-realtime-binding","resumable","transcript-idle","process-identity"],G=(0,p.yV)(null),H=a=>(0,p.yV)(a);function I(a){return a.seat.determined&&"revoked"===a.seat.value}function J(a){return null===a.process.startIdentity?(0,p.nZ)(`the registry stored no kernel identity for pid ${a.process.pid}`):(0,p.yV)(a.process.startIdentity)}let K={"seat-free":a=>(0,p.Le)(a.seat,a=>"live"===a?"the host holds a live orchestrator seat":null),"turn-settled":a=>null!==a.activeTurnRef?H(`turn ${a.activeTurnRef} is in flight`):(0,p.Le)(a.turnBusy,a=>a?"the conversation turn has not settled":null),"attention-settled":a=>a.pendingAttention.length>0?H(`${a.pendingAttention.length} question(s) await an operator answer`):G,"host-idle-or-dead":a=>E.has(a.status)?G:H(`the host status is ${a.status}`),"no-active-flags":a=>{let b=(0,w.S0)(a.activeFlags);return b.length>0?H(`the host is flagged ${b.join(", ")}`):G},"handoff-queue-drained":a=>(0,p.Le)(a.undeliveredHandoffEntries,a=>a>0?`${a} undelivered handoff entr(ies) name this key`:null),"no-open-operation":a=>null!==a.pendingAction?H(`a ${a.pendingAction} action is pending`):null!==a.structuredHostOperationId?H("a structured host operation is still in flight"):a.openOperations>0?H(`${a.openOperations} spawn receipt(s) are pending or non-terminal`):G,"events-flushed":a=>(0,p.Le)(a.durableEventTail,b=>a.eventCursor<b?`the flushed cursor ${a.eventCursor} is behind the session's ${b}`:null),"no-realtime-binding":a=>(0,p.Le)(a.realtimeBound,a=>a?"a realtime session is bound to this conversation":null),resumable:a=>""===a.transcriptPath?H("the host names no transcript to resume from"):(0,p.Le)(a.transcriptFile,a=>null===a?"the transcript is not present on disk":null),"transcript-idle":(a,b)=>(0,p.Le)(a.transcriptFile,c=>{if(null===c)return"the transcript is not present on disk";if(I(a))return null;let d=b.now-c.mtimeMs;return d<b.idleMs?`the transcript was written ${Math.max(0,Math.round(d/1e3))}s ago`:null}),"process-identity":a=>{let b=J(a);if(!b.determined)return b;let c="string"==typeof a.process.bootEpoch&&a.process.bootEpoch?(0,p.yV)(a.process.bootEpoch):(0,p.nZ)(`the registry stored no boot epoch for pid ${a.process.pid}`);if(!c.determined)return c;if(!a.observedStartIdentity.determined)return a.observedStartIdentity;if(!a.observedBootEpoch.determined)return a.observedBootEpoch;let d=a.observedStartIdentity.value,e=a.observedBootEpoch.value;return"alive"===(0,n.Ue)(a.process,{pidAlive:()=>!0,processIdentity:()=>d,bootEpoch:()=>e})?G:H(`pid ${a.process.pid} is no longer the recorded host`)}};function L(a,b){let c=[];for(let d of F){let e=K[d](a,b);if(!e.determined)return{retire:!1,clause:d,reason:e.why,undetermined:!0};if(null!==e.value)return{retire:!1,clause:d,reason:e.value};c.push(d)}let d=J(a);return d.determined?{retire:!0,passed:c,startIdentity:d.value}:{retire:!1,clause:"process-identity",reason:d.why,undetermined:!0}}function M(a=process.env){let b=a.LLV_HOST_RETIREMENT_IDLE_HOURS;if(void 0===b||""===b.trim())return 216e5;let c=Number(b);return!Number.isFinite(c)||c<0?(console.warn("[host retirement] LLV_HOST_RETIREMENT_IDLE_HOURS is not a duration; using 6h"),216e5):0===c?null:36e5*c}function N(a=process.env){let b=a.LLV_HOST_RETIREMENT_GRACE_MS;if(void 0===b||""===b.trim())return 5e3;let c=Number(b);return!Number.isFinite(c)||c<0?5e3:Math.min(c,6e4)}function O(a){try{let b=e().statSync(a);return(0,p.yV)(b.isFile()?{mtimeMs:b.mtimeMs}:null)}catch(b){let a=b.code;return"ENOENT"===a||"ENOTDIR"===a?(0,p.yV)(null):(0,p.nZ)(`the transcript could not be read (${a??"unknown"})`)}}function P(a){try{if((0,z.VD)().has(a))return(0,p.yV)(!0);let b=(0,x.Aj)(a);return(0,p.yV)("function"==typeof b?.currentRealtimeSessionId&&null!==b.currentRealtimeSessionId())}catch(a){return(0,p.nZ)(`the realtime binding could not be read: ${T(a)}`)}}function Q(){let a;try{let b=(0,k.activeOrchestratorSeatsOrUnknown)();if(null===b)return(0,p.nZ)("the orchestrator seat store could not be established");let c=R();a=new Set(b.flatMap(a=>a.conversationId?[c(a.conversationId)]:[]))}catch(a){return(0,p.nZ)(`the orchestrator seat store could not be read: ${T(a)}`)}return(0,p.yV)(a)}function R(){let a=(0,h.agentRegistry)();return b=>a.canonicalConversationId(b)}function S(){let a;try{a=(0,k.revokedOrchestratorSeatConversationsOrUnknown)(R())}catch(a){return(0,p.nZ)(`the orchestrator revocation record could not be read: ${T(a)}`)}return null===a?(0,p.nZ)("the orchestrator revocation record could not be established"):(0,p.yV)(a)}function T(a){return a instanceof Error?a.message:String(a)}function U(a){let{refused:b,...c}=a,d={},e={};for(let a of b)d[a.clause]=(d[a.clause]??0)+1,a.undetermined&&(e[a.clause]=(e[a.clause]??0)+1);return{...c,refusedByClause:d,undeterminedByClause:e}}function V(a){try{var b;let c;b=(0,j.BQ)("host-retirement-report.json"),e().mkdirSync(g().dirname(b),{recursive:!0,mode:448}),c=`${b}.${process.pid}.tmp`,e().writeFileSync(c,`${JSON.stringify(a,null,2)}
23
+ `,{encoding:"utf8",mode:384}),e().renameSync(c,b)}catch(a){console.error("[host retirement] report could not be written",a)}try{let b=(0,j.BQ)("host-retirement-journal.ndjson");e().mkdirSync(g().dirname(b),{recursive:!0,mode:448});try{e().statSync(b).size>4194304&&e().renameSync(b,`${b}.1`)}catch{}e().appendFileSync(b,`${JSON.stringify(U(a))}
24
+ `,{encoding:"utf8",mode:384})}catch(a){console.error("[host retirement] journal could not be appended",a)}for(let b of a.retired){let a=b.seatRevoked?", revoked seat":"";console.warn(`[host retirement] retired ${b.key} (${b.role??"no role"}, idle ${Math.round(b.idleMs/6e4)}m${a}) via ${b.via}: ${b.reclaimed.processes} process(es), ${Math.round(b.reclaimed.rssBytes/1048576)} MiB resident + ${Math.round(b.reclaimed.swapBytes/1048576)} MiB swapped reclaimed`)}for(let b of a.failed)console.warn(`[host retirement] left ${b.key} intact: ${b.error}`);let c=Object.entries(U(a).undeterminedByClause);if(c.length>0){let b=c.map(([a,b])=>`${a} (${b})`).join(", "),d=a.refused.find(a=>a.undetermined)?.reason??"";console.warn(`[host retirement] kept hosts whose clauses could not be determined: ${b} — ${d}`)}}class W{add(a){null!==a&&this.counts.set(a,(this.counts.get(a)??0)+1)}addKey(a){this.add(`key:${a}`)}addConversation(a){this.add(null===a?null:`conv:${a}`)}count(a,b){return(this.counts.get(`key:${a}`)??0)+(null===b?0:this.counts.get(`conv:${b}`)??0)}constructor(){this.counts=new Map}}function X(a){var b;let c=a.snapshot(),d=new Map;for(let a of Object.values(c.conversations))for(let b of a.generations)d.set(b.id,a);return{file:c,conversationsBySession:d,undelivered:(b=a.handoffRows(),(0,p.Le)(b,a=>{let b=new W;for(let c of a){let a=new Set(c.replayedDeliveryIds??[]);(c.pendingDeliveries??[]).some(b=>!a.has(b.deliveryId))&&("claude"===c.engine||"codex"===c.engine?b.addKey(`${c.engine}:${c.engineSessionId}`):b.addConversation(c.conversationId))}for(let a of Object.values(c.heldDeliveries??{}))D.has(a.state)&&b.addConversation(a.conversationId);return b})),openOperations:function(a){let b=new W;for(let c of Object.values(a.receipts??{}))C.has(c.state)||(null!==c.key?b.addKey((0,i.pp)(c.key)):b.addConversation(c.conversationId));return b}(c),seatConversations:a.seatConversations(),revokedConversations:a.revokedConversations()}}function Y(a,b,c){var d,e,f;let g,h=a.structuredHost,j=h.process,k=a.key,l=(0,i.pp)(k),m=b.conversationsBySession.get(k.sessionId)??null,n=m?.id??null,o=m?b.file.memberships[m.id]??[]:[],q=o.find(a=>"pipeline"===a.kind)??null,r=m?.generations.find(a=>a.id===k.sessionId)??null;return{key:k,keyId:l,conversationId:n,title:r?.launchProfile.title??null,role:m?.agentRole??q?.role??r?.launchProfile.role??null,stage:q?.stageId??q?.slot??null,cwd:a.cwd||r?.launchProfile.cwd||"",transcriptPath:a.artifactPath||"",process:j,status:a.status,activeTurnRef:h.activeTurnRef,turnBusy:null===m?(0,p.nZ)("no conversation record establishes this host's turn state"):"unknown"===m.turn.state?(0,p.nZ)("the conversation's turn state is unknown"):(0,p.yV)("busy"===m.turn.state),pendingAttention:h.pendingAttention,activeFlags:h.activeFlags,pendingAction:a.pendingAction,structuredHostOperationId:a.structuredHostOperationId??null,undeliveredHandoffEntries:(0,p.Le)(b.undelivered,a=>a.count(l,n)),openOperations:b.openOperations.count(l,n),eventCursor:h.eventCursor,durableEventTail:c.durableEventTail(k.sessionId),realtimeBound:null===n?(0,p.nZ)("the host names no conversation, so no realtime binding can be looked up"):c.realtimeBound(n),seat:null===m?(0,p.nZ)("no conversation record establishes whether this host holds a seat"):(d=m.id,e=b.seatConversations,f=b.revokedConversations,(g=o.some(a=>"orchestrator"===a.kind)?(0,p.yV)(!0):(0,p.Le)(e,a=>a.has(d))).determined?g.value?(0,p.Le)(f,a=>a.has(d)?"revoked":"live"):(0,p.yV)("none"):g),transcriptFile:a.artifactPath?c.transcriptStat(a.artifactPath):(0,p.yV)(null),observedStartIdentity:c.processIdentity(j.pid),observedBootEpoch:c.bootEpoch()}}async function Z(a={}){let b=a.now??Date.now,c=b(),d=a.idleMs??M()??216e5,e=a.graceMs??N(),f=a.batch??B(e),g={snapshot:a.snapshot??(()=>(0,h.agentRegistry)().readOnlySnapshot()),handoffRows:a.handoffRows??(()=>{try{return(0,p.yV)((v??=new t(new u((0,j.BQ)("handoff-queue.sqlite")))).rows())}catch(a){return(0,p.nZ)(`the handoff queue could not be read: ${T(a)}`)}}),seatConversations:a.orchestratorSeatConversations??Q,revokedConversations:a.revokedSeatConversations??S},i={durableEventTail:a.durableEventTail??(a=>(0,q.t2)(a)),realtimeBound:a.realtimeBound??P,transcriptStat:a.transcriptStat??O,processIdentity:a.processIdentity??(a=>{let b=l.B.processIdentity(a);return null===b?(0,p.nZ)(`no kernel identity can be observed for pid ${a}`):(0,p.yV)(b)}),bootEpoch:a.bootEpoch??(()=>{let a=(0,n.h_)();return null===a?(0,p.nZ)("the kernel boot epoch could not be read"):(0,p.yV)(a)})},k=a.processMemory??(a=>l.B.processMemory(a)),r=a.ppidMap??(()=>l.B.ppidMap()),s=a.owned??x.sy,w=a.terminate??(a=>(0,y.$X)(a,{graceMs:e,deadlineMs:e+1e4})),z=a.record??V,A=a.publicationState??x.du,C={version:1,startedAt:new Date(c).toISOString(),finishedAt:"",idleHours:d/36e5,evaluated:0,deferred:0,standDown:null,retired:[],refused:[],failed:[],reclaimed:{rssBytes:0,swapBytes:0,processes:0}},D=A();if("ready"!==D)return C.standDown=D,C.finishedAt=new Date(b()).toISOString(),z(C),C;let E=X(g),F=Object.values(E.file.entries).filter(a=>!!a.structuredHost?.process&&("claude"===a.key.engine||"codex"===a.key.engine)&&null===a.host).slice(0,o.sb);C.evaluated=F.length;let G=[];for(let a of F){let b=Y(a,E,i),e=L(b,{now:c,idleMs:d});if(!e.retire){C.refused.push({key:b.keyId,conversationId:b.conversationId,clause:e.clause,reason:e.reason,...e.undetermined?{undetermined:!0}:{}});continue}if(G.length>=f){C.deferred+=1;continue}G.push(b)}let H=null;for(let a of G){var J;let e,f=X(g),h=f.file.entries[a.keyId]??null;if(null===h||!h.structuredHost?.process){C.refused.push({key:a.keyId,conversationId:a.conversationId,clause:"process-identity",reason:"the registry no longer records this host",changed:!0});continue}let j=Y(h,f,i),l=L(j,{now:b(),idleMs:d});if(!l.retire){C.refused.push({key:j.keyId,conversationId:j.conversationId,clause:l.clause,reason:l.reason,...l.undetermined?{undetermined:!0}:{},changed:!0});continue}let n=j.process,o=j.transcriptFile.determined?j.transcriptFile.value?.mtimeMs??null:null;H??=r();let p=k((0,m.mO)(n.pid,H)),q={rssBytes:0,swapBytes:0,processes:p.size};for(let a of p.values())q.rssBytes+=a.rssBytes,q.swapBytes+=a.swapBytes;let t={kind:"structured",pid:n.pid,startIdentity:l.startIdentity,bootEpoch:n.bootEpoch??null,engine:j.key.engine,sessionId:j.key.sessionId,conversationId:j.conversationId,seat:j.seat.determined?"live"===j.seat.value:null,turnBusy:(J=j.turnBusy).determined?J.value:null,owned:s(j.key),lastActiveAt:null===o?null:new Date(o).toISOString()};try{e=await w(t)}catch(a){C.failed.push({key:j.keyId,conversationId:j.conversationId,error:String(a),remaining:[]});continue}if(!e.ok){C.failed.push({key:j.keyId,conversationId:j.conversationId,error:e.error,remaining:e.remaining});continue}C.retired.push({key:j.keyId,engine:j.key.engine,sessionId:j.key.sessionId,conversationId:j.conversationId,title:j.title,role:j.role,stage:j.stage,cwd:j.cwd,idleMs:null===o?0:c-o,passed:l.passed,...I(j)?{seatRevoked:!0}:{},via:e.via,pids:e.pids,reclaimed:q}),C.reclaimed.rssBytes+=q.rssBytes,C.reclaimed.swapBytes+=q.swapBytes,C.reclaimed.processes+=q.processes,H=null}return C.finishedAt=new Date(b()).toISOString(),z(C),C}async function $(a={}){let b=M(a.env??process.env);if(null===b)return null;let c=a.sweep??(a=>Z({idleMs:a}));try{return await c(b)}catch(a){return console.error("[host retirement] sweep failed",a),null}}let _=globalThis;function aa(a={}){if(_.__llvStructuredHostRetirementTimer)return;let b=a.scheduleInterval??((a,b)=>setInterval(a,b)),c=a.sweep??(()=>$()),d=b(()=>{c()},a.intervalMs??A);d.unref?.(),_.__llvStructuredHostRetirementTimer=d}function ab(){let a=_.__llvStructuredHostRetirementTimer;a&&clearInterval(a),_.__llvStructuredHostRetirementTimer=void 0}},55541:(a,b,c)=>{c.d(b,{WG:()=>o,cO:()=>n,yb:()=>l});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(19777);let l=262144,m=String.raw`import fcntl
25
+ import io
26
+ import os
27
+ import stat
28
+ import sys
29
+ import threading
30
+
31
+ try:
32
+ _path = os.environ["LLV_TELEGRAM_CONNECTOR_LOG"]
33
+ _limit = int(os.environ["LLV_TELEGRAM_CONNECTOR_LOG_MAX_BYTES"])
34
+ if _limit <= 0:
35
+ raise ValueError("invalid log limit")
36
+ _flags = os.O_RDWR | os.O_CREAT | os.O_APPEND
37
+ if hasattr(os, "O_NOFOLLOW"):
38
+ _flags |= os.O_NOFOLLOW
39
+ _fd = os.open(_path, _flags, 0o600)
40
+ _info = os.fstat(_fd)
41
+ if not stat.S_ISREG(_info.st_mode) or (_info.st_mode & 0o077):
42
+ raise PermissionError("unsafe connector log")
43
+ if hasattr(os, "getuid") and _info.st_uid != os.getuid():
44
+ raise PermissionError("connector log owner mismatch")
45
+ except Exception as _error:
46
+ raise SystemExit("connector log sink unavailable") from _error
47
+
48
+
49
+ def _write_all(data):
50
+ view = memoryview(data)
51
+ while view:
52
+ written = os.write(_fd, view)
53
+ view = view[written:]
54
+
55
+
56
+ class _BoundedConnectorLog(io.TextIOBase):
57
+ encoding = "utf-8"
58
+ errors = "backslashreplace"
59
+
60
+ def __init__(self):
61
+ self._lock = threading.Lock()
62
+
63
+ def writable(self):
64
+ return True
65
+
66
+ def isatty(self):
67
+ return False
68
+
69
+ def fileno(self):
70
+ return _fd
71
+
72
+ def flush(self):
73
+ return None
74
+
75
+ def write(self, value):
76
+ if not isinstance(value, str):
77
+ value = str(value)
78
+ data = value.encode(self.encoding, self.errors)
79
+ if not data:
80
+ return len(value)
81
+ with self._lock:
82
+ fcntl.flock(_fd, fcntl.LOCK_EX)
83
+ try:
84
+ size = os.fstat(_fd).st_size
85
+ if len(data) >= _limit:
86
+ tail = data[-_limit:]
87
+ os.ftruncate(_fd, 0)
88
+ _write_all(tail)
89
+ elif size + len(data) > _limit:
90
+ keep = _limit - len(data)
91
+ prior = os.pread(_fd, keep, max(0, size - keep))
92
+ os.ftruncate(_fd, 0)
93
+ _write_all(prior[-keep:] + data)
94
+ else:
95
+ _write_all(data)
96
+ finally:
97
+ fcntl.flock(_fd, fcntl.LOCK_UN)
98
+ return len(value)
99
+
100
+
101
+ _sink = _BoundedConnectorLog()
102
+ sys.stdout = _sink
103
+ sys.stderr = _sink
104
+ `;function n(){return(0,j.BQ)("telegram","connector.log")}function o(){(0,k._q)(!0);let a=(0,j.BQ)("telegram","connector-log-sink");g().mkdirSync(a,{recursive:!0,mode:448});let b=g().lstatSync(a);if(!b.isDirectory()||b.isSymbolicLink()||(63&b.mode)!=0||"function"==typeof process.getuid&&b.uid!==process.getuid())throw Error("unsafe connector log sink directory");let c=i().join(a,"sitecustomize.py"),d=`${c}.${process.pid}.${e().randomUUID()}.tmp`;try{g().writeFileSync(d,m,{flag:"wx",mode:384}),g().renameSync(d,c),g().chmodSync(c,384)}finally{g().rmSync(d,{force:!0})}return!function(){let a="O_NOFOLLOW"in g().constants?g().constants.O_NOFOLLOW:0,b=g().openSync(n(),g().constants.O_RDWR|g().constants.O_CREAT|a,384);try{let a=g().fstatSync(b);if(!a.isFile()||(63&a.mode)!=0||"function"==typeof process.getuid&&a.uid!==process.getuid())throw Error("unsafe connector log");if(a.size<=l)return;let c=Buffer.alloc(l);g().readSync(b,c,0,c.length,a.size-c.length),g().ftruncateSync(b,0),g().writeSync(b,c,0,c.length,0)}finally{g().closeSync(b)}}(),{PYTHONPATH:a,LLV_TELEGRAM_CONNECTOR_LOG:n(),LLV_TELEGRAM_CONNECTOR_LOG_MAX_BYTES:String(l)}}}};
@@ -1,4 +1,4 @@
1
- "use strict";exports.id=7139,exports.ids=[1888,3598,7139,9507],exports.modules={26277:(a,b,c)=>{c.d(b,{Gs:()=>C,Kn:()=>w,gY:()=>x,h3:()=>q,jd:()=>v,kt:()=>E,ue:()=>D,vx:()=>y,w5:()=>z});var d=c(31421);c(77598);var e=c(73024),f=c.n(e),g=c(48161),h=c.n(g),i=c(76760),j=c.n(i),k=c(27146),l=c(89204),m=c(55541),n=c(19777);Object.freeze({repo:"https://github.com/chigwell/telegram-mcp",release:"v3.2.22",commit:"a61294362226bd93052f5a40b4a1b1269a99ce69",license:"Apache-2.0"});let o="127.0.0.1";function p(){let a=Number(process.env.LLV_TELEGRAM_MCP_PORT);return Number.isInteger(a)&&a>0&&a<65536?a:8809}function q(){return`http://${o}:${p()}/mcp`}function r(a,...b){if(a)return a;let c=j().join(process.cwd(),...b);if(f().existsSync(c))return c;let d=j().join(process.cwd(),"..","..",...b);return f().existsSync(d)?d:c}function s(){return r(process.env.LLV_TELEGRAM_VENDOR_DIR,"vendor","telegram-mcp")}function t(){return(0,k.BQ)("telegram","venv")}function u(){return(0,k.BQ)("telegram","vendor-src")}function v(){return process.env.LLV_TELEGRAM_PYTHON||j().join(t(),"bin","python")}function w(){return r(process.env.LLV_TELEGRAM_SERVER_BRIDGE,"bin","telegram-mcp-server.py")}function x(){return r(process.env.LLV_TELEGRAM_SESSION_READER,"bin","telegram-session-reader.mjs")}let y=Object.freeze(["wait_for_settled_message"]);function z(){let a=process.env.LLV_TELEGRAM_API_ID,b=process.env.LLV_TELEGRAM_API_HASH;if(a&&b)return{apiId:a,apiHash:b};try{let a=JSON.parse(f().readFileSync((0,k.ks)("telegram.json"),"utf8"));if("string"==typeof a.apiId&&a.apiId&&"string"==typeof a.apiHash&&a.apiHash)return{apiId:a.apiId,apiHash:a.apiHash}}catch{}return null}function A(){return f().existsSync(j().join(t(),".llv-provisioned"))&&f().existsSync(v())&&f().existsSync(j().join(u(),"pyproject.toml"))}let B=null;function C(){return A()?Promise.resolve(!0):B||(B=(async()=>((0,n._q)(!0),await (0,l.pM)((0,k.BQ)("telegram","connector-provision"),"Telegram connector provisioning is busy",async()=>{var a;return!!A()||await (a={command:process.execPath,args:[r(process.env.LLV_TELEGRAM_PROVISIONER,"bin","provision-telegram-connector.mjs")],cwd:s(),env:{...F(),LLV_STATE_DIR:(0,k.Pn)(),LLV_TELEGRAM_VENDOR_DIR:s(),LLV_TELEGRAM_PYTHON:v()}},new Promise(b=>{let c;try{c=(0,d.spawn)(a.command,a.args,{cwd:a.cwd,env:a.env,stdio:"ignore"})}catch{b(!1);return}c.once("error",()=>b(!1)),c.once("exit",a=>b(0===a))}))&&A()})))().catch(()=>!1).finally(()=>{B=null}))}function D(a){let b=u(),c=(0,m.WG)();return{command:v(),args:[w()],cwd:b,env:{...F(),...c,TELEGRAM_API_ID:a.credentials.apiId,TELEGRAM_API_HASH:a.credentials.apiHash,TELEGRAM_SESSION_STRING:a.sessionString,TELEGRAM_EXPOSED_TOOLS:"read-only",TELEGRAM_EVENT_FEED:"1",TELEGRAM_EVENT_FEED_FILE:(0,n.ZI)(a.credentialRef),LLV_TELEGRAM_EXCLUDED_TOOLS:y.join(","),LLV_TELEGRAM_MCP_TOKEN:a.connectorToken,LLV_TELEGRAM_VENDOR_DIR:b,MCP_TRANSPORT:"http",MCP_HOST:o,MCP_PORT:String(p())}}}function E(a,b){return{command:v(),args:[r(process.env.LLV_TELEGRAM_BRIDGE,"bin","telegram-login-bridge.py"),a],cwd:h().homedir(),env:{...F(),TELEGRAM_API_ID:b.apiId,TELEGRAM_API_HASH:b.apiHash}}}function F(){let a={};for(let b of["PATH","HOME","LANG","LC_ALL","TMPDIR"])void 0!==process.env[b]&&(a[b]=process.env[b]);return a}},51888:(a,b,c)=>{c.d(b,{Gh:()=>l,JL:()=>i,OV:()=>n,RC:()=>k,c7:()=>d,cC:()=>j,fC:()=>f,g9:()=>q,ll:()=>p,wi:()=>r});let d="gpt-6-astra",e="gpt-5.6-sol",f="gpt-5.6-terra",g="gpt-5.6-luna",h=new Set([d,e,f,g,"gpt-5.5","gpt-5.4","gpt-5.4-mini"]);function i(a){return!a?.trim()||h.has(a.trim())}let j={claude:[{id:"opus",label:"Opus 5",shortLabel:"Opus 5",use:"review"},{id:"fable",label:"Fable",shortLabel:"Fable",use:"general"},{id:"sonnet",label:"Sonnet",shortLabel:"Sonnet",use:"implement"},{id:"haiku",label:"Haiku",shortLabel:"Haiku",use:"general"}],codex:[{id:d,label:"GPT-6-Astra",shortLabel:"6-Astra",use:"review"},{id:e,label:"GPT-5.6-Sol",shortLabel:"5.6-Sol",use:"review"},{id:f,label:"GPT-5.6-Terra",shortLabel:"5.6-Terra",use:"implement"},{id:g,label:"GPT-5.6-Luna",shortLabel:"5.6-Luna",use:"general"}]};function k(a,b){let c=b.trim(),d=j[a].map(a=>a.id);return d.includes(c)?{model:c}:{error:`invalid ${a} model id ${JSON.stringify(c)}; valid ${a} model ids: ${d.join(", ")}`}}function l(a){return"codex"===a?d:"opus"}let m=["fable","opus","sonnet","haiku"];function n(a){if("string"!=typeof a)return null;let b=a.trim().toLowerCase();if(!b||b.length>128||/[\u0000-\u001f\u007f]/.test(b))return null;for(let a of m)if(b===a||RegExp(`(?:^|[-_.])${a}(?:[-_.]|$)`).test(b))return a;return null}let o=new Set(["fable","opus"]);function p(a){let b=n(a);return null===b||o.has(b)}function q(a){if("string"!=typeof a)return!1;let b=a.trim();return b.startsWith("gpt-")&&b.length<=128&&!/[\u0000-\u001f\u007f]/.test(b)}function r(a){if(void 0===a.model||null===a.model||""===a.model)return{model:null};if("string"!=typeof a.model)return{model:null,error:"model must be a string"};let b=a.model.trim();return b?b.length>128||/[\u0000-\u001f\u007f]/.test(b)?{model:null,error:"model must be a printable id up to 128 characters"}:{model:b}:{model:null}}},55541:(a,b,c)=>{c.d(b,{WG:()=>o,cO:()=>n,yb:()=>l});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(19777);let l=262144,m=String.raw`import fcntl
1
+ "use strict";exports.id=9298,exports.ids=[6277,9298],exports.modules={26277:(a,b,c)=>{c.d(b,{Gs:()=>C,Kn:()=>w,gY:()=>x,h3:()=>q,jd:()=>v,kt:()=>E,ue:()=>D,vx:()=>y,w5:()=>z});var d=c(31421);c(77598);var e=c(73024),f=c.n(e),g=c(48161),h=c.n(g),i=c(76760),j=c.n(i),k=c(27146),l=c(89204),m=c(55541),n=c(19777);Object.freeze({repo:"https://github.com/chigwell/telegram-mcp",release:"v3.2.22",commit:"a61294362226bd93052f5a40b4a1b1269a99ce69",license:"Apache-2.0"});let o="127.0.0.1";function p(){let a=Number(process.env.LLV_TELEGRAM_MCP_PORT);return Number.isInteger(a)&&a>0&&a<65536?a:8809}function q(){return`http://${o}:${p()}/mcp`}function r(a,...b){if(a)return a;let c=j().join(process.cwd(),...b);if(f().existsSync(c))return c;let d=j().join(process.cwd(),"..","..",...b);return f().existsSync(d)?d:c}function s(){return r(process.env.LLV_TELEGRAM_VENDOR_DIR,"vendor","telegram-mcp")}function t(){return(0,k.BQ)("telegram","venv")}function u(){return(0,k.BQ)("telegram","vendor-src")}function v(){return process.env.LLV_TELEGRAM_PYTHON||j().join(t(),"bin","python")}function w(){return r(process.env.LLV_TELEGRAM_SERVER_BRIDGE,"bin","telegram-mcp-server.py")}function x(){return r(process.env.LLV_TELEGRAM_SESSION_READER,"bin","telegram-session-reader.mjs")}let y=Object.freeze(["wait_for_settled_message"]);function z(){let a=process.env.LLV_TELEGRAM_API_ID,b=process.env.LLV_TELEGRAM_API_HASH;if(a&&b)return{apiId:a,apiHash:b};try{let a=JSON.parse(f().readFileSync((0,k.ks)("telegram.json"),"utf8"));if("string"==typeof a.apiId&&a.apiId&&"string"==typeof a.apiHash&&a.apiHash)return{apiId:a.apiId,apiHash:a.apiHash}}catch{}return null}function A(){return f().existsSync(j().join(t(),".llv-provisioned"))&&f().existsSync(v())&&f().existsSync(j().join(u(),"pyproject.toml"))}let B=null;function C(){return A()?Promise.resolve(!0):B||(B=(async()=>((0,n._q)(!0),await (0,l.pM)((0,k.BQ)("telegram","connector-provision"),"Telegram connector provisioning is busy",async()=>{var a;return!!A()||await (a={command:process.execPath,args:[r(process.env.LLV_TELEGRAM_PROVISIONER,"bin","provision-telegram-connector.mjs")],cwd:s(),env:{...F(),LLV_STATE_DIR:(0,k.Pn)(),LLV_TELEGRAM_VENDOR_DIR:s(),LLV_TELEGRAM_PYTHON:v()}},new Promise(b=>{let c;try{c=(0,d.spawn)(a.command,a.args,{cwd:a.cwd,env:a.env,stdio:"ignore"})}catch{b(!1);return}c.once("error",()=>b(!1)),c.once("exit",a=>b(0===a))}))&&A()})))().catch(()=>!1).finally(()=>{B=null}))}function D(a){let b=u(),c=(0,m.WG)();return{command:v(),args:[w()],cwd:b,env:{...F(),...c,TELEGRAM_API_ID:a.credentials.apiId,TELEGRAM_API_HASH:a.credentials.apiHash,TELEGRAM_SESSION_STRING:a.sessionString,TELEGRAM_EXPOSED_TOOLS:"read-only",TELEGRAM_EVENT_FEED:"1",TELEGRAM_EVENT_FEED_FILE:(0,n.ZI)(a.credentialRef),LLV_TELEGRAM_EXCLUDED_TOOLS:y.join(","),LLV_TELEGRAM_MCP_TOKEN:a.connectorToken,LLV_TELEGRAM_VENDOR_DIR:b,MCP_TRANSPORT:"http",MCP_HOST:o,MCP_PORT:String(p())}}}function E(a,b){return{command:v(),args:[r(process.env.LLV_TELEGRAM_BRIDGE,"bin","telegram-login-bridge.py"),a],cwd:h().homedir(),env:{...F(),TELEGRAM_API_ID:b.apiId,TELEGRAM_API_HASH:b.apiHash}}}function F(){let a={};for(let b of["PATH","HOME","LANG","LC_ALL","TMPDIR"])void 0!==process.env[b]&&(a[b]=process.env[b]);return a}},55541:(a,b,c)=>{c.d(b,{WG:()=>o,cO:()=>n,yb:()=>l});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(19777);let l=262144,m=String.raw`import fcntl
2
2
  import io
3
3
  import os
4
4
  import stat
@@ -78,5 +78,5 @@ class _BoundedConnectorLog(io.TextIOBase):
78
78
  _sink = _BoundedConnectorLog()
79
79
  sys.stdout = _sink
80
80
  sys.stderr = _sink
81
- `;function n(){return(0,j.BQ)("telegram","connector.log")}function o(){(0,k._q)(!0);let a=(0,j.BQ)("telegram","connector-log-sink");g().mkdirSync(a,{recursive:!0,mode:448});let b=g().lstatSync(a);if(!b.isDirectory()||b.isSymbolicLink()||(63&b.mode)!=0||"function"==typeof process.getuid&&b.uid!==process.getuid())throw Error("unsafe connector log sink directory");let c=i().join(a,"sitecustomize.py"),d=`${c}.${process.pid}.${e().randomUUID()}.tmp`;try{g().writeFileSync(d,m,{flag:"wx",mode:384}),g().renameSync(d,c),g().chmodSync(c,384)}finally{g().rmSync(d,{force:!0})}return!function(){let a="O_NOFOLLOW"in g().constants?g().constants.O_NOFOLLOW:0,b=g().openSync(n(),g().constants.O_RDWR|g().constants.O_CREAT|a,384);try{let a=g().fstatSync(b);if(!a.isFile()||(63&a.mode)!=0||"function"==typeof process.getuid&&a.uid!==process.getuid())throw Error("unsafe connector log");if(a.size<=l)return;let c=Buffer.alloc(l);g().readSync(b,c,0,c.length,a.size-c.length),g().ftruncateSync(b,0),g().writeSync(b,c,0,c.length,0)}finally{g().closeSync(b)}}(),{PYTHONPATH:a,LLV_TELEGRAM_CONNECTOR_LOG:n(),LLV_TELEGRAM_CONNECTOR_LOG_MAX_BYTES:String(l)}}},60156:(a,b,c)=>{c.r(b),c.d(b,{FLOW_PIPELINE_WATCHDOG_MS:()=>p,FlowPipelineController:()=>s,controllerFileScan:()=>r,flowPipelineController:()=>v,startFlowPipelineController:()=>w,startFlowPipelineControllerRuntime:()=>t,writeFlowPipelineControllerHeartbeat:()=>q});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(19190),l=c(58444),m=c(20576),n=c(17665),o=c(18027);let p=3e4;function q(a,b=(0,j.BQ)("flow-pipeline-controller-heartbeat.json")){g().mkdirSync(i().dirname(b),{recursive:!0,mode:448});let c=i().join(i().dirname(b),`.${i().basename(b)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,`${JSON.stringify(a,null,2)}
81
+ `;function n(){return(0,j.BQ)("telegram","connector.log")}function o(){(0,k._q)(!0);let a=(0,j.BQ)("telegram","connector-log-sink");g().mkdirSync(a,{recursive:!0,mode:448});let b=g().lstatSync(a);if(!b.isDirectory()||b.isSymbolicLink()||(63&b.mode)!=0||"function"==typeof process.getuid&&b.uid!==process.getuid())throw Error("unsafe connector log sink directory");let c=i().join(a,"sitecustomize.py"),d=`${c}.${process.pid}.${e().randomUUID()}.tmp`;try{g().writeFileSync(d,m,{flag:"wx",mode:384}),g().renameSync(d,c),g().chmodSync(c,384)}finally{g().rmSync(d,{force:!0})}return!function(){let a="O_NOFOLLOW"in g().constants?g().constants.O_NOFOLLOW:0,b=g().openSync(n(),g().constants.O_RDWR|g().constants.O_CREAT|a,384);try{let a=g().fstatSync(b);if(!a.isFile()||(63&a.mode)!=0||"function"==typeof process.getuid&&a.uid!==process.getuid())throw Error("unsafe connector log");if(a.size<=l)return;let c=Buffer.alloc(l);g().readSync(b,c,0,c.length,a.size-c.length),g().ftruncateSync(b,0),g().writeSync(b,c,0,c.length,0)}finally{g().closeSync(b)}}(),{PYTHONPATH:a,LLV_TELEGRAM_CONNECTOR_LOG:n(),LLV_TELEGRAM_CONNECTOR_LOG_MAX_BYTES:String(l)}}},60156:(a,b,c)=>{c.r(b),c.d(b,{FLOW_PIPELINE_WATCHDOG_MS:()=>p,FlowPipelineController:()=>s,controllerFileScan:()=>r,flowPipelineController:()=>v,startFlowPipelineController:()=>w,startFlowPipelineControllerRuntime:()=>t,writeFlowPipelineControllerHeartbeat:()=>q});var d=c(77598),e=c.n(d),f=c(73024),g=c.n(f),h=c(76760),i=c.n(h),j=c(27146),k=c(81970),l=c(58444),m=c(1690),n=c(88370),o=c(18027);let p=3e4;function q(a,b=(0,j.BQ)("flow-pipeline-controller-heartbeat.json")){g().mkdirSync(i().dirname(b),{recursive:!0,mode:448});let c=i().join(i().dirname(b),`.${i().basename(b)}.${process.pid}.${e().randomUUID()}.tmp`);g().writeFileSync(c,`${JSON.stringify(a,null,2)}
82
82
  `,{encoding:"utf8",mode:384}),g().renameSync(c,b)}async function r(){let a=await (0,l.Nm)();return{files:a.snapshot.files,complete:a.snapshot.complete}}class s{constructor(a,b={}){this.running=null,this.trailingCycleRequested=!1,this.trailingTrigger="signal",this.cycle=0,this.lastArchiveSweepAt=0,this.activePhases=new Map,this.ports={...a,scan:a.scan??(async()=>({files:[],complete:!0})),now:a.now??Date.now,scheduleTimeout:a.scheduleTimeout??((a,b)=>setTimeout(a,b)),clearTimeout:a.clearTimeout??(a=>clearTimeout(a)),publishHeartbeat:a.publishHeartbeat??(()=>void 0),log:a.log??((a,b)=>{void 0===b?console.error(a):console.error(a,b)})},this.phaseDeadlineMs=b.phaseDeadlineMs??15e3,this.maxPasses=b.maxPasses??8}tick(a="signal"){return this.running?(this.trailingCycleRequested=!0,this.trailingTrigger=a):this.running=this.runRequestedCycles(a).finally(()=>{if(this.running=null,this.trailingCycleRequested)return this.tick(this.trailingTrigger)}),this.running}poll(){return this.running??this.tick("watchdog")}recover(){return this.tick("startup")}async runRequestedCycles(a){let b=a;do this.trailingCycleRequested=!1,await this.runCycle(b),b=this.trailingTrigger;while(this.trailingCycleRequested)}async runCycle(a){let b=++this.cycle,c=0,d=[],e=!1;for(let f=1;f<=this.maxPasses;f+=1){c=f;let g=await this.runPhase("pipelines",b,f,a,()=>this.ports.tickPipelines(d)),h=1===f?await this.runPhase("scan",b,f,a,this.ports.scan):null;if(h?.state==="failed")throw h.error;h?.state==="completed"&&h.value.complete&&(d=h.value.files,e=!0);let i=e?await this.runPhase("flows",b,f,a,()=>this.ports.tickFlows(d)):null,j="failed"===g.state?g.error:i?.state==="failed"?i.error:null;if(null!==j)throw j;if(!("completed"===g.state&&g.value.changed||i?.state==="completed"&&i.value.changed||h?.state==="completed"&&h.value.complete))break}this.sweepSettledArchive();let f=[...this.activePhases.entries()].sort((a,b)=>a[1].startedAt-b[1].startedAt)[0];f?this.publish({cycle:b,pass:c,trigger:a,phase:f[0],state:"blocked",startedAt:f[1].startedAt}):this.publish({cycle:b,pass:c,trigger:a,phase:"idle",state:"idle",startedAt:this.ports.now()})}sweepSettledArchive(){let a=this.ports.now();a-this.lastArchiveSweepAt<36e5||(this.lastArchiveSweepAt=a,(0,o.archiveSettledPipelines)(a).then(a=>{a>0&&this.ports.log(`[flow pipeline controller] archived ${a} settled pipeline record(s)`)}).catch(a=>{this.ports.log("[flow pipeline controller] settled pipeline archive sweep failed",a)}))}async runPhase(a,b,c,d,e){let f=this.activePhases.get(a);if(f)return this.publish({cycle:b,pass:c,trigger:d,phase:a,state:"blocked",startedAt:f.startedAt}),{state:"blocked"};let g=this.ports.now();this.publish({cycle:b,pass:c,trigger:d,phase:a,state:"running",startedAt:g});let h=Promise.resolve().then(e),i={startedAt:g,promise:h};this.activePhases.set(a,i),h.then(()=>{this.activePhases.get(a)===i&&this.activePhases.delete(a)},()=>{this.activePhases.get(a)===i&&this.activePhases.delete(a)});let j=()=>{},k=new Promise(a=>{j=()=>a({state:"timed-out"})}),l=this.ports.scheduleTimeout(j,this.phaseDeadlineMs),m=await Promise.race([h.then(a=>({state:"completed",value:a}),a=>({state:"failed",error:a})),k]);return this.ports.clearTimeout(l),this.publish({cycle:b,pass:c,trigger:d,phase:a,state:m.state,startedAt:g}),"failed"===m.state?this.ports.log(`[flow pipeline controller] ${a} phase failed`,m.error):"timed-out"===m.state&&this.ports.log(`[flow pipeline controller] ${a} phase exceeded its deadline`),m}publish(a){let b=this.ports.now();try{this.ports.publishHeartbeat({schemaVersion:1,controller:"flow-pipeline",cycle:a.cycle,pass:a.pass,trigger:a.trigger,phase:a.phase,state:a.state,phaseStartedAt:new Date(a.startedAt).toISOString(),updatedAt:new Date(b).toISOString(),ageMs:Math.max(0,b-a.startedAt),deadlineMs:this.phaseDeadlineMs})}catch(a){this.ports.log("[flow pipeline controller] durable heartbeat publication failed",a)}}}function t(a,b,c){b.__llvFlowPipelineUnregister?.(),b.__llvFlowPipelineUnregister=c.registerTick(()=>a.tick("signal")),b.__llvFlowPipelineWatchdog||(b.__llvFlowPipelineWatchdog=c.scheduleInterval(()=>void a.poll().catch(a=>{c.log("[flow pipeline controller] watchdog reconciliation failed",a)}),p),b.__llvFlowPipelineWatchdog.unref?.()),a.recover().catch(a=>{c.log("[flow pipeline controller] startup reconciliation failed",a)})}let u=globalThis;function v(){return u.__llvFlowPipelineController??=new s({scan:r,tickPipelines:n.n6,tickFlows:k.zn,publishHeartbeat:q})}function w(){t(v(),u,{registerTick:m.n_,scheduleInterval:(a,b)=>setInterval(a,b),log:(a,b)=>console.error(a,b)})}}};