@tracecode/harness 0.6.6 → 0.7.0-beta8

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 (494) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +134 -15
  3. package/THIRD_PARTY_NOTICES.md +170 -0
  4. package/dist/browser.cjs +2361 -1033
  5. package/dist/browser.cjs.map +1 -1
  6. package/dist/browser.d.cts +33 -3
  7. package/dist/browser.d.ts +33 -3
  8. package/dist/browser.js +2357 -1033
  9. package/dist/browser.js.map +1 -1
  10. package/dist/cli.cjs +160 -23
  11. package/dist/cli.cjs.map +1 -1
  12. package/dist/cli.js +161 -24
  13. package/dist/cli.js.map +1 -1
  14. package/dist/core.cjs +748 -867
  15. package/dist/core.cjs.map +1 -1
  16. package/dist/core.d.cts +21 -85
  17. package/dist/core.d.ts +21 -85
  18. package/dist/core.js +734 -855
  19. package/dist/core.js.map +1 -1
  20. package/dist/cpp-worker-client-Bn7kC0_L.d.ts +84 -0
  21. package/dist/cpp-worker-client-BzdJLuZa.d.cts +84 -0
  22. package/dist/cpp.cjs +1063 -0
  23. package/dist/cpp.cjs.map +1 -0
  24. package/dist/cpp.d.cts +7 -0
  25. package/dist/cpp.d.ts +7 -0
  26. package/dist/cpp.js +1035 -0
  27. package/dist/cpp.js.map +1 -0
  28. package/dist/csharp-worker-client-DMHIa2YG.d.cts +69 -0
  29. package/dist/csharp-worker-client-JwqS6LiX.d.ts +69 -0
  30. package/dist/csharp.cjs +1012 -0
  31. package/dist/csharp.cjs.map +1 -0
  32. package/dist/csharp.d.cts +7 -0
  33. package/dist/csharp.d.ts +7 -0
  34. package/dist/csharp.js +984 -0
  35. package/dist/csharp.js.map +1 -0
  36. package/dist/index.cjs +3142 -1160
  37. package/dist/index.cjs.map +1 -1
  38. package/dist/index.d.cts +13 -5
  39. package/dist/index.d.ts +13 -5
  40. package/dist/index.js +3117 -1148
  41. package/dist/index.js.map +1 -1
  42. package/dist/internal/browser.cjs +1639 -30
  43. package/dist/internal/browser.cjs.map +1 -1
  44. package/dist/internal/browser.d.cts +6 -199
  45. package/dist/internal/browser.d.ts +6 -199
  46. package/dist/internal/browser.js +1636 -30
  47. package/dist/internal/browser.js.map +1 -1
  48. package/dist/java-worker-client-BOwKW-11.d.cts +72 -0
  49. package/dist/java-worker-client-C97DDnCp.d.ts +72 -0
  50. package/dist/java.cjs +1225 -0
  51. package/dist/java.cjs.map +1 -0
  52. package/dist/java.d.cts +7 -0
  53. package/dist/java.d.ts +7 -0
  54. package/dist/java.js +1197 -0
  55. package/dist/java.js.map +1 -0
  56. package/dist/javascript-worker-client-CYBGEEvc.d.cts +51 -0
  57. package/dist/javascript-worker-client-DIX1Mp21.d.ts +51 -0
  58. package/dist/javascript.cjs +1063 -19
  59. package/dist/javascript.cjs.map +1 -1
  60. package/dist/javascript.d.cts +7 -4
  61. package/dist/javascript.d.ts +7 -4
  62. package/dist/javascript.js +1061 -19
  63. package/dist/javascript.js.map +1 -1
  64. package/dist/pyodide-worker-client-C-2rfHj9.d.ts +111 -0
  65. package/dist/pyodide-worker-client-Cn0a8Uv3.d.cts +111 -0
  66. package/dist/python.cjs +1282 -74
  67. package/dist/python.cjs.map +1 -1
  68. package/dist/python.d.cts +20 -14
  69. package/dist/python.d.ts +20 -14
  70. package/dist/python.js +1279 -74
  71. package/dist/python.js.map +1 -1
  72. package/dist/runtime-language-info-BFUSti3-.d.ts +43 -0
  73. package/dist/runtime-language-info-Bxza1cI2.d.cts +43 -0
  74. package/dist/runtime-types-2qM0MukN.d.cts +244 -0
  75. package/dist/runtime-types-2qM0MukN.d.ts +244 -0
  76. package/package.json +73 -8
  77. package/workers/cpp/cpp-compiler-frame.html +82 -0
  78. package/workers/cpp/cpp-compiler-worker.js +131 -0
  79. package/workers/cpp/cpp-worker.js +5790 -0
  80. package/workers/cpp/tracecode_runtime.hpp +6169 -0
  81. package/workers/csharp/csharp-worker.js +301 -0
  82. package/workers/java/.build/classes/harness/browser/JavaRewriteLibrary.class +0 -0
  83. package/workers/java/java-source-augmentations.js +907 -0
  84. package/workers/java/java-worker.js +2161 -177
  85. package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1659 -32
  86. package/workers/java/src/javafx/util/Pair.java +42 -0
  87. package/workers/java/src/tracecode/browser/BrowserCompileAndTraceLibrary.java +714 -0
  88. package/workers/java/src/tracecode/browser/BrowserCompileAndTraceMain.java +76 -0
  89. package/workers/java/src/tracecode/browser/RuntimeProbeMain.java +14 -0
  90. package/workers/java/src/tracecode/user/TraceHooks.java +1414 -0
  91. package/workers/javascript/javascript-libraries-entry.js +71 -0
  92. package/workers/javascript/javascript-worker.js +2055 -424
  93. package/workers/python/generated-python-harness-snippets.js +4 -4
  94. package/workers/python/pyodide-worker.js +222 -61
  95. package/workers/python/runtime-core.js +1387 -301
  96. package/workers/vendor/csharp/.stamp +0 -0
  97. package/workers/vendor/csharp/TraceCode.CSharpHost.runtimeconfig.json +32 -0
  98. package/workers/vendor/csharp/_framework/Microsoft.CSharp.wasm +0 -0
  99. package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.CSharp.wasm +0 -0
  100. package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.wasm +0 -0
  101. package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
  102. package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.wasm +0 -0
  103. package/workers/vendor/csharp/_framework/Microsoft.Win32.Primitives.wasm +0 -0
  104. package/workers/vendor/csharp/_framework/Microsoft.Win32.Registry.wasm +0 -0
  105. package/workers/vendor/csharp/_framework/System.AppContext.wasm +0 -0
  106. package/workers/vendor/csharp/_framework/System.Buffers.wasm +0 -0
  107. package/workers/vendor/csharp/_framework/System.Collections.Concurrent.wasm +0 -0
  108. package/workers/vendor/csharp/_framework/System.Collections.Immutable.wasm +0 -0
  109. package/workers/vendor/csharp/_framework/System.Collections.NonGeneric.wasm +0 -0
  110. package/workers/vendor/csharp/_framework/System.Collections.Specialized.wasm +0 -0
  111. package/workers/vendor/csharp/_framework/System.Collections.wasm +0 -0
  112. package/workers/vendor/csharp/_framework/System.ComponentModel.Annotations.wasm +0 -0
  113. package/workers/vendor/csharp/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
  114. package/workers/vendor/csharp/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
  115. package/workers/vendor/csharp/_framework/System.ComponentModel.Primitives.wasm +0 -0
  116. package/workers/vendor/csharp/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
  117. package/workers/vendor/csharp/_framework/System.ComponentModel.wasm +0 -0
  118. package/workers/vendor/csharp/_framework/System.Configuration.wasm +0 -0
  119. package/workers/vendor/csharp/_framework/System.Console.wasm +0 -0
  120. package/workers/vendor/csharp/_framework/System.Core.wasm +0 -0
  121. package/workers/vendor/csharp/_framework/System.Data.Common.wasm +0 -0
  122. package/workers/vendor/csharp/_framework/System.Data.DataSetExtensions.wasm +0 -0
  123. package/workers/vendor/csharp/_framework/System.Data.wasm +0 -0
  124. package/workers/vendor/csharp/_framework/System.Diagnostics.Contracts.wasm +0 -0
  125. package/workers/vendor/csharp/_framework/System.Diagnostics.Debug.wasm +0 -0
  126. package/workers/vendor/csharp/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
  127. package/workers/vendor/csharp/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
  128. package/workers/vendor/csharp/_framework/System.Diagnostics.Process.wasm +0 -0
  129. package/workers/vendor/csharp/_framework/System.Diagnostics.StackTrace.wasm +0 -0
  130. package/workers/vendor/csharp/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
  131. package/workers/vendor/csharp/_framework/System.Diagnostics.Tools.wasm +0 -0
  132. package/workers/vendor/csharp/_framework/System.Diagnostics.TraceSource.wasm +0 -0
  133. package/workers/vendor/csharp/_framework/System.Diagnostics.Tracing.wasm +0 -0
  134. package/workers/vendor/csharp/_framework/System.Drawing.Primitives.wasm +0 -0
  135. package/workers/vendor/csharp/_framework/System.Drawing.wasm +0 -0
  136. package/workers/vendor/csharp/_framework/System.Dynamic.Runtime.wasm +0 -0
  137. package/workers/vendor/csharp/_framework/System.Formats.Asn1.wasm +0 -0
  138. package/workers/vendor/csharp/_framework/System.Formats.Tar.wasm +0 -0
  139. package/workers/vendor/csharp/_framework/System.Globalization.Calendars.wasm +0 -0
  140. package/workers/vendor/csharp/_framework/System.Globalization.Extensions.wasm +0 -0
  141. package/workers/vendor/csharp/_framework/System.Globalization.wasm +0 -0
  142. package/workers/vendor/csharp/_framework/System.IO.Compression.Brotli.wasm +0 -0
  143. package/workers/vendor/csharp/_framework/System.IO.Compression.FileSystem.wasm +0 -0
  144. package/workers/vendor/csharp/_framework/System.IO.Compression.ZipFile.wasm +0 -0
  145. package/workers/vendor/csharp/_framework/System.IO.Compression.wasm +0 -0
  146. package/workers/vendor/csharp/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
  147. package/workers/vendor/csharp/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
  148. package/workers/vendor/csharp/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
  149. package/workers/vendor/csharp/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
  150. package/workers/vendor/csharp/_framework/System.IO.FileSystem.wasm +0 -0
  151. package/workers/vendor/csharp/_framework/System.IO.IsolatedStorage.wasm +0 -0
  152. package/workers/vendor/csharp/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
  153. package/workers/vendor/csharp/_framework/System.IO.Pipelines.wasm +0 -0
  154. package/workers/vendor/csharp/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
  155. package/workers/vendor/csharp/_framework/System.IO.Pipes.wasm +0 -0
  156. package/workers/vendor/csharp/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
  157. package/workers/vendor/csharp/_framework/System.IO.wasm +0 -0
  158. package/workers/vendor/csharp/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
  159. package/workers/vendor/csharp/_framework/System.Linq.Expressions.wasm +0 -0
  160. package/workers/vendor/csharp/_framework/System.Linq.Parallel.wasm +0 -0
  161. package/workers/vendor/csharp/_framework/System.Linq.Queryable.wasm +0 -0
  162. package/workers/vendor/csharp/_framework/System.Linq.wasm +0 -0
  163. package/workers/vendor/csharp/_framework/System.Memory.wasm +0 -0
  164. package/workers/vendor/csharp/_framework/System.Net.Http.Json.wasm +0 -0
  165. package/workers/vendor/csharp/_framework/System.Net.Http.wasm +0 -0
  166. package/workers/vendor/csharp/_framework/System.Net.HttpListener.wasm +0 -0
  167. package/workers/vendor/csharp/_framework/System.Net.Mail.wasm +0 -0
  168. package/workers/vendor/csharp/_framework/System.Net.NameResolution.wasm +0 -0
  169. package/workers/vendor/csharp/_framework/System.Net.NetworkInformation.wasm +0 -0
  170. package/workers/vendor/csharp/_framework/System.Net.Ping.wasm +0 -0
  171. package/workers/vendor/csharp/_framework/System.Net.Primitives.wasm +0 -0
  172. package/workers/vendor/csharp/_framework/System.Net.Quic.wasm +0 -0
  173. package/workers/vendor/csharp/_framework/System.Net.Requests.wasm +0 -0
  174. package/workers/vendor/csharp/_framework/System.Net.Security.wasm +0 -0
  175. package/workers/vendor/csharp/_framework/System.Net.ServerSentEvents.wasm +0 -0
  176. package/workers/vendor/csharp/_framework/System.Net.ServicePoint.wasm +0 -0
  177. package/workers/vendor/csharp/_framework/System.Net.Sockets.wasm +0 -0
  178. package/workers/vendor/csharp/_framework/System.Net.WebClient.wasm +0 -0
  179. package/workers/vendor/csharp/_framework/System.Net.WebHeaderCollection.wasm +0 -0
  180. package/workers/vendor/csharp/_framework/System.Net.WebProxy.wasm +0 -0
  181. package/workers/vendor/csharp/_framework/System.Net.WebSockets.Client.wasm +0 -0
  182. package/workers/vendor/csharp/_framework/System.Net.WebSockets.wasm +0 -0
  183. package/workers/vendor/csharp/_framework/System.Net.wasm +0 -0
  184. package/workers/vendor/csharp/_framework/System.Numerics.Vectors.wasm +0 -0
  185. package/workers/vendor/csharp/_framework/System.Numerics.wasm +0 -0
  186. package/workers/vendor/csharp/_framework/System.ObjectModel.wasm +0 -0
  187. package/workers/vendor/csharp/_framework/System.Private.CoreLib.wasm +0 -0
  188. package/workers/vendor/csharp/_framework/System.Private.DataContractSerialization.wasm +0 -0
  189. package/workers/vendor/csharp/_framework/System.Private.Uri.wasm +0 -0
  190. package/workers/vendor/csharp/_framework/System.Private.Xml.Linq.wasm +0 -0
  191. package/workers/vendor/csharp/_framework/System.Private.Xml.wasm +0 -0
  192. package/workers/vendor/csharp/_framework/System.Reflection.DispatchProxy.wasm +0 -0
  193. package/workers/vendor/csharp/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
  194. package/workers/vendor/csharp/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
  195. package/workers/vendor/csharp/_framework/System.Reflection.Emit.wasm +0 -0
  196. package/workers/vendor/csharp/_framework/System.Reflection.Extensions.wasm +0 -0
  197. package/workers/vendor/csharp/_framework/System.Reflection.Metadata.wasm +0 -0
  198. package/workers/vendor/csharp/_framework/System.Reflection.Primitives.wasm +0 -0
  199. package/workers/vendor/csharp/_framework/System.Reflection.TypeExtensions.wasm +0 -0
  200. package/workers/vendor/csharp/_framework/System.Reflection.wasm +0 -0
  201. package/workers/vendor/csharp/_framework/System.Resources.Reader.wasm +0 -0
  202. package/workers/vendor/csharp/_framework/System.Resources.ResourceManager.wasm +0 -0
  203. package/workers/vendor/csharp/_framework/System.Resources.Writer.wasm +0 -0
  204. package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
  205. package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
  206. package/workers/vendor/csharp/_framework/System.Runtime.Extensions.wasm +0 -0
  207. package/workers/vendor/csharp/_framework/System.Runtime.Handles.wasm +0 -0
  208. package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
  209. package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
  210. package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.wasm +0 -0
  211. package/workers/vendor/csharp/_framework/System.Runtime.Intrinsics.wasm +0 -0
  212. package/workers/vendor/csharp/_framework/System.Runtime.Loader.wasm +0 -0
  213. package/workers/vendor/csharp/_framework/System.Runtime.Numerics.wasm +0 -0
  214. package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
  215. package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Json.wasm +0 -0
  216. package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
  217. package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
  218. package/workers/vendor/csharp/_framework/System.Runtime.Serialization.wasm +0 -0
  219. package/workers/vendor/csharp/_framework/System.Runtime.wasm +0 -0
  220. package/workers/vendor/csharp/_framework/System.Security.AccessControl.wasm +0 -0
  221. package/workers/vendor/csharp/_framework/System.Security.Claims.wasm +0 -0
  222. package/workers/vendor/csharp/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
  223. package/workers/vendor/csharp/_framework/System.Security.Cryptography.Cng.wasm +0 -0
  224. package/workers/vendor/csharp/_framework/System.Security.Cryptography.Csp.wasm +0 -0
  225. package/workers/vendor/csharp/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
  226. package/workers/vendor/csharp/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
  227. package/workers/vendor/csharp/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
  228. package/workers/vendor/csharp/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
  229. package/workers/vendor/csharp/_framework/System.Security.Cryptography.wasm +0 -0
  230. package/workers/vendor/csharp/_framework/System.Security.Principal.Windows.wasm +0 -0
  231. package/workers/vendor/csharp/_framework/System.Security.Principal.wasm +0 -0
  232. package/workers/vendor/csharp/_framework/System.Security.SecureString.wasm +0 -0
  233. package/workers/vendor/csharp/_framework/System.Security.wasm +0 -0
  234. package/workers/vendor/csharp/_framework/System.ServiceModel.Web.wasm +0 -0
  235. package/workers/vendor/csharp/_framework/System.ServiceProcess.wasm +0 -0
  236. package/workers/vendor/csharp/_framework/System.Text.Encoding.CodePages.wasm +0 -0
  237. package/workers/vendor/csharp/_framework/System.Text.Encoding.Extensions.wasm +0 -0
  238. package/workers/vendor/csharp/_framework/System.Text.Encoding.wasm +0 -0
  239. package/workers/vendor/csharp/_framework/System.Text.Encodings.Web.wasm +0 -0
  240. package/workers/vendor/csharp/_framework/System.Text.Json.wasm +0 -0
  241. package/workers/vendor/csharp/_framework/System.Text.RegularExpressions.wasm +0 -0
  242. package/workers/vendor/csharp/_framework/System.Threading.AccessControl.wasm +0 -0
  243. package/workers/vendor/csharp/_framework/System.Threading.Channels.wasm +0 -0
  244. package/workers/vendor/csharp/_framework/System.Threading.Overlapped.wasm +0 -0
  245. package/workers/vendor/csharp/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
  246. package/workers/vendor/csharp/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
  247. package/workers/vendor/csharp/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
  248. package/workers/vendor/csharp/_framework/System.Threading.Tasks.wasm +0 -0
  249. package/workers/vendor/csharp/_framework/System.Threading.Thread.wasm +0 -0
  250. package/workers/vendor/csharp/_framework/System.Threading.ThreadPool.wasm +0 -0
  251. package/workers/vendor/csharp/_framework/System.Threading.Timer.wasm +0 -0
  252. package/workers/vendor/csharp/_framework/System.Threading.wasm +0 -0
  253. package/workers/vendor/csharp/_framework/System.Transactions.Local.wasm +0 -0
  254. package/workers/vendor/csharp/_framework/System.Transactions.wasm +0 -0
  255. package/workers/vendor/csharp/_framework/System.ValueTuple.wasm +0 -0
  256. package/workers/vendor/csharp/_framework/System.Web.HttpUtility.wasm +0 -0
  257. package/workers/vendor/csharp/_framework/System.Web.wasm +0 -0
  258. package/workers/vendor/csharp/_framework/System.Windows.wasm +0 -0
  259. package/workers/vendor/csharp/_framework/System.Xml.Linq.wasm +0 -0
  260. package/workers/vendor/csharp/_framework/System.Xml.ReaderWriter.wasm +0 -0
  261. package/workers/vendor/csharp/_framework/System.Xml.Serialization.wasm +0 -0
  262. package/workers/vendor/csharp/_framework/System.Xml.XDocument.wasm +0 -0
  263. package/workers/vendor/csharp/_framework/System.Xml.XPath.XDocument.wasm +0 -0
  264. package/workers/vendor/csharp/_framework/System.Xml.XPath.wasm +0 -0
  265. package/workers/vendor/csharp/_framework/System.Xml.XmlDocument.wasm +0 -0
  266. package/workers/vendor/csharp/_framework/System.Xml.XmlSerializer.wasm +0 -0
  267. package/workers/vendor/csharp/_framework/System.Xml.wasm +0 -0
  268. package/workers/vendor/csharp/_framework/System.wasm +0 -0
  269. package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
  270. package/workers/vendor/csharp/_framework/WindowsBase.wasm +0 -0
  271. package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  272. package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.resources.wasm +0 -0
  273. package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  274. package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.resources.wasm +0 -0
  275. package/workers/vendor/csharp/_framework/dotnet.boot.js +1958 -0
  276. package/workers/vendor/csharp/_framework/dotnet.js +4 -0
  277. package/workers/vendor/csharp/_framework/dotnet.js.map +1 -0
  278. package/workers/vendor/csharp/_framework/dotnet.native.js +6687 -0
  279. package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
  280. package/workers/vendor/csharp/_framework/dotnet.runtime.js +4 -0
  281. package/workers/vendor/csharp/_framework/dotnet.runtime.js.map +1 -0
  282. package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  283. package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.resources.wasm +0 -0
  284. package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  285. package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.resources.wasm +0 -0
  286. package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  287. package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.resources.wasm +0 -0
  288. package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  289. package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.resources.wasm +0 -0
  290. package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  291. package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.resources.wasm +0 -0
  292. package/workers/vendor/csharp/_framework/mscorlib.wasm +0 -0
  293. package/workers/vendor/csharp/_framework/netstandard.wasm +0 -0
  294. package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  295. package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.resources.wasm +0 -0
  296. package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  297. package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.resources.wasm +0 -0
  298. package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  299. package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.resources.wasm +0 -0
  300. package/workers/vendor/csharp/_framework/supportFiles/0_Microsoft.CodeAnalysis.CSharp.dll +0 -0
  301. package/workers/vendor/csharp/_framework/supportFiles/100_System.Reflection.Emit.ILGeneration.dll +0 -0
  302. package/workers/vendor/csharp/_framework/supportFiles/101_System.Reflection.Emit.Lightweight.dll +0 -0
  303. package/workers/vendor/csharp/_framework/supportFiles/102_System.Reflection.Extensions.dll +0 -0
  304. package/workers/vendor/csharp/_framework/supportFiles/103_System.Reflection.Metadata.dll +0 -0
  305. package/workers/vendor/csharp/_framework/supportFiles/104_System.Reflection.Primitives.dll +0 -0
  306. package/workers/vendor/csharp/_framework/supportFiles/105_System.Reflection.TypeExtensions.dll +0 -0
  307. package/workers/vendor/csharp/_framework/supportFiles/106_System.Resources.Reader.dll +0 -0
  308. package/workers/vendor/csharp/_framework/supportFiles/107_System.Resources.ResourceManager.dll +0 -0
  309. package/workers/vendor/csharp/_framework/supportFiles/108_System.Resources.Writer.dll +0 -0
  310. package/workers/vendor/csharp/_framework/supportFiles/109_System.Runtime.CompilerServices.Unsafe.dll +0 -0
  311. package/workers/vendor/csharp/_framework/supportFiles/10_System.Buffers.dll +0 -0
  312. package/workers/vendor/csharp/_framework/supportFiles/110_System.Runtime.CompilerServices.VisualC.dll +0 -0
  313. package/workers/vendor/csharp/_framework/supportFiles/111_System.Runtime.dll +0 -0
  314. package/workers/vendor/csharp/_framework/supportFiles/112_System.Runtime.Extensions.dll +0 -0
  315. package/workers/vendor/csharp/_framework/supportFiles/113_System.Runtime.Handles.dll +0 -0
  316. package/workers/vendor/csharp/_framework/supportFiles/114_System.Runtime.InteropServices.dll +0 -0
  317. package/workers/vendor/csharp/_framework/supportFiles/115_System.Runtime.InteropServices.JavaScript.dll +0 -0
  318. package/workers/vendor/csharp/_framework/supportFiles/116_System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
  319. package/workers/vendor/csharp/_framework/supportFiles/117_System.Runtime.Intrinsics.dll +0 -0
  320. package/workers/vendor/csharp/_framework/supportFiles/118_System.Runtime.Loader.dll +0 -0
  321. package/workers/vendor/csharp/_framework/supportFiles/119_System.Runtime.Numerics.dll +0 -0
  322. package/workers/vendor/csharp/_framework/supportFiles/11_System.Collections.Concurrent.dll +0 -0
  323. package/workers/vendor/csharp/_framework/supportFiles/120_System.Runtime.Serialization.dll +0 -0
  324. package/workers/vendor/csharp/_framework/supportFiles/121_System.Runtime.Serialization.Formatters.dll +0 -0
  325. package/workers/vendor/csharp/_framework/supportFiles/122_System.Runtime.Serialization.Json.dll +0 -0
  326. package/workers/vendor/csharp/_framework/supportFiles/123_System.Runtime.Serialization.Primitives.dll +0 -0
  327. package/workers/vendor/csharp/_framework/supportFiles/124_System.Runtime.Serialization.Xml.dll +0 -0
  328. package/workers/vendor/csharp/_framework/supportFiles/125_System.Security.AccessControl.dll +0 -0
  329. package/workers/vendor/csharp/_framework/supportFiles/126_System.Security.Claims.dll +0 -0
  330. package/workers/vendor/csharp/_framework/supportFiles/127_System.Security.Cryptography.Algorithms.dll +0 -0
  331. package/workers/vendor/csharp/_framework/supportFiles/128_System.Security.Cryptography.Cng.dll +0 -0
  332. package/workers/vendor/csharp/_framework/supportFiles/129_System.Security.Cryptography.Csp.dll +0 -0
  333. package/workers/vendor/csharp/_framework/supportFiles/12_System.Collections.dll +0 -0
  334. package/workers/vendor/csharp/_framework/supportFiles/130_System.Security.Cryptography.dll +0 -0
  335. package/workers/vendor/csharp/_framework/supportFiles/131_System.Security.Cryptography.Encoding.dll +0 -0
  336. package/workers/vendor/csharp/_framework/supportFiles/132_System.Security.Cryptography.OpenSsl.dll +0 -0
  337. package/workers/vendor/csharp/_framework/supportFiles/133_System.Security.Cryptography.Primitives.dll +0 -0
  338. package/workers/vendor/csharp/_framework/supportFiles/134_System.Security.Cryptography.X509Certificates.dll +0 -0
  339. package/workers/vendor/csharp/_framework/supportFiles/135_System.Security.dll +0 -0
  340. package/workers/vendor/csharp/_framework/supportFiles/136_System.Security.Principal.dll +0 -0
  341. package/workers/vendor/csharp/_framework/supportFiles/137_System.Security.Principal.Windows.dll +0 -0
  342. package/workers/vendor/csharp/_framework/supportFiles/138_System.Security.SecureString.dll +0 -0
  343. package/workers/vendor/csharp/_framework/supportFiles/139_System.ServiceModel.Web.dll +0 -0
  344. package/workers/vendor/csharp/_framework/supportFiles/13_System.Collections.Immutable.dll +0 -0
  345. package/workers/vendor/csharp/_framework/supportFiles/140_System.ServiceProcess.dll +0 -0
  346. package/workers/vendor/csharp/_framework/supportFiles/141_System.Text.Encoding.CodePages.dll +0 -0
  347. package/workers/vendor/csharp/_framework/supportFiles/142_System.Text.Encoding.dll +0 -0
  348. package/workers/vendor/csharp/_framework/supportFiles/143_System.Text.Encoding.Extensions.dll +0 -0
  349. package/workers/vendor/csharp/_framework/supportFiles/144_System.Text.Encodings.Web.dll +0 -0
  350. package/workers/vendor/csharp/_framework/supportFiles/145_System.Text.Json.dll +0 -0
  351. package/workers/vendor/csharp/_framework/supportFiles/146_System.Text.RegularExpressions.dll +0 -0
  352. package/workers/vendor/csharp/_framework/supportFiles/147_System.Threading.AccessControl.dll +0 -0
  353. package/workers/vendor/csharp/_framework/supportFiles/148_System.Threading.Channels.dll +0 -0
  354. package/workers/vendor/csharp/_framework/supportFiles/149_System.Threading.dll +0 -0
  355. package/workers/vendor/csharp/_framework/supportFiles/14_System.Collections.NonGeneric.dll +0 -0
  356. package/workers/vendor/csharp/_framework/supportFiles/150_System.Threading.Overlapped.dll +0 -0
  357. package/workers/vendor/csharp/_framework/supportFiles/151_System.Threading.Tasks.Dataflow.dll +0 -0
  358. package/workers/vendor/csharp/_framework/supportFiles/152_System.Threading.Tasks.dll +0 -0
  359. package/workers/vendor/csharp/_framework/supportFiles/153_System.Threading.Tasks.Extensions.dll +0 -0
  360. package/workers/vendor/csharp/_framework/supportFiles/154_System.Threading.Tasks.Parallel.dll +0 -0
  361. package/workers/vendor/csharp/_framework/supportFiles/155_System.Threading.Thread.dll +0 -0
  362. package/workers/vendor/csharp/_framework/supportFiles/156_System.Threading.ThreadPool.dll +0 -0
  363. package/workers/vendor/csharp/_framework/supportFiles/157_System.Threading.Timer.dll +0 -0
  364. package/workers/vendor/csharp/_framework/supportFiles/158_System.Transactions.dll +0 -0
  365. package/workers/vendor/csharp/_framework/supportFiles/159_System.Transactions.Local.dll +0 -0
  366. package/workers/vendor/csharp/_framework/supportFiles/15_System.Collections.Specialized.dll +0 -0
  367. package/workers/vendor/csharp/_framework/supportFiles/160_System.ValueTuple.dll +0 -0
  368. package/workers/vendor/csharp/_framework/supportFiles/161_System.Web.dll +0 -0
  369. package/workers/vendor/csharp/_framework/supportFiles/162_System.Web.HttpUtility.dll +0 -0
  370. package/workers/vendor/csharp/_framework/supportFiles/163_System.Windows.dll +0 -0
  371. package/workers/vendor/csharp/_framework/supportFiles/164_System.Xml.dll +0 -0
  372. package/workers/vendor/csharp/_framework/supportFiles/165_System.Xml.Linq.dll +0 -0
  373. package/workers/vendor/csharp/_framework/supportFiles/166_System.Xml.ReaderWriter.dll +0 -0
  374. package/workers/vendor/csharp/_framework/supportFiles/167_System.Xml.Serialization.dll +0 -0
  375. package/workers/vendor/csharp/_framework/supportFiles/168_System.Xml.XDocument.dll +0 -0
  376. package/workers/vendor/csharp/_framework/supportFiles/169_System.Xml.XmlDocument.dll +0 -0
  377. package/workers/vendor/csharp/_framework/supportFiles/16_System.ComponentModel.Annotations.dll +0 -0
  378. package/workers/vendor/csharp/_framework/supportFiles/170_System.Xml.XmlSerializer.dll +0 -0
  379. package/workers/vendor/csharp/_framework/supportFiles/171_System.Xml.XPath.dll +0 -0
  380. package/workers/vendor/csharp/_framework/supportFiles/172_System.Xml.XPath.XDocument.dll +0 -0
  381. package/workers/vendor/csharp/_framework/supportFiles/173_TraceCode.CSharpHost.dll +0 -0
  382. package/workers/vendor/csharp/_framework/supportFiles/174_WindowsBase.dll +0 -0
  383. package/workers/vendor/csharp/_framework/supportFiles/17_System.ComponentModel.DataAnnotations.dll +0 -0
  384. package/workers/vendor/csharp/_framework/supportFiles/18_System.ComponentModel.dll +0 -0
  385. package/workers/vendor/csharp/_framework/supportFiles/19_System.ComponentModel.EventBasedAsync.dll +0 -0
  386. package/workers/vendor/csharp/_framework/supportFiles/1_Microsoft.CodeAnalysis.dll +0 -0
  387. package/workers/vendor/csharp/_framework/supportFiles/20_System.ComponentModel.Primitives.dll +0 -0
  388. package/workers/vendor/csharp/_framework/supportFiles/21_System.ComponentModel.TypeConverter.dll +0 -0
  389. package/workers/vendor/csharp/_framework/supportFiles/22_System.Configuration.dll +0 -0
  390. package/workers/vendor/csharp/_framework/supportFiles/23_System.Console.dll +0 -0
  391. package/workers/vendor/csharp/_framework/supportFiles/24_System.Core.dll +0 -0
  392. package/workers/vendor/csharp/_framework/supportFiles/25_System.Data.Common.dll +0 -0
  393. package/workers/vendor/csharp/_framework/supportFiles/26_System.Data.DataSetExtensions.dll +0 -0
  394. package/workers/vendor/csharp/_framework/supportFiles/27_System.Data.dll +0 -0
  395. package/workers/vendor/csharp/_framework/supportFiles/28_System.Diagnostics.Contracts.dll +0 -0
  396. package/workers/vendor/csharp/_framework/supportFiles/29_System.Diagnostics.Debug.dll +0 -0
  397. package/workers/vendor/csharp/_framework/supportFiles/2_Microsoft.CSharp.dll +0 -0
  398. package/workers/vendor/csharp/_framework/supportFiles/30_System.Diagnostics.DiagnosticSource.dll +0 -0
  399. package/workers/vendor/csharp/_framework/supportFiles/31_System.Diagnostics.FileVersionInfo.dll +0 -0
  400. package/workers/vendor/csharp/_framework/supportFiles/32_System.Diagnostics.Process.dll +0 -0
  401. package/workers/vendor/csharp/_framework/supportFiles/33_System.Diagnostics.StackTrace.dll +0 -0
  402. package/workers/vendor/csharp/_framework/supportFiles/34_System.Diagnostics.TextWriterTraceListener.dll +0 -0
  403. package/workers/vendor/csharp/_framework/supportFiles/35_System.Diagnostics.Tools.dll +0 -0
  404. package/workers/vendor/csharp/_framework/supportFiles/36_System.Diagnostics.TraceSource.dll +0 -0
  405. package/workers/vendor/csharp/_framework/supportFiles/37_System.Diagnostics.Tracing.dll +0 -0
  406. package/workers/vendor/csharp/_framework/supportFiles/38_System.dll +0 -0
  407. package/workers/vendor/csharp/_framework/supportFiles/39_System.Drawing.dll +0 -0
  408. package/workers/vendor/csharp/_framework/supportFiles/3_Microsoft.VisualBasic.Core.dll +0 -0
  409. package/workers/vendor/csharp/_framework/supportFiles/40_System.Drawing.Primitives.dll +0 -0
  410. package/workers/vendor/csharp/_framework/supportFiles/41_System.Dynamic.Runtime.dll +0 -0
  411. package/workers/vendor/csharp/_framework/supportFiles/42_System.Formats.Asn1.dll +0 -0
  412. package/workers/vendor/csharp/_framework/supportFiles/43_System.Formats.Tar.dll +0 -0
  413. package/workers/vendor/csharp/_framework/supportFiles/44_System.Globalization.Calendars.dll +0 -0
  414. package/workers/vendor/csharp/_framework/supportFiles/45_System.Globalization.dll +0 -0
  415. package/workers/vendor/csharp/_framework/supportFiles/46_System.Globalization.Extensions.dll +0 -0
  416. package/workers/vendor/csharp/_framework/supportFiles/47_System.IO.Compression.Brotli.dll +0 -0
  417. package/workers/vendor/csharp/_framework/supportFiles/48_System.IO.Compression.dll +0 -0
  418. package/workers/vendor/csharp/_framework/supportFiles/49_System.IO.Compression.FileSystem.dll +0 -0
  419. package/workers/vendor/csharp/_framework/supportFiles/4_Microsoft.VisualBasic.dll +0 -0
  420. package/workers/vendor/csharp/_framework/supportFiles/50_System.IO.Compression.ZipFile.dll +0 -0
  421. package/workers/vendor/csharp/_framework/supportFiles/51_System.IO.dll +0 -0
  422. package/workers/vendor/csharp/_framework/supportFiles/52_System.IO.FileSystem.AccessControl.dll +0 -0
  423. package/workers/vendor/csharp/_framework/supportFiles/53_System.IO.FileSystem.dll +0 -0
  424. package/workers/vendor/csharp/_framework/supportFiles/54_System.IO.FileSystem.DriveInfo.dll +0 -0
  425. package/workers/vendor/csharp/_framework/supportFiles/55_System.IO.FileSystem.Primitives.dll +0 -0
  426. package/workers/vendor/csharp/_framework/supportFiles/56_System.IO.FileSystem.Watcher.dll +0 -0
  427. package/workers/vendor/csharp/_framework/supportFiles/57_System.IO.IsolatedStorage.dll +0 -0
  428. package/workers/vendor/csharp/_framework/supportFiles/58_System.IO.MemoryMappedFiles.dll +0 -0
  429. package/workers/vendor/csharp/_framework/supportFiles/59_System.IO.Pipelines.dll +0 -0
  430. package/workers/vendor/csharp/_framework/supportFiles/5_Microsoft.Win32.Primitives.dll +0 -0
  431. package/workers/vendor/csharp/_framework/supportFiles/60_System.IO.Pipes.AccessControl.dll +0 -0
  432. package/workers/vendor/csharp/_framework/supportFiles/61_System.IO.Pipes.dll +0 -0
  433. package/workers/vendor/csharp/_framework/supportFiles/62_System.IO.UnmanagedMemoryStream.dll +0 -0
  434. package/workers/vendor/csharp/_framework/supportFiles/63_System.Linq.AsyncEnumerable.dll +0 -0
  435. package/workers/vendor/csharp/_framework/supportFiles/64_System.Linq.dll +0 -0
  436. package/workers/vendor/csharp/_framework/supportFiles/65_System.Linq.Expressions.dll +0 -0
  437. package/workers/vendor/csharp/_framework/supportFiles/66_System.Linq.Parallel.dll +0 -0
  438. package/workers/vendor/csharp/_framework/supportFiles/67_System.Linq.Queryable.dll +0 -0
  439. package/workers/vendor/csharp/_framework/supportFiles/68_System.Memory.dll +0 -0
  440. package/workers/vendor/csharp/_framework/supportFiles/69_System.Net.dll +0 -0
  441. package/workers/vendor/csharp/_framework/supportFiles/6_Microsoft.Win32.Registry.dll +0 -0
  442. package/workers/vendor/csharp/_framework/supportFiles/70_System.Net.Http.dll +0 -0
  443. package/workers/vendor/csharp/_framework/supportFiles/71_System.Net.Http.Json.dll +0 -0
  444. package/workers/vendor/csharp/_framework/supportFiles/72_System.Net.HttpListener.dll +0 -0
  445. package/workers/vendor/csharp/_framework/supportFiles/73_System.Net.Mail.dll +0 -0
  446. package/workers/vendor/csharp/_framework/supportFiles/74_System.Net.NameResolution.dll +0 -0
  447. package/workers/vendor/csharp/_framework/supportFiles/75_System.Net.NetworkInformation.dll +0 -0
  448. package/workers/vendor/csharp/_framework/supportFiles/76_System.Net.Ping.dll +0 -0
  449. package/workers/vendor/csharp/_framework/supportFiles/77_System.Net.Primitives.dll +0 -0
  450. package/workers/vendor/csharp/_framework/supportFiles/78_System.Net.Quic.dll +0 -0
  451. package/workers/vendor/csharp/_framework/supportFiles/79_System.Net.Requests.dll +0 -0
  452. package/workers/vendor/csharp/_framework/supportFiles/7_mscorlib.dll +0 -0
  453. package/workers/vendor/csharp/_framework/supportFiles/80_System.Net.Security.dll +0 -0
  454. package/workers/vendor/csharp/_framework/supportFiles/81_System.Net.ServerSentEvents.dll +0 -0
  455. package/workers/vendor/csharp/_framework/supportFiles/82_System.Net.ServicePoint.dll +0 -0
  456. package/workers/vendor/csharp/_framework/supportFiles/83_System.Net.Sockets.dll +0 -0
  457. package/workers/vendor/csharp/_framework/supportFiles/84_System.Net.WebClient.dll +0 -0
  458. package/workers/vendor/csharp/_framework/supportFiles/85_System.Net.WebHeaderCollection.dll +0 -0
  459. package/workers/vendor/csharp/_framework/supportFiles/86_System.Net.WebProxy.dll +0 -0
  460. package/workers/vendor/csharp/_framework/supportFiles/87_System.Net.WebSockets.Client.dll +0 -0
  461. package/workers/vendor/csharp/_framework/supportFiles/88_System.Net.WebSockets.dll +0 -0
  462. package/workers/vendor/csharp/_framework/supportFiles/89_System.Numerics.dll +0 -0
  463. package/workers/vendor/csharp/_framework/supportFiles/8_netstandard.dll +0 -0
  464. package/workers/vendor/csharp/_framework/supportFiles/90_System.Numerics.Vectors.dll +0 -0
  465. package/workers/vendor/csharp/_framework/supportFiles/91_System.ObjectModel.dll +0 -0
  466. package/workers/vendor/csharp/_framework/supportFiles/92_System.Private.CoreLib.dll +0 -0
  467. package/workers/vendor/csharp/_framework/supportFiles/93_System.Private.DataContractSerialization.dll +0 -0
  468. package/workers/vendor/csharp/_framework/supportFiles/94_System.Private.Uri.dll +0 -0
  469. package/workers/vendor/csharp/_framework/supportFiles/95_System.Private.Xml.dll +0 -0
  470. package/workers/vendor/csharp/_framework/supportFiles/96_System.Private.Xml.Linq.dll +0 -0
  471. package/workers/vendor/csharp/_framework/supportFiles/97_System.Reflection.DispatchProxy.dll +0 -0
  472. package/workers/vendor/csharp/_framework/supportFiles/98_System.Reflection.dll +0 -0
  473. package/workers/vendor/csharp/_framework/supportFiles/99_System.Reflection.Emit.dll +0 -0
  474. package/workers/vendor/csharp/_framework/supportFiles/9_System.AppContext.dll +0 -0
  475. package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  476. package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.resources.wasm +0 -0
  477. package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  478. package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.resources.wasm +0 -0
  479. package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
  480. package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.resources.wasm +0 -0
  481. package/workers/vendor/csharp/main.mjs +5 -0
  482. package/workers/vendor/csharp/package.json +1 -0
  483. package/workers/vendor/java-browser-helper.jar +0 -0
  484. package/workers/vendor/java-rewriter.jar +0 -0
  485. package/workers/vendor/javascript-libraries.js +10106 -0
  486. package/dist/runtime-types-89nchXlY.d.cts +0 -89
  487. package/dist/runtime-types-CCQ-ZLc9.d.ts +0 -89
  488. package/dist/types-zyvpJKCi.d.cts +0 -100
  489. package/dist/types-zyvpJKCi.d.ts +0 -100
  490. package/workers/java/java-source-augmentations.cjs +0 -242
  491. package/workers/java/src/spike/user/TraceHooks.java +0 -619
  492. package/workers/vendor/java-browser-spike-helper.jar +0 -0
  493. package/workers/vendor/java-practice-rewriter.jar +0 -0
  494. package/workers/vendor/java-rewrite-bridge.jar +0 -0
package/dist/browser.js CHANGED
@@ -1,8 +1,365 @@
1
+ // packages/harness-core/src/generated/runtime-language-info-data.ts
2
+ var LANGUAGE_RUNTIME_INFOS = Object.freeze({
3
+ "python": {
4
+ "language": "python",
5
+ "displayName": "Python",
6
+ "versionLabel": "Python 3.13.2 (Pyodide 0.29.0)",
7
+ "description": "Python 3.13.2 (Pyodide 0.29.0).\n\nCommon algorithm helpers are imported automatically, including array, bisect, collections, functools, heapq, itertools. Other standard-library modules can be imported normally.\n\nsortedcontainers 2.4.0 is available for TreeMap, ordered-set, and sorted-list style workflows.",
8
+ "runtime": {
9
+ "name": "Pyodide",
10
+ "version": "0.29.0",
11
+ "detail": "CPython 3.13.2 compiled to WebAssembly."
12
+ },
13
+ "defaultImports": [
14
+ "array",
15
+ "bisect",
16
+ "collections",
17
+ "functools",
18
+ "heapq",
19
+ "itertools",
20
+ "operator",
21
+ "re",
22
+ "string",
23
+ "typing"
24
+ ],
25
+ "libraries": [
26
+ {
27
+ "name": "sortedcontainers",
28
+ "version": "2.4.0",
29
+ "importName": "sortedcontainers",
30
+ "detail": "SortedDict, SortedList, and SortedSet are loaded for tree-map/tree-set style use cases."
31
+ }
32
+ ]
33
+ },
34
+ "javascript": {
35
+ "language": "javascript",
36
+ "displayName": "JavaScript",
37
+ "versionLabel": "JavaScript (ECMAScript 2023)",
38
+ "runtime": {
39
+ "name": "Browser Worker JavaScript runtime",
40
+ "detail": "Runs in the host browser worker; Node.js is not required for browser execution."
41
+ },
42
+ "libraries": [
43
+ {
44
+ "name": "lodash",
45
+ "version": "4.17.21",
46
+ "importName": "lodash",
47
+ "globalName": "_"
48
+ },
49
+ {
50
+ "name": "@datastructures-js/binary-search-tree",
51
+ "version": "5.4.0",
52
+ "importName": "@datastructures-js/binary-search-tree"
53
+ },
54
+ {
55
+ "name": "@datastructures-js/deque",
56
+ "version": "1.0.8",
57
+ "importName": "@datastructures-js/deque"
58
+ },
59
+ {
60
+ "name": "@datastructures-js/graph",
61
+ "version": "5.3.1",
62
+ "importName": "@datastructures-js/graph"
63
+ },
64
+ {
65
+ "name": "@datastructures-js/heap",
66
+ "version": "4.3.7",
67
+ "importName": "@datastructures-js/heap"
68
+ },
69
+ {
70
+ "name": "@datastructures-js/linked-list",
71
+ "version": "6.1.4",
72
+ "importName": "@datastructures-js/linked-list"
73
+ },
74
+ {
75
+ "name": "@datastructures-js/priority-queue",
76
+ "version": "6.3.5",
77
+ "importName": "@datastructures-js/priority-queue"
78
+ },
79
+ {
80
+ "name": "@datastructures-js/queue",
81
+ "version": "4.3.0",
82
+ "importName": "@datastructures-js/queue"
83
+ },
84
+ {
85
+ "name": "@datastructures-js/set",
86
+ "version": "4.2.2",
87
+ "importName": "@datastructures-js/set"
88
+ },
89
+ {
90
+ "name": "@datastructures-js/stack",
91
+ "version": "3.1.6",
92
+ "importName": "@datastructures-js/stack"
93
+ },
94
+ {
95
+ "name": "@datastructures-js/trie",
96
+ "version": "4.2.3",
97
+ "importName": "@datastructures-js/trie"
98
+ }
99
+ ],
100
+ "standard": "ECMAScript 2023-compatible syntax in the browser worker lane.",
101
+ "description": 'JavaScript runs in an isolated browser Web Worker with ECMAScript 2023-compatible syntax.\n\nLodash 4.17.21 is available as both lodash and _.\n\nThe @datastructures-js packages are bundled for common algorithm data structures. Queue, Stack, Deque, Heap, PriorityQueue, MinPriorityQueue, and MaxPriorityQueue are available globally.\n\nBundled @datastructures-js versions:\n\n"@datastructures-js/binary-search-tree": "5.4.0"\n"@datastructures-js/deque": "1.0.8"\n"@datastructures-js/graph": "5.3.1"\n"@datastructures-js/heap": "4.3.7"\n"@datastructures-js/linked-list": "6.1.4"\n"@datastructures-js/priority-queue": "6.3.5"\n"@datastructures-js/queue": "4.3.0"\n"@datastructures-js/set": "4.2.2"\n"@datastructures-js/stack": "3.1.6"\n"@datastructures-js/trie": "4.2.3"\n\nBinary Search Tree, Trie, and Graph are bundled too, but are not exposed globally because those names can collide with problem definitions. Import or require the matching package when you need one.'
102
+ },
103
+ "typescript": {
104
+ "language": "typescript",
105
+ "displayName": "TypeScript",
106
+ "versionLabel": "TypeScript 5.9.3",
107
+ "description": 'TypeScript 5.9.3 is compiled in the browser and then executed on the JavaScript worker runtime.\n\nCompiler options: --target ES2020 --module None --strict false --esModuleInterop\n\nLodash 4.17.21 is available as both lodash and _.\n\nThe @datastructures-js packages are bundled for common algorithm data structures. Queue, Stack, Deque, Heap, PriorityQueue, MinPriorityQueue, and MaxPriorityQueue are available globally.\n\nBundled @datastructures-js versions:\n\n"@datastructures-js/binary-search-tree": "5.4.0"\n"@datastructures-js/deque": "1.0.8"\n"@datastructures-js/graph": "5.3.1"\n"@datastructures-js/heap": "4.3.7"\n"@datastructures-js/linked-list": "6.1.4"\n"@datastructures-js/priority-queue": "6.3.5"\n"@datastructures-js/queue": "4.3.0"\n"@datastructures-js/set": "4.2.2"\n"@datastructures-js/stack": "3.1.6"\n"@datastructures-js/trie": "4.2.3"\n\nBinary Search Tree, Trie, and Graph are bundled too, but are not exposed globally because those names can collide with problem definitions. Import or require the matching package when you need one.\n\nThe compiled output runs on the same browser worker execution lane as JavaScript submissions.',
108
+ "runtime": {
109
+ "name": "Browser Worker JavaScript runtime",
110
+ "detail": "TypeScript is compiled before execution and runs on the JavaScript worker lane."
111
+ },
112
+ "compiler": {
113
+ "name": "TypeScript",
114
+ "version": "5.9.3"
115
+ },
116
+ "standard": "Transpiles to JavaScript for the browser worker lane.",
117
+ "libraries": [
118
+ {
119
+ "name": "lodash",
120
+ "version": "4.17.21",
121
+ "importName": "lodash",
122
+ "globalName": "_"
123
+ },
124
+ {
125
+ "name": "@datastructures-js/binary-search-tree",
126
+ "version": "5.4.0",
127
+ "importName": "@datastructures-js/binary-search-tree"
128
+ },
129
+ {
130
+ "name": "@datastructures-js/deque",
131
+ "version": "1.0.8",
132
+ "importName": "@datastructures-js/deque"
133
+ },
134
+ {
135
+ "name": "@datastructures-js/graph",
136
+ "version": "5.3.1",
137
+ "importName": "@datastructures-js/graph"
138
+ },
139
+ {
140
+ "name": "@datastructures-js/heap",
141
+ "version": "4.3.7",
142
+ "importName": "@datastructures-js/heap"
143
+ },
144
+ {
145
+ "name": "@datastructures-js/linked-list",
146
+ "version": "6.1.4",
147
+ "importName": "@datastructures-js/linked-list"
148
+ },
149
+ {
150
+ "name": "@datastructures-js/priority-queue",
151
+ "version": "6.3.5",
152
+ "importName": "@datastructures-js/priority-queue"
153
+ },
154
+ {
155
+ "name": "@datastructures-js/queue",
156
+ "version": "4.3.0",
157
+ "importName": "@datastructures-js/queue"
158
+ },
159
+ {
160
+ "name": "@datastructures-js/set",
161
+ "version": "4.2.2",
162
+ "importName": "@datastructures-js/set"
163
+ },
164
+ {
165
+ "name": "@datastructures-js/stack",
166
+ "version": "3.1.6",
167
+ "importName": "@datastructures-js/stack"
168
+ },
169
+ {
170
+ "name": "@datastructures-js/trie",
171
+ "version": "4.2.3",
172
+ "importName": "@datastructures-js/trie"
173
+ }
174
+ ]
175
+ },
176
+ "java": {
177
+ "language": "java",
178
+ "displayName": "Java",
179
+ "versionLabel": "Java 17",
180
+ "description": "Java 17 is compiled with javac 17 and executed in the browser through CheerpJ 4.2.\n\nCommon imports are added automatically: java.util.*, java.io.*, java.math.*, java.util.stream.*, javafx.util.Pair.",
181
+ "runtime": {
182
+ "name": "CheerpJ browser-local OpenJDK runtime",
183
+ "version": "17",
184
+ "detail": "Loaded through CheerpJ 4.2."
185
+ },
186
+ "compiler": {
187
+ "name": "javac",
188
+ "version": "17"
189
+ },
190
+ "defaultImports": [
191
+ "java.util.*",
192
+ "java.io.*",
193
+ "java.math.*",
194
+ "java.util.stream.*",
195
+ "javafx.util.Pair"
196
+ ],
197
+ "libraries": [
198
+ {
199
+ "name": "JavaParser",
200
+ "version": "3.25.10",
201
+ "detail": "Used internally for Java source rewriting."
202
+ },
203
+ {
204
+ "name": "javafx.util.Pair",
205
+ "detail": "Small compatibility Pair class bundled with the Java helper jar."
206
+ }
207
+ ]
208
+ },
209
+ "csharp": {
210
+ "language": "csharp",
211
+ "displayName": "C#",
212
+ "versionLabel": "C# 14 (.NET 10.0.8)",
213
+ "description": "C# 14 with .NET 10.0.8 runtime.\n\nCode is compiled with Microsoft.CodeAnalysis.CSharp 5.3.0 and executed by a browser-local .NET WebAssembly runtime.\n\nCommon namespaces are imported automatically: System, System.Collections, System.Collections.Generic, System.Linq, System.Numerics, System.Text, System.Text.RegularExpressions.",
214
+ "runtime": {
215
+ "name": ".NET WebAssembly runtime",
216
+ "version": "10.0.8",
217
+ "detail": "Browser-local .NET runtime targeting net10.0."
218
+ },
219
+ "compiler": {
220
+ "name": "Microsoft.CodeAnalysis.CSharp",
221
+ "version": "5.3.0"
222
+ },
223
+ "standard": "C# 14",
224
+ "defaultImports": [
225
+ "System",
226
+ "System.Collections",
227
+ "System.Collections.Generic",
228
+ "System.Linq",
229
+ "System.Numerics",
230
+ "System.Text",
231
+ "System.Text.RegularExpressions"
232
+ ]
233
+ },
234
+ "cpp": {
235
+ "language": "cpp",
236
+ "displayName": "C++",
237
+ "versionLabel": "C++23 (YoWASP Clang 22)",
238
+ "description": "C++ is compiled with YoWASP Clang/LLD 22.0.0-git20542-10 using the C++23 standard.\n\nSubmissions compile to WebAssembly and run in a browser-local WASI-style execution lane. The harness currently compiles with -O0 and -fno-exceptions, with a fixed program stack size.\n\nCommon standard library headers are included automatically, including <algorithm>, <array>, <bitset>, <climits>, <cmath>, <cstdint>, <functional>, <limits>, <numeric>, <sstream>, <tuple>, <vector>, <unordered_map>, <unordered_set> and more.",
239
+ "runtime": {
240
+ "name": "WASI/WebAssembly execution lane",
241
+ "detail": "Compiled and executed in a browser-local WASI-style worker lane."
242
+ },
243
+ "compiler": {
244
+ "name": "YoWASP Clang/LLD",
245
+ "version": "22.0.0-git20542-10"
246
+ },
247
+ "standard": "C++23",
248
+ "defaultImports": [
249
+ "<algorithm>",
250
+ "<array>",
251
+ "<bitset>",
252
+ "<climits>",
253
+ "<cmath>",
254
+ "<cstdint>",
255
+ "<functional>",
256
+ "<limits>",
257
+ "<numeric>",
258
+ "<sstream>",
259
+ "<tuple>",
260
+ "<vector>",
261
+ "<unordered_map>",
262
+ "<unordered_set>",
263
+ "<map>",
264
+ "<set>",
265
+ "<deque>",
266
+ "<queue>",
267
+ "<stack>",
268
+ "<utility>",
269
+ "<string>",
270
+ "<span>",
271
+ "<ranges>",
272
+ "<concepts>",
273
+ "<any>",
274
+ "<bit>",
275
+ "<cctype>",
276
+ "<cerrno>",
277
+ "<cfloat>",
278
+ "<charconv>",
279
+ "<chrono>",
280
+ "<cinttypes>",
281
+ "<compare>",
282
+ "<complex>",
283
+ "<cstddef>",
284
+ "<cstdio>",
285
+ "<cstdlib>",
286
+ "<cstring>",
287
+ "<exception>",
288
+ "<expected>",
289
+ "<forward_list>",
290
+ "<initializer_list>",
291
+ "<iomanip>",
292
+ "<ios>",
293
+ "<iostream>",
294
+ "<iterator>",
295
+ "<list>",
296
+ "<memory>",
297
+ "<numbers>",
298
+ "<optional>",
299
+ "<random>",
300
+ "<ratio>",
301
+ "<regex>",
302
+ "<stdexcept>",
303
+ "<string_view>",
304
+ "<type_traits>",
305
+ "<typeindex>",
306
+ "<typeinfo>",
307
+ "<valarray>",
308
+ "<variant>",
309
+ "<version>"
310
+ ],
311
+ "libraries": [
312
+ {
313
+ "name": "C++ standard library and WASI libc",
314
+ "detail": "Provided by the YoWASP Clang toolchain bundle."
315
+ }
316
+ ]
317
+ }
318
+ });
319
+
320
+ // packages/harness-core/src/runtime-language-info.ts
321
+ var SUPPORTED_LANGUAGE_RUNTIME_INFOS = Object.freeze(
322
+ Object.values(LANGUAGE_RUNTIME_INFOS)
323
+ );
324
+ function getLanguageRuntimeInfo(language) {
325
+ const info = LANGUAGE_RUNTIME_INFOS[language];
326
+ if (!info) {
327
+ throw new Error(`Runtime info for language "${language}" is not implemented yet.`);
328
+ }
329
+ return info;
330
+ }
331
+ function getSupportedLanguageRuntimeInfos() {
332
+ return SUPPORTED_LANGUAGE_RUNTIME_INFOS;
333
+ }
334
+
335
+ // packages/harness-browser/src/runtime-diagnostics.ts
336
+ var CONSOLE_METHOD_BY_LEVEL = {
337
+ debug: "debug",
338
+ info: "info",
339
+ warn: "warn",
340
+ error: "error"
341
+ };
342
+ function runtimeDiagnosticEvent(params) {
343
+ return {
344
+ schema: "tracecode.runtime-diagnostic.v1",
345
+ source: "harness",
346
+ ...params
347
+ };
348
+ }
349
+ function logRuntimeDiagnostic(level, params, options = {}) {
350
+ if (options.enabled === false && level !== "error") {
351
+ return;
352
+ }
353
+ const method = CONSOLE_METHOD_BY_LEVEL[level] ?? "info";
354
+ console[method]("[TraceRuntime]", runtimeDiagnosticEvent(params));
355
+ }
356
+
1
357
  // packages/harness-browser/src/javascript-worker-client.ts
2
- var EXECUTION_TIMEOUT_MS = 7e3;
358
+ var EXECUTION_TIMEOUT_MS = 2e4;
3
359
  var INTERVIEW_MODE_TIMEOUT_MS = 5e3;
4
- var TRACING_TIMEOUT_MS = 7e3;
360
+ var TRACING_TIMEOUT_MS = 2e4;
5
361
  var INIT_TIMEOUT_MS = 1e4;
362
+ var TYPESCRIPT_WARMUP_TIMEOUT_MS = 3e4;
6
363
  var MESSAGE_TIMEOUT_MS = 12e3;
7
364
  var WORKER_READY_TIMEOUT_MS = 1e4;
8
365
  var JavaScriptWorkerClient = class {
@@ -15,6 +372,7 @@ var JavaScriptWorkerClient = class {
15
372
  messageId = 0;
16
373
  isInitializing = false;
17
374
  initPromise = null;
375
+ warmupPromises = /* @__PURE__ */ new Map();
18
376
  workerReadyPromise = null;
19
377
  workerReadyResolve = null;
20
378
  workerReadyReject = null;
@@ -39,7 +397,12 @@ var JavaScriptWorkerClient = class {
39
397
  this.workerReadyResolve?.();
40
398
  this.workerReadyResolve = null;
41
399
  this.workerReadyReject = null;
42
- if (this.debug) console.log("[JavaScriptWorkerClient] worker-ready");
400
+ logRuntimeDiagnostic("info", {
401
+ component: "JavaScriptWorkerClient",
402
+ runtime: "javascript",
403
+ phase: "worker-ready",
404
+ message: "JavaScript worker is ready."
405
+ }, { enabled: this.debug });
43
406
  return;
44
407
  }
45
408
  if (id) {
@@ -55,7 +418,18 @@ var JavaScriptWorkerClient = class {
55
418
  }
56
419
  };
57
420
  this.worker.onerror = (error) => {
58
- console.error("[JavaScriptWorkerClient] Worker error:", error);
421
+ logRuntimeDiagnostic("error", {
422
+ component: "JavaScriptWorkerClient",
423
+ runtime: "javascript",
424
+ phase: "worker-error",
425
+ message: "JavaScript worker emitted an error event.",
426
+ detail: {
427
+ message: error.message,
428
+ filename: error.filename,
429
+ lineno: error.lineno,
430
+ colno: error.colno
431
+ }
432
+ });
59
433
  const workerError = new Error("Worker error");
60
434
  this.workerReadyReject?.(workerError);
61
435
  this.workerReadyResolve = null;
@@ -148,6 +522,7 @@ var JavaScriptWorkerClient = class {
148
522
  this.worker = null;
149
523
  }
150
524
  this.initPromise = null;
525
+ this.warmupPromises.clear();
151
526
  this.isInitializing = false;
152
527
  this.workerReadyPromise = null;
153
528
  this.workerReadyResolve = null;
@@ -175,6 +550,25 @@ var JavaScriptWorkerClient = class {
175
550
  this.isInitializing = false;
176
551
  }
177
552
  }
553
+ async warmup(language = "javascript") {
554
+ const existing = this.warmupPromises.get(language);
555
+ if (existing) return existing;
556
+ const warmupPromise = (async () => {
557
+ await this.init();
558
+ return this.sendMessage(
559
+ "warmup",
560
+ { language },
561
+ language === "typescript" ? TYPESCRIPT_WARMUP_TIMEOUT_MS : INIT_TIMEOUT_MS
562
+ );
563
+ })();
564
+ this.warmupPromises.set(language, warmupPromise);
565
+ try {
566
+ return await warmupPromise;
567
+ } catch (error) {
568
+ this.warmupPromises.delete(language);
569
+ throw error;
570
+ }
571
+ }
178
572
  async executeWithTracing(code, functionName, inputs, options, executionStyle = "function", language = "javascript") {
179
573
  await this.init();
180
574
  return this.executeWithTimeout(
@@ -254,344 +648,6 @@ var JavaScriptWorkerClient = class {
254
648
  }
255
649
  };
256
650
 
257
- // packages/harness-core/src/trace-contract.ts
258
- var RUNTIME_TRACE_CONTRACT_SCHEMA_VERSION = "2026-04-21";
259
- var TRACE_EVENTS = /* @__PURE__ */ new Set([
260
- "line",
261
- "call",
262
- "return",
263
- "exception",
264
- "timeout",
265
- "stdout"
266
- ]);
267
- var TRACE_ACCESS_KINDS = /* @__PURE__ */ new Set([
268
- "indexed-read",
269
- "indexed-write",
270
- "cell-read",
271
- "cell-write",
272
- "mutating-call"
273
- ]);
274
- function normalizeLineNumber(value, fallback = 1) {
275
- if (typeof value !== "number" || !Number.isFinite(value)) return fallback;
276
- const normalized = Math.floor(value);
277
- return normalized > 0 ? normalized : fallback;
278
- }
279
- function normalizeOutputLineCount(value) {
280
- if (typeof value !== "number" || !Number.isFinite(value)) return void 0;
281
- const normalized = Math.floor(value);
282
- return normalized >= 0 ? normalized : void 0;
283
- }
284
- function normalizeEvent(value) {
285
- if (typeof value === "string" && TRACE_EVENTS.has(value)) {
286
- return value;
287
- }
288
- return "line";
289
- }
290
- function normalizeAccessKind(value) {
291
- if (typeof value === "string" && TRACE_ACCESS_KINDS.has(value)) {
292
- return value;
293
- }
294
- return null;
295
- }
296
- function normalizeFunctionName(value) {
297
- if (typeof value === "string" && value.length > 0) return value;
298
- return "<module>";
299
- }
300
- function normalizeKind(value) {
301
- if (value === "map" || value === "set" || value === "hashmap" || value === "object") {
302
- return value;
303
- }
304
- return "hashmap";
305
- }
306
- function normalizeObjectKind(value) {
307
- if (value === "hashmap" || value === "object" || value === "map" || value === "set" || value === "tree" || value === "linked-list" || value === "graph-adjacency") {
308
- return value;
309
- }
310
- return null;
311
- }
312
- function normalizeScalar(value) {
313
- if (value === null || value === void 0) return value;
314
- if (typeof value === "string" || typeof value === "boolean") return value;
315
- if (typeof value === "number") return Number.isFinite(value) ? value : String(value);
316
- if (typeof value === "bigint") {
317
- const asNumber = Number(value);
318
- return Number.isSafeInteger(asNumber) ? asNumber : String(value);
319
- }
320
- if (typeof value === "function") return "<function>";
321
- return null;
322
- }
323
- function normalizeUnknown(value, depth = 0, seen = /* @__PURE__ */ new WeakSet()) {
324
- if (depth > 48) return "<max depth>";
325
- const scalar = normalizeScalar(value);
326
- if (scalar !== null || value === null || value === void 0) {
327
- return scalar;
328
- }
329
- if (Array.isArray(value)) {
330
- return value.map((item) => {
331
- if (item === void 0) return null;
332
- return normalizeUnknown(item, depth + 1, seen);
333
- });
334
- }
335
- if (typeof value === "object" && value) {
336
- if (seen.has(value)) return "<cycle>";
337
- seen.add(value);
338
- const normalized = {};
339
- for (const key of Object.keys(value).sort()) {
340
- const child = value[key];
341
- if (child === void 0) continue;
342
- normalized[key] = normalizeUnknown(child, depth + 1, seen);
343
- }
344
- seen.delete(value);
345
- return normalized;
346
- }
347
- return String(value);
348
- }
349
- function normalizeAccesses(accesses) {
350
- if (!Array.isArray(accesses) || accesses.length === 0) {
351
- return void 0;
352
- }
353
- const normalized = accesses.map((access) => {
354
- const variable = typeof access?.variable === "string" && access.variable.length > 0 ? access.variable : "";
355
- const kind = normalizeAccessKind(access?.kind);
356
- if (!variable || !kind) {
357
- return null;
358
- }
359
- const indices = Array.isArray(access?.indices) ? access.indices.map(
360
- (index) => typeof index === "number" && Number.isFinite(index) ? Math.floor(index) : null
361
- ).filter((index) => index !== null) : void 0;
362
- const pathDepth = access?.pathDepth === 1 || access?.pathDepth === 2 ? access.pathDepth : void 0;
363
- const method = typeof access?.method === "string" && access.method.length > 0 ? access.method : void 0;
364
- const payload = {
365
- variable,
366
- kind
367
- };
368
- if (indices && indices.length > 0) {
369
- payload.indices = indices;
370
- }
371
- if (pathDepth !== void 0) {
372
- payload.pathDepth = pathDepth;
373
- }
374
- if (method) {
375
- payload.method = method;
376
- }
377
- return payload;
378
- }).filter((access) => access !== null);
379
- if (normalized.length === 0) {
380
- return void 0;
381
- }
382
- const statsByVariable = /* @__PURE__ */ new Map();
383
- for (const access of normalized) {
384
- const stats = statsByVariable.get(access.variable) ?? { hasCellRead: false, hasCellWrite: false };
385
- if (access.kind === "cell-read") stats.hasCellRead = true;
386
- if (access.kind === "cell-write") stats.hasCellWrite = true;
387
- statsByVariable.set(access.variable, stats);
388
- }
389
- const deduped = /* @__PURE__ */ new Set();
390
- const collapsed = normalized.filter((access) => {
391
- const stats = statsByVariable.get(access.variable);
392
- if (access.kind === "indexed-read" && (stats?.hasCellRead || stats?.hasCellWrite)) {
393
- return false;
394
- }
395
- if (access.kind === "indexed-write" && stats?.hasCellWrite) {
396
- return false;
397
- }
398
- const key = JSON.stringify([
399
- access.variable,
400
- access.kind,
401
- access.indices ?? null,
402
- access.pathDepth ?? null,
403
- access.method ?? null
404
- ]);
405
- if (deduped.has(key)) {
406
- return false;
407
- }
408
- deduped.add(key);
409
- return true;
410
- });
411
- return collapsed.length > 0 ? collapsed : void 0;
412
- }
413
- function normalizeRecord(value) {
414
- if (!value || typeof value !== "object" || Array.isArray(value)) return {};
415
- return normalizeUnknown(value);
416
- }
417
- function normalizeVariableSources(value) {
418
- if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
419
- const entries = Object.entries(value).filter(
420
- ([name, source]) => typeof name === "string" && name.length > 0 && (source === "user" || source === "user-input" || source === "harness-prelude")
421
- ).sort((a, b) => a[0].localeCompare(b[0]));
422
- if (entries.length === 0) return void 0;
423
- return Object.fromEntries(entries);
424
- }
425
- function normalizeCallStackFrame(frame) {
426
- return {
427
- function: normalizeFunctionName(frame?.function),
428
- line: normalizeLineNumber(frame?.line, 1),
429
- args: normalizeRecord(frame?.args)
430
- };
431
- }
432
- function normalizeVisualizationPayload(payload) {
433
- const hashMaps = Array.isArray(payload?.hashMaps) ? payload.hashMaps.map((entry) => ({
434
- name: typeof entry?.name === "string" ? entry.name : "",
435
- kind: normalizeKind(entry?.kind),
436
- entries: Array.isArray(entry?.entries) ? entry.entries.map((item) => ({
437
- key: normalizeUnknown(item?.key),
438
- value: normalizeUnknown(item?.value),
439
- ...item?.highlight ? { highlight: true } : {}
440
- })) : [],
441
- ...entry?.highlightedKey !== void 0 ? { highlightedKey: normalizeUnknown(entry.highlightedKey) } : {},
442
- ...entry?.deletedKey !== void 0 ? { deletedKey: normalizeUnknown(entry.deletedKey) } : {},
443
- ...typeof entry?.objectClassName === "string" && entry.objectClassName.length > 0 ? { objectClassName: entry.objectClassName } : {},
444
- ...typeof entry?.objectId === "string" && entry.objectId.length > 0 ? { objectId: entry.objectId } : {}
445
- })).sort((a, b) => `${a.name}:${a.kind}`.localeCompare(`${b.name}:${b.kind}`)) : [];
446
- const objectKinds = payload?.objectKinds && typeof payload.objectKinds === "object" ? Object.fromEntries(
447
- Object.entries(payload.objectKinds).filter(([name]) => typeof name === "string" && name.length > 0).map(([name, kind]) => [name, normalizeObjectKind(kind)]).filter((entry) => entry[1] !== null).sort((a, b) => a[0].localeCompare(b[0]))
448
- ) : void 0;
449
- if (hashMaps.length === 0 && (!objectKinds || Object.keys(objectKinds).length === 0)) {
450
- return void 0;
451
- }
452
- return {
453
- ...hashMaps.length > 0 ? { hashMaps } : {},
454
- ...objectKinds && Object.keys(objectKinds).length > 0 ? { objectKinds } : {}
455
- };
456
- }
457
- function normalizeTraceStep(step) {
458
- const normalizedStdoutCount = normalizeOutputLineCount(step?.stdoutLineCount);
459
- const normalizedVisualization = normalizeVisualizationPayload(step?.visualization);
460
- const normalizedAccesses = normalizeAccesses(step?.accesses);
461
- const normalizedVariableSources = normalizeVariableSources(step?.variableSources);
462
- return {
463
- event: normalizeEvent(step?.event),
464
- line: normalizeLineNumber(step?.line, 1),
465
- function: normalizeFunctionName(step?.function),
466
- variables: normalizeRecord(step?.variables),
467
- ...normalizedVariableSources ? { variableSources: normalizedVariableSources } : {},
468
- ...Array.isArray(step?.callStack) && step.callStack.length > 0 ? { callStack: step.callStack.map(normalizeCallStackFrame) } : {},
469
- ...normalizedAccesses ? { accesses: normalizedAccesses } : {},
470
- ...step?.returnValue !== void 0 ? { returnValue: normalizeUnknown(step.returnValue) } : {},
471
- ...normalizedStdoutCount !== void 0 ? { stdoutLineCount: normalizedStdoutCount } : {},
472
- ...normalizedVisualization ? { visualization: normalizedVisualization } : {}
473
- };
474
- }
475
- function collapseTraceAccessNoise(trace) {
476
- const variablesWithCellAccess = /* @__PURE__ */ new Set();
477
- const accessStatsByVariable = /* @__PURE__ */ new Map();
478
- for (const step of trace) {
479
- for (const access of step.accesses ?? []) {
480
- const stats = accessStatsByVariable.get(access.variable) ?? {
481
- hasCellRead: false,
482
- hasCellWrite: false,
483
- hasMutatingCall: false,
484
- hasIndexedWrite: false
485
- };
486
- if (access.kind === "cell-read" || access.kind === "cell-write") {
487
- variablesWithCellAccess.add(access.variable);
488
- }
489
- if (access.kind === "cell-read") stats.hasCellRead = true;
490
- if (access.kind === "cell-write") stats.hasCellWrite = true;
491
- if (access.kind === "mutating-call") stats.hasMutatingCall = true;
492
- if (access.kind === "indexed-write") stats.hasIndexedWrite = true;
493
- accessStatsByVariable.set(access.variable, stats);
494
- }
495
- }
496
- if (variablesWithCellAccess.size === 0) {
497
- return trace;
498
- }
499
- return trace.map((step) => {
500
- if (!step.accesses?.length) {
501
- return step;
502
- }
503
- const filtered = step.accesses.filter((access) => {
504
- const stats = accessStatsByVariable.get(access.variable);
505
- if (variablesWithCellAccess.has(access.variable)) {
506
- return access.kind !== "indexed-read" && access.kind !== "indexed-write";
507
- }
508
- if (access.kind === "mutating-call" && stats?.hasIndexedWrite && !stats.hasCellRead && !stats.hasCellWrite) {
509
- return false;
510
- }
511
- if (access.kind === "indexed-read" && stats?.hasMutatingCall && !stats.hasIndexedWrite && !stats.hasCellRead && !stats.hasCellWrite) {
512
- return false;
513
- }
514
- return true;
515
- });
516
- if (filtered.length === step.accesses.length) {
517
- return step;
518
- }
519
- return {
520
- ...step,
521
- ...filtered.length > 0 ? { accesses: filtered } : {},
522
- ...filtered.length === 0 ? { accesses: void 0 } : {}
523
- };
524
- });
525
- }
526
- function normalizeRuntimeTraceContract(language, result) {
527
- const rawNormalizedTrace = collapseTraceAccessNoise(
528
- Array.isArray(result.trace) ? result.trace.map(normalizeTraceStep) : []
529
- );
530
- const maxTraceSteps = typeof result.maxTraceSteps === "number" && Number.isFinite(result.maxTraceSteps) ? Math.max(1, Math.floor(result.maxTraceSteps)) : void 0;
531
- const traceWasClipped = maxTraceSteps !== void 0 && rawNormalizedTrace.length > maxTraceSteps;
532
- const normalizedTrace = traceWasClipped && maxTraceSteps !== void 0 ? rawNormalizedTrace.slice(0, maxTraceSteps) : rawNormalizedTrace;
533
- const lineEventCount = typeof result.lineEventCount === "number" && Number.isFinite(result.lineEventCount) ? Math.floor(result.lineEventCount) : normalizedTrace.filter((step) => step.event === "line").length;
534
- const normalizedConsole = Array.isArray(result.consoleOutput) ? result.consoleOutput.map((line) => String(line)) : [];
535
- return {
536
- schemaVersion: RUNTIME_TRACE_CONTRACT_SCHEMA_VERSION,
537
- language,
538
- success: Boolean(result.success),
539
- ...Object.prototype.hasOwnProperty.call(result, "output") ? { output: normalizeUnknown(result.output) } : {},
540
- ...typeof result.error === "string" && result.error.length > 0 ? { error: result.error } : {},
541
- ...typeof result.errorLine === "number" && Number.isFinite(result.errorLine) ? { errorLine: Math.floor(result.errorLine) } : {},
542
- consoleOutput: normalizedConsole,
543
- trace: normalizedTrace,
544
- ...result.traceLimitExceeded !== void 0 || traceWasClipped ? { traceLimitExceeded: Boolean(result.traceLimitExceeded) || traceWasClipped } : {},
545
- ...typeof result.timeoutReason === "string" && result.timeoutReason.length > 0 ? { timeoutReason: result.timeoutReason } : {},
546
- lineEventCount: Math.max(0, lineEventCount),
547
- traceStepCount: normalizedTrace.length
548
- };
549
- }
550
-
551
- // packages/harness-core/src/trace-adapters/shared.ts
552
- function denormalizeCallStackFrame(frame) {
553
- return {
554
- function: frame.function,
555
- line: frame.line,
556
- args: frame.args
557
- };
558
- }
559
- function denormalizeTraceStep(step) {
560
- return {
561
- line: step.line,
562
- event: step.event,
563
- variables: step.variables,
564
- function: step.function,
565
- ...step.callStack ? { callStack: step.callStack.map(denormalizeCallStackFrame) } : {},
566
- ...step.accesses ? { accesses: step.accesses } : {},
567
- ...step.returnValue !== void 0 ? { returnValue: step.returnValue } : {},
568
- ...step.stdoutLineCount !== void 0 ? { stdoutLineCount: step.stdoutLineCount } : {},
569
- ...step.visualization ? { visualization: step.visualization } : {}
570
- };
571
- }
572
- function adaptTraceExecutionResult(language, result) {
573
- const normalized = normalizeRuntimeTraceContract(language, result);
574
- const adaptedTrace = normalized.trace.map(denormalizeTraceStep);
575
- return {
576
- success: normalized.success,
577
- ...Object.prototype.hasOwnProperty.call(normalized, "output") ? { output: normalized.output } : {},
578
- ...normalized.error ? { error: normalized.error } : {},
579
- ...normalized.errorLine !== void 0 ? { errorLine: normalized.errorLine } : {},
580
- trace: adaptedTrace,
581
- executionTimeMs: typeof result.executionTimeMs === "number" && Number.isFinite(result.executionTimeMs) ? result.executionTimeMs : 0,
582
- consoleOutput: normalized.consoleOutput,
583
- ...normalized.traceLimitExceeded !== void 0 ? { traceLimitExceeded: normalized.traceLimitExceeded } : {},
584
- ...normalized.timeoutReason ? { timeoutReason: normalized.timeoutReason } : {},
585
- lineEventCount: normalized.lineEventCount,
586
- traceStepCount: adaptedTrace.length
587
- };
588
- }
589
-
590
- // packages/harness-core/src/trace-adapters/javascript.ts
591
- function adaptJavaScriptTraceExecutionResult(language, result) {
592
- return adaptTraceExecutionResult(language, result);
593
- }
594
-
595
651
  // packages/harness-browser/src/runtime-capability-guards.ts
596
652
  function isScriptRequest(functionName) {
597
653
  if (functionName == null) return true;
@@ -684,12 +740,6 @@ var PYTHON_RUNTIME_PROFILE = {
684
740
  setSerialization: true,
685
741
  graphSerialization: true,
686
742
  cycleReferences: true
687
- },
688
- visualization: {
689
- runtimePayloads: true,
690
- objectKinds: true,
691
- hashMaps: true,
692
- stepVisualization: true
693
743
  }
694
744
  }
695
745
  };
@@ -746,12 +796,6 @@ var JAVASCRIPT_RUNTIME_PROFILE = {
746
796
  setSerialization: true,
747
797
  graphSerialization: true,
748
798
  cycleReferences: true
749
- },
750
- visualization: {
751
- runtimePayloads: true,
752
- objectKinds: true,
753
- hashMaps: true,
754
- stepVisualization: true
755
799
  }
756
800
  }
757
801
  };
@@ -808,12 +852,6 @@ var TYPESCRIPT_RUNTIME_PROFILE = {
808
852
  setSerialization: true,
809
853
  graphSerialization: true,
810
854
  cycleReferences: true
811
- },
812
- visualization: {
813
- runtimePayloads: true,
814
- objectKinds: true,
815
- hashMaps: true,
816
- stepVisualization: true
817
855
  }
818
856
  }
819
857
  };
@@ -870,12 +908,6 @@ var JAVA_RUNTIME_PROFILE = {
870
908
  setSerialization: true,
871
909
  graphSerialization: false,
872
910
  cycleReferences: true
873
- },
874
- visualization: {
875
- runtimePayloads: true,
876
- objectKinds: true,
877
- hashMaps: true,
878
- stepVisualization: true
879
911
  }
880
912
  },
881
913
  notes: [
@@ -884,37 +916,168 @@ var JAVA_RUNTIME_PROFILE = {
884
916
  'Script-style Java uses an empty function name with executionStyle="function" and reads the top-level result variable.'
885
917
  ]
886
918
  };
887
- var LANGUAGE_RUNTIME_PROFILES = {
888
- python: PYTHON_RUNTIME_PROFILE,
889
- javascript: JAVASCRIPT_RUNTIME_PROFILE,
890
- typescript: TYPESCRIPT_RUNTIME_PROFILE,
891
- java: JAVA_RUNTIME_PROFILE
919
+ var CSHARP_RUNTIME_PROFILE = {
920
+ language: "csharp",
921
+ maturity: "experimental",
922
+ capabilities: {
923
+ execution: {
924
+ styles: {
925
+ function: true,
926
+ solutionMethod: true,
927
+ opsClass: true,
928
+ script: true,
929
+ interviewMode: true
930
+ },
931
+ timeouts: {
932
+ clientTimeouts: true,
933
+ runtimeTimeouts: true
934
+ }
935
+ },
936
+ tracing: {
937
+ supported: true,
938
+ events: {
939
+ line: true,
940
+ call: true,
941
+ return: true,
942
+ exception: true,
943
+ stdout: true,
944
+ timeout: true
945
+ },
946
+ controls: {
947
+ maxTraceSteps: true,
948
+ maxLineEvents: true,
949
+ maxSingleLineHits: true,
950
+ maxStoredEvents: true,
951
+ minimalTrace: true
952
+ },
953
+ fidelity: {
954
+ preciseLineMapping: true,
955
+ stableFunctionNames: true,
956
+ callStack: true
957
+ }
958
+ },
959
+ diagnostics: {
960
+ compileErrors: true,
961
+ runtimeErrors: true,
962
+ mappedErrorLines: true,
963
+ stackTraces: false
964
+ },
965
+ structures: {
966
+ treeNodeRefs: true,
967
+ listNodeRefs: true,
968
+ mapSerialization: true,
969
+ setSerialization: true,
970
+ graphSerialization: true,
971
+ cycleReferences: true
972
+ }
973
+ },
974
+ notes: [
975
+ "C# support is browser-local and experimental.",
976
+ "C# supports named function-style requests where the browser-local host can bind the named method.",
977
+ 'Script-style C# uses an empty function name with executionStyle="function" and reads the top-level result variable.',
978
+ "Interview-mode C# uses the same browser-local worker execution path with interview timeout normalization.",
979
+ "The first C# slice supports public class Solution methods.",
980
+ "ListNode and TreeNode inputs are hydrated from level-order arrays or object-shaped JSON.",
981
+ "Dictionary, HashSet, List, and array return values serialize through the browser-local worker.",
982
+ "Tracing currently supports line, call, return, stdout, and simple local variable write events.",
983
+ "Structural visualization is added after execution and diagnostics are proven."
984
+ ]
892
985
  };
893
- var SUPPORTED_LANGUAGES = Object.freeze(
894
- Object.keys(LANGUAGE_RUNTIME_PROFILES)
895
- );
896
- function getLanguageRuntimeProfile(language) {
897
- const profile = LANGUAGE_RUNTIME_PROFILES[language];
898
- if (!profile) {
899
- throw new Error(`Runtime profile for language "${language}" is not implemented yet.`);
900
- }
901
- return profile;
902
- }
903
- function getSupportedLanguageProfiles() {
904
- return SUPPORTED_LANGUAGES.map((language) => LANGUAGE_RUNTIME_PROFILES[language]);
905
- }
906
- function isLanguageSupported(language) {
907
- return SUPPORTED_LANGUAGES.includes(language);
908
- }
909
-
910
- // packages/harness-browser/src/javascript-runtime-client.ts
911
- var JavaScriptRuntimeClient = class {
912
- constructor(runtimeLanguage, workerClient) {
913
- this.runtimeLanguage = runtimeLanguage;
914
- this.workerClient = workerClient;
915
- }
916
- async init() {
917
- return this.workerClient.init();
986
+ var CPP_RUNTIME_PROFILE = {
987
+ language: "cpp",
988
+ maturity: "experimental",
989
+ capabilities: {
990
+ execution: {
991
+ styles: {
992
+ function: true,
993
+ solutionMethod: true,
994
+ opsClass: true,
995
+ script: true,
996
+ interviewMode: true
997
+ },
998
+ timeouts: {
999
+ clientTimeouts: true,
1000
+ runtimeTimeouts: true
1001
+ }
1002
+ },
1003
+ tracing: {
1004
+ supported: true,
1005
+ events: {
1006
+ line: true,
1007
+ call: true,
1008
+ return: true,
1009
+ exception: true,
1010
+ stdout: true,
1011
+ timeout: true
1012
+ },
1013
+ controls: {
1014
+ maxTraceSteps: true,
1015
+ maxLineEvents: true,
1016
+ maxSingleLineHits: true,
1017
+ maxStoredEvents: true,
1018
+ minimalTrace: true
1019
+ },
1020
+ fidelity: {
1021
+ preciseLineMapping: true,
1022
+ stableFunctionNames: true,
1023
+ callStack: true
1024
+ }
1025
+ },
1026
+ diagnostics: {
1027
+ compileErrors: true,
1028
+ runtimeErrors: true,
1029
+ mappedErrorLines: true,
1030
+ stackTraces: false
1031
+ },
1032
+ structures: {
1033
+ treeNodeRefs: true,
1034
+ listNodeRefs: true,
1035
+ mapSerialization: true,
1036
+ setSerialization: true,
1037
+ graphSerialization: true,
1038
+ cycleReferences: true
1039
+ }
1040
+ },
1041
+ notes: [
1042
+ "C++ uses a focused browser-local Clang/LLD/WASI compiler lane with TraceCode-owned execution glue.",
1043
+ "The runtime intentionally does not depend on a generic multi-language container/runtime SDK.",
1044
+ 'Script-style C++ uses an empty function name with executionStyle="function"; the snippet must assign a serializable result variable.',
1045
+ "Interview-mode C++ reuses the tracing compiler path with a trace budget and returns a non-trace execution result."
1046
+ ]
1047
+ };
1048
+ var LANGUAGE_RUNTIME_PROFILES = {
1049
+ python: PYTHON_RUNTIME_PROFILE,
1050
+ javascript: JAVASCRIPT_RUNTIME_PROFILE,
1051
+ typescript: TYPESCRIPT_RUNTIME_PROFILE,
1052
+ java: JAVA_RUNTIME_PROFILE,
1053
+ csharp: CSHARP_RUNTIME_PROFILE,
1054
+ cpp: CPP_RUNTIME_PROFILE
1055
+ };
1056
+ var SUPPORTED_LANGUAGES = Object.freeze(
1057
+ Object.keys(LANGUAGE_RUNTIME_PROFILES)
1058
+ );
1059
+ function getLanguageRuntimeProfile(language) {
1060
+ const profile = LANGUAGE_RUNTIME_PROFILES[language];
1061
+ if (!profile) {
1062
+ throw new Error(`Runtime profile for language "${language}" is not implemented yet.`);
1063
+ }
1064
+ return profile;
1065
+ }
1066
+ function getSupportedLanguageProfiles() {
1067
+ return SUPPORTED_LANGUAGES.map((language) => LANGUAGE_RUNTIME_PROFILES[language]);
1068
+ }
1069
+ function isLanguageSupported(language) {
1070
+ return SUPPORTED_LANGUAGES.includes(language);
1071
+ }
1072
+
1073
+ // packages/harness-browser/src/javascript-runtime-client.ts
1074
+ var JavaScriptRuntimeClient = class {
1075
+ constructor(runtimeLanguage, workerClient) {
1076
+ this.runtimeLanguage = runtimeLanguage;
1077
+ this.workerClient = workerClient;
1078
+ }
1079
+ async init() {
1080
+ return this.workerClient.init();
918
1081
  }
919
1082
  async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
920
1083
  assertRuntimeRequestSupported(getLanguageRuntimeProfile(this.runtimeLanguage), {
@@ -922,7 +1085,7 @@ var JavaScriptRuntimeClient = class {
922
1085
  executionStyle,
923
1086
  functionName
924
1087
  });
925
- const rawResult = await this.workerClient.executeWithTracing(
1088
+ return this.workerClient.executeWithTracing(
926
1089
  code,
927
1090
  functionName,
928
1091
  inputs,
@@ -930,7 +1093,6 @@ var JavaScriptRuntimeClient = class {
930
1093
  executionStyle,
931
1094
  this.runtimeLanguage
932
1095
  );
933
- return adaptJavaScriptTraceExecutionResult(this.runtimeLanguage, rawResult);
934
1096
  }
935
1097
  async executeCode(code, functionName, inputs, executionStyle = "function") {
936
1098
  assertRuntimeRequestSupported(getLanguageRuntimeProfile(this.runtimeLanguage), {
@@ -965,11 +1127,364 @@ function createJavaScriptRuntimeClient(runtimeLanguage, workerClient) {
965
1127
  return new JavaScriptRuntimeClient(runtimeLanguage, workerClient);
966
1128
  }
967
1129
 
1130
+ // packages/harness-core/src/runtime-trace.ts
1131
+ var RUNTIME_TRACE_SCHEMA_VERSION = "runtime-trace-2026-04-28";
1132
+ function createEmptyRuntimeTrace(language, options = {}) {
1133
+ return {
1134
+ schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
1135
+ language,
1136
+ runId: options.runId ?? `${language}:run`,
1137
+ events: [],
1138
+ lineEventCount: 0,
1139
+ traceStepCount: 0
1140
+ };
1141
+ }
1142
+
1143
+ // packages/harness-core/src/runtime-raw-emission-contract.ts
1144
+ function sortedUnique(values) {
1145
+ return [...new Set(values)].sort((left, right) => left.localeCompare(right));
1146
+ }
1147
+ var FORBIDDEN_RUNTIME_TRACE_TOKENS = [
1148
+ "visualization",
1149
+ "objectKinds",
1150
+ "hashMaps",
1151
+ "graph-adjacency",
1152
+ "linked-list",
1153
+ "tree"
1154
+ ];
1155
+ var FORBIDDEN_RUNTIME_TRACE_KEYS = /* @__PURE__ */ new Set([
1156
+ "visualization",
1157
+ "objectKinds",
1158
+ "hashMaps",
1159
+ "graph-adjacency",
1160
+ "linked-list"
1161
+ ]);
1162
+ function normalizeJavaNativeTraceJsonPayload(payload) {
1163
+ return payload.replace(/(?<![A-Za-z0-9_"])-Infinity(?![A-Za-z0-9_"])/g, '"-Infinity"').replace(/(?<![A-Za-z0-9_"])Infinity(?![A-Za-z0-9_"])/g, '"Infinity"').replace(/(?<![A-Za-z0-9_"])NaN(?![A-Za-z0-9_"])/g, '"NaN"');
1164
+ }
1165
+ function forbiddenRuntimeTraceTokens(value) {
1166
+ const tokens = /* @__PURE__ */ new Set();
1167
+ collectForbiddenRuntimeTraceTokens(value, tokens, null, false);
1168
+ return FORBIDDEN_RUNTIME_TRACE_TOKENS.filter((token) => tokens.has(token));
1169
+ }
1170
+ function collectForbiddenRuntimeTraceTokens(value, tokens, parentKey, semanticPayload) {
1171
+ if (typeof value === "string") {
1172
+ if ((semanticPayload || parentKey === "kind" || parentKey === "type" || parentKey === "category") && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(value)) {
1173
+ tokens.add(value);
1174
+ }
1175
+ return;
1176
+ }
1177
+ if (value === null || typeof value !== "object") return;
1178
+ if (Array.isArray(value)) {
1179
+ for (const item of value) collectForbiddenRuntimeTraceTokens(item, tokens, parentKey, semanticPayload);
1180
+ return;
1181
+ }
1182
+ const entries = Object.entries(value);
1183
+ const objectSemanticPayload = entries.some(([key, child]) => {
1184
+ if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) return true;
1185
+ return (key === "kind" || key === "type" || key === "category") && typeof child === "string" && FORBIDDEN_RUNTIME_TRACE_TOKENS.includes(child);
1186
+ });
1187
+ for (const [key, child] of entries) {
1188
+ if (parentKey !== "args" && FORBIDDEN_RUNTIME_TRACE_KEYS.has(key)) {
1189
+ tokens.add(key);
1190
+ }
1191
+ if (key === "target" || key === "variable" || key === "function") continue;
1192
+ collectForbiddenRuntimeTraceTokens(child, tokens, key, semanticPayload || objectSemanticPayload);
1193
+ }
1194
+ }
1195
+ function unsupportedForbiddenPayload(label, value) {
1196
+ const tokens = forbiddenRuntimeTraceTokens(value);
1197
+ if (tokens.length === 0) return null;
1198
+ return `${label} contains forbidden runtime trace token(s): ${tokens.join(", ")}`;
1199
+ }
1200
+ function javaNativeTracePayloadKind(event) {
1201
+ if (!event.startsWith("trace:")) return null;
1202
+ try {
1203
+ const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
1204
+ if (parsed.kind === "line") return "line";
1205
+ if (parsed.kind === "call") return "call";
1206
+ if (parsed.kind === "return") return "return";
1207
+ if (parsed.kind === "exception") return "exception";
1208
+ if (parsed.kind === "timeout") return "timeout";
1209
+ if (parsed.kind === "stdout") return "stdout";
1210
+ if (parsed.kind === "snapshot") return "snapshot";
1211
+ if (parsed.kind === "read") return "read";
1212
+ if (parsed.kind === "write") return "write";
1213
+ if (parsed.kind === "mutate") return "mutate";
1214
+ } catch {
1215
+ return null;
1216
+ }
1217
+ return null;
1218
+ }
1219
+ function summarizeJavaRawEmissions(events) {
1220
+ const kinds = [];
1221
+ const unsupported = [];
1222
+ for (const [index, event] of events.entries()) {
1223
+ if (event.startsWith("trace:")) {
1224
+ try {
1225
+ const parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
1226
+ const forbiddenPayload = unsupportedForbiddenPayload(`java trace event ${index}`, parsed);
1227
+ if (forbiddenPayload) {
1228
+ unsupported.push(forbiddenPayload);
1229
+ continue;
1230
+ }
1231
+ } catch {
1232
+ }
1233
+ }
1234
+ const nativeKind = javaNativeTracePayloadKind(event);
1235
+ if (nativeKind) {
1236
+ kinds.push(nativeKind);
1237
+ continue;
1238
+ }
1239
+ unsupported.push(event);
1240
+ }
1241
+ return {
1242
+ language: "java",
1243
+ kinds: sortedUnique(kinds),
1244
+ unsupported
1245
+ };
1246
+ }
1247
+ function assertSupportedRawEmissions(summary, label) {
1248
+ if (summary.unsupported.length > 0) {
1249
+ throw new Error(
1250
+ `${label} emitted unsupported raw runtime payloads:
1251
+ ${summary.unsupported.slice(0, 20).join("\n")}`
1252
+ );
1253
+ }
1254
+ }
1255
+
1256
+ // packages/harness-core/src/trace-adapters/java.ts
1257
+ function isNativeJavaTraceEvent(event) {
1258
+ return event.startsWith("trace:");
1259
+ }
1260
+ function stripInlineComments(line, inBlockComment) {
1261
+ let result = "";
1262
+ let index = 0;
1263
+ let inBlock = inBlockComment;
1264
+ while (index < line.length) {
1265
+ const current = line[index];
1266
+ const next = index + 1 < line.length ? line[index + 1] : "";
1267
+ if (inBlock) {
1268
+ if (current === "*" && next === "/") {
1269
+ inBlock = false;
1270
+ index += 2;
1271
+ continue;
1272
+ }
1273
+ index += 1;
1274
+ continue;
1275
+ }
1276
+ if (current === "/" && next === "*") {
1277
+ inBlock = true;
1278
+ index += 2;
1279
+ continue;
1280
+ }
1281
+ if (current === "/" && next === "/") break;
1282
+ result += current;
1283
+ index += 1;
1284
+ }
1285
+ return { text: result, inBlockComment: inBlock };
1286
+ }
1287
+ function isMethodDeclarationLine(line) {
1288
+ const trimmed = line.trim();
1289
+ if (!trimmed) return false;
1290
+ if (trimmed.startsWith("@")) return false;
1291
+ if (!trimmed.includes("(") || !trimmed.includes(")")) return false;
1292
+ if (trimmed.endsWith(";")) return false;
1293
+ if (trimmed.includes("->")) return false;
1294
+ if (/^(?:if|for|while|switch|catch|do|try|else|return|throw|new)\b/.test(trimmed)) return false;
1295
+ if (!/[A-Za-z_][A-Za-z0-9_]*\s*\([^{};]*\)/.test(trimmed)) return false;
1296
+ return /(?:\{\s*)?$/.test(trimmed);
1297
+ }
1298
+ function buildLocalDeclarationNamesByLine(sourceText) {
1299
+ const namesByLine = /* @__PURE__ */ new Map();
1300
+ if (typeof sourceText !== "string" || sourceText.length === 0) return namesByLine;
1301
+ const lines = sourceText.split(/\r?\n/);
1302
+ let inBlockComment = false;
1303
+ for (let index = 0; index < lines.length; index += 1) {
1304
+ const { text, inBlockComment: nextInBlockComment } = stripInlineComments(lines[index] ?? "", inBlockComment);
1305
+ inBlockComment = nextInBlockComment;
1306
+ if (isMethodDeclarationLine(text)) continue;
1307
+ const names = [];
1308
+ const declarationPattern = /\b(?:final\s+)?(?:[A-Za-z_][A-Za-z0-9_.$]*(?:\s*<[^;=(){}]+>)?(?:\s*\[\])?)\s+([A-Za-z_][A-Za-z0-9_]*)\s*=/g;
1309
+ for (const match of text.matchAll(declarationPattern)) {
1310
+ if (match[1]) names.push(match[1]);
1311
+ }
1312
+ if (names.length > 0) namesByLine.set(index + 1, names);
1313
+ }
1314
+ return namesByLine;
1315
+ }
1316
+ function removeSameLineMutationDeclarationSnapshotEvents(events, sourceText) {
1317
+ const declarationNamesByLine = buildLocalDeclarationNamesByLine(sourceText);
1318
+ if (declarationNamesByLine.size === 0) return events;
1319
+ const mutationVariablesByLine = /* @__PURE__ */ new Map();
1320
+ for (const event of events) {
1321
+ if (event.kind !== "mutate" || typeof event.line !== "number" || !("variable" in event.target)) continue;
1322
+ const variables = mutationVariablesByLine.get(event.line) ?? /* @__PURE__ */ new Set();
1323
+ variables.add(event.target.variable);
1324
+ mutationVariablesByLine.set(event.line, variables);
1325
+ }
1326
+ if (mutationVariablesByLine.size === 0) return events;
1327
+ return events.filter((event) => {
1328
+ if (event.kind !== "snapshot" || typeof event.line !== "number" || !("variable" in event.target)) return true;
1329
+ const declaredNames = declarationNamesByLine.get(event.line);
1330
+ if (!declaredNames?.includes(event.target.variable)) return true;
1331
+ const mutationVariables = mutationVariablesByLine.get(event.line);
1332
+ return mutationVariables?.has(event.target.variable) === true;
1333
+ });
1334
+ }
1335
+ function collectJavaLineDeclarationsForHeaderExpansion(line) {
1336
+ const names = [];
1337
+ const declarationPattern = /\b(?:final\s+)?((?:boolean|byte|char|short|int|long|float|double|String|Object|[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^,;=(){}:]+>)?)\s*(?:\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?==)/g;
1338
+ const skippedNames = /* @__PURE__ */ new Set(["class", "interface", "enum", "record", "return", "new"]);
1339
+ for (const match of line.matchAll(declarationPattern)) {
1340
+ const typeSource = match[1] ?? "";
1341
+ const name = match[2];
1342
+ if (!name || skippedNames.has(name) || name.startsWith("__tracecode")) continue;
1343
+ if (typeSource.includes("[")) continue;
1344
+ names.push(name);
1345
+ }
1346
+ return names;
1347
+ }
1348
+ function collectJavaControlHeaderDeclarations(line) {
1349
+ const forMatch = /\bfor\s*\(\s*(?:final\s+)?(?:[A-Za-z_][A-Za-z0-9_<>.?]*(?:\s*<[^;=(){}:]+>)?|\w+(?:\s*\[\s*\])*)\s+([A-Za-z_][A-Za-z0-9_]*)\s*(?:=|:)/.exec(line);
1350
+ return forMatch?.[1] ? [forMatch[1]] : [];
1351
+ }
1352
+ function buildJavaControlHeaderInfo(sourceText) {
1353
+ if (typeof sourceText !== "string" || sourceText.length === 0) return null;
1354
+ const lines = sourceText.split(/\r?\n/);
1355
+ const loopBodyLineToHeader = /* @__PURE__ */ new Map();
1356
+ const headerLineToExcludedVariables = /* @__PURE__ */ new Map();
1357
+ for (let index = 0; index < lines.length; index += 1) {
1358
+ const line = lines[index] ?? "";
1359
+ const isLoopHeader = /\b(?:for|while)\s*\(/.test(line);
1360
+ const isControlHeader = /\b(?:for|while|if|else\s+if)\s*\(/.test(line);
1361
+ if (!isControlHeader || !line.includes("{")) continue;
1362
+ for (let bodyIndex = index + 1; bodyIndex < lines.length; bodyIndex += 1) {
1363
+ const trimmed = (lines[bodyIndex] ?? "").trim();
1364
+ if (trimmed.length === 0) continue;
1365
+ if (trimmed.startsWith("}")) break;
1366
+ const headerInfo = {
1367
+ line: index + 1,
1368
+ excludedVariables: new Set(collectJavaLineDeclarationsForHeaderExpansion(lines[bodyIndex] ?? "")),
1369
+ headerVariables: new Set(collectJavaControlHeaderDeclarations(line))
1370
+ };
1371
+ if (isLoopHeader) loopBodyLineToHeader.set(bodyIndex + 1, headerInfo);
1372
+ headerLineToExcludedVariables.set(index + 1, headerInfo.excludedVariables);
1373
+ break;
1374
+ }
1375
+ }
1376
+ if (loopBodyLineToHeader.size === 0 && headerLineToExcludedVariables.size === 0) return null;
1377
+ return { loopBodyLineToHeader, headerLineToExcludedVariables };
1378
+ }
1379
+ function eventLine(event) {
1380
+ return typeof event.line === "number" && Number.isFinite(event.line) && event.line > 0 ? event.line : null;
1381
+ }
1382
+ function eventSnapshotVariable(event) {
1383
+ if (event.kind !== "snapshot") return null;
1384
+ const target = event.target;
1385
+ if (!target || typeof target !== "object" || !("variable" in target)) return null;
1386
+ const variable = target.variable;
1387
+ return typeof variable === "string" && variable.length > 0 ? variable : null;
1388
+ }
1389
+ function cloneRuntimeEventAtLine(event, line) {
1390
+ return { ...event, line };
1391
+ }
1392
+ function expandJavaLoopHeaderTraceEvents(events, sourceText) {
1393
+ if (events.length === 0) return events;
1394
+ const controlHeaderInfo = buildJavaControlHeaderInfo(sourceText);
1395
+ if (!controlHeaderInfo) return events;
1396
+ const { loopBodyLineToHeader, headerLineToExcludedVariables } = controlHeaderInfo;
1397
+ const expanded = [];
1398
+ const latestSnapshotByVariable = /* @__PURE__ */ new Map();
1399
+ let lastLineEventLine = null;
1400
+ for (let index = 0; index < events.length; index += 1) {
1401
+ const event = events[index];
1402
+ const line = eventLine(event);
1403
+ const snapshotVariable = eventSnapshotVariable(event);
1404
+ if (line !== null && snapshotVariable && headerLineToExcludedVariables.get(line)?.has(snapshotVariable)) {
1405
+ continue;
1406
+ }
1407
+ const headerInfo = line === null ? void 0 : loopBodyLineToHeader.get(line);
1408
+ const headerLine = headerInfo?.line;
1409
+ if (headerInfo && typeof headerLine === "number" && event.kind === "line" && lastLineEventLine !== headerLine) {
1410
+ expanded.push(cloneRuntimeEventAtLine(event, headerLine));
1411
+ for (const [variable, snapshotEvent] of latestSnapshotByVariable) {
1412
+ if (headerInfo.excludedVariables.has(variable)) continue;
1413
+ expanded.push(cloneRuntimeEventAtLine(snapshotEvent, headerLine));
1414
+ }
1415
+ lastLineEventLine = headerLine;
1416
+ }
1417
+ if (headerInfo && typeof headerLine === "number" && event.kind === "line") {
1418
+ for (let lookahead = index + 1; lookahead < events.length; lookahead += 1) {
1419
+ if (eventLine(events[lookahead]) !== line) break;
1420
+ const variable = eventSnapshotVariable(events[lookahead]);
1421
+ if (!variable || !headerInfo.headerVariables.has(variable)) continue;
1422
+ expanded.push(cloneRuntimeEventAtLine(events[lookahead], headerLine));
1423
+ }
1424
+ }
1425
+ expanded.push(event);
1426
+ if (event.kind === "line") {
1427
+ lastLineEventLine = line;
1428
+ }
1429
+ if (snapshotVariable) {
1430
+ latestSnapshotByVariable.set(snapshotVariable, event);
1431
+ }
1432
+ }
1433
+ return expanded;
1434
+ }
1435
+ function nativeJavaTraceEventsToTrace(events, sourceText, options = {}) {
1436
+ const runId = options.runId ?? "java:run";
1437
+ let parsedEvents = events.map((event) => {
1438
+ let parsed;
1439
+ try {
1440
+ parsed = JSON.parse(normalizeJavaNativeTraceJsonPayload(event.slice("trace:".length)));
1441
+ } catch (error) {
1442
+ const message = error instanceof Error ? error.message : String(error);
1443
+ throw new Error(`Invalid Java native runtime trace event: ${message}
1444
+ ${event.slice(0, 500)}`);
1445
+ }
1446
+ return {
1447
+ ...parsed,
1448
+ runId,
1449
+ ...options.file ? { file: options.file } : {}
1450
+ };
1451
+ });
1452
+ parsedEvents = removeSameLineMutationDeclarationSnapshotEvents(parsedEvents, sourceText);
1453
+ parsedEvents = expandJavaLoopHeaderTraceEvents(parsedEvents, sourceText);
1454
+ return {
1455
+ schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
1456
+ language: "java",
1457
+ runId,
1458
+ events: parsedEvents,
1459
+ lineEventCount: parsedEvents.filter((event) => event.kind === "line").length,
1460
+ traceStepCount: parsedEvents.length
1461
+ };
1462
+ }
1463
+ function javaTraceHooksEventsToRuntimeTrace(events, sourceText, options = {}) {
1464
+ assertSupportedRawEmissions(summarizeJavaRawEmissions(events), "java");
1465
+ if (events.length === 0) {
1466
+ return {
1467
+ schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
1468
+ language: "java",
1469
+ runId: options.runId ?? "java:run",
1470
+ events: [],
1471
+ lineEventCount: 0,
1472
+ traceStepCount: 0
1473
+ };
1474
+ }
1475
+ if (!events.every(isNativeJavaTraceEvent)) {
1476
+ throw new Error("Java TraceHooks must emit native runtime trace events. Unsupported line=... events are no longer supported.");
1477
+ }
1478
+ return nativeJavaTraceEventsToTrace(events, sourceText, options);
1479
+ }
1480
+
968
1481
  // packages/harness-browser/src/java-worker-client.ts
1482
+ var EXECUTION_TIMEOUT_MS2 = 2e4;
969
1483
  var TRACING_TIMEOUT_MS2 = 25e3;
970
- var INIT_TIMEOUT_MS2 = 25e3;
1484
+ var INIT_TIMEOUT_MS2 = 12e4;
971
1485
  var MESSAGE_TIMEOUT_MS2 = 3e4;
972
1486
  var WORKER_READY_TIMEOUT_MS2 = 1e4;
1487
+ var JAVA_DEFAULT_FILE = "solution.java";
973
1488
  var JavaWorkerClient = class {
974
1489
  constructor(options) {
975
1490
  this.options = options;
@@ -980,6 +1495,7 @@ var JavaWorkerClient = class {
980
1495
  messageId = 0;
981
1496
  isInitializing = false;
982
1497
  initPromise = null;
1498
+ warmupPromise = null;
983
1499
  workerReadyPromise = null;
984
1500
  workerReadyResolve = null;
985
1501
  workerReadyReject = null;
@@ -1004,6 +1520,22 @@ var JavaWorkerClient = class {
1004
1520
  this.workerReadyResolve?.();
1005
1521
  this.workerReadyResolve = null;
1006
1522
  this.workerReadyReject = null;
1523
+ logRuntimeDiagnostic("info", {
1524
+ component: "JavaWorkerClient",
1525
+ runtime: "java",
1526
+ phase: "worker-ready",
1527
+ message: "Java worker is ready."
1528
+ }, { enabled: this.debug });
1529
+ return;
1530
+ }
1531
+ if (type === "idle-timeout") {
1532
+ logRuntimeDiagnostic("info", {
1533
+ component: "JavaWorkerClient",
1534
+ runtime: "java",
1535
+ phase: "idle-timeout",
1536
+ message: "Java worker closed after idle timeout."
1537
+ }, { enabled: this.debug });
1538
+ this.terminateAndReset(new Error("Java worker closed after idle timeout"));
1007
1539
  return;
1008
1540
  }
1009
1541
  if (!id) return;
@@ -1018,6 +1550,18 @@ var JavaWorkerClient = class {
1018
1550
  pending.resolve(payload);
1019
1551
  };
1020
1552
  this.worker.onerror = (error) => {
1553
+ logRuntimeDiagnostic("error", {
1554
+ component: "JavaWorkerClient",
1555
+ runtime: "java",
1556
+ phase: "worker-error",
1557
+ message: "Java worker emitted an error event.",
1558
+ detail: {
1559
+ message: error.message,
1560
+ filename: error.filename,
1561
+ lineno: error.lineno,
1562
+ colno: error.colno
1563
+ }
1564
+ });
1021
1565
  const workerError = new Error(error.message || "Java worker error");
1022
1566
  this.workerReadyReject?.(workerError);
1023
1567
  this.workerReadyResolve = null;
@@ -1042,6 +1586,13 @@ var JavaWorkerClient = class {
1042
1586
  const timeoutError = new Error(
1043
1587
  `Java worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS2 / 1e3)}s)`
1044
1588
  );
1589
+ logRuntimeDiagnostic("warn", {
1590
+ component: "JavaWorkerClient",
1591
+ runtime: "java",
1592
+ phase: "worker-ready-timeout",
1593
+ message: "Java worker did not send worker-ready before the timeout.",
1594
+ detail: { timeoutMs: WORKER_READY_TIMEOUT_MS2 }
1595
+ }, { enabled: this.debug });
1045
1596
  this.terminateAndReset(timeoutError);
1046
1597
  reject(timeoutError);
1047
1598
  }, WORKER_READY_TIMEOUT_MS2);
@@ -1071,6 +1622,13 @@ var JavaWorkerClient = class {
1071
1622
  const pending2 = this.pendingMessages.get(id);
1072
1623
  if (!pending2) return;
1073
1624
  this.pendingMessages.delete(id);
1625
+ logRuntimeDiagnostic("warn", {
1626
+ component: "JavaWorkerClient",
1627
+ runtime: "java",
1628
+ phase: "worker-request-timeout",
1629
+ message: "Java worker request timed out.",
1630
+ detail: { id, type, timeoutMs }
1631
+ }, { enabled: this.debug });
1074
1632
  pending2.reject(new Error(`Worker request timed out: ${type}`));
1075
1633
  }, timeoutMs);
1076
1634
  const pending = this.pendingMessages.get(id);
@@ -1084,6 +1642,13 @@ var JavaWorkerClient = class {
1084
1642
  const timeoutId = globalThis.setTimeout(() => {
1085
1643
  if (settled) return;
1086
1644
  settled = true;
1645
+ logRuntimeDiagnostic("warn", {
1646
+ component: "JavaWorkerClient",
1647
+ runtime: "java",
1648
+ phase: "execution-timeout",
1649
+ message: "Java execution timed out; terminating worker.",
1650
+ detail: { timeoutMs }
1651
+ }, { enabled: this.debug });
1087
1652
  this.terminateAndReset();
1088
1653
  reject(
1089
1654
  new Error(
@@ -1111,6 +1676,7 @@ var JavaWorkerClient = class {
1111
1676
  this.worker = null;
1112
1677
  }
1113
1678
  this.initPromise = null;
1679
+ this.warmupPromise = null;
1114
1680
  this.isInitializing = false;
1115
1681
  this.workerReadyPromise = null;
1116
1682
  this.workerReadyResolve = null;
@@ -1128,7 +1694,26 @@ var JavaWorkerClient = class {
1128
1694
  return this.init();
1129
1695
  }
1130
1696
  this.isInitializing = true;
1131
- this.initPromise = this.sendMessage("init", void 0, INIT_TIMEOUT_MS2);
1697
+ this.initPromise = (async () => {
1698
+ try {
1699
+ return await this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS2);
1700
+ } catch (error) {
1701
+ const message = error instanceof Error ? error.message : String(error);
1702
+ const shouldRetry = message.includes("Worker request timed out: init") || message.includes("Worker was terminated") || message.includes("Java worker error") || message.includes("failed to initialize in time");
1703
+ if (!shouldRetry) {
1704
+ throw error;
1705
+ }
1706
+ logRuntimeDiagnostic("warn", {
1707
+ component: "JavaWorkerClient",
1708
+ runtime: "java",
1709
+ phase: "init-retry",
1710
+ message: "Java worker init failed; resetting worker and retrying once.",
1711
+ detail: { message }
1712
+ }, { enabled: this.debug });
1713
+ this.terminateAndReset(error instanceof Error ? error : new Error(message));
1714
+ return this.sendMessage("init", this.workerOptionsPayload(), INIT_TIMEOUT_MS2);
1715
+ }
1716
+ })();
1132
1717
  try {
1133
1718
  return await this.initPromise;
1134
1719
  } catch (error) {
@@ -1138,9 +1723,29 @@ var JavaWorkerClient = class {
1138
1723
  this.isInitializing = false;
1139
1724
  }
1140
1725
  }
1726
+ workerOptionsPayload() {
1727
+ return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
1728
+ }
1729
+ async warmup() {
1730
+ if (this.warmupPromise) return this.warmupPromise;
1731
+ this.warmupPromise = (async () => {
1732
+ try {
1733
+ await this.init();
1734
+ return await this.sendMessage(
1735
+ "warmup",
1736
+ this.workerOptionsPayload(),
1737
+ INIT_TIMEOUT_MS2
1738
+ );
1739
+ } catch (error) {
1740
+ this.warmupPromise = null;
1741
+ throw error;
1742
+ }
1743
+ })();
1744
+ return this.warmupPromise;
1745
+ }
1141
1746
  async executeWithTracing(code, functionName, inputs, options, executionStyle) {
1142
1747
  await this.init();
1143
- return this.executeWithTimeout(
1748
+ const result = await this.executeWithTimeout(
1144
1749
  () => this.sendMessage(
1145
1750
  "execute-with-tracing",
1146
1751
  { code, functionName, inputs, options, executionStyle },
@@ -1148,668 +1753,1225 @@ var JavaWorkerClient = class {
1148
1753
  ),
1149
1754
  TRACING_TIMEOUT_MS2
1150
1755
  );
1756
+ return {
1757
+ ...result,
1758
+ trace: result.success ? javaTraceHooksEventsToRuntimeTrace(result.events, result.sourceText, {
1759
+ runId: "java:run",
1760
+ file: JAVA_DEFAULT_FILE
1761
+ }) : createEmptyRuntimeTrace("java", { runId: "java:run", file: JAVA_DEFAULT_FILE })
1762
+ };
1151
1763
  }
1152
1764
  async executeCode(code, functionName, inputs, options, executionStyle) {
1153
- const result = await this.executeWithTracing(code, functionName, inputs, options, executionStyle);
1765
+ return this.executeCodeMessage("execute-code", code, functionName, inputs, options, executionStyle);
1766
+ }
1767
+ async executeCodeMessage(type, code, functionName, inputs, options, executionStyle) {
1768
+ await this.init();
1769
+ const result = await this.executeWithTimeout(
1770
+ () => this.sendMessage(
1771
+ type,
1772
+ { code, functionName, inputs, options, executionStyle },
1773
+ EXECUTION_TIMEOUT_MS2 + 5e3
1774
+ ),
1775
+ EXECUTION_TIMEOUT_MS2
1776
+ );
1154
1777
  if (!result.success) {
1155
1778
  return {
1156
1779
  success: false,
1157
1780
  output: null,
1158
1781
  error: result.error ?? "Java execution failed",
1159
1782
  ...result.errorLine !== void 0 ? { errorLine: result.errorLine } : {},
1160
- consoleOutput: result.consoleOutput
1783
+ consoleOutput: result.consoleOutput ?? [],
1784
+ timings: result.timings
1161
1785
  };
1162
1786
  }
1163
1787
  return {
1164
1788
  success: true,
1165
1789
  output: result.output,
1166
- consoleOutput: result.consoleOutput
1790
+ consoleOutput: result.consoleOutput ?? [],
1791
+ timings: result.timings
1167
1792
  };
1168
1793
  }
1169
1794
  async executeCodeInterviewMode(code, functionName, inputs, options, executionStyle) {
1170
- return this.executeCode(code, functionName, inputs, options, executionStyle);
1795
+ return this.executeCodeMessage("execute-code-interview", code, functionName, inputs, options, executionStyle);
1171
1796
  }
1172
1797
  terminate() {
1173
1798
  this.terminateAndReset();
1174
1799
  }
1175
1800
  };
1176
1801
 
1177
- // packages/harness-core/src/trace-adapters/java.ts
1178
- function parseScalar(raw) {
1179
- if (raw === "null") return null;
1180
- if (raw === "true") return true;
1181
- if (raw === "false") return false;
1182
- if (/^-?\d+$/.test(raw)) return Number.parseInt(raw, 10);
1183
- if (/^-?\d+\.\d+$/.test(raw)) return Number.parseFloat(raw);
1184
- if (raw.startsWith('"') && raw.endsWith('"') || raw.startsWith("[") && raw.endsWith("]") || raw.startsWith("{") && raw.endsWith("}")) {
1185
- try {
1186
- return JSON.parse(raw);
1187
- } catch {
1188
- }
1189
- }
1190
- return raw;
1191
- }
1192
- function normalizeJavaSerializedResult(output) {
1193
- if (typeof output !== "string") {
1194
- return output;
1195
- }
1196
- try {
1197
- return JSON.parse(output);
1198
- } catch {
1199
- return output;
1802
+ // packages/harness-browser/src/java-runtime-client.ts
1803
+ var JAVA_DEFAULT_FILE2 = "solution.java";
1804
+ var JavaRuntimeClient = class {
1805
+ constructor(workerClient) {
1806
+ this.workerClient = workerClient;
1200
1807
  }
1201
- }
1202
- function parseKeyValuePairs(fragment) {
1203
- const variables = {};
1204
- const matches = Array.from(fragment.matchAll(/\b([A-Za-z_][A-Za-z0-9_.]*)=/g));
1205
- for (let index = 0; index < matches.length; index += 1) {
1206
- const match = matches[index];
1207
- const rawKey = match[1];
1208
- const valueStart = (match.index ?? 0) + match[0].length;
1209
- const valueEnd = index + 1 < matches.length ? matches[index + 1].index ?? fragment.length : fragment.length;
1210
- const rawValue = fragment.slice(valueStart, valueEnd).trim();
1211
- if (!rawKey || rawValue === void 0) continue;
1212
- if (rawKey === "method") continue;
1213
- variables[rawKey.replaceAll(".", "_")] = parseScalar(rawValue);
1214
- }
1215
- return variables;
1216
- }
1217
- function extractLineMetadata(event) {
1218
- const match = event.match(/^line=(\d+)(?:\s+(.*))?$/);
1219
- if (!match) {
1220
- return { line: 1, payload: event };
1808
+ async init() {
1809
+ return this.workerClient.init();
1221
1810
  }
1222
- return {
1223
- line: Number.parseInt(match[1], 10),
1224
- payload: match[2] ?? ""
1225
- };
1226
- }
1227
- function stripInlineComments(line, inBlockComment) {
1228
- let result = "";
1229
- let index = 0;
1230
- let inBlock = inBlockComment;
1231
- while (index < line.length) {
1232
- const current = line[index];
1233
- const next = index + 1 < line.length ? line[index + 1] : "";
1234
- if (inBlock) {
1235
- if (current === "*" && next === "/") {
1236
- inBlock = false;
1237
- index += 2;
1238
- continue;
1811
+ async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
1812
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
1813
+ request: "trace",
1814
+ executionStyle,
1815
+ functionName
1816
+ });
1817
+ const rawResult = await this.workerClient.executeWithTracing(
1818
+ code,
1819
+ functionName ?? "",
1820
+ inputs,
1821
+ options,
1822
+ executionStyle
1823
+ );
1824
+ if (!rawResult.success) {
1825
+ return {
1826
+ success: false,
1827
+ error: rawResult.error ?? "Java tracing failed",
1828
+ ...rawResult.errorLine !== void 0 ? { errorLine: rawResult.errorLine } : {},
1829
+ trace: createEmptyRuntimeTrace("java", { runId: "java:run", file: JAVA_DEFAULT_FILE2 }),
1830
+ executionTimeMs: rawResult.executionTimeMs,
1831
+ consoleOutput: rawResult.consoleOutput,
1832
+ ...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
1833
+ ...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
1834
+ lineEventCount: 0,
1835
+ traceStepCount: 0,
1836
+ timings: rawResult.timings
1837
+ };
1838
+ }
1839
+ return {
1840
+ success: true,
1841
+ output: rawResult.output,
1842
+ trace: rawResult.trace,
1843
+ consoleOutput: rawResult.consoleOutput,
1844
+ executionTimeMs: rawResult.executionTimeMs,
1845
+ ...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
1846
+ ...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
1847
+ lineEventCount: rawResult.trace.lineEventCount,
1848
+ traceStepCount: rawResult.trace.traceStepCount,
1849
+ timings: rawResult.timings
1850
+ };
1851
+ }
1852
+ async executeCode(code, functionName, inputs, executionStyle = "function") {
1853
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
1854
+ request: "execute",
1855
+ executionStyle,
1856
+ functionName
1857
+ });
1858
+ return this.workerClient.executeCode(
1859
+ code,
1860
+ functionName,
1861
+ inputs,
1862
+ void 0,
1863
+ executionStyle
1864
+ );
1865
+ }
1866
+ async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
1867
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
1868
+ request: "interview",
1869
+ executionStyle,
1870
+ functionName
1871
+ });
1872
+ return this.workerClient.executeCodeInterviewMode(
1873
+ code,
1874
+ functionName,
1875
+ inputs,
1876
+ void 0,
1877
+ executionStyle
1878
+ );
1879
+ }
1880
+ };
1881
+ function createJavaRuntimeClient(workerClient) {
1882
+ return new JavaRuntimeClient(workerClient);
1883
+ }
1884
+
1885
+ // packages/harness-browser/src/csharp-worker-client.ts
1886
+ var EXECUTION_TIMEOUT_MS3 = 2e4;
1887
+ var TRACING_TIMEOUT_MS3 = 2e4;
1888
+ var INTERVIEW_MODE_TIMEOUT_MS2 = 5e3;
1889
+ var INIT_TIMEOUT_MS3 = 45e3;
1890
+ var MESSAGE_TIMEOUT_MS3 = 3e4;
1891
+ var WORKER_READY_TIMEOUT_MS3 = 1e4;
1892
+ var CSHARP_DEFAULT_FILE = "solution.cs";
1893
+ var CSHARP_LEGACY_USER_FILE = "UserCode.cs";
1894
+ function isCSharpUserFile(file) {
1895
+ return Boolean(file?.endsWith(CSHARP_DEFAULT_FILE) || file?.endsWith(CSHARP_LEGACY_USER_FILE));
1896
+ }
1897
+ function isCSharpUserDiagnostic(diagnostic) {
1898
+ return isCSharpUserFile(diagnostic.file);
1899
+ }
1900
+ function normalizeCSharpTraceEventFile(event) {
1901
+ return isCSharpUserFile(event.file) ? { ...event, file: CSHARP_DEFAULT_FILE } : event;
1902
+ }
1903
+ var CSharpWorkerClient = class {
1904
+ constructor(options) {
1905
+ this.options = options;
1906
+ this.debug = options.debug ?? process.env.NODE_ENV === "development";
1907
+ this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS3;
1908
+ this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS3;
1909
+ this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS3;
1910
+ this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS2;
1911
+ }
1912
+ worker = null;
1913
+ pendingMessages = /* @__PURE__ */ new Map();
1914
+ messageId = 0;
1915
+ isInitializing = false;
1916
+ initPromise = null;
1917
+ warmupPromise = null;
1918
+ workerReadyPromise = null;
1919
+ workerReadyResolve = null;
1920
+ workerReadyReject = null;
1921
+ debug;
1922
+ initTimeoutMs;
1923
+ executionTimeoutMs;
1924
+ tracingTimeoutMs;
1925
+ interviewTimeoutMs;
1926
+ isSupported() {
1927
+ return typeof Worker !== "undefined";
1928
+ }
1929
+ getWorker() {
1930
+ if (this.worker) return this.worker;
1931
+ if (!this.isSupported()) {
1932
+ throw new Error("Web Workers are not supported in this environment");
1933
+ }
1934
+ this.workerReadyPromise = new Promise((resolve, reject) => {
1935
+ this.workerReadyResolve = resolve;
1936
+ this.workerReadyReject = (error) => reject(error);
1937
+ });
1938
+ const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
1939
+ this.worker = new Worker(workerUrl, { type: "module" });
1940
+ this.worker.onmessage = (event) => {
1941
+ const { id, type, payload } = event.data;
1942
+ if (type === "worker-ready") {
1943
+ this.workerReadyResolve?.();
1944
+ this.workerReadyResolve = null;
1945
+ this.workerReadyReject = null;
1946
+ logRuntimeDiagnostic("info", {
1947
+ component: "CSharpWorkerClient",
1948
+ runtime: "csharp",
1949
+ phase: "worker-ready",
1950
+ message: "C# worker is ready."
1951
+ }, { enabled: this.debug });
1952
+ return;
1953
+ }
1954
+ if (type === "idle-timeout") {
1955
+ logRuntimeDiagnostic("info", {
1956
+ component: "CSharpWorkerClient",
1957
+ runtime: "csharp",
1958
+ phase: "idle-timeout",
1959
+ message: "C# worker closed after idle timeout."
1960
+ }, { enabled: this.debug });
1961
+ this.terminateAndReset(new Error("C# worker closed after idle timeout"));
1962
+ return;
1963
+ }
1964
+ if (!id) return;
1965
+ const pending = this.pendingMessages.get(id);
1966
+ if (!pending) return;
1967
+ this.pendingMessages.delete(id);
1968
+ if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
1969
+ if (type === "error") {
1970
+ pending.reject(new Error(payload.error));
1971
+ return;
1972
+ }
1973
+ pending.resolve(payload);
1974
+ };
1975
+ this.worker.onerror = (error) => {
1976
+ logRuntimeDiagnostic("error", {
1977
+ component: "CSharpWorkerClient",
1978
+ runtime: "csharp",
1979
+ phase: "worker-error",
1980
+ message: "C# worker emitted an error event.",
1981
+ detail: {
1982
+ message: error.message,
1983
+ filename: error.filename,
1984
+ lineno: error.lineno,
1985
+ colno: error.colno
1986
+ }
1987
+ });
1988
+ const workerError = new Error(error.message || "C# worker error");
1989
+ this.workerReadyReject?.(workerError);
1990
+ this.workerReadyResolve = null;
1991
+ this.workerReadyReject = null;
1992
+ for (const [, pending] of this.pendingMessages) {
1993
+ if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
1994
+ pending.reject(workerError);
1995
+ }
1996
+ this.pendingMessages.clear();
1997
+ this.terminateAndReset(workerError);
1998
+ };
1999
+ return this.worker;
2000
+ }
2001
+ async waitForWorkerReady() {
2002
+ const readyPromise = this.workerReadyPromise;
2003
+ if (!readyPromise) return;
2004
+ await new Promise((resolve, reject) => {
2005
+ let settled = false;
2006
+ const timeoutId = globalThis.setTimeout(() => {
2007
+ if (settled) return;
2008
+ settled = true;
2009
+ const timeoutError = new Error(
2010
+ `C# worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS3 / 1e3)}s)`
2011
+ );
2012
+ logRuntimeDiagnostic("warn", {
2013
+ component: "CSharpWorkerClient",
2014
+ runtime: "csharp",
2015
+ phase: "worker-ready-timeout",
2016
+ message: "C# worker did not send worker-ready before the timeout.",
2017
+ detail: { timeoutMs: WORKER_READY_TIMEOUT_MS3 }
2018
+ }, { enabled: this.debug });
2019
+ this.terminateAndReset(timeoutError);
2020
+ reject(timeoutError);
2021
+ }, WORKER_READY_TIMEOUT_MS3);
2022
+ readyPromise.then(() => {
2023
+ if (settled) return;
2024
+ settled = true;
2025
+ globalThis.clearTimeout(timeoutId);
2026
+ resolve();
2027
+ }).catch((error) => {
2028
+ if (settled) return;
2029
+ settled = true;
2030
+ globalThis.clearTimeout(timeoutId);
2031
+ reject(error instanceof Error ? error : new Error(String(error)));
2032
+ });
2033
+ });
2034
+ }
2035
+ async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS3) {
2036
+ const worker = this.getWorker();
2037
+ await this.waitForWorkerReady();
2038
+ const id = String(++this.messageId);
2039
+ return new Promise((resolve, reject) => {
2040
+ this.pendingMessages.set(id, {
2041
+ resolve,
2042
+ reject
2043
+ });
2044
+ const timeoutId = globalThis.setTimeout(() => {
2045
+ const pending2 = this.pendingMessages.get(id);
2046
+ if (!pending2) return;
2047
+ this.pendingMessages.delete(id);
2048
+ logRuntimeDiagnostic("warn", {
2049
+ component: "CSharpWorkerClient",
2050
+ runtime: "csharp",
2051
+ phase: "worker-request-timeout",
2052
+ message: "C# worker request timed out.",
2053
+ detail: { id, type, timeoutMs }
2054
+ }, { enabled: this.debug });
2055
+ pending2.reject(new Error(`Worker request timed out: ${type}`));
2056
+ }, timeoutMs);
2057
+ const pending = this.pendingMessages.get(id);
2058
+ if (pending) pending.timeoutId = timeoutId;
2059
+ worker.postMessage({ id, type, payload });
2060
+ });
2061
+ }
2062
+ async executeWithTimeout(executor, timeoutMs) {
2063
+ return new Promise((resolve, reject) => {
2064
+ let settled = false;
2065
+ const timeoutId = globalThis.setTimeout(() => {
2066
+ if (settled) return;
2067
+ settled = true;
2068
+ logRuntimeDiagnostic("warn", {
2069
+ component: "CSharpWorkerClient",
2070
+ runtime: "csharp",
2071
+ phase: "execution-timeout",
2072
+ message: "C# execution timed out; terminating worker.",
2073
+ detail: { timeoutMs }
2074
+ }, { enabled: this.debug });
2075
+ this.terminateAndReset();
2076
+ reject(new Error(`C# execution timed out after ${Math.round(timeoutMs / 1e3)} seconds.`));
2077
+ }, timeoutMs);
2078
+ executor().then((result) => {
2079
+ if (settled) return;
2080
+ settled = true;
2081
+ globalThis.clearTimeout(timeoutId);
2082
+ resolve(result);
2083
+ }).catch((error) => {
2084
+ if (settled) return;
2085
+ settled = true;
2086
+ globalThis.clearTimeout(timeoutId);
2087
+ reject(error);
2088
+ });
2089
+ });
2090
+ }
2091
+ terminateAndReset(reason = new Error("Worker was terminated")) {
2092
+ this.workerReadyReject?.(reason);
2093
+ if (this.worker) {
2094
+ this.worker.terminate();
2095
+ this.worker = null;
2096
+ }
2097
+ this.initPromise = null;
2098
+ this.warmupPromise = null;
2099
+ this.isInitializing = false;
2100
+ this.workerReadyPromise = null;
2101
+ this.workerReadyResolve = null;
2102
+ this.workerReadyReject = null;
2103
+ for (const [, pending] of this.pendingMessages) {
2104
+ if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
2105
+ pending.reject(reason);
2106
+ }
2107
+ this.pendingMessages.clear();
2108
+ }
2109
+ shouldRetryInit(error) {
2110
+ const message = error instanceof Error ? error.message : String(error);
2111
+ return message.includes("timed out") || message.includes("Worker request timed out") || message.includes("worker error") || message.includes("Failed to fetch") || message.includes("was terminated") || message.includes("closed after idle timeout");
2112
+ }
2113
+ sendInitMessage() {
2114
+ return this.sendMessage(
2115
+ "init",
2116
+ { assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
2117
+ this.initTimeoutMs
2118
+ );
2119
+ }
2120
+ workerOptionsPayload() {
2121
+ return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
2122
+ }
2123
+ async init() {
2124
+ if (this.initPromise) return this.initPromise;
2125
+ if (this.isInitializing) {
2126
+ await new Promise((resolve) => globalThis.setTimeout(resolve, 100));
2127
+ return this.init();
2128
+ }
2129
+ this.isInitializing = true;
2130
+ this.initPromise = (async () => {
2131
+ try {
2132
+ return await this.sendInitMessage();
2133
+ } catch (error) {
2134
+ if (!this.shouldRetryInit(error)) throw error;
2135
+ this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
2136
+ return this.sendInitMessage();
2137
+ }
2138
+ })();
2139
+ try {
2140
+ return await this.initPromise;
2141
+ } catch (error) {
2142
+ this.initPromise = null;
2143
+ throw error;
2144
+ } finally {
2145
+ this.isInitializing = false;
2146
+ }
2147
+ }
2148
+ async warmup() {
2149
+ if (this.warmupPromise) return this.warmupPromise;
2150
+ this.warmupPromise = (async () => {
2151
+ try {
2152
+ await this.init();
2153
+ return await this.sendMessage(
2154
+ "warmup",
2155
+ { assetBaseUrl: this.options.assetBaseUrl, ...this.workerOptionsPayload() },
2156
+ this.initTimeoutMs
2157
+ );
2158
+ } catch (error) {
2159
+ this.warmupPromise = null;
2160
+ throw error;
2161
+ }
2162
+ })();
2163
+ return this.warmupPromise;
2164
+ }
2165
+ async executeCode(code, functionName, inputs, executionStyle) {
2166
+ await this.init();
2167
+ const result = await this.executeWithTimeout(
2168
+ () => this.sendMessage(
2169
+ "execute-code",
2170
+ {
2171
+ code,
2172
+ functionName,
2173
+ inputs,
2174
+ executionStyle,
2175
+ assetBaseUrl: this.options.assetBaseUrl,
2176
+ timeoutMs: Math.max(100, this.executionTimeoutMs - 1e3),
2177
+ ...this.workerOptionsPayload()
2178
+ },
2179
+ this.executionTimeoutMs + 5e3
2180
+ ),
2181
+ this.executionTimeoutMs
2182
+ );
2183
+ if (!result.success) {
2184
+ const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
2185
+ return {
2186
+ success: false,
2187
+ output: null,
2188
+ error: result.error ?? "C# execution failed",
2189
+ ...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
2190
+ consoleOutput: result.consoleOutput ?? [],
2191
+ timings: result.timings
2192
+ };
2193
+ }
2194
+ return {
2195
+ success: true,
2196
+ output: result.output,
2197
+ consoleOutput: result.consoleOutput ?? [],
2198
+ timings: result.timings
2199
+ };
2200
+ }
2201
+ async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
2202
+ await this.init();
2203
+ let result;
2204
+ try {
2205
+ result = await this.executeWithTimeout(
2206
+ () => this.sendMessage(
2207
+ "execute-code-interview",
2208
+ {
2209
+ code,
2210
+ functionName,
2211
+ inputs,
2212
+ executionStyle,
2213
+ assetBaseUrl: this.options.assetBaseUrl,
2214
+ timeoutMs: Math.max(100, this.interviewTimeoutMs - 1e3),
2215
+ ...this.workerOptionsPayload()
2216
+ },
2217
+ this.interviewTimeoutMs + 5e3
2218
+ ),
2219
+ this.interviewTimeoutMs
2220
+ );
2221
+ } catch {
2222
+ return {
2223
+ success: false,
2224
+ output: null,
2225
+ error: "Time Limit Exceeded",
2226
+ timeoutReason: "client-timeout",
2227
+ diagnosticStage: "interview",
2228
+ consoleOutput: [],
2229
+ timings: { totalMs: this.interviewTimeoutMs }
2230
+ };
2231
+ }
2232
+ if (!result.success) {
2233
+ const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
2234
+ if (this.isInterviewTimeoutLike(result)) {
2235
+ return {
2236
+ success: false,
2237
+ output: null,
2238
+ error: "Time Limit Exceeded",
2239
+ timeoutReason: result.timeoutReason ?? "client-timeout",
2240
+ diagnosticStage: "interview",
2241
+ consoleOutput: result.consoleOutput ?? [],
2242
+ timings: result.timings
2243
+ };
1239
2244
  }
1240
- index += 1;
1241
- continue;
2245
+ return {
2246
+ success: false,
2247
+ output: null,
2248
+ error: result.error ?? "C# execution failed",
2249
+ ...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
2250
+ consoleOutput: result.consoleOutput ?? [],
2251
+ timings: result.timings
2252
+ };
1242
2253
  }
1243
- if (current === "/" && next === "*") {
1244
- inBlock = true;
1245
- index += 2;
1246
- continue;
2254
+ return {
2255
+ success: true,
2256
+ output: result.output,
2257
+ consoleOutput: result.consoleOutput ?? [],
2258
+ timings: result.timings
2259
+ };
2260
+ }
2261
+ async executeWithTracing(code, functionName, inputs, options, executionStyle) {
2262
+ await this.init();
2263
+ let result;
2264
+ try {
2265
+ result = await this.executeWithTimeout(
2266
+ () => this.sendMessage(
2267
+ "execute-with-tracing",
2268
+ {
2269
+ code,
2270
+ functionName,
2271
+ inputs,
2272
+ executionStyle,
2273
+ assetBaseUrl: this.options.assetBaseUrl,
2274
+ timeoutMs: Math.max(100, this.tracingTimeoutMs - 1e3),
2275
+ maxTraceSteps: options?.maxTraceSteps,
2276
+ maxLineEvents: options?.maxLineEvents,
2277
+ maxSingleLineHits: options?.maxSingleLineHits,
2278
+ maxStoredEvents: options?.maxStoredEvents,
2279
+ minimalTrace: options?.minimalTrace,
2280
+ ...this.workerOptionsPayload()
2281
+ },
2282
+ this.tracingTimeoutMs + 5e3
2283
+ ),
2284
+ this.tracingTimeoutMs
2285
+ );
2286
+ } catch (error) {
2287
+ const message = error instanceof Error ? error.message : String(error);
2288
+ const trace2 = this.createTrace([
2289
+ {
2290
+ kind: "timeout",
2291
+ runId: "csharp:run",
2292
+ file: CSHARP_DEFAULT_FILE,
2293
+ message
2294
+ }
2295
+ ]);
2296
+ return {
2297
+ success: false,
2298
+ output: null,
2299
+ error: message,
2300
+ trace: trace2,
2301
+ executionTimeMs: this.tracingTimeoutMs,
2302
+ consoleOutput: [],
2303
+ traceLimitExceeded: true,
2304
+ timeoutReason: "client-timeout",
2305
+ lineEventCount: trace2.lineEventCount,
2306
+ traceStepCount: trace2.traceStepCount,
2307
+ timings: { totalMs: this.tracingTimeoutMs }
2308
+ };
1247
2309
  }
1248
- if (current === "/" && next === "/") {
1249
- break;
2310
+ const consoleOutput = result.consoleOutput ?? [];
2311
+ const events = [
2312
+ ...result.events ?? [],
2313
+ ...consoleOutput.map((text) => ({
2314
+ kind: "stdout",
2315
+ runId: "csharp:run",
2316
+ file: CSHARP_DEFAULT_FILE,
2317
+ text
2318
+ }))
2319
+ ];
2320
+ const trace = this.createTrace(events);
2321
+ if (!result.success) {
2322
+ const firstUserDiagnostic = result.diagnostics?.find(isCSharpUserDiagnostic);
2323
+ return {
2324
+ success: false,
2325
+ output: null,
2326
+ error: result.error ?? "C# execution failed",
2327
+ ...firstUserDiagnostic ? { errorLine: firstUserDiagnostic.line } : {},
2328
+ trace,
2329
+ executionTimeMs: result.executionTimeMs ?? 0,
2330
+ consoleOutput,
2331
+ ...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
2332
+ ...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
2333
+ lineEventCount: trace.lineEventCount,
2334
+ traceStepCount: trace.traceStepCount,
2335
+ timings: result.timings
2336
+ };
1250
2337
  }
1251
- result += current;
1252
- index += 1;
2338
+ return {
2339
+ success: true,
2340
+ output: result.output,
2341
+ trace,
2342
+ executionTimeMs: result.executionTimeMs ?? 0,
2343
+ consoleOutput,
2344
+ ...result.traceLimitExceeded !== void 0 ? { traceLimitExceeded: result.traceLimitExceeded } : {},
2345
+ ...result.timeoutReason ? { timeoutReason: result.timeoutReason } : {},
2346
+ lineEventCount: trace.lineEventCount,
2347
+ traceStepCount: trace.traceStepCount,
2348
+ timings: result.timings
2349
+ };
1253
2350
  }
1254
- return { text: result, inBlockComment: inBlock };
1255
- }
1256
- function isMethodDeclarationLine(line) {
1257
- const trimmed = line.trim();
1258
- if (!trimmed) return false;
1259
- if (trimmed.startsWith("@")) return false;
1260
- if (!trimmed.includes("(") || !trimmed.includes(")")) return false;
1261
- if (trimmed.endsWith(";")) return false;
1262
- if (trimmed.includes("->")) return false;
1263
- if (/^(?:if|for|while|switch|catch|do|try|else|return|throw|new)\b/.test(trimmed)) {
1264
- return false;
2351
+ createTrace(events) {
2352
+ return {
2353
+ schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
2354
+ language: "csharp",
2355
+ runId: "csharp:run",
2356
+ events: events.map(normalizeCSharpTraceEventFile),
2357
+ lineEventCount: events.filter((event) => event.kind === "line").length,
2358
+ traceStepCount: events.length
2359
+ };
1265
2360
  }
1266
- if (!/[A-Za-z_][A-Za-z0-9_]*\s*\([^{};]*\)/.test(trimmed)) {
1267
- return false;
2361
+ isInterviewTimeoutLike(result) {
2362
+ if (result.timeoutReason) return true;
2363
+ const normalized = String(result.error ?? "").toLowerCase();
2364
+ return normalized.includes("timed out") || normalized.includes("trace-limit") || normalized.includes("line-limit") || normalized.includes("single-line-limit") || normalized.includes("recursion-limit") || normalized.includes("memory-limit");
1268
2365
  }
1269
- return /(?:\{\s*)?$/.test(trimmed);
1270
- }
1271
- function buildLineRemap(sourceText) {
1272
- if (typeof sourceText !== "string" || sourceText.length === 0) {
1273
- return null;
2366
+ terminate() {
2367
+ this.terminateAndReset();
1274
2368
  }
1275
- const lines = sourceText.split(/\r?\n/);
1276
- const executable = /* @__PURE__ */ new Set();
1277
- let inBlockComment = false;
1278
- for (let index = 0; index < lines.length; index += 1) {
1279
- const { text, inBlockComment: nextInBlockComment } = stripInlineComments(lines[index] ?? "", inBlockComment);
1280
- inBlockComment = nextInBlockComment;
1281
- if (text.trim().length > 0) {
1282
- executable.add(index + 1);
1283
- }
2369
+ };
2370
+
2371
+ // packages/harness-browser/src/csharp-runtime-client.ts
2372
+ var CSharpRuntimeClient = class {
2373
+ constructor(workerClient) {
2374
+ this.workerClient = workerClient;
1284
2375
  }
1285
- if (executable.size === 0) {
1286
- return null;
2376
+ async init() {
2377
+ return this.workerClient.init();
1287
2378
  }
1288
- const nextExecutableAtOrAfter = new Array(lines.length + 2).fill(null);
1289
- let nextExecutable = null;
1290
- for (let line = lines.length; line >= 1; line -= 1) {
1291
- if (executable.has(line)) {
1292
- nextExecutable = line;
1293
- }
1294
- nextExecutableAtOrAfter[line] = nextExecutable;
2379
+ async executeWithTracing(code, functionName, inputs, options, executionStyle = "solution-method") {
2380
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
2381
+ request: "trace",
2382
+ executionStyle,
2383
+ functionName
2384
+ });
2385
+ return this.workerClient.executeWithTracing(
2386
+ code,
2387
+ functionName ?? "",
2388
+ inputs,
2389
+ options,
2390
+ executionStyle
2391
+ );
1295
2392
  }
1296
- const previousExecutableAtOrBefore = new Array(lines.length + 2).fill(null);
1297
- let previousExecutable = null;
1298
- for (let line = 1; line <= lines.length; line += 1) {
1299
- if (executable.has(line)) {
1300
- previousExecutable = line;
1301
- }
1302
- previousExecutableAtOrBefore[line] = previousExecutable;
2393
+ async executeCode(code, functionName, inputs, executionStyle = "solution-method") {
2394
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
2395
+ request: "execute",
2396
+ executionStyle,
2397
+ functionName
2398
+ });
2399
+ return this.workerClient.executeCode(
2400
+ code,
2401
+ functionName,
2402
+ inputs,
2403
+ executionStyle
2404
+ );
1303
2405
  }
1304
- const remap = /* @__PURE__ */ new Map();
1305
- for (let line = 1; line <= lines.length; line += 1) {
1306
- if (executable.has(line)) continue;
1307
- const forward = nextExecutableAtOrAfter[line];
1308
- const backward = previousExecutableAtOrBefore[line];
1309
- const target = forward ?? backward;
1310
- if (target !== null && target !== line) {
1311
- remap.set(line, target);
1312
- }
2406
+ async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "solution-method") {
2407
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("csharp"), {
2408
+ request: "interview",
2409
+ executionStyle,
2410
+ functionName
2411
+ });
2412
+ return this.workerClient.executeCodeInterviewMode(
2413
+ code,
2414
+ functionName,
2415
+ inputs,
2416
+ executionStyle
2417
+ );
1313
2418
  }
1314
- return remap;
2419
+ };
2420
+ function createCSharpRuntimeClient(workerClient) {
2421
+ return new CSharpRuntimeClient(workerClient);
1315
2422
  }
1316
- function buildMethodDeclarationLineSet(sourceText) {
1317
- if (typeof sourceText !== "string" || sourceText.length === 0) {
1318
- return null;
2423
+
2424
+ // packages/harness-browser/src/cpp-worker-client.ts
2425
+ var CppClientTimeoutError = class extends Error {
2426
+ constructor(message, stage, timeoutMs) {
2427
+ super(message);
2428
+ this.stage = stage;
2429
+ this.timeoutMs = timeoutMs;
2430
+ this.name = "CppClientTimeoutError";
1319
2431
  }
1320
- const declarationLines = /* @__PURE__ */ new Set();
1321
- const lines = sourceText.split(/\r?\n/);
1322
- let inBlockComment = false;
1323
- for (let index = 0; index < lines.length; index += 1) {
1324
- const { text, inBlockComment: nextInBlockComment } = stripInlineComments(lines[index] ?? "", inBlockComment);
1325
- inBlockComment = nextInBlockComment;
1326
- if (isMethodDeclarationLine(text)) {
1327
- declarationLines.add(index + 1);
1328
- }
2432
+ };
2433
+ var INIT_TIMEOUT_MS4 = 12e4;
2434
+ var EXECUTION_TIMEOUT_MS4 = 6e4;
2435
+ var TRACING_TIMEOUT_MS4 = 6e4;
2436
+ var INTERVIEW_MODE_TIMEOUT_MS3 = 3e4;
2437
+ var MESSAGE_TIMEOUT_MS4 = 3e4;
2438
+ var WORKER_READY_TIMEOUT_MS4 = 1e4;
2439
+ var CPP_DEFAULT_FILE = "solution.cpp";
2440
+ var CppWorkerClient = class {
2441
+ constructor(options) {
2442
+ this.options = options;
2443
+ this.debug = options.debug ?? process.env.NODE_ENV === "development";
2444
+ this.initTimeoutMs = options.initTimeoutMs ?? INIT_TIMEOUT_MS4;
2445
+ this.executionTimeoutMs = options.executionTimeoutMs ?? EXECUTION_TIMEOUT_MS4;
2446
+ this.tracingTimeoutMs = options.tracingTimeoutMs ?? TRACING_TIMEOUT_MS4;
2447
+ this.interviewTimeoutMs = options.interviewTimeoutMs ?? INTERVIEW_MODE_TIMEOUT_MS3;
2448
+ this.compilerFrameUrl = options.compilerFrameUrl;
1329
2449
  }
1330
- return declarationLines;
1331
- }
1332
- function parseAccessEvent(payload) {
1333
- const isEphemeralOutputArrayName = (name) => /^(output|outputs)$/i.test(name);
1334
- const cellRead = payload.match(/^access ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\]\[(\d+)\]=(.+)$/);
1335
- if (cellRead) {
1336
- return [{
1337
- variable: cellRead[1],
1338
- kind: "cell-read",
1339
- indices: [Number.parseInt(cellRead[2], 10), Number.parseInt(cellRead[3], 10)],
1340
- pathDepth: 2
1341
- }];
1342
- }
1343
- const indexedRead = payload.match(/^access ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\]=(.+)$/);
1344
- if (indexedRead) {
1345
- return [{
1346
- variable: indexedRead[1],
1347
- kind: "indexed-read",
1348
- indices: [Number.parseInt(indexedRead[2], 10)],
1349
- pathDepth: 1
1350
- }];
1351
- }
1352
- const cellWrite = payload.match(/^write-array ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\]\[(\d+)\]=(.+)$/);
1353
- if (cellWrite) {
1354
- return [{
1355
- variable: cellWrite[1],
1356
- kind: "cell-write",
1357
- indices: [Number.parseInt(cellWrite[2], 10), Number.parseInt(cellWrite[3], 10)],
1358
- pathDepth: 2
1359
- }];
1360
- }
1361
- const indexedWrite = payload.match(/^write-array ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\]=(.+)$/);
1362
- if (indexedWrite) {
1363
- if (isEphemeralOutputArrayName(indexedWrite[1])) {
1364
- return void 0;
1365
- }
1366
- return [{
1367
- variable: indexedWrite[1],
1368
- kind: "indexed-write",
1369
- indices: [Number.parseInt(indexedWrite[2], 10)],
1370
- pathDepth: 1
1371
- }];
1372
- }
1373
- const mutatingCall = payload.match(/^mutate ([A-Za-z_][A-Za-z0-9_]*) method=([A-Za-z_][A-Za-z0-9_]*)$/);
1374
- if (mutatingCall) {
1375
- return [{
1376
- variable: mutatingCall[1],
1377
- kind: "mutating-call",
1378
- method: mutatingCall[2],
1379
- pathDepth: 1
1380
- }];
1381
- }
1382
- const indexedMutatingCall = payload.match(/^mutate-indexed ([A-Za-z_][A-Za-z0-9_]*)\[(\d+)\] method=([A-Za-z_][A-Za-z0-9_]*)$/);
1383
- if (indexedMutatingCall) {
1384
- return [{
1385
- variable: indexedMutatingCall[1],
1386
- kind: "mutating-call",
1387
- indices: [Number.parseInt(indexedMutatingCall[2], 10)],
1388
- method: indexedMutatingCall[3],
1389
- pathDepth: 1
1390
- }];
1391
- }
1392
- const keyedCall = payload.match(/^keyed-call ([A-Za-z_][A-Za-z0-9_]*) method=([A-Za-z_][A-Za-z0-9_]*)(?:\s+.*)?$/);
1393
- if (keyedCall) {
1394
- return [{
1395
- variable: keyedCall[1],
1396
- kind: "mutating-call",
1397
- method: keyedCall[2],
1398
- pathDepth: 1
1399
- }];
1400
- }
1401
- return void 0;
1402
- }
1403
- function parseStructureState(payload) {
1404
- const match = payload.match(/^state (linked-list|tree|graph-adjacency) ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
1405
- if (!match) return null;
1406
- return {
1407
- structure: match[1],
1408
- variable: match[2],
1409
- value: JSON.parse(match[3])
1410
- };
1411
- }
1412
- function parseObjectState(payload) {
1413
- const match = payload.match(/^object-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
1414
- if (!match) return null;
1415
- return {
1416
- variable: match[1],
1417
- visualization: JSON.parse(match[2])
1418
- };
1419
- }
1420
- function parseMapState(payload) {
1421
- const match = payload.match(/^map-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
1422
- if (!match) return null;
1423
- return {
1424
- variable: match[1],
1425
- visualization: JSON.parse(match[2])
1426
- };
1427
- }
1428
- function parseSetState(payload) {
1429
- const match = payload.match(/^set-state ([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
1430
- if (!match) return null;
1431
- return {
1432
- variable: match[1],
1433
- visualization: JSON.parse(match[2])
1434
- };
1435
- }
1436
- function parseObjectFieldEvent(payload) {
1437
- const match = payload.match(/^(access|write) ([A-Za-z_][A-Za-z0-9_]*)\.([A-Za-z_][A-Za-z0-9_]*)=(.+)$/);
1438
- if (!match) return null;
1439
- return {
1440
- variable: match[2],
1441
- field: match[3],
1442
- value: parseScalar(match[4])
1443
- };
1444
- }
1445
- function isArrayLengthAccessEvent(payload) {
1446
- return /^access [A-Za-z_][A-Za-z0-9_]*\.length=\d+$/.test(payload);
1447
- }
1448
- function buildFieldVisualization(event) {
1449
- return {
1450
- objectKinds: {
1451
- [event.variable]: "object"
1452
- },
1453
- hashMaps: [
1454
- {
1455
- name: event.variable,
1456
- kind: "object",
1457
- objectClassName: event.field === "next" || event.field === "prev" ? "ListNode" : event.field === "left" || event.field === "right" ? "TreeNode" : void 0,
1458
- objectId: `${event.variable}-object`,
1459
- highlightedKey: event.field,
1460
- entries: [{ key: event.field, value: event.value, highlight: true }]
2450
+ worker = null;
2451
+ pendingMessages = /* @__PURE__ */ new Map();
2452
+ messageId = 0;
2453
+ initPromise = null;
2454
+ warmupPromise = null;
2455
+ workerReadyPromise = null;
2456
+ workerReadyResolve = null;
2457
+ workerReadyReject = null;
2458
+ debug;
2459
+ initTimeoutMs;
2460
+ executionTimeoutMs;
2461
+ tracingTimeoutMs;
2462
+ interviewTimeoutMs;
2463
+ compilerFrameUrl;
2464
+ activeCompilerFrames = /* @__PURE__ */ new Set();
2465
+ compilerFrame = null;
2466
+ compilerFrameReadyPromise = null;
2467
+ compilerFrameReadyResolve = null;
2468
+ compilerFrameReadyReject = null;
2469
+ compilerFrameTargetOrigin = "";
2470
+ compilerFrameRequestId = 0;
2471
+ compilerFrameMessageHandler = null;
2472
+ pendingCompilerFrameRequests = /* @__PURE__ */ new Map();
2473
+ isSupported() {
2474
+ return typeof Worker !== "undefined";
2475
+ }
2476
+ getWorker() {
2477
+ if (this.worker) return this.worker;
2478
+ if (!this.isSupported()) {
2479
+ throw new Error("Web Workers are not supported in this environment");
2480
+ }
2481
+ this.workerReadyPromise = new Promise((resolve, reject) => {
2482
+ this.workerReadyResolve = resolve;
2483
+ this.workerReadyReject = (error) => reject(error);
2484
+ });
2485
+ const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
2486
+ this.worker = new Worker(workerUrl, { type: "module" });
2487
+ this.worker.onmessage = (event) => {
2488
+ const { id, type, payload } = event.data;
2489
+ if (type === "worker-ready") {
2490
+ this.workerReadyResolve?.();
2491
+ this.workerReadyResolve = null;
2492
+ this.workerReadyReject = null;
2493
+ logRuntimeDiagnostic("info", {
2494
+ component: "CppWorkerClient",
2495
+ runtime: "cpp",
2496
+ phase: "worker-ready",
2497
+ message: "C++ worker is ready."
2498
+ }, { enabled: this.debug });
2499
+ return;
1461
2500
  }
1462
- ]
1463
- };
1464
- }
1465
- function callStacksEqual(left, right) {
1466
- return JSON.stringify(left ?? []) === JSON.stringify(right ?? []);
1467
- }
1468
- function mergeVisualizationPayloads(left, right) {
1469
- if (!left) return right;
1470
- if (!right) return left;
1471
- return {
1472
- ...left,
1473
- ...right,
1474
- objectKinds: {
1475
- ...left.objectKinds ?? {},
1476
- ...right.objectKinds ?? {}
1477
- },
1478
- hashMaps: [
1479
- ...left.hashMaps ?? [],
1480
- ...right.hashMaps ?? []
1481
- ]
1482
- };
1483
- }
1484
- function maybeMergeConsecutiveLineStep(trace, nextStep) {
1485
- if (nextStep.event !== "line") {
1486
- return false;
2501
+ if (type === "idle-timeout") {
2502
+ logRuntimeDiagnostic("info", {
2503
+ component: "CppWorkerClient",
2504
+ runtime: "cpp",
2505
+ phase: "idle-timeout",
2506
+ message: "C++ worker closed after idle timeout."
2507
+ }, { enabled: this.debug });
2508
+ this.terminateAndReset(new Error("C++ worker closed after idle timeout"));
2509
+ return;
2510
+ }
2511
+ if (type === "compile-request") {
2512
+ this.handleCompileRequest(event.data).catch((error) => {
2513
+ if (!event.data.requestId) return;
2514
+ this.worker?.postMessage({
2515
+ type: "compile-response",
2516
+ requestId: event.data.requestId,
2517
+ payload: { success: false, error: error instanceof Error ? error.message : String(error) }
2518
+ });
2519
+ });
2520
+ return;
2521
+ }
2522
+ if (!id) return;
2523
+ const pending = this.pendingMessages.get(id);
2524
+ if (!pending) return;
2525
+ this.pendingMessages.delete(id);
2526
+ if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
2527
+ if (type === "error") {
2528
+ pending.reject(new Error(payload.error));
2529
+ return;
2530
+ }
2531
+ pending.resolve(payload);
2532
+ };
2533
+ this.worker.onerror = (error) => {
2534
+ logRuntimeDiagnostic("error", {
2535
+ component: "CppWorkerClient",
2536
+ runtime: "cpp",
2537
+ phase: "worker-error",
2538
+ message: "C++ worker emitted an error event.",
2539
+ detail: {
2540
+ message: error.message,
2541
+ filename: error.filename,
2542
+ lineno: error.lineno,
2543
+ colno: error.colno
2544
+ }
2545
+ });
2546
+ const workerError = new Error(error.message || "C++ worker error");
2547
+ this.workerReadyReject?.(workerError);
2548
+ this.workerReadyResolve = null;
2549
+ this.workerReadyReject = null;
2550
+ this.terminateAndReset(workerError);
2551
+ };
2552
+ return this.worker;
2553
+ }
2554
+ async waitForWorkerReady() {
2555
+ const readyPromise = this.workerReadyPromise;
2556
+ if (!readyPromise) return;
2557
+ await new Promise((resolve, reject) => {
2558
+ let settled = false;
2559
+ const timeoutId = globalThis.setTimeout(() => {
2560
+ if (settled) return;
2561
+ settled = true;
2562
+ const timeoutError = new Error(
2563
+ `C++ worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS4 / 1e3)}s)`
2564
+ );
2565
+ logRuntimeDiagnostic("warn", {
2566
+ component: "CppWorkerClient",
2567
+ runtime: "cpp",
2568
+ phase: "worker-ready-timeout",
2569
+ message: "C++ worker did not send worker-ready before the timeout.",
2570
+ detail: { timeoutMs: WORKER_READY_TIMEOUT_MS4 }
2571
+ }, { enabled: this.debug });
2572
+ this.terminateAndReset(timeoutError);
2573
+ reject(timeoutError);
2574
+ }, WORKER_READY_TIMEOUT_MS4);
2575
+ readyPromise.then(() => {
2576
+ if (settled) return;
2577
+ settled = true;
2578
+ globalThis.clearTimeout(timeoutId);
2579
+ resolve();
2580
+ }).catch((error) => {
2581
+ if (settled) return;
2582
+ settled = true;
2583
+ globalThis.clearTimeout(timeoutId);
2584
+ reject(error instanceof Error ? error : new Error(String(error)));
2585
+ });
2586
+ });
1487
2587
  }
1488
- const previous = trace.at(-1);
1489
- if (!previous || previous.event !== "line") {
1490
- return false;
2588
+ async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS4) {
2589
+ const worker = this.getWorker();
2590
+ await this.waitForWorkerReady();
2591
+ const id = String(++this.messageId);
2592
+ return new Promise((resolve, reject) => {
2593
+ this.pendingMessages.set(id, {
2594
+ resolve,
2595
+ reject
2596
+ });
2597
+ const timeoutId = globalThis.setTimeout(() => {
2598
+ const pending2 = this.pendingMessages.get(id);
2599
+ if (!pending2) return;
2600
+ this.pendingMessages.delete(id);
2601
+ logRuntimeDiagnostic("warn", {
2602
+ component: "CppWorkerClient",
2603
+ runtime: "cpp",
2604
+ phase: "worker-request-timeout",
2605
+ message: "C++ worker request timed out.",
2606
+ detail: { id, type, timeoutMs }
2607
+ }, { enabled: this.debug });
2608
+ pending2.reject(new Error(`Worker request timed out: ${type}`));
2609
+ }, timeoutMs);
2610
+ const pending = this.pendingMessages.get(id);
2611
+ if (pending) pending.timeoutId = timeoutId;
2612
+ worker.postMessage({ id, type, payload });
2613
+ });
1491
2614
  }
1492
- if (previous.line !== nextStep.line || previous.function !== nextStep.function) {
1493
- return false;
2615
+ async executeWithTimeout(executor, timeoutMs, stage) {
2616
+ return new Promise((resolve, reject) => {
2617
+ let settled = false;
2618
+ const timeoutId = globalThis.setTimeout(() => {
2619
+ if (settled) return;
2620
+ settled = true;
2621
+ const timeoutLabel = stage === "trace" ? "tracing" : stage === "interview" ? "interview execution" : "compile/run";
2622
+ const timeoutError = new CppClientTimeoutError(
2623
+ `C++ ${timeoutLabel} timed out after ${Math.round(timeoutMs / 1e3)} seconds.`,
2624
+ stage,
2625
+ timeoutMs
2626
+ );
2627
+ logRuntimeDiagnostic("warn", {
2628
+ component: "CppWorkerClient",
2629
+ runtime: "cpp",
2630
+ phase: "execution-timeout",
2631
+ message: "C++ execution timed out; terminating worker.",
2632
+ detail: { timeoutMs, stage }
2633
+ }, { enabled: this.debug });
2634
+ this.terminateAndReset(timeoutError);
2635
+ reject(timeoutError);
2636
+ }, timeoutMs);
2637
+ executor().then((result) => {
2638
+ if (settled) return;
2639
+ settled = true;
2640
+ globalThis.clearTimeout(timeoutId);
2641
+ resolve(result);
2642
+ }).catch((error) => {
2643
+ if (settled) return;
2644
+ settled = true;
2645
+ globalThis.clearTimeout(timeoutId);
2646
+ reject(error);
2647
+ });
2648
+ });
1494
2649
  }
1495
- if (!callStacksEqual(previous.callStack, nextStep.callStack)) {
1496
- return false;
2650
+ isClientTimeout(error) {
2651
+ return error instanceof CppClientTimeoutError || error instanceof Error && error.message.includes("C++") && error.message.includes("timed out");
1497
2652
  }
1498
- previous.variables = { ...previous.variables ?? {}, ...nextStep.variables ?? {} };
1499
- if (nextStep.accesses?.length) {
1500
- previous.accesses = [...previous.accesses ?? [], ...nextStep.accesses];
2653
+ timeoutCodeResult(error) {
2654
+ const timeoutError = error instanceof CppClientTimeoutError ? error : null;
2655
+ return {
2656
+ success: false,
2657
+ output: null,
2658
+ error: error instanceof Error ? error.message : String(error),
2659
+ consoleOutput: [],
2660
+ timeoutReason: "client-timeout",
2661
+ diagnosticStage: timeoutError?.stage === "interview" ? "interview" : "runtime",
2662
+ timings: { totalMs: timeoutError?.timeoutMs ?? this.executionTimeoutMs }
2663
+ };
1501
2664
  }
1502
- previous.visualization = mergeVisualizationPayloads(previous.visualization, nextStep.visualization);
1503
- return true;
1504
- }
1505
- function filterStructuredVariables(variables) {
1506
- if (!variables) {
1507
- return void 0;
2665
+ timeoutTraceResult(error) {
2666
+ const timeoutError = error instanceof CppClientTimeoutError ? error : null;
2667
+ const trace = createEmptyRuntimeTrace("cpp", { runId: "cpp:run", file: CPP_DEFAULT_FILE });
2668
+ trace.events = [
2669
+ {
2670
+ kind: "timeout",
2671
+ runId: "cpp:run",
2672
+ file: CPP_DEFAULT_FILE,
2673
+ message: error instanceof Error ? error.message : String(error)
2674
+ }
2675
+ ];
2676
+ trace.traceStepCount = 1;
2677
+ return {
2678
+ success: false,
2679
+ output: null,
2680
+ error: error instanceof Error ? error.message : String(error),
2681
+ trace,
2682
+ executionTimeMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs,
2683
+ consoleOutput: [],
2684
+ traceLimitExceeded: true,
2685
+ timeoutReason: "client-timeout",
2686
+ lineEventCount: 0,
2687
+ traceStepCount: 1,
2688
+ timings: { totalMs: timeoutError?.timeoutMs ?? this.tracingTimeoutMs }
2689
+ };
1508
2690
  }
1509
- const isEphemeralOutputArrayName = (name) => /^(output|outputs)$/i.test(name);
1510
- const entries = Object.entries(variables).filter(([name, value]) => {
1511
- if (value === null || typeof value !== "object") {
1512
- return false;
1513
- }
1514
- if (!Array.isArray(value)) {
1515
- return true;
2691
+ terminateAndReset(reason = new Error("Worker was terminated")) {
2692
+ this.workerReadyReject?.(reason);
2693
+ if (this.worker) {
2694
+ this.worker.terminate();
2695
+ this.worker = null;
1516
2696
  }
1517
- if (Array.isArray(value[0])) {
1518
- return true;
2697
+ this.initPromise = null;
2698
+ this.warmupPromise = null;
2699
+ this.workerReadyPromise = null;
2700
+ this.workerReadyResolve = null;
2701
+ this.workerReadyReject = null;
2702
+ for (const [, pending] of this.pendingMessages) {
2703
+ if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
2704
+ pending.reject(reason);
1519
2705
  }
1520
- return !isEphemeralOutputArrayName(name);
1521
- });
1522
- if (entries.length === 0) {
1523
- return void 0;
1524
- }
1525
- return Object.fromEntries(entries);
1526
- }
1527
- function appendJavaTraceStep(trace, step, pendingAccesses, options = {}) {
1528
- const nextStep = pendingAccesses.length > 0 ? { ...step, accesses: [...pendingAccesses] } : step;
1529
- pendingAccesses.length = 0;
1530
- if (options.allowMerge !== false && maybeMergeConsecutiveLineStep(trace, nextStep)) {
1531
- return;
2706
+ this.pendingMessages.clear();
2707
+ this.clearCompilerFrames();
1532
2708
  }
1533
- trace.push(nextStep);
1534
- }
1535
- function mergeIntoPreviousMatchingLineStep(trace, line, currentFunction, currentCallStack, patch) {
1536
- const candidate = trace.at(-1);
1537
- if (!candidate || candidate.event !== "line") {
1538
- return false;
2709
+ shouldRetryInit(error) {
2710
+ const message = error instanceof Error ? error.message : String(error);
2711
+ return message.includes("timed out") || message.includes("Worker request timed out") || message.includes("worker error") || message.includes("Failed to fetch") || message.includes("was terminated") || message.includes("closed after idle timeout");
1539
2712
  }
1540
- if (candidate.line !== line || candidate.function !== currentFunction) {
1541
- return false;
2713
+ sendInitMessage() {
2714
+ return this.sendMessage(
2715
+ "init",
2716
+ {
2717
+ assets: {
2718
+ clangWasmUrl: this.options.clangWasmUrl,
2719
+ lldWasmUrl: this.options.lldWasmUrl,
2720
+ sysrootUrl: this.options.sysrootUrl,
2721
+ runtimeHeaderUrl: this.options.runtimeHeaderUrl,
2722
+ compilerBundleUrl: this.options.compilerBundleUrl,
2723
+ compilerFrameEnabled: Boolean(this.compilerFrameUrl && typeof document !== "undefined"),
2724
+ compilerFrameUrl: this.compilerFrameUrl,
2725
+ compilerWorkerUrl: this.options.compilerWorkerUrl
2726
+ },
2727
+ ...this.workerOptionsPayload()
2728
+ },
2729
+ this.initTimeoutMs
2730
+ );
1542
2731
  }
1543
- if (!callStacksEqual(candidate.callStack, currentCallStack)) {
1544
- return false;
2732
+ async init() {
2733
+ if (this.initPromise) return this.initPromise;
2734
+ this.initPromise = (async () => {
2735
+ try {
2736
+ return await this.sendInitMessage();
2737
+ } catch (error) {
2738
+ if (!this.shouldRetryInit(error)) throw error;
2739
+ this.terminateAndReset(error instanceof Error ? error : new Error(String(error)));
2740
+ return this.sendInitMessage();
2741
+ }
2742
+ })();
2743
+ try {
2744
+ return await this.initPromise;
2745
+ } catch (error) {
2746
+ this.initPromise = null;
2747
+ throw error;
2748
+ }
1545
2749
  }
1546
- candidate.variables = { ...candidate.variables ?? {}, ...patch.variables ?? {} };
1547
- if (patch.accesses?.length) {
1548
- candidate.accesses = [...candidate.accesses ?? [], ...patch.accesses];
2750
+ workerOptionsPayload() {
2751
+ return this.options.workerIdleTimeoutMs === void 0 ? {} : { idleTimeoutMs: this.options.workerIdleTimeoutMs };
1549
2752
  }
1550
- candidate.visualization = mergeVisualizationPayloads(candidate.visualization, patch.visualization);
1551
- return true;
1552
- }
1553
- function mergeAccessesIntoPreviousMatchingLineStep(trace, line, currentFunction, currentCallStack, accesses) {
1554
- return mergeIntoPreviousMatchingLineStep(trace, line, currentFunction, currentCallStack, {
1555
- variables: void 0,
1556
- accesses,
1557
- visualization: void 0
1558
- });
1559
- }
1560
- function eventsToRawTrace(events, sourceText) {
1561
- const trace = [];
1562
- const variables = {};
1563
- const objectKinds = {};
1564
- const stack = [];
1565
- const pendingAccesses = [];
1566
- let currentFunction = "<module>";
1567
- let previousRawLine = null;
1568
- const lineRemap = buildLineRemap(sourceText);
1569
- const declarationLines = buildMethodDeclarationLineSet(sourceText);
1570
- for (const rawEvent of events) {
1571
- if (rawEvent === "clear" || rawEvent === "reset") continue;
1572
- const metadata = extractLineMetadata(rawEvent);
1573
- const previousEventRawLine = previousRawLine;
1574
- previousRawLine = metadata.line;
1575
- const line = lineRemap?.get(metadata.line) ?? metadata.line;
1576
- const payload = metadata.payload;
1577
- const isDeclarationLine = declarationLines?.has(line) === true;
1578
- if (payload.startsWith("call ")) {
1579
- const match = payload.match(/^call\s+(\S+)(?:\s+(.*))?$/);
1580
- const functionName = match?.[1] ?? currentFunction;
1581
- const argsFragment = match?.[2] ?? "";
1582
- const args = parseKeyValuePairs(argsFragment);
1583
- Object.assign(variables, args);
1584
- currentFunction = functionName || currentFunction;
1585
- stack.push({ function: currentFunction, line, args });
1586
- appendJavaTraceStep(trace, {
1587
- line,
1588
- event: "call",
1589
- function: currentFunction,
1590
- variables: { ...variables },
1591
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } }))
1592
- }, pendingAccesses);
1593
- continue;
1594
- }
1595
- if (payload.startsWith("return ")) {
1596
- const match = payload.match(/^return\s+(\S+)(?:\s+value=(.*))?$/);
1597
- const functionName = match?.[1] ?? currentFunction;
1598
- const returnValue = match?.[2] !== void 0 ? parseScalar(match[2].trim()) : void 0;
1599
- const returnVariables = functionName === "<module>" ? { ...variables } : filterStructuredVariables(variables) ?? {};
1600
- appendJavaTraceStep(trace, {
1601
- line,
1602
- event: "return",
1603
- function: functionName || currentFunction,
1604
- variables: returnVariables,
1605
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1606
- ...returnValue !== void 0 ? { returnValue } : {}
1607
- }, pendingAccesses);
1608
- stack.pop();
1609
- currentFunction = stack[stack.length - 1]?.function ?? "<module>";
1610
- continue;
1611
- }
1612
- if (isDeclarationLine) {
1613
- continue;
2753
+ async warmup() {
2754
+ if (this.warmupPromise) return this.warmupPromise;
2755
+ this.warmupPromise = (async () => {
2756
+ try {
2757
+ await this.init();
2758
+ return await this.sendMessage("warmup", this.workerOptionsPayload(), this.initTimeoutMs);
2759
+ } catch (error) {
2760
+ this.warmupPromise = null;
2761
+ throw error;
2762
+ }
2763
+ })();
2764
+ return this.warmupPromise;
2765
+ }
2766
+ clearCompilerFrames(reason = new Error("C++ compiler frame was closed")) {
2767
+ this.compilerFrameReadyReject?.(reason);
2768
+ this.compilerFrameReadyPromise = null;
2769
+ this.compilerFrameReadyResolve = null;
2770
+ this.compilerFrameReadyReject = null;
2771
+ if (this.compilerFrameMessageHandler) {
2772
+ globalThis.removeEventListener("message", this.compilerFrameMessageHandler);
2773
+ this.compilerFrameMessageHandler = null;
1614
2774
  }
1615
- if (payload.length === 0) {
1616
- appendJavaTraceStep(trace, {
1617
- line,
1618
- event: "line",
1619
- function: currentFunction,
1620
- variables: { ...variables },
1621
- ...stack.length > 0 ? { callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) } : {}
1622
- }, pendingAccesses, { allowMerge: previousEventRawLine !== metadata.line });
1623
- continue;
2775
+ for (const [, pending] of this.pendingCompilerFrameRequests) {
2776
+ globalThis.clearTimeout(pending.timeoutId);
2777
+ pending.resolve({ success: false, error: reason.message });
1624
2778
  }
1625
- const structureState = parseStructureState(payload);
1626
- if (structureState) {
1627
- variables[structureState.variable] = structureState.value;
1628
- objectKinds[structureState.variable] = structureState.structure;
1629
- appendJavaTraceStep(trace, {
1630
- line,
1631
- event: "line",
1632
- function: currentFunction,
1633
- variables: { ...variables },
1634
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1635
- visualization: {
1636
- objectKinds: { ...objectKinds }
1637
- }
1638
- }, pendingAccesses);
1639
- continue;
2779
+ this.pendingCompilerFrameRequests.clear();
2780
+ this.compilerFrame = null;
2781
+ this.compilerFrameTargetOrigin = "";
2782
+ for (const frame of this.activeCompilerFrames) {
2783
+ frame.remove();
1640
2784
  }
1641
- const objectState = parseObjectState(payload);
1642
- if (objectState) {
1643
- variables[objectState.variable] = { __ref__: objectState.visualization.objectId ?? `${objectState.variable}-object` };
1644
- appendJavaTraceStep(trace, {
1645
- line,
1646
- event: "line",
1647
- function: currentFunction,
1648
- variables: { ...variables },
1649
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1650
- visualization: {
1651
- objectKinds: { [objectState.variable]: "object" },
1652
- hashMaps: [objectState.visualization]
1653
- }
1654
- }, pendingAccesses);
1655
- continue;
2785
+ this.activeCompilerFrames.clear();
2786
+ }
2787
+ async handleCompileRequest(message) {
2788
+ if (!message.requestId) return;
2789
+ const worker = this.worker;
2790
+ if (!worker) return;
2791
+ const result = await this.compileInFrame(message.payload);
2792
+ const transfer = result?.programBuffer instanceof ArrayBuffer ? [result.programBuffer] : [];
2793
+ worker.postMessage(
2794
+ {
2795
+ type: "compile-response",
2796
+ requestId: message.requestId,
2797
+ payload: result
2798
+ },
2799
+ transfer
2800
+ );
2801
+ }
2802
+ ensureCompilerFrame() {
2803
+ if (!this.compilerFrameUrl || typeof document === "undefined") {
2804
+ return Promise.reject(new Error("C++ compiler frame is not available."));
1656
2805
  }
1657
- const mapState = parseMapState(payload);
1658
- if (mapState) {
1659
- const entries = mapState.visualization.entries.map((entry) => [entry.key, entry.value]);
1660
- variables[mapState.variable] = { __type__: "map", entries };
1661
- appendJavaTraceStep(trace, {
1662
- line,
1663
- event: "line",
1664
- function: currentFunction,
1665
- variables: { ...variables },
1666
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1667
- visualization: {
1668
- objectKinds: { [mapState.variable]: "map" },
1669
- hashMaps: [mapState.visualization]
2806
+ if (this.compilerFrame && this.compilerFrameReadyPromise) return this.compilerFrameReadyPromise;
2807
+ const frameUrl = new URL(this.compilerFrameUrl, globalThis.location?.href);
2808
+ this.compilerFrameTargetOrigin = frameUrl.origin;
2809
+ const iframe = document.createElement("iframe");
2810
+ iframe.src = frameUrl.href;
2811
+ iframe.style.display = "none";
2812
+ iframe.setAttribute("aria-hidden", "true");
2813
+ this.compilerFrame = iframe;
2814
+ this.activeCompilerFrames.add(iframe);
2815
+ this.compilerFrameReadyPromise = new Promise((resolve, reject) => {
2816
+ let settled = false;
2817
+ let timeoutId;
2818
+ const finishReady = () => {
2819
+ if (settled) return;
2820
+ settled = true;
2821
+ globalThis.clearTimeout(timeoutId);
2822
+ this.compilerFrameReadyResolve = null;
2823
+ this.compilerFrameReadyReject = null;
2824
+ resolve();
2825
+ };
2826
+ const onMessage = (event) => {
2827
+ if (event.source !== iframe.contentWindow) return;
2828
+ if (event.origin !== this.compilerFrameTargetOrigin) return;
2829
+ if (event.data?.type === "frame-ready") {
2830
+ finishReady();
2831
+ return;
1670
2832
  }
1671
- }, pendingAccesses);
1672
- continue;
2833
+ const requestId = event.data?.id;
2834
+ if (!requestId) return;
2835
+ const pending = this.pendingCompilerFrameRequests.get(requestId);
2836
+ if (!pending) return;
2837
+ this.pendingCompilerFrameRequests.delete(requestId);
2838
+ globalThis.clearTimeout(pending.timeoutId);
2839
+ const response = event.data;
2840
+ pending.resolve(response.payload ?? { success: false, error: "C++ compiler frame returned an empty response." });
2841
+ };
2842
+ this.compilerFrameMessageHandler = onMessage;
2843
+ timeoutId = globalThis.setTimeout(() => {
2844
+ const error = new Error("C++ compiler frame request timed out.");
2845
+ this.clearCompilerFrames(error);
2846
+ reject(error);
2847
+ }, this.initTimeoutMs);
2848
+ this.compilerFrameReadyResolve = finishReady;
2849
+ this.compilerFrameReadyReject = (error) => {
2850
+ if (settled) return;
2851
+ settled = true;
2852
+ globalThis.clearTimeout(timeoutId);
2853
+ reject(error);
2854
+ };
2855
+ globalThis.addEventListener("message", onMessage);
2856
+ document.body.appendChild(iframe);
2857
+ });
2858
+ return this.compilerFrameReadyPromise;
2859
+ }
2860
+ async compileInFrame(payload) {
2861
+ try {
2862
+ await this.ensureCompilerFrame();
2863
+ } catch (error) {
2864
+ return { success: false, error: error instanceof Error ? error.message : String(error) };
1673
2865
  }
1674
- const setState = parseSetState(payload);
1675
- if (setState) {
1676
- const values = setState.visualization.entries.map((entry) => entry.key);
1677
- variables[setState.variable] = { __type__: "set", values };
1678
- appendJavaTraceStep(trace, {
1679
- line,
1680
- event: "line",
1681
- function: currentFunction,
1682
- variables: { ...variables },
1683
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1684
- visualization: {
1685
- objectKinds: { [setState.variable]: "set" },
1686
- hashMaps: [setState.visualization]
1687
- }
1688
- }, pendingAccesses);
1689
- continue;
2866
+ const iframe = this.compilerFrame;
2867
+ const frameWindow = iframe?.contentWindow;
2868
+ if (!frameWindow) {
2869
+ return { success: false, error: "C++ compiler frame is not available." };
1690
2870
  }
1691
- if (isArrayLengthAccessEvent(payload)) {
1692
- continue;
2871
+ return new Promise((resolve) => {
2872
+ const requestId = `compile-${++this.compilerFrameRequestId}`;
2873
+ const timeoutId = globalThis.setTimeout(() => {
2874
+ this.pendingCompilerFrameRequests.delete(requestId);
2875
+ resolve({ success: false, error: "C++ compiler frame request timed out." });
2876
+ }, this.initTimeoutMs);
2877
+ this.pendingCompilerFrameRequests.set(requestId, { resolve, timeoutId });
2878
+ frameWindow.postMessage(
2879
+ {
2880
+ id: requestId,
2881
+ type: "compile",
2882
+ payload
2883
+ },
2884
+ this.compilerFrameTargetOrigin
2885
+ );
2886
+ });
2887
+ }
2888
+ async executeCode(code, functionName, inputs, executionStyle) {
2889
+ await this.init();
2890
+ try {
2891
+ return await this.executeWithTimeout(
2892
+ () => this.sendMessage(
2893
+ "compile-run",
2894
+ { code, functionName, inputs, executionStyle },
2895
+ this.executionTimeoutMs + 5e3
2896
+ ),
2897
+ this.executionTimeoutMs,
2898
+ "compile-run"
2899
+ );
2900
+ } catch (error) {
2901
+ if (this.isClientTimeout(error)) return this.timeoutCodeResult(error);
2902
+ throw error;
1693
2903
  }
1694
- const accesses = parseAccessEvent(payload);
1695
- if (accesses) {
1696
- const currentCallStack = stack.length > 0 ? stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) : void 0;
1697
- if (mergeAccessesIntoPreviousMatchingLineStep(trace, line, currentFunction, currentCallStack, accesses)) {
1698
- continue;
1699
- }
1700
- pendingAccesses.push(...accesses);
1701
- continue;
2904
+ }
2905
+ async executeWithTracing(code, functionName, inputs, options, executionStyle) {
2906
+ await this.init();
2907
+ try {
2908
+ return await this.executeWithTimeout(
2909
+ () => this.sendMessage(
2910
+ "execute-with-tracing",
2911
+ { code, functionName, inputs, options, executionStyle },
2912
+ this.tracingTimeoutMs + 5e3
2913
+ ),
2914
+ this.tracingTimeoutMs,
2915
+ "trace"
2916
+ );
2917
+ } catch (error) {
2918
+ if (this.isClientTimeout(error)) return this.timeoutTraceResult(error);
2919
+ throw error;
1702
2920
  }
1703
- const objectField = parseObjectFieldEvent(payload);
1704
- if (objectField) {
1705
- variables[objectField.variable] = { __ref__: `${objectField.variable}-object` };
1706
- const currentCallStack = stack.length > 0 ? stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) : void 0;
1707
- if (mergeIntoPreviousMatchingLineStep(trace, line, currentFunction, currentCallStack, {
1708
- variables: { ...variables },
1709
- accesses: void 0,
1710
- visualization: buildFieldVisualization(objectField)
1711
- })) {
1712
- continue;
1713
- }
1714
- appendJavaTraceStep(trace, {
1715
- line,
1716
- event: "line",
1717
- function: currentFunction,
1718
- variables: { ...variables },
1719
- callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })),
1720
- visualization: buildFieldVisualization(objectField)
1721
- }, pendingAccesses);
1722
- continue;
2921
+ }
2922
+ async executeCodeInterviewMode(code, functionName, inputs, executionStyle) {
2923
+ await this.init();
2924
+ try {
2925
+ return await this.executeWithTimeout(
2926
+ () => this.sendMessage(
2927
+ "execute-code-interview",
2928
+ { code, functionName, inputs, executionStyle },
2929
+ this.interviewTimeoutMs + 5e3
2930
+ ),
2931
+ this.interviewTimeoutMs,
2932
+ "interview"
2933
+ );
2934
+ } catch {
2935
+ return {
2936
+ success: false,
2937
+ output: null,
2938
+ error: "Time Limit Exceeded",
2939
+ timeoutReason: "client-timeout",
2940
+ diagnosticStage: "interview",
2941
+ consoleOutput: [],
2942
+ timings: { totalMs: this.interviewTimeoutMs }
2943
+ };
1723
2944
  }
1724
- Object.assign(variables, parseKeyValuePairs(payload));
1725
- appendJavaTraceStep(trace, {
1726
- line,
1727
- event: "line",
1728
- function: currentFunction,
1729
- variables: { ...variables },
1730
- ...stack.length > 0 ? { callStack: stack.map((frame) => ({ function: frame.function, line: frame.line, args: { ...frame.args } })) } : {}
1731
- }, pendingAccesses);
1732
2945
  }
1733
- if (pendingAccesses.length > 0 && trace.length > 0) {
1734
- const last = trace[trace.length - 1];
1735
- last.accesses = [...last.accesses ?? [], ...pendingAccesses];
2946
+ terminate() {
2947
+ this.terminateAndReset();
1736
2948
  }
1737
- return trace;
1738
- }
1739
- function buildJavaExecutionResult(output, events, executionTimeMs = 0, traceLimitExceeded, timeoutReason, maxTraceSteps, sourceText, options = {}) {
1740
- const trace = eventsToRawTrace(events, sourceText);
1741
- return {
1742
- success: true,
1743
- output: options.outputIsSerialized === false ? output : normalizeJavaSerializedResult(output),
1744
- trace,
1745
- executionTimeMs,
1746
- consoleOutput: [],
1747
- ...traceLimitExceeded !== void 0 ? { traceLimitExceeded } : {},
1748
- ...maxTraceSteps !== void 0 ? { maxTraceSteps } : {},
1749
- ...timeoutReason ? { timeoutReason } : {},
1750
- lineEventCount: trace.filter((step) => step.event === "line").length,
1751
- traceStepCount: trace.length
1752
- };
1753
- }
1754
- function adaptJavaTraceExecutionResult(result) {
1755
- return adaptTraceExecutionResult("java", result);
1756
- }
2949
+ };
1757
2950
 
1758
- // packages/harness-browser/src/java-runtime-client.ts
1759
- var JavaRuntimeClient = class {
2951
+ // packages/harness-browser/src/cpp-runtime-client.ts
2952
+ var CppRuntimeClient = class {
1760
2953
  constructor(workerClient) {
1761
2954
  this.workerClient = workerClient;
1762
2955
  }
1763
2956
  async init() {
1764
2957
  return this.workerClient.init();
1765
2958
  }
1766
- async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
1767
- assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
2959
+ async executeWithTracing(code, functionName, inputs, options, executionStyle = "solution-method") {
2960
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
1768
2961
  request: "trace",
1769
2962
  executionStyle,
1770
2963
  functionName
1771
2964
  });
1772
- const rawResult = await this.workerClient.executeWithTracing(
2965
+ return this.workerClient.executeWithTracing(
1773
2966
  code,
1774
2967
  functionName ?? "",
1775
2968
  inputs,
1776
2969
  options,
1777
2970
  executionStyle
1778
2971
  );
1779
- if (!rawResult.success) {
1780
- return {
1781
- success: false,
1782
- error: rawResult.error ?? "Java tracing failed",
1783
- ...rawResult.errorLine !== void 0 ? { errorLine: rawResult.errorLine } : {},
1784
- trace: [],
1785
- executionTimeMs: rawResult.executionTimeMs,
1786
- consoleOutput: rawResult.consoleOutput,
1787
- ...rawResult.traceLimitExceeded !== void 0 ? { traceLimitExceeded: rawResult.traceLimitExceeded } : {},
1788
- ...rawResult.timeoutReason ? { timeoutReason: rawResult.timeoutReason } : {},
1789
- lineEventCount: 0,
1790
- traceStepCount: 0
1791
- };
1792
- }
1793
- const adapted = adaptJavaTraceExecutionResult(
1794
- buildJavaExecutionResult(
1795
- rawResult.output,
1796
- rawResult.events,
1797
- rawResult.executionTimeMs,
1798
- rawResult.traceLimitExceeded,
1799
- rawResult.timeoutReason,
1800
- void 0,
1801
- rawResult.sourceText,
1802
- { outputIsSerialized: false }
1803
- )
1804
- );
1805
- return {
1806
- ...adapted,
1807
- consoleOutput: rawResult.consoleOutput,
1808
- executionTimeMs: rawResult.executionTimeMs
1809
- };
1810
2972
  }
1811
- async executeCode(code, functionName, inputs, executionStyle = "function") {
1812
- assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
2973
+ async executeCode(code, functionName, inputs, executionStyle = "solution-method") {
2974
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
1813
2975
  request: "execute",
1814
2976
  executionStyle,
1815
2977
  functionName
@@ -1818,12 +2980,11 @@ var JavaRuntimeClient = class {
1818
2980
  code,
1819
2981
  functionName,
1820
2982
  inputs,
1821
- void 0,
1822
2983
  executionStyle
1823
2984
  );
1824
2985
  }
1825
- async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
1826
- assertRuntimeRequestSupported(getLanguageRuntimeProfile("java"), {
2986
+ async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "solution-method") {
2987
+ assertRuntimeRequestSupported(getLanguageRuntimeProfile("cpp"), {
1827
2988
  request: "interview",
1828
2989
  executionStyle,
1829
2990
  functionName
@@ -1832,23 +2993,22 @@ var JavaRuntimeClient = class {
1832
2993
  code,
1833
2994
  functionName,
1834
2995
  inputs,
1835
- void 0,
1836
2996
  executionStyle
1837
2997
  );
1838
2998
  }
1839
2999
  };
1840
- function createJavaRuntimeClient(workerClient) {
1841
- return new JavaRuntimeClient(workerClient);
3000
+ function createCppRuntimeClient(workerClient) {
3001
+ return new CppRuntimeClient(workerClient);
1842
3002
  }
1843
3003
 
1844
3004
  // packages/harness-browser/src/pyodide-worker-client.ts
1845
- var EXECUTION_TIMEOUT_MS2 = 1e4;
1846
- var INTERVIEW_MODE_TIMEOUT_MS2 = 5e3;
1847
- var TRACING_TIMEOUT_MS3 = 3e4;
1848
- var INIT_TIMEOUT_MS3 = 12e4;
1849
- var MESSAGE_TIMEOUT_MS3 = 2e4;
1850
- var WORKER_READY_TIMEOUT_MS3 = 1e4;
1851
- var PyodideWorkerClient = class {
3005
+ var EXECUTION_TIMEOUT_MS5 = 1e4;
3006
+ var INTERVIEW_MODE_TIMEOUT_MS4 = 5e3;
3007
+ var TRACING_TIMEOUT_MS5 = 3e4;
3008
+ var INIT_TIMEOUT_MS5 = 12e4;
3009
+ var MESSAGE_TIMEOUT_MS5 = 2e4;
3010
+ var WORKER_READY_TIMEOUT_MS5 = 1e4;
3011
+ var PythonWorkerClient = class {
1852
3012
  constructor(options) {
1853
3013
  this.options = options;
1854
3014
  this.debug = options.debug ?? process.env.NODE_ENV === "development";
@@ -1858,6 +3018,7 @@ var PyodideWorkerClient = class {
1858
3018
  messageId = 0;
1859
3019
  isInitializing = false;
1860
3020
  initPromise = null;
3021
+ warmupPromise = null;
1861
3022
  workerReadyPromise = null;
1862
3023
  workerReadyResolve = null;
1863
3024
  workerReadyReject = null;
@@ -1888,11 +3049,22 @@ var PyodideWorkerClient = class {
1888
3049
  this.workerReadyResolve?.();
1889
3050
  this.workerReadyResolve = null;
1890
3051
  this.workerReadyReject = null;
1891
- if (this.debug) console.log("[PyodideWorkerClient] worker-ready");
3052
+ logRuntimeDiagnostic("info", {
3053
+ component: "PythonWorkerClient",
3054
+ runtime: "python",
3055
+ phase: "worker-ready",
3056
+ message: "Python worker is ready."
3057
+ }, { enabled: this.debug });
1892
3058
  return;
1893
3059
  }
1894
3060
  if (this.debug && !id) {
1895
- console.log("[PyodideWorkerClient] event", { type, payload });
3061
+ logRuntimeDiagnostic("debug", {
3062
+ component: "PythonWorkerClient",
3063
+ runtime: "python",
3064
+ phase: "worker-event",
3065
+ message: "Python worker emitted an unsolicited event.",
3066
+ detail: { type, payload }
3067
+ }, { enabled: this.debug });
1896
3068
  }
1897
3069
  if (id) {
1898
3070
  const pending = this.pendingMessages.get(id);
@@ -1902,14 +3074,31 @@ var PyodideWorkerClient = class {
1902
3074
  if (type === "error") {
1903
3075
  pending.reject(new Error(payload.error));
1904
3076
  } else {
1905
- if (this.debug) console.log("[PyodideWorkerClient] recv", { id, type });
3077
+ logRuntimeDiagnostic("debug", {
3078
+ component: "PythonWorkerClient",
3079
+ runtime: "python",
3080
+ phase: "worker-response",
3081
+ message: "Python worker response received.",
3082
+ detail: { id, type }
3083
+ }, { enabled: this.debug });
1906
3084
  pending.resolve(payload);
1907
3085
  }
1908
3086
  }
1909
3087
  }
1910
3088
  };
1911
3089
  this.worker.onerror = (error) => {
1912
- console.error("[PyodideWorkerClient] Worker error:", error);
3090
+ logRuntimeDiagnostic("error", {
3091
+ component: "PythonWorkerClient",
3092
+ runtime: "python",
3093
+ phase: "worker-error",
3094
+ message: "Python worker emitted an error event.",
3095
+ detail: {
3096
+ message: error.message,
3097
+ filename: error.filename,
3098
+ lineno: error.lineno,
3099
+ colno: error.colno
3100
+ }
3101
+ });
1913
3102
  const workerError = new Error("Worker error");
1914
3103
  this.workerReadyReject?.(workerError);
1915
3104
  this.workerReadyResolve = null;
@@ -1937,14 +3126,18 @@ var PyodideWorkerClient = class {
1937
3126
  if (settled) return;
1938
3127
  settled = true;
1939
3128
  const timeoutError = new Error(
1940
- `Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS3 / 1e3)}s)`
3129
+ `Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS5 / 1e3)}s)`
1941
3130
  );
1942
- if (this.debug) {
1943
- console.warn("[PyodideWorkerClient] worker-ready timeout", { timeoutMs: WORKER_READY_TIMEOUT_MS3 });
1944
- }
3131
+ logRuntimeDiagnostic("warn", {
3132
+ component: "PythonWorkerClient",
3133
+ runtime: "python",
3134
+ phase: "worker-ready-timeout",
3135
+ message: "Python worker did not send worker-ready before the timeout.",
3136
+ detail: { timeoutMs: WORKER_READY_TIMEOUT_MS5 }
3137
+ }, { enabled: this.debug });
1945
3138
  this.terminateAndReset(timeoutError);
1946
3139
  reject(timeoutError);
1947
- }, WORKER_READY_TIMEOUT_MS3);
3140
+ }, WORKER_READY_TIMEOUT_MS5);
1948
3141
  readyPromise.then(() => {
1949
3142
  if (settled) return;
1950
3143
  settled = true;
@@ -1961,7 +3154,7 @@ var PyodideWorkerClient = class {
1961
3154
  /**
1962
3155
  * Send a message to the worker and wait for a response
1963
3156
  */
1964
- async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS3) {
3157
+ async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS5) {
1965
3158
  const worker = this.getWorker();
1966
3159
  await this.waitForWorkerReady();
1967
3160
  const id = String(++this.messageId);
@@ -1970,12 +3163,24 @@ var PyodideWorkerClient = class {
1970
3163
  resolve,
1971
3164
  reject
1972
3165
  });
1973
- if (this.debug) console.log("[PyodideWorkerClient] send", { id, type });
3166
+ logRuntimeDiagnostic("debug", {
3167
+ component: "PythonWorkerClient",
3168
+ runtime: "python",
3169
+ phase: "worker-request",
3170
+ message: "Sending request to Python worker.",
3171
+ detail: { id, type }
3172
+ }, { enabled: this.debug });
1974
3173
  const timeoutId = globalThis.setTimeout(() => {
1975
3174
  const pending2 = this.pendingMessages.get(id);
1976
3175
  if (!pending2) return;
1977
3176
  this.pendingMessages.delete(id);
1978
- if (this.debug) console.warn("[PyodideWorkerClient] timeout", { id, type });
3177
+ logRuntimeDiagnostic("warn", {
3178
+ component: "PythonWorkerClient",
3179
+ runtime: "python",
3180
+ phase: "worker-request-timeout",
3181
+ message: "Python worker request timed out.",
3182
+ detail: { id, type, timeoutMs }
3183
+ }, { enabled: this.debug });
1979
3184
  pending2.reject(new Error(`Worker request timed out: ${type}`));
1980
3185
  }, timeoutMs);
1981
3186
  const pending = this.pendingMessages.get(id);
@@ -1986,15 +3191,19 @@ var PyodideWorkerClient = class {
1986
3191
  /**
1987
3192
  * Execute code with a timeout - terminates worker if execution takes too long
1988
3193
  */
1989
- async executeWithTimeout(executor, timeoutMs = EXECUTION_TIMEOUT_MS2) {
3194
+ async executeWithTimeout(executor, timeoutMs = EXECUTION_TIMEOUT_MS5) {
1990
3195
  return new Promise((resolve, reject) => {
1991
3196
  let settled = false;
1992
3197
  const timeoutId = globalThis.setTimeout(() => {
1993
3198
  if (settled) return;
1994
3199
  settled = true;
1995
- if (this.debug) {
1996
- console.warn("[PyodideWorkerClient] Execution timeout - terminating worker");
1997
- }
3200
+ logRuntimeDiagnostic("warn", {
3201
+ component: "PythonWorkerClient",
3202
+ runtime: "python",
3203
+ phase: "execution-timeout",
3204
+ message: "Python execution timed out; terminating worker.",
3205
+ detail: { timeoutMs }
3206
+ }, { enabled: this.debug });
1998
3207
  this.terminateAndReset();
1999
3208
  const seconds = Math.round(timeoutMs / 1e3);
2000
3209
  reject(new Error(`Execution timed out (possible infinite loop). Code execution was stopped after ${seconds} seconds.`));
@@ -2022,6 +3231,7 @@ var PyodideWorkerClient = class {
2022
3231
  this.worker = null;
2023
3232
  }
2024
3233
  this.initPromise = null;
3234
+ this.warmupPromise = null;
2025
3235
  this.isInitializing = false;
2026
3236
  this.workerReadyPromise = null;
2027
3237
  this.workerReadyResolve = null;
@@ -2032,7 +3242,7 @@ var PyodideWorkerClient = class {
2032
3242
  this.pendingMessages.clear();
2033
3243
  }
2034
3244
  /**
2035
- * Initialize Pyodide in the worker
3245
+ * Initialize the Python worker. Runtime loading is lazy unless warmup() is called.
2036
3246
  */
2037
3247
  async init() {
2038
3248
  if (this.initPromise) {
@@ -2045,18 +3255,22 @@ var PyodideWorkerClient = class {
2045
3255
  this.isInitializing = true;
2046
3256
  this.initPromise = (async () => {
2047
3257
  try {
2048
- return await this.sendMessage("init", void 0, INIT_TIMEOUT_MS3);
3258
+ return await this.sendMessage("init", void 0, INIT_TIMEOUT_MS5);
2049
3259
  } catch (error) {
2050
3260
  const message = error instanceof Error ? error.message : String(error);
2051
3261
  const shouldRetry = message.includes("Worker request timed out: init") || message.includes("Worker was terminated") || message.includes("Worker error") || message.includes("failed to initialize in time");
2052
3262
  if (!shouldRetry) {
2053
3263
  throw error;
2054
3264
  }
2055
- if (this.debug) {
2056
- console.warn("[PyodideWorkerClient] init failed, resetting worker and retrying once", { message });
2057
- }
3265
+ logRuntimeDiagnostic("warn", {
3266
+ component: "PythonWorkerClient",
3267
+ runtime: "python",
3268
+ phase: "init-retry",
3269
+ message: "Python worker init failed; resetting worker and retrying once.",
3270
+ detail: { message }
3271
+ }, { enabled: this.debug });
2058
3272
  this.terminateAndReset();
2059
- return this.sendMessage("init", void 0, INIT_TIMEOUT_MS3);
3273
+ return this.sendMessage("init", void 0, INIT_TIMEOUT_MS5);
2060
3274
  }
2061
3275
  })();
2062
3276
  try {
@@ -2069,6 +3283,19 @@ var PyodideWorkerClient = class {
2069
3283
  this.isInitializing = false;
2070
3284
  }
2071
3285
  }
3286
+ async warmup() {
3287
+ if (this.warmupPromise) return this.warmupPromise;
3288
+ this.warmupPromise = (async () => {
3289
+ try {
3290
+ await this.init();
3291
+ return await this.sendMessage("warmup", void 0, INIT_TIMEOUT_MS5);
3292
+ } catch (error) {
3293
+ this.warmupPromise = null;
3294
+ throw error;
3295
+ }
3296
+ })();
3297
+ return this.warmupPromise;
3298
+ }
2072
3299
  /**
2073
3300
  * Execute Python code with tracing for step-by-step visualization
2074
3301
  * @param options.maxLineEvents - Max line events before abort (for complexity analysis, use higher values)
@@ -2083,9 +3310,9 @@ var PyodideWorkerClient = class {
2083
3310
  inputs,
2084
3311
  executionStyle,
2085
3312
  options
2086
- }, TRACING_TIMEOUT_MS3 + 5e3),
3313
+ }, TRACING_TIMEOUT_MS5 + 5e3),
2087
3314
  // Message timeout slightly longer than execution timeout
2088
- TRACING_TIMEOUT_MS3
3315
+ TRACING_TIMEOUT_MS5
2089
3316
  );
2090
3317
  } catch (error) {
2091
3318
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -2094,8 +3321,8 @@ var PyodideWorkerClient = class {
2094
3321
  return {
2095
3322
  success: false,
2096
3323
  error: errorMessage,
2097
- trace: [],
2098
- executionTimeMs: TRACING_TIMEOUT_MS3,
3324
+ trace: createEmptyRuntimeTrace("python", { runId: "python:run", file: "solution.py" }),
3325
+ executionTimeMs: TRACING_TIMEOUT_MS5,
2099
3326
  consoleOutput: [],
2100
3327
  traceLimitExceeded: true,
2101
3328
  timeoutReason: "client-timeout",
@@ -2117,8 +3344,8 @@ var PyodideWorkerClient = class {
2117
3344
  functionName,
2118
3345
  inputs,
2119
3346
  executionStyle
2120
- }, EXECUTION_TIMEOUT_MS2 + 5e3),
2121
- EXECUTION_TIMEOUT_MS2
3347
+ }, EXECUTION_TIMEOUT_MS5 + 5e3),
3348
+ EXECUTION_TIMEOUT_MS5
2122
3349
  );
2123
3350
  }
2124
3351
  /**
@@ -2134,8 +3361,8 @@ var PyodideWorkerClient = class {
2134
3361
  functionName,
2135
3362
  inputs,
2136
3363
  executionStyle
2137
- }, INTERVIEW_MODE_TIMEOUT_MS2 + 2e3),
2138
- INTERVIEW_MODE_TIMEOUT_MS2
3364
+ }, INTERVIEW_MODE_TIMEOUT_MS4 + 2e3),
3365
+ INTERVIEW_MODE_TIMEOUT_MS4
2139
3366
  );
2140
3367
  if (!result.success && result.error) {
2141
3368
  const normalizedError = result.error.toLowerCase();
@@ -2190,11 +3417,6 @@ var PyodideWorkerClient = class {
2190
3417
  }
2191
3418
  };
2192
3419
 
2193
- // packages/harness-core/src/trace-adapters/python.ts
2194
- function adaptPythonTraceExecutionResult(result) {
2195
- return adaptTraceExecutionResult("python", result);
2196
- }
2197
-
2198
3420
  // packages/harness-browser/src/python-runtime-client.ts
2199
3421
  var PythonRuntimeClient = class {
2200
3422
  constructor(workerClient) {
@@ -2209,14 +3431,13 @@ var PythonRuntimeClient = class {
2209
3431
  executionStyle,
2210
3432
  functionName
2211
3433
  });
2212
- const rawResult = await this.workerClient.executeWithTracing(
3434
+ return this.workerClient.executeWithTracing(
2213
3435
  code,
2214
3436
  functionName,
2215
3437
  inputs,
2216
3438
  options,
2217
3439
  executionStyle
2218
3440
  );
2219
- return adaptPythonTraceExecutionResult(rawResult);
2220
3441
  }
2221
3442
  async executeCode(code, functionName, inputs, executionStyle = "function") {
2222
3443
  assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
@@ -2257,7 +3478,17 @@ var DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS = Object.freeze({
2257
3478
  pythonSnippets: "generated-python-harness-snippets.js",
2258
3479
  javascriptWorker: "javascript-worker.js",
2259
3480
  javaWorker: "java-worker.js",
2260
- typescriptCompiler: "vendor/typescript.js"
3481
+ csharpWorker: "csharp-worker.js",
3482
+ csharpAssetBaseUrl: "vendor/csharp",
3483
+ typescriptCompiler: "vendor/typescript.js",
3484
+ cppWorker: "cpp-worker.js",
3485
+ cppCompilerFrame: "cpp-compiler-frame.html",
3486
+ cppCompilerWorker: "cpp-compiler-worker.js",
3487
+ cppClangWasm: "",
3488
+ cppLldWasm: "",
3489
+ cppSysroot: "",
3490
+ cppRuntimeHeader: "cpp/tracecode_runtime.hpp",
3491
+ cppCompilerBundle: "vendor/cpp/yowasp/bundle.js"
2261
3492
  });
2262
3493
  function isExplicitAssetPath(pathname) {
2263
3494
  return pathname.startsWith("/") || pathname.startsWith("./") || pathname.startsWith("../") || pathname.startsWith("http://") || pathname.startsWith("https://") || pathname.startsWith("data:") || pathname.startsWith("blob:");
@@ -2269,6 +3500,9 @@ function trimLeadingSlash(value) {
2269
3500
  return value.replace(/^\/+/, "");
2270
3501
  }
2271
3502
  function resolveAssetPath(baseUrl, pathname) {
3503
+ if (pathname === "") {
3504
+ return "";
3505
+ }
2272
3506
  if (isExplicitAssetPath(pathname)) {
2273
3507
  return pathname;
2274
3508
  }
@@ -2291,9 +3525,34 @@ function resolveBrowserHarnessAssets(options = {}) {
2291
3525
  assets.javascriptWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.javascriptWorker
2292
3526
  ),
2293
3527
  javaWorker: resolveAssetPath(assetBaseUrl, assets.javaWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.javaWorker),
3528
+ csharpWorker: resolveAssetPath(assetBaseUrl, assets.csharpWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.csharpWorker),
3529
+ csharpAssetBaseUrl: resolveAssetPath(
3530
+ assetBaseUrl,
3531
+ assets.csharpAssetBaseUrl ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.csharpAssetBaseUrl
3532
+ ),
2294
3533
  typescriptCompiler: resolveAssetPath(
2295
3534
  assetBaseUrl,
2296
3535
  assets.typescriptCompiler ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.typescriptCompiler
3536
+ ),
3537
+ cppWorker: resolveAssetPath(assetBaseUrl, assets.cppWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppWorker),
3538
+ cppCompilerFrame: resolveAssetPath(
3539
+ assetBaseUrl,
3540
+ assets.cppCompilerFrame ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerFrame
3541
+ ),
3542
+ cppCompilerWorker: resolveAssetPath(
3543
+ assetBaseUrl,
3544
+ assets.cppCompilerWorker ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerWorker
3545
+ ),
3546
+ cppClangWasm: resolveAssetPath(assetBaseUrl, assets.cppClangWasm ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppClangWasm),
3547
+ cppLldWasm: resolveAssetPath(assetBaseUrl, assets.cppLldWasm ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppLldWasm),
3548
+ cppSysroot: resolveAssetPath(assetBaseUrl, assets.cppSysroot ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppSysroot),
3549
+ cppRuntimeHeader: resolveAssetPath(
3550
+ assetBaseUrl,
3551
+ assets.cppRuntimeHeader ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppRuntimeHeader
3552
+ ),
3553
+ cppCompilerBundle: resolveAssetPath(
3554
+ assetBaseUrl,
3555
+ assets.cppCompilerBundle ?? DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS.cppCompilerBundle
2297
3556
  )
2298
3557
  };
2299
3558
  }
@@ -2305,10 +3564,12 @@ var BrowserHarnessRuntime = class {
2305
3564
  pythonWorkerClient;
2306
3565
  javaScriptWorkerClient;
2307
3566
  javaWorkerClient;
3567
+ csharpWorkerClient;
3568
+ cppWorkerClient;
2308
3569
  clients;
2309
3570
  constructor(options = {}) {
2310
3571
  this.assets = resolveBrowserHarnessAssets(options);
2311
- this.pythonWorkerClient = new PyodideWorkerClient({
3572
+ this.pythonWorkerClient = new PythonWorkerClient({
2312
3573
  workerUrl: this.assets.pythonWorker,
2313
3574
  debug: options.debug
2314
3575
  });
@@ -2318,13 +3579,38 @@ var BrowserHarnessRuntime = class {
2318
3579
  });
2319
3580
  this.javaWorkerClient = new JavaWorkerClient({
2320
3581
  workerUrl: this.assets.javaWorker,
2321
- debug: options.debug
3582
+ debug: options.debug,
3583
+ workerIdleTimeoutMs: options.java?.workerIdleTimeoutMs
3584
+ });
3585
+ this.csharpWorkerClient = new CSharpWorkerClient({
3586
+ workerUrl: this.assets.csharpWorker,
3587
+ assetBaseUrl: this.assets.csharpAssetBaseUrl,
3588
+ debug: options.debug,
3589
+ workerIdleTimeoutMs: options.csharp?.workerIdleTimeoutMs
3590
+ });
3591
+ this.cppWorkerClient = new CppWorkerClient({
3592
+ workerUrl: this.assets.cppWorker,
3593
+ compilerFrameUrl: this.assets.cppCompilerFrame,
3594
+ compilerWorkerUrl: this.assets.cppCompilerWorker,
3595
+ clangWasmUrl: this.assets.cppClangWasm,
3596
+ lldWasmUrl: this.assets.cppLldWasm,
3597
+ sysrootUrl: this.assets.cppSysroot,
3598
+ runtimeHeaderUrl: this.assets.cppRuntimeHeader,
3599
+ compilerBundleUrl: this.assets.cppCompilerBundle,
3600
+ debug: options.debug,
3601
+ initTimeoutMs: options.cpp?.initTimeoutMs,
3602
+ executionTimeoutMs: options.cpp?.executionTimeoutMs,
3603
+ tracingTimeoutMs: options.cpp?.tracingTimeoutMs,
3604
+ interviewTimeoutMs: options.cpp?.interviewTimeoutMs,
3605
+ workerIdleTimeoutMs: options.cpp?.workerIdleTimeoutMs
2322
3606
  });
2323
3607
  this.clients = {
2324
3608
  python: createPythonRuntimeClient(this.pythonWorkerClient),
2325
3609
  javascript: createJavaScriptRuntimeClient("javascript", this.javaScriptWorkerClient),
2326
3610
  typescript: createJavaScriptRuntimeClient("typescript", this.javaScriptWorkerClient),
2327
- java: createJavaRuntimeClient(this.javaWorkerClient)
3611
+ java: createJavaRuntimeClient(this.javaWorkerClient),
3612
+ csharp: createCSharpRuntimeClient(this.csharpWorkerClient),
3613
+ cpp: createCppRuntimeClient(this.cppWorkerClient)
2328
3614
  };
2329
3615
  }
2330
3616
  getClient(language) {
@@ -2340,9 +3626,33 @@ var BrowserHarnessRuntime = class {
2340
3626
  getSupportedLanguageProfiles() {
2341
3627
  return getSupportedLanguageProfiles();
2342
3628
  }
3629
+ getLanguageInfo(language) {
3630
+ return getLanguageRuntimeInfo(language);
3631
+ }
3632
+ getSupportedLanguageInfos() {
3633
+ return getSupportedLanguageRuntimeInfos();
3634
+ }
2343
3635
  isLanguageSupported(language) {
2344
3636
  return isLanguageSupported(language);
2345
3637
  }
3638
+ warmLanguage(language) {
3639
+ if (language === "python") {
3640
+ return this.pythonWorkerClient.warmup();
3641
+ }
3642
+ if (language === "java") {
3643
+ return this.javaWorkerClient.warmup();
3644
+ }
3645
+ if (language === "cpp") {
3646
+ return this.cppWorkerClient.warmup();
3647
+ }
3648
+ if (language === "csharp") {
3649
+ return this.csharpWorkerClient.warmup();
3650
+ }
3651
+ if (language === "typescript") {
3652
+ return this.javaScriptWorkerClient.warmup("typescript");
3653
+ }
3654
+ return this.getClient(language).init();
3655
+ }
2346
3656
  disposeLanguage(language) {
2347
3657
  if (language === "python") {
2348
3658
  this.pythonWorkerClient.terminate();
@@ -2352,12 +3662,22 @@ var BrowserHarnessRuntime = class {
2352
3662
  this.javaWorkerClient.terminate();
2353
3663
  return;
2354
3664
  }
3665
+ if (language === "csharp") {
3666
+ this.csharpWorkerClient.terminate();
3667
+ return;
3668
+ }
3669
+ if (language === "cpp") {
3670
+ this.cppWorkerClient.terminate();
3671
+ return;
3672
+ }
2355
3673
  this.javaScriptWorkerClient.terminate();
2356
3674
  }
2357
3675
  dispose() {
2358
3676
  this.pythonWorkerClient.terminate();
2359
3677
  this.javaScriptWorkerClient.terminate();
2360
3678
  this.javaWorkerClient.terminate();
3679
+ this.csharpWorkerClient.terminate();
3680
+ this.cppWorkerClient.terminate();
2361
3681
  }
2362
3682
  };
2363
3683
  function createBrowserHarness(options = {}) {
@@ -2365,12 +3685,16 @@ function createBrowserHarness(options = {}) {
2365
3685
  }
2366
3686
  export {
2367
3687
  DEFAULT_BROWSER_HARNESS_ASSET_RELATIVE_PATHS,
3688
+ LANGUAGE_RUNTIME_INFOS,
2368
3689
  LANGUAGE_RUNTIME_PROFILES,
2369
3690
  SUPPORTED_LANGUAGES,
3691
+ SUPPORTED_LANGUAGE_RUNTIME_INFOS,
2370
3692
  assertRuntimeRequestSupported,
2371
3693
  createBrowserHarness,
3694
+ getLanguageRuntimeInfo,
2372
3695
  getLanguageRuntimeProfile,
2373
3696
  getSupportedLanguageProfiles,
3697
+ getSupportedLanguageRuntimeInfos,
2374
3698
  isLanguageSupported,
2375
3699
  resolveBrowserHarnessAssets
2376
3700
  };