@rubytech/create-sitedesk-code 0.1.610 → 0.1.611

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 (178) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +45 -23
  3. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +5 -0
  4. package/payload/platform/plugins/docs/references/telegram-guide.md +44 -22
  5. package/payload/server/public/activity.html +6 -6
  6. package/payload/server/public/agents.html +5 -5
  7. package/payload/server/public/assets/{AdminLoginScreens-uk2gBvI9.js → AdminLoginScreens-Bjsr45ed.js} +1 -1
  8. package/payload/server/public/assets/AdminLoginScreens-Bjsr45ed.js.br +0 -0
  9. package/payload/server/public/assets/AdminLoginScreens-Bjsr45ed.js.gz +0 -0
  10. package/payload/server/public/assets/{AdminShell-DyOPTLdb.js → AdminShell-Dm_nY4jF.js} +1 -1
  11. package/payload/server/public/assets/AdminShell-Dm_nY4jF.js.br +0 -0
  12. package/payload/server/public/assets/AdminShell-Dm_nY4jF.js.gz +0 -0
  13. package/payload/server/public/assets/{activity-DfIud5UH.js → activity-Dz5eWZze.js} +1 -1
  14. package/payload/server/public/assets/activity-Dz5eWZze.js.br +0 -0
  15. package/payload/server/public/assets/activity-Dz5eWZze.js.gz +0 -0
  16. package/payload/server/public/assets/{admin-Duy2d3ks.js → admin-B2IkUoSc.js} +1 -1
  17. package/payload/server/public/assets/admin-B2IkUoSc.js.br +0 -0
  18. package/payload/server/public/assets/admin-B2IkUoSc.js.gz +0 -0
  19. package/payload/server/public/assets/{agents-Rcdk-pni.js → agents-DjDwemOg.js} +1 -1
  20. package/payload/server/public/assets/agents-DjDwemOg.js.br +0 -0
  21. package/payload/server/public/assets/agents-DjDwemOg.js.gz +0 -0
  22. package/payload/server/public/assets/{browser-Bt6h1Pjb.js → browser-BDFx14YM.js} +1 -1
  23. package/payload/server/public/assets/browser-BDFx14YM.js.br +0 -0
  24. package/payload/server/public/assets/browser-BDFx14YM.js.gz +0 -0
  25. package/payload/server/public/assets/{calendar-Di0yArmc.js → calendar-BbUsdMKW.js} +1 -1
  26. package/payload/server/public/assets/calendar-BbUsdMKW.js.br +0 -0
  27. package/payload/server/public/assets/calendar-BbUsdMKW.js.gz +0 -0
  28. package/payload/server/public/assets/chat-fP4sE4pU.js +1 -0
  29. package/payload/server/public/assets/chat-fP4sE4pU.js.br +2 -0
  30. package/payload/server/public/assets/chat-fP4sE4pU.js.gz +0 -0
  31. package/payload/server/public/assets/{chevron-left-QGcFX-3R.js → chevron-left-D3_hiHLC.js} +1 -1
  32. package/payload/server/public/assets/chevron-left-D3_hiHLC.js.br +0 -0
  33. package/payload/server/public/assets/clock-kLje910u.js +1 -0
  34. package/payload/server/public/assets/clock-kLje910u.js.br +0 -0
  35. package/payload/server/public/assets/clock-kLje910u.js.gz +0 -0
  36. package/payload/server/public/assets/{copy-RSaF-402.js → copy-Dnw0TkVh.js} +1 -1
  37. package/payload/server/public/assets/copy-Dnw0TkVh.js.br +0 -0
  38. package/payload/server/public/assets/copy-Dnw0TkVh.js.gz +0 -0
  39. package/payload/server/public/assets/data-DKz9_73S.js +1 -0
  40. package/payload/server/public/assets/data-DKz9_73S.js.br +1 -0
  41. package/payload/server/public/assets/data-DKz9_73S.js.gz +0 -0
  42. package/payload/server/public/assets/{field-nfpVNHyk.js → field-mhgbdofr.js} +1 -1
  43. package/payload/server/public/assets/field-mhgbdofr.js.br +0 -0
  44. package/payload/server/public/assets/field-mhgbdofr.js.gz +0 -0
  45. package/payload/server/public/assets/{file-text-Cws2LExM.js → file-text-CVZAL3Er.js} +1 -1
  46. package/payload/server/public/assets/file-text-CVZAL3Er.js.br +0 -0
  47. package/payload/server/public/assets/file-text-CVZAL3Er.js.gz +0 -0
  48. package/payload/server/public/assets/{graph-56nTCvKa.js → graph-NmOxFNdx.js} +1 -1
  49. package/payload/server/public/assets/graph-NmOxFNdx.js.br +0 -0
  50. package/payload/server/public/assets/graph-NmOxFNdx.js.gz +0 -0
  51. package/payload/server/public/assets/{graph-labels-qHDVYalh.js → graph-labels-BTFUSc63.js} +1 -1
  52. package/payload/server/public/assets/graph-labels-BTFUSc63.js.br +0 -0
  53. package/payload/server/public/assets/graph-labels-BTFUSc63.js.gz +0 -0
  54. package/payload/server/public/assets/{jsx-runtime-B5zQuMcr.css → jsx-runtime-dao9WPN0.css} +1 -1
  55. package/payload/server/public/assets/jsx-runtime-dao9WPN0.css.br +0 -0
  56. package/payload/server/public/assets/{jsx-runtime-B5zQuMcr.css.gz → jsx-runtime-dao9WPN0.css.gz} +0 -0
  57. package/payload/server/public/assets/{operator-D-P6oemk.js → operator-CO5ma-ky.js} +1 -1
  58. package/payload/server/public/assets/operator-CO5ma-ky.js.br +0 -0
  59. package/payload/server/public/assets/operator-CO5ma-ky.js.gz +0 -0
  60. package/payload/server/public/assets/{page-8goE0IWS.js → page-BBRWbFzG.js} +1 -1
  61. package/payload/server/public/assets/page-BBRWbFzG.js.br +0 -0
  62. package/payload/server/public/assets/page-BBRWbFzG.js.gz +0 -0
  63. package/payload/server/public/assets/page-CdRrpkky.js +1 -0
  64. package/payload/server/public/assets/page-CdRrpkky.js.br +0 -0
  65. package/payload/server/public/assets/page-CdRrpkky.js.gz +0 -0
  66. package/payload/server/public/assets/play-eeQX0FtC.js +1 -0
  67. package/payload/server/public/assets/play-eeQX0FtC.js.br +0 -0
  68. package/payload/server/public/assets/play-eeQX0FtC.js.gz +0 -0
  69. package/payload/server/public/assets/{public-BwfIj7tM.js → public-2mLo4k7L.js} +1 -1
  70. package/payload/server/public/assets/public-2mLo4k7L.js.br +0 -0
  71. package/payload/server/public/assets/public-2mLo4k7L.js.gz +0 -0
  72. package/payload/server/public/assets/{rotate-ccw-X7-7vE7t.js → rotate-ccw-D-2d4YGp.js} +1 -1
  73. package/payload/server/public/assets/rotate-ccw-D-2d4YGp.js.br +0 -0
  74. package/payload/server/public/assets/rotate-ccw-D-2d4YGp.js.gz +0 -0
  75. package/payload/server/public/assets/{routines-sFud5tka.js → routines-CMW8sm10.js} +1 -1
  76. package/payload/server/public/assets/routines-CMW8sm10.js.br +0 -0
  77. package/payload/server/public/assets/routines-CMW8sm10.js.gz +0 -0
  78. package/payload/server/public/assets/{skills-_Dc3eG9T.js → skills-BQC7SM0J.js} +1 -1
  79. package/payload/server/public/assets/skills-BQC7SM0J.js.br +0 -0
  80. package/payload/server/public/assets/skills-BQC7SM0J.js.gz +0 -0
  81. package/payload/server/public/assets/{tasks-C0u8AtqT.js → tasks-CIs0y00-.js} +1 -1
  82. package/payload/server/public/assets/tasks-CIs0y00-.js.br +0 -0
  83. package/payload/server/public/assets/tasks-CIs0y00-.js.gz +0 -0
  84. package/payload/server/public/assets/{triangle-alert-DD4kSK45.js → triangle-alert-C_68TrTq.js} +1 -1
  85. package/payload/server/public/assets/triangle-alert-C_68TrTq.js.br +0 -0
  86. package/payload/server/public/assets/triangle-alert-C_68TrTq.js.gz +0 -0
  87. package/payload/server/public/assets/{useCopyFeedback-Dq-Putj7.js → useCopyFeedback-1MKNUzp3.js} +1 -1
  88. package/payload/server/public/assets/useCopyFeedback-1MKNUzp3.js.br +0 -0
  89. package/payload/server/public/assets/useCopyFeedback-1MKNUzp3.js.gz +0 -0
  90. package/payload/server/public/assets/{useMediaQuery-Cm_fvNIH.js → useMediaQuery-e4ciNiuO.js} +1 -1
  91. package/payload/server/public/assets/useMediaQuery-e4ciNiuO.js.br +0 -0
  92. package/payload/server/public/assets/useMediaQuery-e4ciNiuO.js.gz +0 -0
  93. package/payload/server/public/assets/{useVoiceRecorder-C6xqnm7i.js → useVoiceRecorder-D7_wLtrS.js} +1 -1
  94. package/payload/server/public/assets/useVoiceRecorder-D7_wLtrS.js.br +0 -0
  95. package/payload/server/public/assets/{useVoiceRecorder-C6xqnm7i.js.gz → useVoiceRecorder-D7_wLtrS.js.gz} +0 -0
  96. package/payload/server/public/assets/{wrench-Bjw6eVl_.js → wrench-BI28h1JF.js} +1 -1
  97. package/payload/server/public/assets/wrench-BI28h1JF.js.br +0 -0
  98. package/payload/server/public/assets/wrench-BI28h1JF.js.gz +0 -0
  99. package/payload/server/public/browser.html +5 -5
  100. package/payload/server/public/calendar.html +8 -8
  101. package/payload/server/public/chat.html +14 -14
  102. package/payload/server/public/data.html +12 -12
  103. package/payload/server/public/field.html +3 -3
  104. package/payload/server/public/graph.html +10 -10
  105. package/payload/server/public/index.html +14 -14
  106. package/payload/server/public/operator.html +16 -16
  107. package/payload/server/public/public.html +14 -14
  108. package/payload/server/public/routines.html +8 -8
  109. package/payload/server/public/skills.html +6 -6
  110. package/payload/server/public/tasks.html +7 -7
  111. package/payload/server/server.js +650 -528
  112. package/payload/server/public/assets/AdminLoginScreens-uk2gBvI9.js.br +0 -0
  113. package/payload/server/public/assets/AdminLoginScreens-uk2gBvI9.js.gz +0 -0
  114. package/payload/server/public/assets/AdminShell-DyOPTLdb.js.br +0 -0
  115. package/payload/server/public/assets/AdminShell-DyOPTLdb.js.gz +0 -0
  116. package/payload/server/public/assets/activity-DfIud5UH.js.br +0 -0
  117. package/payload/server/public/assets/activity-DfIud5UH.js.gz +0 -0
  118. package/payload/server/public/assets/admin-Duy2d3ks.js.br +0 -0
  119. package/payload/server/public/assets/admin-Duy2d3ks.js.gz +0 -0
  120. package/payload/server/public/assets/agents-Rcdk-pni.js.br +0 -0
  121. package/payload/server/public/assets/agents-Rcdk-pni.js.gz +0 -0
  122. package/payload/server/public/assets/browser-Bt6h1Pjb.js.br +0 -0
  123. package/payload/server/public/assets/browser-Bt6h1Pjb.js.gz +0 -0
  124. package/payload/server/public/assets/calendar-Di0yArmc.js.br +0 -0
  125. package/payload/server/public/assets/calendar-Di0yArmc.js.gz +0 -0
  126. package/payload/server/public/assets/chat-xJTrFY2U.js +0 -1
  127. package/payload/server/public/assets/chat-xJTrFY2U.js.br +0 -1
  128. package/payload/server/public/assets/chat-xJTrFY2U.js.gz +0 -0
  129. package/payload/server/public/assets/chevron-left-QGcFX-3R.js.br +0 -0
  130. package/payload/server/public/assets/clock-PkEm8y4i.js +0 -1
  131. package/payload/server/public/assets/clock-PkEm8y4i.js.br +0 -0
  132. package/payload/server/public/assets/clock-PkEm8y4i.js.gz +0 -0
  133. package/payload/server/public/assets/copy-RSaF-402.js.br +0 -0
  134. package/payload/server/public/assets/copy-RSaF-402.js.gz +0 -0
  135. package/payload/server/public/assets/data-CLmmCyzs.js +0 -1
  136. package/payload/server/public/assets/data-CLmmCyzs.js.br +0 -1
  137. package/payload/server/public/assets/data-CLmmCyzs.js.gz +0 -0
  138. package/payload/server/public/assets/field-nfpVNHyk.js.br +0 -0
  139. package/payload/server/public/assets/field-nfpVNHyk.js.gz +0 -0
  140. package/payload/server/public/assets/file-text-Cws2LExM.js.br +0 -0
  141. package/payload/server/public/assets/file-text-Cws2LExM.js.gz +0 -0
  142. package/payload/server/public/assets/graph-56nTCvKa.js.br +0 -0
  143. package/payload/server/public/assets/graph-56nTCvKa.js.gz +0 -0
  144. package/payload/server/public/assets/graph-labels-qHDVYalh.js.br +0 -0
  145. package/payload/server/public/assets/graph-labels-qHDVYalh.js.gz +0 -0
  146. package/payload/server/public/assets/jsx-runtime-B5zQuMcr.css.br +0 -0
  147. package/payload/server/public/assets/operator-D-P6oemk.js.br +0 -2
  148. package/payload/server/public/assets/operator-D-P6oemk.js.gz +0 -0
  149. package/payload/server/public/assets/page-8goE0IWS.js.br +0 -0
  150. package/payload/server/public/assets/page-8goE0IWS.js.gz +0 -0
  151. package/payload/server/public/assets/page-iL446JAc.js +0 -1
  152. package/payload/server/public/assets/page-iL446JAc.js.br +0 -0
  153. package/payload/server/public/assets/page-iL446JAc.js.gz +0 -0
  154. package/payload/server/public/assets/play-B8bxRax6.js +0 -1
  155. package/payload/server/public/assets/play-B8bxRax6.js.br +0 -0
  156. package/payload/server/public/assets/play-B8bxRax6.js.gz +0 -0
  157. package/payload/server/public/assets/public-BwfIj7tM.js.br +0 -0
  158. package/payload/server/public/assets/public-BwfIj7tM.js.gz +0 -0
  159. package/payload/server/public/assets/rotate-ccw-X7-7vE7t.js.br +0 -0
  160. package/payload/server/public/assets/rotate-ccw-X7-7vE7t.js.gz +0 -0
  161. package/payload/server/public/assets/routines-sFud5tka.js.br +0 -0
  162. package/payload/server/public/assets/routines-sFud5tka.js.gz +0 -0
  163. package/payload/server/public/assets/skills-_Dc3eG9T.js.br +0 -0
  164. package/payload/server/public/assets/skills-_Dc3eG9T.js.gz +0 -0
  165. package/payload/server/public/assets/tasks-C0u8AtqT.js.br +0 -0
  166. package/payload/server/public/assets/tasks-C0u8AtqT.js.gz +0 -0
  167. package/payload/server/public/assets/triangle-alert-DD4kSK45.js.br +0 -0
  168. package/payload/server/public/assets/triangle-alert-DD4kSK45.js.gz +0 -0
  169. package/payload/server/public/assets/useCopyFeedback-Dq-Putj7.js.br +0 -0
  170. package/payload/server/public/assets/useCopyFeedback-Dq-Putj7.js.gz +0 -0
  171. package/payload/server/public/assets/useMediaQuery-Cm_fvNIH.js.br +0 -0
  172. package/payload/server/public/assets/useMediaQuery-Cm_fvNIH.js.gz +0 -0
  173. package/payload/server/public/assets/useVoiceRecorder-C6xqnm7i.js.br +0 -0
  174. package/payload/server/public/assets/wrench-Bjw6eVl_.js.br +0 -0
  175. package/payload/server/public/assets/wrench-Bjw6eVl_.js.gz +0 -0
  176. /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js → jsx-runtime-BY35JYDT.js} +0 -0
  177. /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js.br → jsx-runtime-BY35JYDT.js.br} +0 -0
  178. /package/payload/server/public/assets/{jsx-runtime-DeRQuYlX.js.gz → jsx-runtime-BY35JYDT.js.gz} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-sitedesk-code",
3
- "version": "0.1.610",
3
+ "version": "0.1.611",
4
4
  "description": "Install SiteDesk — automated back office for independent building contractors",
5
5
  "bin": {
6
6
  "create-sitedesk-code": "./dist/index.js"
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: platform-architecture
3
3
  description: Use when grounding any documented-surface claim about what SiteDesk ships — plugins, skills, specialists, install/deploy flows, internals. This is the install catalogue, not evidence of what is enabled on the current account. For install state on this account, call `capabilities-here`; for documented surface, cite the `Source:` URL inline.
4
- content-hash: sha256:10a85aebfe311aca7adc6d999fd75ed0b233f35c57f4bf26006e4c76cb170ecc
4
+ content-hash: sha256:0dc53f94b5b4c397c2debe144a846e140121e86dacaa9ed4d8c82b72cca56487
5
5
  brand: sitedesk-code
6
6
  product-name: SiteDesk
7
7
  ---
@@ -3060,21 +3060,37 @@ from the dashboard.
3060
3060
  ### What the agent knows about a message you typed
3061
3061
 
3062
3062
  When you type into a public bot's conversation, that agent's own memory is
3063
- updated with what you sent, so its next answer does not contradict you. It knows
3064
- the words came from you and that the visitor has already received them, so it
3065
- sends nothing in reply. The visitor sees one message, yours.
3063
+ updated with what you sent, so its next answer does not contradict you. The
3064
+ visitor sees one message, yours.
3066
3065
 
3067
3066
  This matters because without it the agent carries on from what it believed. On a
3068
3067
  live conversation an operator sent a visitor the real prices by hand, and the
3069
3068
  agent's memory still held a visitor asking for a price it had never given.
3070
3069
 
3071
- Four situations record nothing, and each one says which in the log rather than
3072
- failing quietly:
3070
+ There are two ways your words get there, and which one runs depends on whether
3071
+ that conversation has an agent running at that moment and whether the bot is
3072
+ switched on.
3073
+
3074
+ **The agent is running and the bot is on.** Your message is handed straight to
3075
+ it. It knows the words came from you and that the visitor already has them, so
3076
+ it sends nothing in reply.
3077
+
3078
+ **Anything else, including a bot you have switched off.** Your words are written
3079
+ into that conversation's own record, as something the agent's side already said.
3080
+ No agent is started and no reply is composed. The next time that conversation
3081
+ runs, it picks your words up and carries on from them.
3082
+
3083
+ That second case is the one that matters most, because switching the bot off is
3084
+ exactly when you answer people by hand. Switch it off, answer a few visitors
3085
+ yourself, switch it back on, and the agent resumes knowing what you said on its
3086
+ behalf. It never wakes up while you have it switched off.
3087
+
3088
+ Three situations record nothing, and each says which in the log rather than
3089
+ failing quietly. The send still goes out in all three, and the send box now
3090
+ shows you the reason:
3073
3091
 
3074
3092
  - The bot is not a public bot. Your own admin bot and any specialist bot are
3075
3093
  conversations with your own side, so there is no agent knowledge to correct.
3076
- - The agent has been switched off. Nothing is woken behind your back, which is
3077
- the whole point of having switched it off. Your message still goes out.
3078
3094
  - The chat belongs to a connected business account. Those conversations are held
3079
3095
  separately and this route cannot reach them.
3080
3096
  - The conversation has not started yet. There is nothing to keep consistent, and
@@ -3083,23 +3099,29 @@ failing quietly:
3083
3099
  To check it is working, look at the log after sending:
3084
3100
 
3085
3101
  ```bash
3086
- grep -hE 'op=(sent|context-recorded)|telegram-manual-census|op=text-suppressed' ~/.maxy-code/logs/server.log
3102
+ grep -hE 'op=(sent|context)|telegram-manual-census|op=text-suppressed' ~/.maxy-code/logs/server.log
3087
3103
  ```
3088
3104
 
3089
- A healthy send shows one `op=sent … ok=true`, one `op=context-recorded
3090
- suppressed=yes reason=-`, and one `op=text-suppressed reason=operator-sent` for
3091
- that conversation. The standing line
3092
- `[telegram-manual-census] sent=N recorded=N suppressed=N unrecorded=0 skipped=0
3093
- leaked=0 window=60m` should show `recorded` and `suppressed` both equal to `sent`,
3094
- once the four situations above are set aside.
3095
-
3096
- - **`unrecorded`** above zero: a send reached no conversation and nothing said
3097
- why.
3098
- - **`leaked`** above zero: a send reached a conversation, and ten minutes later
3099
- nothing had reported holding that turn's reply back. Either the agent never
3100
- woke, or it answered on top of your message and the visitor saw it twice.
3101
- - **`skipped`** above zero is normal. It is one of the four situations above, and
3102
- the `reason=` on that send's own line says which.
3105
+ A healthy send shows one `op=sent … ok=true` and one `op=context …
3106
+ mechanism=inject|append written=yes reason=-`. On `mechanism=inject` there is
3107
+ also one `op=text-suppressed reason=operator-sent`, which is the agent's reply
3108
+ being held back so the visitor is not told twice. On `mechanism=append` there is
3109
+ none, because no reply was ever composed.
3110
+
3111
+ The standing line is
3112
+ `[telegram-manual-census] sent=N injected=N written=N suppressed=N unrecorded=0
3113
+ skipped=0 leaked=0 window=60m`, and `injected + written + skipped` should equal
3114
+ `sent`.
3115
+
3116
+ - **`unrecorded`** above zero: a send reached neither a running agent nor the
3117
+ conversation record, and nothing said why.
3118
+ - **`leaked`** above zero: a send was handed to a running agent, and ten minutes
3119
+ later nothing had reported holding that turn's reply back. Either the agent
3120
+ never took the turn, or it answered on top of your message and the visitor saw
3121
+ it twice. This only ever counts the handed-straight-over case; a written one
3122
+ composes no reply, so it has nothing to hold back.
3123
+ - **`skipped`** above zero is normal. It is one of the three situations above,
3124
+ and the `reason=` on that send's own line says which.
3103
3125
 
3104
3126
  ## Building your own Telegram functionality
3105
3127
 
@@ -9,6 +9,11 @@ Invoked by the admin agent directly.
9
9
 
10
10
  This is the platform's release timeline, newest first. Each entry shows the date it shipped and the version it shipped in, so you can tell the operator how current their install is. To compare, read the installed version from `capabilities-here` and match it against the versions below. Keep answers high level and in plain English; this is a summary, not a full commit log.
11
11
 
12
+ ## 2026-08-15 (0.1.611)
13
+
14
+ - A message you send by hand to a switched-off agent is now recorded in the conversation instead of being refused. It was delivered as though it had arrived from the other person, so an agent that was off declined to take it.
15
+ - The send box now says which route was used and whether the message landed, and a failure is reported as a failure rather than as a skip.
16
+
12
17
  ## 2026-08-15 (0.1.610)
13
18
 
14
19
  - The show-more control on a long chat message now sits in the message footer rather than over the text, and it is readable on a Telegram bubble, where it previously blended into the background.
@@ -237,21 +237,37 @@ from the dashboard.
237
237
  ### What the agent knows about a message you typed
238
238
 
239
239
  When you type into a public bot's conversation, that agent's own memory is
240
- updated with what you sent, so its next answer does not contradict you. It knows
241
- the words came from you and that the visitor has already received them, so it
242
- sends nothing in reply. The visitor sees one message, yours.
240
+ updated with what you sent, so its next answer does not contradict you. The
241
+ visitor sees one message, yours.
243
242
 
244
243
  This matters because without it the agent carries on from what it believed. On a
245
244
  live conversation an operator sent a visitor the real prices by hand, and the
246
245
  agent's memory still held a visitor asking for a price it had never given.
247
246
 
248
- Four situations record nothing, and each one says which in the log rather than
249
- failing quietly:
247
+ There are two ways your words get there, and which one runs depends on whether
248
+ that conversation has an agent running at that moment and whether the bot is
249
+ switched on.
250
+
251
+ **The agent is running and the bot is on.** Your message is handed straight to
252
+ it. It knows the words came from you and that the visitor already has them, so
253
+ it sends nothing in reply.
254
+
255
+ **Anything else, including a bot you have switched off.** Your words are written
256
+ into that conversation's own record, as something the agent's side already said.
257
+ No agent is started and no reply is composed. The next time that conversation
258
+ runs, it picks your words up and carries on from them.
259
+
260
+ That second case is the one that matters most, because switching the bot off is
261
+ exactly when you answer people by hand. Switch it off, answer a few visitors
262
+ yourself, switch it back on, and the agent resumes knowing what you said on its
263
+ behalf. It never wakes up while you have it switched off.
264
+
265
+ Three situations record nothing, and each says which in the log rather than
266
+ failing quietly. The send still goes out in all three, and the send box now
267
+ shows you the reason:
250
268
 
251
269
  - The bot is not a public bot. Your own admin bot and any specialist bot are
252
270
  conversations with your own side, so there is no agent knowledge to correct.
253
- - The agent has been switched off. Nothing is woken behind your back, which is
254
- the whole point of having switched it off. Your message still goes out.
255
271
  - The chat belongs to a connected business account. Those conversations are held
256
272
  separately and this route cannot reach them.
257
273
  - The conversation has not started yet. There is nothing to keep consistent, and
@@ -260,23 +276,29 @@ failing quietly:
260
276
  To check it is working, look at the log after sending:
261
277
 
262
278
  ```bash
263
- grep -hE 'op=(sent|context-recorded)|telegram-manual-census|op=text-suppressed' ~/.maxy-code/logs/server.log
279
+ grep -hE 'op=(sent|context)|telegram-manual-census|op=text-suppressed' ~/.maxy-code/logs/server.log
264
280
  ```
265
281
 
266
- A healthy send shows one `op=sent … ok=true`, one `op=context-recorded
267
- suppressed=yes reason=-`, and one `op=text-suppressed reason=operator-sent` for
268
- that conversation. The standing line
269
- `[telegram-manual-census] sent=N recorded=N suppressed=N unrecorded=0 skipped=0
270
- leaked=0 window=60m` should show `recorded` and `suppressed` both equal to `sent`,
271
- once the four situations above are set aside.
272
-
273
- - **`unrecorded`** above zero: a send reached no conversation and nothing said
274
- why.
275
- - **`leaked`** above zero: a send reached a conversation, and ten minutes later
276
- nothing had reported holding that turn's reply back. Either the agent never
277
- woke, or it answered on top of your message and the visitor saw it twice.
278
- - **`skipped`** above zero is normal. It is one of the four situations above, and
279
- the `reason=` on that send's own line says which.
282
+ A healthy send shows one `op=sent … ok=true` and one `op=context …
283
+ mechanism=inject|append written=yes reason=-`. On `mechanism=inject` there is
284
+ also one `op=text-suppressed reason=operator-sent`, which is the agent's reply
285
+ being held back so the visitor is not told twice. On `mechanism=append` there is
286
+ none, because no reply was ever composed.
287
+
288
+ The standing line is
289
+ `[telegram-manual-census] sent=N injected=N written=N suppressed=N unrecorded=0
290
+ skipped=0 leaked=0 window=60m`, and `injected + written + skipped` should equal
291
+ `sent`.
292
+
293
+ - **`unrecorded`** above zero: a send reached neither a running agent nor the
294
+ conversation record, and nothing said why.
295
+ - **`leaked`** above zero: a send was handed to a running agent, and ten minutes
296
+ later nothing had reported holding that turn's reply back. Either the agent
297
+ never took the turn, or it answered on top of your message and the visitor saw
298
+ it twice. This only ever counts the handed-straight-over case; a written one
299
+ composes no reply, so it has nothing to hold back.
300
+ - **`skipped`** above zero is normal. It is one of the three situations above,
301
+ and the `reason=` on that send's own line says which.
280
302
 
281
303
  ## Building your own Telegram functionality
282
304
 
@@ -5,13 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Activity — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/activity-DfIud5UH.js"></script>
8
+ <script type="module" crossorigin src="/assets/activity-Dz5eWZze.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-BycB0eMI.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DeRQuYlX.js">
11
- <link rel="modulepreload" crossorigin href="/assets/useMediaQuery-Cm_fvNIH.js">
12
- <link rel="modulepreload" crossorigin href="/assets/AdminShell-DyOPTLdb.js">
13
- <link rel="modulepreload" crossorigin href="/assets/triangle-alert-DD4kSK45.js">
14
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-B5zQuMcr.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BY35JYDT.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/useMediaQuery-e4ciNiuO.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/AdminShell-Dm_nY4jF.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/triangle-alert-C_68TrTq.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-dao9WPN0.css">
15
15
  <link rel="stylesheet" crossorigin href="/assets/useMediaQuery-DXAuc8G-.css">
16
16
  <link rel="stylesheet" href="/brand-defaults.css">
17
17
  </head>
@@ -5,12 +5,12 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Agents — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/agents-Rcdk-pni.js"></script>
8
+ <script type="module" crossorigin src="/assets/agents-DjDwemOg.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-BycB0eMI.js">
10
- <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-DeRQuYlX.js">
11
- <link rel="modulepreload" crossorigin href="/assets/useMediaQuery-Cm_fvNIH.js">
12
- <link rel="modulepreload" crossorigin href="/assets/AdminShell-DyOPTLdb.js">
13
- <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-B5zQuMcr.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/jsx-runtime-BY35JYDT.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/useMediaQuery-e4ciNiuO.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/AdminShell-Dm_nY4jF.js">
13
+ <link rel="stylesheet" crossorigin href="/assets/jsx-runtime-dao9WPN0.css">
14
14
  <link rel="stylesheet" crossorigin href="/assets/useMediaQuery-DXAuc8G-.css">
15
15
  <link rel="stylesheet" href="/brand-defaults.css">
16
16
  </head>
@@ -1 +1 @@
1
- import{o as e}from"./chunk-BycB0eMI.js";import{i as t,t as n}from"./jsx-runtime-DeRQuYlX.js";import{N as r,it as i,lt as a,ot as o}from"./useMediaQuery-Cm_fvNIH.js";import{P as s}from"./useVoiceRecorder-C6xqnm7i.js";import{D as c,O as l,k as u,p as d}from"./AdminShell-DyOPTLdb.js";var f=e(t(),1);function p(e=`admin`){let[t,n]=(0,f.useState)(`loading`),[r,i]=(0,f.useState)(``),[o,c]=(0,f.useState)(``),[l,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(void 0),[k,A]=(0,f.useState)(null),[j,M]=(0,f.useState)(void 0),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(void 0),z=(0,f.useRef)(void 0),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!0);(0,f.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&V(!0)}).catch(()=>{})},[]);let W=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();w(r.session_key),I(r.sessionId??null),O(r.businessName),A(r.role??null),M(r.userName===void 0?null:r.userName),P(r.avatar??null);let i=s(r.thinkingView);return z.current=i,R(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}U(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,f.useEffect)(()=>{t===`chat`&&C&&fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(C)}`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&E(e)}).catch(()=>{})},[t,C]);let K=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();U(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(C)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(C)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){a(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),K.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,C]),(0,f.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(U(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function q(e,t){g(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){a(`enter-pin`,`/api/admin/session`);return}d(e.error||`Invalid PIN`);return}let o=await r.json();w(o.session_key),I(o.sessionId??null),O(o.businessName),A(o.role??null),M(o.userName===void 0?null:o.userName),P(o.avatar??null);let c=s(o.thinkingView);z.current=c,R(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}}let J=(0,f.useCallback)(async e=>{if(e.preventDefault(),h)return;d(``);let t=o.trim();if(!t){d(`Please enter your name.`);return}if(r.length<4){d(`PIN must be at least 4 characters.`);return}let s=r;g(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){a(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):d(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}d(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await q(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}},[r,h,o]),Y=(0,f.useCallback)(async e=>{e.preventDefault(),d(``),await q(r)},[r]),X=(0,f.useCallback)(async()=>{S(!0);try{if(!await u())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;U(!1),w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return n(`connect-claude`),!0}finally{S(!1)}},[]),Z=(0,f.useCallback)(()=>{w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}i(``),d(``),n(`enter-pin`)},[]);return(0,f.useEffect)(()=>{K.current=Z},[Z]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:o,setOperatorName:c,pinError:l,setPinError:d,showPin:p,setShowPin:m,pinLoading:h,authPolling:_,setAuthPolling:v,authLoading:y,setAuthLoading:b,disconnecting:x,cacheKey:C,setCacheKey:w,claudeInfo:T,setClaudeInfo:E,businessName:D,role:k,userName:j,userAvatar:N,sessionId:F,setSessionId:I,expandAll:L,setExpandAll:R,expandAllDefaultRef:z,remoteAuthEnabled:B,claudeConnected:H,pinInputRef:W,setPinFormRef:G,handleSetPin:J,handleLogin:Y,handleDisconnect:X,handleLogout:Z}}var m=n();function h({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,f.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,m.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,m.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function g(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:g,setOperatorName:_}=e;return(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,m.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,m.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:g,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,m.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!g.trim(),loading:s,"aria-label":`Set PIN`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(l,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function _(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:g}=e;return(0,m.jsxs)(`div`,{className:`connect-page`,children:[p&&g&&(0,m.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:g,children:`Sign out`}),(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,m.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(`div`,{className:`pin-options`,children:(0,m.jsx)(l,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function v(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:a,pinError:s,setPinError:l,setAppState:u}=e,[p,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1),A=(0,f.useRef)(0);(0,f.useEffect)(()=>{try{D(sessionStorage.getItem(`maxy-admin-session-key`))}catch{}k(!0)},[]);async function j(){C(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:b})})).json();e.accepted?(C(`Code submitted. Finishing sign-in…`),x(``)):C(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),C(`Could not submit code.`)}}async function M(){_(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?h(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}_(!1)}async function N(){let e=++A.current;a(!0),l(``);try{let t=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(t.started){n(!0),h(!0),a(!1),y(t.transport||``);for(let t=0;t<120;t++){if(await new Promise(e=>setTimeout(e,2e3)),A.current!==e)return;let t=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json();if(typeof t.authTargetId==`string`&&T(t.authTargetId),t.authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else t.error&&l(t.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}a(!1)}async function P(){A.current++,await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||p?(0,m.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,m.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,m.jsx)(`button`,{onClick:P,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,m.jsx)(`button`,{onClick:()=>h(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,m.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,m.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,m.jsx)(`div`,{style:{marginTop:`12px`},children:(0,m.jsx)(c,{variant:`primary`,onClick:N,disabled:r,children:r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&v===`native`&&(0,m.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,m.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,m.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,m.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,m.jsx)(c,{variant:`primary`,onClick:j,disabled:!b.trim(),children:`Submit`})]}),S&&(0,m.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:S})]})]}),(0,m.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:O&&(0,m.jsx)(d,{preferTargetId:w,cacheKey:E,chrome:!1})}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsxs)(`div`,{className:`connect-logos`,children:[(0,m.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,m.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,m.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,m.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,m.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,m.jsx)(c,{variant:`primary`,onClick:N,disabled:r,children:r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,m.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,m.jsx)(`button`,{onClick:M,disabled:g,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:g?`Launching…`:`Open browser first`}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function y({auth:e}){return e.appState===`loading`?(0,m.jsx)(r,{surface:`gate`}):e.appState===`set-pin`?(0,m.jsx)(g,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,m.jsx)(v,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,m.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{window.location.href=`/__remote-auth/logout`}}):null}export{p as n,y as t};
1
+ import{o as e}from"./chunk-BycB0eMI.js";import{i as t,t as n}from"./jsx-runtime-BY35JYDT.js";import{N as r,it as i,lt as a,ot as o}from"./useMediaQuery-e4ciNiuO.js";import{P as s}from"./useVoiceRecorder-D7_wLtrS.js";import{D as c,O as l,k as u,p as d}from"./AdminShell-Dm_nY4jF.js";var f=e(t(),1);function p(e=`admin`){let[t,n]=(0,f.useState)(`loading`),[r,i]=(0,f.useState)(``),[o,c]=(0,f.useState)(``),[l,d]=(0,f.useState)(``),[p,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(!1),[_,v]=(0,f.useState)(!1),[y,b]=(0,f.useState)(!1),[x,S]=(0,f.useState)(!1),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(null),[D,O]=(0,f.useState)(void 0),[k,A]=(0,f.useState)(null),[j,M]=(0,f.useState)(void 0),[N,P]=(0,f.useState)(null),[F,I]=(0,f.useState)(null),[L,R]=(0,f.useState)(void 0),z=(0,f.useRef)(void 0),[B,V]=(0,f.useState)(!1),[H,U]=(0,f.useState)(!0);(0,f.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&V(!0)}).catch(()=>{})},[]);let W=(0,f.useRef)(null),G=(0,f.useRef)(null);(0,f.useEffect)(()=>{async function e(){let e=null;try{e=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!e)return!1;try{let t=await fetch(`/api/admin/session?session_key=${encodeURIComponent(e)}`);if(t.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return!1}if(!t.ok)return!1;let r=await t.json();w(r.session_key),I(r.sessionId??null),O(r.businessName),A(r.role??null),M(r.userName===void 0?null:r.userName),P(r.avatar??null);let i=s(r.thinkingView);return z.current=i,R(i),n(`chat`),!0}catch(e){return console.error(`[admin] session restore failed:`,e),!1}}async function t(r=2){try{let i=await fetch(`/api/health`);if(!i.ok){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check returned ${i.status} after retries`),n(`set-pin`);return}let a=await i.json();if(!a.pin_configured){n(`set-pin`);return}U(!!a.claude_authenticated);let o=!1;try{o=new URLSearchParams(window.location.search).get(`connect`)===`claude`}catch{}if(o){try{let e=new URL(window.location.href);e.searchParams.delete(`connect`),window.history.replaceState(null,``,e.pathname+e.search+e.hash)}catch{}if(!a.claude_authenticated){n(`connect-claude`);return}}if(await e())return;n(`enter-pin`)}catch(e){if(r>0)return await new Promise(e=>setTimeout(e,1500)),t(r-1);console.error(`[admin] health check failed:`,e),n(`set-pin`)}}t()},[]),(0,f.useEffect)(()=>{t===`chat`&&C&&fetch(`/api/admin/claude-info?session_key=${encodeURIComponent(C)}`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&E(e)}).catch(()=>{})},[t,C]);let K=(0,f.useRef)(null);(0,f.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();U(t.auth_status!==`dead`&&t.auth_status!==`missing`)}}catch{}if(C)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(C)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){a(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),K.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,C]),(0,f.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&(U(!0),n(`enter-pin`))}).catch(()=>{})},[t]);async function q(e,t){g(!0);try{let r=await fetch(`/api/admin/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:e,...t?{accountId:t}:{}})});if(!r.ok){let e=await r.json().catch(()=>({}));if(r.status===401&&e?.code===`remote-auth-required`){a(`enter-pin`,`/api/admin/session`);return}d(e.error||`Invalid PIN`);return}let o=await r.json();w(o.session_key),I(o.sessionId??null),O(o.businessName),A(o.role??null),M(o.userName===void 0?null:o.userName),P(o.avatar??null);let c=s(o.thinkingView);z.current=c,R(c);try{sessionStorage.setItem(`maxy-admin-session-key`,o.session_key)}catch{}i(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}}let J=(0,f.useCallback)(async e=>{if(e.preventDefault(),h)return;d(``);let t=o.trim();if(!t){d(`Please enter your name.`);return}if(r.length<4){d(`PIN must be at least 4 characters.`);return}let s=r;g(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:s,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){a(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){try{let e=await fetch(`/api/health`);if(e.ok){let r=await e.json();r.pin_configured&&r.claude_authenticated?n(`enter-pin`):r.pin_configured?n(`connect-claude`):d(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}d(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await q(s);return}i(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),d(`Could not connect.`)}finally{g(!1)}},[r,h,o]),Y=(0,f.useCallback)(async e=>{e.preventDefault(),d(``),await q(r)},[r]),X=(0,f.useCallback)(async()=>{S(!0);try{if(!await u())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;U(!1),w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}return n(`connect-claude`),!0}finally{S(!1)}},[]),Z=(0,f.useCallback)(()=>{w(null),A(null),M(void 0),P(null);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}i(``),d(``),n(`enter-pin`)},[]);return(0,f.useEffect)(()=>{K.current=Z},[Z]),{appState:t,setAppState:n,pin:r,setPin:i,operatorName:o,setOperatorName:c,pinError:l,setPinError:d,showPin:p,setShowPin:m,pinLoading:h,authPolling:_,setAuthPolling:v,authLoading:y,setAuthLoading:b,disconnecting:x,cacheKey:C,setCacheKey:w,claudeInfo:T,setClaudeInfo:E,businessName:D,role:k,userName:j,userAvatar:N,sessionId:F,setSessionId:I,expandAll:L,setExpandAll:R,expandAllDefaultRef:z,remoteAuthEnabled:B,claudeConnected:H,pinInputRef:W,setPinFormRef:G,handleSetPin:J,handleLogin:Y,handleDisconnect:X,handleLogout:Z}}var m=n();function h({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,f.useRef)([]);function s(e,r){r.key===`Backspace`?(r.preventDefault(),t[e]?n(t.slice(0,e)+t.slice(e+1)):e>0&&(n(t.slice(0,e-1)+t.slice(e)),o.current[e-1]?.focus())):r.key===`ArrowLeft`&&e>0?o.current[e-1]?.focus():r.key===`ArrowRight`&&e<5?o.current[e+1]?.focus():r.key===`Enter`&&(r.preventDefault(),r.currentTarget.form?.requestSubmit())}function c(e,i){let a=i.nativeEvent.data;if(!a||!/^\d$/.test(a))return;let s=t.split(``);for(s[e]=a;s.length<e;)s.push(``);let c=s.join(``).replace(/\D/g,``).slice(0,6);n(c),c.length===6?r?.(c):e<5&&o.current[e+1]?.focus()}function l(e){e.preventDefault();let t=e.clipboardData.getData(`text`).replace(/\D/g,``).slice(0,6);t&&(n(t),t.length===6?r?.(t):o.current[t.length]?.focus())}return(0,m.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,m.jsx)(`input`,{ref:t=>{o.current[r]=t,r===0&&e&&(e.current=t)},type:`text`,inputMode:`numeric`,className:`pin-box${t[r]?` pin-box-filled`:``}`,value:t[r]?i?t[r]:`•`:``,onKeyDown:e=>s(r,e),onInput:e=>c(r,e),onPaste:l,onFocus:e=>e.target.select(),autoFocus:a&&r===0,autoComplete:`off`,maxLength:1,"aria-label":`PIN digit ${r+1}`},r))})}function g(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:g,setOperatorName:_}=e;return(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,i.productName]}),(0,m.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,i.productName,` who you are, then choose a PIN.`]}),(0,m.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:g,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,m.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!t||!g.trim(),loading:s,"aria-label":`Set PIN`,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(l,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function _(e){let{pin:t,setPin:n,showPin:r,setShowPin:a,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:g}=e;return(0,m.jsxs)(`div`,{className:`connect-page`,children:[p&&g&&(0,m.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:g,children:`Sign out`}),(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`h1`,{className:`connect-title`,children:i.productName}),(0,m.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,m.jsxs)(`div`,{className:`pin-input-row`,children:[(0,m.jsx)(h,{inputRef:d,value:t,onChange:n,onComplete:()=>{},showPin:r,autoFocus:!0}),(0,m.jsx)(c,{variant:`send`,type:`submit`,disabled:!t,loading:s,children:(0,m.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,m.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,m.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,m.jsx)(`div`,{className:`pin-options`,children:(0,m.jsx)(l,{checked:r,onChange:()=>a(e=>!e),label:`Show PIN`})})]}),u&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function v(e){let{authPolling:t,setAuthPolling:n,authLoading:r,setAuthLoading:a,pinError:s,setPinError:l,setAppState:u}=e,[p,h]=(0,f.useState)(!1),[g,_]=(0,f.useState)(!1),[v,y]=(0,f.useState)(``),[b,x]=(0,f.useState)(``),[S,C]=(0,f.useState)(``),[w,T]=(0,f.useState)(null),[E,D]=(0,f.useState)(null),[O,k]=(0,f.useState)(!1),A=(0,f.useRef)(0);(0,f.useEffect)(()=>{try{D(sessionStorage.getItem(`maxy-admin-session-key`))}catch{}k(!0)},[]);async function j(){C(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`paste-code`,code:b})})).json();e.accepted?(C(`Code submitted. Finishing sign-in…`),x(``)):C(e.error||`Could not submit code.`)}catch(e){console.error(`[admin] paste-code error:`,e),C(`Could not submit code.`)}}async function M(){_(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`launch-browser`})})).json();e.launched?h(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}_(!1)}async function N(){let e=++A.current;a(!0),l(``);try{let t=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(t.started){n(!0),h(!0),a(!1),y(t.transport||``);for(let t=0;t<120;t++){if(await new Promise(e=>setTimeout(e,2e3)),A.current!==e)return;let t=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json();if(typeof t.authTargetId==`string`&&T(t.authTargetId),t.authenticated){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),u(`enter-pin`);return}}l(`Timed out waiting for sign-in. Try again.`),n(!1)}else t.error&&l(t.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}a(!1)}async function P(){A.current++,await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),n(!1),l(``)}return t||p?(0,m.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,m.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[t?(0,m.jsx)(`button`,{onClick:P,style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Cancel`,children:`✕`}):(0,m.jsx)(`button`,{onClick:()=>h(!1),style:{position:`absolute`,top:`12px`,right:`12px`,background:`none`,border:`none`,color:`#999`,fontSize:`13px`,cursor:`pointer`,padding:`4px 8px`},"aria-label":`Close browser`,children:`✕`}),(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,m.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,m.jsx)(`p`,{className:`chat-intro`,children:t?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!t&&(0,m.jsx)(`div`,{style:{marginTop:`12px`},children:(0,m.jsx)(c,{variant:`primary`,onClick:N,disabled:r,children:r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})}),t&&v===`native`&&(0,m.jsxs)(`div`,{style:{marginTop:`14px`,maxWidth:`420px`,margin:`14px auto 0`,display:`flex`,flexDirection:`column`,gap:`8px`},children:[(0,m.jsx)(`label`,{style:{fontSize:`12px`,color:`#999`,lineHeight:1.4},children:`If the browser didn't finish sign-in, paste the code or full redirect URL from Claude's page:`}),(0,m.jsxs)(`div`,{style:{display:`flex`,gap:`8px`},children:[(0,m.jsx)(`input`,{type:`text`,value:b,onChange:e=>x(e.target.value),placeholder:`Paste code or redirect URL`,style:{flex:1,padding:`8px 10px`,fontSize:`13px`,border:`1px solid #ccc`,borderRadius:`6px`}}),(0,m.jsx)(c,{variant:`primary`,onClick:j,disabled:!b.trim(),children:`Submit`})]}),S&&(0,m.jsx)(`p`,{style:{fontSize:`12px`,color:`#999`,margin:0},children:S})]})]}),(0,m.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:O&&(0,m.jsx)(d,{preferTargetId:w,cacheKey:E,chrome:!1})}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,m.jsx)(`div`,{className:`connect-page`,children:(0,m.jsxs)(`div`,{className:`connect-content`,children:[(0,m.jsxs)(`div`,{className:`connect-logos`,children:[(0,m.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,m.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,m.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,m.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,m.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,m.jsx)(`img`,{src:o,alt:i.productName,className:`connect-logo connect-logo--maxy`}),!i.logoContainsName&&(0,m.jsx)(`span`,{className:`connect-logo-label`,children:i.productName})]})]}),(0,m.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,i.productName]}),(0,m.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,m.jsx)(c,{variant:`primary`,onClick:N,disabled:r,children:r?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,m.jsx)(`p`,{style:{marginTop:`6px`,fontSize:`11px`,color:`#999`,maxWidth:`300px`,textAlign:`center`,lineHeight:`1.4`},children:`First time? You may need to sign into your email and Anthropic account in the browser before connecting.`}),(0,m.jsx)(`button`,{onClick:M,disabled:g,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:g?`Launching…`:`Open browser first`}),s&&(0,m.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function y({auth:e}){return e.appState===`loading`?(0,m.jsx)(r,{surface:`gate`}):e.appState===`set-pin`?(0,m.jsx)(g,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,setPinFormRef:e.setPinFormRef,onSubmit:e.handleSetPin,operatorName:e.operatorName,setOperatorName:e.setOperatorName}):e.appState===`connect-claude`?(0,m.jsx)(v,{authPolling:e.authPolling,setAuthPolling:e.setAuthPolling,authLoading:e.authLoading,setAuthLoading:e.setAuthLoading,pinError:e.pinError,setPinError:e.setPinError,setAppState:e.setAppState}):e.appState===`enter-pin`?(0,m.jsx)(_,{pin:e.pin,setPin:e.setPin,showPin:e.showPin,setShowPin:e.setShowPin,pinLoading:e.pinLoading,pinError:e.pinError,pinInputRef:e.pinInputRef,onSubmit:e.handleLogin,remoteAuthEnabled:e.remoteAuthEnabled,onSignOutRemote:()=>{window.location.href=`/__remote-auth/logout`}}):null}export{p as n,y as t};