wednesdayai 0.6.1-dev.27 → 0.6.1-dev.28

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 (185) hide show
  1. package/dist/{agent-CQhgyAis.js → agent-BDuI5Zvc.js} +26 -26
  2. package/dist/{agent-Y_2aRBZH.js → agent-BW-Yan08.js} +11 -11
  3. package/dist/{agent-turn-runner-faZvyYiv.js → agent-turn-runner-BfXiXNe2.js} +6 -6
  4. package/dist/{agent-turn-runner-ClBJoKQQ.js → agent-turn-runner-CHm-I95T.js} +5 -5
  5. package/dist/build-info.json +3 -3
  6. package/dist/bundled/boot-md/handler.js +32 -32
  7. package/dist/bundled/bootstrap-extra-files/handler.js +4 -4
  8. package/dist/bundled/command-logger/handler.js +2 -2
  9. package/dist/bundled/session-journal/handler.js +31 -31
  10. package/dist/bundled/session-memory/handler.js +31 -31
  11. package/dist/canvas-host/a2ui/.bundle.hash +1 -1
  12. package/dist/{chrome-B3nEcesV.js → chrome-CKy31bWh.js} +32 -32
  13. package/dist/{chrome-DLbFTDQE.js → chrome-Ct9vb6SC.js} +12 -12
  14. package/dist/{command-queue-BSbitNdP.js → command-queue-AIWqKnVD.js} +1 -1
  15. package/dist/{command-queue-BijpV9rd.js → command-queue-CNStMA4Y.js} +1 -1
  16. package/dist/control-ui-v2/assets/{AgentsView-DVvw6PTU.js → AgentsView-3Qsr3xnf.js} +1 -1
  17. package/dist/control-ui-v2/assets/{AutomationsView-CxjmPRdI.js → AutomationsView-DkBzPKKQ.js} +1 -1
  18. package/dist/control-ui-v2/assets/Badge-CB5TWfdz.js +1 -0
  19. package/dist/control-ui-v2/assets/{Button-DL76WqX4.js → Button-CGdLofSY.js} +1 -1
  20. package/dist/control-ui-v2/assets/{ChannelsView-BDcVzQIM.js → ChannelsView-BRb8eYyh.js} +1 -1
  21. package/dist/control-ui-v2/assets/{ConfigForm-CbvOdyOA.js → ConfigForm-D8_bqW8x.js} +1 -1
  22. package/dist/control-ui-v2/assets/{ConfirmDialog-DGHQXUr5.js → ConfirmDialog-B7aotBjN.js} +1 -1
  23. package/dist/control-ui-v2/assets/{DataTable-lEkd1R85.js → DataTable-CSi930kO.js} +1 -1
  24. package/dist/control-ui-v2/assets/{DebugView-CHHmLv3x.js → DebugView-8cZqh6FQ.js} +1 -1
  25. package/dist/control-ui-v2/assets/{Dialog-rIrrCPSu.js → Dialog-CQE8Pvh6.js} +1 -1
  26. package/dist/control-ui-v2/assets/{DreamsView-uQSpm1S4.js → DreamsView-B0KzP2OM.js} +1 -1
  27. package/dist/control-ui-v2/assets/{EntityLink-AEBgCNQX.js → EntityLink-BO2oG3y8.js} +1 -1
  28. package/dist/control-ui-v2/assets/{FilterPills-HxAXXDO8.js → FilterPills-9pNaAyrL.js} +1 -1
  29. package/dist/control-ui-v2/assets/{InstancesView-Svk7C7AX.js → InstancesView-BbunCxYg.js} +1 -1
  30. package/dist/control-ui-v2/assets/{LearningView-CWqWycCM.js → LearningView-CEqD48Ll.js} +1 -1
  31. package/dist/control-ui-v2/assets/{LogsView-D7kaR6es.js → LogsView-fcI0vxkz.js} +1 -1
  32. package/dist/control-ui-v2/assets/{NodesView-CqKA1XAX.js → NodesView-BONHE7EP.js} +1 -1
  33. package/dist/control-ui-v2/assets/{OverviewView-Dz3YnxWP.js → OverviewView-BpynJnjy.js} +1 -1
  34. package/dist/control-ui-v2/assets/{Panel-CyfpswdJ.js → Panel-9wOynsWc.js} +1 -1
  35. package/dist/control-ui-v2/assets/{PluginMount-C1HeSpS9.js → PluginMount-6N20-nhI.js} +1 -1
  36. package/dist/control-ui-v2/assets/{PluginPageView-Dap5OwAt.js → PluginPageView-DZ3bh805.js} +1 -1
  37. package/dist/control-ui-v2/assets/{PluginPanels-DdDZQ_Dn.js → PluginPanels-DulRlgcm.js} +1 -1
  38. package/dist/control-ui-v2/assets/{RunsView-CQXkKsIZ.js → RunsView-dcBTwtFX.js} +1 -1
  39. package/dist/control-ui-v2/assets/{SessionsView-Bs9UqOQr.js → SessionsView-CZuTvckb.js} +1 -1
  40. package/dist/control-ui-v2/assets/{SettingsView-BhorzAw5.js → SettingsView-BTcubWvr.js} +1 -1
  41. package/dist/control-ui-v2/assets/{SkillsView-ClzUjPU-.js → SkillsView-Bj7lvW23.js} +1 -1
  42. package/dist/control-ui-v2/assets/{Stat-BruDi6qc.js → Stat-BZwg1PGE.js} +1 -1
  43. package/dist/control-ui-v2/assets/{StatusDot-Cij-6nH8.js → StatusDot-DHhJ1VpB.js} +1 -1
  44. package/dist/control-ui-v2/assets/{StorageView-BYgvfNcg.js → StorageView-B5cF1lld.js} +1 -1
  45. package/dist/control-ui-v2/assets/{UpdatedAgo-DWSnE4WG.js → UpdatedAgo-Dw3kxb2x.js} +1 -1
  46. package/dist/control-ui-v2/assets/{UsageView-C_ezU9jy.js → UsageView-DBZ1WkEI.js} +1 -1
  47. package/dist/control-ui-v2/assets/{config-store-27hOx1yp.js → config-store-XvvVJ8Fq.js} +1 -1
  48. package/dist/control-ui-v2/assets/{format-dlOOV12I.js → format-CGs6a1G6.js} +1 -1
  49. package/dist/control-ui-v2/assets/gateway-features-BZH74_Oc.js +1 -0
  50. package/dist/control-ui-v2/assets/{index-OijNknZs.js → index-BvXiY83i.js} +1 -1
  51. package/dist/control-ui-v2/assets/{links-C1sAzVEH.js → links-DlVrQOFC.js} +2 -2
  52. package/dist/control-ui-v2/assets/{run-rows-BYCIH1Sn.js → run-rows-Au2UUkD7.js} +1 -1
  53. package/dist/control-ui-v2/assets/{runs-store-DLIlHRM6.js → runs-store-DXgNPFWM.js} +1 -1
  54. package/dist/control-ui-v2/assets/{use-gateway-query-CF94JYnM.js → use-gateway-query-D25QZANO.js} +1 -1
  55. package/dist/control-ui-v2/index.html +7 -7
  56. package/dist/{deliver-CY4Fs4RX.js → deliver-DsuMPE0S.js} +28 -28
  57. package/dist/{deliver-xfGDp6XD.js → deliver-DxVojbH7.js} +6 -6
  58. package/dist/{diagnostic-S8OX1Eq2.js → diagnostic-C4pLNG6a.js} +1 -1
  59. package/dist/{diagnostic-BZYYYnMx.js → diagnostic-DJ11ZJIJ.js} +3 -3
  60. package/dist/{errors-BRYMqzPb.js → errors-0-at0aYV.js} +1 -1
  61. package/dist/extensionAPI.js +24 -24
  62. package/dist/{fences-Dtk43Q2a.js → fences-Z8d1dj8p.js} +16 -16
  63. package/dist/{fences-DbKcVN_n.js → fences-j5vzXLXf.js} +1 -1
  64. package/dist/{fetch-guard-UCuiKQ5E.js → fetch-guard-BQ-NMG7L.js} +2 -2
  65. package/dist/{fetch-guard-DuBGo4VE.js → fetch-guard-BaBd9ZVm.js} +2 -2
  66. package/dist/{frontmatter-DHBTRDiB.js → frontmatter-CzhUc9Ri.js} +5 -5
  67. package/dist/{fs-safe-Bk4Thq7a.js → fs-safe-Bd1xxVwv.js} +1 -1
  68. package/dist/{fs-safe-CyG0wflg.js → fs-safe-DMWtsz4J.js} +26 -26
  69. package/dist/{legacy-names-6uH6aLhq.js → legacy-names-chsmo2vs.js} +26 -26
  70. package/dist/llm-slug-generator.js +31 -31
  71. package/dist/{manager-BvLLls5L.js → manager-B4xc1xN6.js} +16 -16
  72. package/dist/{manager-Cf3W8LKj.js → manager-CD-sBxdS.js} +3 -3
  73. package/dist/{model-selection-Ca4WCV4n.js → model-selection-CYS--Nqz.js} +1 -1
  74. package/dist/{model-selection-CbMZx9fR.js → model-selection-Ds5bEVQ2.js} +82 -82
  75. package/dist/{nudge-DelcKR7z.js → nudge-CKFTN2YI.js} +9 -9
  76. package/dist/{nudge-Dd9wU1K5.js → nudge-DZuNGDE_.js} +32 -32
  77. package/dist/{outbound-attachment-CKATrxgO.js → outbound-attachment-BsEApkFu.js} +9 -9
  78. package/dist/{outbound-attachment-Btl5f-Lu.js → outbound-attachment-DHLTkCuI.js} +4 -4
  79. package/dist/{pi-embedded-ApthdT0k.js → pi-embedded-C8SqFziv.js} +40 -40
  80. package/dist/{pi-embedded-D-4wht-f.js → pi-embedded-yXKiYEGf.js} +229 -229
  81. package/dist/{pi-model-discovery-Dgbp4zjx.js → pi-model-discovery-CtfGh_up.js} +7 -7
  82. package/dist/{pi-model-discovery-D-D_mngz.js → pi-model-discovery-De5Z6lro.js} +1 -1
  83. package/dist/{proxy-env-v_oj7Urd.js → proxy-env-D4WYaw6X.js} +1 -1
  84. package/dist/{proxy-env-BRG1LWK1.js → proxy-env-DPCNy_X3.js} +1 -1
  85. package/dist/{pw-ai-BH-MmrGa.js → pw-ai-BmuDO1HM.js} +5 -5
  86. package/dist/{pw-ai-DK4N7_nV.js → pw-ai-ohfJZ9jX.js} +11 -11
  87. package/dist/{qmd-manager-Cdz2xlNp.js → qmd-manager-2dro3Ccn.js} +9 -9
  88. package/dist/{qmd-manager-NT_CKYQG.js → qmd-manager-CgZ9ng9u.js} +4 -4
  89. package/dist/{qmd-scope-CyWbQgiS.js → qmd-scope-DMUA3Vq9.js} +1 -1
  90. package/dist/{qmd-scope-hzI66flw.js → qmd-scope-RFd-g5Qi.js} +1 -1
  91. package/dist/{query-expansion-CPkdZdty.js → query-expansion-DQ8zm-TE.js} +1 -1
  92. package/dist/{query-expansion-feTsk3WF.js → query-expansion-GZKwviqQ.js} +13 -13
  93. package/dist/{recorder-DCGoPaKG.js → recorder-DA5NY6nl.js} +1 -1
  94. package/dist/{recorder-C3f7IlHZ.js → recorder-dKE74HOC.js} +2 -2
  95. package/dist/{redact-C4XKILzo.js → redact-LOuk7TRy.js} +1 -1
  96. package/dist/{reply-directives-BjV2MFIq.js → reply-directives-8FtYI79u.js} +9 -9
  97. package/dist/{reply-directives-ToqsETSh.js → reply-directives-CE9WoRyW.js} +49 -49
  98. package/dist/{runs-CPjMwHXQ.js → runs-BIabbRe5.js} +8 -8
  99. package/dist/{runs-D7qs08K3.js → runs-Dw8BeXyu.js} +5 -5
  100. package/dist/{send-BnVk7V-5.js → send-BQzswQlt.js} +5 -5
  101. package/dist/{send-DDBl5H1k.js → send-BTp_lz-m.js} +4 -4
  102. package/dist/{send-B9huC0Lk.js → send-CWcFiq7U.js} +3 -3
  103. package/dist/{send-Cj5zKV3M.js → send-DW_8PsC0.js} +4 -4
  104. package/dist/{sessions-zel35iDK.js → sessions-Bz8mUwgo.js} +5 -5
  105. package/dist/{sessions-CXuFR_IY.js → sessions-DKv9bCbi.js} +1 -1
  106. package/dist/{subsystem-DoQFckDJ.js → subsystem-cFv2jJm-.js} +71 -71
  107. package/dist/{tool-loop-detection-CtOkwPJY.js → tool-loop-detection-9fAxiikd.js} +2 -2
  108. package/dist/{user-run-recording-BVpLQDqe.js → user-run-recording-C1LRU5Lb.js} +2 -2
  109. package/dist/{user-run-recording-C10wwXyW.js → user-run-recording-CWRiZJsh.js} +1 -1
  110. package/dist/web-client/assets/{hast-util-from-dom-CvePVP6E.js → hast-util-from-dom-BoP9fB2c.js} +1 -1
  111. package/dist/web-client/assets/{hast-util-to-mdast-CwugKdbc.js → hast-util-to-mdast-Bo07nYTv.js} +1 -1
  112. package/dist/web-client/assets/{index-CFHLAWrp.js → index-CwqOe0fG.js} +2 -2
  113. package/dist/web-client/index.html +1 -1
  114. package/dist/{ws-2U5gNvRt.js → ws-Do6yaRWR.js} +1 -1
  115. package/dist/{ws-DrXm3NWZ.js → ws-Dt2EocLN.js} +1 -1
  116. package/extensions/a2a/package.json +1 -1
  117. package/extensions/acpx/package.json +1 -1
  118. package/extensions/anthropic/package.json +1 -1
  119. package/extensions/bifrost/package.json +1 -1
  120. package/extensions/bluebubbles/package.json +1 -1
  121. package/extensions/copilot-proxy/package.json +1 -1
  122. package/extensions/deepgram/package.json +1 -1
  123. package/extensions/deepinfra/package.json +1 -1
  124. package/extensions/diagnostics-otel/package.json +1 -1
  125. package/extensions/diffs/package.json +1 -1
  126. package/extensions/discord/package.json +1 -1
  127. package/extensions/dream-cycle/package.json +1 -1
  128. package/extensions/elevenlabs/package.json +1 -1
  129. package/extensions/feishu/package.json +1 -1
  130. package/extensions/gemini-search/package.json +1 -1
  131. package/extensions/google/package.json +1 -1
  132. package/extensions/google-gemini-cli-auth/package.json +1 -1
  133. package/extensions/googlechat/package.json +1 -1
  134. package/extensions/grok-search/package.json +1 -1
  135. package/extensions/groq/package.json +1 -1
  136. package/extensions/identity-oidc/package.json +1 -1
  137. package/extensions/imessage/package.json +1 -1
  138. package/extensions/irc/package.json +1 -1
  139. package/extensions/kimi-search/package.json +1 -1
  140. package/extensions/kokoro/package.json +1 -1
  141. package/extensions/learning-core/package.json +1 -1
  142. package/extensions/line/package.json +1 -1
  143. package/extensions/llm-task/package.json +1 -1
  144. package/extensions/lobster/package.json +1 -1
  145. package/extensions/matrix/CHANGELOG.md +1 -1
  146. package/extensions/matrix/package.json +1 -1
  147. package/extensions/mattermost/package.json +1 -1
  148. package/extensions/memory-core/package.json +1 -1
  149. package/extensions/memory-lancedb/package.json +1 -1
  150. package/extensions/minimax/package.json +1 -1
  151. package/extensions/minimax-portal-auth/package.json +1 -1
  152. package/extensions/mistral/package.json +1 -1
  153. package/extensions/moonshot/package.json +1 -1
  154. package/extensions/msteams/CHANGELOG.md +1 -1
  155. package/extensions/msteams/package.json +1 -1
  156. package/extensions/nextcloud-talk/package.json +1 -1
  157. package/extensions/nostr/CHANGELOG.md +1 -1
  158. package/extensions/nostr/package.json +1 -1
  159. package/extensions/open-prose/package.json +1 -1
  160. package/extensions/openai/package.json +1 -1
  161. package/extensions/openai-realtime/package.json +1 -1
  162. package/extensions/openrouter/package.json +1 -1
  163. package/extensions/perplexity-search/package.json +1 -1
  164. package/extensions/searxng-search/package.json +1 -1
  165. package/extensions/signal/package.json +1 -1
  166. package/extensions/slack/package.json +1 -1
  167. package/extensions/synology-chat/package.json +1 -1
  168. package/extensions/telegram/package.json +1 -1
  169. package/extensions/tlon/package.json +1 -1
  170. package/extensions/twitch/CHANGELOG.md +1 -1
  171. package/extensions/twitch/package.json +1 -1
  172. package/extensions/ui-surfaces/package.json +1 -1
  173. package/extensions/voice-call/CHANGELOG.md +1 -1
  174. package/extensions/voice-call/package.json +1 -1
  175. package/extensions/whatsapp/package.json +1 -1
  176. package/extensions/zai/package.json +1 -1
  177. package/extensions/zalo/CHANGELOG.md +1 -1
  178. package/extensions/zalo/package.json +1 -1
  179. package/extensions/zalouser/CHANGELOG.md +1 -1
  180. package/extensions/zalouser/package.json +1 -1
  181. package/package.json +1 -1
  182. package/dist/control-ui-v2/assets/Badge-4n2tRQ02.js +0 -1
  183. package/dist/control-ui-v2/assets/gateway-features-BIj6-KTX.js +0 -1
  184. package/dist/github-copilot-token-Bm6yG6tw.js +0 -106
  185. package/dist/paths-BIDPYPVC.js +0 -233
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,i as r,l as i,s as a}from"./format-dlOOV12I.js";import{t as o}from"./Button-DL76WqX4.js";import{n as s,t as c}from"./use-gateway-query-CF94JYnM.js";import{t as l}from"./Panel-CyfpswdJ.js";var u=e(n(),1);function d(e,t){return t?.presence&&Array.isArray(t.presence)?t.presence:e}function f(e){return`${e.host??`unknown`} ${e.ip?`(${e.ip})`:``} ${e.mode??``} ${e.version??``}`.trim()}function p(e){let t=[e.mode??`unknown`],n=Array.isArray(e.roles)?e.roles.filter(Boolean):[];t.push(...n);let r=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[];return r.length>0&&t.push(r.length>3?`${r.length} scopes`:`scopes: ${r.join(`, `)}`),e.platform&&t.push(e.platform),e.deviceFamily&&t.push(e.deviceFamily),e.modelIdentifier&&t.push(e.modelIdentifier),e.version&&t.push(e.version),t}var m=t();function h(){let e=s(`system-presence`,{},{refreshMs:c}),t=(0,u.useRef)(null);t.current=e.data??null;let[n,r]=(0,u.useState)(null);(0,u.useEffect)(()=>i.getState().subscribe(`presence`,e=>{r(n=>d(n??t.current??[],e))}),[]),(0,u.useEffect)(()=>{r(null)},[e.data]);let f=n??e.data??[];return(0,m.jsxs)(`div`,{className:`ct-page`,"data-testid":`instances-view`,children:[(0,m.jsxs)(`header`,{className:`ct-page__head`,children:[(0,m.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,m.jsx)(`h1`,{className:`ct-page__title`,children:`Instances`}),(0,m.jsx)(`p`,{className:`ct-page__sub`,children:`Presence beacons from the gateway and clients.`})]}),(0,m.jsx)(o,{onClick:()=>{r(null),e.reload()},disabled:e.loading,children:`Refresh`})]}),(0,m.jsxs)(l,{title:`Connected Instances`,sub:`Updated live from gateway presence events.`,children:[e.error?(0,m.jsx)(a,{tone:`error`,message:e.error}):null,e.loading&&!e.data?(0,m.jsx)(a,{tone:`loading`,message:`Loading…`}):null,!e.error&&f.length===0&&!(e.loading&&!e.data)?(0,m.jsx)(a,{message:`No instances reported yet.`}):null,(0,m.jsx)(`div`,{className:`ct-instances__list`,role:`list`,"aria-label":`Connected instances`,children:f.map((e,t)=>(0,m.jsx)(g,{entry:e},`${e.host??`unknown`}-${e.instanceId??t}`))})]})]})}function g({entry:e}){let t=e.lastInputSeconds==null?`n/a`:`${e.lastInputSeconds}s ago`;return(0,m.jsxs)(`div`,{className:`ct-instances__item`,role:`listitem`,"data-testid":`instances-row`,children:[(0,m.jsxs)(`div`,{className:`ct-instances__main`,children:[(0,m.jsx)(`div`,{className:`ct-instances__host`,"data-testid":`instances-host`,children:e.host??`unknown host`}),(0,m.jsx)(`div`,{className:`ct-instances__sub`,children:f(e)}),(0,m.jsx)(`div`,{className:`ct-instances__chips`,children:p(e).map((e,t)=>(0,m.jsx)(`span`,{className:`ct-instances__chip`,children:e},`${e}-${t}`))})]}),(0,m.jsxs)(`div`,{className:`ct-instances__meta`,children:[(0,m.jsx)(`div`,{children:r(e.ts)}),(0,m.jsxs)(`div`,{className:`ct-instances__muted`,children:[`Last input `,t]}),(0,m.jsxs)(`div`,{className:`ct-instances__muted`,children:[`Reason `,e.reason??``]})]})]})}export{h as default};
1
+ import{_ as e,c as t,h as n,i as r,l as i,s as a}from"./format-CGs6a1G6.js";import{t as o}from"./Button-CGdLofSY.js";import{n as s,t as c}from"./use-gateway-query-D25QZANO.js";import{t as l}from"./Panel-9wOynsWc.js";var u=e(n(),1);function d(e,t){return t?.presence&&Array.isArray(t.presence)?t.presence:e}function f(e){return`${e.host??`unknown`} ${e.ip?`(${e.ip})`:``} ${e.mode??``} ${e.version??``}`.trim()}function p(e){let t=[e.mode??`unknown`],n=Array.isArray(e.roles)?e.roles.filter(Boolean):[];t.push(...n);let r=Array.isArray(e.scopes)?e.scopes.filter(Boolean):[];return r.length>0&&t.push(r.length>3?`${r.length} scopes`:`scopes: ${r.join(`, `)}`),e.platform&&t.push(e.platform),e.deviceFamily&&t.push(e.deviceFamily),e.modelIdentifier&&t.push(e.modelIdentifier),e.version&&t.push(e.version),t}var m=t();function h(){let e=s(`system-presence`,{},{refreshMs:c}),t=(0,u.useRef)(null);t.current=e.data??null;let[n,r]=(0,u.useState)(null);(0,u.useEffect)(()=>i.getState().subscribe(`presence`,e=>{r(n=>d(n??t.current??[],e))}),[]),(0,u.useEffect)(()=>{r(null)},[e.data]);let f=n??e.data??[];return(0,m.jsxs)(`div`,{className:`ct-page`,"data-testid":`instances-view`,children:[(0,m.jsxs)(`header`,{className:`ct-page__head`,children:[(0,m.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,m.jsx)(`h1`,{className:`ct-page__title`,children:`Instances`}),(0,m.jsx)(`p`,{className:`ct-page__sub`,children:`Presence beacons from the gateway and clients.`})]}),(0,m.jsx)(o,{onClick:()=>{r(null),e.reload()},disabled:e.loading,children:`Refresh`})]}),(0,m.jsxs)(l,{title:`Connected Instances`,sub:`Updated live from gateway presence events.`,children:[e.error?(0,m.jsx)(a,{tone:`error`,message:e.error}):null,e.loading&&!e.data?(0,m.jsx)(a,{tone:`loading`,message:`Loading…`}):null,!e.error&&f.length===0&&!(e.loading&&!e.data)?(0,m.jsx)(a,{message:`No instances reported yet.`}):null,(0,m.jsx)(`div`,{className:`ct-instances__list`,role:`list`,"aria-label":`Connected instances`,children:f.map((e,t)=>(0,m.jsx)(g,{entry:e},`${e.host??`unknown`}-${e.instanceId??t}`))})]})]})}function g({entry:e}){let t=e.lastInputSeconds==null?`n/a`:`${e.lastInputSeconds}s ago`;return(0,m.jsxs)(`div`,{className:`ct-instances__item`,role:`listitem`,"data-testid":`instances-row`,children:[(0,m.jsxs)(`div`,{className:`ct-instances__main`,children:[(0,m.jsx)(`div`,{className:`ct-instances__host`,"data-testid":`instances-host`,children:e.host??`unknown host`}),(0,m.jsx)(`div`,{className:`ct-instances__sub`,children:f(e)}),(0,m.jsx)(`div`,{className:`ct-instances__chips`,children:p(e).map((e,t)=>(0,m.jsx)(`span`,{className:`ct-instances__chip`,children:e},`${e}-${t}`))})]}),(0,m.jsxs)(`div`,{className:`ct-instances__meta`,children:[(0,m.jsx)(`div`,{children:r(e.ts)}),(0,m.jsxs)(`div`,{className:`ct-instances__muted`,children:[`Last input `,t]}),(0,m.jsxs)(`div`,{className:`ct-instances__muted`,children:[`Reason `,e.reason??``]})]})]})}export{h as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-dlOOV12I.js";import{n as o,t as s}from"./links-C1sAzVEH.js";import{t as c}from"./Button-DL76WqX4.js";import{n as l,t as u}from"./use-gateway-query-CF94JYnM.js";import{t as d}from"./Badge-4n2tRQ02.js";import{t as f}from"./Panel-CyfpswdJ.js";import{t as p}from"./EntityLink-AEBgCNQX.js";import{t as m}from"./Stat-BruDi6qc.js";import{t as h}from"./DataTable-lEkd1R85.js";import{t as g}from"./FilterPills-HxAXXDO8.js";import{t as _}from"./ConfirmDialog-DGHQXUr5.js";var v=e(n(),1);function y(e,t){return e.validFrom&&e.validFrom>t?!1:!e.invalidAt||e.invalidAt>t}function b(e){return e.map(e=>({...e.lesson,sessionId:e.sessionId??e.lesson.sessionId}))}var x=t(),S=[`procedure`,`failure`,`preference`,`correction`],C=`No rationale recorded (created before provenance tracking)`;function w({title:e,testId:t,children:n}){return(0,x.jsxs)(`section`,{className:`ct-learning__section`,"data-testid":t,children:[(0,x.jsx)(`h3`,{className:`ct-learning__section-title`,children:e}),n]})}function T({quote:e}){return(0,x.jsxs)(`blockquote`,{className:`ct-learning__quote`,children:[(0,x.jsx)(`span`,{className:`ct-learning__quote-role`,children:e.role}),e.text]})}function E({evidence:e}){let{sessionKey:t}=e,n=(e.quotes??[]).find(e=>e.entryId!==void 0)?.entryId;return(0,x.jsxs)(`div`,{className:`ct-learning__evidence`,children:[(0,x.jsxs)(`div`,{className:`ct-learning__evidence-meta`,children:[(0,x.jsx)(`span`,{children:e.observedAt}),(0,x.jsxs)(`span`,{children:[`Sender: `,e.senderDisplay??e.userId??`unknown sender`]}),e.agentId===void 0?(0,x.jsx)(`span`,{children:`Agent: —`}):(0,x.jsxs)(`span`,{children:[`Agent: `,(0,x.jsx)(p,{to:o.agent(e.agentId),children:e.agentId})]})]}),(e.quotes??[]).length>0?(e.quotes??[]).map((e,t)=>(0,x.jsx)(T,{quote:e},t)):(0,x.jsx)(`p`,{className:`ct-learning__evidence-summary`,children:e.summary}),t?(0,x.jsx)(`div`,{children:(0,x.jsx)(c,{size:`sm`,onClick:()=>s(o.session(t,n?{entry:n}:{})),children:`Open session`})}):null]})}function D({lessonId:e,agentId:t,onClose:n,onChanged:o}){let s=r(e=>e.request),u=l(`learning.inspectLesson`,{lessonId:e,...t?{agentId:t}:{}}),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[b,T]=(0,v.useState)(`correction`),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(!1),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),z=u.data?.lesson,B=async(e,t)=>{I(!0),R(null);try{t(await e())}catch(e){R(a(e))}finally{I(!1)}},V=e=>{g(e.text),T(e.kind),O(``),m(!0)},H=e=>{let n=D.trim();B(()=>s(`learning.reviseLesson`,{lessonId:e.id,...t?{agentId:t}:{},text:h,kind:b,...n?{note:n}:{}}),e=>{m(!1),o({id:e.lesson.id,agentId:t})})},U=e=>{B(()=>s(`learning.rateLesson`,{lessonId:e.id,...t?{agentId:t}:{},score:1}),()=>{u.reload(),o({id:e.id,agentId:t})})},W=e=>{let n=N.trim();M(!1),A(!1),B(()=>s(`learning.rateLesson`,{lessonId:e.id,...t?{agentId:t}:{},score:-1,...n?{note:n}:{}}),()=>{P(``),u.reload(),o({id:e.id,agentId:t})})},G=()=>{A(!1),M(!1),P(``)},K=new Date().toISOString(),q=z!==void 0&&y(z,K),J=z?.origin;return(0,x.jsx)(f,{title:`Lesson`,testId:`lesson-detail`,actions:(0,x.jsx)(c,{onClick:n,size:`sm`,children:`Close`}),children:u.error?(0,x.jsx)(i,{message:u.error,tone:`error`,testId:`lesson-detail-error`}):u.loading&&!u.data?(0,x.jsx)(i,{message:`Loading lesson…`,tone:`loading`}):z?(0,x.jsxs)(`div`,{className:`ct-learning__detail`,children:[L?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:L}):null,(0,x.jsxs)(w,{title:`Lesson`,testId:`lesson-lesson`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:z.text}),(0,x.jsxs)(`div`,{className:`ct-learning__badges`,children:[(0,x.jsx)(d,{tone:`accent`,children:z.kind}),(0,x.jsx)(d,{tone:q?`ok`:`warn`,children:q?`active`:`retired`}),z.rating===1?(0,x.jsx)(d,{tone:`ok`,children:`Endorsed`}):null,z.producer===`operator`?(0,x.jsx)(d,{tone:`accent`,children:`Edited by operator`}):null]}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[`Confidence `,Math.round(z.confidence*100),`%`]})]}),(0,x.jsx)(w,{title:`Why`,testId:`lesson-why`,children:(0,x.jsx)(`p`,{className:`ct-learning__rationale`,children:J?.rationale??C})}),(0,x.jsx)(w,{title:`Produced by`,testId:`lesson-produced-by`,children:(0,x.jsxs)(`dl`,{className:`ct-learning__kv`,children:[(0,x.jsx)(`dt`,{children:`Producer`}),(0,x.jsx)(`dd`,{children:z.producer??`—`}),(0,x.jsx)(`dt`,{children:`Model`}),(0,x.jsx)(`dd`,{children:J?.model??`—`}),(0,x.jsx)(`dt`,{children:`Prompt`}),(0,x.jsx)(`dd`,{children:J?.promptVersion??`—`}),(0,x.jsx)(`dt`,{children:`At`}),(0,x.jsx)(`dd`,{children:J?.at??`—`}),J?.actor?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`dt`,{children:`Actor`}),(0,x.jsx)(`dd`,{children:J.actor})]}):null]})}),(0,x.jsx)(w,{title:`Evidence`,testId:`lesson-evidence`,children:z.evidence.length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No evidence recorded.`}):z.evidence.map((e,t)=>(0,x.jsx)(E,{evidence:e},t))}),(0,x.jsx)(w,{title:`History`,testId:`lesson-history`,children:(u.data?.chain??[]).length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No history.`}):(u.data?.chain??[]).map(e=>(0,x.jsxs)(`div`,{className:`ct-learning__chain-row`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:e.text}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[e.validFrom,e.invalidAt?` → ${e.invalidAt}`:``,e.origin?.producer?` · ${e.origin.producer}`:``,e.origin?.actor?` · ${e.origin.actor}`:``]})]},e.id))}),(0,x.jsx)(w,{title:`Skill proposals`,testId:`lesson-proposals`,children:(u.data?.proposals??[]).length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No linked proposals.`}):(u.data?.proposals??[]).map(e=>(0,x.jsxs)(`div`,{className:`ct-learning__chain-row`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:e.title}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[e.id,` · `,e.status]})]},e.id))}),q?(0,x.jsx)(w,{title:`Actions`,testId:`lesson-actions`,children:p?(0,x.jsxs)(`div`,{className:`ct-learning__edit-form`,children:[(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Lesson text`}),(0,x.jsx)(`textarea`,{maxLength:400,rows:3,value:h,onChange:e=>g(e.target.value)})]}),(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Kind`}),(0,x.jsx)(`select`,{value:b,onChange:e=>T(e.target.value),children:S.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))})]}),(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Revision note`}),(0,x.jsx)(`input`,{value:D,onChange:e=>O(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{variant:`primary`,disabled:F||h.trim().length===0,onClick:()=>H(z),children:`Save`}),(0,x.jsx)(c,{disabled:F,onClick:()=>m(!1),children:`Cancel`})]})]}):k?(0,x.jsxs)(`div`,{className:`ct-learning__edit-form`,children:[(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Retirement note`}),(0,x.jsx)(`input`,{value:N,onChange:e=>P(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{variant:`danger`,disabled:F,onClick:()=>M(!0),children:`Retire lesson`}),(0,x.jsx)(c,{disabled:F,onClick:G,children:`Cancel`})]})]}):(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{size:`sm`,disabled:F,onClick:()=>V(z),children:`Edit`}),(0,x.jsx)(c,{size:`sm`,disabled:F,onClick:()=>U(z),children:`Endorse`}),(0,x.jsx)(c,{size:`sm`,variant:`danger`,disabled:F,onClick:()=>A(!0),children:`Retire`})]})}):(0,x.jsx)(w,{title:`Retired`,testId:`lesson-retired`,children:z.invalidationReason?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:z.invalidationReason}):null}),(0,x.jsx)(_,{open:j,title:`Retire lesson`,body:`Retire this lesson? It will be marked inactive and excluded from the active list.`,confirmLabel:`Retire`,danger:!0,busy:F,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>z&&W(z),onCancel:()=>M(!1)})]}):null})}var O=300;function k(e,t){return[{key:`kind`,label:e.kind},{key:`recordKind`,label:e.recordKind??`lesson`},{key:`durability`,label:e.durability??`decaying`},{key:`validity`,label:y(e,t)?`active`:`inactive`,tone:y(e,t)?`ok`:`warn`},...e.producer===`operator`?[{key:`producer`,label:`Edited by operator`,tone:`accent`}]:[],...e.rating===1?[{key:`rating`,label:`Endorsed`,tone:`ok`}]:[]]}function A(){let e=r(e=>e.request),t=l(`learning.listLessons`,{},{refreshMs:u}),[n,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,g]=(0,v.useState)(null),_=(0,v.useRef)(0),y=(0,v.useCallback)(t=>{let n=_.current+1;return _.current=n,e(`learning.searchLessons`,{query:t,k:20}).then(e=>{_.current===n&&(c(b(e.hits??[])),p(null))}).catch(e=>{_.current===n&&p(a(e))})},[e]);(0,v.useEffect)(()=>{let e=n.trim();if(!e){_.current+=1,c(null),p(null);return}let t=window.setTimeout(()=>void y(e),O);return()=>window.clearTimeout(t)},[n,y]);let S=s??t.data?.lessons??[],C=new Date().toISOString();return(0,x.jsxs)(`div`,{className:`ct-learning__tab`,"data-testid":`lessons-view`,children:[(0,x.jsx)(`input`,{type:`search`,className:`ct-learning__search`,"aria-label":`Search lessons`,placeholder:`Search lessons`,value:n,onChange:e=>o(e.target.value)}),f?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:f}):null,t.error?(0,x.jsx)(i,{message:t.error,tone:`error`,testId:`lessons-error`}):t.loading&&!t.data?(0,x.jsx)(i,{message:`Loading lessons…`,tone:`loading`,testId:`lessons-loading`}):null,t.data||!t.loading&&!t.error?(0,x.jsx)(h,{columns:[{key:`badges`,label:`Badges`,render:e=>(0,x.jsx)(`span`,{className:`ct-learning__badges`,children:k(e,C).map(e=>(0,x.jsx)(d,{tone:e.tone,children:e.label},e.key))})},{key:`text`,label:`Lesson`,render:e=>e.text},{key:`scope`,label:`Scope`,render:e=>e.scopeLabel?.workspaceLabel??`—`},{key:`confidence`,label:`Confidence`,render:e=>e.confidence===void 0?`—`:`${Math.round(e.confidence*100)}%`},{key:`occurrences`,label:`Seen`,render:e=>e.occurrences===void 0?`—`:`${e.occurrences}×`},{key:`sessions`,label:`Sessions`,render:e=>e.distinctSessions===void 0?`—`:`${e.distinctSessions} sessions`}],rows:S,rowKey:e=>`${e.scopeLabel?.agentId??``}:${e.id}`,label:`Learning lessons`,empty:(0,x.jsx)(i,{message:`No lessons.`,testId:`lessons-empty`}),onRowClick:e=>g({id:e.id,agentId:e.scopeLabel?.agentId}),selectedKey:m?`${m.agentId??``}:${m.id}`:null}):null,m?(0,x.jsx)(D,{lessonId:m.id,agentId:m.agentId,onClose:()=>g(null),onChanged:e=>{g(e),t.reload();let r=n.trim();r&&y(r)}},`${m.agentId??``}:${m.id}`):null]})}var j=[{value:`all`,label:`All`},{value:`pending`,label:`Pending`},{value:`applied`,label:`Applied`},{value:`rejected`,label:`Rejected`},{value:`quarantined`,label:`Quarantined`}],M={pending:`accent`,applied:`ok`,rejected:`danger`,quarantined:`warn`};function N({proposalId:e,onClose:t}){let n=l(`learning.inspectProposal`,{proposalId:e});return(0,x.jsx)(f,{title:`Proposal`,testId:`proposal-detail`,actions:(0,x.jsx)(c,{onClick:t,size:`sm`,children:`Close`}),children:n.error?(0,x.jsx)(i,{message:n.error,tone:`error`,testId:`proposal-detail-error`}):n.loading&&!n.data?(0,x.jsx)(i,{message:`Loading proposal…`,tone:`loading`}):n.data?(0,x.jsx)(`pre`,{className:`ct-learning__body`,"data-testid":`proposal-body`,children:n.data.body}):null})}function P({reloadOverview:e}){let t=r(e=>e.request),[n,o]=(0,v.useState)(`all`),s=l(`learning.listProposals`,n===`all`?{}:{status:n},{refreshMs:u}),[f,p]=(0,v.useState)([]),[m,y]=(0,v.useState)(!1),[b,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),k=s.data?.proposals??[],A=async(t,n)=>{y(!0),S(null);try{await t(),s.reload(),e(),n?.()}catch(e){S(a(e))}finally{y(!1)}},P=(e,n)=>(w(null),A(()=>t(`learning.decideProposal`,{proposalId:e,action:n}))),F=e=>{let n=f;return E(null),A(()=>t(`learning.decideProposals`,{ids:n,action:e}),()=>p([]))},I=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},L=f.length,R=k.find(e=>e.id===C)??null;return(0,x.jsxs)(`div`,{className:`ct-learning__tab`,"data-testid":`proposals-view`,children:[(0,x.jsxs)(`div`,{className:`ct-learning__toolbar`,children:[(0,x.jsx)(g,{value:n,options:j,onChange:e=>{o(e),p([])},label:`Filter proposals by status`}),L>0?(0,x.jsxs)(`div`,{className:`ct-learning__bulk`,"data-testid":`bulk-actions`,children:[(0,x.jsxs)(`span`,{className:`ct-learning__bulk-count`,children:[L,` selected`]}),(0,x.jsxs)(c,{disabled:m,onClick:()=>E(`apply`),children:[`Apply `,L,` selected`]}),(0,x.jsxs)(c,{disabled:m,onClick:()=>E(`reject`),children:[`Reject `,L,` selected`]})]}):null]}),b?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:b}):null,s.error?(0,x.jsx)(i,{message:s.error,tone:`error`,testId:`proposals-error`}):s.loading&&!s.data?(0,x.jsx)(i,{message:`Loading proposals…`,tone:`loading`,testId:`proposals-loading`}):null,s.data||!s.loading&&!s.error?(0,x.jsx)(h,{columns:[{key:`select`,label:``,render:e=>(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,checked:f.includes(e.id),disabled:m,onClick:e=>e.stopPropagation(),onChange:()=>I(e.id)})},{key:`status`,label:`Status`,render:e=>(0,x.jsx)(d,{tone:M[e.status],children:e.status})},{key:`title`,label:`Title`,render:e=>e.title},{key:`scope`,label:`Scope`,render:e=>e.scopeLabel?.workspaceLabel??`—`},{key:`findings`,label:`Findings`,render:e=>e.findingCount===void 0?`—`:`${e.findingCount} findings`},{key:`actions`,label:`Actions`,render:e=>(0,x.jsxs)(`div`,{className:`ct-learning__row-actions`,children:[(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Apply ${e.title}`,onClick:()=>w(e.id),children:`Apply`}),(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Reject ${e.title}`,onClick:()=>void P(e.id,`reject`),children:`Reject`}),(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Quarantine ${e.title}`,onClick:()=>void P(e.id,`quarantine`),children:`Quarantine`})]})}],rows:k,rowKey:e=>e.id,label:`Learning proposals`,empty:(0,x.jsx)(i,{message:`No proposals.`,testId:`proposals-empty`}),onRowClick:e=>O(e.id),selectedKey:D}):null,D?(0,x.jsx)(N,{proposalId:D,onClose:()=>O(null)}):null,(0,x.jsx)(_,{open:R!==null,title:`Apply proposal`,body:R?`Apply "${R.title}"?`:``,confirmLabel:`Apply proposal`,busy:m,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>R&&P(R.id,`apply`),onCancel:()=>w(null)}),(0,x.jsx)(_,{open:T!==null,title:T===`reject`?`Reject proposals`:`Apply proposals`,body:`${T===`reject`?`Reject`:`Apply`} ${L} selected proposals?`,confirmLabel:T===`reject`?`Reject proposals`:`Apply proposals`,busy:m,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>T&&F(T),onCancel:()=>E(null)})]})}var F=[{value:`proposals`,label:`Proposals`},{value:`lessons`,label:`Lessons`}];function I(){let e=l(`learning.overview`,{},{refreshMs:u}),[t,n]=(0,v.useState)(`proposals`),r=e.data?.proposals;return(0,x.jsxs)(`div`,{className:`ct-page`,"data-testid":`learning-view`,children:[(0,x.jsx)(`header`,{className:`ct-page__head`,children:(0,x.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,x.jsx)(`h1`,{className:`ct-page__title`,children:`Learning`}),(0,x.jsx)(`p`,{className:`ct-page__sub`,children:`Lesson proposals and the distilled lesson index.`})]})}),e.error?(0,x.jsx)(i,{message:e.error,tone:`error`,testId:`learning-overview-error`}):e.loading&&!e.data?(0,x.jsx)(i,{message:`Loading learning overview…`,tone:`loading`}):null,e.data?(0,x.jsxs)(`div`,{className:`ct-learning__stats`,"data-testid":`learning-overview`,children:[(0,x.jsx)(m,{label:`Pending`,value:r?.pending??0}),(0,x.jsx)(m,{label:`Applied`,value:r?.applied??0}),(0,x.jsx)(m,{label:`Rejected`,value:r?.rejected??0}),(0,x.jsx)(m,{label:`Quarantined`,value:r?.quarantined??0}),(0,x.jsx)(m,{label:`Lessons`,value:e.data.lessons}),(0,x.jsx)(m,{label:`Scopes`,value:e.data.scopes}),e.data.backend?(0,x.jsx)(d,{tone:`neutral`,children:e.data.backend}):null]}):null,(0,x.jsx)(g,{value:t,options:F,onChange:n,label:`Learning sections`}),t===`proposals`?(0,x.jsx)(P,{reloadOverview:e.reload}):(0,x.jsx)(A,{})]})}export{I as default};
1
+ import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-CGs6a1G6.js";import{n as o,t as s}from"./links-DlVrQOFC.js";import{t as c}from"./Button-CGdLofSY.js";import{n as l,t as u}from"./use-gateway-query-D25QZANO.js";import{t as d}from"./Badge-CB5TWfdz.js";import{t as f}from"./Panel-9wOynsWc.js";import{t as p}from"./EntityLink-BO2oG3y8.js";import{t as m}from"./Stat-BZwg1PGE.js";import{t as h}from"./DataTable-CSi930kO.js";import{t as g}from"./FilterPills-9pNaAyrL.js";import{t as _}from"./ConfirmDialog-B7aotBjN.js";var v=e(n(),1);function y(e,t){return e.validFrom&&e.validFrom>t?!1:!e.invalidAt||e.invalidAt>t}function b(e){return e.map(e=>({...e.lesson,sessionId:e.sessionId??e.lesson.sessionId}))}var x=t(),S=[`procedure`,`failure`,`preference`,`correction`],C=`No rationale recorded (created before provenance tracking)`;function w({title:e,testId:t,children:n}){return(0,x.jsxs)(`section`,{className:`ct-learning__section`,"data-testid":t,children:[(0,x.jsx)(`h3`,{className:`ct-learning__section-title`,children:e}),n]})}function T({quote:e}){return(0,x.jsxs)(`blockquote`,{className:`ct-learning__quote`,children:[(0,x.jsx)(`span`,{className:`ct-learning__quote-role`,children:e.role}),e.text]})}function E({evidence:e}){let{sessionKey:t}=e,n=(e.quotes??[]).find(e=>e.entryId!==void 0)?.entryId;return(0,x.jsxs)(`div`,{className:`ct-learning__evidence`,children:[(0,x.jsxs)(`div`,{className:`ct-learning__evidence-meta`,children:[(0,x.jsx)(`span`,{children:e.observedAt}),(0,x.jsxs)(`span`,{children:[`Sender: `,e.senderDisplay??e.userId??`unknown sender`]}),e.agentId===void 0?(0,x.jsx)(`span`,{children:`Agent: —`}):(0,x.jsxs)(`span`,{children:[`Agent: `,(0,x.jsx)(p,{to:o.agent(e.agentId),children:e.agentId})]})]}),(e.quotes??[]).length>0?(e.quotes??[]).map((e,t)=>(0,x.jsx)(T,{quote:e},t)):(0,x.jsx)(`p`,{className:`ct-learning__evidence-summary`,children:e.summary}),t?(0,x.jsx)(`div`,{children:(0,x.jsx)(c,{size:`sm`,onClick:()=>s(o.session(t,n?{entry:n}:{})),children:`Open session`})}):null]})}function D({lessonId:e,agentId:t,onClose:n,onChanged:o}){let s=r(e=>e.request),u=l(`learning.inspectLesson`,{lessonId:e,...t?{agentId:t}:{}}),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[b,T]=(0,v.useState)(`correction`),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(!1),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),z=u.data?.lesson,B=async(e,t)=>{I(!0),R(null);try{t(await e())}catch(e){R(a(e))}finally{I(!1)}},V=e=>{g(e.text),T(e.kind),O(``),m(!0)},H=e=>{let n=D.trim();B(()=>s(`learning.reviseLesson`,{lessonId:e.id,...t?{agentId:t}:{},text:h,kind:b,...n?{note:n}:{}}),e=>{m(!1),o({id:e.lesson.id,agentId:t})})},U=e=>{B(()=>s(`learning.rateLesson`,{lessonId:e.id,...t?{agentId:t}:{},score:1}),()=>{u.reload(),o({id:e.id,agentId:t})})},W=e=>{let n=N.trim();M(!1),A(!1),B(()=>s(`learning.rateLesson`,{lessonId:e.id,...t?{agentId:t}:{},score:-1,...n?{note:n}:{}}),()=>{P(``),u.reload(),o({id:e.id,agentId:t})})},G=()=>{A(!1),M(!1),P(``)},K=new Date().toISOString(),q=z!==void 0&&y(z,K),J=z?.origin;return(0,x.jsx)(f,{title:`Lesson`,testId:`lesson-detail`,actions:(0,x.jsx)(c,{onClick:n,size:`sm`,children:`Close`}),children:u.error?(0,x.jsx)(i,{message:u.error,tone:`error`,testId:`lesson-detail-error`}):u.loading&&!u.data?(0,x.jsx)(i,{message:`Loading lesson…`,tone:`loading`}):z?(0,x.jsxs)(`div`,{className:`ct-learning__detail`,children:[L?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:L}):null,(0,x.jsxs)(w,{title:`Lesson`,testId:`lesson-lesson`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:z.text}),(0,x.jsxs)(`div`,{className:`ct-learning__badges`,children:[(0,x.jsx)(d,{tone:`accent`,children:z.kind}),(0,x.jsx)(d,{tone:q?`ok`:`warn`,children:q?`active`:`retired`}),z.rating===1?(0,x.jsx)(d,{tone:`ok`,children:`Endorsed`}):null,z.producer===`operator`?(0,x.jsx)(d,{tone:`accent`,children:`Edited by operator`}):null]}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[`Confidence `,Math.round(z.confidence*100),`%`]})]}),(0,x.jsx)(w,{title:`Why`,testId:`lesson-why`,children:(0,x.jsx)(`p`,{className:`ct-learning__rationale`,children:J?.rationale??C})}),(0,x.jsx)(w,{title:`Produced by`,testId:`lesson-produced-by`,children:(0,x.jsxs)(`dl`,{className:`ct-learning__kv`,children:[(0,x.jsx)(`dt`,{children:`Producer`}),(0,x.jsx)(`dd`,{children:z.producer??`—`}),(0,x.jsx)(`dt`,{children:`Model`}),(0,x.jsx)(`dd`,{children:J?.model??`—`}),(0,x.jsx)(`dt`,{children:`Prompt`}),(0,x.jsx)(`dd`,{children:J?.promptVersion??`—`}),(0,x.jsx)(`dt`,{children:`At`}),(0,x.jsx)(`dd`,{children:J?.at??`—`}),J?.actor?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`dt`,{children:`Actor`}),(0,x.jsx)(`dd`,{children:J.actor})]}):null]})}),(0,x.jsx)(w,{title:`Evidence`,testId:`lesson-evidence`,children:z.evidence.length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No evidence recorded.`}):z.evidence.map((e,t)=>(0,x.jsx)(E,{evidence:e},t))}),(0,x.jsx)(w,{title:`History`,testId:`lesson-history`,children:(u.data?.chain??[]).length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No history.`}):(u.data?.chain??[]).map(e=>(0,x.jsxs)(`div`,{className:`ct-learning__chain-row`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:e.text}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[e.validFrom,e.invalidAt?` → ${e.invalidAt}`:``,e.origin?.producer?` · ${e.origin.producer}`:``,e.origin?.actor?` · ${e.origin.actor}`:``]})]},e.id))}),(0,x.jsx)(w,{title:`Skill proposals`,testId:`lesson-proposals`,children:(u.data?.proposals??[]).length===0?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:`No linked proposals.`}):(u.data?.proposals??[]).map(e=>(0,x.jsxs)(`div`,{className:`ct-learning__chain-row`,children:[(0,x.jsx)(`p`,{className:`ct-learning__lesson-text`,children:e.title}),(0,x.jsxs)(`p`,{className:`ct-learning__meta-line`,children:[e.id,` · `,e.status]})]},e.id))}),q?(0,x.jsx)(w,{title:`Actions`,testId:`lesson-actions`,children:p?(0,x.jsxs)(`div`,{className:`ct-learning__edit-form`,children:[(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Lesson text`}),(0,x.jsx)(`textarea`,{maxLength:400,rows:3,value:h,onChange:e=>g(e.target.value)})]}),(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Kind`}),(0,x.jsx)(`select`,{value:b,onChange:e=>T(e.target.value),children:S.map(e=>(0,x.jsx)(`option`,{value:e,children:e},e))})]}),(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Revision note`}),(0,x.jsx)(`input`,{value:D,onChange:e=>O(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{variant:`primary`,disabled:F||h.trim().length===0,onClick:()=>H(z),children:`Save`}),(0,x.jsx)(c,{disabled:F,onClick:()=>m(!1),children:`Cancel`})]})]}):k?(0,x.jsxs)(`div`,{className:`ct-learning__edit-form`,children:[(0,x.jsxs)(`label`,{className:`ct-learning__field`,children:[(0,x.jsx)(`span`,{children:`Retirement note`}),(0,x.jsx)(`input`,{value:N,onChange:e=>P(e.target.value)})]}),(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{variant:`danger`,disabled:F,onClick:()=>M(!0),children:`Retire lesson`}),(0,x.jsx)(c,{disabled:F,onClick:G,children:`Cancel`})]})]}):(0,x.jsxs)(`div`,{className:`ct-learning__actions`,children:[(0,x.jsx)(c,{size:`sm`,disabled:F,onClick:()=>V(z),children:`Edit`}),(0,x.jsx)(c,{size:`sm`,disabled:F,onClick:()=>U(z),children:`Endorse`}),(0,x.jsx)(c,{size:`sm`,variant:`danger`,disabled:F,onClick:()=>A(!0),children:`Retire`})]})}):(0,x.jsx)(w,{title:`Retired`,testId:`lesson-retired`,children:z.invalidationReason?(0,x.jsx)(`p`,{className:`ct-learning__meta-line`,children:z.invalidationReason}):null}),(0,x.jsx)(_,{open:j,title:`Retire lesson`,body:`Retire this lesson? It will be marked inactive and excluded from the active list.`,confirmLabel:`Retire`,danger:!0,busy:F,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>z&&W(z),onCancel:()=>M(!1)})]}):null})}var O=300;function k(e,t){return[{key:`kind`,label:e.kind},{key:`recordKind`,label:e.recordKind??`lesson`},{key:`durability`,label:e.durability??`decaying`},{key:`validity`,label:y(e,t)?`active`:`inactive`,tone:y(e,t)?`ok`:`warn`},...e.producer===`operator`?[{key:`producer`,label:`Edited by operator`,tone:`accent`}]:[],...e.rating===1?[{key:`rating`,label:`Endorsed`,tone:`ok`}]:[]]}function A(){let e=r(e=>e.request),t=l(`learning.listLessons`,{},{refreshMs:u}),[n,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,g]=(0,v.useState)(null),_=(0,v.useRef)(0),y=(0,v.useCallback)(t=>{let n=_.current+1;return _.current=n,e(`learning.searchLessons`,{query:t,k:20}).then(e=>{_.current===n&&(c(b(e.hits??[])),p(null))}).catch(e=>{_.current===n&&p(a(e))})},[e]);(0,v.useEffect)(()=>{let e=n.trim();if(!e){_.current+=1,c(null),p(null);return}let t=window.setTimeout(()=>void y(e),O);return()=>window.clearTimeout(t)},[n,y]);let S=s??t.data?.lessons??[],C=new Date().toISOString();return(0,x.jsxs)(`div`,{className:`ct-learning__tab`,"data-testid":`lessons-view`,children:[(0,x.jsx)(`input`,{type:`search`,className:`ct-learning__search`,"aria-label":`Search lessons`,placeholder:`Search lessons`,value:n,onChange:e=>o(e.target.value)}),f?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:f}):null,t.error?(0,x.jsx)(i,{message:t.error,tone:`error`,testId:`lessons-error`}):t.loading&&!t.data?(0,x.jsx)(i,{message:`Loading lessons…`,tone:`loading`,testId:`lessons-loading`}):null,t.data||!t.loading&&!t.error?(0,x.jsx)(h,{columns:[{key:`badges`,label:`Badges`,render:e=>(0,x.jsx)(`span`,{className:`ct-learning__badges`,children:k(e,C).map(e=>(0,x.jsx)(d,{tone:e.tone,children:e.label},e.key))})},{key:`text`,label:`Lesson`,render:e=>e.text},{key:`scope`,label:`Scope`,render:e=>e.scopeLabel?.workspaceLabel??`—`},{key:`confidence`,label:`Confidence`,render:e=>e.confidence===void 0?`—`:`${Math.round(e.confidence*100)}%`},{key:`occurrences`,label:`Seen`,render:e=>e.occurrences===void 0?`—`:`${e.occurrences}×`},{key:`sessions`,label:`Sessions`,render:e=>e.distinctSessions===void 0?`—`:`${e.distinctSessions} sessions`}],rows:S,rowKey:e=>`${e.scopeLabel?.agentId??``}:${e.id}`,label:`Learning lessons`,empty:(0,x.jsx)(i,{message:`No lessons.`,testId:`lessons-empty`}),onRowClick:e=>g({id:e.id,agentId:e.scopeLabel?.agentId}),selectedKey:m?`${m.agentId??``}:${m.id}`:null}):null,m?(0,x.jsx)(D,{lessonId:m.id,agentId:m.agentId,onClose:()=>g(null),onChanged:e=>{g(e),t.reload();let r=n.trim();r&&y(r)}},`${m.agentId??``}:${m.id}`):null]})}var j=[{value:`all`,label:`All`},{value:`pending`,label:`Pending`},{value:`applied`,label:`Applied`},{value:`rejected`,label:`Rejected`},{value:`quarantined`,label:`Quarantined`}],M={pending:`accent`,applied:`ok`,rejected:`danger`,quarantined:`warn`};function N({proposalId:e,onClose:t}){let n=l(`learning.inspectProposal`,{proposalId:e});return(0,x.jsx)(f,{title:`Proposal`,testId:`proposal-detail`,actions:(0,x.jsx)(c,{onClick:t,size:`sm`,children:`Close`}),children:n.error?(0,x.jsx)(i,{message:n.error,tone:`error`,testId:`proposal-detail-error`}):n.loading&&!n.data?(0,x.jsx)(i,{message:`Loading proposal…`,tone:`loading`}):n.data?(0,x.jsx)(`pre`,{className:`ct-learning__body`,"data-testid":`proposal-body`,children:n.data.body}):null})}function P({reloadOverview:e}){let t=r(e=>e.request),[n,o]=(0,v.useState)(`all`),s=l(`learning.listProposals`,n===`all`?{}:{status:n},{refreshMs:u}),[f,p]=(0,v.useState)([]),[m,y]=(0,v.useState)(!1),[b,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(null),k=s.data?.proposals??[],A=async(t,n)=>{y(!0),S(null);try{await t(),s.reload(),e(),n?.()}catch(e){S(a(e))}finally{y(!1)}},P=(e,n)=>(w(null),A(()=>t(`learning.decideProposal`,{proposalId:e,action:n}))),F=e=>{let n=f;return E(null),A(()=>t(`learning.decideProposals`,{ids:n,action:e}),()=>p([]))},I=e=>{p(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},L=f.length,R=k.find(e=>e.id===C)??null;return(0,x.jsxs)(`div`,{className:`ct-learning__tab`,"data-testid":`proposals-view`,children:[(0,x.jsxs)(`div`,{className:`ct-learning__toolbar`,children:[(0,x.jsx)(g,{value:n,options:j,onChange:e=>{o(e),p([])},label:`Filter proposals by status`}),L>0?(0,x.jsxs)(`div`,{className:`ct-learning__bulk`,"data-testid":`bulk-actions`,children:[(0,x.jsxs)(`span`,{className:`ct-learning__bulk-count`,children:[L,` selected`]}),(0,x.jsxs)(c,{disabled:m,onClick:()=>E(`apply`),children:[`Apply `,L,` selected`]}),(0,x.jsxs)(c,{disabled:m,onClick:()=>E(`reject`),children:[`Reject `,L,` selected`]})]}):null]}),b?(0,x.jsx)(`p`,{className:`ct-learning__callout ct-learning__callout--error`,role:`alert`,children:b}):null,s.error?(0,x.jsx)(i,{message:s.error,tone:`error`,testId:`proposals-error`}):s.loading&&!s.data?(0,x.jsx)(i,{message:`Loading proposals…`,tone:`loading`,testId:`proposals-loading`}):null,s.data||!s.loading&&!s.error?(0,x.jsx)(h,{columns:[{key:`select`,label:``,render:e=>(0,x.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${e.title}`,checked:f.includes(e.id),disabled:m,onClick:e=>e.stopPropagation(),onChange:()=>I(e.id)})},{key:`status`,label:`Status`,render:e=>(0,x.jsx)(d,{tone:M[e.status],children:e.status})},{key:`title`,label:`Title`,render:e=>e.title},{key:`scope`,label:`Scope`,render:e=>e.scopeLabel?.workspaceLabel??`—`},{key:`findings`,label:`Findings`,render:e=>e.findingCount===void 0?`—`:`${e.findingCount} findings`},{key:`actions`,label:`Actions`,render:e=>(0,x.jsxs)(`div`,{className:`ct-learning__row-actions`,children:[(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Apply ${e.title}`,onClick:()=>w(e.id),children:`Apply`}),(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Reject ${e.title}`,onClick:()=>void P(e.id,`reject`),children:`Reject`}),(0,x.jsx)(c,{size:`sm`,disabled:m,"aria-label":`Quarantine ${e.title}`,onClick:()=>void P(e.id,`quarantine`),children:`Quarantine`})]})}],rows:k,rowKey:e=>e.id,label:`Learning proposals`,empty:(0,x.jsx)(i,{message:`No proposals.`,testId:`proposals-empty`}),onRowClick:e=>O(e.id),selectedKey:D}):null,D?(0,x.jsx)(N,{proposalId:D,onClose:()=>O(null)}):null,(0,x.jsx)(_,{open:R!==null,title:`Apply proposal`,body:R?`Apply "${R.title}"?`:``,confirmLabel:`Apply proposal`,busy:m,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>R&&P(R.id,`apply`),onCancel:()=>w(null)}),(0,x.jsx)(_,{open:T!==null,title:T===`reject`?`Reject proposals`:`Apply proposals`,body:`${T===`reject`?`Reject`:`Apply`} ${L} selected proposals?`,confirmLabel:T===`reject`?`Reject proposals`:`Apply proposals`,busy:m,bodyClassName:`ct-learning__confirm-body`,onConfirm:()=>T&&F(T),onCancel:()=>E(null)})]})}var F=[{value:`proposals`,label:`Proposals`},{value:`lessons`,label:`Lessons`}];function I(){let e=l(`learning.overview`,{},{refreshMs:u}),[t,n]=(0,v.useState)(`proposals`),r=e.data?.proposals;return(0,x.jsxs)(`div`,{className:`ct-page`,"data-testid":`learning-view`,children:[(0,x.jsx)(`header`,{className:`ct-page__head`,children:(0,x.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,x.jsx)(`h1`,{className:`ct-page__title`,children:`Learning`}),(0,x.jsx)(`p`,{className:`ct-page__sub`,children:`Lesson proposals and the distilled lesson index.`})]})}),e.error?(0,x.jsx)(i,{message:e.error,tone:`error`,testId:`learning-overview-error`}):e.loading&&!e.data?(0,x.jsx)(i,{message:`Loading learning overview…`,tone:`loading`}):null,e.data?(0,x.jsxs)(`div`,{className:`ct-learning__stats`,"data-testid":`learning-overview`,children:[(0,x.jsx)(m,{label:`Pending`,value:r?.pending??0}),(0,x.jsx)(m,{label:`Applied`,value:r?.applied??0}),(0,x.jsx)(m,{label:`Rejected`,value:r?.rejected??0}),(0,x.jsx)(m,{label:`Quarantined`,value:r?.quarantined??0}),(0,x.jsx)(m,{label:`Lessons`,value:e.data.lessons}),(0,x.jsx)(m,{label:`Scopes`,value:e.data.scopes}),e.data.backend?(0,x.jsx)(d,{tone:`neutral`,children:e.data.backend}):null]}):null,(0,x.jsx)(g,{value:t,options:F,onChange:n,label:`Learning sections`}),t===`proposals`?(0,x.jsx)(P,{reloadOverview:e.reload}):(0,x.jsx)(A,{})]})}export{I as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-dlOOV12I.js";import{t as o}from"./Button-DL76WqX4.js";import{i as s,t as c}from"./index-OijNknZs.js";import{t as l}from"./Panel-CyfpswdJ.js";import{t as u}from"./FilterPills-HxAXXDO8.js";var d=e(n(),1),f={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function p(e){if(typeof e!=`string`)return null;let t=e.toLowerCase();return Object.hasOwn(f,t)?t:null}function m(e){let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return null;try{let e=JSON.parse(t);return e&&typeof e==`object`?e:null}catch{return null}}var h=new RegExp(String.raw`\u001b\[[0-9;]*m`,`g`);function g(e,t){let n={id:t,raw:e,time:null,level:null,subsystem:null,message:e},r=m(e);if(!r)return n;let i=typeof r._meta==`object`&&r._meta!==null?r._meta:null,a=typeof r.time==`string`?r.time:typeof i?.date==`string`?i.date:null,o=typeof r[0]==`string`?r[0]:typeof i?.name==`string`?i.name:null,s=o?m(o):null,c=null;s&&(typeof s.subsystem==`string`?c=s.subsystem:typeof s.module==`string`&&(c=s.module)),!c&&o&&o.length<120&&(c=o);let l=null;return typeof r[1]==`string`?l=r[1]:!s&&typeof r[0]==`string`?l=r[0]:typeof r.message==`string`&&(l=r.message),{id:t,raw:e,time:a,level:p(i?.logLevelName??i?.level),subsystem:c,message:(l??e).replaceAll(h,``)}}var _=t(),v=500,y=25e4,b=2e3,x=2e3,S={all:`All levels`,debug:`Debug`,info:`Info`,warn:`Warn`,error:`Error`};function C(e,t,n){return t!==`all`&&(e.level===null||f[e.level]<f[t])?!1:n.length===0||e.raw.toLowerCase().includes(n)}function w(){let e=r(e=>e.request),t=r(e=>e.status),[n,f]=(0,d.useState)([]),[p,m]=(0,d.useState)(null),[h,b]=(0,d.useState)(!0),[w,T]=(0,d.useState)(`all`),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(null),k=(0,d.useRef)(0),A=(0,d.useRef)(!1),j=(0,d.useRef)(null),M=(0,d.useCallback)(async()=>{if(!A.current){A.current=!0;try{let t=await e(`logs.tail`,{...O.current===null?{}:{cursor:O.current},limit:v,maxBytes:y}),n=(Array.isArray(t.lines)?t.lines.filter(e=>typeof e==`string`):[]).map(e=>g(e,k.current++)),r=t.reset===!0||O.current===null;f(e=>(r?n:[...e,...n]).slice(-2e3)),typeof t.cursor==`number`&&(O.current=t.cursor),m(null)}catch(e){m(a(e))}finally{A.current=!1}}},[e]),N=s();(0,d.useEffect)(()=>{if(!h||t!==`connected`||!N)return;M();let e=window.setInterval(()=>void M(),x);return()=>window.clearInterval(e)},[h,t,N,M]);let P=E.trim().toLowerCase(),F=n.filter(e=>C(e,w,P));return(0,d.useLayoutEffect)(()=>{let e=j.current;h&&e&&(e.scrollTop=e.scrollHeight)},[h,F.at(-1)?.id??-1]),(0,_.jsxs)(`div`,{className:`ct-page ct-page--fill`,"data-testid":`logs-view`,children:[(0,_.jsxs)(`header`,{className:`ct-page__head`,children:[(0,_.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,_.jsx)(`h1`,{className:`ct-page__title`,children:`Logs`}),(0,_.jsx)(`p`,{className:`ct-page__sub`,children:`The gateway's file log, newest at the bottom.`})]}),(0,_.jsxs)(o,{variant:h?`secondary`:`primary`,onClick:()=>b(e=>!e),"aria-pressed":!h,children:[(0,_.jsx)(c,{name:h?`pause`:`play`,size:15}),h?`Pause`:`Follow`]})]}),(0,_.jsxs)(`div`,{className:`ct-toolbar`,children:[(0,_.jsx)(u,{label:`Minimum level`,value:w,onChange:T,options:[`all`,`debug`,`info`,`warn`,`error`].map(e=>({value:e,label:S[e]}))}),(0,_.jsx)(`div`,{className:`ct-toolbar__grow`}),(0,_.jsxs)(`label`,{className:`ct-search`,children:[(0,_.jsx)(c,{name:`search`,size:15}),(0,_.jsx)(`input`,{className:`ct-search__input`,type:`search`,placeholder:`Filter lines`,"aria-label":`Filter log lines`,value:E,onChange:e=>D(e.target.value)})]})]}),(0,_.jsxs)(l,{title:`Gateway log`,sub:`${F.length} of ${n.length} lines${h?` · following`:` · paused`}`,className:`ct-logs`,children:[p?(0,_.jsx)(i,{tone:`error`,message:`Logs could not be read.`,hint:p}):null,(0,_.jsx)(`div`,{className:`ct-logs__scroll`,ref:j,"data-testid":`log-lines`,children:F.length===0?(0,_.jsx)(i,{message:n.length===0?`No log lines yet.`:`No lines match.`}):F.map(e=>(0,_.jsxs)(`div`,{className:`ct-log-line ct-log-line--${e.level??`plain`}`,"data-level":e.level??void 0,children:[(0,_.jsx)(`span`,{className:`ct-log-line__time`,children:e.time?new Date(e.time).toLocaleTimeString(`en-AU`):``}),(0,_.jsx)(`span`,{className:`ct-log-line__level`,children:e.level??``}),(0,_.jsx)(`span`,{className:`ct-log-line__subsystem`,children:e.subsystem??``}),(0,_.jsx)(`span`,{className:`ct-log-line__message`,children:e.message})]},e.id))})]})]})}export{b as LOG_BUFFER_LIMIT,x as LOG_POLL_MS,w as default};
1
+ import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-CGs6a1G6.js";import{t as o}from"./Button-CGdLofSY.js";import{i as s,t as c}from"./index-BvXiY83i.js";import{t as l}from"./Panel-9wOynsWc.js";import{t as u}from"./FilterPills-9pNaAyrL.js";var d=e(n(),1),f={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function p(e){if(typeof e!=`string`)return null;let t=e.toLowerCase();return Object.hasOwn(f,t)?t:null}function m(e){let t=e.trim();if(!t.startsWith(`{`)||!t.endsWith(`}`))return null;try{let e=JSON.parse(t);return e&&typeof e==`object`?e:null}catch{return null}}var h=new RegExp(String.raw`\u001b\[[0-9;]*m`,`g`);function g(e,t){let n={id:t,raw:e,time:null,level:null,subsystem:null,message:e},r=m(e);if(!r)return n;let i=typeof r._meta==`object`&&r._meta!==null?r._meta:null,a=typeof r.time==`string`?r.time:typeof i?.date==`string`?i.date:null,o=typeof r[0]==`string`?r[0]:typeof i?.name==`string`?i.name:null,s=o?m(o):null,c=null;s&&(typeof s.subsystem==`string`?c=s.subsystem:typeof s.module==`string`&&(c=s.module)),!c&&o&&o.length<120&&(c=o);let l=null;return typeof r[1]==`string`?l=r[1]:!s&&typeof r[0]==`string`?l=r[0]:typeof r.message==`string`&&(l=r.message),{id:t,raw:e,time:a,level:p(i?.logLevelName??i?.level),subsystem:c,message:(l??e).replaceAll(h,``)}}var _=t(),v=500,y=25e4,b=2e3,x=2e3,S={all:`All levels`,debug:`Debug`,info:`Info`,warn:`Warn`,error:`Error`};function C(e,t,n){return t!==`all`&&(e.level===null||f[e.level]<f[t])?!1:n.length===0||e.raw.toLowerCase().includes(n)}function w(){let e=r(e=>e.request),t=r(e=>e.status),[n,f]=(0,d.useState)([]),[p,m]=(0,d.useState)(null),[h,b]=(0,d.useState)(!0),[w,T]=(0,d.useState)(`all`),[E,D]=(0,d.useState)(``),O=(0,d.useRef)(null),k=(0,d.useRef)(0),A=(0,d.useRef)(!1),j=(0,d.useRef)(null),M=(0,d.useCallback)(async()=>{if(!A.current){A.current=!0;try{let t=await e(`logs.tail`,{...O.current===null?{}:{cursor:O.current},limit:v,maxBytes:y}),n=(Array.isArray(t.lines)?t.lines.filter(e=>typeof e==`string`):[]).map(e=>g(e,k.current++)),r=t.reset===!0||O.current===null;f(e=>(r?n:[...e,...n]).slice(-2e3)),typeof t.cursor==`number`&&(O.current=t.cursor),m(null)}catch(e){m(a(e))}finally{A.current=!1}}},[e]),N=s();(0,d.useEffect)(()=>{if(!h||t!==`connected`||!N)return;M();let e=window.setInterval(()=>void M(),x);return()=>window.clearInterval(e)},[h,t,N,M]);let P=E.trim().toLowerCase(),F=n.filter(e=>C(e,w,P));return(0,d.useLayoutEffect)(()=>{let e=j.current;h&&e&&(e.scrollTop=e.scrollHeight)},[h,F.at(-1)?.id??-1]),(0,_.jsxs)(`div`,{className:`ct-page ct-page--fill`,"data-testid":`logs-view`,children:[(0,_.jsxs)(`header`,{className:`ct-page__head`,children:[(0,_.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,_.jsx)(`h1`,{className:`ct-page__title`,children:`Logs`}),(0,_.jsx)(`p`,{className:`ct-page__sub`,children:`The gateway's file log, newest at the bottom.`})]}),(0,_.jsxs)(o,{variant:h?`secondary`:`primary`,onClick:()=>b(e=>!e),"aria-pressed":!h,children:[(0,_.jsx)(c,{name:h?`pause`:`play`,size:15}),h?`Pause`:`Follow`]})]}),(0,_.jsxs)(`div`,{className:`ct-toolbar`,children:[(0,_.jsx)(u,{label:`Minimum level`,value:w,onChange:T,options:[`all`,`debug`,`info`,`warn`,`error`].map(e=>({value:e,label:S[e]}))}),(0,_.jsx)(`div`,{className:`ct-toolbar__grow`}),(0,_.jsxs)(`label`,{className:`ct-search`,children:[(0,_.jsx)(c,{name:`search`,size:15}),(0,_.jsx)(`input`,{className:`ct-search__input`,type:`search`,placeholder:`Filter lines`,"aria-label":`Filter log lines`,value:E,onChange:e=>D(e.target.value)})]})]}),(0,_.jsxs)(l,{title:`Gateway log`,sub:`${F.length} of ${n.length} lines${h?` · following`:` · paused`}`,className:`ct-logs`,children:[p?(0,_.jsx)(i,{tone:`error`,message:`Logs could not be read.`,hint:p}):null,(0,_.jsx)(`div`,{className:`ct-logs__scroll`,ref:j,"data-testid":`log-lines`,children:F.length===0?(0,_.jsx)(i,{message:n.length===0?`No log lines yet.`:`No lines match.`}):F.map(e=>(0,_.jsxs)(`div`,{className:`ct-log-line ct-log-line--${e.level??`plain`}`,"data-level":e.level??void 0,children:[(0,_.jsx)(`span`,{className:`ct-log-line__time`,children:e.time?new Date(e.time).toLocaleTimeString(`en-AU`):``}),(0,_.jsx)(`span`,{className:`ct-log-line__level`,children:e.level??``}),(0,_.jsx)(`span`,{className:`ct-log-line__subsystem`,children:e.subsystem??``}),(0,_.jsx)(`span`,{className:`ct-log-line__message`,children:e.message})]},e.id))})]})]})}export{b as LOG_BUFFER_LIMIT,x as LOG_POLL_MS,w as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,i as r,l as i,s as a,t as o}from"./format-dlOOV12I.js";import{t as s}from"./Button-DL76WqX4.js";import{t as c}from"./Dialog-rIrrCPSu.js";import{a as l,r as u,t as d}from"./index-OijNknZs.js";import{a as f,r as p,t as m}from"./form-utils-BkwTm73v.js";import{n as h,t as g}from"./use-gateway-query-CF94JYnM.js";import{t as _}from"./Badge-4n2tRQ02.js";import{t as v}from"./Panel-CyfpswdJ.js";import{t as y}from"./DataTable-lEkd1R85.js";import{t as b}from"./FilterPills-HxAXXDO8.js";import{t as x}from"./StatusDot-Cij-6nH8.js";import{t as S}from"./ConfirmDialog-DGHQXUr5.js";var C=e(n(),1);function w(e){return e.toSorted((e,t)=>{if(e.connected!==t.connected)return e.connected?-1:1;let n=(e.displayName??e.nodeId).toLowerCase(),r=(t.displayName??t.nodeId).toLowerCase();return n===r?e.nodeId.localeCompare(t.nodeId):n<r?-1:1})}function T(e){return e.displayName?.trim()||e.nodeId}function E(e){return e.displayName?.trim()||e.deviceId}function D(e){return e.approvalState===`pending`&&e.pendingRequestId?e.pendingRequestId:null}function O(e){return!e||e.length===0?`none`:e.filter(e=>e&&e.trim()).join(`, `)}function k(e){return e.rotatedAtMs??e.createdAtMs??e.lastUsedAtMs??null}function A(e){return e.revokedAtMs?`revoked`:`active`}var j=t();function M({device:e,onClose:t,onLinked:n}){let r=h(`identity.list`,{}),a=r.data?.persons??[],l=i(e=>e.request),[u,d]=(0,C.useState)(e.identity??``),[f,p]=(0,C.useState)(!1),[m,g]=(0,C.useState)(null),_=u||e.identity||a[0]?.person||``,v=e.identity!==void 0,y=async()=>{p(!0),g(null);try{await l(`device.identity.link`,{deviceId:e.deviceId,identity:_}),n()}catch(e){g(o(e))}finally{p(!1)}};return(0,j.jsxs)(c,{open:!0,title:v?`Change identity`:`Link identity`,width:`sm`,onClose:f?()=>{}:t,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s,{onClick:t,disabled:f,children:`Cancel`}),(0,j.jsx)(s,{variant:`primary`,disabled:f||_===``,onClick:()=>void y(),children:v?`Change`:`Link`})]}),children:[(0,j.jsxs)(`p`,{children:[`Attribute activity from `,E(e),` to a person. The device keeps its tokens; only the attribution changes.`]}),r.loading&&a.length===0?(0,j.jsx)(`p`,{children:`Loading identities…`}):null,r.error?(0,j.jsx)(`p`,{role:`alert`,children:r.error}):null,a.length===0&&!r.loading?(0,j.jsxs)(`p`,{children:[`No identities yet. Add one with `,(0,j.jsx)(`code`,{children:`wednesdayai identity add <name>`}),`.`]}):(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[(0,j.jsx)(`span`,{className:`ct-muted`,children:`Identity`}),(0,j.jsx)(`select`,{"aria-label":`Identity`,value:_,disabled:f,onChange:e=>d(e.target.value),children:a.map(e=>(0,j.jsx)(`option`,{value:e.person,children:e.person},e.person))})]}),m?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:m}):null]})}var N={approve:`device.pair.approve`,reject:`device.pair.reject`,rotate:`device.token.rotate`,revoke:`device.token.revoke`,unlink:`device.identity.unlink`,remove:`device.pair.remove`};function P(e){switch(e.kind){case`approve`:case`reject`:return{requestId:e.request.requestId};case`rotate`:return{deviceId:e.device.deviceId,role:e.token.role,scopes:e.token.scopes};case`revoke`:return{deviceId:e.device.deviceId,role:e.token.role};case`unlink`:case`remove`:return{deviceId:e.device.deviceId}}}function F(e){switch(e.kind){case`approve`:return{title:`Approve device pairing`,body:`Approve the pairing request from ${E(e.request)} (${e.request.deviceId})?`,label:`Approve`,danger:!1};case`reject`:return{title:`Reject device pairing`,body:`Reject the pairing request from ${E(e.request)} (${e.request.deviceId})?`,label:`Reject`,danger:!0};case`rotate`:return{title:`Rotate device token`,body:`Rotate the ${e.token.role} token for ${E(e.device)}? The previous token stops working immediately.`,label:`Rotate`,danger:!1};case`revoke`:return{title:`Revoke device token`,body:`Revoke the ${e.token.role} token for ${E(e.device)}? Clients using this token disconnect.`,label:`Revoke`,danger:!0};case`unlink`:return{title:`Unlink identity`,body:`Unlink ${E(e.device)} from ${e.device.identity}? Activity from this device stops being attributed to ${e.device.identity}.`,label:`Unlink`,danger:!0};case`remove`:return{title:`Remove paired device`,body:`Remove ${E(e.device)} (${e.device.deviceId})? Its tokens stop working.`,label:`Remove`,danger:!0}}}function I({devices:e,loading:t,error:n,onRefresh:r}){let l=i(e=>e.request),u=e?.pending??[],d=e?.paired??[],[f,p]=(0,C.useState)(null),[m,h]=(0,C.useState)(!1),[g,_]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,w]=(0,C.useState)(null),T=async()=>{if(f){h(!0),_(null);try{let e=await l(N[f.kind],P(f));p(null),f.kind===`rotate`&&e?.token&&b({token:e.token,role:e.role??f.token.role}),r()}catch(e){_(o(e))}finally{h(!1)}}},E=f?F(f):null;return(0,j.jsxs)(v,{title:`Devices`,sub:`Pairing requests + role tokens.`,testId:`devices-panel`,actions:(0,j.jsx)(s,{onClick:r,disabled:t,children:t?`Loading…`:`Refresh`}),children:[n?(0,j.jsx)(a,{tone:`error`,message:n,hint:(0,j.jsx)(s,{onClick:r,children:`Retry`})}):t&&!e?(0,j.jsx)(a,{tone:`loading`,message:`Loading devices…`}):u.length===0&&d.length===0?(0,j.jsx)(a,{message:`No paired devices.`}):(0,j.jsxs)(`div`,{className:`ct-nodes__devices`,children:[u.length>0?(0,j.jsxs)(`section`,{"aria-label":`Pending pairing requests`,children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Pending`}),u.map(e=>(0,j.jsx)(R,{req:e,busy:m,onApprove:()=>p({kind:`approve`,request:e}),onReject:()=>p({kind:`reject`,request:e})},e.requestId))]}):null,d.length>0?(0,j.jsxs)(`section`,{"aria-label":`Paired devices`,children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Paired`}),d.map(e=>(0,j.jsx)(z,{device:e,busy:m,onLink:()=>w(e),onRotate:t=>p({kind:`rotate`,device:e,token:t}),onRevoke:t=>p({kind:`revoke`,device:e,token:t}),onUnlink:()=>p({kind:`unlink`,device:e}),onRemove:()=>p({kind:`remove`,device:e})},e.deviceId))]}):null]}),g?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:g}):null,(0,j.jsx)(S,{open:E!==null,title:E?.title??``,body:E?.body??``,confirmLabel:E?.label??``,danger:E?.danger??!1,busy:m,bodyClassName:`ct-nodes__confirm-body`,testId:`confirm-device-action`,onConfirm:()=>void T(),onCancel:()=>{p(null),_(null)}}),(0,j.jsx)(c,{open:y!==null,title:`New ${y?.role??`device`} token`,onClose:()=>b(null),width:`sm`,footer:(0,j.jsx)(s,{variant:`primary`,onClick:()=>b(null),"data-testid":`token-done`,children:`Done`}),children:y?(0,j.jsx)(L,{token:y.token}):null}),x===null?null:(0,j.jsx)(M,{device:x,onClose:()=>w(null),onLinked:()=>{w(null),r()}})]})}function L({token:e}){let[t,n]=(0,C.useState)(!1);return(0,j.jsxs)(`div`,{className:`ct-nodes__token-reveal`,children:[(0,j.jsx)(`p`,{children:`Copy it now — it is shown only once and is not stored by the console.`}),(0,j.jsxs)(`div`,{className:`ct-nodes__token-line`,children:[(0,j.jsx)(`code`,{className:`ct-mono`,"data-testid":`rotated-token`,children:e}),(0,j.jsx)(s,{size:`sm`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>n(!0)).catch(()=>n(!1))},children:t?`Copied`:`Copy`})]})]})}function R({req:e,busy:t,onApprove:n,onReject:i}){return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsx)(`div`,{className:`ct-nodes__list-title`,children:E(e)}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:[e.deviceId,e.remoteIp?` · ${e.remoteIp}`:``]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[e.role?.trim()?`role: ${e.role}`:`role: —`,typeof e.ts==`number`?` · requested ${r(e.ts)}`:``,e.isRepair?` · repair`:``]})]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,variant:`primary`,disabled:t,"aria-label":`Approve device ${E(e)}`,onClick:n,children:`Approve`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,"aria-label":`Reject device ${E(e)}`,onClick:i,children:`Reject`})]})]})}function z({device:e,busy:t,onLink:n,onRotate:r,onRevoke:i,onUnlink:a,onRemove:o}){let c=Array.isArray(e.tokens)?e.tokens:[];return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsx)(`div`,{className:`ct-nodes__list-title`,children:E(e)}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:[e.deviceId,e.remoteIp?` · ${e.remoteIp}`:``]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`roles: `,O(e.roles),` · scopes: `,O(e.scopes)]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`Identity:`,` `,e.identity?(0,j.jsx)(_,{tone:`accent`,children:e.identity}):(0,j.jsx)(`span`,{className:`ct-muted`,children:`Not linked`})]}),c.length===0?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub`,children:`Tokens: none`}):(0,j.jsx)(`div`,{className:`ct-nodes__tokens`,children:c.map(n=>(0,j.jsx)(B,{deviceId:e.deviceId,token:n,busy:t,onRotate:()=>r(n),onRevoke:()=>i(n)},n.role))})]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[e.identity?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s,{size:`sm`,disabled:t,onClick:n,children:`Change identity`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,onClick:a,children:`Unlink`})]}):(0,j.jsx)(s,{size:`sm`,variant:`primary`,disabled:t,onClick:n,children:`Link identity`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,onClick:o,children:`Remove`})]})]})}function B({deviceId:e,token:t,busy:n,onRotate:i,onRevoke:a}){let o=k(t),c=A(t)===`revoked`;return(0,j.jsxs)(`div`,{className:`ct-nodes__token-row`,children:[(0,j.jsxs)(`span`,{className:`ct-nodes__list-sub`,children:[(0,j.jsx)(`span`,{className:`ct-mono`,children:e}),` · `,t.role,` ·`,` `,(0,j.jsx)(_,{tone:c?`danger`:`ok`,children:A(t)}),` · scopes:`,` `,O(t.scopes),o?` · ${r(o)}`:``]}),(0,j.jsxs)(`span`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,disabled:n,"aria-label":`Rotate ${t.role} token`,onClick:i,children:`Rotate`}),c?null:(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:n,"aria-label":`Revoke ${t.role} token`,onClick:a,children:`Revoke`})]})]})}var V=`__defaults__`;function H(e){return e===`allowlist`||e===`full`||e===`deny`?e:`deny`}function U(e){return e===`always`||e===`off`||e===`on-miss`?e:`on-miss`}function W(e){return{security:H(e?.security),ask:U(e?.ask),askFallback:H(e?.askFallback??`deny`),autoAllowSkills:e?.autoAllowSkills===!0}}function G(e){if(!e||e.kind===`gateway`)return{method:`exec.approvals.get`,params:{}};let t=e.nodeId.trim();return t?{method:`exec.approvals.node.get`,params:{nodeId:t}}:null}function ee(e,t){if(!e||e.kind===`gateway`)return{method:`exec.approvals.set`,params:t};let n=e.nodeId.trim();return n?{method:`exec.approvals.node.set`,params:{...t,nodeId:n}}:null}function te(e){let t={"system.execApprovals.get":!0,"system.execApprovals.set":!0},n=[];for(let r of e){if(!(Array.isArray(r.commands)?r.commands:[]).some(e=>t[String(e)])||!r.nodeId.trim())continue;let e=r.displayName?.trim();n.push({id:r.nodeId,label:!e||e===r.nodeId?r.nodeId:`${e} · ${r.nodeId}`})}return n.sort((e,t)=>e.label.localeCompare(t.label)),n}function ne(e,t){let n=new Map;for(let t of e)t.id.trim()&&n.set(t.id,{id:t.id,name:t.name,isDefault:t.id===`main`});for(let e of Object.keys(t?.agents??{}))n.has(e)||n.set(e,{id:e,isDefault:e===`main`});let r=Array.from(n.values());return r.length===0&&r.push({id:`main`,isDefault:!0}),r.sort((e,t)=>e.isDefault===t.isDefault?(e.name?.trim()||e.id).localeCompare(t.name?.trim()||t.id):e.isDefault?-1:1),r}function re(e,t){return e===`__defaults__`?V:e&&t.some(t=>t.id===e)?e:V}function K(e,t,n){let r=m(e);return f(r,t,n),r}function q(e,t){let n=m(e);return p(n,t),n}var J=[{value:`deny`,label:`Deny`},{value:`allowlist`,label:`Allowlist`},{value:`full`,label:`Full`}],ie=[{value:`off`,label:`Off`},{value:`on-miss`,label:`On miss`},{value:`always`,label:`Always`}],Y=`__default__`;function X({nodes:e}){let t=i(e=>e.request),[n,r]=(0,C.useState)({kind:`gateway`}),[c,l]=(0,C.useState)(null),[u,d]=(0,C.useState)({form:{},dirty:!1}),[f,p]=(0,C.useState)(null),[g,_]=(0,C.useState)(!1),[y,x]=(0,C.useState)(!1),[S,w]=(0,C.useState)(null),T=(0,C.useRef)(0),E=h(`agents.list`,{}),D=te(e),O=n.kind===`gateway`||n.nodeId?.trim()!==``,k=(0,C.useCallback)(async()=>{let e=++T.current,r=G(n);if(_(!0),w(null),!r){w(`Select a node before loading exec approvals.`),_(!1);return}try{let n=await t(r.method,r.params);if(e!==T.current)return;l(n),d({form:m(n.file??{}),dirty:!1})}catch(t){e===T.current&&w(o(t))}finally{e===T.current&&_(!1)}},[t,n]);(0,C.useEffect)(()=>{k()},[k]);let A=(e,t)=>{l(null),d({form:{},dirty:!1}),p(null),r(e===`gateway`?{kind:`gateway`}:{kind:`node`,nodeId:t??``})},M=async()=>{let e=c?.hash;if(!e){w(`Exec approvals hash missing; reload and retry.`);return}x(!0),w(null);try{let r=ee(n,{file:u.form,baseHash:e});if(!r){w(`Select a node before saving exec approvals.`);return}await t(r.method,r.params),d(e=>({...e,dirty:!1})),await k()}catch(e){w(o(e))}finally{x(!1)}},N=W(u.form.defaults),P=ne(E.data?.agents??[],u.form),F=re(f,P),I=F===V,L=I?[`defaults`]:[`agents`,F],R=I?null:u.form.agents?.[F]??null,z=g||y,B=(e,t)=>{d(n=>({form:K(n.form,[...L,e],t),dirty:!0}))},H=e=>{d(t=>({form:q(t.form,[...L,e]),dirty:!0}))},U=[`agents`,F,`allowlist`],X=R?.allowlist??[];return(0,j.jsxs)(v,{title:`Exec approvals`,sub:`Allowlist and approval policy for exec host=gateway/node.`,testId:`exec-approvals-panel`,actions:(0,j.jsx)(s,{variant:`primary`,onClick:()=>void M(),disabled:z||!u.dirty||!O,children:y?`Saving…`:`Save`}),children:[S?(0,j.jsxs)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:[(0,j.jsx)(`span`,{children:S}),(0,j.jsx)(s,{size:`sm`,onClick:()=>void k(),disabled:g,children:`Reload`})]}):null,(0,j.jsxs)(`div`,{className:`ct-nodes__target-row`,children:[(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Host`,(0,j.jsxs)(`select`,{"aria-label":`Exec approvals host`,value:n.kind,disabled:z,onChange:e=>{e.target.value===`node`?A(`node`,n.kind===`node`?n.nodeId:D[0]?.id??``):A(`gateway`,null)},children:[(0,j.jsx)(`option`,{value:`gateway`,children:`Gateway`}),(0,j.jsx)(`option`,{value:`node`,children:`Node`})]})]}),n.kind===`node`?(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Node`,(0,j.jsxs)(`select`,{"aria-label":`Exec approvals node`,value:n.nodeId??``,disabled:z||D.length===0,onChange:e=>A(`node`,e.target.value||null),children:[(0,j.jsx)(`option`,{value:``,children:`Select node`}),D.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}):null]}),n.kind===`node`&&D.length===0?(0,j.jsx)(a,{message:`No nodes advertise exec approvals yet.`}):null,g&&!c?(0,j.jsx)(a,{tone:`loading`,message:`Loading approvals…`}):c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`ct-nodes__scope-row`,role:`group`,"aria-label":`Exec approvals scope`,children:[(0,j.jsx)(`span`,{className:`ct-nodes__heading`,children:`Scope`}),(0,j.jsx)(b,{label:`Scope`,value:F,options:[{value:V,label:`Defaults`},...P.map(e=>({value:e.id,label:e.name?.trim()?`${e.name} (${e.id})`:e.id}))],onChange:p})]}),(0,j.jsxs)(`dl`,{className:`ct-kv ct-nodes__policy`,children:[(0,j.jsx)(`dt`,{children:`Security`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Security`,disabled:z,value:I?N.security:R?.security??Y,defaultValueText:N.security,showUseDefault:!I,options:J,onChange:e=>{!I&&e===Y?H(`security`):B(`security`,e)}})}),(0,j.jsx)(`dt`,{children:`Ask`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Ask`,disabled:z,value:I?N.ask:R?.ask??Y,defaultValueText:N.ask,showUseDefault:!I,options:ie,onChange:e=>{!I&&e===Y?H(`ask`):B(`ask`,e)}})}),(0,j.jsx)(`dt`,{children:`Ask fallback`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Ask fallback`,disabled:z,value:I?N.askFallback:R?.askFallback??Y,defaultValueText:N.askFallback,showUseDefault:!I,options:J,onChange:e=>{!I&&e===Y?H(`askFallback`):B(`askFallback`,e)}})}),(0,j.jsx)(`dt`,{children:`Auto-allow skill CLIs`}),(0,j.jsx)(`dd`,{children:(0,j.jsxs)(`span`,{className:`ct-nodes__check-row`,children:[(0,j.jsx)(`input`,{type:`checkbox`,"aria-label":`Auto-allow skill CLIs`,disabled:z,checked:I?N.autoAllowSkills:R?.autoAllowSkills??N.autoAllowSkills,onChange:e=>B(`autoAllowSkills`,e.target.checked)}),!I&&R?.autoAllowSkills!==void 0?(0,j.jsx)(s,{size:`sm`,disabled:z,onClick:()=>H(`autoAllowSkills`),children:`Use default`}):null]})})]}),I?null:(0,j.jsxs)(`div`,{className:`ct-nodes__allowlist`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__allowlist-head`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Allowlist`}),(0,j.jsx)(`p`,{className:`ct-nodes__list-sub`,children:`Case-insensitive glob patterns.`})]}),(0,j.jsx)(s,{size:`sm`,disabled:z,onClick:()=>{let e=[...X,{pattern:``}];d(t=>({form:K(t.form,U,e),dirty:!0}))},children:`Add pattern`})]}),X.length===0?(0,j.jsx)(a,{message:`No allowlist entries yet.`}):X.map((e,t)=>(0,j.jsx)(ae,{entry:e,index:t,disabled:z,onPatternChange:e=>{d(n=>({form:K(n.form,[...U,t,`pattern`],e),dirty:!0}))},onRemove:()=>{d(e=>({form:X.length<=1?q(e.form,U):q(e.form,[...U,t]),dirty:!0}))}},e.id??t))]})]}):null]})}function Z({ariaLabel:e,value:t,options:n,showUseDefault:r,defaultValueText:i,disabled:a,onChange:o}){return(0,j.jsxs)(`select`,{"aria-label":e,value:t,disabled:a,onChange:e=>o(e.target.value),children:[r?(0,j.jsxs)(`option`,{value:Y,children:[`Use default (`,i,`)`]}):null,n.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}function ae({entry:e,index:t,disabled:n,onPatternChange:i,onRemove:a}){return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`Last used: `,e.lastUsedAt?r(e.lastUsedAt):`never`]}),e.lastUsedCommand?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:e.lastUsedCommand}):null,e.lastResolvedPath?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:e.lastResolvedPath}):null]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(`input`,{type:`text`,className:`ct-nodes__pattern-input`,"aria-label":`Allowlist pattern ${t+1}`,value:e.pattern??``,disabled:n,onChange:e=>i(e.target.value)}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:n,onClick:a,children:`Remove`})]})]})}function oe({nodeId:e,paired:t,onClose:n,onRenamed:c}){let l=i(e=>e.request),u=h(`node.describe`,{nodeId:e}),[f,p]=(0,C.useState)(null),[m,g]=(0,C.useState)(!1),[y,b]=(0,C.useState)(null),S=u.data,w=f??(S?.displayName?.trim()||e),E=async()=>{let t=w.trim();if(t){g(!0),b(null);try{await l(`node.rename`,{nodeId:e,displayName:t}),p(null),u.reload(),c()}catch(e){b(o(e))}finally{g(!1)}}};return(0,j.jsx)(v,{title:T({nodeId:e,displayName:S?.displayName}),sub:(0,j.jsx)(`span`,{className:`ct-mono`,children:e}),testId:`node-drawer`,actions:(0,j.jsx)(`button`,{type:`button`,className:`ct-icon-btn`,"aria-label":`Close node details`,onClick:n,children:(0,j.jsx)(d,{name:`x`})}),children:(0,j.jsx)(`div`,{className:`ct-nodes__aside-body`,children:u.error?(0,j.jsx)(a,{tone:`error`,message:u.error,hint:(0,j.jsx)(s,{onClick:u.reload,children:`Retry`})}):u.loading&&!S?(0,j.jsx)(a,{tone:`loading`,message:`Loading node…`}):S?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`ct-nodes__status-row`,children:[S.connected?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`ok`,label:`Connected`,pulse:!0}),` Connected`]}):(0,j.jsx)(_,{children:`Offline`}),S.paired?(0,j.jsx)(_,{tone:`accent`,children:`Paired`}):null]}),(0,j.jsxs)(`dl`,{className:`ct-kv`,children:[(0,j.jsx)(`dt`,{children:`Platform`}),(0,j.jsx)(`dd`,{children:S.platform??`—`}),(0,j.jsx)(`dt`,{children:`Version`}),(0,j.jsx)(`dd`,{children:S.version??`—`}),(0,j.jsx)(`dt`,{children:`Device`}),(0,j.jsx)(`dd`,{children:S.deviceFamily??`—`}),(0,j.jsx)(`dt`,{children:`Model`}),(0,j.jsx)(`dd`,{children:S.modelIdentifier??`—`}),(0,j.jsx)(`dt`,{children:`IP`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:S.remoteIp??`—`}),(0,j.jsx)(`dt`,{children:`Connected`}),(0,j.jsx)(`dd`,{children:S.connectedAtMs?r(S.connectedAtMs):`—`}),(0,j.jsx)(`dt`,{children:`Caps`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:O(S.caps)}),(0,j.jsx)(`dt`,{children:`Commands`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:O(S.commands)})]}),t?(0,j.jsxs)(`div`,{className:`ct-nodes__rename`,children:[(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Display name`,(0,j.jsx)(`input`,{type:`text`,value:w,onChange:e=>p(e.target.value),"aria-label":`Node display name`})]}),(0,j.jsx)(s,{variant:`primary`,onClick:()=>void E(),disabled:m,children:m?`Saving…`:`Rename`})]}):null,y?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:y}):null]}):null})})}function se({nodes:e,loading:t,error:n,selectedNodeId:r,onSelectNode:c,onRefresh:l}){let u=i(e=>e.request),[d,f]=(0,C.useState)(null),[p,m]=(0,C.useState)(!1),[h,g]=(0,C.useState)(null),_=async()=>{if(d){m(!0),g(null);try{await u(d.kind===`approve`?`node.pair.approve`:`node.pair.reject`,{requestId:d.node.pendingRequestId}),f(null),l()}catch(e){g(o(e))}finally{m(!1)}}};return(0,j.jsxs)(v,{title:`Nodes`,sub:`Paired devices and live links.`,testId:`nodes-panel`,actions:(0,j.jsx)(s,{onClick:l,disabled:t,children:t?`Loading…`:`Refresh`}),children:[n?(0,j.jsx)(a,{tone:`error`,message:n,hint:(0,j.jsx)(s,{onClick:l,children:`Retry`})}):t&&e.length===0?(0,j.jsx)(a,{tone:`loading`,message:`Loading nodes…`}):e.length===0?(0,j.jsx)(a,{message:`No nodes found.`}):(0,j.jsx)(y,{label:`Nodes`,rows:e,rowKey:e=>e.nodeId,selectedKey:r,onRowClick:c,columns:[{key:`name`,label:`Node`,render:e=>(0,j.jsxs)(`div`,{className:`ct-cell-stack`,children:[(0,j.jsx)(`span`,{className:`ct-cell-stack__main`,children:T(e)}),(0,j.jsx)(`span`,{className:`ct-cell-stack__sub`,children:e.nodeId})]})},{key:`status`,label:`Status`,render:e=>(0,j.jsx)(ce,{node:e})},{key:`platform`,label:`Platform`,render:e=>(0,j.jsxs)(`div`,{className:`ct-cell-stack`,children:[(0,j.jsx)(`span`,{className:`ct-cell-stack__main`,children:e.platform??`—`}),(0,j.jsx)(`span`,{className:`ct-cell-stack__sub`,children:e.version??``})]})},{key:`ip`,label:`IP`,mono:!0,render:e=>e.remoteIp??`—`},{key:`caps`,label:`Caps`,render:e=>(0,j.jsx)(Q,{values:e.caps})},{key:`commands`,label:`Commands`,render:e=>(0,j.jsx)(Q,{values:e.commands})},{key:`actions`,label:``,render:e=>D(e)?(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,variant:`primary`,"aria-label":`Approve pairing for ${T(e)}`,onClick:t=>{t.stopPropagation(),f({kind:`approve`,node:e})},children:`Approve`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,"aria-label":`Reject pairing for ${T(e)}`,onClick:t=>{t.stopPropagation(),f({kind:`reject`,node:e})},children:`Reject`})]}):null}]}),h?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:h}):null,(0,j.jsx)(S,{open:d!==null,title:d?.kind===`approve`?`Approve node pairing`:`Reject node pairing`,body:d?`${d.kind===`approve`?`Approve`:`Reject`} the pairing request from ${T(d.node)} (${d.node.nodeId})?`:``,confirmLabel:d?.kind===`approve`?`Approve`:`Reject`,danger:d?.kind===`reject`,busy:p,bodyClassName:`ct-nodes__confirm-body`,testId:`confirm-node-pairing`,onConfirm:()=>void _(),onCancel:()=>{f(null),g(null)}})]})}function ce({node:e}){return e.connected?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`ok`,label:`Connected`,pulse:!0}),`Connected`]}):D(e)?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`warn`,label:`Pairing pending`,pulse:!0}),`Pending`]}):(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`neutral`,label:`Paired offline`}),(0,j.jsx)(_,{children:`Paired`})]})}function Q({values:e}){return!e||e.length===0?(0,j.jsx)(j.Fragment,{children:`—`}):(0,j.jsxs)(`span`,{className:`ct-nodes__chips`,title:O(e),children:[e.slice(0,3).map(e=>(0,j.jsx)(`span`,{className:`ct-nodes__chip`,children:e},e)),e.length>3?(0,j.jsxs)(`span`,{className:`ct-nodes__chip-more`,children:[`+`,e.length-3]}):null]})}var $=[`device.pair.requested`,`device.pair.resolved`,`node.pair.requested`,`node.pair.resolved`];function le(){let e=i(e=>e.request),t=h(`node.list`,{},{refreshMs:g,invalidateOn:$}),n=h(`device.pair.list`,{},{refreshMs:g,invalidateOn:$}),[r,a]=(0,C.useState)(null),o=(0,C.useCallback)(()=>{t.reload(),n.reload(),l.getState().refresh(e)},[t.reload,n.reload,e]);(0,C.useEffect)(()=>{let{subscribe:t}=i.getState(),n=null,r=()=>{n===null&&(n=window.setTimeout(()=>{n=null,!(!u()||i.getState().status!==`connected`)&&l.getState().refresh(e)},500))},a=$.map(e=>t(e,r));return()=>{n!==null&&(window.clearTimeout(n),n=null);for(let e of a)e()}},[e]);let s=w(t.data?.nodes??[]),c=s.find(e=>e.nodeId===r)??null;return(0,j.jsxs)(`div`,{className:`ct-page`,"data-testid":`nodes-view`,children:[(0,j.jsx)(`header`,{className:`ct-page__head`,children:(0,j.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,j.jsx)(`h1`,{className:`ct-page__title`,children:`Nodes`}),(0,j.jsx)(`p`,{className:`ct-page__sub`,children:`Fleet nodes, device pairing and exec approvals.`})]})}),(0,j.jsx)(X,{nodes:s}),(0,j.jsxs)(`div`,{className:c?`ct-nodes__layout ct-nodes__layout--open`:`ct-nodes__layout`,children:[(0,j.jsx)(se,{nodes:s,loading:t.loading,error:t.error,selectedNodeId:r,onSelectNode:e=>a(e.nodeId),onRefresh:o}),c?(0,j.jsx)(oe,{nodeId:c.nodeId,paired:c.paired,onClose:()=>a(null),onRenamed:o},c.nodeId):null]}),(0,j.jsx)(I,{devices:n.data,loading:n.loading,error:n.error,onRefresh:o})]})}export{le as default};
1
+ import{_ as e,c as t,h as n,i as r,l as i,s as a,t as o}from"./format-CGs6a1G6.js";import{t as s}from"./Button-CGdLofSY.js";import{t as c}from"./Dialog-CQE8Pvh6.js";import{a as l,r as u,t as d}from"./index-BvXiY83i.js";import{a as f,r as p,t as m}from"./form-utils-BkwTm73v.js";import{n as h,t as g}from"./use-gateway-query-D25QZANO.js";import{t as _}from"./Badge-CB5TWfdz.js";import{t as v}from"./Panel-9wOynsWc.js";import{t as y}from"./DataTable-CSi930kO.js";import{t as b}from"./FilterPills-9pNaAyrL.js";import{t as x}from"./StatusDot-DHhJ1VpB.js";import{t as S}from"./ConfirmDialog-B7aotBjN.js";var C=e(n(),1);function w(e){return e.toSorted((e,t)=>{if(e.connected!==t.connected)return e.connected?-1:1;let n=(e.displayName??e.nodeId).toLowerCase(),r=(t.displayName??t.nodeId).toLowerCase();return n===r?e.nodeId.localeCompare(t.nodeId):n<r?-1:1})}function T(e){return e.displayName?.trim()||e.nodeId}function E(e){return e.displayName?.trim()||e.deviceId}function D(e){return e.approvalState===`pending`&&e.pendingRequestId?e.pendingRequestId:null}function O(e){return!e||e.length===0?`none`:e.filter(e=>e&&e.trim()).join(`, `)}function k(e){return e.rotatedAtMs??e.createdAtMs??e.lastUsedAtMs??null}function A(e){return e.revokedAtMs?`revoked`:`active`}var j=t();function M({device:e,onClose:t,onLinked:n}){let r=h(`identity.list`,{}),a=r.data?.persons??[],l=i(e=>e.request),[u,d]=(0,C.useState)(e.identity??``),[f,p]=(0,C.useState)(!1),[m,g]=(0,C.useState)(null),_=u||e.identity||a[0]?.person||``,v=e.identity!==void 0,y=async()=>{p(!0),g(null);try{await l(`device.identity.link`,{deviceId:e.deviceId,identity:_}),n()}catch(e){g(o(e))}finally{p(!1)}};return(0,j.jsxs)(c,{open:!0,title:v?`Change identity`:`Link identity`,width:`sm`,onClose:f?()=>{}:t,footer:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s,{onClick:t,disabled:f,children:`Cancel`}),(0,j.jsx)(s,{variant:`primary`,disabled:f||_===``,onClick:()=>void y(),children:v?`Change`:`Link`})]}),children:[(0,j.jsxs)(`p`,{children:[`Attribute activity from `,E(e),` to a person. The device keeps its tokens; only the attribution changes.`]}),r.loading&&a.length===0?(0,j.jsx)(`p`,{children:`Loading identities…`}):null,r.error?(0,j.jsx)(`p`,{role:`alert`,children:r.error}):null,a.length===0&&!r.loading?(0,j.jsxs)(`p`,{children:[`No identities yet. Add one with `,(0,j.jsx)(`code`,{children:`wednesdayai identity add <name>`}),`.`]}):(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[(0,j.jsx)(`span`,{className:`ct-muted`,children:`Identity`}),(0,j.jsx)(`select`,{"aria-label":`Identity`,value:_,disabled:f,onChange:e=>d(e.target.value),children:a.map(e=>(0,j.jsx)(`option`,{value:e.person,children:e.person},e.person))})]}),m?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:m}):null]})}var N={approve:`device.pair.approve`,reject:`device.pair.reject`,rotate:`device.token.rotate`,revoke:`device.token.revoke`,unlink:`device.identity.unlink`,remove:`device.pair.remove`};function P(e){switch(e.kind){case`approve`:case`reject`:return{requestId:e.request.requestId};case`rotate`:return{deviceId:e.device.deviceId,role:e.token.role,scopes:e.token.scopes};case`revoke`:return{deviceId:e.device.deviceId,role:e.token.role};case`unlink`:case`remove`:return{deviceId:e.device.deviceId}}}function F(e){switch(e.kind){case`approve`:return{title:`Approve device pairing`,body:`Approve the pairing request from ${E(e.request)} (${e.request.deviceId})?`,label:`Approve`,danger:!1};case`reject`:return{title:`Reject device pairing`,body:`Reject the pairing request from ${E(e.request)} (${e.request.deviceId})?`,label:`Reject`,danger:!0};case`rotate`:return{title:`Rotate device token`,body:`Rotate the ${e.token.role} token for ${E(e.device)}? The previous token stops working immediately.`,label:`Rotate`,danger:!1};case`revoke`:return{title:`Revoke device token`,body:`Revoke the ${e.token.role} token for ${E(e.device)}? Clients using this token disconnect.`,label:`Revoke`,danger:!0};case`unlink`:return{title:`Unlink identity`,body:`Unlink ${E(e.device)} from ${e.device.identity}? Activity from this device stops being attributed to ${e.device.identity}.`,label:`Unlink`,danger:!0};case`remove`:return{title:`Remove paired device`,body:`Remove ${E(e.device)} (${e.device.deviceId})? Its tokens stop working.`,label:`Remove`,danger:!0}}}function I({devices:e,loading:t,error:n,onRefresh:r}){let l=i(e=>e.request),u=e?.pending??[],d=e?.paired??[],[f,p]=(0,C.useState)(null),[m,h]=(0,C.useState)(!1),[g,_]=(0,C.useState)(null),[y,b]=(0,C.useState)(null),[x,w]=(0,C.useState)(null),T=async()=>{if(f){h(!0),_(null);try{let e=await l(N[f.kind],P(f));p(null),f.kind===`rotate`&&e?.token&&b({token:e.token,role:e.role??f.token.role}),r()}catch(e){_(o(e))}finally{h(!1)}}},E=f?F(f):null;return(0,j.jsxs)(v,{title:`Devices`,sub:`Pairing requests + role tokens.`,testId:`devices-panel`,actions:(0,j.jsx)(s,{onClick:r,disabled:t,children:t?`Loading…`:`Refresh`}),children:[n?(0,j.jsx)(a,{tone:`error`,message:n,hint:(0,j.jsx)(s,{onClick:r,children:`Retry`})}):t&&!e?(0,j.jsx)(a,{tone:`loading`,message:`Loading devices…`}):u.length===0&&d.length===0?(0,j.jsx)(a,{message:`No paired devices.`}):(0,j.jsxs)(`div`,{className:`ct-nodes__devices`,children:[u.length>0?(0,j.jsxs)(`section`,{"aria-label":`Pending pairing requests`,children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Pending`}),u.map(e=>(0,j.jsx)(R,{req:e,busy:m,onApprove:()=>p({kind:`approve`,request:e}),onReject:()=>p({kind:`reject`,request:e})},e.requestId))]}):null,d.length>0?(0,j.jsxs)(`section`,{"aria-label":`Paired devices`,children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Paired`}),d.map(e=>(0,j.jsx)(z,{device:e,busy:m,onLink:()=>w(e),onRotate:t=>p({kind:`rotate`,device:e,token:t}),onRevoke:t=>p({kind:`revoke`,device:e,token:t}),onUnlink:()=>p({kind:`unlink`,device:e}),onRemove:()=>p({kind:`remove`,device:e})},e.deviceId))]}):null]}),g?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:g}):null,(0,j.jsx)(S,{open:E!==null,title:E?.title??``,body:E?.body??``,confirmLabel:E?.label??``,danger:E?.danger??!1,busy:m,bodyClassName:`ct-nodes__confirm-body`,testId:`confirm-device-action`,onConfirm:()=>void T(),onCancel:()=>{p(null),_(null)}}),(0,j.jsx)(c,{open:y!==null,title:`New ${y?.role??`device`} token`,onClose:()=>b(null),width:`sm`,footer:(0,j.jsx)(s,{variant:`primary`,onClick:()=>b(null),"data-testid":`token-done`,children:`Done`}),children:y?(0,j.jsx)(L,{token:y.token}):null}),x===null?null:(0,j.jsx)(M,{device:x,onClose:()=>w(null),onLinked:()=>{w(null),r()}})]})}function L({token:e}){let[t,n]=(0,C.useState)(!1);return(0,j.jsxs)(`div`,{className:`ct-nodes__token-reveal`,children:[(0,j.jsx)(`p`,{children:`Copy it now — it is shown only once and is not stored by the console.`}),(0,j.jsxs)(`div`,{className:`ct-nodes__token-line`,children:[(0,j.jsx)(`code`,{className:`ct-mono`,"data-testid":`rotated-token`,children:e}),(0,j.jsx)(s,{size:`sm`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>n(!0)).catch(()=>n(!1))},children:t?`Copied`:`Copy`})]})]})}function R({req:e,busy:t,onApprove:n,onReject:i}){return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsx)(`div`,{className:`ct-nodes__list-title`,children:E(e)}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:[e.deviceId,e.remoteIp?` · ${e.remoteIp}`:``]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[e.role?.trim()?`role: ${e.role}`:`role: —`,typeof e.ts==`number`?` · requested ${r(e.ts)}`:``,e.isRepair?` · repair`:``]})]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,variant:`primary`,disabled:t,"aria-label":`Approve device ${E(e)}`,onClick:n,children:`Approve`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,"aria-label":`Reject device ${E(e)}`,onClick:i,children:`Reject`})]})]})}function z({device:e,busy:t,onLink:n,onRotate:r,onRevoke:i,onUnlink:a,onRemove:o}){let c=Array.isArray(e.tokens)?e.tokens:[];return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsx)(`div`,{className:`ct-nodes__list-title`,children:E(e)}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:[e.deviceId,e.remoteIp?` · ${e.remoteIp}`:``]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`roles: `,O(e.roles),` · scopes: `,O(e.scopes)]}),(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`Identity:`,` `,e.identity?(0,j.jsx)(_,{tone:`accent`,children:e.identity}):(0,j.jsx)(`span`,{className:`ct-muted`,children:`Not linked`})]}),c.length===0?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub`,children:`Tokens: none`}):(0,j.jsx)(`div`,{className:`ct-nodes__tokens`,children:c.map(n=>(0,j.jsx)(B,{deviceId:e.deviceId,token:n,busy:t,onRotate:()=>r(n),onRevoke:()=>i(n)},n.role))})]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[e.identity?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(s,{size:`sm`,disabled:t,onClick:n,children:`Change identity`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,onClick:a,children:`Unlink`})]}):(0,j.jsx)(s,{size:`sm`,variant:`primary`,disabled:t,onClick:n,children:`Link identity`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:t,onClick:o,children:`Remove`})]})]})}function B({deviceId:e,token:t,busy:n,onRotate:i,onRevoke:a}){let o=k(t),c=A(t)===`revoked`;return(0,j.jsxs)(`div`,{className:`ct-nodes__token-row`,children:[(0,j.jsxs)(`span`,{className:`ct-nodes__list-sub`,children:[(0,j.jsx)(`span`,{className:`ct-mono`,children:e}),` · `,t.role,` ·`,` `,(0,j.jsx)(_,{tone:c?`danger`:`ok`,children:A(t)}),` · scopes:`,` `,O(t.scopes),o?` · ${r(o)}`:``]}),(0,j.jsxs)(`span`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,disabled:n,"aria-label":`Rotate ${t.role} token`,onClick:i,children:`Rotate`}),c?null:(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:n,"aria-label":`Revoke ${t.role} token`,onClick:a,children:`Revoke`})]})]})}var V=`__defaults__`;function H(e){return e===`allowlist`||e===`full`||e===`deny`?e:`deny`}function U(e){return e===`always`||e===`off`||e===`on-miss`?e:`on-miss`}function W(e){return{security:H(e?.security),ask:U(e?.ask),askFallback:H(e?.askFallback??`deny`),autoAllowSkills:e?.autoAllowSkills===!0}}function G(e){if(!e||e.kind===`gateway`)return{method:`exec.approvals.get`,params:{}};let t=e.nodeId.trim();return t?{method:`exec.approvals.node.get`,params:{nodeId:t}}:null}function ee(e,t){if(!e||e.kind===`gateway`)return{method:`exec.approvals.set`,params:t};let n=e.nodeId.trim();return n?{method:`exec.approvals.node.set`,params:{...t,nodeId:n}}:null}function te(e){let t={"system.execApprovals.get":!0,"system.execApprovals.set":!0},n=[];for(let r of e){if(!(Array.isArray(r.commands)?r.commands:[]).some(e=>t[String(e)])||!r.nodeId.trim())continue;let e=r.displayName?.trim();n.push({id:r.nodeId,label:!e||e===r.nodeId?r.nodeId:`${e} · ${r.nodeId}`})}return n.sort((e,t)=>e.label.localeCompare(t.label)),n}function ne(e,t){let n=new Map;for(let t of e)t.id.trim()&&n.set(t.id,{id:t.id,name:t.name,isDefault:t.id===`main`});for(let e of Object.keys(t?.agents??{}))n.has(e)||n.set(e,{id:e,isDefault:e===`main`});let r=Array.from(n.values());return r.length===0&&r.push({id:`main`,isDefault:!0}),r.sort((e,t)=>e.isDefault===t.isDefault?(e.name?.trim()||e.id).localeCompare(t.name?.trim()||t.id):e.isDefault?-1:1),r}function re(e,t){return e===`__defaults__`?V:e&&t.some(t=>t.id===e)?e:V}function K(e,t,n){let r=m(e);return f(r,t,n),r}function q(e,t){let n=m(e);return p(n,t),n}var J=[{value:`deny`,label:`Deny`},{value:`allowlist`,label:`Allowlist`},{value:`full`,label:`Full`}],ie=[{value:`off`,label:`Off`},{value:`on-miss`,label:`On miss`},{value:`always`,label:`Always`}],Y=`__default__`;function X({nodes:e}){let t=i(e=>e.request),[n,r]=(0,C.useState)({kind:`gateway`}),[c,l]=(0,C.useState)(null),[u,d]=(0,C.useState)({form:{},dirty:!1}),[f,p]=(0,C.useState)(null),[g,_]=(0,C.useState)(!1),[y,x]=(0,C.useState)(!1),[S,w]=(0,C.useState)(null),T=(0,C.useRef)(0),E=h(`agents.list`,{}),D=te(e),O=n.kind===`gateway`||n.nodeId?.trim()!==``,k=(0,C.useCallback)(async()=>{let e=++T.current,r=G(n);if(_(!0),w(null),!r){w(`Select a node before loading exec approvals.`),_(!1);return}try{let n=await t(r.method,r.params);if(e!==T.current)return;l(n),d({form:m(n.file??{}),dirty:!1})}catch(t){e===T.current&&w(o(t))}finally{e===T.current&&_(!1)}},[t,n]);(0,C.useEffect)(()=>{k()},[k]);let A=(e,t)=>{l(null),d({form:{},dirty:!1}),p(null),r(e===`gateway`?{kind:`gateway`}:{kind:`node`,nodeId:t??``})},M=async()=>{let e=c?.hash;if(!e){w(`Exec approvals hash missing; reload and retry.`);return}x(!0),w(null);try{let r=ee(n,{file:u.form,baseHash:e});if(!r){w(`Select a node before saving exec approvals.`);return}await t(r.method,r.params),d(e=>({...e,dirty:!1})),await k()}catch(e){w(o(e))}finally{x(!1)}},N=W(u.form.defaults),P=ne(E.data?.agents??[],u.form),F=re(f,P),I=F===V,L=I?[`defaults`]:[`agents`,F],R=I?null:u.form.agents?.[F]??null,z=g||y,B=(e,t)=>{d(n=>({form:K(n.form,[...L,e],t),dirty:!0}))},H=e=>{d(t=>({form:q(t.form,[...L,e]),dirty:!0}))},U=[`agents`,F,`allowlist`],X=R?.allowlist??[];return(0,j.jsxs)(v,{title:`Exec approvals`,sub:`Allowlist and approval policy for exec host=gateway/node.`,testId:`exec-approvals-panel`,actions:(0,j.jsx)(s,{variant:`primary`,onClick:()=>void M(),disabled:z||!u.dirty||!O,children:y?`Saving…`:`Save`}),children:[S?(0,j.jsxs)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:[(0,j.jsx)(`span`,{children:S}),(0,j.jsx)(s,{size:`sm`,onClick:()=>void k(),disabled:g,children:`Reload`})]}):null,(0,j.jsxs)(`div`,{className:`ct-nodes__target-row`,children:[(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Host`,(0,j.jsxs)(`select`,{"aria-label":`Exec approvals host`,value:n.kind,disabled:z,onChange:e=>{e.target.value===`node`?A(`node`,n.kind===`node`?n.nodeId:D[0]?.id??``):A(`gateway`,null)},children:[(0,j.jsx)(`option`,{value:`gateway`,children:`Gateway`}),(0,j.jsx)(`option`,{value:`node`,children:`Node`})]})]}),n.kind===`node`?(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Node`,(0,j.jsxs)(`select`,{"aria-label":`Exec approvals node`,value:n.nodeId??``,disabled:z||D.length===0,onChange:e=>A(`node`,e.target.value||null),children:[(0,j.jsx)(`option`,{value:``,children:`Select node`}),D.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}):null]}),n.kind===`node`&&D.length===0?(0,j.jsx)(a,{message:`No nodes advertise exec approvals yet.`}):null,g&&!c?(0,j.jsx)(a,{tone:`loading`,message:`Loading approvals…`}):c?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`ct-nodes__scope-row`,role:`group`,"aria-label":`Exec approvals scope`,children:[(0,j.jsx)(`span`,{className:`ct-nodes__heading`,children:`Scope`}),(0,j.jsx)(b,{label:`Scope`,value:F,options:[{value:V,label:`Defaults`},...P.map(e=>({value:e.id,label:e.name?.trim()?`${e.name} (${e.id})`:e.id}))],onChange:p})]}),(0,j.jsxs)(`dl`,{className:`ct-kv ct-nodes__policy`,children:[(0,j.jsx)(`dt`,{children:`Security`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Security`,disabled:z,value:I?N.security:R?.security??Y,defaultValueText:N.security,showUseDefault:!I,options:J,onChange:e=>{!I&&e===Y?H(`security`):B(`security`,e)}})}),(0,j.jsx)(`dt`,{children:`Ask`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Ask`,disabled:z,value:I?N.ask:R?.ask??Y,defaultValueText:N.ask,showUseDefault:!I,options:ie,onChange:e=>{!I&&e===Y?H(`ask`):B(`ask`,e)}})}),(0,j.jsx)(`dt`,{children:`Ask fallback`}),(0,j.jsx)(`dd`,{children:(0,j.jsx)(Z,{ariaLabel:`Ask fallback`,disabled:z,value:I?N.askFallback:R?.askFallback??Y,defaultValueText:N.askFallback,showUseDefault:!I,options:J,onChange:e=>{!I&&e===Y?H(`askFallback`):B(`askFallback`,e)}})}),(0,j.jsx)(`dt`,{children:`Auto-allow skill CLIs`}),(0,j.jsx)(`dd`,{children:(0,j.jsxs)(`span`,{className:`ct-nodes__check-row`,children:[(0,j.jsx)(`input`,{type:`checkbox`,"aria-label":`Auto-allow skill CLIs`,disabled:z,checked:I?N.autoAllowSkills:R?.autoAllowSkills??N.autoAllowSkills,onChange:e=>B(`autoAllowSkills`,e.target.checked)}),!I&&R?.autoAllowSkills!==void 0?(0,j.jsx)(s,{size:`sm`,disabled:z,onClick:()=>H(`autoAllowSkills`),children:`Use default`}):null]})})]}),I?null:(0,j.jsxs)(`div`,{className:`ct-nodes__allowlist`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__allowlist-head`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:`ct-nodes__heading`,children:`Allowlist`}),(0,j.jsx)(`p`,{className:`ct-nodes__list-sub`,children:`Case-insensitive glob patterns.`})]}),(0,j.jsx)(s,{size:`sm`,disabled:z,onClick:()=>{let e=[...X,{pattern:``}];d(t=>({form:K(t.form,U,e),dirty:!0}))},children:`Add pattern`})]}),X.length===0?(0,j.jsx)(a,{message:`No allowlist entries yet.`}):X.map((e,t)=>(0,j.jsx)(ae,{entry:e,index:t,disabled:z,onPatternChange:e=>{d(n=>({form:K(n.form,[...U,t,`pattern`],e),dirty:!0}))},onRemove:()=>{d(e=>({form:X.length<=1?q(e.form,U):q(e.form,[...U,t]),dirty:!0}))}},e.id??t))]})]}):null]})}function Z({ariaLabel:e,value:t,options:n,showUseDefault:r,defaultValueText:i,disabled:a,onChange:o}){return(0,j.jsxs)(`select`,{"aria-label":e,value:t,disabled:a,onChange:e=>o(e.target.value),children:[r?(0,j.jsxs)(`option`,{value:Y,children:[`Use default (`,i,`)`]}):null,n.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}function ae({entry:e,index:t,disabled:n,onPatternChange:i,onRemove:a}){return(0,j.jsxs)(`div`,{className:`ct-nodes__list-item`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-main`,children:[(0,j.jsxs)(`div`,{className:`ct-nodes__list-sub`,children:[`Last used: `,e.lastUsedAt?r(e.lastUsedAt):`never`]}),e.lastUsedCommand?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:e.lastUsedCommand}):null,e.lastResolvedPath?(0,j.jsx)(`div`,{className:`ct-nodes__list-sub ct-mono`,children:e.lastResolvedPath}):null]}),(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(`input`,{type:`text`,className:`ct-nodes__pattern-input`,"aria-label":`Allowlist pattern ${t+1}`,value:e.pattern??``,disabled:n,onChange:e=>i(e.target.value)}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,disabled:n,onClick:a,children:`Remove`})]})]})}function oe({nodeId:e,paired:t,onClose:n,onRenamed:c}){let l=i(e=>e.request),u=h(`node.describe`,{nodeId:e}),[f,p]=(0,C.useState)(null),[m,g]=(0,C.useState)(!1),[y,b]=(0,C.useState)(null),S=u.data,w=f??(S?.displayName?.trim()||e),E=async()=>{let t=w.trim();if(t){g(!0),b(null);try{await l(`node.rename`,{nodeId:e,displayName:t}),p(null),u.reload(),c()}catch(e){b(o(e))}finally{g(!1)}}};return(0,j.jsx)(v,{title:T({nodeId:e,displayName:S?.displayName}),sub:(0,j.jsx)(`span`,{className:`ct-mono`,children:e}),testId:`node-drawer`,actions:(0,j.jsx)(`button`,{type:`button`,className:`ct-icon-btn`,"aria-label":`Close node details`,onClick:n,children:(0,j.jsx)(d,{name:`x`})}),children:(0,j.jsx)(`div`,{className:`ct-nodes__aside-body`,children:u.error?(0,j.jsx)(a,{tone:`error`,message:u.error,hint:(0,j.jsx)(s,{onClick:u.reload,children:`Retry`})}):u.loading&&!S?(0,j.jsx)(a,{tone:`loading`,message:`Loading node…`}):S?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`div`,{className:`ct-nodes__status-row`,children:[S.connected?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`ok`,label:`Connected`,pulse:!0}),` Connected`]}):(0,j.jsx)(_,{children:`Offline`}),S.paired?(0,j.jsx)(_,{tone:`accent`,children:`Paired`}):null]}),(0,j.jsxs)(`dl`,{className:`ct-kv`,children:[(0,j.jsx)(`dt`,{children:`Platform`}),(0,j.jsx)(`dd`,{children:S.platform??`—`}),(0,j.jsx)(`dt`,{children:`Version`}),(0,j.jsx)(`dd`,{children:S.version??`—`}),(0,j.jsx)(`dt`,{children:`Device`}),(0,j.jsx)(`dd`,{children:S.deviceFamily??`—`}),(0,j.jsx)(`dt`,{children:`Model`}),(0,j.jsx)(`dd`,{children:S.modelIdentifier??`—`}),(0,j.jsx)(`dt`,{children:`IP`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:S.remoteIp??`—`}),(0,j.jsx)(`dt`,{children:`Connected`}),(0,j.jsx)(`dd`,{children:S.connectedAtMs?r(S.connectedAtMs):`—`}),(0,j.jsx)(`dt`,{children:`Caps`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:O(S.caps)}),(0,j.jsx)(`dt`,{children:`Commands`}),(0,j.jsx)(`dd`,{className:`ct-mono`,children:O(S.commands)})]}),t?(0,j.jsxs)(`div`,{className:`ct-nodes__rename`,children:[(0,j.jsxs)(`label`,{className:`ct-nodes__field`,children:[`Display name`,(0,j.jsx)(`input`,{type:`text`,value:w,onChange:e=>p(e.target.value),"aria-label":`Node display name`})]}),(0,j.jsx)(s,{variant:`primary`,onClick:()=>void E(),disabled:m,children:m?`Saving…`:`Rename`})]}):null,y?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:y}):null]}):null})})}function se({nodes:e,loading:t,error:n,selectedNodeId:r,onSelectNode:c,onRefresh:l}){let u=i(e=>e.request),[d,f]=(0,C.useState)(null),[p,m]=(0,C.useState)(!1),[h,g]=(0,C.useState)(null),_=async()=>{if(d){m(!0),g(null);try{await u(d.kind===`approve`?`node.pair.approve`:`node.pair.reject`,{requestId:d.node.pendingRequestId}),f(null),l()}catch(e){g(o(e))}finally{m(!1)}}};return(0,j.jsxs)(v,{title:`Nodes`,sub:`Paired devices and live links.`,testId:`nodes-panel`,actions:(0,j.jsx)(s,{onClick:l,disabled:t,children:t?`Loading…`:`Refresh`}),children:[n?(0,j.jsx)(a,{tone:`error`,message:n,hint:(0,j.jsx)(s,{onClick:l,children:`Retry`})}):t&&e.length===0?(0,j.jsx)(a,{tone:`loading`,message:`Loading nodes…`}):e.length===0?(0,j.jsx)(a,{message:`No nodes found.`}):(0,j.jsx)(y,{label:`Nodes`,rows:e,rowKey:e=>e.nodeId,selectedKey:r,onRowClick:c,columns:[{key:`name`,label:`Node`,render:e=>(0,j.jsxs)(`div`,{className:`ct-cell-stack`,children:[(0,j.jsx)(`span`,{className:`ct-cell-stack__main`,children:T(e)}),(0,j.jsx)(`span`,{className:`ct-cell-stack__sub`,children:e.nodeId})]})},{key:`status`,label:`Status`,render:e=>(0,j.jsx)(ce,{node:e})},{key:`platform`,label:`Platform`,render:e=>(0,j.jsxs)(`div`,{className:`ct-cell-stack`,children:[(0,j.jsx)(`span`,{className:`ct-cell-stack__main`,children:e.platform??`—`}),(0,j.jsx)(`span`,{className:`ct-cell-stack__sub`,children:e.version??``})]})},{key:`ip`,label:`IP`,mono:!0,render:e=>e.remoteIp??`—`},{key:`caps`,label:`Caps`,render:e=>(0,j.jsx)(Q,{values:e.caps})},{key:`commands`,label:`Commands`,render:e=>(0,j.jsx)(Q,{values:e.commands})},{key:`actions`,label:``,render:e=>D(e)?(0,j.jsxs)(`div`,{className:`ct-nodes__row-actions`,children:[(0,j.jsx)(s,{size:`sm`,variant:`primary`,"aria-label":`Approve pairing for ${T(e)}`,onClick:t=>{t.stopPropagation(),f({kind:`approve`,node:e})},children:`Approve`}),(0,j.jsx)(s,{size:`sm`,variant:`danger`,"aria-label":`Reject pairing for ${T(e)}`,onClick:t=>{t.stopPropagation(),f({kind:`reject`,node:e})},children:`Reject`})]}):null}]}),h?(0,j.jsx)(`div`,{className:`ct-nodes__callout`,role:`alert`,children:h}):null,(0,j.jsx)(S,{open:d!==null,title:d?.kind===`approve`?`Approve node pairing`:`Reject node pairing`,body:d?`${d.kind===`approve`?`Approve`:`Reject`} the pairing request from ${T(d.node)} (${d.node.nodeId})?`:``,confirmLabel:d?.kind===`approve`?`Approve`:`Reject`,danger:d?.kind===`reject`,busy:p,bodyClassName:`ct-nodes__confirm-body`,testId:`confirm-node-pairing`,onConfirm:()=>void _(),onCancel:()=>{f(null),g(null)}})]})}function ce({node:e}){return e.connected?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`ok`,label:`Connected`,pulse:!0}),`Connected`]}):D(e)?(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`warn`,label:`Pairing pending`,pulse:!0}),`Pending`]}):(0,j.jsxs)(`span`,{className:`ct-nodes__status`,children:[(0,j.jsx)(x,{tone:`neutral`,label:`Paired offline`}),(0,j.jsx)(_,{children:`Paired`})]})}function Q({values:e}){return!e||e.length===0?(0,j.jsx)(j.Fragment,{children:`—`}):(0,j.jsxs)(`span`,{className:`ct-nodes__chips`,title:O(e),children:[e.slice(0,3).map(e=>(0,j.jsx)(`span`,{className:`ct-nodes__chip`,children:e},e)),e.length>3?(0,j.jsxs)(`span`,{className:`ct-nodes__chip-more`,children:[`+`,e.length-3]}):null]})}var $=[`device.pair.requested`,`device.pair.resolved`,`node.pair.requested`,`node.pair.resolved`];function le(){let e=i(e=>e.request),t=h(`node.list`,{},{refreshMs:g,invalidateOn:$}),n=h(`device.pair.list`,{},{refreshMs:g,invalidateOn:$}),[r,a]=(0,C.useState)(null),o=(0,C.useCallback)(()=>{t.reload(),n.reload(),l.getState().refresh(e)},[t.reload,n.reload,e]);(0,C.useEffect)(()=>{let{subscribe:t}=i.getState(),n=null,r=()=>{n===null&&(n=window.setTimeout(()=>{n=null,!(!u()||i.getState().status!==`connected`)&&l.getState().refresh(e)},500))},a=$.map(e=>t(e,r));return()=>{n!==null&&(window.clearTimeout(n),n=null);for(let e of a)e()}},[e]);let s=w(t.data?.nodes??[]),c=s.find(e=>e.nodeId===r)??null;return(0,j.jsxs)(`div`,{className:`ct-page`,"data-testid":`nodes-view`,children:[(0,j.jsx)(`header`,{className:`ct-page__head`,children:(0,j.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,j.jsx)(`h1`,{className:`ct-page__title`,children:`Nodes`}),(0,j.jsx)(`p`,{className:`ct-page__sub`,children:`Fleet nodes, device pairing and exec approvals.`})]})}),(0,j.jsx)(X,{nodes:s}),(0,j.jsxs)(`div`,{className:c?`ct-nodes__layout ct-nodes__layout--open`:`ct-nodes__layout`,children:[(0,j.jsx)(se,{nodes:s,loading:t.loading,error:t.error,selectedNodeId:r,onSelectNode:e=>a(e.nodeId),onRefresh:o}),c?(0,j.jsx)(oe,{nodeId:c.nodeId,paired:c.paired,onClose:()=>a(null),onRenamed:o},c.nodeId):null]}),(0,j.jsx)(I,{devices:n.data,loading:n.loading,error:n.error,onRefresh:o})]})}export{le as default};
@@ -1 +1 @@
1
- import{_ as e,a as t,c as n,d as r,h as i,i as a,l as o,n as s,r as c,s as l}from"./format-dlOOV12I.js";import{i as u}from"./runs-store-DLIlHRM6.js";import{n as d}from"./links-C1sAzVEH.js";import{a as f}from"./index-OijNknZs.js";import{n as p,t as m}from"./use-gateway-query-CF94JYnM.js";import{t as h}from"./Panel-CyfpswdJ.js";import{t as g}from"./EntityLink-AEBgCNQX.js";import{t as _}from"./Stat-BruDi6qc.js";import{t as v}from"./StatusDot-Cij-6nH8.js";import{n as y,r as b,t as x}from"./usage-range-C-j75vK8.js";import{t as S}from"./UpdatedAgo-DWSnE4WG.js";import{a as C,r as w}from"./run-rows-BYCIH1Sn.js";var T=e(i(),1);function E(e,t){return t===0?`neutral`:e===t?`ok`:e===0?`danger`:`warn`}function D(e){let t=e.channelAccounts??{},n=(e.channelOrder??Object.keys(t)).map(n=>{let r=(t[n]??[]).filter(e=>e.configured!==!1),i=r.filter(e=>e.connected??e.running??!1).length;return{id:n,label:e.channelLabels?.[n]??n,connected:i,configured:r.length,tone:E(i,r.length)}}).filter(e=>e.configured>0),r=n.reduce((e,t)=>e+t.connected,0),i=n.reduce((e,t)=>e+t.configured,0);return{channels:n,connected:r,configured:i,tone:E(r,i)}}var O=n(),k={connected:{label:`Connected`,tone:`ok`},reconnecting:{label:`Reconnecting`,tone:`warn`},offline:{label:`Offline`,tone:`danger`}};function A({loading:e,error:t,empty:n,testId:r}){return t?(0,O.jsx)(l,{tone:`error`,message:`Unavailable right now.`,hint:(0,O.jsx)(`span`,{"data-testid":r,children:t})}):e?(0,O.jsx)(l,{tone:`loading`,message:`Loading…`}):(0,O.jsx)(l,{message:n})}function j(){let e=o(e=>e.status),n=o(e=>e.hello),[i,E]=(0,T.useState)(`24h`),j=b(i),M=p(`status`,{},{refreshMs:m}),N=p(`health`,{},{refreshMs:m}),P=p(`channels.status`,{probe:!1,timeoutMs:8e3},{refreshMs:m}),F=p(`usage.cost`,j,{refreshMs:m}),I=p(`cron.list`,{enabled:`enabled`,sortBy:`nextRunAtMs`,sortDir:`asc`,limit:5},{refreshMs:m}),L=u(e=>e.view),R=f(e=>e),z=r(e=>e.pending),B=r(e=>e.openPanel),V=w(L).filter(e=>e.filter===`running`),H=P.data?D(P.data):null,U=k[e],W=n?.snapshot?.uptimeMs,G=(I.data?.jobs??[]).filter(e=>e.enabled!==!1&&typeof e.state?.nextRunAtMs==`number`),K=F.data?.totals?.missingCostEntries??0;return(0,O.jsxs)(`div`,{className:`ct-page`,"data-testid":`overview-view`,children:[(0,O.jsxs)(`header`,{className:`ct-page__head`,children:[(0,O.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,O.jsx)(`h1`,{className:`ct-page__title`,children:`Overview`}),(0,O.jsx)(`p`,{className:`ct-page__sub`,children:`Health of this installation at a glance.`})]}),(0,O.jsx)(`div`,{className:`ct-segmented`,role:`group`,"aria-label":`Spend range`,children:x.map(e=>(0,O.jsx)(`button`,{type:`button`,className:e===i?`ct-segmented__item ct-segmented__item--active`:`ct-segmented__item`,"aria-pressed":e===i,onClick:()=>E(e),children:y[e]},e))}),(0,O.jsx)(S,{at:M.updatedAt,error:M.error})]}),(0,O.jsxs)(`div`,{className:`ct-stat-grid`,children:[(0,O.jsx)(_,{label:`Gateway`,tone:U.tone,value:U.label,sub:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`ct-mono`,children:n?.server?.version??`—`}),typeof W==`number`?` · up ${c(W)}`:null,N.data?.ok===!0?` · healthy`:null]})}),(0,O.jsx)(_,{label:`Channels`,tone:H?.tone,value:H?`${H.connected}/${H.configured}`:`—`,sub:P.error?`Status unavailable`:(0,O.jsx)(g,{to:d.view(`channels`),children:`Accounts connected`})}),(0,O.jsx)(_,{label:`Active runs`,tone:V.length>0?`accent`:void 0,value:L?V.length:`—`,sub:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(g,{to:d.view(`sessions`),children:`${M.data?.sessions?.count??`—`} sessions`}),` · `,(0,O.jsx)(g,{to:d.runs({filter:`running`}),children:`View running`})]})}),(0,O.jsx)(_,{label:`Spend`,value:s(F.data?.totals?.totalCost),sub:F.error?`Usage unavailable`:(0,O.jsx)(g,{to:d.view(`usage`),children:`${t(F.data?.totals?.totalTokens)} tokens · ${y[i].toLowerCase()}${K>0?` · ${K} unpriced`:``}`})})]}),M.error?(0,O.jsx)(l,{tone:`error`,message:`Gateway status is unavailable.`,hint:(0,O.jsx)(`span`,{"data-testid":`overview-gateway-error`,children:M.error})}):null,(0,O.jsxs)(`div`,{className:`ct-grid`,children:[(0,O.jsx)(h,{className:`ct-span-6`,title:`Active runs`,sub:`Live across all agents`,children:V.length===0?(0,O.jsx)(l,{message:L?`Nothing is running right now.`:`Loading…`}):(0,O.jsx)(`ul`,{className:`ct-list`,children:V.slice(0,5).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:`accent`,label:e.entry.status,pulse:!0}),(0,O.jsx)(g,{to:d.run(e.entry.key),className:`ct-list__main`,children:e.entry.title}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:c(C(e))})]},e.entry.key))})}),(0,O.jsx)(h,{className:`ct-span-6`,title:`Channel health`,sub:`Connected accounts per transport`,testId:`overview-channels`,children:H&&H.channels.length>0?(0,O.jsx)(`ul`,{className:`ct-list`,children:H.channels.map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:e.tone,label:e.label}),(0,O.jsx)(`span`,{className:`ct-list__main`,children:e.label}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:`${e.connected}/${e.configured}`})]},e.id))}):(0,O.jsx)(A,{loading:P.loading,error:P.error,empty:`No channels are configured.`,testId:`overview-channels-error`})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Upcoming automations`,sub:`Next scheduled runs`,children:G.length>0?(0,O.jsx)(`ul`,{className:`ct-list`,children:G.slice(0,5).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(`span`,{className:`ct-list__main`,children:e.name}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:a(e.state?.nextRunAtMs)})]},e.id))}):(0,O.jsx)(A,{loading:I.loading,error:I.error,empty:`No automations are scheduled.`,testId:`overview-cron-error`})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Nodes`,sub:`Paired devices`,children:R.error&&R.paired===0?(0,O.jsx)(A,{loading:!1,error:R.error,empty:``,testId:`overview-nodes-error`}):(0,O.jsxs)(`div`,{className:`ct-stat-grid`,children:[(0,O.jsx)(_,{label:`Connected`,value:R.connected}),(0,O.jsx)(_,{label:`Paired`,value:R.paired})]})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Pending approvals`,sub:`Requested since this console connected`,children:z.length===0?(0,O.jsx)(l,{message:`Nothing is waiting for approval.`}):(0,O.jsx)(`ul`,{className:`ct-list`,children:z.slice(0,3).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:`warn`,label:`Waiting`}),(0,O.jsx)(`button`,{type:`button`,className:`ct-link-btn ct-list__main ct-mono`,onClick:B,children:e.command??`(no command)`}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:e.agentId??``})]},e.id))})})]})]})}export{j as default};
1
+ import{_ as e,a as t,c as n,d as r,h as i,i as a,l as o,n as s,r as c,s as l}from"./format-CGs6a1G6.js";import{i as u}from"./runs-store-DXgNPFWM.js";import{n as d}from"./links-DlVrQOFC.js";import{a as f}from"./index-BvXiY83i.js";import{n as p,t as m}from"./use-gateway-query-D25QZANO.js";import{t as h}from"./Panel-9wOynsWc.js";import{t as g}from"./EntityLink-BO2oG3y8.js";import{t as _}from"./Stat-BZwg1PGE.js";import{t as v}from"./StatusDot-DHhJ1VpB.js";import{n as y,r as b,t as x}from"./usage-range-C-j75vK8.js";import{t as S}from"./UpdatedAgo-Dw3kxb2x.js";import{a as C,r as w}from"./run-rows-Au2UUkD7.js";var T=e(i(),1);function E(e,t){return t===0?`neutral`:e===t?`ok`:e===0?`danger`:`warn`}function D(e){let t=e.channelAccounts??{},n=(e.channelOrder??Object.keys(t)).map(n=>{let r=(t[n]??[]).filter(e=>e.configured!==!1),i=r.filter(e=>e.connected??e.running??!1).length;return{id:n,label:e.channelLabels?.[n]??n,connected:i,configured:r.length,tone:E(i,r.length)}}).filter(e=>e.configured>0),r=n.reduce((e,t)=>e+t.connected,0),i=n.reduce((e,t)=>e+t.configured,0);return{channels:n,connected:r,configured:i,tone:E(r,i)}}var O=n(),k={connected:{label:`Connected`,tone:`ok`},reconnecting:{label:`Reconnecting`,tone:`warn`},offline:{label:`Offline`,tone:`danger`}};function A({loading:e,error:t,empty:n,testId:r}){return t?(0,O.jsx)(l,{tone:`error`,message:`Unavailable right now.`,hint:(0,O.jsx)(`span`,{"data-testid":r,children:t})}):e?(0,O.jsx)(l,{tone:`loading`,message:`Loading…`}):(0,O.jsx)(l,{message:n})}function j(){let e=o(e=>e.status),n=o(e=>e.hello),[i,E]=(0,T.useState)(`24h`),j=b(i),M=p(`status`,{},{refreshMs:m}),N=p(`health`,{},{refreshMs:m}),P=p(`channels.status`,{probe:!1,timeoutMs:8e3},{refreshMs:m}),F=p(`usage.cost`,j,{refreshMs:m}),I=p(`cron.list`,{enabled:`enabled`,sortBy:`nextRunAtMs`,sortDir:`asc`,limit:5},{refreshMs:m}),L=u(e=>e.view),R=f(e=>e),z=r(e=>e.pending),B=r(e=>e.openPanel),V=w(L).filter(e=>e.filter===`running`),H=P.data?D(P.data):null,U=k[e],W=n?.snapshot?.uptimeMs,G=(I.data?.jobs??[]).filter(e=>e.enabled!==!1&&typeof e.state?.nextRunAtMs==`number`),K=F.data?.totals?.missingCostEntries??0;return(0,O.jsxs)(`div`,{className:`ct-page`,"data-testid":`overview-view`,children:[(0,O.jsxs)(`header`,{className:`ct-page__head`,children:[(0,O.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,O.jsx)(`h1`,{className:`ct-page__title`,children:`Overview`}),(0,O.jsx)(`p`,{className:`ct-page__sub`,children:`Health of this installation at a glance.`})]}),(0,O.jsx)(`div`,{className:`ct-segmented`,role:`group`,"aria-label":`Spend range`,children:x.map(e=>(0,O.jsx)(`button`,{type:`button`,className:e===i?`ct-segmented__item ct-segmented__item--active`:`ct-segmented__item`,"aria-pressed":e===i,onClick:()=>E(e),children:y[e]},e))}),(0,O.jsx)(S,{at:M.updatedAt,error:M.error})]}),(0,O.jsxs)(`div`,{className:`ct-stat-grid`,children:[(0,O.jsx)(_,{label:`Gateway`,tone:U.tone,value:U.label,sub:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{className:`ct-mono`,children:n?.server?.version??`—`}),typeof W==`number`?` · up ${c(W)}`:null,N.data?.ok===!0?` · healthy`:null]})}),(0,O.jsx)(_,{label:`Channels`,tone:H?.tone,value:H?`${H.connected}/${H.configured}`:`—`,sub:P.error?`Status unavailable`:(0,O.jsx)(g,{to:d.view(`channels`),children:`Accounts connected`})}),(0,O.jsx)(_,{label:`Active runs`,tone:V.length>0?`accent`:void 0,value:L?V.length:`—`,sub:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(g,{to:d.view(`sessions`),children:`${M.data?.sessions?.count??`—`} sessions`}),` · `,(0,O.jsx)(g,{to:d.runs({filter:`running`}),children:`View running`})]})}),(0,O.jsx)(_,{label:`Spend`,value:s(F.data?.totals?.totalCost),sub:F.error?`Usage unavailable`:(0,O.jsx)(g,{to:d.view(`usage`),children:`${t(F.data?.totals?.totalTokens)} tokens · ${y[i].toLowerCase()}${K>0?` · ${K} unpriced`:``}`})})]}),M.error?(0,O.jsx)(l,{tone:`error`,message:`Gateway status is unavailable.`,hint:(0,O.jsx)(`span`,{"data-testid":`overview-gateway-error`,children:M.error})}):null,(0,O.jsxs)(`div`,{className:`ct-grid`,children:[(0,O.jsx)(h,{className:`ct-span-6`,title:`Active runs`,sub:`Live across all agents`,children:V.length===0?(0,O.jsx)(l,{message:L?`Nothing is running right now.`:`Loading…`}):(0,O.jsx)(`ul`,{className:`ct-list`,children:V.slice(0,5).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:`accent`,label:e.entry.status,pulse:!0}),(0,O.jsx)(g,{to:d.run(e.entry.key),className:`ct-list__main`,children:e.entry.title}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:c(C(e))})]},e.entry.key))})}),(0,O.jsx)(h,{className:`ct-span-6`,title:`Channel health`,sub:`Connected accounts per transport`,testId:`overview-channels`,children:H&&H.channels.length>0?(0,O.jsx)(`ul`,{className:`ct-list`,children:H.channels.map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:e.tone,label:e.label}),(0,O.jsx)(`span`,{className:`ct-list__main`,children:e.label}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:`${e.connected}/${e.configured}`})]},e.id))}):(0,O.jsx)(A,{loading:P.loading,error:P.error,empty:`No channels are configured.`,testId:`overview-channels-error`})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Upcoming automations`,sub:`Next scheduled runs`,children:G.length>0?(0,O.jsx)(`ul`,{className:`ct-list`,children:G.slice(0,5).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(`span`,{className:`ct-list__main`,children:e.name}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:a(e.state?.nextRunAtMs)})]},e.id))}):(0,O.jsx)(A,{loading:I.loading,error:I.error,empty:`No automations are scheduled.`,testId:`overview-cron-error`})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Nodes`,sub:`Paired devices`,children:R.error&&R.paired===0?(0,O.jsx)(A,{loading:!1,error:R.error,empty:``,testId:`overview-nodes-error`}):(0,O.jsxs)(`div`,{className:`ct-stat-grid`,children:[(0,O.jsx)(_,{label:`Connected`,value:R.connected}),(0,O.jsx)(_,{label:`Paired`,value:R.paired})]})}),(0,O.jsx)(h,{className:`ct-span-4`,title:`Pending approvals`,sub:`Requested since this console connected`,children:z.length===0?(0,O.jsx)(l,{message:`Nothing is waiting for approval.`}):(0,O.jsx)(`ul`,{className:`ct-list`,children:z.slice(0,3).map(e=>(0,O.jsxs)(`li`,{className:`ct-list__item`,children:[(0,O.jsx)(v,{tone:`warn`,label:`Waiting`}),(0,O.jsx)(`button`,{type:`button`,className:`ct-link-btn ct-list__main ct-mono`,onClick:B,children:e.command??`(no command)`}),(0,O.jsx)(`span`,{className:`ct-list__meta`,children:e.agentId??``})]},e.id))})})]})]})}export{j as default};
@@ -1 +1 @@
1
- import{c as e}from"./format-dlOOV12I.js";var t=e();function n({title:e,sub:n,actions:r,className:i,children:a,testId:o}){return(0,t.jsxs)(`section`,{className:[`ct-panel`,i].filter(Boolean).join(` `),"aria-label":e,"data-testid":o,children:[(0,t.jsxs)(`header`,{className:`ct-panel__head`,children:[(0,t.jsxs)(`div`,{className:`ct-panel__titles`,children:[(0,t.jsx)(`h2`,{className:`ct-panel__title`,children:e}),n===void 0?null:(0,t.jsx)(`p`,{className:`ct-panel__sub`,children:n})]}),r?(0,t.jsx)(`div`,{className:`ct-panel__actions`,children:r}):null]}),(0,t.jsx)(`div`,{className:`ct-panel__body`,children:a})]})}export{n as t};
1
+ import{c as e}from"./format-CGs6a1G6.js";var t=e();function n({title:e,sub:n,actions:r,className:i,children:a,testId:o}){return(0,t.jsxs)(`section`,{className:[`ct-panel`,i].filter(Boolean).join(` `),"aria-label":e,"data-testid":o,children:[(0,t.jsxs)(`header`,{className:`ct-panel__head`,children:[(0,t.jsxs)(`div`,{className:`ct-panel__titles`,children:[(0,t.jsx)(`h2`,{className:`ct-panel__title`,children:e}),n===void 0?null:(0,t.jsx)(`p`,{className:`ct-panel__sub`,children:n})]}),r?(0,t.jsx)(`div`,{className:`ct-panel__actions`,children:r}):null]}),(0,t.jsx)(`div`,{className:`ct-panel__body`,children:a})]})}export{n as t};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,s as r,t as i}from"./format-dlOOV12I.js";var a=e(n(),1),o=t();function s({host:e,label:t,mount:n,props:s}){let c=(0,a.useRef)(null),[l,u]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let t=c.current;if(!t)return;u(null);let r=new AbortController,a=null;try{let i=n(t,{host:e,signal:r.signal,props:s});i&&typeof i.dispose==`function`&&(a=i.dispose)}catch(e){u(i(e))}return()=>{r.abort();try{a?.()}catch{}t.replaceChildren()}},[e,n,JSON.stringify(s)]),l===null?(0,o.jsx)(`div`,{ref:c,className:`ct-plugin-mount`}):(0,o.jsx)(r,{tone:`error`,message:`${t} failed to render.`,hint:l})}export{s as t};
1
+ import{_ as e,c as t,h as n,s as r,t as i}from"./format-CGs6a1G6.js";var a=e(n(),1),o=t();function s({host:e,label:t,mount:n,props:s}){let c=(0,a.useRef)(null),[l,u]=(0,a.useState)(null);return(0,a.useEffect)(()=>{let t=c.current;if(!t)return;u(null);let r=new AbortController,a=null;try{let i=n(t,{host:e,signal:r.signal,props:s});i&&typeof i.dispose==`function`&&(a=i.dispose)}catch(e){u(i(e))}return()=>{r.abort();try{a?.()}catch{}t.replaceChildren()}},[e,n,JSON.stringify(s)]),l===null?(0,o.jsx)(`div`,{ref:c,className:`ct-plugin-mount`}):(0,o.jsx)(r,{tone:`error`,message:`${t} failed to render.`,hint:l})}export{s as t};
@@ -1 +1 @@
1
- import{c as e,s as t}from"./format-dlOOV12I.js";import{o as n}from"./links-C1sAzVEH.js";import{s as r}from"./index-OijNknZs.js";import{t as i}from"./PluginMount-C1HeSpS9.js";var a=e();function o(){let e=n(),o=r(e=>e.status),s=r(e=>e.pages),c=e.params.get(`plugin`),l=e.params.get(`page`),u=c!==null&&l!==null?s.find(e=>e.pluginId===c&&e.page.id===l)??null:null;if(o===`idle`||o===`loading`)return(0,a.jsx)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:(0,a.jsx)(t,{tone:`loading`,message:`Loading plugin UI…`})});if(u===null)return(0,a.jsx)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:(0,a.jsx)(t,{message:`This plugin page is not available.`,hint:`Check Debug for plugin UI load failures, or add the plugin to gateway.controlUiV2.pluginUi.allow.`})});let d={};return e.params.forEach((e,t)=>{t!==`plugin`&&t!==`page`&&(d[t]=e)}),(0,a.jsxs)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:[(0,a.jsx)(`header`,{className:`ct-page__head`,children:(0,a.jsx)(`div`,{className:`ct-page__head-text`,children:(0,a.jsx)(`h1`,{className:`ct-page__title`,children:u.page.label})})}),(0,a.jsx)(i,{host:u.host,label:u.page.label,mount:u.page.mount,props:d},`${u.pluginId}/${u.page.id}/${JSON.stringify(d)}`)]})}export{o as default};
1
+ import{c as e,s as t}from"./format-CGs6a1G6.js";import{o as n}from"./links-DlVrQOFC.js";import{s as r}from"./index-BvXiY83i.js";import{t as i}from"./PluginMount-6N20-nhI.js";var a=e();function o(){let e=n(),o=r(e=>e.status),s=r(e=>e.pages),c=e.params.get(`plugin`),l=e.params.get(`page`),u=c!==null&&l!==null?s.find(e=>e.pluginId===c&&e.page.id===l)??null:null;if(o===`idle`||o===`loading`)return(0,a.jsx)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:(0,a.jsx)(t,{tone:`loading`,message:`Loading plugin UI…`})});if(u===null)return(0,a.jsx)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:(0,a.jsx)(t,{message:`This plugin page is not available.`,hint:`Check Debug for plugin UI load failures, or add the plugin to gateway.controlUiV2.pluginUi.allow.`})});let d={};return e.params.forEach((e,t)=>{t!==`plugin`&&t!==`page`&&(d[t]=e)}),(0,a.jsxs)(`div`,{className:`ct-page`,"data-testid":`plugin-page-view`,children:[(0,a.jsx)(`header`,{className:`ct-page__head`,children:(0,a.jsx)(`div`,{className:`ct-page__head-text`,children:(0,a.jsx)(`h1`,{className:`ct-page__title`,children:u.page.label})})}),(0,a.jsx)(i,{host:u.host,label:u.page.label,mount:u.page.mount,props:d},`${u.pluginId}/${u.page.id}/${JSON.stringify(d)}`)]})}export{o as default};
@@ -1 +1 @@
1
- import{c as e}from"./format-dlOOV12I.js";import{s as t}from"./index-OijNknZs.js";import{t as n}from"./PluginMount-C1HeSpS9.js";var r=e();function i(e){let n=[...t(e=>e.panels)].toSorted((e,t)=>e.pluginId.localeCompare(t.pluginId));return e.placement===`session`?(0,r.jsx)(s,{entries:n.filter(a),props:e.props}):(0,r.jsx)(s,{entries:n.filter(o),props:e.props})}function a(e){return e.panel.placement===`session`}function o(e){return e.panel.placement===`run`}function s({entries:e,props:t}){return e.length===0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`h3`,{className:`ct-inspector__heading`,children:`Plugins`}),e.map(e=>(0,r.jsxs)(`details`,{open:!0,className:`ct-plugin-panel`,children:[(0,r.jsxs)(`summary`,{children:[(0,r.jsx)(`span`,{className:`ct-plugin-panel__label`,children:e.panel.label}),(0,r.jsx)(`span`,{className:`ct-plugin-panel__plugin`,children:e.pluginName})]}),(0,r.jsx)(n,{host:e.host,label:e.panel.label,mount:e.panel.mount,props:t},`${e.pluginId}/${e.panel.id}/${JSON.stringify(t)}`)]},`${e.pluginId}/${e.panel.id}`))]})}export{i as t};
1
+ import{c as e}from"./format-CGs6a1G6.js";import{s as t}from"./index-BvXiY83i.js";import{t as n}from"./PluginMount-6N20-nhI.js";var r=e();function i(e){let n=[...t(e=>e.panels)].toSorted((e,t)=>e.pluginId.localeCompare(t.pluginId));return e.placement===`session`?(0,r.jsx)(s,{entries:n.filter(a),props:e.props}):(0,r.jsx)(s,{entries:n.filter(o),props:e.props})}function a(e){return e.panel.placement===`session`}function o(e){return e.panel.placement===`run`}function s({entries:e,props:t}){return e.length===0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(`h3`,{className:`ct-inspector__heading`,children:`Plugins`}),e.map(e=>(0,r.jsxs)(`details`,{open:!0,className:`ct-plugin-panel`,children:[(0,r.jsxs)(`summary`,{children:[(0,r.jsx)(`span`,{className:`ct-plugin-panel__label`,children:e.panel.label}),(0,r.jsx)(`span`,{className:`ct-plugin-panel__plugin`,children:e.pluginName})]}),(0,r.jsx)(n,{host:e.host,label:e.panel.label,mount:e.panel.mount,props:t},`${e.pluginId}/${e.panel.id}/${JSON.stringify(t)}`)]},`${e.pluginId}/${e.panel.id}`))]})}export{i as t};
@@ -1 +1 @@
1
- import{_ as e,c as t,d as n,h as r,i,l as a,o,r as s,s as c,t as l}from"./format-dlOOV12I.js";import{i as u,o as d}from"./runs-store-DLIlHRM6.js";import{a as f,n as p,o as m}from"./links-C1sAzVEH.js";import{t as h}from"./Button-DL76WqX4.js";import{t as g}from"./Dialog-rIrrCPSu.js";import{n as _,t as v}from"./index-OijNknZs.js";import{n as y,t as b}from"./use-gateway-query-CF94JYnM.js";import{t as x}from"./Badge-4n2tRQ02.js";import{t as S}from"./Panel-CyfpswdJ.js";import{t as C}from"./EntityLink-AEBgCNQX.js";import{t as w}from"./DataTable-lEkd1R85.js";import{t as T}from"./FilterPills-HxAXXDO8.js";import{t as E}from"./StatusDot-Cij-6nH8.js";import{t as D}from"./UpdatedAgo-DWSnE4WG.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./run-rows-BYCIH1Sn.js";import{t as P}from"./PluginPanels-DdDZQ_Dn.js";var F=e(r(),1),I=t();function L(e,t){let n=a(e=>e.request),r=a(e=>e.status===`connected`),[i,o]=(0,F.useState)([]);return(0,F.useEffect)(()=>{o([])},[e]),(0,F.useEffect)(()=>{if(!e||!r)return;let t=!1;return n(`sessions.runs.events`,{sessionRunId:e}).then(e=>{t||o((e.events??[]).map(e=>({id:e.eventId,at:e.createdAt,label:e.eventType})))}).catch(()=>{}),()=>{t=!0}},[n,e,t,r]),i}function R(e,t){return e.task?e.events.map(e=>({id:e.eventId,at:e.createdAt,label:e.eventType})):t}function z({row:e,detail:t,onClose:r}){let d=a(e=>e.request),f=u(e=>e.refresh),m=n(e=>e.pending),[y,b]=(0,F.useState)(!1),[w,T]=(0,F.useState)(!1),[E,D]=(0,F.useState)(null),k=R(t,L(e.sessionRunId,e.entry.changedAt)),j=e.sessionKey?m.filter(t=>t.sessionKey===e.sessionKey):[],M=e.entry.kind===`session`&&e.filter===`running`&&e.sessionKey,z=e.entry.kind===`session`&&e.entry.status===`needs_recovery_decision`&&e.decisionVersion!==null,B=async(e,t)=>{T(!0),D(null);try{await d(e,t),await f()}catch(e){D(l(e))}finally{T(!1)}},V=t.session?.model,H=[[`Agent`,e.agent?(0,I.jsx)(C,{to:p.agent(e.agent),children:e.agent}):`—`],[`Kind`,e.kind],[`Started`,i(e.startedAt)],[`Duration`,s(O(e))],[`Status`,e.entry.status]];return V&&H.push([`Model`,V]),(0,I.jsxs)(S,{className:`ct-inspector`,title:e.entry.title,sub:(0,I.jsx)(`span`,{className:`ct-mono`,children:e.sessionKey??e.entry.subtitle}),testId:`run-inspector`,actions:(0,I.jsx)(`button`,{type:`button`,className:`ct-icon-btn`,"aria-label":`Close run`,onClick:r,children:(0,I.jsx)(v,{name:`x`})}),children:[(0,I.jsxs)(`div`,{className:`ct-inspector__body`,children:[(0,I.jsx)(x,{tone:A[e.filter],children:N[e.filter]}),t.loading?(0,I.jsx)(c,{tone:`loading`,message:`Loading run…`}):null,t.error?(0,I.jsx)(c,{tone:`error`,message:t.error}):null,(0,I.jsx)(`dl`,{className:`ct-kv`,children:H.map(([e,t])=>(0,I.jsxs)(`div`,{className:`ct-kv__row`,children:[(0,I.jsx)(`dt`,{children:e}),(0,I.jsx)(`dd`,{children:t})]},e))}),e.sessionKey?(0,I.jsxs)(`div`,{className:`ct-inspector__links`,children:[(0,I.jsx)(C,{to:p.session(e.sessionKey),children:e.sessionKey}),e.runId?(0,I.jsx)(C,{to:p.session(e.sessionKey,{run:e.runId}),children:`Transcript`}):null]}):null,j.map(e=>(0,I.jsxs)(`div`,{className:`ct-approval`,"data-testid":`run-approval`,children:[(0,I.jsx)(`code`,{className:`ct-approval__command`,children:e.command??`(no command)`}),(0,I.jsx)(_,{approval:e})]},e.id)),(0,I.jsxs)(`div`,{className:`ct-inspector__actions`,children:[M?(0,I.jsxs)(h,{variant:`danger`,disabled:w,onClick:()=>b(!0),children:[(0,I.jsx)(v,{name:`stop`,size:15}),`Abort run`]}):null,z?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{variant:`primary`,disabled:w,onClick:()=>void B(`sessions.runs.continue`,{sessionRunId:e.sessionRunId,expectedDecisionVersion:e.decisionVersion}),children:`Continue run`}),(0,I.jsx)(h,{variant:`danger`,disabled:w,onClick:()=>void B(`sessions.runs.cancel`,{sessionRunId:e.sessionRunId,expectedDecisionVersion:e.decisionVersion}),children:`Cancel run`})]}):null]}),E?(0,I.jsx)(`p`,{className:`ct-approval__error`,role:`alert`,children:E}):null,(0,I.jsx)(`h3`,{className:`ct-inspector__heading`,children:`Timeline`}),k.length===0?(0,I.jsx)(c,{message:`No recorded events for this run.`}):(0,I.jsx)(`ol`,{className:`ct-timeline`,children:k.map(e=>(0,I.jsxs)(`li`,{className:`ct-timeline__item`,children:[(0,I.jsx)(`span`,{className:`ct-timeline__time ct-mono`,children:new Date(o(e.at)??0).toLocaleTimeString(`en-AU`)}),(0,I.jsx)(`span`,{className:`ct-timeline__label`,children:e.label})]},e.id))}),(0,I.jsx)(P,{placement:`run`,props:{sessionKey:e.sessionKey,runId:e.runId,sessionRunId:e.sessionRunId}})]}),(0,I.jsx)(g,{open:y,title:`Abort run?`,width:`sm`,onClose:()=>b(!1),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{onClick:()=>b(!1),children:`Keep running`}),(0,I.jsx)(h,{variant:`danger`,disabled:w,onClick:()=>{b(!1),B(`sessions.abort`,{key:e.sessionKey,...e.runId?{runId:e.runId}:{}})},children:`Abort run`})]}),children:(0,I.jsx)(`p`,{children:`The agent stops this turn now. Anything it already replied stays in the transcript.`})})]})}var B=[`all`,`queued`,`running`,`needs`,`failed`,`done`],V=100,H=[{key:`status`,label:`Status`,render:e=>(0,I.jsxs)(`span`,{className:`ct-run-status`,children:[(0,I.jsx)(E,{tone:A[e.filter],label:e.entry.status,pulse:e.filter===`running`}),(0,I.jsx)(x,{tone:A[e.filter],children:N[e.filter]})]})},{key:`run`,label:`Run`,render:e=>(0,I.jsxs)(`span`,{className:`ct-cell-stack`,children:[(0,I.jsx)(`span`,{className:`ct-cell-stack__main`,children:e.entry.title}),(0,I.jsx)(`span`,{className:`ct-cell-stack__sub ct-mono`,children:e.sessionKey??e.entry.subtitle})]})},{key:`agent`,label:`Agent`,render:e=>e.agent??`—`},{key:`kind`,label:`Kind`,render:e=>e.kind},{key:`started`,label:`Started`,render:e=>i(e.startedAt)},{key:`duration`,label:`Duration`,align:`end`,mono:!0,render:e=>s(O(e))}];function U(e){return e!==null&&B.includes(e)}function W(){let e=m(),t=u(e=>e.view),n=u(e=>e.select),r=u(e=>e.loadMore),i=u(e=>e.refresh),a=e.params.get(`run`),o=e.params.get(`session`)||null,s=e.params.get(`agent`)||null,l=e.params.get(`filter`),p=U(l)?l:`all`,g=o!==null||s!==null,_=y(`sessions.runs.list`,{...o?{sessionKey:o}:{},...s?{agentId:s}:{},limit:100},{enabled:g,invalidateOn:[`runs.invalidated`],refreshMs:b});(0,F.useEffect)(()=>{n(a)},[n,a]);let x=(0,F.useMemo)(()=>g?k(_.data?.runs??[]):M(t),[g,_.data,t]),C=p===`all`?x:x.filter(e=>e.filter===p),E=(0,F.useRef)(null),O=null;if(a){let e=x.find(e=>e.entry.key===a)??null;e?(E.current=e,O=e):E.current?.entry.key===a?O=E.current:t?.detail.key===a&&t.detail.session&&(O=j(d(t.detail.session),t.detail.session))}let A=e=>{let t={},n=e.filter??p;n!==`all`&&(t.filter=n);let r=e.session===void 0?o:e.session;r&&(t.session=r);let i=e.agent===void 0?s:e.agent;i&&(t.agent=i);let c=e.run===void 0?a:e.run;c&&(t.run=c),f(`runs`,t)},P=t?Object.entries(t.lists).filter(([,e])=>e.error!==null):[],L=P.some(([,e])=>e.errorCode===`UNAVAILABLE`),R=P.filter(([,e])=>e.errorCode!==`UNAVAILABLE`),V=t?Object.values(t.lists).some(e=>e.cursor!==null):!1;return(0,I.jsxs)(`div`,{className:`ct-page`,"data-testid":`runs-view`,children:[(0,I.jsxs)(`header`,{className:`ct-page__head`,children:[(0,I.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,I.jsx)(`h1`,{className:`ct-page__title`,children:`Runs`}),(0,I.jsx)(`p`,{className:`ct-page__sub`,children:`Agent turns and task runs across this gateway, live. Select a run to inspect it.`})]}),(0,I.jsx)(D,{at:g?_.updatedAt:t?.lastReconciledAt??null,error:g?_.error:R[0]?.[1].error??null}),(0,I.jsxs)(h,{onClick:()=>{i(),g&&_.reload()},disabled:t?.refreshing,children:[(0,I.jsx)(v,{name:`refresh`,size:15}),`Refresh`]})]}),(0,I.jsxs)(`div`,{className:`ct-toolbar`,children:[(0,I.jsx)(T,{label:`Filter runs`,value:p,onChange:e=>A({filter:e,run:null}),options:B.map(e=>({value:e,label:N[e],count:e===`all`?x.length:x.filter(t=>t.filter===e).length}))}),o?(0,I.jsxs)(`span`,{className:`ct-chip`,children:[`Session `,(0,I.jsx)(`span`,{className:`ct-chip__value`,children:o}),(0,I.jsx)(`button`,{type:`button`,className:`ct-chip__clear`,"aria-label":`Show runs for every session`,onClick:()=>A({session:null,run:null}),children:(0,I.jsx)(v,{name:`x`,size:12})})]}):null,s?(0,I.jsxs)(`span`,{className:`ct-chip`,children:[`Agent `,(0,I.jsx)(`span`,{className:`ct-chip__value`,children:s}),(0,I.jsx)(`button`,{type:`button`,className:`ct-chip__clear`,"aria-label":`Show runs for every agent`,onClick:()=>A({agent:null,run:null}),children:(0,I.jsx)(v,{name:`x`,size:12})})]}):null]}),!g&&L?(0,I.jsx)(c,{message:`Queued and task runs are not available on this gateway.`,hint:`They need SQLite or Postgres session storage (session.storage.backend). Agent turns still show below.`}):null,!g&&R.map(([e,t])=>(0,I.jsx)(c,{tone:`error`,message:`Some ${e===`sessions`?`agent`:`task`} runs could not be listed.`,hint:t.error},e)),(0,I.jsxs)(`div`,{className:O?`ct-split ct-split--open`:`ct-split`,children:[(0,I.jsx)(S,{title:`${N[p]} runs`,sub:`${C.length} shown`,children:g?_.error&&!_.data?(0,I.jsx)(c,{tone:`error`,message:`Runs could not be listed.`,hint:_.error}):_.loading&&!_.data?(0,I.jsx)(c,{tone:`loading`,message:`Loading runs…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{label:`Runs`,columns:H,rows:C,rowKey:e=>e.entry.key,selectedKey:a,onRowClick:e=>A({run:e.entry.key}),empty:(0,I.jsx)(c,{message:`No runs match this filter.`,hint:`Runs appear here as agents and scheduled tasks start working.`})}),_.data?.nextCursor?(0,I.jsxs)(`p`,{className:`ct-scoped-note`,children:[`Showing the `,100,` most recent runs.`]}):null]}):t===null?(0,I.jsx)(c,{tone:`loading`,message:`Loading runs…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{label:`Runs`,columns:H,rows:C,rowKey:e=>e.entry.key,selectedKey:a,onRowClick:e=>A({run:e.entry.key}),empty:(0,I.jsx)(c,{message:`No runs match this filter.`,hint:`Runs appear here as agents and scheduled tasks start working.`})}),V?(0,I.jsx)(`div`,{className:`ct-load-more`,children:(0,I.jsx)(h,{size:`sm`,onClick:()=>{for(let e of[`queued`,`tasks`,`sessions`])t?.lists[e].cursor&&r(e)},children:`Load more`})}):null]})}),O&&t?(0,I.jsx)(z,{row:O,detail:t.detail,onClose:()=>A({run:null})}):null]})]})}export{V as SCOPED_RUNS_LIMIT,W as default};
1
+ import{_ as e,c as t,d as n,h as r,i,l as a,o,r as s,s as c,t as l}from"./format-CGs6a1G6.js";import{i as u,o as d}from"./runs-store-DXgNPFWM.js";import{a as f,n as p,o as m}from"./links-DlVrQOFC.js";import{t as h}from"./Button-CGdLofSY.js";import{t as g}from"./Dialog-CQE8Pvh6.js";import{n as _,t as v}from"./index-BvXiY83i.js";import{n as y,t as b}from"./use-gateway-query-D25QZANO.js";import{t as x}from"./Badge-CB5TWfdz.js";import{t as S}from"./Panel-9wOynsWc.js";import{t as C}from"./EntityLink-BO2oG3y8.js";import{t as w}from"./DataTable-CSi930kO.js";import{t as T}from"./FilterPills-9pNaAyrL.js";import{t as E}from"./StatusDot-DHhJ1VpB.js";import{t as D}from"./UpdatedAgo-Dw3kxb2x.js";import{a as O,i as k,n as A,o as j,r as M,t as N}from"./run-rows-Au2UUkD7.js";import{t as P}from"./PluginPanels-DulRlgcm.js";var F=e(r(),1),I=t();function L(e,t){let n=a(e=>e.request),r=a(e=>e.status===`connected`),[i,o]=(0,F.useState)([]);return(0,F.useEffect)(()=>{o([])},[e]),(0,F.useEffect)(()=>{if(!e||!r)return;let t=!1;return n(`sessions.runs.events`,{sessionRunId:e}).then(e=>{t||o((e.events??[]).map(e=>({id:e.eventId,at:e.createdAt,label:e.eventType})))}).catch(()=>{}),()=>{t=!0}},[n,e,t,r]),i}function R(e,t){return e.task?e.events.map(e=>({id:e.eventId,at:e.createdAt,label:e.eventType})):t}function z({row:e,detail:t,onClose:r}){let d=a(e=>e.request),f=u(e=>e.refresh),m=n(e=>e.pending),[y,b]=(0,F.useState)(!1),[w,T]=(0,F.useState)(!1),[E,D]=(0,F.useState)(null),k=R(t,L(e.sessionRunId,e.entry.changedAt)),j=e.sessionKey?m.filter(t=>t.sessionKey===e.sessionKey):[],M=e.entry.kind===`session`&&e.filter===`running`&&e.sessionKey,z=e.entry.kind===`session`&&e.entry.status===`needs_recovery_decision`&&e.decisionVersion!==null,B=async(e,t)=>{T(!0),D(null);try{await d(e,t),await f()}catch(e){D(l(e))}finally{T(!1)}},V=t.session?.model,H=[[`Agent`,e.agent?(0,I.jsx)(C,{to:p.agent(e.agent),children:e.agent}):`—`],[`Kind`,e.kind],[`Started`,i(e.startedAt)],[`Duration`,s(O(e))],[`Status`,e.entry.status]];return V&&H.push([`Model`,V]),(0,I.jsxs)(S,{className:`ct-inspector`,title:e.entry.title,sub:(0,I.jsx)(`span`,{className:`ct-mono`,children:e.sessionKey??e.entry.subtitle}),testId:`run-inspector`,actions:(0,I.jsx)(`button`,{type:`button`,className:`ct-icon-btn`,"aria-label":`Close run`,onClick:r,children:(0,I.jsx)(v,{name:`x`})}),children:[(0,I.jsxs)(`div`,{className:`ct-inspector__body`,children:[(0,I.jsx)(x,{tone:A[e.filter],children:N[e.filter]}),t.loading?(0,I.jsx)(c,{tone:`loading`,message:`Loading run…`}):null,t.error?(0,I.jsx)(c,{tone:`error`,message:t.error}):null,(0,I.jsx)(`dl`,{className:`ct-kv`,children:H.map(([e,t])=>(0,I.jsxs)(`div`,{className:`ct-kv__row`,children:[(0,I.jsx)(`dt`,{children:e}),(0,I.jsx)(`dd`,{children:t})]},e))}),e.sessionKey?(0,I.jsxs)(`div`,{className:`ct-inspector__links`,children:[(0,I.jsx)(C,{to:p.session(e.sessionKey),children:e.sessionKey}),e.runId?(0,I.jsx)(C,{to:p.session(e.sessionKey,{run:e.runId}),children:`Transcript`}):null]}):null,j.map(e=>(0,I.jsxs)(`div`,{className:`ct-approval`,"data-testid":`run-approval`,children:[(0,I.jsx)(`code`,{className:`ct-approval__command`,children:e.command??`(no command)`}),(0,I.jsx)(_,{approval:e})]},e.id)),(0,I.jsxs)(`div`,{className:`ct-inspector__actions`,children:[M?(0,I.jsxs)(h,{variant:`danger`,disabled:w,onClick:()=>b(!0),children:[(0,I.jsx)(v,{name:`stop`,size:15}),`Abort run`]}):null,z?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{variant:`primary`,disabled:w,onClick:()=>void B(`sessions.runs.continue`,{sessionRunId:e.sessionRunId,expectedDecisionVersion:e.decisionVersion}),children:`Continue run`}),(0,I.jsx)(h,{variant:`danger`,disabled:w,onClick:()=>void B(`sessions.runs.cancel`,{sessionRunId:e.sessionRunId,expectedDecisionVersion:e.decisionVersion}),children:`Cancel run`})]}):null]}),E?(0,I.jsx)(`p`,{className:`ct-approval__error`,role:`alert`,children:E}):null,(0,I.jsx)(`h3`,{className:`ct-inspector__heading`,children:`Timeline`}),k.length===0?(0,I.jsx)(c,{message:`No recorded events for this run.`}):(0,I.jsx)(`ol`,{className:`ct-timeline`,children:k.map(e=>(0,I.jsxs)(`li`,{className:`ct-timeline__item`,children:[(0,I.jsx)(`span`,{className:`ct-timeline__time ct-mono`,children:new Date(o(e.at)??0).toLocaleTimeString(`en-AU`)}),(0,I.jsx)(`span`,{className:`ct-timeline__label`,children:e.label})]},e.id))}),(0,I.jsx)(P,{placement:`run`,props:{sessionKey:e.sessionKey,runId:e.runId,sessionRunId:e.sessionRunId}})]}),(0,I.jsx)(g,{open:y,title:`Abort run?`,width:`sm`,onClose:()=>b(!1),footer:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(h,{onClick:()=>b(!1),children:`Keep running`}),(0,I.jsx)(h,{variant:`danger`,disabled:w,onClick:()=>{b(!1),B(`sessions.abort`,{key:e.sessionKey,...e.runId?{runId:e.runId}:{}})},children:`Abort run`})]}),children:(0,I.jsx)(`p`,{children:`The agent stops this turn now. Anything it already replied stays in the transcript.`})})]})}var B=[`all`,`queued`,`running`,`needs`,`failed`,`done`],V=100,H=[{key:`status`,label:`Status`,render:e=>(0,I.jsxs)(`span`,{className:`ct-run-status`,children:[(0,I.jsx)(E,{tone:A[e.filter],label:e.entry.status,pulse:e.filter===`running`}),(0,I.jsx)(x,{tone:A[e.filter],children:N[e.filter]})]})},{key:`run`,label:`Run`,render:e=>(0,I.jsxs)(`span`,{className:`ct-cell-stack`,children:[(0,I.jsx)(`span`,{className:`ct-cell-stack__main`,children:e.entry.title}),(0,I.jsx)(`span`,{className:`ct-cell-stack__sub ct-mono`,children:e.sessionKey??e.entry.subtitle})]})},{key:`agent`,label:`Agent`,render:e=>e.agent??`—`},{key:`kind`,label:`Kind`,render:e=>e.kind},{key:`started`,label:`Started`,render:e=>i(e.startedAt)},{key:`duration`,label:`Duration`,align:`end`,mono:!0,render:e=>s(O(e))}];function U(e){return e!==null&&B.includes(e)}function W(){let e=m(),t=u(e=>e.view),n=u(e=>e.select),r=u(e=>e.loadMore),i=u(e=>e.refresh),a=e.params.get(`run`),o=e.params.get(`session`)||null,s=e.params.get(`agent`)||null,l=e.params.get(`filter`),p=U(l)?l:`all`,g=o!==null||s!==null,_=y(`sessions.runs.list`,{...o?{sessionKey:o}:{},...s?{agentId:s}:{},limit:100},{enabled:g,invalidateOn:[`runs.invalidated`],refreshMs:b});(0,F.useEffect)(()=>{n(a)},[n,a]);let x=(0,F.useMemo)(()=>g?k(_.data?.runs??[]):M(t),[g,_.data,t]),C=p===`all`?x:x.filter(e=>e.filter===p),E=(0,F.useRef)(null),O=null;if(a){let e=x.find(e=>e.entry.key===a)??null;e?(E.current=e,O=e):E.current?.entry.key===a?O=E.current:t?.detail.key===a&&t.detail.session&&(O=j(d(t.detail.session),t.detail.session))}let A=e=>{let t={},n=e.filter??p;n!==`all`&&(t.filter=n);let r=e.session===void 0?o:e.session;r&&(t.session=r);let i=e.agent===void 0?s:e.agent;i&&(t.agent=i);let c=e.run===void 0?a:e.run;c&&(t.run=c),f(`runs`,t)},P=t?Object.entries(t.lists).filter(([,e])=>e.error!==null):[],L=P.some(([,e])=>e.errorCode===`UNAVAILABLE`),R=P.filter(([,e])=>e.errorCode!==`UNAVAILABLE`),V=t?Object.values(t.lists).some(e=>e.cursor!==null):!1;return(0,I.jsxs)(`div`,{className:`ct-page`,"data-testid":`runs-view`,children:[(0,I.jsxs)(`header`,{className:`ct-page__head`,children:[(0,I.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,I.jsx)(`h1`,{className:`ct-page__title`,children:`Runs`}),(0,I.jsx)(`p`,{className:`ct-page__sub`,children:`Agent turns and task runs across this gateway, live. Select a run to inspect it.`})]}),(0,I.jsx)(D,{at:g?_.updatedAt:t?.lastReconciledAt??null,error:g?_.error:R[0]?.[1].error??null}),(0,I.jsxs)(h,{onClick:()=>{i(),g&&_.reload()},disabled:t?.refreshing,children:[(0,I.jsx)(v,{name:`refresh`,size:15}),`Refresh`]})]}),(0,I.jsxs)(`div`,{className:`ct-toolbar`,children:[(0,I.jsx)(T,{label:`Filter runs`,value:p,onChange:e=>A({filter:e,run:null}),options:B.map(e=>({value:e,label:N[e],count:e===`all`?x.length:x.filter(t=>t.filter===e).length}))}),o?(0,I.jsxs)(`span`,{className:`ct-chip`,children:[`Session `,(0,I.jsx)(`span`,{className:`ct-chip__value`,children:o}),(0,I.jsx)(`button`,{type:`button`,className:`ct-chip__clear`,"aria-label":`Show runs for every session`,onClick:()=>A({session:null,run:null}),children:(0,I.jsx)(v,{name:`x`,size:12})})]}):null,s?(0,I.jsxs)(`span`,{className:`ct-chip`,children:[`Agent `,(0,I.jsx)(`span`,{className:`ct-chip__value`,children:s}),(0,I.jsx)(`button`,{type:`button`,className:`ct-chip__clear`,"aria-label":`Show runs for every agent`,onClick:()=>A({agent:null,run:null}),children:(0,I.jsx)(v,{name:`x`,size:12})})]}):null]}),!g&&L?(0,I.jsx)(c,{message:`Queued and task runs are not available on this gateway.`,hint:`They need SQLite or Postgres session storage (session.storage.backend). Agent turns still show below.`}):null,!g&&R.map(([e,t])=>(0,I.jsx)(c,{tone:`error`,message:`Some ${e===`sessions`?`agent`:`task`} runs could not be listed.`,hint:t.error},e)),(0,I.jsxs)(`div`,{className:O?`ct-split ct-split--open`:`ct-split`,children:[(0,I.jsx)(S,{title:`${N[p]} runs`,sub:`${C.length} shown`,children:g?_.error&&!_.data?(0,I.jsx)(c,{tone:`error`,message:`Runs could not be listed.`,hint:_.error}):_.loading&&!_.data?(0,I.jsx)(c,{tone:`loading`,message:`Loading runs…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{label:`Runs`,columns:H,rows:C,rowKey:e=>e.entry.key,selectedKey:a,onRowClick:e=>A({run:e.entry.key}),empty:(0,I.jsx)(c,{message:`No runs match this filter.`,hint:`Runs appear here as agents and scheduled tasks start working.`})}),_.data?.nextCursor?(0,I.jsxs)(`p`,{className:`ct-scoped-note`,children:[`Showing the `,100,` most recent runs.`]}):null]}):t===null?(0,I.jsx)(c,{tone:`loading`,message:`Loading runs…`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(w,{label:`Runs`,columns:H,rows:C,rowKey:e=>e.entry.key,selectedKey:a,onRowClick:e=>A({run:e.entry.key}),empty:(0,I.jsx)(c,{message:`No runs match this filter.`,hint:`Runs appear here as agents and scheduled tasks start working.`})}),V?(0,I.jsx)(`div`,{className:`ct-load-more`,children:(0,I.jsx)(h,{size:`sm`,onClick:()=>{for(let e of[`queued`,`tasks`,`sessions`])t?.lists[e].cursor&&r(e)},children:`Load more`})}):null]})}),O&&t?(0,I.jsx)(z,{row:O,detail:t.detail,onClose:()=>A({run:null})}):null]})]})}export{V as SCOPED_RUNS_LIMIT,W as default};
@@ -1,2 +1,2 @@
1
- import{_ as e,a as t,c as n,h as r,i,l as a,n as o,r as s,s as c,t as l}from"./format-dlOOV12I.js";import{a as u,i as d,n as f}from"./runs-store-DLIlHRM6.js";import{a as p,n as m,o as h,t as g}from"./links-C1sAzVEH.js";import{t as _}from"./Button-DL76WqX4.js";import{i as v,r as y,t as b}from"./index-OijNknZs.js";import{n as x}from"./use-gateway-query-CF94JYnM.js";import{t as S}from"./Badge-4n2tRQ02.js";import{t as C}from"./Panel-CyfpswdJ.js";import{t as w}from"./EntityLink-AEBgCNQX.js";import{t as T}from"./Stat-BruDi6qc.js";import{t as E}from"./DataTable-lEkd1R85.js";import{t as D}from"./FilterPills-HxAXXDO8.js";import{n as O,r as k,t as A}from"./usage-range-C-j75vK8.js";import{t as j}from"./UpdatedAgo-DWSnE4WG.js";import{t as M}from"./PluginPanels-DdDZQ_Dn.js";var N=e(r(),1);function P(e){let t=I(e.role)?.toLowerCase();return t===`toolresult`||t===`tool_result`||t===`tool`||t===`function`||I(e.toolCallId)!==void 0||I(e.tool_call_id)!==void 0||I(e.toolName)!==void 0||I(e.tool_name)!==void 0}var F=new Set([`toolcall`,`tooluse`,`tool_use`,`functioncall`,`function_call`,`tool_call`]);function I(e){return typeof e==`string`&&e.trim()?e:void 0}function L(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function R(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{let t=L(e);return t&&typeof t.text==`string`?t.text:null}).filter(e=>e!==null).join(`
1
+ import{_ as e,a as t,c as n,h as r,i,l as a,n as o,r as s,s as c,t as l}from"./format-CGs6a1G6.js";import{a as u,i as d,n as f}from"./runs-store-DXgNPFWM.js";import{a as p,n as m,o as h,t as g}from"./links-DlVrQOFC.js";import{t as _}from"./Button-CGdLofSY.js";import{i as v,r as y,t as b}from"./index-BvXiY83i.js";import{n as x}from"./use-gateway-query-D25QZANO.js";import{t as S}from"./Badge-CB5TWfdz.js";import{t as C}from"./Panel-9wOynsWc.js";import{t as w}from"./EntityLink-BO2oG3y8.js";import{t as T}from"./Stat-BZwg1PGE.js";import{t as E}from"./DataTable-CSi930kO.js";import{t as D}from"./FilterPills-9pNaAyrL.js";import{n as O,r as k,t as A}from"./usage-range-C-j75vK8.js";import{t as j}from"./UpdatedAgo-Dw3kxb2x.js";import{t as M}from"./PluginPanels-DulRlgcm.js";var N=e(r(),1);function P(e){let t=I(e.role)?.toLowerCase();return t===`toolresult`||t===`tool_result`||t===`tool`||t===`function`||I(e.toolCallId)!==void 0||I(e.tool_call_id)!==void 0||I(e.toolName)!==void 0||I(e.tool_name)!==void 0}var F=new Set([`toolcall`,`tooluse`,`tool_use`,`functioncall`,`function_call`,`tool_call`]);function I(e){return typeof e==`string`&&e.trim()?e:void 0}function L(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:null}function R(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>{let t=L(e);return t&&typeof t.text==`string`?t.text:null}).filter(e=>e!==null).join(`
2
2
  `):typeof e==`object`&&e?JSON.stringify(e,null,2):``}function z(e){let t=I(e.toolCallId)??I(e.tool_call_id);if(P(e)){let n=I(e.error),r=R(e.content??e.output)||(n??``),i=e.isError===!0||n!==void 0;return[{kind:`toolResult`,id:t??I(e.toolUseId)??I(e.call_id)??null,isError:i,text:r}]}let n=e.content;if(typeof n==`string`)return n?[{kind:`text`,text:n}]:[];if(!Array.isArray(n))return typeof e.text==`string`&&e.text?[{kind:`text`,text:e.text}]:[];let r=[];for(let e of n){let t=L(e);if(!t)continue;let n=I(t.type);if(n!==void 0&&(n===`text`||n===`output_text`||n===`input_text`)&&typeof t.text==`string`){r.push({kind:`text`,text:t.text});continue}if(n!==void 0&&(n===`thinking`||n===`reasoning`)&&typeof(t.thinking??t.text)==`string`){r.push({kind:`thinking`,text:t.thinking??t.text});continue}if(n!==void 0&&F.has(n.toLowerCase())){let e=L(t.function),n=I(t.id)??I(t.toolCallId)??I(t.call_id),i=I(t.name)??I(e?.name),a=t.arguments??t.input??(e?.arguments===void 0?void 0:e.arguments);r.push({kind:`toolCall`,id:n??null,name:i??`tool`,args:JSON.stringify(a??{},null,2)});continue}if(n===`toolResult`||n===`tool_result`){let e=I(t.toolCallId)??I(t.toolUseId)??I(t.id);r.push({kind:`toolResult`,id:e??null,isError:t.isError===!0||I(t.error)!==void 0,text:R(t.content??t.output)})}}return r}function B(e){let t=typeof e==`string`?e.toLowerCase():``;return t===`user`||t===`assistant`||t===`system`?t:`other`}function V(e){return e.map((e,t)=>{let n=L(e),r=n?L(n.__openclaw):null,i=n?.timestamp??n?.timestampMs;return{rowId:I(r?.rowId)??String(t),entryId:I(r?.id)??null,runId:I(r?.runId)??null,role:n&&P(n)?`tool`:B(n?.role),timestamp:typeof i==`number`?i:null,blocks:n?z(n):[]}})}var H=n(),U=50,W=200,G=1e3,K=20,q=`ct-transcript__item--anchor`,J={user:`accent`,assistant:`ok`,tool:`warn`,system:`neutral`,other:`neutral`};function Y(e,t){return!(t.entry!==void 0&&e.entryId!==t.entry||t.run!==void 0&&e.runId!==t.run)}function X({item:e,sessionKey:t,index:n}){if(e.runId===null)return null;let r=n.get(e.runId);return r===void 0?(0,H.jsx)(w,{to:m.runs({session:t}),children:`Runs`}):(0,H.jsx)(w,{to:m.run(`session:${r}`),children:`Run`})}function Z({block:e}){return e.kind===`text`?(0,H.jsx)(`p`,{className:`ct-transcript__text`,children:e.text}):e.kind===`thinking`?(0,H.jsxs)(`details`,{className:`ct-transcript__thinking`,children:[(0,H.jsx)(`summary`,{children:`Thinking`}),(0,H.jsx)(`p`,{className:`ct-transcript__text`,children:e.text})]}):e.kind===`toolCall`?(0,H.jsxs)(`details`,{className:`ct-transcript__tool`,children:[(0,H.jsxs)(`summary`,{children:[`Tool call · `,e.name]}),(0,H.jsx)(`pre`,{children:e.args})]}):(0,H.jsxs)(`details`,{className:`ct-transcript__result`,children:[(0,H.jsx)(`summary`,{children:e.isError?(0,H.jsx)(S,{tone:`danger`,children:`Error`}):`Result`}),(0,H.jsx)(`pre`,{children:e.text})]})}function ee(e){let{sessionKey:t}=e,n=e.anchor.entry,r=e.anchor.run,o=n!==void 0||r!==void 0,s=(0,N.useMemo)(()=>({entry:n,run:r}),[n,r]),u=a(e=>e.request),d=a(e=>e.status),f=x(`sessions.runs.list`,{sessionKey:t,limit:100},{invalidateOn:[`runs.invalidated`]}),p=(0,N.useMemo)(()=>{let e=new Map;for(let t of f.data?.runs??[])e.set(t.runId,t.sessionRunId);return e},[f.data]),[m,h]=(0,N.useState)([]),[g,v]=(0,N.useState)(!1),[y,b]=(0,N.useState)(null),[C,w]=(0,N.useState)(!0),[T,E]=(0,N.useState)(null),[D,O]=(0,N.useState)(o?`pending`:`found`),k=(0,N.useRef)(0),A=(0,N.useRef)(0),M=(0,N.useRef)(null),P=(0,N.useRef)(null),[F,I]=(0,N.useState)(!1),L=(0,N.useRef)(null),R=(0,N.useCallback)(async()=>{let e=++k.current;A.current=0,b(null),w(!0),h([]),M.current=null,v(!1),P.current=null,I(!1),O(o?`pending`:`found`);try{let n=o?W:U,r=await u(`chat.history`,{sessionKey:t,limit:n});if(k.current!==e)return;A.current+=1;let i=V(r.messages??[]),a=r.cursor??null,c=r.hasMore===!0;for(;o&&!i.some(e=>Y(e,s))&&c&&a!==null&&i.length<G&&A.current<K;){let r=await u(`chat.history`,{sessionKey:t,limit:n,before:a});if(k.current!==e)return;A.current+=1,i=[...V(r.messages??[]),...i],a=r.cursor??null,c=r.hasMore===!0}h(i),M.current=a,v(c),E(Date.now()),o&&O(i.some(e=>Y(e,s))?`found`:`missing`)}catch(t){k.current===e&&b(l(t))}finally{k.current===e&&w(!1)}},[u,t,s,o]);(0,N.useEffect)(()=>(d===`connected`&&R(),()=>{k.current+=1}),[R,d]);let z=(0,N.useCallback)(async()=>{let e=M.current,n=k.current;if(!(P.current===n||e===null)){P.current=n,I(!0);try{let r=await u(`chat.history`,{sessionKey:t,limit:U,before:e});if(k.current!==n||M.current!==e)return;h(e=>[...V(r.messages??[]),...e]),M.current=r.cursor??null,v(r.hasMore===!0)}catch(e){k.current===n&&b(l(e))}finally{P.current===n&&(P.current=null,I(!1))}}},[u,t]),B=o&&D===`found`;return(0,N.useEffect)(()=>{if(!B)return;let e=L.current?.querySelector(`.${q}`);e instanceof HTMLElement&&e.scrollIntoView?.({block:`center`})},[B,m]),(0,H.jsxs)(`div`,{"data-testid":`session-transcript`,className:`ct-transcript-wrap`,children:[(0,H.jsxs)(`div`,{className:`ct-transcript__bar`,children:[(0,H.jsx)(_,{size:`sm`,onClick:()=>void R(),children:`Refresh`}),(0,H.jsx)(j,{at:T,error:y})]}),y!==null&&m.length===0?(0,H.jsx)(c,{message:y,tone:`error`}):m.length===0&&C?(0,H.jsx)(c,{message:`Loading transcript…`,tone:`loading`}):null,(0,H.jsx)(`ol`,{className:`ct-transcript`,ref:L,children:m.map((e,n)=>{let r=B&&Y(e,s);return(0,H.jsxs)(`li`,{className:r?`ct-transcript__item ${q}`:`ct-transcript__item`,"aria-current":r?`true`:void 0,children:[(0,H.jsxs)(`div`,{className:`ct-transcript__head`,children:[(0,H.jsx)(S,{tone:J[e.role],children:e.role}),(0,H.jsx)(`span`,{className:`ct-transcript__time`,children:e.timestamp===null?null:i(e.timestamp)}),(0,H.jsx)(X,{item:e,sessionKey:t,index:p})]}),e.blocks.map((e,t)=>(0,H.jsx)(Z,{block:e},t))]},e.entryId??`row:${n}:${e.rowId}`)})}),m.length===0&&!C&&y===null&&D!==`missing`?(0,H.jsx)(c,{message:`No transcript messages.`}):null,g?(0,H.jsx)(_,{size:`sm`,onClick:()=>void z(),disabled:F,children:`Load older`}):null,D===`missing`?(0,H.jsx)(c,{message:g?`The linked message is older than the last ${m.length.toLocaleString(`en-US`)} messages.`:`The linked message is not in this session's transcript.`}):null]})}var te=[{key:`model`,label:`Model`,mono:!0,render:e=>{let t=e.provider?`${e.provider}/${e.model??`—`}`:e.model??`—`;return e.actualModel&&e.actualModel!==e.model?`${t} → ${e.actualModel}`:t}},{key:`count`,label:`Calls`,align:`end`,mono:!0,render:e=>e.count},{key:`cost`,label:`Cost`,align:`end`,mono:!0,render:e=>o(e.totals?.totalCost)}],ne=[{key:`name`,label:`Tool`,mono:!0,render:e=>e.name},{key:`count`,label:`Calls`,align:`end`,mono:!0,render:e=>e.count}];function Q({sessionKey:e}){let[n,r]=(0,N.useState)(`30d`),i=x(`sessions.usage`,{...k(n),key:e,limit:1}),a=i.data?.sessions?.[0],l=i.data?.totals,u=i.data?.aggregates,d=l?.missingCostEntries??0,f=a?.usage!==void 0&&a.usage!==null;return(0,H.jsxs)(`div`,{"data-testid":`session-usage`,children:[(0,H.jsxs)(`div`,{className:`ct-session-usage__head`,children:[(0,H.jsx)(D,{label:`Usage range`,value:n,onChange:r,options:A.map(e=>({value:e,label:O[e]}))}),(0,H.jsx)(`div`,{className:`ct-toolbar__grow`}),(0,H.jsxs)(`div`,{className:`ct-session-usage__meta`,children:[(0,H.jsx)(j,{at:i.updatedAt,error:i.error}),(0,H.jsxs)(_,{size:`sm`,onClick:i.reload,disabled:i.loading,children:[(0,H.jsx)(b,{name:`refresh`,size:14}),`Refresh`]})]})]}),i.error?(0,H.jsx)(c,{tone:`error`,message:`Session usage is unavailable.`,hint:i.error}):null,f&&l&&u?(0,H.jsxs)(H.Fragment,{children:[d>0?(0,H.jsx)(`p`,{className:`ct-session-usage__missing`,"data-testid":`session-usage-missing`,children:`${d} messages have no price; spend is a lower bound.`}):null,(0,H.jsxs)(`div`,{className:`ct-stat-grid`,role:`group`,"aria-label":`Session usage`,children:[(0,H.jsx)(T,{label:`Spend`,value:o(l.totalCost),sub:O[n]}),(0,H.jsx)(T,{label:`Tokens`,value:t(l.totalTokens)}),(0,H.jsx)(T,{label:`Messages`,value:u.messages.total}),(0,H.jsx)(T,{label:`Tool calls`,value:u.messages.toolCalls}),(0,H.jsx)(T,{label:`Errors`,value:u.messages.errors}),(0,H.jsx)(T,{label:`p95 latency`,value:s(u.latency?.p95Ms)})]}),(0,H.jsxs)(`div`,{className:`ct-session-usage__tables`,children:[(0,H.jsx)(E,{label:`Models`,columns:te,rows:u.byModel,rowKey:e=>JSON.stringify([e.provider,e.model,e.actualModel]),empty:(0,H.jsx)(c,{message:`No model calls in this range.`})}),(0,H.jsx)(E,{label:`Tools`,columns:ne,rows:u.tools.tools,rowKey:e=>e.name,empty:(0,H.jsx)(c,{message:`No tool calls in this range.`})})]})]}):i.loading&&i.data===null?(0,H.jsx)(c,{tone:`loading`,message:`Loading usage…`}):i.error?null:(0,H.jsx)(c,{message:`No usage recorded in this range.`})]})}function re({sessionKey:e,row:n,tab:r=`overview`,anchor:a={},onTabChange:o,onClose:s}){let l=x(`sessions.describe`,{key:e,includeDerivedTitles:!0},{enabled:n===null}),u=n??l.data?.session??null,d=n===null&&l.error!==null,f=u?.derivedTitle??u?.displayName??u?.label??e,p=typeof u?.totalTokens==`number`?typeof u.contextTokens==`number`&&u.contextTokens>0?`${t(u.totalTokens)} / ${t(u.contextTokens)}`:t(u.totalTokens):`—`,h=[[`Channel`,u?.channel??`—`],[`Model`,u?.model??`—`],[`Tokens`,p],[`Updated`,i(u?.updatedAt??null)],[`Agent`,u?.agentId?(0,H.jsx)(w,{to:m.agent(u.agentId),children:u.agentId}):`—`],[`Parent`,u?.parentSessionKey?(0,H.jsx)(w,{to:m.session(u.parentSessionKey),children:u.parentSessionKey}):`—`]];return(0,H.jsx)(C,{className:`ct-inspector`,title:f,sub:(0,H.jsx)(`span`,{className:`ct-mono`,children:e}),testId:`session-inspector`,actions:(0,H.jsx)(`button`,{type:`button`,className:`ct-icon-btn`,"aria-label":`Close session`,onClick:s,children:(0,H.jsx)(b,{name:`x`})}),children:(0,H.jsxs)(`div`,{className:`ct-inspector__body`,children:[(0,H.jsx)(D,{label:`Session sections`,value:r,onChange:e=>o?.(e),options:[{value:`overview`,label:`Overview`},{value:`transcript`,label:`Transcript`},{value:`usage`,label:`Usage`}]}),r===`overview`?d?(0,H.jsx)(c,{tone:`error`,message:`Session not found.`,hint:l.error}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`dl`,{className:`ct-kv`,children:h.map(([e,t])=>(0,H.jsxs)(`div`,{className:`ct-kv__row`,children:[(0,H.jsx)(`dt`,{children:e}),(0,H.jsx)(`dd`,{children:t})]},e))}),(0,H.jsx)(`div`,{className:`ct-inspector__actions`,children:(0,H.jsx)(_,{onClick:()=>g(m.runs({session:e})),children:`View runs`})}),(0,H.jsx)(M,{placement:`session`,props:{sessionKey:e}})]}):null,r===`transcript`?(0,H.jsx)(ee,{sessionKey:e,anchor:a}):null,r===`usage`?(0,H.jsx)(Q,{sessionKey:e}):null]})})}var ie=50,ae=200,oe=250,$=.8,se=1e3,ce={all:`All`,active:`Active`,idle:`Idle`};function le({row:e}){let{totalTokens:n,contextTokens:r}=e;if(typeof n!=`number`||typeof r!=`number`||r<=0)return(0,H.jsx)(`span`,{className:`ct-muted`,children:`—`});let i=n/r,a=`${t(n)} / ${t(r)}`;return i>=$?(0,H.jsx)(S,{tone:`warn`,children:`${a} · ${Math.round(i*100)}%`}):(0,H.jsx)(`span`,{className:`ct-mono`,children:a})}var ue=[{key:`title`,label:`Session`,render:e=>(0,H.jsxs)(`span`,{className:`ct-cell-stack`,children:[(0,H.jsx)(`span`,{className:`ct-cell-stack__main`,children:e.derivedTitle??e.displayName??e.label??e.key}),(0,H.jsx)(`span`,{className:`ct-cell-stack__sub ct-mono`,children:e.key})]})},{key:`channel`,label:`Channel`,render:e=>e.channel??`—`},{key:`model`,label:`Model`,mono:!0,render:e=>e.model??`—`},{key:`context`,label:`Context`,render:e=>(0,H.jsx)(le,{row:e})},{key:`updated`,label:`Last active`,render:e=>i(e.updatedAt)}];function de(){let e=h(),t=a(e=>e.request),n=a(e=>e.status),r=a(e=>e.subscribe),i=v(),o=d(e=>e.view),s=(0,N.useMemo)(()=>f(o),[o]),m=e.params.get(`agent`)??void 0,g=e.params.get(`filter`),x=g===`active`||g===`idle`?g:`all`,S=e.params.get(`q`)??``,w=e.params.get(`session`)??void 0,T=e.params.get(`tab`),O=e.params.get(`entry`)??void 0,k=e.params.get(`run`)??void 0,A=T===`transcript`||T===`usage`?T:O!==void 0||k!==void 0?`transcript`:`overview`,[M,P]=(0,N.useState)([]),[F,I]=(0,N.useState)(null),[L,R]=(0,N.useState)(null),[z,B]=(0,N.useState)(!0),[V,U]=(0,N.useState)(null),[W,G]=(0,N.useState)(S),K=(0,N.useRef)(0),q=(0,N.useRef)(M);q.current=M,(0,N.useEffect)(()=>{G(S)},[S]);let J=(0,N.useCallback)(e=>{let t={},n={agent:m,filter:x===`all`?void 0:x,q:S||void 0,session:w,tab:A===`overview`?void 0:A,entry:O,run:k};for(let[t,r]of Object.entries(e))n[t]=r===null?void 0:r;for(let[e,r]of Object.entries(n))r!==void 0&&(t[e]=r);p(`sessions`,t)},[m,x,S,w,A,O,k]),Y=(0,N.useCallback)(async(e,n=ie)=>{let r=++K.current;B(!0);try{let i=await t(`sessions.list`,{includeDerivedTitles:!0,...m?{agentId:m}:{},...S?{search:S}:{},offset:e,limit:n});if(r!==K.current)return;let a=Array.isArray(i.sessions)?i.sessions:[];P(t=>e===0?a:[...t,...a]),I(typeof i.nextOffset==`number`?i.nextOffset:null),R(Date.now()),U(null)}catch(e){r===K.current&&U(l(e))}finally{r===K.current&&B(!1)}},[t,m,S]),X=(0,N.useCallback)(async()=>{let e=q.current.length;e>ae||await Y(0,Math.max(e,ie))},[Y]),Z=(0,N.useRef)(!1);(0,N.useEffect)(()=>{n===`connected`&&(Z.current=!1,Y(0))},[Y,n]);let ee=(0,N.useRef)(S);ee.current=S;let te=(0,N.useRef)(J);te.current=J,(0,N.useEffect)(()=>{let e=window.setTimeout(()=>{let e=W.trim();e!==ee.current&&te.current({q:e||null})},oe);return()=>window.clearTimeout(e)},[W]),(0,N.useEffect)(()=>{if(n!==`connected`)return;let e=null,t=()=>{if(!y()){Z.current=!0;return}e===null&&(e=window.setTimeout(()=>{e=null,Z.current=!1,X()},se))},a=[r(`sessions.changed`,t),r(`runs.invalidated`,e=>{u(e)?.scope===`session`&&t()})];return i&&Z.current&&(Z.current=!1,X()),()=>{e!==null&&(Z.current=!0,window.clearTimeout(e));for(let e of a)e()}},[n,i,r,X]);let ne=x===`all`?M:M.filter(e=>s.has(e.key)===(x===`active`)),Q=(0,N.useRef)(null),$=null;if(w){let e=M.find(e=>e.key===w)??null;e?(Q.current=e,$=e):Q.current?.key===w&&($=Q.current)}return(0,H.jsxs)(`div`,{className:`ct-page`,"data-testid":`sessions-view`,children:[(0,H.jsxs)(`header`,{className:`ct-page__head`,children:[(0,H.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,H.jsx)(`h1`,{className:`ct-page__title`,children:`Sessions`}),(0,H.jsx)(`p`,{className:`ct-page__sub`,children:`Every conversation this gateway holds. Select one to inspect it.`})]}),(0,H.jsxs)(`div`,{className:`ct-session-refresh`,children:[(0,H.jsx)(j,{at:L,error:V}),(0,H.jsxs)(_,{onClick:()=>void Y(0),disabled:z,children:[(0,H.jsx)(b,{name:`refresh`,size:15}),`Refresh`]})]})]}),(0,H.jsxs)(`div`,{className:`ct-toolbar`,children:[(0,H.jsx)(D,{label:`Filter sessions`,value:x,onChange:e=>J({filter:e===`all`?null:e}),options:[`all`,`active`,`idle`].map(e=>({value:e,label:ce[e]}))}),m?(0,H.jsxs)(`span`,{className:`ct-chip`,"data-testid":`sessions-agent-chip`,children:[`Agent: `,(0,H.jsx)(`span`,{className:`ct-chip__value`,children:m}),(0,H.jsx)(`button`,{type:`button`,className:`ct-chip__clear`,"aria-label":`Show sessions for every agent`,onClick:()=>J({agent:null}),children:(0,H.jsx)(b,{name:`x`,size:12})})]}):null,(0,H.jsx)(`div`,{className:`ct-toolbar__grow`}),(0,H.jsxs)(`label`,{className:`ct-search`,children:[(0,H.jsx)(b,{name:`search`,size:15}),(0,H.jsx)(`input`,{className:`ct-search__input`,type:`search`,placeholder:`Search sessions`,"aria-label":`Search sessions`,value:W,onChange:e=>G(e.target.value)})]})]}),(0,H.jsxs)(`div`,{className:w?`ct-split ct-split--open`:`ct-split`,children:[(0,H.jsxs)(C,{title:`${ce[x]} sessions`,sub:`${ne.length} shown`,children:[V?(0,H.jsx)(c,{tone:`error`,message:`Sessions could not be listed.`,hint:V}):null,z&&M.length===0?(0,H.jsx)(c,{tone:`loading`,message:`Loading sessions…`}):(0,H.jsx)(E,{label:`Sessions`,columns:ue,rows:ne,rowKey:e=>e.key,selectedKey:w,onRowClick:e=>J({session:e.key,entry:null,run:null}),empty:(0,H.jsx)(c,{message:S?`No sessions match “${S}”.`:`No sessions yet.`})}),F===null?null:(0,H.jsx)(`div`,{className:`ct-load-more`,children:(0,H.jsx)(_,{size:`sm`,disabled:z,onClick:()=>void Y(F),children:`Load more`})})]}),w?(0,H.jsx)(re,{sessionKey:w,row:$,tab:A,anchor:{entry:O,run:k},onTabChange:e=>J({tab:e===`overview`?null:e,entry:null,run:null}),onClose:()=>J({session:null,tab:null,entry:null,run:null})},w):null]})]})}export{se as SESSIONS_REFRESH_COALESCE_MS,de as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,s as r,t as i}from"./format-dlOOV12I.js";import{t as a}from"./Button-DL76WqX4.js";import{t as o}from"./Dialog-rIrrCPSu.js";import{i as s,n as c,r as l,t as u}from"./config-store-27hOx1yp.js";import{l as d,s as f}from"./form-utils-BkwTm73v.js";import{t as p}from"./Badge-4n2tRQ02.js";import{i as m,n as h,r as g,t as _}from"./ConfigForm-CbvOdyOA.js";var v=e(n(),1),y=e(s(),1);function b(e,t){let n=e?.properties;return n?Object.entries(n).map(([e])=>({key:e,label:h(e),order:f([e],t)?.order??50})).toSorted((e,t)=>e.order===t.order?e.key.localeCompare(t.key):e.order-t.order):[]}var x=[`security`,`auth`,`network`,`access`,`privacy`,`observability`,`performance`,`reliability`,`storage`,`models`,`media`,`automation`,`channels`,`tools`,`advanced`];function ee(e){try{return y.default.parse(e),{ok:!0}}catch(e){return{ok:!1,error:i(e)}}}var S=t();function C({message:e,onReload:t}){return(0,S.jsxs)(`div`,{className:`ct-settings__callout`,role:`alert`,"data-testid":`settings-error`,children:[(0,S.jsx)(`p`,{className:`ct-settings__callout-msg`,children:e}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-error-reload`,onClick:t,children:`Reload from gateway`})]})}function w(){let e=l(e=>e.snapshot),t=l(e=>e.schema),n=l(e=>e.draft),i=l(e=>e.dirty),s=l(e=>e.busy),f=l(e=>e.error),h=l(e=>e.pendingRestart),[y,w]=(0,v.useState)(`form`),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),z=(0,v.useRef)(!1);(0,v.useEffect)(()=>{z.current||(z.current=!0,l.getState().load())},[]);let B=e?.raw??null;(0,v.useEffect)(()=>{j||A(B)},[B,j]);let V=(0,v.useMemo)(()=>{let e=t?.schema;return d(e)?e:null},[t]),H=t?.uiHints??{},U=(0,v.useMemo)(()=>b(V,H),[V,H]),W=(0,v.useMemo)(()=>u({draft:n,snapshot:e}),[n,e]),G=y===`raw`&&k!==null?ee(k):{ok:!0},K=i||j,q=y===`form`?W.length>0:k!==null&&k!==B,J=s||!q||y===`raw`&&!G.ok,Y=async e=>{let t=y===`raw`&&k!==null?k:void 0;await l.getState().save(e,t);let n=l.getState();n.error===null&&n.pendingRestart===null&&M(!1)},X=async()=>{let e=l.getState().pendingRestart?.method??null;await l.getState().confirmRestart();let t=l.getState();e===`config.apply`&&t.pendingRestart===null&&t.error===null&&M(!1)},Z=()=>{l.getState().reset(),A(B),M(!1),P(!1)},Q=async()=>{M(!1);let e=l.getState();e.dirty&&e.reset(),await e.load()},$=()=>{if(K){I(!0);return}Q()};if(!e)return(0,S.jsxs)(`div`,{className:`ct-page`,"data-testid":`settings-view`,children:[(0,S.jsx)(`header`,{className:`ct-page__head`,children:(0,S.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,S.jsx)(`h1`,{className:`ct-page__title`,children:`Settings`}),(0,S.jsx)(`p`,{className:`ct-page__sub`,children:`Gateway configuration, form and raw.`})]})}),s?(0,S.jsx)(r,{tone:`loading`,message:`Loading settings…`,testId:`settings-loading`}):f?(0,S.jsx)(C,{message:f,onReload:$}):(0,S.jsx)(r,{message:`No configuration loaded.`,hint:`Reload from the gateway.`})]});let te=y===`form`?`${W.length} unsaved change${W.length===1?``:`s`}`:`Unsaved changes`;return(0,S.jsxs)(`div`,{className:`ct-page`,"data-testid":`settings-view`,children:[(0,S.jsx)(`header`,{className:`ct-page__head`,children:(0,S.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,S.jsx)(`h1`,{className:`ct-page__title`,children:`Settings`}),(0,S.jsx)(`p`,{className:`ct-page__sub`,children:`Gateway configuration, form and raw.`})]})}),(0,S.jsxs)(`div`,{className:`ct-settings__layout`,children:[(0,S.jsxs)(`aside`,{className:`ct-settings__side`,children:[(0,S.jsxs)(`div`,{className:`ct-settings__side-head`,children:[(0,S.jsx)(`span`,{className:`ct-settings__side-title`,children:`Configuration`}),e.valid===!1?(0,S.jsx)(p,{tone:`danger`,children:`invalid`}):e.valid===!0?(0,S.jsx)(p,{tone:`ok`,children:`valid`}):null]}),(0,S.jsx)(`input`,{className:`cfg-input ct-settings__search`,"data-testid":`settings-search`,placeholder:`Search settings…`,value:T,onChange:e=>E(e.target.value)}),(0,S.jsx)(`div`,{className:`ct-settings__tags`,role:`group`,"aria-label":`Tag filters`,children:x.map(e=>{let t=g(T,e);return(0,S.jsxs)(`button`,{type:`button`,className:t?`ct-settings__tag ct-settings__tag--active`:`ct-settings__tag`,"data-testid":`settings-tag-${e}`,"aria-pressed":t,onClick:()=>E(m(T,e)),children:[`tag:`,e]},e)})}),(0,S.jsxs)(`nav`,{className:`ct-settings__nav`,"data-testid":`settings-nav`,"aria-label":`Config sections`,children:[(0,S.jsx)(`button`,{type:`button`,className:D===null?`ct-settings__nav-item ct-settings__nav-item--active`:`ct-settings__nav-item`,"data-testid":`settings-section-all`,onClick:()=>O(null),children:`All settings`}),U.map(e=>(0,S.jsx)(`button`,{type:`button`,className:D===e.key?`ct-settings__nav-item ct-settings__nav-item--active`:`ct-settings__nav-item`,"data-testid":`settings-section-${e.key}`,onClick:()=>O(e.key),children:e.label},e.key))]}),(0,S.jsxs)(`div`,{className:`ct-settings__modes`,role:`group`,"aria-label":`Editor mode`,children:[(0,S.jsx)(`button`,{type:`button`,"data-testid":`settings-mode-form`,className:y===`form`?`ct-settings__mode ct-settings__mode--active`:`ct-settings__mode`,disabled:V===null,onClick:()=>w(`form`),children:`Form`}),(0,S.jsx)(`button`,{type:`button`,"data-testid":`settings-mode-raw`,className:y===`raw`?`ct-settings__mode ct-settings__mode--active`:`ct-settings__mode`,onClick:()=>{let e=l.getState();e.dirty&&!j&&A(c(e.draft,e.schema?.schema??null)),w(`raw`)},children:`Raw`})]})]}),(0,S.jsxs)(`div`,{className:`ct-settings__main`,children:[(0,S.jsxs)(`div`,{className:`ct-settings__toolbar`,children:[q?(0,S.jsx)(`span`,{className:`ct-settings__changes`,"data-testid":`settings-pending`,children:te}):null,(0,S.jsxs)(`div`,{className:`ct-settings__actions`,children:[(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-reload`,disabled:s,onClick:$,children:`Reload`}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-reset`,disabled:!K||s,onClick:()=>P(!0),children:`Reset`}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-update`,disabled:s,onClick:()=>R(!0),children:`Update`}),(0,S.jsx)(a,{size:`sm`,variant:`primary`,"data-testid":`settings-save`,disabled:J,onClick:()=>void Y(`set`),children:`Save`}),(0,S.jsx)(a,{size:`sm`,variant:`primary`,"data-testid":`settings-apply`,disabled:J,onClick:()=>void Y(`apply`),children:`Save & restart`})]})]}),f?(0,S.jsx)(C,{message:f,onReload:$}):null,e.issues.length>0?(0,S.jsxs)(`div`,{className:`ct-settings__issues`,role:`alert`,"data-testid":`settings-issues`,children:[(0,S.jsxs)(`p`,{className:`ct-settings__issues-title`,children:[`The saved config has `,e.issues.length,` validation issue`,e.issues.length===1?``:`s`,`:`]}),(0,S.jsx)(`ul`,{children:e.issues.map((e,t)=>(0,S.jsxs)(`li`,{className:`ct-settings__issue`,children:[(0,S.jsx)(`span`,{className:`ct-mono`,children:e.path}),` — `,e.message]},`${e.path}:${t}`))})]}):null,y===`form`?(0,S.jsxs)(S.Fragment,{children:[W.length>0?(0,S.jsxs)(`details`,{className:`ct-settings__diff`,"data-testid":`settings-pending-list`,children:[(0,S.jsxs)(`summary`,{children:[`View `,W.length,` pending change`,W.length===1?``:`s`]}),(0,S.jsx)(`div`,{className:`ct-settings__diff-list`,children:W.map(e=>(0,S.jsx)(`div`,{className:`ct-settings__diff-path ct-mono`,"data-testid":`settings-pending-path`,children:e},e))})]}):null,(0,S.jsx)(_,{schema:V,uiHints:H,value:n,disabled:s,search:T,rootPath:D===null?void 0:[D],onPatch:(e,t)=>l.getState().setPath(e,t)})]}):(0,S.jsxs)(`div`,{className:`ct-settings__raw`,children:[G.ok?null:(0,S.jsx)(`div`,{className:`ct-settings__raw-error`,role:`alert`,"data-testid":`settings-raw-error`,children:G.error}),(0,S.jsx)(`textarea`,{className:`ct-settings__raw-text`,"data-testid":`settings-raw`,spellCheck:!1,value:k??``,disabled:s,onChange:e=>{A(e.target.value),M(!0)}})]})]})]}),(0,S.jsx)(o,{open:h!==null,title:`Restart the gateway?`,width:`sm`,onClose:s?()=>{}:()=>l.getState().cancelRestart(),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{disabled:s,onClick:()=>l.getState().cancelRestart(),children:`Cancel`}),(0,S.jsx)(a,{variant:`primary`,"data-testid":`settings-restart-confirm`,disabled:s,onClick:()=>void X(),children:`Drain and restart`})]}),children:(0,S.jsxs)(`p`,{className:`ct-settings__dialog-body`,"data-testid":`settings-restart-dialog`,children:[`This operation needs a gateway restart, but`,` `,(0,S.jsxs)(`strong`,{children:[h?.activeRuns??0,` active run`,h?.activeRuns===1?``:`s`]}),` `,`will be interrupted. Continue?`]})}),(0,S.jsx)(o,{open:L,title:`Run the updater?`,width:`sm`,onClose:()=>R(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>R(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`primary`,"data-testid":`settings-update-confirm`,disabled:s,onClick:()=>{R(!1),l.getState().runUpdate()},children:`Run update`})]}),children:(0,S.jsxs)(`p`,{className:`ct-settings__dialog-body`,children:[`Runs `,(0,S.jsx)(`span`,{className:`ct-mono`,children:`update.run`}),` now: it installs the latest release and may restart the gateway.`]})}),(0,S.jsx)(o,{open:F,title:`Discard unsaved changes?`,width:`sm`,onClose:()=>I(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>I(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`danger`,"data-testid":`settings-reload-confirm`,disabled:s,onClick:()=>{I(!1),Q()},children:`Discard and reload`})]}),children:(0,S.jsx)(`p`,{className:`ct-settings__dialog-body`,children:`Unsaved edits are lost and the config is reloaded from the gateway.`})}),(0,S.jsx)(o,{open:N,title:`Discard unsaved changes?`,width:`sm`,onClose:()=>P(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>P(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`danger`,"data-testid":`settings-reset-confirm`,disabled:s,onClick:Z,children:`Discard changes`})]}),children:(0,S.jsx)(`p`,{className:`ct-settings__dialog-body`,children:`Edits are discarded and the saved gateway config is restored in the form.`})})]})}export{w as default};
1
+ import{_ as e,c as t,h as n,s as r,t as i}from"./format-CGs6a1G6.js";import{t as a}from"./Button-CGdLofSY.js";import{t as o}from"./Dialog-CQE8Pvh6.js";import{i as s,n as c,r as l,t as u}from"./config-store-XvvVJ8Fq.js";import{l as d,s as f}from"./form-utils-BkwTm73v.js";import{t as p}from"./Badge-CB5TWfdz.js";import{i as m,n as h,r as g,t as _}from"./ConfigForm-D8_bqW8x.js";var v=e(n(),1),y=e(s(),1);function b(e,t){let n=e?.properties;return n?Object.entries(n).map(([e])=>({key:e,label:h(e),order:f([e],t)?.order??50})).toSorted((e,t)=>e.order===t.order?e.key.localeCompare(t.key):e.order-t.order):[]}var x=[`security`,`auth`,`network`,`access`,`privacy`,`observability`,`performance`,`reliability`,`storage`,`models`,`media`,`automation`,`channels`,`tools`,`advanced`];function ee(e){try{return y.default.parse(e),{ok:!0}}catch(e){return{ok:!1,error:i(e)}}}var S=t();function C({message:e,onReload:t}){return(0,S.jsxs)(`div`,{className:`ct-settings__callout`,role:`alert`,"data-testid":`settings-error`,children:[(0,S.jsx)(`p`,{className:`ct-settings__callout-msg`,children:e}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-error-reload`,onClick:t,children:`Reload from gateway`})]})}function w(){let e=l(e=>e.snapshot),t=l(e=>e.schema),n=l(e=>e.draft),i=l(e=>e.dirty),s=l(e=>e.busy),f=l(e=>e.error),h=l(e=>e.pendingRestart),[y,w]=(0,v.useState)(`form`),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(!1),z=(0,v.useRef)(!1);(0,v.useEffect)(()=>{z.current||(z.current=!0,l.getState().load())},[]);let B=e?.raw??null;(0,v.useEffect)(()=>{j||A(B)},[B,j]);let V=(0,v.useMemo)(()=>{let e=t?.schema;return d(e)?e:null},[t]),H=t?.uiHints??{},U=(0,v.useMemo)(()=>b(V,H),[V,H]),W=(0,v.useMemo)(()=>u({draft:n,snapshot:e}),[n,e]),G=y===`raw`&&k!==null?ee(k):{ok:!0},K=i||j,q=y===`form`?W.length>0:k!==null&&k!==B,J=s||!q||y===`raw`&&!G.ok,Y=async e=>{let t=y===`raw`&&k!==null?k:void 0;await l.getState().save(e,t);let n=l.getState();n.error===null&&n.pendingRestart===null&&M(!1)},X=async()=>{let e=l.getState().pendingRestart?.method??null;await l.getState().confirmRestart();let t=l.getState();e===`config.apply`&&t.pendingRestart===null&&t.error===null&&M(!1)},Z=()=>{l.getState().reset(),A(B),M(!1),P(!1)},Q=async()=>{M(!1);let e=l.getState();e.dirty&&e.reset(),await e.load()},$=()=>{if(K){I(!0);return}Q()};if(!e)return(0,S.jsxs)(`div`,{className:`ct-page`,"data-testid":`settings-view`,children:[(0,S.jsx)(`header`,{className:`ct-page__head`,children:(0,S.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,S.jsx)(`h1`,{className:`ct-page__title`,children:`Settings`}),(0,S.jsx)(`p`,{className:`ct-page__sub`,children:`Gateway configuration, form and raw.`})]})}),s?(0,S.jsx)(r,{tone:`loading`,message:`Loading settings…`,testId:`settings-loading`}):f?(0,S.jsx)(C,{message:f,onReload:$}):(0,S.jsx)(r,{message:`No configuration loaded.`,hint:`Reload from the gateway.`})]});let te=y===`form`?`${W.length} unsaved change${W.length===1?``:`s`}`:`Unsaved changes`;return(0,S.jsxs)(`div`,{className:`ct-page`,"data-testid":`settings-view`,children:[(0,S.jsx)(`header`,{className:`ct-page__head`,children:(0,S.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,S.jsx)(`h1`,{className:`ct-page__title`,children:`Settings`}),(0,S.jsx)(`p`,{className:`ct-page__sub`,children:`Gateway configuration, form and raw.`})]})}),(0,S.jsxs)(`div`,{className:`ct-settings__layout`,children:[(0,S.jsxs)(`aside`,{className:`ct-settings__side`,children:[(0,S.jsxs)(`div`,{className:`ct-settings__side-head`,children:[(0,S.jsx)(`span`,{className:`ct-settings__side-title`,children:`Configuration`}),e.valid===!1?(0,S.jsx)(p,{tone:`danger`,children:`invalid`}):e.valid===!0?(0,S.jsx)(p,{tone:`ok`,children:`valid`}):null]}),(0,S.jsx)(`input`,{className:`cfg-input ct-settings__search`,"data-testid":`settings-search`,placeholder:`Search settings…`,value:T,onChange:e=>E(e.target.value)}),(0,S.jsx)(`div`,{className:`ct-settings__tags`,role:`group`,"aria-label":`Tag filters`,children:x.map(e=>{let t=g(T,e);return(0,S.jsxs)(`button`,{type:`button`,className:t?`ct-settings__tag ct-settings__tag--active`:`ct-settings__tag`,"data-testid":`settings-tag-${e}`,"aria-pressed":t,onClick:()=>E(m(T,e)),children:[`tag:`,e]},e)})}),(0,S.jsxs)(`nav`,{className:`ct-settings__nav`,"data-testid":`settings-nav`,"aria-label":`Config sections`,children:[(0,S.jsx)(`button`,{type:`button`,className:D===null?`ct-settings__nav-item ct-settings__nav-item--active`:`ct-settings__nav-item`,"data-testid":`settings-section-all`,onClick:()=>O(null),children:`All settings`}),U.map(e=>(0,S.jsx)(`button`,{type:`button`,className:D===e.key?`ct-settings__nav-item ct-settings__nav-item--active`:`ct-settings__nav-item`,"data-testid":`settings-section-${e.key}`,onClick:()=>O(e.key),children:e.label},e.key))]}),(0,S.jsxs)(`div`,{className:`ct-settings__modes`,role:`group`,"aria-label":`Editor mode`,children:[(0,S.jsx)(`button`,{type:`button`,"data-testid":`settings-mode-form`,className:y===`form`?`ct-settings__mode ct-settings__mode--active`:`ct-settings__mode`,disabled:V===null,onClick:()=>w(`form`),children:`Form`}),(0,S.jsx)(`button`,{type:`button`,"data-testid":`settings-mode-raw`,className:y===`raw`?`ct-settings__mode ct-settings__mode--active`:`ct-settings__mode`,onClick:()=>{let e=l.getState();e.dirty&&!j&&A(c(e.draft,e.schema?.schema??null)),w(`raw`)},children:`Raw`})]})]}),(0,S.jsxs)(`div`,{className:`ct-settings__main`,children:[(0,S.jsxs)(`div`,{className:`ct-settings__toolbar`,children:[q?(0,S.jsx)(`span`,{className:`ct-settings__changes`,"data-testid":`settings-pending`,children:te}):null,(0,S.jsxs)(`div`,{className:`ct-settings__actions`,children:[(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-reload`,disabled:s,onClick:$,children:`Reload`}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-reset`,disabled:!K||s,onClick:()=>P(!0),children:`Reset`}),(0,S.jsx)(a,{size:`sm`,"data-testid":`settings-update`,disabled:s,onClick:()=>R(!0),children:`Update`}),(0,S.jsx)(a,{size:`sm`,variant:`primary`,"data-testid":`settings-save`,disabled:J,onClick:()=>void Y(`set`),children:`Save`}),(0,S.jsx)(a,{size:`sm`,variant:`primary`,"data-testid":`settings-apply`,disabled:J,onClick:()=>void Y(`apply`),children:`Save & restart`})]})]}),f?(0,S.jsx)(C,{message:f,onReload:$}):null,e.issues.length>0?(0,S.jsxs)(`div`,{className:`ct-settings__issues`,role:`alert`,"data-testid":`settings-issues`,children:[(0,S.jsxs)(`p`,{className:`ct-settings__issues-title`,children:[`The saved config has `,e.issues.length,` validation issue`,e.issues.length===1?``:`s`,`:`]}),(0,S.jsx)(`ul`,{children:e.issues.map((e,t)=>(0,S.jsxs)(`li`,{className:`ct-settings__issue`,children:[(0,S.jsx)(`span`,{className:`ct-mono`,children:e.path}),` — `,e.message]},`${e.path}:${t}`))})]}):null,y===`form`?(0,S.jsxs)(S.Fragment,{children:[W.length>0?(0,S.jsxs)(`details`,{className:`ct-settings__diff`,"data-testid":`settings-pending-list`,children:[(0,S.jsxs)(`summary`,{children:[`View `,W.length,` pending change`,W.length===1?``:`s`]}),(0,S.jsx)(`div`,{className:`ct-settings__diff-list`,children:W.map(e=>(0,S.jsx)(`div`,{className:`ct-settings__diff-path ct-mono`,"data-testid":`settings-pending-path`,children:e},e))})]}):null,(0,S.jsx)(_,{schema:V,uiHints:H,value:n,disabled:s,search:T,rootPath:D===null?void 0:[D],onPatch:(e,t)=>l.getState().setPath(e,t)})]}):(0,S.jsxs)(`div`,{className:`ct-settings__raw`,children:[G.ok?null:(0,S.jsx)(`div`,{className:`ct-settings__raw-error`,role:`alert`,"data-testid":`settings-raw-error`,children:G.error}),(0,S.jsx)(`textarea`,{className:`ct-settings__raw-text`,"data-testid":`settings-raw`,spellCheck:!1,value:k??``,disabled:s,onChange:e=>{A(e.target.value),M(!0)}})]})]})]}),(0,S.jsx)(o,{open:h!==null,title:`Restart the gateway?`,width:`sm`,onClose:s?()=>{}:()=>l.getState().cancelRestart(),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{disabled:s,onClick:()=>l.getState().cancelRestart(),children:`Cancel`}),(0,S.jsx)(a,{variant:`primary`,"data-testid":`settings-restart-confirm`,disabled:s,onClick:()=>void X(),children:`Drain and restart`})]}),children:(0,S.jsxs)(`p`,{className:`ct-settings__dialog-body`,"data-testid":`settings-restart-dialog`,children:[`This operation needs a gateway restart, but`,` `,(0,S.jsxs)(`strong`,{children:[h?.activeRuns??0,` active run`,h?.activeRuns===1?``:`s`]}),` `,`will be interrupted. Continue?`]})}),(0,S.jsx)(o,{open:L,title:`Run the updater?`,width:`sm`,onClose:()=>R(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>R(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`primary`,"data-testid":`settings-update-confirm`,disabled:s,onClick:()=>{R(!1),l.getState().runUpdate()},children:`Run update`})]}),children:(0,S.jsxs)(`p`,{className:`ct-settings__dialog-body`,children:[`Runs `,(0,S.jsx)(`span`,{className:`ct-mono`,children:`update.run`}),` now: it installs the latest release and may restart the gateway.`]})}),(0,S.jsx)(o,{open:F,title:`Discard unsaved changes?`,width:`sm`,onClose:()=>I(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>I(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`danger`,"data-testid":`settings-reload-confirm`,disabled:s,onClick:()=>{I(!1),Q()},children:`Discard and reload`})]}),children:(0,S.jsx)(`p`,{className:`ct-settings__dialog-body`,children:`Unsaved edits are lost and the config is reloaded from the gateway.`})}),(0,S.jsx)(o,{open:N,title:`Discard unsaved changes?`,width:`sm`,onClose:()=>P(!1),footer:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(a,{onClick:()=>P(!1),children:`Cancel`}),(0,S.jsx)(a,{variant:`danger`,"data-testid":`settings-reset-confirm`,disabled:s,onClick:Z,children:`Discard changes`})]}),children:(0,S.jsx)(`p`,{className:`ct-settings__dialog-body`,children:`Edits are discarded and the saved gateway config is restored in the form.`})})]})}export{w as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-dlOOV12I.js";import{t as o}from"./Button-DL76WqX4.js";import{n as s,t as c}from"./use-gateway-query-CF94JYnM.js";import{t as l}from"./Badge-4n2tRQ02.js";import{t as u}from"./Panel-CyfpswdJ.js";import{a as d,i as f,n as p,r as m,t as h}from"./skills-model-DANiC-ui.js";var g=e(n(),1),_=t(),v=12e4;function y({agentId:e}){let t=r(e=>e.request),n=s(`skills.status`,e?{agentId:e}:{},{refreshMs:c}),[l,p]=(0,g.useState)(``),[m,h]=(0,g.useState)({}),[y,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=(e,t)=>{e.trim()&&x(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},T=f(n.data?.skills??[],l),E=d(T),D=async e=>{let r=e.disabled;C(e.skillKey);try{await t(`skills.update`,{skillKey:e.skillKey,enabled:r}),await n.reload(),w(e.skillKey,{kind:`success`,message:r?`Skill enabled`:`Skill disabled`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}},O=async e=>{C(e.skillKey);try{let r=m[e.skillKey]??``;await t(`skills.update`,{skillKey:e.skillKey,apiKey:r}),await n.reload(),w(e.skillKey,{kind:`success`,message:`API key saved`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}},k=async e=>{let r=e.install[0]?.id;if(r){C(e.skillKey);try{let i=await t(`skills.install`,{name:e.name,installId:r,timeoutMs:v});await n.reload(),w(e.skillKey,{kind:`success`,message:i?.message??`Installed`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}}};return(0,_.jsxs)(u,{title:`Skills`,sub:`Bundled, managed, and workspace skills.`,actions:(0,_.jsx)(o,{onClick:()=>void n.reload(),disabled:n.loading,children:n.loading?`Loading…`:`Refresh`}),children:[(0,_.jsxs)(`div`,{className:`ct-skills__filters`,children:[(0,_.jsx)(`input`,{className:`ct-skills__search`,type:`text`,"aria-label":`Filter skills`,placeholder:`Search skills`,value:l,onChange:e=>p(e.target.value)}),(0,_.jsxs)(`span`,{className:`ct-skills__count`,children:[T.length,` shown`]})]}),n.error?(0,_.jsx)(i,{tone:`error`,message:n.error}):null,n.loading&&!n.data?(0,_.jsx)(i,{tone:`loading`,message:`Loading…`}):null,!n.error&&!n.loading&&T.length===0?(0,_.jsx)(i,{message:`No skills found.`}):null,(0,_.jsx)(`div`,{className:`ct-skills__groups`,children:E.map(e=>(0,_.jsxs)(`details`,{className:`ct-skills__group`,open:!(e.id===`workspace`||e.id===`built-in`),"data-testid":`skill-group-${e.id}`,children:[(0,_.jsxs)(`summary`,{className:`ct-skills__group-head`,children:[(0,_.jsx)(`span`,{children:e.label}),(0,_.jsx)(`span`,{className:`ct-skills__count`,children:e.skills.length})]}),(0,_.jsx)(`div`,{className:`ct-skills__list`,children:e.skills.map(e=>(0,_.jsx)(b,{skill:e,busy:S===e.skillKey,apiKey:m[e.skillKey]??``,message:y[e.skillKey]??null,onApiKeyEdit:t=>h(n=>({...n,[e.skillKey]:t})),onToggle:()=>void D(e),onSaveKey:()=>void O(e),onInstall:()=>void k(e)},e.skillKey))})]},e.id))})]})}function b({skill:e,busy:t,apiKey:n,message:r,onApiKeyEdit:i,onToggle:a,onSaveKey:s,onInstall:c}){let u=e.install.length>0&&e.missing.bins.length>0,d=e.bundled&&e.source!==`openclaw-bundled`,f=p(e),g=m(e);return(0,_.jsxs)(`div`,{className:`ct-skills__item`,"data-testid":`skill-row-${e.skillKey}`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__main`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__title`,children:[e.emoji?`${e.emoji} `:``,e.name]}),(0,_.jsx)(`div`,{className:`ct-skills__desc`,children:h(e.description,140)}),(0,_.jsxs)(`div`,{className:`ct-skills__chips`,children:[(0,_.jsx)(l,{children:e.source}),d?(0,_.jsx)(l,{children:`bundled`}):null,(0,_.jsx)(l,{tone:e.eligible?`ok`:`warn`,children:e.eligible?`eligible`:`blocked`}),e.disabled?(0,_.jsx)(l,{tone:`warn`,children:`disabled`}):null]}),f.length>0?(0,_.jsxs)(`p`,{className:`ct-skills__note`,children:[`Missing: `,f.join(`, `)]}):null,g.length>0?(0,_.jsxs)(`p`,{className:`ct-skills__note`,children:[`Reason: `,g.join(`, `)]}):null]}),(0,_.jsxs)(`div`,{className:`ct-skills__side`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__actions`,children:[(0,_.jsx)(o,{onClick:a,disabled:t,"aria-label":`${e.disabled?`Enable`:`Disable`} ${e.name}`,children:e.disabled?`Enable`:`Disable`}),u?(0,_.jsx)(o,{onClick:c,disabled:t,"aria-label":`Install ${e.name}`,children:t?`Installing…`:e.install[0].label}):null]}),r?(0,_.jsx)(`p`,{className:r.kind===`error`?`ct-skills__msg ct-skills__msg--error`:`ct-skills__msg`,role:r.kind===`error`?`alert`:void 0,children:r.message}):null,e.primaryEnv?(0,_.jsxs)(`div`,{className:`ct-skills__key`,children:[(0,_.jsxs)(`label`,{className:`ct-skills__key-label`,htmlFor:`skill-key-${e.skillKey}`,children:[`API key for `,e.name]}),(0,_.jsx)(`input`,{id:`skill-key-${e.skillKey}`,type:`password`,autoComplete:`off`,value:n,onChange:e=>i(e.target.value)}),(0,_.jsx)(o,{variant:`primary`,onClick:s,disabled:t,"aria-label":`Save API key for ${e.name}`,children:`Save key`})]}):null]})]})}function x(){return(0,_.jsxs)(`div`,{className:`ct-page`,"data-testid":`skills-view`,children:[(0,_.jsx)(`header`,{className:`ct-page__head`,children:(0,_.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,_.jsx)(`h1`,{className:`ct-page__title`,children:`Skills`}),(0,_.jsx)(`p`,{className:`ct-page__sub`,children:`Workspace, built-in and installed skills, with eligibility at a glance.`})]})}),(0,_.jsx)(y,{})]})}export{x as default};
1
+ import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-CGs6a1G6.js";import{t as o}from"./Button-CGdLofSY.js";import{n as s,t as c}from"./use-gateway-query-D25QZANO.js";import{t as l}from"./Badge-CB5TWfdz.js";import{t as u}from"./Panel-9wOynsWc.js";import{a as d,i as f,n as p,r as m,t as h}from"./skills-model-DANiC-ui.js";var g=e(n(),1),_=t(),v=12e4;function y({agentId:e}){let t=r(e=>e.request),n=s(`skills.status`,e?{agentId:e}:{},{refreshMs:c}),[l,p]=(0,g.useState)(``),[m,h]=(0,g.useState)({}),[y,x]=(0,g.useState)({}),[S,C]=(0,g.useState)(null),w=(e,t)=>{e.trim()&&x(n=>{let r={...n};return t?r[e]=t:delete r[e],r})},T=f(n.data?.skills??[],l),E=d(T),D=async e=>{let r=e.disabled;C(e.skillKey);try{await t(`skills.update`,{skillKey:e.skillKey,enabled:r}),await n.reload(),w(e.skillKey,{kind:`success`,message:r?`Skill enabled`:`Skill disabled`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}},O=async e=>{C(e.skillKey);try{let r=m[e.skillKey]??``;await t(`skills.update`,{skillKey:e.skillKey,apiKey:r}),await n.reload(),w(e.skillKey,{kind:`success`,message:`API key saved`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}},k=async e=>{let r=e.install[0]?.id;if(r){C(e.skillKey);try{let i=await t(`skills.install`,{name:e.name,installId:r,timeoutMs:v});await n.reload(),w(e.skillKey,{kind:`success`,message:i?.message??`Installed`})}catch(t){w(e.skillKey,{kind:`error`,message:a(t)})}finally{C(null)}}};return(0,_.jsxs)(u,{title:`Skills`,sub:`Bundled, managed, and workspace skills.`,actions:(0,_.jsx)(o,{onClick:()=>void n.reload(),disabled:n.loading,children:n.loading?`Loading…`:`Refresh`}),children:[(0,_.jsxs)(`div`,{className:`ct-skills__filters`,children:[(0,_.jsx)(`input`,{className:`ct-skills__search`,type:`text`,"aria-label":`Filter skills`,placeholder:`Search skills`,value:l,onChange:e=>p(e.target.value)}),(0,_.jsxs)(`span`,{className:`ct-skills__count`,children:[T.length,` shown`]})]}),n.error?(0,_.jsx)(i,{tone:`error`,message:n.error}):null,n.loading&&!n.data?(0,_.jsx)(i,{tone:`loading`,message:`Loading…`}):null,!n.error&&!n.loading&&T.length===0?(0,_.jsx)(i,{message:`No skills found.`}):null,(0,_.jsx)(`div`,{className:`ct-skills__groups`,children:E.map(e=>(0,_.jsxs)(`details`,{className:`ct-skills__group`,open:!(e.id===`workspace`||e.id===`built-in`),"data-testid":`skill-group-${e.id}`,children:[(0,_.jsxs)(`summary`,{className:`ct-skills__group-head`,children:[(0,_.jsx)(`span`,{children:e.label}),(0,_.jsx)(`span`,{className:`ct-skills__count`,children:e.skills.length})]}),(0,_.jsx)(`div`,{className:`ct-skills__list`,children:e.skills.map(e=>(0,_.jsx)(b,{skill:e,busy:S===e.skillKey,apiKey:m[e.skillKey]??``,message:y[e.skillKey]??null,onApiKeyEdit:t=>h(n=>({...n,[e.skillKey]:t})),onToggle:()=>void D(e),onSaveKey:()=>void O(e),onInstall:()=>void k(e)},e.skillKey))})]},e.id))})]})}function b({skill:e,busy:t,apiKey:n,message:r,onApiKeyEdit:i,onToggle:a,onSaveKey:s,onInstall:c}){let u=e.install.length>0&&e.missing.bins.length>0,d=e.bundled&&e.source!==`openclaw-bundled`,f=p(e),g=m(e);return(0,_.jsxs)(`div`,{className:`ct-skills__item`,"data-testid":`skill-row-${e.skillKey}`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__main`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__title`,children:[e.emoji?`${e.emoji} `:``,e.name]}),(0,_.jsx)(`div`,{className:`ct-skills__desc`,children:h(e.description,140)}),(0,_.jsxs)(`div`,{className:`ct-skills__chips`,children:[(0,_.jsx)(l,{children:e.source}),d?(0,_.jsx)(l,{children:`bundled`}):null,(0,_.jsx)(l,{tone:e.eligible?`ok`:`warn`,children:e.eligible?`eligible`:`blocked`}),e.disabled?(0,_.jsx)(l,{tone:`warn`,children:`disabled`}):null]}),f.length>0?(0,_.jsxs)(`p`,{className:`ct-skills__note`,children:[`Missing: `,f.join(`, `)]}):null,g.length>0?(0,_.jsxs)(`p`,{className:`ct-skills__note`,children:[`Reason: `,g.join(`, `)]}):null]}),(0,_.jsxs)(`div`,{className:`ct-skills__side`,children:[(0,_.jsxs)(`div`,{className:`ct-skills__actions`,children:[(0,_.jsx)(o,{onClick:a,disabled:t,"aria-label":`${e.disabled?`Enable`:`Disable`} ${e.name}`,children:e.disabled?`Enable`:`Disable`}),u?(0,_.jsx)(o,{onClick:c,disabled:t,"aria-label":`Install ${e.name}`,children:t?`Installing…`:e.install[0].label}):null]}),r?(0,_.jsx)(`p`,{className:r.kind===`error`?`ct-skills__msg ct-skills__msg--error`:`ct-skills__msg`,role:r.kind===`error`?`alert`:void 0,children:r.message}):null,e.primaryEnv?(0,_.jsxs)(`div`,{className:`ct-skills__key`,children:[(0,_.jsxs)(`label`,{className:`ct-skills__key-label`,htmlFor:`skill-key-${e.skillKey}`,children:[`API key for `,e.name]}),(0,_.jsx)(`input`,{id:`skill-key-${e.skillKey}`,type:`password`,autoComplete:`off`,value:n,onChange:e=>i(e.target.value)}),(0,_.jsx)(o,{variant:`primary`,onClick:s,disabled:t,"aria-label":`Save API key for ${e.name}`,children:`Save key`})]}):null]})]})}function x(){return(0,_.jsxs)(`div`,{className:`ct-page`,"data-testid":`skills-view`,children:[(0,_.jsx)(`header`,{className:`ct-page__head`,children:(0,_.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,_.jsx)(`h1`,{className:`ct-page__title`,children:`Skills`}),(0,_.jsx)(`p`,{className:`ct-page__sub`,children:`Workspace, built-in and installed skills, with eligibility at a glance.`})]})}),(0,_.jsx)(y,{})]})}export{x as default};
@@ -1 +1 @@
1
- import{c as e}from"./format-dlOOV12I.js";var t=e();function n({label:e,value:n,sub:r,tone:i}){return(0,t.jsxs)(`div`,{className:`ct-stat`,children:[(0,t.jsxs)(`span`,{className:`ct-stat__label`,children:[i?(0,t.jsx)(`span`,{className:`ct-dot ct-dot--${i}`,"aria-hidden":`true`}):null,e]}),(0,t.jsx)(`span`,{className:`ct-stat__value`,children:n}),r===void 0?null:(0,t.jsx)(`span`,{className:`ct-stat__sub`,children:r})]})}export{n as t};
1
+ import{c as e}from"./format-CGs6a1G6.js";var t=e();function n({label:e,value:n,sub:r,tone:i}){return(0,t.jsxs)(`div`,{className:`ct-stat`,children:[(0,t.jsxs)(`span`,{className:`ct-stat__label`,children:[i?(0,t.jsx)(`span`,{className:`ct-dot ct-dot--${i}`,"aria-hidden":`true`}):null,e]}),(0,t.jsx)(`span`,{className:`ct-stat__value`,children:n}),r===void 0?null:(0,t.jsx)(`span`,{className:`ct-stat__sub`,children:r})]})}export{n as t};
@@ -1 +1 @@
1
- import{c as e}from"./format-dlOOV12I.js";var t=e();function n({tone:e,label:n,pulse:r=!1}){return(0,t.jsx)(`span`,{className:[`ct-dot`,`ct-dot--${e}`,r?`ct-dot--pulse`:null].filter(Boolean).join(` `),role:`img`,"aria-label":n,title:n})}export{n as t};
1
+ import{c as e}from"./format-CGs6a1G6.js";var t=e();function n({tone:e,label:n,pulse:r=!1}){return(0,t.jsx)(`span`,{className:[`ct-dot`,`ct-dot--${e}`,r?`ct-dot--pulse`:null].filter(Boolean).join(` `),role:`img`,"aria-label":n,title:n})}export{n as t};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-dlOOV12I.js";import{t as o}from"./Button-DL76WqX4.js";import{n as s}from"./use-gateway-query-CF94JYnM.js";import{t as c}from"./Badge-4n2tRQ02.js";import{t as l}from"./Panel-CyfpswdJ.js";import{t as u}from"./Stat-BruDi6qc.js";import{t as d}from"./DataTable-lEkd1R85.js";import{t as f}from"./StatusDot-Cij-6nH8.js";import{t as p}from"./ConfirmDialog-DGHQXUr5.js";var m=e(n(),1),h=t(),g=5e3,_=3e4,v=`Retry every failed legacy import, including ones past the attempt cap?`,y=`Use pg_dump / your managed Postgres backups for Postgres session storage.`;function b(e){switch(e.state){case`none`:return`No legacy JSONL data to import.`;case`pending`:return`Legacy import queued.`;case`running`:return`${e.done} of ${e.total} sources imported`;case`completed`:return e.total===0?`No legacy JSONL data to import.`:e.failed+e.capped===0?`All ${e.total} sources imported.`:`Legacy import finished: ${e.imported} of ${e.total} sources imported, ${e.failed} failed, ${e.capped} past the attempt cap.`;case`error`:return`Legacy import stopped: ${e.failed} failed sources, ${e.capped} past the attempt cap.`}}function x({status:e}){if(e.state!==`running`)return null;let t=e.total>0?Math.round(e.done/e.total*100):0;return(0,h.jsx)(`div`,{className:`ct-storage__progress`,role:`progressbar`,"aria-label":`Legacy import progress`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,h.jsx)(`div`,{className:`ct-storage__progress-fill`,style:{width:`${t}%`}})})}function S({status:e}){return e?(0,h.jsxs)(`div`,{className:`ct-storage__section`,"data-testid":`import-section`,children:[(0,h.jsx)(`h3`,{className:`ct-storage__section-title`,children:`Legacy JSONL import`}),(0,h.jsx)(x,{status:e}),(0,h.jsx)(`p`,{className:`ct-storage__headline`,children:b(e)}),(0,h.jsxs)(`div`,{className:`ct-storage__counts`,children:[(0,h.jsx)(u,{label:`Pending`,value:e.pending}),(0,h.jsx)(u,{label:`Imported`,value:e.imported}),(0,h.jsx)(u,{label:`Failed`,value:e.failed}),(0,h.jsx)(u,{label:`Capped`,value:e.capped}),(0,h.jsx)(u,{label:`Vanished`,value:e.vanished}),(0,h.jsx)(u,{label:`Rejected entries`,value:e.rejectedEntries})]}),e.lastError?(0,h.jsx)(`p`,{className:`ct-storage__callout ct-storage__callout--error`,role:`alert`,children:e.lastError}):null,e.archiveRoot||e.backupPath?(0,h.jsxs)(`dl`,{className:`ct-storage__kv`,children:[e.archiveRoot?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{children:`Archive root`}),(0,h.jsx)(`dd`,{className:`ct-mono`,children:e.archiveRoot})]}):null,e.backupPath?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{children:`Backup path`}),(0,h.jsx)(`dd`,{className:`ct-mono`,children:e.backupPath})]}):null]}):null]}):null}function C({result:e}){return(0,h.jsxs)(`div`,{className:`ct-storage__section`,"data-testid":`validate-section`,children:[(0,h.jsxs)(`h3`,{className:`ct-storage__section-title`,children:[`Validation`,` `,(0,h.jsx)(c,{tone:e.ok?`ok`:`danger`,children:e.ok?`all checks passed`:`checks failed`})]}),(0,h.jsx)(d,{columns:[{key:`name`,label:`Check`,render:e=>e.name},{key:`result`,label:`Result`,render:e=>(0,h.jsx)(c,{tone:e.ok?`ok`:`danger`,children:e.ok?`ok`:`failed`})},{key:`detail`,label:`Detail`,mono:!0,render:e=>e.detail??`—`}],rows:e.checks,rowKey:e=>e.name,label:`Storage validation checks`})]})}function w(){let e=r(e=>e.request),t=s(`sessions.storage.status`,{}),[n,c]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[b,x]=(0,m.useState)(null),[w,T]=(0,m.useState)(null),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(!1);(0,m.useEffect)(()=>{t.data&&c(null)},[t.data]);let A=n??t.data?.legacyImport??null,j=A?.state===`pending`||A?.state===`running`,{reload:M}=t,N=r(e=>e.status===`connected`);if((0,m.useEffect)(()=>{if(!N)return;let e=window.setInterval(M,j?g:_);return()=>window.clearInterval(e)},[M,j,N]),t.error&&!t.data)return(0,h.jsxs)(`div`,{className:`ct-page`,"data-testid":`storage-view`,children:[(0,h.jsx)(`header`,{className:`ct-page__head`,children:(0,h.jsx)(`div`,{className:`ct-page__head-text`,children:(0,h.jsx)(`h1`,{className:`ct-page__title`,children:`Storage`})})}),(0,h.jsx)(i,{message:t.error,tone:`error`,testId:`storage-error`})]});let P=t.data,F=async e=>{d(!0),x(null);try{await e()}catch(e){x(a(e))}finally{d(!1)}},I=()=>F(async()=>{T(await e(`sessions.storage.validate`,{}))}),L=()=>F(async()=>{D(await e(`sessions.storage.backup`,{}))}),R=()=>F(async()=>{k(!1);try{let t=await e(`sessions.storage.import`,{retryFailed:!0});c(t.status)}finally{M()}}),z=A!==null&&A.failed+A.capped>0;return(0,h.jsxs)(`div`,{className:`ct-page`,"data-testid":`storage-view`,children:[(0,h.jsx)(`header`,{className:`ct-page__head`,children:(0,h.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,h.jsx)(`h1`,{className:`ct-page__title`,children:`Storage`}),(0,h.jsx)(`p`,{className:`ct-page__sub`,children:`SQL session storage, legacy import progress and maintenance.`})]})}),(0,h.jsx)(l,{title:`Session storage`,testId:`storage-status`,sub:P?(0,h.jsxs)(`span`,{className:`ct-storage__meta`,children:[(0,h.jsx)(f,{tone:P.ready?`ok`:`warn`,label:P.ready?`Storage ready`:`Storage starting`}),(0,h.jsx)(`span`,{className:`ct-mono`,children:P.backend})]}):void 0,actions:P?(0,h.jsxs)(`div`,{className:`ct-storage__actions`,children:[P.backend===`postgres`?(0,h.jsx)(`span`,{className:`ct-storage__pgnote`,children:y}):(0,h.jsx)(o,{onClick:L,disabled:u,children:`Back up now`}),(0,h.jsx)(o,{variant:`primary`,onClick:I,disabled:u,children:`Validate`})]}):void 0,children:t.loading&&!P?(0,h.jsx)(i,{message:`Loading storage status…`,tone:`loading`,testId:`storage-loading`}):t.error?(0,h.jsx)(i,{message:t.error,tone:`error`,testId:`storage-status-error`}):P?(0,h.jsxs)(`div`,{className:`ct-storage__section`,children:[b?(0,h.jsx)(`p`,{className:`ct-storage__callout ct-storage__callout--error`,role:`alert`,children:b}):null,E?(0,h.jsxs)(`p`,{className:`ct-storage__callout ct-storage__callout--ok`,"data-testid":`backup-result`,children:[`Backup written: `,(0,h.jsx)(`span`,{className:`ct-mono`,children:E.path}),` ·`,` `,(0,h.jsxs)(`span`,{children:[E.bytes.toLocaleString(`en-AU`),` bytes`]})]}):null,(0,h.jsx)(S,{status:A}),z?(0,h.jsx)(`div`,{children:(0,h.jsx)(o,{onClick:()=>k(!0),disabled:u,children:`Retry failed imports`})}):null]}):null}),w?(0,h.jsx)(l,{title:`Validation`,testId:`storage-validate`,children:(0,h.jsx)(C,{result:w})}):null,(0,h.jsx)(p,{open:O,title:`Retry failed imports`,body:v,confirmLabel:`Retry failed imports`,busy:u,bodyClassName:`ct-storage__confirm-body`,onConfirm:R,onCancel:()=>k(!1)})]})}export{w as default};
1
+ import{_ as e,c as t,h as n,l as r,s as i,t as a}from"./format-CGs6a1G6.js";import{t as o}from"./Button-CGdLofSY.js";import{n as s}from"./use-gateway-query-D25QZANO.js";import{t as c}from"./Badge-CB5TWfdz.js";import{t as l}from"./Panel-9wOynsWc.js";import{t as u}from"./Stat-BZwg1PGE.js";import{t as d}from"./DataTable-CSi930kO.js";import{t as f}from"./StatusDot-DHhJ1VpB.js";import{t as p}from"./ConfirmDialog-B7aotBjN.js";var m=e(n(),1),h=t(),g=5e3,_=3e4,v=`Retry every failed legacy import, including ones past the attempt cap?`,y=`Use pg_dump / your managed Postgres backups for Postgres session storage.`;function b(e){switch(e.state){case`none`:return`No legacy JSONL data to import.`;case`pending`:return`Legacy import queued.`;case`running`:return`${e.done} of ${e.total} sources imported`;case`completed`:return e.total===0?`No legacy JSONL data to import.`:e.failed+e.capped===0?`All ${e.total} sources imported.`:`Legacy import finished: ${e.imported} of ${e.total} sources imported, ${e.failed} failed, ${e.capped} past the attempt cap.`;case`error`:return`Legacy import stopped: ${e.failed} failed sources, ${e.capped} past the attempt cap.`}}function x({status:e}){if(e.state!==`running`)return null;let t=e.total>0?Math.round(e.done/e.total*100):0;return(0,h.jsx)(`div`,{className:`ct-storage__progress`,role:`progressbar`,"aria-label":`Legacy import progress`,"aria-valuemin":0,"aria-valuemax":e.total,"aria-valuenow":e.done,children:(0,h.jsx)(`div`,{className:`ct-storage__progress-fill`,style:{width:`${t}%`}})})}function S({status:e}){return e?(0,h.jsxs)(`div`,{className:`ct-storage__section`,"data-testid":`import-section`,children:[(0,h.jsx)(`h3`,{className:`ct-storage__section-title`,children:`Legacy JSONL import`}),(0,h.jsx)(x,{status:e}),(0,h.jsx)(`p`,{className:`ct-storage__headline`,children:b(e)}),(0,h.jsxs)(`div`,{className:`ct-storage__counts`,children:[(0,h.jsx)(u,{label:`Pending`,value:e.pending}),(0,h.jsx)(u,{label:`Imported`,value:e.imported}),(0,h.jsx)(u,{label:`Failed`,value:e.failed}),(0,h.jsx)(u,{label:`Capped`,value:e.capped}),(0,h.jsx)(u,{label:`Vanished`,value:e.vanished}),(0,h.jsx)(u,{label:`Rejected entries`,value:e.rejectedEntries})]}),e.lastError?(0,h.jsx)(`p`,{className:`ct-storage__callout ct-storage__callout--error`,role:`alert`,children:e.lastError}):null,e.archiveRoot||e.backupPath?(0,h.jsxs)(`dl`,{className:`ct-storage__kv`,children:[e.archiveRoot?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{children:`Archive root`}),(0,h.jsx)(`dd`,{className:`ct-mono`,children:e.archiveRoot})]}):null,e.backupPath?(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(`dt`,{children:`Backup path`}),(0,h.jsx)(`dd`,{className:`ct-mono`,children:e.backupPath})]}):null]}):null]}):null}function C({result:e}){return(0,h.jsxs)(`div`,{className:`ct-storage__section`,"data-testid":`validate-section`,children:[(0,h.jsxs)(`h3`,{className:`ct-storage__section-title`,children:[`Validation`,` `,(0,h.jsx)(c,{tone:e.ok?`ok`:`danger`,children:e.ok?`all checks passed`:`checks failed`})]}),(0,h.jsx)(d,{columns:[{key:`name`,label:`Check`,render:e=>e.name},{key:`result`,label:`Result`,render:e=>(0,h.jsx)(c,{tone:e.ok?`ok`:`danger`,children:e.ok?`ok`:`failed`})},{key:`detail`,label:`Detail`,mono:!0,render:e=>e.detail??`—`}],rows:e.checks,rowKey:e=>e.name,label:`Storage validation checks`})]})}function w(){let e=r(e=>e.request),t=s(`sessions.storage.status`,{}),[n,c]=(0,m.useState)(null),[u,d]=(0,m.useState)(!1),[b,x]=(0,m.useState)(null),[w,T]=(0,m.useState)(null),[E,D]=(0,m.useState)(null),[O,k]=(0,m.useState)(!1);(0,m.useEffect)(()=>{t.data&&c(null)},[t.data]);let A=n??t.data?.legacyImport??null,j=A?.state===`pending`||A?.state===`running`,{reload:M}=t,N=r(e=>e.status===`connected`);if((0,m.useEffect)(()=>{if(!N)return;let e=window.setInterval(M,j?g:_);return()=>window.clearInterval(e)},[M,j,N]),t.error&&!t.data)return(0,h.jsxs)(`div`,{className:`ct-page`,"data-testid":`storage-view`,children:[(0,h.jsx)(`header`,{className:`ct-page__head`,children:(0,h.jsx)(`div`,{className:`ct-page__head-text`,children:(0,h.jsx)(`h1`,{className:`ct-page__title`,children:`Storage`})})}),(0,h.jsx)(i,{message:t.error,tone:`error`,testId:`storage-error`})]});let P=t.data,F=async e=>{d(!0),x(null);try{await e()}catch(e){x(a(e))}finally{d(!1)}},I=()=>F(async()=>{T(await e(`sessions.storage.validate`,{}))}),L=()=>F(async()=>{D(await e(`sessions.storage.backup`,{}))}),R=()=>F(async()=>{k(!1);try{let t=await e(`sessions.storage.import`,{retryFailed:!0});c(t.status)}finally{M()}}),z=A!==null&&A.failed+A.capped>0;return(0,h.jsxs)(`div`,{className:`ct-page`,"data-testid":`storage-view`,children:[(0,h.jsx)(`header`,{className:`ct-page__head`,children:(0,h.jsxs)(`div`,{className:`ct-page__head-text`,children:[(0,h.jsx)(`h1`,{className:`ct-page__title`,children:`Storage`}),(0,h.jsx)(`p`,{className:`ct-page__sub`,children:`SQL session storage, legacy import progress and maintenance.`})]})}),(0,h.jsx)(l,{title:`Session storage`,testId:`storage-status`,sub:P?(0,h.jsxs)(`span`,{className:`ct-storage__meta`,children:[(0,h.jsx)(f,{tone:P.ready?`ok`:`warn`,label:P.ready?`Storage ready`:`Storage starting`}),(0,h.jsx)(`span`,{className:`ct-mono`,children:P.backend})]}):void 0,actions:P?(0,h.jsxs)(`div`,{className:`ct-storage__actions`,children:[P.backend===`postgres`?(0,h.jsx)(`span`,{className:`ct-storage__pgnote`,children:y}):(0,h.jsx)(o,{onClick:L,disabled:u,children:`Back up now`}),(0,h.jsx)(o,{variant:`primary`,onClick:I,disabled:u,children:`Validate`})]}):void 0,children:t.loading&&!P?(0,h.jsx)(i,{message:`Loading storage status…`,tone:`loading`,testId:`storage-loading`}):t.error?(0,h.jsx)(i,{message:t.error,tone:`error`,testId:`storage-status-error`}):P?(0,h.jsxs)(`div`,{className:`ct-storage__section`,children:[b?(0,h.jsx)(`p`,{className:`ct-storage__callout ct-storage__callout--error`,role:`alert`,children:b}):null,E?(0,h.jsxs)(`p`,{className:`ct-storage__callout ct-storage__callout--ok`,"data-testid":`backup-result`,children:[`Backup written: `,(0,h.jsx)(`span`,{className:`ct-mono`,children:E.path}),` ·`,` `,(0,h.jsxs)(`span`,{children:[E.bytes.toLocaleString(`en-AU`),` bytes`]})]}):null,(0,h.jsx)(S,{status:A}),z?(0,h.jsx)(`div`,{children:(0,h.jsx)(o,{onClick:()=>k(!0),disabled:u,children:`Retry failed imports`})}):null]}):null}),w?(0,h.jsx)(l,{title:`Validation`,testId:`storage-validate`,children:(0,h.jsx)(C,{result:w})}):null,(0,h.jsx)(p,{open:O,title:`Retry failed imports`,body:v,confirmLabel:`Retry failed imports`,busy:u,bodyClassName:`ct-storage__confirm-body`,onConfirm:R,onCancel:()=>k(!1)})]})}export{w as default};
@@ -1 +1 @@
1
- import{_ as e,c as t,h as n,i as r}from"./format-dlOOV12I.js";import{i}from"./index-OijNknZs.js";import{t as a}from"./Badge-4n2tRQ02.js";var o=e(n(),1),s=t();function c(e){let[t,n]=(0,o.useState)(()=>Date.now()),r=i();return(0,o.useEffect)(()=>{if(!r)return;let t=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(t)},[r,e]),t}function l({at:e,error:t}){let n=c(1e4);return e===null?null:(0,s.jsxs)(`span`,{className:`ct-updated`,"data-testid":`updated-ago`,title:t??void 0,children:[t?(0,s.jsx)(a,{tone:`warn`,children:`Stale`}):null,`Updated ${r(e,Math.max(n,e))}`]})}export{l as t};
1
+ import{_ as e,c as t,h as n,i as r}from"./format-CGs6a1G6.js";import{i}from"./index-BvXiY83i.js";import{t as a}from"./Badge-CB5TWfdz.js";var o=e(n(),1),s=t();function c(e){let[t,n]=(0,o.useState)(()=>Date.now()),r=i();return(0,o.useEffect)(()=>{if(!r)return;let t=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(t)},[r,e]),t}function l({at:e,error:t}){let n=c(1e4);return e===null?null:(0,s.jsxs)(`span`,{className:`ct-updated`,"data-testid":`updated-ago`,title:t??void 0,children:[t?(0,s.jsx)(a,{tone:`warn`,children:`Stale`}):null,`Updated ${r(e,Math.max(n,e))}`]})}export{l as t};