forge-openclaw-plugin 0.3.12 → 0.3.14

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 (136) hide show
  1. package/dist/assets/{action-bar-BFjWjRIM.js → action-bar-B9MYlps2.js} +1 -1
  2. package/dist/assets/{activity-page-D-6yBWuZ.js → activity-page-DbzbChcE.js} +1 -1
  3. package/dist/assets/{ai-surface-workspace-BEfo9bRO.js → ai-surface-workspace-CF0257Hs.js} +1 -1
  4. package/dist/assets/{atlas-panel-BfMyJXxQ.js → atlas-panel-CO3RYAKn.js} +1 -1
  5. package/dist/assets/{calendar-page-D4tQNJ2V.js → calendar-page-BuuHKEHC.js} +1 -1
  6. package/dist/assets/{calendar-rules-C-6O_uGU.js → calendar-rules-DKftgNx5.js} +1 -1
  7. package/dist/assets/{calendar-week-toolbar-_NzeKsYx.js → calendar-week-toolbar-ChIpkT-G.js} +1 -1
  8. package/dist/assets/{companion-sync-lab-page-D1Oqsf6M.js → companion-sync-lab-page-BZRX4Btw.js} +1 -1
  9. package/dist/assets/{daily-metrics-dashboard-DtE3pVOl.js → daily-metrics-dashboard-CXDsaAQd.js} +1 -1
  10. package/dist/assets/{define-workbench-box-D-32C8nM.js → define-workbench-box-CpG0Zb1L.js} +1 -1
  11. package/dist/assets/{entity-link-multiselect-DcCvkesQ.js → entity-link-multiselect-Dl4rZqdg.js} +1 -1
  12. package/dist/assets/{entity-note-count-link-Cjsk5oT2.js → entity-note-count-link-Bs1aKYyD.js} +1 -1
  13. package/dist/assets/{entity-notes-surface-DQQPLjxd.js → entity-notes-surface-B56XSw7M.js} +1 -1
  14. package/dist/assets/{execution-board-agWQbN-y.js → execution-board-D66C_ikW.js} +1 -1
  15. package/dist/assets/{faceted-token-search-DldM3-ru.js → faceted-token-search-Dg2rjknH.js} +1 -1
  16. package/dist/assets/{flagship-signal-deck-BlLYW9Kz.js → flagship-signal-deck-C6KVPhmM.js} +1 -1
  17. package/dist/assets/{floating-action-menu-D9-psbha.js → floating-action-menu-DAFAEBcA.js} +1 -1
  18. package/dist/assets/{generic-node-view-CcepUVhP.js → generic-node-view-C6DK5hJ6.js} +1 -1
  19. package/dist/assets/{goal-detail-page-DP1n5-Hk.js → goal-detail-page-CC4VXud6.js} +1 -1
  20. package/dist/assets/{goal-dialog-Oxx8WqbZ.js → goal-dialog-15hD8EBp.js} +1 -1
  21. package/dist/assets/{goals-page-CUt1a4Y2.js → goals-page-CQ2lJMzI.js} +1 -1
  22. package/dist/assets/{habits-page-5REbWAlo.js → habits-page-a7KVPaQp.js} +1 -1
  23. package/dist/assets/{health-boxes-sHNML3tm.js → health-boxes-DqgvIYoL.js} +1 -1
  24. package/dist/assets/index-ClJbJhca.css +1 -0
  25. package/dist/assets/index-FpGANF9S.js +2 -0
  26. package/dist/assets/{inline-note-fields-Bql_KfR9.js → inline-note-fields-COgzxr_7.js} +1 -1
  27. package/dist/assets/{insight-flow-dialog-CN-CMSB7.js → insight-flow-dialog-Dmb6NSGp.js} +1 -1
  28. package/dist/assets/{insights-page-B1u6ONtQ.js → insights-page-OnqR4cYI.js} +1 -1
  29. package/dist/assets/{kanban-boxes-DB1kuUlY.js → kanban-boxes-BWUzntCV.js} +1 -1
  30. package/dist/assets/{kanban-page-BBW9_vMu.js → kanban-page-BI16Gzp_.js} +1 -1
  31. package/dist/assets/{knowledge-graph-page-CoJaydZb.js → knowledge-graph-page-DxEBaEke.js} +1 -1
  32. package/dist/assets/{life-force-page-DBYbA1GF.js → life-force-page-CDEXEQai.js} +1 -1
  33. package/dist/assets/{life-force-workspace-BiD9xOEt.js → life-force-workspace-C7UOnJEf.js} +1 -1
  34. package/dist/assets/{metric-tile-CuP9DOYm.js → metric-tile-boeHB1R1.js} +1 -1
  35. package/dist/assets/{movement-boxes-DZg_qPPg.js → movement-boxes-BUSqaTL2.js} +1 -1
  36. package/dist/assets/{movement-page-CmwsQGR_.js → movement-page-DcbO0497.js} +1 -1
  37. package/dist/assets/note-markdown-DXXI3W3V.js +3 -0
  38. package/dist/assets/{note-tags-input-C_x5WdK5.js → note-tags-input-CYh3TVW2.js} +1 -1
  39. package/dist/assets/{notes-boxes-BEFlp9yd.js → notes-boxes-CMJXX2K0.js} +1 -1
  40. package/dist/assets/{notes-page-B6Vl-GPf.js → notes-page-DvHMcQey.js} +1 -1
  41. package/dist/assets/{open-in-graph-button-C-bJekoH.js → open-in-graph-button-4UYrp1XP.js} +1 -1
  42. package/dist/assets/{orbit-map-DHeTM15g.js → orbit-map-BwK7sDaC.js} +1 -1
  43. package/dist/assets/{overview-page-BRWje1F9.js → overview-page-Z5vaUTm3.js} +1 -1
  44. package/dist/assets/{page-hero-8bITsx_x.js → page-hero-DvrM83_C.js} +1 -1
  45. package/dist/assets/{pill-cluster-XQjm-wPc.js → pill-cluster-DYI3Ibj8.js} +1 -1
  46. package/dist/assets/{preference-entity-handoff-button-DwYF_5i3.js → preference-entity-handoff-button-C2ATjvws.js} +1 -1
  47. package/dist/assets/{preferences-page-C7DBPpNb.js → preferences-page-BAexXHye.js} +1 -1
  48. package/dist/assets/{project-collections-mtxanSMf.js → project-collections-B9nr-Ts-.js} +1 -1
  49. package/dist/assets/{project-detail-page-BT87Goqc.js → project-detail-page-B9PqyPu9.js} +1 -1
  50. package/dist/assets/{project-dialog-DnZe757y.js → project-dialog-CBA-D65n.js} +1 -1
  51. package/dist/assets/{project-management-hierarchy-page-B3R2lNFI.js → project-management-hierarchy-page-DXK14jn0.js} +1 -1
  52. package/dist/assets/{project-management-section-nav-DyBWxHbe.js → project-management-section-nav-DJ3QKCtr.js} +1 -1
  53. package/dist/assets/{projects-boxes-CxZj3P29.js → projects-boxes-iBu_PRqe.js} +1 -1
  54. package/dist/assets/{projects-page-Bec11c0x.js → projects-page-CdAk-ByT.js} +1 -1
  55. package/dist/assets/{psyche-behaviors-page-DWRpYvl1.js → psyche-behaviors-page-CbhhTfU2.js} +1 -1
  56. package/dist/assets/{psyche-flashcards-page-CX4rcsXZ.js → psyche-flashcards-page-DQaw_vUQ.js} +1 -1
  57. package/dist/assets/{psyche-goal-map-page-Y6b3lCvV.js → psyche-goal-map-page-C-ZTVOEP.js} +1 -1
  58. package/dist/assets/{psyche-graph-CQuCWKIp.js → psyche-graph-DYzeClxn.js} +1 -1
  59. package/dist/assets/{psyche-metrics-page-DadDJOnm.js → psyche-metrics-page-C9hKn10A.js} +1 -1
  60. package/dist/assets/{psyche-mode-guide-page-B1nz0uCg.js → psyche-mode-guide-page-CR8e984W.js} +1 -1
  61. package/dist/assets/{psyche-modes-page-i3uSuhKA.js → psyche-modes-page-lQdpAcY3.js} +1 -1
  62. package/dist/assets/{psyche-page-Y_s-BE2m.js → psyche-page-CTdIDkw9.js} +1 -1
  63. package/dist/assets/{psyche-patterns-page-DaaOLIlN.js → psyche-patterns-page-Drgm-f7I.js} +1 -1
  64. package/dist/assets/{psyche-questionnaire-builder-page-CuF7rXOv.js → psyche-questionnaire-builder-page-gRwdGXde.js} +1 -1
  65. package/dist/assets/{psyche-questionnaire-detail-page-BfFEMkRY.js → psyche-questionnaire-detail-page-CIP9b2UI.js} +1 -1
  66. package/dist/assets/{psyche-questionnaire-run-detail-page-BoQTvd7Q.js → psyche-questionnaire-run-detail-page-SYndwtF3.js} +1 -1
  67. package/dist/assets/{psyche-questionnaire-run-page-C0qKiNZN.js → psyche-questionnaire-run-page-CXiJyd5i.js} +1 -1
  68. package/dist/assets/{psyche-questionnaires-page-B6hfD448.js → psyche-questionnaires-page-CFPKwA3O.js} +1 -1
  69. package/dist/assets/{psyche-report-detail-page-BlFL8moM.js → psyche-report-detail-page-dU30a2WE.js} +1 -1
  70. package/dist/assets/{psyche-reports-page-DAAcYENp.js → psyche-reports-page-Cn0EBndy.js} +1 -1
  71. package/dist/assets/{psyche-schemas-beliefs-page-CsxKSrKM.js → psyche-schemas-beliefs-page-Bab4xSWv.js} +1 -1
  72. package/dist/assets/{psyche-screen-time-page-n4b0e58x.js → psyche-screen-time-page-lIe6GQxJ.js} +1 -1
  73. package/dist/assets/{psyche-self-observation-page-BaxEQ2-3.js → psyche-self-observation-page-BTE3KfIl.js} +1 -1
  74. package/dist/assets/{psyche-values-page-DTv5NMSU.js → psyche-values-page-DclBZ9xw.js} +1 -1
  75. package/dist/assets/question-flow-dialog-Ded2E85L.js +2 -0
  76. package/dist/assets/{report-chain-fields-D132-EMh.js → report-chain-fields-DY640iqL.js} +1 -1
  77. package/dist/assets/{rewards-page-C533lVP-.js → rewards-page-FxUXB76B.js} +1 -1
  78. package/dist/assets/{scheduling-rules-editor-CDpontGp.js → scheduling-rules-editor-jakFfxqF.js} +1 -1
  79. package/dist/assets/{schema-badge-B3DiMnjB.js → schema-badge-30B5syHA.js} +1 -1
  80. package/dist/assets/{schemas-CH1_ngUX.js → schemas-Db29G8NU.js} +1 -1
  81. package/dist/assets/{select-menu-BOF-k4Ln.js → select-menu-BF2zI3RW.js} +1 -1
  82. package/dist/assets/{settings-agents-page-B5OQtlZX.js → settings-agents-page-Bh-Bv6FQ.js} +1 -1
  83. package/dist/assets/{settings-bin-page-D_bk3Kcu.js → settings-bin-page-DT8JJero.js} +1 -1
  84. package/dist/assets/{settings-calendar-page-PuSj9_kM.js → settings-calendar-page-BA4_Qqiu.js} +3 -3
  85. package/dist/assets/{settings-data-page-EwFMaeq6.js → settings-data-page-K4kpmQJY.js} +1 -1
  86. package/dist/assets/{settings-logs-page-BKkse0DX.js → settings-logs-page-DkuNPAZo.js} +1 -1
  87. package/dist/assets/{settings-mobile-page-BrIVmdeB.js → settings-mobile-page-4pCNwD91.js} +1 -1
  88. package/dist/assets/{settings-models-page-Mg84D_0K.js → settings-models-page-CZHG3t7W.js} +1 -1
  89. package/dist/assets/{settings-page-D-kul92f.js → settings-page-B_Be0vOY.js} +1 -1
  90. package/dist/assets/{settings-rewards-page-waNyCcX_.js → settings-rewards-page-C6nFTWJu.js} +1 -1
  91. package/dist/assets/{settings-section-nav-BmJWnrYk.js → settings-section-nav-Lo-VKCfZ.js} +1 -1
  92. package/dist/assets/{settings-users-page-DBgC6y56.js → settings-users-page-CVzNp4-m.js} +1 -1
  93. package/dist/assets/{settings-wiki-page-CM0te9dI.js → settings-wiki-page-DXM--7BB.js} +1 -1
  94. package/dist/assets/sleep-page-DvPdZMKx.js +1 -0
  95. package/dist/assets/{sports-page-eg5Rfc_E.js → sports-page-DjuZlOur.js} +1 -1
  96. package/dist/assets/{strategies-page-D4AqvFNW.js → strategies-page-PE1IlatS.js} +1 -1
  97. package/dist/assets/{strategy-detail-page-BlYVkXaW.js → strategy-detail-page-C4KiEGCI.js} +1 -1
  98. package/dist/assets/{strategy-dialog-FO9Oa0dB.js → strategy-dialog-Cwf7Y3P5.js} +1 -1
  99. package/dist/assets/surface-ubuOfukq.js +1 -0
  100. package/dist/assets/{task-detail-page-Dy-aRyY6.js → task-detail-page-B3SMFZQ3.js} +1 -1
  101. package/dist/assets/{task-dialog-DrA9pba7.js → task-dialog-CI_Fy_FW.js} +1 -1
  102. package/dist/assets/{timebox-planning-dialog-C_gnfxFx.js → timebox-planning-dialog-BtFuVoA1.js} +1 -1
  103. package/dist/assets/{today-boxes-BFOws_iC.js → today-boxes-CYuxSkZf.js} +1 -1
  104. package/dist/assets/{today-page-BoPj6a6q.js → today-page-CHGpLEZ3.js} +1 -1
  105. package/dist/assets/{training-load-page-DGU40Zfl.js → training-load-page-GZJF-Yy5.js} +1 -1
  106. package/dist/assets/{user-badge-CZWtYeMw.js → user-badge-ByhC6bMU.js} +1 -1
  107. package/dist/assets/{utility-widgets-B3wWGxQc.js → utility-widgets-ilORjDmg.js} +1 -1
  108. package/dist/assets/{vitals-page-BXRZEP_8.js → vitals-page-mdEqIm_9.js} +1 -1
  109. package/dist/assets/{weekly-review-page-D5cebA5x.js → weekly-review-page-C8W-yg5r.js} +1 -1
  110. package/dist/assets/weight-loss-page-BApTknCn.js +5 -0
  111. package/dist/assets/{wiki-article-markdown-CvaCjg_t.js → wiki-article-markdown-DBccllQg.js} +1 -1
  112. package/dist/assets/{wiki-editor-page-Dco79SLY.js → wiki-editor-page-BfRfH1O3.js} +2 -2
  113. package/dist/assets/{wiki-ingest-history-page-uvKRkRDF.js → wiki-ingest-history-page-C-6H3MU6.js} +1 -1
  114. package/dist/assets/{wiki-ingest-modal-BW6AJPea.js → wiki-ingest-modal-DnlhByD_.js} +1 -1
  115. package/dist/assets/{wiki-page-BIL5zMqv.js → wiki-page-DPZ55e3x.js} +1 -1
  116. package/dist/assets/{workbench-flow-page-Dx_nq8R_.js → workbench-flow-page-_-NKIx5R.js} +1 -1
  117. package/dist/assets/{workbench-page-BJnt_Zzf.js → workbench-page-NIAzggwX.js} +1 -1
  118. package/dist/assets/{workout-detail-page-CKgqyB-y.js → workout-detail-page-3fxr6HL4.js} +1 -1
  119. package/dist/index.html +2 -2
  120. package/dist/server/server/src/app.js +8 -4
  121. package/dist/server/server/src/health-weight-loss.js +321 -14
  122. package/dist/server/server/src/managers/platform/openai-responses-provider.js +2 -2
  123. package/dist/server/server/src/openapi.js +26 -3
  124. package/dist/server/server/src/repositories/ai-connectors.js +1 -1
  125. package/openclaw.plugin.json +1 -1
  126. package/package.json +1 -1
  127. package/skills/forge-openclaw/SKILL.md +22 -0
  128. package/skills/forge-openclaw/entity_conversation_playbooks.md +17 -0
  129. package/skills/forge-openclaw/psyche_entity_playbooks.md +7 -0
  130. package/dist/assets/index-CQ5r7ZUz.js +0 -2
  131. package/dist/assets/index-FxgNSuZX.css +0 -1
  132. package/dist/assets/note-markdown-B82ncnFt.js +0 -3
  133. package/dist/assets/question-flow-dialog-CskCt5NZ.js +0 -2
  134. package/dist/assets/sleep-page-C_krRE59.js +0 -1
  135. package/dist/assets/surface-MVeeZGKB.js +0 -1
  136. package/dist/assets/weight-loss-page-BuUdFh9z.js +0 -5
@@ -1,4 +1,4 @@
1
- import{j as e,r as g,dK as aa,dL as ra,dH as sa,dM as na,dN as ia,dO as oa,aG as la,dP as ca,cl as $a,c1 as Ue,cm as da,b9 as Ge,b2 as za,aC as Va,cL as Da,c4 as Ua,cg as Ga,dQ as Qa,c6 as Ja,b6 as Ya}from"./vendor-BwL6m4SE.js";import{O as Xa}from"./open-in-graph-button-C-bJekoH.js";import{P as Za}from"./page-hero-8bITsx_x.js";import{T as er,M as tr,S as ar,W as rr,Q as sr}from"./utility-widgets-B3wWGxQc.js";import{a as _,n as xe,q as ua,j as R,c as O,e as M,d as L,g as A,b as H,f as q,r as nr,s as ir,h as ma,k as or,t as lr,u as cr,v as _e,W as dr,w as Dt}from"./generic-node-view-CcepUVhP.js";import{d as K}from"./define-workbench-box-D-32C8nM.js";import{K as ur,a as mr,b as pr}from"./kanban-boxes-DB1kuUlY.js";import{S as hr,a as gr,b as xr,c as br,d as fr,e as vr}from"./health-boxes-sHNML3tm.js";import{M as yr,a as kr,b as wr,c as jr,d as Nr}from"./movement-boxes-DZg_qPPg.js";import{N as Sr,a as Cr,b as _r}from"./notes-boxes-BEFlp9yd.js";import{P as Tr,a as Ir,b as Pr}from"./projects-boxes-CxZj3P29.js";import{T as Fr,a as Br,b as Rr,c as Wr,d as Er}from"./today-boxes-BFOws_iC.js";import{H as Or,P as Ut,i as Kr,B as Mr,a as Lr,b as Ar,c as Hr}from"./graph-BF4IsheG.js";import{F as C,Q as qr}from"./question-flow-dialog-CskCt5NZ.js";import{W as pa,c as E,a4 as te,B,aC as $r,eG as zr,eH as Vr,b as Gt,eD as Dr,eI as Ur,eJ as Gr,eK as Qr,eL as Jr,eM as Yr,eN as Xr,L as Zr,h as es,e as ts}from"./index-CQ5r7ZUz.js";import{R as as,P as rs,O as ss,C as ns,T as is,D as os,a as ls}from"./ui-B9TWEtCx.js";import{F as cs}from"./faceted-token-search-DldM3-ru.js";import"./state-Bpe5dF3T.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function ds({children:t}){return e.jsx(e.Fragment,{children:t})}function ha(t,n,r,i,c,d){return K(ds,{id:t,surfaceId:"insights",routePath:"/insights",title:n,icon:"insights",description:r,category:"Insights",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const us=ha("surface:insights:feed","Insights feed","Current coaching feed, status summary, and evidence-backed insight stream.",["insights","feed"],t=>ua(t),[_({label:"Insight summary",description:"Summary of the current coaching feed and evidence-backed insight stream."}),xe({key:"insights",label:"Insight payload",description:"Structured status and coaching payload returned by Forge insights.",modelName:"ForgeInsightsPayload"})]),ms=ha("surface:insights:coaching","Coaching recommendation","Single-action coaching summary for what Forge thinks matters next.",["insights","coaching"],t=>R(t,{focus:"coaching_recommendation"},"Coaching recommendation surface for the highest-leverage next move."),[_({label:"Coaching recommendation",description:"Summary of the highest-leverage coaching recommendation."})]);function ps({children:t}){return e.jsx(e.Fragment,{children:t})}function et(t,n,r,i,c,d,u,s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(ps,{id:t,surfaceId:"calendar",routePath:"/calendar",title:n,icon:"calendar",description:r,category:"Calendar",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const hs=et("surface:calendar:overview","Calendar overview","Main calendar surface for mirrored events, work blocks, and planned timeboxes.",["calendar","overview"],t=>R(t,{surfaces:["events","work_blocks","timeboxes"]},"Calendar overview spanning mirrored events, work blocks, and timeboxes."),[_({label:"Calendar summary",description:"Summary of mirrored events, work blocks, and timeboxes."})],[]),gs=et("surface:calendar:events","Calendar events","Mirrored calendar events and Forge-managed calendar records.",["calendar","events","mirrored"],t=>q(t,{query:"",entityTypes:["calendar_event"],limit:20}),H({itemKind:"calendar_event",itemLabel:"Calendar event"}),[A("Search calendar-backed Forge entities and planning records.")],{inputs:L({itemKind:"calendar_event",itemLabel:"Calendar event",defaultEntityTypes:["calendar_event"],defaultLimit:20}),params:M()}),xs=et("surface:calendar:planning","Planning blocks","Planned task timeboxes and reusable work block templates.",["calendar","planning","timeboxes"],t=>q(t,{query:"",entityTypes:["task_timebox","work_block_template"],limit:20}),H({itemKind:"calendar_plan",itemLabel:"Planning record"}),[A("Search calendar-backed Forge entities and planning records.")],{inputs:L({itemKind:"calendar_plan",itemLabel:"Planning record",defaultEntityTypes:["task_timebox","work_block_template"],defaultLimit:20}),params:M()});function bs({children:t}){return e.jsx(e.Fragment,{children:t})}function tt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(bs,{id:t,surfaceId:"goals",routePath:"/goals",title:n,icon:"goal",description:r,category:"Goals",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const fs=tt("surface:goals:hero","Goals hero","Goals page header and long-horizon direction context.",["goals","hero"],t=>R(t,null,"Goals page header."),[_({label:"Goals summary",description:"High-level goals page framing."})]),vs=tt("surface:goals:search-results","Goals list and results","Goal browser, linked context, and search results.",["goals","search"],t=>q(t,{query:"",entityTypes:["goal"],limit:20}),H({itemKind:"goal",itemLabel:"Goal"}),[A("Search goal entities by query and entity types.")],{inputs:L({itemKind:"goal",itemLabel:"Goal",defaultEntityTypes:["goal"],defaultLimit:20}),params:M()}),ys=tt("surface:goals:summary","Goals summary","Goal collection summary and state context.",["goals","summary"],t=>R(t,null,"Goal collection summary."),[_({label:"Goals summary",description:"Summary of the goal collection and its current state."})]);function ks({children:t}){return e.jsx(e.Fragment,{children:t})}function at(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(ks,{id:t,surfaceId:"habits",routePath:"/habits",title:n,icon:"habit",description:r,category:"Habits",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const ws=at("surface:habits:hero","Habits hero","Habits page header and recurring execution context.",["habits","hero"],t=>R(t,null,"Habits page header."),[_({label:"Habits summary",description:"High-level habits page framing."})]),js=at("surface:habits:search-results","Habits list and results","Habit browser, due habits, and recurring check-in context.",["habits","search","check-ins"],t=>q(t,{query:"",entityTypes:["habit"],limit:20}),H({itemKind:"habit",itemLabel:"Habit"}),[A("Search habit entities by query and entity types.")],{inputs:L({itemKind:"habit",itemLabel:"Habit",defaultEntityTypes:["habit"],defaultLimit:20}),params:M()}),Ns=at("surface:habits:summary","Habits summary","Habit streaks, due state, and collection-level rhythm context.",["habits","summary","streaks"],t=>R(t,null,"Habit collection summary."),[_({label:"Habit summary",description:"Summary of habit streaks, due state, and collection rhythm."})]);function Ss({children:t}){return e.jsx(e.Fragment,{children:t})}function rt(t,n,r,i,c,d){return K(Ss,{id:t,surfaceId:"overview",routePath:"/overview",title:n,icon:"overview",description:r,category:"Overview",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const Cs=rt("surface:overview:snapshot","Forge snapshot","Live overview of goals, projects, tasks, habits, and current operating pressure.",["overview","snapshot"],t=>nr(t),[_({label:"Overview summary",description:"Compact summary of goals, projects, tasks, and habits."}),xe({key:"context",label:"Overview context",description:"Structured Forge overview context for the current operating picture.",modelName:"ForgeOverviewContext"})]),_s=rt("surface:overview:momentum","Momentum and health","Momentum-focused summary of streaks, neglected areas, and active execution pressure.",["overview","momentum"],t=>R(t,{dimensions:["momentum","neglected_goals","domain_balance"]},"Overview momentum surface tracking neglected goals, domain balance, and execution pressure."),[_({label:"Momentum summary",description:"Summary of momentum, neglected goals, and execution pressure."})]),Ts=rt("surface:overview:insights","Overview insights","Insight-oriented summary of the current Forge operating picture.",["overview","insights"],t=>ua(t),[_({label:"Insight summary",description:"Compact explanation of the current insight payload."}),xe({key:"insights",label:"Insight payload",description:"Structured insight and coaching payload returned by Forge.",modelName:"ForgeInsightsPayload"})]);function Is({children:t}){return e.jsx(e.Fragment,{children:t})}function st(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Is,{id:t,surfaceId:"preferences",routePath:"/preferences",title:n,icon:"preferences",description:r,category:"Preferences",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ps=st("surface:preferences:workspace","Preferences workspace","Main preference modeling workspace, including summaries, tradeoffs, and evidence.",["preferences","workspace"],t=>R(t,{surfaces:["summary","comparison_game","evidence"]},"Preferences workspace with summary, pairwise comparison, and evidence views."),[_({label:"Preference summary",description:"Summary of the active preference modeling workspace."})]),Fs=st("surface:preferences:contexts","Preference contexts","Preference contexts that shape which tradeoffs and evidence are active.",["preferences","contexts"],t=>q(t,{query:"",entityTypes:["preference_context"],limit:20}),H({itemKind:"preference_context",itemLabel:"Preference context"}),[A("Search preference contexts and modeled preference items.")],{inputs:L({itemKind:"preference_context",itemLabel:"Preference context",defaultEntityTypes:["preference_context"],defaultLimit:20}),params:M()}),Bs=st("surface:preferences:items","Preference items","Preference items scored and compared inside the active context.",["preferences","items"],t=>q(t,{query:"",entityTypes:["preference_item"],limit:20}),H({itemKind:"preference_item",itemLabel:"Preference item"}),[A("Search preference contexts and modeled preference items.")],{inputs:L({itemKind:"preference_item",itemLabel:"Preference item",defaultEntityTypes:["preference_item"],defaultLimit:20}),params:M()});function Rs({children:t}){return e.jsx(e.Fragment,{children:t})}function nt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Rs,{id:t,surfaceId:"psyche",routePath:"/psyche",title:n,icon:"psyche",description:r,category:"Psyche",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ws=nt("surface:psyche:overview","Psyche overview","High-level overview of values, patterns, beliefs, modes, and reports.",["psyche","overview"],t=>R(t,{surfaces:["values","patterns","beliefs","modes","reports"]},"Psyche overview spanning values, patterns, beliefs, modes, and reports."),[_({label:"Psyche summary",description:"Summary of values, patterns, beliefs, modes, and reports."})]),Es=nt("surface:psyche:values","Psyche values","Values and long-lived internal directions tracked inside Forge.",["psyche","values"],t=>q(t,{query:"",entityTypes:["psyche_value"],limit:20}),H({itemKind:"psyche_value",itemLabel:"Psyche value"}),[A("Search psyche entities and reflective records.")],{inputs:L({itemKind:"psyche_value",itemLabel:"Psyche value",defaultEntityTypes:["psyche_value"],defaultLimit:20}),params:M()}),Os=nt("surface:psyche:reports","Trigger reports","Trigger reports and behavior-pattern signals linked to reflective work.",["psyche","reports","patterns"],t=>q(t,{query:"",entityTypes:["trigger_report","behavior_pattern","belief_entry","mode_profile"],limit:20}),H({itemKind:"psyche_record",itemLabel:"Psyche record"}),[A("Search psyche entities and reflective records.")],{inputs:L({itemKind:"psyche_record",itemLabel:"Psyche record",defaultEntityTypes:["trigger_report","behavior_pattern","belief_entry","mode_profile"],defaultLimit:20}),params:M()});function Ks({children:t}){return e.jsx(e.Fragment,{children:t})}function it(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Ks,{id:t,surfaceId:"questionnaires",routePath:"/psyche/questionnaires",title:n,icon:"questionnaire",description:r,category:"Questionnaires",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ms=it("surface:questionnaires:library","Questionnaire library","Library of questionnaire instruments available in Forge.",["questionnaires","library"],t=>q(t,{query:"",entityTypes:["questionnaire_instrument"],limit:20}),H({itemKind:"questionnaire_instrument",itemLabel:"Questionnaire"}),[A("Search questionnaire instruments and related records.")],{inputs:L({itemKind:"questionnaire_instrument",itemLabel:"Questionnaire",defaultEntityTypes:["questionnaire_instrument"],defaultLimit:20}),params:M()}),Ls=it("surface:questionnaires:drafting","Questionnaire drafting","Drafting and publishing context for questionnaire instruments.",["questionnaires","drafting","authoring"],t=>R(t,{states:["draft","published","run"]},"Questionnaire drafting surface with draft, publish, and run lifecycle context."),[_({label:"Drafting summary",description:"Summary of questionnaire drafting and lifecycle context."})]),As=it("surface:questionnaires:self-observation","Self-observation calendar","Calendar of self-observation notes and linked psyche context.",["questionnaires","self-observation","psyche"],t=>R(t,{linkedDomains:["patterns","reports","notes"]},"Self-observation calendar surface with linked psyche context."),[_({label:"Observation summary",description:"Summary of the self-observation calendar and linked psyche context."})]);function Hs({children:t}){return e.jsx(e.Fragment,{children:t})}function ga(t,n,r,i,c,d){return K(Hs,{id:t,surfaceId:"review",routePath:"/review/weekly",title:n,icon:"review",description:r,category:"Review",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const qs=ga("surface:review:weekly-summary","Weekly review summary","Weekly review payload with momentum, wins, calibration, and completion state.",["review","weekly"],t=>ir(t),[_({label:"Weekly review summary",description:"Summary of momentum, wins, calibration, and review completion state."}),xe({key:"weeklyReview",label:"Weekly review payload",description:"Structured weekly review payload returned by Forge.",modelName:"ForgeWeeklyReview"})]),$s=ga("surface:review:reward","Review reward","Reward framing and completion incentive for closing the current review cycle.",["review","reward"],t=>R(t,{reward:"weekly_review_completion"},"Weekly review reward surface for locking the current cycle into evidence."),[_({label:"Review reward summary",description:"Summary of the reward framing for closing the current review cycle."})]);function zs({children:t}){return e.jsx(e.Fragment,{children:t})}function ot(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(zs,{id:t,surfaceId:"strategies",routePath:"/strategies",title:n,icon:"strategy",description:r,category:"Strategies",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Vs=ot("surface:strategies:hero","Strategies hero","Strategies page header and sequencing context.",["strategies","hero"],t=>R(t,null,"Strategies page header."),[_({label:"Strategies summary",description:"High-level strategies page framing."})]),Ds=ot("surface:strategies:search-results","Strategies list and results","Strategy browser and structured operating context.",["strategies","search"],t=>q(t,{query:"",entityTypes:["strategy"],limit:20}),H({itemKind:"strategy",itemLabel:"Strategy"}),[A("Search strategy entities by query and entity types.")],{inputs:L({itemKind:"strategy",itemLabel:"Strategy",defaultEntityTypes:["strategy"],defaultLimit:20}),params:M()}),Us=ot("surface:strategies:summary","Strategies summary","Strategy collection summary and state context.",["strategies","summary"],t=>R(t,null,"Strategy collection summary."),[_({label:"Strategy summary",description:"Summary of strategy state and collection context."})]);function Gs({children:t}){return e.jsx(e.Fragment,{children:t})}function lt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Gs,{id:t,surfaceId:"tasks",routePath:"/today",title:n,icon:"task",description:r,category:"Tasks",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Qs=lt("surface:tasks:inbox","Task queue","Searchable task queue spanning backlog, focus, and in-progress work.",["tasks","queue","search"],t=>q(t,{query:"",entityTypes:["task"],limit:20}),H({itemKind:"task",itemLabel:"Task"}),[A("Search task entities by title, status, or linked context."),ma("Move a task between backlog, focus, in progress, blocked, and done.")],{inputs:L({itemKind:"task",itemLabel:"Task",defaultEntityTypes:["task"],defaultLimit:20}),params:M()}),Js=lt("surface:tasks:focus-lane","Focus lane","Focused task lane for what should happen next right now.",["tasks","focus","execution"],t=>R(t,{hint:"Use this surface to represent active or next-up work."},"Focus lane context for the current execution board."),[_({label:"Focus summary",description:"Human-readable explanation of what the focus lane represents."})],[ma("Change task state as the flow decides what should happen next.")]),Ys=lt("surface:tasks:summary","Task summary","High-level summary of the current task system and work state.",["tasks","summary"],t=>R(t,{states:["backlog","focus","in_progress","blocked","done"]},"Task system summary with the key task states Forge tracks."),[_({label:"Task summary",description:"High-level summary of the current task system and work state."})]);function Xs({children:t}){return e.jsx(e.Fragment,{children:t})}function ct(t,n,r,i,c,d){return K(Xs,{id:t,surfaceId:"wiki",routePath:"/wiki",title:n,icon:"wiki",description:r,category:"Wiki",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const Zs=ct("surface:wiki:pages","Wiki pages","Live list of wiki pages that can be used as memory or authored knowledge.",["wiki","pages"],t=>lr(t),[_({label:"Wiki page summary",description:"Summary of the currently available wiki pages."}),or({key:"pages",label:"Wiki pages",description:"Structured wiki page records available in Forge memory.",modelName:"ForgeWikiPages",itemKind:"wiki_page"})]),en=ct("surface:wiki:health","Wiki health","Index health, unresolved links, and orphaned-page signals for the wiki.",["wiki","health"],t=>cr(t),[_({label:"Wiki health summary",description:"Summary of unresolved links and orphaned-page signals."}),xe({key:"health",label:"Wiki health",description:"Structured wiki health payload returned by Forge.",modelName:"ForgeWikiHealth"})]),tn=ct("surface:wiki:authoring","Wiki authoring","Authoring and ingest surface for creating or refining Forge memory.",["wiki","authoring","ingest"],t=>R(t,{actions:["upsert","ingest","reindex"]},"Wiki authoring surface for ingesting sources and maintaining memory pages."),[_({label:"Wiki authoring summary",description:"Summary of wiki authoring and ingest actions available on this surface."})]),an=[er,tr,ar,rr,sr,hs,gs,xs,fs,vs,ys,ws,js,Ns,us,ms,ur,mr,pr,Sr,Cr,_r,Cs,_s,Ts,yr,kr,wr,jr,Nr,hr,gr,xr,br,fr,vr,Tr,Ir,Pr,Ps,Fs,Bs,Ws,Es,Os,Ms,Ls,As,qs,$s,Vs,Ds,Us,Qs,Js,Ys,Fr,Br,Rr,Wr,Er,Zs,en,tn],xa=new Map(an.filter(t=>t.workbench).map(t=>[t.workbench.id,t.workbench]));function ba(){return Array.from(xa.values())}function rn(t){return xa.get(t)??null}function sn(){return ba().map(t=>({id:t.id,boxId:t.id,surfaceId:t.surfaceId,routePath:t.routePath,title:t.title,label:t.title,icon:t.icon??null,description:t.description,category:t.category,tags:t.tags,capabilityModes:["content",...t.tools.length>0?["tool"]:[]],inputs:_e(t.inputs),params:_e(t.params),output:_e(t.output),tools:t.tools,outputs:_e(t.output),toolAdapters:t.tools,snapshotResolverKey:void 0}))}const nn=g.createContext(null),on={definitions:ba(),catalog:sn(),getDefinition:rn};function fa(){return g.useContext(nn)??on}function ln(){return fa().catalog}function cn(t){const n=fa();return t?n.getDefinition(t):null}const Qe=[...dr];function Pe(t){return typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):Array.isArray(t)||t&&typeof t=="object"?JSON.stringify(t,null,2):""}function va(t,n){if(t==="array"||t==="entity_list"||t==="record_list"||t==="object"||t==="json"||t==="record"||t==="context"||t==="filters"||t==="metrics"||t==="timeline"||t==="selection"||t==="entity"){if(!n.trim())return"";try{return JSON.parse(n)}catch{return n}}if(t==="boolean")return n.trim()?n.trim().toLowerCase()==="true"?!0:n.trim().toLowerCase()==="false"?!1:n:"";if(t==="number"){const r=n.trim();if(!r)return"";const i=Number(r);return Number.isFinite(i)?i:n}return n}function dn(t,n){if(n==null||typeof n=="string"&&n.trim().length===0)return!t.required;switch(t.kind){case"text":case"markdown":case"summary":return typeof n=="string";case"number":return typeof n=="number"&&Number.isFinite(n);case"boolean":return typeof n=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(n);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!n&&typeof n=="object";default:return!0}}function ya(t){switch(t){case"box":case"box_input":return{inputs:[],outputs:[{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}]};case"user_input":return{inputs:[],outputs:[{key:"message",label:"Message",kind:"text",description:"Raw user message passed into the flow.",modelName:"WorkbenchUserMessage"},{key:"context",label:"Structured context",kind:"context",description:"Structured context fields that arrived with the user input.",modelName:"WorkbenchUserContext"}]};case"value":return{inputs:[],outputs:[{key:"value",label:"Value",kind:"record",description:"Literal value emitted by this node.",modelName:"WorkbenchLiteralValue"}]};case"functor":case"chat":return{inputs:[{key:"input",label:"Flow input",kind:"context",required:!1,description:"Context gathered from upstream nodes."}],outputs:[{key:"answer",label:"Answer",kind:"markdown",description:"Primary answer returned by this AI node.",modelName:"WorkbenchAiAnswer"}]};case"merge":return{inputs:[{key:"left",label:"Left input",kind:"context",required:!1,description:"First context record to merge."},{key:"right",label:"Right input",kind:"context",required:!1,description:"Second context record to merge."}],outputs:[{key:"merged",label:"Merged context",kind:"context",description:"Combined context assembled from upstream nodes.",modelName:"WorkbenchMergedContext"}]};case"template":return{inputs:[{key:"input",label:"Template input",kind:"context",required:!1,description:"Structured context available to the template."}],outputs:[{key:"rendered",label:"Rendered output",kind:"markdown",description:"Rendered text produced by the template node.",modelName:"WorkbenchTemplateOutput"}]};case"pick_key":return{inputs:[{key:"object",label:"Source object",kind:"object",required:!1,description:"Object record the node should read from."}],outputs:[{key:"selected",label:"Selected value",kind:"record",description:"Value extracted from the chosen key.",modelName:"WorkbenchSelectedValue"}]};case"output":return{inputs:[{key:"result",label:"Published result",kind:"context",required:!1,description:"Final value the flow should publish."}],outputs:[]}}}function ka(t,n){var c,d,u,s;const r=(o,m)=>o.map(h=>{const f=Dt(h),k=f.key==="primary"?m==="output"?t.type==="functor"||t.type==="chat"?"answer":t.type==="box"||t.type==="box_input"?"summary":t.type==="value"?"value":t.type==="merge"?"merged":t.type==="template"?"rendered":t.type==="pick_key"?"selected":"result":t.type==="functor"||t.type==="chat"?"input":t.type==="output"?"result":f.key:f.key;return Dt({...f,key:k,kind:k===f.key?f.kind:void 0})});if(t.type==="box"||t.type==="box_input"){const o=n.find(m=>m.id===t.data.boxId);return{inputs:r((o==null?void 0:o.inputs)??[],"input"),outputs:(c=o==null?void 0:o.output)!=null&&c.length?r(o.output,"output"):r([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(d=t.data.enabledToolKeys)!=null&&d.length?t.data.enabledToolKeys:((o==null?void 0:o.tools)??[]).map(m=>m.key),boxId:(o==null?void 0:o.id)??t.data.boxId??null}}const i=ya(t.type);return{inputs:r((u=t.data.inputs)!=null&&u.length?t.data.inputs:i.inputs,"input"),outputs:r((s=t.data.outputs)!=null&&s.length?t.data.outputs:i.outputs,"output"),enabledToolKeys:t.data.enabledToolKeys??[],boxId:t.data.boxId??null}}function un(t,n){var i,c,d;const r=(i=t.data.outputKey)==null?void 0:i.trim();return!r||r==="primary"?((c=n[0])==null?void 0:c.key)??"":n.some(u=>u.key===r)?r:((d=n[0])==null?void 0:d.key)??r}function Qt(t,n,r){var i,c;return n.length===0?null:!t||t==="primary"?r&&n.some(d=>d.key===r)?r:((i=n[0])==null?void 0:i.key)??null:n.some(d=>d.key===t)?t:r&&n.some(d=>d.key===r)?r:((c=n[0])==null?void 0:c.key)??null}function De(t,n){const r=t.graph.nodes.map(d=>{const u=ka(d,n),s={...d,data:{...d.data,inputs:u.inputs,outputs:u.outputs,outputKey:un(d,u.outputs)}};return Je(s,n)}),i=new Map(r.map(d=>[d.id,d])),c=t.graph.edges.map(d=>{var h,f,k,v;const u=i.get(d.source),s=i.get(d.target),o=Qt(d.sourceHandle,(u==null?void 0:u.data.outputs)??[],(f=(h=u==null?void 0:u.data.outputs)==null?void 0:h[0])==null?void 0:f.key),m=Qt(d.targetHandle,(s==null?void 0:s.data.inputs)??[],(v=(k=s==null?void 0:s.data.inputs)==null?void 0:k[0])==null?void 0:v.key);return wa({...d,sourceHandle:o,targetHandle:m})});return{nodes:r,edges:c}}function Je(t,n){const r=ka(t,n);return{id:t.id,type:"workbench",position:t.position,data:{...t.data,nodeType:t.type==="box_input"?"box":t.type,boxId:r.boxId,enabledToolKeys:r.enabledToolKeys,inputs:r.inputs,outputs:r.outputs,params:t.data.params??[],paramValues:t.data.paramValues??{}}}}function wa(t){return{id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle??void 0,targetHandle:t.targetHandle??void 0,label:t.label??void 0,style:{stroke:"color-mix(in srgb, var(--primary) 44%, transparent)",strokeWidth:1.6}}}function ja(t){return{id:t.id,type:t.data.nodeType==="box"?"box":t.data.nodeType,position:t.position,data:{label:t.data.label,description:t.data.description,boxId:t.data.boxId??null,prompt:t.data.prompt??"",promptTemplate:t.data.promptTemplate??"",systemPrompt:t.data.systemPrompt??"",outputKey:t.data.outputKey??"",enabledToolKeys:t.data.enabledToolKeys??[],inputs:t.data.inputs??[],outputs:t.data.outputs??[],params:t.data.params??[],paramValues:t.data.paramValues??{},template:t.data.template??"",selectedKey:t.data.selectedKey??"",valueType:t.data.valueType??"string",valueLiteral:t.data.valueLiteral??"",modelConfig:t.data.modelConfig}}}function mn(t){return{id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null,label:typeof t.label=="string"?t.label:null}}function Jt(t,n,r){var c;const i=ya(t);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+n.length%3*320,y:80+Math.floor(n.length/3)*220},data:{nodeType:t,label:(r==null?void 0:r.title)??(t==="functor"?"Functor":t==="chat"?"Chat node":t==="output"?"Output":t==="value"?"Value":t==="template"?"Template":t==="pick_key"?"Pick key":t==="merge"?"Merge":"User input"),description:(r==null?void 0:r.description)??(t==="box"?"Registered Forge box.":t==="chat"?"Conversational flow node.":t==="functor"?"Single transformation node.":"Workbench node."),boxId:(r==null?void 0:r.id)??null,enabledToolKeys:((r==null?void 0:r.tools)??[]).map(d=>d.key),inputs:(r==null?void 0:r.inputs)??i.inputs,outputs:(r==null?void 0:r.output)??i.outputs,params:(r==null?void 0:r.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((c=((r==null?void 0:r.output)??i.outputs)[0])==null?void 0:c.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function pn(t){return[t.kind,t.modelName,t.itemKind?`item:${t.itemKind}`:null].filter(Boolean).join(" · ")}function hn(t,n){switch(t){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return n?`Save failed: ${n}`:"Save failed";default:return"Saved"}}function gn(t){const n=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${t}_${n}`,label:t==="input"?"New input":"New output",kind:t==="input"?"context":"record",description:"",required:!1,modelName:t==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function xn(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function he(t){return t==="functor"||t==="chat"}function bn(t){const n=t instanceof pa||t instanceof Error?t.message:String(t);return n.includes("No model connection is configured for this connector node.")?["This flow uses an AI node, but Forge does not have any model connection configured yet.","Open Settings > Models, add a model connection, then run the flow again.","Once a model exists, the node can use the default model automatically or you can pick a specific model inside the node editor."].join(`
1
+ import{j as e,r as g,dK as aa,dL as ra,dH as sa,dM as na,dN as ia,dO as oa,aG as la,dP as ca,cl as $a,c1 as Ue,cm as da,b9 as Ge,b2 as za,aC as Va,cL as Da,c4 as Ua,cg as Ga,dQ as Qa,c6 as Ja,b6 as Ya}from"./vendor-BwL6m4SE.js";import{O as Xa}from"./open-in-graph-button-4UYrp1XP.js";import{P as Za}from"./page-hero-DvrM83_C.js";import{T as er,M as tr,S as ar,W as rr,Q as sr}from"./utility-widgets-ilORjDmg.js";import{a as _,n as xe,q as ua,j as R,c as O,e as M,d as L,g as A,b as H,f as q,r as nr,s as ir,h as ma,k as or,t as lr,u as cr,v as _e,W as dr,w as Dt}from"./generic-node-view-C6DK5hJ6.js";import{d as K}from"./define-workbench-box-CpG0Zb1L.js";import{K as ur,a as mr,b as pr}from"./kanban-boxes-BWUzntCV.js";import{S as hr,a as gr,b as xr,c as br,d as fr,e as vr}from"./health-boxes-DqgvIYoL.js";import{M as yr,a as kr,b as wr,c as jr,d as Nr}from"./movement-boxes-BUSqaTL2.js";import{N as Sr,a as Cr,b as _r}from"./notes-boxes-CMJXX2K0.js";import{P as Tr,a as Ir,b as Pr}from"./projects-boxes-iBu_PRqe.js";import{T as Fr,a as Br,b as Rr,c as Wr,d as Er}from"./today-boxes-CYuxSkZf.js";import{H as Or,P as Ut,i as Kr,B as Mr,a as Lr,b as Ar,c as Hr}from"./graph-BF4IsheG.js";import{F as C,Q as qr}from"./question-flow-dialog-Ded2E85L.js";import{W as pa,c as E,a4 as te,B,aC as $r,eG as zr,eH as Vr,b as Gt,eD as Dr,eI as Ur,eJ as Gr,eK as Qr,eL as Jr,eM as Yr,eN as Xr,L as Zr,h as es,e as ts}from"./index-FpGANF9S.js";import{R as as,P as rs,O as ss,C as ns,T as is,D as os,a as ls}from"./ui-B9TWEtCx.js";import{F as cs}from"./faceted-token-search-Dg2rjknH.js";import"./state-Bpe5dF3T.js";import"./motion-DcgUnXhY.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function ds({children:t}){return e.jsx(e.Fragment,{children:t})}function ha(t,n,r,i,c,d){return K(ds,{id:t,surfaceId:"insights",routePath:"/insights",title:n,icon:"insights",description:r,category:"Insights",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const us=ha("surface:insights:feed","Insights feed","Current coaching feed, status summary, and evidence-backed insight stream.",["insights","feed"],t=>ua(t),[_({label:"Insight summary",description:"Summary of the current coaching feed and evidence-backed insight stream."}),xe({key:"insights",label:"Insight payload",description:"Structured status and coaching payload returned by Forge insights.",modelName:"ForgeInsightsPayload"})]),ms=ha("surface:insights:coaching","Coaching recommendation","Single-action coaching summary for what Forge thinks matters next.",["insights","coaching"],t=>R(t,{focus:"coaching_recommendation"},"Coaching recommendation surface for the highest-leverage next move."),[_({label:"Coaching recommendation",description:"Summary of the highest-leverage coaching recommendation."})]);function ps({children:t}){return e.jsx(e.Fragment,{children:t})}function et(t,n,r,i,c,d,u,s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(ps,{id:t,surfaceId:"calendar",routePath:"/calendar",title:n,icon:"calendar",description:r,category:"Calendar",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const hs=et("surface:calendar:overview","Calendar overview","Main calendar surface for mirrored events, work blocks, and planned timeboxes.",["calendar","overview"],t=>R(t,{surfaces:["events","work_blocks","timeboxes"]},"Calendar overview spanning mirrored events, work blocks, and timeboxes."),[_({label:"Calendar summary",description:"Summary of mirrored events, work blocks, and timeboxes."})],[]),gs=et("surface:calendar:events","Calendar events","Mirrored calendar events and Forge-managed calendar records.",["calendar","events","mirrored"],t=>q(t,{query:"",entityTypes:["calendar_event"],limit:20}),H({itemKind:"calendar_event",itemLabel:"Calendar event"}),[A("Search calendar-backed Forge entities and planning records.")],{inputs:L({itemKind:"calendar_event",itemLabel:"Calendar event",defaultEntityTypes:["calendar_event"],defaultLimit:20}),params:M()}),xs=et("surface:calendar:planning","Planning blocks","Planned task timeboxes and reusable work block templates.",["calendar","planning","timeboxes"],t=>q(t,{query:"",entityTypes:["task_timebox","work_block_template"],limit:20}),H({itemKind:"calendar_plan",itemLabel:"Planning record"}),[A("Search calendar-backed Forge entities and planning records.")],{inputs:L({itemKind:"calendar_plan",itemLabel:"Planning record",defaultEntityTypes:["task_timebox","work_block_template"],defaultLimit:20}),params:M()});function bs({children:t}){return e.jsx(e.Fragment,{children:t})}function tt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(bs,{id:t,surfaceId:"goals",routePath:"/goals",title:n,icon:"goal",description:r,category:"Goals",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const fs=tt("surface:goals:hero","Goals hero","Goals page header and long-horizon direction context.",["goals","hero"],t=>R(t,null,"Goals page header."),[_({label:"Goals summary",description:"High-level goals page framing."})]),vs=tt("surface:goals:search-results","Goals list and results","Goal browser, linked context, and search results.",["goals","search"],t=>q(t,{query:"",entityTypes:["goal"],limit:20}),H({itemKind:"goal",itemLabel:"Goal"}),[A("Search goal entities by query and entity types.")],{inputs:L({itemKind:"goal",itemLabel:"Goal",defaultEntityTypes:["goal"],defaultLimit:20}),params:M()}),ys=tt("surface:goals:summary","Goals summary","Goal collection summary and state context.",["goals","summary"],t=>R(t,null,"Goal collection summary."),[_({label:"Goals summary",description:"Summary of the goal collection and its current state."})]);function ks({children:t}){return e.jsx(e.Fragment,{children:t})}function at(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(ks,{id:t,surfaceId:"habits",routePath:"/habits",title:n,icon:"habit",description:r,category:"Habits",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const ws=at("surface:habits:hero","Habits hero","Habits page header and recurring execution context.",["habits","hero"],t=>R(t,null,"Habits page header."),[_({label:"Habits summary",description:"High-level habits page framing."})]),js=at("surface:habits:search-results","Habits list and results","Habit browser, due habits, and recurring check-in context.",["habits","search","check-ins"],t=>q(t,{query:"",entityTypes:["habit"],limit:20}),H({itemKind:"habit",itemLabel:"Habit"}),[A("Search habit entities by query and entity types.")],{inputs:L({itemKind:"habit",itemLabel:"Habit",defaultEntityTypes:["habit"],defaultLimit:20}),params:M()}),Ns=at("surface:habits:summary","Habits summary","Habit streaks, due state, and collection-level rhythm context.",["habits","summary","streaks"],t=>R(t,null,"Habit collection summary."),[_({label:"Habit summary",description:"Summary of habit streaks, due state, and collection rhythm."})]);function Ss({children:t}){return e.jsx(e.Fragment,{children:t})}function rt(t,n,r,i,c,d){return K(Ss,{id:t,surfaceId:"overview",routePath:"/overview",title:n,icon:"overview",description:r,category:"Overview",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const Cs=rt("surface:overview:snapshot","Forge snapshot","Live overview of goals, projects, tasks, habits, and current operating pressure.",["overview","snapshot"],t=>nr(t),[_({label:"Overview summary",description:"Compact summary of goals, projects, tasks, and habits."}),xe({key:"context",label:"Overview context",description:"Structured Forge overview context for the current operating picture.",modelName:"ForgeOverviewContext"})]),_s=rt("surface:overview:momentum","Momentum and health","Momentum-focused summary of streaks, neglected areas, and active execution pressure.",["overview","momentum"],t=>R(t,{dimensions:["momentum","neglected_goals","domain_balance"]},"Overview momentum surface tracking neglected goals, domain balance, and execution pressure."),[_({label:"Momentum summary",description:"Summary of momentum, neglected goals, and execution pressure."})]),Ts=rt("surface:overview:insights","Overview insights","Insight-oriented summary of the current Forge operating picture.",["overview","insights"],t=>ua(t),[_({label:"Insight summary",description:"Compact explanation of the current insight payload."}),xe({key:"insights",label:"Insight payload",description:"Structured insight and coaching payload returned by Forge.",modelName:"ForgeInsightsPayload"})]);function Is({children:t}){return e.jsx(e.Fragment,{children:t})}function st(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Is,{id:t,surfaceId:"preferences",routePath:"/preferences",title:n,icon:"preferences",description:r,category:"Preferences",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ps=st("surface:preferences:workspace","Preferences workspace","Main preference modeling workspace, including summaries, tradeoffs, and evidence.",["preferences","workspace"],t=>R(t,{surfaces:["summary","comparison_game","evidence"]},"Preferences workspace with summary, pairwise comparison, and evidence views."),[_({label:"Preference summary",description:"Summary of the active preference modeling workspace."})]),Fs=st("surface:preferences:contexts","Preference contexts","Preference contexts that shape which tradeoffs and evidence are active.",["preferences","contexts"],t=>q(t,{query:"",entityTypes:["preference_context"],limit:20}),H({itemKind:"preference_context",itemLabel:"Preference context"}),[A("Search preference contexts and modeled preference items.")],{inputs:L({itemKind:"preference_context",itemLabel:"Preference context",defaultEntityTypes:["preference_context"],defaultLimit:20}),params:M()}),Bs=st("surface:preferences:items","Preference items","Preference items scored and compared inside the active context.",["preferences","items"],t=>q(t,{query:"",entityTypes:["preference_item"],limit:20}),H({itemKind:"preference_item",itemLabel:"Preference item"}),[A("Search preference contexts and modeled preference items.")],{inputs:L({itemKind:"preference_item",itemLabel:"Preference item",defaultEntityTypes:["preference_item"],defaultLimit:20}),params:M()});function Rs({children:t}){return e.jsx(e.Fragment,{children:t})}function nt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Rs,{id:t,surfaceId:"psyche",routePath:"/psyche",title:n,icon:"psyche",description:r,category:"Psyche",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ws=nt("surface:psyche:overview","Psyche overview","High-level overview of values, patterns, beliefs, modes, and reports.",["psyche","overview"],t=>R(t,{surfaces:["values","patterns","beliefs","modes","reports"]},"Psyche overview spanning values, patterns, beliefs, modes, and reports."),[_({label:"Psyche summary",description:"Summary of values, patterns, beliefs, modes, and reports."})]),Es=nt("surface:psyche:values","Psyche values","Values and long-lived internal directions tracked inside Forge.",["psyche","values"],t=>q(t,{query:"",entityTypes:["psyche_value"],limit:20}),H({itemKind:"psyche_value",itemLabel:"Psyche value"}),[A("Search psyche entities and reflective records.")],{inputs:L({itemKind:"psyche_value",itemLabel:"Psyche value",defaultEntityTypes:["psyche_value"],defaultLimit:20}),params:M()}),Os=nt("surface:psyche:reports","Trigger reports","Trigger reports and behavior-pattern signals linked to reflective work.",["psyche","reports","patterns"],t=>q(t,{query:"",entityTypes:["trigger_report","behavior_pattern","belief_entry","mode_profile"],limit:20}),H({itemKind:"psyche_record",itemLabel:"Psyche record"}),[A("Search psyche entities and reflective records.")],{inputs:L({itemKind:"psyche_record",itemLabel:"Psyche record",defaultEntityTypes:["trigger_report","behavior_pattern","belief_entry","mode_profile"],defaultLimit:20}),params:M()});function Ks({children:t}){return e.jsx(e.Fragment,{children:t})}function it(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Ks,{id:t,surfaceId:"questionnaires",routePath:"/psyche/questionnaires",title:n,icon:"questionnaire",description:r,category:"Questionnaires",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Ms=it("surface:questionnaires:library","Questionnaire library","Library of questionnaire instruments available in Forge.",["questionnaires","library"],t=>q(t,{query:"",entityTypes:["questionnaire_instrument"],limit:20}),H({itemKind:"questionnaire_instrument",itemLabel:"Questionnaire"}),[A("Search questionnaire instruments and related records.")],{inputs:L({itemKind:"questionnaire_instrument",itemLabel:"Questionnaire",defaultEntityTypes:["questionnaire_instrument"],defaultLimit:20}),params:M()}),Ls=it("surface:questionnaires:drafting","Questionnaire drafting","Drafting and publishing context for questionnaire instruments.",["questionnaires","drafting","authoring"],t=>R(t,{states:["draft","published","run"]},"Questionnaire drafting surface with draft, publish, and run lifecycle context."),[_({label:"Drafting summary",description:"Summary of questionnaire drafting and lifecycle context."})]),As=it("surface:questionnaires:self-observation","Self-observation calendar","Calendar of self-observation notes and linked psyche context.",["questionnaires","self-observation","psyche"],t=>R(t,{linkedDomains:["patterns","reports","notes"]},"Self-observation calendar surface with linked psyche context."),[_({label:"Observation summary",description:"Summary of the self-observation calendar and linked psyche context."})]);function Hs({children:t}){return e.jsx(e.Fragment,{children:t})}function ga(t,n,r,i,c,d){return K(Hs,{id:t,surfaceId:"review",routePath:"/review/weekly",title:n,icon:"review",description:r,category:"Review",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const qs=ga("surface:review:weekly-summary","Weekly review summary","Weekly review payload with momentum, wins, calibration, and completion state.",["review","weekly"],t=>ir(t),[_({label:"Weekly review summary",description:"Summary of momentum, wins, calibration, and review completion state."}),xe({key:"weeklyReview",label:"Weekly review payload",description:"Structured weekly review payload returned by Forge.",modelName:"ForgeWeeklyReview"})]),$s=ga("surface:review:reward","Review reward","Reward framing and completion incentive for closing the current review cycle.",["review","reward"],t=>R(t,{reward:"weekly_review_completion"},"Weekly review reward surface for locking the current cycle into evidence."),[_({label:"Review reward summary",description:"Summary of the reward framing for closing the current review cycle."})]);function zs({children:t}){return e.jsx(e.Fragment,{children:t})}function ot(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(zs,{id:t,surfaceId:"strategies",routePath:"/strategies",title:n,icon:"strategy",description:r,category:"Strategies",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Vs=ot("surface:strategies:hero","Strategies hero","Strategies page header and sequencing context.",["strategies","hero"],t=>R(t,null,"Strategies page header."),[_({label:"Strategies summary",description:"High-level strategies page framing."})]),Ds=ot("surface:strategies:search-results","Strategies list and results","Strategy browser and structured operating context.",["strategies","search"],t=>q(t,{query:"",entityTypes:["strategy"],limit:20}),H({itemKind:"strategy",itemLabel:"Strategy"}),[A("Search strategy entities by query and entity types.")],{inputs:L({itemKind:"strategy",itemLabel:"Strategy",defaultEntityTypes:["strategy"],defaultLimit:20}),params:M()}),Us=ot("surface:strategies:summary","Strategies summary","Strategy collection summary and state context.",["strategies","summary"],t=>R(t,null,"Strategy collection summary."),[_({label:"Strategy summary",description:"Summary of strategy state and collection context."})]);function Gs({children:t}){return e.jsx(e.Fragment,{children:t})}function lt(t,n,r,i,c,d,u=[],s){const o=(s==null?void 0:s.inputs)??[],m=(s==null?void 0:s.params)??[];return K(Gs,{id:t,surfaceId:"tasks",routePath:"/today",title:n,icon:"task",description:r,category:"Tasks",tags:i,inputs:o,params:m,output:d,tools:u,NodeView:O({title:n,description:r,inputs:o,params:m,output:d,tools:u}),execute:c})}const Qs=lt("surface:tasks:inbox","Task queue","Searchable task queue spanning backlog, focus, and in-progress work.",["tasks","queue","search"],t=>q(t,{query:"",entityTypes:["task"],limit:20}),H({itemKind:"task",itemLabel:"Task"}),[A("Search task entities by title, status, or linked context."),ma("Move a task between backlog, focus, in progress, blocked, and done.")],{inputs:L({itemKind:"task",itemLabel:"Task",defaultEntityTypes:["task"],defaultLimit:20}),params:M()}),Js=lt("surface:tasks:focus-lane","Focus lane","Focused task lane for what should happen next right now.",["tasks","focus","execution"],t=>R(t,{hint:"Use this surface to represent active or next-up work."},"Focus lane context for the current execution board."),[_({label:"Focus summary",description:"Human-readable explanation of what the focus lane represents."})],[ma("Change task state as the flow decides what should happen next.")]),Ys=lt("surface:tasks:summary","Task summary","High-level summary of the current task system and work state.",["tasks","summary"],t=>R(t,{states:["backlog","focus","in_progress","blocked","done"]},"Task system summary with the key task states Forge tracks."),[_({label:"Task summary",description:"High-level summary of the current task system and work state."})]);function Xs({children:t}){return e.jsx(e.Fragment,{children:t})}function ct(t,n,r,i,c,d){return K(Xs,{id:t,surfaceId:"wiki",routePath:"/wiki",title:n,icon:"wiki",description:r,category:"Wiki",tags:i,inputs:[],params:[],output:d,tools:[],NodeView:O({title:n,description:r,inputs:[],params:[],output:d,tools:[]}),execute:c})}const Zs=ct("surface:wiki:pages","Wiki pages","Live list of wiki pages that can be used as memory or authored knowledge.",["wiki","pages"],t=>lr(t),[_({label:"Wiki page summary",description:"Summary of the currently available wiki pages."}),or({key:"pages",label:"Wiki pages",description:"Structured wiki page records available in Forge memory.",modelName:"ForgeWikiPages",itemKind:"wiki_page"})]),en=ct("surface:wiki:health","Wiki health","Index health, unresolved links, and orphaned-page signals for the wiki.",["wiki","health"],t=>cr(t),[_({label:"Wiki health summary",description:"Summary of unresolved links and orphaned-page signals."}),xe({key:"health",label:"Wiki health",description:"Structured wiki health payload returned by Forge.",modelName:"ForgeWikiHealth"})]),tn=ct("surface:wiki:authoring","Wiki authoring","Authoring and ingest surface for creating or refining Forge memory.",["wiki","authoring","ingest"],t=>R(t,{actions:["upsert","ingest","reindex"]},"Wiki authoring surface for ingesting sources and maintaining memory pages."),[_({label:"Wiki authoring summary",description:"Summary of wiki authoring and ingest actions available on this surface."})]),an=[er,tr,ar,rr,sr,hs,gs,xs,fs,vs,ys,ws,js,Ns,us,ms,ur,mr,pr,Sr,Cr,_r,Cs,_s,Ts,yr,kr,wr,jr,Nr,hr,gr,xr,br,fr,vr,Tr,Ir,Pr,Ps,Fs,Bs,Ws,Es,Os,Ms,Ls,As,qs,$s,Vs,Ds,Us,Qs,Js,Ys,Fr,Br,Rr,Wr,Er,Zs,en,tn],xa=new Map(an.filter(t=>t.workbench).map(t=>[t.workbench.id,t.workbench]));function ba(){return Array.from(xa.values())}function rn(t){return xa.get(t)??null}function sn(){return ba().map(t=>({id:t.id,boxId:t.id,surfaceId:t.surfaceId,routePath:t.routePath,title:t.title,label:t.title,icon:t.icon??null,description:t.description,category:t.category,tags:t.tags,capabilityModes:["content",...t.tools.length>0?["tool"]:[]],inputs:_e(t.inputs),params:_e(t.params),output:_e(t.output),tools:t.tools,outputs:_e(t.output),toolAdapters:t.tools,snapshotResolverKey:void 0}))}const nn=g.createContext(null),on={definitions:ba(),catalog:sn(),getDefinition:rn};function fa(){return g.useContext(nn)??on}function ln(){return fa().catalog}function cn(t){const n=fa();return t?n.getDefinition(t):null}const Qe=[...dr];function Pe(t){return typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):Array.isArray(t)||t&&typeof t=="object"?JSON.stringify(t,null,2):""}function va(t,n){if(t==="array"||t==="entity_list"||t==="record_list"||t==="object"||t==="json"||t==="record"||t==="context"||t==="filters"||t==="metrics"||t==="timeline"||t==="selection"||t==="entity"){if(!n.trim())return"";try{return JSON.parse(n)}catch{return n}}if(t==="boolean")return n.trim()?n.trim().toLowerCase()==="true"?!0:n.trim().toLowerCase()==="false"?!1:n:"";if(t==="number"){const r=n.trim();if(!r)return"";const i=Number(r);return Number.isFinite(i)?i:n}return n}function dn(t,n){if(n==null||typeof n=="string"&&n.trim().length===0)return!t.required;switch(t.kind){case"text":case"markdown":case"summary":return typeof n=="string";case"number":return typeof n=="number"&&Number.isFinite(n);case"boolean":return typeof n=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(n);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!n&&typeof n=="object";default:return!0}}function ya(t){switch(t){case"box":case"box_input":return{inputs:[],outputs:[{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}]};case"user_input":return{inputs:[],outputs:[{key:"message",label:"Message",kind:"text",description:"Raw user message passed into the flow.",modelName:"WorkbenchUserMessage"},{key:"context",label:"Structured context",kind:"context",description:"Structured context fields that arrived with the user input.",modelName:"WorkbenchUserContext"}]};case"value":return{inputs:[],outputs:[{key:"value",label:"Value",kind:"record",description:"Literal value emitted by this node.",modelName:"WorkbenchLiteralValue"}]};case"functor":case"chat":return{inputs:[{key:"input",label:"Flow input",kind:"context",required:!1,description:"Context gathered from upstream nodes."}],outputs:[{key:"answer",label:"Answer",kind:"markdown",description:"Primary answer returned by this AI node.",modelName:"WorkbenchAiAnswer"}]};case"merge":return{inputs:[{key:"left",label:"Left input",kind:"context",required:!1,description:"First context record to merge."},{key:"right",label:"Right input",kind:"context",required:!1,description:"Second context record to merge."}],outputs:[{key:"merged",label:"Merged context",kind:"context",description:"Combined context assembled from upstream nodes.",modelName:"WorkbenchMergedContext"}]};case"template":return{inputs:[{key:"input",label:"Template input",kind:"context",required:!1,description:"Structured context available to the template."}],outputs:[{key:"rendered",label:"Rendered output",kind:"markdown",description:"Rendered text produced by the template node.",modelName:"WorkbenchTemplateOutput"}]};case"pick_key":return{inputs:[{key:"object",label:"Source object",kind:"object",required:!1,description:"Object record the node should read from."}],outputs:[{key:"selected",label:"Selected value",kind:"record",description:"Value extracted from the chosen key.",modelName:"WorkbenchSelectedValue"}]};case"output":return{inputs:[{key:"result",label:"Published result",kind:"context",required:!1,description:"Final value the flow should publish."}],outputs:[]}}}function ka(t,n){var c,d,u,s;const r=(o,m)=>o.map(h=>{const f=Dt(h),k=f.key==="primary"?m==="output"?t.type==="functor"||t.type==="chat"?"answer":t.type==="box"||t.type==="box_input"?"summary":t.type==="value"?"value":t.type==="merge"?"merged":t.type==="template"?"rendered":t.type==="pick_key"?"selected":"result":t.type==="functor"||t.type==="chat"?"input":t.type==="output"?"result":f.key:f.key;return Dt({...f,key:k,kind:k===f.key?f.kind:void 0})});if(t.type==="box"||t.type==="box_input"){const o=n.find(m=>m.id===t.data.boxId);return{inputs:r((o==null?void 0:o.inputs)??[],"input"),outputs:(c=o==null?void 0:o.output)!=null&&c.length?r(o.output,"output"):r([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(d=t.data.enabledToolKeys)!=null&&d.length?t.data.enabledToolKeys:((o==null?void 0:o.tools)??[]).map(m=>m.key),boxId:(o==null?void 0:o.id)??t.data.boxId??null}}const i=ya(t.type);return{inputs:r((u=t.data.inputs)!=null&&u.length?t.data.inputs:i.inputs,"input"),outputs:r((s=t.data.outputs)!=null&&s.length?t.data.outputs:i.outputs,"output"),enabledToolKeys:t.data.enabledToolKeys??[],boxId:t.data.boxId??null}}function un(t,n){var i,c,d;const r=(i=t.data.outputKey)==null?void 0:i.trim();return!r||r==="primary"?((c=n[0])==null?void 0:c.key)??"":n.some(u=>u.key===r)?r:((d=n[0])==null?void 0:d.key)??r}function Qt(t,n,r){var i,c;return n.length===0?null:!t||t==="primary"?r&&n.some(d=>d.key===r)?r:((i=n[0])==null?void 0:i.key)??null:n.some(d=>d.key===t)?t:r&&n.some(d=>d.key===r)?r:((c=n[0])==null?void 0:c.key)??null}function De(t,n){const r=t.graph.nodes.map(d=>{const u=ka(d,n),s={...d,data:{...d.data,inputs:u.inputs,outputs:u.outputs,outputKey:un(d,u.outputs)}};return Je(s,n)}),i=new Map(r.map(d=>[d.id,d])),c=t.graph.edges.map(d=>{var h,f,k,v;const u=i.get(d.source),s=i.get(d.target),o=Qt(d.sourceHandle,(u==null?void 0:u.data.outputs)??[],(f=(h=u==null?void 0:u.data.outputs)==null?void 0:h[0])==null?void 0:f.key),m=Qt(d.targetHandle,(s==null?void 0:s.data.inputs)??[],(v=(k=s==null?void 0:s.data.inputs)==null?void 0:k[0])==null?void 0:v.key);return wa({...d,sourceHandle:o,targetHandle:m})});return{nodes:r,edges:c}}function Je(t,n){const r=ka(t,n);return{id:t.id,type:"workbench",position:t.position,data:{...t.data,nodeType:t.type==="box_input"?"box":t.type,boxId:r.boxId,enabledToolKeys:r.enabledToolKeys,inputs:r.inputs,outputs:r.outputs,params:t.data.params??[],paramValues:t.data.paramValues??{}}}}function wa(t){return{id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle??void 0,targetHandle:t.targetHandle??void 0,label:t.label??void 0,style:{stroke:"color-mix(in srgb, var(--primary) 44%, transparent)",strokeWidth:1.6}}}function ja(t){return{id:t.id,type:t.data.nodeType==="box"?"box":t.data.nodeType,position:t.position,data:{label:t.data.label,description:t.data.description,boxId:t.data.boxId??null,prompt:t.data.prompt??"",promptTemplate:t.data.promptTemplate??"",systemPrompt:t.data.systemPrompt??"",outputKey:t.data.outputKey??"",enabledToolKeys:t.data.enabledToolKeys??[],inputs:t.data.inputs??[],outputs:t.data.outputs??[],params:t.data.params??[],paramValues:t.data.paramValues??{},template:t.data.template??"",selectedKey:t.data.selectedKey??"",valueType:t.data.valueType??"string",valueLiteral:t.data.valueLiteral??"",modelConfig:t.data.modelConfig}}}function mn(t){return{id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle??null,targetHandle:t.targetHandle??null,label:typeof t.label=="string"?t.label:null}}function Jt(t,n,r){var c;const i=ya(t);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+n.length%3*320,y:80+Math.floor(n.length/3)*220},data:{nodeType:t,label:(r==null?void 0:r.title)??(t==="functor"?"Functor":t==="chat"?"Chat node":t==="output"?"Output":t==="value"?"Value":t==="template"?"Template":t==="pick_key"?"Pick key":t==="merge"?"Merge":"User input"),description:(r==null?void 0:r.description)??(t==="box"?"Registered Forge box.":t==="chat"?"Conversational flow node.":t==="functor"?"Single transformation node.":"Workbench node."),boxId:(r==null?void 0:r.id)??null,enabledToolKeys:((r==null?void 0:r.tools)??[]).map(d=>d.key),inputs:(r==null?void 0:r.inputs)??i.inputs,outputs:(r==null?void 0:r.output)??i.outputs,params:(r==null?void 0:r.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((c=((r==null?void 0:r.output)??i.outputs)[0])==null?void 0:c.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function pn(t){return[t.kind,t.modelName,t.itemKind?`item:${t.itemKind}`:null].filter(Boolean).join(" · ")}function hn(t,n){switch(t){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return n?`Save failed: ${n}`:"Save failed";default:return"Saved"}}function gn(t){const n=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${t}_${n}`,label:t==="input"?"New input":"New output",kind:t==="input"?"context":"record",description:"",required:!1,modelName:t==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function xn(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function he(t){return t==="functor"||t==="chat"}function bn(t){const n=t instanceof pa||t instanceof Error?t.message:String(t);return n.includes("No model connection is configured for this connector node.")?["This flow uses an AI node, but Forge does not have any model connection configured yet.","Open Settings > Models, add a model connection, then run the flow again.","Once a model exists, the node can use the default model automatically or you can pick a specific model inside the node editor."].join(`
2
2
 
3
3
  `):n}function fn(t){return t.map(({key:n,kind:r,required:i,description:c,modelName:d,itemKind:u,shape:s,exampleValue:o})=>({key:n,kind:r,required:!!i,description:c,modelName:d,itemKind:u,shape:s,exampleValue:o}))}function vn(t){const n=Array.from(new Set(t.map(i=>i.trim()).filter(Boolean)));return(n.includes("answer")?n:["answer",...n]).map(i=>({key:i,label:i==="answer"?"Answer":i.split(/[_-]+/).map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join(" "),kind:i==="answer"?"markdown":"record",description:i==="answer"?"Primary answer returned by this AI node.":`Named output published for downstream nodes under "${i}".`,modelName:i==="answer"?"WorkbenchAiAnswer":`Workbench${i.split(/[_-]+/).map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("")}`,exampleValue:i==="answer"?"Concise answer":void 0}))}function yn(t,n){return Na(t,n)[0]??null}function Na(t,n){var u,s;const r=[],i=new Map(t.map(o=>[o.id,o]));t.length===0&&r.push("Add at least one node before running the flow.");const c=t.filter(o=>o.data.nodeType==="output");c.length===0&&r.push("Add an Output node so Forge knows what result the flow should publish.");const d=new Map;for(const o of n){d.set(o.target,(d.get(o.target)??0)+1);const m=i.get(o.source),h=i.get(o.target),f=(m==null?void 0:m.data.outputs)??[],k=(h==null?void 0:h.data.inputs)??[];m&&(o.sourceHandle&&!f.some(v=>v.key===o.sourceHandle)?r.push(`Edge from "${m.data.label}" points to missing output "${o.sourceHandle}". Update the edge or restore that output contract.`):!o.sourceHandle&&f.length>1&&r.push(`Edge from "${m.data.label}" does not name which output it should use. Pick one explicit output handle.`)),h&&(o.targetHandle&&!k.some(v=>v.key===o.targetHandle)?r.push(`Edge into "${h.data.label}" points to missing input "${o.targetHandle}". Update the edge or restore that input contract.`):!o.targetHandle&&k.length>1&&r.push(`Edge into "${h.data.label}" does not name which input it should feed. Pick one explicit input handle.`))}for(const o of c){(d.get(o.id)??0)===0&&r.push(`Connect something into the output node "${o.data.label}" so the flow has something to return.`);const m=n.filter(h=>h.target===o.id).flatMap(h=>{const f=i.get(h.source),k=(f==null?void 0:f.data.outputs)??[];return h.sourceHandle?k.filter(v=>v.key===h.sourceHandle).map(v=>v.key):k.map(v=>v.key)});o.data.outputKey&&m.length>0&&!m.includes(o.data.outputKey)&&r.push(`Output node "${o.data.label}" is configured to publish "${o.data.outputKey}", but that key is not arriving from its upstream nodes.`)}for(const o of t){const m=d.get(o.id)??0,h=n.filter(f=>f.source===o.id).length;o.data.nodeType!=="user_input"&&o.data.nodeType!=="value"&&m===0&&o.data.nodeType!=="box"&&r.push(`Connect an upstream source into "${o.data.label}" so it has real input to work with.`),o.data.nodeType==="merge"&&m<2&&r.push(`Merge node "${o.data.label}" should receive both left and right inputs before you run it.`),o.data.nodeType==="template"&&!(o.data.template??"").trim()&&r.push(`Add a template string to "${o.data.label}" before running the flow.`),o.data.nodeType==="pick_key"&&!(o.data.selectedKey??"").trim()&&r.push(`Choose which key "${o.data.label}" should pick from incoming objects.`),o.data.nodeType!=="output"&&h===0&&r.push(`Connect the output of "${o.data.label}" somewhere useful or remove the node from the graph.`)}for(const o of t)he(o.data.nodeType)&&!((u=o.data.promptTemplate)!=null&&u.trim()||(s=o.data.prompt)!=null&&s.trim())&&r.push(`Add a prompt to the AI node "${o.data.label}" before running the flow.`);return r}function Yt({title:t,description:n,kind:r,publicInputs:i,nodes:c,edges:d}){return{title:t,description:n,kind:r,publicInputs:i,graph:{nodes:c.map(ja),edges:d.map(mn)}}}const y="rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-strong)] outline-none transition placeholder:text-[var(--ui-ink-faint)] focus:border-[color-mix(in_srgb,var(--primary)_40%,transparent)] focus:bg-[var(--ui-surface-2)]",Sa={summary:"border-[color-mix(in_srgb,var(--warning)_30%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--warning)]",markdown:"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",text:"border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[var(--ui-info-soft)] text-[var(--info)]",number:"border-[color-mix(in_srgb,var(--success)_30%,transparent)] bg-[var(--ui-success-soft)] text-[var(--success)]",boolean:"border-[color-mix(in_srgb,var(--success)_30%,transparent)] bg-[var(--ui-success-soft)] text-[var(--success)]",entity:"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",entity_list:"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",context:"border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[var(--ui-info-soft)] text-[var(--info)]",metrics:"border-[color-mix(in_srgb,var(--success)_30%,transparent)] bg-[var(--ui-success-soft)] text-[var(--success)]",filters:"border-[color-mix(in_srgb,var(--warning)_30%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--warning)]",record:"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",record_list:"border-[color-mix(in_srgb,var(--primary)_30%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--primary)]",selection:"border-[color-mix(in_srgb,var(--danger)_30%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--danger)]",timeline:"border-[color-mix(in_srgb,var(--info)_30%,transparent)] bg-[var(--ui-info-soft)] text-[var(--info)]",json:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",object:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",array:"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]",tool:"border-[color-mix(in_srgb,var(--danger)_30%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--danger)]"};function kn(t){switch(t){case"box":case"box_input":return{icon:e.jsx($a,{className:"size-4"}),badge:"box"};case"chat":return{icon:e.jsx(ca,{className:"size-4"}),badge:"chat"};case"functor":return{icon:e.jsx(la,{className:"size-4"}),badge:"functor"};case"output":return{icon:e.jsx(oa,{className:"size-4"}),badge:"output"};case"value":return{icon:e.jsx(ia,{className:"size-4"}),badge:"value"};case"merge":return{icon:e.jsx(na,{className:"size-4"}),badge:"merge"};case"template":return{icon:e.jsx(sa,{className:"size-4"}),badge:"template"};case"pick_key":return{icon:e.jsx(ra,{className:"size-4"}),badge:"pick key"};default:return{icon:e.jsx(aa,{className:"size-4"}),badge:"input"}}}function Fe({kind:t}){return e.jsx("span",{className:E("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]",Sa[t]??"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t.replaceAll("_"," ")})}function G({label:t,onClick:n,emphasis:r=!1}){return e.jsx("button",{type:"button",className:E("rounded-full border px-3 py-1.5 text-[11px] font-medium transition",r?"border-[color-mix(in_srgb,var(--primary)_32%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)] hover:bg-[var(--ui-surface-active)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onPointerDown:i=>i.stopPropagation(),onClick:i=>{i.stopPropagation(),n()},children:t})}function Xt({side:t,ports:n,collapsed:r}){return e.jsxs("div",{className:"grid gap-1.5",children:[e.jsxs("div",{className:E("flex items-center gap-1 px-1 text-[10px] font-medium uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",t==="left"?"text-left":"text-right"),children:[e.jsx("span",{children:t==="left"?"Inputs":"Outputs"}),e.jsx(te,{content:t==="left"?"Inputs are values this node expects from earlier nodes in the flow.":"Outputs are the values this node publishes for later nodes to consume.",label:t==="left"?"Explain node inputs":"Explain node outputs"})]}),n.length===0?e.jsx("div",{className:E("rounded-full border border-dashed border-[var(--ui-border-subtle)] px-3 py-1.5 text-[11px] text-[var(--ui-ink-faint)]",t==="left"?"text-left":"text-right"),children:"None"}):null,n.map(i=>e.jsxs("div",{className:E("relative min-h-6 rounded-[16px] border px-3 py-2 text-[11px] tracking-[0.01em]",t==="left"?"pl-5 text-left":"pr-5 text-right",r?"bg-[var(--ui-surface-1)]":"bg-[var(--ui-surface-2)]",Sa[i.kind]??"border-[var(--ui-border-subtle)] text-[var(--ui-ink-soft)]"),children:[e.jsx(Or,{type:t==="left"?"target":"source",position:t==="left"?Ut.Left:Ut.Right,id:i.key,className:"!size-2.5 !border",style:{[t]:6,background:"var(--primary)",borderColor:"var(--ui-ink-strong)"}}),r?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:i.label}),e.jsx(Fe,{kind:i.kind})]}),e.jsx("div",{className:"mt-1 text-[10px] text-[var(--ui-ink-faint)]",children:pn(i)})]})]},`${t}-${i.key}`))]})}function wn(t){var m,h,f,k;const n=cn(t.data.boxId??null),[r,i]=g.useState(!1),[c,d]=g.useState(!1),u=kn(t.data.nodeType),s=((m=t.data.params)==null?void 0:m.length)??0,o=`${((h=t.data.inputs)==null?void 0:h.length)??0} in · ${((f=t.data.outputs)==null?void 0:f.length)??0} out`;if(n&&t.data.nodeType==="box"){const v=n.NodeView;return e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"absolute right-3 top-3 z-10 flex flex-wrap items-center justify-end gap-2",children:[e.jsx(G,{label:"Edit",onClick:()=>{var w,F;return(F=(w=t.data).onEditRequest)==null?void 0:F.call(w)}}),e.jsx(G,{label:o,onClick:()=>{var w,F;return(F=(w=t.data).onContractEditRequest)==null?void 0:F.call(w)}}),s>0?e.jsx(G,{label:`${s} parameter${s===1?"":"s"}`,onClick:()=>{var w,F;return(F=(w=t.data).onParameterEditRequest)==null?void 0:F.call(w)},emphasis:!0}):null]}),e.jsx("div",{className:E("rounded-[28px] p-[2px] transition",t.selected?"bg-[linear-gradient(135deg,color-mix(in_srgb,var(--primary)_60%,transparent),color-mix(in_srgb,var(--primary)_28%,transparent))]":"bg-transparent"),children:e.jsx(v,{nodeId:t.id,inputs:void 0,params:void 0,compact:!1})})]})}return e.jsxs("div",{className:E("min-w-[270px] rounded-[24px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] p-3 shadow-[var(--ui-shadow-floating)]",t.selected&&"border-[color-mix(in_srgb,var(--primary)_52%,transparent)]"),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[u.icon,e.jsx("div",{className:"truncate text-sm font-semibold",children:t.data.label})]}),t.data.description?e.jsx("div",{className:"mt-1 line-clamp-2 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:t.data.description}):null]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(G,{label:r?"Show ports":"Hide labels",onClick:()=>i(v=>!v)}),e.jsx("div",{className:"rounded-full bg-[var(--ui-surface-2)] px-2.5 py-1 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-soft)]",children:u.badge})]})]}),t.data.boxId?e.jsx("div",{className:"mt-3 rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] text-[var(--ui-ink-soft)]",children:t.data.boxId}):null,e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[(k=t.data.enabledToolKeys)!=null&&k.length?e.jsxs("div",{className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[11px] text-[var(--ui-ink-soft)]",children:[t.data.enabledToolKeys.length," tool",t.data.enabledToolKeys.length===1?"":"s"," enabled"]}):null,e.jsx(G,{label:c?"Hide schema":"Preview schema",onClick:()=>d(v=>!v)}),e.jsx(G,{label:"Edit",onClick:()=>{var v,w;return(w=(v=t.data).onEditRequest)==null?void 0:w.call(v)}}),e.jsx(G,{label:o,onClick:()=>{var v,w;return(w=(v=t.data).onContractEditRequest)==null?void 0:w.call(v)}}),s>0?e.jsx(G,{label:`${s} parameter${s===1?"":"s"}`,onClick:()=>{var v,w;return(w=(v=t.data).onParameterEditRequest)==null?void 0:w.call(v)},emphasis:!0}):null]}),e.jsxs("div",{className:"mt-3 grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3",children:[e.jsx(Xt,{side:"left",ports:t.data.inputs??[],collapsed:r}),e.jsx(Xt,{side:"right",ports:t.data.outputs??[],collapsed:r})]}),c?e.jsxs("div",{className:"mt-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{children:"Node contract"}),e.jsx(te,{content:"This preview shows the shape of the values and tools this node exposes inside the flow graph.",label:"Explain node contract preview"})]}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:JSON.stringify({inputs:(t.data.inputs??[]).map(({key:v,kind:w,required:F})=>({key:v,kind:w,required:!!F})),outputs:(t.data.outputs??[]).map(({key:v,kind:w,required:F})=>({key:v,kind:w,required:!!F})),tools:t.data.enabledToolKeys??[]},null,2)})]}):null]})}const Ca="grid gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",_a="grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",jn="grid gap-3 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",Ye="rounded-[18px] border border-dashed border-[var(--ui-border-strong)] px-4 py-3 text-sm text-[var(--ui-ink-faint)]",Xe="flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",Ze="text-sm leading-6 text-[var(--ui-ink-soft)]",Ta="flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]";function Q(t,n,r){return t.map((i,c)=>c===n?{...i,...r}:i)}function pe(t,n,r,i){return t.map((c,d)=>d===n?{...c,shape:(c.shape??[]).map((u,s)=>s===r?{...u,...i}:u)}:c)}function Nn(){return{key:`field_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New field",kind:"text",required:!1}}function Te({title:t,description:n,ports:r,onChange:i,prefix:c}){return e.jsxs("div",{className:Ca,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:Xe,children:[e.jsx("span",{children:t}),e.jsx(te,{content:n,label:`Explain ${t.toLowerCase()}`})]}),e.jsx("div",{className:`mt-1 ${Ze}`,children:n})]}),e.jsxs(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>i([...r??[],gn(c)]),children:["Add ",c]})]}),e.jsxs("div",{className:"grid gap-3",children:[r.length===0?e.jsxs("div",{className:Ye,children:["No ",c,"s defined yet."]}):null,r.map((d,u)=>e.jsxs("div",{className:_a,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:d.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:d.label})]}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(r.filter((s,o)=>o!==u)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"Downstream nodes reference this exact key.",labelHelp:"Keep keys stable once edges depend on them. Use snake_case names that describe the value clearly.",children:e.jsx("input",{value:d.key,onChange:s=>i(Q(r,u,{key:s.target.value})),className:y})}),e.jsx(C,{label:"Label",description:"Readable name shown in the graph editor.",children:e.jsx("input",{value:d.label,onChange:s=>i(Q(r,u,{label:s.target.value})),className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"This colors the port and tells the flow what sort of value should move through it.",children:e.jsx("select",{value:d.kind,onChange:s=>i(Q(r,u,{kind:s.target.value})),className:y,children:Qe.map(s=>e.jsx("option",{value:s,children:s.replaceAll("_"," ")},s))})}),e.jsx(C,{label:"Model name",description:"Semantic model name for this port, used in previews and runtime contracts.",children:e.jsx("input",{value:d.modelName??"",onChange:s=>i(Q(r,u,{modelName:s.target.value||void 0})),placeholder:"WorkbenchTaskSearchResults",className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Item kind",description:"Optional entity or item subtype when this port carries a collection.",children:e.jsx("input",{value:d.itemKind??"",onChange:s=>i(Q(r,u,{itemKind:s.target.value||void 0})),placeholder:"task",className:y})}),e.jsx(C,{label:"Example value",description:"Short example shown in collapsed previews.",children:e.jsx("input",{value:d.exampleValue??"",onChange:s=>i(Q(r,u,{exampleValue:s.target.value||void 0})),placeholder:c==="input"?"task ids and filters":"summarized result",className:y})})]}),e.jsx(C,{label:"Expectation",description:"Describe what should actually be inside this value so the graph stays legible.",children:e.jsx("textarea",{rows:3,value:d.description??"",onChange:s=>i(Q(r,u,{description:s.target.value||void 0})),placeholder:c==="input"?"Explain what upstream nodes should provide here.":"Explain what downstream nodes can expect from this output.",className:y})}),e.jsxs("details",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-[var(--ui-ink-strong)]",children:"Shape fields"}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsx("div",{className:Ze,children:"Describe the object structure or list item shape this port carries."}),e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>i(r.map((s,o)=>o===u?{...s,shape:[...s.shape??[],Nn()]}:s)),children:"Add field"})]}),(d.shape??[]).length===0?e.jsx("div",{className:Ye,children:"No explicit structure fields yet."}):null,(d.shape??[]).map((s,o)=>e.jsxs("div",{className:jn,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(Fe,{kind:s.kind}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>i(r.map((m,h)=>h===u?{...m,shape:(m.shape??[]).filter((f,k)=>k!==o)}:m)),children:"Remove field"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("input",{value:s.key,onChange:m=>i(pe(r,u,o,{key:m.target.value})),placeholder:"field_key",className:y}),e.jsx("input",{value:s.label,onChange:m=>i(pe(r,u,o,{label:m.target.value})),placeholder:"Field label",className:y})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("select",{value:s.kind,onChange:m=>i(pe(r,u,o,{kind:m.target.value})),className:y,children:Qe.map(m=>e.jsx("option",{value:m,children:m.replaceAll("_"," ")},m))}),e.jsxs("label",{className:"flex items-center gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("input",{type:"checkbox",checked:!!s.required,onChange:m=>i(pe(r,u,o,{required:m.target.checked}))}),"Required field"]})]}),e.jsx("textarea",{rows:2,value:s.description??"",onChange:m=>i(pe(r,u,o,{description:m.target.value||void 0})),placeholder:"What should this field contain?",className:y})]},`${d.key}-shape-${s.key}-${o}`))]})]}),e.jsxs("label",{className:Ta,children:[e.jsx("input",{type:"checkbox",checked:!!d.required,onChange:s=>i(Q(r,u,{required:s.target.checked}))}),"Required port"]})]},`${c}-${d.key}-${u}`))]})]})}function Sn({inputs:t,nodes:n,onChange:r}){return e.jsxs("div",{className:Ca,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:Xe,children:[e.jsx("span",{children:"Flow inputs"}),e.jsx(te,{content:"These are the typed inputs your Workbench flow exposes to the API and the Run modal.",label:"Explain flow inputs"})]}),e.jsx("div",{className:`mt-1 ${Ze}`,children:"Define the external contract once, then bind each input to the node inputs or parameters that should consume it."})]}),e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>r([...t??[],xn()]),children:"Add flow input"})]}),t.length===0?e.jsx("div",{className:Ye,children:"No public flow inputs defined yet."}):null,e.jsx("div",{className:"grid gap-3",children:t.map((i,c)=>{const d=n.filter(s=>(s.data.inputs??[]).length>0||(s.data.params??[]).length>0),u=s=>r(t.map((o,m)=>m===c?{...o,...s}:o));return e.jsxs("div",{className:_a,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Fe,{kind:i.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:i.label})]}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>r(t.filter((s,o)=>o!==c)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Key",description:"External API key callers will send.",children:e.jsx("input",{value:i.key,onChange:s=>u({key:s.target.value}),className:y})}),e.jsx(C,{label:"Label",description:"Human-readable name used in the Run modal.",children:e.jsx("input",{value:i.label,onChange:s=>u({label:s.target.value}),className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(C,{label:"Value type",description:"Expected type for this flow input.",children:e.jsx("select",{value:i.kind,onChange:s=>u({kind:s.target.value}),className:y,children:Qe.map(s=>e.jsx("option",{value:s,children:s.replaceAll("_"," ")},s))})}),e.jsx(C,{label:"Default value",description:"Used when a caller omits this input.",children:e.jsx("textarea",{rows:3,value:Pe(i.defaultValue),onChange:s=>u({defaultValue:va(i.kind,s.target.value)}),className:y})})]}),e.jsx(C,{label:"Description",description:"Explain what callers should send here.",children:e.jsx("textarea",{rows:3,value:i.description??"",onChange:s=>u({description:s.target.value}),className:y})}),e.jsxs("label",{className:Ta,children:[e.jsx("input",{type:"checkbox",checked:!!i.required,onChange:s=>u({required:s.target.checked})}),"Required input"]}),e.jsxs("div",{className:"grid gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-3",children:[e.jsxs("div",{className:Xe,children:["Bindings",e.jsx(te,{content:"Bind this public input to one or more node inputs or parameters. If you leave bindings empty and a node uses the same key, Forge will bind it automatically by key.",label:"Explain bindings"})]}),(i.bindings??[]).map((s,o)=>{const m=n.find(f=>f.id===s.nodeId)??null,h=s.targetKind==="param"?(m==null?void 0:m.data.params)??[]:(m==null?void 0:m.data.inputs)??[];return e.jsxs("div",{className:"grid gap-3 rounded-[16px] bg-[var(--ui-surface-2)] p-3 md:grid-cols-[1.2fr_1fr_1fr_auto]",children:[e.jsxs("select",{value:s.nodeId,onChange:f=>u({bindings:(i.bindings??[]).map((k,v)=>v===o?{...k,nodeId:f.target.value,targetKey:""}:k)}),className:y,children:[e.jsx("option",{value:"",children:"Select node"}),d.map(f=>e.jsx("option",{value:f.id,children:f.data.label},f.id))]}),e.jsxs("select",{value:s.targetKind,onChange:f=>u({bindings:(i.bindings??[]).map((k,v)=>v===o?{...k,targetKind:f.target.value,targetKey:""}:k)}),className:y,children:[e.jsx("option",{value:"input",children:"Node input"}),e.jsx("option",{value:"param",children:"Node parameter"})]}),e.jsxs("select",{value:s.targetKey,onChange:f=>u({bindings:(i.bindings??[]).map((k,v)=>v===o?{...k,targetKey:f.target.value}:k)}),className:y,children:[e.jsx("option",{value:"",children:"Select target"}),h.map(f=>e.jsx("option",{value:f.key,children:f.label},f.key))]}),e.jsx(B,{type:"button",variant:"ghost",size:"sm",onClick:()=>u({bindings:(i.bindings??[]).filter((f,k)=>k!==o)}),children:"Remove"})]},`${s.nodeId}-${s.targetKey}-${o}`)}),e.jsx(B,{type:"button",variant:"secondary",size:"sm",onClick:()=>u({bindings:[...i.bindings??[],{nodeId:"",targetKind:"input",targetKey:""}]}),children:"Add binding"})]})]},`${i.key}-${c}`)})})]})}const Cn="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",Zt="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-left text-[var(--ui-ink-medium)] transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",ea="rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2.5 py-1 text-[11px] text-[var(--ui-ink-soft)]",_n="text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]";function ge({open:t,onOpenChange:n,title:r,description:i,children:c}){return e.jsx(as,{open:t,onOpenChange:n,children:e.jsxs(rs,{children:[e.jsx(ss,{className:"fixed inset-0 z-50 bg-[var(--ui-overlay-backdrop)] backdrop-blur-sm"}),e.jsxs(ns,{className:"fixed inset-x-4 bottom-4 top-4 z-50 mx-auto flex max-w-[min(44rem,calc(100vw-2rem))] flex-col overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-modal)] shadow-[var(--ui-shadow-floating)] md:left-1/2 md:right-auto md:top-[8vh] md:h-[min(82vh,58rem)] md:w-[min(44rem,calc(100vw-1.25rem))] md:-translate-x-1/2 md:bottom-auto",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 border-b border-[var(--ui-border-subtle)] px-5 py-4 backdrop-blur-xl",children:[e.jsxs("div",{children:[e.jsx(is,{className:"font-display text-[1.28rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:r}),i?e.jsx(os,{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:i}):null]}),e.jsx(ls,{asChild:!0,children:e.jsx($r,{"aria-label":"Close workbench flow dialog"})})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-5 py-5",children:c})]})]})})}const Tn=[{type:"user_input",label:"User input",icon:e.jsx(aa,{className:"size-4"})},{type:"value",label:"Value",icon:e.jsx(ia,{className:"size-4"})},{type:"functor",label:"Functor",icon:e.jsx(la,{className:"size-4"})},{type:"chat",label:"Chat",icon:e.jsx(za,{className:"size-4"})},{type:"merge",label:"Merge",icon:e.jsx(na,{className:"size-4"})},{type:"template",label:"Template",icon:e.jsx(sa,{className:"size-4"})},{type:"pick_key",label:"Pick key",icon:e.jsx(ra,{className:"size-4"})},{type:"output",label:"Output",icon:e.jsx(oa,{className:"size-4"})}];function In({open:t,onOpenChange:n,boxQuery:r,onBoxQueryChange:i,boxOptions:c,boxFilters:d,onBoxFiltersChange:u,filteredBoxes:s,onAddNodeType:o,onAddBox:m}){return e.jsx(ge,{open:t,onOpenChange:n,title:"Add node",description:"Add a Forge box, AI node, or utility node to the flow.",children:e.jsxs("div",{className:"grid gap-4",children:[e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:Tn.map(h=>e.jsxs("button",{type:"button",className:`${Zt} flex items-center gap-3 px-4 py-3`,onClick:()=>o(h.type),children:[h.icon,e.jsx("span",{children:h.label})]},h.type))}),e.jsx(cs,{title:"Forge boxes",description:"",query:r,onQueryChange:i,options:c,selectedOptionIds:d,onSelectedOptionIdsChange:u,resultSummary:`${s.length} boxes`,placeholder:"Search visible Forge boxes by title, route, or category",emptyStateMessage:"No boxes match the current query."}),e.jsx("div",{className:"grid max-h-[18rem] gap-2 overflow-auto pr-1",children:s.map(h=>e.jsxs("button",{type:"button",className:`${Zt} px-4 py-3`,onClick:()=>m(h),children:[e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words text-sm font-medium text-[var(--ui-ink-strong)]",children:h.title}),e.jsxs("div",{className:`flex shrink-0 flex-wrap gap-2 ${_n}`,children:[e.jsxs("span",{children:[h.output.length," output",h.output.length===1?"":"s"]}),e.jsxs("span",{children:[h.tools.length," tool",h.tools.length===1?"":"s"]})]})]}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:h.description}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("div",{className:ea,children:h.category}),h.routePath?e.jsx("div",{className:ea,children:h.routePath}):null]})]},h.id))})]})})}function Pn({open:t,onOpenChange:n,title:r,onTitleChange:i,description:c,onDescriptionChange:d,kind:u,onKindChange:s,publicInputs:o,onPublicInputsChange:m,nodes:h,flowId:f,onDelete:k,onSave:v}){return e.jsx(ge,{open:t,onOpenChange:n,title:"Flow settings",description:"Edit the flow identity and persistence without covering the graph with permanent forms.",children:e.jsxs("div",{className:"grid gap-3",children:[e.jsx("input",{value:r,onChange:w=>i(w.target.value),placeholder:"Flow title",className:y}),e.jsx("textarea",{rows:4,value:c,onChange:w=>d(w.target.value),placeholder:"Flow description",className:y}),e.jsxs("select",{value:u,onChange:w=>s(w.target.value),className:y,children:[e.jsx("option",{value:"functor",children:"Functor flow"}),e.jsx("option",{value:"chat",children:"Chat flow"})]}),e.jsx(Sn,{inputs:o,nodes:h,onChange:m}),e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] px-4 py-3 font-mono text-sm text-[var(--ui-code-text)] [overflow-wrap:anywhere]",children:f}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-2 pt-2",children:[e.jsxs(B,{type:"button",variant:"secondary",onClick:()=>{k()},children:[e.jsx(Ue,{className:"size-4"}),"Delete flow"]}),e.jsxs(B,{type:"button",variant:"primary",onClick:()=>{v().then(()=>n(!1))},children:[e.jsx(da,{className:"size-4"}),"Save settings"]})]})]})})}function Fn(t){if(t.trim())try{return JSON.parse(t)}catch{return t}}function Bn({open:t,onOpenChange:n,runError:r,graphIssues:i,hasAiNodes:c,modelConnectionCount:d,publicInputs:u,runInputs:s,onRunInputChange:o,shouldShowLegacyUserInput:m,userInput:h,onUserInputChange:f,debugEnabled:k,onDebugEnabledChange:v,onRun:w,onChat:F,runs:I}){return e.jsx(ge,{open:t,onOpenChange:n,title:"Run flow",description:"Run the flow or chat with it and keep the debug trace for every node.",children:e.jsxs("div",{className:"grid gap-3",children:[r?e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] px-4 py-3 text-sm leading-6 text-[var(--danger)]",children:r}):null,!r&&i.length>0?e.jsxs("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-3 text-sm leading-6 text-[var(--warning)]",children:[e.jsx("div",{className:"font-medium",children:"Fix these graph issues before running:"}),e.jsx("ul",{className:"mt-2 grid gap-1",children:i.slice(0,4).map(x=>e.jsxs("li",{children:["• ",x]},x))})]}):null,!r&&c&&d===0?e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] px-4 py-3 text-sm leading-6 text-[var(--info)]",children:"This flow contains AI nodes, but Forge does not have a model connection yet. Open Settings > Models, add one connection, then come back and run the flow."}):null,u.length>0?e.jsxs("div",{className:`grid gap-3 p-4 ${Cn}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-strong)]",children:["Flow inputs",e.jsx(te,{content:"These are the typed inputs this flow exposes through the API and the Run modal.",label:"Explain flow inputs"})]}),e.jsx("div",{className:"grid gap-3",children:u.map(x=>e.jsx(C,{label:x.label,description:x.description||"Typed input for this flow.",children:x.kind==="boolean"?e.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]",children:[e.jsx("input",{type:"checkbox",checked:!!s[x.key],onChange:T=>o(x.key,T.target.checked)}),x.label]}):x.kind==="number"?e.jsx("input",{type:"number",value:typeof s[x.key]=="number"?String(s[x.key]):"",onChange:T=>o(x.key,T.target.value.trim().length===0?void 0:Number(T.target.value)),className:y}):x.kind==="array"||x.kind==="entity_list"||x.kind==="record_list"||x.kind==="object"||x.kind==="json"||x.kind==="record"||x.kind==="context"||x.kind==="filters"||x.kind==="metrics"||x.kind==="timeline"||x.kind==="selection"||x.kind==="entity"?e.jsx("textarea",{rows:4,value:Pe(s[x.key]),onChange:T=>o(x.key,Fn(T.target.value)),placeholder:'{"key":"value"}',className:y}):e.jsx("input",{value:typeof s[x.key]=="string"?s[x.key]:"",onChange:T=>o(x.key,T.target.value),placeholder:x.exampleValue||x.label,className:y})},x.key))})]}):null,m?e.jsx("textarea",{rows:5,value:h,onChange:x=>f(x.target.value),placeholder:"User input",className:y}):null,e.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-soft)]",children:[e.jsx("input",{type:"checkbox",checked:k,onChange:x=>v(x.target.checked)}),"Return debug trace"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(B,{type:"button",variant:"primary",onClick:w,children:[e.jsx(Ge,{className:"size-4"}),"Run"]}),e.jsxs(B,{type:"button",variant:"secondary",onClick:F,children:[e.jsx(ca,{className:"size-4"}),"Chat"]})]}),e.jsx("div",{className:"grid gap-2 pt-2",children:I.slice(0,5).map(x=>{var T;return e.jsxs("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px] text-[var(--ui-ink-faint)]",children:[e.jsx("span",{children:x.mode}),e.jsx("span",{children:new Date(x.createdAt).toLocaleString()})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:((T=x.result)==null?void 0:T.primaryText)??x.error??"No output yet."})]},x.id)})})]})})}function Be(t){switch(t){case"exec":return 4;case"read_write":return 3;case"write":return 2;case"read":default:return 1}}function Rn(t,n){return Be(t)>=Be(n)?t:n}function ta(t,n){return t==="forge.search_entities"?"Search across Forge entities. You can optionally narrow the search to specific entity types.":t==="forge.create_note"?"Create a Forge note from generated content or captured markdown.":t==="forge.update_task_status"?"Move a task between execution states such as backlog, focus, in progress, blocked, and done.":n.sort((r,i)=>i.length-r.length)[0]??"Workbench tool"}function Wn(t){const n=new Map;for(const r of t)for(const i of r.tools){const c=n.get(i.key);if(!c){n.set(i.key,{key:i.key,label:i.label,description:ta(i.key,[i.description]),accessMode:i.accessMode,argsSchema:i.argsSchema,sources:[r.title],sourceSurfaceIds:r.surfaceId?[r.surfaceId]:[]});continue}c.accessMode=Rn(c.accessMode,i.accessMode),c.label=c.label.length>=i.label.length?c.label:i.label,c.description=ta(i.key,[c.description,i.description]),c.argsSchema=c.argsSchema??i.argsSchema,c.sources.includes(r.title)||c.sources.push(r.title),r.surfaceId&&!c.sourceSurfaceIds.includes(r.surfaceId)&&c.sourceSurfaceIds.push(r.surfaceId)}return[...n.values()].sort((r,i)=>{const c=Be(i.accessMode)-Be(r.accessMode);return c!==0?c:r.label.localeCompare(i.label)})}const En={workbench:wn},Ie="inline-flex h-11 items-center gap-2 rounded-full bg-[color-mix(in_srgb,var(--surface-glass)_94%,transparent)] px-4 text-sm font-medium text-[var(--ui-ink-strong)] shadow-[var(--ui-shadow-soft)] transition hover:bg-[var(--ui-surface-hover)]";function On(t){return t==="error"?"border-[color-mix(in_srgb,var(--danger)_28%,transparent)] bg-[var(--ui-danger-soft)] text-[var(--danger)]":t==="saving"?"border-[color-mix(in_srgb,var(--info)_28%,transparent)] bg-[var(--ui-info-soft)] text-[var(--info)]":t==="dirty"?"border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] text-[var(--warning)]":"border-[color-mix(in_srgb,var(--success)_28%,transparent)] bg-[var(--ui-success-soft)] text-[var(--success)]"}function Kn({flow:t,boxes:n,modelConnections:r,runs:i,onSave:c,onDelete:d,onRun:u,onChat:s}){var Nt,St,Ct,_t,Tt,It,Pt,Ft,Bt,Rt,Wt,Et,Ot,Kt,Mt,Lt,At,Ht,qt,$t,zt,Vt;const[o,m]=g.useState(t.title),[h,f]=g.useState(t.description),[k,v]=g.useState(t.kind),[w,F]=g.useState(t.publicInputs??[]),[I,x]=g.useState(()=>De(t,n).nodes),[T,ne]=g.useState(()=>De(t,n).edges),[be,Re]=g.useState(null),[Ia,fe]=g.useState(!1),[dt,J]=g.useState(!1),[ve,ye]=g.useState("overview"),[Pa,We]=g.useState(void 0),[Fa,ke]=g.useState(!1),[Ba,ut]=g.useState(!1),[Ee,Oe]=g.useState(!1),[Ke,Ra]=g.useState(""),[Me,Wa]=g.useState([]),[Le,Ea]=g.useState(""),[mt,pt]=g.useState({}),[Ae,Oa]=g.useState(!0),[Ka,Y]=g.useState(null),[He,X]=g.useState("idle"),[Ma,we]=g.useState(null),[ae,ht]=g.useState(((Nt=i[0])==null?void 0:Nt.id)??null),[je,gt]=g.useState(null),$=g.useMemo(()=>JSON.stringify(Yt({title:t.title,description:t.description,kind:t.kind,publicInputs:t.publicInputs??[],nodes:t.graph.nodes.map(a=>Je(a,n)),edges:t.graph.edges.map(wa)})),[n,t]),re=g.useRef($),qe=g.useRef($),xt=g.useRef({}),Ne=g.useRef($),Se=g.useRef(null),Ce=g.useRef(!1);g.useEffect(()=>{if($===qe.current)return;qe.current=$,re.current=$,Ne.current=$,m(t.title),f(t.description),v(t.kind),F(t.publicInputs??[]);const a=De(t,n);x(a.nodes),ne(a.edges),X("idle"),we(null)},[n,t,$]),g.useEffect(()=>{pt(Object.fromEntries((t.publicInputs??[]).filter(a=>a.defaultValue!==void 0).map(a=>[a.key,a.defaultValue])))},[t.publicInputs]),g.useEffect(()=>{var a;ht(((a=i[0])==null?void 0:a.id)??null)},[i]),g.useEffect(()=>{x(a=>a.map(l=>l.data.nodeType!=="box"||!l.data.boxId?l:Je(ja(l),n)))},[n]);const La=g.useMemo(()=>Array.from(new Set(n.map(l=>l.category))).map(l=>({id:`category:${l}`,label:l,description:"Workbench box category"})),[n]),Aa=g.useMemo(()=>{const a=Ke.trim().toLowerCase();return n.filter(l=>{const p=a.length===0||[l.title,l.description,l.category,l.routePath??"",...l.tags].join(" ").toLowerCase().includes(a),N=Me.every(S=>S.startsWith("category:")?l.category===S.replace("category:",""):!0);return p&&N})},[Me,Ke,n]),b=g.useMemo(()=>I.find(a=>a.id===be)??null,[I,be]),ie=i[0]??null,Z=i.find(a=>a.id===ae)??ie??null,se=zr({flowId:t.id,runId:ae??""},{skip:!ae||!Ee}),z=((St=se.data)==null?void 0:St.nodeResults.find(a=>a.nodeId===je))??null,V=Vr({flowId:t.id,runId:ae??"",nodeId:je??""},{skip:!ae||!je||!Ee}),$e=g.useMemo(()=>Na(I,T),[I,T]),bt=g.useMemo(()=>I.some(a=>he(a.data.nodeType)),[I]),ze=g.useMemo(()=>I.some(a=>a.data.nodeType==="user_input")||(w??[]).length===0,[I,w]);g.useEffect(()=>{var l,p;const a=((p=(l=se.data)==null?void 0:l.nodeResults[0])==null?void 0:p.nodeId)??null;gt(a)},[(Ct=se.data)==null?void 0:Ct.nodeResults]);const ft=g.useMemo(()=>!!(b&&b.data.nodeType!=="box"&&b.data.nodeType!=="box_input"),[b]),vt=g.useMemo(()=>b?T.filter(a=>a.target===b.id).flatMap(a=>{const l=I.find(N=>N.id===a.source),p=(l==null?void 0:l.data.outputs)??[];return a.sourceHandle?p.filter(N=>N.key===a.sourceHandle):p}):[],[T,I,b]),oe=g.useMemo(()=>Wn(n),[n]),le=g.useMemo(()=>{if(!b||!he(b.data.nodeType))return[];const a=new Set(b.data.enabledToolKeys??[]);return oe.filter(l=>a.has(l.key))},[oe,b]),Ve=g.useMemo(()=>Yt({title:o,description:h,kind:k,publicInputs:w,nodes:I,edges:T}),[h,T,k,I,w,o]),ce=g.useMemo(()=>JSON.stringify(Ve),[Ve]),yt=ce!==re.current;g.useEffect(()=>{if(xt.current=Ve,Ne.current=ce,ce===re.current){we(null),X(a=>a==="saved"?a:"idle");return}X(a=>a==="saving"?a:"dirty")},[ce]);const Ha=g.useMemo(()=>!b||!he(b.data.nodeType)?[]:[{id:"overview",eyebrow:b.data.nodeType==="chat"?"Chat node":"Functor node",title:"Define what this node is responsible for",description:"Give the node a clear role in the flow before configuring prompts and models.",render:(a,l)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Label",description:"This is the name shown on the canvas and in debug traces.",children:e.jsx("input",{value:a.label,onChange:p=>l({label:p.target.value}),className:y})}),e.jsx(C,{label:"Description",description:"Explain what this node should do with the incoming flow context.",children:e.jsx("textarea",{rows:4,value:a.description,onChange:p=>l({description:p.target.value}),className:y})})]})},{id:"prompts",eyebrow:"Prompts",title:"Set the prompt contract",description:"Separate the main prompt from the system instruction so this node stays easier to maintain.",render:(a,l)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Prompt template",description:"This is the main instruction the node sends with the current flow input.",children:e.jsx("textarea",{rows:8,value:a.promptTemplate??a.prompt??"",onChange:p=>l({promptTemplate:p.target.value,prompt:p.target.value}),className:y})}),e.jsx(C,{label:"System prompt",description:"Use this for durable behavior and output rules that should stay consistent.",children:e.jsx("textarea",{rows:5,value:a.systemPrompt??"",onChange:p=>l({systemPrompt:p.target.value}),className:y})})]})},{id:"model",eyebrow:"Model",title:"Choose how this node reaches a model",description:"Pick a specific model connection or leave it on the Forge default once models are configured.",render:(a,l)=>{var p,N,S;return e.jsxs(e.Fragment,{children:[r.length===0?e.jsx("div",{className:"rounded-[20px] border border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[var(--ui-warning-soft)] px-4 py-3 text-sm leading-6 text-[var(--warning)]",children:"No model connection is configured yet. Open Settings > Models, add one connection, then come back here."}):null,e.jsx(C,{label:"Model connection",description:"This can stay empty if you want the node to use Forge's default configured model.",children:e.jsxs("select",{value:((p=a.modelConfig)==null?void 0:p.connectionId)??"",onChange:j=>{var D,U;const P=r.find(ee=>ee.id===j.target.value);l({modelConfig:{connectionId:(P==null?void 0:P.id)??null,provider:(P==null?void 0:P.provider)??null,baseUrl:(P==null?void 0:P.baseUrl)??null,model:(P==null?void 0:P.model)??"",thinking:((D=a.modelConfig)==null?void 0:D.thinking)??null,verbosity:((U=a.modelConfig)==null?void 0:U.verbosity)??null}})},className:y,children:[e.jsx("option",{value:"",children:"Use Forge default model"}),r.map(j=>e.jsx("option",{value:j.id,children:j.label},j.id))]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(C,{label:"Thinking effort",description:"Optional reasoning setting for models that support it.",children:e.jsxs("select",{value:((N=a.modelConfig)==null?void 0:N.thinking)??"",onChange:j=>{var P,D,U,ee,me;return l({modelConfig:{connectionId:((P=a.modelConfig)==null?void 0:P.connectionId)??null,provider:((D=a.modelConfig)==null?void 0:D.provider)??null,baseUrl:((U=a.modelConfig)==null?void 0:U.baseUrl)??null,model:((ee=a.modelConfig)==null?void 0:ee.model)??"",thinking:j.target.value||null,verbosity:((me=a.modelConfig)==null?void 0:me.verbosity)??null}})},className:y,children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})}),e.jsx(C,{label:"Verbosity",description:"Optional output detail setting for models that support it.",children:e.jsxs("select",{value:((S=a.modelConfig)==null?void 0:S.verbosity)??"",onChange:j=>{var P,D,U,ee,me;return l({modelConfig:{connectionId:((P=a.modelConfig)==null?void 0:P.connectionId)??null,provider:((D=a.modelConfig)==null?void 0:D.provider)??null,baseUrl:((U=a.modelConfig)==null?void 0:U.baseUrl)??null,model:((ee=a.modelConfig)==null?void 0:ee.model)??"",thinking:((me=a.modelConfig)==null?void 0:me.thinking)??null,verbosity:j.target.value||null}})},className:y,children:[e.jsx("option",{value:"",children:"Default"}),e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"})]})})]})]})}},{id:"contracts",eyebrow:"Contracts",title:"Define the input and output contract",description:"Give this AI node truthful port names, value types, and expectations so the graph stays readable.",render:(a,l)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(Te,{title:"Inputs",description:"Name the upstream values this AI node expects to receive.",ports:a.inputs??[],onChange:p=>l({inputs:p}),prefix:"input"}),e.jsx(Te,{title:"Outputs",description:"Describe exactly what this AI node will publish for later nodes.",ports:a.outputs??[],onChange:p=>l({outputs:p}),prefix:"output"})]})},{id:"tools",eyebrow:"Outputs and tools",title:"Control what this node can call and publish",description:"Keep tool access tight and name any extra outputs the rest of the flow should consume.",render:(a,l)=>e.jsxs(e.Fragment,{children:[e.jsx(C,{label:"Enabled tools",description:"Only checked tools will be available to this AI node during execution.",children:e.jsx("div",{className:"grid max-h-[18rem] gap-2 overflow-y-auto pr-1",children:oe.length>0?oe.map(p=>{const N=(a.enabledToolKeys??[]).includes(p.key);return e.jsxs("label",{className:"flex items-start gap-3 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-2 text-left",children:[e.jsx("input",{type:"checkbox",checked:N,onChange:S=>{const j=new Set(a.enabledToolKeys??[]);S.target.checked?j.add(p.key):j.delete(p.key),l({enabledToolKeys:[...j]})}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-strong)]",children:[e.jsx("span",{children:p.label}),e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-0.5 text-[10px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:p.accessMode.replace("_"," ")})]}),e.jsx("div",{className:"text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:p.description}),p.sources.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:p.sources.map(S=>e.jsx("span",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-2 py-1 text-[10px] text-[var(--ui-ink-faint)]",children:S},`${p.key}-${S}`))}):null,e.jsx("div",{className:"mt-1 font-mono text-[10px] text-[var(--ui-ink-faint)]",children:p.key}),p.argsSchema?e.jsxs("details",{className:"mt-2 rounded-[14px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] px-3 py-2",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] text-[var(--ui-ink-soft)]",children:"Preview tool arguments"}),e.jsx("pre",{className:"mt-2 overflow-auto whitespace-pre-wrap text-[10px] leading-5 text-[var(--ui-ink-faint)]",children:JSON.stringify(p.argsSchema,null,2)})]}):null]})]},p.key)}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-faint)]",children:"No registered Forge tools are available yet."})})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(C,{label:"Enabled tool preview",description:"Collapsed by default in the node card, this is the contract the AI node can call at run time.",children:e.jsxs("details",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] px-4 py-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-[var(--ui-ink-medium)]",children:le.length>0?`${le.length} tool contract${le.length===1?"":"s"}`:"No tool contract yet"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:JSON.stringify(le.map(p=>({key:p.key,label:p.label,accessMode:p.accessMode,sources:p.sources,argsSchema:p.argsSchema})),null,2)})]})}),e.jsx(C,{label:"Output preview",description:"This is the structure downstream nodes will see from this AI node.",children:e.jsxs("details",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] px-4 py-3",children:[e.jsxs("summary",{className:"cursor-pointer text-sm text-[var(--ui-ink-medium)]",children:[(a.outputs??[]).length," published output",(a.outputs??[]).length===1?"":"s"]}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[11px] leading-5 text-[var(--ui-ink-soft)]",children:JSON.stringify(fn(a.outputs??[]),null,2)})]})})]}),e.jsx(C,{label:"Named outputs",description:"Add comma-separated output keys when later nodes should read more than the primary answer.",children:e.jsx("input",{value:(a.outputs??[]).filter(p=>p.key!=="answer").map(p=>p.key).join(", "),onChange:p=>l({outputs:vn(["answer",...p.target.value.split(",")])}),placeholder:"summary, plan, next_steps",className:y})}),e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:"Danger zone"}),e.jsx("div",{className:"mt-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Remove this node from the graph if you no longer need it."}),e.jsxs(B,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{kt(b.id),J(!1)},children:[e.jsx(Ue,{className:"size-4"}),"Delete node"]})]})]})}],[oe,r,le,b]),de=g.useCallback(async()=>{const a=Ne.current,l=xt.current;if(a===re.current)return X("saved"),!0;if(Se.current)return Ce.current=!0,Se.current;X("saving"),we(null);const p=c(l).then(()=>(re.current=a,qe.current=a,X("saved"),!0)).catch(N=>{const S=N instanceof pa||N instanceof Error?N.message:String(N);return we(S),X("error"),!1}).finally(()=>{Se.current=null,Ce.current&&Ne.current!==re.current?(Ce.current=!1,de()):Ce.current=!1});return Se.current=p,p},[c]);g.useEffect(()=>{if(!yt)return;const a=window.setTimeout(()=>{de()},2e3);return()=>window.clearTimeout(a)},[yt,de,ce]);const ue=g.useCallback((a,l="overview")=>{Re(a),ye(l),We(l==="contracts"?"contracts":"overview"),J(!0)},[]),qa=g.useMemo(()=>I.map(a=>({...a,data:{...a.data,onEditRequest:()=>ue(a.id,"overview"),onContractEditRequest:()=>ue(a.id,"contracts"),onParameterEditRequest:()=>ue(a.id,"parameters")}})),[I,ue]);function W(a){be&&x(l=>l.map(p=>p.id===be?a(p):p))}function kt(a){x(l=>l.filter(p=>p.id!==a)),ne(l=>l.filter(p=>p.source!==a&&p.target!==a)),Re(l=>l===a?null:l)}async function wt(){await de()}async function jt(a){if(!await de()){Y("Forge could not save the latest flow changes before running. Fix the save error and try again.");return}const p=yn(I,T);if(p){Y(p);return}if(bt&&r.length===0){Y(["This flow includes an AI node, but no model is configured in Forge yet.","Open Settings > Models, add a model connection, then try again."].join(`
4
4
 
@@ -1 +1 @@
1
- import{b6 as v,bY as j,r as o,j as t}from"./vendor-BwL6m4SE.js";import{j as S,i as N,k as F}from"./state-Bpe5dF3T.js";import{F as C}from"./faceted-token-search-DldM3-ru.js";import{P as I}from"./page-hero-8bITsx_x.js";import{B as m,b as Q,eD as W,eE as K,eF as $}from"./index-CQ5r7ZUz.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function L(){var h;const l=v(),p=S(),[f]=j(),b=f.get("surface"),[i,g]=o.useState(""),[c,w]=o.useState([]),x=N({queryKey:["forge-workbench-flows"],queryFn:$}),d=F({mutationFn:e=>K({title:e==="chat"?"New chat flow":"New flow",description:e==="chat"?"Conversational workbench flow.":"Reusable workbench transformation flow.",kind:e,homeSurfaceId:b}),onSuccess:({flow:e})=>{p.invalidateQueries({queryKey:["forge-workbench-flows"]}),l(`/workbench/${e.id}`)}}),a=((h=x.data)==null?void 0:h.flows)??[],y=o.useMemo(()=>{const e=[{id:"kind:functor",label:"Functor",description:"Single transformation flows"},{id:"kind:chat",label:"Chat",description:"Conversational flows with user input"}],r=Array.from(new Set(a.map(s=>s.homeSurfaceId).filter(s=>!!s))).map(s=>({id:`surface:${s}`,label:s,description:"Home surface"}));return[...e,...r]},[a]),u=o.useMemo(()=>{const e=i.trim().toLowerCase();return a.filter(r=>{const s=e.length===0||[r.title,r.description,r.kind,r.homeSurfaceId??"",...r.graph.nodes.map(n=>n.data.label)].join(" ").toLowerCase().includes(e),k=c.every(n=>n.startsWith("kind:")?r.kind===n.replace("kind:",""):n.startsWith("surface:")?r.homeSurfaceId===n.replace("surface:",""):!0);return s&&k})},[a,i,c]);return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(I,{entityKind:"workbench",title:"Workbench",titleText:"Workbench",description:"Search and launch reusable Forge flows, then open a flow to edit its graph, tools, prompts, and outputs.",badge:`${a.length} flows`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(m,{type:"button",variant:"primary",onClick:()=>void d.mutateAsync("functor"),children:"New flow"}),t.jsx(m,{type:"button",variant:"secondary",onClick:()=>void d.mutateAsync("chat"),children:"New chat flow"})]}),t.jsx(C,{title:"Flow search",description:"Filter by flow kind or surface, then open a flow to edit or run it.",query:i,onQueryChange:g,options:y,selectedOptionIds:c,onSelectedOptionIdsChange:w,resultSummary:`${u.length} of ${a.length} flows`,placeholder:"Search flow title, description, nodes, or home surface"}),t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:u.map(e=>t.jsxs("button",{type:"button",className:"min-w-0 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",onClick:()=>l(`/workbench/${e.id}`),children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-lg font-semibold text-[var(--ui-ink-strong)]",children:e.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:e.description||"No description yet."})]}),t.jsx(Q,{kind:W(e.kind),label:e.kind==="chat"?"Chat flow":"Functor flow",compact:!0,gradient:!1})]}),t.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap gap-2 text-[12px] text-[var(--ui-ink-faint)]",children:[t.jsxs("span",{className:"min-w-0 break-words",children:[e.graph.nodes.length," nodes"]}),t.jsxs("span",{className:"min-w-0 break-words",children:[e.graph.edges.length," edges"]}),e.homeSurfaceId?t.jsx("span",{className:"min-w-0 break-words",children:e.homeSurfaceId}):null]})]},e.id))})]})}export{L as WorkbenchPage};
1
+ import{b6 as v,bY as j,r as o,j as t}from"./vendor-BwL6m4SE.js";import{j as S,i as N,k as F}from"./state-Bpe5dF3T.js";import{F as C}from"./faceted-token-search-Dg2rjknH.js";import{P as I}from"./page-hero-DvrM83_C.js";import{B as m,b as Q,eD as W,eE as K,eF as $}from"./index-FpGANF9S.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";function L(){var h;const l=v(),p=S(),[f]=j(),b=f.get("surface"),[i,g]=o.useState(""),[c,w]=o.useState([]),x=N({queryKey:["forge-workbench-flows"],queryFn:$}),d=F({mutationFn:e=>K({title:e==="chat"?"New chat flow":"New flow",description:e==="chat"?"Conversational workbench flow.":"Reusable workbench transformation flow.",kind:e,homeSurfaceId:b}),onSuccess:({flow:e})=>{p.invalidateQueries({queryKey:["forge-workbench-flows"]}),l(`/workbench/${e.id}`)}}),a=((h=x.data)==null?void 0:h.flows)??[],y=o.useMemo(()=>{const e=[{id:"kind:functor",label:"Functor",description:"Single transformation flows"},{id:"kind:chat",label:"Chat",description:"Conversational flows with user input"}],r=Array.from(new Set(a.map(s=>s.homeSurfaceId).filter(s=>!!s))).map(s=>({id:`surface:${s}`,label:s,description:"Home surface"}));return[...e,...r]},[a]),u=o.useMemo(()=>{const e=i.trim().toLowerCase();return a.filter(r=>{const s=e.length===0||[r.title,r.description,r.kind,r.homeSurfaceId??"",...r.graph.nodes.map(n=>n.data.label)].join(" ").toLowerCase().includes(e),k=c.every(n=>n.startsWith("kind:")?r.kind===n.replace("kind:",""):n.startsWith("surface:")?r.homeSurfaceId===n.replace("surface:",""):!0);return s&&k})},[a,i,c]);return t.jsxs("div",{className:"grid gap-5",children:[t.jsx(I,{entityKind:"workbench",title:"Workbench",titleText:"Workbench",description:"Search and launch reusable Forge flows, then open a flow to edit its graph, tools, prompts, and outputs.",badge:`${a.length} flows`}),t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(m,{type:"button",variant:"primary",onClick:()=>void d.mutateAsync("functor"),children:"New flow"}),t.jsx(m,{type:"button",variant:"secondary",onClick:()=>void d.mutateAsync("chat"),children:"New chat flow"})]}),t.jsx(C,{title:"Flow search",description:"Filter by flow kind or surface, then open a flow to edit or run it.",query:i,onQueryChange:g,options:y,selectedOptionIds:c,onSelectedOptionIdsChange:w,resultSummary:`${u.length} of ${a.length} flows`,placeholder:"Search flow title, description, nodes, or home surface"}),t.jsx("div",{className:"grid gap-3 lg:grid-cols-2",children:u.map(e=>t.jsxs("button",{type:"button",className:"min-w-0 rounded-[26px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)] p-5 text-left transition hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]",onClick:()=>l(`/workbench/${e.id}`),children:[t.jsxs("div",{className:"flex items-start justify-between gap-4",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate text-lg font-semibold text-[var(--ui-ink-strong)]",children:e.title}),t.jsx("div",{className:"mt-1 line-clamp-2 text-sm leading-6 text-[var(--ui-ink-soft)]",children:e.description||"No description yet."})]}),t.jsx(Q,{kind:W(e.kind),label:e.kind==="chat"?"Chat flow":"Functor flow",compact:!0,gradient:!1})]}),t.jsxs("div",{className:"mt-4 flex min-w-0 flex-wrap gap-2 text-[12px] text-[var(--ui-ink-faint)]",children:[t.jsxs("span",{className:"min-w-0 break-words",children:[e.graph.nodes.length," nodes"]}),t.jsxs("span",{className:"min-w-0 break-words",children:[e.graph.edges.length," edges"]}),e.homeSurfaceId?t.jsx("span",{className:"min-w-0 break-words",children:e.homeSurfaceId}):null]})]},e.id))})]})}export{L as WorkbenchPage};
@@ -1,2 +1,2 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/maps-BTVHALP8.js","assets/vendor-BwL6m4SE.js","assets/vendor-CRS-psbw.css","assets/maps-B-YMMjus.css"])))=>i.map(i=>d[i]);
2
- import{S as B,e as D,k as j,C as c,T as H,I as P,B as E,e3 as I,e1 as K,e4 as W}from"./index-CQ5r7ZUz.js";import{c6 as Q,r as h,j as e,aC as O,cL as q,bs as Z,bB as Y,dw as G,cm as U}from"./vendor-BwL6m4SE.js";import{j as V,i as X,k as J}from"./state-Bpe5dF3T.js";import"./maps-BTVHALP8.js";import{P as ee}from"./page-hero-8bITsx_x.js";import{R as C,A as te,C as ae,X as T,Y as _,T as z,a as se,e as ie,B as re}from"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const A={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"};function k(t){return t?`${Math.round(t/60)}m`:"0m"}function F(t,s){const o=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),n=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${o.format(new Date(t))} · ${n.format(new Date(t))} - ${n.format(new Date(s))}`}function $(t){const s=typeof t=="number"?Math.floor(t):Number.parseFloat(String(t??""));return Number.isFinite(s)?new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function ne(t,s){if(typeof t=="number"){const o=Number.isInteger(t)?String(t):t.toFixed(1);return s&&s!=="count"?`${o} ${s}`:o}return typeof t=="boolean"?t?"Yes":"No":t==null?"n/a":String(t)}function oe(t){return t.length===0?null:{minLat:Math.min(...t.map(s=>s.latitude)),maxLat:Math.max(...t.map(s=>s.latitude)),minLon:Math.min(...t.map(s=>s.longitude)),maxLon:Math.max(...t.map(s=>s.longitude))}}function le({points:t}){var g;const s=h.useRef(null),[o,n]=h.useState(!1),u=typeof window<"u"?((g=window.localStorage.getItem("forge.map.tile-url"))==null?void 0:g.trim())??"":"";h.useEffect(()=>{let x=!1,i=null;if(!u||!s.current||t.length<2){n(!1);return}return I(()=>import("./maps-BTVHALP8.js").then(r=>r.m),__vite__mapDeps([0,1,2,3])).then(r=>{x||!s.current||(i=new r.Map({container:s.current,style:{version:8,sources:{tiles:{type:"raster",tiles:[u],tileSize:256}},layers:[{id:"tiles",type:"raster",source:"tiles"}]},center:[t[0].longitude,t[0].latitude],zoom:13,attributionControl:!1}),i.on("load",()=>{if(!i)return;const d=t.map(m=>[m.longitude,m.latitude]);i.addSource("route",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:d}}}),i.addLayer({id:"route",type:"line",source:"route",paint:{"line-color":"#f97316","line-width":4}});const f=d.reduce((m,p)=>m.extend(p),new r.LngLatBounds(d[0],d[0]));i.fitBounds(f,{padding:44,maxZoom:15}),n(!0)}))}),()=>{x=!0,i==null||i.remove()}},[t,u]);const l=oe(t),v=h.useMemo(()=>{if(!l||t.length<2)return"";const x=720,i=280,r=Math.max(1e-6,l.maxLon-l.minLon),d=Math.max(1e-6,l.maxLat-l.minLat);return t.map(f=>{const m=(f.longitude-l.minLon)/r*x,p=i-(f.latitude-l.minLat)/d*i;return`${m.toFixed(1)},${p.toFixed(1)}`}).join(" ")},[l,t]);return e.jsxs("div",{className:"relative min-h-[280px] overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsx("div",{ref:s,className:"absolute inset-0"}),o?null:e.jsxs("svg",{viewBox:"0 0 720 280",className:"absolute inset-0 h-full w-full",children:[e.jsx("rect",{width:"720",height:"280",fill:"var(--ui-surface-1)"}),v?e.jsx("polyline",{points:v,fill:"none",stroke:"#f97316",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}):null]}),e.jsx("div",{className:"absolute left-3 top-3 max-w-[calc(100%-1.5rem)] rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-xs text-[var(--ui-ink-medium)] backdrop-blur",children:u?"Local-first map tiles configured":"No tile source configured; showing private route shape only"})]})}function de({zones:t}){return e.jsx("div",{className:"grid gap-3",children:t.map(s=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:s.label}),e.jsxs("span",{className:"shrink-0 text-[var(--ui-ink-strong)]",children:[(s.percentage*100).toFixed(1),"% · ",k(s.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,s.percentage*100)}%`,background:A[s.key]??"#f8fafc"}})})]},s.key))})}function we(){var p,y,N,b,S,L,R,M;const{workoutId:t=""}=Q(),s=V(),o=X({queryKey:["workout-detail",t],queryFn:()=>W(t),enabled:t.length>0}),n=o.data,[u,l]=h.useState(""),[v,g]=h.useState("");h.useEffect(()=>{n!=null&&n.workout&&(l(n.workout.meaningText??""),g(n.workout.tags.join(", ")))},[n==null?void 0:n.workout]);const x=J({mutationFn:()=>K(t,{meaningText:u,tags:v.split(",").map(a=>a.trim()).filter(Boolean)}),onSuccess:async()=>{await s.invalidateQueries({queryKey:["workout-detail",t]}),await s.invalidateQueries({queryKey:["forge-fitness"]})}});if(o.isLoading)return e.jsx(B,{title:"Loading workout"});if(o.isError||!n)return e.jsx(D,{eyebrow:"Workout detail",error:o.error??new Error("Forge could not load this workout detail."),onRetry:()=>void o.refetch()});const{workout:i,analytics:r,evidence:d}=n,f=d.timeSeries.filter(a=>a.metricKey==="heart_rate").map((a,w)=>({time:Date.parse(a.startedAt)+w/1e3,bpm:a.value})),m=r.zoneDurations.map(a=>({zone:a.label,minutes:Math.round(a.seconds/60),fill:A[a.key]??"#f8fafc"}));return e.jsxs("div",{className:"grid gap-6",children:[e.jsxs(O,{to:"/sports",className:"inline-flex w-fit items-center gap-2 text-sm text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",children:[e.jsx(q,{className:"size-4"}),"Back to sports"]}),e.jsx(ee,{eyebrow:"Workout evidence",title:i.workoutTypeLabel??i.workoutType,description:`${F(i.startedAt,i.endedAt)} · ${i.sourceDevice||"Apple Health"}`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{children:k(i.durationSeconds)}),e.jsxs(j,{tone:"meta",children:[r.confidence," HR zones"]}),(p=r.routeSummary)!=null&&p.hasRoute?e.jsxs(j,{tone:"meta",children:[r.routeSummary.pointCount," route points"]}):null]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Avg HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.hrSummary.averageHr??i.averageHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Max HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.hrSummary.maxHr??i.maxHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.load.trimp??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"Forge TRIMP"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[Math.round((r.dataQuality.sampleCoverage??0)*100),"%"]}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:[r.dataQuality.heartRateSampleCount??0," samples"]})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]",children:[e.jsxs(c,{className:"min-h-[360px] min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(Z,{className:"size-4 text-[var(--primary)]"}),"Heart-rate timeline"]}),e.jsx("div",{className:"mt-4 h-[300px]",children:f.length>0?e.jsx(C,{width:"100%",height:"100%",children:e.jsxs(te,{data:f,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"#ef4444",stopOpacity:.04})]})}),e.jsx(ae,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(T,{dataKey:"time",interval:"preserveStartEnd",tick:{fill:"var(--ui-ink-soft)",fontSize:11},tickFormatter:$,type:"number",domain:["dataMin","dataMax"]}),e.jsx(_,{tick:{fill:"var(--ui-ink-soft)",fontSize:11},width:42}),e.jsx(z,{labelFormatter:$,contentStyle:{background:"var(--surface-glass)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(se,{type:"monotone",dataKey:"bpm",stroke:"#ef4444",fill:"url(#hrFill)",strokeWidth:2,dot:!1})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-[var(--ui-surface-1)] text-sm text-[var(--ui-ink-soft)]",children:"No raw HR timeline has been synced for this workout yet."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(Y,{className:"size-4 text-[var(--primary)]"}),"Zone mix"]}),e.jsx("div",{className:"mt-4",children:e.jsx(de,{zones:r.zoneDurations})}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(C,{width:"100%",height:"100%",children:e.jsxs(ie,{data:m,children:[e.jsx(T,{dataKey:"zone",tick:{fill:"var(--ui-ink-soft)",fontSize:10}}),e.jsx(_,{tick:{fill:"var(--ui-ink-soft)",fontSize:10},width:34}),e.jsx(z,{contentStyle:{background:"var(--surface-glass)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(re,{dataKey:"minutes",radius:[4,4,0,0]})]})})})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(G,{className:"size-4 text-[var(--primary)]"}),"Route"]}),e.jsx("div",{className:"mt-4",children:d.routePoints.length>1?e.jsx(le,{points:d.routePoints}):e.jsx("div",{className:"grid min-h-[240px] place-items-center rounded-[8px] bg-[var(--ui-surface-1)] text-sm text-[var(--ui-ink-soft)]",children:"No route evidence is available for this workout."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Captured metrics"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((y=i.details)==null?void 0:y.metrics)??[]).slice(0,14).map(a=>e.jsxs("div",{className:"min-w-0 rounded-[8px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:a.label}),e.jsx("div",{className:"mt-1 break-words text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:ne(a.value,a.unit)})]},`${a.category}:${a.key}:${a.statistic}`))})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.7fr)]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Events and phases"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[[...((N=i.details)==null?void 0:N.events)??[],...((b=i.details)==null?void 0:b.components)??[]].slice(0,18).map((a,w)=>e.jsxs("div",{className:"min-w-0 rounded-[8px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:"label"in a?a.label:a.activity.canonicalLabel}),e.jsx(j,{tone:"meta",children:k(a.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:F(a.startedAt,a.endedAt??a.startedAt)})]},`${"type"in a?a.type:a.externalUid}:${a.startedAt}:${w}`)),(((L=(S=i.details)==null?void 0:S.events)==null?void 0:L.length)??0)+(((M=(R=i.details)==null?void 0:R.components)==null?void 0:M.length)??0)===0?e.jsx("div",{className:"rounded-[8px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"No provider events or phases were captured."}):null]})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Reflection"}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Meaning and impact"}),e.jsx(H,{className:"min-h-[160px]",value:u,onChange:a=>l(a.target.value)})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Tags"}),e.jsx(P,{value:v,onChange:a=>g(a.target.value)})]}),e.jsxs(E,{type:"button",pending:x.isPending,pendingLabel:"Saving",onClick:()=>x.mutate(),children:[e.jsx(U,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{we as WorkoutDetailPage};
2
+ import{S as B,e as D,k as j,C as c,T as H,I as P,B as E,e3 as I,e1 as K,e4 as W}from"./index-FpGANF9S.js";import{c6 as Q,r as h,j as e,aC as O,cL as q,bs as Z,bB as Y,dw as G,cm as U}from"./vendor-BwL6m4SE.js";import{j as V,i as X,k as J}from"./state-Bpe5dF3T.js";import"./maps-BTVHALP8.js";import{P as ee}from"./page-hero-DvrM83_C.js";import{R as C,A as te,C as ae,X as T,Y as _,T as z,a as se,e as ie,B as re}from"./charts-BzT4pUPg.js";import"./motion-DcgUnXhY.js";import"./ui-B9TWEtCx.js";import"./board-CuxQRKPJ.js";import"./forms-D1qJ3oOP.js";const A={below_z1:"#94a3b8",zone_1:"#38bdf8",zone_2:"#22c55e",zone_3:"#eab308",zone_4:"#f97316",zone_5:"#ef4444"};function k(t){return t?`${Math.round(t/60)}m`:"0m"}function F(t,s){const o=new Intl.DateTimeFormat(void 0,{weekday:"short",day:"numeric",month:"short"}),n=new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit"});return`${o.format(new Date(t))} · ${n.format(new Date(t))} - ${n.format(new Date(s))}`}function $(t){const s=typeof t=="number"?Math.floor(t):Number.parseFloat(String(t??""));return Number.isFinite(s)?new Date(s).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function ne(t,s){if(typeof t=="number"){const o=Number.isInteger(t)?String(t):t.toFixed(1);return s&&s!=="count"?`${o} ${s}`:o}return typeof t=="boolean"?t?"Yes":"No":t==null?"n/a":String(t)}function oe(t){return t.length===0?null:{minLat:Math.min(...t.map(s=>s.latitude)),maxLat:Math.max(...t.map(s=>s.latitude)),minLon:Math.min(...t.map(s=>s.longitude)),maxLon:Math.max(...t.map(s=>s.longitude))}}function le({points:t}){var g;const s=h.useRef(null),[o,n]=h.useState(!1),u=typeof window<"u"?((g=window.localStorage.getItem("forge.map.tile-url"))==null?void 0:g.trim())??"":"";h.useEffect(()=>{let x=!1,i=null;if(!u||!s.current||t.length<2){n(!1);return}return I(()=>import("./maps-BTVHALP8.js").then(r=>r.m),__vite__mapDeps([0,1,2,3])).then(r=>{x||!s.current||(i=new r.Map({container:s.current,style:{version:8,sources:{tiles:{type:"raster",tiles:[u],tileSize:256}},layers:[{id:"tiles",type:"raster",source:"tiles"}]},center:[t[0].longitude,t[0].latitude],zoom:13,attributionControl:!1}),i.on("load",()=>{if(!i)return;const d=t.map(m=>[m.longitude,m.latitude]);i.addSource("route",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:d}}}),i.addLayer({id:"route",type:"line",source:"route",paint:{"line-color":"#f97316","line-width":4}});const f=d.reduce((m,p)=>m.extend(p),new r.LngLatBounds(d[0],d[0]));i.fitBounds(f,{padding:44,maxZoom:15}),n(!0)}))}),()=>{x=!0,i==null||i.remove()}},[t,u]);const l=oe(t),v=h.useMemo(()=>{if(!l||t.length<2)return"";const x=720,i=280,r=Math.max(1e-6,l.maxLon-l.minLon),d=Math.max(1e-6,l.maxLat-l.minLat);return t.map(f=>{const m=(f.longitude-l.minLon)/r*x,p=i-(f.latitude-l.minLat)/d*i;return`${m.toFixed(1)},${p.toFixed(1)}`}).join(" ")},[l,t]);return e.jsxs("div",{className:"relative min-h-[280px] overflow-hidden rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)]",children:[e.jsx("div",{ref:s,className:"absolute inset-0"}),o?null:e.jsxs("svg",{viewBox:"0 0 720 280",className:"absolute inset-0 h-full w-full",children:[e.jsx("rect",{width:"720",height:"280",fill:"var(--ui-surface-1)"}),v?e.jsx("polyline",{points:v,fill:"none",stroke:"#f97316",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"}):null]}),e.jsx("div",{className:"absolute left-3 top-3 max-w-[calc(100%-1.5rem)] rounded-[8px] border border-[var(--ui-border-subtle)] bg-[var(--surface-glass)] px-3 py-2 text-xs text-[var(--ui-ink-medium)] backdrop-blur",children:u?"Local-first map tiles configured":"No tile source configured; showing private route shape only"})]})}function de({zones:t}){return e.jsx("div",{className:"grid gap-3",children:t.map(s=>e.jsxs("div",{className:"grid gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-sm",children:[e.jsx("span",{className:"min-w-0 break-words text-[var(--ui-ink-medium)] [overflow-wrap:anywhere]",children:s.label}),e.jsxs("span",{className:"shrink-0 text-[var(--ui-ink-strong)]",children:[(s.percentage*100).toFixed(1),"% · ",k(s.seconds)]})]}),e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-[var(--ui-surface-2)]",children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${Math.max(1,s.percentage*100)}%`,background:A[s.key]??"#f8fafc"}})})]},s.key))})}function we(){var p,y,N,b,S,L,R,M;const{workoutId:t=""}=Q(),s=V(),o=X({queryKey:["workout-detail",t],queryFn:()=>W(t),enabled:t.length>0}),n=o.data,[u,l]=h.useState(""),[v,g]=h.useState("");h.useEffect(()=>{n!=null&&n.workout&&(l(n.workout.meaningText??""),g(n.workout.tags.join(", ")))},[n==null?void 0:n.workout]);const x=J({mutationFn:()=>K(t,{meaningText:u,tags:v.split(",").map(a=>a.trim()).filter(Boolean)}),onSuccess:async()=>{await s.invalidateQueries({queryKey:["workout-detail",t]}),await s.invalidateQueries({queryKey:["forge-fitness"]})}});if(o.isLoading)return e.jsx(B,{title:"Loading workout"});if(o.isError||!n)return e.jsx(D,{eyebrow:"Workout detail",error:o.error??new Error("Forge could not load this workout detail."),onRetry:()=>void o.refetch()});const{workout:i,analytics:r,evidence:d}=n,f=d.timeSeries.filter(a=>a.metricKey==="heart_rate").map((a,w)=>({time:Date.parse(a.startedAt)+w/1e3,bpm:a.value})),m=r.zoneDurations.map(a=>({zone:a.label,minutes:Math.round(a.seconds/60),fill:A[a.key]??"#f8fafc"}));return e.jsxs("div",{className:"grid gap-6",children:[e.jsxs(O,{to:"/sports",className:"inline-flex w-fit items-center gap-2 text-sm text-[var(--ui-ink-soft)] transition hover:text-[var(--ui-ink-strong)]",children:[e.jsx(q,{className:"size-4"}),"Back to sports"]}),e.jsx(ee,{eyebrow:"Workout evidence",title:i.workoutTypeLabel??i.workoutType,description:`${F(i.startedAt,i.endedAt)} · ${i.sourceDevice||"Apple Health"}`,actions:e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(j,{children:k(i.durationSeconds)}),e.jsxs(j,{tone:"meta",children:[r.confidence," HR zones"]}),(p=r.routeSummary)!=null&&p.hasRoute?e.jsxs(j,{tone:"meta",children:[r.routeSummary.pointCount," route points"]}):null]})}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-4",children:[e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Avg HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.hrSummary.averageHr??i.averageHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Max HR"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.hrSummary.maxHr??i.maxHeartRate??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"bpm"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Training load"}),e.jsx("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:r.load.trimp??"n/a"}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:"Forge TRIMP"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"HR coverage"}),e.jsxs("div",{className:"mt-3 font-display text-4xl text-[var(--ui-ink-strong)]",children:[Math.round((r.dataQuality.sampleCoverage??0)*100),"%"]}),e.jsxs("div",{className:"mt-1 text-sm text-[var(--ui-ink-faint)]",children:[r.dataQuality.heartRateSampleCount??0," samples"]})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1.25fr)_minmax(280px,0.75fr)]",children:[e.jsxs(c,{className:"min-h-[360px] min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(Z,{className:"size-4 text-[var(--primary)]"}),"Heart-rate timeline"]}),e.jsx("div",{className:"mt-4 h-[300px]",children:f.length>0?e.jsx(C,{width:"100%",height:"100%",children:e.jsxs(te,{data:f,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"hrFill",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#ef4444",stopOpacity:.38}),e.jsx("stop",{offset:"100%",stopColor:"#ef4444",stopOpacity:.04})]})}),e.jsx(ae,{stroke:"var(--ui-border-subtle)",vertical:!1}),e.jsx(T,{dataKey:"time",interval:"preserveStartEnd",tick:{fill:"var(--ui-ink-soft)",fontSize:11},tickFormatter:$,type:"number",domain:["dataMin","dataMax"]}),e.jsx(_,{tick:{fill:"var(--ui-ink-soft)",fontSize:11},width:42}),e.jsx(z,{labelFormatter:$,contentStyle:{background:"var(--surface-glass)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(se,{type:"monotone",dataKey:"bpm",stroke:"#ef4444",fill:"url(#hrFill)",strokeWidth:2,dot:!1})]})}):e.jsx("div",{className:"grid h-full place-items-center rounded-[8px] bg-[var(--ui-surface-1)] text-sm text-[var(--ui-ink-soft)]",children:"No raw HR timeline has been synced for this workout yet."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(Y,{className:"size-4 text-[var(--primary)]"}),"Zone mix"]}),e.jsx("div",{className:"mt-4",children:e.jsx(de,{zones:r.zoneDurations})}),e.jsx("div",{className:"mt-5 h-[180px]",children:e.jsx(C,{width:"100%",height:"100%",children:e.jsxs(ie,{data:m,children:[e.jsx(T,{dataKey:"zone",tick:{fill:"var(--ui-ink-soft)",fontSize:10}}),e.jsx(_,{tick:{fill:"var(--ui-ink-soft)",fontSize:10},width:34}),e.jsx(z,{contentStyle:{background:"var(--surface-glass)",border:"1px solid var(--ui-border-subtle)",borderRadius:8,color:"var(--ui-ink-strong)"}}),e.jsx(re,{dataKey:"minutes",radius:[4,4,0,0]})]})})})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[var(--ui-ink-strong)]",children:[e.jsx(G,{className:"size-4 text-[var(--primary)]"}),"Route"]}),e.jsx("div",{className:"mt-4",children:d.routePoints.length>1?e.jsx(le,{points:d.routePoints}):e.jsx("div",{className:"grid min-h-[240px] place-items-center rounded-[8px] bg-[var(--ui-surface-1)] text-sm text-[var(--ui-ink-soft)]",children:"No route evidence is available for this workout."})})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Captured metrics"}),e.jsx("div",{className:"mt-4 grid gap-3",children:(((y=i.details)==null?void 0:y.metrics)??[]).slice(0,14).map(a=>e.jsxs("div",{className:"min-w-0 rounded-[8px] bg-[var(--ui-surface-1)] px-3 py-2",children:[e.jsx("div",{className:"break-words text-sm text-[var(--ui-ink-soft)] [overflow-wrap:anywhere]",children:a.label}),e.jsx("div",{className:"mt-1 break-words text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:ne(a.value,a.unit)})]},`${a.category}:${a.key}:${a.statistic}`))})]})]}),e.jsxs("section",{className:"grid min-w-0 gap-4 lg:grid-cols-[minmax(0,1fr)_minmax(280px,0.7fr)]",children:[e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Events and phases"}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[[...((N=i.details)==null?void 0:N.events)??[],...((b=i.details)==null?void 0:b.components)??[]].slice(0,18).map((a,w)=>e.jsxs("div",{className:"min-w-0 rounded-[8px] bg-[var(--ui-surface-1)] px-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("div",{className:"min-w-0 break-words text-[var(--ui-ink-strong)] [overflow-wrap:anywhere]",children:"label"in a?a.label:a.activity.canonicalLabel}),e.jsx(j,{tone:"meta",children:k(a.durationSeconds)})]}),e.jsx("div",{className:"mt-1 text-sm text-[var(--ui-ink-soft)]",children:F(a.startedAt,a.endedAt??a.startedAt)})]},`${"type"in a?a.type:a.externalUid}:${a.startedAt}:${w}`)),(((L=(S=i.details)==null?void 0:S.events)==null?void 0:L.length)??0)+(((M=(R=i.details)==null?void 0:R.components)==null?void 0:M.length)??0)===0?e.jsx("div",{className:"rounded-[8px] bg-[var(--ui-surface-1)] p-4 text-sm text-[var(--ui-ink-soft)]",children:"No provider events or phases were captured."}):null]})]}),e.jsxs(c,{className:"min-w-0 overflow-hidden",children:[e.jsx("div",{className:"text-[var(--ui-ink-strong)]",children:"Reflection"}),e.jsxs("div",{className:"mt-4 grid gap-4",children:[e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Meaning and impact"}),e.jsx(H,{className:"min-h-[160px]",value:u,onChange:a=>l(a.target.value)})]}),e.jsxs("label",{className:"grid gap-2",children:[e.jsx("span",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Tags"}),e.jsx(P,{value:v,onChange:a=>g(a.target.value)})]}),e.jsxs(E,{type:"button",pending:x.isPending,pendingLabel:"Saving",onClick:()=>x.mutate(),children:[e.jsx(U,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{we as WorkoutDetailPage};
package/dist/index.html CHANGED
@@ -130,7 +130,7 @@
130
130
  }
131
131
  }
132
132
  </style>
133
- <script type="module" crossorigin src="/forge/assets/index-CQ5r7ZUz.js"></script>
133
+ <script type="module" crossorigin src="/forge/assets/index-FpGANF9S.js"></script>
134
134
  <link rel="modulepreload" crossorigin href="/forge/assets/vendor-BwL6m4SE.js">
135
135
  <link rel="modulepreload" crossorigin href="/forge/assets/state-Bpe5dF3T.js">
136
136
  <link rel="modulepreload" crossorigin href="/forge/assets/motion-DcgUnXhY.js">
@@ -138,7 +138,7 @@
138
138
  <link rel="modulepreload" crossorigin href="/forge/assets/board-CuxQRKPJ.js">
139
139
  <link rel="modulepreload" crossorigin href="/forge/assets/forms-D1qJ3oOP.js">
140
140
  <link rel="stylesheet" crossorigin href="/forge/assets/vendor-CRS-psbw.css">
141
- <link rel="stylesheet" crossorigin href="/forge/assets/index-FxgNSuZX.css">
141
+ <link rel="stylesheet" crossorigin href="/forge/assets/index-ClJbJhca.css">
142
142
  </head>
143
143
  <body class="bg-canvas text-ink antialiased">
144
144
  <div id="root">
@@ -5036,6 +5036,7 @@ function buildAgentOnboardingPayload(request) {
5036
5036
  "Movement is not a normal batch CRUD entity family. It is a dedicated record of stays and trips: a stay means the user remained in the same place for a span of time, and a trip means they traveled between places.",
5037
5037
  "Route-selection questions are internal. User-facing questions should ask for the useful time window, place, selected span, stay, or trip instead of reciting day/month/all-time/timeline/selection route keys.",
5038
5038
  "Use /api/v1/movement/day, /month, /all-time, /timeline, or /selection when the user wants behavioral answers such as how long they stayed at home, when they traveled, which places dominated a period, or what happened across a selected span.",
5039
+ "After a Movement read, translate the result into one next action: no change, a manual overlay, a place boundary correction, a settings change, or a linked note. Ask only for the missing span, place, boundary, or confirmation that enables that action.",
5039
5040
  "Use GET /api/v1/movement/settings and PATCH /api/v1/movement/settings when the user wants to inspect or change passive capture, publish mode, retention mode, or companion readiness. Do not route settings changes through stays, trips, places, or batch CRUD.",
5040
5041
  "For known-place creation or cleanup, ask for the place label, boundary, and future use, then use POST /api/v1/movement/places or PATCH /api/v1/movement/places/:id instead of tags or generic entity writes.",
5041
5042
  "Use the movement write routes when the user wants to add a place or manual overlay, update a specific stay or trip, repair one recorded movement span, or attach movement context to another Forge record. If the user is filling a missing-data gap, the usual write path is a user-defined overlay box rather than a raw stay or trip patch.",
@@ -5079,6 +5080,7 @@ function buildAgentOnboardingPayload(request) {
5079
5080
  "Use GET /api/v1/life-force for the current overview payload with stats, drains, recommendations, and current-curve state.",
5080
5081
  "Patch the profile only for durable personal settings, update weekday templates only for the curve itself, and post fatigue signals for real-time tired or recovered observations.",
5081
5082
  "If the user only needs an explanation or planning read, use the overview first and do not turn the conversation into a profile or template mutation.",
5083
+ "After a Life Force overview, translate the result into one planning implication: lighter workload, added recovery, protected timebox, meeting change, task-choice change, or no change. Ask for a profile, weekday-template, or fatigue-signal detail only when that implication requires a mutation.",
5082
5084
  "For profile or weekday-template edits, ask what future planning behavior should change, such as workload, recovery time, timeboxes, meeting load, or task choice, so the write is not just a nicer description.",
5083
5085
  "If the user says something like 'I always dip on Tuesdays after lunch', treat that as a weekday-template change rather than a one-off fatigue signal.",
5084
5086
  "If the user is asking what changed after a profile, template, or fatigue write, read the overview back so the effect stays visible.",
@@ -5122,6 +5124,7 @@ function buildAgentOnboardingPayload(request) {
5122
5124
  "Use GET /api/v1/life-force for the current overview payload with stats, drains, recommendations, and current-curve state.",
5123
5125
  "Patch the profile only for durable personal settings, update weekday templates only for the curve itself, and post fatigue signals for real-time tired or recovered observations.",
5124
5126
  "If the user only needs an explanation or planning read, use the overview first and do not turn the conversation into a profile or template mutation.",
5127
+ "After a Life Force overview, translate the result into one planning implication: lighter workload, added recovery, protected timebox, meeting change, task-choice change, or no change. Ask for a profile, weekday-template, or fatigue-signal detail only when that implication requires a mutation.",
5125
5128
  "For profile or weekday-template edits, ask what future planning behavior should change, such as workload, recovery time, timeboxes, meeting load, or task choice, so the write is not just a nicer description.",
5126
5129
  "If the user says something like 'I always dip on Tuesdays after lunch', treat that as a weekday-template change rather than a one-off fatigue signal.",
5127
5130
  "If the user is asking what changed after a profile, template, or fatigue write, read the overview back so the effect stays visible.",
@@ -5215,6 +5218,7 @@ function buildAgentOnboardingPayload(request) {
5215
5218
  "For saved flow chat follow-ups, use POST /api/v1/workbench/flows/:id/chat only when the user wants to continue a flow-specific conversation. Do not turn that into a new run, note, or generic entity update unless the user asks.",
5216
5219
  "Prefer the dedicated output and node-result routes over reverse-engineering raw traces.",
5217
5220
  "If the user only wants a published output, latest node output, or run detail, do not reopen a flow-edit intake before reading that artifact.",
5221
+ "After a Workbench read, translate the artifact into one next action: rerun with clearer input, inspect a specific node, edit the saved flow, publish or preserve the output, or stop because the answer is already sufficient. Ask only for the missing input, node, run, preservation choice, or confirmation that would change that action.",
5218
5222
  "If the user already named the flow and wants one output or one run, skip the broad lane question and ask only for the missing run, node, or output scope."
5219
5223
  ]
5220
5224
  }
@@ -5482,14 +5486,14 @@ function buildAgentOnboardingPayload(request) {
5482
5486
  saveSuggestionPlacement: "end_of_message",
5483
5487
  saveSuggestionTone: "gentle_optional",
5484
5488
  maxQuestionsPerTurn: 1,
5485
- psycheExplorationRule: "When a Psyche entity needs understanding first, begin with one exploratory question before any working formulation, replacement belief, suggested title, or save pitch. Keep the opening reflection to one or two short sentences, stay in plain prose instead of bullets or numbered lists, keep that first reply short, do not mention Forge search or save structure yet, avoid colons or list-shaped phrasing, prefer what/when/how over why until the experience is grounded, wait for the user's answer before offering a fuller formulation, ask permission before moving from charged exploration into naming or challenge when needed, make the next question help the user feel more able to name the experience rather than more examined, do not widen into adjacent entities until the current one has a working sentence the user recognizes, and once the lived experience is coherent stop deepening and help the user name it cleanly. After one concrete example is clear and a hypothesis lands or is corrected, translate it into a saveable record shape such as a belief sentence, functional loop, behavior, mode, trigger report, value, event type, or emotion definition; ask one accuracy question instead of reopening broad exploration, then use the shared batch entity routes after the user accepts the wording or explicitly asks to save. When the user is updating a Psyche record because of one fresh episode, anchor in that episode before renaming the durable formulation, begin with the smallest part of the old wording that no longer fits, and do not reopen the full origin story unless the new understanding is truly structural. If the user accepts the wording, move toward the save instead of reopening deeper exploration.",
5489
+ psycheExplorationRule: "When a Psyche entity needs understanding first, begin with one exploratory question before any working formulation, replacement belief, suggested title, or save pitch. Keep the opening reflection to one or two short sentences, stay in plain prose instead of bullets or numbered lists, keep that first reply short, do not mention Forge search or save structure yet, avoid colons or list-shaped phrasing, prefer what/when/how over why until the experience is grounded, wait for the user's answer before offering a fuller formulation, ask permission before moving from charged exploration into naming or challenge when needed, make the next question help the user feel more able to name the experience rather than more examined, do not widen into adjacent entities until the current one has a working sentence the user recognizes, and once the lived experience is coherent stop deepening and help the user name it cleanly. After one concrete example is clear and a hypothesis lands or is corrected, translate it into a saveable record shape such as a belief sentence, functional loop, behavior, mode, trigger report, value, event type, or emotion definition; do not leave the user with interpretation alone, name the primary Forge record it is becoming, and ask one accuracy or consent question instead of reopening broad exploration, then use the shared batch entity routes after the user accepts the wording or explicitly asks to save. When the user is updating a Psyche record because of one fresh episode, anchor in that episode before renaming the durable formulation, begin with the smallest part of the old wording that no longer fits, and do not reopen the full origin story unless the new understanding is truly structural. If the user accepts the wording, move toward the save instead of reopening deeper exploration.",
5486
5490
  progressiveDisclosureRule: "Treat partial answers as progress, not as failed intake. Before asking another question, identify what is already usable: operation, entity or surface, target record or time span, working wording, owner or placement, route lane, and consent. Say the usable part back briefly, then ask only for the first missing detail that changes the action: duplicate disambiguation, hierarchy parent, time window, weekday, flow, run, node, correction, link, or save consent. For normal batch entities, do not ask for optional tags, priority, status, dates, color, links, or assignees when the accepted wording and meaningful body are already enough unless that metadata changes accountability, retrieval, or execution. For Movement, Life Force, and Workbench, if the user's wording already implies the dedicated lane, skip the broad route-family question and ask only for the target span, place, weekday, profile field, flow, run, node, output, correction, or consent that is still missing. For direct Psyche saves or updates, treat an offered belief sentence, functional loop, part voice, trigger episode, value phrase, event kind, emotion signature, or flashcard message as real data; ask one accuracy or consent question instead of reopening origin, evidence, or repair.",
5487
5491
  writeConfirmationRule: "After create, update, delete, restore, run, read, or repair actions, confirm the user-facing record, action, and result in the user's language instead of reopening intake. For batch creates and updates, confirm the working title or accepted wording, container, and owner or placement only when those changed retrieval, accountability, or execution; if optional tags, priority, status, color, links, dates, or assignees were left provisional, say that plainly once instead of asking for all of them. For action workflows, confirm the real product action such as task run started or completed, work adjustment applied, preference judgment or signal submitted, questionnaire run updated or completed, calendar connection synced, or self-observation note written. For Psyche saves, confirm the accepted wording and whether it was saved as a first version, update, link, archive, or distinct version; do not reopen origin, evidence, repair, or adjacent entity mapping after the save unless that next object is already visible and materially useful. Ask a follow-up only if it changes the next action: correction, link, schedule, run, publish, enrichment, preservation choice, or UI handoff.",
5488
- specializedSurfaceRule: "For Movement, Life Force, and Workbench, clarify the job first, then choose the dedicated route family internally and do not guess at a generic CRUD path. Use specializedDomainSurfaces.routeSelectionQuestions when they are present so the next follow-up selects the right route instead of asking generic questions. When available, use forge_call_movement_route, forge_call_life_force_route, or forge_call_workbench_route after the lane is clear. In user-facing language, talk about timeline, overlay, weekday template, published output, run detail, or node result rather than surfaces, payloads, read paths, mutation paths, or CRUD. If the truth of the current state is still uncertain, read the relevant dedicated view before you mutate it. When the user already named a precise correction or review target, confirm only the route-selecting detail that is still missing. After a concrete Movement, Life Force, or Workbench correction, mutation, or result-producing run, read the relevant view back when the user is trying to understand the result rather than just store it: timeline or place/settings detail for Movement, the Life Force overview for energy-planning impact, and flow detail, run detail, node result, latest node output, published output, or run history for Workbench. The canonical runtime routes stay under /api/v1/*, and the OpenClaw HTTP mirror exposes the same families under /forge/v1/movement, /forge/v1/life-force, and /forge/v1/workbench.",
5489
- reviewShortcutRule: "When the user is reviewing or correcting an existing record, ask what practical question they want the read or correction to answer, then narrow the saved object, timeframe, or route family first. Use the correct read posture before asking write-shaped questions: shared batch search or read hints for normal entities, wiki/calendar dedicated reads for specialized CRUD, read-model routes for overviews, and Movement, Life Force, or Workbench dedicated reads for those domain surfaces. After the read, answer the practical question before asking for any save, correction, link, run, enrichment, or publish detail. Do not reopen the whole intake unless the user is actually redefining the record.",
5492
+ specializedSurfaceRule: "For Movement, Life Force, and Workbench, clarify the job first, then choose the dedicated route family internally and do not guess at a generic CRUD path. Use specializedDomainSurfaces.routeSelectionQuestions when they are present so the next follow-up selects the right route instead of asking generic questions. When available, use forge_call_movement_route, forge_call_life_force_route, or forge_call_workbench_route after the lane is clear. In user-facing language, talk about timeline, overlay, weekday template, published output, run detail, or node result rather than surfaces, payloads, read paths, mutation paths, or CRUD. If the truth of the current state is still uncertain, read the relevant dedicated view before you mutate it. When the user already named a precise correction or review target, confirm only the route-selecting detail that is still missing. After a concrete Movement, Life Force, or Workbench correction, mutation, or result-producing run, read the relevant view back when the user is trying to understand the result rather than just store it: timeline or place/settings detail for Movement, the Life Force overview for energy-planning impact, and flow detail, run detail, node result, latest node output, published output, or run history for Workbench. After any dedicated read, translate the result into one next action: no change, Movement overlay/place/settings/link, Life Force workload/recovery/timebox/meeting/task-choice change, or Workbench rerun/node inspection/flow edit/publish/preserve/stop. Ask only for the missing span, place, weekday, flow, run, node, output, correction, preservation choice, or confirmation that would change that action. The canonical runtime routes stay under /api/v1/*, and the OpenClaw HTTP mirror exposes the same families under /forge/v1/movement, /forge/v1/life-force, and /forge/v1/workbench.",
5493
+ reviewShortcutRule: "When the user is reviewing or correcting an existing record, ask what practical question they want the read or correction to answer, then narrow the saved object, timeframe, or route family first. Use the correct read posture before asking write-shaped questions: shared batch search or read hints for normal entities, wiki/calendar dedicated reads for specialized CRUD, read-model routes for overviews, and Movement, Life Force, or Workbench dedicated reads for those domain surfaces. After the read, answer the practical question before asking for any save, correction, link, run, enrichment, or publish detail. If several actions are possible, narrow to the one most directly supported by the read instead of handing the user a broad menu. Do not reopen the whole intake unless the user is actually redefining the record.",
5490
5494
  readModelWriteRule: "Self-observation is note-backed and should be written through observed notes with frontmatter.observedAt only when a lightweight episode observation is the right container. Do not use it as the default bucket for Psyche material: prefer trigger_report for one emotionally meaningful episode, behavior_pattern for functional analysis of a recurring loop, behavior for one repeated move, belief_entry for a core sentence, mode_guide_session or mode_profile for a central part-state, and wiki_page for durable memory such as books, articles, concepts, sources, or personal manuals. Sleep and workout sessions stay on batch CRUD by default; use the reflective review helpers only when enriching one already-known record after review.",
5491
5495
  psycheOpeningQuestionRule: "Prefer a concrete opening question tied to the entity: ask when the value mattered, what happened the last time the pattern appeared, what cue or body signal came first before the behavior, what the belief starts saying about self or outcome, what feels most at risk inside the mode, what the part is trying to get the user to do or stop doing, or where the shift began in the incident. Reflect briefly before the question, choose one follow-up lane at a time, say what is becoming clearer before the next deeper question, and if several Psyche entities are visible hold the adjacent ones lightly until the main container is clear.",
5492
- psycheHypothesisRule: "When one concrete Psyche example is visible, a helpful hypothesis should start from evidence in the user's own example, offer one testable interpretation, name the function without blame such as protection, prediction, relief, or cost, and ask whether the danger, need, or wording fits. Use the hypothesis timing checkpoint before asking a second or third deepening question: offer a hypothesis when one concrete episode, body cue, belief sentence, behavior, or mode voice is visible and the hypothesis would change the record shape, wording, links, or next action. Do not keep asking broad exploratory Psyche questions after the cue, meaning, protection, payoff, or cost is already visible. For behavior_pattern, belief_entry, mode_profile, mode_guide_session, and trigger_report, the next helpful move is usually one active formulation plus one correction question, not another passive reflection. Hypotheses should reduce the formulation burden. Do not make the user prove the experience: after one hypothesis, ask one fit-or-correction question rather than a stack of evidence, origin, and repair questions. If accuracy needs grounding, ask for the smallest lived cue or contrast that would change the wording, danger, protection, payoff, cost, or record shape. Do not hypothesize yet when no concrete moment is visible, the user only wants a direct mechanical save, the user is flooded or unsafe, or the only available interpretation would be diagnosis-like, an origin story, or a certainty claim. Do not present schema, mode, belief, or pattern language as a verdict. If the user corrects the hypothesis, revise it once and move toward the saveable record shape instead of asking for another broad story.",
5496
+ psycheHypothesisRule: "When one concrete Psyche example is visible, a helpful hypothesis should start from evidence in the user's own example, offer one testable interpretation, name the function without blame such as protection, prediction, relief, or cost, and ask whether the danger, need, or wording fits. Use the hypothesis timing checkpoint before asking a second or third deepening question: offer a hypothesis when one concrete episode, body cue, belief sentence, behavior, or mode voice is visible and the hypothesis would change the record shape, wording, links, or next action. Do not keep asking broad exploratory Psyche questions after the cue, meaning, protection, payoff, or cost is already visible. For behavior_pattern, belief_entry, mode_profile, mode_guide_session, and trigger_report, the next helpful move is usually one active formulation plus one correction question, not another passive reflection. Hypotheses should reduce the formulation burden. Do not make the user prove the experience: after one hypothesis, ask one fit-or-correction question rather than a stack of evidence, origin, and repair questions. If accuracy needs grounding, ask for the smallest lived cue or contrast that would change the wording, danger, protection, payoff, cost, or record shape. Do not hypothesize yet when no concrete moment is visible, the user only wants a direct mechanical save, the user is flooded or unsafe, or the only available interpretation would be diagnosis-like, an origin story, or a certainty claim. Do not present schema, mode, belief, or pattern language as a verdict. Do not leave the user with interpretation alone; name the primary Forge record and ask one accuracy or consent question that moves toward saving the corrected formulation. If the user corrects the hypothesis, revise it once and move toward the saveable record shape instead of asking for another broad story.",
5493
5497
  mixedIntentSequencingRule: "When one user message combines several Forge jobs, identify the primary job and the order of operations before asking a follow-up. If a read changes the truth of a later write, read first: Movement timeline or box detail before correction, Workbench run or node detail before editing or publishing, and Life Force overview before changing durable assumptions when the current energy picture is uncertain. If the user asks to understand and save Psyche material plus create a support record, formulate the primary Psyche record first, then derive the flashcard, note, link, task, or habit from the accepted wording. If the user already gave the concrete action, do not ask a broad lane question; say the product sequence briefly and ask only for the missing span, wording, flow, run, node, weekday, or link that changes the next action.",
5494
5498
  duplicateDisambiguationRule: "Before creating or updating a normal stored entity when duplicate risk is plausible, search the shared batch entity route by entity type, distinctive title or wording, owner scope, and linked content. If a likely existing record appears, ask whether the user wants to update that record, link to it, or save a separate new record; do not reopen the whole create flow. For Psyche records, a similar belief, pattern, mode, trigger report, value, or flashcard is a formulation choice, not a duplicate error: compare the sentence, cue/payoff/cost, protective job, episode, urge sentence, or message and let the user choose update, link, or new version. For wiki_page and calendar_connection, use dedicated search/list/read routes before creating another page or connection. For Movement, Life Force, and Workbench, use the dedicated read lanes instead of batch duplicate search.",
5495
5499
  destructiveActionRule: "Before deleting, archiving, invalidating, overwriting, disconnecting, or substantially replacing a Forge record or specialized object, confirm the exact target and what should remain understandable. Prefer normal soft-delete for stored entities unless the user explicitly asks for permanent removal. For Psyche records, preserve therapeutic history by asking whether the old belief, pattern, mode, trigger report, value, or flashcard should be updated, linked as history, archived, or kept distinct; do not delete it just because a cleaner formulation exists. For Movement, distinguish user-defined overlay deletion from automatic-box invalidation and stay/trip/point deletion, and read the specific span first when the target is uncertain. For calendar connections, Workbench flows, wiki pages, and questionnaire instruments, ask what downstream sync, published output, backlinks, run history, or completed runs should remain understandable before deleting or replacing the saved object.",