elanous 0.3.2 → 0.3.3

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 (214) hide show
  1. package/apps/pwa/out/404/index.html +1 -1
  2. package/apps/pwa/out/404.html +1 -1
  3. package/apps/pwa/out/_next/static/chunks/{280-f880696e14bc1032.js → 280-53fe7ab5dbd19607.js} +1 -1
  4. package/apps/pwa/out/_next/static/chunks/{5359-11952bdf39bae0c7.js → 5359-7aa498ded308ea17.js} +1 -1
  5. package/apps/pwa/out/_next/static/chunks/app/approvals/{page-822c5395a88eb1e5.js → page-c9e997416c86c8dd.js} +1 -1
  6. package/apps/pwa/out/_next/static/chunks/app/autopilot/page-4e24912975188223.js +1 -0
  7. package/apps/pwa/out/_next/static/chunks/app/board/{page-26941f067e899ed3.js → page-b117b7ee316afe86.js} +1 -1
  8. package/apps/pwa/out/_next/static/chunks/app/botlab/{page-3c29b0e0d681e33d.js → page-a447a17fd887c68e.js} +1 -1
  9. package/apps/pwa/out/_next/static/chunks/app/bots/page-2b3e0df385eba76f.js +1 -0
  10. package/apps/pwa/out/_next/static/chunks/app/ceo/{page-1224ce11e2a2eef5.js → page-409ed1d2f2c5f706.js} +1 -1
  11. package/apps/pwa/out/_next/static/chunks/app/chat/{page-940b44876305fac2.js → page-1e90543da0a66b63.js} +1 -1
  12. package/apps/pwa/out/_next/static/chunks/app/consult/{page-c5b8f3b77568a8e9.js → page-f68c84b50dee9796.js} +1 -1
  13. package/apps/pwa/out/_next/static/chunks/app/control/page-afefb7fac0047855.js +1 -0
  14. package/apps/pwa/out/_next/static/chunks/app/decisions/{page-3048505d466ec98a.js → page-79f9d6ae042c07b4.js} +1 -1
  15. package/apps/pwa/out/_next/static/chunks/app/design-check/{page-8d97da172a2cd552.js → page-9726864cd21303a2.js} +1 -1
  16. package/apps/pwa/out/_next/static/chunks/app/editor/page-ab0febcc6695f4e4.js +1 -0
  17. package/apps/pwa/out/_next/static/chunks/app/exec/page-6f6b157c52869db0.js +1 -0
  18. package/apps/pwa/out/_next/static/chunks/app/field/{page-c4f1095489266f97.js → page-78aef36734ddd588.js} +1 -1
  19. package/apps/pwa/out/_next/static/chunks/app/inside/page-6a634383e6247c6b.js +1 -0
  20. package/apps/pwa/out/_next/static/chunks/app/intake/{page-111a4245428caa84.js → page-66f0dc569bce5230.js} +1 -1
  21. package/apps/pwa/out/_next/static/chunks/app/{layout-956789c8340e289e.js → layout-fda2f39e4d21744c.js} +1 -1
  22. package/apps/pwa/out/_next/static/chunks/app/live/page-a6fd7cb710d80092.js +1 -0
  23. package/apps/pwa/out/_next/static/chunks/app/live-run/page-2a7c714e7f65229d.js +1 -0
  24. package/apps/pwa/out/_next/static/chunks/app/loops/page-a71ad5f5b075be8d.js +1 -0
  25. package/apps/pwa/out/_next/static/chunks/app/market/page-df7f2d252ff836b5.js +1 -0
  26. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-7f38deb0998488bf.js +1 -0
  27. package/apps/pwa/out/_next/static/chunks/app/morning/{page-afa5068541a55cd1.js → page-7e80f3b354be205e.js} +1 -1
  28. package/apps/pwa/out/_next/static/chunks/app/not-found-5ea0e042882e87de.js +1 -0
  29. package/apps/pwa/out/_next/static/chunks/app/observatory/{page-527a398eac0b4699.js → page-f3df76408c930b99.js} +1 -1
  30. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/page-88996ccc31edf06c.js +1 -0
  31. package/apps/pwa/out/_next/static/chunks/app/ops/release/page-d95db9df4a907fe1.js +1 -0
  32. package/apps/pwa/out/_next/static/chunks/app/ops/resources/{page-da8f855dc25cae3d.js → page-5a518950f4136aad.js} +1 -1
  33. package/apps/pwa/out/_next/static/chunks/app/ops/seats/page-d9e070e009e1a521.js +1 -0
  34. package/apps/pwa/out/_next/static/chunks/app/outputs/{page-905013106f55daad.js → page-167c44a8ff378706.js} +1 -1
  35. package/apps/pwa/out/_next/static/chunks/app/page-4763cf1b0e52e28b.js +1 -0
  36. package/apps/pwa/out/_next/static/chunks/app/reflection/{page-3b0434a6fc1154e1.js → page-a5bcd883385064d4.js} +1 -1
  37. package/apps/pwa/out/_next/static/chunks/app/scheduler/{page-9deae0524ce7a7e2.js → page-f9ef43f59ba98937.js} +1 -1
  38. package/apps/pwa/out/_next/static/chunks/app/sessions/{page-4f4f0858754f73a4.js → page-43c5d7004582f888.js} +1 -1
  39. package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-20dfe2b5bca855eb.js +1 -0
  40. package/apps/pwa/out/_next/static/chunks/app/settings/page-7c022f7edf3203d5.js +1 -0
  41. package/apps/pwa/out/_next/static/chunks/app/setup/done/{page-2e8cc4d212f1ca01.js → page-adc6daed842128e6.js} +1 -1
  42. package/apps/pwa/out/_next/static/chunks/app/setup/page-683c175da53e9ec3.js +1 -0
  43. package/apps/pwa/out/_next/static/chunks/app/share/page-a91d9cbaf50cc8b4.js +1 -0
  44. package/apps/pwa/out/_next/static/chunks/app/showroom/page-376f3a03f4d31706.js +1 -0
  45. package/apps/pwa/out/_next/static/chunks/app/tasks/{page-aedaede687cc293d.js → page-256d83e84ed55191.js} +1 -1
  46. package/apps/pwa/out/_next/static/chunks/app/term/{page-bb5c95ce68358be2.js → page-5e1fb7a8e0927cf6.js} +1 -1
  47. package/apps/pwa/out/_next/static/chunks/app/today/page-95994b2b507ee120.js +1 -0
  48. package/apps/pwa/out/_next/static/chunks/app/trace/{page-45967d78c1748112.js → page-486b1d3605dbd5f3.js} +1 -1
  49. package/apps/pwa/out/_next/static/chunks/app/vault/{page-9a1cdd7c5a50bf73.js → page-0159591688c45cae.js} +1 -1
  50. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-e640489e459c2789.js +1 -0
  51. package/apps/pwa/out/_next/static/chunks/app/workflows/page-89c00bebfb27b5d5.js +1 -0
  52. package/apps/pwa/out/_next/static/chunks/app/workspace/{page-8f291522cb3d91a6.js → page-edf90eaa6d354fee.js} +1 -1
  53. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-2f2bd38085305ef0.js +1 -0
  54. package/apps/pwa/out/approvals/index.html +1 -1
  55. package/apps/pwa/out/approvals/index.txt +13 -13
  56. package/apps/pwa/out/autopilot/index.html +1 -1
  57. package/apps/pwa/out/autopilot/index.txt +13 -13
  58. package/apps/pwa/out/board/index.html +1 -1
  59. package/apps/pwa/out/board/index.txt +13 -13
  60. package/apps/pwa/out/botlab/index.html +1 -1
  61. package/apps/pwa/out/botlab/index.txt +13 -13
  62. package/apps/pwa/out/bots/index.html +1 -1
  63. package/apps/pwa/out/bots/index.txt +13 -13
  64. package/apps/pwa/out/ceo/index.html +1 -1
  65. package/apps/pwa/out/ceo/index.txt +13 -13
  66. package/apps/pwa/out/chat/index.html +1 -1
  67. package/apps/pwa/out/chat/index.txt +13 -13
  68. package/apps/pwa/out/consult/index.html +1 -1
  69. package/apps/pwa/out/consult/index.txt +13 -13
  70. package/apps/pwa/out/control/index.html +1 -1
  71. package/apps/pwa/out/control/index.txt +13 -13
  72. package/apps/pwa/out/decisions/index.html +1 -1
  73. package/apps/pwa/out/decisions/index.txt +13 -13
  74. package/apps/pwa/out/design-check/index.html +1 -1
  75. package/apps/pwa/out/design-check/index.txt +13 -13
  76. package/apps/pwa/out/editor/index.html +1 -1
  77. package/apps/pwa/out/editor/index.txt +13 -13
  78. package/apps/pwa/out/exec/index.html +1 -1
  79. package/apps/pwa/out/exec/index.txt +13 -13
  80. package/apps/pwa/out/field/index.html +1 -1
  81. package/apps/pwa/out/field/index.txt +13 -13
  82. package/apps/pwa/out/healthz +1 -1
  83. package/apps/pwa/out/index.html +1 -1
  84. package/apps/pwa/out/index.txt +13 -13
  85. package/apps/pwa/out/inside/index.html +1 -1
  86. package/apps/pwa/out/inside/index.txt +13 -13
  87. package/apps/pwa/out/intake/index.html +1 -1
  88. package/apps/pwa/out/intake/index.txt +13 -13
  89. package/apps/pwa/out/live/index.html +1 -1
  90. package/apps/pwa/out/live/index.txt +13 -13
  91. package/apps/pwa/out/live-run/index.html +1 -1
  92. package/apps/pwa/out/live-run/index.txt +13 -13
  93. package/apps/pwa/out/loops/index.html +1 -1
  94. package/apps/pwa/out/loops/index.txt +13 -13
  95. package/apps/pwa/out/market/index.html +1 -1
  96. package/apps/pwa/out/market/index.txt +13 -13
  97. package/apps/pwa/out/missions/placeholder/index.html +1 -1
  98. package/apps/pwa/out/missions/placeholder/index.txt +13 -13
  99. package/apps/pwa/out/morning/index.html +1 -1
  100. package/apps/pwa/out/morning/index.txt +13 -13
  101. package/apps/pwa/out/observatory/index.html +1 -1
  102. package/apps/pwa/out/observatory/index.txt +13 -13
  103. package/apps/pwa/out/ops/checklist/index.html +1 -1
  104. package/apps/pwa/out/ops/checklist/index.txt +13 -13
  105. package/apps/pwa/out/ops/release/index.html +1 -1
  106. package/apps/pwa/out/ops/release/index.txt +13 -13
  107. package/apps/pwa/out/ops/resources/index.html +1 -1
  108. package/apps/pwa/out/ops/resources/index.txt +13 -13
  109. package/apps/pwa/out/ops/seats/index.html +1 -1
  110. package/apps/pwa/out/ops/seats/index.txt +13 -13
  111. package/apps/pwa/out/outputs/index.html +1 -1
  112. package/apps/pwa/out/outputs/index.txt +13 -13
  113. package/apps/pwa/out/reflection/index.html +1 -1
  114. package/apps/pwa/out/reflection/index.txt +14 -14
  115. package/apps/pwa/out/scheduler/index.html +1 -1
  116. package/apps/pwa/out/scheduler/index.txt +13 -13
  117. package/apps/pwa/out/sessions/index.html +1 -1
  118. package/apps/pwa/out/sessions/index.txt +13 -13
  119. package/apps/pwa/out/settings/devices/index.html +1 -1
  120. package/apps/pwa/out/settings/devices/index.txt +13 -13
  121. package/apps/pwa/out/settings/index.html +1 -1
  122. package/apps/pwa/out/settings/index.txt +13 -13
  123. package/apps/pwa/out/setup/done/index.html +1 -1
  124. package/apps/pwa/out/setup/done/index.txt +13 -13
  125. package/apps/pwa/out/setup/index.html +1 -1
  126. package/apps/pwa/out/setup/index.txt +13 -13
  127. package/apps/pwa/out/share/index.html +1 -1
  128. package/apps/pwa/out/share/index.txt +13 -13
  129. package/apps/pwa/out/showroom/index.html +1 -1
  130. package/apps/pwa/out/showroom/index.txt +13 -13
  131. package/apps/pwa/out/tasks/index.html +1 -1
  132. package/apps/pwa/out/tasks/index.txt +13 -13
  133. package/apps/pwa/out/term/index.html +1 -1
  134. package/apps/pwa/out/term/index.txt +13 -13
  135. package/apps/pwa/out/today/index.html +1 -1
  136. package/apps/pwa/out/today/index.txt +13 -13
  137. package/apps/pwa/out/trace/index.html +1 -1
  138. package/apps/pwa/out/trace/index.txt +13 -13
  139. package/apps/pwa/out/vault/index.html +1 -1
  140. package/apps/pwa/out/vault/index.txt +13 -13
  141. package/apps/pwa/out/workflows/chat-ui/index.html +1 -1
  142. package/apps/pwa/out/workflows/chat-ui/index.txt +13 -13
  143. package/apps/pwa/out/workflows/index.html +1 -1
  144. package/apps/pwa/out/workflows/index.txt +13 -13
  145. package/apps/pwa/out/workspace/index.html +1 -1
  146. package/apps/pwa/out/workspace/index.txt +13 -13
  147. package/apps/pwa/out/worktrees/index.html +1 -1
  148. package/apps/pwa/out/worktrees/index.txt +13 -13
  149. package/graphs/natural-language-research.yaml +38 -0
  150. package/package.json +1 -1
  151. package/personas/botlab-4.yaml +8 -0
  152. package/src/auto-research/research-turn.ts +120 -5
  153. package/src/cli/intake-source-cli.ts +9 -4
  154. package/src/cli/release-cli.ts +7 -2
  155. package/src/cli/setup-cli.ts +2 -2
  156. package/src/cli/setup-keys.ts +8 -5
  157. package/src/core-turn/run-core-turn.ts +93 -14
  158. package/src/dashboard/first-screen-band.ts +2 -6
  159. package/src/dashboard/index.ts +41 -13
  160. package/src/dashboard/plugin-wizard-runtime.ts +15 -1
  161. package/src/dashboard/plugin-wizard-tool.ts +16 -2
  162. package/src/dashboard/turn-preamble.ts +8 -0
  163. package/src/index.ts +26 -0
  164. package/src/intake-plane/actions.ts +20 -12
  165. package/src/intake-plane/intake-sources.ts +32 -11
  166. package/src/intake-plane/items.ts +1 -1
  167. package/src/mcp/server.ts +7 -2
  168. package/src/native-tool-catalog.ts +3 -0
  169. package/src/nexus/api/harness-traversal.ts +3 -3
  170. package/src/nexus/api/meta-api.ts +3 -1
  171. package/src/nexus/api/research-run-observer.ts +59 -0
  172. package/src/onboarding/first-run-doctor-test-control.ts +42 -0
  173. package/src/onboarding/first-run-doctor.ts +1 -0
  174. package/src/prompt-library/session-guidance.ts +7 -6
  175. package/src/self-implement/run-ledger.ts +1 -1
  176. package/src/self-implement/run-step-projection.ts +10 -2
  177. package/src/session/chat.ts +2 -0
  178. package/src/session-runtime/index.ts +47 -5
  179. package/src/setup/service-key-catalog.ts +4 -2
  180. package/src/setup/service-keys.ts +34 -10
  181. package/src/terminal/coding-agent.ts +12 -1
  182. package/src/tool-hints/gate.ts +7 -3
  183. package/src/tool-hints/signals.ts +43 -1
  184. package/src/tui.ts +97 -4
  185. package/src/ux-sim/classic-tui-seat-scenarios.ts +54 -4
  186. package/src/ux-sim/mock-scenario-catalog.json +8 -3
  187. package/src/version/packed-revision.json +1 -1
  188. package/apps/pwa/out/_next/static/chunks/app/autopilot/page-9d7432ad7cb155ce.js +0 -1
  189. package/apps/pwa/out/_next/static/chunks/app/bots/page-d1cdb65c4ceb5c33.js +0 -1
  190. package/apps/pwa/out/_next/static/chunks/app/control/page-77db1e47b120b94e.js +0 -1
  191. package/apps/pwa/out/_next/static/chunks/app/editor/page-6a36535d413596b1.js +0 -1
  192. package/apps/pwa/out/_next/static/chunks/app/exec/page-8696a777c88bacc2.js +0 -1
  193. package/apps/pwa/out/_next/static/chunks/app/inside/page-ea374796ca2317b9.js +0 -1
  194. package/apps/pwa/out/_next/static/chunks/app/live/page-7645ef6d17d2314b.js +0 -1
  195. package/apps/pwa/out/_next/static/chunks/app/live-run/page-3448160192777209.js +0 -1
  196. package/apps/pwa/out/_next/static/chunks/app/loops/page-e911bcd2bfb5c305.js +0 -1
  197. package/apps/pwa/out/_next/static/chunks/app/market/page-52b55f54c9d8e0fb.js +0 -1
  198. package/apps/pwa/out/_next/static/chunks/app/missions/[id]/page-6a904a7d1b3aee11.js +0 -1
  199. package/apps/pwa/out/_next/static/chunks/app/not-found-3eb72a4f6788a903.js +0 -1
  200. package/apps/pwa/out/_next/static/chunks/app/ops/checklist/page-c9e4ca5025534239.js +0 -1
  201. package/apps/pwa/out/_next/static/chunks/app/ops/release/page-63c8938149254e9d.js +0 -1
  202. package/apps/pwa/out/_next/static/chunks/app/ops/seats/page-f48403ffee4c4b77.js +0 -1
  203. package/apps/pwa/out/_next/static/chunks/app/page-f95beb047d743d09.js +0 -1
  204. package/apps/pwa/out/_next/static/chunks/app/settings/devices/page-73857fa536e7c832.js +0 -1
  205. package/apps/pwa/out/_next/static/chunks/app/settings/page-c0bdee145df0f6c9.js +0 -1
  206. package/apps/pwa/out/_next/static/chunks/app/setup/page-fe67b4e66f496b3a.js +0 -1
  207. package/apps/pwa/out/_next/static/chunks/app/share/page-b8c0c73c2e5a8917.js +0 -1
  208. package/apps/pwa/out/_next/static/chunks/app/showroom/page-2e8ed69b1a70c746.js +0 -1
  209. package/apps/pwa/out/_next/static/chunks/app/today/page-c6b096777f73c43a.js +0 -1
  210. package/apps/pwa/out/_next/static/chunks/app/workflows/chat-ui/page-c54c8b957ebf94e2.js +0 -1
  211. package/apps/pwa/out/_next/static/chunks/app/workflows/page-9dc19aee0932542a.js +0 -1
  212. package/apps/pwa/out/_next/static/chunks/app/worktrees/page-52b36e1c8acd087f.js +0 -1
  213. /package/apps/pwa/out/_next/static/{5URFQKPO21SIgTlLvb1Jv → K-ckEB9hu9tXQ6iqnl27L}/_buildManifest.js +0 -0
  214. /package/apps/pwa/out/_next/static/{5URFQKPO21SIgTlLvb1Jv → K-ckEB9hu9tXQ6iqnl27L}/_ssgManifest.js +0 -0
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6766],{13390:(e,t,r)=>{"use strict";r.d(t,{$5:()=>d,dJ:()=>u});var n=r(48082);let a=new Set,o=new Set;function s(e,t){if(t!==a.has(e))for(let r of(t?a.add(e):a.delete(e),o))r()}function l(){return a.size>0}function i(e){return o.add(e),()=>{o.delete(e)}}function d(){return(0,n.useSyncExternalStore)(i,l,()=>!1)}function u(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];(0,n.useEffect)(()=>(s(e,t),()=>s(e,!1)),[e,t])}},15249:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>s,f6:()=>a,oD:()=>o});let n="elanous.daemon.sessionId";function a(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"s-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function o(){let e=function(){let e=new URLSearchParams(window.location.search).get("session");return e?(localStorage.setItem(n,e),e):localStorage.getItem(n)}();if(e)return e;let t=a();return localStorage.setItem(n,t),t}function s(){let e=a();return localStorage.setItem(n,e),e}},29177:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>eI});var n=r(17594),a=r(48082),o=r(34585),s=r(74055),l=r(96545),i=r(2430),d=r(9114);r(12574);var u=r(453),c=r(46982),p=r(67307),m=r(43755);let f=[{graph:"workflow",label:"작업 노드",fallbackKinds:m.CF},{graph:"harness",label:"실행 단계 노드",fallbackKinds:m.DN}];var x=r(3138),g=r(81998);r(90456),r(87474);var h=r(92698),b=r(21078),v=r(48206);let y=/^[a-z0-9-]+$/,k=["recipes","overlay","overlays"],j=["ok","rework","fail"];function w(e){return"cmd:".concat(e)}let N="outcome";function S(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"my-graph";return{graphId:e,entry:null,terminals:[],nodes:[],edges:[]}}function C(e,t){var r,n,a,o;let s=null!=(r=t.id)?r:function(e,t){var r;let n=(null!=(r=t.split(":").pop())?r:"node").replace(/[^A-Za-z0-9_-]/g,"-")||"node",a=new Set(e.nodes.map(e=>e.id));for(let e=1;;e++)if(!a.has("".concat(n,"-").concat(e)))return"".concat(n,"-").concat(e)}(e,t.kind);if(e.nodes.some(e=>e.id===s))throw Error("이미 있는 노드 id 입니다: ".concat(s));let l=void 0!==t.x&&void 0!==t.y?{x:t.x,y:t.y}:function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"horizontal",r=e.nodes.length;return"vertical"===t?{x:40,y:40+130*r}:{x:40+r%5*240,y:40+180*Math.floor(r/5)}}(e,t.flow),i={id:s,kind:t.kind,recipe:null!=(n=t.recipe)?n:w(s),maxVisits:null!=(a=t.maxVisits)?a:1,...l};return{graph:{...e,entry:null!=(o=e.entry)?o:s,nodes:[...e.nodes,i]},id:s}}function I(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",a=n.trim();if(t===r)throw Error("같은 노드끼리는 연결할 수 없습니다");return e.edges.some(e=>e.from===t&&e.to===r&&e.outcome===a)?e:{...e,edges:[...e.edges,{from:t,to:r,outcome:a}]}}function E(e,t){var r;let n=e.edges.filter(e=>e.from===t);return n.some(e=>!e.outcome)?"":null!=(r=j.find(e=>!n.some(t=>t.outcome===e)))?r:""}function R(e,t){return{...e,edges:e.edges.filter((e,r)=>r!==t)}}function _(e,t,r){var n;let a=null==(n=r.id)?void 0:n.trim();if(void 0!==a&&a!==t){if(!a)throw Error("노드 id 는 비울 수 없습니다");if(e.nodes.some(e=>e.id===a))throw Error("이미 있는 노드 id 입니다: ".concat(a))}let o=e=>a&&e===t?a:e;return{...e,entry:null===e.entry?null:o(e.entry),terminals:e.terminals.map(o),nodes:e.nodes.map(e=>{var n;if(e.id!==t)return e;let o=null!=(n=r.recipe)?n:a&&e.recipe===w(t)?w(a):e.recipe;return{...e,...r,id:a||t,recipe:o}}),edges:e.edges.map(e=>({...e,from:o(e.from),to:o(e.to)}))}}function z(e,t,r){if(!e.nodes.some(e=>e.id===t))return e;let n=e.terminals.filter(e=>e!==t);return{...e,terminals:r?[...n,t]:n}}function A(e){let t=new Set(e.nodes.map(e=>e.id));return e.terminals.filter(e=>t.has(e))}function M(e){var t,r;let n=new u.yo({graph_id:e.graphId,version:"number"==typeof(null==(t=e.extra)?void 0:t.version)?e.extra.version:1,...e.entry?{entry_node:e.entry}:{},terminal_nodes:A(e)}).toString(),a=(0,m.lu)(n);for(let t of e.nodes)(0,m.bC)(a,{nodeId:t.id,kind:t.kind,recipe:t.recipe,maxVisits:t.maxVisits});let o=[],s=new Map,l=new Map,i=new Set;for(let[t,n]of(e.edges.forEach(e=>{var t,r;if(!e.outcome){let t="".concat(e.from,"\0").concat(e.to);if(i.has(t))return;i.add(t),o.push({...e.extra,from:e.from,to:e.to});return}let n="string"==typeof(null==(t=e.extra)?void 0:t.on)?e.extra.on:"outcome",a="".concat(e.from,":").concat(n),d=void 0===e.sourceMapIndex?null!=(r=l.get(a))?r:"new:".concat(a):"source:".concat(e.sourceMapIndex),u=s.get(d);u||(u={...e.extra,from:e.from,on:n,map:{}},s.set(d,u),l.has(a)||l.set(a,d),o.push(u)),u.map[e.outcome]=e.to}),a.set("edges",a.createNode(o)),Object.entries(null!=(r=e.extra)?r:{})))a.has(t)||a.set(t,a.createNode(n));let d=a.get("nodes");return e.nodes.forEach((e,t)=>{let r=(0,u.oP)(d)?d.items[t]:void 0;if((0,u.jh)(r)){var n;for(let[t,o]of Object.entries(null!=(n=e.extra)?n:{}))r.has(t)||r.set(t,a.createNode(o))}}),(0,m.ys)(a)}function D(e,t){var r,n;let a=[],o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return a.push({message:e,source:"local",...t})};y.test(e.graphId)||o("그래프 id 는 영문 소문자\xb7숫자\xb7- 만 쓸 수 있습니다"),k.includes(e.graphId)&&o("\xab".concat(e.graphId,"\xbb 는 예약된 그래프 id 입니다")),0===e.nodes.length&&o("노드가 하나도 없습니다");let s=new Map;for(let t of e.nodes)s.set(t.id,(null!=(r=s.get(t.id))?r:0)+1);for(let r of e.nodes)(!r.id.trim()||/\s/.test(r.id))&&o("노드 id 는 비우거나 공백을 넣을 수 없습니다",{nodeId:r.id}),(null!=(n=s.get(r.id))?n:0)>1&&o("노드 id \xab".concat(r.id,"\xbb 가 겹칩니다"),{nodeId:r.id}),t&&!t.includes(r.kind)&&o("팔레트에 없는 kind 입니다: ".concat(r.kind),{nodeId:r.id}),r.recipe.trim()||o("recipe 가 비었습니다",{nodeId:r.id}),(!Number.isInteger(r.maxVisits)||r.maxVisits<1)&&o("max_visits 는 1 이상의 정수여야 합니다",{nodeId:r.id});let l=new Set(e.nodes.map(e=>e.id));for(let t of(e.edges.forEach((e,t)=>{l.has(e.from)||o("간선 출발 \xab".concat(e.from,"\xbb 은 없는 노드입니다"),{edgeIndex:t}),l.has(e.to)||o("간선 도착 \xab".concat(e.to,"\xbb 은 없는 노드입니다"),{edgeIndex:t,...l.has(e.from)?{nodeId:e.from}:{}})}),l)){let r=e.edges.filter(e=>e.from===t),n=r.filter(e=>!e.outcome);n.length>1&&o("조건 없는 간선은 노드마다 하나만 둘 수 있습니다 — 결과 이름을 붙이세요",{nodeId:t}),n.length>0&&n.length<r.length&&o("조건 없는 간선과 결과 간선을 섞을 수 없습니다",{nodeId:t});let a=r.filter(e=>e.outcome).map(e=>e.outcome);new Set(a).size<a.length&&o("같은 결과 이름의 간선이 둘 이상입니다",{nodeId:t})}return e.nodes.length>0&&(e.entry&&l.has(e.entry)||o("시작 노드를 정하세요"),0===A(e).length&&o("끝 노드가 없습니다 — 노드를 골라 \xab끝 노드\xbb 로 표시하세요")),{ok:0===a.length,issues:a}}function O(e,t){let r={};try{var n;r=null!=(n=(0,u.parse)(e))?n:{}}catch(e){}return t.errors.map(e=>{var t,n,a,o,s,l;let i=/\/nodes\/(\d+)/.exec(null!=(s=e.path)?s:""),d=/\/edges\/(\d+)/.exec(null!=(l=e.path)?l:""),u=i?null==(n=r.nodes)||null==(t=n[Number(i[1])])?void 0:t.node_id:d?null==(o=r.edges)||null==(a=o[Number(d[1])])?void 0:a.from:void 0;return{message:e.message,source:"server",..."string"==typeof u?{nodeId:u}:{}}})}function V(e){var t,r;let n=(0,u.parse)(e);if(!n||"object"!=typeof n)throw Error("그래프 YAML 최상위가 맵이 아닙니다");let a=(Array.isArray(n.nodes)?n.nodes:[]).flatMap(e=>e&&"string"==typeof e.node_id?[{id:e.node_id,kind:"string"==typeof e.kind?e.kind:"",recipe:"string"==typeof e.recipe?e.recipe:"",maxVisits:"number"==typeof e.max_visits?e.max_visits:1,x:0,y:0,...L(e,["node_id","kind","recipe","max_visits"])}]:[]),o=(Array.isArray(n.edges)?n.edges:[]).flatMap((e,t)=>e&&"string"==typeof e.from?"string"==typeof e.to?[{from:e.from,to:e.to,outcome:"",...L(e,["from","to"])}]:e.map&&"object"==typeof e.map?Object.entries(e.map).filter(e=>"string"==typeof e[1]).map(r=>{let[n,a]=r;return{from:e.from,to:a,outcome:n,sourceMapIndex:t,...L(e,["from","map",...e.on===N?["on"]:[]])}}):[]:[]),s="string"==typeof n.entry_node?n.entry_node:null!=(r=null==(t=a[0])?void 0:t.id)?r:null;T(a,o,s,"horizontal");let l=new Set(a.map(e=>e.id)),i=(Array.isArray(n.terminal_nodes)?n.terminal_nodes:[]).filter(e=>"string"==typeof e&&l.has(e));return{graphId:"string"==typeof n.graph_id?n.graph_id:"my-graph",entry:s,terminals:i,nodes:a,edges:o,...L(n,["graph_id","entry_node","terminal_nodes","nodes","edges"])}}let P={width:180,height:72};function G(e){return"fail"===e?"실패 시":e}function T(e,t,r,n,a){let o=(0,b.Fq)(e.map(e=>({id:e.id,...P})),t,{entry:r,flow:n,rename:G,...void 0!==a?{lineLength:a}:{}});for(let t of e){let e=o.get(t.id);e&&(t.x=e.x,t.y=e.y)}}function F(e,t,r){let n=e.nodes.map(e=>({...e}));return T(n,e.edges,e.entry,t,r),{...e,nodes:n}}function L(e,t){let r=Object.fromEntries(Object.entries(e).filter(e=>{let[r]=e;return!t.includes(r)}));return Object.keys(r).length>0?{extra:r}:{}}function B(e){var t;let r=[],n=new Map;for(let t of e.edges){if(!t.outcome){r.push({from:t.from,to:t.to});continue}let e=n.get(t.from);if(e)e[t.outcome]=t.to;else{let e={[t.outcome]:t.to};n.set(t.from,e),r.push({from:t.from,on:N,map:e})}}return{id:e.graphId||"canvas",source:"mine",editable:!0,entry_node:null!=(t=e.entry)?t:"",terminal_nodes:e.terminals,nodes:e.nodes.map(e=>{let t=K(e);return{node_id:e.id,kind:e.kind,recipe:e.recipe,max_visits:e.maxVisits,...null!==t?{group:t}:{}}}),edges:r}}function K(e){var t;return("string"==typeof(null==(t=e.extra)?void 0:t.group)?e.extra.group.trim():"")||null}async function U(e,t,r,n){let a=await e.putRunGraphAccess(t,r,n),o=await e.getRunGraphAccess(t);if(!o.grants.some(e=>e.recipient===a.recipient&&e.permission===n))throw Error("권한 적용을 확인할 수 없습니다");return o}function Y(e){return{ok:!1,issues:[{source:"server",message:e}]}}async function Z(e,t,r,n,a){try{let o=a&&Object.keys(a).length?a:void 0,s="create"===n?await e.createRunGraph(t,r,o):await e.putRunGraphYaml(t,r,o);return{ok:!0,id:t,created:"create"===n,..."number"==typeof s.version?{version:s.version}:{}}}catch(a){var o,s;if(!(a instanceof p.Iu))return Y("저장 실패: ".concat(a instanceof Error?a.message:String(a)));let e=null!=(o=a.body)?o:{};if(Array.isArray(e.errors)&&e.errors.length>0)return{ok:!1,issues:O(r,{errors:e.errors})};if("create"===n&&(404===a.status||405===a.status))return Y("새 그래프 저장(POST /v1/graphs)을 이 Daemon 이 아직 지원하지 않습니다 — 서버 업데이트 후 다시 저장하세요");if(409===a.status)return Y("\xab".concat(t,"\xbb 는 이미 있는 그래프 id 입니다 — 다른 id 를 쓰세요"));if("reserved-id"===e.error)return Y("\xab".concat(t,"\xbb 는 예약된 id 라 쓸 수 없습니다 — 다른 id 를 쓰세요"));if("graph-id-mismatch"===e.error)return Y("YAML 의 graph_id 가 저장할 id 와 다릅니다");if(403===a.status)return Y("\xab".concat(t,"\xbb 는 기본 제공 그래프라 덮어쓸 수 없습니다 — 다른 id 를 쓰세요"));if("update"===n&&404===a.status)return Y("\xab".concat(t,"\xbb 가 서버에 없습니다 — 새 그래프로 저장하세요"));return Y(null!=(s=e.reason)?s:e.error?"저장 실패: ".concat(e.error," (").concat(a.status,")"):"저장 실패 (".concat(a.status,")"))}}var q=r(4879),W=r(85679);let Q="application/x-elanous-graph-kind",J={agent:"#3b82f6",gate:"#f59e0b",git:"#10b981",judge:"#a855f7",observe:"#06b6d4",hitl:"#f43f5e",subgraph:"#8b5cf6"},X={running:{word:"● 도는 중",ring:"#3b82f6",chip:"bg-blue-500/15 text-blue-400"},done:{word:"✓ 끝",ring:"#10b981",chip:"bg-emerald-500/15 text-emerald-400"},failed:{word:"✗ 실패",ring:"#ef4444",chip:"bg-red-500/15 text-red-400"},skipped:{word:"– 건너뜀",ring:"#6b7280",chip:"bg-muted text-muted-foreground"},awaiting_approval:{word:"⏸ 승인 대기",ring:"#f59e0b",chip:"bg-amber-500/15 text-amber-400"}},H={pending:{word:"대기",tint:"var(--border, #94a3b8)"},running:{word:"도는 중",tint:"#f59e0b"},passed:{word:"통과",tint:"var(--chart-2, #16a34a)"},failed:{word:"실패",tint:"var(--destructive, #ef4444)"}},$={running:"running",done:"passed",failed:"failed",skipped:"pending",awaiting_approval:"running"},ee={canvas:function(e){var t;let{data:r,selected:a}=e,o="vertical"===r.flow,s=r.runStatus?X[r.runStatus]:void 0,l=r.unit?H[r.unit.state]:void 0;return(0,n.jsxs)("div",{"data-testid":"canvas-node-".concat(r.id),"data-run-status":r.runStatus,role:r.unit?"button":void 0,tabIndex:r.unit?0:void 0,onClick:e=>{if(r.unit){var t;e.stopPropagation(),null==(t=r.openUnit)||t.call(r,r.unit.name)}},onKeyDown:e=>{if(r.unit&&("Enter"===e.key||" "===e.key)){var t;e.preventDefault(),null==(t=r.openUnit)||t.call(r,r.unit.name)}},className:"rounded-lg border bg-background px-3 py-2 shadow-sm ".concat(r.issueCount?"border-red-500":a?"border-primary":"border-border"," ").concat(r.unit?"cursor-pointer nodrag nopan":""),style:{width:P.width,borderLeft:"4px solid ".concat(l?l.tint:null!=(t=J[r.kind])?t:"#64748b"),...s?{boxShadow:"0 0 0 2px ".concat(s.ring)}:{}},children:[(0,n.jsx)(i.h7,{id:"in",type:"target",position:o?d.yX.Top:d.yX.Left,className:"!h-3 !w-3"}),(0,n.jsxs)("div",{className:"flex items-center gap-1 text-[10px] text-muted-foreground",children:[(0,n.jsx)("span",{children:r.unit?"묶음 \xb7 눌러서 펼치기":r.kind}),r.entry&&(0,n.jsx)("span",{className:"rounded bg-emerald-500/15 px-1 text-emerald-500",children:"시작"}),r.terminal&&(0,n.jsx)("span",{className:"rounded bg-sky-500/15 px-1 text-sky-500",children:"끝"}),r.issueCount>0&&(0,n.jsxs)("span",{className:"rounded bg-red-500/15 px-1 text-red-500",children:["오류 ",r.issueCount]}),l&&(0,n.jsx)("span",{className:"rounded px-1 font-semibold",style:{color:l.tint},children:l.word}),s&&(0,n.jsx)("span",{className:"rounded px-1 font-semibold ".concat(s.chip),children:s.word})]}),r.unit?(0,n.jsxs)(n.Fragment,{children:["subgraph"===r.kind&&(0,v.Fi)(r.id)&&(0,n.jsx)("span",{className:"text-[10px] text-violet-400",children:"묶음 \xb7 눌러서 안쪽 그래프 열기"}),(0,n.jsxs)("div",{className:"max-w-[150px] truncate text-sm font-semibold text-foreground",title:r.unit.name,children:["▣ ",r.unit.name]})]}):r.label?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"max-w-[150px] truncate text-sm font-semibold text-foreground",title:r.label,children:r.label}),(0,n.jsx)("div",{className:"font-mono text-[10px] text-muted-foreground",children:r.id})]}):(0,n.jsx)("div",{className:"font-mono text-sm font-semibold text-foreground",children:r.id}),(0,n.jsx)("div",{className:"max-w-[150px] truncate text-[10px] text-muted-foreground",title:r.recipe,children:r.recipe}),(0,n.jsx)(i.h7,{id:"out",type:"source",position:o?d.yX.Bottom:d.yX.Right,className:"!h-3 !w-3"})]})},...W.r},et={"--xy-controls-button-background-color":"var(--card)","--xy-controls-button-background-color-hover":"var(--muted)","--xy-controls-button-color":"var(--foreground)","--xy-controls-button-color-hover":"var(--foreground)","--xy-controls-button-border-color":"var(--border)","--xy-controls-box-shadow":"0 0 0 1px var(--border)"};function er(e){var t,r,o;let{palette:s,client:l,initialGraph:d,initialSaved:u,nodeStatus:c,renderActions:p,onChange:m,onSaved:f,replace:x,highlight:g,wizardMode:y=!1,nodeLabels:k,wizardSteps:w,installedPacks:N,onKnowledgePackChange:_}=e,[z,T]=(0,a.useState)(()=>null!=d?d:S("")),[L,U]=(0,a.useState)({}),[Y,W]=(0,a.useState)(()=>u?JSON.stringify(null!=w?w:{}):null),[X,H]=(0,a.useState)(void 0),er=(null!=w?w:X)&&Object.fromEntries(Object.entries(null!=(t=null!=w?w:X)?t:{}).map(e=>{let[t,r]=e;return[t,void 0!==L[t]&&"knowledge-rag"===r.step?{...r,arg:L[t]}:r]})),[ea,eo]=(0,a.useState)(null),[es,el]=(0,a.useState)(null),[ei,ed]=(0,a.useState)(null),[eu,ec]=(0,a.useState)(null),[ep,em]=(0,a.useState)(null),[ef,ex]=(0,a.useState)(()=>u&&d?{id:d.graphId,yaml:M(d)}:null),[eg,eh]=(0,a.useState)(null),[eb,ev]=(0,a.useState)([]),[ey,ek]=(0,a.useState)(""),[ej,ew]=(0,a.useState)(null),eN=(0,a.useRef)(null),eS=(0,a.useRef)(null),[eC,eI]=(0,a.useState)("horizontal"),[eE,eR]=(0,a.useState)(void 0),e_=(0,a.useRef)(.85);e_.current=y?.6:.85,(0,a.useEffect)(()=>{let e=eS.current;if(!e||"undefined"==typeof ResizeObserver)return;let t=new ResizeObserver(e=>{var t;let[r]=e,n=null!=(t=null==r?void 0:r.contentRect.width)?t:1e3;eI(n<640?"vertical":"horizontal"),eR(n<640?void 0:100*Math.floor(n/e_.current/100))});return t.observe(e),()=>t.disconnect()},[]);let ez=(0,a.useRef)(!1),eA=(0,a.useRef)({flow:eC,lineLength:eE});eA.current={flow:eC,lineLength:eE};let eM=(0,a.useCallback)(e=>ez.current||e.nodes.length<2?e:F(e,eA.current.flow,eA.current.lineLength),[]),eD=(0,a.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;setTimeout(()=>{let t=eN.current,r=eS.current;t&&Promise.resolve(t.fitView({padding:.12,maxZoom:1.1,minZoom:e_.current,...e?{duration:e}:{}})).then(()=>{let e=t.getNodes();if(!r||0===e.length)return;let n=t.getNodesBounds(e),{zoom:a,x:o,y:s}=t.getViewport(),l=r.getBoundingClientRect(),i=n.width*a+48>l.width,d=n.height*a+48>l.height;(i||d)&&t.setViewport({zoom:a,x:i?24-n.x*a:o,y:d?24-n.y*a:s})})},80)},[]),eO=(0,a.useRef)("horizontal:undefined");(0,a.useEffect)(()=>{let e="".concat(eC,":").concat(eE);e===eO.current||ez.current||(eO.current=e,T(e=>eM(e)),eD())},[eC,eE,eM,eD]);let[eV,eP]=(0,a.useState)({}),[eG,eT]=(0,a.useState)(()=>new Set),[eF,eL]=(0,a.useState)(null),[eB,eK]=(0,a.useState)(!1),eU=(0,a.useMemo)(()=>(0,v.S0)(B(z)),[z]),eY=(0,a.useMemo)(()=>(0,v.F8)(B(z)),[z]),eZ=(0,a.useMemo)(()=>{let e=new Map;for(let r of z.nodes){var t;let n=eY.get(r.id);n&&e.set(n,[...null!=(t=e.get(n))?t:[],r.id])}return e},[z,eY]);(0,a.useEffect)(()=>{eT(e=>{let t=new Set([...e].filter(e=>eU.includes(e)));return t.size===e.size?e:t})},[eU]);let eq=(eG.size>0||null!==eF)&&eU.length>0,eW=(0,a.useMemo)(()=>{var e;return null!==eF&&eB?function(e,t){var r,n,a,o;let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,l={id:e.graphId,source:"mine",editable:!0,entry_node:null!=(o=e.entry)?o:"",terminal_nodes:e.terminals,nodes:e.nodes.map(e=>{var t;return{node_id:e.id,kind:e.kind,recipe:e.recipe,max_visits:e.maxVisits,..."string"==typeof(null==(t=e.extra)?void 0:t.group)?{group:e.extra.group}:{}}}),edges:e.edges.map(e=>e.outcome?{from:e.from,on:"outcome",map:{[e.outcome]:e.to}}:{from:e.from,to:e.to})},i=(0,v.S0)(l);if(0===i.length||!s&&!i.some(e=>t.has(e)))return e;let d=(0,v.F8)(l),u=s&&i.includes(s)?{...l,nodes:l.nodes.filter(e=>d.get(e.node_id)===s),edges:l.edges.flatMap(e=>{var t;if(d.get(e.from)!==s)return[];if(e.to)return d.get(e.to)===s?[e]:[];let r=Object.fromEntries(Object.entries(null!=(t=e.map)?t:{}).filter(e=>{let[,t]=e;return d.get(t)===s}));return Object.keys(r).length?[{from:e.from,on:e.on,map:r}]:[]})}:(0,v.ws)(l,t).graph,c=new Map(e.nodes.map(e=>[e.id,e])),p=u.nodes.map(t=>{let r=c.get(t.node_id);if(r)return r;let n=e.nodes.find(e=>d.get(e.id)===t.group);return{id:t.node_id,kind:t.kind,recipe:t.recipe,maxVisits:t.max_visits,x:n.x,y:n.y}}),m=u.edges.flatMap(e=>{var t;return e.to?[{from:e.from,to:e.to,outcome:""}]:Object.entries(null!=(t=e.map)?t:{}).map(t=>{let[r,n]=t;return{from:e.from,to:n,outcome:r}})}),f=new Set(p.map(e=>e.id)),x=s?e=>e:(0,v.ws)(l,t).resolve,g=x(null!=(n=e.entry)?n:""),h=f.has(g)?g:null!=(a=null==(r=p[0])?void 0:r.id)?a:null;return{...e,nodes:p,edges:m,entry:h,terminals:[...new Set(e.terminals.map(x))].filter(e=>f.has(e))}}(z,eG,eF):eq?F(0===(e=null!==eF?new Set([...eG].filter(e=>e!==eF)):eG).size?z:function(e,t){let r=new Map;for(let e of t.nodes){var n;let t=K(e);null!==t&&r.set(t,[...null!=(n=r.get(t))?n:[],e])}let a=new Map(t.nodes.map(e=>[e.id,e])),o=e.nodes.map(e=>{var t,n,o,s,l;let i=(0,v.Fi)(e.node_id)&&null!=(o=r.get(e.node_id.slice(v.EQ.length)))?o:[],d=i.length>0?i.reduce((e,t)=>e+t.x,0)/i.length:null!=(s=null==(t=a.get(e.node_id))?void 0:t.x)?s:0,u=i.length>0?i.reduce((e,t)=>e+t.y,0)/i.length:null!=(l=null==(n=a.get(e.node_id))?void 0:n.y)?l:0;return{id:e.node_id,kind:e.kind,recipe:e.recipe,maxVisits:e.max_visits,x:d,y:u}}),s=e.edges.flatMap(e=>{var t;return"map"in e&&e.map?Object.entries(e.map).map(t=>{let[r,n]=t;return{from:e.from,to:n,outcome:r}}):[{from:e.from,to:null!=(t=e.to)?t:"",outcome:""}]});return{graphId:t.graphId,entry:e.entry_node||null,terminals:e.terminal_nodes,nodes:o,edges:s}}((0,v.ws)(B(z),e).graph,z),eC,eE):z},[z,eG,eF,eB,eq,eC,eE]),eQ=(0,a.useCallback)(e=>{eT(t=>new Set([...t,e])),eL(t=>t===e?null:t),eK(!0)},[]),eJ=(0,a.useCallback)(e=>{eL(e),setTimeout(()=>{let t=eN.current,r=null==t?void 0:t.getNodes().find(t=>{var r;return"groupBox"===t.type&&(null==(r=t.data)?void 0:r.group)===e});t&&r&&t.fitView({nodes:[{id:r.id}],duration:600,maxZoom:1.4,padding:.2})},80)},[]),eX=(0,a.useCallback)(()=>{eT(e=>e.size===eU.length?new Set:new Set(eU)),eL(null),eK(!1)},[eU]),eH=(0,a.useCallback)(e=>(0,v.Oc)(e.map(e=>{let t=null==c?void 0:c[e];return void 0!==t?$[t]:"pending"})),[c]);(0,a.useEffect)(()=>{null===eF&&eD(300)},[eG,eF,eD]);let e$=(0,a.useRef)(null);(0,a.useEffect)(()=>{var e,t;x&&e$.current!==x.rev&&(e$.current=x.rev,T(eM(x.graph)),U({}),H(void 0),eo(null),ec(null),ed(null),"vertical"===eC&&(null==(t=eS.current)||null==(e=t.scrollIntoView)||e.call(t,{block:"start",behavior:"smooth"})),eD(300))},[x]);let e0=(0,a.useMemo)(()=>{var e;return new Set(null!=(e=null==g?void 0:g.nodes)?e:[])},[g]),e1=(0,a.useMemo)(()=>{var e;return new Set(null!=(e=null==g?void 0:g.edges)?e:[])},[g]),e5=(0,a.useMemo)(()=>s.map(e=>e.kind),[s]),e2=(0,a.useMemo)(()=>M(z),[z]),e4=(0,a.useMemo)(()=>D(z,e5),[z,e5]),e3=(null==eu?void 0:eu.yaml)===e2?eu:null,e6=(null==e3?void 0:e3.server)?e3.issues:[],e8=[...e4.issues,...e6],e9={graphId:z.graphId,yaml:e2,graph:z,valid:e4.ok&&0===e6.length,saved:(null==ef?void 0:ef.id)===z.graphId&&ef.yaml===e2&&(null===Y||Y===JSON.stringify(null!=er?er:{}))},e7=(0,a.useRef)(e9);e7.current=e9,(0,a.useEffect)(()=>{null==m||m(e7.current)},[m,z,e2,e9.valid,e9.saved]),(0,a.useEffect)(()=>{if(!l)return;let e=!0;return l.getRunGraphs().then(t=>{e&&ev(t.graphs)}).catch(()=>{}),()=>{e=!1}},[l,ef]);let te=(0,a.useCallback)(e=>{eq||T(t=>{try{let r=e(t);return ed(null),r}catch(e){return ed(e instanceof Error?e.message:String(e)),t}})},[eq]),tt=(0,a.useCallback)(()=>eD(200),[eD]);function tr(e,t){if(eq)return;let r=null;te(n=>{let a=C(n,{kind:e,flow:eC,...null!=t?t:{}});return r=a.id,a.graph}),r&&eo({type:"node",id:r}),t||tt()}let tn=(0,a.useMemo)(()=>{var e;let t=new Map;for(let r of e8)r.nodeId&&t.set(r.nodeId,(null!=(e=t.get(r.nodeId))?e:0)+1);return t},[e8]),ta=(0,a.useMemo)(()=>new Set(A(eW)),[eW]),to=(0,a.useMemo)(()=>(0,b.gL)(eW.nodes.map(e=>{var t;return{id:e.id,x:e.x,y:e.y,...null!=(t=eV[e.id])?t:P}}),(0,b.IU)(eW.edges),{flow:eC,rename:G}),[eW.nodes,eW.edges,eV,eC]),ts=(0,b.d1)(eW.nodes.some(e=>e.id===es)?es:null,to),tl=eW.nodes.map(e=>{var t,r;return{id:e.id,type:"canvas",position:{x:e.x,y:e.y},selected:(null==ea?void 0:ea.type)==="node"&&ea.id===e.id,draggable:z.nodes.some(t=>t.id===e.id),zIndex:1,className:[c?(0,h.V)(c[e.id]):"",e0.has(e.id)?"graph-wizard-new":""].filter(Boolean).join(" ")||void 0,...ts&&!ts.nodes.has(e.id)?{style:{opacity:b.zZ.dimNode}}:{},data:{id:e.id,kind:e.kind,recipe:e.recipe,...(null==k?void 0:k[e.id])?{label:k[e.id]}:{},entry:eW.entry===e.id,terminal:ta.has(e.id),issueCount:null!=(t=tn.get(e.id))?t:0,flow:eC,...(0,v.Fi)(e.id)?{unit:{name:e.id.slice(v.EQ.length),state:eH(null!=(r=eZ.get(e.id.slice(v.EQ.length)))?r:[])},openUnit:eJ}:{},...(null==c?void 0:c[e.id])?{runStatus:c[e.id]}:{}}}}),ti=to.map(e=>{let t=e.indexes.some(e=>{let t=eW.edges[e];return void 0!==t&&e1.has("".concat(t.from,"->").concat(t.to,":").concat(t.outcome))}),r=(0,b.f_)(ts,e.id);return{id:e.id,source:e.from,target:e.to,sourceHandle:"out",targetHandle:"in",type:"tidy",data:{route:e},selected:(null==ea?void 0:ea.type)==="edge"&&e.indexes.some(e=>{let t=eW.edges[e],r=z.edges[ea.index];return!!(t&&r&&t.from===r.from&&t.to===r.to&&t.outcome===r.outcome)}),className:(null==ts?void 0:ts.edges.has(e.id))?"wiring-edge-flow":void 0,animated:r.animated||t||(null==c?void 0:c[e.from])==="done"&&(null==c?void 0:c[e.to])==="running",...ts?{style:r.style}:t?{style:{stroke:"#a855f7",strokeWidth:3}}:{}}}),td=(0,a.useMemo)(()=>(0,v.Vc)(eW.nodes.map(e=>{var t;return{id:e.id,position:{x:e.x,y:e.y},...null!=(t=eV[e.id])?t:P}}),eY),[eW,eV,eY]),tu=[...eB&&null!==eF?[]:td.map(e=>({id:e.id,type:"groupBox",position:{x:e.x,y:e.y},zIndex:0,selectable:!1,draggable:!1,focusable:!1,data:{group:e.group,state:eH(e.members),memberCount:e.members.length,stepCount:e.members.length,width:e.width,height:e.height,onCollapse:eQ}})),...tl];async function tc(){if(eh(null),!e4.ok||!l)return void ec({yaml:e2,issues:e4.issues,server:!1});em("validate");try{let e=await l.validateGraph("harness",e2);ec({yaml:e2,issues:e.ok&&0===e.errors.length?[]:O(e2,e),server:!0})}catch(e){ec({yaml:e2,issues:[{source:"server",message:"검증 요청 실패: ".concat(e instanceof Error?e.message:String(e))}],server:!0})}finally{em(null)}}async function tp(){if(!l||!e4.ok)return void tc();em("save"),eh(null);let e=z.graphId;try{let t=await Z(l,e,e2,(null==ef?void 0:ef.id)===e?"update":"create",er);t.ok?(ex({id:e,yaml:e2,...void 0!==t.version?{version:t.version}:{}}),W(JSON.stringify(null!=er?er:{})),eh("\xab".concat(e,"\xbb 를 ").concat(t.created?"새로 ":"","저장했습니다").concat(void 0!==t.version?" (v".concat(t.version,")"):"")),null==f||f(e)):ec({yaml:e2,issues:t.issues,server:!0,from:"save"})}finally{em(null)}}async function tm(e){if(l&&e){em("load");try{var t;let r=await l.getRunGraphYaml(e),n=V(r.yaml);ez.current=!1,T(eM(n)),U({}),H(r.steps),W(JSON.stringify(null!=(t=r.steps)?t:{})),eo(null),ec(null),ex("mine"===r.source?{id:r.id,yaml:M(n)}:null),eh("mine"===r.source?"\xab".concat(e,"\xbb 를 불러왔습니다"):"\xab".concat(e,"\xbb 는 기본 제공 그래프입니다 — id 를 바꿔 내 그래프로 저장하세요")),tt()}catch(e){ed("불러오기 실패: ".concat(e instanceof Error?e.message:String(e)))}finally{em(null)}}}let tf=(null==ea?void 0:ea.type)==="node"&&null!=(r=z.nodes.find(e=>e.id===ea.id))?r:null,tx=(null==ea?void 0:ea.type)==="edge"&&null!=(o=z.edges[ea.index])?o:null,tg=e8.filter(e=>!e.nodeId),th="validate"===ep?null:e3,tb=(0,a.useRef)(null);return(0,a.useEffect)(()=>{var e;z.graphId||null==(e=tb.current)||e.focus()},[z.graphId]),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col","data-graph-id":z.graphId,"aria-label":"그래프 만들기",children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-xs",children:[(0,n.jsxs)("label",{className:"flex items-center gap-1 text-muted-foreground",children:["그래프 id",(0,n.jsx)("input",{ref:tb,"aria-label":"그래프 id",value:z.graphId,disabled:eq,spellCheck:!1,placeholder:"예: my-graph",autoCapitalize:"off",autoCorrect:"off",onChange:e=>te(t=>{var r;return r=e.target.value,{...t,graphId:r.trim()}}),className:"w-36 rounded border border-border bg-background px-2 py-1 font-mono text-foreground"})]}),(0,n.jsx)("button",{type:"button",onClick:()=>{T(S("")),H(void 0),U({}),W(null),eo(null),ec(null),ex(null),eh(null),ed(null)},className:"rounded border border-border px-2 py-1",children:"새 그래프"}),l&&(0,n.jsxs)("select",{"aria-label":"그래프 불러오기",value:"",disabled:null!==ep,onChange:e=>{tm(e.target.value)},className:"max-w-[10rem] rounded border border-border bg-background px-1 py-1",children:[(0,n.jsx)("option",{value:"",children:"불러오기…"}),eb.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.id,"mine"===e.source?" \xb7 내 그래프":""]},e.id))]}),(0,n.jsx)("span",{className:"text-muted-foreground",children:e9.saved?"저장됨".concat((null==ef?void 0:ef.version)!==void 0?" \xb7 v".concat(ef.version):""):(null==ef?void 0:ef.id)===z.graphId?"저장 안 된 변경":"아직 저장 안 함"}),(0,n.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[eU.length>0&&(0,n.jsx)("button",{type:"button","data-testid":"toggle-units",onClick:eX,title:"모든 묶음을 한 그래프에 펼치거나(통합 보기), 묶음마다 노드 하나로 절습니다(접은 보기)",className:"rounded border border-border px-2 py-1",children:eG.size===eU.length?"묶음 펼치기 (통합 보기)":"묶음 접기"}),(0,n.jsx)("button",{type:"button",onClick:()=>{tc()},disabled:null!==ep,title:l?"저장하지 않고 서버의 그래프 로더로 검증합니다":"Daemon 연결이 없어 로컬 검사만 합니다",className:"rounded border border-border px-3 py-1 disabled:opacity-50",children:"validate"===ep?"검증 중…":"검증"}),(0,n.jsx)("button",{type:"button",onClick:()=>{tp()},disabled:!l||null!==ep||e9.saved,className:"rounded bg-primary px-3 py-1 text-primary-foreground disabled:opacity-50",children:"save"===ep?"저장 중…":"저장"}),null==p?void 0:p(e9)]})]}),th&&(0===th.issues.length?(0,n.jsxs)("p",{role:"status","data-testid":"graph-check-line",className:"border-b border-emerald-500/40 bg-emerald-500/10 px-3 py-1.5 text-sm font-medium text-emerald-500",children:["✓ 검증 통과",th.server?"":" (로컬 검사 — Daemon 연결 없음)"]}):(0,n.jsxs)("div",{role:"alert","data-testid":"graph-check-line",className:"border-b border-red-500/40 bg-red-500/10 px-3 py-1.5 text-sm text-red-500",children:[(0,n.jsxs)("p",{className:"font-medium",children:["✗ ","save"===th.from?"저장 실패":"검증 실패"," ",th.issues.length,"건"]}),(0,n.jsx)("ul",{className:"mt-0.5 list-disc pl-5 text-xs",children:th.issues.map((e,t)=>(0,n.jsxs)("li",{children:[e.nodeId?(0,n.jsxs)("span",{className:"font-mono",children:[e.nodeId,": "]}):null,e.message]},t))})]})),(ei||eg)&&(0,n.jsx)("p",{role:ei?"alert":"status",className:"border-b border-border px-3 py-1 text-xs ".concat(ei?"text-red-500":"text-emerald-500"),children:null!=ei?ei:eg}),eU.length>0&&(0,n.jsxs)("div",{"data-testid":"unit-view-bar",className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-1.5 text-xs",children:[null!==eF?(0,n.jsxs)("nav",{"aria-label":"묶음 위치","data-testid":"unit-breadcrumb",className:"flex items-center gap-1",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{eT(new Set(eU)),eL(null)},title:"모든 묶음을 접어 돌아갑니다",className:"font-mono text-muted-foreground hover:underline",children:z.graphId||"그래프"}),(0,n.jsx)("span",{"aria-hidden":!0,className:"text-muted-foreground",children:"›"}),(0,n.jsxs)("span",{className:"font-mono font-semibold text-foreground",children:["▣ ",eF]})]}):(0,n.jsx)("span",{className:"text-muted-foreground",children:eq?"접은 보기 — 묶음을 눌러 안쪽 그래프를 여세요 (편집은 통합 보기에서)":"통합 보기 — 모든 묶음이 한 그래프에 펼쳐 있습니다"}),(0,n.jsxs)("span",{className:"ml-auto text-muted-foreground",children:["묶음 ",eU.length," \xb7 접힘 ",eG.size]})]}),(0,n.jsx)("datalist",{id:"graph-canvas-outcomes",children:j.map(e=>(0,n.jsx)("option",{value:e},e))}),eU.length>0&&(0,n.jsxs)("nav",{"aria-label":"유닛 보기",className:"sr-only",children:[(0,n.jsx)("button",{type:"button","aria-label":"부모 그래프",onClick:()=>{eL(null),eo(null),tt()},children:z.graphId||"부모"}),eF&&(0,n.jsxs)("span",{children:["› ",(0,n.jsx)("span",{children:eF})]}),(0,n.jsx)("button",{type:"button","data-testid":"editor-toggle-units",onClick:eX,children:eG.size===eU.length?"묶음 펼치기 (통합 보기)":"묶음 접기"})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col ".concat(y?"":"min-[900px]:flex-row"),children:[(0,n.jsxs)("aside",{"aria-label":"노드 팔레트",className:y?"flex shrink-0 items-center gap-2 border-b border-border px-2 py-1.5":"shrink-0 border-b border-border p-2 min-[900px]:w-44 min-[900px]:overflow-y-auto min-[900px]:border-b-0 min-[900px]:border-r",children:[(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground ".concat(y?"shrink-0":"mb-1"),children:y?"눌러서 추가":(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{className:"min-[900px]:hidden",children:"눌러서 추가"}),(0,n.jsx)("span",{className:"hidden min-[900px]:inline",children:"끌어 놓거나 눌러서 추가"})]})}),(0,n.jsx)("ul",{className:y?"flex min-w-0 gap-1 overflow-x-auto":"flex gap-1 overflow-x-auto min-[900px]:flex-col min-[900px]:overflow-visible",children:s.map(e=>{var t,r;return(0,n.jsx)("li",{className:"shrink-0",children:(0,n.jsxs)("button",{type:"button",draggable:!eq,disabled:eq,title:e.description||e.kind,"aria-label":"".concat(e.kind," 노드 추가"),onDragStart:t=>{t.dataTransfer.setData(Q,e.kind),t.dataTransfer.effectAllowed="copy"},onClick:()=>tr(e.kind),className:"flex w-full items-center gap-1 rounded border border-border bg-background px-2 py-1.5 text-left text-xs hover:bg-muted",style:{borderLeft:"4px solid ".concat(null!=(t=J[e.kind])?t:"#64748b")},children:[(0,n.jsx)("span",{"aria-hidden":!0,children:"+"}),e.kind,e.plugin&&(0,n.jsx)("small",{className:"rounded bg-accent/15 px-1 text-accent",children:e.plugin})]})},"".concat(null!=(r=e.plugin)?r:"core",":").concat(e.kind))})})]}),(0,n.jsxs)("div",{className:y?"flex min-h-0 flex-1 flex-col min-[900px]:flex-row":"contents",children:[(0,n.jsxs)("section",{ref:eS,"aria-label":"그래프 캔버스",className:"relative h-[56vh] min-h-[300px] shrink-0 bg-background min-[900px]:h-auto min-[900px]:min-w-0 min-[900px]:flex-1",onDragOver:e=>{Array.from(e.dataTransfer.types).includes(Q)&&(e.preventDefault(),e.dataTransfer.dropEffect="copy")},onDrop:e=>{var t,r;let n=e.dataTransfer.getData(Q);if(eq||!n||!e5.includes(n))return;e.preventDefault();let a=null!=(r=null==(t=eN.current)?void 0:t.screenToFlowPosition({x:e.clientX,y:e.clientY}))?r:{x:40,y:40};tr(n,{x:a.x-85,y:a.y-30})},children:[0===z.nodes.length&&(0,n.jsx)("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6 text-center text-sm text-muted-foreground",children:"빈 캔버스입니다. 팔레트에서 노드를 끌어 놓거나 눌러서 추가하세요."}),(0,n.jsxs)(i.Gc,{nodes:tu,edges:ti,nodeTypes:ee,edgeTypes:q.T,onInit:e=>{eN.current=e},nodesDraggable:!eq,nodesConnectable:!eq,onNodesChange:function(e){for(let t of e){if("dimensions"===t.type&&t.dimensions){let{id:e,dimensions:r}=t;eP(t=>{var n,a;return(null==(n=t[e])?void 0:n.width)===r.width&&(null==(a=t[e])?void 0:a.height)===r.height?t:{...t,[e]:r}})}if("position"===t.type&&t.position&&z.nodes.some(e=>e.id===t.id)){let{id:e,position:r}=t;t.dragging&&(ez.current=!0),eq||te(t=>(function(e,t,r,n){return{...e,nodes:e.nodes.map(e=>e.id===t?{...e,x:r,y:n}:e)}})(t,e,r.x,r.y))}}},onConnect:e=>{!eq&&e.source&&e.target&&z.nodes.some(t=>t.id===e.source)&&z.nodes.some(t=>t.id===e.target)&&te(t=>I(t,e.source,e.target,E(t,e.source)))},onNodeMouseEnter:(e,t)=>el(t.id),onNodeMouseLeave:()=>el(null),onNodeClick:(e,t)=>{if("groupBox"!==t.type){if((0,v.Fi)(t.id)&&!z.nodes.some(e=>e.id===t.id))return void eJ(t.id.slice(v.EQ.length));eq||eo({type:"node",id:t.id})}},onEdgeClick:(e,t)=>{if(eq)return;let r=eW.edges[Number(t.id.slice(1))],n=r?z.edges.findIndex(e=>e.from===r.from&&e.to===r.to&&e.outcome===r.outcome):-1;n>=0&&eo({type:"edge",index:n})},onPaneClick:()=>eo(null),deleteKeyCode:null,fitView:!0,fitViewOptions:{padding:.12,maxZoom:1.1,minZoom:y?.6:.85},minZoom:.3,maxZoom:1.5,className:"!bg-background",style:et,children:[(0,n.jsx)(i.VS,{}),(0,n.jsx)(i.H2,{showInteractive:!1,position:"bottom-left"})]})]}),!eq&&(!y||ea)&&(0,n.jsxs)("aside",{"aria-label":"속성",className:"shrink-0 overflow-y-auto border-t border-border p-3 text-xs min-[900px]:w-72 min-[900px]:border-l min-[900px]:border-t-0",children:[tf?(0,n.jsx)(en,{graph:z,nodeId:tf.id,palette:s,issues:e8.filter(e=>e.nodeId===tf.id),linkTarget:ey,linkOutcome:ej,setLinkTarget:ek,setLinkOutcome:ew,onEdit:te,onRenamed:e=>eo({type:"node",id:e}),onRemoved:()=>eo(null),installedPacks:N,effectiveSteps:er,onKnowledgePackChange:e=>{U(t=>({...t,[tf.id]:e})),null==_||_(e)}},tf.id):tx&&(null==ea?void 0:ea.type)==="edge"?(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsxs)("h2",{className:"text-sm font-semibold",children:["간선 ",(0,n.jsxs)("span",{className:"font-mono",children:[tx.from," → ",tx.to]})]}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["결과 이름 (비우면 조건 없이 이어짐)",(0,n.jsx)("input",{"aria-label":"간선 결과",list:"graph-canvas-outcomes",value:tx.outcome,placeholder:"예: pass \xb7 fail",onChange:e=>te(t=>{var r,n;return r=ea.index,n={outcome:e.target.value},{...t,edges:t.edges.map((e,t)=>{var a;if(t!==r)return e;let o=(null!=(a=n.outcome)?a:e.outcome).trim(),{extra:s,...l}={...e,...n,outcome:o};return s&&!!o==!!e.outcome?{...l,extra:s}:l})}}),className:"rounded border border-border bg-background px-2 py-1 font-mono text-foreground"})]}),(0,n.jsx)("button",{type:"button",onClick:()=>{te(e=>R(e,ea.index)),eo(null)},className:"self-start rounded border border-red-500 px-2 py-1 text-red-500",children:"간선 삭제"})]}):(0,n.jsxs)("div",{className:"flex flex-col gap-2 text-muted-foreground",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:"속성"}),(0,n.jsx)("p",{children:"노드를 누르면 id\xb7kind\xb7recipe 를 고칠 수 있습니다. 노드 오른쪽 점을 다른 노드로 끌거나, 노드를 고른 뒤 \xab다음 노드 연결\xbb 로 간선을 잇습니다."}),(0,n.jsxs)("p",{children:["노드 ",z.nodes.length," \xb7 간선 ",z.edges.length,z.entry?" \xb7 시작 ".concat(z.entry):""]})]}),tg.length>0&&(0,n.jsx)("ul",{"aria-label":"그래프 오류",className:"mt-3 flex flex-col gap-1 border-t border-border pt-2",children:tg.map((e,t)=>(0,n.jsx)("li",{className:"text-red-500",children:e.message},t))}),(0,n.jsxs)("details",{className:"mt-3 border-t border-border pt-2",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-muted-foreground",children:"YAML 보기"}),(0,n.jsx)("pre",{"aria-label":"그래프 YAML",className:"mt-2 max-h-64 overflow-auto rounded bg-muted p-2 font-mono text-[11px] text-foreground",children:e2})]})]})]})]}),(0,n.jsxs)("p",{className:"shrink-0 px-3 py-1 text-[11px] text-muted-foreground",children:["배선도 디자인: ",(0,n.jsx)("a",{href:"https://malfoy-meme-making.vercel.app/wiring/index.html",target:"_blank",rel:"noopener noreferrer",className:"underline",children:"공냥이 AI 실험실"})]})]})}function en(e){var t,r,o,s,l,i,d;let{graph:u,nodeId:c,palette:p,issues:m,linkTarget:f,linkOutcome:x,setLinkTarget:g,setLinkOutcome:h,onEdit:b,onRenamed:v,onRemoved:y,installedPacks:k,effectiveSteps:j,onKnowledgePackChange:w}=e,N=u.nodes.find(e=>e.id===c),[S,C]=(0,a.useState)(N.id),[A,M]=(0,a.useState)(null),D=u.nodes.filter(e=>e.id!==c).map(e=>e.id),O=D.includes(f)?f:null!=(o=D[0])?o:"",V=null!=x?x:E(u,c),P=p.find(e=>e.kind===N.kind),G=u.edges.map((e,t)=>({edge:e,index:t})).filter(e=>{let{edge:t}=e;return t.from===c});function T(){let e=S.trim();if(e!==N.id)try{_(u,N.id,{id:e}),b(t=>_(t,N.id,{id:e})),M(null),v(e)}catch(e){M(e instanceof Error?e.message:String(e))}}return(0,n.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,n.jsxs)("h2",{className:"text-sm font-semibold",children:["노드 ",(0,n.jsx)("span",{className:"font-mono",children:N.id})]}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["id",(0,n.jsx)("input",{"aria-label":"노드 id",value:S,spellCheck:!1,onChange:e=>C(e.target.value),onBlur:T,onKeyDown:e=>{"Enter"===e.key&&T()},className:"rounded border border-border bg-background px-2 py-1 font-mono text-foreground"})]}),A&&(0,n.jsx)("p",{role:"alert",className:"text-red-500",children:A}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["kind",(0,n.jsxs)("select",{"aria-label":"노드 kind",value:N.kind,onChange:e=>b(t=>_(t,c,{kind:e.target.value})),className:"rounded border border-border bg-background px-1 py-1 text-foreground",children:[!P&&(0,n.jsxs)("option",{value:N.kind,children:[N.kind," (팔레트에 없음)"]}),p.map(e=>{var t;return(0,n.jsxs)("option",{value:e.kind,children:[e.kind,e.plugin?" \xb7 ".concat(e.plugin):""]},"".concat(null!=(t=e.plugin)?t:"core",":").concat(e.kind))})]})]}),(null==P?void 0:P.description)&&(0,n.jsx)("p",{className:"text-[11px] text-muted-foreground",children:P.description}),k&&(null==j||null==(t=j[c])?void 0:t.step)==="knowledge-rag"&&(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["지식(RAG) 팩",(0,n.jsxs)("select",{"aria-label":"지식(RAG) 팩",value:null!=(s=null==(r=j[c])?void 0:r.arg)?s:"",onChange:e=>null==w?void 0:w(e.target.value),className:"rounded border border-border bg-background px-1 py-1 text-foreground",children:[(0,n.jsx)("option",{value:"",disabled:!0,children:"팩 선택"}),k.map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title," (",e.id,")"]},e.id))]})]}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["recipe",(0,n.jsx)("input",{"aria-label":"recipe",value:N.recipe,spellCheck:!1,onChange:e=>b(t=>_(t,c,{recipe:e.target.value})),className:"rounded border border-border bg-background px-2 py-1 font-mono text-foreground"})]}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 text-muted-foreground",children:["최대 방문 (max_visits)",(0,n.jsx)("input",{"aria-label":"max_visits",type:"number",min:1,step:1,value:N.maxVisits,onChange:e=>b(t=>_(t,c,{maxVisits:Number(e.target.value)})),className:"w-24 rounded border border-border bg-background px-2 py-1 text-foreground"})]}),(0,n.jsxs)("label",{className:"flex items-center gap-2 text-foreground",children:[(0,n.jsx)("input",{type:"checkbox","aria-label":"끝 노드",checked:u.terminals.includes(c),onChange:e=>b(t=>z(t,c,e.target.checked))}),"끝 노드 (여기서 실행이 끝남)"]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2",children:[u.entry===c?(0,n.jsx)("span",{className:"rounded bg-emerald-500/15 px-2 py-1 text-emerald-500",children:"시작 노드"}):(0,n.jsx)("button",{type:"button",onClick:()=>b(e=>e.nodes.some(e=>e.id===c)?{...e,entry:c}:e),className:"rounded border border-border px-2 py-1",children:"시작 노드로"}),(0,n.jsx)("button",{type:"button",onClick:()=>{b(e=>(function(e,t){var r,n;let a=e.nodes.filter(e=>e.id!==t);return{...e,entry:e.entry===t?null!=(n=null==(r=a[0])?void 0:r.id)?n:null:e.entry,terminals:e.terminals.filter(e=>e!==t),nodes:a,edges:e.edges.filter(e=>e.from!==t&&e.to!==t)}})(e,c)),y()},className:"rounded border border-red-500 px-2 py-1 text-red-500",children:"노드 삭제"})]}),(0,n.jsxs)("label",{className:"flex flex-col gap-1 border-t border-border pt-2 text-muted-foreground",children:["실패 시 다음 노드",(0,n.jsxs)("select",{"aria-label":"실패 시 다음 노드",value:null!==(l=null!=(d=null==(i=u.edges.find(e=>e.from===c&&"fail"===e.outcome))?void 0:i.to)?d:null)&&void 0!==l?l:"",onChange:e=>b(t=>(function(e,t,r){if(r===t)throw Error("실패 경로를 자기 자신으로 둘 수 없습니다");let n=e.edges.filter(e=>e.from!==t||"fail"!==e.outcome).map(e=>null===r||e.from!==t||e.outcome?e:{...e,outcome:"ok"});return{...e,edges:null===r?n:[...n,{from:t,to:r,outcome:"fail"}]}})(t,c,e.target.value||null)),className:"rounded border border-border bg-background px-1 py-1 font-mono text-foreground",children:[(0,n.jsx)("option",{value:"",children:"선택 안 함"}),D.map(e=>(0,n.jsx)("option",{value:e,children:e},e))]})]}),(0,n.jsxs)("fieldset",{className:"mt-1 flex flex-col gap-1 border-t border-border pt-2",children:[(0,n.jsx)("legend",{className:"text-muted-foreground",children:"다음 노드 연결"}),0===D.length?(0,n.jsx)("p",{className:"text-muted-foreground",children:"이을 다른 노드가 없습니다."}):(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-1",children:[(0,n.jsx)("select",{"aria-label":"연결할 노드",value:O,onChange:e=>g(e.target.value),className:"rounded border border-border bg-background px-1 py-1 font-mono text-foreground",children:D.map(e=>(0,n.jsx)("option",{value:e,children:e},e))}),(0,n.jsx)("input",{"aria-label":"연결 결과",list:"graph-canvas-outcomes",value:V,placeholder:"결과(비우면 조건 없음)",onChange:e=>h(e.target.value),className:"w-24 rounded border border-border bg-background px-2 py-1 font-mono text-foreground"}),(0,n.jsx)("button",{type:"button",onClick:()=>{b(e=>I(e,c,O,V)),h(null)},className:"rounded border border-border px-2 py-1",children:"연결"})]}),G.length>0&&(0,n.jsx)("ul",{className:"flex flex-col gap-1",children:G.map(e=>{let{edge:t,index:r}=e;return(0,n.jsxs)("li",{className:"flex items-center gap-2 font-mono",children:[(0,n.jsxs)("span",{children:["→ ",t.to,t.outcome?" (".concat(t.outcome,")"):""]}),(0,n.jsx)("button",{type:"button","aria-label":"".concat(t.to," 간선 삭제"),onClick:()=>b(e=>R(e,r)),className:"rounded px-1 text-red-500 hover:bg-red-500/10",children:"삭제"})]},r)})})]}),m.length>0&&(0,n.jsx)("ul",{"aria-label":"노드 오류",className:"flex flex-col gap-1 border-t border-border pt-2",children:m.map((e,t)=>(0,n.jsx)("li",{className:"text-red-500",children:e.message},t))})]})}let ea=e=>null!==e&&"object"==typeof e&&!Array.isArray(e);async function eo(e,t){try{let r=await e.startRunGraphRun(t);return"string"==typeof(null==r?void 0:r.runId)?{kind:"started",runId:r.runId}:{kind:"error",status:0,message:"런 id 가 없다"}}catch(r){if(!(r instanceof p.Iu))return{kind:"error",status:0,message:"데몬에 닿지 못했다"};let e=r.body;if(403===r.status)return{kind:"forbidden"};if(409===r.status&&ea(e)&&"string"==typeof e.error&&e.error.startsWith("peer-edit-"))return{kind:"peer-edit",message:"string"==typeof e.reason&&e.reason?e.reason:"상대가 바꾼 그래프 — 변경을 확인하고 승인해야 실행할 수 있다",..."peer-edit-unapproved"===e.error&&"string"==typeof e.version?{version:e.version}:{},..."string"==typeof e.editedBy?{editedBy:e.editedBy}:{}};if(422===r.status&&ea(e)&&Array.isArray(e.issues))return{kind:"not-runnable",issues:e.issues.filter(e=>"string"==typeof e)};let t=ea(e)&&"string"==typeof e.reason?e.reason:ea(e)&&"string"==typeof e.error?e.error:"";return{kind:"error",status:r.status,message:t}}}async function es(e,t,r){try{var n;return n=await e.getRunGraphRun(t,r),ea(n)&&"string"==typeof n.runId&&"string"==typeof n.status&&Array.isArray(n.path)&&Array.isArray(n.nodes)?n:null}catch(e){return null}}let el=new Set(["done","failed","budget-exceeded","awaiting-approval"]);function ei(e){return Object.fromEntries(Object.entries(function(e){let t={};for(let r of e.nodes){let e=r.startedAt&&r.endedAt?Math.max(0,Date.parse(r.endedAt)-Date.parse(r.startedAt)):void 0,n=r.ok?"done":"failed";t[r.nodeId]={status:n,...void 0!==e&&Number.isFinite(e)?{durationMs:e}:{},...r.error?{error:r.error}:{}}}return e.currentNode&&!el.has(e.status)&&(t[e.currentNode.nodeId]={status:"running"}),"awaiting-approval"===e.status&&e.currentNode&&(t[e.currentNode.nodeId]={status:"awaiting_approval"}),t}(e)).map(e=>{let[t,r]=e;return[t,r.status]}))}function ed(e){let{context:t,client:r,onStatus:o}=e,[s,l]=(0,a.useState)({kind:"idle"}),i=(0,a.useRef)(t.graphId),d=t.graphId?t.valid?t.saved?null:"저장한 뒤 실행할 수 있습니다 — 서버는 저장된 판을 돌립니다":"검증을 통과해야 실행할 수 있습니다":"그래프 id 가 없습니다";(0,a.useEffect)(()=>{i.current!==t.graphId&&(i.current=t.graphId,l({kind:"idle"}),o(void 0))},[t.graphId,o]);let u="running"===s.kind?s.runId:null,c="running"===s.kind&&null!==s.run&&el.has(s.run.status);(0,a.useEffect)(()=>{if(!u||c)return;let e=!1,n="running"===s.kind?s:null,a=setTimeout(async()=>{let a=await es(r,t.graphId,u);if(!e&&n){if(!a){let e=n.misses+1;l(e>=5?{kind:"refused",lines:["런 상태를 ".concat(e,"번 연속 읽지 못했습니다 — 데몬을 확인한 뒤 다시 실행하세요")]}:{...n,misses:e,tick:n.tick+1});return}if(Date.now()-n.since>18e4&&!el.has(a.status)){l({kind:"refused",lines:["데모 실행이 ".concat(Math.round(3),"분 넘게 끝나지 않습니다 — 원장이 \xab도는 중\xbb으로 남았을 수 있습니다(데몬 재시작 등)")]}),o(ei(a));return}l({...n,run:a,misses:0,tick:n.tick+1}),o(ei(a))}},1e3);return()=>{e=!0,clearTimeout(a)}},[u,c,s,r,t.graphId,o]);let p=async()=>{l({kind:"starting"}),o(void 0);let e=await eo(r,t.graphId);"started"===e.kind?l({kind:"running",runId:e.runId,run:null,misses:0,since:Date.now(),tick:0}):"not-runnable"===e.kind?l({kind:"refused",lines:e.issues}):"forbidden"===e.kind?l({kind:"refused",lines:["운영자만 실행할 수 있습니다"]}):"peer-edit"===e.kind?l({kind:"peer-edit",message:e.message,...e.version?{version:e.version}:{},...e.editedBy?{editedBy:e.editedBy}:{}}):l({kind:"refused",lines:["실행을 시작하지 못했습니다".concat(e.message?" — ".concat(e.message):"").concat(e.status?" (".concat(e.status,")"):"")]})},m=async()=>{if("peer-edit"===s.kind&&s.version&&r.approveRunGraph){l({...s,approving:!0});try{await r.approveRunGraph(t.graphId,s.version),l({kind:"idle"})}catch(e){l({...s,approving:!1,error:"승인 실패".concat(e instanceof Error?" — ".concat(e.message):"")})}}},f="starting"===s.kind||"running"===s.kind&&!c,x="running"===s.kind?s.run:null,g=(null==x?void 0:x.status)==="done"?"text-emerald-700 dark:text-emerald-400":x&&el.has(x.status)?"text-red-700 dark:text-red-400":"text-sky-700 dark:text-sky-400";return(0,n.jsxs)("span",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{p()},disabled:f||null!==d,title:null!=d?d:"저장된 그래프를 데모 레시피로 실행합니다",className:"rounded border border-sky-600/60 bg-sky-600/10 px-2.5 py-1 text-xs font-semibold text-sky-800 disabled:cursor-not-allowed disabled:opacity-50 dark:text-sky-300",children:"▶ 데모 실행"}),d&&"idle"===s.kind&&(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:d}),"starting"===s.kind&&(0,n.jsx)("span",{role:"status",className:"text-xs text-sky-700 dark:text-sky-400",children:"데모 실행 \xb7 시작하는 중"}),"running"===s.kind&&(0,n.jsx)("span",{role:"status","aria-live":"polite",className:"text-xs font-semibold ".concat(g),children:x?function(e){let t=e.path.length,r=t-new Set(e.path).size;switch(e.status){case"starting":return"데모 실행 \xb7 시작하는 중";case"running":return"데모 실행 \xb7 도는 중".concat(e.currentNode?" ".concat(e.currentNode.nodeId):""," \xb7 지난 노드 ").concat(e.nodes.length);case"done":return"데모 실행 \xb7 성공 \xb7 거친 노드 ".concat(t).concat(r?"(다시 지남 ".concat(r,")"):"");case"budget-exceeded":return"데모 실행 \xb7 방문 한도 초과".concat(e.path.at(-1)?" ".concat(e.path.at(-1)):""," — max_visits 를 늘려 저장하고 다시 실행");case"awaiting-approval":return"데모 실행 \xb7 승인 대기".concat(e.currentNode?" ".concat(e.currentNode.nodeId):"");default:{let t=[...e.nodes].reverse().find(e=>!e.ok);return"데모 실행 \xb7 실패".concat(t?" ".concat(t.nodeId):"").concat(e.error?" — ".concat(e.error):(null==t?void 0:t.error)?" — ".concat(t.error):"")}}}(x):"데모 실행 \xb7 시작하는 중"}),"refused"===s.kind&&(0,n.jsx)("span",{role:"alert",className:"text-xs font-semibold text-red-700 dark:text-red-400",children:s.lines.join(" \xb7 ")}),"peer-edit"===s.kind&&(0,n.jsxs)("span",{role:"alert",className:"text-xs font-semibold text-red-700 dark:text-red-400",children:[s.message,s.editedBy?" (".concat(s.editedBy,")"):"",s.error?" \xb7 ".concat(s.error):""]}),"peer-edit"===s.kind&&s.version&&r.approveRunGraph&&(0,n.jsx)("button",{type:"button",onClick:()=>{m()},disabled:!0===s.approving,title:"캔버스에서 상대의 변경을 확인한 뒤 승인하세요 — 승인하면 이 판을 실행할 수 있습니다",className:"rounded border border-red-600/60 px-2.5 py-1 text-xs font-semibold text-red-800 disabled:opacity-50 dark:text-red-300",children:"변경 확인 \xb7 승인"})]})}var eu=r(13390);let ec=["매일 아침 AI 뉴스 요약해서 텔레그램으로","PR 리뷰하고 문제 없으면 머지","조사해서 표로 정리하고 내가 승인하면 게시"];function ep(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){let t="string"==typeof e.nodeId?e.nodeId:"string"==typeof e.path?e.path:"",r="string"==typeof e.message?e.message:JSON.stringify(e);return t?"".concat(t,": ").concat(r):r}return String(e)}async function em(e,t,r){if(!t.prompt.trim())return{kind:"empty"};try{let n=await e.graphWizard(t,r?{signal:r}:void 0);return ef(n)}catch(e){if((null==r?void 0:r.aborted)||e instanceof Error&&"AbortError"===e.name)return{kind:"cancelled"};if(e instanceof p.Iu){var n,a;if(404===e.status||405===e.status)return{kind:"unsupported"};if(422===e.status&&e.body&&"object"==typeof e.body&&"ok"in e.body)return ef(e.body);let t=null!=(n=e.body)?n:{};if(400===e.status&&(!t.reason||"prompt required"===t.reason))return{kind:"empty"};if(400===e.status)return{kind:"error",message:"요청을 받지 않았습니다 — ".concat(t.reason)};return{kind:"error",message:null!=(a=t.reason)?a:t.error?"".concat(t.error," (").concat(e.status,")"):"요청 실패 (".concat(e.status,")")}}return{kind:"error",message:e instanceof Error?e.message:String(e)}}}function ef(e){var t;let r,n=(null!=(t=e.issues)?t:[]).map(ep),a="string"==typeof e.yaml?e.yaml:"",o=null;if(a.trim()){try{o=V(a)}catch(e){r=e instanceof Error?e.message:String(e)}o&&0===o.nodes.length&&(o=null,r="초안에 노드가 없습니다")}else r="응답에 YAML 이 없습니다";return{kind:"draft",ok:!0===e.ok&&0===n.length,yaml:a,graph:o,issues:n,...r?{parseError:r}:{},...e.base?{base:e.base}:{},..."number"==typeof e.attempts?{attempts:e.attempts}:{},...e.summary?{summary:e.summary}:{},...e.labels&&"object"==typeof e.labels?{labels:Object.fromEntries(Object.entries(e.labels).filter(e=>"string"==typeof e[1]&&""!==e[1].trim()))}:{},...e.steps&&"object"==typeof e.steps&&!Array.isArray(e.steps)?{steps:e.steps}:{},..."string"==typeof e.baseReason&&e.baseReason.trim()?{baseReason:e.baseReason.trim()}:{}}}function ex(e){return e.baseReason?e.base?"기반: ".concat(e.base," — 이유 ").concat(e.baseReason):"기반 선택 이유: ".concat(e.baseReason):null}function eg(e){return"".concat(e.from,"->").concat(e.to,":").concat(e.outcome)}function eh(e){var t,r,o;let{client:s,current:l,laid:i,onApply:d,onRestore:u,initialPrompt:c,packId:p,className:m=""}=e,[f,x]=(0,a.useState)([]),[g,h]=(0,a.useState)(""),[b,v]=(0,a.useState)(null),[y,k]=(0,a.useState)(0),[j,w]=(0,a.useState)(!1),N=(0,a.useRef)(1),S=(0,a.useRef)(null),C=(0,a.useRef)(null),I=(0,a.useRef)(!1),E=(0,a.useRef)(f);E.current=f;let R=(0,a.useRef)(null);function _(e){let t=N.current++;return x(r=>[...r,{...e,id:t}]),t}async function z(e,t,r){let n=e.trim();if(b)return;if(!n)return void _({role:"assistant",text:"무엇을 만들지 한 줄로 적어 주세요.",tone:"warn"});let a=void 0!==t?t:l(),o=!a||0===a.graph.nodes.length,u=E.current.filter(e=>!e.undone&&(void 0===r||e.id<r)).map(e=>({role:e.role,text:e.text})),c=_({role:"user",text:n});h("");let m=new AbortController;v({startedAt:Date.now(),controller:m});try{var f,x,g,y;let e=await em(s,{...(y=o?null:a.yaml,{prompt:n.trim(),kind:"harness",...y?{currentYaml:y}:{},...u.length?{history:u.slice(-10).map(e=>({role:e.role,text:e.text}))}:{}}),...p?{packId:p}:{}},m.signal);if("cancelled"===e.kind)return void _({role:"assistant",text:"취소했습니다 — 캔버스는 그대로입니다.",tone:"warn"});if("unsupported"===e.kind)return void _({role:"assistant",text:"이 Daemon 이 아직 그래프 마법사를 지원하지 않습니다 — 서버 업데이트 후 다시 시도하세요",tone:"error"});if("empty"===e.kind)return void _({role:"assistant",text:"무엇을 만들지 한 줄로 적어 주세요.",tone:"warn"});if("error"===e.kind)return void _({role:"assistant",text:"만들기 실패: ".concat(e.message),tone:"error"});let t=o?null:a.graph,r=i?i():R.current;if(e.graph){let n=function(e,t){if(!t||0===t.nodes.length)return!1;if(!e)return!0;let r=new Map(e.nodes.map(e=>[e.id,e]));return t.nodes.some(e=>{let t=r.get(e.id);return!t||t.x!==e.x||t.y!==e.y})}(r,t),a=function(e,t){var r,n,a;let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=null==(r=o.keepPositions)||r,l=new Map((null!=(n=null==e?void 0:e.nodes)?n:[]).map(e=>[e.id,e])),i=t.nodes.map(e=>{let t=s?l.get(e.id):void 0;return t?{...e,x:t.x,y:t.y}:e}),d=new Set((null!=(a=null==e?void 0:e.edges)?a:[]).map(eg));return{graph:{...t,nodes:i},added:{nodes:t.nodes.filter(e=>!l.has(e.id)).map(e=>e.id),edges:t.edges.filter(e=>!d.has(eg(e))).map(eg)}}}(t,e.graph,{keepPositions:n});d(a.graph,a.added,!n,e.labels,e.steps),(null==(f=(x=window).matchMedia)?void 0:f.call(x,"(max-width: 1023.98px)").matches)&&w(!0),R.current=a.graph}_({role:"assistant",text:null!=(g=e.summary)?g:o?"그래프 초안을 만들었습니다.":"그래프를 고쳤습니다.",tone:e.ok?"ok":e.graph?"warn":"error",status:function(e){let t=e.base?" \xb7 기반 템플릿 ".concat(e.base):"",r=void 0!==e.attempts?"(시도 ".concat(e.attempts,")"):"";return e.ok?"초안".concat(t," \xb7 검증 통과").concat(r):"초안".concat(t," \xb7 검증 실패 ").concat(e.issues.length,"건").concat(r)}(e),...ex(e)?{baseLine:ex(e)}:{},...e.issues.length?{issues:e.issues}:{},...e.parseError?{parseError:e.parseError}:{},...e.graph?{before:t,applied:!0,laidBefore:r,...e.steps?{steps:e.steps}:{}}:{},prompt:n,userId:c})}finally{v(null)}}function A(e){var t,r,n;let a=E.current.find(t=>t.id===e);if(!a||"assistant"!==a.role||!a.applied||a.undone)return;let o=[...E.current].reverse().find(t=>"assistant"===t.role&&t.applied&&!t.undone&&t.id<e);u(null!=(t=a.before)?t:null,o&&"assistant"===o.role?o.steps:void 0),R.current=null!=(r=a.laidBefore)?r:null;let s=null!=(n=a.userId)?n:e;x(e=>e.map(e=>e.id>=s?{...e,undone:!0}:e))}function D(){var e;h("검증 오류를 고쳐줘"),null==(e=C.current)||e.focus()}(0,eu.dJ)("graph-wizard"),(0,a.useEffect)(()=>{if(!b)return;k(0);let e=setInterval(()=>k(Math.floor((Date.now()-b.startedAt)/1e3)),1e3);return()=>clearInterval(e)},[b]),(0,a.useEffect)(()=>{let e=S.current;e&&"function"==typeof e.scrollTo&&e.scrollTo({top:e.scrollHeight})},[f,b,j]),(0,a.useEffect)(()=>{c&&!I.current&&(I.current=!0,z(c))},[c]);let O=null!=(o=null==(t=[...f].reverse().find(e=>"assistant"===e.role))?void 0:t.text)?o:"",V=null==(r=[...f].reverse().find(e=>"assistant"===e.role&&e.applied&&!e.undone))?void 0:r.id;return(0,n.jsxs)("aside",{"aria-label":"말로 만들기","data-testid":"graph-wizard-chat",className:"flex min-h-0 shrink-0 flex-col border-border bg-background ".concat(j?"":"max-lg:h-[38vh]"," max-lg:border-t lg:h-auto lg:w-[360px] lg:shrink-0 lg:border-l ").concat(m),children:[(0,n.jsxs)("header",{className:"flex items-center gap-2 border-b border-border px-3 py-2 text-sm",children:[(0,n.jsx)("strong",{className:"shrink-0",children:"말로 만들기"}),j&&O?(0,n.jsx)("span",{"data-testid":"wizard-collapsed-line",className:"min-w-0 truncate text-xs text-muted-foreground lg:hidden",children:O}):null,(0,n.jsx)("span",{className:"text-xs text-muted-foreground ".concat(j&&O?"max-lg:hidden":""),children:"말하면 노드와 간선이 생깁니다"}),(0,n.jsx)("button",{type:"button",onClick:()=>w(e=>!e),"aria-expanded":!j,className:"ml-auto shrink-0 whitespace-nowrap rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted lg:hidden",children:j?"펼치기":"접기"})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col ".concat(j?"max-lg:hidden":""),children:[(0,n.jsxs)("ol",{ref:S,className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto px-3 py-2 text-sm","aria-live":"polite",children:[0===f.length&&(0,n.jsxs)("li",{className:"text-xs text-muted-foreground",children:[(0,n.jsx)("p",{children:"만들고 싶은 일을 한 줄로 적으세요. 이어서 말하면 지금 그래프를 고칩니다."}),(0,n.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:ec.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>{z(e)},disabled:null!==b,className:"rounded-full border border-border px-2.5 py-1 text-left text-foreground hover:bg-muted disabled:opacity-50",children:e},e))})]}),f.map(e=>"user"===e.role?(0,n.jsx)("li",{"data-role":"user",className:"max-w-[85%] self-end whitespace-pre-wrap break-words rounded-lg bg-primary/15 px-3 py-1.5 text-foreground ".concat(e.undone?"opacity-50 line-through decoration-muted-foreground/60":""),children:e.text},e.id):(0,n.jsxs)("li",{"data-role":"assistant","data-tone":e.tone,className:"rounded-lg border px-3 py-1.5 ".concat(e.undone?"opacity-50":""," ").concat("ok"===e.tone?"border-emerald-500/40":"warn"===e.tone?"border-amber-500/40":"border-red-500/40"),children:[(0,n.jsx)("p",{className:"error"===e.tone?"text-red-500":"text-foreground",children:e.text}),e.status&&(0,n.jsxs)("p",{"data-testid":"wizard-status",className:"mt-0.5 text-xs ".concat("ok"===e.tone?"text-emerald-500":"text-amber-500"),children:["ok"===e.tone?"✓ ":"✗ ",e.status]}),e.baseLine&&(0,n.jsx)("p",{"data-testid":"wizard-base",className:"mt-0.5 text-xs text-muted-foreground",children:e.baseLine}),e.parseError&&(0,n.jsxs)("p",{className:"mt-0.5 text-xs text-red-500",children:["초안을 캔버스에 올리지 못했습니다: ",e.parseError]}),e.issues&&(0,n.jsx)("ul",{"data-testid":"wizard-issues",className:"mt-1 list-disc pl-5 text-xs text-red-500",children:e.issues.map((e,t)=>(0,n.jsx)("li",{children:e},t))}),e.undone&&(0,n.jsx)("p",{className:"mt-0.5 text-xs text-muted-foreground",children:"되돌림"}),(0,n.jsxs)("div",{className:"mt-1 flex flex-wrap gap-1.5 text-xs",children:[e.applied&&!e.undone&&(0,n.jsx)("button",{type:"button",onClick:()=>A(e.id),disabled:null!==b,title:e.id===V?"이 답 전의 캔버스로":"이 답과 그 뒤의 답을 모두 되돌립니다",className:"rounded border border-border px-2 py-0.5 hover:bg-muted disabled:opacity-50",children:"되돌리기"}),e.prompt&&!e.undone&&(0,n.jsx)("button",{type:"button",onClick:()=>(function(e){var t;let r=E.current.find(t=>t.id===e);if(!r||"assistant"!==r.role||!r.prompt)return;let n=r.applied?r.before?{graph:r.before,yaml:M(r.before)}:null:void 0;A(e);let a=g.trim();z(a?"".concat(r.prompt,"\n추가 지시: ").concat(a):r.prompt,n,null!=(t=r.userId)?t:e)})(e.id),disabled:null!==b,title:"이 답을 되돌리고 같은 말(+ 입력창의 추가 지시)로 다시 만듭니다",className:"rounded border border-border px-2 py-0.5 hover:bg-muted disabled:opacity-50",children:"다시 만들기"}),e.issues&&!e.undone&&(0,n.jsx)("button",{type:"button",onClick:D,disabled:null!==b,className:"rounded border border-amber-500/50 px-2 py-0.5 text-amber-500 hover:bg-amber-500/10 disabled:opacity-50",children:"고쳐서 다시"})]})]},e.id)),b&&(0,n.jsxs)("li",{role:"status","data-testid":"wizard-pending",className:"rounded-lg border border-border px-3 py-2 text-xs text-muted-foreground",children:[(0,n.jsxs)("div",{className:"flex items-center gap-2",children:[(0,n.jsx)("span",{className:"inline-block h-2 w-2 animate-pulse rounded-full bg-primary"}),(0,n.jsx)("span",{"data-testid":"wizard-phase",className:"text-foreground",children:y<4?"요청을 읽는 중…":y<12?"노드 구성 중…":y<22?"간선 잇는 중…":"검증하고 고치는 중…"}),(0,n.jsxs)("span",{className:"tabular-nums",children:[y,"초"]}),(0,n.jsx)("button",{type:"button",onClick:()=>b.controller.abort(),className:"ml-auto rounded border border-border px-2 py-0.5 text-foreground hover:bg-muted",children:"취소"})]}),(0,n.jsx)("div",{className:"mt-1.5 h-1 overflow-hidden rounded bg-muted","aria-hidden":!0,children:(0,n.jsx)("div",{className:"h-full rounded bg-primary transition-[width] duration-1000 ease-linear",style:{width:"".concat(Math.min(92,Math.round(100*(1-Math.exp(-y/15)))),"%")}})})]})]}),(0,n.jsxs)("form",{className:"flex items-end gap-2 border-t border-border px-3 py-2",onSubmit:e=>{e.preventDefault(),z(g)},children:[(0,n.jsx)("textarea",{ref:C,"aria-label":"만들고 싶은 일",value:g,rows:2,placeholder:"예: 매일 아침 AI 뉴스 요약해서 텔레그램으로",onChange:e=>h(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),z(g))},className:"min-h-[2.5rem] flex-1 resize-none rounded border border-border bg-background px-2 py-1.5 text-sm text-foreground"}),(0,n.jsx)("button",{type:"submit",disabled:null!==b,className:"rounded bg-primary px-3 py-2 text-sm text-primary-foreground disabled:opacity-50",children:"만들기"})]})]})]})}function eb(e){let{onStart:t}=e,[r,o]=(0,a.useState)(""),[s,l]=(0,a.useState)(null);function i(e){if(!e.trim())return void l("무엇을 만들지 한 줄로 적어 주세요.");l(null),t(e.trim())}return(0,n.jsxs)("section",{"aria-label":"말로 만들기","data-testid":"graph-wizard-entry",className:"border-b border-border bg-primary/5 px-4 py-3",children:[(0,n.jsx)("h2",{className:"text-sm font-semibold",children:"말로 만들기"}),(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"하고 싶은 일을 말하면 그래프 초안이 생깁니다. 이어서 말하며 고치세요."}),(0,n.jsxs)("form",{className:"mt-2 flex flex-col gap-2 min-[640px]:flex-row min-[640px]:items-end",onSubmit:e=>{e.preventDefault(),i(r)},children:[(0,n.jsx)("textarea",{"aria-label":"만들고 싶은 일",value:r,rows:2,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),i(r))},placeholder:"예: PR 리뷰하고 문제 없으면 머지",className:"min-h-[2.5rem] flex-1 resize-none rounded border border-border bg-background px-2 py-1.5 text-sm text-foreground"}),(0,n.jsx)("button",{type:"submit",className:"rounded bg-primary px-4 py-2 text-sm text-primary-foreground",children:"만들기"})]}),s&&(0,n.jsx)("p",{role:"status",className:"mt-1 text-xs text-amber-500",children:s}),(0,n.jsx)("div",{className:"mt-2 flex flex-wrap gap-1.5 text-xs",children:ec.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>i(e),className:"rounded-full border border-border px-2.5 py-1 hover:bg-muted",children:e},e))})]})}var ev=r(63763);function ey(e){let{groups:t,onAdd:r}=e;return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("strong",{children:"노드 팔레트"}),(0,n.jsx)("div",{className:"flex flex-wrap gap-4",children:t.map(e=>(0,n.jsxs)("section",{"aria-label":e.label,className:"min-w-0 flex-1",children:[(0,n.jsx)("h2",{className:"font-semibold",children:e.label}),(0,n.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:e.kinds.map(t=>r?(0,n.jsxs)("button",{type:"button",title:t.description,"data-graph":t.graph,"aria-label":"".concat(e.label," ").concat(t.kind," 추가"),onClick:()=>r(t),className:"rounded border border-border px-2 py-0.5",children:[t.kind," ",t.plugin&&(0,n.jsx)("small",{children:t.plugin})]},"".concat(t.graph,":").concat(t.kind)):(0,n.jsxs)("span",{title:t.description,"data-graph":t.graph,className:"rounded border border-border px-2 py-0.5",children:[t.kind," ",t.plugin&&(0,n.jsx)("small",{children:t.plugin})]},"".concat(t.graph,":").concat(t.kind)))}),e.fallback&&(0,n.jsx)("p",{role:"status",className:"mt-1 text-warning",children:"어휘 목록을 불러오지 못해 코어 팔레트를 표시합니다."})]},e.graph))})]})}function ek(e){let{groups:t,onAdd:r}=e,a=t.reduce((e,t)=>e+t.kinds.length,0);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("details",{className:"border-b border-border px-3 py-2 text-xs min-[640px]:hidden","aria-label":"노드 팔레트",children:[(0,n.jsxs)("summary",{className:"cursor-pointer",children:["노드 더하기 (",a,")"]}),(0,n.jsx)("div",{className:"mt-2",children:(0,n.jsx)(ey,{groups:t,onAdd:r})})]}),(0,n.jsx)("div",{className:"hidden border-b border-border px-3 py-2 text-xs min-[640px]:block","aria-label":"노드 팔레트",children:(0,n.jsx)(ey,{groups:t,onAdd:r})})]})}let ej={shared:function(e){let{data:t}=e;return(0,n.jsxs)("div",{className:"rounded border border-border bg-background px-3 py-2 text-xs","data-graph":t.graph,children:[(0,n.jsx)(i.h7,{type:"target",position:d.yX.Left}),(0,n.jsxs)("span",{children:["workflow"===t.graph?"작업 노드":"실행 단계 노드"," \xb7 ",t.kind]}),(0,n.jsx)("div",{className:"font-mono",children:t.id}),(0,n.jsx)(i.h7,{type:"source",position:d.yX.Right})]})}};function ew(e){let{groups:t,client:r}=e,[o,s]=(0,a.useState)([]),[l,d]=(0,a.useState)([]),[c,p]=(0,a.useState)({workflow:"",harness:""}),[m,f]=(0,a.useState)({workflow:"",harness:""}),[x,g]=(0,a.useState)({workflow:"",harness:""}),[h,b]=(0,a.useState)(!1);async function v(e,n){let a=c[e].trim();if(!a||!o.some(t=>t.graph===e))return void g(t=>({...t,[e]:"그래프 이름과 노드가 필요합니다."}));if("workflow"===e&&o.some(t=>{var r;return t.graph===e&&"subworkflow"===t.kind&&!(null==(r=t.workflow)?void 0:r.trim())}))return void g(t=>({...t,[e]:"subworkflow 참조 워크플로를 입력하세요."}));let s=function(e,t,r,n){let a=r.filter(t=>t.graph===e);if("workflow"===e){let e={name:t,nodes:[]};for(let t of a)e=t.kind.includes(":")?{...e,nodes:[...e.nodes,{id:t.id,kind:t.kind,inputs:{}}]}:"subworkflow"===t.kind?{...e,nodes:[...e.nodes,{id:t.id,kind:"subworkflow",workflow:t.workflow,inputs:{}}]}:(0,ev.iu)(e,t.kind,{id:t.id});return e={...e,nodes:e.nodes.map(e=>({...e,...n.filter(t=>t.to===e.id&&a.some(e=>e.id===t.from)).length?{depends_on:n.filter(t=>t.to===e.id&&a.some(e=>e.id===t.from)).map(e=>e.from)}:{}}))},(0,u.As)(e)}let o=S(t);for(let e of a)o=C(o,{kind:e.kind,id:e.id,x:e.x,y:e.y}).graph;return(o={...o,edges:n.filter(e=>a.some(t=>t.id===e.from)&&a.some(t=>t.id===e.to)).map(e=>({...e,outcome:""}))}).nodes.length&&(o=z(o,o.nodes[o.nodes.length-1].id,!0)),M(o)}(e,a,o,l);if("harness"===e){let r=D(V(s),t.find(t=>t.graph===e).kinds.map(e=>e.kind));if(!r.ok)return void g(t=>({...t,[e]:r.issues.map(e=>e.message).join(", ")}))}b(!0);try{let t=await r.validateGraph(e,s);if(!t.ok)return void g(r=>({...r,[e]:t.errors.map(e=>e.message).join(", ")}));n&&("workflow"===e?await r.saveWorkflow(a,{yaml:s,scope:"project"}):m.harness===a?await r.putRunGraphYaml(a,s):await r.createRunGraph(a,s),f(t=>({...t,[e]:a}))),g(t=>({...t,[e]:n?"저장했습니다.":"검증 통과"}))}catch(t){g(r=>({...r,[e]:t instanceof Error?t.message:String(t)}))}finally{b(!1)}}let y=o.map(e=>({id:e.id,type:"shared",position:{x:e.x,y:e.y},data:e})),k=l.map(e=>({id:"".concat(e.from,":").concat(e.to),source:e.from,target:e.to}));return(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[(0,n.jsx)(ek,{groups:t,onAdd:function(e){s(t=>{let r="".concat(e.graph,"-").concat(e.kind.split(":").pop().replace(/[^a-zA-Z0-9-]/g,"-")),n=1;for(;t.some(e=>e.id==="".concat(r,"-").concat(n));)n++;return[...t,{graph:e.graph,kind:e.kind,id:"".concat(r,"-").concat(n),x:40+t.length%5*210,y:40+130*Math.floor(t.length/5)}]})}}),o.filter(e=>"workflow"===e.graph&&"subworkflow"===e.kind).map(e=>{var t;return(0,n.jsxs)("label",{className:"px-3 py-1 text-xs",children:[e.id," 참조 워크플로",(0,n.jsx)("input",{"aria-label":"".concat(e.id," 참조 워크플로"),value:null!=(t=e.workflow)?t:"",onChange:t=>s(r=>r.map(r=>r.id===e.id?{...r,workflow:t.target.value}:r)),className:"ml-2 rounded border border-border bg-background px-2 py-1"})]},e.id)}),(0,n.jsx)("div",{className:"flex flex-wrap gap-4 border-b border-border px-3 py-2 text-xs",children:t.map(e=>(0,n.jsxs)("section",{"aria-label":"".concat(e.label," 검증과 저장"),children:[(0,n.jsxs)("label",{children:[e.label," 이름 ",(0,n.jsx)("input",{"aria-label":"".concat(e.label," 이름"),value:c[e.graph],onChange:t=>p(r=>({...r,[e.graph]:t.target.value})),className:"rounded border border-border bg-background px-2 py-1"})]}),(0,n.jsx)("button",{type:"button",disabled:h,onClick:()=>{v(e.graph,!1)},children:"검증"}),(0,n.jsx)("button",{type:"button",disabled:h,onClick:()=>{v(e.graph,!0)},children:"저장"}),x[e.graph]&&(0,n.jsx)("span",{role:"status",children:x[e.graph]})]},e.graph))}),(0,n.jsx)("div",{className:"min-h-[300px] flex-1","aria-label":"그래프 캔버스",children:(0,n.jsxs)(i.Gc,{nodes:y,edges:k,nodeTypes:ej,fitView:!0,onNodesChange:e=>{let t=new Set(e.filter(e=>"remove"===e.type).map(e=>e.id));s(r=>r.filter(e=>!t.has(e.id)).map(t=>{let r=e.find(e=>"position"===e.type&&e.id===t.id);return(null==r?void 0:r.type)==="position"&&r.position?{...t,...r.position}:t})),t.size&&d(e=>e.filter(e=>!t.has(e.from)&&!t.has(e.to)))},onEdgesChange:e=>{let t=new Set(e.filter(e=>"remove"===e.type).map(e=>e.id));t.size&&d(e=>e.filter(e=>!t.has("".concat(e.from,":").concat(e.to))))},onConnect:e=>{let t=o.find(t=>t.id===e.source),r=o.find(t=>t.id===e.target);t&&r&&t.id!==r.id&&t.graph===r.graph&&d(e=>e.some(e=>e.from===t.id&&e.to===r.id)?e:[...e,{from:t.id,to:r.id}])},children:[(0,n.jsx)(i.VS,{}),(0,n.jsx)(i.H2,{})]})})]})}function eN(e){var t;let{context:r,client:o}=e,[s,l]=(0,a.useState)(null),[i,d]=(0,a.useState)(""),[u,c]=(0,a.useState)("view"),[p,m]=(0,a.useState)(!1),f=r&&(t=r).saved&&t.graphId.trim()?t.graphId:null;async function x(){if(f&&i.trim()&&!p){m(!0),l(null);try{await U(o,f,i.trim(),u),l("".concat("edit"===u?"편집":"보기"," 권한을 부여하고 서버에서 확인했습니다."))}catch(e){l("권한 설정 실패: ".concat(e instanceof Error?e.message:String(e)))}finally{m(!1)}}}return(0,a.useEffect)(()=>{l(null),d("")},[f]),(0,n.jsxs)("div",{className:"ml-auto flex flex-wrap items-center gap-2",children:[(0,n.jsxs)("label",{children:["공유용 그래프 토큰 ",(0,n.jsx)("input",{"aria-label":"공유용 그래프 토큰",autoComplete:"off",value:i,onChange:e=>{d(e.target.value),l(null)},className:"rounded border border-border px-2 py-1"})]}),(0,n.jsx)("button",{type:"button",onClick:()=>{d("eg_".concat(Array.from(crypto.getRandomValues(new Uint8Array(24)),e=>e.toString(16).padStart(2,"0")).join(""))),l(null)},className:"rounded border border-border px-2 py-1",children:"새 토큰 만들기"}),(0,n.jsx)("span",{children:"권한 설정 뒤 이 토큰과 그래프 ID를 상대에게 전달하세요. 상대는 Nexus 연결 토큰으로 이 값을 사용해 해당 그래프 API에 접근합니다. 목록\xb7실행은 공유되지 않습니다."}),(0,n.jsxs)("label",{children:["권한 ",(0,n.jsxs)("select",{"aria-label":"공유 권한",value:u,onChange:e=>{c(e.target.value),l(null)},children:[(0,n.jsx)("option",{value:"view",children:"보기"}),(0,n.jsx)("option",{value:"edit",children:"편집"})]})]}),"edit"===u&&(0,n.jsx)("span",{role:"note",className:"font-semibold text-red-700 dark:text-red-400",children:"상대가 바꾼 그래프를 실행하면 상대 명령이 이 기계에서 돈다 — 실행 전 승인 필요"}),(0,n.jsx)("button",{type:"button",onClick:()=>{x()},disabled:!f||!i.trim()||p,title:f?"그래프 접근 권한을 설정합니다":"저장 안 된 변경은 공유할 수 없습니다. 먼저 저장하세요",className:"rounded border border-border px-2 py-1 disabled:opacity-50",children:"권한 설정"}),s&&(0,n.jsx)("span",{role:"status",children:s})]})}function eS(){let e=(0,c.Qj)();return e?(0,n.jsx)(eC,{client:e}):(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,n.jsx)("header",{className:"border-b border-border px-4 py-2",children:(0,n.jsx)("h1",{className:"text-sm font-semibold",children:"편집기"})}),(0,n.jsx)("p",{className:"p-4 text-sm text-text-tertiary",children:"Daemon 연결이 설정되지 않았습니다. Settings 에서 Base URL 을 입력하세요."})]})}function eC(e){var t,r,i,d,u;let{client:c}=e,m=(0,l.useSearchParams)(),h="harness"===(null!=(i=null==m?void 0:m.get("mode"))?i:null)?"harness":"workflow",[b,v]=(0,a.useState)(h),[y,k]=(0,a.useState)(()=>(null==m?void 0:m.get("mode"))!=null);(0,a.useEffect)(()=>{v(h)},[h]);let j=(0,a.useCallback)(e=>{v(e),window.history.replaceState(null,"",function(e){let t=f.find(t=>t.graph===e);return"/app/editor/?mode=".concat(t.graph)}(e))},[]),w=(0,o.jE)(),[N,C]=(0,a.useState)(null),[I,E]=(0,a.useState)(null),[R,_]=(0,a.useState)(void 0),[z,A]=(0,a.useState)(""),M=(0,s.I)({queryKey:["graph-wizard-packs"],queryFn:()=>c.getGraphWizardPacks(),enabled:"harness"===b&&!!c.getGraphWizardPacks,retry:!1}),D=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2600,[t,r]=(0,a.useState)(void 0),[n,o]=(0,a.useState)(void 0),[s,l]=(0,a.useState)({}),[i,d]=(0,a.useState)(void 0),u=(0,a.useRef)(null),c=(0,a.useRef)(0),p=(0,a.useRef)(null),m=(0,a.useRef)(!1),f=(0,a.useCallback)(e=>{u.current=e,m.current&&(p.current=e.graph,m.current=!1)},[]),x=(0,a.useCallback)(()=>p.current,[]),g=(0,a.useCallback)(()=>u.current?{graph:u.current.graph,yaml:u.current.yaml}:null,[]),h=(0,a.useCallback)(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],a=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;d(s&&Object.keys(s).length?s:void 0),a&&Object.keys(a).length&&l(e=>({...e,...a})),c.current+=1,m.current=!0,r({rev:c.current,graph:e,...n?{autoLayout:n}:{}}),o(t)},[]),b=(0,a.useCallback)((e,t)=>{var n,a;d(t&&Object.keys(t).length?t:void 0),c.current+=1,m.current=!0,r({rev:c.current,graph:null!=e?e:S(null!=(a=null==(n=u.current)?void 0:n.graphId)?a:"")}),o(void 0)},[]),v=(0,a.useCallback)(()=>{u.current=null,p.current=null,m.current=!1,r(void 0),o(void 0),l({}),d(void 0)},[]);return(0,a.useEffect)(()=>{if(!n)return;let t=setTimeout(()=>o(void 0),e);return()=>clearTimeout(t)},[n,e]),{replace:t,highlight:n,labels:s,steps:i,onChange:f,current:g,laid:x,apply:h,restore:b,reset:v}}(),[O,P]=(0,a.useState)(!1),G=(0,a.useCallback)(e=>{D.reset(),P(!!e.wizardPrompt),E(null),C({key:Date.now(),...e})},[D.reset]),T=null!=(d=null==m?void 0:m.get("wizard"))?d:null,F=(0,a.useRef)(null);(0,a.useEffect)(()=>{"harness"===b&&T&&F.current!==T&&(F.current=T,k(!0),G({saved:!1,wizardPrompt:T}))},[b,T,G]);let L=(0,a.useCallback)(e=>_(e),[]),B=(0,s.I)({queryKey:["graph-kinds","workflow"],queryFn:()=>c.getGraphKinds("workflow"),retry:!1}),K=(0,s.I)({queryKey:["graph-kinds","harness"],queryFn:()=>c.getGraphKinds("harness"),retry:!1}),U=(0,a.useMemo)(()=>{var e,t,r,n,a;return a=[...null!=(r=null==(e=B.data)?void 0:e.kinds)?r:[],...null!=(n=null==(t=K.data)?void 0:t.kinds)?n:[]],f.map(e=>{let{graph:t,label:r,fallbackKinds:n}=e,o=a.filter(e=>e.graph===t);return{graph:t,label:r,kinds:o.length?o:n.map(e=>({graph:t,kind:e,plugin:null,description:"",schema:{},core:!0})),fallback:0===o.length}})},[B.data,K.data]),Y=U.find(e=>e.graph===b).kinds,Z=U.find(e=>e.graph===b).fallback,q=e=>{e!==b&&(C(null),E(null),_(void 0),j(e)),k(!0)},W=(0,a.useCallback)(e=>{D.onChange(e),E(e)},[D.onChange]);return(0,n.jsxs)("div",{className:"flex h-full min-h-0 flex-col",children:[(0,n.jsxs)("header",{className:"flex items-center gap-3 border-b border-border px-4 py-2",children:[(0,n.jsx)("h1",{className:"text-sm font-semibold",children:"편집기"}),(0,n.jsx)("button",{type:"button","aria-pressed":!y,onClick:()=>{var e;k(!1),null==(e=window.history)||e.replaceState(null,"","/app/editor/")},children:"통합 캔버스"}),(0,n.jsx)("button",{type:"button","aria-pressed":y&&"workflow"===b,onClick:()=>q("workflow"),children:"워크플로 목록"}),(0,n.jsx)("button",{type:"button","aria-pressed":y&&"harness"===b,onClick:()=>q("harness"),children:"실행 그래프 목록"})]}),(0,n.jsx)("div",{className:y?"hidden":"flex min-h-0 flex-1 flex-col",children:(0,n.jsx)(ew,{groups:U,client:c})}),y&&(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[!("harness"===b&&N)&&(0,n.jsx)(eb,{onStart:e=>{j("harness"),G({saved:!1,wizardPrompt:e})}}),"workflow"===b?(0,n.jsx)(x.N,{palette:Y}):N?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-1.5 text-xs",children:[(0,n.jsx)("button",{type:"button",onClick:()=>{C(null),E(null),_(void 0)},children:"← 그래프 목록"}),(0,n.jsx)(eN,{context:I,client:c},N.key),Z&&(0,n.jsx)("span",{role:"status",children:"어휘 목록을 불러오지 못해 코어 팔레트를 씁니다."})]}),(0,n.jsxs)("div",{className:"border-b border-border px-3 py-2 text-xs",children:[(0,n.jsx)("label",{htmlFor:"knowledge-pack",children:"지식(RAG) 노드 \xb7 설치된 팩"}),(0,n.jsxs)("select",{id:"knowledge-pack",value:z,onChange:e=>A(e.target.value),className:"ml-2 rounded border border-border bg-background px-2 py-1",children:[(0,n.jsx)("option",{value:"",children:"팩 사용 안 함"}),(null!=(u=null==(t=M.data)?void 0:t.packs)?u:[]).map(e=>(0,n.jsxs)("option",{value:e.id,children:[e.title," (",e.id,")"]},e.id))]}),M.isError&&(0,n.jsx)("span",{role:"status",children:"설치된 팩을 불러오지 못했습니다."})]}),(0,n.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col lg:flex-row",children:[(0,n.jsx)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col max-lg:overflow-y-auto",children:(0,n.jsx)(er,{palette:Y,client:c,wizardMode:O,...N.graph?{initialGraph:N.graph,initialSaved:N.saved}:{},...R?{nodeStatus:R}:{},...D.replace?{replace:D.replace}:{},...D.highlight?{highlight:D.highlight}:{},nodeLabels:D.labels,...D.steps?{wizardSteps:D.steps}:{},onChange:W,installedPacks:null==(r=M.data)?void 0:r.packs,onKnowledgePackChange:A,renderActions:e=>(0,n.jsx)(ed,{context:e,client:c,onStatus:L}),onSaved:()=>{w.invalidateQueries({queryKey:["run-graphs"]})}},N.key)}),(0,n.jsx)(eh,{client:function(e){let t=e.graphWizard;return t?{graphWizard:(e,r)=>t(e,r)}:{graphWizard:async()=>{throw new p.Iu(404,"/v1/graphs/wizard",null)}}}(c),current:D.current,laid:D.laid,...z?{packId:z}:{},onApply:(e,t,r,n,a)=>{P(!0),D.apply(e,t,r,n,a)},onRestore:D.restore,...N.wizardPrompt?{initialPrompt:N.wizardPrompt}:{}},N.key)]})]}):(0,n.jsx)(g.F,{palette:Y,onNewGraph:()=>G({saved:!1}),onOpenInCanvas:(e,t)=>G({graph:V(t),saved:!0})})]})]})}function eI(){return(0,n.jsx)(a.Suspense,{fallback:(0,n.jsx)("p",{className:"p-4 text-sm",children:"편집기를 불러오는 중…"}),children:(0,n.jsx)(eS,{})})}},56424:(e,t,r)=>{Promise.resolve().then(r.bind(r,29177))},87691:(e,t,r)=>{"use strict";r.d(t,{C:()=>d,DaemonProvider:()=>u,Q:()=>c});var n=r(17594),a=r(48082),o=r(87338),s=r(15249),l=r(47648),i=r(91659);let d=(0,a.createContext)(null);function u(e){let{children:t}=e,r={baseUrl:"",token:"",provider:""},[u,c]=(0,a.useState)(r),[p,m]=(0,a.useState)(""),[f]=(0,a.useState)(()=>new l.ki(r));(0,a.useEffect)(()=>{let e=(0,o.Fp)();c(e),f.updateConfig(e),m((0,s.oD)()),(0,i.cY)("webterm.provider.daemon.init",{baseUrl:e.baseUrl,hasToken:!!e.token})},[f]),(0,a.useEffect)(()=>{let e=e=>{if("elanous.daemon.token"===e.key||"elanous.nexus.baseUrl"===e.key){let t=(0,o.Fp)();f.updateConfig(t),c(t),(0,i.cY)("webterm.provider.daemon.config-cross-tab",{key:e.key,hasToken:!!t.token});return}"elanous.daemon.sessionId"===e.key&&e.newValue&&m(t=>t===e.newValue?t:((0,i.cY)("webterm.provider.daemon.session-cross-tab",{previous:t||"(empty)",next:e.newValue}),e.newValue))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[f]);let x=e=>{c(t=>{let r={...t,...e};return(0,o.Qc)(e),f.updateConfig(r),(0,i.cY)("webterm.provider.daemon.config-update",{keys:Object.keys(e)}),r})},g=e=>{m(e),localStorage.setItem("elanous.daemon.sessionId",e),(0,i.cY)("webterm.provider.daemon.session-set",{sessionId:e})},h=(0,a.useMemo)(()=>({config:u,setConfig:x,client:f,sessionId:p,setSessionId:g}),[u,f,p]);return(0,n.jsx)(d.Provider,{value:h,children:t})}function c(){let e=(0,a.useContext)(d);if(!e)throw Error("useDaemon must be used inside <DaemonProvider>");return e}}},e=>{e.O(0,[8997,7571,3727,5616,4055,3603,8073,3985,5892,7648,7307,5359,6955,597,4306,3702,7358],()=>e(e.s=56424)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[650],{13604:(e,t,r)=>{Promise.resolve().then(r.bind(r,37197))},15249:(e,t,r)=>{"use strict";r.d(t,{Zr:()=>l,f6:()=>s,oD:()=>a});let n="elanous.daemon.sessionId";function s(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"s-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function a(){let e=function(){let e=new URLSearchParams(window.location.search).get("session");return e?(localStorage.setItem(n,e),e):localStorage.getItem(n)}();if(e)return e;let t=s();return localStorage.setItem(n,t),t}function l(){let e=s();return localStorage.setItem(n,e),e}},37197:(e,t,r)=>{"use strict";r.r(t),r.d(t,{default:()=>m});var n=r(17594),s=r(48082),a=r(87691),l=r(39306);let o={report:"보고서",pdf:"PDF",video:"영상",image:"그림",text:"글",link:"링크"};function c(e,t){if(e.startsWith("/v1/exec-requests/".concat(encodeURIComponent(t),"/files/")))return{url:e,daemonFile:!0};try{let t=new URL(e);if(("https:"===t.protocol||"http:"===t.protocol)&&!t.username&&!t.password)return{url:t.href,daemonFile:!1}}catch(e){}return null}function i(e){let{client:t,id:r,result:a}=e,[l,i]=(0,s.useState)(""),[u,d]=(0,s.useState)(!1),[m,p]=(0,s.useState)(null),f=c(a.url,r),x=a.title||o[a.kind],h=(null==f?void 0:f.daemonFile)&&("video"===a.kind||"image"===a.kind);if((0,s.useEffect)(()=>{let e;if(!h||!f)return;let r=!0;return p(null),i(""),t.fetchResponse(f.url).then(async t=>{if(!t.ok)throw Error("HTTP ".concat(t.status));let n=await t.blob();r&&p(e=URL.createObjectURL(n))}).catch(()=>{r&&i("결과 파일을 열지 못했습니다. 다시 시도해 주세요.")}),()=>{r=!1,e&&URL.revokeObjectURL(e)}},[t,h,null==f?void 0:f.url]),!f)return null;async function b(){if(!(null==f?void 0:f.daemonFile)||u)return;let e="pdf"===a.kind?window.open("","_blank"):null;if("pdf"===a.kind&&!e)return void i("결과 파일을 열지 못했습니다. 다시 시도해 주세요.");e&&(e.opener=null),d(!0),i("");try{let n=await t.fetchResponse(f.url);if(!n.ok)throw Error("HTTP ".concat(n.status));let s=URL.createObjectURL(await n.blob());if(e)e.closed?URL.revokeObjectURL(s):(e.location.replace(s),setTimeout(()=>URL.revokeObjectURL(s),6e4));else{var r;let e=document.createElement("a");e.href=s,e.download=decodeURIComponent(null!=(r=f.url.split("/").at(-1))?r:x),document.body.appendChild(e),e.click(),e.remove(),setTimeout(()=>URL.revokeObjectURL(s),6e4)}}catch(t){null==e||e.close(),i("결과 파일을 열지 못했습니다. 다시 시도해 주세요.")}finally{d(!1)}}return(0,n.jsxs)("li",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm",children:[h?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{className:"font-medium",children:x}),m&&("video"===a.kind?(0,n.jsx)("video",{controls:!0,src:m,"aria-label":x,className:"mt-2 max-w-full"}):(0,n.jsx)("img",{src:m,alt:x,className:"mt-2 max-w-full"}))]}):f.daemonFile?(0,n.jsx)("button",{type:"button",onClick:()=>void b(),disabled:u,className:"font-medium text-primary underline underline-offset-4 disabled:opacity-50",children:u?"여는 중…":x}):(0,n.jsx)("a",{href:f.url,target:"_blank",rel:"noopener noreferrer",className:"font-medium text-primary underline underline-offset-4",children:x}),(0,n.jsxs)("span",{className:"ml-2 text-muted-foreground",children:[a.seat.toUpperCase()," \xb7 ",o[a.kind]]}),a.sources&&a.sources.length>0&&(0,n.jsx)("ul",{className:"mt-2 flex flex-wrap gap-2","aria-label":"출처",children:a.sources.slice(0,3).map((e,t)=>{let s=c(e.url,r);return s&&!s.daemonFile?(0,n.jsx)("li",{children:(0,n.jsx)("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline underline-offset-4",children:e.title})},"".concat(e.url,":").concat(t)):null})}),l&&(0,n.jsx)("p",{role:"alert",className:"mt-1 text-destructive",children:l})]})}function u(e){switch(e){case"planning":return"계획 중";case"running":return"진행 중";case"done":return"완료";case"failed":return"멈춤"}}function d(e){switch(e){case"waiting":return"대기";case"running":return"진행 중";case"done":return"완료";case"failed":return"못 함"}}function m(){var e,t,r,o;let{client:c}=(0,a.Q)(),[m,p]=(0,s.useState)(""),[f,x]=(0,s.useState)(!1),[h,b]=(0,s.useState)([]),[g,y]=(0,s.useState)(!1),[v,j]=(0,s.useState)(""),[N,w]=(0,s.useState)(""),[k,R]=(0,s.useState)(null),[S,U]=(0,s.useState)(null),[C,I]=(0,s.useState)(""),[E,L]=(0,s.useState)(0),[O,P]=(0,s.useState)(null),D=(0,s.useRef)(new Map),F=(0,s.useRef)(0),T=(0,s.useRef)(k);T.current=k;let _=(0,s.useRef)(null),H=(0,s.useRef)(0),M=h.some(e=>"planning"===e.status||"running"===e.status),q=null==(e=h.find(e=>e.id===k))?void 0:e.status,Y=(null==S?void 0:S.id)===k&&(null===O?S.approvals.length>0:O>0);(0,s.useEffect)(()=>{var e,t;return F.current+=1,H.current+=1,_.current=null,D.current=new Map,p(""),x(!1),b([]),y(!1),j(""),w(""),R(new URLSearchParams(null!=(t=null==(e=window.location)?void 0:e.search)?t:"").get("request")),U(null),I(""),P(null),()=>{F.current+=1}},[c]),(0,s.useEffect)(()=>{let e=!0,t=!1;async function r(){if(!t){t=!0;try{let t=await c.listExecRequests();if(!e)return;for(let e of t.items)D.current.delete(e.id);b([...D.current.values(),...t.items].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||t.id.localeCompare(e.id))),j("")}catch(t){e&&j("맡긴 일을 읽지 못했습니다. 연결을 확인해 주세요.")}finally{t=!1,e&&y(!0)}}}r();let n=M?setInterval(()=>void r(),5e3):null;return()=>{e=!1,n&&clearInterval(n)}},[c,M]);let A=(0,s.useCallback)(async()=>{if(!k)return;let e=F.current,t=H.current,r="".concat(e,":").concat(t,":").concat(k);if(_.current!==r){_.current=r;try{let r=await c.getExecRequest(k);if(F.current!==e||H.current!==t||T.current!==k)return;U(r),I("")}catch(r){F.current===e&&H.current===t&&T.current===k&&I("상세를 읽지 못했습니다. 잠시 뒤 다시 시도해 주세요.")}finally{_.current===r&&(_.current=null)}}},[c,k]);async function V(e){e.preventDefault();let t=m.trim();if(!t||f)return;let r=F.current;x(!0),w("");try{let e=await c.submitExecRequest(t);if(F.current!==r)return;let n={id:e.id,text:t,createdAt:new Date().toISOString(),status:e.status,seats:[],resultCount:0};D.current.set(n.id,n),b(e=>[n,...e.filter(e=>e.id!==n.id)]),p("")}catch(e){F.current===r&&w("보내지 못했습니다. 연결을 확인하고 다시 시도해 주세요.")}finally{F.current===r&&x(!1)}}(0,s.useEffect)(()=>{k&&A()},[A,E]),(0,s.useEffect)(()=>{if(!k||"planning"!==q&&"running"!==q&&!Y)return;let e=setInterval(()=>void A(),5e3);return()=>clearInterval(e)},[k,q,Y,A]);let z=h.find(e=>e.id===k),J=(null==S?void 0:S.id)===k?S:null;return(0,n.jsxs)("main",{className:"mx-auto w-full max-w-2xl space-y-8 px-5 py-10 sm:py-14",children:[(0,n.jsxs)("section",{"aria-labelledby":"exec-compose",className:"space-y-4",children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("h1",{id:"exec-compose",className:"text-2xl font-semibold tracking-tight",children:"COO 에게 맡기기"}),(0,n.jsx)("p",{className:"mt-2 text-sm text-muted-foreground",children:"할 일을 한 줄로 적어 보내세요. 자리별 진행과 결과를 여기서 볼 수 있습니다."})]}),(0,n.jsxs)("form",{onSubmit:V,className:"flex gap-2",children:[(0,n.jsx)("label",{htmlFor:"exec-text",className:"sr-only",children:"한 줄로 맡길 일"}),(0,n.jsx)("input",{id:"exec-text",name:"text",value:m,onChange:e=>p(e.target.value),placeholder:"한 줄로 맡길 일",className:"min-w-0 flex-1 rounded-lg border border-input bg-background px-3 py-2 text-sm"}),(0,n.jsx)("button",{type:"submit",disabled:!m.trim()||f,className:"rounded-lg bg-primary px-4 py-2 text-sm font-medium text-primary-foreground disabled:opacity-50",children:f?"보내는 중…":"보내기"})]}),N&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:N})]}),(0,n.jsxs)("section",{"aria-labelledby":"exec-list",className:"space-y-3",children:[(0,n.jsx)("h2",{id:"exec-list",className:"text-xl font-semibold",children:"맡긴 일"}),v&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:v}),!g&&0===h.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"불러오는 중…"}),g&&0===h.length&&!v&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"아직 맡긴 일이 없습니다."}),(0,n.jsx)("ul",{className:"space-y-2",children:h.map(e=>{var t;return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button",onClick:()=>{k!==e.id&&(H.current+=1,R(e.id),U(null),I(""),P(null))},"aria-expanded":k===e.id,className:"w-full rounded-xl border border-border bg-card p-4 text-left hover:border-primary focus-visible:outline focus-visible:outline-2 focus-visible:outline-primary",children:[(0,n.jsxs)("span",{className:"flex items-start justify-between gap-3",children:[(0,n.jsx)("span",{className:"min-w-0 truncate text-sm font-semibold",children:null!=(t=e.text.trim().split(/\r?\n/,1)[0])?t:""}),(0,n.jsx)("span",{className:"shrink-0 text-sm font-medium text-primary",children:u(e.status)})]}),e.seats.length>0&&(0,n.jsx)("span",{className:"mt-2 block truncate text-xs text-muted-foreground",children:e.seats.map(e=>"".concat(e.seat.toUpperCase()," ").concat(d(e.status))).join(" \xb7 ")}),e.resultCount>0&&(0,n.jsxs)("span",{className:"mt-1 block text-xs text-muted-foreground",children:["결과 ",e.resultCount,"개"]})]})},e.id)})})]}),k&&(0,n.jsxs)("section",{"aria-labelledby":"exec-detail",className:"space-y-5 rounded-xl border border-border bg-card p-5",children:[(0,n.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,n.jsx)("h2",{id:"exec-detail",className:"text-lg font-semibold",children:"맡긴 일 상세"}),(0,n.jsx)("button",{type:"button",onClick:()=>{H.current+=1,R(null),U(null),P(null)},className:"text-sm text-primary underline underline-offset-4",children:"닫기"})]}),(0,n.jsx)("p",{className:"whitespace-pre-wrap text-sm",children:null!=(t=null==J?void 0:J.text)?t:null==z?void 0:z.text}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:u(null!=(o=null!=(r=null==J?void 0:J.status)?r:null==z?void 0:z.status)?o:"planning")}),C&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:C}),!J&&!C&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"상세 불러오는 중…"}),J&&(0,n.jsxs)(n.Fragment,{children:[J.summary&&(0,n.jsx)("p",{className:"text-sm",children:J.summary}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"font-semibold",children:"이렇게 나눠 맡겼습니다"}),0===J.seats.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"planning"===J.status?"COO 가 나누는 중입니다":"맡은 자리가 없습니다"}),(0,n.jsx)("ul",{className:"space-y-2",children:J.seats.map(e=>(0,n.jsxs)("li",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm",children:[(0,n.jsxs)("div",{className:"flex justify-between gap-2",children:[(0,n.jsxs)("span",{className:"font-semibold",children:[e.seat.toUpperCase()," \xb7 ",e.title]}),(0,n.jsx)("span",{className:"shrink-0 text-muted-foreground",children:d(e.status)})]}),"failed"===e.status&&e.reason&&(0,n.jsxs)("p",{className:"mt-2 text-destructive",children:["못 한 이유 \xb7 ",e.reason]})]},"".concat(e.seat,":").concat(e.title)))})]}),(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"font-semibold",children:"결과"}),0===J.results.length&&(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"아직 결과가 없습니다."}),(0,n.jsx)("ul",{className:"space-y-2",children:J.results.map(e=>(0,n.jsx)(i,{client:c,id:J.id,result:e},e.url))})]}),(0,n.jsx)(l.a,{client:c,approvals:J.approvals,onDecided:()=>L(e=>e+1),onPendingChange:P},J.id)]})]})]})}},37664:(e,t,r)=>{"use strict";function n(e){return{slides:e.slides.map(e=>{let{image:t,caption:r,include:n}=e;return{image:t,caption:r,include:n}}),caption:{hook:e.caption.hook,body:e.caption.body},hashtags:[...e.hashtags],cover:{text:e.cover.text,sub:e.cover.sub},location:e.location}}r.d(t,{$Y:()=>l,LP:()=>c,Mz:()=>n,ll:()=>u,rH:()=>o});class s extends Error{constructor(e,t){super(t),this.status=e,this.name="GraphApprovalsApiError"}}let a={list:"목록을 보려면",decide:"승인하려면",save:"초안을 저장하려면"},l="/app/settings/#bearer-token";function o(e){return e instanceof s&&(401===e.status||403===e.status)}function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"decide";return e instanceof s?401===e.status||403===e.status?"".concat(a[t]," 이 기기를 데몬에 연결해야 합니다 — 설정 › 데몬 연결 › 연결 토큰 칸에 토큰을 넣어 주세요."):404===e.status?"이 실행을 찾지 못했습니다. 목록을 다시 확인해 주세요.":409===e.status?"이미 결정된 실행입니다. 목록을 다시 확인해 주세요.":400===e.status?"결정 내용을 확인한 뒤 다시 시도해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요.":e instanceof TypeError?"서버에 연결하지 못했습니다. 연결 상태를 확인해 주세요.":"승인 요청을 처리하지 못했습니다. 잠시 뒤 다시 시도해 주세요."}let i="/v1/graph-approvals";function u(e){var t,r;let n=(null!=(t=e.baseUrl)?t:"").replace(/\/+$/,""),a=null!=(r=e.fetchImpl)?r:fetch;async function l(t,r){let l={...r,headers:{"content-type":"application/json",...e.authHeader?{authorization:e.authHeader}:{}}},o=e.client?await e.client.fetchResponse(t,l):await a("".concat(n).concat(t),l),c=await o.json().catch(()=>null);if(!o.ok){let e=c&&"object"==typeof c&&"error"in c&&"string"==typeof c.error?c.error:"request-failed";throw new s(o.status,e)}return c}return{list:()=>l(i),decide:(e,t,r)=>l("".concat(i,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t)),{method:"POST",body:JSON.stringify({decision:r})}),saveFeedDraft:(e,t,r)=>l("".concat(i,"/").concat(encodeURIComponent(e),"/").concat(encodeURIComponent(t),"/feed-draft"),{method:"PUT",body:JSON.stringify(r)}),feedMedia:async(t,r,l)=>{let o="".concat(i,"/").concat(encodeURIComponent(t),"/").concat(encodeURIComponent(r),"/media?path=").concat(encodeURIComponent(l)),c={headers:e.authHeader?{authorization:e.authHeader}:{}},u=e.client?await e.client.fetchResponse(o,c):await a("".concat(n).concat(o),c);if(!u.ok)throw new s(u.status,"media-failed");return u.blob()}}}},39306:(e,t,r)=>{"use strict";r.d(t,{a:()=>o});var n=r(17594),s=r(48082),a=r(37664);let l=e=>JSON.stringify([e.graphId,e.runId]);function o(e){let{client:t,approvals:r,onDecided:o,onPendingChange:c}=e,i=(0,s.useMemo)(()=>(0,a.ll)({client:t}),[t]),[u,d]=(0,s.useState)([]),[m,p]=(0,s.useState)({}),[f,x]=(0,s.useState)(null),[h,b]=(0,s.useState)(""),g=(0,s.useRef)(0),y=r.map(l).join("|");function v(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:m;d(e),c(r.filter(r=>!t[l(r)]&&e.some(e=>l(e)===l(r))).length)}async function j(e,t){let n=l(e);if(f||m[n]||!r.some(e=>l(e)===n)||!u.some(e=>l(e)===n))return;let s=g.current;x(n),b("");try{if(await i.decide(e.graphId,e.runId,t),g.current!==s)return;let r={...m,[n]:t};p(r),v(u,r),o();let a=await i.list();g.current===s&&v(a.items,r)}catch(e){g.current===s&&b((0,a.LP)(e,"decide"))}finally{g.current===s&&x(null)}}return((0,s.useEffect)(()=>{let e=++g.current;return(d([]),b(""),y)?(i.list().then(t=>{g.current===e&&v(t.items)}).catch(t=>{g.current===e&&b((0,a.LP)(t,"list"))}),()=>{g.current+=1}):(c(0),()=>{g.current+=1})},[i,y]),0===r.length)?null:(0,n.jsxs)("div",{className:"space-y-2",children:[(0,n.jsx)("h3",{className:"font-semibold",children:"게시 승인"}),h&&(0,n.jsx)("p",{role:"alert",className:"text-sm text-destructive",children:h}),(0,n.jsx)("ul",{className:"space-y-2",children:r.map(e=>{let t=l(e),r=u.some(e=>l(e)===t);return(0,n.jsxs)("li",{className:"rounded-lg border border-border bg-background px-4 py-3 text-sm",children:[(0,n.jsx)("p",{children:e.message}),m[t]?(0,n.jsx)("p",{className:"mt-2 text-muted-foreground",children:"approved"===m[t]?"승인됨":"보류됨"}):r?(0,n.jsxs)("div",{className:"mt-2 flex gap-2",children:[(0,n.jsx)("button",{type:"button",disabled:null!==f,onClick:()=>void j(e,"approved"),className:"rounded-lg bg-primary px-3 py-1 text-primary-foreground disabled:opacity-50",children:"승인"}),(0,n.jsx)("button",{type:"button",disabled:null!==f,onClick:()=>void j(e,"rejected"),className:"rounded-lg border border-border px-3 py-1 disabled:opacity-50",children:"보류"})]}):(0,n.jsx)("p",{className:"mt-2 text-muted-foreground",children:"대기 중인 승인이 아닙니다."})]},t)})})]})}},87691:(e,t,r)=>{"use strict";r.d(t,{C:()=>i,DaemonProvider:()=>u,Q:()=>d});var n=r(17594),s=r(48082),a=r(87338),l=r(15249),o=r(47648),c=r(91659);let i=(0,s.createContext)(null);function u(e){let{children:t}=e,r={baseUrl:"",token:"",provider:""},[u,d]=(0,s.useState)(r),[m,p]=(0,s.useState)(""),[f]=(0,s.useState)(()=>new o.ki(r));(0,s.useEffect)(()=>{let e=(0,a.Fp)();d(e),f.updateConfig(e),p((0,l.oD)()),(0,c.cY)("webterm.provider.daemon.init",{baseUrl:e.baseUrl,hasToken:!!e.token})},[f]),(0,s.useEffect)(()=>{let e=e=>{if("elanous.daemon.token"===e.key||"elanous.nexus.baseUrl"===e.key){let t=(0,a.Fp)();f.updateConfig(t),d(t),(0,c.cY)("webterm.provider.daemon.config-cross-tab",{key:e.key,hasToken:!!t.token});return}"elanous.daemon.sessionId"===e.key&&e.newValue&&p(t=>t===e.newValue?t:((0,c.cY)("webterm.provider.daemon.session-cross-tab",{previous:t||"(empty)",next:e.newValue}),e.newValue))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[f]);let x=e=>{d(t=>{let r={...t,...e};return(0,a.Qc)(e),f.updateConfig(r),(0,c.cY)("webterm.provider.daemon.config-update",{keys:Object.keys(e)}),r})},h=e=>{p(e),localStorage.setItem("elanous.daemon.sessionId",e),(0,c.cY)("webterm.provider.daemon.session-set",{sessionId:e})},b=(0,s.useMemo)(()=>({config:u,setConfig:x,client:f,sessionId:m,setSessionId:h}),[u,f,m]);return(0,n.jsx)(i.Provider,{value:b,children:t})}function d(){let e=(0,s.useContext)(i);if(!e)throw Error("useDaemon must be used inside <DaemonProvider>");return e}}},e=>{e.O(0,[7648,4306,3702,7358],()=>e(e.s=13604)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8891],{11247:(e,t,n)=>{Promise.resolve().then(n.bind(n,37473))},37473:(e,t,n)=>{"use strict";n.d(t,{InsidePage:()=>W});var s=n(17594),r=n(48082),a=n(96545),l=n(87534);let i=[{id:"loop-agent",title:"루프 에이전트",oneLine:"일을 반복 관측하고 다음 행동을 고릅니다.",docs:["docs/manual/MANUAL-execution-and-landing-loops-2026-09-29.md"],code:["src/harness/mission-solve-loop.ts","src/mission-loop/composite-cycle.ts"]},{id:"graph-engineering",title:"그래프 엔지니어링",oneLine:"실행의 노드와 경로를 그래프로 읽습니다.",docs:["docs/manual/MANUAL-graph-operations-2026-09-10.md"],code:["src/self-implement/graph-templates.ts","src/self-implement/graph-authority.ts"]},{id:"pty-intelligence",title:"PTY 인텔리전스",oneLine:"에이전트가 터미널의 실행과 관측을 연결합니다.",docs:["docs/manual/MANUAL-external-agent-pty-missions-2026-08-11.md"],code:["src/self-dev/dev-cli.ts"]},{id:"harness",title:"받침 \xb7 하니스",oneLine:"구현과 검증이 지나가는 실행 받침입니다.",docs:["docs/TECH-harness-execution-anatomy-current-state-2026-08-10.md"],code:["src/self-implement/orchestrator.ts","src/self-dev/dev-cli.ts"]},{id:"mission-fabric",title:"미션 패브릭",oneLine:"들어온 일을 미션으로 정하고 실행에 잇습니다.",docs:["docs/manual/MANUAL-mission-fabric-integration-2026-09-03.md"],code:["src/mission-loop/composite-cycle.ts","src/harness/mission-solve-loop.ts"]},{id:"observation",title:"바닥 \xb7 관측\xb7인지\xb7힐링",oneLine:"본 것을 이해하고 스스로 고치는 바닥입니다.",docs:["docs/manual/MANUAL-self-cognition-observability-2026-07-14.md"],code:["src/self-implement/orchestrator.ts"]}];var o=n(71029);function d(e){let{entry:t}=e,[n,a]=(0,r.useState)(!1);return(0,s.jsxs)("details",{open:n,style:{minWidth:0,border:"1px solid #68788f",borderRadius:12,padding:18,background:"#16263b"},children:[(0,s.jsx)("summary",{onClick:e=>{e.preventDefault(),a(e=>!e)},style:{cursor:"pointer",fontWeight:700,overflowWrap:"anywhere"},children:(0,o.t)(t.title)}),(0,s.jsx)("p",{children:(0,o.t)(t.oneLine)}),(0,s.jsxs)("div",{children:[(0,s.jsx)("strong",{children:"문서"}),(0,s.jsx)("ul",{children:t.docs.map(e=>(0,s.jsx)("li",{style:{overflowWrap:"anywhere"},children:(0,o.t)(e)},e))}),(0,s.jsx)("strong",{children:"코드"}),(0,s.jsx)("ul",{children:t.code.map(e=>(0,s.jsx)("li",{style:{overflowWrap:"anywhere"},children:(0,o.t)(e)},e))})]})]})}function c(){return(0,s.jsxs)("div",{"data-architecture-scene":!0,style:{width:"100%",maxWidth:1600,margin:"auto",display:"grid",gap:20,fontSize:18},children:[(0,s.jsx)("h2",{style:{fontSize:28,margin:0},children:"엘라누스의 구조"}),(0,s.jsx)("div",{"aria-label":"메인",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 240px), 1fr))",gap:16},children:i.slice(0,2).map(e=>(0,s.jsx)(d,{entry:e},e.id))}),(0,s.jsx)("div",{"aria-label":"받침",style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(min(100%, 240px), 1fr))",gap:16},children:i.slice(2,4).map(e=>(0,s.jsx)(d,{entry:e},e.id))}),(0,s.jsx)("div",{"aria-label":"실행 이음",style:{width:"100%",maxWidth:480,justifySelf:"center"},children:(0,s.jsx)(d,{entry:i[4]})}),(0,s.jsx)("div",{"aria-label":"바닥",children:(0,s.jsx)(d,{entry:i[5]})})]})}var u=n(87691),p=n(50750);let m={currentMissionId:null,missions:{}},f=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),h=e=>"string"==typeof e&&e.trim().length>0;function g(e){let t=e;if("string"==typeof t)try{t=JSON.parse(t)}catch(e){return null}if(!t||"object"!=typeof t||Array.isArray(t))return null;let n=t;if("wizard.step"!==n.category||"wizard.step"!==n.event||!n.data||"object"!=typeof n.data||Array.isArray(n.data))return null;let s=n.data;return"string"==typeof s.ts&&Number.isFinite(Date.parse(s.ts))&&"string"==typeof s.wizardId&&s.wizardId&&["request","research","draft","validate","install","done"].includes(s.step)&&"string"==typeof s.text?{ts:s.ts,wizardId:s.wizardId,step:s.step,text:s.text,...void 0===s.detail?{}:{detail:s.detail}}:null}function x(e,t){let n=e.logsStreamUrl({exactCategory:"wizard.step"});return n?(0,p.BX)(n,{events:{log:e=>{let n=g(e.data);n&&t(n)}}}):()=>{}}let y={currentRunId:null,runs:{}},b={start:"border-sky-400 bg-sky-500/15 text-sky-200",ok:"border-green-500 bg-green-500/15 text-green-300",fail:"border-red-500 bg-red-500/15 text-red-300"};function v(e){let{state:t,now:n,receivedAt:r,lastSettlement:a,lastActivityTs:l=null,activityStatus:i="loading",wizardSteps:d=[]}=e,c=t.currentRunId?t.runs[t.currentRunId]:null,u=!c||n-r>6e4,p=null==c?void 0:c.order.some(e=>"start"===c.nodes[e].phase),m=a&&!p&&n-a.receivedAt<15e3,f=a&&!p&&n-a.receivedAt>=15e3,h=c?Math.max(0,Math.floor((n-Date.parse(c.startedAt))/1e3)):0,g=c&&a?Math.max(0,Math.floor((Date.parse(a.ts)-Date.parse(c.startedAt))/1e3)):0,x=f?"fail"===a.phase?"실패 \xb7 ".concat(a.nodeId):"완료 \xb7 ".concat(g,"초"):null;return(0,s.jsxs)("section",{"aria-label":"라이브 트레이스",className:"min-w-0 space-y-6 p-6 text-lg leading-relaxed",children:[d.length>0&&(0,s.jsx)("ol",{"aria-label":"플러그인 마법사 흐름",children:d.map(e=>(0,s.jsxs)("li",{children:["마법사 ",e.step," \xb7 ",(0,o.t)(e.text)]},"".concat(e.wizardId,":").concat(e.step)))}),u?(0,s.jsxs)("div",{className:"space-y-4 text-muted-foreground",children:[(0,s.jsx)("p",{children:"지금 도는 런이 없습니다"}),(0,s.jsxs)("p",{role:"status",children:["마지막 활동: ",l&&Number.isFinite(Date.parse(l))?(0,s.jsxs)("time",{dateTime:l,children:[new Date(l).toLocaleString("ko-KR",{timeZone:"Asia/Seoul"})," KST"]}):"loading"===i?"확인 중":"unavailable"===i?"못 읽음":"기록 없음"]}),(0,s.jsx)("button",{type:"button",className:"rounded-lg border border-border px-5 py-3 text-lg",disabled:!0,children:"녹화 보기"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-x-5 gap-y-2 break-all text-lg",children:[(0,s.jsx)("h2",{className:"font-semibold",children:c.graphId}),(0,s.jsxs)("span",{children:["런 ",c.runId.slice(0,6)]}),(0,s.jsxs)("span",{children:["경과 ",h,"초"]}),x&&(0,s.jsx)("span",{role:"status",children:x})]}),(0,s.jsxs)("div",{role:"list","aria-label":"노드 흐름",className:"flex flex-wrap gap-3",children:[m&&(0,s.jsx)("span",{className:"rounded-lg border border-border bg-muted px-3 py-1 text-sm text-muted-foreground",children:"다음 단계 준비 중"}),c.order.map(e=>{let t=c.nodes[e];return(0,s.jsxs)("div",{role:"listitem",className:"min-w-0 max-w-full break-all rounded-lg border px-5 py-3 ".concat(b[t.phase]),children:[(0,s.jsxs)("span",{className:"start"===t.phase?"animate-pulse":"",children:[t.nodeId," \xb7 ","start"===t.phase?"진행 중":"ok"===t.phase?"ok":"fail"]}),t.retries>0&&(0,s.jsxs)("span",{className:"ml-3","aria-label":"다시 ".concat(t.retries,"회"),children:["↻",t.retries]})]},e)})]})]})]})}function w(){let{client:e,config:t}=(0,u.Q)(),[n,a]=(0,r.useState)(()=>({client:e,baseUrl:t.baseUrl,token:t.token,state:y,receivedAt:0,lastSettlement:null,lastActivityTs:null,activityStatus:"loading"})),[l,i]=(0,r.useState)(0),[o,d]=(0,r.useState)([]),c=n.client===e&&n.baseUrl===t.baseUrl&&n.token===t.token;return(0,r.useEffect)(()=>{let n=!0;a({client:e,baseUrl:t.baseUrl,token:t.token,state:y,receivedAt:0,lastSettlement:null,lastActivityTs:null,activityStatus:"loading"}),d([]),e.listLogs({category:"graph.run",event:"node",limit:"1"}).then(s=>{n&&a(n=>{var r,a;if(n.client!==e||n.baseUrl!==t.baseUrl||n.token!==t.token)return n;let l=null==(a=s.logs)||null==(r=a[0])?void 0:r.ts,i="string"==typeof l&&Number.isFinite(Date.parse(l))?l:null,o=i&&(!n.lastActivityTs||Date.parse(i)>Date.parse(n.lastActivityTs))?i:n.lastActivityTs;return{...n,lastActivityTs:o,activityStatus:s.ok&&Array.isArray(s.logs)?"ready":"unavailable"}})}).catch(()=>{n&&a(n=>n.client===e&&n.baseUrl===t.baseUrl&&n.token===t.token?{...n,activityStatus:"unavailable"}:n)});let s=x(e,e=>{n&&d(t=>"request"===e.step?[e]:[...t.filter(t=>t.wizardId===e.wizardId),e].slice(-6))}),r=function(e,t){let n=e.logsStreamUrl({category:"graph.run"});return n?(0,p.BX)(n,{events:{log:e=>{let n=function(e){let t=e;if("string"==typeof t)try{t=JSON.parse(t)}catch(e){return null}if("object"!=typeof t||null===t||Array.isArray(t))return null;let n=t;if("graph.run"!==n.category||"node"!==n.event)return null;let s=n.data;return"object"!=typeof s||null===s||Array.isArray(s)?null:["graphId","runId","nodeId"].every(e=>"string"==typeof s[e]&&s[e].trim().length>0)&&("start"===s.phase||"ok"===s.phase||"fail"===s.phase)&&"string"==typeof n.ts&&Number.isFinite(Date.parse(n.ts))&&(void 0===s.seconds||"number"==typeof s.seconds&&Number.isFinite(s.seconds)&&!(s.seconds<0))?{kind:"node",graphId:s.graphId,runId:s.runId,nodeId:s.nodeId,phase:s.phase,ts:n.ts,...void 0===s.seconds?{}:{seconds:s.seconds}}:null}(e.data);n&&t(n)}}}):()=>{}}(e,s=>{if(!n)return;let r=Date.now();a(a=>{var l,i;if(!n)return a;let o=a.client===e&&a.baseUrl===t.baseUrl&&a.token===t.token,d=o?a.state:y,c=d.currentRunId===s.runId&&"start"!==s.phase&&(null==(i=d.runs[s.runId])||null==(l=i.nodes[s.nodeId])?void 0:l.phase)===s.phase,u=d.currentRunId!==s.runId&&d.runs[s.runId]?a.lastSettlement:"start"===s.phase||d.currentRunId!==s.runId?null:c?a.lastSettlement:{receivedAt:r,nodeId:s.nodeId,phase:s.phase,ts:s.ts},p=!o||!a.lastActivityTs||Date.parse(s.ts)>Date.parse(a.lastActivityTs)?s.ts:a.lastActivityTs;return{client:e,baseUrl:t.baseUrl,token:t.token,receivedAt:r,lastSettlement:u,lastActivityTs:p,activityStatus:o?a.activityStatus:"loading",state:function(e,t){var n,s,r,a;let l=Object.hasOwn(e.runs,t.runId)?e.runs[t.runId]:void 0,i=l&&Object.hasOwn(l.nodes,t.nodeId)?l.nodes[t.nodeId]:void 0,o={nodeId:t.nodeId,phase:t.phase,retries:(null!=(n=null==i?void 0:i.retries)?n:0)+("start"===t.phase&&i?1:0)},d={graphId:t.graphId,runId:t.runId,startedAt:null!=(s=null==l?void 0:l.startedAt)?s:t.ts,order:i?l.order:[...null!=(r=null==l?void 0:l.order)?r:[],t.nodeId],nodes:{...null==l?void 0:l.nodes,[t.nodeId]:o}};return{currentRunId:l&&null!=(a=e.currentRunId)?a:t.runId,runs:{...e.runs,[t.runId]:d}}}(d,s)}}),i(r)}),l=setInterval(()=>i(Date.now()),1e3);return()=>{n=!1,r(),s(),clearInterval(l)}},[e,t.baseUrl,t.token]),(0,s.jsx)(v,{state:c?n.state:y,now:l,receivedAt:n.receivedAt,lastSettlement:c?n.lastSettlement:null,lastActivityTs:c?n.lastActivityTs:null,activityStatus:c?n.activityStatus:"loading",wizardSteps:c?o:[]})}var j=n(81998),k=n(3138),I=n(43755);let A=I.DN.map(e=>({graph:"harness",kind:e,plugin:null,description:"",schema:{},core:!0})),S=I.CF.map(e=>({graph:"workflow",kind:e,plugin:null,description:"",schema:{},core:!0}));function N(){let{GraphEditor:e=j.F,WorkflowEditor:t=k.N}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[n,a]=(0,r.useState)("harness");return(0,s.jsxs)("section",{"aria-label":"그래프 편집기",className:"flex h-full min-h-[640px] min-w-0 flex-col",children:[(0,s.jsx)("div",{role:"tablist","aria-label":"그래프 편집 모드",className:"flex shrink-0 gap-2 border-b border-border px-4 py-3",children:["harness","workflow"].map(e=>(0,s.jsx)("button",{type:"button",role:"tab",id:"inside-editor-tab-".concat(e),"aria-controls":"inside-editor-panel-".concat(e),"aria-selected":n===e,onClick:()=>a(e),className:"rounded-lg px-4 py-2 text-lg min-[1440px]:text-[22px] ".concat(n===e?"bg-accent/15 text-text-primary":"text-text-tertiary hover:bg-surface-elevated"),children:"harness"===e?"실행 그래프":"워크플로"},e))}),(0,s.jsx)("div",{id:"inside-editor-panel-harness",role:"tabpanel","aria-labelledby":"inside-editor-tab-harness",hidden:"harness"!==n,className:"harness"===n?"min-h-0 min-w-0 flex-1 overflow-x-auto":"hidden",children:(0,s.jsx)("div",{className:"flex h-full min-h-[640px] min-w-[700px] flex-col min-[700px]:min-w-0",children:(0,s.jsx)(e,{palette:A,initialGraphId:"self-implement"})})}),(0,s.jsx)("div",{id:"inside-editor-panel-workflow",role:"tabpanel","aria-labelledby":"inside-editor-tab-workflow",hidden:"workflow"!==n,className:"workflow"===n?"min-h-0 min-w-0 flex-1 overflow-x-auto":"hidden",children:(0,s.jsx)("div",{className:"flex h-full min-h-[640px] min-w-[700px] flex-col min-[700px]:min-w-0",children:(0,s.jsx)(t,{palette:S})})})]})}var T=n(99777);let D=/^\s*(승인|거부|반려|보류|허용|차단|중단|취소)(?=$|[\s.,!?;:])/;function z(e){let{decisions:t,now:n=Date.now()}=e,r=Object.values(t.missions).flat().filter(e=>"answer"===e.step).sort((e,t)=>Date.parse(t.ts)-Date.parse(e.ts)||t.seq-e.seq),a=r[0],l=a?Math.max(0,Math.floor((n-Date.parse(a.ts))/6e4)):null,i=r.flatMap(e=>{var t;let s=null==(t=D.exec(e.detail.answer))?void 0:t[1];return s&&n-Date.parse(e.ts)<3e5?[{item:e,outcome:s}]:[]});return(0,s.jsxs)("section",{"aria-label":"PTY 인텔리전스",className:"min-w-0 rounded-xl border border-slate-600 p-5 text-lg leading-relaxed min-[1440px]:text-[22px]",children:[(0,s.jsx)("h2",{className:"mb-5 font-semibold",children:"PTY 판단"}),0===i.length?(0,s.jsxs)("p",{role:"status",children:["지금 PTY 판단이 없습니다 — 마지막 판단 ",null===l?"기록 없음":"".concat(l,"분 전")]}):(0,s.jsx)("ol",{"aria-label":"최근 PTY 판단",className:"space-y-4",children:i.slice(0,3).map(e=>{let{item:t,outcome:n}=e;return(0,s.jsxs)("li",{className:"min-w-0 rounded-lg border border-slate-600 p-4",children:[(0,s.jsx)("time",{dateTime:t.ts,children:(0,o.t)(t.ts)})," \xb7 ",(0,o.t)(n)]},"".concat(t.missionId,":").concat(t.seq))})})]})}let U=[{step:"request",label:"요청"},{step:"research",label:"조사"},{step:"draft",label:"초안"},{step:"validate",label:"검증"},{step:"install",label:"설치"},{step:"done",label:"끝"}],C={done:"border-green-500 bg-green-500/15 text-green-300",now:"border-sky-400 bg-sky-500/15 text-sky-200",todo:"border-slate-500 bg-slate-500/15 text-slate-300",failed:"border-red-500 bg-red-500/15 text-red-300"},E={done:"완료",now:"진행 중",todo:"대기",failed:"실패"};function L(e){let{events:t}=e,n=function(e){if(0===e.length)return[];let t=e.map((e,t)=>({event:e,order:t,time:function(e){let t=Date.parse(e);return Number.isFinite(t)?t:-1/0}(e.ts)})).sort((e,t)=>e.time-t.time||e.order-t.order),n=t[t.length-1].event.wizardId,s=t.filter(e=>e.event.wizardId===n),r=s[s.length-1].event,a=U.findIndex(e=>e.step===r.step);return U.map((e,t)=>{var n;let{step:l,label:i}=e,o=null==(n=s.filter(e=>e.event.step===l).at(-1))?void 0:n.event,d=(null==o?void 0:o.detail)!=null&&"object"==typeof o.detail&&!Array.isArray(o.detail)&&!1===o.detail.ok;return{step:l,label:i,state:"done"===r.step?"done":d?"failed":t<a?"done":t===a?"now":"todo",...o?{text:o.text,at:o.ts}:{}}})}(t);return(0,s.jsx)("section",{"aria-label":"마법사 → 마켓",className:"min-w-0 space-y-6 p-4 text-lg min-[1440px]:text-[22px]",children:0===n.length?(0,s.jsxs)("p",{children:["마법사가 아직 돌지 않았습니다 — ",(0,s.jsx)("code",{children:'elanous plugin make "<한 줄>"'})," 로 시작"]}):(0,s.jsx)("ol",{"aria-label":"마법사 단계",className:"grid grid-cols-1 gap-3 min-[900px]:grid-cols-6",children:n.map(e=>(0,s.jsxs)("li",{"data-wizard-step":e.step,"data-state":e.state,className:"min-w-0 rounded-xl border p-4 ".concat(C[e.state]),children:[(0,s.jsxs)("div",{className:"font-semibold",children:[e.label," ",(0,s.jsxs)("span",{className:"font-normal",children:["\xb7 ",E[e.state]]})]}),e.text&&(0,s.jsx)("p",{className:"mt-3 overflow-hidden text-ellipsis whitespace-nowrap",title:(0,o.t)(e.text),children:(0,o.t)(e.text)})]},e.step))})})}let M=e=>"".concat(e.wizardId,":").concat(e.step,":").concat(e.ts,":").concat(e.text);function R(){let{client:e}=(0,u.Q)(),[t,n]=(0,r.useState)(()=>({client:e,events:[]}));return(0,r.useEffect)(()=>{let t=!0;n({client:e,events:[]});let s=s=>{t&&s.length&&n(t=>({client:e,events:function(e,t){let n=new Map;for(let s of[...e,...t])n.set(M(s),s);return[...n.values()].sort((e,t)=>e.ts.localeCompare(t.ts)).slice(-50)}(t.client===e?t.events:[],s)}))},r=e.fetchJson;"function"==typeof r&&r.call(e,"/v1/logs?exactCategory=wizard.step&limit=".concat(50)).then(e=>{let t=null==e?void 0:e.logs;s(Array.isArray(t)?t.map(g).filter(e=>null!==e):[])}).catch(()=>{});let a=x(e,e=>s([e]));return()=>{t=!1,a()}},[e]),(0,s.jsx)(L,{events:t.client===e?t.events:[]})}var K=n(77978);let q=["문서 아키텍처","라이브 트레이스","루프 에이전트","그래프 편집기","마법사 → 마켓","PTY 인텔리전스"],O=q.length,F="elanous.inside.demo";function P(e){return null!==e&&/^[1-9]$/.test(e)&&Number(e)<=O?Number(e):1}function W(){let{loopInteraction:e=K.ZR}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,a.useSearchParams)();return(0,s.jsx)(Y,{search:t,loopInteraction:e})}function Y(e){let{search:t,loopInteraction:n=K.ZR,liveTrace:a=(0,s.jsx)(w,{}),editorScene:i=(0,s.jsx)(N,{}),loopScene:d,wizardScene:u=(0,s.jsx)(R,{}),ptyScene:p=(0,s.jsx)(_,{})}=e,m=(0,K.kU)(t,n.refParam),[f,h]=(0,r.useState)(()=>P(t.get("scene"))),[g,x]=(0,r.useState)(()=>"1"===t.get("demo")),y=(0,r.useRef)(null),b=(0,r.useRef)(f),v=(0,r.useRef)(g);b.current=f,v.current=g;let j=(0,r.useCallback)(e=>{let t=new URL(window.location.href);for(let[n,s]of Object.entries(e))t.searchParams.set(n,s);window.history.replaceState(window.history.state,"",t.toString())},[]),k=(0,r.useCallback)(e=>{e<1||e>O||(b.current=e,h(e),j({scene:String(e)}))},[j]),I=(0,r.useCallback)(()=>{let e=!v.current;v.current=e,x(e),j({demo:e?"1":"0"});try{window.localStorage.setItem(F,e?"1":"0")}catch(e){}},[j]);return(0,r.useEffect)(()=>{let e=t.get("demo"),n="1"===e;if(null===e)try{n="1"===window.localStorage.getItem(F)}catch(e){}else try{window.localStorage.setItem(F,n?"1":"0")}catch(e){}v.current=n,x(n);let s=P(t.get("scene"));b.current=s,h(s)},[t]),(0,r.useEffect)(()=>{window.dispatchEvent(new window.Event("elanous:inside-demo"))},[g]),(0,r.useEffect)(()=>{let e=e=>{if(!(e.altKey||e.ctrlKey||e.metaKey||(0,l._i)(e.target))){if("ArrowLeft"===e.key||"ArrowRight"===e.key){e.preventDefault();let t="ArrowRight"===e.key?1:-1;k(Math.min(O,Math.max(1,b.current+t)))}else if("d"===e.key.toLowerCase())I();else if("f"===e.key.toLowerCase()){var t;"function"==typeof(null==(t=y.current)?void 0:t.requestFullscreen)&&y.current.requestFullscreen().catch(()=>{})}}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[k,I]),(0,s.jsxs)("main",{ref:y,"data-inside-page":!0,style:{width:"100%",minHeight:"100vh",minWidth:0,padding:20,boxSizing:"border-box",background:"#0c1828",color:"#f1f5fa",fontSize:18},children:[(0,s.jsx)("style",{children:'@media (min-width: 1440px) {\n [data-inside-page] h1 { font-size: 40px !important; }\n [data-inside-page] nav button { font-size: 22px !important; }\n [data-inside-page] [data-inside-scene="1"] [data-architecture-scene],\n [data-inside-page] [data-inside-scene="2"] section,\n [data-inside-page] [data-inside-scene="2"] header,\n [data-inside-page] [data-inside-scene="2"] button,\n [data-inside-page] [data-inside-scene="2"] .text-sm { font-size: 22px !important; }\n }'}),(0,s.jsxs)("header",{style:{display:"flex",alignItems:"center",gap:16},children:[(0,s.jsx)("h1",{style:{fontSize:28,margin:0},children:"엘라누스 안쪽"}),g&&(0,s.jsx)("span",{"aria-label":"시연 모드",style:{fontSize:18},children:"시연"})]}),(0,s.jsx)("nav",{"aria-label":"장면 선택",style:{display:"flex",minHeight:48,overflowX:"auto",gap:8,margin:"18px 0",whiteSpace:"nowrap"},children:q.map((e,t)=>(0,s.jsx)("button",{type:"button","aria-current":f===t+1?"page":void 0,onClick:()=>k(t+1),style:{flexShrink:0,minHeight:48,padding:"8px 16px",fontSize:18,borderRadius:8,border:"1px solid #7188a5",color:"#fff",background:f===t+1?"#22558b":"#203147"},children:(0,o.t)("".concat(t+1," ").concat(e))},e))}),q.map((e,t)=>(0,s.jsx)("section",{"data-inside-scene":t+1,hidden:f!==t+1,"aria-label":(0,o.t)("".concat(t+1," ").concat(e)),style:{minWidth:0},children:0===t?(0,s.jsx)(c,{}):1===t?a:2===t?null!=d?d:(0,s.jsx)(T.p1,{initialLoopRef:m}):3===t?i:4===t?u:p},e))]})}function _(){let{client:e}=(0,u.Q)(),[t,n]=(0,r.useState)(()=>({client:e,decisions:m})),[a,l]=(0,r.useState)(()=>Date.now());return(0,r.useEffect)(()=>{let e=setInterval(()=>l(Date.now()),6e4);return()=>clearInterval(e)},[]),(0,r.useEffect)(()=>{let t=!0;n({client:e,decisions:m});let s=function(e,t){let n=e.logsStreamUrl({exactCategory:"pty.decision"});return n?(0,p.BX)(n,{events:{log:e=>{let n;try{n=JSON.parse(e.data)}catch(e){return}if(!n||"object"!=typeof n||Array.isArray(n))return;let s=n;if("pty.decision"!==s.category)return;let r=function(e){if(!f(e))return null;let{ts:t,missionId:n,seq:s,sessionId:r,terminalId:a,agent:l,step:i,text:o,detail:d}=e;if(!h(t)||!Number.isFinite(Date.parse(t))||!h(n)||!Number.isSafeInteger(s)||s<0||!h(r)||!h(a)||!h(l)||!h(o)||void 0!==d&&!f(d)||f(d)&&(void 0!==d.keys&&"string"!=typeof d.keys||void 0!==d.row&&(!Number.isSafeInteger(d.row)||d.row<0)))return null;let c={ts:t,missionId:n,seq:s,sessionId:r,terminalId:a,agent:l,text:o},u=f(d)?{...void 0!==d.keys?{keys:d.keys}:{},...void 0!==d.row?{row:d.row}:{}}:{};return"answer"===i?f(d)&&h(d.question)&&h(d.answer)?{...c,step:i,detail:{...u,question:d.question,answer:d.answer}}:null:"recover"===i?f(d)&&h(d.blocked)&&h(d.action)?{...c,step:i,detail:{...u,blocked:d.blocked,action:d.action}}:null:"done"===i?f(d)&&f(d.result)&&h(d.result.ref)&&("pr"===d.result.kind||"file"===d.result.kind||"text"===d.result.kind)?{...c,step:i,detail:{...u,result:{kind:d.result.kind,ref:d.result.ref}}}:null:"read"===i||"judge"===i||"input"===i?{...c,step:i,...void 0!==d?{detail:u}:{}}:null}(s.data);r&&s.event===r.step&&t(r)}}}):()=>{}}(e,s=>{t&&n(t=>({client:e,decisions:function(e,t){let n=Object.hasOwn(e.missions,t.missionId)?e.missions[t.missionId]:[];if(n.some(e=>e.seq===t.seq))return e;let s=[...n,t].sort((e,t)=>e.seq-t.seq),r={...e.missions,[t.missionId]:s},a=e.currentMissionId?r[e.currentMissionId]:void 0,l=s.at(-1),i=null==a?void 0:a.at(-1);return{missions:r,currentMissionId:!i||Date.parse(l.ts)>Date.parse(i.ts)?t.missionId:e.currentMissionId}}(t.client===e?t.decisions:m,s)}))});return()=>{t=!1,s()}},[e]),(0,s.jsx)(z,{decisions:t.client===e?t.decisions:m,now:a})}},87534:(e,t,n)=>{"use strict";function s(e){return e.metaKey||e.ctrlKey}function r(e){let t=e.key.toLowerCase();return!s(e)||e.shiftKey||e.altKey||"k"!==t?s(e)&&e.shiftKey&&!e.altKey&&"j"===t?e.fromEditable?null:"toggle-role-judge":s(e)&&e.shiftKey&&!e.altKey&&"m"===t?e.fromEditable?null:"toggle-voice":s(e)&&e.shiftKey&&!e.altKey&&"y"===t?e.fromEditable?null:"toggle-tts":"?"!==e.key||s(e)||e.altKey?null:e.fromEditable?null:"open-help":"focus-broadcast-input"}function a(e){var t;if(!e)return!1;let n=e.tagName;if(!n)return!1;if("INPUT"===n||"TEXTAREA"===n||"SELECT"===n)return!0;let s=null==(t=e.getAttribute)?void 0:t.call(e,"contenteditable");return""===s||"true"===s}n.d(t,{ZQ:()=>r,_i:()=>a,nm:()=>l});let l=[{id:"focus-broadcast-input",combo:"⌘K / Ctrl+K",effect:"Focus broadcast input"},{id:"toggle-role-judge",combo:"⌘⇧J / Ctrl+⇧J",effect:"Toggle role-judge backend"},{id:"toggle-voice",combo:"⌘⇧M / Ctrl+⇧M",effect:"Toggle voice mode (mic)"},{id:"toggle-tts",combo:"⌘⇧Y / Ctrl+⇧Y",effect:"Toggle TTS mute"},{id:"open-help",combo:"?",effect:"Open this help overlay"}]}},e=>{e.O(0,[8997,7571,3727,5616,4055,3603,8073,3985,5892,7648,7307,8987,5359,5456,6955,597,9777,4306,3702,7358],()=>e(e.s=11247)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3141],{10466:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});let n=(0,a(89570).A)("activity",[["path",{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",key:"169zse"}]])},17337:(e,t,a)=>{Promise.resolve().then(a.bind(a,43097))},24144:(e,t,a)=>{"use strict";a.d(t,{A:()=>n});let n=(0,a(89570).A)("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]])},43097:(e,t,a)=>{"use strict";a.r(t),a.d(t,{default:()=>R});var n=a(17594),r=a(48082),s=a(96545),l=a(74055),i=a(10466),o=a(24144),d=a(46982),c=a(99081),u=a(12252),x=a(17240),m=a(22244),h=a(81755),p=a(273);let g={PLAN:"text-sky-600 dark:text-sky-400",ROUTE:"text-violet-600 dark:text-violet-400",VERIFY:"text-amber-600 dark:text-amber-400",HEAL:"text-emerald-600 dark:text-emerald-400",ESCALATE:"text-rose-600 dark:text-rose-400",SHIP:"text-green-700 dark:text-green-400 font-semibold"};function f(e){let{board:t,lines:a,mode:r,onSelectRun:s,selectedRunId:l,role:i="owner"}=e,o="max"===r,d="owner"===i,c=t.gauges,{snapshot:x}=t,m=d?0:t.stream.filter(e=>null!=e.why&&(0,u.Yu)(e.why)).length;return(0,n.jsxs)("div",{className:(0,p.cn)("space-y-4",o&&"live-max"),"data-live-mode":r,children:[(0,n.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-6",children:[(0,n.jsx)(b,{label:"LIVE",hint:"도는 런",value:String(c.live),tone:c.live>0?"live":"idle",max:o}),(0,n.jsx)(b,{label:"DECISIONS/MIN",hint:"판단 ".concat(c.decisions,"건"),value:String(c.decisionsPerMin),max:o}),(0,n.jsx)(b,{label:"SHIPPED",hint:"병합\xb7PR",value:String(c.shipped),tone:"ok",max:o}),(0,n.jsx)(b,{label:"SELF-HEAL",hint:c.selfHealRuns?"수리 런 ".concat(c.selfHealRuns):"수리 런 없음",value:null===c.selfHealRate?"—":"".concat(c.selfHealRate,"%"),max:o}),(0,n.jsx)(b,{label:"BURN",hint:"토큰/분",value:v(c.burnTokensPerMin),max:o}),(0,n.jsx)(b,{label:"BLOCKED",hint:"막힌 런",value:String(x.counters.blocked),tone:x.counters.blocked?"bad":"idle",max:o})]}),(0,n.jsxs)("section",{className:"space-y-2","aria-label":"런",children:[(0,n.jsxs)("h2",{className:"text-sm font-medium",children:["런 ",(0,n.jsxs)("span",{className:"text-xs text-muted-foreground",children:["최근 ",x.windowMinutes,"분 \xb7 ",x.runs.length]})]}),0===x.runs.length?(0,n.jsx)("p",{className:"rounded-md border border-dashed p-4 text-sm text-muted-foreground","data-live-empty":!0,children:"지금 이 창에 런 신호가 없습니다 — 텔레그램이나 Intake 로 한 줄 보내면 여기에 런이 뜹니다."}):(0,n.jsx)("ul",{className:"space-y-1.5",children:x.runs.slice(0,12).map(e=>(0,n.jsx)(j,{run:e,round:t.rounds[e.runId],max:o,selected:e.runId===l,onSelect:s,owner:d},e.runId))})]}),(0,n.jsxs)("div",{className:"grid gap-4 lg:grid-cols-5",children:[(0,n.jsxs)("section",{className:"space-y-2 lg:col-span-3","aria-label":"판단 스트림",children:[(0,n.jsxs)("h2",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:["판단 스트림",u.jg.map(e=>(0,n.jsx)("span",{className:(0,p.cn)("text-[11px] lg:text-[10px] font-mono",g[e]),children:e},e))]}),0===t.stream.length?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"이 창에 판단 신호가 없습니다."}):(0,n.jsx)("ul",{className:"max-h-80 space-y-1 overflow-auto rounded-md border p-2 font-mono text-[11px]","data-live-stream":!0,children:t.stream.slice(0,40).map((e,t)=>(0,n.jsxs)("li",{className:(0,p.cn)("leading-relaxed",o&&0===t&&"live-line-in",o&&"SHIP"===e.kind&&"live-ship"),children:[(0,n.jsxs)("span",{className:"text-muted-foreground",children:[(0,n.jsx)("span",{title:e.ts,children:(0,u.qo)(e.ts)})," "]}),(0,n.jsxs)("span",{className:g[e.kind],children:["[",e.kind,"]"]})," ",d?e.what:(0,u.hS)(e.what.replace(/run-[0-9a-f]{8}-[^\s]*/gi,""),i),e.why&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 왜: ",(0,u.hS)(e.why,i)]}),e.purpose&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" \xb7 목적: ",e.purpose]}),e.target&&(0,n.jsxs)("span",{className:"text-muted-foreground",children:[" → ",e.target]})]},"".concat(e.ts,"-").concat(t)))})]}),(0,n.jsxs)("section",{className:"space-y-2 lg:col-span-2","aria-label":"성적표",children:[(0,n.jsx)("h2",{className:"text-sm font-medium",children:"모델 성적표"}),0===t.scorecard.length?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"이 창에 모델 요청이 없습니다."}):(0,n.jsxs)("table",{className:"w-full text-[11px]",children:[(0,n.jsx)("thead",{children:(0,n.jsxs)("tr",{className:"text-muted-foreground",children:[(0,n.jsx)("th",{className:"text-left font-normal",children:"모델"}),(0,n.jsx)("th",{className:"text-right font-normal",children:"요청"}),(0,n.jsx)("th",{className:"text-right font-normal",children:"토큰"}),(0,n.jsx)("th",{className:"text-right font-normal",children:"과금"})]})}),(0,n.jsx)("tbody",{children:t.scorecard.slice(0,8).map(e=>{var t;return(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"truncate",children:e.model}),(0,n.jsx)("td",{className:"text-right tabular-nums",children:e.requests}),(0,n.jsx)("td",{className:"text-right tabular-nums",children:v(e.tokens)}),(0,n.jsx)("td",{className:"text-right text-muted-foreground",children:null!=(t=e.billing)?t:"—"})]},e.model)})})]}),(0,n.jsx)("h2",{className:"pt-2 text-sm font-medium",children:"리뷰 판정"}),(0,n.jsx)(N,{items:x.reviewVerdicts,max:o})]})]}),(0,n.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[d?(0,n.jsxs)("section",{className:"space-y-2","aria-label":"흐르는 로그",children:[(0,n.jsx)("h2",{className:"text-sm font-medium",children:"흐르는 로그"}),(0,n.jsx)("pre",{className:"max-h-60 overflow-auto rounded-md border bg-muted/30 p-2 text-[11px] leading-relaxed","data-live-log":!0,children:a.slice(0,60).join("\n")||"—"})]}):m>0?(0,n.jsxs)("p",{className:"text-xs text-muted-foreground","data-live-folded-errors":!0,children:["오류 ",m,"건 접힘"]}):null,(0,n.jsxs)("section",{className:"space-y-2","aria-label":"빈 칸 표",children:[(0,n.jsxs)("h2",{className:"text-sm font-medium",children:["빈 칸 표 ",(0,n.jsx)("span",{className:"text-xs text-muted-foreground",children:"판단 로그에 없는 칸"})]}),0===t.missing.length?(0,n.jsx)("p",{className:"text-xs text-muted-foreground",children:"빈 칸 없음."}):(0,n.jsx)("table",{className:"w-full text-[11px]","data-live-missing":!0,children:(0,n.jsx)("tbody",{children:t.missing.slice(0,10).map(e=>(0,n.jsxs)("tr",{children:[(0,n.jsx)("td",{className:"font-mono",children:e.key}),(0,n.jsx)("td",{className:"text-right tabular-nums",children:e.count}),(0,n.jsx)("td",{className:"pl-2 text-muted-foreground",children:e.lacks.join(" \xb7 ")})]},e.key))})})]})]})]})}function v(e){return e>=1e6?"".concat((e/1e6).toFixed(1),"M"):e>=1e3?"".concat((e/1e3).toFixed(e>=1e5?0:1),"k"):String(e)}function b(e){let{label:t,hint:a,value:r,tone:s="idle",max:l}=e;return(0,n.jsxs)("div",{className:(0,p.cn)("rounded-lg border p-3","live"===s&&"border-primary/50","bad"===s&&"border-error/50","ok"===s&&"border-green-600/40",l&&"live-gauge",l&&"live"===s&&"live-glow"),children:[(0,n.jsx)("div",{className:"font-mono text-[11px] lg:text-[10px] tracking-wider text-muted-foreground",children:t}),(0,n.jsx)("div",{className:(0,p.cn)("text-2xl font-semibold tabular-nums",l&&"live-count"),"data-live-gauge":t,children:r}),(0,n.jsx)("div",{className:"text-[11px] lg:text-[10px] text-muted-foreground",children:a})]})}function j(e){let{run:t,round:a,max:r,selected:s,onSelect:l,owner:i}=e;return(0,n.jsx)("li",{children:(0,n.jsxs)("button",{type:"button","data-live-run":t.runId,onClick:()=>null==l?void 0:l(t.runId),className:(0,p.cn)("flex w-full items-center gap-3 rounded-md border px-3 py-2 text-left text-xs hover:bg-muted/40",s&&"ring-1 ring-primary"),children:[(0,n.jsx)("span",{className:"w-24 shrink-0 truncate font-mono text-[11px] text-muted-foreground",children:i?t.runId.replace(/^run-/,"").slice(0,8):"런"}),(0,n.jsx)("span",{className:"flex flex-1 gap-1","aria-label":"단계",children:u.lV.map(e=>{let a=t.stages[e],s=t.current===e;return(0,n.jsx)("span",{title:"".concat(u.fQ[e]," \xb7 ").concat(null!=a?a:"신호 없음"),"data-stage":e,"data-tone":null!=a?a:"none",className:(0,p.cn)("h-2 flex-1 rounded-full bg-muted","info"===a&&"bg-primary/60","ok"===a&&"bg-green-600","bad"===a&&"bg-error",r&&s&&"bad"!==a&&"live-pulse",r&&s&&"bad"===a&&"live-pulse-bad")},e)})}),(0,n.jsx)("span",{className:"w-14 shrink-0 text-right font-mono text-[11px] lg:text-[10px] text-muted-foreground",children:a?"R ".concat(a,"/3"):""}),(0,n.jsx)("span",{className:"w-24 shrink-0 text-right text-[11px]",children:t.blocked?(0,n.jsx)("span",{className:"text-error",children:"막힘"}):"ok"===t.stages.land?(0,n.jsxs)("span",{className:"text-green-700",children:["착지",t.pr?" #".concat(t.pr):""]}):t.current?u.fQ[t.current]:""})]})})}function N(e){let{items:t,max:a}=e,r=Math.max(1,...t.map(e=>e.count));return 0===t.length?(0,n.jsx)("div",{className:"text-[11px] text-muted-foreground",children:"—"}):(0,n.jsx)("ul",{className:"space-y-1",children:t.slice(0,6).map(e=>(0,n.jsxs)("li",{className:"flex items-center gap-2 text-[11px]",children:[(0,n.jsx)("span",{className:"w-24 shrink-0 truncate",children:e.name}),(0,n.jsx)("span",{className:"h-1.5 flex-1 rounded-full bg-muted",children:(0,n.jsx)("span",{className:(0,p.cn)("block h-1.5 rounded-full bg-primary/70",a&&"transition-[width] duration-700"),style:{width:"".concat(e.count/r*100,"%")}})}),(0,n.jsx)("span",{className:"w-8 text-right tabular-nums",children:e.count})]},e.name))})}var w=a(20486),y=a(33330);let k=[15,60,360,1440],S="@active";function E(){return(0,d.Qj)()?(0,n.jsx)(M,{}):(0,n.jsxs)("div",{className:"mx-auto max-w-2xl space-y-2 p-6",children:[(0,n.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"Live"}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"Connect to a NEXUS daemon to watch runs live."})]})}function M(){var e,t,a,s,p,g;let v=(0,h.In)(),[b,j]=(0,r.useState)("practical"),[N,E]=(0,r.useState)(null),[M,C]=(0,r.useState)("all"),[L,R]=(0,r.useState)(!1);(0,r.useEffect)(()=>{try{window.localStorage.removeItem("elanous.live.mode")}catch(e){}},[]),(0,r.useEffect)(()=>{if(!N)return;let e=setTimeout(()=>{j("practical"),E(null)},Math.max(0,N-Date.now()));return()=>clearTimeout(e)},[N]);let H=(0,d.M1)(),[D,P]=(0,r.useState)(null),X=e=>{e.on?(j("max"),C(e.scope&&"all"!==e.scope?"run":"all"),E(e.until?Date.parse(e.until):Date.now()+18e5)):(j("practical"),E(null))};(0,r.useEffect)(()=>{let e=!0;return H.getLiveDetail().then(t=>{e&&X(t)}).catch(()=>{}),()=>{e=!1}},[H]);let q=e=>{R(!1),P(null);let t="run"===e&&z?z:"all";H.setLiveDetail({scope:t,ttlMin:30,by:"pwa-live"}).then(X).catch(e=>P(e instanceof Error?e.message:String(e)))},[O,U]=(0,r.useState)(60),[_,B]=(0,r.useState)(""),T=(0,r.useRef)(!1);(0,r.useEffect)(()=>{"max"!==b||T.current||(T.current=!0,B(S),U(1440)),"max"!==b&&(T.current=!1)},[b]);let[z,F]=(0,r.useState)(null),{logs:W,runs:K,instances:V}=(0,c.HI)({store:_||void 0,windowMinutes:O}),[Y,Q]=(0,r.useState)(()=>Date.now());(0,r.useEffect)(()=>{Q(Date.now())},[W.dataUpdatedAt]);let[Z,G]=(0,r.useState)(!1);(0,r.useEffect)(()=>{"public"===new URLSearchParams(window.location.search).get("capture")&&G(!0)},[]);let $=null!=(s=null==(e=W.data)?void 0:e.logs)?s:I,J=(0,r.useMemo)(()=>Z?(0,m.yR)($):$,[$,Z]),ee=(0,l.I)({queryKey:["live","shipped",O],queryFn:()=>H.getLiveShipped("".concat(O,"m")),refetchInterval:6e4}),et=(0,r.useMemo)(()=>{var e,t,a;let n=(0,u.Hc)(J,null!=(a=null==(e=K.data)?void 0:e.entries)?a:[],{now:Y,windowMinutes:O}),r=null==(t=ee.data)?void 0:t.merged;if("number"!=typeof r)return n;let s=(0,x.NZ)(J).length;return{...n,gauges:{...n.gauges,shipped:r,selfHealRuns:s,selfHealRate:r>0?Math.round(s/r*100):null}}},[J,K.data,Y,O,ee.data]),ea=O>0?Math.round(J.length/O*10)/10:0,en=Math.round(JSON.stringify(J).length/1024),er=(0,r.useMemo)(()=>J.filter(e=>{var t;return!z||(null==(t=e.data)?void 0:t.runId)===z}).map(e=>(0,u.BP)(e)),[J,z]),es=(null!=(p=null==(t=V.data)?void 0:t.instances)?p:[]).filter(e=>!1!==e.dbExists&&!e.current);return(0,n.jsxs)("div",{className:"mx-auto ".concat("max"===b?"max-w-none space-y-2 p-2":"max-w-6xl space-y-4 p-4 sm:p-6"),children:[(0,n.jsx)("style",{children:A}),(0,n.jsxs)("header",{className:"flex flex-wrap items-center gap-3 ".concat("max"===b?"justify-end":"justify-between"),children:[(0,n.jsxs)("div",{className:"max"===b?"hidden":"",children:[(0,n.jsxs)("h1",{className:"flex items-center gap-2 text-xl font-semibold tracking-tight",children:[(0,n.jsx)(i.A,{className:"h-5 w-5","aria-hidden":!0})," Live"]}),(0,n.jsx)("p",{className:"text-sm text-muted-foreground",children:"하니스 런이 판단하고 기획하는 신호 — 보이는 수는 전부 진짜다."})]}),(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[(0,n.jsx)("select",{"aria-label":"시간 창",value:O,onChange:e=>U(Number(e.target.value)),className:"rounded-md border bg-background px-2 py-1",children:k.map(e=>(0,n.jsx)("option",{value:e,children:e<60?"".concat(e,"분"):"".concat(e/60,"시간")},e))}),(0,n.jsxs)("select",{"aria-label":"신호 출처",value:_,onChange:e=>B(e.target.value),className:"max-w-48 rounded-md border bg-background px-2 py-1",children:[(0,n.jsx)("option",{value:"",children:"이 인스턴스"}),(0,n.jsx)("option",{value:S,children:"전체(연합 \xb7 최근 24시간에 쓰인 우주)"}),es.map(e=>(0,n.jsx)("option",{value:e.name,children:e.name},e.name))]}),(0,n.jsx)("button",{type:"button","data-elanous-action":"live-public-capture","aria-pressed":Z,onClick:()=>G(e=>!e),title:"녹화\xb7스크린샷용 — 계정 이름 → account-N \xb7 크레딧\xb7USD 숨김 \xb7 홈 경로 가림",className:"rounded-md border px-2 py-1 ".concat(Z?"border-emerald-500 text-emerald-600 dark:text-emerald-300":"hover:bg-muted"),children:Z?"● 공개 캡처 켜짐":"공개 캡처"}),"max"===b?(0,n.jsxs)("button",{type:"button","data-elanous-action":"live-max-off",onClick:()=>{P(null),H.setLiveDetail({scope:"all",ttlMin:0,by:"pwa-live"}).then(X).catch(e=>P(e instanceof Error?e.message:String(e))),j("practical"),E(null)},className:"inline-flex items-center gap-1 rounded-md border border-primary px-2 py-1 text-primary hover:bg-muted",children:[(0,n.jsx)(o.A,{className:"h-3.5 w-3.5","aria-hidden":!0})," 화려함 MAX 켜짐 \xb7 끄기"]}):(0,n.jsxs)("button",{type:"button","data-elanous-action":"live-max-on",onClick:()=>R(!0),className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 hover:bg-muted",children:[(0,n.jsx)(o.A,{className:"h-3.5 w-3.5","aria-hidden":!0})," 화려함 MAX"]})]})]}),L&&(0,n.jsxs)("div",{role:"dialog","aria-label":"화려함 MAX 켜기",className:"space-y-2 rounded-md border border-primary/50 bg-primary/5 p-3 text-sm","data-live-max-confirm":!0,children:[(0,n.jsx)("p",{className:"font-medium",children:"화려함 MAX 를 켤까요?"}),(0,n.jsxs)("p",{className:"text-xs text-muted-foreground",children:["마케팅(시연\xb7녹화)과 상세 런 디버깅용입니다. 켜면 하니스가 판단마다 \xab왜\xb7목적\xb7보낸 곳\xbb을 추가로 기록합니다(부하가 듭니다) — 30분 뒤 자동으로 꺼지고, 다른 기기에서도 같은 상태로 보입니다. 지금 이 화면이 받는 신호: 분당 ",ea,"건 \xb7 응답 약 ",en,"KB."]}),(0,n.jsxs)("div",{className:"flex flex-wrap gap-2 text-xs",children:[(0,n.jsx)("button",{type:"button","data-elanous-action":"live-max-all",onClick:()=>q("all"),className:"rounded-md border px-2 py-1 hover:bg-muted",children:"전체로 켜기"}),(0,n.jsx)("button",{type:"button","data-elanous-action":"live-max-run",disabled:!z,onClick:()=>q("run"),className:"rounded-md border px-2 py-1 hover:bg-muted disabled:opacity-50",children:z?"이 런만 켜기":"이 런만 켜기(먼저 런을 고르세요)"}),(0,n.jsx)("button",{type:"button",onClick:()=>R(!1),className:"rounded-md px-2 py-1 text-muted-foreground hover:bg-muted",children:"취소"})]})]}),D&&(0,n.jsxs)("p",{className:"rounded-md bg-error/10 p-2 text-xs text-error",children:["MAX 스위치를 못 바꿨다: ",D]}),"max"===b&&(0,n.jsxs)("p",{className:"rounded-md border border-primary/40 px-3 py-1 text-[11px] lg:text-[10px] text-muted-foreground","data-live-cost-badge":!0,children:["화려함 MAX \xb7 범위 ","run"===M&&z?"런 ".concat(z.replace(/^run-/,"").slice(0,8)):"전체"," \xb7 받는 신호 분당 ",ea,"건 \xb7 응답 약 ",en,"KB",N?" \xb7 ".concat(Math.max(0,Math.round((N-Y)/6e4)),"분 뒤 자동 꺼짐"):""," \xb7 하니스 판단 이벤트 ",et.emitted,"건"]}),W.error?(0,n.jsxs)("p",{className:"rounded-md bg-error/10 p-3 text-sm text-error",children:["신호를 못 읽었다: ",W.error instanceof Error?W.error.message:String(W.error)]}):null,z&&(0,n.jsx)(y.RT,{runId:z,run:null!=(g=et.snapshot.runs.find(e=>e.runId===z))?g:null,lines:er,onClose:()=>F(null)}),"max"===b?(0,n.jsx)(w.xl,{board:et,rows:J,windowMinutes:O,sourceLabel:_===S?"federated":_||"this instance",shippedSource:"number"==typeof(null==(a=ee.data)?void 0:a.merged)?"github":"log",publicCapture:Z,role:v,onSelectRun:e=>F(t=>t===e?null:e)}):(0,n.jsx)(f,{board:et,lines:er,mode:b,role:v,selectedRunId:z,onSelectRun:e=>F(t=>t===e?null:e)}),(0,n.jsxs)("p",{className:"text-[11px] text-muted-foreground ".concat("max"===b?"hidden":""),children:["갱신 5초 \xb7 출처 ",(0,n.jsx)("code",{children:"/v1/logs"})," \xb7 ",(0,n.jsx)("code",{children:"/v1/harness/runs"})," \xb7 비밀처럼 보이는 조각은 가린다."]})]})}let I=[],A="\n@keyframes live-pulse { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(99,102,241,0) } 50% { opacity: .55; box-shadow: 0 0 10px 2px rgba(99,102,241,.55) } }\n@keyframes live-pulse-bad { 0%,100% { opacity: 1 } 50% { opacity: .4; box-shadow: 0 0 10px 2px rgba(239,68,68,.6) } }\n@keyframes live-glow { 0%,100% { box-shadow: 0 0 0 0 rgba(99,102,241,0) } 50% { box-shadow: 0 0 18px 2px rgba(99,102,241,.35) } }\n@keyframes live-line-in { from { transform: translateY(-6px); opacity: 0 } to { transform: none; opacity: 1 } }\n@keyframes live-ship { 0% { background: rgba(34,197,94,.35) } 100% { background: transparent } }\n.live-max .live-pulse { animation: live-pulse 1.4s ease-in-out infinite }\n.live-max .live-pulse-bad { animation: live-pulse-bad 1s ease-in-out infinite }\n.live-max .live-glow { animation: live-glow 2.4s ease-in-out infinite }\n.live-max .live-line-in { animation: live-line-in .45s ease-out }\n.live-max .live-ship { animation: live-ship 2.4s ease-out; font-size: 12px }\n.live-max .live-gauge { background: radial-gradient(120% 120% at 0% 0%, rgba(99,102,241,.10), transparent 60%) }\n.live-max .live-count { text-shadow: 0 0 12px rgba(99,102,241,.45) }\n.live-stage { background: radial-gradient(120% 90% at 50% 0%, rgba(79,70,229,.25), rgba(2,6,23,.98) 60%), #020617; box-shadow: inset 0 0 0 1px rgba(99,102,241,.25) }\n.live-stage .live-line-in { animation: live-line-in .45s ease-out }\n@keyframes live-v5-marquee { from { transform: translateX(0) } to { transform: translateX(-50%) } }\n@keyframes live-v5-blink { 0%,100% { opacity: 1 } 50% { opacity: .45 } }\n@keyframes live-v5-hot { 0%,100% { box-shadow: 0 0 14px #a78bfa55, inset 0 0 14px #a78bfa22 } 50% { box-shadow: 0 0 26px #a78bfa99, inset 0 0 22px #a78bfa44 } }\n.live-v5-marquee { animation: live-v5-marquee linear infinite }\n.live-v5-blink { animation: live-v5-blink 1.6s ease-in-out infinite }\n.live-v5-hot { animation: live-v5-hot 1.8s ease-in-out infinite }\n@media (prefers-reduced-motion: reduce) { .live-max *, .live-v5 * { animation: none !important; transition: none !important } }\n";var C=a(85359);function L(){let e=(0,s.useSearchParams)().get("run");return e?(0,n.jsx)(C.Yd,{runId:e}):(0,n.jsx)(E,{})}function R(){return(0,n.jsx)(r.Suspense,{fallback:(0,n.jsx)("p",{className:"p-4 text-sm text-text-tertiary",children:"라이브를 여는 중…"}),children:(0,n.jsx)(L,{})})}},81755:(e,t,a)=>{"use strict";a.d(t,{GC:()=>r,In:()=>d,OG:()=>i});var n=a(48082);let r="elanous.pwa.role",s="elanous:pwa-role";function l(){try{let e=window.localStorage.getItem(r);if("owner"===e||"contributor"===e||"general"===e)return e}catch(e){}return"general"}function i(e){try{window.localStorage.setItem(r,e)}catch(e){}"function"==typeof window.dispatchEvent&&window.dispatchEvent(new Event(s))}function o(e){if("function"!=typeof window.addEventListener)return()=>{};window.addEventListener(s,e);let t=t=>{(t.key===r||null===t.key)&&e()};return window.addEventListener("storage",t),()=>{window.removeEventListener(s,e),window.removeEventListener("storage",t)}}function d(){return(0,n.useSyncExternalStore)(o,l,()=>"general")}},89570:(e,t,a)=>{"use strict";a.d(t,{A:()=>d});var n=a(48082);let r=function(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return t.filter((e,t,a)=>!!e&&""!==e.trim()&&a.indexOf(e)===t).join(" ").trim()},s=e=>{let t=e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,a)=>a?a.toUpperCase():t.toLowerCase());return t.charAt(0).toUpperCase()+t.slice(1)};var l={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let i=(0,n.createContext)({}),o=(0,n.forwardRef)((e,t)=>{var a,s,o;let{color:d,size:c,strokeWidth:u,absoluteStrokeWidth:x,className:m="",children:h,iconNode:p,...g}=e,{size:f=24,strokeWidth:v=2,absoluteStrokeWidth:b=!1,color:j="currentColor",className:N=""}=null!=(a=(0,n.useContext)(i))?a:{},w=(null!=x?x:b)?24*Number(null!=u?u:v)/Number(null!=c?c:f):null!=u?u:v;return(0,n.createElement)("svg",{ref:t,...l,width:null!=(s=null!=c?c:f)?s:l.width,height:null!=(o=null!=c?c:f)?o:l.height,stroke:null!=d?d:j,strokeWidth:w,className:r("lucide",N,m),...!h&&!(e=>{for(let t in e)if(t.startsWith("aria-")||"role"===t||"title"===t)return!0;return!1})(g)&&{"aria-hidden":"true"},...g},[...p.map(e=>{let[t,a]=e;return(0,n.createElement)(t,a)}),...Array.isArray(h)?h:[h]])}),d=(e,t)=>{let a=(0,n.forwardRef)((a,l)=>{let{className:i,...d}=a;return(0,n.createElement)(o,{ref:l,iconNode:t,className:r("lucide-".concat(s(e).replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()),"lucide-".concat(e),i),...d})});return a.displayName=s(e),a}}},e=>{e.O(0,[8997,7571,3727,1695,5616,1596,4055,3603,8073,3985,5359,7988,4306,3702,7358],()=>e(e.s=17337)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[125],{58497:(e,t,l)=>{Promise.resolve().then(l.bind(l,76559))},76559:(e,t,l)=>{"use strict";l.r(t),l.d(t,{default:()=>b});var s=l(17594),r=l(48082),a=l(96545),n=l(74055),c=l(46982),i=l(268),o=l(52191),d=l(85359);let x="__auto_follow_latest__";function u(){return(0,c.Qj)()?(0,s.jsx)(m,{}):(0,s.jsxs)("div",{className:"mx-auto max-w-2xl space-y-2 p-6",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"런 장면"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"데몬에 연결되면 최근 하니스 런을 자동으로 따라갑니다."})]})}function m(){let e=(0,c.M1)(),t=(0,a.useRouter)(),l=(0,a.useSearchParams)(),u=(0,r.useMemo)(()=>Date.now()-864e5,[]),m=(0,n.I)({queryKey:["harness-runs-since",u],queryFn:()=>e.getHarnessRunsSince(u,{includeLanded:!1}),refetchInterval:3e4}),h=(0,r.useMemo)(()=>{var e,t;return m.data?(0,i.wk)(null!=(e=m.data.entries)?e:[],null!=(t=m.data.finished)?t:[]):[]},[m.data]),p=(0,i.ov)(h);return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-4",children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("h1",{className:"text-base font-semibold text-text-primary",children:"런 장면"}),(0,s.jsx)("span",{className:"text-xs text-text-tertiary",children:"최신 세션 런을 자동으로 따라갑니다 (라이브 \xb7 리플레이)"}),(0,s.jsxs)("label",{className:"flex w-full min-w-0 items-center gap-1 text-xs text-text-secondary sm:ml-auto sm:w-auto sm:min-w-[320px]",children:[(0,s.jsx)("span",{className:"shrink-0",children:"런"}),(0,s.jsxs)("select",{"aria-label":"런 고르기",value:x,onChange:e=>{let l;e.target.value&&e.target.value!==x&&(l=e.target.value,t.replace("/live-run/?run=".concat(encodeURIComponent(l))))},className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1 text-xs text-text-primary",children:[(0,s.jsx)("option",{value:x,children:m.isLoading?"불러오는 중…":"최신 런 자동 따라가기"}),h.some(e=>e.live)&&(0,s.jsx)("optgroup",{label:"도는 중",children:h.filter(e=>e.live).map(e=>(0,s.jsxs)("option",{value:e.runId,children:["● ",e.label]},e.runId))}),h.some(e=>!e.live)&&(0,s.jsx)("optgroup",{label:"끝난 런 (최근 24시간)",children:h.filter(e=>!e.live).map(e=>(0,s.jsxs)("option",{value:e.runId,children:[e.at?"".concat((0,o.Xf)(e.at).slice(0,5)," \xb7 "):"",e.label]},e.runId))})]})]})]}),m.isError&&(0,s.jsx)("p",{role:"status",className:"text-xs text-warning",children:"런 목록을 읽지 못했습니다."}),p?(0,s.jsx)(d.Yd,{runId:p,initialFolded:"folded"===l.get("units")},p):(0,s.jsx)("p",{role:"status",className:"rounded-lg border border-border bg-surface p-4 text-sm text-text-secondary",children:m.isLoading?"최근 런 목록을 불러오는 중입니다.":"최근 24시간 런이 없습니다."})]})}function h(){return(0,c.Qj)()?(0,s.jsx)(p,{}):(0,s.jsxs)("div",{className:"mx-auto max-w-2xl space-y-2 p-6",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold tracking-tight",children:"런 장면"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"데몬에 연결되면 하니스 런 하나가 도는 장면을 그립니다."})]})}function p(){var e;let t=(0,c.M1)(),l=(0,a.useRouter)(),x=(0,a.useSearchParams)(),u=(null==(e=x.get("run"))?void 0:e.trim())||null,[m,h]=(0,r.useState)(!1),p="1"===x.get("stage")&&!!u,b=(0,r.useMemo)(()=>Date.now()-864e5,[]),f=(0,n.I)({queryKey:["harness-runs-since",b],queryFn:()=>t.getHarnessRunsSince(b,{includeLanded:!1}),enabled:!u||m,refetchInterval:3e4}),g=(0,r.useMemo)(()=>{var e,t;return f.data?(0,i.wk)(null!=(e=f.data.entries)?e:[],null!=(t=f.data.finished)?t:[]):[]},[f.data]),v=e=>l.replace("/live-run/?run=".concat(encodeURIComponent(e)));return(0,s.jsxs)("div",{className:p?"fixed inset-0 z-[100] flex min-h-0 flex-col overflow-hidden bg-[#070b18] p-3 text-white sm:p-5":"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-4",children:[(0,s.jsxs)("header",{className:"flex flex-wrap items-center gap-2 ".concat(p?"mb-2 border-b border-white/10 pb-2":""),children:[(0,s.jsx)("h1",{className:"font-semibold ".concat(p?"text-lg tracking-[0.18em] text-cyan-100 sm:text-xl":"text-base text-text-primary"),children:p?"ELANOUS \xb7 LIVE GRAPH":"런 장면"}),(0,s.jsx)("span",{className:"text-xs ".concat(p?"text-white/55":"text-text-tertiary"),children:p?"DEMO1104 \xb7 GRAPH SHOWSTOPPER":"하니스 런 하나가 실제로 밟은 노드\xb7간선 (라이브 \xb7 리플레이)"}),!p&&(0,s.jsxs)("label",{className:"flex w-full min-w-0 items-center gap-1 text-xs text-text-secondary sm:ml-auto sm:w-auto sm:min-w-[320px]",children:[(0,s.jsx)("span",{className:"shrink-0",children:"런"}),(0,s.jsxs)("select",{"aria-label":"런 고르기",value:null!=u?u:"",onChange:e=>{e.target.value&&v(e.target.value)},onFocus:()=>h(!0),onBlur:()=>h(!1),className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1 text-xs text-text-primary",children:[(0,s.jsx)("option",{value:"",children:u?"현재 런 \xb7 목록 열기":f.isLoading?"불러오는 중…":g.length?"런을 고르세요":"최근 24시간 런 없음"}),u&&!g.some(e=>e.runId===u)&&(0,s.jsx)("option",{value:u,children:u}),g.some(e=>e.live)&&(0,s.jsx)("optgroup",{label:"도는 중",children:g.filter(e=>e.live).map(e=>(0,s.jsxs)("option",{value:e.runId,children:["● ",e.label]},e.runId))}),g.some(e=>!e.live)&&(0,s.jsx)("optgroup",{label:"끝난 런 (최근 24시간)",children:g.filter(e=>!e.live).map(e=>(0,s.jsxs)("option",{value:e.runId,children:[e.at?"".concat((0,o.Xf)(e.at).slice(0,5)," \xb7 "):"",e.label]},e.runId))})]})]}),u&&(0,s.jsx)("button",{type:"button",onClick:p?()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>void 0),l.replace("/live-run/?run=".concat(encodeURIComponent(null!=u?u:"")),{scroll:!1})}:()=>{if(!u)return;let e=document.documentElement.requestFullscreen;e&&e.call(document.documentElement).catch(()=>void 0),l.replace("/live-run/?run=".concat(encodeURIComponent(u),"&stage=1"),{scroll:!1})},className:"rounded-lg border px-3 py-1.5 text-xs font-semibold ".concat(p?"border-white/20 bg-white/10 text-white hover:bg-white/20":"ml-auto border-border text-text-primary hover:bg-surface-elevated"),children:p?"무대 모드 종료":"⛶ 무대 모드"})]}),f.isError&&(0,s.jsx)("p",{role:"status",className:"text-xs text-warning",children:"런 목록을 읽지 못했습니다 — 주소에 ?run=<runId> 를 주면 그 런은 그대로 그립니다."}),u?(0,s.jsx)(d.Yd,{runId:u,initialFolded:"folded"===x.get("units"),stageMode:p},u):(0,s.jsx)("ul",{className:"grid gap-2 sm:grid-cols-2",children:g.slice(0,12).map(e=>(0,s.jsx)("li",{children:(0,s.jsxs)("button",{type:"button",onClick:()=>v(e.runId),className:"w-full rounded-lg border border-border bg-surface p-3 text-left hover:bg-surface-elevated",children:[(0,s.jsx)("span",{className:"text-xs font-semibold ".concat(e.live?"text-amber-500":"text-text-tertiary"),children:e.live?"● 도는 중":"끝남 ".concat(e.at?(0,o.Xf)(e.at):"")}),(0,s.jsx)("span",{className:"mt-1 block truncate text-sm text-text-primary",children:e.label}),(0,s.jsx)("span",{className:"block font-mono text-[11px] text-text-tertiary",children:e.runId})]})},e.runId))})]})}function b(){return(0,s.jsx)(r.Suspense,{fallback:(0,s.jsx)("p",{className:"p-4 text-sm",children:"런 장면을 불러오는 중…"}),children:(0,s.jsx)(f,{})})}function f(){var e;let t=(0,a.useSearchParams)(),l=(0,a.useRouter)();if(!(null==(e=t.get("run"))?void 0:e.trim()))return(0,s.jsx)(u,{});let r="1"===t.get("stage");return(0,s.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col",children:[!r&&(0,s.jsx)("div",{className:"flex shrink-0 justify-end px-4 pt-2",children:(0,s.jsx)("button",{type:"button","aria-label":"최신 런 자동 따라가기",onClick:()=>l.replace("/live-run/"),className:"rounded border border-border bg-surface px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated",children:"최신 런 자동 따라가기"})}),(0,s.jsx)(h,{})]})}}},e=>{e.O(0,[8997,7571,3727,5616,4055,3603,8073,3985,5359,4306,3702,7358],()=>e(e.s=58497)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9902],{5010:(e,t,r)=>{"use strict";r.d(t,{D:()=>s,F:()=>a});let s="/loops?view=interact";function a(e){return(null==e?void 0:e.get("view"))==="resources"?"resources":(null==e?void 0:e.get("view"))==="interact"?"interact":"status"}},6258:(e,t,r)=>{Promise.resolve().then(r.bind(r,68697))},49620:(e,t,r)=>{"use strict";r.d(t,{r:()=>o});var s=r(17594),a=r(51596),n=r.n(a);let l=[{key:"autopilot",href:"/autopilot",num:"①",label:"미션",sub:"Autopilot"},{key:"tasks",href:"/tasks",num:"②",label:"작업",sub:"Tasks"},{key:"scheduler",href:"/scheduler",num:"③",label:"스케줄",sub:"Schedules"}];function o(e){let{active:t}=e;return(0,s.jsxs)("nav",{"aria-label":"Mission Fabric 파이프라인","data-testid":"fabric-stage-header",className:"flex flex-wrap items-center gap-1 text-xs",children:[(0,s.jsx)("span",{className:"mr-1 text-muted-foreground",children:"Missions"}),l.map((e,r)=>(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsxs)(n(),{href:e.href,"aria-current":e.key===t?"page":void 0,className:["rounded px-2 py-1 ring-1 transition-colors",e.key===t?"bg-primary/15 font-medium text-foreground ring-primary/40":"text-muted-foreground ring-border hover:bg-muted hover:text-foreground"].join(" "),children:[(0,s.jsx)("span",{className:"mr-1",children:e.num}),e.label,(0,s.jsx)("span",{className:"ml-1 text-[10px] opacity-70",children:e.sub})]}),r<l.length-1&&(0,s.jsx)("span",{className:"text-muted-foreground/50","aria-hidden":!0,children:"→"})]},e.key))]})}},50750:(e,t,r)=>{"use strict";r.d(t,{BX:()=>a});let s=new Map;function a(e,t){var r,a;let n=s.get(e);if(!n){let a;try{a=new EventSource(e)}catch(e){return null==(r=t.onConstructError)||r.call(t,e),()=>{}}let l={source:a,subscribers:new Set};a.onmessage=e=>{var t,r;for(let s of[...l.subscribers])null==(t=(r=s.handlers).onMessage)||t.call(r,e)},a.onerror=e=>{var t,r;for(let s of[...l.subscribers])null==(t=(r=s.handlers).onError)||t.call(r,e)},s.set(e,l),n=l}let l=n,o=[];for(let[e,r]of Object.entries(null!=(a=t.events)?a:{})){let t=e=>{r(e)};l.source.addEventListener(e,t),o.push([e,t])}let i={handlers:t};l.subscribers.add(i);let d=!1;return()=>{if(!d){for(let[e,t]of(d=!0,o))try{l.source.removeEventListener(e,t)}catch(e){}if(l.subscribers.delete(i),0===l.subscribers.size){try{l.source.close()}catch(e){}s.get(e)===l&&s.delete(e)}}}}},68697:(e,t,r)=>{"use strict";r.d(t,{LoopsView:()=>T});var s=r(17594),a=r(51596),n=r.n(a),l=r(96545),o=r(49620),i=r(99777),d=r(48082),c=r(87691),u=r(478);let m={"살아 있음":"bg-emerald-500/15 text-emerald-300 ring-emerald-500/30",늦음:"bg-red-500/15 text-red-300 ring-red-500/30",실패:"bg-red-500/15 text-red-300 ring-red-500/30",꺼짐:"bg-muted text-muted-foreground ring-border","판정 불가":"bg-muted text-muted-foreground ring-border"};function x(e){let{value:t}=e;return(0,s.jsx)("span",{"data-loop-verdict":t,className:"inline-flex shrink-0 rounded-full px-2 py-0.5 text-xs font-semibold ring-1 ".concat(m[t]),children:t})}function h(e){let{rows:t,state:r}=e;return"loading"===r?(0,s.jsx)("p",{role:"status",className:"text-sm text-muted-foreground",children:"루프 현황을 읽는 중…"}):"error"===r?(0,s.jsx)("p",{role:"alert",className:"text-sm text-red-300",children:"루프 현황을 읽지 못했습니다. 일부 레지스트리 조회가 실패했습니다. 데몬 연결을 확인하세요."}):t.length?(0,s.jsxs)("div",{className:"rounded-xl border border-border bg-card",children:[(0,s.jsxs)("table",{className:"hidden w-full table-fixed text-left text-sm md:table",children:[(0,s.jsx)("thead",{className:"border-b border-border text-muted-foreground",children:(0,s.jsxs)("tr",{children:[(0,s.jsx)("th",{scope:"col",className:"w-1/4 px-4 py-3",children:"루프 \xb7 층"}),(0,s.jsx)("th",{scope:"col",className:"px-4 py-3",children:"주인(자리)"}),(0,s.jsx)("th",{scope:"col",className:"px-4 py-3",children:"모드"}),(0,s.jsx)("th",{scope:"col",className:"px-4 py-3",children:"마지막 실행 시각"}),(0,s.jsx)("th",{scope:"col",className:"px-4 py-3",children:"판정"})]})}),(0,s.jsx)("tbody",{children:t.map(e=>{var t;return(0,s.jsxs)("tr",{className:"border-b border-border/60 last:border-0","data-loop-id":e.id,children:[(0,s.jsxs)("th",{scope:"row",className:"break-words px-4 py-3 font-medium",children:[e.name,(0,s.jsx)("span",{className:"block text-xs font-normal text-muted-foreground",children:e.layer})]}),(0,s.jsx)("td",{className:"px-4 py-3",children:e.owner}),(0,s.jsx)("td",{className:"px-4 py-3",children:e.mode}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsx)("time",{dateTime:null!=(t=e.lastRun)?t:void 0,children:e.lastRun?new Date(e.lastRun).toLocaleString("ko-KR"):"기록 없음"})}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsx)(x,{value:e.verdict})})]},e.id)})})]}),(0,s.jsx)("ul",{className:"divide-y divide-border/60 md:hidden",children:t.map(e=>{var t;return(0,s.jsxs)("li",{className:"min-w-0 px-3 py-3","data-loop-id":e.id,children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("strong",{className:"min-w-0 truncate text-sm",title:e.name,children:e.name}),(0,s.jsx)(x,{value:e.verdict})]}),(0,s.jsxs)("div",{className:"mt-1 flex flex-wrap gap-x-2 text-xs text-muted-foreground",children:[(0,s.jsx)("span",{children:e.layer}),(0,s.jsxs)("span",{children:["\xb7 ",e.owner]}),(0,s.jsxs)("span",{children:["\xb7 ",e.mode]}),(0,s.jsxs)("time",{dateTime:null!=(t=e.lastRun)?t:void 0,children:["\xb7 ",e.lastRun?new Date(e.lastRun).toLocaleString("ko-KR"):"기록 없음"]})]})]},e.id)})})]}):(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"등록된 루프\xb7크론이 없습니다."}),(0,s.jsx)("p",{"data-plain-lead":"loop",className:"text-xs text-muted-foreground",children:"루프 = 당번 서는 AI — 정해진 때마다 스스로 깨어 맡은 일을 보고 기록을 남긴다."})]})}function p(){var e,t;let{client:r}=(0,c.Q)(),[a,l]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=(0,u.Pz)(e=>r.fetchJson(e),e=>{let{rows:t,state:s}=e;return l({client:r,rows:t,state:s})});e.refresh();let t=window.setInterval(()=>void e.refresh(),3e4);return()=>{e.dispose(),window.clearInterval(t)}},[r]);let i=(null==a?void 0:a.client)===r?a:null;return(0,s.jsxs)("main",{className:"mx-auto max-w-[1200px] space-y-5 p-4",children:[(0,s.jsx)(o.r,{active:"scheduler"}),(0,s.jsxs)("header",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold",children:"루프 현황"}),(0,s.jsx)("span",{className:"rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:"beta \xb7 운영용"})]}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"데몬의 루프\xb7크론 레지스트리 \xb7 늦음은 마지막 실행 후 주기의 2배 초과"})]}),(0,s.jsx)(n(),{href:"/scheduler",className:"rounded-lg border border-border px-3 py-2 text-sm hover:bg-accent",children:"전체 스케줄 →"})]}),(0,s.jsx)(h,{rows:null!=(e=null==i?void 0:i.rows)?e:[],state:null!=(t=null==i?void 0:i.state)?t:"loading"})]})}var b=r(2430);r(12574);var f=r(71029),g=r(81513);let v=[{id:"머신",members:"mbp\xb7node-b\xb7node-c\xb7minim5\xb7elangram\xb7host-e(WSL)"},{id:"손",members:"Codex\xb7Claude Code"},{id:"모델",members:"gpt 계열\xb7Claude\xb7Grok\xb7GLM"},{id:"검색",members:"Exa\xb7Firecrawl\xb7Grok"},{id:"업무 도구",members:"Linear\xb7Telegram\xb7browser\xb7메일(초안)"},{id:"영상 파이프라인",members:"graphs/video/explainer-line.yaml"}],j=["title","text","message","prompt","variant","workflowName","nodeId","name"],w=["provider","model","agent","hand","tool","toolName","service","channel","who","machine","machineName","host","variant","workflowName"],y=["codex","claude"],N=["gpt","claude","grok","glm"],k=["exa","firecrawl","grok"],E=["linear","telegram","browser"];function C(e){return e.nextCell&&""!==e.nextCell.id.trim()?e.nextCell:null}function I(e,t){return e.split(/[^a-z0-9]+/).includes(t.toLowerCase())}function L(e){var t;return(null!=(t=e.podWorkers)?t:[]).filter(e=>"leased"===e.state&&!e.expired)}function M(e){var t;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now(),s=(null!=(t=e.recentEvents)?t:[]).filter(e=>"number"==typeof e.ts&&Number.isFinite(e.ts)&&e.ts<=r+5e3&&r-e.ts<=12e4);return v.map(t=>{let r=[...s].reverse().find(e=>(function(e,t){var r;let s=e.kind.toLowerCase(),a=function(e){if(!e)return"";let t=w.flatMap(t=>{let r=e[t];return"string"==typeof r?[r]:Array.isArray(r)?r.flatMap(e=>e&&"object"==typeof e?[e.who,e.provider,e.model,e.agent,e.kind].filter(e=>"string"==typeof e):[]):[]}),r=e.graphEvents;if(Array.isArray(r))for(let e of r)e&&"object"==typeof e&&t.push(...[e.who,e.provider,e.model,e.agent,e.kind].filter(e=>"string"==typeof e));return t.join(" ").toLowerCase()}(e.detail);return"머신"===t?s.startsWith("tab.")||s.startsWith("host."):"손"===t?s.startsWith("mission.")&&(y.some(e=>I(a,e))||Array.isArray(null==(r=e.detail)?void 0:r.graphEvents)&&e.detail.graphEvents.some(e=>!!e&&"object"==typeof e&&"kind"in e&&"hand"===e.kind&&"who"in e&&"string"==typeof e.who&&y.some(t=>I(e.who,t)))):"모델"===t?s.startsWith("session.")&&N.some(e=>I(a,e)):"검색"===t?(s.startsWith("trigger.")||s.includes(".search"))&&k.some(e=>I(a,e)||s.includes(e)):"업무 도구"===t?E.some(e=>s.startsWith("".concat(e,".")))||s.startsWith("hitl.")&&E.some(e=>I(a,e)):"영상 파이프라인"===t&&s.startsWith("media.")})(e,t.id)),a="머신"===t.id?function(e){var t;let r=[],s=[],a=null==(t=e.grid)?void 0:t.members;for(let e of null!=a?a:[])null!==e.occupied&&e.occupied>0?r.push("".concat(e.context," ").concat(e.occupied,"/").concat(e.capacity," occupied")):null===e.occupied&&s.push("".concat(e.context," 호스트 프로브 미측정").concat(e.reason?" (".concat(e.reason,")"):""));for(let t of(e.grid&&void 0===a?s.push("호스트 프로브 미측정"):e.grid&&(null==a?void 0:a.length)===0&&e.grid.poolReason&&s.push("호스트 프로브 미측정 (".concat(e.grid.poolReason,")")),L(e)))r.push("".concat(t.machine,"\xb7").concat(t.workerId," ").concat(t.state));return null==e.grid&&s.push("호스트 프로브 미측정"),null==e.podWorkers&&s.push("Pod 원장 미측정"),{active:r,unmeasured:s}}(e):"손"===t.id?{active:L(e).filter(e=>y.some(t=>e.workerId.toLowerCase().includes(t))).map(e=>"".concat(e.machine,"\xb7").concat(e.workerId," ").concat(e.state)),unmeasured:null==e.podWorkers?["Pod 원장 미측정"]:[]}:{active:[],unmeasured:[]},n=[r?function(e){let t=function(e){if(!e)return"";for(let t of j){let r=e[t];if("string"==typeof r&&""!==r.trim())return r.trim()}return""}(e.detail);return t?"".concat(e.kind," — ").concat(t):e.kind}(r):"",...a.active].filter(Boolean),l=[...null==e.recentEvents?["이벤트 스트림 미측정"]:[],...a.unmeasured],o=n.length>0;return{id:t.id,members:t.members,lit:o,status:o?"active":l.length?"unmeasured":"idle",activity:[...n,...l].join(" \xb7 ")}})}let S={resource:function(e){let{data:t}=e,{label:r,detail:a}=t;return(0,s.jsxs)("div",{className:"relative w-72 rounded-xl border border-sky-400 bg-[#173556] p-3 text-white shadow-md",children:[(0,s.jsx)("strong",{className:"break-words",children:(0,f.t)(r)}),(0,s.jsx)("p",{className:"mt-1 break-words text-xs",children:(0,f.t)(a)})]})},resourceCell:function(e){let{data:t}=e,{label:r,detail:a,lit:n,status:l,cellId:o}=t,i="active"===l?"● ".concat((0,f.t)(a)):"unmeasured"===l?"◌ ".concat((0,f.t)(a)):"○ 최근 관측 없음";return(0,s.jsxs)("div",{role:"group","aria-label":"".concat((0,f.t)(r)," ").concat(i),"data-resource-cell":o,"data-lit":String(n),"data-linked-node":g.qn,className:"relative w-64 rounded-xl border p-3 text-white shadow-md ".concat(n?"border-emerald-400 bg-[#14532d]":"border-slate-500 bg-slate-800"),children:[(0,s.jsx)("strong",{className:"break-words",children:(0,f.t)(r)}),(0,s.jsx)("p",{className:"mt-1 break-words text-xs ".concat(n?"text-emerald-200":"unmeasured"===l?"text-amber-200":"text-slate-400"),children:i})]})}};function R(e){let{snapshot:t}=e,[r,a]=(0,d.useState)(1),n="near"===(0,g.QU)(r),l=t.resource.seats,o=M(t,Date.now()),{nodes:i,edges:c}=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:M(e),s=e.resource.seats,a=t?s.map(e=>{var t;let r=C(e);return"".concat(e.seat," ").concat(e.running,"/").concat(e.cap," \xb7 몫 ").concat(null!=(t=e.baseShare)?t:"못 읽음"," \xb7 발사 상한 ").concat(e.launchCap," \xb7 임대 ").concat(e.borrowed," \xb7 대여 ").concat(e.lent," \xb7 ").concat(r?"대기 잡 ".concat(r.id," ").concat(r.title," (").concat(e.idle?"요청 가능":"대기 중",")"):"다음 잡 판정 없음")}).join(" / "):"자리 ".concat(s.length," \xb7 미배정 런 ").concat(e.resource.unassigned);return{nodes:[{id:g.qn,type:"resource",position:{x:0,y:0},data:{label:"자원 관리 루프",detail:a}},...r.map((e,t)=>{let s=t/r.length*Math.PI*2-Math.PI/2,a=e.members?"".concat(e.id,"(").concat(e.members,")"):e.id;return{id:"resource-cell:".concat(e.id),type:"resourceCell",position:{x:Math.round(320*Math.cos(s)),y:Math.round(240*Math.sin(s))},data:{label:a,detail:e.activity,lit:e.lit,status:e.status,cellId:e.id}}})],edges:r.map(e=>({id:"resource-edge:".concat(e.id),source:g.qn,target:"resource-cell:".concat(e.id),animated:e.lit}))}}(t,n,o);return(0,s.jsxs)("section",{"aria-label":"자원 LOOP-INTERACT","data-observed-at":t.resource.now,className:"space-y-3",children:[(0,s.jsx)("p",{className:"text-sm",children:"자리 \xb7 잡 \xb7 임대 \xb7 대기 — 확대하면 자리 몫과 다음 잡을 볼 수 있습니다."}),(0,s.jsx)("div",{className:"h-[520px] w-full min-w-0 rounded-xl border bg-[#10243b]",children:(0,s.jsxs)(b.Gc,{nodes:i,edges:c,nodeTypes:S,fitView:!0,minZoom:.25,maxZoom:2.5,onInit:e=>a(e.getZoom()),onMove:(e,t)=>a(t.zoom),nodesDraggable:!1,nodesConnectable:!1,edgesReconnectable:!1,deleteKeyCode:null,children:[(0,s.jsx)(b.VS,{}),(0,s.jsx)(b.H2,{showInteractive:!1})]})}),(0,s.jsx)("ul",{"aria-label":"데모 자원",className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-3",children:o.map(e=>{let t=e.members?"".concat(e.id,"(").concat(e.members,")"):e.id;return(0,s.jsxs)("li",{"data-resource-cell":e.id,"data-lit":String(e.lit),className:"min-h-16 rounded-lg border p-3 ".concat(e.lit?"border-emerald-400 bg-emerald-950 text-emerald-100":"border-border bg-card text-muted-foreground"),children:[(0,s.jsx)("strong",{children:(0,f.t)(t)}),(0,s.jsx)("p",{className:"mt-1 text-xs ".concat("unmeasured"===e.status?"text-amber-700 dark:text-amber-300":""),children:"active"===e.status?"● ".concat((0,f.t)(e.activity)):"unmeasured"===e.status?"◌ ".concat((0,f.t)(e.activity)):"○ 최근 관측 없음"})]},e.id)})}),(0,s.jsx)("ul",{"aria-label":"자원 목록",className:"grid gap-2 sm:grid-cols-2",children:l.map(e=>{var t;let r=C(e);return(0,s.jsxs)("li",{"data-cell-id":r?r.id:void 0,className:"rounded-lg border p-3",children:[(0,s.jsxs)("strong",{children:[e.seat," ",e.running,"/",e.cap]})," \xb7 몫 ",null!=(t=e.baseShare)?t:"못 읽음"," \xb7 발사 상한 ",e.launchCap," \xb7 ","임대 ",e.borrowed," \xb7 대여 ",e.lent," \xb7 ",r?"대기 잡 ".concat((0,f.t)(r.id)," \xb7 ").concat((0,f.t)(r.title)," \xb7 ").concat(e.idle?"요청 가능":"대기 중"):"다음 잡 판정 없음"]},e.seat)})})]})}function W(){let{client:e}=(0,c.Q)(),[t,r]=(0,d.useState)(null);(0,d.useEffect)(()=>{let t=!0,s=!1,a=async()=>{if(t&&!s&&!document.hidden){s=!0;try{var a,n;let[s,l,o]=await Promise.all([e.fetchJson("/v1/loops/resources"),e.fetchJson("/v1/nexus").catch(()=>null),e.fetchJson("/v1/grid").catch(()=>null)]),i={...s,recentEvents:null!=(n=null==l?void 0:l.recentEvents)?n:null,grid:o};if(!Array.isArray(null==(a=i.resource)?void 0:a.seats))throw Error("resource observation unavailable");t&&r({source:e,snapshot:i,error:!1})}catch(s){t&&r({source:e,snapshot:null,error:!0})}finally{s=!1}}};a();let n=window.setInterval(()=>{a()},1e4),l=()=>{a()};return document.addEventListener("visibilitychange",l),()=>{t=!1,window.clearInterval(n),document.removeEventListener("visibilitychange",l)}},[e]);let a=(null==t?void 0:t.source)===e?t:null;return(0,s.jsxs)("main",{className:"mx-auto max-w-[1400px] space-y-4 p-4",children:[(0,s.jsxs)("header",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold",children:"자원"}),(0,s.jsx)(n(),{href:"/loops?view=interact",className:"rounded-lg border px-3 py-2 text-sm",children:"루프 상호작용 →"})]}),(null==a?void 0:a.error)&&(0,s.jsx)("p",{role:"alert",children:"자원 원천을 읽지 못했습니다"}),!a&&(0,s.jsx)("p",{role:"status",children:"자원을 읽는 중…"}),(null==a?void 0:a.snapshot)&&(0,s.jsx)(R,{snapshot:a.snapshot})]})}var A=r(5010);function P(){return(0,s.jsxs)("main",{className:"mx-auto min-w-0 max-w-[1400px] space-y-4 p-4",children:[(0,s.jsx)(o.r,{active:"scheduler"}),(0,s.jsxs)("header",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("h1",{className:"text-xl font-semibold",children:"루프 상호작용"}),(0,s.jsx)("span",{className:"rounded-full border border-border px-2 py-0.5 text-xs text-muted-foreground",children:"beta \xb7 운영용"})]}),(0,s.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"자리\xb7루프\xb7런 사이에 오간 실제 사건 \xb7 새 사건이 들어오면 다시 읽습니다"})]}),(0,s.jsx)(n(),{href:"/loops",className:"rounded-lg border border-border px-3 py-2 text-sm hover:bg-accent",children:"루프 현황 →"})]}),(0,s.jsx)("div",{className:"min-w-0 rounded-2xl bg-[#0c1828] text-[#f1f5fa]",children:(0,s.jsx)(i.p1,{initialMode:"map"})})]})}function T(){let e=(0,l.useSearchParams)(),t=(0,A.F)(e);return"resources"===t?(0,s.jsx)(W,{}):"interact"===t?(0,s.jsx)(P,{}):(0,s.jsx)(p,{})}}},e=>{e.O(0,[8997,3727,1596,3603,8073,7648,7307,8987,5456,9777,4306,3702,7358],()=>e(e.s=6258)),_N_E=e.O()}]);
@@ -1 +0,0 @@
1
- (self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2967],{15249:(e,t,n)=>{"use strict";n.d(t,{Zr:()=>a,f6:()=>s,oD:()=>l});let r="elanous.daemon.sessionId";function s(){return"undefined"!=typeof crypto&&"function"==typeof crypto.randomUUID?crypto.randomUUID():"s-".concat(Date.now().toString(36),"-").concat(Math.random().toString(36).slice(2,10))}function l(){let e=function(){let e=new URLSearchParams(window.location.search).get("session");return e?(localStorage.setItem(r,e),e):localStorage.getItem(r)}();if(e)return e;let t=s();return localStorage.setItem(r,t),t}function a(){let e=s();return localStorage.setItem(r,e),e}},19375:(e,t,n)=>{Promise.resolve().then(n.bind(n,43056))},43056:(e,t,n)=>{"use strict";n.d(t,{MarketPanel:()=>h});var r=n(17594),s=n(48082),l=n(87691),a=n(46982);let i={resolve:"받는 중",verify:"서명 확인",consent:"권한 동의",credentials:"자격 필요",registered:"등록",done:"완료",failed:"실패"},o={signature:"서명을 확인하지 못했습니다.",scan:"플러그인 파일을 확인하지 못했습니다.","consent-denied":"필요한 권한에 동의하지 않았습니다.",credentials:"연결 정보가 필요합니다.",conflict:"이미 설치된 플러그인입니다.",io:"설치 중 오류가 발생했습니다."};var c=n(67307);function d(e){return e.fields.map(e=>{let{name:t,env:n,set:r}=e;return{name:t,env:n,set:r}})}function u(e){if(e instanceof c.Iu){if(404===e.status)return"설치된 플러그인을 찾을 수 없습니다.";if(401===e.status)return"연결 정보를 관리할 권한이 없습니다.";if(400===e.status)return"선언되지 않은 연결 정보 항목입니다."}return"연결 정보를 불러오거나 저장하지 못했습니다."}function m(e){let{client:t,name:n}=e,[l,a]=(0,s.useState)(null),[i,o]=(0,s.useState)({}),[c,m]=(0,s.useState)([]),[p,h]=(0,s.useState)(null),[x,b]=(0,s.useState)(!1);async function f(e){if(e.preventDefault(),x||!l)return;let{fields:r}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n={};for(let[t,r]of Object.entries(e))r.trim()&&(n[t]=r);for(let e of t)n[e]=null;return{fields:n}}(i,c);if(0!==Object.keys(r).length){b(!0),h(null);try{await t.putPluginCredentials(n,r),o({}),m([]),a(null),a(await t.getPluginCredentials(n))}catch(e){h(u(e))}finally{b(!1)}}}return(0,s.useEffect)(()=>{let e=!0;return a(null),o({}),m([]),h(null),t.getPluginCredentials(n).then(t=>{e&&a(t)}).catch(t=>{e&&h(u(t))}),()=>{e=!1}},[t,n]),(0,r.jsxs)("form",{className:"space-y-3 rounded-lg border border-border p-4",onSubmit:e=>void f(e),children:[(0,r.jsx)("h3",{className:"font-medium",children:"연결 정보"}),p&&(0,r.jsx)("p",{role:"alert",className:"text-sm",children:p}),!l&&!p&&(0,r.jsx)("p",{role:"status",children:"연결 정보를 불러오는 중…"}),l&&0===d(l).length&&(0,r.jsx)("p",{className:"text-sm",children:"입력할 연결 정보가 없습니다."}),l&&d(l).map(e=>{var t;return(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("label",{className:"block text-sm font-medium",htmlFor:"credential-".concat(n,"-").concat(e.name),children:e.name}),(0,r.jsxs)("small",{className:"block text-muted-foreground",children:["환경 변수: ",(0,r.jsx)("code",{children:e.env})]}),(0,r.jsx)("p",{className:"text-sm",role:"status",children:e.set?"✓ 저장됨":"비어 있음"}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("input",{id:"credential-".concat(n,"-").concat(e.name),type:"password",autoComplete:"new-password",className:"min-w-0 flex-1 rounded border border-border bg-background px-2 py-1",value:null!=(t=i[e.name])?t:"",disabled:x,onChange:t=>{o(n=>({...n,[e.name]:t.target.value})),m(t=>t.filter(t=>t!==e.name))}}),e.set&&(0,r.jsx)("button",{type:"button",className:"rounded border px-2 py-1 text-sm",disabled:x,onClick:()=>{o(t=>({...t,[e.name]:""})),m(t=>t.includes(e.name)?t:[...t,e.name])},children:c.includes(e.name)?"삭제 예정":"지우기"})]})]},e.name)}),l&&l.fields.length>0&&(0,r.jsx)("button",{type:"submit",disabled:x||0===c.length&&!Object.values(i).some(e=>e.trim()),className:"rounded border px-3 py-1 text-sm",children:x?"저장 중…":"저장"})]})}let p={name:"",description:"",instructions:"",connectorId:"",credentialNames:""};function h(){var e;let t=(0,a.Qj)(),n=(0,s.useContext)(l.C),[c,d]=(0,s.useState)("browse"),[u,h]=(0,s.useState)(null),[x,b]=(0,s.useState)([]),[f,g]=(0,s.useState)(null),[j,y]=(0,s.useState)(!1),[w,N]=(0,s.useState)(!1),[v,k]=(0,s.useState)(!1),[C,S]=(0,s.useState)(!1),[E,I]=(0,s.useState)(null),[P,z]=(0,s.useState)(!1),[O,D]=(0,s.useState)([]),[q,U]=(0,s.useState)(null),[M,A]=(0,s.useState)(p),[W,_]=(0,s.useState)(""),[L,R]=(0,s.useState)([]),[T,F]=(0,s.useState)([]),[Y,J]=(0,s.useState)(null),[Q,V]=(0,s.useState)(!1),[$,Z]=(0,s.useState)(null);async function B(){if(!Q){V(!0),J(null);try{let e=W.trim(),t=function(e,t){let n=e.trim();if(!n)throw Error("플러그인 설명을 입력하세요.");return t.description?{...t,instructions:"".concat(t.instructions||t.description,"\n").concat(n)}:{...t,description:n,instructions:t.instructions||n}}(e,M),r=[...L,{role:"user",text:e}];if(null==n?void 0:n.config.baseUrl){let e=r.map(e=>"".concat("user"===e.role?"사용자":"마법사",": ").concat(e.text)).join("\n"),t=await fetch("".concat(n.config.baseUrl.replace(/\/$/,""),"/v1/prompt"),{method:"POST",headers:{"content-type":"application/json",...n.config.token?{authorization:"Bearer ".concat(n.config.token)}:{}},body:JSON.stringify({tools:"none",userText:["플러그인 연구 초안 폼 편집 도우미입니다. 도구 실행\xb7설치\xb7저장은 하지 마세요.","대화와 현재 폼을 바탕으로 description\xb7instructions\xb7reply 문자열이 있는 JSON 객체만 반환하세요. reply는 사용자에게 다음에 무엇을 다듬을지 묻거나 폼 변경 내용을 설명하는 자연스러운 답변입니다.","현재 설명: ".concat(M.description,"\n현재 지시문: ").concat(M.instructions),e].join("\n\n")})});if(!t.ok)throw Error("마법사 대화를 처리하지 못했습니다 (".concat(t.status,"). 다시 요청하세요."));let s=await t.json();if("string"!=typeof s.text)throw Error("마법사 응답에 폼이 없습니다. 다시 요청하세요.");let l=function(e,t){let n,r=e.trim(),s=r.startsWith("```json")&&r.endsWith("```")?r.slice(7,-3).trim():r;if(!s.startsWith("{")||!s.endsWith("}"))throw Error("마법사 응답에 폼이 없습니다. 다시 요청하세요.");try{n=JSON.parse(s)}catch(e){throw Error("마법사 응답을 읽지 못했습니다. 다시 요청하세요.")}if(!n||"object"!=typeof n||Array.isArray(n))throw Error("마법사 응답에 폼이 없습니다. 다시 요청하세요.");let l=n;if("string"!=typeof l.description||!l.description.trim()||"string"!=typeof l.instructions||!l.instructions.trim()||"string"!=typeof l.reply||!l.reply.trim())throw Error("마법사 응답에 설명과 지시문과 답변이 필요합니다. 다시 요청하세요.");return{form:{...t,description:l.description.trim(),instructions:l.instructions.trim()},reply:l.reply.trim()}}(s.text,M);A(e=>({...e,description:l.form.description,instructions:l.form.instructions})),R([...r,{role:"assistant",text:l.reply}])}else A(t),R([...r,{role:"assistant",text:"초안을 폼에 옮겼습니다. LLM 대화는 데몬 연결 후 사용할 수 있습니다. 내용을 검토하고 저장하세요."}]);_(""),J(null)}catch(e){J(e instanceof Error?e.message:"초안을 만들지 못했습니다.")}finally{V(!1)}}}async function K(){if(t&&!Q){V(!0),J(null);try{let e=function(e){var t,n;let r=e.name.trim();if(!/^[a-z0-9][a-z0-9-]{1,31}$/.test(r))throw Error("플러그인 이름은 영문 소문자\xb7숫자\xb7하이픈 2~32자로 입력하세요.");if(!e.description.trim())throw Error("플러그인 설명을 입력하세요.");let s=e.connectorId.trim(),l=e.credentialNames.split(",").map(e=>e.trim()).filter(Boolean);if(s&&!/^[a-z0-9][a-z0-9-]{1,31}$/.test(s))throw Error("연결 이름이 올바르지 않습니다.");if(!s&&l.length)throw Error("연결 이름을 먼저 입력하세요.");if(l.some(e=>!/^[A-Za-z_][A-Za-z0-9_-]*$/.test(e))||new Set(l).size!==l.length)throw Error("자격 정보에는 중복 없는 항목 이름만 입력하세요.");let a=null!=(t=e.otherConnectors)?t:[];if(s&&a.some(e=>e.id===s))throw Error("연결 이름이 중복됩니다.");return{name:r,draft:{description:e.description.trim(),...s||a.length?{connectors:[...s?[{id:s,credentials:l.map(e=>({name:e}))}]:[],...a]}:{},skill:{description:null!=(n=e.skillDescription)?n:e.description.trim(),instructions:e.instructions.trim()||e.description.trim(),...e.requires?{requires:e.requires}:{}}}}}(M);if($&&$!==e.name)throw Error("다시 만들 때는 기존 플러그인 이름을 유지하세요. 새 이름으로 만들려면 새 초안을 선택하세요.");await t.saveWizardPlugin({...e,...$===e.name?{regenerate:!0}:{}}),Z(e.name),R(t=>[...t,{role:"assistant",text:"".concat(e.name," 연구 초안을 저장했습니다. 실행\xb7설치 전 그래프 단계를 구현하고 검증해야 합니다.")}]);try{F((await t.getWizardPlugins()).plugins)}catch(e){J("초안은 저장했지만 만든 플러그인 목록을 불러오지 못했습니다. 탭을 다시 열어 목록을 새로고침하세요.")}}catch(e){J(e instanceof Error?e.message:"플러그인을 저장하지 못했습니다.")}finally{V(!1)}}}async function H(){if(d("wizard"),t)try{F((await t.getWizardPlugins()).plugins),J(null)}catch(e){J("만든 플러그인 목록을 불러오지 못했습니다.")}}async function G(){if(t){S(!0),I(null);try{if(!(await t.refreshPluginMarket("elanous")).ok)throw Error("공식 마켓을 받지 못했습니다.");h(await t.getPluginsIndex()),y(!1)}catch(e){I("공식 마켓을 받지 못했습니다.")}finally{S(!1)}}}async function X(){if(!t||!f)return;S(!0),D([]),I(null);let e=null;try{await t.installMarketPlugin("".concat(f.plugin.name,"@").concat(f.market.name),f.plugin.capabilities,t=>{let n=function(e){let t;try{t=JSON.parse(e)}catch(e){return null}if(!t||"object"!=typeof t)return null;let n=t.event;if("string"!=typeof n||!Object.hasOwn(i,n))return null;if("failed"===n){var r;let e=t.reason,n=t.detail,s="string"==typeof e&&null!=(r=o[e])?r:o.io;return{step:"실패",reason:"string"==typeof n&&n.trim()?"".concat(s," — ").concat(n.trim()):s}}return"credentials"===n?!0===t.required?{step:"자격 필요",credentialsRequired:!0}:null:{step:i[n]}}(t);n&&(("완료"===n.step||"실패"===n.step)&&(e=n.step),D(e=>[...e,n]))}),e||D(e=>[...e,{step:"실패",reason:"설치가 끝나지 않았습니다."}])}catch(t){e||D(e=>[...e,{step:"실패",reason:"설치 중 오류가 발생했습니다."}])}if("완료"===e)try{b(await t.getInstalledPlugins()),k(!0),N(!1)}catch(e){N(!0),I("설치는 완료됐지만 설치 목록을 불러오지 못했습니다.")}S(!1)}async function ee(e){if(t){S(!0),I(null);try{await t.removeMarketPlugin(e)}catch(e){I("플러그인을 제거하지 못했습니다."),S(!1);return}U(null),b(t=>t.filter(t=>t.name!==e));try{b(await t.getInstalledPlugins()),k(!0),N(!1)}catch(e){N(!0),I("플러그인은 제거됐지만 설치 목록을 불러오지 못했습니다.")}finally{S(!1)}}}(0,s.useEffect)(()=>{if(!t)return;let e=!0;return h(null),b([]),g(null),y(!1),N(!1),k(!1),D([]),z(!1),U(null),I(null),F([]),A(p),R([]),Z(null),J(null),t.getPluginsIndex().then(t=>{e&&h(t)}).catch(()=>{e&&y(!0)}),t.getInstalledPlugins().then(t=>{e&&(b(t),k(!0))}).catch(()=>{e&&(N(!0),k(!0))}),()=>{e=!1}},[t]);let et=u?u.markets.flatMap(e=>e.plugins.map(t=>({market:e,plugin:t,price:function(e){var t;if("free"===e.model)return"무료";let n=void 0===e.amount?"가격 미정":"".concat(e.amount.toLocaleString("ko-KR")," ").concat(null!=(t=e.currency)?t:"").trim();return"subscription"===e.model&&e.period?"".concat(n," / ").concat(e.period):n}(t.pricing),badge:function(e){switch(e){case"ok":return"✅ 서명 확인";case"missing":return"⚠️ 서명 없음";case"unknown-key":return"⚠️ 알 수 없는 서명 키";case"malformed":return"⚠️ 잘못된 서명";case"stale":return"⚠️ 유효하지 않은 서명"}}(e.signature)}))).sort((e,t)=>("ok"!==e.market.signature)-("ok"!==t.market.signature)||e.plugin.name.localeCompare(t.plugin.name)||e.market.name.localeCompare(t.market.name)):[];return(0,r.jsxs)("main",{className:"mx-auto max-w-5xl space-y-6 p-5 text-foreground","aria-label":"마켓",children:[(0,r.jsxs)("header",{children:[(0,r.jsx)("h1",{className:"text-2xl font-semibold",children:"마켓"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"확인된 플러그인을 살펴보고 설치할 수 있습니다."})]}),(0,r.jsx)("nav",{"aria-label":"마켓 탭",className:"flex flex-wrap gap-2",children:[["browse","찾아보기"],["detail","상세"],["installed","설치됨"],["wizard","플러그인 만들기"]].map(e=>{let[t,n]=e;return(0,r.jsx)("button",{type:"button","aria-current":c===t?"page":void 0,className:"rounded-lg border px-4 py-2 text-sm ".concat(c===t?"border-blue-500 font-semibold":"border-border"),onClick:()=>{"wizard"===t?H():d(t)},children:n},t)})}),!t&&(0,r.jsx)("p",{role:"status",children:"서버 연결이 설정되지 않았습니다. 설정에서 서버 주소를 입력하세요."}),E&&(0,r.jsx)("p",{role:"alert",children:E}),"installed"!==c&&"wizard"!==c&&j&&(0,r.jsx)("p",{role:"alert",children:"마켓을 불러오지 못했습니다."}),"installed"!==c&&"wizard"!==c&&t&&!j&&!u&&(0,r.jsx)("p",{role:"status",children:"마켓을 불러오는 중…"}),"installed"===c&&w&&(0,r.jsx)("p",{role:"alert",children:"설치 목록을 불러오지 못했습니다."}),"installed"===c&&t&&!v&&(0,r.jsx)("p",{role:"status",children:"설치 목록을 불러오는 중…"}),"browse"===c&&u&&(0===u.markets.length?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{children:"아직 받아 둔 마켓이 없습니다."}),(0,r.jsx)("button",{type:"button",disabled:C||!t,className:"rounded border px-3 py-2",onClick:()=>void G(),children:"공식 마켓 받기"})]}):0===et.length?(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{children:"등록된 플러그인이 없습니다."}),(0,r.jsx)("button",{type:"button",disabled:C||!t,className:"rounded border px-3 py-2",onClick:()=>void G(),children:"공식 마켓 받기"})]}):(0,r.jsx)("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:et.map(e=>{var t;return(0,r.jsxs)("article",{className:"rounded-xl border border-border p-4 space-y-2",children:[(0,r.jsxs)("h2",{className:"font-semibold",children:[e.plugin.name," ",(0,r.jsxs)("span",{className:"text-xs font-normal",children:["v",e.plugin.version]})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:null!=(t=e.plugin.description)?t:"설명이 없습니다."}),(0,r.jsxs)("p",{className:"text-sm",children:[e.price," \xb7 ",(0,r.jsx)("span",{title:e.market.detail,children:e.badge})]}),(0,r.jsx)("button",{type:"button",className:"rounded border px-3 py-1 text-sm",onClick:()=>{g(e),z(!1),D([]),d("detail")},children:"상세 보기"})]},"".concat(e.market.name,"/").concat(e.plugin.name,"/").concat(e.plugin.version))})})),"detail"===c&&!j&&(f?(0,r.jsxs)("section",{className:"space-y-4 rounded-xl border border-border p-5","aria-label":"플러그인 상세",children:[(0,r.jsxs)("h2",{className:"text-xl font-semibold",children:[f.plugin.name," ",(0,r.jsxs)("small",{children:["v",f.plugin.version]})]}),(0,r.jsx)("p",{children:f.plugin.description}),(0,r.jsxs)("p",{children:[f.price," \xb7 ",f.badge]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"font-medium",children:"권한"}),(0,r.jsx)("ul",{children:f.plugin.capabilities.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"font-medium",children:"연결 정보 항목"}),f.plugin.connectors.map(e=>(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{children:"연결 정보"}),(0,r.jsx)("ul",{children:e.userConfig.map(e=>(0,r.jsxs)("li",{children:[e.label,e.secret?" \xb7 비공개 정보":""]},e.key))})]},e.id))]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"font-medium",children:"포함된 기능"}),(0,r.jsx)("ul",{children:null==(e=f.plugin.graphs)?void 0:e.map(e=>(0,r.jsx)("li",{children:e},e))})]}),(0,r.jsxs)("p",{children:["파일 확인값: ",(0,r.jsx)("code",{children:f.plugin.sha256.slice(0,12)})]}),P?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("p",{children:"이 플러그인이 요청하는 권한을 확인하세요."}),(0,r.jsx)("ul",{children:f.plugin.capabilities.map(e=>(0,r.jsx)("li",{children:e},e))}),(0,r.jsx)("button",{type:"button",disabled:C,className:"rounded border px-3 py-1",onClick:()=>void X(),children:"동의하고 설치"}),(0,r.jsx)("button",{type:"button",disabled:C,className:"rounded border px-3 py-1",onClick:()=>z(!1),children:"취소"})]}):(0,r.jsx)("button",{type:"button",disabled:C||"ok"!==f.market.signature,className:"rounded border px-3 py-1",onClick:()=>z(!0),children:"설치"}),O.length>0&&(0,r.jsx)("ol",{"aria-label":"설치 진행",className:"space-y-1",children:O.map((e,t)=>(0,r.jsxs)("li",{role:"실패"===e.step?"alert":void 0,children:[e.step,e.reason?": ".concat(e.reason):"",e.credentialsRequired?" — 이 플러그인은 연결 정보가 필요합니다.":""]},t))}),t&&O.some(e=>e.credentialsRequired)&&(0,r.jsx)(m,{client:t,name:f.plugin.name},"".concat(f.plugin.name,"-").concat(O.some(e=>"완료"===e.step||"등록"===e.step)))]}):(0,r.jsx)("p",{children:"찾아보기에서 플러그인을 선택하세요."})),"wizard"===c&&(0,r.jsxs)("section",{"aria-label":"플러그인 마법사",className:"min-w-0 space-y-5",children:[(0,r.jsx)("h2",{className:"text-xl font-semibold",children:"플러그인 마법사"}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"대화로 요청을 정리하고 폼을 다듬어 연구 초안을 만듭니다. 생성된 그래프는 아직 실행\xb7설치할 수 없습니다."}),(0,r.jsxs)("div",{className:"grid min-w-0 gap-5 md:grid-cols-2",children:[(0,r.jsxs)("section",{"aria-label":"마법사 대화 입력",className:"min-w-0 space-y-3",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"대화로 요청하기"}),(0,r.jsx)("ol",{"aria-label":"마법사 대화",className:"max-h-64 space-y-2 overflow-y-auto break-words","aria-live":"polite",children:L.map((e,t)=>(0,r.jsxs)("li",{className:"rounded-lg border border-border p-3",children:[(0,r.jsxs)("strong",{children:["user"===e.role?"나":"마법사",": "]}),e.text]},t))}),(0,r.jsxs)("label",{className:"block",children:["만들고 싶은 플러그인",(0,r.jsx)("textarea",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:W,disabled:Q,onChange:e=>{Q||_(e.target.value)}})]}),(0,r.jsx)("button",{type:"button",disabled:Q,className:"w-full rounded border px-3 py-2 sm:w-auto",onClick:()=>void B(),children:Q?"대화 중…":"대화에 추가"})]}),(0,r.jsxs)("section",{"aria-label":"마법사 초안 편집",className:"min-w-0 space-y-3",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"폼으로 다듬기"}),(0,r.jsxs)("div",{className:"grid min-w-0 gap-3",children:[(0,r.jsxs)("label",{className:"min-w-0 break-words",children:["이름 (영문 소문자\xb7숫자\xb7하이픈)",(0,r.jsx)("input",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:M.name,disabled:Q,onChange:e=>{Q||A(t=>({...t,name:e.target.value}))}})]}),(0,r.jsxs)("label",{className:"min-w-0 break-words",children:["설명",(0,r.jsx)("input",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:M.description,disabled:Q,onChange:e=>{Q||A(t=>({...t,description:e.target.value}))}})]}),(0,r.jsxs)("label",{className:"min-w-0 break-words",children:["스킬 지시문",(0,r.jsx)("textarea",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:M.instructions,disabled:Q,onChange:e=>{Q||A(t=>({...t,instructions:e.target.value}))}})]}),(0,r.jsxs)("label",{className:"min-w-0 break-words",children:["연결 이름 (선택)",(0,r.jsx)("input",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:M.connectorId,disabled:Q,onChange:e=>{Q||A(t=>({...t,connectorId:e.target.value}))}})]}),(0,r.jsxs)("label",{className:"min-w-0 break-words",children:["자격 정보 항목 이름 (쉼표 구분, 값은 입력하지 마세요)",(0,r.jsx)("input",{className:"mt-1 w-full min-w-0 rounded border border-border bg-background p-2",value:M.credentialNames,disabled:Q,onChange:e=>{Q||A(t=>({...t,credentialNames:e.target.value}))}})]})]}),Y&&(0,r.jsx)("p",{role:"alert",children:Y}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsx)("button",{type:"button",disabled:!t||Q,className:"rounded border px-3 py-2",onClick:()=>void K(),children:Q?"저장 중…":$===M.name?"다시 만들기":"초안 만들기"}),(0,r.jsx)("button",{type:"button",disabled:Q,className:"rounded border px-3 py-2",onClick:()=>{A(p),R([]),_(""),Z(null),J(null)},children:"새 초안"})]})]})]}),(0,r.jsxs)("section",{"aria-label":"만든 플러그인",className:"min-w-0 space-y-2",children:[(0,r.jsx)("h3",{className:"font-semibold",children:"만든 플러그인"}),0===T.length?(0,r.jsx)("p",{children:"만든 초안이 없습니다."}):(0,r.jsx)("ul",{className:"grid gap-2 lg:grid-cols-2",children:T.map(e=>(0,r.jsxs)("li",{className:"flex min-w-0 flex-col items-start gap-2 rounded border border-border p-3",children:[(0,r.jsxs)("span",{className:"max-w-full break-words",children:[e.name," \xb7 ",e.description]}),(0,r.jsx)("button",{type:"button",disabled:Q,className:"rounded border px-3 py-2",onClick:()=>{if(!Q){var t,n,r,s,l,a,i,o,c,d,u,m;A({name:e.name,description:e.draft.description,instructions:null!=(d=null==(t=e.draft.skill)?void 0:t.instructions)?d:"",connectorId:null!=(u=null==(r=e.draft.connectors)||null==(n=r[0])?void 0:n.id)?u:"",credentialNames:null!=(m=null==(a=e.draft.connectors)||null==(l=a[0])||null==(s=l.credentials)?void 0:s.map(e=>e.name).join(", "))?m:"",...(null==(o=e.draft.skill)||null==(i=o.requires)?void 0:i.length)?{requires:e.draft.skill.requires}:{},...(null==(c=e.draft.skill)?void 0:c.description)&&e.draft.skill.description!==e.draft.description?{skillDescription:e.draft.skill.description}:{},...e.draft.connectors&&e.draft.connectors.length>1?{otherConnectors:e.draft.connectors.slice(1)}:{}}),Z(e.name),R([]),J(null)}},children:"다듬고 다시 만들기"})]},e.name))})]})]}),"installed"===c&&v&&!w&&(0===x.length?(0,r.jsx)("p",{children:"설치된 플러그인이 없습니다."}):(0,r.jsx)("ul",{className:"space-y-2",children:x.map(e=>(0,r.jsxs)("li",{className:"rounded-lg border border-border p-3",children:[e.name," \xb7 v",e.version," \xb7 설치 시각: ",e.installedAt&&Number.isFinite(Date.parse(e.installedAt))?(0,r.jsx)("time",{dateTime:e.installedAt,children:new Date(e.installedAt).toLocaleString("ko-KR")}):"알 수 없음",q===e.name?(0,r.jsxs)("span",{className:"ml-3",children:["제거할까요? ",(0,r.jsx)("button",{type:"button",disabled:C,onClick:()=>void ee(e.name),children:"제거 확인"})," ",(0,r.jsx)("button",{type:"button",onClick:()=>U(null),children:"취소"})]}):(0,r.jsx)("button",{type:"button",disabled:C,className:"ml-3 rounded border px-3 py-1",onClick:()=>U(e.name),children:"제거"}),t&&(0,r.jsxs)("details",{className:"mt-3",children:[(0,r.jsx)("summary",{className:"cursor-pointer",children:"연결 정보"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(m,{client:t,name:e.name})})]})]},"".concat(e.market,"/").concat(e.name,"/").concat(e.version)))}))]})}},46982:(e,t,n)=>{"use strict";n.d(t,{M1:()=>c,Qj:()=>d,tI:()=>o});var r=n(17594),s=n(48082),l=n(67384),a=n(34585);let i=(0,s.createContext)(null);function o(e){let{client:t,queryClient:n,defaultStaleTimeMs:o,children:c}=e,d=(0,s.useMemo)(()=>null!=n?n:new l.E({defaultOptions:{queries:{staleTime:null!=o?o:2e3,refetchOnWindowFocus:!1}}}),[n,o]);return(0,r.jsx)(i.Provider,{value:t,children:(0,r.jsx)(a.Ht,{client:d,children:c})})}function c(){let e=(0,s.useContext)(i);if(!e)throw Error("useNexusClient must be used within <NexusProvider>");return e}function d(){return(0,s.useContext)(i)}},87691:(e,t,n)=>{"use strict";n.d(t,{C:()=>c,DaemonProvider:()=>d,Q:()=>u});var r=n(17594),s=n(48082),l=n(87338),a=n(15249),i=n(47648),o=n(91659);let c=(0,s.createContext)(null);function d(e){let{children:t}=e,n={baseUrl:"",token:"",provider:""},[d,u]=(0,s.useState)(n),[m,p]=(0,s.useState)(""),[h]=(0,s.useState)(()=>new i.ki(n));(0,s.useEffect)(()=>{let e=(0,l.Fp)();u(e),h.updateConfig(e),p((0,a.oD)()),(0,o.cY)("webterm.provider.daemon.init",{baseUrl:e.baseUrl,hasToken:!!e.token})},[h]),(0,s.useEffect)(()=>{let e=e=>{if("elanous.daemon.token"===e.key||"elanous.nexus.baseUrl"===e.key){let t=(0,l.Fp)();h.updateConfig(t),u(t),(0,o.cY)("webterm.provider.daemon.config-cross-tab",{key:e.key,hasToken:!!t.token});return}"elanous.daemon.sessionId"===e.key&&e.newValue&&p(t=>t===e.newValue?t:((0,o.cY)("webterm.provider.daemon.session-cross-tab",{previous:t||"(empty)",next:e.newValue}),e.newValue))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[h]);let x=e=>{u(t=>{let n={...t,...e};return(0,l.Qc)(e),h.updateConfig(n),(0,o.cY)("webterm.provider.daemon.config-update",{keys:Object.keys(e)}),n})},b=e=>{p(e),localStorage.setItem("elanous.daemon.sessionId",e),(0,o.cY)("webterm.provider.daemon.session-set",{sessionId:e})},f=(0,s.useMemo)(()=>({config:d,setConfig:x,client:h,sessionId:m,setSessionId:b}),[d,h,m]);return(0,r.jsx)(c.Provider,{value:f,children:t})}function u(){let e=(0,s.useContext)(c);if(!e)throw Error("useDaemon must be used inside <DaemonProvider>");return e}}},e=>{e.O(0,[5616,7648,7307,4306,3702,7358],()=>e(e.s=19375)),_N_E=e.O()}]);