@rubytech/create-sitedesk-code 0.1.387 → 0.1.389

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 (296) hide show
  1. package/dist/__tests__/joblogic-excluded.test.js +39 -0
  2. package/dist/index.js +21 -0
  3. package/package.json +1 -1
  4. package/payload/platform/config/brand.json +3 -3
  5. package/payload/platform/plugins/.claude-plugin/marketplace.json +0 -10
  6. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +21 -2
  7. package/payload/platform/plugins/docs/references/admin-session.md +4 -0
  8. package/payload/platform/plugins/docs/references/admin-ui.md +18 -1
  9. package/payload/platform/plugins/docs/references/joblogic.md +2 -0
  10. package/payload/platform/plugins/whatsapp/references/channels-whatsapp.md +7 -3
  11. package/payload/platform/plugins/whatsapp/skills/manage-whatsapp-config/SKILL.md +2 -0
  12. package/payload/platform/plugins/work/PLUGIN.md +3 -0
  13. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.d.ts +2 -0
  14. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.d.ts.map +1 -0
  15. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js +98 -0
  16. package/payload/platform/plugins/work/mcp/dist/__tests__/session-metering.test.js.map +1 -0
  17. package/payload/platform/plugins/work/mcp/dist/index.js +16 -0
  18. package/payload/platform/plugins/work/mcp/dist/index.js.map +1 -1
  19. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.d.ts +53 -0
  20. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.d.ts.map +1 -0
  21. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js +80 -0
  22. package/payload/platform/plugins/work/mcp/dist/tools/session-metering.js.map +1 -0
  23. package/payload/platform/plugins/work/mcp/package.json +2 -1
  24. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  25. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
  26. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  27. package/payload/platform/services/claude-session-manager/dist/http-server.d.ts.map +1 -1
  28. package/payload/platform/services/claude-session-manager/dist/http-server.js +98 -8
  29. package/payload/platform/services/claude-session-manager/dist/http-server.js.map +1 -1
  30. package/payload/platform/services/claude-session-manager/dist/pricing.d.ts +45 -0
  31. package/payload/platform/services/claude-session-manager/dist/pricing.d.ts.map +1 -0
  32. package/payload/platform/services/claude-session-manager/dist/pricing.js +57 -0
  33. package/payload/platform/services/claude-session-manager/dist/pricing.js.map +1 -0
  34. package/payload/platform/services/claude-session-manager/dist/session-metering.d.ts +38 -0
  35. package/payload/platform/services/claude-session-manager/dist/session-metering.d.ts.map +1 -0
  36. package/payload/platform/services/claude-session-manager/dist/session-metering.js +292 -0
  37. package/payload/platform/services/claude-session-manager/dist/session-metering.js.map +1 -0
  38. package/payload/platform/templates/specialists/agents/project-manager.md +1 -1
  39. package/payload/premium-plugins/.claude-plugin/marketplace.json +0 -15
  40. package/payload/server/public/assets/{AdminLoginScreens-BejIjbmU.js → AdminLoginScreens-CerrEc_m.js} +1 -1
  41. package/payload/server/public/assets/AdminShell-cRTvNRbo.js +1 -0
  42. package/payload/server/public/assets/{Checkbox-1F1tzqca.js → Checkbox-Dh2pLMFN.js} +1 -1
  43. package/payload/server/public/assets/{Transcript-DkGa4CQH.js → Transcript-B_GVJujB.js} +1 -1
  44. package/payload/server/public/assets/{admin-DqQARkjy.js → admin-BXaYelnR.js} +1 -1
  45. package/payload/server/public/assets/{browser-nDtEK6RC.js → browser-fhjGE7fH.js} +1 -1
  46. package/payload/server/public/assets/calendar-PnZudAtc.js +1 -0
  47. package/payload/server/public/assets/chat-Dy_zrjKS.js +1 -0
  48. package/payload/server/public/assets/chevron-left-IB6TmMZ_.js +1 -0
  49. package/payload/server/public/assets/data-B2IcjAj6.js +1 -0
  50. package/payload/server/public/assets/{graph-DFyicKd7.js → graph-CycO3tkW.js} +2 -2
  51. package/payload/server/public/assets/{graph-labels-D3BQdcpD.js → graph-labels-DlSsSpBV.js} +1 -1
  52. package/payload/server/public/assets/{operator-BxrjWdT9.js → operator-L4kBC-zS.js} +1 -1
  53. package/payload/server/public/assets/page-D5E-Ng4D.js +1 -0
  54. package/payload/server/public/assets/page-M8sD9LOi.js +32 -0
  55. package/payload/server/public/assets/{public-DbdqfdYq.js → public-BmnajF3K.js} +1 -1
  56. package/payload/server/public/assets/{rotate-ccw-BkX8HODe.js → rotate-ccw-W5HhvAbo.js} +1 -1
  57. package/payload/server/public/assets/useSubAccountSwitcher-D1TI1xvd.css +1 -0
  58. package/payload/server/public/assets/useSubAccountSwitcher-UqZbmzYy.js +9 -0
  59. package/payload/server/public/browser.html +4 -4
  60. package/payload/server/public/calendar.html +5 -5
  61. package/payload/server/public/chat.html +8 -8
  62. package/payload/server/public/data.html +7 -7
  63. package/payload/server/public/graph.html +8 -8
  64. package/payload/server/public/index.html +10 -10
  65. package/payload/server/public/operator.html +10 -10
  66. package/payload/server/public/public.html +8 -8
  67. package/payload/server/server.js +444 -315
  68. package/payload/platform/plugins/joblogic/.claude-plugin/plugin.json +0 -21
  69. package/payload/platform/plugins/joblogic/PLUGIN.md +0 -182
  70. package/payload/platform/plugins/joblogic/lib/mcp-spawn-tee/index.js +0 -193
  71. package/payload/platform/plugins/joblogic/lib/mcp-spawn-tee/package.json +0 -3
  72. package/payload/platform/plugins/joblogic/mcp/dist/index.d.ts +0 -2
  73. package/payload/platform/plugins/joblogic/mcp/dist/index.d.ts.map +0 -1
  74. package/payload/platform/plugins/joblogic/mcp/dist/index.js +0 -229
  75. package/payload/platform/plugins/joblogic/mcp/dist/index.js.map +0 -1
  76. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.d.ts +0 -31
  77. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.d.ts.map +0 -1
  78. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.js +0 -78
  79. package/payload/platform/plugins/joblogic/mcp/dist/lib/auth.js.map +0 -1
  80. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.d.ts +0 -35
  81. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.d.ts.map +0 -1
  82. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.js +0 -106
  83. package/payload/platform/plugins/joblogic/mcp/dist/lib/client.js.map +0 -1
  84. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.d.ts +0 -8
  85. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.d.ts.map +0 -1
  86. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.js +0 -41
  87. package/payload/platform/plugins/joblogic/mcp/dist/lib/idempotency.js.map +0 -1
  88. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.d.ts +0 -21
  89. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.d.ts.map +0 -1
  90. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.js +0 -47
  91. package/payload/platform/plugins/joblogic/mcp/dist/lib/secrets.js.map +0 -1
  92. package/payload/platform/plugins/joblogic/mcp/package.json +0 -10
  93. package/payload/platform/plugins/joblogic/skills/joblogic/SKILL.md +0 -32
  94. package/payload/platform/plugins/sales/.claude-plugin/plugin.json +0 -8
  95. package/payload/platform/plugins/sales/PLUGIN.md +0 -106
  96. package/payload/platform/plugins/sales/references/close-tracking.md +0 -69
  97. package/payload/platform/plugins/sales/references/comparisons.md +0 -99
  98. package/payload/platform/plugins/sales/references/competitive-positioning.md +0 -51
  99. package/payload/platform/plugins/sales/references/faq.md +0 -73
  100. package/payload/platform/plugins/sales/references/objection-handling.md +0 -157
  101. package/payload/platform/plugins/sales/references/pricing.md +0 -101
  102. package/payload/premium-plugins/teaching/.claude-plugin/plugin.json +0 -8
  103. package/payload/premium-plugins/teaching/PLUGIN.md +0 -58
  104. package/payload/premium-plugins/teaching/skills/interactive-tutor/SKILL.md +0 -59
  105. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/assessment.md +0 -70
  106. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/classroom-conduct.md +0 -43
  107. package/payload/premium-plugins/teaching/skills/interactive-tutor/references/teaching-modes.md +0 -83
  108. package/payload/premium-plugins/teaching/skills/lesson-planner/SKILL.md +0 -48
  109. package/payload/premium-plugins/teaching/skills/lesson-planner/references/context-gathering.md +0 -41
  110. package/payload/premium-plugins/teaching/skills/lesson-planner/references/plan-structure.md +0 -94
  111. package/payload/premium-plugins/teaching/skills/study-pack-builder/SKILL.md +0 -52
  112. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/disaggregation.md +0 -49
  113. package/payload/premium-plugins/teaching/skills/study-pack-builder/references/materials.md +0 -116
  114. package/payload/premium-plugins/venture-studio/.claude-plugin/plugin.json +0 -8
  115. package/payload/premium-plugins/venture-studio/PLUGIN.md +0 -128
  116. package/payload/premium-plugins/venture-studio/bin/scaffold.sh +0 -116
  117. package/payload/premium-plugins/venture-studio/skills/brand-pack/SKILL.md +0 -256
  118. package/payload/premium-plugins/venture-studio/skills/brand-pack/references/color-psychology.md +0 -118
  119. package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +0 -436
  120. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/business-plan-template.md +0 -64
  121. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/competitive-battlecard.md +0 -37
  122. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/competitor-analysis.md +0 -32
  123. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/compliance-research-checklist.md +0 -53
  124. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/data-room-structure.md +0 -88
  125. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/deck-blueprint-template.md +0 -39
  126. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/design-tokens-application.md +0 -79
  127. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/html-pdf-pipeline.md +0 -236
  128. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/internal-workings-scrub.md +0 -33
  129. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/monetization-strategy.md +0 -35
  130. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/pricing-strategy.md +0 -37
  131. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/strategy-frameworks.md +0 -46
  132. package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/termsheet-template.md +0 -88
  133. package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/index.html +0 -1565
  134. package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/render-pdf.mjs +0 -91
  135. package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/term_sheet.html +0 -715
  136. package/payload/premium-plugins/venture-studio/skills/legal-essentials/SKILL.md +0 -65
  137. package/payload/premium-plugins/venture-studio/skills/office-hours/SKILL.md +0 -587
  138. package/payload/premium-plugins/venture-studio/skills/prototype-host/SKILL.md +0 -179
  139. package/payload/premium-plugins/venture-studio/skills/prototype-host/references/cloudflared-ingress-edit.md +0 -81
  140. package/payload/premium-plugins/venture-studio/skills/prototype-host/references/scaffold-frameworks.md +0 -60
  141. package/payload/premium-plugins/venture-studio/skills/prototype-host/references/systemd-user-service.md +0 -104
  142. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/SKILL.md +0 -342
  143. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/aarrr-metrics.md +0 -275
  144. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/assumption-testing.md +0 -93
  145. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/boolean-search.md +0 -308
  146. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/build-measure-learn.md +0 -262
  147. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/business-model-canvas.md +0 -171
  148. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/commitment-signals.md +0 -246
  149. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/design-thinking.md +0 -183
  150. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/earlyvangelist.md +0 -190
  151. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/first-principles.md +0 -58
  152. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/fishbone.md +0 -114
  153. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/five-whys.md +0 -43
  154. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/ice-scoring.md +0 -237
  155. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/innovation-accounting.md +0 -290
  156. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/jtbd.md +0 -105
  157. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/landing-page.md +0 -361
  158. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/market-sizing.md +0 -58
  159. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/market-type.md +0 -167
  160. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/mom-test.md +0 -193
  161. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/mvp-types.md +0 -200
  162. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/og-images.md +0 -239
  163. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pareto.md +0 -103
  164. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/persona-development.md +0 -291
  165. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pivot-types.md +0 -225
  166. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/positioning-statement.md +0 -179
  167. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/prd.md +0 -363
  168. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/pre-mortem.md +0 -74
  169. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/problem-validation.md +0 -253
  170. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/product-market-fit.md +0 -256
  171. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/research-synthesis.md +0 -276
  172. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/strategy-red-team.md +0 -41
  173. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/three-engines-of-growth.md +0 -248
  174. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/validation-tests.md +0 -89
  175. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/value-proposition-canvas.md +0 -121
  176. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/win-loss-analysis.md +0 -242
  177. package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/workflow-mapping.md +0 -271
  178. package/payload/premium-plugins/writer-craft/.claude-plugin/plugin.json +0 -21
  179. package/payload/premium-plugins/writer-craft/PLUGIN.md +0 -134
  180. package/payload/premium-plugins/writer-craft/agents/writer-craft--manuscript-reviewer.md +0 -108
  181. package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts +0 -8
  182. package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.d.ts.map +0 -1
  183. package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js +0 -71
  184. package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/dist/index.js.map +0 -1
  185. package/payload/premium-plugins/writer-craft/lib/mcp-lifeline/package.json +0 -7
  186. package/payload/premium-plugins/writer-craft/lib/mcp-spawn-tee/index.js +0 -193
  187. package/payload/premium-plugins/writer-craft/lib/mcp-spawn-tee/package.json +0 -3
  188. package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts +0 -51
  189. package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.d.ts.map +0 -1
  190. package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js +0 -196
  191. package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/dist/index.js.map +0 -1
  192. package/payload/premium-plugins/writer-craft/lib/mcp-stderr-tee/package.json +0 -7
  193. package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts +0 -3
  194. package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.d.ts.map +0 -1
  195. package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js +0 -58
  196. package/payload/premium-plugins/writer-craft/mcp/dist/cli/ingest-session-text.js.map +0 -1
  197. package/payload/premium-plugins/writer-craft/mcp/dist/index.d.ts +0 -3
  198. package/payload/premium-plugins/writer-craft/mcp/dist/index.d.ts.map +0 -1
  199. package/payload/premium-plugins/writer-craft/mcp/dist/index.js +0 -403
  200. package/payload/premium-plugins/writer-craft/mcp/dist/index.js.map +0 -1
  201. package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.d.ts +0 -14
  202. package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.d.ts.map +0 -1
  203. package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.js +0 -47
  204. package/payload/premium-plugins/writer-craft/mcp/dist/lib/neo4j.js.map +0 -1
  205. package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.d.ts +0 -117
  206. package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.d.ts.map +0 -1
  207. package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.js +0 -138
  208. package/payload/premium-plugins/writer-craft/mcp/dist/lib/voice-corpus.js.map +0 -1
  209. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.d.ts +0 -90
  210. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.d.ts.map +0 -1
  211. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.js +0 -609
  212. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-distil-profile.js.map +0 -1
  213. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.d.ts +0 -19
  214. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.d.ts.map +0 -1
  215. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.js +0 -124
  216. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-ingest-session-text.js.map +0 -1
  217. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.d.ts +0 -38
  218. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.d.ts.map +0 -1
  219. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.js +0 -93
  220. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-record-feedback.js.map +0 -1
  221. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.d.ts +0 -61
  222. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.d.ts.map +0 -1
  223. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.js +0 -171
  224. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-retrieve-conditioning.js.map +0 -1
  225. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.d.ts +0 -35
  226. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.d.ts.map +0 -1
  227. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.js +0 -127
  228. package/payload/premium-plugins/writer-craft/mcp/dist/tools/voice-tag-content.js.map +0 -1
  229. package/payload/premium-plugins/writer-craft/mcp/package-lock.json +0 -1327
  230. package/payload/premium-plugins/writer-craft/mcp/package.json +0 -19
  231. package/payload/premium-plugins/writer-craft/mcp/scripts/smoke.mjs +0 -420
  232. package/payload/premium-plugins/writer-craft/mcp/src/index.ts +0 -457
  233. package/payload/premium-plugins/writer-craft/mcp/src/lib/neo4j.ts +0 -56
  234. package/payload/premium-plugins/writer-craft/mcp/src/lib/voice-corpus.ts +0 -154
  235. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-distil-profile.ts +0 -833
  236. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-ingest-session-text.ts +0 -153
  237. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-record-feedback.ts +0 -148
  238. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-retrieve-conditioning.ts +0 -270
  239. package/payload/premium-plugins/writer-craft/mcp/src/tools/voice-tag-content.ts +0 -181
  240. package/payload/premium-plugins/writer-craft/mcp/tsconfig.json +0 -8
  241. package/payload/premium-plugins/writer-craft/skills/citation-style/SKILL.md +0 -94
  242. package/payload/premium-plugins/writer-craft/skills/citation-style/references/book-and-chapter-models.md +0 -77
  243. package/payload/premium-plugins/writer-craft/skills/citation-style/references/citation-rules.md +0 -103
  244. package/payload/premium-plugins/writer-craft/skills/citation-style/references/journal-article-models.md +0 -74
  245. package/payload/premium-plugins/writer-craft/skills/citation-style/references/other-source-models.md +0 -146
  246. package/payload/premium-plugins/writer-craft/skills/citation-style/references/reference-list-rules.md +0 -70
  247. package/payload/premium-plugins/writer-craft/skills/editorial-practice/SKILL.md +0 -108
  248. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/copyediting.md +0 -73
  249. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/developmental-editing.md +0 -85
  250. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/genre-specific-editing.md +0 -78
  251. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/line-editing.md +0 -55
  252. package/payload/premium-plugins/writer-craft/skills/editorial-practice/references/self-editing.md +0 -89
  253. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/SKILL.md +0 -114
  254. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/audience-analysis.md +0 -73
  255. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/crafting-persuasive-story.md +0 -76
  256. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/persuasion-case-studies.md +0 -67
  257. package/payload/premium-plugins/writer-craft/skills/persuasive-storytelling/references/transformation-framework.md +0 -86
  258. package/payload/premium-plugins/writer-craft/skills/point-of-view/SKILL.md +0 -97
  259. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/indirect-narration.md +0 -72
  260. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/pov-types-and-voice.md +0 -91
  261. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/protagonist-filter.md +0 -71
  262. package/payload/premium-plugins/writer-craft/skills/point-of-view/references/tense-and-person.md +0 -85
  263. package/payload/premium-plugins/writer-craft/skills/prose-craft/SKILL.md +0 -100
  264. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/punctuation-and-grammar.md +0 -72
  265. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/repetition.md +0 -71
  266. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/sound-and-rhythm.md +0 -64
  267. package/payload/premium-plugins/writer-craft/skills/prose-craft/references/word-economy.md +0 -93
  268. package/payload/premium-plugins/writer-craft/skills/reader-engagement/SKILL.md +0 -100
  269. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/cause-effect-setup-payoff.md +0 -79
  270. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/conflict-escalation.md +0 -81
  271. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/hooking-readers.md +0 -67
  272. package/payload/premium-plugins/writer-craft/skills/reader-engagement/references/neurochemistry-of-engagement.md +0 -94
  273. package/payload/premium-plugins/writer-craft/skills/review-manuscript/SKILL.md +0 -111
  274. package/payload/premium-plugins/writer-craft/skills/review-manuscript/references/review-manuscript-checklist.md +0 -119
  275. package/payload/premium-plugins/writer-craft/skills/review-prose/SKILL.md +0 -99
  276. package/payload/premium-plugins/writer-craft/skills/review-prose/references/prose-review-checklist.md +0 -112
  277. package/payload/premium-plugins/writer-craft/skills/review-scene/SKILL.md +0 -99
  278. package/payload/premium-plugins/writer-craft/skills/review-scene/references/scene-analysis-framework.md +0 -95
  279. package/payload/premium-plugins/writer-craft/skills/story-architecture/SKILL.md +0 -106
  280. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/blueprinting-and-scene-cards.md +0 -118
  281. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/inner-issue-and-protagonist-goal.md +0 -66
  282. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/misbelief-desire-worldview.md +0 -87
  283. package/payload/premium-plugins/writer-craft/skills/story-architecture/references/origin-scenes-and-escalation.md +0 -82
  284. package/payload/premium-plugins/writer-craft/skills/story-blueprint/SKILL.md +0 -133
  285. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-exercises.md +0 -118
  286. package/payload/premium-plugins/writer-craft/skills/story-blueprint/references/blueprinting-process.md +0 -128
  287. package/payload/premium-plugins/writer-craft/skills/voice-mirror/SKILL.md +0 -241
  288. package/payload/server/public/assets/AdminShell-D2-uBSB5.js +0 -1
  289. package/payload/server/public/assets/calendar-CO4Bwmho.js +0 -1
  290. package/payload/server/public/assets/chat-DeIge_bC.js +0 -1
  291. package/payload/server/public/assets/chevron-left-DhVdq0aN.js +0 -1
  292. package/payload/server/public/assets/data-B1GIdzHk.js +0 -1
  293. package/payload/server/public/assets/page-ByDLq_o1.js +0 -1
  294. package/payload/server/public/assets/page-D-Ep4bXd.js +0 -32
  295. package/payload/server/public/assets/useSubAccountSwitcher-DMbRhLPv.js +0 -9
  296. package/payload/server/public/assets/useSubAccountSwitcher-DS0iqSkP.css +0 -1
@@ -0,0 +1,57 @@
1
+ // Dated pricing / FX / tokenizer constants for session metering (Task 1384).
2
+ //
3
+ // Every value here is NAMED and DATED with a source, never a bare literal in the
4
+ // cost math. When Anthropic changes list prices or the GBP rate drifts, edit the
5
+ // constant and bump OPUS_PRICE_DATE — `pricingIsStale` warns once the date ages
6
+ // past 90 days so a stale estimate is a visible signal, not a silent drift.
7
+ //
8
+ // Source: https://www.anthropic.com/pricing#api (list API prices, USD per 1M tokens)
9
+ // Captured: 2026-07-04.
10
+ export const PRICING_SOURCE = 'https://www.anthropic.com/pricing#api';
11
+ export const OPUS_PRICE_DATE = '2026-07-04';
12
+ /** Default GBP conversion. USD amounts are divided by this to yield GBP. */
13
+ export const USD_PER_GBP = 1.34;
14
+ /** Sonnet 4.6 uses an older tokenizer; every token count is multiplied by this
15
+ * factor before the Sonnet rate is applied, so its estimate reflects the token
16
+ * volume that tokenizer would have produced. Opus 4.8 counts are used as-is. */
17
+ export const SONNET_TOKENIZER_FACTOR = 0.7;
18
+ /** USD per 1,000,000 tokens. `cacheWrite5m` is the 5-minute cache-creation rate;
19
+ * session metering prices all `cache_creation_input_tokens` at this rate. */
20
+ export const OPUS_4_8 = { input: 5, cacheWrite5m: 6.25, cacheRead: 0.5, output: 25 };
21
+ export const SONNET_4_6 = { input: 3, cacheWrite5m: 3.75, cacheRead: 0.3, output: 15 };
22
+ export function defaultPricingConfig() {
23
+ return { usdPerGbp: USD_PER_GBP, tokenizerFactor: SONNET_TOKENIZER_FACTOR, priceDate: OPUS_PRICE_DATE };
24
+ }
25
+ function usdPerMillion(rate, t) {
26
+ return (t.input * rate.input +
27
+ t.cacheWrite * rate.cacheWrite5m +
28
+ t.cacheRead * rate.cacheRead +
29
+ t.output * rate.output) / 1_000_000;
30
+ }
31
+ /** GBP cost of a token bundle at the Opus 4.8 rate (no tokenizer scaling). */
32
+ export function opusCostGBP(t, cfg) {
33
+ return usdPerMillion(OPUS_4_8, t) / cfg.usdPerGbp;
34
+ }
35
+ /** GBP cost at the Sonnet 4.6 rate with every token count scaled by the
36
+ * tokenizer factor. */
37
+ export function sonnetCostGBP(t, cfg) {
38
+ const f = cfg.tokenizerFactor;
39
+ const scaled = {
40
+ input: t.input * f,
41
+ cacheWrite: t.cacheWrite * f,
42
+ cacheRead: t.cacheRead * f,
43
+ output: t.output * f,
44
+ };
45
+ return usdPerMillion(SONNET_4_6, scaled) / cfg.usdPerGbp;
46
+ }
47
+ /** True when `priceDate` is more than 90 days before `nowIso`. Both are ISO
48
+ * date strings; comparison is in whole UTC days. */
49
+ export function pricingIsStale(cfg, nowIso) {
50
+ const price = Date.parse(cfg.priceDate);
51
+ const now = Date.parse(nowIso);
52
+ if (!Number.isFinite(price) || !Number.isFinite(now))
53
+ return false;
54
+ const days = (now - price) / 86_400_000;
55
+ return days > 90;
56
+ }
57
+ //# sourceMappingURL=pricing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pricing.js","sourceRoot":"","sources":["../src/pricing.ts"],"names":[],"mappings":"AAAA,6EAA6E;AAC7E,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,4EAA4E;AAC5E,EAAE;AACF,sFAAsF;AACtF,wBAAwB;AAExB,MAAM,CAAC,MAAM,cAAc,GAAG,uCAAuC,CAAA;AACrE,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAA;AAE3C,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,CAAA;AAC/B;;iFAEiF;AACjF,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,CAAA;AAE1C;8EAC8E;AAC9E,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAW,CAAA;AAC7F,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAW,CAAA;AAmB/F,MAAM,UAAU,oBAAoB;IAClC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,uBAAuB,EAAE,SAAS,EAAE,eAAe,EAAE,CAAA;AACzG,CAAC;AAED,SAAS,aAAa,CAAC,IAAe,EAAE,CAAiB;IACvD,OAAO,CACL,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK;QACpB,CAAC,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY;QAChC,CAAC,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS;QAC5B,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CACvB,GAAG,SAAS,CAAA;AACf,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,CAAiB,EAAE,GAAkB;IAC/D,OAAO,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,CAAA;AACnD,CAAC;AAED;wBACwB;AACxB,MAAM,UAAU,aAAa,CAAC,CAAiB,EAAE,GAAkB;IACjE,MAAM,CAAC,GAAG,GAAG,CAAC,eAAe,CAAA;IAC7B,MAAM,MAAM,GAAmB;QAC7B,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;QAClB,UAAU,EAAE,CAAC,CAAC,UAAU,GAAG,CAAC;QAC5B,SAAS,EAAE,CAAC,CAAC,SAAS,GAAG,CAAC;QAC1B,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;KACrB,CAAA;IACD,OAAO,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,SAAS,CAAA;AAC1D,CAAC;AAED;qDACqD;AACrD,MAAM,UAAU,cAAc,CAAC,GAAkB,EAAE,MAAc;IAC/D,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACvC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;IAC9B,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAA;IAClE,MAAM,IAAI,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,UAAU,CAAA;IACvC,OAAO,IAAI,GAAG,EAAE,CAAA;AAClB,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { type PricingConfig, type MeteringTokens } from './pricing.js';
2
+ export interface MeteringActive {
3
+ thinking: number;
4
+ messaging: number;
5
+ toolUse: number;
6
+ }
7
+ export interface MeteringCost {
8
+ opus: number;
9
+ sonnet: number;
10
+ }
11
+ export interface MeteringDay {
12
+ date: string;
13
+ activeMs: MeteringActive;
14
+ idleMs: number;
15
+ turns: number;
16
+ tools: number;
17
+ tokens: MeteringTokens;
18
+ costGBP: MeteringCost;
19
+ }
20
+ export interface MeteringSummary {
21
+ sessionId: string;
22
+ days: MeteringDay[];
23
+ totals: Omit<MeteringDay, 'date'>;
24
+ corrOutputVsActive: number;
25
+ pricing: {
26
+ opusPriceDate: string;
27
+ usdPerGbp: number;
28
+ tokenizerFactor: number;
29
+ };
30
+ }
31
+ export interface ComputeMeteringOpts {
32
+ pricing?: PricingConfig;
33
+ nowIso?: string;
34
+ logger?: (m: string) => void;
35
+ verbose?: boolean;
36
+ }
37
+ export declare function computeMetering(jsonlPath: string, opts?: ComputeMeteringOpts): Promise<MeteringSummary>;
38
+ //# sourceMappingURL=session-metering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-metering.d.ts","sourceRoot":"","sources":["../src/session-metering.ts"],"names":[],"mappings":"AA2BA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,cAAc,CAAA;AAIrB,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,CAAA;CAChB;AACD,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AACD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,cAAc,CAAA;IACtB,OAAO,EAAE,YAAY,CAAA;CACtB;AACD,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IACjC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,OAAO,EAAE;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,CAAA;CAC/E;AAwCD,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAsB,eAAe,CACnC,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC,eAAe,CAAC,CA6N1B"}
@@ -0,0 +1,292 @@
1
+ // Deterministic per-day metering over a full session JSONL (Task 1384).
2
+ //
3
+ // One streaming pass produces per-day active time (thinking / messaging / tool
4
+ // use), idle time, turn and matched-tool counts, deduped token classes, and
5
+ // estimated GBP cost for Opus 4.8 and Sonnet 4.6. No LLM in the path — the same
6
+ // summary is served by the http endpoint and the MCP tool.
7
+ //
8
+ // Model (all values from the task-1384 evidence; see pricing.ts for constants):
9
+ // - Only `user` and `assistant` records anchor time. Auxiliary record types
10
+ // (attachment, queue-operation, last-prompt, system, mode) carry out-of-order
11
+ // timestamps and are ignored.
12
+ // - Each assistant JSONL line carries exactly one content block (thinking |
13
+ // text | tool_use). Time is tiled over consecutive records in FILE ORDER:
14
+ // the delta ending at a record is attributed by that record's kind. A
15
+ // negative delta (rare sub-second streaming write race) clamps to 0 and its
16
+ // magnitude accrues to residualMs.
17
+ // - A delta into the FIRST assistant block of a turn (prior record not an
18
+ // assistant block) counts as idle when it exceeds 120s (human wait); a
19
+ // tool_result delta is folded into tool use; a human inbound delta is idle.
20
+ // - Tokens are turn-level: `message.usage` repeats identically across a turn's
21
+ // block-lines, so they are deduped by `message.id` and attributed to the UTC
22
+ // day of that turn's first block-line. Thinking is redacted (`thinking:''`),
23
+ // so per-activity token attribution is structurally impossible.
24
+ import { createReadStream } from 'node:fs';
25
+ import { createInterface } from 'node:readline';
26
+ import { basename } from 'node:path';
27
+ import { defaultPricingConfig, opusCostGBP, sonnetCostGBP, pricingIsStale, OPUS_4_8, } from './pricing.js';
28
+ const IDLE_LEAD_MS = 120_000;
29
+ function zeroTokens() {
30
+ return { output: 0, input: 0, cacheWrite: 0, cacheRead: 0 };
31
+ }
32
+ function newDay() {
33
+ return {
34
+ activeMs: { thinking: 0, messaging: 0, toolUse: 0 },
35
+ idleMs: 0,
36
+ tokens: zeroTokens(),
37
+ turnIds: new Set(),
38
+ toolUseIds: [],
39
+ };
40
+ }
41
+ function dayKey(tsMs) {
42
+ return new Date(tsMs).toISOString().slice(0, 10);
43
+ }
44
+ function num(x) {
45
+ return typeof x === 'number' && Number.isFinite(x) ? x : 0;
46
+ }
47
+ export async function computeMetering(jsonlPath, opts = {}) {
48
+ const cfg = opts.pricing ?? defaultPricingConfig();
49
+ const sessionId = basename(jsonlPath).replace(/\.jsonl$/, '');
50
+ const log = (m) => opts.logger?.(`[metering] ${m}`);
51
+ const evs = [];
52
+ const usageById = new Map(); // first usage per turn
53
+ const firstLineById = new Map(); // first block-line ts per turn
54
+ const toolResultIds = new Set();
55
+ let thinkingBlocks = 0;
56
+ let thinkingWithText = 0;
57
+ const rl = createInterface({ input: createReadStream(jsonlPath, { encoding: 'utf8' }), crlfDelay: Infinity });
58
+ for await (const line of rl) {
59
+ if (!line)
60
+ continue;
61
+ let o;
62
+ try {
63
+ o = JSON.parse(line);
64
+ }
65
+ catch {
66
+ continue;
67
+ }
68
+ const type = o?.type;
69
+ if (type !== 'user' && type !== 'assistant')
70
+ continue;
71
+ const ts = typeof o.timestamp === 'string' ? Date.parse(o.timestamp) : NaN;
72
+ if (!Number.isFinite(ts))
73
+ continue;
74
+ const msg = o.message;
75
+ if (!msg || typeof msg !== 'object')
76
+ continue;
77
+ if (type === 'user') {
78
+ const content = msg.content;
79
+ if (Array.isArray(content)) {
80
+ const results = content.filter((b) => b && typeof b === 'object' && b.type === 'tool_result');
81
+ if (results.length > 0) {
82
+ for (const r of results) {
83
+ const id = r.tool_use_id;
84
+ if (typeof id === 'string')
85
+ toolResultIds.add(id);
86
+ }
87
+ evs.push({ ts, kind: 'toolResult', isAssistantBlock: false });
88
+ continue;
89
+ }
90
+ }
91
+ // string content, or a list with no tool_result → a human inbound turn
92
+ evs.push({ ts, kind: 'human', isAssistantBlock: false });
93
+ continue;
94
+ }
95
+ // assistant
96
+ const model = msg.model;
97
+ if (model === '<synthetic>')
98
+ continue; // CLI placeholder line, not a real turn
99
+ const messageId = typeof msg.id === 'string' ? msg.id : undefined;
100
+ const content = msg.content;
101
+ const block = Array.isArray(content) && content[0] && typeof content[0] === 'object' ? content[0] : null;
102
+ const btype = block?.type;
103
+ const usageRaw = msg.usage;
104
+ let usage;
105
+ if (usageRaw && typeof usageRaw === 'object') {
106
+ const u = usageRaw;
107
+ usage = {
108
+ output: num(u.output_tokens),
109
+ input: num(u.input_tokens),
110
+ cacheWrite: num(u.cache_creation_input_tokens),
111
+ cacheRead: num(u.cache_read_input_tokens),
112
+ };
113
+ }
114
+ if (messageId) {
115
+ if (!firstLineById.has(messageId))
116
+ firstLineById.set(messageId, ts);
117
+ if (usage && !usageById.has(messageId))
118
+ usageById.set(messageId, usage);
119
+ }
120
+ if (btype === 'thinking') {
121
+ thinkingBlocks += 1;
122
+ if (typeof block.thinking === 'string' && block.thinking.trim().length > 0)
123
+ thinkingWithText += 1;
124
+ evs.push({ ts, kind: 'thinking', isAssistantBlock: true, messageId, usage });
125
+ }
126
+ else if (btype === 'tool_use') {
127
+ const id = typeof block.id === 'string' ? block.id : undefined;
128
+ evs.push({ ts, kind: 'toolUse', isAssistantBlock: true, messageId, usage, toolUseId: id });
129
+ }
130
+ else {
131
+ // text (or any other single assistant block) — messaging
132
+ evs.push({ ts, kind: 'text', isAssistantBlock: true, messageId, usage });
133
+ }
134
+ }
135
+ const days = new Map();
136
+ const get = (key) => {
137
+ let d = days.get(key);
138
+ if (!d) {
139
+ d = newDay();
140
+ days.set(key, d);
141
+ }
142
+ return d;
143
+ };
144
+ // Time tiling — file order, clamp negatives into residual.
145
+ let residualMs = 0;
146
+ let prev = null;
147
+ for (const ev of evs) {
148
+ if (prev) {
149
+ let delta = ev.ts - prev.ts;
150
+ if (delta < 0) {
151
+ residualMs += -delta;
152
+ delta = 0;
153
+ }
154
+ const d = get(dayKey(ev.ts));
155
+ if (ev.kind === 'human') {
156
+ d.idleMs += delta;
157
+ }
158
+ else if (ev.kind === 'toolResult') {
159
+ d.activeMs.toolUse += delta;
160
+ }
161
+ else {
162
+ // assistant block
163
+ const leadIn = !prev.isAssistantBlock;
164
+ if (leadIn && delta > IDLE_LEAD_MS) {
165
+ d.idleMs += delta;
166
+ }
167
+ else if (ev.kind === 'thinking') {
168
+ d.activeMs.thinking += delta;
169
+ }
170
+ else if (ev.kind === 'text') {
171
+ d.activeMs.messaging += delta;
172
+ }
173
+ else {
174
+ d.activeMs.toolUse += delta;
175
+ }
176
+ }
177
+ }
178
+ prev = ev;
179
+ }
180
+ // Turns and tools per day.
181
+ for (const [id, ts] of firstLineById) {
182
+ get(dayKey(ts)).turnIds.add(id);
183
+ }
184
+ for (const ev of evs) {
185
+ if (ev.kind === 'toolUse' && ev.toolUseId)
186
+ get(dayKey(ev.ts)).toolUseIds.push(ev.toolUseId);
187
+ }
188
+ // Tokens per day, attributed to the turn's first-line day.
189
+ for (const [id, usage] of usageById) {
190
+ const ts = firstLineById.get(id);
191
+ if (ts === undefined)
192
+ continue;
193
+ const t = get(dayKey(ts)).tokens;
194
+ t.output += usage.output;
195
+ t.input += usage.input;
196
+ t.cacheWrite += usage.cacheWrite;
197
+ t.cacheRead += usage.cacheRead;
198
+ }
199
+ const sortedKeys = [...days.keys()].sort();
200
+ const dayRows = sortedKeys.map((date) => {
201
+ const d = days.get(date);
202
+ const tools = d.toolUseIds.filter((id) => toolResultIds.has(id)).length;
203
+ return {
204
+ date,
205
+ activeMs: { ...d.activeMs },
206
+ idleMs: d.idleMs,
207
+ turns: d.turnIds.size,
208
+ tools,
209
+ tokens: { ...d.tokens },
210
+ costGBP: { opus: opusCostGBP(d.tokens, cfg), sonnet: sonnetCostGBP(d.tokens, cfg) },
211
+ };
212
+ });
213
+ // Totals — cost re-derived from summed tokens (not summed rounded costs).
214
+ const totalTokens = zeroTokens();
215
+ const totalActive = { thinking: 0, messaging: 0, toolUse: 0 };
216
+ let totalIdle = 0;
217
+ let totalTurns = 0;
218
+ let totalTools = 0;
219
+ for (const r of dayRows) {
220
+ totalTokens.output += r.tokens.output;
221
+ totalTokens.input += r.tokens.input;
222
+ totalTokens.cacheWrite += r.tokens.cacheWrite;
223
+ totalTokens.cacheRead += r.tokens.cacheRead;
224
+ totalActive.thinking += r.activeMs.thinking;
225
+ totalActive.messaging += r.activeMs.messaging;
226
+ totalActive.toolUse += r.activeMs.toolUse;
227
+ totalIdle += r.idleMs;
228
+ totalTurns += r.turns;
229
+ totalTools += r.tools;
230
+ }
231
+ const totals = {
232
+ activeMs: totalActive,
233
+ idleMs: totalIdle,
234
+ turns: totalTurns,
235
+ tools: totalTools,
236
+ tokens: totalTokens,
237
+ costGBP: { opus: opusCostGBP(totalTokens, cfg), sonnet: sonnetCostGBP(totalTokens, cfg) },
238
+ };
239
+ const corr = pearson(dayRows.map((r) => r.tokens.output), dayRows.map((r) => r.activeMs.thinking + r.activeMs.messaging + r.activeMs.toolUse));
240
+ // Observability.
241
+ const usedTools = new Set(evs.filter((e) => e.kind === 'toolUse' && e.toolUseId).map((e) => e.toolUseId));
242
+ const matched = [...usedTools].filter((id) => toolResultIds.has(id)).length;
243
+ const spanMs = evs.length > 0 ? evs[evs.length - 1].ts - evs[0].ts : 0;
244
+ const nowIso = opts.nowIso ?? new Date().toISOString();
245
+ if (opts.verbose) {
246
+ for (const r of dayRows) {
247
+ const active = r.activeMs.thinking + r.activeMs.messaging + r.activeMs.toolUse;
248
+ const span = active + r.idleMs;
249
+ const idlePct = span > 0 ? Math.round((r.idleMs / span) * 100) : 0;
250
+ log(`session=${sessionId.slice(0, 8)} day=${r.date} activeMin=${(active / 60000).toFixed(1)} idleMin=${(r.idleMs / 60000).toFixed(1)} idlePct=${idlePct}`);
251
+ const opusUSDcacheRead = (r.tokens.cacheRead * OPUS_4_8.cacheRead) / 1_000_000;
252
+ const opusUSDtotal = r.costGBP.opus * cfg.usdPerGbp;
253
+ const cacheReadPct = opusUSDtotal > 0 ? Math.round((opusUSDcacheRead / opusUSDtotal) * 100) : 0;
254
+ log(`op=cost day=${r.date} opusGBP=${r.costGBP.opus.toFixed(2)} sonnetGBP=${r.costGBP.sonnet.toFixed(2)} cacheReadPct=${cacheReadPct}`);
255
+ }
256
+ }
257
+ log(`op=reconcile residualMs=${residualMs} spanMs=${spanMs}`);
258
+ log(`op=pricing opusPriceDate=${cfg.priceDate} usdPerGbp=${cfg.usdPerGbp} tokenizerFactor=${cfg.tokenizerFactor}`);
259
+ if (pricingIsStale(cfg, nowIso))
260
+ log(`WARN op=pricing stale opusPriceDate=${cfg.priceDate} now=${nowIso.slice(0, 10)}`);
261
+ log(`op=tool-pairs used=${usedTools.size} matched=${matched} orphaned=${usedTools.size - matched}`);
262
+ log(`op=turns count=${firstLineById.size} usageBearing=${usageById.size}`);
263
+ log(`op=thinking blocks=${thinkingBlocks} withText=${thinkingWithText}`);
264
+ return {
265
+ sessionId,
266
+ days: dayRows,
267
+ totals,
268
+ corrOutputVsActive: corr,
269
+ pricing: { opusPriceDate: cfg.priceDate, usdPerGbp: cfg.usdPerGbp, tokenizerFactor: cfg.tokenizerFactor },
270
+ };
271
+ }
272
+ function pearson(xs, ys) {
273
+ const n = xs.length;
274
+ if (n < 2)
275
+ return 0;
276
+ const mx = xs.reduce((a, b) => a + b, 0) / n;
277
+ const my = ys.reduce((a, b) => a + b, 0) / n;
278
+ let sxy = 0;
279
+ let sxx = 0;
280
+ let syy = 0;
281
+ for (let i = 0; i < n; i++) {
282
+ const dx = xs[i] - mx;
283
+ const dy = ys[i] - my;
284
+ sxy += dx * dy;
285
+ sxx += dx * dx;
286
+ syy += dy * dy;
287
+ }
288
+ if (sxx === 0 || syy === 0)
289
+ return 0;
290
+ return sxy / Math.sqrt(sxx * syy);
291
+ }
292
+ //# sourceMappingURL=session-metering.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-metering.js","sourceRoot":"","sources":["../src/session-metering.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,2DAA2D;AAC3D,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,iFAAiF;AACjF,iCAAiC;AACjC,6EAA6E;AAC7E,6EAA6E;AAC7E,yEAAyE;AACzE,+EAA+E;AAC/E,sCAAsC;AACtC,2EAA2E;AAC3E,0EAA0E;AAC1E,+EAA+E;AAC/E,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,mEAAmE;AAEnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AACpC,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,cAAc,EACd,QAAQ,GAGT,MAAM,cAAc,CAAA;AAErB,MAAM,YAAY,GAAG,OAAO,CAAA;AA+C5B,SAAS,UAAU;IACjB,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAA;AAC7D,CAAC;AACD,SAAS,MAAM;IACb,OAAO;QACL,QAAQ,EAAE,EAAE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M,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;QACrB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAA;QACrB,GAAG,IAAI,EAAE,GAAG,EAAE,CAAA;QACd,GAAG,IAAI,EAAE,GAAG,EAAE,CAAA;QACd,GAAG,IAAI,EAAE,GAAG,EAAE,CAAA;IAChB,CAAC;IACD,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC;QAAE,OAAO,CAAC,CAAA;IACpC,OAAO,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;AACnC,CAAC"}
@@ -3,7 +3,7 @@ name: project-manager
3
3
  description: "Create, track, and complete tasks and projects, name sessions, and compose and run multi-step workflows. Delegate when the work is about organising what's on, tracking progress, or building a repeatable workflow."
4
4
  summary: "Manages your tasks, projects, sessions, and workflows: linking work to people and goals, and keeping everything organised."
5
5
  model: claude-sonnet-5
6
- tools: mcp__plugin_work_work__work-create, mcp__plugin_work_work__work-update, mcp__plugin_work_work__work-list, mcp__plugin_work_work__work-get, mcp__plugin_work_work__work-relate, mcp__plugin_work_work__work-complete, mcp__plugin_work_work__work-ready, mcp__plugin_work_work__project-create, mcp__plugin_work_work__project-list, mcp__plugin_work_work__project-get, mcp__plugin_work_work__project-update, mcp__plugin_work_work__project-complete, mcp__plugin_work_work__session-list, mcp__plugin_work_work__session-name, mcp__plugin_workflows_workflows__workflow-create, mcp__plugin_workflows_workflows__workflow-list, mcp__plugin_workflows_workflows__workflow-get, mcp__plugin_workflows_workflows__workflow-update, mcp__plugin_workflows_workflows__workflow-delete, mcp__plugin_workflows_workflows__workflow-validate, mcp__plugin_workflows_workflows__workflow-execute, mcp__plugin_workflows_workflows__workflow-runs, mcp__plugin_memory_memory__memory-search, Skill
6
+ tools: mcp__plugin_work_work__work-create, mcp__plugin_work_work__work-update, mcp__plugin_work_work__work-list, mcp__plugin_work_work__work-get, mcp__plugin_work_work__work-relate, mcp__plugin_work_work__work-complete, mcp__plugin_work_work__work-ready, mcp__plugin_work_work__project-create, mcp__plugin_work_work__project-list, mcp__plugin_work_work__project-get, mcp__plugin_work_work__project-update, mcp__plugin_work_work__project-complete, mcp__plugin_work_work__session-list, mcp__plugin_work_work__session-name, mcp__plugin_work_work__session-metering, mcp__plugin_workflows_workflows__workflow-create, mcp__plugin_workflows_workflows__workflow-list, mcp__plugin_workflows_workflows__workflow-get, mcp__plugin_workflows_workflows__workflow-update, mcp__plugin_workflows_workflows__workflow-delete, mcp__plugin_workflows_workflows__workflow-validate, mcp__plugin_workflows_workflows__workflow-execute, mcp__plugin_workflows_workflows__workflow-runs, mcp__plugin_memory_memory__memory-search, Skill
7
7
  ---
8
8
 
9
9
  # Project Manager
@@ -8,21 +8,6 @@
8
8
  "name": "sitedesk",
9
9
  "source": "./sitedesk",
10
10
  "version": "0.1.0"
11
- },
12
- {
13
- "name": "teaching",
14
- "source": "./teaching",
15
- "version": "0.1.0"
16
- },
17
- {
18
- "name": "venture-studio",
19
- "source": "./venture-studio",
20
- "version": "0.1.0"
21
- },
22
- {
23
- "name": "writer-craft",
24
- "source": "./writer-craft",
25
- "version": "0.1.0"
26
11
  }
27
12
  ]
28
13
  }
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CAM3fms7.js";import{A as t,L as n,M as r,N as i,O as a}from"./useSubAccountSwitcher-DMbRhLPv.js";import{i as o}from"./admin-types-hioowVct.js";import{v as s,y as c}from"./AdminShell-D2-uBSB5.js";import{t as l}from"./Checkbox-1F1tzqca.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(n(),1);function m(e=`admin`){let[t,n]=(0,p.useState)(`loading`),[r,a]=(0,p.useState)(``),[s,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let G=(0,p.useRef)(null),K=(0,p.useRef)(null);(0,p.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();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=o(r.thinkingView);return H.current=i,V(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}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,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let q=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();if(t.auth_status===`dead`||t.auth_status===`missing`){n(`connect-claude`);return}}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){i(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),q.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&n(`enter-pin`)}).catch(()=>{})},[t]);async function J(e,t){y(!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`){i(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await r.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Y=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=s.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let o=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){i(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);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`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await J(o);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,s]),X=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await J(r)},[r]),Z=(0,p.useCallback)(async()=>{T(!0);try{if(!await c())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),Q=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{q.current=Q},[Q]),{appState:t,setAppState:n,pin:r,setPin:a,operatorName:s,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,pinInputRef:G,setPinFormRef:K,handleSetPin:Y,handleLogin:X,handleDisconnect:Z,handleLogout:Q}}var h=r();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.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,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.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 _(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,a.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,a.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n||!m.trim(),loading:c,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:c,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:a.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(s,{variant:`send`,type:`submit`,disabled:!n,loading:c,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:n,setAuthPolling:r,authLoading:i,setAuthLoading:o,pinError:c,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1);async function _(){g(!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?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function v(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){r(!0),f(!0),o(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).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.`),r(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function y(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),r(!1),l(``)}return n||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[n?(0,h.jsx)(`button`,{onClick:y,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,h.jsx)(`button`,{onClick:()=>f(!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,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:n?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!n&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(s,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:c})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:a.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,a.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(s,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.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,h.jsx)(`button`,{onClick:_,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),c&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:c})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{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,h.jsx)(y,{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,h.jsx)(v,{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:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};
1
+ import{o as e}from"./chunk-CAM3fms7.js";import{A as t,L as n,M as r,N as i,O as a}from"./useSubAccountSwitcher-UqZbmzYy.js";import{i as o}from"./admin-types-hioowVct.js";import{b as s,y as c}from"./AdminShell-cRTvNRbo.js";import{t as l}from"./Checkbox-Dh2pLMFN.js";var u=`admin-landing-redirected`,d=`/graph`;function f(e){return e.variant===`operator`?!1:e.appState===`chat`&&!e.alreadyRedirected}var p=e(n(),1);function m(e=`admin`){let[t,n]=(0,p.useState)(`loading`),[r,a]=(0,p.useState)(``),[c,l]=(0,p.useState)(``),[m,h]=(0,p.useState)(``),[g,_]=(0,p.useState)(!1),[v,y]=(0,p.useState)(!1),[b,x]=(0,p.useState)(!1),[S,C]=(0,p.useState)(!1),[w,T]=(0,p.useState)(!1),[E,D]=(0,p.useState)(null),[O,k]=(0,p.useState)(null),[A,j]=(0,p.useState)(void 0),[M,N]=(0,p.useState)(null),[P,F]=(0,p.useState)(void 0),[I,L]=(0,p.useState)(null),[R,z]=(0,p.useState)(null),[B,V]=(0,p.useState)(void 0),H=(0,p.useRef)(void 0),[U,W]=(0,p.useState)(!1);(0,p.useEffect)(()=>{typeof window>`u`||fetch(`/api/remote-auth/status`).then(e=>e.ok?e.json():null).then(e=>{e?.configured&&W(!0)}).catch(()=>{})},[]);let G=(0,p.useRef)(null),K=(0,p.useRef)(null);(0,p.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();D(r.session_key),z(r.sessionId??null),j(r.businessName),N(r.role??null),F(r.userName===void 0?null:r.userName),L(r.avatar??null);let i=o(r.thinkingView);return H.current=i,V(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}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,p.useEffect)(()=>{t===`chat`&&fetch(`/api/admin/claude-info`).then(e=>{if(e.ok)return e.json()}).then(e=>{e&&k(e)}).catch(()=>{})},[t]),(0,p.useEffect)(()=>{if(typeof window>`u`)return;let n=!1;try{n=sessionStorage.getItem(u)===`1`}catch{}if(f({appState:t,alreadyRedirected:n,variant:e})){try{sessionStorage.setItem(u,`1`)}catch{}console.info(`[admin-ui] landing-redirect target=${d}`),window.location.replace(d)}},[t,e]);let q=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(t!==`chat`)return;let e=setInterval(async()=>{try{let e=await fetch(`/api/health`);if(e.ok){let t=await e.json();if(t.auth_status===`dead`||t.auth_status===`missing`){n(`connect-claude`);return}}}catch{}if(E)try{let e=await fetch(`/api/admin/session?session_key=${encodeURIComponent(E)}`);if(e.status!==401)return;let t=(await e.clone().json().catch(()=>null))?.code??`unknown-401`;if(t===`remote-auth-required`){i(`heartbeat`,`/api/admin/session`);return}console.warn(`[admin-auth] outcome=heartbeat-detected-expiry code=${t}`),q.current?.()}catch{}},300*1e3);return()=>clearInterval(e)},[t,E]),(0,p.useEffect)(()=>{t===`connect-claude`&&fetch(`/api/health`).then(e=>e.ok?e.json():null).then(e=>{e?.claude_authenticated&&n(`enter-pin`)}).catch(()=>{})},[t]);async function J(e,t){y(!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`){i(`enter-pin`,`/api/admin/session`);return}h(e.error||`Invalid PIN`);return}let s=await r.json();D(s.session_key),z(s.sessionId??null),j(s.businessName),N(s.role??null),F(s.userName===void 0?null:s.userName),L(s.avatar??null);let c=o(s.thinkingView);H.current=c,V(c);try{sessionStorage.setItem(`maxy-admin-session-key`,s.session_key)}catch{}a(``),n(`chat`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}}let Y=(0,p.useCallback)(async e=>{if(e.preventDefault(),v)return;h(``);let t=c.trim();if(!t){h(`Please enter your name.`);return}if(r.length<4){h(`PIN must be at least 4 characters.`);return}let o=r;y(!0);try{let e=await fetch(`/api/onboarding/set-pin`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({pin:o,name:t})});if(!e.ok){let t=await e.json().catch(()=>({}));if(e.status===401&&t?.code===`remote-auth-required`){i(`set-pin`,`/api/onboarding/set-pin`);return}if(e.status===409){console.log(`[admin] PIN already configured — re-checking health`);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`):h(t.error||`Failed to set PIN.`)}else n(`enter-pin`)}catch{n(`enter-pin`)}return}h(t.error||`Failed to set PIN.`);return}let r=await fetch(`/api/health`);if((r.ok?await r.json():null)?.claude_authenticated){await J(o);return}a(``),n(`connect-claude`)}catch(e){console.error(`[admin] connection error:`,e),h(`Could not connect.`)}finally{y(!1)}},[r,v,c]),X=(0,p.useCallback)(async e=>{e.preventDefault(),h(``),await J(r)},[r]),Z=(0,p.useCallback)(async()=>{T(!0);try{if(!await s())return console.warn(`[admin-ui] claude-disconnect not verified — credentials may persist; staying put`),!1;D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}return n(`connect-claude`),!0}finally{T(!1)}},[]),Q=(0,p.useCallback)(()=>{D(null),N(null),F(void 0),L(null);try{sessionStorage.removeItem(`maxy-admin-session-key`),sessionStorage.removeItem(u)}catch{}a(``),h(``),n(`enter-pin`)},[]);return(0,p.useEffect)(()=>{q.current=Q},[Q]),{appState:t,setAppState:n,pin:r,setPin:a,operatorName:c,setOperatorName:l,pinError:m,setPinError:h,showPin:g,setShowPin:_,pinLoading:v,authPolling:b,setAuthPolling:x,authLoading:S,setAuthLoading:C,disconnecting:w,cacheKey:E,setCacheKey:D,claudeInfo:O,setClaudeInfo:k,businessName:A,role:M,userName:P,userAvatar:I,sessionId:R,setSessionId:z,expandAll:B,setExpandAll:V,expandAllDefaultRef:H,remoteAuthEnabled:U,pinInputRef:G,setPinFormRef:K,handleSetPin:Y,handleLogin:X,handleDisconnect:Z,handleLogout:Q}}var h=r();function g({inputRef:e,value:t,onChange:n,onComplete:r,showPin:i,autoFocus:a}){let o=(0,p.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,h.jsx)(`div`,{className:`pin-field`,children:Array.from({length:6}).map((n,r)=>(0,h.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 _(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,setPinFormRef:f,onSubmit:p,operatorName:m,setOperatorName:_}=e;return(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Welcome to `,a.productName]}),(0,h.jsxs)(`p`,{className:`connect-subtitle`,children:[`Tell `,a.productName,` who you are, then choose a PIN.`]}),(0,h.jsxs)(`form`,{ref:f,onSubmit:p,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(`input`,{type:`text`,className:`connect-name-input`,placeholder:`Your full name`,value:m,onChange:e=>_(e.target.value),autoComplete:`name`,autoFocus:!0,required:!0,"aria-label":`Your full name`}),(0,h.jsx)(`div`,{style:{width:38,flexShrink:0},"aria-hidden":`true`})]}),(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!n||!m.trim(),loading:s,"aria-label":`Set PIN`,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})})}function v(e){let{pin:n,setPin:r,showPin:i,setShowPin:o,pinLoading:s,pinError:u,pinInputRef:d,onSubmit:f,remoteAuthEnabled:p,onSignOutRemote:m}=e;return(0,h.jsxs)(`div`,{className:`connect-page`,children:[p&&m&&(0,h.jsx)(`button`,{type:`button`,className:`connect-signout`,onClick:m,children:`Sign out`}),(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`h1`,{className:`connect-title`,children:a.productName}),(0,h.jsxs)(`form`,{onSubmit:f,className:`connect-pin-form`,children:[(0,h.jsxs)(`div`,{className:`pin-input-row`,children:[(0,h.jsx)(g,{inputRef:d,value:n,onChange:r,onComplete:()=>{},showPin:i,autoFocus:!0}),(0,h.jsx)(c,{variant:`send`,type:`submit`,disabled:!n,loading:s,children:(0,h.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,h.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`}),(0,h.jsx)(`polyline`,{points:`12 5 19 12 12 19`})]})})]}),(0,h.jsx)(`div`,{className:`pin-options`,children:(0,h.jsx)(l,{checked:i,onChange:()=>o(e=>!e),label:`Show PIN`})})]}),u&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:u})]})]})}function y(e){let{authPolling:n,setAuthPolling:r,authLoading:i,setAuthLoading:o,pinError:s,setPinError:l,setAppState:u}=e,[d,f]=(0,p.useState)(!1),[m,g]=(0,p.useState)(!1);async function _(){g(!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?f(!0):e.error&&l(e.error)}catch(e){console.error(`[admin] browser launch error:`,e),l(`Could not launch browser.`)}g(!1)}async function v(){o(!0),l(``);try{let e=await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`})).json();if(e.started){r(!0),f(!0),o(!1);for(let e=0;e<120;e++)if(await new Promise(e=>setTimeout(e,2e3)),(await(await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`wait`})})).json()).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.`),r(!1)}else e.error&&l(e.error)}catch(e){console.error(`[admin] auth flow error:`,e),l(`Could not start auth flow.`)}o(!1)}async function y(){await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`stop`})}),r(!1),l(``)}return n||d?(0,h.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,height:`100dvh`,overflow:`auto`},children:[(0,h.jsxs)(`header`,{className:`chat-header`,style:{paddingBottom:`12px`,flexShrink:0,position:`relative`,maxWidth:`680px`,width:`100%`,margin:`0 auto`,padding:`24px 20px 12px`},children:[n?(0,h.jsx)(`button`,{onClick:y,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,h.jsx)(`button`,{onClick:()=>f(!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,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`chat-logo`}),(0,h.jsx)(`h1`,{className:`chat-tagline`,children:`Connect Claude`}),(0,h.jsx)(`p`,{className:`chat-intro`,children:n?`Sign in and authorize in the browser below.`:`Open your email or prepare your accounts, then sign in.`}),!n&&(0,h.jsx)(`div`,{style:{marginTop:`12px`},children:(0,h.jsx)(c,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`})})]}),(0,h.jsx)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,gap:`10px`,padding:`0 0 16px`},children:(0,h.jsx)(`iframe`,{src:`/vnc-viewer.html`,style:{flex:1,width:`100%`,minHeight:0,border:`none`,background:`#111`,display:`block`},title:`Claude Sign-in`})}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,style:{textAlign:`center`,padding:`0 20px 16px`},children:s})]}):(0,h.jsx)(`div`,{className:`connect-page`,children:(0,h.jsxs)(`div`,{className:`connect-content`,children:[(0,h.jsxs)(`div`,{className:`connect-logos`,children:[(0,h.jsx)(`div`,{className:`connect-logo-wrap`,children:(0,h.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`connect-logo`})}),(0,h.jsx)(`svg`,{className:`connect-arrow`,viewBox:`0 0 48 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,h.jsx)(`path`,{d:`M0 12h44m0 0l-8-8m8 8l-8 8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,h.jsxs)(`div`,{className:`connect-logo-wrap`,children:[(0,h.jsx)(`img`,{src:t,alt:a.productName,className:`connect-logo connect-logo--maxy`}),!a.logoContainsName&&(0,h.jsx)(`span`,{className:`connect-logo-label`,children:a.productName})]})]}),(0,h.jsxs)(`h1`,{className:`connect-title`,children:[`Connect Claude to power `,a.productName]}),(0,h.jsx)(`p`,{className:`connect-subtitle`,children:`Sign in with your Anthropic account to get started.`}),(0,h.jsx)(c,{variant:`primary`,onClick:v,disabled:i,children:i?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`span`,{className:`spin`,style:{display:`inline-block`},children:`✱`}),` Connecting…`]}):`Sign in to Claude`}),(0,h.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,h.jsx)(`button`,{onClick:_,disabled:m,style:{marginTop:`12px`,background:`none`,border:`none`,color:`var(--color-primary, #666)`,fontSize:`13px`,cursor:`pointer`,textDecoration:`underline`,textUnderlineOffset:`3px`},children:m?`Launching…`:`Open browser first`}),s&&(0,h.jsx)(`p`,{className:`admin-pin-error`,children:s})]})})}function b({auth:e}){return e.appState===`loading`?(0,h.jsx)(`div`,{className:`connect-page`}):e.appState===`set-pin`?(0,h.jsx)(_,{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,h.jsx)(y,{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,h.jsx)(v,{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:()=>{console.info(`[admin-ui] remote-auth sign-out → /__remote-auth/logout`),window.location.href=`/__remote-auth/logout`}}):null}export{m as n,b as t};