forge-openclaw-plugin 0.2.109 → 0.2.110
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.
- package/dist/assets/{activity-page-DWHZ8_sJ.js → activity-page-BdeoV3N4.js} +1 -1
- package/dist/assets/{ai-surface-workspace-DPygfyhc.js → ai-surface-workspace-BCbQUekv.js} +1 -1
- package/dist/assets/{atlas-panel-D261RUQF.js → atlas-panel-DTnRBOZx.js} +1 -1
- package/dist/assets/{calendar-page-BQbJkdPF.js → calendar-page-YDexXy_e.js} +1 -1
- package/dist/assets/{calendar-rules-BoFsuvZ8.js → calendar-rules-B_aOcMi3.js} +1 -1
- package/dist/assets/{calendar-week-toolbar-LetevPI7.js → calendar-week-toolbar-BTbIzq3e.js} +1 -1
- package/dist/assets/{companion-sync-lab-page-Bid-4B8W.js → companion-sync-lab-page-DKouMut9.js} +1 -1
- package/dist/assets/{daily-metrics-dashboard-CqnGJNeI.js → daily-metrics-dashboard-B3UCGG1t.js} +1 -1
- package/dist/assets/{entity-note-count-link-VMURwBMi.js → entity-note-count-link-DUxobQUt.js} +1 -1
- package/dist/assets/{entity-notes-surface-DGXcyNzo.js → entity-notes-surface-BdHBn8rx.js} +1 -1
- package/dist/assets/{execution-board-BGf6zZqJ.js → execution-board-R5-oyf-Z.js} +1 -1
- package/dist/assets/{faceted-token-search-CAsZrhZ4.js → faceted-token-search-DtO6OUwQ.js} +1 -1
- package/dist/assets/{flagship-signal-deck-DJsq3jn2.js → flagship-signal-deck-B9k46sWA.js} +1 -1
- package/dist/assets/{floating-action-menu-B3tQStUN.js → floating-action-menu-DBzfnJOx.js} +1 -1
- package/dist/assets/{goal-detail-page-DBs-9wpk.js → goal-detail-page-Mr_gnZ2l.js} +1 -1
- package/dist/assets/{goals-page-CPmhjsG-.js → goals-page-BG7FuqK1.js} +1 -1
- package/dist/assets/{habits-page-DkW8zT6_.js → habits-page-CGdaOqL3.js} +1 -1
- package/dist/assets/{index-BhkubYaC.js → index-BP9__l6C.js} +2 -2
- package/dist/assets/{insight-flow-dialog-BvgRjkPi.js → insight-flow-dialog-BUv06Vn-.js} +1 -1
- package/dist/assets/{insights-page-Dtij6pm5.js → insights-page-BgD1_1we.js} +1 -1
- package/dist/assets/{kanban-page-R1x5hUU-.js → kanban-page-DvZSN-Bi.js} +1 -1
- package/dist/assets/{knowledge-graph-page-BRBB5Vvz.js → knowledge-graph-page-BXWXtPvo.js} +1 -1
- package/dist/assets/{life-force-page-DGPWKM9I.js → life-force-page-CwjHvpzu.js} +1 -1
- package/dist/assets/{life-force-workspace-DoRIQoU_.js → life-force-workspace-Ct70SsNQ.js} +1 -1
- package/dist/assets/{metric-tile-NJiFcFxW.js → metric-tile-DCxLxNli.js} +1 -1
- package/dist/assets/{movement-page-Dk8aV737.js → movement-page-C06ebiYk.js} +1 -1
- package/dist/assets/{note-markdown-CZHjJDve.js → note-markdown-3wB52NOn.js} +1 -1
- package/dist/assets/{note-tags-input-DFpxZHPg.js → note-tags-input-Blg5Gqz_.js} +1 -1
- package/dist/assets/{notes-page-r3kymlqg.js → notes-page-CSkjizyK.js} +1 -1
- package/dist/assets/{open-in-graph-button-B_XHtHZD.js → open-in-graph-button-CDHxzS8B.js} +1 -1
- package/dist/assets/{orbit-map-C_xy4kYC.js → orbit-map-OV-GcUZl.js} +1 -1
- package/dist/assets/{overview-page-Dwg4uYe9.js → overview-page-Cw3pI34n.js} +1 -1
- package/dist/assets/{page-hero-DzEsy8i5.js → page-hero-DgnhI5es.js} +1 -1
- package/dist/assets/{pill-cluster-DcBUeEMT.js → pill-cluster-DIGkIvKN.js} +1 -1
- package/dist/assets/{preference-entity-handoff-button-BX2n07ob.js → preference-entity-handoff-button-LT_GBuqB.js} +1 -1
- package/dist/assets/{preferences-page-BSnwiWBt.js → preferences-page-Dkvz7nkU.js} +1 -1
- package/dist/assets/{project-collections-BR6YdlCZ.js → project-collections-BsAT8WYE.js} +1 -1
- package/dist/assets/{project-detail-page-DeYshcCb.js → project-detail-page-DsJUWg8k.js} +1 -1
- package/dist/assets/{project-management-hierarchy-page-Bhdt79Ea.js → project-management-hierarchy-page-CIy0wAp8.js} +1 -1
- package/dist/assets/{project-management-section-nav-DnXuWUfe.js → project-management-section-nav-ClB2S1FW.js} +1 -1
- package/dist/assets/{projects-page-BA9W0ZPk.js → projects-page-Da1bZLSH.js} +1 -1
- package/dist/assets/{psyche-behaviors-page-DpTj53GI.js → psyche-behaviors-page-D0uwf78o.js} +1 -1
- package/dist/assets/{psyche-flashcards-page-CV58hAJA.js → psyche-flashcards-page-e_qwwsOf.js} +1 -1
- package/dist/assets/{psyche-goal-map-page-C07CALFg.js → psyche-goal-map-page-BIY028Wx.js} +1 -1
- package/dist/assets/{psyche-graph-CP7mxfMP.js → psyche-graph-Y1UKALEm.js} +1 -1
- package/dist/assets/{psyche-metrics-page-CY8e9R0D.js → psyche-metrics-page-DDkGJzo_.js} +1 -1
- package/dist/assets/{psyche-mode-guide-page-DYt6AmHl.js → psyche-mode-guide-page-C7mD9uiv.js} +1 -1
- package/dist/assets/{psyche-modes-page-Dd77kTtJ.js → psyche-modes-page-RUdaOQWr.js} +1 -1
- package/dist/assets/{psyche-page-DNXZjIKp.js → psyche-page-D3FZy__c.js} +1 -1
- package/dist/assets/{psyche-patterns-page-DxGzpeT5.js → psyche-patterns-page-BSD35F41.js} +1 -1
- package/dist/assets/{psyche-questionnaire-builder-page-5EQctRHO.js → psyche-questionnaire-builder-page-BpgUTMgj.js} +1 -1
- package/dist/assets/{psyche-questionnaire-detail-page-W8nhUGAc.js → psyche-questionnaire-detail-page-DwjyjNhg.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-detail-page-DVwzSuqg.js → psyche-questionnaire-run-detail-page-mJ-DgeB-.js} +1 -1
- package/dist/assets/{psyche-questionnaire-run-page-BHResQgL.js → psyche-questionnaire-run-page-YuMBkH1G.js} +1 -1
- package/dist/assets/{psyche-questionnaires-page-DFTOXpyp.js → psyche-questionnaires-page-CNglToKh.js} +1 -1
- package/dist/assets/{psyche-report-detail-page-BqDE_tf7.js → psyche-report-detail-page-CV6tbLxz.js} +1 -1
- package/dist/assets/{psyche-reports-page-B75pDz0l.js → psyche-reports-page-BEOe8OPA.js} +1 -1
- package/dist/assets/{psyche-schemas-beliefs-page-BjSO4tYL.js → psyche-schemas-beliefs-page-KIRqmO8C.js} +1 -1
- package/dist/assets/{psyche-screen-time-page-B7lKf1g7.js → psyche-screen-time-page-DvXuwgU1.js} +1 -1
- package/dist/assets/{psyche-self-observation-page-C6RMThwc.js → psyche-self-observation-page-E6yDPBm1.js} +1 -1
- package/dist/assets/{psyche-values-page-1O158mIJ.js → psyche-values-page-CSLG7C6a.js} +1 -1
- package/dist/assets/{report-chain-fields-CyJ_VFY5.js → report-chain-fields-BYEp3tRr.js} +1 -1
- package/dist/assets/{rewards-page-sPlDYuVo.js → rewards-page-pAa_MIte.js} +1 -1
- package/dist/assets/{scheduling-rules-editor-DGgcBs1W.js → scheduling-rules-editor-BmGrjC9q.js} +1 -1
- package/dist/assets/{schema-badge-Do-YvNHm.js → schema-badge-IVJ4SoeC.js} +1 -1
- package/dist/assets/{select-menu-CAM7rMdO.js → select-menu-BE5AIdgO.js} +1 -1
- package/dist/assets/{settings-agents-page-BsZY71kz.js → settings-agents-page-hqI0IaNx.js} +1 -1
- package/dist/assets/{settings-bin-page-kB3jtHo_.js → settings-bin-page-2bPjFtZ3.js} +1 -1
- package/dist/assets/{settings-calendar-page-C-IGNk3_.js → settings-calendar-page-u_TfZJEh.js} +1 -1
- package/dist/assets/{settings-data-page-CFGSL9g3.js → settings-data-page-DSQ14F2i.js} +1 -1
- package/dist/assets/{settings-logs-page-C7e9FIN_.js → settings-logs-page-BU0CJhDM.js} +1 -1
- package/dist/assets/{settings-mobile-page-DzKeZQDM.js → settings-mobile-page-B1fQ61BB.js} +1 -1
- package/dist/assets/{settings-models-page-dFhaOV3E.js → settings-models-page-B0Dis_c_.js} +1 -1
- package/dist/assets/{settings-page-C0fSyYUx.js → settings-page-V4ibXIp9.js} +1 -1
- package/dist/assets/{settings-rewards-page-D-LuZHhv.js → settings-rewards-page-DeCGBNn5.js} +1 -1
- package/dist/assets/{settings-section-nav-kFFQSJEe.js → settings-section-nav-DV5umEkp.js} +1 -1
- package/dist/assets/{settings-users-page-CX797HPB.js → settings-users-page-BB8Dzd_P.js} +1 -1
- package/dist/assets/{settings-wiki-page-CWLAvcsf.js → settings-wiki-page-B0k0KRsU.js} +1 -1
- package/dist/assets/{sleep-page-QgBkKyk_.js → sleep-page-CPwUb-em.js} +1 -1
- package/dist/assets/{sports-page-C8tLMl7V.js → sports-page-Cl4vZVwh.js} +1 -1
- package/dist/assets/{strategies-page-CGgh-KXu.js → strategies-page-DhFXf-g3.js} +1 -1
- package/dist/assets/{strategy-detail-page-CnzqjjoD.js → strategy-detail-page-B2gotRKI.js} +1 -1
- package/dist/assets/{strategy-dialog-C6AThZ9L.js → strategy-dialog-DD1bbrRB.js} +1 -1
- package/dist/assets/{surface-CIDhCEsF.js → surface-98myBzix.js} +1 -1
- package/dist/assets/{task-detail-page-Dp0r_qZP.js → task-detail-page-nx4eQbMW.js} +1 -1
- package/dist/assets/{timebox-planning-dialog-B3uaSsWI.js → timebox-planning-dialog-DoZ9zUra.js} +1 -1
- package/dist/assets/{today-page-CTnMYrPi.js → today-page-7BH7Yne1.js} +1 -1
- package/dist/assets/{training-load-page-D0WB5_Tq.js → training-load-page-E82pNn1-.js} +1 -1
- package/dist/assets/{vitals-page-0vg8nqwj.js → vitals-page-D64WlwVv.js} +1 -1
- package/dist/assets/{weekly-review-page-CSSKlkbH.js → weekly-review-page-BkRxxm7Q.js} +1 -1
- package/dist/assets/weight-loss-page-DPbg7rTC.js +5 -0
- package/dist/assets/{wiki-article-markdown-CBFvfJx_.js → wiki-article-markdown-B0Q6082A.js} +1 -1
- package/dist/assets/{wiki-editor-page-CL1uxpih.js → wiki-editor-page-Tkb50wEA.js} +1 -1
- package/dist/assets/{wiki-ingest-history-page-XX8DeNCC.js → wiki-ingest-history-page-CcQzkZRr.js} +1 -1
- package/dist/assets/{wiki-ingest-modal-j-ftDmzp.js → wiki-ingest-modal-D6yft0Qb.js} +1 -1
- package/dist/assets/{wiki-page-B46TQYpy.js → wiki-page-DEND1jmD.js} +1 -1
- package/dist/assets/{workbench-flow-page-CicEuBKq.js → workbench-flow-page-CkNI03j_.js} +1 -1
- package/dist/assets/{workbench-page-tXezYLh_.js → workbench-page-W3zQpeWr.js} +1 -1
- package/dist/assets/{workout-detail-page-BTO5X0Of.js → workout-detail-page-BVSZv53z.js} +1 -1
- package/dist/index.html +1 -1
- package/dist/server/server/src/app.js +2 -0
- package/dist/server/server/src/health-weight-loss.js +160 -10
- package/dist/server/src/lib/weight-loss-energy-model.js +64 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/skills/forge-openclaw/SKILL.md +10 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +33 -0
- package/skills/forge-openclaw/psyche_entity_playbooks.md +31 -0
- package/dist/assets/weight-loss-page-Dcr4wjjy.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b5 as Ce,cc as Se,c2 as Ee,r as c,j as e,b3 as Pe,cx as ae,aG as ie,cG as We,cL as Re,c7 as Ke,b4 as Le,aC as le,aK as ce,bl as $e}from"./vendor-Dnkkx2co.js";import{R as de,P as ue,O as pe,C as me,T as xe,a as ge,D as ze}from"./ui-C1iwpj2-.js";import{j as qe,i as R,k as Ue}from"./state-vCcAT5Hq.js";import{u as Fe,a9 as Te,bq as De,f6 as Oe,L as O,E as ne,a as Be,b as oe,a8 as Me,B as U,Z as N,cL as Qe,I as Je,c as _e,bY as Ae,f7 as He,f8 as Ge,f9 as Ye,fa as Ve}from"./index-BhkubYaC.js";import{O as Xe}from"./open-in-graph-button-B_XHtHZD.js";import{W as Ze}from"./wiki-article-markdown-CBFvfJx_.js";import{W as es}from"./wiki-ingest-modal-j-ftDmzp.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function ss(m){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(new Date(m))}function ts(m){return m.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function he({nodes:m,activeSlug:o,spaceId:p,depth:i=0}){return e.jsx("ul",{className:N("grid gap-1",i>0&&"mt-1"),children:m.map(n=>{const h=n.page.slug===o;return e.jsxs("li",{className:"grid gap-1",children:[e.jsx(le,{to:{pathname:n.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(n.page.slug)}`,search:`?spaceId=${encodeURIComponent(p)}`},className:N("rounded-lg px-2 py-1.5 text-[12px] leading-5 transition",h?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]"),style:{paddingLeft:`${.5+i*.7}rem`},children:n.page.title}),n.children.length>0?e.jsx(he,{nodes:n.children,activeSlug:o,spaceId:p,depth:i+1}):null]},n.page.id)})})}function rs({open:m,onOpenChange:o,spaces:p,activeSpaceId:i,onSelect:n}){var I;const h=((I=p.find(d=>d.visibility==="shared"))==null?void 0:I.id)??"";return e.jsx(de,{open:m,onOpenChange:o,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Choose KarpaWiki space"}),e.jsx(ze,{className:"mt-1 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:"Switch the reading space without leaving the article surface."})]}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close space picker",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:p.map(d=>{const K=d.id===i,L=d.id===h;return e.jsxs("button",{type:"button",className:N("flex items-center justify-between gap-3 rounded-[22px] border px-4 py-3 text-left transition",K?"border-[color-mix(in_srgb,var(--primary)_26%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>{n(d.id),o(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-inherit",children:d.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:d.description||`/${d.slug}`}),L?e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-200/90 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-stone-950",children:"Recovered pages"}):null]}),K?e.jsx($e,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},d.id)})})]})]})})}function gs(){var A,H,G,Y,V,X,Z,ee,se,te;const m=Fe(),o=Ce(),p=qe(),{slug:i}=Se(),[n,h]=Ee(),[I,d]=c.useState(!1),[K,L]=c.useState(!1),[F,C]=c.useState(!1),[f,fe]=c.useState("hybrid"),[S,be]=c.useState(""),[E,B]=c.useState(""),M=c.useRef(null),T=n.get("spaceId")??"",ve=n.get("ingest")==="1",Q=n.get("ingestJobId"),l=R({queryKey:["forge-wiki-settings"],queryFn:Ae}),t=T||((H=(A=l.data)==null?void 0:A.settings.spaces[0])==null?void 0:H.id)||"",P=((G=l.data)==null?void 0:G.settings.embeddingProfiles.filter(s=>s.enabled))??[];c.useEffect(()=>{var s;!E&&((s=P[0])!=null&&s.id)&&B(P[0].id)},[P,E]),c.useEffect(()=>{var s,a;if(!T&&((a=(s=l.data)==null?void 0:s.settings.spaces[0])!=null&&a.id)){const x=new URLSearchParams(n);x.set("spaceId",l.data.settings.spaces[0].id),h(x,{replace:!0})}},[n,T,h,l.data]);const y=R({queryKey:["forge-wiki-home",t],queryFn:()=>He({spaceId:t||void 0}),enabled:!!t&&!i}),g=R({queryKey:["forge-wiki-page-by-slug",t,i],queryFn:()=>Ge({slug:i??"index",spaceId:t||void 0}),enabled:!!t&&!!i}),W=R({queryKey:["forge-wiki-tree",t],queryFn:()=>Ye({spaceId:t||void 0,kind:"wiki"}),enabled:!!t}),j=R({queryKey:["forge-wiki-modal-search",t,f,S,E],queryFn:()=>Ve({spaceId:t||void 0,mode:f,query:S.trim(),profileId:(f==="semantic"||f==="hybrid")&&E||void 0,limit:30}),enabled:I&&!!t&&S.trim().length>0}),$=i?g.data??null:y.data??null,[ke,ye]=c.useState(null);c.useEffect(()=>{$&&ye($)},[$]);const z=!!t&&(i?g.isFetching:y.isFetching),b=$??(z?ke:null),r=(b==null?void 0:b.page)??null,u=((Y=l.data)==null?void 0:Y.settings.spaces.find(s=>s.id===t))??null,v=((V=l.data)==null?void 0:V.settings.spaces.find(s=>s.visibility==="shared"))??null,je=!!v&&!!u&&(u==null?void 0:u.id)!==(v==null?void 0:v.id)&&(u==null?void 0:u.visibility)==="personal",q=(r==null?void 0:r.slug)!=="index",k=i&&g.error instanceof Te&&g.error.status===404?i.trim():null;c.useEffect(()=>{if(!t||!k)return;const s=new URLSearchParams;s.set("spaceId",t),s.set("title",k);const a=ts(k);a&&s.set("slug",a),o(`/wiki/new?${s.toString()}`,{replace:!0})},[t,k,o]);const J=c.useMemo(()=>((r==null?void 0:r.links)??[]).map(s=>({id:`${s.entityType}:${s.entityId}`,href:De(s.entityType,s.entityId),label:`${s.entityType} · ${s.entityId}`})),[r==null?void 0:r.links]),w=Ue({mutationFn:async s=>Oe(s),onSuccess:async()=>{await Promise.all([p.invalidateQueries({queryKey:["forge-wiki-tree"]}),p.invalidateQueries({queryKey:["forge-wiki-home"]}),p.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),p.invalidateQueries({queryKey:["forge-wiki-modal-search"]})]),o(`/wiki${t?`?spaceId=${encodeURIComponent(t)}`:""}`)}}),D=(s,a=!1)=>{const x=new URLSearchParams(n);s(x),h(x,{replace:a})},_=s=>{D(a=>{a.set("ingest","1"),s?a.set("ingestJobId",s):a.delete("ingestJobId"),t&&a.set("spaceId",t)})},we=()=>{D(s=>{s.delete("ingest"),s.delete("ingestJobId")})},Ne=s=>{D(a=>{a.set("ingest","1"),s?a.set("ingestJobId",s):a.delete("ingestJobId"),t&&a.set("spaceId",t)})},Ie=()=>{!r||!q||w.isPending||!window.confirm(`Delete KarpaWiki page "${r.title}"? You can restore it later from the bin.`)||w.mutateAsync(r.id)};return c.useEffect(()=>{if(!F)return;const s=x=>{var re;(re=M.current)!=null&&re.contains(x.target)||C(!1)},a=x=>{x.key==="Escape"&&C(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",a)}},[F]),!r&&(l.isLoading||W.isLoading||!i&&y.isLoading||i&&g.isLoading)?e.jsx(O,{eyebrow:"KarpaWiki",title:"Loading the article",description:"Preparing the current space, article, and KarpaWiki index."}):!r&&!k&&(l.isError||y.isError||g.isError||W.isError)?e.jsx(ne,{eyebrow:"KarpaWiki",error:l.error??y.error??g.error??W.error,onRetry:()=>{l.refetch(),y.refetch(),g.refetch(),W.refetch()}}):r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1680px] flex-col gap-4",children:[e.jsxs("section",{className:"wiki-frame px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{kind:"wiki_page",label:"KarpaWiki page",compact:!0,gradient:!1}),u?e.jsx(oe,{kind:"wiki_space",label:u.label,compact:!0,gradient:!1,wrap:!0,className:"max-w-[20rem]"}):null,e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:ss(r.updatedAt)}),e.jsx(Me,{metrics:m.snapshot.metrics,className:"ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row lg:items-center",children:[e.jsxs("button",{type:"button",className:"wiki-search-launch flex min-h-[2.9rem] w-full items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-left text-[14px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] lg:flex-1",onClick:()=>d(!0),children:[e.jsx(Pe,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"}),e.jsx("span",{children:"Search KarpaWiki"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:shrink-0",children:[e.jsxs("button",{type:"button",className:"wiki-space-trigger inline-flex min-h-[2.9rem] items-center gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-[13px] font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",onClick:()=>L(!0),children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:(u==null?void 0:u.label)??"KarpaWiki space"}),e.jsx(ae,{className:"size-3.5 text-[var(--ui-ink-faint)]"})]}),e.jsxs("div",{className:"relative",ref:M,children:[e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>C(s=>!s),children:[e.jsx(ie,{className:"size-3.5"}),"Ingest",e.jsx(ae,{className:"size-3.5"})]}),F?e.jsxs("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-20 grid min-w-[15rem] gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{C(!1),_()},children:[e.jsx(ie,{className:"mt-0.5 size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"New ingest"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Start a fresh import from files, URLs, or pasted text."})]})]}),e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{C(!1),o(`/wiki/ingest-history${t?`?spaceId=${encodeURIComponent(t)}`:""}`)},children:[e.jsx(We,{className:"mt-0.5 size-4 shrink-0 text-[var(--secondary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"History"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Browse prior ingests, reopen reviews, and delete old ingest records."})]})]})]}):null]}),e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/edit/${encodeURIComponent(r.id)}?spaceId=${encodeURIComponent(t)}`,{state:{initialPage:r}}),children:[e.jsx(Re,{className:"size-3.5"}),"Edit"]}),e.jsx(Xe,{entityType:"note",entityId:r.id,label:"Open in graph",size:"sm"}),e.jsxs(U,{variant:"secondary",size:"sm",className:N("min-h-[2.9rem] border border-rose-400/18 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18",!q&&"opacity-60"),onClick:Ie,pending:w.isPending,pendingLabel:"Deleting",disabled:!q,title:q?"Delete this KarpaWiki page":"The KarpaWiki home page cannot be deleted",children:[e.jsx(Ke,{className:"size-3.5"}),"Delete"]}),e.jsxs(U,{size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/new?spaceId=${encodeURIComponent(t)}`),children:[e.jsx(Le,{className:"size-3.5"}),"New page"]})]})]}),je&&v?e.jsxs("div",{className:"mt-3 flex flex-col gap-3 rounded-[22px] border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3 text-[13px] leading-6 text-amber-50 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["You are viewing the personal starter wiki. The recovered people, story, and conversation pages are in"," ",e.jsx("strong",{children:v.label}),"."]}),e.jsx("button",{type:"button",className:"inline-flex min-h-10 shrink-0 items-center justify-center rounded-2xl bg-amber-200 px-4 text-[12px] font-semibold uppercase tracking-[0.14em] text-stone-950 transition hover:bg-amber-100",onClick:()=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(v.id)}`})},children:"Open shared memory"})]}):null]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[16rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"wiki-frame h-fit px-2 py-3 sm:px-3 lg:sticky lg:top-[5.75rem]",children:[e.jsx("div",{className:"px-2 pb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Index"}),e.jsx(he,{nodes:((X=W.data)==null?void 0:X.tree)??[],activeSlug:r.slug,spaceId:t})]}),e.jsxs("article",{"aria-busy":z,className:N("wiki-frame relative overflow-hidden px-4 py-5 transition-[opacity,transform] duration-200 sm:px-6 sm:py-6",z&&"opacity-[0.985]"),children:[z?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[color-mix(in_srgb,var(--primary)_70%,transparent)] opacity-90"}):null,e.jsxs("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:[w.isError?e.jsx("div",{className:"mb-4 rounded-[18px] border border-rose-400/20 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:w.error instanceof Error?w.error.message:"Forge could not delete this KarpaWiki page."}):null,e.jsx(Ze,{markdown:r.contentMarkdown,spaceId:t}),r.summary.trim()?e.jsx("p",{className:"mt-5 border-t border-[var(--ui-border-subtle)] pt-4 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:r.summary}):null,J.length>0?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Forge links"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:J.map(s=>e.jsx("a",{href:s.href?Qe(s.href):void 0,className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",children:s.label},s.id))})]}):null,b!=null&&b.backlinkSourceNotes.length?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked here"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:b.backlinkSourceNotes.map(s=>e.jsxs(le,{to:{pathname:s.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.slug)}`,search:`?spaceId=${encodeURIComponent(s.spaceId)}`},className:"rounded-xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"text-[13px] font-semibold text-[var(--ui-ink-strong)]",children:s.title}),s.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.summary}):null]},s.id))})]}):null]})]})]})]})}),e.jsx(de,{open:I,onOpenChange:d,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(54rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{children:e.jsx(xe,{className:"font-display text-[1.35rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Search the wiki"})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close search",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(Je,{autoFocus:!0,value:S,onChange:s=>be(s.target.value),placeholder:"Search KarpaWiki pages",className:"h-11 rounded-2xl border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[14px] text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)]"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["text","hybrid","semantic","entity"].map(s=>e.jsx("button",{type:"button",className:N("rounded-full px-3 py-1.5 text-[12px] font-medium uppercase tracking-[0.14em] transition",f===s?"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>fe(s),children:s},s)),(f==="semantic"||f==="hybrid")&&P.length>0?e.jsx("select",{className:"ml-auto rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-strong)]",value:E,onChange:s=>B(s.target.value),children:P.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))}):null]})]}),e.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto",children:S.trim()?j.isLoading?e.jsx(O,{eyebrow:"KarpaWiki search",title:"Searching",description:"Ranking matching pages for this query."}):j.isError?e.jsx(ne,{eyebrow:"KarpaWiki search",error:j.error,onRetry:()=>void j.refetch()}):(Z=j.data)!=null&&Z.results.length?e.jsx("div",{className:"grid gap-2",children:j.data.results.map(s=>e.jsx("button",{type:"button",className:"rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{d(!1),o({pathname:s.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.page.slug)}`,search:`?spaceId=${encodeURIComponent(s.page.spaceId)}`})},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-[var(--ui-ink-strong)]",children:s.page.title}),s.page.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.page.summary}):null]}),e.jsx(_e,{size:"sm",tone:"meta",children:s.score.toFixed(2)})]})},s.page.id))}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"No pages matched this search."}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"Start typing to search the current KarpaWiki space."})})]})]})}),e.jsx(rs,{open:K,onOpenChange:L,spaces:((ee=l.data)==null?void 0:ee.settings.spaces)??[],activeSpaceId:t,onSelect:s=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(s)}`},{replace:!0})}}),e.jsx(es,{open:ve,onOpenChange:s=>{if(s){_(Q);return}we()},spaces:((se=l.data)==null?void 0:se.settings.spaces)??[],llmProfiles:((te=l.data)==null?void 0:te.settings.llmProfiles)??[],initialSpaceId:t,selectedJobId:Q,onJobSelected:Ne,linkedEntityHints:r.links.map(s=>({entityType:s.entityType,entityId:s.entityId,anchorKey:null}))??[]})]}):k?e.jsx(O,{eyebrow:"KarpaWiki",title:"Opening a new page",description:`Creating a draft for ${k}.`}):e.jsx(Be,{eyebrow:"KarpaWiki",title:"Article not found",description:"This page does not exist in the selected space."})}export{gs as WikiPage};
|
|
1
|
+
import{b5 as Ce,cc as Se,c2 as Ee,r as c,j as e,b3 as Pe,cx as ae,aG as ie,cG as We,cL as Re,c7 as Ke,b4 as Le,aC as le,aK as ce,bl as $e}from"./vendor-Dnkkx2co.js";import{R as de,P as ue,O as pe,C as me,T as xe,a as ge,D as ze}from"./ui-C1iwpj2-.js";import{j as qe,i as R,k as Ue}from"./state-vCcAT5Hq.js";import{u as Fe,a9 as Te,bq as De,f6 as Oe,L as O,E as ne,a as Be,b as oe,a8 as Me,B as U,Z as N,cL as Qe,I as Je,c as _e,bY as Ae,f7 as He,f8 as Ge,f9 as Ye,fa as Ve}from"./index-BP9__l6C.js";import{O as Xe}from"./open-in-graph-button-CDHxzS8B.js";import{W as Ze}from"./wiki-article-markdown-B0Q6082A.js";import{W as es}from"./wiki-ingest-modal-D6yft0Qb.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function ss(m){return new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",year:"numeric"}).format(new Date(m))}function ts(m){return m.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function he({nodes:m,activeSlug:o,spaceId:p,depth:i=0}){return e.jsx("ul",{className:N("grid gap-1",i>0&&"mt-1"),children:m.map(n=>{const h=n.page.slug===o;return e.jsxs("li",{className:"grid gap-1",children:[e.jsx(le,{to:{pathname:n.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(n.page.slug)}`,search:`?spaceId=${encodeURIComponent(p)}`},className:N("rounded-lg px-2 py-1.5 text-[12px] leading-5 transition",h?"bg-[var(--ui-surface-2)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-1)] hover:text-[var(--ui-ink-strong)]"),style:{paddingLeft:`${.5+i*.7}rem`},children:n.page.title}),n.children.length>0?e.jsx(he,{nodes:n.children,activeSlug:o,spaceId:p,depth:i+1}):null]},n.page.id)})})}function rs({open:m,onOpenChange:o,spaces:p,activeSpaceId:i,onSelect:n}){var I;const h=((I=p.find(d=>d.visibility==="shared"))==null?void 0:I.id)??"";return e.jsx(de,{open:m,onOpenChange:o,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[14vh] z-50 w-[min(28rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx(xe,{className:"font-display text-[1.2rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Choose KarpaWiki space"}),e.jsx(ze,{className:"mt-1 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:"Switch the reading space without leaving the article surface."})]}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close space picker",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsx("div",{className:"mt-4 grid gap-2",children:p.map(d=>{const K=d.id===i,L=d.id===h;return e.jsxs("button",{type:"button",className:N("flex items-center justify-between gap-3 rounded-[22px] border px-4 py-3 text-left transition",K?"border-[color-mix(in_srgb,var(--primary)_26%,transparent)] bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[var(--ui-ink-medium)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>{n(d.id),o(!1)},children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-[14px] font-semibold text-inherit",children:d.label}),e.jsx("span",{className:"mt-1 block text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:d.description||`/${d.slug}`}),L?e.jsx("span",{className:"mt-2 inline-flex rounded-full bg-amber-200/90 px-2 py-0.5 text-[10px] font-semibold uppercase tracking-[0.14em] text-stone-950",children:"Recovered pages"}):null]}),K?e.jsx($e,{className:"size-4 shrink-0 text-[var(--primary)]"}):null]},d.id)})})]})]})})}function gs(){var A,H,G,Y,V,X,Z,ee,se,te;const m=Fe(),o=Ce(),p=qe(),{slug:i}=Se(),[n,h]=Ee(),[I,d]=c.useState(!1),[K,L]=c.useState(!1),[F,C]=c.useState(!1),[f,fe]=c.useState("hybrid"),[S,be]=c.useState(""),[E,B]=c.useState(""),M=c.useRef(null),T=n.get("spaceId")??"",ve=n.get("ingest")==="1",Q=n.get("ingestJobId"),l=R({queryKey:["forge-wiki-settings"],queryFn:Ae}),t=T||((H=(A=l.data)==null?void 0:A.settings.spaces[0])==null?void 0:H.id)||"",P=((G=l.data)==null?void 0:G.settings.embeddingProfiles.filter(s=>s.enabled))??[];c.useEffect(()=>{var s;!E&&((s=P[0])!=null&&s.id)&&B(P[0].id)},[P,E]),c.useEffect(()=>{var s,a;if(!T&&((a=(s=l.data)==null?void 0:s.settings.spaces[0])!=null&&a.id)){const x=new URLSearchParams(n);x.set("spaceId",l.data.settings.spaces[0].id),h(x,{replace:!0})}},[n,T,h,l.data]);const y=R({queryKey:["forge-wiki-home",t],queryFn:()=>He({spaceId:t||void 0}),enabled:!!t&&!i}),g=R({queryKey:["forge-wiki-page-by-slug",t,i],queryFn:()=>Ge({slug:i??"index",spaceId:t||void 0}),enabled:!!t&&!!i}),W=R({queryKey:["forge-wiki-tree",t],queryFn:()=>Ye({spaceId:t||void 0,kind:"wiki"}),enabled:!!t}),j=R({queryKey:["forge-wiki-modal-search",t,f,S,E],queryFn:()=>Ve({spaceId:t||void 0,mode:f,query:S.trim(),profileId:(f==="semantic"||f==="hybrid")&&E||void 0,limit:30}),enabled:I&&!!t&&S.trim().length>0}),$=i?g.data??null:y.data??null,[ke,ye]=c.useState(null);c.useEffect(()=>{$&&ye($)},[$]);const z=!!t&&(i?g.isFetching:y.isFetching),b=$??(z?ke:null),r=(b==null?void 0:b.page)??null,u=((Y=l.data)==null?void 0:Y.settings.spaces.find(s=>s.id===t))??null,v=((V=l.data)==null?void 0:V.settings.spaces.find(s=>s.visibility==="shared"))??null,je=!!v&&!!u&&(u==null?void 0:u.id)!==(v==null?void 0:v.id)&&(u==null?void 0:u.visibility)==="personal",q=(r==null?void 0:r.slug)!=="index",k=i&&g.error instanceof Te&&g.error.status===404?i.trim():null;c.useEffect(()=>{if(!t||!k)return;const s=new URLSearchParams;s.set("spaceId",t),s.set("title",k);const a=ts(k);a&&s.set("slug",a),o(`/wiki/new?${s.toString()}`,{replace:!0})},[t,k,o]);const J=c.useMemo(()=>((r==null?void 0:r.links)??[]).map(s=>({id:`${s.entityType}:${s.entityId}`,href:De(s.entityType,s.entityId),label:`${s.entityType} · ${s.entityId}`})),[r==null?void 0:r.links]),w=Ue({mutationFn:async s=>Oe(s),onSuccess:async()=>{await Promise.all([p.invalidateQueries({queryKey:["forge-wiki-tree"]}),p.invalidateQueries({queryKey:["forge-wiki-home"]}),p.invalidateQueries({queryKey:["forge-wiki-page-by-slug"]}),p.invalidateQueries({queryKey:["forge-wiki-modal-search"]})]),o(`/wiki${t?`?spaceId=${encodeURIComponent(t)}`:""}`)}}),D=(s,a=!1)=>{const x=new URLSearchParams(n);s(x),h(x,{replace:a})},_=s=>{D(a=>{a.set("ingest","1"),s?a.set("ingestJobId",s):a.delete("ingestJobId"),t&&a.set("spaceId",t)})},we=()=>{D(s=>{s.delete("ingest"),s.delete("ingestJobId")})},Ne=s=>{D(a=>{a.set("ingest","1"),s?a.set("ingestJobId",s):a.delete("ingestJobId"),t&&a.set("spaceId",t)})},Ie=()=>{!r||!q||w.isPending||!window.confirm(`Delete KarpaWiki page "${r.title}"? You can restore it later from the bin.`)||w.mutateAsync(r.id)};return c.useEffect(()=>{if(!F)return;const s=x=>{var re;(re=M.current)!=null&&re.contains(x.target)||C(!1)},a=x=>{x.key==="Escape"&&C(!1)};return document.addEventListener("pointerdown",s),document.addEventListener("keydown",a),()=>{document.removeEventListener("pointerdown",s),document.removeEventListener("keydown",a)}},[F]),!r&&(l.isLoading||W.isLoading||!i&&y.isLoading||i&&g.isLoading)?e.jsx(O,{eyebrow:"KarpaWiki",title:"Loading the article",description:"Preparing the current space, article, and KarpaWiki index."}):!r&&!k&&(l.isError||y.isError||g.isError||W.isError)?e.jsx(ne,{eyebrow:"KarpaWiki",error:l.error??y.error??g.error??W.error,onRetry:()=>{l.refetch(),y.refetch(),g.refetch(),W.refetch()}}):r?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 py-4 sm:px-5 lg:px-6",children:e.jsxs("div",{className:"mx-auto flex w-full max-w-[1680px] flex-col gap-4",children:[e.jsxs("section",{className:"wiki-frame px-3 py-3 sm:px-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(oe,{kind:"wiki_page",label:"KarpaWiki page",compact:!0,gradient:!1}),u?e.jsx(oe,{kind:"wiki_space",label:u.label,compact:!0,gradient:!1,wrap:!0,className:"max-w-[20rem]"}):null,e.jsx("span",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:ss(r.updatedAt)}),e.jsx(Me,{metrics:m.snapshot.metrics,className:"ml-auto"})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-2 lg:flex-row lg:items-center",children:[e.jsxs("button",{type:"button",className:"wiki-search-launch flex min-h-[2.9rem] w-full items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-left text-[14px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)] lg:flex-1",onClick:()=>d(!0),children:[e.jsx(Pe,{className:"size-4 shrink-0 text-[var(--ui-ink-faint)]"}),e.jsx("span",{children:"Search KarpaWiki"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 lg:shrink-0",children:[e.jsxs("button",{type:"button",className:"wiki-space-trigger inline-flex min-h-[2.9rem] items-center gap-2 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 text-[13px] font-medium text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]",onClick:()=>L(!0),children:[e.jsx("span",{className:"text-[11px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]",children:"Space"}),e.jsx("span",{className:"max-w-[16rem] truncate",children:(u==null?void 0:u.label)??"KarpaWiki space"}),e.jsx(ae,{className:"size-3.5 text-[var(--ui-ink-faint)]"})]}),e.jsxs("div",{className:"relative",ref:M,children:[e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>C(s=>!s),children:[e.jsx(ie,{className:"size-3.5"}),"Ingest",e.jsx(ae,{className:"size-3.5"})]}),F?e.jsxs("div",{className:"absolute right-0 top-[calc(100%+0.5rem)] z-20 grid min-w-[15rem] gap-2 rounded-[22px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-2 shadow-[var(--ui-shadow-floating)]",children:[e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{C(!1),_()},children:[e.jsx(ie,{className:"mt-0.5 size-4 shrink-0 text-[var(--primary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"New ingest"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Start a fresh import from files, URLs, or pasted text."})]})]}),e.jsxs("button",{type:"button",className:"flex items-start gap-3 rounded-[18px] px-3 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{C(!1),o(`/wiki/ingest-history${t?`?spaceId=${encodeURIComponent(t)}`:""}`)},children:[e.jsx(We,{className:"mt-0.5 size-4 shrink-0 text-[var(--secondary)]"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-sm font-medium text-[var(--ui-ink-strong)]",children:"History"}),e.jsx("span",{className:"mt-1 block text-xs leading-5 text-[var(--ui-ink-faint)]",children:"Browse prior ingests, reopen reviews, and delete old ingest records."})]})]})]}):null]}),e.jsxs(U,{variant:"secondary",size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/edit/${encodeURIComponent(r.id)}?spaceId=${encodeURIComponent(t)}`,{state:{initialPage:r}}),children:[e.jsx(Re,{className:"size-3.5"}),"Edit"]}),e.jsx(Xe,{entityType:"note",entityId:r.id,label:"Open in graph",size:"sm"}),e.jsxs(U,{variant:"secondary",size:"sm",className:N("min-h-[2.9rem] border border-rose-400/18 bg-rose-500/10 text-rose-100 hover:bg-rose-500/18",!q&&"opacity-60"),onClick:Ie,pending:w.isPending,pendingLabel:"Deleting",disabled:!q,title:q?"Delete this KarpaWiki page":"The KarpaWiki home page cannot be deleted",children:[e.jsx(Ke,{className:"size-3.5"}),"Delete"]}),e.jsxs(U,{size:"sm",className:"min-h-[2.9rem]",onClick:()=>o(`/wiki/new?spaceId=${encodeURIComponent(t)}`),children:[e.jsx(Le,{className:"size-3.5"}),"New page"]})]})]}),je&&v?e.jsxs("div",{className:"mt-3 flex flex-col gap-3 rounded-[22px] border border-amber-300/20 bg-amber-300/[0.08] px-4 py-3 text-[13px] leading-6 text-amber-50 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{children:["You are viewing the personal starter wiki. The recovered people, story, and conversation pages are in"," ",e.jsx("strong",{children:v.label}),"."]}),e.jsx("button",{type:"button",className:"inline-flex min-h-10 shrink-0 items-center justify-center rounded-2xl bg-amber-200 px-4 text-[12px] font-semibold uppercase tracking-[0.14em] text-stone-950 transition hover:bg-amber-100",onClick:()=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(v.id)}`})},children:"Open shared memory"})]}):null]}),e.jsxs("section",{className:"grid gap-4 lg:grid-cols-[15rem_minmax(0,1fr)] xl:grid-cols-[16rem_minmax(0,1fr)]",children:[e.jsxs("aside",{className:"wiki-frame h-fit px-2 py-3 sm:px-3 lg:sticky lg:top-[5.75rem]",children:[e.jsx("div",{className:"px-2 pb-2 text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Index"}),e.jsx(he,{nodes:((X=W.data)==null?void 0:X.tree)??[],activeSlug:r.slug,spaceId:t})]}),e.jsxs("article",{"aria-busy":z,className:N("wiki-frame relative overflow-hidden px-4 py-5 transition-[opacity,transform] duration-200 sm:px-6 sm:py-6",z&&"opacity-[0.985]"),children:[z?e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-[color-mix(in_srgb,var(--primary)_70%,transparent)] opacity-90"}):null,e.jsxs("div",{className:"wiki-reading-copy wiki-reading-flow mx-auto max-w-[76rem]",children:[w.isError?e.jsx("div",{className:"mb-4 rounded-[18px] border border-rose-400/20 bg-rose-500/10 px-4 py-3 text-sm text-rose-100",children:w.error instanceof Error?w.error.message:"Forge could not delete this KarpaWiki page."}):null,e.jsx(Ze,{markdown:r.contentMarkdown,spaceId:t}),r.summary.trim()?e.jsx("p",{className:"mt-5 border-t border-[var(--ui-border-subtle)] pt-4 text-[13px] leading-6 text-[var(--ui-ink-soft)]",children:r.summary}):null,J.length>0?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Forge links"}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:J.map(s=>e.jsx("a",{href:s.href?Qe(s.href):void 0,className:"rounded-full bg-[var(--ui-surface-2)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-medium)] transition hover:bg-[var(--ui-surface-3)] hover:text-[var(--ui-ink-strong)]",children:s.label},s.id))})]}):null,b!=null&&b.backlinkSourceNotes.length?e.jsxs("section",{className:"mt-8 border-t border-[var(--ui-border-subtle)] pt-4",children:[e.jsx("div",{className:"text-[11px] font-semibold uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Linked here"}),e.jsx("div",{className:"mt-3 grid gap-2 sm:grid-cols-2",children:b.backlinkSourceNotes.map(s=>e.jsxs(le,{to:{pathname:s.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.slug)}`,search:`?spaceId=${encodeURIComponent(s.spaceId)}`},className:"rounded-xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 transition hover:bg-[var(--ui-surface-2)]",children:[e.jsx("div",{className:"text-[13px] font-semibold text-[var(--ui-ink-strong)]",children:s.title}),s.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.summary}):null]},s.id))})]}):null]})]})]})]})}),e.jsx(de,{open:I,onOpenChange:d,children:e.jsxs(ue,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 surface-overlay backdrop-blur-sm"}),e.jsxs(me,{className:"fixed left-1/2 top-[8vh] z-50 w-[min(54rem,calc(100vw-1.5rem))] -translate-x-1/2 rounded-[28px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-popover)] p-4 shadow-[var(--ui-shadow-floating)] sm:p-5",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("div",{children:e.jsx(xe,{className:"font-display text-[1.35rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:"Search the wiki"})}),e.jsx(ge,{asChild:!0,children:e.jsx("button",{type:"button",className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-2 text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]","aria-label":"Close search",children:e.jsx(ce,{className:"size-4"})})})]}),e.jsxs("div",{className:"mt-4 grid gap-3",children:[e.jsx(Je,{autoFocus:!0,value:S,onChange:s=>be(s.target.value),placeholder:"Search KarpaWiki pages",className:"h-11 rounded-2xl border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] text-[14px] text-[var(--ui-ink-strong)] placeholder:text-[var(--ui-ink-faint)]"}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[["text","hybrid","semantic","entity"].map(s=>e.jsx("button",{type:"button",className:N("rounded-full px-3 py-1.5 text-[12px] font-medium uppercase tracking-[0.14em] transition",f===s?"bg-[var(--ui-surface-3)] text-[var(--ui-ink-strong)]":"bg-[var(--ui-surface-1)] text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-2)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>fe(s),children:s},s)),(f==="semantic"||f==="hybrid")&&P.length>0?e.jsx("select",{className:"ml-auto rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-3 py-1.5 text-[12px] text-[var(--ui-ink-strong)]",value:E,onChange:s=>B(s.target.value),children:P.map(s=>e.jsx("option",{value:s.id,children:s.label},s.id))}):null]})]}),e.jsx("div",{className:"mt-4 max-h-[60vh] overflow-y-auto",children:S.trim()?j.isLoading?e.jsx(O,{eyebrow:"KarpaWiki search",title:"Searching",description:"Ranking matching pages for this query."}):j.isError?e.jsx(ne,{eyebrow:"KarpaWiki search",error:j.error,onRetry:()=>void j.refetch()}):(Z=j.data)!=null&&Z.results.length?e.jsx("div",{className:"grid gap-2",children:j.data.results.map(s=>e.jsx("button",{type:"button",className:"rounded-2xl border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] px-4 py-3 text-left transition hover:bg-[var(--ui-surface-2)]",onClick:()=>{d(!1),o({pathname:s.page.slug==="index"?"/wiki":`/wiki/page/${encodeURIComponent(s.page.slug)}`,search:`?spaceId=${encodeURIComponent(s.page.spaceId)}`})},children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[14px] font-semibold text-[var(--ui-ink-strong)]",children:s.page.title}),s.page.summary?e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:s.page.summary}):null]}),e.jsx(_e,{size:"sm",tone:"meta",children:s.score.toFixed(2)})]})},s.page.id))}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"No pages matched this search."}):e.jsx("div",{className:"rounded-2xl border border-dashed border-[var(--ui-border-subtle)] px-4 py-10 text-center text-[13px] leading-6 text-[var(--ui-ink-faint)]",children:"Start typing to search the current KarpaWiki space."})})]})]})}),e.jsx(rs,{open:K,onOpenChange:L,spaces:((ee=l.data)==null?void 0:ee.settings.spaces)??[],activeSpaceId:t,onSelect:s=>{o({pathname:"/wiki",search:`?spaceId=${encodeURIComponent(s)}`},{replace:!0})}}),e.jsx(es,{open:ve,onOpenChange:s=>{if(s){_(Q);return}we()},spaces:((se=l.data)==null?void 0:se.settings.spaces)??[],llmProfiles:((te=l.data)==null?void 0:te.settings.llmProfiles)??[],initialSpaceId:t,selectedJobId:Q,onJobSelected:Ne,linkedEntityHints:r.links.map(s=>({entityType:s.entityType,entityId:s.entityId,anchorKey:null}))??[]})]}):k?e.jsx(O,{eyebrow:"KarpaWiki",title:"Opening a new page",description:`Creating a draft for ${k}.`}):e.jsx(Be,{eyebrow:"KarpaWiki",title:"Article not found",description:"This page does not exist in the selected space."})}export{gs as WikiPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as x,j as e,dJ as At,dK as Kt,dG as Mt,dL as zt,dM as Wt,dN as $t,aG as Ht,dO as Lt,cr as xa,c7 as Ke,bX as Bt,br as Me,b2 as ga,aC as ba,bk as va,ca as fa,cm as ya,dP as ja,cc as ka,b5 as Na}from"./vendor-Dnkkx2co.js";import{O as wa}from"./open-in-graph-button-B_XHtHZD.js";import{P as Ca}from"./page-hero-DzEsy8i5.js";import{fu as Sa,a9 as Ut,fv as Ct,fw as _a,Z as O,aq as D,B as R,F as S,aV as Ia,fx as Ta,fy as Fa,b as St,fs as Ra,Q as Ea,fz as Oa,fA as Pa,fB as Aa,fC as Ka,fD as Ma,fE as za,fF as Wa,L as $a,a as Ha,E as La}from"./index-BhkubYaC.js";import{H as Ba,P as _t,i as Ua,B as qa,a as Da,b as Va,c as Ga}from"./graph-DDUZNRsO.js";import{R as Qa,P as Ja,O as Ya,C as Xa,T as Za,D as es,a as ts}from"./ui-C1iwpj2-.js";import{F as as}from"./faceted-token-search-CAsZrhZ4.js";import"./state-vCcAT5Hq.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";const ze=[...Sa];function fe(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 qt(t,i){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(!i.trim())return"";try{return JSON.parse(i)}catch{return i}}if(t==="boolean")return i.trim()?i.trim().toLowerCase()==="true"?!0:i.trim().toLowerCase()==="false"?!1:i:"";if(t==="number"){const s=i.trim();if(!s)return"";const n=Number(s);return Number.isFinite(n)?n:i}return i}function ss(t,i){if(i==null||typeof i=="string"&&i.trim().length===0)return!t.required;switch(t.kind){case"text":case"markdown":case"summary":return typeof i=="string";case"number":return typeof i=="number"&&Number.isFinite(i);case"boolean":return typeof i=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(i);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!i&&typeof i=="object";default:return!0}}function Dt(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 Vt(t,i){var d,u,p,o;const s=(l,h)=>l.map(m=>{const v=Ct(m),j=v.key==="primary"?h==="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":v.key:v.key;return Ct({...v,key:j,kind:j===v.key?v.kind:void 0})});if(t.type==="box"||t.type==="box_input"){const l=i.find(h=>h.id===t.data.boxId);return{inputs:s((l==null?void 0:l.inputs)??[],"input"),outputs:(d=l==null?void 0:l.output)!=null&&d.length?s(l.output,"output"):s([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(u=t.data.enabledToolKeys)!=null&&u.length?t.data.enabledToolKeys:((l==null?void 0:l.tools)??[]).map(h=>h.key),boxId:(l==null?void 0:l.id)??t.data.boxId??null}}const n=Dt(t.type);return{inputs:s((p=t.data.inputs)!=null&&p.length?t.data.inputs:n.inputs,"input"),outputs:s((o=t.data.outputs)!=null&&o.length?t.data.outputs:n.outputs,"output"),enabledToolKeys:t.data.enabledToolKeys??[],boxId:t.data.boxId??null}}function rs(t,i){var n,d,u;const s=(n=t.data.outputKey)==null?void 0:n.trim();return!s||s==="primary"?((d=i[0])==null?void 0:d.key)??"":i.some(p=>p.key===s)?s:((u=i[0])==null?void 0:u.key)??s}function It(t,i,s){var n,d;return i.length===0?null:!t||t==="primary"?s&&i.some(u=>u.key===s)?s:((n=i[0])==null?void 0:n.key)??null:i.some(u=>u.key===t)?t:s&&i.some(u=>u.key===s)?s:((d=i[0])==null?void 0:d.key)??null}function Ae(t,i){const s=t.graph.nodes.map(u=>{const p=Vt(u,i),o={...u,data:{...u.data,inputs:p.inputs,outputs:p.outputs,outputKey:rs(u,p.outputs)}};return We(o,i)}),n=new Map(s.map(u=>[u.id,u])),d=t.graph.edges.map(u=>{var m,v,j,f;const p=n.get(u.source),o=n.get(u.target),l=It(u.sourceHandle,(p==null?void 0:p.data.outputs)??[],(v=(m=p==null?void 0:p.data.outputs)==null?void 0:m[0])==null?void 0:v.key),h=It(u.targetHandle,(o==null?void 0:o.data.inputs)??[],(f=(j=o==null?void 0:o.data.inputs)==null?void 0:j[0])==null?void 0:f.key);return Gt({...u,sourceHandle:l,targetHandle:h})});return{nodes:s,edges:d}}function We(t,i){const s=Vt(t,i);return{id:t.id,type:"workbench",position:t.position,data:{...t.data,nodeType:t.type==="box_input"?"box":t.type,boxId:s.boxId,enabledToolKeys:s.enabledToolKeys,inputs:s.inputs,outputs:s.outputs,params:t.data.params??[],paramValues:t.data.paramValues??{}}}}function Gt(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 Qt(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 ns(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 Tt(t,i,s){var d;const n=Dt(t);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+i.length%3*320,y:80+Math.floor(i.length/3)*220},data:{nodeType:t,label:(s==null?void 0:s.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:(s==null?void 0:s.description)??(t==="box"?"Registered Forge box.":t==="chat"?"Conversational flow node.":t==="functor"?"Single transformation node.":"Workbench node."),boxId:(s==null?void 0:s.id)??null,enabledToolKeys:((s==null?void 0:s.tools)??[]).map(u=>u.key),inputs:(s==null?void 0:s.inputs)??n.inputs,outputs:(s==null?void 0:s.output)??n.outputs,params:(s==null?void 0:s.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((d=((s==null?void 0:s.output)??n.outputs)[0])==null?void 0:d.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function is(t){return[t.kind,t.modelName,t.itemKind?`item:${t.itemKind}`:null].filter(Boolean).join(" · ")}function ls(t,i){switch(t){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return i?`Save failed: ${i}`:"Save failed";default:return"Saved"}}function os(t){const i=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${t}_${i}`,label:t==="input"?"New input":"New output",kind:t==="input"?"context":"record",description:"",required:!1,modelName:t==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function ds(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function ne(t){return t==="functor"||t==="chat"}function cs(t){const i=t instanceof Ut||t instanceof Error?t.message:String(t);return i.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{r as x,j as e,dJ as At,dK as Kt,dG as Mt,dL as zt,dM as Wt,dN as $t,aG as Ht,dO as Lt,cr as xa,c7 as Ke,bX as Bt,br as Me,b2 as ga,aC as ba,bk as va,ca as fa,cm as ya,dP as ja,cc as ka,b5 as Na}from"./vendor-Dnkkx2co.js";import{O as wa}from"./open-in-graph-button-CDHxzS8B.js";import{P as Ca}from"./page-hero-DgnhI5es.js";import{fu as Sa,a9 as Ut,fv as Ct,fw as _a,Z as O,aq as D,B as R,F as S,aV as Ia,fx as Ta,fy as Fa,b as St,fs as Ra,Q as Ea,fz as Oa,fA as Pa,fB as Aa,fC as Ka,fD as Ma,fE as za,fF as Wa,L as $a,a as Ha,E as La}from"./index-BP9__l6C.js";import{H as Ba,P as _t,i as Ua,B as qa,a as Da,b as Va,c as Ga}from"./graph-DDUZNRsO.js";import{R as Qa,P as Ja,O as Ya,C as Xa,T as Za,D as es,a as ts}from"./ui-C1iwpj2-.js";import{F as as}from"./faceted-token-search-DtO6OUwQ.js";import"./state-vCcAT5Hq.js";import"./motion-Lt5B1XuE.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";const ze=[...Sa];function fe(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 qt(t,i){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(!i.trim())return"";try{return JSON.parse(i)}catch{return i}}if(t==="boolean")return i.trim()?i.trim().toLowerCase()==="true"?!0:i.trim().toLowerCase()==="false"?!1:i:"";if(t==="number"){const s=i.trim();if(!s)return"";const n=Number(s);return Number.isFinite(n)?n:i}return i}function ss(t,i){if(i==null||typeof i=="string"&&i.trim().length===0)return!t.required;switch(t.kind){case"text":case"markdown":case"summary":return typeof i=="string";case"number":return typeof i=="number"&&Number.isFinite(i);case"boolean":return typeof i=="boolean";case"array":case"entity_list":case"record_list":return Array.isArray(i);case"object":case"json":case"record":case"context":case"filters":case"metrics":case"timeline":case"selection":case"entity":return!!i&&typeof i=="object";default:return!0}}function Dt(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 Vt(t,i){var d,u,p,o;const s=(l,h)=>l.map(m=>{const v=Ct(m),j=v.key==="primary"?h==="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":v.key:v.key;return Ct({...v,key:j,kind:j===v.key?v.kind:void 0})});if(t.type==="box"||t.type==="box_input"){const l=i.find(h=>h.id===t.data.boxId);return{inputs:s((l==null?void 0:l.inputs)??[],"input"),outputs:(d=l==null?void 0:l.output)!=null&&d.length?s(l.output,"output"):s([{key:"summary",label:"Summary",kind:"summary",description:"Human-readable summary of the box snapshot.",modelName:"WorkbenchBoxSummary"}],"output"),enabledToolKeys:(u=t.data.enabledToolKeys)!=null&&u.length?t.data.enabledToolKeys:((l==null?void 0:l.tools)??[]).map(h=>h.key),boxId:(l==null?void 0:l.id)??t.data.boxId??null}}const n=Dt(t.type);return{inputs:s((p=t.data.inputs)!=null&&p.length?t.data.inputs:n.inputs,"input"),outputs:s((o=t.data.outputs)!=null&&o.length?t.data.outputs:n.outputs,"output"),enabledToolKeys:t.data.enabledToolKeys??[],boxId:t.data.boxId??null}}function rs(t,i){var n,d,u;const s=(n=t.data.outputKey)==null?void 0:n.trim();return!s||s==="primary"?((d=i[0])==null?void 0:d.key)??"":i.some(p=>p.key===s)?s:((u=i[0])==null?void 0:u.key)??s}function It(t,i,s){var n,d;return i.length===0?null:!t||t==="primary"?s&&i.some(u=>u.key===s)?s:((n=i[0])==null?void 0:n.key)??null:i.some(u=>u.key===t)?t:s&&i.some(u=>u.key===s)?s:((d=i[0])==null?void 0:d.key)??null}function Ae(t,i){const s=t.graph.nodes.map(u=>{const p=Vt(u,i),o={...u,data:{...u.data,inputs:p.inputs,outputs:p.outputs,outputKey:rs(u,p.outputs)}};return We(o,i)}),n=new Map(s.map(u=>[u.id,u])),d=t.graph.edges.map(u=>{var m,v,j,f;const p=n.get(u.source),o=n.get(u.target),l=It(u.sourceHandle,(p==null?void 0:p.data.outputs)??[],(v=(m=p==null?void 0:p.data.outputs)==null?void 0:m[0])==null?void 0:v.key),h=It(u.targetHandle,(o==null?void 0:o.data.inputs)??[],(f=(j=o==null?void 0:o.data.inputs)==null?void 0:j[0])==null?void 0:f.key);return Gt({...u,sourceHandle:l,targetHandle:h})});return{nodes:s,edges:d}}function We(t,i){const s=Vt(t,i);return{id:t.id,type:"workbench",position:t.position,data:{...t.data,nodeType:t.type==="box_input"?"box":t.type,boxId:s.boxId,enabledToolKeys:s.enabledToolKeys,inputs:s.inputs,outputs:s.outputs,params:t.data.params??[],paramValues:t.data.paramValues??{}}}}function Gt(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 Qt(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 ns(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 Tt(t,i,s){var d;const n=Dt(t);return{id:`node_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,type:"workbench",position:{x:120+i.length%3*320,y:80+Math.floor(i.length/3)*220},data:{nodeType:t,label:(s==null?void 0:s.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:(s==null?void 0:s.description)??(t==="box"?"Registered Forge box.":t==="chat"?"Conversational flow node.":t==="functor"?"Single transformation node.":"Workbench node."),boxId:(s==null?void 0:s.id)??null,enabledToolKeys:((s==null?void 0:s.tools)??[]).map(u=>u.key),inputs:(s==null?void 0:s.inputs)??n.inputs,outputs:(s==null?void 0:s.output)??n.outputs,params:(s==null?void 0:s.params)??[],paramValues:{},prompt:"",promptTemplate:"",systemPrompt:"",template:"",selectedKey:"",valueType:"string",valueLiteral:"",outputKey:((d=((s==null?void 0:s.output)??n.outputs)[0])==null?void 0:d.key)??"summary",modelConfig:{connectionId:null,provider:null,baseUrl:null,model:"",thinking:null,verbosity:null}}}}function is(t){return[t.kind,t.modelName,t.itemKind?`item:${t.itemKind}`:null].filter(Boolean).join(" · ")}function ls(t,i){switch(t){case"dirty":return"Unsaved changes";case"saving":return"Saving…";case"saved":return"All changes saved";case"error":return i?`Save failed: ${i}`:"Save failed";default:return"Saved"}}function os(t){const i=crypto.randomUUID().replaceAll("-","").slice(0,4);return{key:`${t}_${i}`,label:t==="input"?"New input":"New output",kind:t==="input"?"context":"record",description:"",required:!1,modelName:t==="input"?"WorkbenchInputContract":"WorkbenchOutputContract"}}function ds(){return{key:`flow_input_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New flow input",kind:"text",description:"",required:!1,modelName:"WorkbenchFlowInput",bindings:[]}}function ne(t){return t==="functor"||t==="chat"}function cs(t){const i=t instanceof Ut||t instanceof Error?t.message:String(t);return i.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
|
`):i}function us(t){return t.map(({key:i,kind:s,required:n,description:d,modelName:u,itemKind:p,shape:o,exampleValue:l})=>({key:i,kind:s,required:!!n,description:d,modelName:u,itemKind:p,shape:o,exampleValue:l}))}function ps(t){const i=Array.from(new Set(t.map(n=>n.trim()).filter(Boolean)));return(i.includes("answer")?i:["answer",...i]).map(n=>({key:n,label:n==="answer"?"Answer":n.split(/[_-]+/).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join(" "),kind:n==="answer"?"markdown":"record",description:n==="answer"?"Primary answer returned by this AI node.":`Named output published for downstream nodes under "${n}".`,modelName:n==="answer"?"WorkbenchAiAnswer":`Workbench${n.split(/[_-]+/).map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join("")}`,exampleValue:n==="answer"?"Concise answer":void 0}))}function ms(t,i){return Jt(t,i)[0]??null}function Jt(t,i){var p,o;const s=[],n=new Map(t.map(l=>[l.id,l]));t.length===0&&s.push("Add at least one node before running the flow.");const d=t.filter(l=>l.data.nodeType==="output");d.length===0&&s.push("Add an Output node so Forge knows what result the flow should publish.");const u=new Map;for(const l of i){u.set(l.target,(u.get(l.target)??0)+1);const h=n.get(l.source),m=n.get(l.target),v=(h==null?void 0:h.data.outputs)??[],j=(m==null?void 0:m.data.inputs)??[];h&&(l.sourceHandle&&!v.some(f=>f.key===l.sourceHandle)?s.push(`Edge from "${h.data.label}" points to missing output "${l.sourceHandle}". Update the edge or restore that output contract.`):!l.sourceHandle&&v.length>1&&s.push(`Edge from "${h.data.label}" does not name which output it should use. Pick one explicit output handle.`)),m&&(l.targetHandle&&!j.some(f=>f.key===l.targetHandle)?s.push(`Edge into "${m.data.label}" points to missing input "${l.targetHandle}". Update the edge or restore that input contract.`):!l.targetHandle&&j.length>1&&s.push(`Edge into "${m.data.label}" does not name which input it should feed. Pick one explicit input handle.`))}for(const l of d){(u.get(l.id)??0)===0&&s.push(`Connect something into the output node "${l.data.label}" so the flow has something to return.`);const h=i.filter(m=>m.target===l.id).flatMap(m=>{const v=n.get(m.source),j=(v==null?void 0:v.data.outputs)??[];return m.sourceHandle?j.filter(f=>f.key===m.sourceHandle).map(f=>f.key):j.map(f=>f.key)});l.data.outputKey&&h.length>0&&!h.includes(l.data.outputKey)&&s.push(`Output node "${l.data.label}" is configured to publish "${l.data.outputKey}", but that key is not arriving from its upstream nodes.`)}for(const l of t){const h=u.get(l.id)??0,m=i.filter(v=>v.source===l.id).length;l.data.nodeType!=="user_input"&&l.data.nodeType!=="value"&&h===0&&l.data.nodeType!=="box"&&s.push(`Connect an upstream source into "${l.data.label}" so it has real input to work with.`),l.data.nodeType==="merge"&&h<2&&s.push(`Merge node "${l.data.label}" should receive both left and right inputs before you run it.`),l.data.nodeType==="template"&&!(l.data.template??"").trim()&&s.push(`Add a template string to "${l.data.label}" before running the flow.`),l.data.nodeType==="pick_key"&&!(l.data.selectedKey??"").trim()&&s.push(`Choose which key "${l.data.label}" should pick from incoming objects.`),l.data.nodeType!=="output"&&m===0&&s.push(`Connect the output of "${l.data.label}" somewhere useful or remove the node from the graph.`)}for(const l of t)ne(l.data.nodeType)&&!((p=l.data.promptTemplate)!=null&&p.trim()||(o=l.data.prompt)!=null&&o.trim())&&s.push(`Add a prompt to the AI node "${l.data.label}" before running the flow.`);return s}function Ft({title:t,description:i,kind:s,publicInputs:n,nodes:d,edges:u}){return{title:t,description:i,kind:s,publicInputs:n,graph:{nodes:d.map(Qt),edges:u.map(ns)}}}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)]",Yt={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 hs(t){switch(t){case"box":case"box_input":return{icon:e.jsx(xa,{className:"size-4"}),badge:"box"};case"chat":return{icon:e.jsx(Lt,{className:"size-4"}),badge:"chat"};case"functor":return{icon:e.jsx(Ht,{className:"size-4"}),badge:"functor"};case"output":return{icon:e.jsx($t,{className:"size-4"}),badge:"output"};case"value":return{icon:e.jsx(Wt,{className:"size-4"}),badge:"value"};case"merge":return{icon:e.jsx(zt,{className:"size-4"}),badge:"merge"};case"template":return{icon:e.jsx(Mt,{className:"size-4"}),badge:"template"};case"pick_key":return{icon:e.jsx(Kt,{className:"size-4"}),badge:"pick key"};default:return{icon:e.jsx(At,{className:"size-4"}),badge:"input"}}}function ye({kind:t}){return e.jsx("span",{className:O("inline-flex items-center rounded-full border px-2.5 py-1 text-[10px] uppercase tracking-[0.16em]",Yt[t]??"border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] text-[var(--ui-ink-soft)]"),children:t.replaceAll("_"," ")})}function W({label:t,onClick:i,emphasis:s=!1}){return e.jsx("button",{type:"button",className:O("rounded-full border px-3 py-1.5 text-[11px] font-medium transition",s?"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:n=>n.stopPropagation(),onClick:n=>{n.stopPropagation(),i()},children:t})}function Rt({side:t,ports:i,collapsed:s}){return e.jsxs("div",{className:"grid gap-1.5",children:[e.jsxs("div",{className:O("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(D,{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"})]}),i.length===0?e.jsx("div",{className:O("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,i.map(n=>e.jsxs("div",{className:O("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",s?"bg-[var(--ui-surface-1)]":"bg-[var(--ui-surface-2)]",Yt[n.kind]??"border-[var(--ui-border-subtle)] text-[var(--ui-ink-soft)]"),children:[e.jsx(Ba,{type:t==="left"?"target":"source",position:t==="left"?_t.Left:_t.Right,id:n.key,className:"!size-2.5 !border",style:{[t]:6,background:"var(--primary)",borderColor:"var(--ui-ink-strong)"}}),s?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:n.label}),e.jsx(ye,{kind:n.kind})]}),e.jsx("div",{className:"mt-1 text-[10px] text-[var(--ui-ink-faint)]",children:is(n)})]})]},`${t}-${n.key}`))]})}function xs(t){var h,m,v,j;const i=_a(t.data.boxId??null),[s,n]=x.useState(!1),[d,u]=x.useState(!1),p=hs(t.data.nodeType),o=((h=t.data.params)==null?void 0:h.length)??0,l=`${((m=t.data.inputs)==null?void 0:m.length)??0} in · ${((v=t.data.outputs)==null?void 0:v.length)??0} out`;if(i&&t.data.nodeType==="box"){const f=i.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(W,{label:"Edit",onClick:()=>{var k,F;return(F=(k=t.data).onEditRequest)==null?void 0:F.call(k)}}),e.jsx(W,{label:l,onClick:()=>{var k,F;return(F=(k=t.data).onContractEditRequest)==null?void 0:F.call(k)}}),o>0?e.jsx(W,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var k,F;return(F=(k=t.data).onParameterEditRequest)==null?void 0:F.call(k)},emphasis:!0}):null]}),e.jsx("div",{className:O("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(f,{nodeId:t.id,inputs:void 0,params:void 0,compact:!1})})]})}return e.jsxs("div",{className:O("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:[p.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(W,{label:s?"Show ports":"Hide labels",onClick:()=>n(f=>!f)}),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:p.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:[(j=t.data.enabledToolKeys)!=null&&j.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(W,{label:d?"Hide schema":"Preview schema",onClick:()=>u(f=>!f)}),e.jsx(W,{label:"Edit",onClick:()=>{var f,k;return(k=(f=t.data).onEditRequest)==null?void 0:k.call(f)}}),e.jsx(W,{label:l,onClick:()=>{var f,k;return(k=(f=t.data).onContractEditRequest)==null?void 0:k.call(f)}}),o>0?e.jsx(W,{label:`${o} parameter${o===1?"":"s"}`,onClick:()=>{var f,k;return(k=(f=t.data).onParameterEditRequest)==null?void 0:k.call(f)},emphasis:!0}):null]}),e.jsxs("div",{className:"mt-3 grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3",children:[e.jsx(Rt,{side:"left",ports:t.data.inputs??[],collapsed:s}),e.jsx(Rt,{side:"right",ports:t.data.outputs??[],collapsed:s})]}),d?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(D,{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:f,kind:k,required:F})=>({key:f,kind:k,required:!!F})),outputs:(t.data.outputs??[]).map(({key:f,kind:k,required:F})=>({key:f,kind:k,required:!!F})),tools:t.data.enabledToolKeys??[]},null,2)})]}):null]})}const Xt="grid gap-3 rounded-[24px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",Zt="grid gap-3 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",gs="grid gap-3 rounded-[16px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-1)] p-4",$e="rounded-[18px] border border-dashed border-[var(--ui-border-strong)] px-4 py-3 text-sm text-[var(--ui-ink-faint)]",He="flex items-center gap-2 text-sm font-medium text-[var(--ui-ink-strong)]",Le="text-sm leading-6 text-[var(--ui-ink-soft)]",ea="flex items-center gap-2 text-sm text-[var(--ui-ink-medium)]";function $(t,i,s){return t.map((n,d)=>d===i?{...n,...s}:n)}function re(t,i,s,n){return t.map((d,u)=>u===i?{...d,shape:(d.shape??[]).map((p,o)=>o===s?{...p,...n}:p)}:d)}function bs(){return{key:`field_${crypto.randomUUID().replaceAll("-","").slice(0,4)}`,label:"New field",kind:"text",required:!1}}function be({title:t,description:i,ports:s,onChange:n,prefix:d}){return e.jsxs("div",{className:Xt,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:He,children:[e.jsx("span",{children:t}),e.jsx(D,{content:i,label:`Explain ${t.toLowerCase()}`})]}),e.jsx("div",{className:`mt-1 ${Le}`,children:i})]}),e.jsxs(R,{type:"button",variant:"secondary",size:"sm",onClick:()=>n([...s??[],os(d)]),children:["Add ",d]})]}),e.jsxs("div",{className:"grid gap-3",children:[s.length===0?e.jsxs("div",{className:$e,children:["No ",d,"s defined yet."]}):null,s.map((u,p)=>e.jsxs("div",{className:Zt,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(ye,{kind:u.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:u.label})]}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:()=>n(s.filter((o,l)=>l!==p)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(S,{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:u.key,onChange:o=>n($(s,p,{key:o.target.value})),className:y})}),e.jsx(S,{label:"Label",description:"Readable name shown in the graph editor.",children:e.jsx("input",{value:u.label,onChange:o=>n($(s,p,{label:o.target.value})),className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(S,{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:u.kind,onChange:o=>n($(s,p,{kind:o.target.value})),className:y,children:ze.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(S,{label:"Model name",description:"Semantic model name for this port, used in previews and runtime contracts.",children:e.jsx("input",{value:u.modelName??"",onChange:o=>n($(s,p,{modelName:o.target.value||void 0})),placeholder:"WorkbenchTaskSearchResults",className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(S,{label:"Item kind",description:"Optional entity or item subtype when this port carries a collection.",children:e.jsx("input",{value:u.itemKind??"",onChange:o=>n($(s,p,{itemKind:o.target.value||void 0})),placeholder:"task",className:y})}),e.jsx(S,{label:"Example value",description:"Short example shown in collapsed previews.",children:e.jsx("input",{value:u.exampleValue??"",onChange:o=>n($(s,p,{exampleValue:o.target.value||void 0})),placeholder:d==="input"?"task ids and filters":"summarized result",className:y})})]}),e.jsx(S,{label:"Expectation",description:"Describe what should actually be inside this value so the graph stays legible.",children:e.jsx("textarea",{rows:3,value:u.description??"",onChange:o=>n($(s,p,{description:o.target.value||void 0})),placeholder:d==="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:Le,children:"Describe the object structure or list item shape this port carries."}),e.jsx(R,{type:"button",variant:"secondary",size:"sm",onClick:()=>n(s.map((o,l)=>l===p?{...o,shape:[...o.shape??[],bs()]}:o)),children:"Add field"})]}),(u.shape??[]).length===0?e.jsx("div",{className:$e,children:"No explicit structure fields yet."}):null,(u.shape??[]).map((o,l)=>e.jsxs("div",{className:gs,children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx(ye,{kind:o.kind}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:()=>n(s.map((h,m)=>m===p?{...h,shape:(h.shape??[]).filter((v,j)=>j!==l)}:h)),children:"Remove field"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("input",{value:o.key,onChange:h=>n(re(s,p,l,{key:h.target.value})),placeholder:"field_key",className:y}),e.jsx("input",{value:o.label,onChange:h=>n(re(s,p,l,{label:h.target.value})),placeholder:"Field label",className:y})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx("select",{value:o.kind,onChange:h=>n(re(s,p,l,{kind:h.target.value})),className:y,children:ze.map(h=>e.jsx("option",{value:h,children:h.replaceAll("_"," ")},h))}),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:!!o.required,onChange:h=>n(re(s,p,l,{required:h.target.checked}))}),"Required field"]})]}),e.jsx("textarea",{rows:2,value:o.description??"",onChange:h=>n(re(s,p,l,{description:h.target.value||void 0})),placeholder:"What should this field contain?",className:y})]},`${u.key}-shape-${o.key}-${l}`))]})]}),e.jsxs("label",{className:ea,children:[e.jsx("input",{type:"checkbox",checked:!!u.required,onChange:o=>n($(s,p,{required:o.target.checked}))}),"Required port"]})]},`${d}-${u.key}-${p}`))]})]})}function vs({inputs:t,nodes:i,onChange:s}){return e.jsxs("div",{className:Xt,children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:He,children:[e.jsx("span",{children:"Flow inputs"}),e.jsx(D,{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 ${Le}`,children:"Define the external contract once, then bind each input to the node inputs or parameters that should consume it."})]}),e.jsx(R,{type:"button",variant:"secondary",size:"sm",onClick:()=>s([...t??[],ds()]),children:"Add flow input"})]}),t.length===0?e.jsx("div",{className:$e,children:"No public flow inputs defined yet."}):null,e.jsx("div",{className:"grid gap-3",children:t.map((n,d)=>{const u=i.filter(o=>(o.data.inputs??[]).length>0||(o.data.params??[]).length>0),p=o=>s(t.map((l,h)=>h===d?{...l,...o}:l));return e.jsxs("div",{className:Zt,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(ye,{kind:n.kind}),e.jsx("span",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:n.label})]}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:()=>s(t.filter((o,l)=>l!==d)),children:"Remove"})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(S,{label:"Key",description:"External API key callers will send.",children:e.jsx("input",{value:n.key,onChange:o=>p({key:o.target.value}),className:y})}),e.jsx(S,{label:"Label",description:"Human-readable name used in the Run modal.",children:e.jsx("input",{value:n.label,onChange:o=>p({label:o.target.value}),className:y})})]}),e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsx(S,{label:"Value type",description:"Expected type for this flow input.",children:e.jsx("select",{value:n.kind,onChange:o=>p({kind:o.target.value}),className:y,children:ze.map(o=>e.jsx("option",{value:o,children:o.replaceAll("_"," ")},o))})}),e.jsx(S,{label:"Default value",description:"Used when a caller omits this input.",children:e.jsx("textarea",{rows:3,value:fe(n.defaultValue),onChange:o=>p({defaultValue:qt(n.kind,o.target.value)}),className:y})})]}),e.jsx(S,{label:"Description",description:"Explain what callers should send here.",children:e.jsx("textarea",{rows:3,value:n.description??"",onChange:o=>p({description:o.target.value}),className:y})}),e.jsxs("label",{className:ea,children:[e.jsx("input",{type:"checkbox",checked:!!n.required,onChange:o=>p({required:o.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:He,children:["Bindings",e.jsx(D,{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"})]}),(n.bindings??[]).map((o,l)=>{const h=i.find(v=>v.id===o.nodeId)??null,m=o.targetKind==="param"?(h==null?void 0:h.data.params)??[]:(h==null?void 0:h.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:o.nodeId,onChange:v=>p({bindings:(n.bindings??[]).map((j,f)=>f===l?{...j,nodeId:v.target.value,targetKey:""}:j)}),className:y,children:[e.jsx("option",{value:"",children:"Select node"}),u.map(v=>e.jsx("option",{value:v.id,children:v.data.label},v.id))]}),e.jsxs("select",{value:o.targetKind,onChange:v=>p({bindings:(n.bindings??[]).map((j,f)=>f===l?{...j,targetKind:v.target.value,targetKey:""}:j)}),className:y,children:[e.jsx("option",{value:"input",children:"Node input"}),e.jsx("option",{value:"param",children:"Node parameter"})]}),e.jsxs("select",{value:o.targetKey,onChange:v=>p({bindings:(n.bindings??[]).map((j,f)=>f===l?{...j,targetKey:v.target.value}:j)}),className:y,children:[e.jsx("option",{value:"",children:"Select target"}),m.map(v=>e.jsx("option",{value:v.key,children:v.label},v.key))]}),e.jsx(R,{type:"button",variant:"ghost",size:"sm",onClick:()=>p({bindings:(n.bindings??[]).filter((v,j)=>j!==l)}),children:"Remove"})]},`${o.nodeId}-${o.targetKey}-${l}`)}),e.jsx(R,{type:"button",variant:"secondary",size:"sm",onClick:()=>p({bindings:[...n.bindings??[],{nodeId:"",targetKind:"input",targetKey:""}]}),children:"Add binding"})]})]},`${n.key}-${d}`)})})]})}const fs="min-w-0 rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)]",Et="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)]",Ot="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)]",ys="text-[10px] uppercase tracking-[0.14em] text-[var(--ui-ink-faint)]";function ie({open:t,onOpenChange:i,title:s,description:n,children:d}){return e.jsx(Qa,{open:t,onOpenChange:i,children:e.jsxs(Ja,{children:[e.jsx(Ya,{className:"fixed inset-0 z-50 bg-[var(--ui-overlay-backdrop)] backdrop-blur-sm"}),e.jsxs(Xa,{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(Za,{className:"font-display text-[1.28rem] tracking-[-0.04em] text-[var(--ui-ink-strong)]",children:s}),n?e.jsx(es,{className:"mt-1 text-sm leading-6 text-[var(--ui-ink-soft)]",children:n}):null]}),e.jsx(ts,{asChild:!0,children:e.jsx(Ia,{"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:d})]})]})})}const js=[{type:"user_input",label:"User input",icon:e.jsx(At,{className:"size-4"})},{type:"value",label:"Value",icon:e.jsx(Wt,{className:"size-4"})},{type:"functor",label:"Functor",icon:e.jsx(Ht,{className:"size-4"})},{type:"chat",label:"Chat",icon:e.jsx(ga,{className:"size-4"})},{type:"merge",label:"Merge",icon:e.jsx(zt,{className:"size-4"})},{type:"template",label:"Template",icon:e.jsx(Mt,{className:"size-4"})},{type:"pick_key",label:"Pick key",icon:e.jsx(Kt,{className:"size-4"})},{type:"output",label:"Output",icon:e.jsx($t,{className:"size-4"})}];function ks({open:t,onOpenChange:i,boxQuery:s,onBoxQueryChange:n,boxOptions:d,boxFilters:u,onBoxFiltersChange:p,filteredBoxes:o,onAddNodeType:l,onAddBox:h}){return e.jsx(ie,{open:t,onOpenChange:i,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:js.map(m=>e.jsxs("button",{type:"button",className:`${Et} flex items-center gap-3 px-4 py-3`,onClick:()=>l(m.type),children:[m.icon,e.jsx("span",{children:m.label})]},m.type))}),e.jsx(as,{title:"Forge boxes",description:"",query:s,onQueryChange:n,options:d,selectedOptionIds:u,onSelectedOptionIdsChange:p,resultSummary:`${o.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:o.map(m=>e.jsxs("button",{type:"button",className:`${Et} px-4 py-3`,onClick:()=>h(m),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:m.title}),e.jsxs("div",{className:`flex shrink-0 flex-wrap gap-2 ${ys}`,children:[e.jsxs("span",{children:[m.output.length," output",m.output.length===1?"":"s"]}),e.jsxs("span",{children:[m.tools.length," tool",m.tools.length===1?"":"s"]})]})]}),e.jsx("div",{className:"mt-1 text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:m.description}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsx("div",{className:Ot,children:m.category}),m.routePath?e.jsx("div",{className:Ot,children:m.routePath}):null]})]},m.id))})]})})}function Ns({open:t,onOpenChange:i,title:s,onTitleChange:n,description:d,onDescriptionChange:u,kind:p,onKindChange:o,publicInputs:l,onPublicInputsChange:h,nodes:m,flowId:v,onDelete:j,onSave:f}){return e.jsx(ie,{open:t,onOpenChange:i,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:s,onChange:k=>n(k.target.value),placeholder:"Flow title",className:y}),e.jsx("textarea",{rows:4,value:d,onChange:k=>u(k.target.value),placeholder:"Flow description",className:y}),e.jsxs("select",{value:p,onChange:k=>o(k.target.value),className:y,children:[e.jsx("option",{value:"functor",children:"Functor flow"}),e.jsx("option",{value:"chat",children:"Chat flow"})]}),e.jsx(vs,{inputs:l,nodes:m,onChange:h}),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:v}),e.jsxs("div",{className:"flex flex-wrap justify-between gap-2 pt-2",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>{j()},children:[e.jsx(Ke,{className:"size-4"}),"Delete flow"]}),e.jsxs(R,{type:"button",variant:"primary",onClick:()=>{f().then(()=>i(!1))},children:[e.jsx(Bt,{className:"size-4"}),"Save settings"]})]})]})})}function ws(t){if(t.trim())try{return JSON.parse(t)}catch{return t}}function Cs({open:t,onOpenChange:i,runError:s,graphIssues:n,hasAiNodes:d,modelConnectionCount:u,publicInputs:p,runInputs:o,onRunInputChange:l,shouldShowLegacyUserInput:h,userInput:m,onUserInputChange:v,debugEnabled:j,onDebugEnabledChange:f,onRun:k,onChat:F,runs:I}){return e.jsx(ie,{open:t,onOpenChange:i,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:[s?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:s}):null,!s&&n.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:n.slice(0,4).map(g=>e.jsxs("li",{children:["• ",g]},g))})]}):null,!s&&d&&u===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,p.length>0?e.jsxs("div",{className:`grid gap-3 p-4 ${fs}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--ui-ink-strong)]",children:["Flow inputs",e.jsx(D,{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:p.map(g=>e.jsx(S,{label:g.label,description:g.description||"Typed input for this flow.",children:g.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:!!o[g.key],onChange:_=>l(g.key,_.target.checked)}),g.label]}):g.kind==="number"?e.jsx("input",{type:"number",value:typeof o[g.key]=="number"?String(o[g.key]):"",onChange:_=>l(g.key,_.target.value.trim().length===0?void 0:Number(_.target.value)),className:y}):g.kind==="array"||g.kind==="entity_list"||g.kind==="record_list"||g.kind==="object"||g.kind==="json"||g.kind==="record"||g.kind==="context"||g.kind==="filters"||g.kind==="metrics"||g.kind==="timeline"||g.kind==="selection"||g.kind==="entity"?e.jsx("textarea",{rows:4,value:fe(o[g.key]),onChange:_=>l(g.key,ws(_.target.value)),placeholder:'{"key":"value"}',className:y}):e.jsx("input",{value:typeof o[g.key]=="string"?o[g.key]:"",onChange:_=>l(g.key,_.target.value),placeholder:g.exampleValue||g.label,className:y})},g.key))})]}):null,h?e.jsx("textarea",{rows:5,value:m,onChange:g=>v(g.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:j,onChange:g=>f(g.target.checked)}),"Return debug trace"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(R,{type:"button",variant:"primary",onClick:k,children:[e.jsx(Me,{className:"size-4"}),"Run"]}),e.jsxs(R,{type:"button",variant:"secondary",onClick:F,children:[e.jsx(Lt,{className:"size-4"}),"Chat"]})]}),e.jsx("div",{className:"grid gap-2 pt-2",children:I.slice(0,5).map(g=>{var _;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:g.mode}),e.jsx("span",{children:new Date(g.createdAt).toLocaleString()})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:((_=g.result)==null?void 0:_.primaryText)??g.error??"No output yet."})]},g.id)})})]})})}function je(t){switch(t){case"exec":return 4;case"read_write":return 3;case"write":return 2;case"read":default:return 1}}function Ss(t,i){return je(t)>=je(i)?t:i}function Pt(t,i){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.":i.sort((s,n)=>n.length-s.length)[0]??"Workbench tool"}function _s(t){const i=new Map;for(const s of t)for(const n of s.tools){const d=i.get(n.key);if(!d){i.set(n.key,{key:n.key,label:n.label,description:Pt(n.key,[n.description]),accessMode:n.accessMode,argsSchema:n.argsSchema,sources:[s.title],sourceSurfaceIds:s.surfaceId?[s.surfaceId]:[]});continue}d.accessMode=Ss(d.accessMode,n.accessMode),d.label=d.label.length>=n.label.length?d.label:n.label,d.description=Pt(n.key,[d.description,n.description]),d.argsSchema=d.argsSchema??n.argsSchema,d.sources.includes(s.title)||d.sources.push(s.title),s.surfaceId&&!d.sourceSurfaceIds.includes(s.surfaceId)&&d.sourceSurfaceIds.push(s.surfaceId)}return[...i.values()].sort((s,n)=>{const d=je(n.accessMode)-je(s.accessMode);return d!==0?d:s.label.localeCompare(n.label)})}const Is={workbench:xs},ve="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 Ts(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 Fs({flow:t,boxes:i,modelConnections:s,runs:n,onSave:d,onDelete:u,onRun:p,onChat:o}){var st,rt,nt,it,lt,ot,dt,ct,ut,pt,mt,ht,xt,gt,bt,vt,ft,yt,jt,kt,Nt,wt;const[l,h]=x.useState(t.title),[m,v]=x.useState(t.description),[j,f]=x.useState(t.kind),[k,F]=x.useState(t.publicInputs??[]),[I,g]=x.useState(()=>Ae(t,i).nodes),[_,J]=x.useState(()=>Ae(t,i).edges),[le,ke]=x.useState(null),[ta,oe]=x.useState(!1),[Be,H]=x.useState(!1),[de,ce]=x.useState("overview"),[aa,Ne]=x.useState(void 0),[sa,ue]=x.useState(!1),[ra,Ue]=x.useState(!1),[we,Ce]=x.useState(!1),[Se,na]=x.useState(""),[_e,ia]=x.useState([]),[Ie,la]=x.useState(""),[qe,De]=x.useState({}),[Te,oa]=x.useState(!0),[da,L]=x.useState(null),[Fe,B]=x.useState("idle"),[ca,pe]=x.useState(null),[V,Ve]=x.useState(((st=n[0])==null?void 0:st.id)??null),[me,Ge]=x.useState(null),P=x.useMemo(()=>JSON.stringify(Ft({title:t.title,description:t.description,kind:t.kind,publicInputs:t.publicInputs??[],nodes:t.graph.nodes.map(a=>We(a,i)),edges:t.graph.edges.map(Gt)})),[i,t]),G=x.useRef(P),Re=x.useRef(P),Qe=x.useRef({}),he=x.useRef(P),xe=x.useRef(null),ge=x.useRef(!1);x.useEffect(()=>{if(P===Re.current)return;Re.current=P,G.current=P,he.current=P,h(t.title),v(t.description),f(t.kind),F(t.publicInputs??[]);const a=Ae(t,i);g(a.nodes),J(a.edges),B("idle"),pe(null)},[i,t,P]),x.useEffect(()=>{De(Object.fromEntries((t.publicInputs??[]).filter(a=>a.defaultValue!==void 0).map(a=>[a.key,a.defaultValue])))},[t.publicInputs]),x.useEffect(()=>{var a;Ve(((a=n[0])==null?void 0:a.id)??null)},[n]),x.useEffect(()=>{g(a=>a.map(r=>r.data.nodeType!=="box"||!r.data.boxId?r:We(Qt(r),i)))},[i]);const ua=x.useMemo(()=>Array.from(new Set(i.map(r=>r.category))).map(r=>({id:`category:${r}`,label:r,description:"Workbench box category"})),[i]),pa=x.useMemo(()=>{const a=Se.trim().toLowerCase();return i.filter(r=>{const c=a.length===0||[r.title,r.description,r.category,r.routePath??"",...r.tags].join(" ").toLowerCase().includes(a),w=_e.every(C=>C.startsWith("category:")?r.category===C.replace("category:",""):!0);return c&&w})},[_e,Se,i]),b=x.useMemo(()=>I.find(a=>a.id===le)??null,[I,le]),Y=n[0]??null,U=n.find(a=>a.id===V)??Y??null,Q=Ta({flowId:t.id,runId:V??""},{skip:!V||!we}),A=((rt=Q.data)==null?void 0:rt.nodeResults.find(a=>a.nodeId===me))??null,K=Fa({flowId:t.id,runId:V??"",nodeId:me??""},{skip:!V||!me||!we}),Ee=x.useMemo(()=>Jt(I,_),[I,_]),Je=x.useMemo(()=>I.some(a=>ne(a.data.nodeType)),[I]),Oe=x.useMemo(()=>I.some(a=>a.data.nodeType==="user_input")||(k??[]).length===0,[I,k]);x.useEffect(()=>{var r,c;const a=((c=(r=Q.data)==null?void 0:r.nodeResults[0])==null?void 0:c.nodeId)??null;Ge(a)},[(nt=Q.data)==null?void 0:nt.nodeResults]);const Ye=x.useMemo(()=>!!(b&&b.data.nodeType!=="box"&&b.data.nodeType!=="box_input"),[b]),Xe=x.useMemo(()=>b?_.filter(a=>a.target===b.id).flatMap(a=>{const r=I.find(w=>w.id===a.source),c=(r==null?void 0:r.data.outputs)??[];return a.sourceHandle?c.filter(w=>w.key===a.sourceHandle):c}):[],[_,I,b]),X=x.useMemo(()=>_s(i),[i]),Z=x.useMemo(()=>{if(!b||!ne(b.data.nodeType))return[];const a=new Set(b.data.enabledToolKeys??[]);return X.filter(r=>a.has(r.key))},[X,b]),Pe=x.useMemo(()=>Ft({title:l,description:m,kind:j,publicInputs:k,nodes:I,edges:_}),[m,_,j,I,k,l]),ee=x.useMemo(()=>JSON.stringify(Pe),[Pe]),Ze=ee!==G.current;x.useEffect(()=>{if(Qe.current=Pe,he.current=ee,ee===G.current){pe(null),B(a=>a==="saved"?a:"idle");return}B(a=>a==="saving"?a:"dirty")},[ee]);const ma=x.useMemo(()=>!b||!ne(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,r)=>e.jsxs(e.Fragment,{children:[e.jsx(S,{label:"Label",description:"This is the name shown on the canvas and in debug traces.",children:e.jsx("input",{value:a.label,onChange:c=>r({label:c.target.value}),className:y})}),e.jsx(S,{label:"Description",description:"Explain what this node should do with the incoming flow context.",children:e.jsx("textarea",{rows:4,value:a.description,onChange:c=>r({description:c.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,r)=>e.jsxs(e.Fragment,{children:[e.jsx(S,{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:c=>r({promptTemplate:c.target.value,prompt:c.target.value}),className:y})}),e.jsx(S,{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:c=>r({systemPrompt:c.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,r)=>{var c,w,C;return e.jsxs(e.Fragment,{children:[s.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(S,{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:((c=a.modelConfig)==null?void 0:c.connectionId)??"",onChange:N=>{var M,z;const T=s.find(q=>q.id===N.target.value);r({modelConfig:{connectionId:(T==null?void 0:T.id)??null,provider:(T==null?void 0:T.provider)??null,baseUrl:(T==null?void 0:T.baseUrl)??null,model:(T==null?void 0:T.model)??"",thinking:((M=a.modelConfig)==null?void 0:M.thinking)??null,verbosity:((z=a.modelConfig)==null?void 0:z.verbosity)??null}})},className:y,children:[e.jsx("option",{value:"",children:"Use Forge default model"}),s.map(N=>e.jsx("option",{value:N.id,children:N.label},N.id))]})}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(S,{label:"Thinking effort",description:"Optional reasoning setting for models that support it.",children:e.jsxs("select",{value:((w=a.modelConfig)==null?void 0:w.thinking)??"",onChange:N=>{var T,M,z,q,se;return r({modelConfig:{connectionId:((T=a.modelConfig)==null?void 0:T.connectionId)??null,provider:((M=a.modelConfig)==null?void 0:M.provider)??null,baseUrl:((z=a.modelConfig)==null?void 0:z.baseUrl)??null,model:((q=a.modelConfig)==null?void 0:q.model)??"",thinking:N.target.value||null,verbosity:((se=a.modelConfig)==null?void 0:se.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(S,{label:"Verbosity",description:"Optional output detail setting for models that support it.",children:e.jsxs("select",{value:((C=a.modelConfig)==null?void 0:C.verbosity)??"",onChange:N=>{var T,M,z,q,se;return r({modelConfig:{connectionId:((T=a.modelConfig)==null?void 0:T.connectionId)??null,provider:((M=a.modelConfig)==null?void 0:M.provider)??null,baseUrl:((z=a.modelConfig)==null?void 0:z.baseUrl)??null,model:((q=a.modelConfig)==null?void 0:q.model)??"",thinking:((se=a.modelConfig)==null?void 0:se.thinking)??null,verbosity:N.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,r)=>e.jsxs("div",{className:"grid gap-4",children:[e.jsx(be,{title:"Inputs",description:"Name the upstream values this AI node expects to receive.",ports:a.inputs??[],onChange:c=>r({inputs:c}),prefix:"input"}),e.jsx(be,{title:"Outputs",description:"Describe exactly what this AI node will publish for later nodes.",ports:a.outputs??[],onChange:c=>r({outputs:c}),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,r)=>e.jsxs(e.Fragment,{children:[e.jsx(S,{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:X.length>0?X.map(c=>{const w=(a.enabledToolKeys??[]).includes(c.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:w,onChange:C=>{const N=new Set(a.enabledToolKeys??[]);C.target.checked?N.add(c.key):N.delete(c.key),r({enabledToolKeys:[...N]})}}),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:c.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:c.accessMode.replace("_"," ")})]}),e.jsx("div",{className:"text-[12px] leading-5 text-[var(--ui-ink-soft)]",children:c.description}),c.sources.length>0?e.jsx("div",{className:"mt-2 flex flex-wrap gap-2",children:c.sources.map(C=>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:C},`${c.key}-${C}`))}):null,e.jsx("div",{className:"mt-1 font-mono text-[10px] text-[var(--ui-ink-faint)]",children:c.key}),c.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(c.argsSchema,null,2)})]}):null]})]},c.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(S,{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:Z.length>0?`${Z.length} tool contract${Z.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(Z.map(c=>({key:c.key,label:c.label,accessMode:c.accessMode,sources:c.sources,argsSchema:c.argsSchema})),null,2)})]})}),e.jsx(S,{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(us(a.outputs??[]),null,2)})]})})]}),e.jsx(S,{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(c=>c.key!=="answer").map(c=>c.key).join(", "),onChange:c=>r({outputs:ps(["answer",...c.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(R,{type:"button",variant:"secondary",className:"mt-4",onClick:()=>{et(b.id),H(!1)},children:[e.jsx(Ke,{className:"size-4"}),"Delete node"]})]})]})}],[X,s,Z,b]),te=x.useCallback(async()=>{const a=he.current,r=Qe.current;if(a===G.current)return B("saved"),!0;if(xe.current)return ge.current=!0,xe.current;B("saving"),pe(null);const c=d(r).then(()=>(G.current=a,Re.current=a,B("saved"),!0)).catch(w=>{const C=w instanceof Ut||w instanceof Error?w.message:String(w);return pe(C),B("error"),!1}).finally(()=>{xe.current=null,ge.current&&he.current!==G.current?(ge.current=!1,te()):ge.current=!1});return xe.current=c,c},[d]);x.useEffect(()=>{if(!Ze)return;const a=window.setTimeout(()=>{te()},2e3);return()=>window.clearTimeout(a)},[Ze,te,ee]);const ae=x.useCallback((a,r="overview")=>{ke(a),ce(r),Ne(r==="contracts"?"contracts":"overview"),H(!0)},[]),ha=x.useMemo(()=>I.map(a=>({...a,data:{...a.data,onEditRequest:()=>ae(a.id,"overview"),onContractEditRequest:()=>ae(a.id,"contracts"),onParameterEditRequest:()=>ae(a.id,"parameters")}})),[I,ae]);function E(a){le&&g(r=>r.map(c=>c.id===le?a(c):c))}function et(a){g(r=>r.filter(c=>c.id!==a)),J(r=>r.filter(c=>c.source!==a&&c.target!==a)),ke(r=>r===a?null:r)}async function tt(){await te()}async function at(a){if(!await te()){L("Forge could not save the latest flow changes before running. Fix the save error and try again.");return}const c=ms(I,_);if(c){L(c);return}if(Je&&s.length===0){L(["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{b5 as v,c2 as j,r as o,j as t}from"./vendor-Dnkkx2co.js";import{j as S,i as N,k as F}from"./state-vCcAT5Hq.js";import{F as C}from"./faceted-token-search-
|
|
1
|
+
import{b5 as v,c2 as j,r as o,j as t}from"./vendor-Dnkkx2co.js";import{j as S,i as N,k as F}from"./state-vCcAT5Hq.js";import{F as C}from"./faceted-token-search-DtO6OUwQ.js";import{P as I}from"./page-hero-DgnhI5es.js";import{fr as Q,B as m,b as W,fs as K,ft as $}from"./index-BP9__l6C.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.js";function R(){var h;const l=v(),p=S(),[f]=j(),g=f.get("surface"),[i,b]=o.useState(""),[c,w]=o.useState([]),x=N({queryKey:["forge-workbench-flows"],queryFn:$}),d=F({mutationFn:e=>Q({title:e==="chat"?"New chat flow":"New flow",description:e==="chat"?"Conversational workbench flow.":"Reusable workbench transformation flow.",kind:e,homeSurfaceId:g}),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:b,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(W,{kind:K(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{R as WorkbenchPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/maps-C-yOWiDN.js","assets/vendor-Dnkkx2co.js","assets/vendor-CRS-psbw.css","assets/maps-B-YMMjus.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{eH as D,S as H,E as B,c as j,C as c,T as E,I as P,B as I,eM as K,eN as W}from"./index-BhkubYaC.js";import{cc as Q,r as h,j as e,aC as O,bk as q,bG as Z,bL as G,dw as X,bX as Y}from"./vendor-Dnkkx2co.js";import{j as U,i as V,k as J}from"./state-vCcAT5Hq.js";import"./maps-C-yOWiDN.js";import{P as ee}from"./page-hero-DzEsy8i5.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-DFnEuIMB.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.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 K(()=>import("./maps-C-yOWiDN.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 ke(){var p,N,b,y,S,L,M,R;const{workoutId:t=""}=Q(),s=U(),o=V({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:()=>D(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(H,{title:"Loading workout"});if(o.isError||!n)return e.jsx(B,{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(G,{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(X,{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:(((N=i.details)==null?void 0:N.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:[[...((b=i.details)==null?void 0:b.events)??[],...((y=i.details)==null?void 0:y.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)+(((R=(M=i.details)==null?void 0:M.components)==null?void 0:R.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(E,{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(I,{type:"button",pending:x.isPending,pendingLabel:"Saving",onClick:()=>x.mutate(),children:[e.jsx(Y,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{ke as WorkoutDetailPage};
|
|
2
|
+
import{eH as D,S as H,E as B,c as j,C as c,T as E,I as P,B as I,eM as K,eN as W}from"./index-BP9__l6C.js";import{cc as Q,r as h,j as e,aC as O,bk as q,bG as Z,bL as G,dw as X,bX as Y}from"./vendor-Dnkkx2co.js";import{j as U,i as V,k as J}from"./state-vCcAT5Hq.js";import"./maps-C-yOWiDN.js";import{P as ee}from"./page-hero-DgnhI5es.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-DFnEuIMB.js";import"./motion-Lt5B1XuE.js";import"./ui-C1iwpj2-.js";import"./forms-hB0SqEh-.js";import"./board-dIX6etHh.js";import"./graph-DDUZNRsO.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 K(()=>import("./maps-C-yOWiDN.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 ke(){var p,N,b,y,S,L,M,R;const{workoutId:t=""}=Q(),s=U(),o=V({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:()=>D(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(H,{title:"Loading workout"});if(o.isError||!n)return e.jsx(B,{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(G,{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(X,{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:(((N=i.details)==null?void 0:N.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:[[...((b=i.details)==null?void 0:b.events)??[],...((y=i.details)==null?void 0:y.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)+(((R=(M=i.details)==null?void 0:M.components)==null?void 0:R.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(E,{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(I,{type:"button",pending:x.isPending,pendingLabel:"Saving",onClick:()=>x.mutate(),children:[e.jsx(Y,{className:"size-4"}),"Save reflection"]})]})]})]})]})}export{ke 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-
|
|
133
|
+
<script type="module" crossorigin src="/forge/assets/index-BP9__l6C.js"></script>
|
|
134
134
|
<link rel="modulepreload" crossorigin href="/forge/assets/vendor-Dnkkx2co.js">
|
|
135
135
|
<link rel="modulepreload" crossorigin href="/forge/assets/state-vCcAT5Hq.js">
|
|
136
136
|
<link rel="modulepreload" crossorigin href="/forge/assets/motion-Lt5B1XuE.js">
|
|
@@ -3105,6 +3105,7 @@ const AGENT_ONBOARDING_CONVERSATION_RULES = [
|
|
|
3105
3105
|
"If the user already answered the normal opening question, do not repeat it. Move to the next missing clarification.",
|
|
3106
3106
|
"Do not over-therapize logistical entities. For tasks, calendar events, work blocks, timeboxes, and task runs, one brief confirming sentence plus one question is usually enough.",
|
|
3107
3107
|
"After each substantive answer, briefly say what is becoming clearer and ask only for the next thing that still changes the record shape or usefulness.",
|
|
3108
|
+
"Use a minimum save-readiness checkpoint before asking another follow-up. For normal batch entities, act when you have accepted wording, meaningful body, and any ownership or placement that changes later use; do not ask for tags, links, priority, dates, assignees, or status just because optional fields exist. For operational records, act when the target action plus the time, object, or state that makes it truthful is clear. For read-model surfaces, read once the practical question and answer-changing scope are clear. For specialized Movement, Life Force, and Workbench writes, act once the lane plus target span/object/weekday/flow/run/node and intended correction or effect are clear.",
|
|
3108
3109
|
"For strategic, reflective, or emotionally meaningful non-Psyche records, ask what feels important to keep true before you ask for labels, dates, or taxonomy.",
|
|
3109
3110
|
"For reflection-sensitive non-Psyche records such as questionnaire_instrument, questionnaire_run, self_observation, reflective note, wiki_page, sleep_session, workout_session, preference_judgment, and preference_signal, first ask what the reflection should help the user understand, decide, notice, remember, or change later; then keep the API posture exact: batch CRUD for normal stored records, questionnaire run actions for answer lifecycle, self-observation calendar reads plus observed-note writes, and wiki routes for wiki pages.",
|
|
3110
3111
|
"For reusable records such as tags, event types, emotion definitions, preference contexts, or questionnaires, ask what distinction or decision the record should help with before you ask for wording.",
|
|
@@ -3124,6 +3125,7 @@ const AGENT_ONBOARDING_CONVERSATION_RULES = [
|
|
|
3124
3125
|
"Do not minimize functional analysis, trigger chains, behavior patterns, modes, beliefs, or schema themes. After at least one concrete example is clear, offer one careful interpretive hypothesis when it would help the user understand what the reaction may be protecting, predicting, relieving, or costing.",
|
|
3125
3126
|
"Phrase Psyche interpretive hypotheses as collaborative and testable, not as verdicts. Ask whether the hypothesis lands or needs correction before turning it into a saved belief, pattern, mode, trigger report, or note.",
|
|
3126
3127
|
"A useful Psyche hypothesis starts from the user's concrete example, names one possible protection, prediction, relief, or cost, and asks for correction before it becomes a saved record shape.",
|
|
3128
|
+
"For Psyche save-readiness, stop deepening once the user recognizes the working formulation and the minimum shape is present: belief sentence, functional loop, behavior move, part-state, trigger episode, value, event type, emotion definition, or flashcard cue/message. Ask one accuracy question at most, then save through shared batch CRUD when the user says yes.",
|
|
3127
3129
|
"Once the Movement, Life Force, or Workbench job is clear, speak in product nouns such as timeline, overlay, weekday template, published output, run detail, or node result instead of generic record language.",
|
|
3128
3130
|
"If the next answer would not change the route, wording, timing, or write shape in a meaningful way, stop asking and act.",
|
|
3129
3131
|
"Before saving, briefly summarize the working formulation in the user's own language when that would reduce ambiguity.",
|