forge-openclaw-plugin 0.2.101 → 0.2.103
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-Dv6X5ZCV.js +1 -0
- package/dist/assets/ai-surface-workspace-CutiG6uS.js +1 -0
- package/dist/assets/atlas-panel-jgMRyaHn.js +1 -0
- package/dist/assets/{board-BkDRaMp6.js → board-dIX6etHh.js} +1 -1
- package/dist/assets/calendar-page-q7Nm5E2U.js +1 -0
- package/dist/assets/calendar-rules-DPFsfiRl.js +1 -0
- package/dist/assets/calendar-week-toolbar-nVhgB-0s.js +1 -0
- package/dist/assets/{charts-P7EVhIog.js → charts-DFnEuIMB.js} +8 -8
- package/dist/assets/companion-sync-lab-page-CJ8UTij8.js +1 -0
- package/dist/assets/daily-metrics-dashboard-CiJkkkd1.js +1 -0
- package/dist/assets/entity-note-count-link-RzBB6ujx.js +1 -0
- package/dist/assets/entity-notes-surface-Djz50HvD.js +1 -0
- package/dist/assets/execution-board-CtPhI-58.js +1 -0
- package/dist/assets/faceted-token-search-DEC6ANa9.js +1 -0
- package/dist/assets/flagship-signal-deck-CtHC3mql.js +1 -0
- package/dist/assets/floating-action-menu-CKQRhff9.js +1 -0
- package/dist/assets/{forms-BFlTgZ3W.js → forms-hB0SqEh-.js} +1 -1
- package/dist/assets/goal-detail-page-CF5fNQeR.js +1 -0
- package/dist/assets/goals-page-fsY8NzGB.js +1 -0
- package/dist/assets/{graph-D6JLqDbD.js → graph-DDUZNRsO.js} +14 -14
- package/dist/assets/habits-page-COoGz4kj.js +1 -0
- package/dist/assets/index-BAXYM89v.css +1 -0
- package/dist/assets/index-EqQsXoat.js +19 -0
- package/dist/assets/insight-flow-dialog-DtX_5W7g.js +1 -0
- package/dist/assets/insights-page-cBd74ObU.js +8 -0
- package/dist/assets/kanban-page-CYav9THw.js +1 -0
- package/dist/assets/knowledge-graph-page-D2A-W1jE.js +1 -0
- package/dist/assets/{life-force-page-Dy0JTS2G.js → life-force-page-CACGlNhq.js} +1 -1
- package/dist/assets/life-force-workspace-BJ4N1I78.js +1 -0
- package/dist/assets/{maps-ClgJoCjz.js → maps-C-yOWiDN.js} +1 -1
- package/dist/assets/metric-tile-CMadwnGz.js +1 -0
- package/dist/assets/{motion-BeD44FeG.js → motion-Lt5B1XuE.js} +1 -1
- package/dist/assets/movement-page-D5VqFd2q.js +1 -0
- package/dist/assets/note-markdown-BzK2Qlgr.js +3 -0
- package/dist/assets/note-tags-input-CZzqJMLc.js +1 -0
- package/dist/assets/notes-page-D3Hsh90C.js +1 -0
- package/dist/assets/{open-in-graph-button-IXe9SGth.js → open-in-graph-button-BFPKfyK3.js} +1 -1
- package/dist/assets/orbit-map-CnyfSmOG.js +1 -0
- package/dist/assets/overview-page-CXdWrOV1.js +1 -0
- package/dist/assets/page-hero-ffKzgyW3.js +1 -0
- package/dist/assets/pill-cluster-C2D0h3lx.js +1 -0
- package/dist/assets/{preference-entity-handoff-button-5PzUn42S.js → preference-entity-handoff-button-Dj3V6VxL.js} +1 -1
- package/dist/assets/preferences-page-Jo8Gw386.js +1 -0
- package/dist/assets/project-collections-qSqp90HN.js +1 -0
- package/dist/assets/{project-detail-page-BXK5-4xW.js → project-detail-page-BifhiLQX.js} +1 -1
- package/dist/assets/project-management-hierarchy-page-DZ_9klIc.js +1 -0
- package/dist/assets/project-management-section-nav-BImLCVvf.js +1 -0
- package/dist/assets/projects-page-ptcx6H38.js +1 -0
- package/dist/assets/psyche-behaviors-page-BDwXyDta.js +5 -0
- package/dist/assets/psyche-flashcards-page-DL1BP1jX.js +1 -0
- package/dist/assets/psyche-goal-map-page-ovcpisx1.js +1 -0
- package/dist/assets/psyche-graph-EP5GL612.js +1 -0
- package/dist/assets/{psyche-metrics-page-CuR9oqEy.js → psyche-metrics-page-Bcu813Rg.js} +1 -1
- package/dist/assets/psyche-mode-guide-page-C0g27Xpt.js +1 -0
- package/dist/assets/psyche-modes-page-BjKjX5MR.js +1 -0
- package/dist/assets/psyche-page-F4tF2W70.js +1 -0
- package/dist/assets/psyche-patterns-page-B-14hukK.js +5 -0
- package/dist/assets/psyche-questionnaire-builder-page-BdXmoHvK.js +1 -0
- package/dist/assets/psyche-questionnaire-detail-page-Cu5uwlJu.js +1 -0
- package/dist/assets/psyche-questionnaire-run-detail-page-C3R4PClg.js +1 -0
- package/dist/assets/psyche-questionnaire-run-page-Div3iDdt.js +1 -0
- package/dist/assets/psyche-questionnaires-page-DpqAPQCp.js +1 -0
- package/dist/assets/psyche-report-detail-page-BvWVDKP3.js +3 -0
- package/dist/assets/psyche-reports-page-BrbWUlAq.js +1 -0
- package/dist/assets/{psyche-schemas-HFmg37Wj.js → psyche-schemas-Dxj554nU.js} +1 -1
- package/dist/assets/psyche-schemas-beliefs-page-DYKvAtSD.js +9 -0
- package/dist/assets/psyche-screen-time-page-CAOKCyQw.js +1 -0
- package/dist/assets/psyche-self-observation-page-F0MVA0UH.js +1 -0
- package/dist/assets/psyche-values-page-DyvX-d0o.js +5 -0
- package/dist/assets/report-chain-fields-CeC1cJFS.js +1 -0
- package/dist/assets/rewards-page-C2loyODo.js +1 -0
- package/dist/assets/scheduling-rules-editor-D40AC2jR.js +1 -0
- package/dist/assets/schema-badge-FY7818qB.js +1 -0
- package/dist/assets/schema-visuals-CvC9a3i6.js +1 -0
- package/dist/assets/select-menu-DJsCG6rM.js +1 -0
- package/dist/assets/settings-agents-page-BFkJ5AAD.js +6 -0
- package/dist/assets/settings-bin-page-D3-Ab-iA.js +1 -0
- package/dist/assets/settings-calendar-page-ly_mSTAD.js +5 -0
- package/dist/assets/settings-data-page-D7QOqNf-.js +1 -0
- package/dist/assets/settings-logs-page-Ca87HEUx.js +1 -0
- package/dist/assets/settings-mobile-page-D0jejZot.js +1 -0
- package/dist/assets/settings-models-page-DPDsZjSc.js +1 -0
- package/dist/assets/settings-page-1cArlSPM.js +1 -0
- package/dist/assets/settings-rewards-page-Db4BV1DC.js +1 -0
- package/dist/assets/{settings-section-nav-DSOuht_F.js → settings-section-nav-DP9o4peU.js} +1 -1
- package/dist/assets/settings-users-page-BHFyDSsd.js +1 -0
- package/dist/assets/settings-wiki-page-BNaiupBm.js +1 -0
- package/dist/assets/sleep-page-BmOPF0yD.js +1 -0
- package/dist/assets/sports-page-BldIiclr.js +1 -0
- package/dist/assets/{state-B-4sS1xO.js → state-vCcAT5Hq.js} +1 -1
- package/dist/assets/strategies-page-CaTN99qj.js +1 -0
- package/dist/assets/strategy-detail-page-DsgFTd-U.js +1 -0
- package/dist/assets/strategy-dialog-7X7peRzu.js +1 -0
- package/dist/assets/surface-CJI17F3n.js +1 -0
- package/dist/assets/{table-WfAPUppN.js → table-BNqMG3_S.js} +1 -1
- package/dist/assets/task-detail-page-M1sIIPA8.js +1 -0
- package/dist/assets/timebox-planning-dialog-ByojN0AN.js +1 -0
- package/dist/assets/today-page-BjDijtn8.js +1 -0
- package/dist/assets/training-load-page-BPRmaWmF.js +1 -0
- package/dist/assets/{ui-C13Nbgas.js → ui-C1iwpj2-.js} +4 -4
- package/dist/assets/use-psyche-focus-target-Ct-acS9G.js +1 -0
- package/dist/assets/vendor-Dnkkx2co.js +1067 -0
- package/dist/assets/{vitals-page-qre17Nw8.js → vitals-page-CE9zdGLF.js} +1 -1
- package/dist/assets/weekly-review-page-CzhTv90n.js +1 -0
- package/dist/assets/weight-loss-page-Bp_cIk78.js +5 -0
- package/dist/assets/wiki-article-markdown-Dok2uy2p.js +4 -0
- package/dist/assets/wiki-editor-page-BuW32Y3f.js +26 -0
- package/dist/assets/wiki-ingest-history-page-DZKSBNHV.js +1 -0
- package/dist/assets/wiki-ingest-modal-DyqBEZcC.js +1 -0
- package/dist/assets/wiki-page-DqxlbLKG.js +1 -0
- package/dist/assets/workbench-flow-page-C4nc9jUg.js +5 -0
- package/dist/assets/workbench-page-BnyR7SL0.js +1 -0
- package/dist/assets/workout-detail-page-DT-c5cHL.js +2 -0
- package/dist/index.html +9 -9
- package/dist/openclaw/local-runtime.js +41 -14
- package/dist/server/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/dist/server/server/src/app.js +125 -33
- package/dist/server/server/src/health-weight-loss.js +554 -77
- package/dist/server/server/src/health.js +12 -4
- package/dist/server/server/src/movement.js +84 -1
- package/dist/server/server/src/openapi.js +123 -18
- package/dist/server/server/src/repositories/model-settings.js +21 -12
- package/dist/server/server/src/repositories/settings.js +19 -5
- package/dist/server/src/components/ui/info-tooltip.js +6 -6
- package/dist/server/src/components/workbench-boxes/shared/generic-node-view.js +13 -5
- package/dist/server/src/lib/api.js +24 -5
- package/dist/server/src/lib/theme-system.js +8 -0
- package/openclaw.plugin.json +1 -1
- package/package.json +3 -3
- package/server/migrations/067_weight_loss_daily_active_overrides.sql +13 -0
- package/skills/forge-openclaw/SKILL.md +13 -0
- package/skills/forge-openclaw/entity_conversation_playbooks.md +7 -1
- package/dist/assets/activity-page-CpjuNSHw.js +0 -1
- package/dist/assets/ai-surface-workspace-DEAFZruS.js +0 -1
- package/dist/assets/atlas-panel-CdVNPotj.js +0 -1
- package/dist/assets/calendar-page-DNNt6lfz.js +0 -1
- package/dist/assets/calendar-rules-DNJFNsxi.js +0 -1
- package/dist/assets/calendar-week-toolbar-BbPwYeN0.js +0 -1
- package/dist/assets/companion-sync-lab-page-KxEDigM6.js +0 -1
- package/dist/assets/daily-metrics-dashboard-B3cqJgDt.js +0 -1
- package/dist/assets/entity-note-count-link-DrhjJZ4i.js +0 -1
- package/dist/assets/entity-notes-surface-CkcRsKJQ.js +0 -1
- package/dist/assets/execution-board-D07gOocB.js +0 -1
- package/dist/assets/faceted-token-search-BxRRcM3q.js +0 -1
- package/dist/assets/flagship-signal-deck-cmy82b8_.js +0 -1
- package/dist/assets/floating-action-menu-Fs_ZiUMo.js +0 -1
- package/dist/assets/goal-detail-page-CqLiNz4f.js +0 -1
- package/dist/assets/goals-page-BTk7mg_T.js +0 -1
- package/dist/assets/habits-page-BJxagdzx.js +0 -1
- package/dist/assets/index-CF4J4R9L.js +0 -19
- package/dist/assets/index-CZbuZQjw.css +0 -1
- package/dist/assets/insight-flow-dialog-8f3D0GuC.js +0 -1
- package/dist/assets/insights-page-D6rOa7uk.js +0 -8
- package/dist/assets/kanban-page-XQ7Se6dH.js +0 -1
- package/dist/assets/knowledge-graph-page-BtAg8iv3.js +0 -1
- package/dist/assets/life-force-workspace-OfyB9HJM.js +0 -1
- package/dist/assets/metric-tile-DKpo-8xw.js +0 -1
- package/dist/assets/movement-page-Bg_T_Stx.js +0 -1
- package/dist/assets/note-markdown-N-uxD3Xt.js +0 -3
- package/dist/assets/note-tags-input-Cdu7wiw6.js +0 -1
- package/dist/assets/notes-page-CKXnF_KU.js +0 -1
- package/dist/assets/orbit-map-Dzi6KliQ.js +0 -1
- package/dist/assets/overview-page-1miYqaVS.js +0 -1
- package/dist/assets/page-hero-DRy5b2MU.js +0 -1
- package/dist/assets/pill-cluster-C9QczVJ2.js +0 -1
- package/dist/assets/preferences-page-DtNaF5Q3.js +0 -1
- package/dist/assets/project-collections-xPz2mlRr.js +0 -1
- package/dist/assets/project-management-hierarchy-page-DtRpMABw.js +0 -1
- package/dist/assets/project-management-section-nav-P3ixzPa-.js +0 -1
- package/dist/assets/projects-page-C5ViRuf4.js +0 -1
- package/dist/assets/psyche-behaviors-page-Dco46sC4.js +0 -5
- package/dist/assets/psyche-flashcards-page-ZcoEB8gV.js +0 -1
- package/dist/assets/psyche-goal-map-page-CLBAQOI0.js +0 -1
- package/dist/assets/psyche-graph-k4tX2tdp.js +0 -1
- package/dist/assets/psyche-mode-guide-page-hIVXcCnE.js +0 -1
- package/dist/assets/psyche-modes-page-0lYtBlhO.js +0 -1
- package/dist/assets/psyche-page-VZ9k9ISp.js +0 -1
- package/dist/assets/psyche-patterns-page-gx5nmdGq.js +0 -5
- package/dist/assets/psyche-questionnaire-builder-page-Bn0TOISd.js +0 -1
- package/dist/assets/psyche-questionnaire-detail-page-CmVzSd_s.js +0 -1
- package/dist/assets/psyche-questionnaire-run-detail-page-BsMbmXCG.js +0 -1
- package/dist/assets/psyche-questionnaire-run-page-CgkRL2vi.js +0 -1
- package/dist/assets/psyche-questionnaires-page-D7V8uLXM.js +0 -1
- package/dist/assets/psyche-report-detail-page-OlFq57eL.js +0 -3
- package/dist/assets/psyche-reports-page-dVUZjna1.js +0 -1
- package/dist/assets/psyche-schemas-beliefs-page-BCgc8FUd.js +0 -9
- package/dist/assets/psyche-screen-time-page-B_6BT_WN.js +0 -1
- package/dist/assets/psyche-self-observation-page-CEG5mluK.js +0 -1
- package/dist/assets/psyche-values-page-DRbRfEd6.js +0 -5
- package/dist/assets/report-chain-fields-CALCV3V5.js +0 -1
- package/dist/assets/rewards-page-DmC4R_Ps.js +0 -1
- package/dist/assets/scheduling-rules-editor-D02s70hr.js +0 -1
- package/dist/assets/schema-badge-BZO-qNhO.js +0 -1
- package/dist/assets/schema-visuals-D6nxjbYC.js +0 -1
- package/dist/assets/select-menu-fYyreSdQ.js +0 -1
- package/dist/assets/settings-agents-page-C_v_hMJF.js +0 -6
- package/dist/assets/settings-bin-page-DY5bg81n.js +0 -1
- package/dist/assets/settings-calendar-page-D1CzE6cg.js +0 -5
- package/dist/assets/settings-data-page-CHRQFU9H.js +0 -1
- package/dist/assets/settings-logs-page-B04pUwEv.js +0 -1
- package/dist/assets/settings-mobile-page-D9kTlYDS.js +0 -1
- package/dist/assets/settings-models-page-D26270R2.js +0 -1
- package/dist/assets/settings-page-DYDTFlnv.js +0 -1
- package/dist/assets/settings-rewards-page-cl4vqqO_.js +0 -1
- package/dist/assets/settings-users-page-BU79JB_T.js +0 -1
- package/dist/assets/settings-wiki-page-DwAUlyA3.js +0 -1
- package/dist/assets/sleep-page-D8NbdhyS.js +0 -1
- package/dist/assets/sports-page-CV4Cnzwn.js +0 -1
- package/dist/assets/strategies-page-C4qvXnql.js +0 -1
- package/dist/assets/strategy-detail-page-DJLo5rfy.js +0 -1
- package/dist/assets/strategy-dialog-D3AuUlVz.js +0 -1
- package/dist/assets/task-detail-page-z-9u9rF0.js +0 -1
- package/dist/assets/timebox-planning-dialog-DB6FLqmI.js +0 -1
- package/dist/assets/today-page-BKlu6gx5.js +0 -1
- package/dist/assets/training-load-page-CyJQqo_3.js +0 -1
- package/dist/assets/use-psyche-focus-target-C1C_XjYG.js +0 -1
- package/dist/assets/vendor-DHkYh85p.js +0 -1052
- package/dist/assets/weekly-review-page-Cz4vkRcx.js +0 -1
- package/dist/assets/weight-loss-page-BQrnOI0y.js +0 -1
- package/dist/assets/wiki-article-markdown-DdiR2TJE.js +0 -4
- package/dist/assets/wiki-editor-page-DqwoqVFb.js +0 -26
- package/dist/assets/wiki-ingest-history-page--evBLbOw.js +0 -1
- package/dist/assets/wiki-ingest-modal--ohzFnj2.js +0 -1
- package/dist/assets/wiki-page-B_VJFBPA.js +0 -1
- package/dist/assets/workbench-flow-page-Du62mtJU.js +0 -5
- package/dist/assets/workbench-page-4MKr3iRm.js +0 -1
- package/dist/assets/workout-detail-page-DfUbYYw1.js +0 -2
|
@@ -0,0 +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-EqQsXoat.js";import{O as Xe}from"./open-in-graph-button-BFPKfyK3.js";import{W as Ze}from"./wiki-article-markdown-Dok2uy2p.js";import{W as es}from"./wiki-ingest-modal-DyqBEZcC.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
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-BFPKfyK3.js";import{P as Ca}from"./page-hero-ffKzgyW3.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-EqQsXoat.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-DEC6ANa9.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
|
+
|
|
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
|
+
|
|
5
|
+
`));return}L(null);const w={};for(const C of k){const N=qe[C.key];if(!ss(C,N)){L(`Flow input "${C.label}" must match the ${C.kind} type.`);return}N!=null&&!(typeof N=="string"&&N.trim().length===0)&&(w[C.key]=N)}try{a==="run"?await p({userInput:Oe?Ie:"",inputs:w,debug:Te}):await o({userInput:Oe?Ie:"",inputs:w,debug:Te}),ue(!1)}catch(C){L(cs(C))}}return e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsxs(ba,{to:"/workbench",className:"inline-flex h-9 items-center gap-2 rounded-full bg-[var(--ui-surface-1)] px-3 text-sm text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",children:[e.jsx(va,{className:"size-4"}),"Flows"]}),e.jsxs("div",{className:"min-w-0",children:[e.jsx(St,{kind:"workbench",label:"Workbench Flow",compact:!0,gradient:!1}),e.jsx("div",{className:"truncate font-display text-[1.55rem] tracking-[-0.05em] text-[var(--ui-ink-strong)]",children:l})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(St,{kind:Ra(j),label:j==="chat"?"Chat flow":"Functor flow",compact:!0,gradient:!1}),e.jsx("div",{className:O("rounded-full border px-3 py-2 text-[12px]",Ts(Fe)),children:ls(Fe,ca)}),Y?e.jsxs("button",{type:"button",className:"rounded-full bg-[var(--ui-surface-1)] px-3 py-2 text-[12px] text-[var(--ui-ink-soft)] transition hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]",onClick:()=>Ce(!0),children:["Latest ",Y.mode," · ",Y.status]}):null,e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>ue(!0),children:[e.jsx(Me,{className:"size-4"}),"Run"]}),e.jsxs(R,{type:"button",variant:"primary",pending:Fe==="saving",pendingLabel:"Saving…",onClick:()=>void tt(),children:[e.jsx(Bt,{className:"size-4"}),"Save now"]})]})]}),e.jsxs("div",{className:"relative h-[76vh] overflow-hidden rounded-[32px] border border-[var(--ui-border-subtle)] bg-[image:var(--ui-surface-section)]",children:[Ee.length>0?e.jsxs("div",{className:"pointer-events-none absolute left-4 top-4 z-20 max-w-[32rem] rounded-[24px] border border-[color-mix(in_srgb,var(--warning)_28%,transparent)] bg-[color-mix(in_srgb,var(--ui-warning-soft)_82%,var(--surface-glass))] p-4 shadow-[var(--ui-shadow-floating)] backdrop-blur-xl",children:[e.jsxs("div",{className:"pointer-events-auto flex items-center gap-2 text-[11px] uppercase tracking-[0.18em] text-[var(--warning)]",children:[e.jsx("span",{children:"Graph checks"}),e.jsx(D,{content:"These are preflight issues Forge found in the current graph before runtime. Fixing them here should prevent brittle run failures later.",label:"Explain graph checks"})]}),e.jsx("ul",{className:"mt-3 grid gap-2 text-sm leading-6 text-[var(--ui-ink-strong)]",children:Ee.map(a=>e.jsx("li",{className:"list-inside list-disc",children:a},a))})]}):null,e.jsx(Ua,{nodeTypes:Is,nodes:ha,edges:_,onNodesChange:a=>g(r=>Ga(a,r)),onEdgesChange:a=>J(r=>Va(a,r)),onConnect:a=>J(r=>Da({...a,id:`edge_${crypto.randomUUID().replaceAll("-","").slice(0,8)}`,style:{stroke:"color-mix(in srgb, var(--primary) 44%, transparent)",strokeWidth:1.6}},r)),onEdgeClick:(a,r)=>{J(c=>c.filter(w=>w.id!==r.id))},onNodeClick:(a,r)=>{ke(r.id)},onNodeDoubleClick:(a,r)=>{ae(r.id,"overview")},fitView:!0,proOptions:{hideAttribution:!0},className:"bg-transparent",children:e.jsx(qa,{color:"var(--ui-border-subtle)",gap:28})}),e.jsx("div",{className:"pointer-events-none absolute right-4 bottom-4 z-20 flex flex-col gap-2",children:e.jsxs("div",{className:"pointer-events-auto flex flex-col items-end gap-2",children:[e.jsxs("button",{type:"button",className:ve,onClick:()=>oe(!0),children:[e.jsx(fa,{className:"size-4"}),"Add node"]}),e.jsxs("button",{type:"button",className:ve,onClick:()=>Ue(!0),children:[e.jsx(ya,{className:"size-4"}),"Flow settings"]}),e.jsxs("button",{type:"button",className:ve,onClick:()=>ue(!0),children:[e.jsx(Me,{className:"size-4"}),"Run flow"]}),Y?e.jsxs("button",{type:"button",className:ve,onClick:()=>Ce(!0),children:[e.jsx(ja,{className:"size-4"}),"Latest trace"]}):null]})})]}),e.jsx(ks,{open:ta,onOpenChange:oe,boxQuery:Se,onBoxQueryChange:na,boxOptions:ua,boxFilters:_e,onBoxFiltersChange:ia,filteredBoxes:pa,onAddNodeType:a=>{g(r=>[...r,Tt(a,r)]),oe(!1)},onAddBox:a=>{g(r=>[...r,Tt("box",r,a)]),oe(!1)}}),b&&ne(b.data.nodeType)?e.jsx(Ea,{open:Be,onOpenChange:a=>{H(a),a||Ne(void 0)},eyebrow:`Workbench · ${b.data.nodeType==="chat"?"Chat node":"Functor node"}`,title:b.data.label??"Edit node",description:"Configure this AI node with the same paged editor Forge uses elsewhere.",value:b.data,onChange:a=>E(r=>({...r,data:a})),draftPersistenceKey:`workbench.ai-node.${b.id}`,steps:ma,initialStepId:aa,onSubmit:async()=>{H(!1),Ne(void 0)},submitLabel:"Done",contentClassName:"md:w-[min(60rem,calc(100vw-1.5rem))]"}):e.jsx(ie,{open:Be,onOpenChange:a=>{H(a),a||ce("overview")},title:(b==null?void 0:b.data.label)??"Edit node",description:"Edit the selected node without covering the graph with permanent forms.",children:b?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("div",{className:"flex flex-wrap gap-2 rounded-full bg-[var(--ui-surface-1)] p-1",children:[{id:"overview",label:"Overview"},{id:"contracts",label:"Contracts"},{id:"parameters",label:"Parameters"}].filter(a=>a.id!=="contracts"||Ye).filter(a=>{var r;return a.id!=="parameters"||(((r=b.data.params)==null?void 0:r.length)??0)>0}).map(a=>e.jsx("button",{type:"button",className:O("rounded-full px-3 py-2 text-sm transition",de===a.id?"bg-[var(--ui-accent-soft)] text-[var(--ui-ink-strong)]":"text-[var(--ui-ink-soft)] hover:bg-[var(--ui-surface-hover)] hover:text-[var(--ui-ink-strong)]"),onClick:()=>ce(a.id),children:a.label},a.id))}),de==="overview"?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("input",{value:b.data.label,onChange:a=>E(r=>({...r,data:{...r.data,label:a.target.value}})),className:y}),e.jsx("textarea",{rows:3,value:b.data.description,onChange:a=>E(r=>({...r,data:{...r.data,description:a.target.value}})),className:y}),b.data.nodeType==="box"||b.data.nodeType==="box_input"?e.jsxs("select",{value:b.data.boxId??"",onChange:a=>{const r=i.find(c=>c.id===a.target.value);E(c=>({...c,data:{...c.data,boxId:a.target.value,label:(r==null?void 0:r.title)??c.data.label,description:(r==null?void 0:r.description)??c.data.description,inputs:(r==null?void 0:r.inputs)??[],outputs:(r==null?void 0:r.output)??[],params:(r==null?void 0:r.params)??[],enabledToolKeys:((r==null?void 0:r.tools)??[]).map(w=>w.key)}}))},className:y,children:[e.jsx("option",{value:"",children:"Select Forge box"}),i.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]}):null,b.data.nodeType==="template"?e.jsx("textarea",{rows:4,value:b.data.template??"",onChange:a=>E(r=>({...r,data:{...r.data,template:a.target.value}})),placeholder:"Template string",className:y}):null,b.data.nodeType==="pick_key"?e.jsx("input",{value:b.data.selectedKey??"",onChange:a=>E(r=>({...r,data:{...r.data,selectedKey:a.target.value}})),placeholder:"Key to select from object input",className:y}):null,b.data.nodeType==="output"?e.jsxs("div",{className:"grid gap-3",children:[e.jsx("select",{value:b.data.outputKey??"answer",onChange:a=>E(r=>({...r,data:{...r.data,outputKey:a.target.value}})),className:y,children:Xe.length>0?Xe.map(a=>e.jsxs("option",{value:a.key,children:[a.label," (",a.key,")"]},a.key)):e.jsx("option",{value:b.data.outputKey??"answer",children:b.data.outputKey??"answer"})}),e.jsx("div",{className:"rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-3 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"Publish one upstream output as the flow result. If the output key is missing from the graph, Forge will flag it in graph checks."})]}):null,b.data.nodeType==="value"?e.jsxs(e.Fragment,{children:[e.jsx("select",{value:b.data.valueType??"string",onChange:a=>E(r=>({...r,data:{...r.data,valueType:a.target.value}})),className:y,children:["string","number","boolean","null","array","object"].map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsx("textarea",{rows:4,value:b.data.valueLiteral??"",onChange:a=>E(r=>({...r,data:{...r.data,valueLiteral:a.target.value}})),placeholder:"Value literal or JSON",className:y})]}):null]}):null,de==="contracts"?Ye?e.jsxs("div",{className:"grid gap-4",children:[e.jsx(be,{title:"Inputs",description:"Name the values this node expects so upstream wiring stays obvious.",ports:b.data.inputs??[],onChange:a=>E(r=>({...r,data:{...r.data,inputs:a}})),prefix:"input"}),e.jsx(be,{title:"Outputs",description:"Describe exactly what this node publishes, including semantic model names.",ports:b.data.outputs??[],onChange:a=>E(r=>({...r,data:{...r.data,outputs:a}})),prefix:"output"})]}):e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This node inherits its contract from the registered Forge box. Edit the box definition in the registry when the contract itself needs to change."}):null,de==="parameters"?e.jsxs("div",{className:"grid gap-3",children:[(b.data.params??[]).length===0?e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-4 py-4 text-sm leading-6 text-[var(--ui-ink-soft)]",children:"This node does not expose any configurable parameters."}):null,(b.data.params??[]).map(a=>{var r,c,w;return e.jsxs("div",{className:"grid gap-2",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-[0.18em] text-[var(--ui-ink-faint)]",children:a.label}),a.kind==="boolean"?e.jsxs("label",{className:"flex items-center gap-3 rounded-[18px] border border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] px-4 py-3 text-sm text-[var(--ui-ink-strong)]",children:[e.jsx("input",{type:"checkbox",checked:!!((r=b.data.paramValues)!=null&&r[a.key]),onChange:C=>E(N=>({...N,data:{...N.data,paramValues:{...N.data.paramValues??{},[a.key]:C.target.checked}}}))}),a.description??"Enabled"]}):a.kind==="array"||a.kind==="json"?e.jsx("textarea",{value:fe((c=b.data.paramValues)==null?void 0:c[a.key]),onChange:C=>E(N=>({...N,data:{...N.data,paramValues:{...N.data.paramValues??{},[a.key]:C.target.value}}})),placeholder:a.description??a.label,className:O(y,"min-h-[104px] resize-y")}):e.jsx("input",{type:a.kind==="number"?"number":"text",value:fe((w=b.data.paramValues)==null?void 0:w[a.key]),onChange:C=>E(N=>({...N,data:{...N.data,paramValues:{...N.data.paramValues??{},[a.key]:qt(a.kind,C.target.value)}}})),placeholder:a.description??a.label,className:y})]},a.key)})]}):null,e.jsxs("div",{className:"flex flex-wrap justify-between gap-2 pt-2",children:[e.jsxs(R,{type:"button",variant:"secondary",onClick:()=>{et(b.id),H(!1)},children:[e.jsx(Ke,{className:"size-4"}),"Delete node"]}),e.jsx(R,{type:"button",variant:"primary",onClick:()=>{H(!1),ce("overview")},children:"Done"})]})]}):null}),e.jsx(Ns,{open:ra,onOpenChange:Ue,title:l,onTitleChange:h,description:m,onDescriptionChange:v,kind:j,onKindChange:f,publicInputs:k,onPublicInputsChange:F,nodes:I,flowId:t.id,onDelete:u,onSave:tt}),e.jsx(Cs,{open:sa,onOpenChange:a=>{ue(a),a&&L(null)},runError:da,graphIssues:Ee,hasAiNodes:Je,modelConnectionCount:s.length,publicInputs:k,runInputs:qe,onRunInputChange:(a,r)=>De(c=>({...c,[a]:r})),shouldShowLegacyUserInput:Oe,userInput:Ie,onUserInputChange:la,debugEnabled:Te,onDebugEnabledChange:oa,onRun:()=>void at("run"),onChat:()=>void at("chat"),runs:n}),e.jsx(ie,{open:we,onOpenChange:Ce,title:"Run inspector",description:"Inspect whole-flow outputs and stable node-level results for any saved run.",children:U?e.jsx("div",{className:"grid gap-4",children:e.jsxs("div",{className:"grid gap-3 md:grid-cols-[0.9fr_1.1fr]",children:[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:"Run history"}),e.jsx("div",{className:"mt-3 grid gap-2",children:n.slice(0,12).map(a=>{var r;return e.jsxs("button",{type:"button",className:O("rounded-[18px] border px-4 py-3 text-left transition",V===a.id?"border-[var(--secondary)]/40 bg-[var(--secondary)]/12":"border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>Ve(a.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 text-[12px] text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:a.mode}),e.jsx("span",{children:new Date(a.createdAt).toLocaleString()})]}),e.jsx("div",{className:"mt-2 text-sm text-[var(--ui-ink-medium)]",children:((r=a.result)==null?void 0:r.primaryText)??a.error??"No output yet."})]},a.id)})})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 text-[12px] text-[var(--ui-ink-soft)]",children:[e.jsx("span",{children:U.mode}),e.jsx("span",{children:new Date(U.createdAt).toLocaleString()})]}),e.jsx("div",{className:"mt-3 text-sm leading-6 text-[var(--ui-ink-medium)]",children:((it=U.result)==null?void 0:it.primaryText)??U.error??"No output yet."}),(lt=U.result)!=null&<.outputs?e.jsxs("details",{className:"mt-3 rounded-[16px] bg-[var(--ui-code-bg)] p-3",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Published outputs"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[12px] leading-5 text-[var(--ui-code-text)]",children:JSON.stringify(U.result.outputs,null,2)})]}):null]}),(((ot=Q.data)==null?void 0:ot.nodeResults)??[]).length>0?e.jsxs("div",{className:"grid gap-3 xl:grid-cols-[0.9fr_1.1fr]",children:[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:"Node results"}),e.jsx("div",{className:"mt-3 grid gap-2",children:(((dt=Q.data)==null?void 0:dt.nodeResults)??[]).map(a=>e.jsx("button",{type:"button",className:O("rounded-[18px] border px-4 py-3 text-left transition",me===a.nodeId?"border-[var(--secondary)]/40 bg-[var(--secondary)]/12":"border-[var(--ui-border-subtle)] bg-[var(--ui-code-bg)] hover:border-[var(--ui-border-strong)] hover:bg-[var(--ui-surface-hover)]"),onClick:()=>Ge(a.nodeId),children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[var(--ui-ink-strong)]",children:a.label}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:a.nodeType})]}),e.jsxs("div",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1 text-[11px] text-[var(--ui-ink-soft)]",children:[Object.keys(a.outputMap).length," outputs"]})]})},a.nodeId))})]}),e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4",children:A||(ct=K.data)!=null&&ct.nodeResult?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium text-[var(--ui-ink-strong)]",children:(pt=((ut=K.data)==null?void 0:ut.nodeResult)??A)==null?void 0:pt.label}),e.jsx("div",{className:"text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:(ht=((mt=K.data)==null?void 0:mt.nodeResult)??A)==null?void 0:ht.nodeType})]}),e.jsxs("div",{className:"rounded-full border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] px-3 py-1 text-[11px] text-[var(--ui-ink-soft)]",children:[(((gt=((xt=K.data)==null?void 0:xt.nodeResult)??A)==null?void 0:gt.tools)??[]).length," ","tool",(((vt=((bt=K.data)==null?void 0:bt.nodeResult)??A)==null?void 0:vt.tools)??[]).length===1?"":"s"]})]}),e.jsxs("div",{className:"mt-3 grid gap-3",children:[e.jsxs("details",{className:"rounded-[16px] bg-[var(--ui-code-bg)] p-3",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Inputs"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[12px] leading-5 text-[var(--ui-code-text)]",children:JSON.stringify(((yt=((ft=K.data)==null?void 0:ft.nodeResult)??A)==null?void 0:yt.input)??[],null,2)})]}),e.jsxs("details",{className:"rounded-[16px] bg-[var(--ui-code-bg)] p-3",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Output map"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[12px] leading-5 text-[var(--ui-code-text)]",children:JSON.stringify(((kt=((jt=K.data)==null?void 0:jt.nodeResult)??A)==null?void 0:kt.outputMap)??{},null,2)})]}),e.jsxs("details",{className:"rounded-[16px] bg-[var(--ui-code-bg)] p-3",children:[e.jsx("summary",{className:"cursor-pointer text-[11px] uppercase tracking-[0.16em] text-[var(--ui-ink-faint)]",children:"Payload"}),e.jsx("pre",{className:"mt-3 overflow-auto whitespace-pre-wrap text-[12px] leading-5 text-[var(--ui-code-text)]",children:JSON.stringify(((wt=((Nt=K.data)==null?void 0:Nt.nodeResult)??A)==null?void 0:wt.payload)??null,null,2)})]})]})]}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Pick a node result to inspect its resolved inputs and outputs."})})]}):e.jsx("div",{className:"rounded-[20px] border border-[var(--ui-border-subtle)] bg-[var(--ui-surface-2)] p-4 text-sm text-[var(--ui-ink-soft)]",children:Q.isFetching?"Loading node results…":"This run does not have stored node results yet."})]})]})}):e.jsx("div",{className:"text-sm text-[var(--ui-ink-soft)]",children:"Run the flow once to inspect its published outputs and node-level results here."})})]})}function Ls(){const t=ka(),i=Na(),s=t.flowId??"",n=Oa(),d=Pa(s,{skip:s.length===0}),u=Aa(),[p]=Ka(),[o]=Ma(),[l]=za(),[h]=Wa();return d.isLoading||u.isLoading?e.jsx($a,{eyebrow:"Workbench Flow",title:"Loading flow",description:"Preparing the Workbench graph editor."}):d.isError||u.isError||!d.data?!d.data&&!d.isError&&!u.isError?e.jsx(Ha,{eyebrow:"Workbench Flow",title:"Flow unavailable",description:"Forge could not find that flow."}):e.jsx(La,{eyebrow:"Workbench Flow",error:d.error??u.error??null}):e.jsxs("div",{className:"grid gap-5",children:[e.jsx(Ca,{entityKind:d.data.flow.kind,title:d.data.flow.title,titleText:d.data.flow.title,description:d.data.flow.description||"Inspect, run, and publish this Workbench flow.",badge:d.data.flow.kind,actions:e.jsx(wa,{entityType:"workbench_flow",entityId:d.data.flow.id})}),e.jsx(Fs,{flow:d.data.flow,boxes:n,modelConnections:(u.data.settings.modelSettings.connections??[]).map(m=>({id:m.id,label:m.label,provider:m.provider,model:m.model,baseUrl:m.baseUrl})),runs:d.data.runs,onSave:async m=>{await p({flowId:s,patch:m}).unwrap()},onDelete:async()=>{await o(s).unwrap(),i("/workbench")},onRun:async m=>{await l({flowId:s,input:m}).unwrap()},onChat:async m=>{await h({flowId:s,input:m}).unwrap()}})]})}export{Ls as WorkbenchFlowPage};
|
|
@@ -0,0 +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-DEC6ANa9.js";import{P as I}from"./page-hero-ffKzgyW3.js";import{fr as Q,B as m,b as W,fs as K,ft as $}from"./index-EqQsXoat.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-EqQsXoat.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-ffKzgyW3.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
|
@@ -128,17 +128,17 @@
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
</style>
|
|
131
|
-
<script type="module" crossorigin src="/forge/assets/index-
|
|
132
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/vendor-
|
|
133
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/state-
|
|
134
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/
|
|
135
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/ui-
|
|
136
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/
|
|
137
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/
|
|
138
|
-
<link rel="modulepreload" crossorigin href="/forge/assets/graph-
|
|
131
|
+
<script type="module" crossorigin src="/forge/assets/index-EqQsXoat.js"></script>
|
|
132
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/vendor-Dnkkx2co.js">
|
|
133
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/state-vCcAT5Hq.js">
|
|
134
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/motion-Lt5B1XuE.js">
|
|
135
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/ui-C1iwpj2-.js">
|
|
136
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/forms-hB0SqEh-.js">
|
|
137
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/board-dIX6etHh.js">
|
|
138
|
+
<link rel="modulepreload" crossorigin href="/forge/assets/graph-DDUZNRsO.js">
|
|
139
139
|
<link rel="stylesheet" crossorigin href="/forge/assets/vendor-CRS-psbw.css">
|
|
140
140
|
<link rel="stylesheet" crossorigin href="/forge/assets/graph-BZV40eAE.css">
|
|
141
|
-
<link rel="stylesheet" crossorigin href="/forge/assets/index-
|
|
141
|
+
<link rel="stylesheet" crossorigin href="/forge/assets/index-BAXYM89v.css">
|
|
142
142
|
</head>
|
|
143
143
|
<body class="bg-canvas text-ink antialiased">
|
|
144
144
|
<div id="root">
|
|
@@ -178,8 +178,16 @@ function shouldEnableManagedDevWeb(plan, env = process.env) {
|
|
|
178
178
|
function getCurrentModuleRoot() {
|
|
179
179
|
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
180
180
|
}
|
|
181
|
+
function uniquePaths(paths) {
|
|
182
|
+
return Array.from(new Set(paths.map((candidate) => path.resolve(candidate))));
|
|
183
|
+
}
|
|
181
184
|
function buildLaunchPlanSearchPaths(moduleRoot) {
|
|
182
185
|
const repoRoot = path.resolve(moduleRoot, "..");
|
|
186
|
+
const sourceRoots = uniquePaths([
|
|
187
|
+
repoRoot,
|
|
188
|
+
moduleRoot,
|
|
189
|
+
path.resolve(moduleRoot, "..", "..", "..")
|
|
190
|
+
]);
|
|
183
191
|
return {
|
|
184
192
|
packagedEntries: [
|
|
185
193
|
path.join(moduleRoot, "server", "index.js"),
|
|
@@ -188,14 +196,9 @@ function buildLaunchPlanSearchPaths(moduleRoot) {
|
|
|
188
196
|
path.join(moduleRoot, "dist", "server", "server", "src", "index.js")
|
|
189
197
|
],
|
|
190
198
|
packagedMigrations: path.join(moduleRoot, "server", "migrations"),
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
],
|
|
195
|
-
tsxCliCandidates: [
|
|
196
|
-
path.join(repoRoot, "node_modules", "tsx", "dist", "cli.mjs"),
|
|
197
|
-
path.join(moduleRoot, "node_modules", "tsx", "dist", "cli.mjs")
|
|
198
|
-
],
|
|
199
|
+
sourceRoots,
|
|
200
|
+
sourceEntries: sourceRoots.map((root) => path.join(root, "server", "src", "index.ts")),
|
|
201
|
+
tsxCliCandidates: sourceRoots.map((root) => path.join(root, "node_modules", "tsx", "dist", "cli.mjs")),
|
|
199
202
|
repoRoot
|
|
200
203
|
};
|
|
201
204
|
}
|
|
@@ -209,6 +212,20 @@ function formatLaunchPlanFailure(moduleRoot) {
|
|
|
209
212
|
`tsx candidates: ${paths.tsxCliCandidates.join(", ")}.`
|
|
210
213
|
].join(" ");
|
|
211
214
|
}
|
|
215
|
+
function resolveSourceRuntimeCandidate(paths) {
|
|
216
|
+
for (const sourceRoot of paths.sourceRoots) {
|
|
217
|
+
const entryFile = path.join(sourceRoot, "server", "src", "index.ts");
|
|
218
|
+
const tsxCli = path.join(sourceRoot, "node_modules", "tsx", "dist", "cli.mjs");
|
|
219
|
+
if (existsSync(entryFile) && existsSync(tsxCli)) {
|
|
220
|
+
return {
|
|
221
|
+
root: sourceRoot,
|
|
222
|
+
entryFile,
|
|
223
|
+
tsxCli
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return null;
|
|
228
|
+
}
|
|
212
229
|
function getRuntimeLogPath(config) {
|
|
213
230
|
const origin = new URL(config.origin).hostname.toLowerCase().replace(/[^a-z0-9._-]+/g, "-");
|
|
214
231
|
return path.join(homedir(), ".openclaw", "logs", FORGE_PLUGIN_ID, `${origin}-${config.port}.log`);
|
|
@@ -292,6 +309,18 @@ async function ensurePackagedRuntimeDependencies(plan, config) {
|
|
|
292
309
|
function resolveLaunchPlan() {
|
|
293
310
|
const moduleRoot = getCurrentModuleRoot();
|
|
294
311
|
const paths = buildLaunchPlanSearchPaths(moduleRoot);
|
|
312
|
+
const sourceCandidate = resolveSourceRuntimeCandidate(paths);
|
|
313
|
+
if (isTruthyEnvFlag(process.env.FORGE_OPENCLAW_DEV)) {
|
|
314
|
+
if (sourceCandidate) {
|
|
315
|
+
return {
|
|
316
|
+
packageRoot: sourceCandidate.root,
|
|
317
|
+
entryFile: sourceCandidate.tsxCli,
|
|
318
|
+
mode: "source",
|
|
319
|
+
sourceEntryFile: sourceCandidate.entryFile
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
throw new Error(formatLaunchPlanFailure(moduleRoot));
|
|
323
|
+
}
|
|
295
324
|
// Published or linked plugin package runtime.
|
|
296
325
|
const packagedEntry = paths.packagedEntries.find((candidate) => existsSync(candidate));
|
|
297
326
|
if (packagedEntry && existsSync(paths.packagedMigrations)) {
|
|
@@ -302,14 +331,12 @@ function resolveLaunchPlan() {
|
|
|
302
331
|
};
|
|
303
332
|
}
|
|
304
333
|
// Source-tree fallback for local development before packaging.
|
|
305
|
-
|
|
306
|
-
const tsxCli = paths.tsxCliCandidates.find((candidate) => existsSync(candidate));
|
|
307
|
-
if (sourceEntry && tsxCli) {
|
|
334
|
+
if (sourceCandidate) {
|
|
308
335
|
return {
|
|
309
|
-
packageRoot:
|
|
310
|
-
entryFile: tsxCli,
|
|
336
|
+
packageRoot: sourceCandidate.root,
|
|
337
|
+
entryFile: sourceCandidate.tsxCli,
|
|
311
338
|
mode: "source",
|
|
312
|
-
sourceEntryFile:
|
|
339
|
+
sourceEntryFile: sourceCandidate.entryFile
|
|
313
340
|
};
|
|
314
341
|
}
|
|
315
342
|
return null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CREATE TABLE IF NOT EXISTS nutrition_daily_energy_overrides (
|
|
2
|
+
id TEXT PRIMARY KEY,
|
|
3
|
+
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
|
4
|
+
day_key TEXT NOT NULL,
|
|
5
|
+
active_calories_kcal REAL NOT NULL,
|
|
6
|
+
notes TEXT NOT NULL DEFAULT '',
|
|
7
|
+
created_at TEXT NOT NULL,
|
|
8
|
+
updated_at TEXT NOT NULL,
|
|
9
|
+
UNIQUE (user_id, day_key)
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX IF NOT EXISTS idx_nutrition_daily_energy_overrides_user_day
|
|
13
|
+
ON nutrition_daily_energy_overrides(user_id, day_key DESC);
|