@spencerboucher/switchyard 0.10.0 → 0.12.0

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 (129) hide show
  1. package/README.md +4 -1
  2. package/dist/bridge/agent-channel.js +449 -0
  3. package/dist/bridge/agent-tools.js +235 -0
  4. package/dist/bridge/message-delivery.js +185 -0
  5. package/dist/bridge/pi-model.js +12 -0
  6. package/dist/bridge/policy.js +213 -0
  7. package/dist/bridge/switchyard-bridge.js +73 -3
  8. package/dist/bridge/switchyard-terminal.js +143 -12
  9. package/dist/bridge/tool-preflight.js +155 -0
  10. package/dist/policies/worker.js +2877 -0
  11. package/dist/switchyard.mjs +19268 -10196
  12. package/dist/terminal/holder.js +47 -1
  13. package/package.json +3 -1
  14. package/web-dist/assets/AutomationView-BRVq9y-T.js +2 -0
  15. package/web-dist/assets/AutomationView-BRVq9y-T.js.map +1 -0
  16. package/web-dist/assets/{Card-CAFxHoHd.js → Card-BqrWFEYY.js} +2 -2
  17. package/web-dist/assets/{Card-CAFxHoHd.js.map → Card-BqrWFEYY.js.map} +1 -1
  18. package/web-dist/assets/{Checkbox-rDvnQnxc.js → Checkbox-DExv3fUO.js} +2 -2
  19. package/web-dist/assets/{Checkbox-rDvnQnxc.js.map → Checkbox-DExv3fUO.js.map} +1 -1
  20. package/web-dist/assets/{Copy-D8xhl7eJ.js → Copy-BuBbxEQI.js} +2 -2
  21. package/web-dist/assets/{Copy-D8xhl7eJ.js.map → Copy-BuBbxEQI.js.map} +1 -1
  22. package/web-dist/assets/{InteractionCard-Yu5wgLC3.js → InteractionCard-0PH6pIkH.js} +4 -4
  23. package/web-dist/assets/{InteractionCard-Yu5wgLC3.js.map → InteractionCard-0PH6pIkH.js.map} +1 -1
  24. package/web-dist/assets/{Menu-euseM8yR.js → Menu-BJ3Gyh5V.js} +2 -2
  25. package/web-dist/assets/{Menu-euseM8yR.js.map → Menu-BJ3Gyh5V.js.map} +1 -1
  26. package/web-dist/assets/Overlay-BgqVqKc6.js +2 -0
  27. package/web-dist/assets/Overlay-BgqVqKc6.js.map +1 -0
  28. package/web-dist/assets/Priority-B2tdgI2D.js +2 -0
  29. package/web-dist/assets/{Priority-Ca1B2yFr.js.map → Priority-B2tdgI2D.js.map} +1 -1
  30. package/web-dist/assets/{SegmentedControl-D2d-NEr-.js → SegmentedControl-DzwdZG6q.js} +2 -2
  31. package/web-dist/assets/{SegmentedControl-D2d-NEr-.js.map → SegmentedControl-DzwdZG6q.js.map} +1 -1
  32. package/web-dist/assets/{Select-C9L1HKMm.js → Select-DZ-qJ_AO.js} +2 -2
  33. package/web-dist/assets/{Select-C9L1HKMm.js.map → Select-DZ-qJ_AO.js.map} +1 -1
  34. package/web-dist/assets/{Switch-DAcUcSbH.js → Switch-DKiwAXXz.js} +2 -2
  35. package/web-dist/assets/{Switch-DAcUcSbH.js.map → Switch-DKiwAXXz.js.map} +1 -1
  36. package/web-dist/assets/{Tabs-xtagjtA5.js → Tabs-HOeWNnHD.js} +4 -4
  37. package/web-dist/assets/{Tabs-xtagjtA5.js.map → Tabs-HOeWNnHD.js.map} +1 -1
  38. package/web-dist/assets/{TextArea-CKGHwURx.js → TextArea-DK1uv3xX.js} +2 -2
  39. package/web-dist/assets/{TextArea-CKGHwURx.js.map → TextArea-DK1uv3xX.js.map} +1 -1
  40. package/web-dist/assets/{TextLink-Bub7sMxr.js → TextLink-BoFPQuaH.js} +2 -2
  41. package/web-dist/assets/{TextLink-Bub7sMxr.js.map → TextLink-BoFPQuaH.js.map} +1 -1
  42. package/web-dist/assets/attention-D1G0KCOr.js +2 -0
  43. package/web-dist/assets/attention-D1G0KCOr.js.map +1 -0
  44. package/web-dist/assets/automations-DUUAfMK8.js +2 -0
  45. package/web-dist/assets/{automations-BzpsJoa3.js.map → automations-DUUAfMK8.js.map} +1 -1
  46. package/web-dist/assets/board-tIuyEKO0.js +10 -0
  47. package/web-dist/assets/board-tIuyEKO0.js.map +1 -0
  48. package/web-dist/assets/code-B1njb2Cr.css +1 -0
  49. package/web-dist/assets/code-O-DyPB50.js +25 -0
  50. package/web-dist/assets/code-O-DyPB50.js.map +1 -0
  51. package/web-dist/assets/describe-BW5uUuvy.js +5 -0
  52. package/web-dist/assets/{describe-CVXeUClF.js.map → describe-BW5uUuvy.js.map} +1 -1
  53. package/web-dist/assets/enroll-CL0BGGhd.js +2 -0
  54. package/web-dist/assets/{enroll-jnKygG4L.js.map → enroll-CL0BGGhd.js.map} +1 -1
  55. package/web-dist/assets/index-D-JHf__5.css +2 -0
  56. package/web-dist/assets/index-K0QOY1Li.js +11 -0
  57. package/web-dist/assets/index-K0QOY1Li.js.map +1 -0
  58. package/web-dist/assets/more-DNN_mtX8.js +2 -0
  59. package/web-dist/assets/{more-DvKHMdBk.js.map → more-DNN_mtX8.js.map} +1 -1
  60. package/web-dist/assets/plus-BLP-wIYD.js +2 -0
  61. package/web-dist/assets/plus-BLP-wIYD.js.map +1 -0
  62. package/web-dist/assets/policyLogic-BKSj6mhC.js +2 -0
  63. package/web-dist/assets/policyLogic-BKSj6mhC.js.map +1 -0
  64. package/web-dist/assets/preload-helper-BudhqmWi.js +13 -0
  65. package/web-dist/assets/preload-helper-BudhqmWi.js.map +1 -0
  66. package/web-dist/assets/queue-k4o-I9uY.js +2 -0
  67. package/web-dist/assets/{queue-B2Vl0uSh.js.map → queue-k4o-I9uY.js.map} +1 -1
  68. package/web-dist/assets/repo-CSQAnBaF.js +2 -0
  69. package/web-dist/assets/repo-CSQAnBaF.js.map +1 -0
  70. package/web-dist/assets/settings-CrYZRJ7E.js +7 -0
  71. package/web-dist/assets/settings-CrYZRJ7E.js.map +1 -0
  72. package/web-dist/assets/shared-DIA598ns.js +3 -0
  73. package/web-dist/assets/shared-DIA598ns.js.map +1 -0
  74. package/web-dist/assets/states-C8oEFqek.js +58 -0
  75. package/web-dist/assets/states-C8oEFqek.js.map +1 -0
  76. package/web-dist/assets/{terminal-login-BK5UjUir.js → terminal-login-M5orrPPe.js} +2 -2
  77. package/web-dist/assets/{terminal-login-BK5UjUir.js.map → terminal-login-M5orrPPe.js.map} +1 -1
  78. package/web-dist/assets/timer-BCIucSXh.js +2 -0
  79. package/web-dist/assets/timer-BCIucSXh.js.map +1 -0
  80. package/web-dist/assets/useBreakpoint-CA0Mbmvv.js +2 -0
  81. package/web-dist/assets/useBreakpoint-CA0Mbmvv.js.map +1 -0
  82. package/web-dist/assets/useNow-Dx0MCCez.js +2 -0
  83. package/web-dist/assets/useNow-Dx0MCCez.js.map +1 -0
  84. package/web-dist/assets/{useResource-BBqCoY2q.js → useResource-BTjwa4tV.js} +2 -2
  85. package/web-dist/assets/{useResource-BBqCoY2q.js.map → useResource-BTjwa4tV.js.map} +1 -1
  86. package/web-dist/index.html +10 -7
  87. package/web-dist/sw.js +1 -1
  88. package/web-dist/sw.js.map +1 -1
  89. package/web-dist/assets/AutomationView-BsTwLnMp.js +0 -2
  90. package/web-dist/assets/AutomationView-BsTwLnMp.js.map +0 -1
  91. package/web-dist/assets/Field-Dbg_8KTt.js +0 -2
  92. package/web-dist/assets/Field-Dbg_8KTt.js.map +0 -1
  93. package/web-dist/assets/Overlay-BNPvMjLX.js +0 -2
  94. package/web-dist/assets/Overlay-BNPvMjLX.js.map +0 -1
  95. package/web-dist/assets/Priority-Ca1B2yFr.js +0 -2
  96. package/web-dist/assets/StatusChip-BYuVxYS7.js +0 -2
  97. package/web-dist/assets/StatusChip-BYuVxYS7.js.map +0 -1
  98. package/web-dist/assets/attention-CI4dHY81.js +0 -2
  99. package/web-dist/assets/attention-CI4dHY81.js.map +0 -1
  100. package/web-dist/assets/auth-308hUVgi.js +0 -2
  101. package/web-dist/assets/auth-308hUVgi.js.map +0 -1
  102. package/web-dist/assets/automations-BzpsJoa3.js +0 -2
  103. package/web-dist/assets/bell-DSwa2PAb.js +0 -2
  104. package/web-dist/assets/bell-DSwa2PAb.js.map +0 -1
  105. package/web-dist/assets/board-CeJxBVHC.js +0 -10
  106. package/web-dist/assets/board-CeJxBVHC.js.map +0 -1
  107. package/web-dist/assets/code-DkNQvMI9.js +0 -12
  108. package/web-dist/assets/code-DkNQvMI9.js.map +0 -1
  109. package/web-dist/assets/describe-CVXeUClF.js +0 -5
  110. package/web-dist/assets/enroll-jnKygG4L.js +0 -2
  111. package/web-dist/assets/index-BHGZTS2e.js +0 -16
  112. package/web-dist/assets/index-BHGZTS2e.js.map +0 -1
  113. package/web-dist/assets/index-D2ml031z.css +0 -2
  114. package/web-dist/assets/more-DvKHMdBk.js +0 -2
  115. package/web-dist/assets/queue-B2Vl0uSh.js +0 -2
  116. package/web-dist/assets/repo-BDS8RBxq.js +0 -2
  117. package/web-dist/assets/repo-BDS8RBxq.js.map +0 -1
  118. package/web-dist/assets/server-BqZ-w6M8.js +0 -2
  119. package/web-dist/assets/server-BqZ-w6M8.js.map +0 -1
  120. package/web-dist/assets/settings-CLt7x9u8.js +0 -8
  121. package/web-dist/assets/settings-CLt7x9u8.js.map +0 -1
  122. package/web-dist/assets/states-C773NlHo.js +0 -56
  123. package/web-dist/assets/states-C773NlHo.js.map +0 -1
  124. package/web-dist/assets/useBackTo-BIrCq3W2.js +0 -2
  125. package/web-dist/assets/useBackTo-BIrCq3W2.js.map +0 -1
  126. package/web-dist/assets/useBreakpoint-BphHBrzF.js +0 -2
  127. package/web-dist/assets/useBreakpoint-BphHBrzF.js.map +0 -1
  128. package/web-dist/assets/useNow-Cm-tdyod.js +0 -2
  129. package/web-dist/assets/useNow-Cm-tdyod.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"StatusChip-BYuVxYS7.js","names":["__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","__iconData","MessageCircleQuestion","__commonJSMin","require_react","require_jsx_runtime","MessageCircleQuestionMark","CircleAlert","cn","InteractionState","Spinner","TriangleAlert","Inbox","RefreshCw","Clock","CircleX","WifiOff","CircleCheck","require_react_dom_production","React","formatProdErrorMessage","url","code","i","noop","Internals","REACT_PORTAL_TYPE","REACT_RECOVERABLE_TYPE","REACT_OPTIMISTIC_KEY","createPortal$1","key","ReactSharedInternals","getCrossOriginStringAs","as","input","reason","container","children","previousTransition","previousUpdatePriority","fn","href","options","crossOrigin","integrity","fetchPriority","form","a","action","initialState","permalink","require_react_dom","checkDCE","err","__iconData$14","Activity","createLucideIcon","__iconData$13","Ban","__iconData$12","CircleDashed","__iconData$11","CircleDot","__iconData$10","CirclePause","__iconData$9","CirclePlay","__iconData$8","CircleSlash","__iconData$7","CloudOff","__iconData$6","Eye","__iconData$5","Hourglass","__iconData$4","ListChecks","__iconData$3","LoaderCircle","__iconData$2","Repeat","__iconData$1","Square","__iconData","Wifi","import_jsx_runtime","TONE_CLASSES","TONE_TEXT","Badge","tone","className","label","CountBadge","count","RUNTIME_STATUS","REVIEW_STATUS","TASK_STATUS","RUN_STATUS","HOST_STATUS","CONNECTION_STATUS","INTERACTION_STATUS","ATTENTION_STATUS","OCCURRENCE_STATUS","FALLBACK","statusInfo","props","s","StatusChip","info","Icon","sm","InlineStatus","spin"],"sources":["../../../../node_modules/.pnpm/react-dom@19.3.1_react@19.3.1/node_modules/react-dom/cjs/react-dom.production.js","../../../../node_modules/.pnpm/react-dom@19.3.1_react@19.3.1/node_modules/react-dom/index.js","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/activity.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/ban.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/circle-dashed.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/circle-dot.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/circle-pause.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/circle-play.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/circle-slash.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/cloud-off.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/eye.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/hourglass.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/list-checks.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/loader-circle.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/repeat.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/square.mjs","../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/wifi.mjs","../../src/components/ui/Badge.tsx","../../src/components/ui/StatusChip.tsx"],"sourcesContent":["/**\n * @license React\n * react-dom.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar React = require(\"react\");\nfunction formatProdErrorMessage(code) {\n var url = \"https://react.dev/errors/\" + code;\n if (1 < arguments.length) {\n url += \"?args[]=\" + encodeURIComponent(arguments[1]);\n for (var i = 2; i < arguments.length; i++)\n url += \"&args[]=\" + encodeURIComponent(arguments[i]);\n }\n return (\n \"Minified React error #\" +\n code +\n \"; visit \" +\n url +\n \" for the full message or use the non-minified dev environment for full errors and additional helpful warnings.\"\n );\n}\nfunction noop() {}\nvar Internals = {\n d: {\n f: noop,\n r: function () {\n throw Error(formatProdErrorMessage(522));\n },\n D: noop,\n C: noop,\n L: noop,\n m: noop,\n X: noop,\n S: noop,\n M: noop\n },\n p: 0,\n findDOMNode: null\n },\n REACT_PORTAL_TYPE = Symbol.for(\"react.portal\"),\n REACT_RECOVERABLE_TYPE = Symbol.for(\"react.recoverable\"),\n REACT_OPTIMISTIC_KEY = Symbol.for(\"react.optimistic_key\");\nfunction createPortal$1(children, containerInfo, implementation) {\n var key =\n 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null;\n return {\n $$typeof: REACT_PORTAL_TYPE,\n key:\n null == key\n ? null\n : key === REACT_OPTIMISTIC_KEY\n ? REACT_OPTIMISTIC_KEY\n : \"\" + key,\n children: children,\n containerInfo: containerInfo,\n implementation: implementation\n };\n}\nvar ReactSharedInternals =\n React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;\nfunction getCrossOriginStringAs(as, input) {\n if (\"font\" === as) return \"\";\n if (\"string\" === typeof input)\n return \"use-credentials\" === input ? input : \"\";\n}\nexports.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE =\n Internals;\nexports.browser = function (reason) {\n return { $$typeof: REACT_RECOVERABLE_TYPE, _reason: reason };\n};\nexports.createPortal = function (children, container) {\n var key =\n 2 < arguments.length && void 0 !== arguments[2] ? arguments[2] : null;\n if (\n !container ||\n (1 !== container.nodeType &&\n 9 !== container.nodeType &&\n 11 !== container.nodeType)\n )\n throw Error(formatProdErrorMessage(299));\n return createPortal$1(children, container, null, key);\n};\nexports.flushSync = function (fn) {\n var previousTransition = ReactSharedInternals.T,\n previousUpdatePriority = Internals.p;\n try {\n if (((ReactSharedInternals.T = null), (Internals.p = 2), fn)) return fn();\n } finally {\n (ReactSharedInternals.T = previousTransition),\n (Internals.p = previousUpdatePriority),\n Internals.d.f();\n }\n};\nexports.preconnect = function (href, options) {\n \"string\" === typeof href &&\n (options\n ? ((options = options.crossOrigin),\n (options =\n \"string\" === typeof options\n ? \"use-credentials\" === options\n ? options\n : \"\"\n : void 0))\n : (options = null),\n Internals.d.C(href, options));\n};\nexports.prefetchDNS = function (href) {\n \"string\" === typeof href && Internals.d.D(href);\n};\nexports.preinit = function (href, options) {\n if (\"string\" === typeof href && options && \"string\" === typeof options.as) {\n var as = options.as,\n crossOrigin = getCrossOriginStringAs(as, options.crossOrigin),\n integrity =\n \"string\" === typeof options.integrity ? options.integrity : void 0,\n fetchPriority =\n \"string\" === typeof options.fetchPriority\n ? options.fetchPriority\n : void 0;\n \"style\" === as\n ? Internals.d.S(\n href,\n \"string\" === typeof options.precedence ? options.precedence : void 0,\n {\n crossOrigin: crossOrigin,\n integrity: integrity,\n fetchPriority: fetchPriority\n }\n )\n : \"script\" === as &&\n Internals.d.X(href, {\n crossOrigin: crossOrigin,\n integrity: integrity,\n fetchPriority: fetchPriority,\n nonce: \"string\" === typeof options.nonce ? options.nonce : void 0\n });\n }\n};\nexports.preinitModule = function (href, options) {\n if (\"string\" === typeof href)\n if (\"object\" === typeof options && null !== options) {\n if (null == options.as || \"script\" === options.as) {\n var crossOrigin = getCrossOriginStringAs(\n options.as,\n options.crossOrigin\n );\n Internals.d.M(href, {\n crossOrigin: crossOrigin,\n integrity:\n \"string\" === typeof options.integrity ? options.integrity : void 0,\n nonce: \"string\" === typeof options.nonce ? options.nonce : void 0,\n fetchPriority:\n \"string\" === typeof options.fetchPriority\n ? options.fetchPriority\n : void 0\n });\n }\n } else null == options && Internals.d.M(href);\n};\nexports.preload = function (href, options) {\n if (\n \"string\" === typeof href &&\n \"object\" === typeof options &&\n null !== options &&\n \"string\" === typeof options.as\n ) {\n var as = options.as,\n crossOrigin = getCrossOriginStringAs(as, options.crossOrigin);\n Internals.d.L(href, as, {\n crossOrigin: crossOrigin,\n integrity:\n \"string\" === typeof options.integrity ? options.integrity : void 0,\n nonce: \"string\" === typeof options.nonce ? options.nonce : void 0,\n type: \"string\" === typeof options.type ? options.type : void 0,\n fetchPriority:\n \"string\" === typeof options.fetchPriority\n ? options.fetchPriority\n : void 0,\n referrerPolicy:\n \"string\" === typeof options.referrerPolicy\n ? options.referrerPolicy\n : void 0,\n imageSrcSet:\n \"string\" === typeof options.imageSrcSet ? options.imageSrcSet : void 0,\n imageSizes:\n \"string\" === typeof options.imageSizes ? options.imageSizes : void 0,\n media: \"string\" === typeof options.media ? options.media : void 0\n });\n }\n};\nexports.preloadModule = function (href, options) {\n if (\"string\" === typeof href)\n if (options) {\n var crossOrigin = getCrossOriginStringAs(options.as, options.crossOrigin);\n Internals.d.m(href, {\n as:\n \"string\" === typeof options.as && \"script\" !== options.as\n ? options.as\n : void 0,\n crossOrigin: crossOrigin,\n integrity:\n \"string\" === typeof options.integrity ? options.integrity : void 0,\n nonce: \"string\" === typeof options.nonce ? options.nonce : void 0,\n fetchPriority:\n \"string\" === typeof options.fetchPriority\n ? options.fetchPriority\n : void 0\n });\n } else Internals.d.m(href);\n};\nexports.requestFormReset = function (form) {\n Internals.d.r(form);\n};\nexports.unstable_batchedUpdates = function (fn, a) {\n return fn(a);\n};\nexports.useFormState = function (action, initialState, permalink) {\n return ReactSharedInternals.H.useFormState(action, initialState, permalink);\n};\nexports.useFormStatus = function () {\n return ReactSharedInternals.H.useHostTransitionStatus();\n};\nexports.version = \"19.3.1\";\n","'use strict';\n\nfunction checkDCE() {\n /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */\n if (\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined' ||\n typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE !== 'function'\n ) {\n return;\n }\n if (process.env.NODE_ENV !== 'production') {\n // This branch is unreachable because this function is only called\n // in production, but the condition is true only in development.\n // Therefore if the branch is still here, dead code elimination wasn't\n // properly applied.\n // Don't change the message. React DevTools relies on it. Also make sure\n // this message doesn't occur elsewhere in this function, or it will cause\n // a false positive.\n throw new Error('^_^');\n }\n try {\n // Verify that the code above has been dead code eliminated (DCE'd).\n __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(checkDCE);\n } catch (err) {\n // DevTools shouldn't crash React, no matter what.\n // We should still report in case we break this code.\n console.error(err);\n }\n}\n\nif (process.env.NODE_ENV === 'production') {\n // DCE check should happen before ReactDOM bundle executes so that\n // DevTools can report bad minification during injection.\n checkDCE();\n module.exports = require('./cjs/react-dom.production.js');\n} else {\n module.exports = require('./cjs/react-dom.development.js');\n}\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"activity\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2\",\n key: \"169zse\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Activity = createLucideIcon(__iconData);\n\nexport { __iconData, Activity as default };\n//# sourceMappingURL=activity.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"ban\",\n size: 24,\n node: [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"path\", { d: \"M4.929 4.929 19.07 19.071\", key: \"196cmz\" }]\n ]\n};\n__iconData.node;\nconst Ban = createLucideIcon(__iconData);\n\nexport { __iconData, Ban as default };\n//# sourceMappingURL=ban.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"circle-dashed\",\n size: 24,\n node: [\n [\"path\", { d: \"M10.1 2.182a10 10 0 0 1 3.8 0\", key: \"5ilxe3\" }],\n [\"path\", { d: \"M13.9 21.818a10 10 0 0 1-3.8 0\", key: \"11zvb9\" }],\n [\"path\", { d: \"M17.609 3.721a10 10 0 0 1 2.69 2.7\", key: \"1iw5b2\" }],\n [\"path\", { d: \"M2.182 13.9a10 10 0 0 1 0-3.8\", key: \"c0bmvh\" }],\n [\"path\", { d: \"M20.279 17.609a10 10 0 0 1-2.7 2.69\", key: \"1ruxm7\" }],\n [\"path\", { d: \"M21.818 10.1a10 10 0 0 1 0 3.8\", key: \"qkgqxc\" }],\n [\"path\", { d: \"M3.721 6.391a10 10 0 0 1 2.7-2.69\", key: \"1mcia2\" }],\n [\"path\", { d: \"M6.391 20.279a10 10 0 0 1-2.69-2.7\", key: \"1fvljs\" }]\n ]\n};\n__iconData.node;\nconst CircleDashed = createLucideIcon(__iconData);\n\nexport { __iconData, CircleDashed as default };\n//# sourceMappingURL=circle-dashed.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"circle-dot\",\n size: 24,\n node: [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"1\", key: \"41hilf\" }],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }]\n ]\n};\n__iconData.node;\nconst CircleDot = createLucideIcon(__iconData);\n\nexport { __iconData, CircleDot as default };\n//# sourceMappingURL=circle-dot.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"circle-pause\",\n size: 24,\n node: [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"line\", { x1: \"10\", x2: \"10\", y1: \"15\", y2: \"9\", key: \"c1nkhi\" }],\n [\"line\", { x1: \"14\", x2: \"14\", y1: \"15\", y2: \"9\", key: \"h65svq\" }]\n ],\n aliases: [\"pause-circle\"]\n};\n__iconData.node;\nconst CirclePause = createLucideIcon(__iconData);\n\nexport { __iconData, CirclePause as default };\n//# sourceMappingURL=circle-pause.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"circle-play\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z\",\n key: \"kmsa83\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }]\n ],\n aliases: [\"play-circle\"]\n};\n__iconData.node;\nconst CirclePlay = createLucideIcon(__iconData);\n\nexport { __iconData, CirclePlay as default };\n//# sourceMappingURL=circle-play.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"circle-slash\",\n size: 24,\n node: [\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"10\", key: \"1mglay\" }],\n [\"line\", { x1: \"9\", x2: \"15\", y1: \"15\", y2: \"9\", key: \"1dfufj\" }]\n ]\n};\n__iconData.node;\nconst CircleSlash = createLucideIcon(__iconData);\n\nexport { __iconData, CircleSlash as default };\n//# sourceMappingURL=circle-slash.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"cloud-off\",\n size: 24,\n node: [\n [\n \"path\",\n { d: \"M10.94 5.274A7 7 0 0 1 15.71 10h1.79a4.5 4.5 0 0 1 4.222 6.057\", key: \"1uxyv8\" }\n ],\n [\"path\", { d: \"M18.796 18.81A4.5 4.5 0 0 1 17.5 19H9A7 7 0 0 1 5.79 5.78\", key: \"99tcn7\" }],\n [\"path\", { d: \"m2 2 20 20\", key: \"1ooewy\" }]\n ]\n};\n__iconData.node;\nconst CloudOff = createLucideIcon(__iconData);\n\nexport { __iconData, CloudOff as default };\n//# sourceMappingURL=cloud-off.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"eye\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0\",\n key: \"1nclc0\"\n }\n ],\n [\"circle\", { cx: \"12\", cy: \"12\", r: \"3\", key: \"1v7zrd\" }]\n ]\n};\n__iconData.node;\nconst Eye = createLucideIcon(__iconData);\n\nexport { __iconData, Eye as default };\n//# sourceMappingURL=eye.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"hourglass\",\n size: 24,\n node: [\n [\"path\", { d: \"M5 22h14\", key: \"ehvnwv\" }],\n [\"path\", { d: \"M5 2h14\", key: \"pdyrp9\" }],\n [\n \"path\",\n {\n d: \"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22\",\n key: \"1d314k\"\n }\n ],\n [\n \"path\",\n {\n d: \"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2\",\n key: \"1vvvr6\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Hourglass = createLucideIcon(__iconData);\n\nexport { __iconData, Hourglass as default };\n//# sourceMappingURL=hourglass.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"list-checks\",\n size: 24,\n node: [\n [\"path\", { d: \"M13 5h8\", key: \"a7qcls\" }],\n [\"path\", { d: \"M13 12h8\", key: \"h98zly\" }],\n [\"path\", { d: \"M13 19h8\", key: \"c3s6r1\" }],\n [\"path\", { d: \"m3 17 2 2 4-4\", key: \"1jhpwq\" }],\n [\"path\", { d: \"m3 7 2 2 4-4\", key: \"1obspn\" }]\n ]\n};\n__iconData.node;\nconst ListChecks = createLucideIcon(__iconData);\n\nexport { __iconData, ListChecks as default };\n//# sourceMappingURL=list-checks.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"loader-circle\",\n size: 24,\n node: [[\"path\", { d: \"M21 12a9 9 0 1 1-6.219-8.56\", key: \"13zald\" }]],\n aliases: [\"loader-2\"]\n};\n__iconData.node;\nconst LoaderCircle = createLucideIcon(__iconData);\n\nexport { __iconData, LoaderCircle as default };\n//# sourceMappingURL=loader-circle.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"repeat\",\n size: 24,\n node: [\n [\"path\", { d: \"m17 2 4 4-4 4\", key: \"nntrym\" }],\n [\"path\", { d: \"M3 11v-1a4 4 0 0 1 4-4h14\", key: \"84bu3i\" }],\n [\"path\", { d: \"m7 22-4-4 4-4\", key: \"1wqhfi\" }],\n [\"path\", { d: \"M21 13v1a4 4 0 0 1-4 4H3\", key: \"1rx37r\" }]\n ]\n};\n__iconData.node;\nconst Repeat = createLucideIcon(__iconData);\n\nexport { __iconData, Repeat as default };\n//# sourceMappingURL=repeat.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"square\",\n size: 24,\n node: [[\"rect\", { width: \"18\", height: \"18\", x: \"3\", y: \"3\", rx: \"2\", key: \"afitv7\" }]]\n};\n__iconData.node;\nconst Square = createLucideIcon(__iconData);\n\nexport { __iconData, Square as default };\n//# sourceMappingURL=square.mjs.map\n","/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"wifi\",\n size: 24,\n node: [\n [\"path\", { d: \"M12 20h.01\", key: \"zekei9\" }],\n [\"path\", { d: \"M2 8.82a15 15 0 0 1 20 0\", key: \"dnpr2z\" }],\n [\"path\", { d: \"M5 12.859a10 10 0 0 1 14 0\", key: \"1x1e6c\" }],\n [\"path\", { d: \"M8.5 16.429a5 5 0 0 1 7 0\", key: \"1bycff\" }]\n ]\n};\n__iconData.node;\nconst Wifi = createLucideIcon(__iconData);\n\nexport { __iconData, Wifi as default };\n//# sourceMappingURL=wifi.mjs.map\n","import type { ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn\";\n\nexport type Tone = \"neutral\" | \"info\" | \"success\" | \"warning\" | \"danger\" | \"accent\";\n\nexport const TONE_CLASSES: Record<Tone, string> = {\n neutral: \"bg-surface-2 text-muted border-border\",\n info: \"bg-info-soft text-info border-transparent\",\n success: \"bg-success-soft text-success border-transparent\",\n warning: \"bg-warning-soft text-warning border-transparent\",\n danger: \"bg-danger-soft text-danger border-transparent\",\n accent: \"bg-accent text-accent-fg border-transparent\",\n};\n\n/** Text colour for each tone (the Badge classes colour the background too). */\nexport const TONE_TEXT: Record<Tone, string> = {\n neutral: \"text-muted\",\n info: \"text-info\",\n success: \"text-success\",\n warning: \"text-warning\",\n danger: \"text-danger\",\n accent: \"text-accent\",\n};\n\nexport interface BadgeProps {\n children: ReactNode;\n tone?: Tone;\n /** Accessible text when the visible content is terse (e.g. a count). */\n label?: string;\n className?: string;\n}\n\n/** Small pill for counts and tags. */\nexport function Badge({ children, tone = \"neutral\", label, className }: BadgeProps) {\n return (\n <span\n className={cn(\n \"inline-flex min-w-5 items-center justify-center rounded-full border px-1.5 text-xs leading-5 font-medium tabular-nums\",\n TONE_CLASSES[tone],\n className,\n )}\n title={label}\n >\n <span aria-hidden={label ? true : undefined}>{children}</span>\n {label && <span className=\"sr-only\">{label}</span>}\n </span>\n );\n}\n\n/** Count badge; renders nothing at zero. Caps at 99+. */\nexport function CountBadge({\n count,\n label,\n tone = \"danger\",\n className,\n}: {\n count: number;\n label: string;\n tone?: Tone;\n className?: string;\n}) {\n if (count <= 0) return null;\n return (\n <Badge tone={tone} label={`${count} ${label}`} className={className}>\n {count > 99 ? \"99+\" : count}\n </Badge>\n );\n}\n","import type {\n AttentionReason,\n Connectivity,\n OccurrenceState,\n RunState,\n RuntimeState,\n TaskState,\n} from \"@switchyard/protocol\";\nimport { InteractionState } from \"@switchyard/protocol\";\nimport {\n Activity,\n Ban,\n CircleAlert,\n CircleCheck,\n CircleDashed,\n CircleDot,\n CirclePause,\n CirclePlay,\n CircleSlash,\n CircleX,\n Clock,\n CloudOff,\n Eye,\n Hourglass,\n Inbox,\n ListChecks,\n LoaderCircle,\n type LucideIcon,\n MessageCircleQuestion,\n RefreshCw,\n Repeat,\n Square,\n TriangleAlert,\n Wifi,\n WifiOff,\n} from \"lucide-react\";\nimport type { ReactNode } from \"react\";\nimport { cn } from \"../../lib/cn\";\nimport type { ConnectionState } from \"../../sync/store\";\nimport { TONE_CLASSES, type Tone } from \"./Badge\";\nimport { Spinner } from \"./Spinner\";\n\n/** A status presentation: always an icon plus a text label (never color alone). */\nexport interface StatusInfo {\n label: string;\n icon: LucideIcon;\n tone: Tone;\n /** Spin the icon (in-flight states). */\n spin?: boolean;\n /** Pulse the icon (ongoing, not transitional). */\n pulse?: boolean;\n}\n\nexport const RUNTIME_STATUS: Record<RuntimeState, StatusInfo> = {\n starting: { label: \"Starting…\", icon: LoaderCircle, tone: \"info\", spin: true },\n idle: { label: \"Idle\", icon: CircleDot, tone: \"neutral\" },\n running: { label: \"Running\", icon: Activity, tone: \"info\", pulse: true },\n waiting_input: { label: \"Needs input\", icon: MessageCircleQuestion, tone: \"warning\" },\n interrupted: { label: \"Interrupted\", icon: CirclePause, tone: \"warning\" },\n failed: { label: \"Failed\", icon: CircleX, tone: \"danger\" },\n stopped: { label: \"Stopped\", icon: Square, tone: \"neutral\" },\n};\n\n/** A finished session nobody has looked at yet. */\nexport const REVIEW_STATUS: StatusInfo = { label: \"Ready to review\", icon: Eye, tone: \"success\" };\n\nexport const TASK_STATUS: Record<TaskState, StatusInfo> = {\n backlog: { label: \"Backlog\", icon: Inbox, tone: \"neutral\" },\n ready: { label: \"Ready\", icon: CirclePlay, tone: \"info\" },\n in_progress: { label: \"In progress\", icon: LoaderCircle, tone: \"info\" },\n review: { label: \"Review\", icon: Eye, tone: \"warning\" },\n done: { label: \"Done\", icon: CircleCheck, tone: \"success\" },\n canceled: { label: \"Canceled\", icon: Ban, tone: \"neutral\" },\n};\n\nexport const RUN_STATUS: Record<RunState, StatusInfo> = {\n queued: { label: \"Queued\", icon: Clock, tone: \"neutral\" },\n dispatching: { label: \"Dispatching…\", icon: LoaderCircle, tone: \"info\", spin: true },\n uncertain: { label: \"Awaiting host confirmation\", icon: Hourglass, tone: \"warning\" },\n running: { label: \"Running\", icon: Activity, tone: \"info\", pulse: true },\n waiting_input: { label: \"Needs input\", icon: MessageCircleQuestion, tone: \"warning\" },\n checking: { label: \"Running checks\", icon: ListChecks, tone: \"info\", spin: false },\n succeeded: { label: \"Succeeded\", icon: CircleCheck, tone: \"success\" },\n failed: { label: \"Failed\", icon: CircleX, tone: \"danger\" },\n interrupted: { label: \"Interrupted\", icon: CirclePause, tone: \"warning\" },\n canceled: { label: \"Canceled\", icon: Ban, tone: \"neutral\" },\n};\n\n/** Host connectivity. */\nexport const HOST_STATUS: Record<Connectivity, StatusInfo> = {\n connected: { label: \"Connected\", icon: Wifi, tone: \"success\" },\n reconnecting: { label: \"Reconnecting…\", icon: RefreshCw, tone: \"warning\", spin: true },\n unreachable: { label: \"Unreachable\", icon: WifiOff, tone: \"danger\" },\n};\n\n/** This client's link to the coordinator. */\nexport const CONNECTION_STATUS: Record<ConnectionState, StatusInfo> = {\n connecting: { label: \"Connecting…\", icon: LoaderCircle, tone: \"info\", spin: true },\n live: { label: \"Live\", icon: Wifi, tone: \"success\" },\n reconnecting: { label: \"Reconnecting…\", icon: RefreshCw, tone: \"warning\", spin: true },\n offline: { label: \"Offline\", icon: CloudOff, tone: \"danger\" },\n};\n\nexport const INTERACTION_STATUS: Record<InteractionState, StatusInfo> = {\n pending: { label: \"Needs input\", icon: MessageCircleQuestion, tone: \"warning\" },\n resolved: { label: \"Answered\", icon: CircleCheck, tone: \"success\" },\n expired: { label: \"Expired\", icon: Hourglass, tone: \"neutral\" },\n canceled: { label: \"Canceled\", icon: CircleSlash, tone: \"neutral\" },\n unsupported: { label: \"Unsupported here\", icon: TriangleAlert, tone: \"warning\" },\n};\n\nexport const ATTENTION_STATUS: Record<AttentionReason, StatusInfo> = {\n needs_input: { label: \"Needs input\", icon: MessageCircleQuestion, tone: \"warning\" },\n failed: { label: \"Failed\", icon: CircleX, tone: \"danger\" },\n ready_for_review: { label: \"Ready for review\", icon: Eye, tone: \"info\" },\n unsupported_interaction: {\n label: \"Unsupported interaction\",\n icon: TriangleAlert,\n tone: \"warning\",\n },\n host_unreachable: { label: \"Host unreachable\", icon: WifiOff, tone: \"danger\" },\n};\n\nexport const OCCURRENCE_STATUS: Record<OccurrenceState, StatusInfo> = {\n fired: { label: \"Fired\", icon: CirclePlay, tone: \"info\" },\n skipped_overlap: { label: \"Skipped (overlap)\", icon: CircleSlash, tone: \"neutral\" },\n skipped_missed: { label: \"Skipped (missed)\", icon: CircleSlash, tone: \"neutral\" },\n queued: { label: \"Queued\", icon: Clock, tone: \"neutral\" },\n appended: { label: \"Appended\", icon: Repeat, tone: \"info\" },\n failed: { label: \"Failed\", icon: CircleX, tone: \"danger\" },\n filtered: { label: \"Filtered out\", icon: CircleDashed, tone: \"neutral\" },\n};\n\nexport type StatusChipProps =\n | { kind: \"runtime\"; value: RuntimeState; label?: string; className?: string; size?: \"sm\" | \"md\" }\n | { kind: \"task\"; value: TaskState; label?: string; className?: string; size?: \"sm\" | \"md\" }\n | { kind: \"run\"; value: RunState; label?: string; className?: string; size?: \"sm\" | \"md\" }\n | { kind: \"host\"; value: Connectivity; label?: string; className?: string; size?: \"sm\" | \"md\" }\n | {\n kind: \"connection\";\n value: ConnectionState;\n label?: string;\n className?: string;\n size?: \"sm\" | \"md\";\n }\n | {\n kind: \"interaction\";\n value: InteractionState;\n label?: string;\n className?: string;\n size?: \"sm\" | \"md\";\n }\n | {\n kind: \"attention\";\n value: AttentionReason;\n label?: string;\n className?: string;\n size?: \"sm\" | \"md\";\n }\n | {\n kind: \"occurrence\";\n value: OccurrenceState;\n label?: string;\n className?: string;\n size?: \"sm\" | \"md\";\n }\n | { kind: \"custom\"; status: StatusInfo; label?: string; className?: string; size?: \"sm\" | \"md\" };\n\nconst FALLBACK: StatusInfo = { label: \"Unknown\", icon: CircleAlert, tone: \"neutral\" };\n\nexport function statusInfo(props: StatusChipProps): StatusInfo {\n switch (props.kind) {\n case \"runtime\":\n return RUNTIME_STATUS[props.value] ?? FALLBACK;\n case \"task\":\n return TASK_STATUS[props.value] ?? FALLBACK;\n case \"run\":\n return RUN_STATUS[props.value] ?? FALLBACK;\n case \"host\":\n return HOST_STATUS[props.value] ?? FALLBACK;\n case \"connection\":\n return CONNECTION_STATUS[props.value] ?? FALLBACK;\n case \"interaction\": {\n // Offline-cache values may still carry the pre-0.9 spelling.\n const s = InteractionState.safeParse(props.value);\n return s.success ? INTERACTION_STATUS[s.data] : FALLBACK;\n }\n case \"attention\":\n return ATTENTION_STATUS[props.value] ?? FALLBACK;\n case \"occurrence\":\n return OCCURRENCE_STATUS[props.value] ?? FALLBACK;\n case \"custom\":\n return props.status;\n }\n}\n\n/** Status pill: icon + text label, tone only reinforces. `label` overrides the text. */\nexport function StatusChip(props: StatusChipProps) {\n const info = statusInfo(props);\n const Icon = info.icon;\n const sm = props.size === \"sm\";\n return (\n <span\n data-status-chip={props.kind}\n className={cn(\n \"inline-flex max-w-full items-center gap-1 rounded-full border font-medium whitespace-nowrap\",\n sm ? \"px-1.5 text-xs leading-5\" : \"px-2 text-xs leading-6\",\n TONE_CLASSES[info.tone],\n props.className,\n )}\n >\n {info.spin ? (\n <Spinner className={sm ? \"size-3\" : \"size-3.5\"} />\n ) : (\n <Icon\n aria-hidden\n className={cn(sm ? \"size-3\" : \"size-3.5\", \"shrink-0\", info.pulse && \"animate-pulse\")}\n />\n )}\n <span className=\"truncate\">{props.label ?? info.label}</span>\n </span>\n );\n}\n\n/** Icon plus text status, the tone only reinforces. */\nexport function InlineStatus({\n icon: Icon,\n label,\n tone = \"neutral\",\n spin,\n className,\n}: {\n icon: LucideIcon;\n label: ReactNode;\n tone?: Tone;\n spin?: boolean;\n className?: string;\n}) {\n return (\n <span\n className={cn(\n \"inline-flex max-w-full items-center gap-1 rounded-full border px-2 text-xs leading-6 font-medium\",\n TONE_CLASSES[tone],\n className,\n )}\n >\n {spin ? <Spinner className=\"size-3.5\" /> : <Icon aria-hidden className=\"size-3.5 shrink-0\" />}\n <span className=\"min-w-0 truncate\">{label}</span>\n </span>\n );\n}\n"],"ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16],"mappings":"A,4OAWA,IAAI+B,EAAAf,EAAA,EACJ,SAASgB,EAAuB,EAAM,CACpC,IAAIC,EAAM,4BAA8BC,EACxC,GAAI,EAAI,UAAU,OAAQ,CACxB,GAAO,WAAa,mBAAmB,UAAU,EAAE,EACnD,IAAK,IAAIC,EAAI,EAAGA,EAAI,UAAU,OAAQ,IACpC,GAAO,WAAa,mBAAmB,UAAUA,EAAE,CACvD,CACA,MACE,yBACAD,EACA,WACAD,EACA,gHAEJ,CACA,SAASG,GAAO,CAAC,CACjB,IAAIC,EAAY,CACZ,EAAG,CACD,EAAGD,EACH,EAAG,UAAY,CACb,MAAM,MAAMJ,EAAuB,GAAG,CAAC,CACzC,EACA,EAAGI,EACH,EAAGA,EACH,EAAGA,EACH,EAAGA,EACH,EAAGA,EACH,EAAGA,EACH,EAAGA,CACL,EACA,EAAG,EACH,YAAa,IACf,EACAE,EAAoB,OAAO,IAAI,cAAc,EAC7CC,EAAyB,OAAO,IAAI,mBAAmB,EACvDC,EAAuB,OAAO,IAAI,sBAAsB,EAC1D,SAASC,EAAe,EAAU,EAAe,EAAgB,CAC/D,IAAIC,EACF,EAAI,UAAU,QAAqB,UAAU,KAArB,IAAK,GAAqB,UAAU,GAAK,KACnE,MAAO,CACL,SAAUJ,EACV,IACUI,GAAR,KACI,KACAA,IAAQF,EACNA,EACA,GAAKE,EACH,WACK,gBACC,gBAClB,CACF,CACA,IAAIC,EACFZ,EAAM,gEACR,SAASa,EAAuB,EAAI,EAAO,CACzC,GAAeC,IAAX,OAAe,MAAO,GAC1B,GAAiB,OAAOC,GAApB,SACF,OAA6BA,IAAtB,kBAA8BA,EAAQ,EACjD,CACA,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AA,GAC5F,EAAAxB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,mBAAoB,SAAAM,CAAY,CAAA,CAC5C,C,EAEV,C"}
@@ -1,2 +0,0 @@
1
- import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{g as a,o,t as s}from"./StatusChip-BYuVxYS7.js";import{b as c,c as l,d as u,f as d,gt as f,h as p,i as m,j as h,n as g,s as _,t as v,u as y,vt as b,yt as x,z as S}from"./states-C773NlHo.js";import{t as C}from"./bell-DSwa2PAb.js";import{i as w,u as T}from"./useBreakpoint-BphHBrzF.js";import{t as E}from"./external-link-3jjTxo92.js";import{n as D,t as O}from"./InteractionCard-Yu5wgLC3.js";import{t as k}from"./server-BqZ-w6M8.js";import{c as A,y as j}from"./index-BHGZTS2e.js";import{t as M}from"./SegmentedControl-D2d-NEr-.js";import{r as N}from"./useResource-BBqCoY2q.js";var P={name:`list-todo`,size:24,node:[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]};P.node;var F=r(P),I=e(n(),1),L=[`needs_input`,`failed`,`ready_for_review`,`unsupported_interaction`,`host_unreachable`];function R(e){let t=Object.fromEntries(L.map(e=>[e,[]]));for(let n of e)t[n.reason]?.push(n);return t}function z(e){return e===`dismissed`||e===`history`?e:`open`}function B(e,t){return t===`history`?[]:e.filter(e=>t===`open`?!e.acknowledgedAt:!!e.acknowledgedAt)}function V(e,t,n){return[e?.name,t?.title,n&&n.title!==t?.title?n.title:null].filter(Boolean).join(` · `)||`Switchyard`}function H(e){let t=N(e?`attention-history`:null,e=>f(`/api/attention`,{resolvedOnly:`true`,limit:200},e),{refreshMs:3e4,check:Array.isArray}),n=S(e=>e.attention),r=(0,I.useRef)(!0),{reload:i}=t;return(0,I.useEffect)(()=>{if(r.current){r.current=!1;return}if(!e)return;let t=setTimeout(i,500);return()=>clearTimeout(t)},[n,e,i]),t}var U=i(),W={needs_input:`Questions from Pi waiting for your answer.`,failed:`Runs that failed or were blocked. Open the task to see why.`,ready_for_review:`Finished runs waiting for your review.`,unsupported_interaction:`Questions this client cannot display. Answer them in a terminal attached to the session.`,host_unreachable:`Running work on hosts that stopped responding. Nothing is restarted elsewhere.`};function G(){let e=h(),t=S(e=>e.hydrated),[n,r]=j(`attentionShow`,`open`),i=z(n),a=e=>r(e),o=(0,I.useMemo)(()=>B(e,i),[e,i]),u=(0,I.useMemo)(()=>B(e,`dismissed`).length,[e]),d=(0,I.useMemo)(()=>R(o),[o]),f=H(i===`history`);return(0,U.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6`,children:[(0,U.jsxs)(`header`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,U.jsx)(`h1`,{className:`flex-1 text-lg font-semibold`,children:`Attention`}),(0,U.jsx)(M,{label:`Show`,className:`max-sm:w-full max-sm:basis-full`,value:i,onChange:a,options:[{value:`open`,label:`Open`},{value:`dismissed`,label:`Dismissed`},{value:`history`,label:`History`}]})]}),(0,U.jsx)(_,{subject:`attention items`,consequence:`Answers are sent once the connection is back.`,show:t}),i===`history`?(0,U.jsx)(`div`,{"data-testid":`attention-history`,className:`flex min-w-0 flex-col gap-2`,children:!f.data&&f.loading?(0,U.jsx)(l,{label:`Loading history…`}):!f.data&&f.error?(0,U.jsx)(g,{compact:!0,title:`Could not load history`,error:x(f.error),onRetry:f.reload}):!f.data||f.data.length===0?(0,U.jsx)(v,{icon:(0,U.jsx)(c,{className:`size-8`}),title:`No history yet`,description:`Resolved questions, failures and reviews show up here.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:f.data.map(e=>(0,U.jsx)(`li`,{className:`min-w-0`,children:(0,U.jsx)(q,{item:e})},e.id))}),f.data.length>=200&&(0,U.jsxs)(`p`,{className:`text-sm text-muted`,children:[`Showing the `,200,` most recent.`]})]})}):t?o.length===0?i===`dismissed`?(0,U.jsx)(v,{icon:(0,U.jsx)(C,{className:`size-8`}),title:`No dismissed items`,description:`Items you dismiss stay here until their question or task is resolved.`,action:{label:`Show open`,onClick:()=>a(`open`)}}):(0,U.jsx)(v,{icon:(0,U.jsx)(C,{className:`size-8`}),title:u>0?`All caught up`:`Nothing needs your attention`,description:u>0?`${u} dismissed ${u===1?`item is`:`items are`} still open.`:`Questions, failures and finished work show up here.`,action:u>0?{label:`Show dismissed`,onClick:()=>a(`dismissed`)}:{label:`Go to Sessions`,to:A.code},secondaryAction:u>0?{label:`Go to Sessions`,to:A.code}:{label:`Go to Board`,to:A.board}}):L.filter(e=>d[e].length>0).map(e=>{let t=s[e],n=t.icon;return(0,U.jsxs)(`section`,{"data-testid":`attention-group-${e}`,"aria-labelledby":`att-${e}`,className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h2`,{id:`att-${e}`,className:`flex items-center gap-2 text-base font-semibold`,children:[(0,U.jsx)(n,{"aria-hidden":!0,className:`size-4 text-muted`}),t.label,(0,U.jsxs)(`span`,{className:`text-sm font-normal text-muted`,children:[`(`,d[e].length,`)`]})]}),(0,U.jsx)(`p`,{className:`text-sm text-muted`,children:W[e]})]}),(0,U.jsx)(`ul`,{className:`flex min-w-0 flex-col gap-2`,children:d[e].map(e=>(0,U.jsx)(`li`,{className:`min-w-0`,children:(0,U.jsx)(K,{item:e})},e.id))})]},e)}):(0,U.jsx)(l,{label:`Loading attention…`})]})}function K({item:e}){let n=S(t=>e.projectId?t.projects[e.projectId]:void 0),r=S(t=>e.taskId?t.tasks[e.taskId]:void 0),i=S(t=>e.sessionId?t.sessions[e.sessionId]:void 0),c=S(e=>i?e.hosts[i.hostId]:void 0),l=S(t=>e.interactionId?t.interactions[e.interactionId]:void 0),[f,h]=(0,I.useState)(!1),[_,v]=(0,I.useState)(null),C=async()=>{h(!0),v(null);try{let t=await b(`/api/attention/${encodeURIComponent(e.id)}/acknowledge`),n=t&&typeof t==`object`&&`id`in t?t:{...e,acknowledgedAt:new Date().toISOString()};S.setState(t=>t.attention[e.id]?{attention:{...t.attention,[e.id]:n}}:{}),w.success(`Dismissed. It stays under All until the task or question is resolved.`)}catch(e){v(e)}finally{h(!1)}},j=e.sessionId?e.interactionId?A.interaction(e.sessionId,e.interactionId):A.session(e.sessionId):null,M=!!c&&c.connectivity!==`connected`,N=null;switch(e.reason){case`needs_input`:N=l&&l.state===`pending`?(0,U.jsx)(O,{flush:!0,interaction:l,readOnlyReason:M?`Host ${c?.name} is offline. You can answer once it reconnects.`:i?.readOnly?`This session is read-only.`:null}):l?(0,U.jsx)(O,{flush:!0,interaction:l}):j?(0,U.jsxs)(t,{to:j,className:d(`primary`,`sm`),children:[(0,U.jsx)(E,{"aria-hidden":!0,className:`size-3.5`}),`Answer in session`]}):null;break;case`failed`:N=e.taskId?(0,U.jsxs)(t,{to:A.task(e.taskId),className:d(`primary`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Open task`]}):null;break;case`ready_for_review`:N=e.sessionId?(0,U.jsxs)(t,{to:`${A.session(e.sessionId)}?tab=changes`,className:d(`primary`,`sm`),children:[(0,U.jsx)(a,{"aria-hidden":!0,className:`size-3.5`}),`Review changes`]}):e.taskId?(0,U.jsxs)(t,{to:A.task(e.taskId),className:d(`primary`,`sm`),children:[(0,U.jsx)(a,{"aria-hidden":!0,className:`size-3.5`}),`Open review`]}):null;break;case`unsupported_interaction`:N=l?(0,U.jsx)(O,{interaction:l,readOnlyReason:M?`Host ${c?.name} is offline. You can choose once it reconnects.`:i?.readOnly?`This session is read-only.`:null}):(0,U.jsx)(y,{capability:`This dialog`,reason:`An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.`});break;case`host_unreachable`:N=c?(0,U.jsx)(m,{compact:!0,hostName:c.name,connectivity:c.connectivity===`reconnecting`?`reconnecting`:`unreachable`,lastSeenAt:c.lastSeenAt}):null}let P=V(n,r,i),L=!!l&&(e.reason===`needs_input`||e.reason===`unsupported_interaction`);return e.reason===`needs_input`&&l?.state===`pending`&&D(l.presentation)?(0,U.jsxs)(`article`,{"aria-label":`Plan awaiting approval: ${P}`,className:`flex min-w-0 flex-col gap-2`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 basis-full truncate sm:basis-auto sm:flex-1`,children:P}),j&&(0,U.jsxs)(t,{to:j,className:d(`ghost`,`sm`),children:[(0,U.jsx)(E,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]}),(0,U.jsx)(`time`,{dateTime:e.createdAt,className:`shrink-0 text-xs text-subtle sm:ml-auto`,children:p(e.createdAt)}),!e.acknowledgedAt&&(0,U.jsx)(u,{size:`sm`,variant:`ghost`,busy:f,onClick:()=>void C(),children:`Dismiss`})]}),N,_!==null&&(0,U.jsx)(g,{compact:!0,title:`Could not dismiss`,error:x(_),onRetry:()=>void C()})]}):(0,U.jsxs)(`article`,{"aria-label":`${s[e.reason].label}: ${r?.title??i?.title??e.summary}`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(o,{kind:`attention`,value:e.reason,size:`sm`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted`,children:P}),(0,U.jsx)(`time`,{dateTime:e.createdAt,className:`shrink-0 text-xs text-subtle`,children:p(e.createdAt)})]}),!L&&(0,U.jsx)(`p`,{className:`min-w-0 text-sm break-words`,children:e.summary}),N&&(0,U.jsx)(`div`,{className:`flex min-w-0 flex-col items-start`,children:N}),(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.reason!==`failed`&&e.taskId&&(0,U.jsxs)(t,{to:A.task(e.taskId),className:d(`ghost`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Task`]}),j&&(0,U.jsxs)(t,{to:j,className:d(`ghost`,`sm`),children:[(0,U.jsx)(E,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]}),e.reason===`host_unreachable`&&c&&(0,U.jsxs)(t,{to:`${A.settings(`hosts`)}/${encodeURIComponent(c.id)}`,className:d(`ghost`,`sm`),children:[(0,U.jsx)(k,{"aria-hidden":!0,className:`size-3.5`}),`Host details`]}),(0,U.jsx)(`span`,{className:`ml-auto`}),e.acknowledgedAt?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-xs text-muted`,children:[(0,U.jsx)(T,{"aria-hidden":!0,className:`size-3.5`}),`Dismissed `,p(e.acknowledgedAt)]}):(0,U.jsx)(u,{size:`sm`,busy:f,onClick:()=>void C(),children:`Dismiss`})]}),_!==null&&(0,U.jsx)(g,{compact:!0,title:`Could not dismiss`,error:x(_),onRetry:()=>void C()})]})}function q({item:e}){let n=S(t=>e.projectId?t.projects[e.projectId]:void 0),r=S(t=>e.taskId?t.tasks[e.taskId]:void 0),i=S(t=>e.sessionId?t.sessions[e.sessionId]:void 0);return(0,U.jsxs)(`article`,{"aria-label":`${s[e.reason].label}: ${r?.title??i?.title??e.summary}`,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(o,{kind:`attention`,value:e.reason,size:`sm`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted`,children:V(n,r,i)}),e.resolvedAt&&(0,U.jsxs)(`time`,{dateTime:e.resolvedAt,className:`shrink-0 text-xs text-subtle`,children:[`Resolved `,p(e.resolvedAt)]})]}),(0,U.jsx)(`p`,{className:`min-w-0 text-sm break-words`,children:e.summary}),(e.taskId||e.sessionId)&&(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[e.taskId&&(0,U.jsxs)(t,{to:A.task(e.taskId),className:d(`ghost`,`sm`),children:[(0,U.jsx)(F,{"aria-hidden":!0,className:`size-3.5`}),`Task`]}),e.sessionId&&(0,U.jsxs)(t,{to:A.session(e.sessionId),className:d(`ghost`,`sm`),children:[(0,U.jsx)(E,{"aria-hidden":!0,className:`size-3.5`}),`Open session`]})]})]})}export{G as default};
2
- //# sourceMappingURL=attention-CI4dHY81.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attention-CI4dHY81.js","names":["useRef","useMemo","History","_Fragment","useState","__toESM","Link","require_react","createLucideIcon","require_jsx_runtime","Eye","ATTENTION_STATUS","RotateCcwClock","LoadingState","Button","buttonClasses","apiGet","formatRelative","HostUnavailable","useOpenAttention","ErrorState","LastKnownNote","EmptyState","UnsupportedCapability","apiPost","errorMessage","useSyncStore","Bell","toast","CircleCheck","ExternalLink","isDocumentPresentation","InteractionCard","Server","ROUTES","useFilter","SegmentedControl","useResource","__iconData","ListTodo","import_react","ATTENTION_GROUPS","groupAttention","out","r","a","items","normalizeShow","v","visibleAttention","show","all","attentionMeta","project","task","session","useAttentionHistory","res","enabled","signal","attention","s","first","reload","import_jsx_runtime","GROUP_HINT","AttentionView","hydrated","stored","setStored","setShow","dismissedCount","groups","history","HistoryRow","info","reason","Icon","AttentionRow","item","host","interaction","busy","setBusy","ackError","setAckError","acknowledge","next","sessionHref","hostOffline","action","metaText","showsCard","StatusChip"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/list-todo.mjs","../../src/features/attention/logic.ts","../../src/features/attention/useAttentionHistory.ts","../../src/features/attention/index.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"list-todo\",\n size: 24,\n node: [\n [\"path\", { d: \"M13 5h8\", key: \"a7qcls\" }],\n [\"path\", { d: \"M13 12h8\", key: \"h98zly\" }],\n [\"path\", { d: \"M13 19h8\", key: \"c3s6r1\" }],\n [\"path\", { d: \"m3 17 2 2 4-4\", key: \"1jhpwq\" }],\n [\"rect\", { x: \"3\", y: \"4\", width: \"6\", height: \"6\", rx: \"1\", key: \"cif1o7\" }]\n ]\n};\n__iconData.node;\nconst ListTodo = createLucideIcon(__iconData);\n\nexport { __iconData, ListTodo as default };\n//# sourceMappingURL=list-todo.mjs.map\n","import type { AttentionItem, AttentionReason, Project, Session, Task } from \"@switchyard/protocol\";\n\nexport const ATTENTION_GROUPS: AttentionReason[] = [\n \"needs_input\",\n \"failed\",\n \"ready_for_review\",\n \"unsupported_interaction\",\n \"host_unreachable\",\n];\n\n/** Group open attention by reason, keeping the input order within a group. */\nexport function groupAttention(items: AttentionItem[]): Record<AttentionReason, AttentionItem[]> {\n const out = Object.fromEntries(ATTENTION_GROUPS.map((r) => [r, [] as AttentionItem[]])) as Record<\n AttentionReason,\n AttentionItem[]\n >;\n for (const a of items) out[a.reason]?.push(a);\n return out;\n}\n\nexport type AttentionShow = \"open\" | \"dismissed\" | \"history\";\n\n/** Stored prefs from before History: \"all\" (open + dismissed) and unknown values read as \"open\". */\nexport function normalizeShow(v: unknown): AttentionShow {\n return v === \"dismissed\" || v === \"history\" ? v : \"open\";\n}\n\n/** Unacknowledged items for \"open\", acknowledged for \"dismissed\"; [] for \"history\". */\nexport function visibleAttention(all: AttentionItem[], show: AttentionShow): AttentionItem[] {\n if (show === \"history\") return [];\n return all.filter((a) => (show === \"open\" ? !a.acknowledgedAt : !!a.acknowledgedAt));\n}\n\n/** \"project · task · session\" (session only when its title differs from the task's), else \"Switchyard\". */\nexport function attentionMeta(project?: Project, task?: Task, session?: Session): string {\n return (\n [project?.name, task?.title, session && session.title !== task?.title ? session.title : null]\n .filter(Boolean)\n .join(\" · \") || \"Switchyard\"\n );\n}\n","import type { AttentionItem } from \"@switchyard/protocol\";\nimport { useEffect, useRef } from \"react\";\nimport { type Resource, useResource } from \"../../lib/useResource\";\nimport { apiGet } from \"../../sync/api\";\nimport { useSyncStore } from \"../../sync/store\";\n\nexport const HISTORY_LIMIT = 200;\n\n/**\n * Resolved attention items, newest first. The sync store drops resolved items, so they come\n * from the API; refetched when open attention changes (debounced) and every 30 s.\n */\nexport function useAttentionHistory(enabled: boolean): Resource<AttentionItem[]> {\n const res = useResource<AttentionItem[]>(\n enabled ? \"attention-history\" : null,\n (signal) =>\n apiGet<AttentionItem[]>(\n \"/api/attention\",\n { resolvedOnly: \"true\", limit: HISTORY_LIMIT },\n signal,\n ),\n { refreshMs: 30_000, check: Array.isArray },\n );\n const attention = useSyncStore((s) => s.attention);\n const first = useRef(true);\n const { reload } = res;\n // biome-ignore lint/correctness/useExhaustiveDependencies: refetch on attention changes\n useEffect(() => {\n if (first.current) {\n first.current = false;\n return;\n }\n if (!enabled) return;\n const t = setTimeout(reload, 500);\n return () => clearTimeout(t);\n }, [attention, enabled, reload]);\n return res;\n}\n","import type { AttentionItem, AttentionReason } from \"@switchyard/protocol\";\nimport { Bell, CircleCheck, ExternalLink, Eye, History, ListTodo, Server } from \"lucide-react\";\nimport { useMemo, useState } from \"react\";\nimport { Link } from \"react-router\";\nimport { ROUTES } from \"../../app/routes\";\nimport { InteractionCard, isDocumentPresentation } from \"../../components/intent/InteractionCard\";\nimport { Button, buttonClasses } from \"../../components/ui/Button\";\nimport { SegmentedControl } from \"../../components/ui/SegmentedControl\";\nimport { ATTENTION_STATUS, StatusChip } from \"../../components/ui/StatusChip\";\nimport {\n EmptyState,\n ErrorState,\n HostUnavailable,\n LastKnownNote,\n LoadingState,\n UnsupportedCapability,\n} from \"../../components/ui/states\";\nimport { toast } from \"../../components/ui/Toast\";\nimport { formatRelative } from \"../../lib/time\";\nimport { useFilter } from \"../../prefs\";\nimport { apiPost, errorMessage } from \"../../sync/api\";\nimport { useOpenAttention, useSyncStore } from \"../../sync/store\";\nimport {\n ATTENTION_GROUPS,\n type AttentionShow,\n attentionMeta,\n groupAttention,\n normalizeShow,\n visibleAttention,\n} from \"./logic\";\nimport { HISTORY_LIMIT, useAttentionHistory } from \"./useAttentionHistory\";\n\nconst GROUP_HINT: Record<AttentionReason, string> = {\n needs_input: \"Questions from Pi waiting for your answer.\",\n failed: \"Runs that failed or were blocked. Open the task to see why.\",\n ready_for_review: \"Finished runs waiting for your review.\",\n unsupported_interaction:\n \"Questions this client cannot display. Answer them in a terminal attached to the session.\",\n host_unreachable:\n \"Running work on hosts that stopped responding. Nothing is restarted elsewhere.\",\n};\n\n/** /attention: Needs input, Failed, Ready for review (plus unsupported and unreachable). */\nexport default function AttentionView() {\n const all = useOpenAttention();\n const hydrated = useSyncStore((s) => s.hydrated);\n const [stored, setStored] = useFilter<AttentionShow | \"all\">(\"attentionShow\", \"open\");\n const show = normalizeShow(stored);\n const setShow = (v: AttentionShow) => setStored(v);\n const items = useMemo(() => visibleAttention(all, show), [all, show]);\n const dismissedCount = useMemo(() => visibleAttention(all, \"dismissed\").length, [all]);\n const groups = useMemo(() => groupAttention(items), [items]);\n const history = useAttentionHistory(show === \"history\");\n\n return (\n <div className=\"flex w-full min-w-0 flex-col gap-4 px-4 pb-4 safe-pt-4 md:px-6\">\n <header className=\"flex min-w-0 flex-wrap items-center gap-3\">\n <h1 className=\"flex-1 text-lg font-semibold\">Attention</h1>\n <SegmentedControl\n label=\"Show\"\n className=\"max-sm:w-full max-sm:basis-full\"\n value={show}\n onChange={setShow}\n options={[\n { value: \"open\", label: \"Open\" },\n { value: \"dismissed\", label: \"Dismissed\" },\n { value: \"history\", label: \"History\" },\n ]}\n />\n </header>\n <LastKnownNote\n subject=\"attention items\"\n consequence=\"Answers are sent once the connection is back.\"\n show={hydrated}\n />\n {show === \"history\" ? (\n <div data-testid=\"attention-history\" className=\"flex min-w-0 flex-col gap-2\">\n {!history.data && history.loading ? (\n <LoadingState label=\"Loading history…\" />\n ) : !history.data && history.error ? (\n <ErrorState\n compact\n title=\"Could not load history\"\n error={errorMessage(history.error)}\n onRetry={history.reload}\n />\n ) : !history.data || history.data.length === 0 ? (\n <EmptyState\n icon={<History className=\"size-8\" />}\n title=\"No history yet\"\n description=\"Resolved questions, failures and reviews show up here.\"\n />\n ) : (\n <>\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {history.data.map((a) => (\n <li key={a.id} className=\"min-w-0\">\n <HistoryRow item={a} />\n </li>\n ))}\n </ul>\n {history.data.length >= HISTORY_LIMIT && (\n <p className=\"text-sm text-muted\">Showing the {HISTORY_LIMIT} most recent.</p>\n )}\n </>\n )}\n </div>\n ) : !hydrated ? (\n <LoadingState label=\"Loading attention…\" />\n ) : items.length === 0 ? (\n show === \"dismissed\" ? (\n <EmptyState\n icon={<Bell className=\"size-8\" />}\n title=\"No dismissed items\"\n description=\"Items you dismiss stay here until their question or task is resolved.\"\n action={{ label: \"Show open\", onClick: () => setShow(\"open\") }}\n />\n ) : (\n <EmptyState\n icon={<Bell className=\"size-8\" />}\n title={dismissedCount > 0 ? \"All caught up\" : \"Nothing needs your attention\"}\n description={\n dismissedCount > 0\n ? `${dismissedCount} dismissed ${dismissedCount === 1 ? \"item is\" : \"items are\"} still open.`\n : \"Questions, failures and finished work show up here.\"\n }\n action={\n dismissedCount > 0\n ? { label: \"Show dismissed\", onClick: () => setShow(\"dismissed\") }\n : { label: \"Go to Sessions\", to: ROUTES.code }\n }\n secondaryAction={\n dismissedCount > 0\n ? { label: \"Go to Sessions\", to: ROUTES.code }\n : { label: \"Go to Board\", to: ROUTES.board }\n }\n />\n )\n ) : (\n ATTENTION_GROUPS.filter((r) => groups[r].length > 0).map((reason) => {\n const info = ATTENTION_STATUS[reason];\n const Icon = info.icon;\n return (\n <section\n key={reason}\n data-testid={`attention-group-${reason}`}\n aria-labelledby={`att-${reason}`}\n className=\"flex min-w-0 flex-col gap-2\"\n >\n <div>\n <h2\n id={`att-${reason}`}\n className=\"flex items-center gap-2 text-base font-semibold\"\n >\n <Icon aria-hidden className=\"size-4 text-muted\" />\n {info.label}\n <span className=\"text-sm font-normal text-muted\">({groups[reason].length})</span>\n </h2>\n <p className=\"text-sm text-muted\">{GROUP_HINT[reason]}</p>\n </div>\n <ul className=\"flex min-w-0 flex-col gap-2\">\n {groups[reason].map((a) => (\n <li key={a.id} className=\"min-w-0\">\n <AttentionRow item={a} />\n </li>\n ))}\n </ul>\n </section>\n );\n })\n )}\n </div>\n );\n}\n\nfunction AttentionRow({ item }: { item: AttentionItem }) {\n const project = useSyncStore((s) => (item.projectId ? s.projects[item.projectId] : undefined));\n const task = useSyncStore((s) => (item.taskId ? s.tasks[item.taskId] : undefined));\n const session = useSyncStore((s) => (item.sessionId ? s.sessions[item.sessionId] : undefined));\n const host = useSyncStore((s) => (session ? s.hosts[session.hostId] : undefined));\n const interaction = useSyncStore((s) =>\n item.interactionId ? s.interactions[item.interactionId] : undefined,\n );\n const [busy, setBusy] = useState(false);\n const [ackError, setAckError] = useState<unknown>(null);\n\n const acknowledge = async () => {\n setBusy(true);\n setAckError(null);\n try {\n const res = await apiPost<AttentionItem>(\n `/api/attention/${encodeURIComponent(item.id)}/acknowledge`,\n );\n const next =\n res && typeof res === \"object\" && \"id\" in res\n ? res\n : { ...item, acknowledgedAt: new Date().toISOString() };\n useSyncStore.setState((s) =>\n s.attention[item.id] ? { attention: { ...s.attention, [item.id]: next } } : {},\n );\n toast.success(\"Dismissed. It stays under All until the task or question is resolved.\");\n } catch (e) {\n setAckError(e);\n } finally {\n setBusy(false);\n }\n };\n\n const sessionHref = item.sessionId\n ? item.interactionId\n ? ROUTES.interaction(item.sessionId, item.interactionId)\n : ROUTES.session(item.sessionId)\n : null;\n const hostOffline = !!host && host.connectivity !== \"connected\";\n\n let action: React.ReactNode = null;\n switch (item.reason) {\n case \"needs_input\":\n action =\n interaction && interaction.state === \"pending\" ? (\n <InteractionCard\n flush\n interaction={interaction}\n readOnlyReason={\n hostOffline\n ? `Host ${host?.name} is offline. You can answer once it reconnects.`\n : session?.readOnly\n ? \"This session is read-only.\"\n : null\n }\n />\n ) : interaction ? (\n <InteractionCard flush interaction={interaction} />\n ) : sessionHref ? (\n <Link to={sessionHref} className={buttonClasses(\"primary\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Answer in session\n </Link>\n ) : null;\n break;\n case \"failed\":\n action = item.taskId ? (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"primary\", \"sm\")}>\n <ListTodo aria-hidden className=\"size-3.5\" />\n Open task\n </Link>\n ) : null;\n break;\n case \"ready_for_review\":\n action = item.sessionId ? (\n <Link\n to={`${ROUTES.session(item.sessionId)}?tab=changes`}\n className={buttonClasses(\"primary\", \"sm\")}\n >\n <Eye aria-hidden className=\"size-3.5\" />\n Review changes\n </Link>\n ) : item.taskId ? (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"primary\", \"sm\")}>\n <Eye aria-hidden className=\"size-3.5\" />\n Open review\n </Link>\n ) : null;\n break;\n case \"unsupported_interaction\":\n action = interaction ? (\n <InteractionCard\n interaction={interaction}\n readOnlyReason={\n hostOffline\n ? `Host ${host?.name} is offline. You can choose once it reconnects.`\n : session?.readOnly\n ? \"This session is read-only.\"\n : null\n }\n />\n ) : (\n <UnsupportedCapability\n capability=\"This dialog\"\n reason=\"An extension opened a terminal-only dialog. In RPC mode Pi gave it no answer, so the extension continued without one.\"\n />\n );\n break;\n case \"host_unreachable\":\n action = host ? (\n <HostUnavailable\n compact\n hostName={host.name}\n connectivity={host.connectivity === \"reconnecting\" ? \"reconnecting\" : \"unreachable\"}\n lastSeenAt={host.lastSeenAt}\n />\n ) : null;\n break;\n }\n\n const metaText = attentionMeta(project, task, session);\n\n const showsCard =\n !!interaction && (item.reason === \"needs_input\" || item.reason === \"unsupported_interaction\");\n\n // A plan awaiting approval gets the whole width: one meta line, no card around it.\n if (\n item.reason === \"needs_input\" &&\n interaction?.state === \"pending\" &&\n isDocumentPresentation(interaction.presentation)\n ) {\n return (\n <article\n aria-label={`Plan awaiting approval: ${metaText}`}\n className=\"flex min-w-0 flex-col gap-2\"\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-sm text-muted\">\n <span className=\"min-w-0 basis-full truncate sm:basis-auto sm:flex-1\">{metaText}</span>\n {sessionHref && (\n <Link to={sessionHref} className={buttonClasses(\"ghost\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n <time dateTime={item.createdAt} className=\"shrink-0 text-xs text-subtle sm:ml-auto\">\n {formatRelative(item.createdAt)}\n </time>\n {!item.acknowledgedAt && (\n <Button size=\"sm\" variant=\"ghost\" busy={busy} onClick={() => void acknowledge()}>\n Dismiss\n </Button>\n )}\n </div>\n {action}\n {ackError !== null && (\n <ErrorState\n compact\n title=\"Could not dismiss\"\n error={errorMessage(ackError)}\n onRetry={() => void acknowledge()}\n />\n )}\n </article>\n );\n }\n\n return (\n <article\n aria-label={`${ATTENTION_STATUS[item.reason].label}: ${task?.title ?? session?.title ?? item.summary}`}\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\"\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <StatusChip kind=\"attention\" value={item.reason} size=\"sm\" />\n <span className=\"min-w-0 flex-1 truncate text-xs text-muted\">{metaText}</span>\n <time dateTime={item.createdAt} className=\"shrink-0 text-xs text-subtle\">\n {formatRelative(item.createdAt)}\n </time>\n </div>\n {!showsCard && <p className=\"min-w-0 text-sm break-words\">{item.summary}</p>}\n {action && <div className=\"flex min-w-0 flex-col items-start\">{action}</div>}\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n {item.reason !== \"failed\" && item.taskId && (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"ghost\", \"sm\")}>\n <ListTodo aria-hidden className=\"size-3.5\" />\n Task\n </Link>\n )}\n {sessionHref && (\n <Link to={sessionHref} className={buttonClasses(\"ghost\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n {item.reason === \"host_unreachable\" && host && (\n <Link\n to={`${ROUTES.settings(\"hosts\")}/${encodeURIComponent(host.id)}`}\n className={buttonClasses(\"ghost\", \"sm\")}\n >\n <Server aria-hidden className=\"size-3.5\" />\n Host details\n </Link>\n )}\n <span className=\"ml-auto\" />\n {item.acknowledgedAt ? (\n <span className=\"inline-flex items-center gap-1 text-xs text-muted\">\n <CircleCheck aria-hidden className=\"size-3.5\" />\n Dismissed {formatRelative(item.acknowledgedAt)}\n </span>\n ) : (\n <Button size=\"sm\" busy={busy} onClick={() => void acknowledge()}>\n Dismiss\n </Button>\n )}\n </div>\n {ackError !== null && (\n <ErrorState\n compact\n title=\"Could not dismiss\"\n error={errorMessage(ackError)}\n onRetry={() => void acknowledge()}\n />\n )}\n </article>\n );\n}\n\nfunction HistoryRow({ item }: { item: AttentionItem }) {\n const project = useSyncStore((s) => (item.projectId ? s.projects[item.projectId] : undefined));\n const task = useSyncStore((s) => (item.taskId ? s.tasks[item.taskId] : undefined));\n const session = useSyncStore((s) => (item.sessionId ? s.sessions[item.sessionId] : undefined));\n return (\n <article\n aria-label={`${ATTENTION_STATUS[item.reason].label}: ${task?.title ?? session?.title ?? item.summary}`}\n className=\"flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-surface p-3\"\n >\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n <StatusChip kind=\"attention\" value={item.reason} size=\"sm\" />\n <span className=\"min-w-0 flex-1 truncate text-xs text-muted\">\n {attentionMeta(project, task, session)}\n </span>\n {item.resolvedAt && (\n <time dateTime={item.resolvedAt} className=\"shrink-0 text-xs text-subtle\">\n Resolved {formatRelative(item.resolvedAt)}\n </time>\n )}\n </div>\n <p className=\"min-w-0 text-sm break-words\">{item.summary}</p>\n {(item.taskId || item.sessionId) && (\n <div className=\"flex min-w-0 flex-wrap items-center gap-2\">\n {item.taskId && (\n <Link to={ROUTES.task(item.taskId)} className={buttonClasses(\"ghost\", \"sm\")}>\n <ListTodo aria-hidden className=\"size-3.5\" />\n Task\n </Link>\n )}\n {item.sessionId && (\n <Link to={ROUTES.session(item.sessionId)} className={buttonClasses(\"ghost\", \"sm\")}>\n <ExternalLink aria-hidden className=\"size-3.5\" />\n Open session\n </Link>\n )}\n </div>\n )}\n </article>\n );\n}\n"],"ignoreList":[0],"mappings":"A,8oBASA,IAAMsC,EAAa,CACjB,KAAM,YACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,UAAW,IAAK,QAAS,CAAC,EACxC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,WAAY,IAAK,QAAS,CAAC,EACzC,CAAC,OAAQ,CAAE,EAAG,gBAAiB,IAAK,QAAS,CAAC,EAC9C,CAAC,OAAQ,CAAE,EAAG,IAAK,EAAG,IAAK,MAAO,IAAK,OAAQ,IAAK,GAAI,IAAK,IAAK,QAAS,CAAC,CAC9E,CACF,EACAA,EAAW,KACX,IAAMC,EAAW/B,EAAiB8B,CAAU,E,WCnB/BG,EAAsC,CACjD,cACA,SACA,mBACA,0BACA,kBACF,EAGA,SAAgBC,EAAe,EAAkE,CAC/F,IAAMC,EAAM,OAAO,YAAYF,EAAiB,IAAK,GAAM,CAACG,EAAG,CAAC,CAAoB,CAAC,CAAC,EAItF,IAAK,IAAMC,KAAKC,EAAOH,EAAIE,EAAE,OAAO,EAAE,KAAKA,CAAC,EAC5C,OAAOF,CACT,CAKA,SAAgBI,EAAc,EAA2B,CACvD,OAAOC,IAAM,aAAeA,IAAM,UAAYA,EAAI,MACpD,CAGA,SAAgBC,EAAiB,EAAsB,EAAsC,CAE3F,OADIC,IAAS,UAAkB,CAAC,EACzBC,EAAI,OAAQ,G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,C,EAEA,C,EAEb,C"}
@@ -1,2 +0,0 @@
1
- import{D as e,H as t,St as n,gt as r,pt as i,xt as a}from"./states-C773NlHo.js";import{t as o}from"./presence-05bJD5G3.js";var s=`switchyard`,c=`kv`,l=`sync`,u=`sy:sync-cache`,d=null;function f(){return d||(d=new Promise(e=>{if(typeof indexedDB>`u`)return e(null);try{let t=indexedDB.open(s,1);t.onupgradeneeded=()=>t.result.createObjectStore(c),t.onsuccess=()=>e(t.result),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}}),d)}function p(e,t){return f().then(n=>new Promise((r,i)=>{if(!n)return i(Error(`no indexeddb`));let a=t(n.transaction(c,e).objectStore(c));a.onsuccess=()=>r(a.result),a.onerror=()=>i(a.error)}))}async function m(){try{let e=await p(`readonly`,e=>e.get(l));if(e)return e}catch{}try{let e=localStorage.getItem(u);return e?JSON.parse(e):null}catch{return null}}async function h(e){try{await p(`readwrite`,t=>t.put(e,l));return}catch{}try{localStorage.setItem(u,JSON.stringify(e))}catch{}}async function g(){try{await p(`readwrite`,e=>e.delete(l))}catch{}try{localStorage.removeItem(u)}catch{}}var _=25e3,v=1e4,y=1e3,b=3e4,x=1500,S=1e4,C=5e3,w=class{url;ws=null;stopped=!0;everLive=!1;attempts=0;retryTimer=null;pingTimer=null;pongTimer=null;persistTimer=null;connectTimer=null;lastFrameAt=0;unsubscribeStore=null;liveListeners=new Set;logoutListeners=new Set;cacheLoaded=null;constructor(e=T()){this.url=e}start(){this.stopped&&(this.stopped=!1,window.addEventListener(`online`,this.onOnline),window.addEventListener(`offline`,this.onOffline),document.addEventListener(`visibilitychange`,this.onVisibility),window.addEventListener(`pageshow`,this.onForeground),window.addEventListener(`focus`,this.onForeground),this.unsubscribeStore=e.subscribe((e,t)=>{e.synced&&e.seq!==t.seq&&this.schedulePersist()}),this.cacheLoaded??=m().then(t=>{t&&!e.getState().synced&&e.getState().hydrateFromCache(t.seq,t.state,t.savedAt)}),this.cacheLoaded.then(()=>this.connect()))}stop(){this.stopped=!0,window.removeEventListener(`online`,this.onOnline),window.removeEventListener(`offline`,this.onOffline),document.removeEventListener(`visibilitychange`,this.onVisibility),window.removeEventListener(`pageshow`,this.onForeground),window.removeEventListener(`focus`,this.onForeground),this.unsubscribeStore?.(),this.unsubscribeStore=null,this.clearTimers();let e=this.ws;this.ws=null,e?.close(1e3,`client stopped`)}send(e){return this.ws?.readyState===WebSocket.OPEN&&(this.ws.send(JSON.stringify(e)),!0)}get isLive(){return e.getState().connection.state===`live`}onLive(e){return this.liveListeners.add(e),()=>this.liveListeners.delete(e)}onLogout(e){return this.logoutListeners.add(e),()=>this.logoutListeners.delete(e)}reconnectNow(){this.stopped||(this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=null,!(this.ws&&this.ws.readyState<=WebSocket.OPEN)&&this.connect())}connect(){if(this.stopped)return;if(typeof navigator<`u`&&navigator.onLine===!1){e.getState().setConnection({state:`offline`});return}e.getState().setConnection({state:this.everLive?`reconnecting`:`connecting`});let t;try{t=new WebSocket(this.url)}catch{this.scheduleReconnect();return}this.ws=t,this.connectTimer&&clearTimeout(this.connectTimer);let n=S*Math.min(1+this.attempts,3);this.connectTimer=setTimeout(()=>{this.connectTimer=null,this.ws===t&&this.dropSocket(4e3,`connect timeout`)},n);let r=!1;t.onopen=()=>{if(this.ws!==t)return;r=!0;let n=e.getState().seq;t.send(JSON.stringify({type:`hello`,cursor:n}))},t.onmessage=e=>{if(this.ws!==t)return;this.lastFrameAt=Date.now();let n;try{n=JSON.parse(typeof e.data==`string`?e.data:``)}catch{return}this.handle(n)},t.onclose=e=>{this.ws===t&&(this.ws=null,this.clearTimers(),!this.stopped&&(e.code===4401||e.code===4403||e.code===1008?this.emitLogout(e.reason||`unauthorized`):(!r&&this.attempts%5==0&&this.probeAuth(),this.scheduleReconnect())))},t.onerror=()=>{}}probing=!1;probeAuth(){this.probing||(this.probing=!0,r(`/api/me`).catch(()=>void 0).finally(()=>{this.probing=!1}))}handle(t){let n=e.getState();switch(t.type){case`snapshot`:n.applySnapshot(t.seq,t.state),this.becomeLive();break;case`replay`:n.applyReplay(t.seq,t.events),this.becomeLive();break;case`event`:n.applyEvent(t.event);break;case`stream`:n.applyStream(t.delta);break;case`pong`:this.pongTimer&&clearTimeout(this.pongTimer),this.pongTimer=null,n.markSynced();break;case`force_logout`:this.emitLogout(t.reason)}}becomeLive(){this.connectTimer&&clearTimeout(this.connectTimer),this.connectTimer=null,this.everLive=!0,this.attempts=0,e.getState().setConnection({state:`live`,attempts:0}),this.startPing(),this.schedulePersist();for(let e of this.liveListeners)e()}emitLogout(t){this.stop(),g(),e.getState().reset();for(let e of this.logoutListeners)e(t)}startPing(){this.pingTimer&&clearInterval(this.pingTimer),this.pingTimer=setInterval(()=>{this.send({type:`ping`})&&(this.pongTimer||this.armPongTimeout(v))},_)}armPongTimeout(e){this.pongTimer&&clearTimeout(this.pongTimer),this.pongTimer=setTimeout(()=>{this.pongTimer=null,this.dropSocket(4e3,`pong timeout`)},e)}dropSocket(e,t){let n=this.ws;if(n){this.ws=null,this.clearTimers();try{n.close(e,t)}catch{}this.scheduleReconnect()}}scheduleReconnect(){if(this.stopped)return;if(typeof navigator<`u`&&navigator.onLine===!1){e.getState().setConnection({state:`offline`});return}this.attempts++;let t=Math.min(b,y*2**(this.attempts-1)),n=t/2+t/2*Math.random();e.getState().setConnection({state:this.everLive?`reconnecting`:`connecting`,attempts:this.attempts}),this.retryTimer&&clearTimeout(this.retryTimer),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.connect()},n)}schedulePersist(){this.persistTimer||=setTimeout(()=>{this.persistTimer=null;let n=e.getState();n.synced&&n.seq!==null&&h({seq:n.seq,state:t(n),savedAt:new Date().toISOString()})},x)}clearTimers(){this.retryTimer&&clearTimeout(this.retryTimer),this.pingTimer&&clearInterval(this.pingTimer),this.pongTimer&&clearTimeout(this.pongTimer),this.connectTimer&&clearTimeout(this.connectTimer),this.connectTimer=null,this.retryTimer=null,this.pingTimer=null,this.pongTimer=null}onOnline=()=>{this.attempts=0,this.reconnectNow()};onVisibility=()=>{document.visibilityState===`visible`&&this.onForeground()};onForeground=()=>{if(!(this.stopped||document.visibilityState===`hidden`)){if(this.isLive){if(Date.now()-this.lastFrameAt<5e3)return;this.send({type:`ping`})&&this.armPongTimeout(C)}else this.attempts=0,this.reconnectNow()}};onOffline=()=>{e.getState().setConnection({state:`offline`}),this.ws?.close(4e3,`offline`)}};function T(){return`${location.protocol===`https:`?`wss:`:`ws:`}//${location.host}/ws/client`}var E=new w(typeof location>`u`?``:T()),D=n()(()=>({status:`checking`,me:null,error:null,signedOutReason:null})),O=`sy:me`,k=`sy:returnTo`,A=null;function j(){E.start(),A??=o(E)}function M(){E.stop(),A?.(),A=null}function N(){return D.getState().me?.device?.id??null}async function P(){D.setState({status:`checking`,error:null});try{let e=await r(`/api/me`);try{localStorage.setItem(O,JSON.stringify(e))}catch{}return D.setState({status:`authenticated`,me:e,signedOutReason:null}),j(),`authenticated`}catch(e){if(e instanceof i&&(e.status===401||e.code===`device_revoked`))return I(e.code===`device_revoked`?`This device was revoked.`:null),`unauthenticated`;let t=F();return t?(D.setState({status:`authenticated`,me:t}),j(),`authenticated`):(D.setState({status:`error`,error:e}),`error`)}}function F(){try{let e=localStorage.getItem(O),t=e?JSON.parse(e):null;return t?.device?.id?t:null}catch{return null}}function I(t){M(),g(),e.getState().reset();try{localStorage.removeItem(O)}catch{}D.setState({status:`unauthenticated`,me:null,signedOutReason:t})}function L(e){if(!(e.startsWith(`/sign-in`)||e.startsWith(`/enroll`)))try{localStorage.setItem(k,e)}catch{}}function R(e){let t=null;try{t=localStorage.getItem(k),localStorage.removeItem(k)}catch{}let n=e??t;return n?.startsWith(`/`)&&!n.startsWith(`//`)&&!n.startsWith(`/sign-in`)&&!n.startsWith(`/enroll`)?n:`/`}var z=!1;function B(){z||(z=!0,a(e=>{D.getState().status===`authenticated`&&I(e===`device_revoked`?`This device was revoked.`:null)}),E.onLogout(e=>{I(e===`unauthorized`?null:`Signed out: ${e}`)}))}export{I as a,E as c,L as i,N as n,R as o,B as r,D as s,P as t};
2
- //# sourceMappingURL=auth-308hUVgi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-308hUVgi.js","names":["syncStore","toSyncState","create","apiGet","ApiClientError","onUnauthorized","startPresence","DB_NAME","STORE","KEY","LS_KEY","dbPromise","openDb","resolve","req","idb","db","reject","fn","mode","loadCache","v","s","raw","saveCache","value","clearCache","PING_INTERVAL_MS","PONG_TIMEOUT_MS","BACKOFF_BASE_MS","BACKOFF_MAX_MS","PERSIST_DELAY_MS","CONNECT_TIMEOUT_MS","RESUME_PONG_TIMEOUT_MS","SyncClient","defaultWsUrl","url","prev","cached","ws","msg","timeoutMs","opened","cursor","ev","store","reason","ms","code","delay","jittered","syncClient","useAuth","ME_KEY","RETURN_KEY","stopPresence","startSync","stopSync","currentDeviceId","checkAuth","me","signOut","readCachedMe","saveReturnTo","takeReturnTo","saved","candidate","fromQuery","wired","initAuth"],"sources":["../../src/sync/cache.ts","../../src/sync/client.ts","../../src/app/auth.ts"],"sourcesContent":["import type { SyncState } from \"@switchyard/protocol\";\n\n/**\n * Offline cache of the last synced state and its cursor, so the UI shows\n * last-known data while reconnecting and the WS resumes with `hello {cursor}`.\n * IndexedDB when available, localStorage otherwise.\n */\n\nexport interface CachedSync {\n seq: number;\n state: SyncState;\n savedAt: string;\n}\n\nconst DB_NAME = \"switchyard\";\nconst STORE = \"kv\";\nconst KEY = \"sync\";\nconst LS_KEY = \"sy:sync-cache\";\n\nlet dbPromise: Promise<IDBDatabase | null> | null = null;\n\nfunction openDb(): Promise<IDBDatabase | null> {\n if (dbPromise) return dbPromise;\n dbPromise = new Promise((resolve) => {\n if (typeof indexedDB === \"undefined\") return resolve(null);\n try {\n const req = indexedDB.open(DB_NAME, 1);\n req.onupgradeneeded = () => req.result.createObjectStore(STORE);\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => resolve(null);\n req.onblocked = () => resolve(null);\n } catch {\n resolve(null);\n }\n });\n return dbPromise;\n}\n\nfunction idb<T>(mode: IDBTransactionMode, fn: (s: IDBObjectStore) => IDBRequest<T>): Promise<T> {\n return openDb().then(\n (db) =>\n new Promise<T>((resolve, reject) => {\n if (!db) return reject(new Error(\"no indexeddb\"));\n const tx = db.transaction(STORE, mode);\n const req = fn(tx.objectStore(STORE));\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n }),\n );\n}\n\nexport async function loadCache(): Promise<CachedSync | null> {\n try {\n const v = await idb<CachedSync | undefined>(\"readonly\", (s) => s.get(KEY));\n if (v) return v;\n } catch {\n // fall through to localStorage\n }\n try {\n const raw = localStorage.getItem(LS_KEY);\n return raw ? (JSON.parse(raw) as CachedSync) : null;\n } catch {\n return null;\n }\n}\n\nexport async function saveCache(value: CachedSync): Promise<void> {\n try {\n await idb(\"readwrite\", (s) => s.put(value, KEY));\n return;\n } catch {\n // fall through\n }\n try {\n localStorage.setItem(LS_KEY, JSON.stringify(value));\n } catch {\n // quota exceeded: the cache is best effort\n }\n}\n\nexport async function clearCache(): Promise<void> {\n try {\n await idb(\"readwrite\", (s) => s.delete(KEY));\n } catch {\n // ignore\n }\n try {\n localStorage.removeItem(LS_KEY);\n } catch {\n // ignore\n }\n}\n","import type { ClientToServer, ServerToClient } from \"@switchyard/protocol\";\nimport { apiGet } from \"./api\";\nimport { clearCache, loadCache, saveCache } from \"./cache\";\nimport { toSyncState } from \"./reduce\";\nimport { syncStore } from \"./store\";\n\n/**\n * Live sync over `/ws/client`.\n *\n * - On open: `hello {cursor}` with the last applied seq (from memory or the\n * offline cache); the server answers `replay` (events since cursor) or\n * `snapshot` (full SyncState).\n * - Then applies `event` and `stream` frames to the store.\n * - Reconnects with exponential backoff and jitter; `offline` while the\n * browser reports no network.\n * - Probes the link when the page returns to the foreground (a backgrounded phone often\n * holds a dead socket) and gives up on a socket that opens but never syncs.\n * - Persists `{seq, state}` (throttled) so last-known data shows on reload\n * and while reconnecting.\n */\n\nconst PING_INTERVAL_MS = 25_000;\nconst PONG_TIMEOUT_MS = 10_000;\nconst BACKOFF_BASE_MS = 1_000;\nconst BACKOFF_MAX_MS = 30_000;\nconst PERSIST_DELAY_MS = 1_500;\n/** open -> live; scaled by attempts (1x, 2x, 3x) so a large snapshot gets longer on retries. */\nexport const CONNECT_TIMEOUT_MS = 10_000;\nexport const RESUME_PONG_TIMEOUT_MS = 5_000;\n/** Skip the resume ping if a frame arrived this recently. */\nexport const RESUME_FRESH_MS = 5_000;\n\ntype Listener = () => void;\n\nexport class SyncClient {\n private ws: WebSocket | null = null;\n private stopped = true;\n private everLive = false;\n private attempts = 0;\n private retryTimer: ReturnType<typeof setTimeout> | null = null;\n private pingTimer: ReturnType<typeof setInterval> | null = null;\n private pongTimer: ReturnType<typeof setTimeout> | null = null;\n private persistTimer: ReturnType<typeof setTimeout> | null = null;\n private connectTimer: ReturnType<typeof setTimeout> | null = null;\n private lastFrameAt = 0;\n private unsubscribeStore: (() => void) | null = null;\n private liveListeners = new Set<Listener>();\n private logoutListeners = new Set<(reason: string) => void>();\n private cacheLoaded: Promise<void> | null = null;\n\n constructor(private readonly url: string = defaultWsUrl()) {}\n\n /** Load the offline cache into the store and connect. Idempotent. */\n start(): void {\n if (!this.stopped) return;\n this.stopped = false;\n window.addEventListener(\"online\", this.onOnline);\n window.addEventListener(\"offline\", this.onOffline);\n document.addEventListener(\"visibilitychange\", this.onVisibility);\n window.addEventListener(\"pageshow\", this.onForeground);\n window.addEventListener(\"focus\", this.onForeground);\n this.unsubscribeStore = syncStore.subscribe((s, prev) => {\n if (s.synced && s.seq !== prev.seq) this.schedulePersist();\n });\n this.cacheLoaded ??= loadCache().then((cached) => {\n if (cached && !syncStore.getState().synced) {\n syncStore.getState().hydrateFromCache(cached.seq, cached.state, cached.savedAt);\n }\n });\n void this.cacheLoaded.then(() => this.connect());\n }\n\n stop(): void {\n this.stopped = true;\n window.removeEventListener(\"online\", this.onOnline);\n window.removeEventListener(\"offline\", this.onOffline);\n document.removeEventListener(\"visibilitychange\", this.onVisibility);\n window.removeEventListener(\"pageshow\", this.onForeground);\n window.removeEventListener(\"focus\", this.onForeground);\n this.unsubscribeStore?.();\n this.unsubscribeStore = null;\n this.clearTimers();\n const ws = this.ws;\n this.ws = null;\n ws?.close(1000, \"client stopped\");\n }\n\n /** Send a frame when connected. Returns false when it could not be sent. */\n send(msg: ClientToServer): boolean {\n if (this.ws?.readyState !== WebSocket.OPEN) return false;\n this.ws.send(JSON.stringify(msg));\n return true;\n }\n\n get isLive(): boolean {\n return syncStore.getState().connection.state === \"live\";\n }\n\n /** Called each time the connection becomes live (after replay or snapshot). */\n onLive(fn: Listener): () => void {\n this.liveListeners.add(fn);\n return () => this.liveListeners.delete(fn);\n }\n\n /** Called on `force_logout` (device revoked) and on auth failures. */\n onLogout(fn: (reason: string) => void): () => void {\n this.logoutListeners.add(fn);\n return () => this.logoutListeners.delete(fn);\n }\n\n /** Reconnect now (for example from a \"Retry\" button). */\n reconnectNow(): void {\n if (this.stopped) return;\n if (this.retryTimer) clearTimeout(this.retryTimer);\n this.retryTimer = null;\n if (this.ws && this.ws.readyState <= WebSocket.OPEN) return;\n this.connect();\n }\n\n private connect(): void {\n if (this.stopped) return;\n if (typeof navigator !== \"undefined\" && navigator.onLine === false) {\n syncStore.getState().setConnection({ state: \"offline\" });\n return;\n }\n syncStore.getState().setConnection({ state: this.everLive ? \"reconnecting\" : \"connecting\" });\n let ws: WebSocket;\n try {\n ws = new WebSocket(this.url);\n } catch {\n this.scheduleReconnect();\n return;\n }\n this.ws = ws;\n if (this.connectTimer) clearTimeout(this.connectTimer);\n const timeoutMs = CONNECT_TIMEOUT_MS * Math.min(1 + this.attempts, 3);\n this.connectTimer = setTimeout(() => {\n this.connectTimer = null;\n if (this.ws === ws) this.dropSocket(4000, \"connect timeout\");\n }, timeoutMs);\n let opened = false;\n ws.onopen = () => {\n if (this.ws !== ws) return;\n opened = true;\n const cursor = syncStore.getState().seq;\n ws.send(JSON.stringify({ type: \"hello\", cursor } satisfies ClientToServer));\n };\n ws.onmessage = (ev) => {\n if (this.ws !== ws) return;\n this.lastFrameAt = Date.now();\n let msg: ServerToClient;\n try {\n msg = JSON.parse(typeof ev.data === \"string\" ? ev.data : \"\") as ServerToClient;\n } catch {\n return;\n }\n this.handle(msg);\n };\n ws.onclose = (ev) => {\n if (this.ws !== ws) return;\n this.ws = null;\n this.clearTimers();\n if (this.stopped) return;\n // 4401: the coordinator revoked this device (it also sends `force_logout` first).\n // 4403/1008 are treated the same for proxies that map auth failures to close codes.\n if (ev.code === 4401 || ev.code === 4403 || ev.code === 1008) {\n this.emitLogout(ev.reason || \"unauthorized\");\n return;\n }\n // An upgrade rejected with HTTP 401 surfaces only as 1006 before open. Probe\n // GET /api/me: a 401 there signs out through the api() unauthorized listeners.\n if (!opened && this.attempts % 5 === 0) this.probeAuth();\n // 1013 (client too slow) and 1001 (coordinator stopping): reconnect with the cursor.\n this.scheduleReconnect();\n };\n ws.onerror = () => {\n // onclose follows and schedules the reconnect.\n };\n }\n\n private probing = false;\n private probeAuth(): void {\n if (this.probing) return;\n this.probing = true;\n void apiGet(\"/api/me\")\n .catch(() => undefined)\n .finally(() => {\n this.probing = false;\n });\n }\n\n private handle(msg: ServerToClient): void {\n const store = syncStore.getState();\n switch (msg.type) {\n case \"snapshot\":\n store.applySnapshot(msg.seq, msg.state);\n this.becomeLive();\n break;\n case \"replay\":\n store.applyReplay(msg.seq, msg.events);\n this.becomeLive();\n break;\n case \"event\":\n store.applyEvent(msg.event);\n break;\n case \"stream\":\n store.applyStream(msg.delta);\n break;\n case \"pong\":\n if (this.pongTimer) clearTimeout(this.pongTimer);\n this.pongTimer = null;\n store.markSynced();\n break;\n case \"force_logout\":\n this.emitLogout(msg.reason);\n break;\n }\n }\n\n private becomeLive(): void {\n if (this.connectTimer) clearTimeout(this.connectTimer);\n this.connectTimer = null;\n this.everLive = true;\n this.attempts = 0;\n syncStore.getState().setConnection({ state: \"live\", attempts: 0 });\n this.startPing();\n this.schedulePersist();\n for (const fn of this.liveListeners) fn();\n }\n\n private emitLogout(reason: string): void {\n this.stop();\n void clearCache();\n syncStore.getState().reset();\n for (const fn of this.logoutListeners) fn(reason);\n }\n\n private startPing(): void {\n if (this.pingTimer) clearInterval(this.pingTimer);\n this.pingTimer = setInterval(() => {\n if (!this.send({ type: \"ping\" })) return;\n if (!this.pongTimer) this.armPongTimeout(PONG_TIMEOUT_MS);\n }, PING_INTERVAL_MS);\n }\n\n private armPongTimeout(ms: number): void {\n if (this.pongTimer) clearTimeout(this.pongTimer);\n this.pongTimer = setTimeout(() => {\n this.pongTimer = null;\n // No pong: assume a dead socket and reconnect.\n this.dropSocket(4000, \"pong timeout\");\n }, ms);\n }\n\n /** Detach and close a socket we consider dead, then reconnect without waiting for onclose. */\n private dropSocket(code: number, reason: string): void {\n const ws = this.ws;\n if (!ws) return;\n this.ws = null; // its late onclose hits the `this.ws !== ws` guard\n this.clearTimers();\n try {\n ws.close(code, reason);\n } catch {\n // already closing\n }\n this.scheduleReconnect();\n }\n\n private scheduleReconnect(): void {\n if (this.stopped) return;\n if (typeof navigator !== \"undefined\" && navigator.onLine === false) {\n syncStore.getState().setConnection({ state: \"offline\" });\n return;\n }\n this.attempts++;\n const delay = Math.min(BACKOFF_MAX_MS, BACKOFF_BASE_MS * 2 ** (this.attempts - 1));\n const jittered = delay / 2 + Math.random() * (delay / 2);\n syncStore.getState().setConnection({\n state: this.everLive ? \"reconnecting\" : \"connecting\",\n attempts: this.attempts,\n });\n if (this.retryTimer) clearTimeout(this.retryTimer);\n this.retryTimer = setTimeout(() => {\n this.retryTimer = null;\n this.connect();\n }, jittered);\n }\n\n private schedulePersist(): void {\n if (this.persistTimer) return;\n this.persistTimer = setTimeout(() => {\n this.persistTimer = null;\n const s = syncStore.getState();\n if (!s.synced || s.seq === null) return;\n void saveCache({ seq: s.seq, state: toSyncState(s), savedAt: new Date().toISOString() });\n }, PERSIST_DELAY_MS);\n }\n\n private clearTimers(): void {\n if (this.retryTimer) clearTimeout(this.retryTimer);\n if (this.pingTimer) clearInterval(this.pingTimer);\n if (this.pongTimer) clearTimeout(this.pongTimer);\n if (this.connectTimer) clearTimeout(this.connectTimer);\n this.connectTimer = null;\n this.retryTimer = null;\n this.pingTimer = null;\n this.pongTimer = null;\n }\n\n private onOnline = () => {\n this.attempts = 0;\n this.reconnectNow();\n };\n\n private onVisibility = () => {\n if (document.visibilityState === \"visible\") this.onForeground();\n };\n\n /** Back in the foreground (resume, bfcache restore, focus): check the link now. */\n private onForeground = () => {\n if (this.stopped || document.visibilityState === \"hidden\") return;\n if (this.isLive) {\n if (Date.now() - this.lastFrameAt < RESUME_FRESH_MS) return;\n if (this.send({ type: \"ping\" })) this.armPongTimeout(RESUME_PONG_TIMEOUT_MS);\n return;\n }\n this.attempts = 0;\n this.reconnectNow();\n };\n\n private onOffline = () => {\n syncStore.getState().setConnection({ state: \"offline\" });\n this.ws?.close(4000, \"offline\");\n };\n}\n\nexport function defaultWsUrl(): string {\n const proto = location.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n return `${proto}//${location.host}/ws/client`;\n}\n\n/** The app-wide client instance. */\nexport const syncClient = new SyncClient(typeof location === \"undefined\" ? \"\" : defaultWsUrl());\n","import type { MeResponse } from \"@switchyard/protocol\";\nimport { create } from \"zustand\";\nimport { startPresence } from \"../presence\";\nimport { ApiClientError, apiGet, onUnauthorized } from \"../sync/api\";\nimport { clearCache } from \"../sync/cache\";\nimport { syncClient } from \"../sync/client\";\nimport { syncStore } from \"../sync/store\";\n\n/** Response of GET /api/me (protocol `MeResponse`). */\nexport type Me = MeResponse;\n\nexport type AuthStatus = \"checking\" | \"authenticated\" | \"unauthenticated\" | \"error\";\n\ninterface AuthStore {\n status: AuthStatus;\n me: Me | null;\n error: unknown;\n /** Why the device was signed out (device revoked, force_logout reason). */\n signedOutReason: string | null;\n}\n\nexport const useAuth = create<AuthStore>()(() => ({\n status: \"checking\",\n me: null,\n error: null,\n signedOutReason: null,\n}));\n\nconst ME_KEY = \"sy:me\";\nconst RETURN_KEY = \"sy:returnTo\";\n\nlet stopPresence: (() => void) | null = null;\n\nfunction startSync(): void {\n syncClient.start();\n stopPresence ??= startPresence(syncClient);\n}\n\nfunction stopSync(): void {\n syncClient.stop();\n stopPresence?.();\n stopPresence = null;\n}\n\n/** The current device id, when known. */\nexport function currentDeviceId(): string | null {\n const me = useAuth.getState().me;\n return me?.device?.id ?? null;\n}\n\n/** GET /api/me; starts live sync when authenticated. */\nexport async function checkAuth(): Promise<AuthStatus> {\n useAuth.setState({ status: \"checking\", error: null });\n try {\n const me = await apiGet<Me>(\"/api/me\");\n try {\n localStorage.setItem(ME_KEY, JSON.stringify(me));\n } catch {\n // ignore\n }\n useAuth.setState({ status: \"authenticated\", me, signedOutReason: null });\n startSync();\n return \"authenticated\";\n } catch (e) {\n if (e instanceof ApiClientError && (e.status === 401 || e.code === \"device_revoked\")) {\n signOut(e.code === \"device_revoked\" ? \"This device was revoked.\" : null);\n return \"unauthenticated\";\n }\n // Coordinator unreachable: run from the offline cache if this device enrolled before.\n const cached = readCachedMe();\n if (cached) {\n useAuth.setState({ status: \"authenticated\", me: cached });\n startSync();\n return \"authenticated\";\n }\n useAuth.setState({ status: \"error\", error: e });\n return \"error\";\n }\n}\n\nfunction readCachedMe(): Me | null {\n try {\n const raw = localStorage.getItem(ME_KEY);\n const me = raw ? (JSON.parse(raw) as Partial<Me>) : null;\n // Ignore caches written before the shape was known.\n return me?.device?.id ? (me as Me) : null;\n } catch {\n return null;\n }\n}\n\n/** Forget the local session and show sign-in. */\nexport function signOut(reason: string | null): void {\n stopSync();\n void clearCache();\n syncStore.getState().reset();\n try {\n localStorage.removeItem(ME_KEY);\n } catch {\n // ignore\n }\n useAuth.setState({ status: \"unauthenticated\", me: null, signedOutReason: reason });\n}\n\n/** Remember where to go after sign-in (deep links survive authentication). */\nexport function saveReturnTo(url: string): void {\n if (url.startsWith(\"/sign-in\") || url.startsWith(\"/enroll\")) return;\n try {\n localStorage.setItem(RETURN_KEY, url);\n } catch {\n // ignore\n }\n}\n\n/** Saved deep link (consumed). Only same-origin paths are honored. */\nexport function takeReturnTo(fromQuery: string | null): string {\n let saved: string | null = null;\n try {\n saved = localStorage.getItem(RETURN_KEY);\n localStorage.removeItem(RETURN_KEY);\n } catch {\n // ignore\n }\n const candidate = fromQuery ?? saved;\n if (\n candidate?.startsWith(\"/\") &&\n !candidate.startsWith(\"//\") &&\n !candidate.startsWith(\"/sign-in\") &&\n !candidate.startsWith(\"/enroll\")\n ) {\n return candidate;\n }\n return \"/\";\n}\n\nlet wired = false;\n/** Wire global auth listeners once. */\nexport function initAuth(): void {\n if (wired) return;\n wired = true;\n onUnauthorized((code) => {\n if (useAuth.getState().status === \"authenticated\") {\n signOut(code === \"device_revoked\" ? \"This device was revoked.\" : null);\n }\n });\n syncClient.onLogout((reason) => {\n signOut(reason === \"unauthorized\" ? null : `Signed out: ${reason}`);\n });\n}\n"],"mappings":"A,2HAcA,IAAMO,EAAU,aACVC,EAAQ,KACRC,EAAM,OACNC,EAAS,gBAEXC,EAAgD,KAEpD,SAASC,GAAsC,CAc7C,OAbID,IACJ,EAAY,IAAI,QAAS,GAAY,CACnC,GAAI,OAAO,UAAc,IAAa,OAAOE,EAAQ,IAAI,EACzD,GAAI,CACF,IAAMC,EAAM,UAAU,KAAKP,EAAS,CAAC,EACrC,EAAI,oBAAwBO,EAAI,OAAO,kBAAkBN,CAAK,EAC9D,EAAI,cAAkBK,EAAQC,EAAI,MAAM,EACxC,EAAI,YAAgBD,EAAQ,IAAI,EAChC,EAAI,cAAkBA,EAAQ,IAAI,CACpC,MAAQ,CACNA,EAAQ,IAAI,CACd,CACF,CAAC,EACMF,EACT,CAEA,SAASI,EAAO,EAA0B,EAAsD,CAC9F,OAAOH,EAAO,CAAC,CAAC,KACb,GACC,IAAI,SAAY,EAAS,IAAW,CAClC,GAAI,CAACI,EAAI,OAAOC,EAAW,MAAM,cAAc,CAAC,EAEhD,I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AC,CAAC,MAAM,EAC3B,GAAI,CACF,aAAa,WAAWqD,CAAM,CAChC,MAAQ,CAER,CACAD,EAAQ,SAAS,CAAE,OAAQ,kBAAmB,GAAI,KAAM,gBAAiBN,CAAO,CAAC,CACnF,CAGA,SAAgBiB,EAAa,EAAmB,CAC9C,GAAI,IAAI,WAAW,UAAU,GAAK3B,EAAI,WAAW,SAAS,GAC1D,GAAI,CACF,aAAa,QAAQkB,EAAYlB,CAAG,CACtC,MAAQ,CAER,CACF,CAGA,SAAgB4B,EAAa,EAAkC,CAC7D,IAAIC,EAAuB,KAC3B,GAAI,CACF,EAAQ,aAAa,QAAQX,CAAU,EACvC,aAAa,WAAWA,CAAU,CACpC,MAAQ,CAER,CACA,IAAMY,EAAYC,GAAaF,EAS/B,OAPEC,GAAW,WAAW,GAAG,GACzB,CAACA,EAAU,WAAW,IAAI,GAC1B,CAACA,EAAU,WAAW,UAAU,GAChC,CAACA,EAAU,WAAW,SAAS,EAExBA,EAEF,GACT,CAEA,IAAIE,EAAQ,GAEZ,SAAgBC,GAAiB,CAC3BD,IACJ,EAAQ,GACR/D,EAAgB,GAAS,CACnB+C,EAAQ,SAAS,CAAC,CAAC,SAAW,iBAChCS,EAAQb,IAAS,iBAAmB,2BAA6B,IAAI,CAEzE,CAAC,EACDG,EAAW,SAAU,GAAW,CAC9BU,EAAQf,IAAW,eAAiB,KAAO,eAAeA,GAAQ,CACpE,CAAC,EACH,C"}
@@ -1,2 +0,0 @@
1
- import{_ as e,i as t,m as n,n as r,t as i}from"./jsx-runtime-D13aM9HY.js";import{_ as a,c as o,d as s,f as c,gt as l,h as u,n as d,r as f,s as p,t as m,tt as h,z as g}from"./states-C773NlHo.js";import{t as _}from"./calendar-clock-B8zE4JsX.js";import{t as v}from"./chevron-right-evVLS6hq.js";import{c as y,o as b,t as x}from"./useBreakpoint-BphHBrzF.js";import{t as S}from"./hand-UPoHamrn.js";import{t as C}from"./link-2-CaMlUDRG.js";import{t as w}from"./play-CjoDg3ws.js";import{i as T,t as E}from"./useBackTo-BIrCq3W2.js";import{x as D}from"./index-BHGZTS2e.js";import{t as O}from"./Switch-DAcUcSbH.js";import{C as k,D as A,O as j,T as M,_ as N,c as P,k as F,p as I}from"./describe-CVXeUClF.js";var L={name:`webhook`,size:24,node:[[`path`,{d:`M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2`,key:`q3hayz`}],[`path`,{d:`m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06`,key:`1go1hn`}],[`path`,{d:`m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8`,key:`qlwsc0`}]]};L.node;var R=r(L),z=e(n(),1),B=i(),V=`/automations/new`,H=e=>`/automations/${encodeURIComponent(e)}`,U={manual:S,once:y,cron:_,webhook:R,dependency:C};function W(){let e=g(e=>e.hydrated),n=A(),r=g(e=>e.projects),i=g(e=>e.hosts),a=g(e=>e.tasks),s=x(),[u,_]=(0,z.useState)({status:`idle`}),v=(0,z.useCallback)(async()=>{_({status:`loading`});try{let e=await l(`/api/automations`),t=Array.isArray(e)?e:e&&typeof e==`object`&&Array.isArray(e.items)?e.items:null,n=t?h.array().safeParse(t):null;if(!n?.success){_({status:`fatal`,error:Error(`The coordinator returned automations in an unexpected format.`)});return}M.getState().putMany(n.data),_({status:`done`})}catch(e){_({status:`error`,error:e})}},[]);(0,z.useEffect)(()=>{e||v()},[e,v]);let y=(0,z.useMemo)(()=>Object.values(n).sort((e,t)=>e.name.localeCompare(t.name)),[n]),b=e||u.status===`done`,S;return S=b?y.length===0?(0,B.jsx)(m,{icon:(0,B.jsx)(D,{className:`size-8`}),title:`No automations yet`,description:`Automations create tasks on a schedule, from a webhook, or when another task is done.`,action:{label:`Create an automation`,to:V,icon:(0,B.jsx)(T,{className:`size-4`})}}):(0,B.jsx)(K,{automations:y,projects:r,hosts:i,tasks:a,table:s===`desktop`}):u.status===`fatal`?(0,B.jsx)(f,{error:u.error}):u.status===`error`?(0,B.jsx)(d,{title:`Could not load automations`,error:u.error,onRetry:()=>void v()}):(0,B.jsx)(o,{label:`Loading automations…`}),(0,B.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col gap-4 px-4 py-4 md:px-6`,children:[(0,B.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Automations`}),(0,B.jsx)(`p`,{className:`text-sm text-muted`,children:`Scheduled, webhook and dependency automations. Routine successes stay in each automation's history.`})]}),(0,B.jsxs)(t,{to:V,state:E,className:c(`primary`),children:[(0,B.jsx)(T,{"aria-hidden":!0,className:`size-4`}),`New automation`]})]}),(0,B.jsx)(p,{subject:`automations`,consequence:`Changes are sent once the coordinator is reachable again.`}),S]})}var G=`grid grid-cols-[minmax(0,2.4fr)_minmax(0,1fr)_5.5rem_minmax(0,1.2fr)_minmax(0,1.4fr)_7.5rem_7rem_auto] items-center gap-3`;function K({automations:e,projects:t,hosts:n,tasks:r,table:i}){let{busy:o,toggle:s}=F(),{busy:c,run:l}=j(),u=(0,z.useCallback)(e=>r[e]?.title,[r]);return(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden rounded-lg border border-border bg-surface`,children:[i&&(0,B.jsxs)(`div`,{"aria-hidden":!0,className:a(G,`border-b border-border bg-surface-2 px-4 py-2 text-xs font-medium text-muted`),children:[(0,B.jsx)(`span`,{children:`Automation`}),(0,B.jsx)(`span`,{children:`Project`}),(0,B.jsx)(`span`,{children:`Mode`}),(0,B.jsx)(`span`,{children:`Next occurrence`}),(0,B.jsx)(`span`,{children:`Last outcome`}),(0,B.jsx)(`span`,{children:`Failures`}),(0,B.jsx)(`span`,{children:`Enabled`}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Actions`})]}),(0,B.jsx)(`ul`,{"data-testid":`automations-list`,className:`divide-y divide-border`,children:e.map(e=>{let r=t[e.projectId],a=e.hostId??r?.defaultHostId??null,d=a?n[a]:void 0,f={automation:e,projectName:r?.name??`Unknown project`,host:d,trigger:P(e.trigger,{taskTitle:u}),toggling:!!o[e.id],running:!!c[e.id],onToggle:t=>void s(e,t),onRun:()=>void l(e)};return(0,B.jsx)(`li`,{"data-testid":`automation-row`,"data-automation-id":e.id,children:i?(0,B.jsx)(Z,{...f}):(0,B.jsx)(Q,{...f})},e.id)})})]})}function q({automation:e,trigger:t}){let n=U[e.trigger.kind];return(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-1.5 text-sm text-muted`,children:[(0,B.jsx)(n,{"aria-hidden":!0,className:`mt-0.5 size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:t})]})}function J({automation:e}){if(!e.enabled)return(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:`Disabled`});if(!e.nextAt){let t=e.trigger.kind;return(0,B.jsx)(`span`,{className:`text-sm text-muted`,children:t===`manual`?`On demand`:t===`webhook`?`On webhook`:t===`dependency`?`When the task is done`:`None scheduled`})}return(0,B.jsxs)(`span`,{className:`flex min-w-0 flex-col text-sm`,children:[(0,B.jsx)(`span`,{children:u(e.nextAt)}),(0,B.jsx)(`time`,{dateTime:e.nextAt,className:`text-xs text-muted`,children:I(e.nextAt)})]})}function Y({host:e}){return!e||e.connectivity===`connected`?null:(0,B.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-danger`,children:[(0,B.jsx)(b,{"aria-hidden":!0,className:`size-3.5 shrink-0`}),(0,B.jsxs)(`span`,{className:`min-w-0 break-words`,children:[`Host `,e.name,` `,e.connectivity===`reconnecting`?`reconnecting`:`unreachable`]})]})}function X({running:e,onRun:t,name:n}){return(0,B.jsx)(s,{size:`sm`,busy:e,icon:(0,B.jsx)(w,{className:`size-3.5`}),onClick:t,"aria-label":`Run ${n} now`,children:`Run now`})}function Z(e){let n=e.automation;return(0,B.jsxs)(`div`,{className:a(G,`px-4 py-3`),children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(t,{to:H(n.id),state:E,className:`truncate font-medium text-text hover:underline focus-visible:underline`,children:n.name}),(0,B.jsx)(q,{automation:n,trigger:e.trigger})]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Project: `}),(0,B.jsx)(`span`,{className:`truncate text-sm`,children:e.projectName}),(0,B.jsx)(Y,{host:e.host})]}),(0,B.jsxs)(`span`,{className:`text-sm`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Mode: `}),N(n.mode)]}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Next occurrence: `}),(0,B.jsx)(J,{automation:n})]}),(0,B.jsxs)(`div`,{className:`min-w-0 text-sm break-words`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Last outcome: `}),n.lastOutcome??(0,B.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})]}),(0,B.jsx)(k,{count:n.failureCount}),(0,B.jsx)(O,{checked:n.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${n.name}`,onText:`Enabled`,offText:`Disabled`}),(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsx)(X,{running:e.running,onRun:e.onRun,name:n.name}),(0,B.jsx)(t,{to:H(n.id),state:E,"aria-label":`Edit ${n.name}`,title:`Edit`,className:`tap inline-flex size-9 items-center justify-center rounded-md text-muted hover:bg-surface-2 hover:text-text`,children:(0,B.jsx)(v,{"aria-hidden":!0,className:`size-4`})})]})]})}function Q(e){let n=e.automation;return(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2 px-4 py-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,B.jsx)(t,{to:H(n.id),state:E,className:`font-medium break-words text-text hover:underline focus-visible:underline`,children:n.name}),(0,B.jsx)(q,{automation:n,trigger:e.trigger})]}),(0,B.jsx)(O,{checked:n.enabled,onChange:e.onToggle,busy:e.toggling,label:`Enable ${n.name}`,onText:`Enabled`,offText:`Disabled`})]}),(0,B.jsxs)(`dl`,{className:`grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[(0,B.jsx)(`dt`,{className:`text-muted`,children:`Project`}),(0,B.jsxs)(`dd`,{className:`flex min-w-0 flex-col break-words`,children:[e.projectName,(0,B.jsx)(Y,{host:e.host})]}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Mode`}),(0,B.jsx)(`dd`,{children:N(n.mode)}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Next`}),(0,B.jsx)(`dd`,{className:`min-w-0`,children:(0,B.jsx)(J,{automation:n})}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Last outcome`}),(0,B.jsx)(`dd`,{className:`min-w-0 break-words`,children:n.lastOutcome??(0,B.jsx)(`span`,{className:`text-muted`,children:`No runs yet`})}),(0,B.jsx)(`dt`,{className:`text-muted`,children:`Failures`}),(0,B.jsx)(`dd`,{children:(0,B.jsx)(k,{count:n.failureCount})})]}),(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,B.jsx)(X,{running:e.running,onRun:e.onRun,name:n.name}),(0,B.jsxs)(t,{to:H(n.id),state:E,className:c(`ghost`,`sm`),children:[`Edit`,(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3.5`})]})]})]})}export{W as default};
2
- //# sourceMappingURL=automations-BzpsJoa3.js.map
@@ -1,2 +0,0 @@
1
- import{n as e}from"./jsx-runtime-D13aM9HY.js";var t={name:`bell`,size:24,node:[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]};t.node;var n=e(t);export{n as t};
2
- //# sourceMappingURL=bell-DSwa2PAb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bell-DSwa2PAb.js","names":["createLucideIcon","__iconData","Bell"],"sources":["../../../../node_modules/.pnpm/lucide-react@1.61.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/bell.mjs"],"sourcesContent":["/**\n * @license lucide-react v1.61.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"bell\",\n size: 24,\n node: [\n [\"path\", { d: \"M10.268 21a2 2 0 0 0 3.464 0\", key: \"vwvbt9\" }],\n [\n \"path\",\n {\n d: \"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326\",\n key: \"11g9vi\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Bell = createLucideIcon(__iconData);\n\nexport { __iconData, Bell as default };\n//# sourceMappingURL=bell.mjs.map\n"],"ignoreList":[0],"mappings":"A,8CASA,IAAMC,EAAa,CACjB,KAAM,OACN,KAAM,GACN,KAAM,CACJ,CAAC,OAAQ,CAAE,EAAG,+BAAgC,IAAK,QAAS,CAAC,EAC7D,CACE,OACA,CACE,EAAG,gIACH,IAAK,QACP,CACF,CACF,CACF,EACAA,EAAW,KACX,IAAMC,EAAOF,EAAiBC,CAAU,E"}