execweave 1.0.0__py3-none-any.whl

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 (234) hide show
  1. execweave/__init__.py +3 -0
  2. execweave/__main__.py +5 -0
  3. execweave/_conversation_records_core.py +902 -0
  4. execweave/_dashboard_shell_base.py +148 -0
  5. execweave/_http_proxy_base.py +565 -0
  6. execweave/_http_proxy_bounded.py +560 -0
  7. execweave/_http_proxy_stage.py +509 -0
  8. execweave/acceptance_output.py +19 -0
  9. execweave/agent_bootstrap.py +395 -0
  10. execweave/agent_topology.py +313 -0
  11. execweave/agent_trace.py +1162 -0
  12. execweave/agy_preview_sanitize.py +102 -0
  13. execweave/analysis.py +427 -0
  14. execweave/anthropic.py +228 -0
  15. execweave/anthropic_cli.py +171 -0
  16. execweave/anthropic_full_fidelity.py +385 -0
  17. execweave/antigravity_adapter.py +112 -0
  18. execweave/antigravity_adapter_base.py +479 -0
  19. execweave/antigravity_full_fidelity.py +656 -0
  20. execweave/antigravity_full_fidelity_base.py +172 -0
  21. execweave/antigravity_full_fidelity_collaboration_base.py +451 -0
  22. execweave/antigravity_hook_cli.py +209 -0
  23. execweave/antigravity_record.py +96 -0
  24. execweave/antigravity_subagent_linkage.py +449 -0
  25. execweave/antigravity_trace_capability.py +39 -0
  26. execweave/auto_specialized.py +547 -0
  27. execweave/backends.py +102 -0
  28. execweave/benchmark.py +80 -0
  29. execweave/claude_adapter.py +517 -0
  30. execweave/claude_child_transcript.py +314 -0
  31. execweave/claude_delegation.py +136 -0
  32. execweave/claude_full_fidelity.py +396 -0
  33. execweave/claude_hook_cli.py +209 -0
  34. execweave/claude_hook_contract.py +943 -0
  35. execweave/claude_model_observer.py +353 -0
  36. execweave/claude_record.py +106 -0
  37. execweave/cli.py +629 -0
  38. execweave/codex_adapter.py +455 -0
  39. execweave/codex_conversation.py +621 -0
  40. execweave/codex_full_fidelity.py +287 -0
  41. execweave/codex_hook_cli.py +301 -0
  42. execweave/codex_hook_entry.py +207 -0
  43. execweave/codex_hook_lifecycle.py +363 -0
  44. execweave/codex_message_diagnostics.py +322 -0
  45. execweave/codex_message_transport_diagnostics.py +399 -0
  46. execweave/codex_record.py +199 -0
  47. execweave/codex_rollout_structures.py +402 -0
  48. execweave/codex_rollout_trace.py +56 -0
  49. execweave/codex_rollout_trace_base.py +1509 -0
  50. execweave/collector.py +768 -0
  51. execweave/command.py +157 -0
  52. execweave/command_privacy.py +20 -0
  53. execweave/content_evidence.py +101 -0
  54. execweave/content_integrity.py +289 -0
  55. execweave/content_store.py +273 -0
  56. execweave/controlled_checks.py +561 -0
  57. execweave/conversation_archive.py +338 -0
  58. execweave/conversation_message_identity.py +264 -0
  59. execweave/conversation_preview.py +66 -0
  60. execweave/conversation_preview_antigravity.py +32 -0
  61. execweave/conversation_preview_claude.py +31 -0
  62. execweave/conversation_preview_codex.py +107 -0
  63. execweave/conversation_preview_common.py +180 -0
  64. execweave/conversation_preview_generic.py +188 -0
  65. execweave/conversation_preview_lines.py +133 -0
  66. execweave/conversation_preview_transcript.py +121 -0
  67. execweave/conversation_records.py +349 -0
  68. execweave/conversation_records_antigravity.py +370 -0
  69. execweave/conversation_records_codex.py +83 -0
  70. execweave/conversation_records_common.py +17 -0
  71. execweave/conversation_records_ollama.py +39 -0
  72. execweave/correlation.py +818 -0
  73. execweave/cursor_adapter.py +349 -0
  74. execweave/cursor_delegation.py +87 -0
  75. execweave/cursor_delegation_base.py +220 -0
  76. execweave/cursor_full_fidelity.py +489 -0
  77. execweave/cursor_hook_cli.py +195 -0
  78. execweave/cursor_hook_contract.py +439 -0
  79. execweave/cursor_lifecycle.py +159 -0
  80. execweave/cursor_record.py +96 -0
  81. execweave/dashboard_shell.py +283 -0
  82. execweave/delivery_status.py +94 -0
  83. execweave/entry.py +98 -0
  84. execweave/evidence_availability.py +113 -0
  85. execweave/evidence_grade.py +166 -0
  86. execweave/fidelity.py +304 -0
  87. execweave/filesystem.py +327 -0
  88. execweave/finalization.py +92 -0
  89. execweave/focus.py +118 -0
  90. execweave/framework_adapters/__init__.py +34 -0
  91. execweave/framework_adapters/autogen.py +398 -0
  92. execweave/framework_adapters/base.py +580 -0
  93. execweave/framework_adapters/camel.py +270 -0
  94. execweave/framework_adapters/camel_channel.py +71 -0
  95. execweave/framework_adapters/metagpt.py +315 -0
  96. execweave/framework_adapters/metagpt_ollama_compat.py +54 -0
  97. execweave/framework_adapters/metagpt_recording.py +342 -0
  98. execweave/framework_adapters/registry.py +90 -0
  99. execweave/graph.py +590 -0
  100. execweave/graph_ops.py +472 -0
  101. execweave/hook_command.py +32 -0
  102. execweave/hook_delivery.py +32 -0
  103. execweave/hook_input.py +16 -0
  104. execweave/http_proxy.py +187 -0
  105. execweave/http_proxy_cli.py +84 -0
  106. execweave/inference_gateway.py +476 -0
  107. execweave/inference_gateway_cli.py +211 -0
  108. execweave/inference_gateway_full_fidelity.py +613 -0
  109. execweave/inference_identity.py +76 -0
  110. execweave/inference_identity_cli.py +60 -0
  111. execweave/integrity.py +235 -0
  112. execweave/integrity_cli.py +55 -0
  113. execweave/investigation_index.py +445 -0
  114. execweave/litellm_callback.py +211 -0
  115. execweave/litellm_callback_cli.py +42 -0
  116. execweave/live.py +445 -0
  117. execweave/live_core.py +972 -0
  118. execweave/live_view.py +109 -0
  119. execweave/live_view_extra_style.py +11 -0
  120. execweave/live_view_markup.py +29 -0
  121. execweave/live_view_process_layout.py +650 -0
  122. execweave/live_view_readability.py +502 -0
  123. execweave/live_view_script_a.py +59 -0
  124. execweave/live_view_script_b.py +97 -0
  125. execweave/live_view_script_c.py +59 -0
  126. execweave/live_view_script_d.py +40 -0
  127. execweave/live_view_style.py +34 -0
  128. execweave/model_runtime.py +560 -0
  129. execweave/model_runtime_cli.py +265 -0
  130. execweave/model_runtime_full_fidelity.py +519 -0
  131. execweave/observation.py +53 -0
  132. execweave/observation_demo.py +69 -0
  133. execweave/openai_agents.py +267 -0
  134. execweave/openai_agents_sdk.py +453 -0
  135. execweave/openai_compatible.py +239 -0
  136. execweave/openai_compatible_cli.py +189 -0
  137. execweave/openai_compatible_full_fidelity.py +438 -0
  138. execweave/opencode_adapter.py +325 -0
  139. execweave/opencode_event_contract.py +734 -0
  140. execweave/opencode_full_fidelity.py +198 -0
  141. execweave/opencode_hook_cli.py +119 -0
  142. execweave/opencode_plugin_cli.py +150 -0
  143. execweave/opencode_record.py +96 -0
  144. execweave/opencode_task_linkage.py +225 -0
  145. execweave/overhead_benchmark.py +440 -0
  146. execweave/privacy.py +84 -0
  147. execweave/private_io.py +465 -0
  148. execweave/provider_capability.py +578 -0
  149. execweave/provider_lifecycle.py +282 -0
  150. execweave/provider_record.py +290 -0
  151. execweave/reader_identity.py +13 -0
  152. execweave/redacted_archive.py +906 -0
  153. execweave/risk.py +106 -0
  154. execweave/rule_pack.py +359 -0
  155. execweave/rule_pack_cli.py +57 -0
  156. execweave/run_assessment.py +200 -0
  157. execweave/runtime_endpoint_availability.py +44 -0
  158. execweave/scalability_benchmark.py +195 -0
  159. execweave/schema.py +62 -0
  160. execweave/scope.py +85 -0
  161. execweave/semantic.py +453 -0
  162. execweave/session_summary.py +159 -0
  163. execweave/sink.py +71 -0
  164. execweave/strace_backend.py +927 -0
  165. execweave/stream_assembly.py +363 -0
  166. execweave/task_artifacts.py +192 -0
  167. execweave/task_validation.py +317 -0
  168. execweave/theme.py +40 -0
  169. execweave/top.py +599 -0
  170. execweave/top_cli.py +150 -0
  171. execweave/validate.py +196 -0
  172. execweave/vendor/dagre.min.js +815 -0
  173. execweave/view_cli.py +49 -0
  174. execweave/viewer.py +474 -0
  175. execweave/viewer_agent_panel.py +630 -0
  176. execweave/viewer_agent_panel_antigravity.py +31 -0
  177. execweave/viewer_agent_panel_claude.py +9 -0
  178. execweave/viewer_agent_panel_codex.py +50 -0
  179. execweave/viewer_agent_panel_cursor.py +9 -0
  180. execweave/viewer_agent_panel_default.py +79 -0
  181. execweave/viewer_agent_panel_ollama.py +20 -0
  182. execweave/viewer_agent_panel_opencode.py +9 -0
  183. execweave/viewer_agent_panel_registry.py +20 -0
  184. execweave/viewer_archive_verifier.py +178 -0
  185. execweave/viewer_background_files.py +86 -0
  186. execweave/viewer_content_browser.py +307 -0
  187. execweave/viewer_content_health.py +208 -0
  188. execweave/viewer_content_inspector.py +309 -0
  189. execweave/viewer_controlled_checks.py +258 -0
  190. execweave/viewer_conversation_sync.py +115 -0
  191. execweave/viewer_dashboard_clean.py +405 -0
  192. execweave/viewer_dashboard_focus.py +127 -0
  193. execweave/viewer_dashboard_hardening.py +264 -0
  194. execweave/viewer_dashboard_hardening_v2.py +62 -0
  195. execweave/viewer_dashboard_projection.py +261 -0
  196. execweave/viewer_delivery_status.py +155 -0
  197. execweave/viewer_edge_decross.py +117 -0
  198. execweave/viewer_execution_flow.py +611 -0
  199. execweave/viewer_execution_flow_provider_normalization.py +107 -0
  200. execweave/viewer_execution_flow_safety.py +349 -0
  201. execweave/viewer_external_endpoints.py +307 -0
  202. execweave/viewer_flow_canvas.py +1140 -0
  203. execweave/viewer_flow_layout.py +922 -0
  204. execweave/viewer_fold_state.py +31 -0
  205. execweave/viewer_framework_flow.py +68 -0
  206. execweave/viewer_framework_model_output.py +133 -0
  207. execweave/viewer_gif.py +278 -0
  208. execweave/viewer_history_browser.py +225 -0
  209. execweave/viewer_investigation.py +268 -0
  210. execweave/viewer_layout_geometry.py +192 -0
  211. execweave/viewer_layout_v2.py +429 -0
  212. execweave/viewer_layout_v2_detached.py +25 -0
  213. execweave/viewer_limits.py +93 -0
  214. execweave/viewer_live_layout.py +61 -0
  215. execweave/viewer_message_handoffs.py +114 -0
  216. execweave/viewer_projection.py +488 -0
  217. execweave/viewer_projection_base.py +522 -0
  218. execweave/viewer_projection_bridges.py +214 -0
  219. execweave/viewer_recorded_sources.py +146 -0
  220. execweave/viewer_run_assessment.py +274 -0
  221. execweave/viewer_run_guide.py +175 -0
  222. execweave/viewer_runtime_evidence.py +258 -0
  223. execweave/viewer_semantic_projection.py +641 -0
  224. execweave/viewer_session_flow.py +491 -0
  225. execweave/viewer_structure_share.py +132 -0
  226. execweave/viewer_task_validation.py +241 -0
  227. execweave/viewer_tool_mirror_identity.py +75 -0
  228. execweave/viewer_workflow_mode.py +127 -0
  229. execweave/workflow.py +183 -0
  230. execweave-1.0.0.dist-info/METADATA +462 -0
  231. execweave-1.0.0.dist-info/RECORD +234 -0
  232. execweave-1.0.0.dist-info/WHEEL +4 -0
  233. execweave-1.0.0.dist-info/entry_points.txt +30 -0
  234. execweave-1.0.0.dist-info/licenses/LICENSE +16 -0
@@ -0,0 +1,650 @@
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ # Injected after LIVE_READABILITY_SCRIPT. Process trees stay left-to-right by spawn
6
+ # depth; Arrange and the first computed frame then run a layered LR DAG so visible
7
+ # nodes do not overlap. Dagre is vendored; Fit remains the camera button.
8
+
9
+ _DAGRE_JS = (Path(__file__).resolve().parent / "vendor" / "dagre.min.js").read_text(
10
+ encoding="utf-8"
11
+ )
12
+
13
+ _LIVE_PROCESS_LAYOUT_BODY = r"""
14
+ (()=>{
15
+ const PROCESS_COL_GAP=48;
16
+ const PROCESS_ROW_GAP=72;
17
+ function isProcess(node){
18
+ const type=String(node?.type||'').toLowerCase();
19
+ return type==='process'||type==='session'||type==='runtime';
20
+ }
21
+ function processParentEdges(){
22
+ const parents=new Map();
23
+ for(const edge of edgeById.values()){
24
+ const relation=String(edge?.relation||'').toUpperCase();
25
+ if(relation!=='SPAWNED'&&relation!=='LAUNCHED')continue;
26
+ const source=nodeById.get(edge.source),target=nodeById.get(edge.target);
27
+ if(!isProcess(source)||!isProcess(target))continue;
28
+ const current=parents.get(target.id);
29
+ const moment=Number.isInteger(edge.first_sequence)?edge.first_sequence:Number.MAX_SAFE_INTEGER;
30
+ if(!current||moment<current.moment)parents.set(target.id,{parent:source.id,moment});
31
+ }
32
+ return parents;
33
+ }
34
+ function execweaveLayoutProcessTree(topo){
35
+ if(!topo||!topo.spec)return topo;
36
+ const processes=[...nodeById.values()].filter(node=>isProcess(node)&&topo.spec.has(node.id));
37
+ if(processes.length<2)return topo;
38
+ const parentOf=processParentEdges();
39
+ const children=new Map();
40
+ for(const node of processes){
41
+ const parent=parentOf.get(node.id)?.parent;
42
+ if(!parent||!topo.spec.has(parent))continue;
43
+ if(!children.has(parent))children.set(parent,[]);
44
+ children.get(parent).push(node.id);
45
+ }
46
+ for(const list of children.values()){
47
+ list.sort((a,b)=>{
48
+ const am=parentOf.get(a)?.moment??Number.MAX_SAFE_INTEGER;
49
+ const bm=parentOf.get(b)?.moment??Number.MAX_SAFE_INTEGER;
50
+ return am-bm||String(nodeById.get(a)?.name||a).localeCompare(String(nodeById.get(b)?.name||b));
51
+ });
52
+ }
53
+ const roots=processes.filter(node=>!parentOf.has(node.id)||!topo.spec.has(parentOf.get(node.id).parent)).map(node=>node.id);
54
+ roots.sort((a,b)=>String(nodeById.get(a)?.name||a).localeCompare(String(nodeById.get(b)?.name||b)));
55
+ const depth=new Map();
56
+ const order=[];
57
+ const walk=(id,level)=>{
58
+ if(depth.has(id))return;
59
+ depth.set(id,level);
60
+ order.push(id);
61
+ for(const child of(children.get(id)||[]))walk(child,level+1);
62
+ };
63
+ for(const id of roots)walk(id,0);
64
+ for(const node of processes)if(!depth.has(node.id))walk(node.id,0);
65
+ const colWidth=new Map();
66
+ for(const id of order){
67
+ const level=depth.get(id)||0;
68
+ colWidth.set(level,Math.max(colWidth.get(level)||EXECWEAVE_NODE_W,execweaveWidthOf(id)));
69
+ }
70
+ const colX=new Map();
71
+ let x=typeof execweaveLaneXOf==='function'?execweaveLaneXOf('runtime'):0;
72
+ const maxDepth=Math.max(0,...depth.values());
73
+ for(let level=0;level<=maxDepth;level++){
74
+ colX.set(level,x);
75
+ x+=(colWidth.get(level)||EXECWEAVE_NODE_W)+PROCESS_COL_GAP;
76
+ }
77
+ const subtree=new Map();
78
+ const measure=id=>{
79
+ const kids=children.get(id)||[];
80
+ if(!kids.length){subtree.set(id,1);return 1}
81
+ let size=0;for(const child of kids)size+=measure(child);
82
+ subtree.set(id,Math.max(1,size));return subtree.get(id);
83
+ };
84
+ for(const id of roots)measure(id);
85
+ const placed=new Set();
86
+ let row=0;
87
+ const place=(id,rowStart)=>{
88
+ if(placed.has(id))return;
89
+ placed.add(id);
90
+ const kids=children.get(id)||[];
91
+ const spec=topo.spec.get(id);if(!spec)return;
92
+ const span=subtree.get(id)||1;
93
+ spec.x=colX.get(depth.get(id)||0)||spec.x;
94
+ spec.y=100+rowStart*PROCESS_ROW_GAP+Math.max(0,span-1)*PROCESS_ROW_GAP/2;
95
+ spec.processDepth=depth.get(id)||0;
96
+ let childRow=rowStart;
97
+ for(const child of kids){
98
+ place(child,childRow);
99
+ childRow+=subtree.get(child)||1;
100
+ }
101
+ };
102
+ for(const id of roots){
103
+ place(id,row);
104
+ row+=subtree.get(id)||1;
105
+ }
106
+ return topo;
107
+ }
108
+ function execweaveNodeType(node){return String(node?.type||'').toLowerCase()}
109
+ function execweaveIsEndpointNode(node){
110
+ const type=execweaveNodeType(node);
111
+ return type.includes('network')||type.includes('endpoint')||type.includes('socket')||type.includes('host')||node?.name==='External';
112
+ }
113
+ function execweaveNeighborIds(id,topo){
114
+ const out=[];
115
+ for(const edge of edgeById.values()){
116
+ if(!topo.spec.has(edge.source)||!topo.spec.has(edge.target))continue;
117
+ if(edge.source===id)out.push(edge.target);
118
+ else if(edge.target===id)out.push(edge.source);
119
+ }
120
+ return out;
121
+ }
122
+ function execweaveAlignRelatedY(id,topo,prefer){
123
+ const spec=topo.spec.get(id);if(!spec)return;
124
+ const ys=[];
125
+ for(const other of execweaveNeighborIds(id,topo)){
126
+ const node=nodeById.get(other),os=topo.spec.get(other);
127
+ if(!node||!os)continue;
128
+ const type=execweaveNodeType(node);
129
+ if(prefer&&![...prefer].some(token=>type.includes(token)||(token==='agent'&&type==='agent')))continue;
130
+ ys.push(os.y);
131
+ }
132
+ if(!ys.length)return;
133
+ spec.y=ys.reduce((sum,value)=>sum+value,0)/ys.length;
134
+ }
135
+ function execweavePullBesideNeighbors(id,topo,prefer){
136
+ const spec=topo.spec.get(id);if(!spec)return;
137
+ let right=-Infinity,hits=0;
138
+ for(const other of execweaveNeighborIds(id,topo)){
139
+ const node=nodeById.get(other),os=topo.spec.get(other);
140
+ if(!node||!os)continue;
141
+ const type=execweaveNodeType(node);
142
+ if(prefer&&![...prefer].some(token=>type.includes(token)||(token==='agent'&&type==='agent')))continue;
143
+ right=Math.max(right,os.x+(typeof execweaveWidthOf==='function'?execweaveWidthOf(other):EXECWEAVE_NODE_W));
144
+ hits++;
145
+ }
146
+ if(!hits||!Number.isFinite(right))return;
147
+ const desired=right+PROCESS_COL_GAP;
148
+ if(spec.x>desired)spec.x=desired;
149
+ }
150
+ function execweaveSeparateLane(topo){
151
+ const byLane=new Map();
152
+ for(const [id,spec] of topo.spec){
153
+ if(!byLane.has(spec.lane))byLane.set(spec.lane,[]);
154
+ byLane.get(spec.lane).push(id);
155
+ }
156
+ for(const ids of byLane.values()){
157
+ ids.sort((a,b)=>(topo.spec.get(a).y-topo.spec.get(b).y)||String(a).localeCompare(String(b)));
158
+ for(let index=1;index<ids.length;index++){
159
+ const prev=topo.spec.get(ids[index-1]),cur=topo.spec.get(ids[index]);
160
+ const prevH=typeof execweaveHeightOf==='function'?execweaveHeightOf(ids[index-1]):EXECWEAVE_NODE_H;
161
+ const floor=prev.y+prevH+24;
162
+ if(cur.y<floor)cur.y=floor;
163
+ }
164
+ }
165
+ }
166
+ function execweaveLayoutRelated(topo){
167
+ if(!topo||!topo.spec)return topo;
168
+ for(const node of nodeById.values()){
169
+ if(!topo.spec.has(node.id))continue;
170
+ const type=execweaveNodeType(node);
171
+ if(type==='agent'&&!execweaveIsRoot(node))execweaveAlignRelatedY(node.id,topo,['agent']);
172
+ else if(type.includes('tool'))execweaveAlignRelatedY(node.id,topo,['agent']);
173
+ else if(type.includes('file')||type.includes('path'))execweaveAlignRelatedY(node.id,topo,['agent','process']);
174
+ else if(execweaveIsEndpointNode(node))execweaveAlignRelatedY(node.id,topo,['process','session','runtime','agent']);
175
+ }
176
+ for(const node of nodeById.values()){
177
+ if(!topo.spec.has(node.id))continue;
178
+ const type=execweaveNodeType(node);
179
+ if(type.includes('tool')||type.includes('model'))execweavePullBesideNeighbors(node.id,topo,['agent']);
180
+ else if(execweaveIsEndpointNode(node))execweavePullBesideNeighbors(node.id,topo,['process','session','runtime']);
181
+ }
182
+ execweaveSeparateLane(topo);
183
+ return topo;
184
+ }
185
+ const EXECWEAVE_DAG_GAP=24;
186
+ function execweaveEdgeKey(source,target){return`${source}\0${target}`}
187
+ function execweaveRecomputePorts(topo){
188
+ if(!topo||!topo.spec)return topo;
189
+ const sourceEdges=new Map(),targetEdges=new Map();
190
+ for(const edge of edgeById.values()){
191
+ if(!topo.spec.has(edge.source)||!topo.spec.has(edge.target))continue;
192
+ if(!sourceEdges.has(edge.source))sourceEdges.set(edge.source,[]);
193
+ sourceEdges.get(edge.source).push(edge);
194
+ if(!targetEdges.has(edge.target))targetEdges.set(edge.target,[]);
195
+ targetEdges.get(edge.target).push(edge);
196
+ }
197
+ const sourcePort=new Map(),targetPort=new Map();
198
+ for(const list of sourceEdges.values()){
199
+ list.sort((a,b)=>{
200
+ const at=topo.spec.get(a.target),bt=topo.spec.get(b.target);
201
+ return(at?.y??0)-(bt?.y??0)||(at?.x??0)-(bt?.x??0)||edgeId(a).localeCompare(edgeId(b));
202
+ });
203
+ list.forEach((edge,index)=>sourcePort.set(edgeId(edge),{index,total:list.length}));
204
+ }
205
+ for(const list of targetEdges.values()){
206
+ list.sort((a,b)=>{
207
+ const as=topo.spec.get(a.source),bs=topo.spec.get(b.source);
208
+ return(as?.y??0)-(bs?.y??0)||(as?.x??0)-(bs?.x??0)||edgeId(a).localeCompare(edgeId(b));
209
+ });
210
+ list.forEach((edge,index)=>targetPort.set(edgeId(edge),{index,total:list.length}));
211
+ }
212
+ topo.sourcePort=sourcePort;
213
+ topo.targetPort=targetPort;
214
+ return topo;
215
+ }
216
+ function execweaveSeparateOverlappingNodes(topo){
217
+ if(!topo||!topo.spec)return false;
218
+ let shifted=false;
219
+ for(let pass=0;pass<32;pass++){
220
+ const boxes=[...topo.spec.keys()].filter(id=>nodeById.has(id)).map(id=>({
221
+ id,
222
+ spec:topo.spec.get(id),
223
+ x:topo.spec.get(id).x,
224
+ y:topo.spec.get(id).y,
225
+ w:execweaveWidthOf(id),
226
+ h:execweaveHeightOf(id),
227
+ }));
228
+ boxes.sort((a,b)=>a.y-b.y||a.x-b.x||String(a.id).localeCompare(String(b.id)));
229
+ let moved=false;
230
+ for(let i=0;i<boxes.length;i++){
231
+ for(let j=0;j<i;j++){
232
+ const A=boxes[j],B=boxes[i];
233
+ const ix=Math.max(0,Math.min(A.x+A.w,B.x+B.w)-Math.max(A.x,B.x));
234
+ const iy=Math.max(0,Math.min(A.y+A.h,B.y+B.h)-Math.max(A.y,B.y));
235
+ if(ix*iy<=0)continue;
236
+ B.spec.y=A.y+A.h+EXECWEAVE_DAG_GAP;
237
+ B.y=B.spec.y;
238
+ moved=true;
239
+ shifted=true;
240
+ }
241
+ }
242
+ if(!moved)break;
243
+ }
244
+ return shifted;
245
+ }
246
+ function execweaveLayoutDirectedGraph(topo){
247
+ if(!topo||!topo.spec)return topo;
248
+ topo.routePoints=new Map();
249
+ const engine=(typeof dagre!=='undefined'&&dagre&&dagre.graphlib&&typeof dagre.layout==='function')?dagre:null;
250
+ if(!engine){
251
+ console.warn('execweaveLayoutDirectedGraph: dagre unavailable, using process-tree layout');
252
+ execweaveSeparateLane(topo);
253
+ return topo;
254
+ }
255
+ try{
256
+ const graph=new engine.graphlib.Graph();
257
+ graph.setGraph({rankdir:'LR',nodesep:EXECWEAVE_DAG_GAP,ranksep:48,marginx:0,marginy:16,edgesep:16});
258
+ graph.setDefaultEdgeLabel(()=>({}));
259
+ const ids=[];
260
+ for(const id of [...topo.spec.keys()].sort()){
261
+ if(!nodeById.has(id))continue;
262
+ graph.setNode(id,{width:execweaveWidthOf(id),height:execweaveHeightOf(id)});
263
+ ids.push(id);
264
+ }
265
+ const seen=new Set();
266
+ for(const edge of [...edgeById.values()].sort((a,b)=>edgeId(a).localeCompare(edgeId(b)))){
267
+ if(typeof execweaveIsStopped==='function'&&execweaveIsStopped(edge))continue;
268
+ if(!topo.spec.has(edge.source)||!topo.spec.has(edge.target)||edge.source===edge.target)continue;
269
+ const key=execweaveEdgeKey(edge.source,edge.target);
270
+ if(seen.has(key))continue;
271
+ seen.add(key);
272
+ graph.setEdge(edge.source,edge.target);
273
+ }
274
+ // dagre.layout runs Sugiyama: rank → order (crossing minimization) → position → edge points.
275
+ engine.layout(graph);
276
+ for(const id of ids){
277
+ const placed=graph.node(id),spec=topo.spec.get(id);
278
+ if(!placed||!spec)continue;
279
+ spec.x=placed.x-placed.width/2;
280
+ spec.y=placed.y-placed.height/2;
281
+ }
282
+ // Keep Sugiyama step 4 (routing points). First/last are node-box hits; midpoints bend around ranks.
283
+ for(const edge of graph.edges()){
284
+ const label=graph.edge(edge);
285
+ const points=label&&Array.isArray(label.points)?label.points:[];
286
+ if(points.length<2)continue;
287
+ topo.routePoints.set(execweaveEdgeKey(edge.v,edge.w),points.map(point=>({x:point.x,y:point.y})));
288
+ }
289
+ }catch(error){
290
+ console.warn('execweaveLayoutDirectedGraph: dagre failed, using process-tree layout',error);
291
+ execweaveSeparateLane(topo);
292
+ }
293
+ return topo;
294
+ }
295
+ function execweaveRetargetRoutePoints(topo,dagrePlacement){
296
+ if(!topo||!topo.routePoints||!dagrePlacement)return;
297
+ }
298
+ function execweaveRestoreSemanticLayoutConstraints(topo,preferred,dagrePlacement){
299
+ if(!topo||!topo.spec||!preferred||!dagrePlacement)return topo;
300
+ if(typeof nodeById==='undefined'||typeof edgeById==='undefined'||typeof execweaveComponents!=='function')return topo;
301
+ topo.secondaryPackedIds=new Set();
302
+ const nodes=[...nodeById.values()],edges=[...edgeById.values()];
303
+ const componentOf=execweaveComponents(nodes,edges);
304
+
305
+ // Constrain X to measured semantic corridors. Dagre supplies ordering and route
306
+ // control points; process-tree depth is retained within the runtime corridor.
307
+ // All render paths consume these final coordinates, including Arrange.
308
+ let floor=-Infinity;
309
+ for(const [id,before] of preferred){
310
+ const after=topo.spec.get(id),node=nodeById.get(id);
311
+ if(!after||!node||!isProcess(node))continue;
312
+ after.x=before.x;
313
+ floor=Math.max(floor,after.x+(topo.width?.get(id)||EXECWEAVE_NODE_W)+PROCESS_COL_GAP);
314
+ }
315
+ for(const lane of ['root','agent','model','tool','file','endpoint','other']){
316
+ const ids=[...topo.spec.keys()].filter(id=>topo.spec.get(id)?.lane===lane&&!isProcess(nodeById.get(id)));
317
+ if(!ids.length)continue;
318
+ const laneX=Number.isFinite(topo.laneX?.[lane])?topo.laneX[lane]:Math.min(...ids.map(id=>preferred.get(id).x));
319
+ const x=Math.max(laneX,Number.isFinite(floor)?floor:laneX);
320
+ let right=x;
321
+ for(const id of ids){const after=topo.spec.get(id);after.x=x;right=Math.max(right,x+(topo.width?.get(id)||EXECWEAVE_NODE_W))}
322
+ floor=right+PROCESS_COL_GAP;
323
+ }
324
+
325
+ // Y constraint: Dagre coordinates optimize positions within semantic lane/component bounds
326
+ const reorderable=new Set(['agent','model','tool','file','endpoint','other']);
327
+ const groups=new Map();
328
+ for(const [id,before] of preferred){
329
+ const spec=topo.spec.get(id);
330
+ if(!spec)continue;
331
+ const lane=spec.lane||before.lane;
332
+ if(!reorderable.has(lane)){
333
+ spec.y=before.y;
334
+ continue;
335
+ }
336
+ const component=componentOf.has(id)?componentOf.get(id):-1;
337
+ const key=`${lane}\0${component}`;
338
+ if(!groups.has(key))groups.set(key,[]);
339
+ groups.get(key).push(id);
340
+ }
341
+
342
+ for(const ids of groups.values()){
343
+ const slots=ids.map(id=>preferred.get(id)?.y).filter(Number.isFinite).sort((a,b)=>a-b);
344
+ if(!slots.length)continue;
345
+ const ordered=[...ids].sort((a,b)=>{
346
+ const ay=dagrePlacement.get(a)?.y??0,by=dagrePlacement.get(b)?.y??0;
347
+ return ay-by||String(a).localeCompare(String(b));
348
+ });
349
+ const minY=slots[0],maxY=slots[slots.length-1];
350
+ const nodeH=typeof execweaveHeightOf==='function'?execweaveHeightOf(ids[0]):(typeof EXECWEAVE_NODE_H!=='undefined'?EXECWEAVE_NODE_H:50);
351
+ const minStep=nodeH+16;
352
+ let prevY=-Infinity;
353
+
354
+ ordered.forEach((id,index)=>{
355
+ const spec=topo.spec.get(id);
356
+ if(!spec)return;
357
+ const targetY=dagrePlacement.get(id)?.y;
358
+ const slotY=slots[index];
359
+ if(Number.isFinite(targetY)&&targetY>=minY-20&&targetY<=maxY+30&&targetY>=prevY+minStep){
360
+ spec.y=targetY;
361
+ }else if(Number.isFinite(targetY)){
362
+ const bounded=Math.max(prevY+minStep,Math.min(maxY+30,Math.max(minY,targetY)));
363
+ spec.y=bounded;
364
+ }else if(Number.isFinite(slotY)){
365
+ spec.y=slotY;
366
+ }
367
+ prevY=spec.y;
368
+ });
369
+ }
370
+
371
+ // Secondary components 2D grid packing (wrapping with spineWidth)
372
+ if(!componentOf.size)return topo;
373
+ const sizes=new Map();
374
+ for(const value of componentOf.values())sizes.set(value,(sizes.get(value)||0)+1);
375
+ const roots=nodes.filter(typeof execweaveIsRoot==='function'?execweaveIsRoot:()=>false).sort(typeof execweaveStableNodeSort==='function'?execweaveStableNodeSort:(a,b)=>String(a.id).localeCompare(String(b.id)));
376
+ let primary=roots.length?componentOf.get(roots[0].id):undefined;
377
+ if(primary===undefined){
378
+ let best=-1;
379
+ for(const [value,size] of [...sizes.entries()].sort((a,b)=>a[0]-b[0]))if(size>best){best=size;primary=value}
380
+ }
381
+ const agentIds=new Set(nodes.filter(node=>node?.type==='agent').map(node=>node.id));
382
+ const spineComponents=new Set([...componentOf.entries()].filter(([id])=>agentIds.has(id)).map(([,value])=>value));
383
+ if(primary!==undefined)spineComponents.add(primary);
384
+
385
+ let spineLeft=Infinity,spineRight=-Infinity,spineFloor=-Infinity;
386
+ for(const [id,value] of componentOf){
387
+ if(!spineComponents.has(value))continue;
388
+ const spec=topo.spec.get(id);
389
+ if(!spec)continue;
390
+ const w=typeof execweaveWidthOf==='function'?execweaveWidthOf(id):(typeof EXECWEAVE_NODE_W!=='undefined'?EXECWEAVE_NODE_W:160);
391
+ const h=typeof execweaveHeightOf==='function'?execweaveHeightOf(id):(typeof EXECWEAVE_NODE_H!=='undefined'?EXECWEAVE_NODE_H:50);
392
+ spineLeft=Math.min(spineLeft,spec.x);
393
+ spineRight=Math.max(spineRight,spec.x+w);
394
+ spineFloor=Math.max(spineFloor,spec.y+h);
395
+ }
396
+ if(!Number.isFinite(spineLeft)){spineLeft=0;spineRight=600;spineFloor=100}
397
+ const spineWidth=Math.max(600,spineRight-spineLeft);
398
+ const bandGap=typeof EXECWEAVE_BAND_GAP!=='undefined'?EXECWEAVE_BAND_GAP:170;
399
+
400
+ const secondary=[...sizes.keys()].filter(value=>!spineComponents.has(value)).sort((a,b)=>a-b);
401
+ const compBoxes=secondary.map(value=>{
402
+ const members=[...componentOf.entries()].filter(entry=>entry[1]===value).map(entry=>entry[0]);
403
+ let minX=Infinity,maxX=-Infinity,minY=Infinity,maxY=-Infinity;
404
+ for(const id of members){
405
+ const s=topo.spec.get(id);
406
+ if(s){
407
+ const w=typeof execweaveWidthOf==='function'?execweaveWidthOf(id):(typeof EXECWEAVE_NODE_W!=='undefined'?EXECWEAVE_NODE_W:160);
408
+ const h=typeof execweaveHeightOf==='function'?execweaveHeightOf(id):(typeof EXECWEAVE_NODE_H!=='undefined'?EXECWEAVE_NODE_H:50);
409
+ minX=Math.min(minX,s.x);maxX=Math.max(maxX,s.x+w);
410
+ minY=Math.min(minY,s.y);maxY=Math.max(maxY,s.y+h);
411
+ }
412
+ }
413
+ return{value,members,minX,maxX,minY,maxY,w:maxX-minX,h:maxY-minY};
414
+ }).filter(box=>Number.isFinite(box.minX));
415
+
416
+ // Use an aspect-balanced shelf width for disconnected components instead of
417
+ // forcing every component wider than half a short spine onto its own row.
418
+ // Component shapes/ordering stay intact; this is packing, not raw graph repair.
419
+ const columns=Math.max(1,Math.ceil(Math.sqrt(compBoxes.length)));
420
+ const widest=compBoxes.reduce((width,box)=>Math.max(width,box.w),0);
421
+ const packingWidth=Math.max(spineWidth,columns*widest+(columns-1)*bandGap);
422
+ let cursorX=spineLeft,cursorY=spineFloor+bandGap,rowHeight=0;
423
+ for(const box of compBoxes){
424
+ if(cursorX>spineLeft&&cursorX+box.w>spineLeft+packingWidth){
425
+ cursorX=spineLeft;cursorY+=rowHeight+bandGap;rowHeight=0;
426
+ }
427
+ const shiftX=cursorX-box.minX,shiftY=cursorY-box.minY;
428
+ for(const id of box.members){
429
+ const s=topo.spec.get(id);if(s){s.x+=shiftX;s.y+=shiftY;topo.secondaryPackedIds.add(id)}
430
+ }
431
+ cursorX+=box.w+bandGap;
432
+ rowHeight=Math.max(rowHeight,box.h);
433
+ }
434
+ return topo;
435
+ }
436
+ function execweaveApplyDirectedGraph(topo){
437
+ if(!topo||!topo.spec)return topo;
438
+
439
+ // Stage 1: PRE_DAGRE validation snapshot
440
+ const preDagre=new Map();
441
+ for(const [id,spec] of topo.spec.entries()){
442
+ preDagre.set(id,{x:spec.x,y:spec.y,lane:spec.lane,rank:spec.rank,order:spec.order});
443
+ }
444
+
445
+ // Stage 2: POST_DAGRE layout
446
+ execweaveLayoutDirectedGraph(topo);
447
+ const postDagre=new Map();
448
+ for(const [id,spec] of topo.spec.entries()){
449
+ postDagre.set(id,{x:spec.x,y:spec.y,lane:spec.lane});
450
+ }
451
+
452
+ // Stage 3: POST_FINAL_CONSTRAINT integration
453
+ execweaveRestoreSemanticLayoutConstraints(topo,preDagre,postDagre);
454
+ execweaveSeparateOverlappingNodes(topo);
455
+ execweaveRetargetRoutePoints(topo,postDagre);
456
+ execweaveRecomputePorts(topo);
457
+
458
+ const postFinalConstraint=new Map();
459
+ for(const [id,spec] of topo.spec.entries()){
460
+ postFinalConstraint.set(id,{x:spec.x,y:spec.y,lane:spec.lane});
461
+ }
462
+
463
+ // Measure Dagre 2D retention rates
464
+ let xRetained=0,yRetained=0,total=postDagre.size;
465
+ for(const [id,dagrePos] of postDagre.entries()){
466
+ const finalPos=postFinalConstraint.get(id);
467
+ if(!finalPos)continue;
468
+ if(Math.abs(finalPos.x-dagrePos.x)<=2.0)xRetained++;
469
+ if(Math.abs(finalPos.y-dagrePos.y)<=2.0)yRetained++;
470
+ }
471
+ const xRetentionRate=total>0?(xRetained/total)*100:0;
472
+ const yRetentionRate=total>0?(yRetained/total)*100:0;
473
+
474
+ const stagesComplete = preDagre.size === total && postDagre.size === total && postFinalConstraint.size === total;
475
+ const retentionHealthy = total > 0 ? (xRetained > 0 && yRetained > 0) : true;
476
+ const pipelineStatus = (stagesComplete && retentionHealthy) ? 'PASS' : 'FAIL';
477
+
478
+ topo.dagrePipeline={
479
+ stages:{
480
+ PRE_DAGRE:preDagre,
481
+ POST_DAGRE:postDagre,
482
+ POST_FINAL_CONSTRAINT:postFinalConstraint,
483
+ },
484
+ metrics:{
485
+ totalNodes:total,
486
+ xRetained,
487
+ yRetained,
488
+ DAGRE_X_RETENTION_RATE:xRetentionRate,
489
+ DAGRE_Y_RETENTION_RATE:yRetentionRate,
490
+ DAGRE_SEMANTIC_CONSTRAINT_PIPELINE:pipelineStatus,
491
+ },
492
+ };
493
+ if(typeof window!=='undefined'){
494
+ window.__execweaveDagrePipeline=topo.dagrePipeline;
495
+ }
496
+ return topo;
497
+ }
498
+ function execweaveRouteFromPoints(edge,points){
499
+ const sp=(typeof positions!=='undefined'&&positions.get(edge.source))||(execweaveTopology?.spec&&execweaveTopology.spec.get(edge.source))||{x:0,y:0};
500
+ const tp=(typeof positions!=='undefined'&&positions.get(edge.target))||(execweaveTopology?.spec&&execweaveTopology.spec.get(edge.target))||{x:0,y:0};
501
+ const sourcePort=execweaveTopology.sourcePort.get(edgeId(edge)),targetPort=execweaveTopology.targetPort.get(edgeId(edge));
502
+ const sourceSpec=execweaveTopology.spec.get(edge.source)||{},targetSpec=execweaveTopology.spec.get(edge.target)||{};
503
+ const forward=(targetSpec.rank??0)>=(sourceSpec.rank??0);
504
+ const sx=forward?sp.x+execweaveWidthOf(edge.source):sp.x;
505
+ const tx=forward?tp.x:tp.x+execweaveWidthOf(edge.target);
506
+ const sy=execweavePortY(sp,sourcePort,edge.source),ty=execweavePortY(tp,targetPort,edge.target);
507
+ const distance=Math.abs(tx-sx),bend=Math.max(44,distance*.42),sign=forward?1:-1;
508
+ const p0={x:sx,y:sy},p1={x:sx+sign*bend,y:sy},p2={x:tx-sign*bend,y:ty},p3={x:tx,y:ty};
509
+ const cubic=t=>{
510
+ const u=1-t;
511
+ return{
512
+ x:u*u*u*p0.x+3*u*u*t*p1.x+3*u*t*t*p2.x+t*t*t*p3.x,
513
+ y:u*u*u*p0.y+3*u*u*t*p1.y+3*u*t*t*p2.y+t*t*t*p3.y,
514
+ };
515
+ };
516
+ let d=`M ${sx} ${sy}`;
517
+ for(let index=1;index<8;index++){
518
+ const point=cubic(index/8);d+=` L ${point.x} ${point.y}`;
519
+ }
520
+ d+=` L ${tx} ${ty}`;
521
+ const labelPoint=cubic(.5);
522
+ return{d,labelX:labelPoint.x,labelY:labelPoint.y-8,kind:execweaveIsSpawn(edge)?'spawn':(forward?'forward':'reverse'),bundle:null};
523
+ }
524
+ const execweaveBuildTopologyBase=execweaveBuildTopology;
525
+ execweaveBuildTopology=function(){
526
+ // Width/height and lane helpers must see THIS build, never the previous graph.
527
+ const topo=execweaveBuildTopologyBase(),prior=execweaveTopology;
528
+ execweaveTopology=topo;
529
+ try{return execweaveApplyDirectedGraph(execweaveLayoutRelated(execweaveLayoutProcessTree(topo)))}
530
+ finally{execweaveTopology=prior}
531
+ };
532
+ if(typeof window!=='undefined'){
533
+ window.execweaveLayoutDirectedGraph=execweaveLayoutDirectedGraph;
534
+ window.execweaveSeparateOverlappingNodes=execweaveSeparateOverlappingNodes;
535
+ window.execweaveRecomputePorts=execweaveRecomputePorts;
536
+ window.execweaveApplyDirectedGraph=execweaveApplyDirectedGraph;
537
+ window.execweaveRestoreSemanticLayoutConstraints=execweaveRestoreSemanticLayoutConstraints;
538
+ }
539
+ const execweaveRouteBase=execweaveRoute;
540
+ execweaveRoute=function(edge){
541
+ const bundle=execweaveTopology.bundleByEdge.get(edgeId(edge));
542
+ if(bundle&&bundle.size>1)return execweaveRouteBase(edge);
543
+ if(execweaveIsStopped(edge))return execweaveRouteBase(edge);
544
+ const points=execweaveTopology.routePoints&&execweaveTopology.routePoints.get(execweaveEdgeKey(edge.source,edge.target));
545
+ if(points&&points.length>=2)return execweaveRouteFromPoints(edge,points);
546
+ const sp=positions.get(edge.source)||{x:0,y:0},tp=positions.get(edge.target)||{x:0,y:0};
547
+ const sameColumn=Math.abs(sp.x-tp.x)<8;
548
+ if(!sameColumn)return execweaveRouteBase(edge);
549
+ const sourcePort=execweaveTopology.sourcePort.get(edgeId(edge)),targetPort=execweaveTopology.targetPort.get(edgeId(edge));
550
+ const sx=sp.x+execweaveWidthOf(edge.source),sy=execweavePortY(sp,sourcePort,edge.source);
551
+ const tx=tp.x+execweaveWidthOf(edge.target),ty=execweavePortY(tp,targetPort,edge.target);
552
+ const offset=36+((sourcePort?.index||0)%8)*12;
553
+ const rail=Math.max(sx,tx)+offset;
554
+ return{d:`M ${sx} ${sy} H ${rail} V ${ty} H ${tx}`,labelX:rail+8,labelY:(sy+ty)/2,kind:'column',bundle:null};
555
+ };
556
+ function execweaveIsNodeVisible(id){
557
+ if(typeof nodeById==='undefined'||!nodeById.has(id))return false;
558
+ if(typeof nodeElements==='undefined'||!nodeElements.has(id))return true;
559
+ const el=nodeElements.get(id);
560
+ if(!el)return false;
561
+ if(el.classList?.contains('dim'))return false;
562
+ if(el.style?.display==='none'||el.hasAttribute?.('hidden'))return false;
563
+ return true;
564
+ }
565
+ function execweaveIsEdgeVisible(edge){
566
+ if(!execweaveIsNodeVisible(edge.source)||!execweaveIsNodeVisible(edge.target))return false;
567
+ if(typeof edgeElements==='undefined')return true;
568
+ const id=typeof edgeId==='function'?edgeId(edge):edge.id;
569
+ const els=edgeElements.get(id);
570
+ if(!els)return true;
571
+ if(els.visible?.classList?.contains('dim')||els.visible?.style?.display==='none'||els.visible?.hasAttribute?.('hidden'))return false;
572
+ return true;
573
+ }
574
+ function execweaveArrangePositions(){
575
+ execweaveTopology=execweaveBuildTopology();
576
+ const next=new Map();
577
+ const visibleIds=typeof nodeById!=='undefined'?[...nodeById.keys()].filter(execweaveIsNodeVisible):[];
578
+ const ordered=visibleIds.sort((a,b)=>{
579
+ const av=execweaveTopology.spec.get(a)||{},bv=execweaveTopology.spec.get(b)||{};
580
+ return Number(av.rank||0)-Number(bv.rank||0)||Number(av.processDepth||0)-Number(bv.processDepth||0)||Number(av.order||0)-Number(bv.order||0)||String(a).localeCompare(String(b));
581
+ });
582
+ for(const id of ordered){
583
+ const spec=execweaveTopology.spec.get(id);
584
+ next.set(id,spec?{x:spec.x,y:spec.y}:execweavePlaceStable(id,execweaveDesiredPosition(id),next,id));
585
+ }
586
+ if(typeof positions!=='undefined'){
587
+ for(const [id,p] of positions){
588
+ if(!next.has(id))next.set(id,p);
589
+ }
590
+ }
591
+ positions=next;layerRows=new Map();
592
+ for(const [id,p] of positions){
593
+ const spec=execweaveTopology.spec.get(id);
594
+ if(spec)layerRows.set(spec.rank,Math.max(layerRows.get(spec.rank)||0,spec.order+1));
595
+ const group=typeof nodeElements!=='undefined'?nodeElements.get(id):null;
596
+ if(group)group.setAttribute('transform',`translate(${p.x} ${p.y})`);
597
+ const node=typeof nodeById!=='undefined'?nodeById.get(id):null;
598
+ if(node&&typeof updateNodeElement==='function')updateNodeElement(node);
599
+ }
600
+ const visibleEdges=typeof edgeById!=='undefined'?[...edgeById.values()].filter(execweaveIsEdgeVisible):[];
601
+ for(const edge of visibleEdges)if(typeof updateEdgeElement==='function')updateEdgeElement(edge);
602
+ if(typeof svg!=='undefined'&&svg.classList)svg.classList.toggle('execweave-crowded',execweaveTopology.crowded);
603
+ if(typeof applySearch==='function')applySearch();
604
+ if(typeof updateJumpLatest==='function')updateJumpLatest();
605
+ return new Map(positions);
606
+ }
607
+ execweaveArrangeGraph=execweaveArrangePositions;
608
+ if(typeof window!=='undefined'){
609
+ window.__execweaveArrangeGraph=execweaveArrangePositions;
610
+ window.execweaveArrangePositions=execweaveArrangePositions;
611
+ window.execweaveArrangeGraph=execweaveArrangePositions;
612
+ }
613
+ const arrangeButton=typeof document!=='undefined'?document.getElementById('arrange'):null;
614
+ if(arrangeButton)arrangeButton.onclick=()=>execweaveArrangePositions();
615
+ function execweaveWriteDirectedPositions(topo){
616
+ const next=new Map();
617
+ for(const id of nodeById.keys()){
618
+ const spec=topo.spec.get(id);
619
+ next.set(id,spec?{x:spec.x,y:spec.y}:execweaveDesiredPosition(id));
620
+ }
621
+ positions=next;layerRows=new Map();
622
+ for(const [id,p] of positions){
623
+ const spec=topo.spec.get(id);
624
+ if(spec)layerRows.set(spec.rank,Math.max(layerRows.get(spec.rank)||0,spec.order+1));
625
+ const group=nodeElements.get(id);
626
+ if(group)group.setAttribute('transform',`translate(${p.x} ${p.y})`);
627
+ const node=nodeById.get(id);
628
+ if(node)updateNodeElement(node);
629
+ }
630
+ for(const edge of edgeById.values())updateEdgeElement(edge);
631
+ svg.classList.toggle('execweave-crowded',!!topo.crowded);
632
+ }
633
+ function execweaveInstallFinalLayout(priorY){
634
+ execweaveTopology=execweaveBuildTopology();
635
+ execweaveWriteDirectedPositions(execweaveTopology);
636
+ if(priorY.size&&typeof execweaveRestorePriorYUnlessWorse==='function'){
637
+ execweaveRestorePriorYUnlessWorse(priorY,execweaveTopology);
638
+ window.__execweaveLayout.paint();
639
+ }
640
+ }
641
+ fullLayout=function(){
642
+ execweaveInstallFinalLayout(new Map([...positions].map(([id,p])=>[id,p.y])));
643
+ };
644
+ placeAddedNodes=function(_ids){
645
+ execweaveInstallFinalLayout(new Map([...positions].map(([id,p])=>[id,p.y])));
646
+ };
647
+ })();
648
+ """.strip()
649
+
650
+ LIVE_PROCESS_LAYOUT_SCRIPT = f"{_DAGRE_JS}\n{_LIVE_PROCESS_LAYOUT_BODY}"