@runfusion/fusion 0.77.0-beta.1 → 0.77.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/dist/bin.js +298 -62
  2. package/dist/child-process-worker.js +287 -57
  3. package/dist/client/.vite/manifest.json +262 -262
  4. package/dist/client/assets/{AgentDetailView-Crk9OdF-.js → AgentDetailView-Dew3af1O.js} +1 -1
  5. package/dist/client/assets/{AgentPermissionPolicyEditor-BHQ9RPKE.js → AgentPermissionPolicyEditor-CxPQffiY.js} +1 -1
  6. package/dist/client/assets/{AgentsView-BWOl5J6F.js → AgentsView-Cr4LDGdt.js} +3 -3
  7. package/dist/client/assets/{ChatView-BP8-Are_.js → ChatView-cNYtYx05.js} +1 -1
  8. package/dist/client/assets/{CommandCenter-C1adapJC.js → CommandCenter-DCC90LOP.js} +1 -1
  9. package/dist/client/assets/{DevServerView-B2wexHCU.js → DevServerView-B5b520w6.js} +1 -1
  10. package/dist/client/assets/{DirectoryPicker-C7rzLVyD.js → DirectoryPicker-1JvRd5mC.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-hOjlyCfz.js → DocumentsView-ksK9f7xt.js} +1 -1
  12. package/dist/client/assets/{EvalsView-CdAB_4D_.js → EvalsView-a3LhgRSo.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-GEypAOXx.js → ExperimentalAgentOnboardingModal-vdVa8h7F.js} +1 -1
  14. package/dist/client/assets/{GoalsView-DW1qRxeP.js → GoalsView-Dz2o91fd.js} +1 -1
  15. package/dist/client/assets/{InsightsView-B5roc0nI.js → InsightsView-De3R_46d.js} +1 -1
  16. package/dist/client/assets/{MemoryView-B0mSfU8f.js → MemoryView-Cagk2wZG.js} +1 -1
  17. package/dist/client/assets/{PiExtensionsManager-ps7tZzok.js → PiExtensionsManager-C9JABO_4.js} +1 -1
  18. package/dist/client/assets/{PluginManager-BrsdP_Zs.js → PluginManager-D2csmdQa.js} +1 -1
  19. package/dist/client/assets/{PullRequestView-CkLoEm3J.js → PullRequestView-DT8vTeVi.js} +1 -1
  20. package/dist/client/assets/{ReportModal-BKdSSVii.js → ReportModal-YMP6V4vu.js} +1 -1
  21. package/dist/client/assets/{ResearchView-OZW77xd4.js → ResearchView-cNsjYu8F.js} +1 -1
  22. package/dist/client/assets/{SecretsView-CawXNPvr.js → SecretsView-BAmf7KyS.js} +1 -1
  23. package/dist/client/assets/{SessionTerminal-C26iOW6f.js → SessionTerminal-BjGcxq22.js} +1 -1
  24. package/dist/client/assets/{SettingsModal-BNWlULmc.js → SettingsModal-C_9RiEI7.js} +1 -1
  25. package/dist/client/assets/{SettingsModal-CfXTMT99.js → SettingsModal-DLfy2e_5.js} +4 -4
  26. package/dist/client/assets/{SettingsTextareaRow-DrXj-rTG.js → SettingsTextareaRow-D8RHSj8b.js} +1 -1
  27. package/dist/client/assets/{SetupWizardModal-Dk4cldse.js → SetupWizardModal-DRJ96pHQ.js} +2 -2
  28. package/dist/client/assets/{SkillsView-NBEe0Qjt.js → SkillsView-DyeCwYit.js} +1 -1
  29. package/dist/client/assets/{WorkflowNodeEditor-CZX7Mlum.js → WorkflowNodeEditor-C5Jc9w_A.js} +3 -3
  30. package/dist/client/assets/{agent-import-generation-TK-wCZBK.js → agent-import-generation-SCPNeF25.js} +1 -1
  31. package/dist/client/assets/{agentsOrgChartLayout-BFC39-tw.js → agentsOrgChartLayout-CqKtNCjy.js} +1 -1
  32. package/dist/client/assets/{architectureDiagram-3BPJPVTR-CYHuEL_5.js → architectureDiagram-3BPJPVTR-Cz2HYn0b.js} +1 -1
  33. package/dist/client/assets/{blockDiagram-GPEHLZMM-BhFoNt44.js → blockDiagram-GPEHLZMM-IimJVscG.js} +1 -1
  34. package/dist/client/assets/{c4Diagram-AAUBKEIU-CQorfIRn.js → c4Diagram-AAUBKEIU-C-xii7zn.js} +1 -1
  35. package/dist/client/assets/channel-D-UHgx8G.js +1 -0
  36. package/dist/client/assets/{chunk-2J33WTMH-DLyODy_m.js → chunk-2J33WTMH-DQ-9Xccu.js} +1 -1
  37. package/dist/client/assets/{chunk-4BX2VUAB-C4ZfqjSh.js → chunk-4BX2VUAB-DmdAX9Bx.js} +1 -1
  38. package/dist/client/assets/{chunk-55IACEB6-CvGg-ubc.js → chunk-55IACEB6-IF2bk5IL.js} +1 -1
  39. package/dist/client/assets/{chunk-727SXJPM-jCzUYl5C.js → chunk-727SXJPM-AeYpIzVu.js} +1 -1
  40. package/dist/client/assets/{chunk-AQP2D5EJ-DYLT-tu8.js → chunk-AQP2D5EJ-DV942DD9.js} +1 -1
  41. package/dist/client/assets/{chunk-FMBD7UC4-CCgBBj1Z.js → chunk-FMBD7UC4-Bt_riVlZ.js} +1 -1
  42. package/dist/client/assets/{chunk-ND2GUHAM-BFdFrIja.js → chunk-ND2GUHAM-CbyjNbXR.js} +1 -1
  43. package/dist/client/assets/{chunk-QZHKN3VN-BUTaQ50G.js → chunk-QZHKN3VN-DqiRniYQ.js} +1 -1
  44. package/dist/client/assets/classDiagram-4FO5ZUOK-Do-8MdAc.js +1 -0
  45. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-Do-8MdAc.js +1 -0
  46. package/dist/client/assets/{cose-bilkent-S5V4N54A-DUbNlc_8.js → cose-bilkent-S5V4N54A-UCvthviL.js} +1 -1
  47. package/dist/client/assets/{dagre-BM42HDAG-Db_33UO6.js → dagre-BM42HDAG-DnMlT1Oi.js} +1 -1
  48. package/dist/client/assets/{dashboard-view-C3PU63FX.js → dashboard-view-C9D0aoRW.js} +1 -1
  49. package/dist/client/assets/dashboard-view-Cz0sp2Wl.js +1 -0
  50. package/dist/client/assets/{dashboard-view-CblIAx4p.js → dashboard-view-JysoyDRX.js} +1 -1
  51. package/dist/client/assets/{dashboard-view-ZGZ80pF3.js → dashboard-view-myjM9tr8.js} +1 -1
  52. package/dist/client/assets/{diagram-2AECGRRQ-BCTLM-Gj.js → diagram-2AECGRRQ-BYFiqXGw.js} +1 -1
  53. package/dist/client/assets/{diagram-5GNKFQAL-CkYPWqJ0.js → diagram-5GNKFQAL-DZU3pSYq.js} +1 -1
  54. package/dist/client/assets/{diagram-KO2AKTUF-7_DJ9TOL.js → diagram-KO2AKTUF-0ybdKuMm.js} +1 -1
  55. package/dist/client/assets/{diagram-LMA3HP47-BAkMEapl.js → diagram-LMA3HP47-Rxbgnbsp.js} +1 -1
  56. package/dist/client/assets/{diagram-OG6HWLK6-DbsQHZ0F.js → diagram-OG6HWLK6-BAU_hTeV.js} +1 -1
  57. package/dist/client/assets/{erDiagram-TEJ5UH35-Bz1kISgV.js → erDiagram-TEJ5UH35-zr8HrwTt.js} +1 -1
  58. package/dist/client/assets/{flowDiagram-I6XJVG4X-fkBLx_JW.js → flowDiagram-I6XJVG4X-CrTw0iFw.js} +1 -1
  59. package/dist/client/assets/{folder-open-l8Z1o786.js → folder-open-DnAlsXXn.js} +1 -1
  60. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BEDb0Uyw.js → ganttDiagram-6RSMTGT7-CCORsxxz.js} +1 -1
  61. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-Cen5lgL7.js → gitGraphDiagram-PVQCEYII-C07wWSjj.js} +1 -1
  62. package/dist/client/assets/index-B_z7OKl4.js +2818 -0
  63. package/dist/client/assets/index-DPo-IAb2.css +1 -0
  64. package/dist/client/assets/{infoDiagram-5YYISTIA-BHqjYX5-.js → infoDiagram-5YYISTIA-hAeccD_4.js} +1 -1
  65. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-6JaCT-0H.js → ishikawaDiagram-YF4QCWOH-WLCzv-NH.js} +1 -1
  66. package/dist/client/assets/{journeyDiagram-JHISSGLW-C_sUwyWW.js → journeyDiagram-JHISSGLW-ClnasNhy.js} +1 -1
  67. package/dist/client/assets/{kanban-definition-UN3LZRKU-__o8oDEP.js → kanban-definition-UN3LZRKU-CAuARhUz.js} +1 -1
  68. package/dist/client/assets/{mermaid.core-BwF2BF3U.js → mermaid.core-Bh02RvfX.js} +4 -4
  69. package/dist/client/assets/{mindmap-definition-RKZ34NQL-DMhvCrGK.js → mindmap-definition-RKZ34NQL-KNTlbW4V.js} +1 -1
  70. package/dist/client/assets/{pieDiagram-4H26LBE5-Dk0KKcwv.js → pieDiagram-4H26LBE5-BouAfBEw.js} +1 -1
  71. package/dist/client/assets/{puzzle-DcLi6jmv.js → puzzle-CC8Ur3Cy.js} +1 -1
  72. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-DXcBYGil.js → quadrantDiagram-W4KKPZXB-wTdkCUJU.js} +1 -1
  73. package/dist/client/assets/{requirementDiagram-4Y6WPE33--GXgKHm2.js → requirementDiagram-4Y6WPE33-BnjY4Tc_.js} +1 -1
  74. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-fX5WAFdr.js → sankeyDiagram-5OEKKPKP-C-QsS08u.js} +1 -1
  75. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-VQOx2wc2.js → sequenceDiagram-3UESZ5HK-DD36MILE.js} +1 -1
  76. package/dist/client/assets/{shield-alert-DLW2jAvI.js → shield-alert-DcXc56Fy.js} +1 -1
  77. package/dist/client/assets/{standing-instructions-template-RbXYE69q.js → standing-instructions-template-BF5y1BLz.js} +1 -1
  78. package/dist/client/assets/{stateDiagram-AJRCARHV-COZ_NGxp.js → stateDiagram-AJRCARHV-WTq1wQr1.js} +1 -1
  79. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-CmgPEZwe.js → stateDiagram-v2-BHNVJYJU-eILJdjII.js} +1 -1
  80. package/dist/client/assets/{timeline-definition-PNZ67QCA-eJYKjHOn.js → timeline-definition-PNZ67QCA-PRNwI0NR.js} +1 -1
  81. package/dist/client/assets/{upload-DwRVPojw.js → upload-qH_64O-B.js} +1 -1
  82. package/dist/client/assets/{useDiscoveredSkillsCache-DhScYUmX.js → useDiscoveredSkillsCache-C-GPCNaO.js} +1 -1
  83. package/dist/client/assets/{users-BrTlKeXP.js → users-D2UesRE4.js} +1 -1
  84. package/dist/client/assets/{vennDiagram-CIIHVFJN-Ddt59BdZ.js → vennDiagram-CIIHVFJN-CG2Z4T4O.js} +1 -1
  85. package/dist/client/assets/{wardley-L42UT6IY-C4R0wOO2.js → wardley-L42UT6IY-gO_fGvF9.js} +1 -1
  86. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-BJDm4S7I.js → wardleyDiagram-YWT4CUSO-BkyNpjUb.js} +1 -1
  87. package/dist/client/assets/{xychartDiagram-2RQKCTM6-DlypQnRH.js → xychartDiagram-2RQKCTM6-CMlZsiPq.js} +1 -1
  88. package/dist/client/index.html +2 -2
  89. package/dist/client/version.json +1 -1
  90. package/dist/droid-cli/package.json +1 -1
  91. package/dist/extension.js +290 -59
  92. package/dist/pi-claude-cli/package.json +1 -1
  93. package/dist/plugin-sdk/index.js +29 -2
  94. package/dist/plugins/fusion-plugin-acp-runtime/bundled.js +269 -16
  95. package/dist/plugins/fusion-plugin-acp-runtime/mcp-schema-server.cjs +171 -0
  96. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  97. package/dist/plugins/fusion-plugin-claude-runtime/bundled.js +29 -2
  98. package/dist/plugins/fusion-plugin-claude-runtime/package.json +1 -1
  99. package/dist/plugins/fusion-plugin-cli-printing-press/bundled.js +29 -2
  100. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  101. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +29 -2
  102. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  103. package/dist/plugins/fusion-plugin-cursor-runtime/bundled.js +29 -2
  104. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  105. package/dist/plugins/fusion-plugin-dependency-graph/bundled.js +29 -2
  106. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  107. package/dist/plugins/fusion-plugin-droid-runtime/bundled.js +29 -2
  108. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  109. package/dist/plugins/fusion-plugin-grok-runtime/bundled.js +29 -2
  110. package/dist/plugins/fusion-plugin-grok-runtime/package.json +1 -1
  111. package/dist/plugins/fusion-plugin-hermes-runtime/bundled.js +29 -2
  112. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  113. package/dist/plugins/fusion-plugin-linear-import/bundled.js +29 -2
  114. package/dist/plugins/fusion-plugin-linear-import/package.json +1 -1
  115. package/dist/plugins/fusion-plugin-omp-runtime/bundled.js +29 -2
  116. package/dist/plugins/fusion-plugin-omp-runtime/package.json +1 -1
  117. package/dist/plugins/fusion-plugin-openclaw-runtime/bundled.js +29 -2
  118. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  119. package/dist/plugins/fusion-plugin-paperclip-runtime/bundled.js +29 -2
  120. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  121. package/dist/plugins/fusion-plugin-quality/bundled.js +29 -2
  122. package/dist/plugins/fusion-plugin-quality/package.json +1 -1
  123. package/dist/plugins/fusion-plugin-reports/bundled.js +29 -2
  124. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  125. package/dist/plugins/fusion-plugin-roadmap/bundled.js +29 -2
  126. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  127. package/dist/plugins/fusion-plugin-todos/bundled.js +29 -2
  128. package/dist/plugins/fusion-plugin-todos/package.json +1 -1
  129. package/dist/plugins/fusion-plugin-whatsapp-chat/bundled.js +29 -2
  130. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  131. package/package.json +1 -1
  132. package/dist/client/assets/channel-DgImfyB5.js +0 -1
  133. package/dist/client/assets/classDiagram-4FO5ZUOK-C3pUNxZS.js +0 -1
  134. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-C3pUNxZS.js +0 -1
  135. package/dist/client/assets/dashboard-view-c3FuWBJb.js +0 -1
  136. package/dist/client/assets/index-BnZB0GkD.js +0 -2818
  137. package/dist/client/assets/index-CPGSlKrd.css +0 -1
@@ -16225,6 +16225,7 @@ function applyPromptOverridesToIr(ir, overrides) {
16225
16225
  function defaultCodingWorkflowIr() {
16226
16226
  return resolveDefaultWorkflowIr();
16227
16227
  }
16228
+ var inflightSelectionReads = /* @__PURE__ */ new WeakMap();
16228
16229
  async function resolveWorkflowIrById(store, workflowId, irCache) {
16229
16230
  let projectId;
16230
16231
  try {
@@ -16268,8 +16269,34 @@ function didFallBackToDefault(ir) {
16268
16269
  async function resolveWorkflowIrForTaskWithProvenance(store, taskId, irCache, selectionCache) {
16269
16270
  let workflowId;
16270
16271
  try {
16271
- const selection = selectionCache?.has(taskId) ? selectionCache.get(taskId) : store.getTaskWorkflowSelectionAsync ? await store.getTaskWorkflowSelectionAsync(taskId) : store.getTaskWorkflowSelection(taskId);
16272
- if (!selectionCache?.has(taskId)) selectionCache?.set(taskId, selection);
16272
+ const isSelectionCached = selectionCache?.has(taskId) ?? false;
16273
+ let selection = isSelectionCached && selectionCache ? selectionCache.get(taskId) : void 0;
16274
+ if (!isSelectionCached) {
16275
+ let inflight;
16276
+ let coalesced = false;
16277
+ if (selectionCache) {
16278
+ inflight = inflightSelectionReads.get(selectionCache);
16279
+ if (!inflight) {
16280
+ inflight = /* @__PURE__ */ new Map();
16281
+ inflightSelectionReads.set(selectionCache, inflight);
16282
+ }
16283
+ const pending = inflight.get(taskId);
16284
+ if (pending) {
16285
+ selection = await pending;
16286
+ coalesced = true;
16287
+ }
16288
+ }
16289
+ if (!coalesced) {
16290
+ const readPromise = store.getTaskWorkflowSelectionAsync ? store.getTaskWorkflowSelectionAsync(taskId) : Promise.resolve(store.getTaskWorkflowSelection(taskId));
16291
+ if (inflight) inflight.set(taskId, readPromise);
16292
+ try {
16293
+ selection = await readPromise;
16294
+ } finally {
16295
+ inflight?.delete(taskId);
16296
+ }
16297
+ }
16298
+ selectionCache?.set(taskId, selection);
16299
+ }
16273
16300
  workflowId = selection?.workflowId;
16274
16301
  } catch {
16275
16302
  return { ir: defaultCodingWorkflowIr(), source: "default" };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/reports",
3
- "version": "0.1.55-beta.1",
3
+ "version": "0.1.55-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -16105,6 +16105,7 @@ function applyPromptOverridesToIr(ir, overrides) {
16105
16105
  function defaultCodingWorkflowIr() {
16106
16106
  return resolveDefaultWorkflowIr();
16107
16107
  }
16108
+ var inflightSelectionReads = /* @__PURE__ */ new WeakMap();
16108
16109
  async function resolveWorkflowIrById(store, workflowId, irCache) {
16109
16110
  let projectId;
16110
16111
  try {
@@ -16148,8 +16149,34 @@ function didFallBackToDefault(ir) {
16148
16149
  async function resolveWorkflowIrForTaskWithProvenance(store, taskId, irCache, selectionCache) {
16149
16150
  let workflowId;
16150
16151
  try {
16151
- const selection = selectionCache?.has(taskId) ? selectionCache.get(taskId) : store.getTaskWorkflowSelectionAsync ? await store.getTaskWorkflowSelectionAsync(taskId) : store.getTaskWorkflowSelection(taskId);
16152
- if (!selectionCache?.has(taskId)) selectionCache?.set(taskId, selection);
16152
+ const isSelectionCached = selectionCache?.has(taskId) ?? false;
16153
+ let selection = isSelectionCached && selectionCache ? selectionCache.get(taskId) : void 0;
16154
+ if (!isSelectionCached) {
16155
+ let inflight;
16156
+ let coalesced = false;
16157
+ if (selectionCache) {
16158
+ inflight = inflightSelectionReads.get(selectionCache);
16159
+ if (!inflight) {
16160
+ inflight = /* @__PURE__ */ new Map();
16161
+ inflightSelectionReads.set(selectionCache, inflight);
16162
+ }
16163
+ const pending = inflight.get(taskId);
16164
+ if (pending) {
16165
+ selection = await pending;
16166
+ coalesced = true;
16167
+ }
16168
+ }
16169
+ if (!coalesced) {
16170
+ const readPromise = store.getTaskWorkflowSelectionAsync ? store.getTaskWorkflowSelectionAsync(taskId) : Promise.resolve(store.getTaskWorkflowSelection(taskId));
16171
+ if (inflight) inflight.set(taskId, readPromise);
16172
+ try {
16173
+ selection = await readPromise;
16174
+ } finally {
16175
+ inflight?.delete(taskId);
16176
+ }
16177
+ }
16178
+ selectionCache?.set(taskId, selection);
16179
+ }
16153
16180
  workflowId = selection?.workflowId;
16154
16181
  } catch {
16155
16182
  return { ir: defaultCodingWorkflowIr(), source: "default" };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/roadmap",
3
- "version": "0.1.55-beta.1",
3
+ "version": "0.1.55-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -16105,6 +16105,7 @@ function applyPromptOverridesToIr(ir, overrides) {
16105
16105
  function defaultCodingWorkflowIr() {
16106
16106
  return resolveDefaultWorkflowIr();
16107
16107
  }
16108
+ var inflightSelectionReads = /* @__PURE__ */ new WeakMap();
16108
16109
  async function resolveWorkflowIrById(store2, workflowId, irCache) {
16109
16110
  let projectId2;
16110
16111
  try {
@@ -16148,8 +16149,34 @@ function didFallBackToDefault(ir) {
16148
16149
  async function resolveWorkflowIrForTaskWithProvenance(store2, taskId, irCache, selectionCache) {
16149
16150
  let workflowId;
16150
16151
  try {
16151
- const selection = selectionCache?.has(taskId) ? selectionCache.get(taskId) : store2.getTaskWorkflowSelectionAsync ? await store2.getTaskWorkflowSelectionAsync(taskId) : store2.getTaskWorkflowSelection(taskId);
16152
- if (!selectionCache?.has(taskId)) selectionCache?.set(taskId, selection);
16152
+ const isSelectionCached = selectionCache?.has(taskId) ?? false;
16153
+ let selection = isSelectionCached && selectionCache ? selectionCache.get(taskId) : void 0;
16154
+ if (!isSelectionCached) {
16155
+ let inflight;
16156
+ let coalesced = false;
16157
+ if (selectionCache) {
16158
+ inflight = inflightSelectionReads.get(selectionCache);
16159
+ if (!inflight) {
16160
+ inflight = /* @__PURE__ */ new Map();
16161
+ inflightSelectionReads.set(selectionCache, inflight);
16162
+ }
16163
+ const pending = inflight.get(taskId);
16164
+ if (pending) {
16165
+ selection = await pending;
16166
+ coalesced = true;
16167
+ }
16168
+ }
16169
+ if (!coalesced) {
16170
+ const readPromise = store2.getTaskWorkflowSelectionAsync ? store2.getTaskWorkflowSelectionAsync(taskId) : Promise.resolve(store2.getTaskWorkflowSelection(taskId));
16171
+ if (inflight) inflight.set(taskId, readPromise);
16172
+ try {
16173
+ selection = await readPromise;
16174
+ } finally {
16175
+ inflight?.delete(taskId);
16176
+ }
16177
+ }
16178
+ selectionCache?.set(taskId, selection);
16179
+ }
16153
16180
  workflowId = selection?.workflowId;
16154
16181
  } catch {
16155
16182
  return { ir: defaultCodingWorkflowIr(), source: "default" };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/todos",
3
- "version": "0.1.4-beta.1",
3
+ "version": "0.1.4-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -173406,6 +173406,7 @@ function applyPromptOverridesToIr(ir, overrides) {
173406
173406
  function defaultCodingWorkflowIr() {
173407
173407
  return resolveDefaultWorkflowIr();
173408
173408
  }
173409
+ var inflightSelectionReads = /* @__PURE__ */ new WeakMap();
173409
173410
  async function resolveWorkflowIrById(store, workflowId, irCache) {
173410
173411
  let projectId;
173411
173412
  try {
@@ -173449,8 +173450,34 @@ function didFallBackToDefault(ir) {
173449
173450
  async function resolveWorkflowIrForTaskWithProvenance(store, taskId, irCache, selectionCache) {
173450
173451
  let workflowId;
173451
173452
  try {
173452
- const selection = selectionCache?.has(taskId) ? selectionCache.get(taskId) : store.getTaskWorkflowSelectionAsync ? await store.getTaskWorkflowSelectionAsync(taskId) : store.getTaskWorkflowSelection(taskId);
173453
- if (!selectionCache?.has(taskId)) selectionCache?.set(taskId, selection);
173453
+ const isSelectionCached = selectionCache?.has(taskId) ?? false;
173454
+ let selection = isSelectionCached && selectionCache ? selectionCache.get(taskId) : void 0;
173455
+ if (!isSelectionCached) {
173456
+ let inflight;
173457
+ let coalesced = false;
173458
+ if (selectionCache) {
173459
+ inflight = inflightSelectionReads.get(selectionCache);
173460
+ if (!inflight) {
173461
+ inflight = /* @__PURE__ */ new Map();
173462
+ inflightSelectionReads.set(selectionCache, inflight);
173463
+ }
173464
+ const pending = inflight.get(taskId);
173465
+ if (pending) {
173466
+ selection = await pending;
173467
+ coalesced = true;
173468
+ }
173469
+ }
173470
+ if (!coalesced) {
173471
+ const readPromise = store.getTaskWorkflowSelectionAsync ? store.getTaskWorkflowSelectionAsync(taskId) : Promise.resolve(store.getTaskWorkflowSelection(taskId));
173472
+ if (inflight) inflight.set(taskId, readPromise);
173473
+ try {
173474
+ selection = await readPromise;
173475
+ } finally {
173476
+ inflight?.delete(taskId);
173477
+ }
173478
+ }
173479
+ selectionCache?.set(taskId, selection);
173480
+ }
173454
173481
  workflowId = selection?.workflowId;
173455
173482
  } catch {
173456
173483
  return { ir: defaultCodingWorkflowIr(), source: "default" };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fusion-plugin-examples/whatsapp-chat",
3
- "version": "0.1.55-beta.1",
3
+ "version": "0.1.55-beta.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runfusion/fusion",
3
- "version": "0.77.0-beta.1",
3
+ "version": "0.77.0-beta.2",
4
4
  "license": "MIT",
5
5
  "description": "Fusion CLI: HTTP API server, daemon, dashboard launcher, and task tooling for the Fusion AI coding agent.",
6
6
  "homepage": "https://github.com/Runfusion/Fusion#readme",
@@ -1 +0,0 @@
1
- import{U as a,C as n}from"./mermaid.core-BwF2BF3U.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-727SXJPM-jCzUYl5C.js";import{_ as i}from"./mermaid.core-BwF2BF3U.js";import"./vendor-reactflow-BlIeoTu4.js";import"./chunk-FMBD7UC4-CCgBBj1Z.js";import"./chunk-ND2GUHAM-BFdFrIja.js";import"./chunk-55IACEB6-CvGg-ubc.js";import"./chunk-2J33WTMH-DLyODy_m.js";import"./index-BnZB0GkD.js";import"./vendor-react-SZ_qB27O.js";import"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-xterm-BNq00GSj.js";import"./step-yuy0qJer.js";var k={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{k as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as t,C as e}from"./chunk-727SXJPM-jCzUYl5C.js";import{_ as i}from"./mermaid.core-BwF2BF3U.js";import"./vendor-reactflow-BlIeoTu4.js";import"./chunk-FMBD7UC4-CCgBBj1Z.js";import"./chunk-ND2GUHAM-BFdFrIja.js";import"./chunk-55IACEB6-CvGg-ubc.js";import"./chunk-2J33WTMH-DLyODy_m.js";import"./index-BnZB0GkD.js";import"./vendor-react-SZ_qB27O.js";import"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-xterm-BNq00GSj.js";import"./step-yuy0qJer.js";var k={parser:t,get db(){return new e},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{k as diagram};
@@ -1 +0,0 @@
1
- import{r as e,j as H}from"./vendor-react-SZ_qB27O.js";import{e9 as vt,ea as Xt,dy as Yt,dA as _t,dz as jt}from"./index-BnZB0GkD.js";import{Z as $t,a as Gt,M as Wt,R as Ft}from"./zoom-out-DzDzWQt1.js";import"./vendor-i18n-Duky4gdQ.js";import"./vendor-codemirror-CcrtqoCy.js";import"./vendor-reactflow-BlIeoTu4.js";import"./vendor-xterm-BNq00GSj.js";import"./createLucideIcon-CshVyKO4.js";const xt=4,wt=300,Lt=24;function Ut({taskId:n,position:i,scale:r,canDrag:a,onPositionChange:f,onDragStateChange:u,onDragEnd:y,onDoubleTap:b}){const[I,z]=e.useState(!1),M=e.useRef(null),C=e.useRef(i),X=e.useRef(!1),o=e.useRef(null),c=e.useRef(!1);C.current=i,c.current=I;const d=e.useCallback(()=>{o.current=null},[]),T=e.useCallback(l=>{M.current=null,z(!1),c.current=!1,l&&(u?.(!1),y?.(),X.current=!0,d())},[y,u,d]),E=e.useCallback(l=>{if(!l.isPrimary)return;if(l.defaultPrevented){d();return}const P=Date.now();o.current&&P-o.current.timeStamp>wt&&d(),a&&l.stopPropagation();const x=l.currentTarget;a&&typeof x.setPointerCapture=="function"&&x.setPointerCapture(l.pointerId),M.current={pointerId:l.pointerId,pointerType:l.pointerType,startPointer:{x:l.clientX,y:l.clientY},startPosition:C.current,defaultPrevented:l.defaultPrevented,movedBeyondThreshold:!1}},[a,d]),A=e.useCallback(l=>{const P=M.current;if(!P||P.pointerId!==l.pointerId)return;a&&l.stopPropagation();const x=l.clientX-P.startPointer.x,U=l.clientY-P.startPointer.y,O=Math.hypot(x,U);if(O>=xt&&(P.movedBeyondThreshold=!0),!a){P.movedBeyondThreshold&&d();return}if(!c.current&&O>=xt&&(z(!0),c.current=!0,u?.(!0),d()),O<xt)return;const V=r>0?r:1;f(n,{x:P.startPosition.x+x/V,y:P.startPosition.y+U/V})},[a,u,f,d,r,n]),G=e.useCallback((l,P)=>{if(!b||P.defaultPrevented||P.movedBeyondThreshold)return Date.now()-(o.current?.timeStamp??0)>wt&&d(),!1;if(P.pointerType==="mouse")return d(),!1;const x={timeStamp:Date.now(),point:{x:P.startPointer.x,y:P.startPointer.y}},U=o.current;return!U||x.timeStamp-U.timeStamp>wt||Math.hypot(x.point.x-U.point.x,x.point.y-U.point.y)>Lt?(o.current=x,!1):(X.current=!0,d(),b(),!0)},[b,d]),Z=e.useCallback(l=>{const P=M.current;if(!P||P.pointerId!==l.pointerId)return;a&&l.stopPropagation(),a&&typeof l.currentTarget.hasPointerCapture=="function"&&l.currentTarget.hasPointerCapture(l.pointerId)&&typeof l.currentTarget.releasePointerCapture=="function"&&l.currentTarget.releasePointerCapture(l.pointerId);const x=c.current;!x&&G(l,P)&&l.preventDefault(),T(x)},[a,T,G]),W=e.useCallback(l=>{const P=M.current;!P||P.pointerId!==l.pointerId||(a&&l.stopPropagation(),a&&typeof l.currentTarget.hasPointerCapture=="function"&&l.currentTarget.hasPointerCapture(l.pointerId)&&typeof l.currentTarget.releasePointerCapture=="function"&&l.currentTarget.releasePointerCapture(l.pointerId),d(),T(c.current))},[a,T,d]),$=e.useCallback(l=>{X.current&&(X.current=!1,l.preventDefault(),l.stopPropagation())},[]);return e.useMemo(()=>({isDragging:I,onPointerDown:E,onPointerMove:A,onPointerUp:Z,onPointerCancel:W,onClickCapture:$}),[I,$,W,E,A,Z])}const Bt=new Set(["planning","researching","executing","finalizing","merging","merging-fix"]);function Zt(n){return n?n.charAt(0).toUpperCase()+n.slice(1):"Executing"}function Kt({taskColumnFlags:n,style:i,position:r,scale:a,isSelected:f=!1,isHighlighted:u=!1,isDimmed:y=!1,onMouseEnter:b,onMouseLeave:I,onClick:z,onNodePositionChange:M,onNodeDragStateChange:C,onNodeDragEnd:X,...o}){const{task:c,globalPaused:d,taskStuckTimeoutMs:T,lastFetchTimeMs:E,onOpenDetail:A}=o,G=c.status==="failed",Z=c.paused===!0,W=vt(c,T,E,n),$=c.column==="in-progress"||Bt.has(c.status),l=c.status==="awaiting-approval"&&!$,P=!d&&!G&&!Z&&!W&&!l&&$,x=typeof c.currentStep=="number"&&c.currentStep>=0&&Array.isArray(c.steps)&&c.currentStep<c.steps.length,U=c.column==="in-review",O=Ut({taskId:c.id,position:r,scale:a,canDrag:f,onPositionChange:M,onDragStateChange:C,onDragEnd:X,onDoubleTap:()=>A(c)});return H.jsxs("div",{className:`graph-task-node${f?" graph-node--draggable graph-task-node--selected":""}${O.isDragging?" graph-node--dragging":""}${u?" graph-task-node--highlighted graph-node--highlighted":""}${y?" graph-task-node--dimmed graph-node--dimmed":""}${P?" graph-task-node--active":""}${U?" graph-task-node--in-review":""}`,style:i,draggable:!1,"data-testid":`graph-task-node-${c.id}`,"data-current-step":P&&x?String(c.currentStep):void 0,onMouseEnter:b,onMouseLeave:I,onClick:z,onDoubleClick:V=>{V.defaultPrevented||A(c)},onClickCapture:O.onClickCapture,onPointerDown:O.onPointerDown,onPointerMove:O.onPointerMove,onPointerUp:O.onPointerUp,onPointerCancel:O.onPointerCancel,children:[P?H.jsx("div",{className:"graph-task-active-indicator",children:H.jsx("span",{className:"graph-task-active-indicator-text",children:Zt(c.status)})}):null,H.jsx(Xt,{...o,taskColumnFlags:n,onOpenDetail:()=>{},disableDrag:!0})]})}function Vt({zoom:n,onZoomIn:i,onZoomOut:r,onFitToGraph:a,onResetView:f}){return H.jsxs("div",{className:"graph-toolbar","data-testid":"graph-toolbar",children:[H.jsx("button",{className:"btn btn-icon",title:"Zoom in (Ctrl+=)","aria-label":"Zoom in",onClick:i,children:H.jsx($t,{size:16})}),H.jsx("button",{className:"btn btn-icon",title:"Zoom out (Ctrl+-)","aria-label":"Zoom out",onClick:r,children:H.jsx(Gt,{size:16})}),H.jsxs("div",{className:"graph-toolbar__zoom-label","aria-live":"polite",children:[Math.round(n*100),"%"]}),H.jsx("button",{className:"btn btn-icon",title:"Fit to graph (Ctrl+Shift+F)","aria-label":"Fit to graph",onClick:a,children:H.jsx(Wt,{size:16})}),H.jsx("button",{className:"btn btn-icon",title:"Reset view (Ctrl+0)","aria-label":"Reset view",onClick:f,children:H.jsx(Ft,{size:16})})]})}const qt=280,Jt=100;function Qt({edges:n,positions:i,nodeWidth:r=qt,nodeHeight:a=Jt,nodeHeights:f,highlightedEdgeIds:u}){const y=!!(u&&u.size>0);return H.jsxs("svg",{className:"dependency-graph-edges","aria-hidden":"true",children:[H.jsx("defs",{children:H.jsx("marker",{id:"dependency-graph-arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",markerUnits:"strokeWidth",children:H.jsx("path",{d:"M 0 0 L 10 3.5 L 0 7 z",style:{fill:"var(--border)"}})})}),n.map(b=>{const I=i.get(b.source),z=i.get(b.target);if(!I||!z)return null;const M=`${b.source}->${b.target}`,C=y&&(u?.has(M)??!1),X=I.x+r/2,o=I.y+(f?.get(b.source)??a),c=z.x+r/2,d=z.y,T=o+(d-o)/2;return H.jsx("path",{"data-testid":"dependency-edge","data-edge-id":M,className:`dependency-graph-edge${C?" graph-edge--highlighted":""}${y&&!C?" graph-edge--dimmed":""}`,d:`M ${X} ${o} C ${X} ${T}, ${c} ${T}, ${c} ${d}`,fill:"none",markerEnd:"url(#dependency-graph-arrowhead)",style:{opacity:y&&!C?.15:1,stroke:C?"var(--todo)":"var(--border)",strokeWidth:C?"var(--space-xs)":"var(--btn-border-width)",transition:"opacity var(--transition-fast), stroke var(--transition-fast), stroke-width var(--transition-fast)"}},M)})]})}const te=new Set(["done","archived"]);function ee(n){return n.filter(i=>typeof i.column=="string"&&i.column.length>0&&!te.has(i.column))}const ne={nodeWidth:280,nodeHeight:100,horizontalGap:40,verticalGap:80,orientation:"vertical"};function kt(n,i){const r={...ne,...i},a=n.nodes.map(o=>o.task.id);if(a.length===0)return new Map;const f=new Map,u=new Map;for(const o of a)u.set(o,0),f.set(o,[]);for(const o of n.edges)!u.has(o.source)||!u.has(o.target)||(f.get(o.target)?.push(o.source),u.set(o.source,(u.get(o.source)??0)+1));const y=a.filter(o=>(u.get(o)??0)===0),b=[];for(;y.length>0;){const o=y.shift();b.push(o);for(const c of f.get(o)??[]){const d=(u.get(c)??0)-1;u.set(c,d),d===0&&y.push(c)}}for(const o of a)b.includes(o)||b.push(o);const I=new Map;for(const o of b){const c=n.edges.filter(T=>T.source===o).map(T=>T.target);let d=0;for(const T of c)d=Math.max(d,(I.get(T)??0)+1);I.set(o,d)}const z=new Map;for(const o of a){const c=I.get(o)??0,d=z.get(c)??[];d.push(o),z.set(c,d)}const M=new Map,C=Array.from(z.keys()).sort((o,c)=>o-c),X=new Map;if(r.orientation==="vertical"){let o=0;for(const c of C){X.set(c,o);const d=z.get(c)??[],T=Math.max(r.nodeHeight,...d.map(E=>r.measuredHeights?.get(E)??r.nodeHeight));o+=T+r.verticalGap}}for(const o of C){const c=z.get(o)??[];if(c.sort(),r.orientation==="horizontal"){const G=-(c.reduce(($,l)=>$+(r.measuredHeights?.get(l)??r.nodeHeight),0)+Math.max(0,c.length-1)*r.verticalGap)/2,Z=o*(r.nodeWidth+r.horizontalGap);let W=G;for(const $ of c)M.set($,{x:Z,y:W}),W+=(r.measuredHeights?.get($)??r.nodeHeight)+r.verticalGap;continue}const E=-(c.length*r.nodeWidth+Math.max(0,c.length-1)*r.horizontalGap)/2;c.forEach((A,G)=>{const Z=E+G*(r.nodeWidth+r.horizontalGap),W=X.get(o)??o*(r.nodeHeight+r.verticalGap);M.set(A,{x:Z,y:W})})}return M}function re(n){return e.useMemo(()=>{const i=n.map(f=>({task:f})),r=new Set(n.map(f=>f.id)),a=n.flatMap(f=>(f.dependencies??[]).filter(u=>r.has(u)).map(u=>({source:f.id,target:u})));return{nodes:i,edges:a}},[n])}const ut=.1,lt=3,Dt=40,oe=200;function nt(n,i,r){return Math.min(r,Math.max(i,n))}function se(n){if(!(n instanceof HTMLElement))return!1;const i=n.tagName.toLowerCase();return n.isContentEditable||i==="input"||i==="textarea"||i==="select"}function ie(){const[n,i]=e.useState({x:0,y:0}),[r,a]=e.useState(1),[f,u]=e.useState(!1),y=e.useRef(n),b=e.useRef(r),I=e.useRef(null),z=e.useRef(null),M=e.useRef(new Map),C=e.useRef(null),X=e.useRef({minX:0,minY:0,maxX:0,maxY:0});e.useEffect(()=>{y.current=n},[n]),e.useEffect(()=>{b.current=r},[r]),e.useEffect(()=>()=>{I.current!==null&&window.clearTimeout(I.current)},[]);const o=e.useMemo(()=>`translate(${n.x}px, ${n.y}px) scale(${r})`,[n.x,n.y,r]),c=e.useMemo(()=>Math.round(r*100),[r]),d=e.useCallback(s=>{if(!s){I.current!==null&&(window.clearTimeout(I.current),I.current=null),u(!1);return}u(!0),I.current!==null&&window.clearTimeout(I.current),I.current=window.setTimeout(()=>{u(!1),I.current=null},oe)},[]),T=e.useCallback((s,p,w,k=b.current)=>{const S=X.current;if(S.maxX<=S.minX||S.maxY<=S.minY)return{x:nt(s.x,-p,p),y:nt(s.y,-w,w)};const Y=p-S.maxX*k,v=-S.minX*k,_=w-S.maxY*k,B=-S.minY*k,ot=Y>v?(Y+v)/2:nt(s.x,Y,v),J=_>B?(_+B)/2:nt(s.y,_,B);return{x:ot,y:J}},[]),E=e.useCallback((s,p,w,k)=>{const S=b.current,Y=y.current,v=nt(s,ut,lt),_=v/S,B=T({x:p.x-(p.x-Y.x)*_,y:p.y-(p.y-Y.y)*_},w,k,v);a(v),i(B)},[T]),A=e.useCallback((s,p,w,k)=>{d(!1);const S=k??{x:p/2,y:w/2};E(b.current*s,S,p,w)},[d,E]),G=e.useCallback((s,p)=>{if(s&&p){A(1.2,s,p);return}a(w=>nt(w+.1,ut,lt))},[A]),Z=e.useCallback((s,p)=>{if(s&&p){A(1/1.2,s,p);return}a(w=>nt(w-.1,ut,lt))},[A]),W=e.useCallback(()=>{d(!0),i({x:0,y:0}),a(1)},[d]),$=e.useCallback((s,p,w,k)=>{if(d(!0),s.size===0){i({x:0,y:0}),a(1);return}const S=k?.nodeWidth??280,Y=k?.nodeHeight??100,v=Array.from(s.entries()),_=Math.min(...v.map(([,et])=>et.x)),B=Math.min(...v.map(([,et])=>et.y)),ot=Math.max(...v.map(([,et])=>et.x+S)),J=Math.max(...v.map(([et,mt])=>mt.y+(k?.measuredHeights?.get(et)??Y))),F=Math.max(1,ot-_),Q=Math.max(1,J-B),tt=Math.max(1,p-Dt*2),ht=Math.max(1,w-Dt*2),st=nt(Math.min(tt/F,ht/Q),ut,lt),dt=(p-F*st)/2-_*st,pt=(w-Q*st)/2-B*st;a(st),i(T({x:dt,y:pt},p,w,st))},[T,d]),l=e.useCallback((s,p)=>{if(M.current.set(s,p),M.current.size===2){const[w,k]=Array.from(M.current.values());C.current={distance:Math.hypot(w.x-k.x,w.y-k.y),zoom:b.current,pan:y.current,midpoint:{x:(w.x+k.x)/2,y:(w.y+k.y)/2}},z.current=null;return}z.current={start:p,panStart:y.current}},[]),P=e.useCallback((s,p,w,k)=>{if(M.current.has(s)&&M.current.set(s,p),M.current.size===2&&C.current){d(!1);const[v,_]=Array.from(M.current.values()),ot=Math.hypot(v.x-_.x,v.y-_.y)/Math.max(1,C.current.distance),J={x:(v.x+_.x)/2,y:(v.y+_.y)/2},F=nt(C.current.zoom*ot,ut,lt),Q=F/C.current.zoom,tt=T({x:J.x-(C.current.midpoint.x-C.current.pan.x)*Q,y:J.y-(C.current.midpoint.y-C.current.pan.y)*Q},w,k);a(F),i(tt);return}const S=z.current;if(!S)return;d(!1);const Y={x:S.panStart.x+(p.x-S.start.x),y:S.panStart.y+(p.y-S.start.y)};i(T(Y,w,k))},[T,d]),x=e.useCallback(s=>{if(M.current.delete(s),M.current.size<2&&(C.current=null),M.current.size===1){const[p]=Array.from(M.current.values());z.current={start:p,panStart:y.current};return}M.current.size===0&&(z.current=null)},[]),U=e.useCallback((s,p,w,k)=>{d(!1);const S={x:y.current.x-s,y:y.current.y-p};i(T(S,w,k))},[T,d]),O=e.useCallback((s,p,w,k)=>{const S=s<0?1.1:.9;d(!1),E(b.current*S,p,w,k)},[d,E]),V=e.useCallback(s=>{X.current=s},[]),q=e.useCallback((s,p,w,k,S)=>{if(se(s.target))return;const Y=s.metaKey||s.ctrlKey;if(s.key==="Escape"){s.preventDefault(),W();return}if(Y){if(s.key==="="||s.key==="+"){s.preventDefault(),A(1.2,p,w);return}if(s.key==="-"){s.preventDefault(),A(1/1.2,p,w);return}if(s.key==="0"){s.preventDefault(),W();return}(s.key==="f"||s.key==="F")&&s.shiftKey&&(s.preventDefault(),$(k,p,w,S))}},[$,W,A]);return{pan:n,zoom:r,zoomPercent:c,transform:o,transitioning:f,zoomIn:G,zoomOut:Z,resetView:W,fitToGraph:$,setAnimate:d,onPointerDown:l,onPointerMove:P,onPointerUp:x,onWheelPan:U,onWheelZoom:O,handleKeyDown:q,setGraphBounds:V}}function ae(n){const{upstreamMap:i,downstreamMap:r}=e.useMemo(()=>{const f=new Map,u=new Map;for(const y of n)f.set(y.id,new Set(y.dependencies??[])),u.has(y.id)||u.set(y.id,new Set);for(const y of n)for(const b of y.dependencies??[])u.has(b)||u.set(b,new Set),u.get(b)?.add(y.id);return{upstreamMap:f,downstreamMap:u}},[n]);return{getChain:e.useCallback(f=>{if(!i.has(f)&&!r.has(f))return new Set;const u=new Set([f]),y=(b,I)=>{const z=[b],M=new Set([b]);for(;z.length>0;){const C=z.shift();if(!C)continue;const X=I.get(C);if(X)for(const o of X)M.has(o)||(M.add(o),u.add(o),z.push(o))}};return y(f,i),y(f,r),u},[r,i])}}const Mt="fusion-plugin-dependency-graph:positions";function ft(n){if(!n||typeof n!="object")return!1;const i=n;return typeof i.x=="number"&&Number.isFinite(i.x)&&typeof i.y=="number"&&Number.isFinite(i.y)}function ce(n){const i=Yt(Mt,n);if(!i)return{};try{const r=JSON.parse(i);if(!r||typeof r!="object")return{};const a={};for(const[f,u]of Object.entries(r))ft(u)&&(a[f]=u);return a}catch{return{}}}function ue(n,i,r){const a={};for(const[f,u]of Object.entries(n))i.has(f)&&ft(u)&&(a[f]=u);_t(Mt,JSON.stringify(a),r)}function le(n){jt(Mt,n)}function de(n,i,r){const a={};for(const[f,u]of Object.entries(n))r.has(f)&&ft(u)&&(a[f]=u);for(const[f,u]of Object.entries(i))r.has(f)&&ft(u)&&(a[f]=u);return a}function fe(n,i){const r={};for(const[a,f]of Object.entries(n))i.has(a)&&(r[a]=f);return r}function he({projectId:n,visibleTaskIds:i}){const[r,a]=e.useState(null);e.useEffect(()=>{a(ce(n))},[n]);const f=e.useCallback(y=>{ue(y,i,n),a(fe(y,i))},[n,i]),u=e.useCallback(()=>{le(n),a(null)},[n]);return{savedPositions:r,persistPositions:f,clearSavedPositions:u}}const ct=280,rt=100,pe=768,Rt=4;function me({tasks:n,projectId:i,columnFlagsByTaskId:r,onOpenTaskDetail:a,onOpenDetail:f,addToast:u,globalPaused:y,onUpdateTask:b,onArchiveTask:I,onUnarchiveTask:z,onDeleteTask:M,onRetryTask:C,onOpenDetailWithTab:X,taskStuckTimeoutMs:o,onOpenMission:c,onMoveTask:d,lastFetchTimeMs:T}){const E=e.useRef(null),A=e.useRef(null),G=e.useRef(!1),Z=e.useRef(new Map),[W,$]=e.useState(null),[l,P]=e.useState(null),[x,U]=e.useState({width:0,height:0}),[O,V]=e.useState(new Map),q=e.useMemo(()=>ee(n),[n]),s=re(q),{getChain:p}=ae(q),w=W??l,k=e.useMemo(()=>w?p(w):new Set,[w,p]),S=e.useMemo(()=>{const t=x.width||(typeof window<"u"?window.innerWidth:0);return(x.height||(typeof window<"u"?window.innerHeight:0))>t||t<pe?"horizontal":"vertical"},[x.height,x.width]),Y=e.useMemo(()=>({nodeWidth:ct,nodeHeight:rt,horizontalGap:40,verticalGap:80,orientation:S,measuredHeights:O}),[O,S]),v=e.useMemo(()=>kt(s,Y),[s,Y]),_=e.useMemo(()=>new Set(q.map(t=>t.id)),[q]),{savedPositions:B,persistPositions:ot,clearSavedPositions:J}=he({projectId:i,visibleTaskIds:_}),[F,Q]=e.useState(v),[tt,ht]=e.useState(!1);e.useEffect(()=>{const t={};for(const[m,D]of v.entries())t[m]=D;const h=B?de(t,B,_):t;Q(new Map(Object.entries(h)))},[v,B,_]),e.useEffect(()=>{const t=E.current;if(!t)return;const h=(D,N)=>{U(g=>g.width===D&&g.height===N?g:{width:D,height:N})};if(typeof ResizeObserver>"u"){h(t.clientWidth||(typeof window<"u"?window.innerWidth:0),t.clientHeight||(typeof window<"u"?window.innerHeight:0));return}h(t.clientWidth,t.clientHeight);const m=new ResizeObserver(D=>{const N=D[0];N&&h(N.contentRect.width,N.contentRect.height)});return m.observe(t),()=>m.disconnect()},[]),e.useEffect(()=>{const t=E.current;if(!t)return;const h=new Set(s.nodes.map(g=>g.task.id)),m=new Map;for(const g of h){const R=t.querySelector(`[data-testid="graph-task-node-${g}"]`);R&&m.set(g,R)}Z.current=m,V(g=>{let R=!1;const j=new Map;for(const[K,at]of g.entries()){if(!h.has(K)){R=!0;continue}j.set(K,at)}return R?j:g});const D=(g,R)=>{V(j=>{const K=j.get(g);if(K!==void 0&&Math.abs(K-R)<1)return j;const at=new Map(j);return at.set(g,R),at})};for(const[g,R]of m.entries())D(g,R.offsetHeight||rt);if(typeof ResizeObserver>"u")return;const N=new ResizeObserver(g=>{for(const R of g){const j=R.target,K=Array.from(m.entries()).find(([,at])=>at===j)?.[0];K&&D(K,j.offsetHeight||rt)}});for(const g of m.values())N.observe(g);return()=>N.disconnect()},[s.nodes,F,x.height,x.width]);const{transform:st,zoom:dt,transitioning:pt,zoomIn:et,zoomOut:mt,resetView:It,fitToGraph:gt,onPointerDown:Ht,onPointerMove:zt,onPointerUp:bt,onWheelPan:Et,onWheelZoom:Ot,handleKeyDown:Nt,setGraphBounds:Pt}=ie(),L=e.useMemo(()=>{const t=Array.from(F.values());if(t.length===0)return{minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};const h=Math.min(...t.map(g=>g.x)),m=Math.min(...t.map(g=>g.y)),D=Math.max(...t.map(g=>g.x+ct)),N=Math.max(...Array.from(F.entries()).map(([g,R])=>R.y+(O.get(g)??rt)));return{minX:h,minY:m,maxX:D,maxY:N,width:Math.max(0,D-h),height:Math.max(0,N-m)}},[O,F]),it=e.useMemo(()=>{if(F.size===0)return F;const t=new Map;for(const[h,m]of F.entries())t.set(h,{x:m.x-L.minX,y:m.y-L.minY});return t},[L.minX,L.minY,F]);e.useEffect(()=>{Pt({minX:0,minY:0,maxX:L.width,maxY:L.height})},[L.height,L.width,Pt]);const Tt=e.useMemo(()=>Array.from(it.keys()).sort().join("|"),[it]),yt=e.useMemo(()=>[Tt,x.width,x.height,L.width,L.height,Array.from(O.entries()).sort(([t],[h])=>t.localeCompare(h)).map(([t,h])=>`${t}:${Math.round(h)}`).join("|")].join("::"),[L.height,L.width,Tt,O,x.height,x.width]),Ct=e.useRef(null);e.useEffect(()=>{if(q.length===0||it.size===0)return;const t=E.current;if(!t)return;const h=t.clientWidth||x.width,m=t.clientHeight||x.height;if(h===0||m===0||Ct.current===yt)return;let D=0,N=0;const g=()=>{const R=E.current;if(!R)return;const j=R.clientWidth||x.width,K=R.clientHeight||x.height;j===0||K===0||(gt(it,j,K,{nodeWidth:ct,nodeHeight:rt,measuredHeights:O}),Ct.current=yt)};return typeof requestAnimationFrame=="function"?D=requestAnimationFrame(()=>{N=requestAnimationFrame(g)}):g(),()=>{D&&cancelAnimationFrame(D),N&&cancelAnimationFrame(N)}},[q.length,yt,gt,O,it,x.height,x.width]);const St=e.useCallback(()=>{J();const t=kt(s,Y);Q(t)},[J,s,Y]),At=e.useCallback(()=>{const t={};for(const[h,m]of F.entries())t[h]=m;ot(t)},[ot,F]);return H.jsxs("section",{className:"dependency-graph","data-testid":"dependency-graph",children:[H.jsx("div",{ref:E,className:"dependency-graph__viewport",onPointerDown:t=>{tt||(A.current={x:t.clientX,y:t.clientY},G.current=!1,Ht(t.pointerId,{x:t.clientX,y:t.clientY}))},onPointerMove:t=>{if(tt)return;const h=E.current;if(!h)return;const m=A.current;if(m){const D=Math.abs(t.clientX-m.x),N=Math.abs(t.clientY-m.y);(D>Rt||N>Rt)&&(G.current=!0)}zt(t.pointerId,{x:t.clientX,y:t.clientY},h.clientWidth,h.clientHeight)},onPointerUp:t=>{tt||bt(t.pointerId),A.current=null},onPointerCancel:t=>{tt||bt(t.pointerId),A.current=null,G.current=!1},onWheel:t=>{t.preventDefault();const h=E.current;if(h){if(t.ctrlKey||t.metaKey){const m=h.getBoundingClientRect();Ot(t.deltaY,{x:t.clientX-m.left,y:t.clientY-m.top},h.clientWidth,h.clientHeight);return}Et(t.deltaX,t.deltaY,h.clientWidth,h.clientHeight)}},onKeyDown:t=>{const h=E.current;h&&Nt(t,h.clientWidth,h.clientHeight,it,{nodeWidth:ct,nodeHeight:rt,measuredHeights:O})},tabIndex:0,onClick:()=>{G.current||tt||P(null)},children:q.length===0?H.jsx("div",{className:"dependency-graph__empty",children:"No active tasks to display in graph view."}):H.jsxs("div",{className:`graph-canvas-transform${pt?" graph-canvas-transform--animate":""}`,style:{transform:st,width:`${L.width}px`,height:`${L.height}px`},children:[H.jsx(Qt,{edges:s.edges,positions:it,nodeWidth:ct,nodeHeight:rt,nodeHeights:O,highlightedEdgeIds:k.size>0?new Set(s.edges.filter(t=>k.has(t.source)&&k.has(t.target)).map(t=>`${t.source}->${t.target}`)):void 0}),H.jsx("div",{className:"dependency-graph__nodes-layer",children:s.nodes.map(t=>{const h=it.get(t.task.id);return h?H.jsx(Kt,{task:t.task,projectId:i,taskColumnFlags:r?.get(t.task.id),isSelected:l===t.task.id,style:{minHeight:`${rt}px`,left:`${h.x}px`,top:`${h.y}px`},position:h,scale:dt,onNodePositionChange:(m,D)=>{Q(N=>{const g={x:D.x+L.minX,y:D.y+L.minY},R=N.get(m);if(R&&R.x===g.x&&R.y===g.y)return N;const j=new Map(N);return j.set(m,g),j})},onNodeDragStateChange:ht,onNodeDragEnd:At,isHighlighted:k.size>0&&k.has(t.task.id),isDimmed:k.size>0&&!k.has(t.task.id),onOpenDetail:f??(m=>a?.(m.id)),addToast:u??(()=>{}),globalPaused:y,onUpdateTask:b,onArchiveTask:I,onUnarchiveTask:z,onDeleteTask:M,onRetryTask:C,onOpenDetailWithTab:X,taskStuckTimeoutMs:o,onOpenMission:c,onMoveTask:d,lastFetchTimeMs:T,onMouseEnter:()=>$(t.task.id),onMouseLeave:()=>$(null),onClick:m=>{m.stopPropagation(),G.current=!1,P(D=>D===t.task.id?null:t.task.id)}},t.task.id):null})})]})}),H.jsx(Vt,{zoom:dt,onZoomIn:()=>{const t=E.current;t&&et(t.clientWidth,t.clientHeight)},onZoomOut:()=>{const t=E.current;t&&mt(t.clientWidth,t.clientHeight)},onFitToGraph:()=>{St();const t=E.current;if(!t)return;const h=kt(s,Y),m=new Map,D=Array.from(h.values()),N=D.length>0?Math.min(...D.map(R=>R.x)):0,g=D.length>0?Math.min(...D.map(R=>R.y)):0;for(const[R,j]of h.entries())m.set(R,{x:j.x-N,y:j.y-g});gt(m,t.clientWidth,t.clientHeight,{nodeWidth:ct,nodeHeight:rt,measuredHeights:O})},onResetView:()=>{St(),It()}})]})}function Te({context:n}){return e.createElement(me,{tasks:n?.tasks??[],projectId:n?.projectId,columnFlagsByTaskId:n?.columnFlagsByTaskId,onOpenDetail:n?.openTaskDetail})}export{me as DependencyGraph,Te as DependencyGraphDashboardView,Te as default};