@tracecode/harness 0.6.5 → 0.7.0-beta7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +55 -0
- package/README.md +134 -15
- package/THIRD_PARTY_NOTICES.md +170 -0
- package/dist/browser.cjs +2361 -1033
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +33 -3
- package/dist/browser.d.ts +33 -3
- package/dist/browser.js +2357 -1033
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +160 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +161 -24
- package/dist/cli.js.map +1 -1
- package/dist/core.cjs +748 -867
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +21 -85
- package/dist/core.d.ts +21 -85
- package/dist/core.js +734 -855
- package/dist/core.js.map +1 -1
- package/dist/cpp-worker-client-Bn7kC0_L.d.ts +84 -0
- package/dist/cpp-worker-client-BzdJLuZa.d.cts +84 -0
- package/dist/cpp.cjs +1063 -0
- package/dist/cpp.cjs.map +1 -0
- package/dist/cpp.d.cts +7 -0
- package/dist/cpp.d.ts +7 -0
- package/dist/cpp.js +1035 -0
- package/dist/cpp.js.map +1 -0
- package/dist/csharp-worker-client-DMHIa2YG.d.cts +69 -0
- package/dist/csharp-worker-client-JwqS6LiX.d.ts +69 -0
- package/dist/csharp.cjs +1012 -0
- package/dist/csharp.cjs.map +1 -0
- package/dist/csharp.d.cts +7 -0
- package/dist/csharp.d.ts +7 -0
- package/dist/csharp.js +984 -0
- package/dist/csharp.js.map +1 -0
- package/dist/index.cjs +3142 -1160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +3117 -1148
- package/dist/index.js.map +1 -1
- package/dist/internal/browser.cjs +1639 -30
- package/dist/internal/browser.cjs.map +1 -1
- package/dist/internal/browser.d.cts +6 -199
- package/dist/internal/browser.d.ts +6 -199
- package/dist/internal/browser.js +1636 -30
- package/dist/internal/browser.js.map +1 -1
- package/dist/java-worker-client-BOwKW-11.d.cts +72 -0
- package/dist/java-worker-client-C97DDnCp.d.ts +72 -0
- package/dist/java.cjs +1225 -0
- package/dist/java.cjs.map +1 -0
- package/dist/java.d.cts +7 -0
- package/dist/java.d.ts +7 -0
- package/dist/java.js +1197 -0
- package/dist/java.js.map +1 -0
- package/dist/javascript-worker-client-CYBGEEvc.d.cts +51 -0
- package/dist/javascript-worker-client-DIX1Mp21.d.ts +51 -0
- package/dist/javascript.cjs +1063 -19
- package/dist/javascript.cjs.map +1 -1
- package/dist/javascript.d.cts +7 -4
- package/dist/javascript.d.ts +7 -4
- package/dist/javascript.js +1061 -19
- package/dist/javascript.js.map +1 -1
- package/dist/pyodide-worker-client-C-2rfHj9.d.ts +111 -0
- package/dist/pyodide-worker-client-Cn0a8Uv3.d.cts +111 -0
- package/dist/python.cjs +1282 -74
- package/dist/python.cjs.map +1 -1
- package/dist/python.d.cts +20 -14
- package/dist/python.d.ts +20 -14
- package/dist/python.js +1279 -74
- package/dist/python.js.map +1 -1
- package/dist/runtime-language-info-BFUSti3-.d.ts +43 -0
- package/dist/runtime-language-info-Bxza1cI2.d.cts +43 -0
- package/dist/runtime-types-2qM0MukN.d.cts +244 -0
- package/dist/runtime-types-2qM0MukN.d.ts +244 -0
- package/package.json +73 -8
- package/workers/cpp/cpp-compiler-frame.html +82 -0
- package/workers/cpp/cpp-compiler-worker.js +131 -0
- package/workers/cpp/cpp-worker.js +5790 -0
- package/workers/cpp/tracecode_runtime.hpp +6147 -0
- package/workers/csharp/csharp-worker.js +301 -0
- package/workers/java/.build/classes/harness/browser/JavaRewriteLibrary.class +0 -0
- package/workers/java/java-source-augmentations.js +880 -0
- package/workers/java/java-worker.js +2256 -170
- package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1645 -32
- package/workers/java/src/javafx/util/Pair.java +42 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceLibrary.java +714 -0
- package/workers/java/src/tracecode/browser/BrowserCompileAndTraceMain.java +76 -0
- package/workers/java/src/tracecode/browser/RuntimeProbeMain.java +14 -0
- package/workers/java/src/tracecode/user/TraceHooks.java +1406 -0
- package/workers/javascript/javascript-libraries-entry.js +71 -0
- package/workers/javascript/javascript-worker.js +2054 -424
- package/workers/python/generated-python-harness-snippets.js +4 -4
- package/workers/python/pyodide-worker.js +222 -61
- package/workers/python/runtime-core.js +1387 -301
- package/workers/vendor/csharp/.stamp +0 -0
- package/workers/vendor/csharp/TraceCode.CSharpHost.runtimeconfig.json +32 -0
- package/workers/vendor/csharp/_framework/Microsoft.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.CSharp.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.CodeAnalysis.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.VisualBasic.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/Microsoft.Win32.Registry.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.AppContext.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Buffers.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Concurrent.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Immutable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.NonGeneric.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.Specialized.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Collections.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Annotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.DataAnnotations.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.EventBasedAsync.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.TypeConverter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ComponentModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Configuration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Console.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Core.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.Common.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.DataSetExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Data.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Contracts.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Debug.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.DiagnosticSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.FileVersionInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Process.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.StackTrace.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TextWriterTraceListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tools.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.TraceSource.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Diagnostics.Tracing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Drawing.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Dynamic.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Asn1.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Formats.Tar.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Calendars.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Globalization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.Brotli.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.ZipFile.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Compression.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.DriveInfo.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.Watcher.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.FileSystem.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.IsolatedStorage.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.MemoryMappedFiles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipelines.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.Pipes.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.UnmanagedMemoryStream.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.IO.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.AsyncEnumerable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Expressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.Queryable.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Memory.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Http.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.HttpListener.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Mail.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NameResolution.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.NetworkInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Ping.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Quic.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Requests.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServerSentEvents.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.ServicePoint.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.Sockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebClient.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebHeaderCollection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.Client.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.WebSockets.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Net.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.Vectors.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ObjectModel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.CoreLib.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.DataContractSerialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Uri.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Private.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.DispatchProxy.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.ILGeneration.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.Lightweight.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Emit.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Metadata.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.TypeExtensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Reflection.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Reader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.ResourceManager.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Resources.Writer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.Unsafe.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.CompilerServices.VisualC.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Handles.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.JavaScript.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.RuntimeInformation.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.InteropServices.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Intrinsics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Loader.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Numerics.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Formatters.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Runtime.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Claims.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Algorithms.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Cng.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Csp.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.OpenSsl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.Primitives.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.X509Certificates.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Cryptography.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.Principal.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.SecureString.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Security.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceModel.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ServiceProcess.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.CodePages.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encoding.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Encodings.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.Json.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Text.RegularExpressions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.AccessControl.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Channels.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Overlapped.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Dataflow.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Extensions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.Parallel.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Tasks.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Thread.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.ThreadPool.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.Timer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Threading.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.Local.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Transactions.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.ValueTuple.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.HttpUtility.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Web.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Windows.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Linq.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.ReaderWriter.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.Serialization.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.XDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XPath.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlDocument.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.XmlSerializer.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.Xml.wasm +0 -0
- package/workers/vendor/csharp/_framework/System.wasm +0 -0
- package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
- package/workers/vendor/csharp/_framework/WindowsBase.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/cs/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/de/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.boot.js +1958 -0
- package/workers/vendor/csharp/_framework/dotnet.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.js.map +1 -0
- package/workers/vendor/csharp/_framework/dotnet.native.js +6687 -0
- package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js +4 -0
- package/workers/vendor/csharp/_framework/dotnet.runtime.js.map +1 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/es/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/fr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/it/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ja/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ko/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/mscorlib.wasm +0 -0
- package/workers/vendor/csharp/_framework/netstandard.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pl/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/pt-BR/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/ru/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/0_Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/100_System.Reflection.Emit.ILGeneration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/101_System.Reflection.Emit.Lightweight.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/102_System.Reflection.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/103_System.Reflection.Metadata.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/104_System.Reflection.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/105_System.Reflection.TypeExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/106_System.Resources.Reader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/107_System.Resources.ResourceManager.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/108_System.Resources.Writer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/109_System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/10_System.Buffers.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/110_System.Runtime.CompilerServices.VisualC.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/111_System.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/112_System.Runtime.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/113_System.Runtime.Handles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/114_System.Runtime.InteropServices.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/115_System.Runtime.InteropServices.JavaScript.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/116_System.Runtime.InteropServices.RuntimeInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/117_System.Runtime.Intrinsics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/118_System.Runtime.Loader.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/119_System.Runtime.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/11_System.Collections.Concurrent.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/120_System.Runtime.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/121_System.Runtime.Serialization.Formatters.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/122_System.Runtime.Serialization.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/123_System.Runtime.Serialization.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/124_System.Runtime.Serialization.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/125_System.Security.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/126_System.Security.Claims.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/127_System.Security.Cryptography.Algorithms.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/128_System.Security.Cryptography.Cng.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/129_System.Security.Cryptography.Csp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/12_System.Collections.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/130_System.Security.Cryptography.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/131_System.Security.Cryptography.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/132_System.Security.Cryptography.OpenSsl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/133_System.Security.Cryptography.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/134_System.Security.Cryptography.X509Certificates.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/135_System.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/136_System.Security.Principal.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/137_System.Security.Principal.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/138_System.Security.SecureString.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/139_System.ServiceModel.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/13_System.Collections.Immutable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/140_System.ServiceProcess.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/141_System.Text.Encoding.CodePages.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/142_System.Text.Encoding.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/143_System.Text.Encoding.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/144_System.Text.Encodings.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/145_System.Text.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/146_System.Text.RegularExpressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/147_System.Threading.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/148_System.Threading.Channels.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/149_System.Threading.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/14_System.Collections.NonGeneric.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/150_System.Threading.Overlapped.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/151_System.Threading.Tasks.Dataflow.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/152_System.Threading.Tasks.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/153_System.Threading.Tasks.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/154_System.Threading.Tasks.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/155_System.Threading.Thread.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/156_System.Threading.ThreadPool.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/157_System.Threading.Timer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/158_System.Transactions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/159_System.Transactions.Local.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/15_System.Collections.Specialized.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/160_System.ValueTuple.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/161_System.Web.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/162_System.Web.HttpUtility.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/163_System.Windows.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/164_System.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/165_System.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/166_System.Xml.ReaderWriter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/167_System.Xml.Serialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/168_System.Xml.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/169_System.Xml.XmlDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/16_System.ComponentModel.Annotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/170_System.Xml.XmlSerializer.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/171_System.Xml.XPath.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/172_System.Xml.XPath.XDocument.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/173_TraceCode.CSharpHost.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/174_WindowsBase.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/17_System.ComponentModel.DataAnnotations.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/18_System.ComponentModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/19_System.ComponentModel.EventBasedAsync.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/1_Microsoft.CodeAnalysis.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/20_System.ComponentModel.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/21_System.ComponentModel.TypeConverter.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/22_System.Configuration.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/23_System.Console.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/24_System.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/25_System.Data.Common.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/26_System.Data.DataSetExtensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/27_System.Data.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/28_System.Diagnostics.Contracts.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/29_System.Diagnostics.Debug.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/2_Microsoft.CSharp.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/30_System.Diagnostics.DiagnosticSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/31_System.Diagnostics.FileVersionInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/32_System.Diagnostics.Process.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/33_System.Diagnostics.StackTrace.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/34_System.Diagnostics.TextWriterTraceListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/35_System.Diagnostics.Tools.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/36_System.Diagnostics.TraceSource.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/37_System.Diagnostics.Tracing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/38_System.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/39_System.Drawing.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/3_Microsoft.VisualBasic.Core.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/40_System.Drawing.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/41_System.Dynamic.Runtime.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/42_System.Formats.Asn1.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/43_System.Formats.Tar.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/44_System.Globalization.Calendars.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/45_System.Globalization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/46_System.Globalization.Extensions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/47_System.IO.Compression.Brotli.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/48_System.IO.Compression.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/49_System.IO.Compression.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/4_Microsoft.VisualBasic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/50_System.IO.Compression.ZipFile.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/51_System.IO.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/52_System.IO.FileSystem.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/53_System.IO.FileSystem.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/54_System.IO.FileSystem.DriveInfo.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/55_System.IO.FileSystem.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/56_System.IO.FileSystem.Watcher.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/57_System.IO.IsolatedStorage.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/58_System.IO.MemoryMappedFiles.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/59_System.IO.Pipelines.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/5_Microsoft.Win32.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/60_System.IO.Pipes.AccessControl.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/61_System.IO.Pipes.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/62_System.IO.UnmanagedMemoryStream.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/63_System.Linq.AsyncEnumerable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/64_System.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/65_System.Linq.Expressions.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/66_System.Linq.Parallel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/67_System.Linq.Queryable.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/68_System.Memory.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/69_System.Net.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/6_Microsoft.Win32.Registry.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/70_System.Net.Http.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/71_System.Net.Http.Json.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/72_System.Net.HttpListener.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/73_System.Net.Mail.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/74_System.Net.NameResolution.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/75_System.Net.NetworkInformation.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/76_System.Net.Ping.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/77_System.Net.Primitives.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/78_System.Net.Quic.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/79_System.Net.Requests.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/7_mscorlib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/80_System.Net.Security.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/81_System.Net.ServerSentEvents.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/82_System.Net.ServicePoint.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/83_System.Net.Sockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/84_System.Net.WebClient.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/85_System.Net.WebHeaderCollection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/86_System.Net.WebProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/87_System.Net.WebSockets.Client.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/88_System.Net.WebSockets.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/89_System.Numerics.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/8_netstandard.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/90_System.Numerics.Vectors.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/91_System.ObjectModel.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/92_System.Private.CoreLib.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/93_System.Private.DataContractSerialization.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/94_System.Private.Uri.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/95_System.Private.Xml.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/96_System.Private.Xml.Linq.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/97_System.Reflection.DispatchProxy.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/98_System.Reflection.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/99_System.Reflection.Emit.dll +0 -0
- package/workers/vendor/csharp/_framework/supportFiles/9_System.AppContext.dll +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/tr/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hans/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.CSharp.resources.wasm +0 -0
- package/workers/vendor/csharp/_framework/zh-Hant/Microsoft.CodeAnalysis.resources.wasm +0 -0
- package/workers/vendor/csharp/main.mjs +5 -0
- package/workers/vendor/csharp/package.json +1 -0
- package/workers/vendor/java-browser-helper.jar +0 -0
- package/workers/vendor/java-rewriter.jar +0 -0
- package/workers/vendor/javascript-libraries.js +10106 -0
- package/dist/runtime-types-89nchXlY.d.cts +0 -89
- package/dist/runtime-types-CCQ-ZLc9.d.ts +0 -89
- package/dist/types-zyvpJKCi.d.cts +0 -100
- package/dist/types-zyvpJKCi.d.ts +0 -100
- package/workers/java/java-source-augmentations.cjs +0 -242
- package/workers/java/src/spike/user/TraceHooks.java +0 -619
- package/workers/vendor/java-browser-spike-helper.jar +0 -0
- package/workers/vendor/java-practice-rewriter.jar +0 -0
- package/workers/vendor/java-rewrite-bridge.jar +0 -0
package/dist/python.js
CHANGED
|
@@ -61,12 +61,39 @@ class ListNode:
|
|
|
61
61
|
def __repr__(self):
|
|
62
62
|
return f"ListNode({getattr(self, 'val', getattr(self, 'value', None))})"
|
|
63
63
|
`;
|
|
64
|
-
var PYTHON_CONVERSION_HELPERS = "\ndef _ensure_node_value_aliases(node):\n if node is None:\n return node\n try:\n has_val = hasattr(node, 'val')\n has_value = hasattr(node, 'value')\n if has_value and not has_val:\n try:\n setattr(node, 'val', getattr(node, 'value'))\n except Exception:\n pass\n elif has_val and not has_value:\n try:\n setattr(node, 'value', getattr(node, 'val'))\n except Exception:\n pass\n except Exception:\n pass\n return node\n\ndef _dict_to_tree(d):\n if d is None:\n return None\n if not isinstance(d, dict):\n return d\n if 'val' not in d and 'value' not in d:\n return d\n node = TreeNode(d.get('val', d.get('value', 0)))\n _ensure_node_value_aliases(node)\n node.left = _dict_to_tree(d.get('left'))\n node.right = _dict_to_tree(d.get('right'))\n return node\n\ndef _dict_to_list(d, _refs=None):\n if _refs is None:\n _refs = {}\n if d is None:\n return None\n if not isinstance(d, dict):\n return d\n if '__ref__' in d:\n return _refs.get(d.get('__ref__'))\n if 'val' not in d and 'value' not in d:\n return d\n node = ListNode(d.get('val', d.get('value', 0)))\n _ensure_node_value_aliases(node)\n node_id = d.get('__id__')\n if isinstance(node_id, str) and node_id:\n _refs[node_id] = node\n node.next = _dict_to_list(d.get('next'), _refs)\n return node\n";
|
|
64
|
+
var PYTHON_CONVERSION_HELPERS = "\ndef _ensure_node_value_aliases(node):\n if node is None:\n return node\n try:\n has_val = hasattr(node, 'val')\n has_value = hasattr(node, 'value')\n if has_value and not has_val:\n try:\n setattr(node, 'val', getattr(node, 'value'))\n except Exception:\n pass\n elif has_val and not has_value:\n try:\n setattr(node, 'value', getattr(node, 'val'))\n except Exception:\n pass\n except Exception:\n pass\n return node\n\ndef _dict_to_tree(d):\n if d is None:\n return None\n if not isinstance(d, _builtins.dict):\n return d\n if 'val' not in d and 'value' not in d:\n return d\n node = TreeNode(d.get('val', d.get('value', 0)))\n _ensure_node_value_aliases(node)\n node.left = _dict_to_tree(d.get('left'))\n node.right = _dict_to_tree(d.get('right'))\n return node\n\ndef _dict_to_list(d, _refs=None):\n if _refs is None:\n _refs = {}\n if d is None:\n return None\n if not isinstance(d, _builtins.dict):\n return d\n if '__ref__' in d:\n return _refs.get(d.get('__ref__'))\n if 'val' not in d and 'value' not in d:\n return d\n node = ListNode(d.get('val', d.get('value', 0)))\n _ensure_node_value_aliases(node)\n node_id = d.get('__id__')\n if isinstance(node_id, _builtins.str) and node_id:\n _refs[node_id] = node\n node.next = _dict_to_list(d.get('next'), _refs)\n return node\n";
|
|
65
65
|
var PYTHON_TRACE_SERIALIZE_FUNCTION = `
|
|
66
66
|
# Sentinel to mark skipped values (functions, etc.) - distinct from None
|
|
67
67
|
_SKIP_SENTINEL = "__TRACECODE_SKIP__"
|
|
68
68
|
_MAX_SERIALIZE_DEPTH = 48
|
|
69
|
+
_MAX_SERIALIZED_ITEMS = 64
|
|
69
70
|
_MAX_OBJECT_FIELDS = 32
|
|
71
|
+
_tracecode_global_object_refs = {}
|
|
72
|
+
_tracecode_next_object_ref_id = 0
|
|
73
|
+
|
|
74
|
+
def _tracecode_ref_id(obj_ref, node_refs):
|
|
75
|
+
global _tracecode_next_object_ref_id
|
|
76
|
+
if obj_ref in node_refs:
|
|
77
|
+
return node_refs[obj_ref]
|
|
78
|
+
if obj_ref in _tracecode_global_object_refs:
|
|
79
|
+
node_id = _tracecode_global_object_refs[obj_ref]
|
|
80
|
+
else:
|
|
81
|
+
node_id = f"ref-{_tracecode_next_object_ref_id}"
|
|
82
|
+
_tracecode_global_object_refs[obj_ref] = node_id
|
|
83
|
+
_tracecode_next_object_ref_id += 1
|
|
84
|
+
node_refs[obj_ref] = node_id
|
|
85
|
+
return node_id
|
|
86
|
+
|
|
87
|
+
def _truncation_marker(total, emitted):
|
|
88
|
+
return {"__truncated__": True, "remaining": max(0, total - emitted)}
|
|
89
|
+
|
|
90
|
+
def _serialize_sequence(values, depth, node_refs):
|
|
91
|
+
values_list = _builtins.list(values)
|
|
92
|
+
emitted = min(len(values_list), _MAX_SERIALIZED_ITEMS)
|
|
93
|
+
result = [_serialize(x, depth + 1, node_refs) for x in values_list[:emitted]]
|
|
94
|
+
if emitted < len(values_list):
|
|
95
|
+
result.append(_truncation_marker(len(values_list), emitted))
|
|
96
|
+
return result
|
|
70
97
|
|
|
71
98
|
def _serialize(obj, depth=0, node_refs=None):
|
|
72
99
|
if node_refs is None:
|
|
@@ -81,25 +108,36 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
81
108
|
return obj
|
|
82
109
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
83
110
|
return "<max depth>"
|
|
84
|
-
elif isinstance(obj, (list, tuple)):
|
|
85
|
-
return
|
|
111
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
112
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
86
113
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
87
|
-
return
|
|
88
|
-
elif isinstance(obj, dict):
|
|
89
|
-
|
|
114
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
115
|
+
elif isinstance(obj, _builtins.dict):
|
|
116
|
+
items = _builtins.list(obj.items())
|
|
117
|
+
emitted = min(len(items), _MAX_SERIALIZED_ITEMS)
|
|
118
|
+
result = {str(k): _serialize(v, depth + 1, node_refs) for k, v in items[:emitted]}
|
|
119
|
+
if emitted < len(items):
|
|
120
|
+
result["__truncated__"] = True
|
|
121
|
+
result["remaining"] = len(items) - emitted
|
|
122
|
+
return result
|
|
90
123
|
elif isinstance(obj, set):
|
|
91
124
|
# Use try/except for sorting to handle heterogeneous sets
|
|
125
|
+
values = _builtins.list(obj)
|
|
126
|
+
emitted = min(len(values), _MAX_SERIALIZED_ITEMS)
|
|
92
127
|
try:
|
|
93
|
-
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in
|
|
128
|
+
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in values[:emitted]])
|
|
94
129
|
except TypeError:
|
|
95
|
-
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in
|
|
96
|
-
|
|
130
|
+
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in values[:emitted]]
|
|
131
|
+
result = {"__type__": "set", "values": sorted_vals}
|
|
132
|
+
if emitted < len(values):
|
|
133
|
+
result["__truncated__"] = True
|
|
134
|
+
result["remaining"] = len(values) - emitted
|
|
135
|
+
return result
|
|
97
136
|
elif isinstance(obj, TreeNode):
|
|
98
|
-
obj_ref = id(obj)
|
|
137
|
+
obj_ref = _builtins.id(obj)
|
|
99
138
|
if obj_ref in node_refs:
|
|
100
139
|
return {"__ref__": node_refs[obj_ref]}
|
|
101
|
-
node_id =
|
|
102
|
-
node_refs[obj_ref] = node_id
|
|
140
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
103
141
|
result = {
|
|
104
142
|
"__type__": "TreeNode",
|
|
105
143
|
"__id__": node_id,
|
|
@@ -111,11 +149,10 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
111
149
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
112
150
|
return result
|
|
113
151
|
elif isinstance(obj, ListNode):
|
|
114
|
-
obj_ref = id(obj)
|
|
152
|
+
obj_ref = _builtins.id(obj)
|
|
115
153
|
if obj_ref in node_refs:
|
|
116
154
|
return {"__ref__": node_refs[obj_ref]}
|
|
117
|
-
node_id =
|
|
118
|
-
node_refs[obj_ref] = node_id
|
|
155
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
119
156
|
result = {
|
|
120
157
|
"__type__": "ListNode",
|
|
121
158
|
"__id__": node_id,
|
|
@@ -123,15 +160,17 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
123
160
|
}
|
|
124
161
|
result["next"] = _serialize(obj.next, depth + 1, node_refs)
|
|
125
162
|
return result
|
|
163
|
+
elif callable(obj):
|
|
164
|
+
# Skip functions entirely - return sentinel
|
|
165
|
+
return _SKIP_SENTINEL
|
|
126
166
|
elif hasattr(obj, '__dict__'):
|
|
127
|
-
obj_ref = id(obj)
|
|
167
|
+
obj_ref = _builtins.id(obj)
|
|
128
168
|
if obj_ref in node_refs:
|
|
129
169
|
return {"__ref__": node_refs[obj_ref]}
|
|
130
|
-
node_id =
|
|
131
|
-
node_refs[obj_ref] = node_id
|
|
170
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
132
171
|
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
133
172
|
result = {
|
|
134
|
-
"__type__":
|
|
173
|
+
"__type__": class_name,
|
|
135
174
|
"__class__": class_name,
|
|
136
175
|
"__id__": node_id,
|
|
137
176
|
}
|
|
@@ -139,26 +178,106 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
139
178
|
raw_fields = getattr(obj, '__dict__', None)
|
|
140
179
|
except Exception:
|
|
141
180
|
raw_fields = None
|
|
142
|
-
if isinstance(raw_fields, dict):
|
|
143
|
-
|
|
181
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
182
|
+
fields = []
|
|
144
183
|
for key, value in raw_fields.items():
|
|
145
184
|
key_str = str(key)
|
|
146
185
|
if key_str.startswith('_'):
|
|
147
186
|
continue
|
|
148
187
|
if callable(value):
|
|
149
188
|
continue
|
|
189
|
+
fields.append((key_str, value))
|
|
190
|
+
for key_str, value in fields[:_MAX_OBJECT_FIELDS]:
|
|
150
191
|
result[key_str] = _serialize(value, depth + 1, node_refs)
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
192
|
+
if len(fields) > _MAX_OBJECT_FIELDS:
|
|
193
|
+
result["__truncated__"] = True
|
|
194
|
+
result["remaining"] = len(fields) - _MAX_OBJECT_FIELDS
|
|
195
|
+
return result
|
|
196
|
+
else:
|
|
197
|
+
repr_str = repr(obj)
|
|
198
|
+
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
199
|
+
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
200
|
+
return _SKIP_SENTINEL
|
|
201
|
+
return repr_str
|
|
202
|
+
|
|
203
|
+
def _serialize_output(obj, depth=0, node_refs=None):
|
|
204
|
+
if node_refs is None:
|
|
205
|
+
node_refs = {}
|
|
206
|
+
if isinstance(obj, (bool, int, str, type(None))):
|
|
207
|
+
return obj
|
|
208
|
+
elif isinstance(obj, float):
|
|
209
|
+
if not math.isfinite(obj):
|
|
210
|
+
if math.isnan(obj):
|
|
211
|
+
return "NaN"
|
|
212
|
+
return "Infinity" if obj > 0 else "-Infinity"
|
|
213
|
+
return obj
|
|
214
|
+
if depth > _MAX_SERIALIZE_DEPTH:
|
|
215
|
+
return "<max depth>"
|
|
216
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
217
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
218
|
+
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
219
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
220
|
+
elif isinstance(obj, _builtins.dict):
|
|
221
|
+
return {str(k): _serialize_output(v, depth + 1, node_refs) for k, v in obj.items()}
|
|
222
|
+
elif isinstance(obj, set):
|
|
223
|
+
try:
|
|
224
|
+
sorted_vals = sorted([_serialize_output(x, depth + 1, node_refs) for x in obj])
|
|
225
|
+
except TypeError:
|
|
226
|
+
sorted_vals = [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
227
|
+
return {"__type__": "set", "values": sorted_vals}
|
|
228
|
+
elif isinstance(obj, TreeNode):
|
|
229
|
+
obj_ref = _builtins.id(obj)
|
|
230
|
+
if obj_ref in node_refs:
|
|
231
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
232
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
233
|
+
result = {
|
|
234
|
+
"__type__": "TreeNode",
|
|
235
|
+
"__id__": node_id,
|
|
236
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
237
|
+
}
|
|
238
|
+
if hasattr(obj, 'left'):
|
|
239
|
+
result["left"] = _serialize_output(obj.left, depth + 1, node_refs)
|
|
240
|
+
if hasattr(obj, 'right'):
|
|
241
|
+
result["right"] = _serialize_output(obj.right, depth + 1, node_refs)
|
|
242
|
+
return result
|
|
243
|
+
elif isinstance(obj, ListNode):
|
|
244
|
+
obj_ref = _builtins.id(obj)
|
|
245
|
+
if obj_ref in node_refs:
|
|
246
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
247
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
248
|
+
result = {
|
|
249
|
+
"__type__": "ListNode",
|
|
250
|
+
"__id__": node_id,
|
|
251
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
252
|
+
}
|
|
253
|
+
result["next"] = _serialize_output(obj.next, depth + 1, node_refs)
|
|
155
254
|
return result
|
|
156
255
|
elif callable(obj):
|
|
157
|
-
# Skip functions entirely - return sentinel
|
|
158
256
|
return _SKIP_SENTINEL
|
|
257
|
+
elif hasattr(obj, '__dict__'):
|
|
258
|
+
obj_ref = _builtins.id(obj)
|
|
259
|
+
if obj_ref in node_refs:
|
|
260
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
261
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
262
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
263
|
+
result = {
|
|
264
|
+
"__type__": class_name,
|
|
265
|
+
"__class__": class_name,
|
|
266
|
+
"__id__": node_id,
|
|
267
|
+
}
|
|
268
|
+
try:
|
|
269
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
270
|
+
except Exception:
|
|
271
|
+
raw_fields = None
|
|
272
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
273
|
+
for key, value in raw_fields.items():
|
|
274
|
+
key_str = str(key)
|
|
275
|
+
if key_str.startswith('_') or callable(value):
|
|
276
|
+
continue
|
|
277
|
+
result[key_str] = _serialize_output(value, depth + 1, node_refs)
|
|
278
|
+
return result
|
|
159
279
|
else:
|
|
160
280
|
repr_str = repr(obj)
|
|
161
|
-
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
162
281
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
163
282
|
return _SKIP_SENTINEL
|
|
164
283
|
return repr_str
|
|
@@ -177,11 +296,11 @@ def _serialize(obj, depth=0):
|
|
|
177
296
|
return obj
|
|
178
297
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
179
298
|
return "<max depth>"
|
|
180
|
-
elif isinstance(obj, (list, tuple)):
|
|
299
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
181
300
|
return [_serialize(x, depth + 1) for x in obj]
|
|
182
301
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
183
302
|
return [_serialize(x, depth + 1) for x in obj]
|
|
184
|
-
elif isinstance(obj, dict):
|
|
303
|
+
elif isinstance(obj, _builtins.dict):
|
|
185
304
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
186
305
|
elif isinstance(obj, set):
|
|
187
306
|
try:
|
|
@@ -201,6 +320,20 @@ def _serialize(obj, depth=0):
|
|
|
201
320
|
return result
|
|
202
321
|
elif callable(obj):
|
|
203
322
|
return None
|
|
323
|
+
elif hasattr(obj, '__dict__'):
|
|
324
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
325
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
326
|
+
try:
|
|
327
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
328
|
+
except Exception:
|
|
329
|
+
raw_fields = None
|
|
330
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
331
|
+
for key, value in raw_fields.items():
|
|
332
|
+
key_str = str(key)
|
|
333
|
+
if key_str.startswith('_') or callable(value):
|
|
334
|
+
continue
|
|
335
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
336
|
+
return result
|
|
204
337
|
else:
|
|
205
338
|
repr_str = repr(obj)
|
|
206
339
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -220,9 +353,9 @@ def _serialize(obj, depth=0, state=None):
|
|
|
220
353
|
if state["nodes"] > 600:
|
|
221
354
|
return "__MAX_NODES__"
|
|
222
355
|
|
|
223
|
-
if isinstance(obj, (list, tuple)):
|
|
356
|
+
if isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
224
357
|
return [_serialize(x, depth + 1, state) for x in obj]
|
|
225
|
-
elif isinstance(obj, dict):
|
|
358
|
+
elif isinstance(obj, _builtins.dict):
|
|
226
359
|
return {str(k): _serialize(v, depth + 1, state) for k, v in obj.items()}
|
|
227
360
|
elif isinstance(obj, set):
|
|
228
361
|
serialized = [_serialize(x, depth + 1, state) for x in obj]
|
|
@@ -232,7 +365,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
232
365
|
pass
|
|
233
366
|
return {"__type__": "set", "values": serialized}
|
|
234
367
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and (hasattr(obj, 'left') or hasattr(obj, 'right')):
|
|
235
|
-
obj_id = id(obj)
|
|
368
|
+
obj_id = _builtins.id(obj)
|
|
236
369
|
if obj_id in state["seen"]:
|
|
237
370
|
return "__CYCLE__"
|
|
238
371
|
state["seen"].add(obj_id)
|
|
@@ -244,7 +377,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
244
377
|
state["seen"].remove(obj_id)
|
|
245
378
|
return result
|
|
246
379
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and hasattr(obj, 'next'):
|
|
247
|
-
obj_id = id(obj)
|
|
380
|
+
obj_id = _builtins.id(obj)
|
|
248
381
|
if obj_id in state["seen"]:
|
|
249
382
|
return "__CYCLE__"
|
|
250
383
|
state["seen"].add(obj_id)
|
|
@@ -261,9 +394,9 @@ def _serialize(obj, depth=0):
|
|
|
261
394
|
return "<max depth>"
|
|
262
395
|
if isinstance(obj, (int, float, str, bool, type(None))):
|
|
263
396
|
return obj
|
|
264
|
-
elif isinstance(obj, (list, tuple)):
|
|
397
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
265
398
|
return [_serialize(x, depth + 1) for x in obj]
|
|
266
|
-
elif isinstance(obj, dict):
|
|
399
|
+
elif isinstance(obj, _builtins.dict):
|
|
267
400
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
268
401
|
elif isinstance(obj, set):
|
|
269
402
|
try:
|
|
@@ -298,11 +431,11 @@ def _serialize(obj, depth=0):
|
|
|
298
431
|
return obj
|
|
299
432
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
300
433
|
return "<max depth>"
|
|
301
|
-
elif isinstance(obj, (list, tuple)):
|
|
434
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
302
435
|
return [_serialize(x, depth + 1) for x in obj]
|
|
303
436
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
304
437
|
return [_serialize(x, depth + 1) for x in obj]
|
|
305
|
-
elif isinstance(obj, dict):
|
|
438
|
+
elif isinstance(obj, _builtins.dict):
|
|
306
439
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
307
440
|
elif isinstance(obj, set):
|
|
308
441
|
try:
|
|
@@ -322,6 +455,20 @@ def _serialize(obj, depth=0):
|
|
|
322
455
|
return result
|
|
323
456
|
elif callable(obj):
|
|
324
457
|
return None
|
|
458
|
+
elif hasattr(obj, '__dict__'):
|
|
459
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
460
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
461
|
+
try:
|
|
462
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
463
|
+
except Exception:
|
|
464
|
+
raw_fields = None
|
|
465
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
466
|
+
for key, value in raw_fields.items():
|
|
467
|
+
key_str = str(key)
|
|
468
|
+
if key_str.startswith('_') or callable(value):
|
|
469
|
+
continue
|
|
470
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
471
|
+
return result
|
|
325
472
|
else:
|
|
326
473
|
repr_str = repr(obj)
|
|
327
474
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -370,7 +517,9 @@ function generateSolutionScript(solutionCode, functionName, inputs) {
|
|
|
370
517
|
const paramList = Object.keys(inputs).map((key) => `${key}=${key}`).join(", ");
|
|
371
518
|
return `
|
|
372
519
|
import json
|
|
520
|
+
import math
|
|
373
521
|
import sys
|
|
522
|
+
import builtins as _builtins
|
|
374
523
|
from typing import *
|
|
375
524
|
|
|
376
525
|
${PYTHON_CLASS_DEFINITIONS}
|
|
@@ -484,7 +633,7 @@ def _ensure_node_value_aliases(node):
|
|
|
484
633
|
def _dict_to_tree(d):
|
|
485
634
|
if d is None:
|
|
486
635
|
return None
|
|
487
|
-
if not isinstance(d, dict):
|
|
636
|
+
if not isinstance(d, _builtins.dict):
|
|
488
637
|
return d
|
|
489
638
|
if 'val' not in d and 'value' not in d:
|
|
490
639
|
return d
|
|
@@ -499,7 +648,7 @@ def _dict_to_list(d, _refs=None):
|
|
|
499
648
|
_refs = {}
|
|
500
649
|
if d is None:
|
|
501
650
|
return None
|
|
502
|
-
if not isinstance(d, dict):
|
|
651
|
+
if not isinstance(d, _builtins.dict):
|
|
503
652
|
return d
|
|
504
653
|
if '__ref__' in d:
|
|
505
654
|
return _refs.get(d.get('__ref__'))
|
|
@@ -508,7 +657,7 @@ def _dict_to_list(d, _refs=None):
|
|
|
508
657
|
node = ListNode(d.get('val', d.get('value', 0)))
|
|
509
658
|
_ensure_node_value_aliases(node)
|
|
510
659
|
node_id = d.get('__id__')
|
|
511
|
-
if isinstance(node_id, str) and node_id:
|
|
660
|
+
if isinstance(node_id, _builtins.str) and node_id:
|
|
512
661
|
_refs[node_id] = node
|
|
513
662
|
node.next = _dict_to_list(d.get('next'), _refs)
|
|
514
663
|
return node
|
|
@@ -517,7 +666,34 @@ var TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION = `
|
|
|
517
666
|
# Sentinel to mark skipped values (functions, etc.) - distinct from None
|
|
518
667
|
_SKIP_SENTINEL = "__TRACECODE_SKIP__"
|
|
519
668
|
_MAX_SERIALIZE_DEPTH = 48
|
|
669
|
+
_MAX_SERIALIZED_ITEMS = 64
|
|
520
670
|
_MAX_OBJECT_FIELDS = 32
|
|
671
|
+
_tracecode_global_object_refs = {}
|
|
672
|
+
_tracecode_next_object_ref_id = 0
|
|
673
|
+
|
|
674
|
+
def _tracecode_ref_id(obj_ref, node_refs):
|
|
675
|
+
global _tracecode_next_object_ref_id
|
|
676
|
+
if obj_ref in node_refs:
|
|
677
|
+
return node_refs[obj_ref]
|
|
678
|
+
if obj_ref in _tracecode_global_object_refs:
|
|
679
|
+
node_id = _tracecode_global_object_refs[obj_ref]
|
|
680
|
+
else:
|
|
681
|
+
node_id = f"ref-{_tracecode_next_object_ref_id}"
|
|
682
|
+
_tracecode_global_object_refs[obj_ref] = node_id
|
|
683
|
+
_tracecode_next_object_ref_id += 1
|
|
684
|
+
node_refs[obj_ref] = node_id
|
|
685
|
+
return node_id
|
|
686
|
+
|
|
687
|
+
def _truncation_marker(total, emitted):
|
|
688
|
+
return {"__truncated__": True, "remaining": max(0, total - emitted)}
|
|
689
|
+
|
|
690
|
+
def _serialize_sequence(values, depth, node_refs):
|
|
691
|
+
values_list = _builtins.list(values)
|
|
692
|
+
emitted = min(len(values_list), _MAX_SERIALIZED_ITEMS)
|
|
693
|
+
result = [_serialize(x, depth + 1, node_refs) for x in values_list[:emitted]]
|
|
694
|
+
if emitted < len(values_list):
|
|
695
|
+
result.append(_truncation_marker(len(values_list), emitted))
|
|
696
|
+
return result
|
|
521
697
|
|
|
522
698
|
def _serialize(obj, depth=0, node_refs=None):
|
|
523
699
|
if node_refs is None:
|
|
@@ -532,25 +708,36 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
532
708
|
return obj
|
|
533
709
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
534
710
|
return "<max depth>"
|
|
535
|
-
elif isinstance(obj, (list, tuple)):
|
|
536
|
-
return
|
|
711
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
712
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
537
713
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
538
|
-
return
|
|
539
|
-
elif isinstance(obj, dict):
|
|
540
|
-
|
|
714
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
715
|
+
elif isinstance(obj, _builtins.dict):
|
|
716
|
+
items = _builtins.list(obj.items())
|
|
717
|
+
emitted = min(len(items), _MAX_SERIALIZED_ITEMS)
|
|
718
|
+
result = {str(k): _serialize(v, depth + 1, node_refs) for k, v in items[:emitted]}
|
|
719
|
+
if emitted < len(items):
|
|
720
|
+
result["__truncated__"] = True
|
|
721
|
+
result["remaining"] = len(items) - emitted
|
|
722
|
+
return result
|
|
541
723
|
elif isinstance(obj, set):
|
|
542
724
|
# Use try/except for sorting to handle heterogeneous sets
|
|
725
|
+
values = _builtins.list(obj)
|
|
726
|
+
emitted = min(len(values), _MAX_SERIALIZED_ITEMS)
|
|
543
727
|
try:
|
|
544
|
-
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in
|
|
728
|
+
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in values[:emitted]])
|
|
545
729
|
except TypeError:
|
|
546
|
-
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in
|
|
547
|
-
|
|
730
|
+
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in values[:emitted]]
|
|
731
|
+
result = {"__type__": "set", "values": sorted_vals}
|
|
732
|
+
if emitted < len(values):
|
|
733
|
+
result["__truncated__"] = True
|
|
734
|
+
result["remaining"] = len(values) - emitted
|
|
735
|
+
return result
|
|
548
736
|
elif isinstance(obj, TreeNode):
|
|
549
|
-
obj_ref = id(obj)
|
|
737
|
+
obj_ref = _builtins.id(obj)
|
|
550
738
|
if obj_ref in node_refs:
|
|
551
739
|
return {"__ref__": node_refs[obj_ref]}
|
|
552
|
-
node_id =
|
|
553
|
-
node_refs[obj_ref] = node_id
|
|
740
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
554
741
|
result = {
|
|
555
742
|
"__type__": "TreeNode",
|
|
556
743
|
"__id__": node_id,
|
|
@@ -562,11 +749,10 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
562
749
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
563
750
|
return result
|
|
564
751
|
elif isinstance(obj, ListNode):
|
|
565
|
-
obj_ref = id(obj)
|
|
752
|
+
obj_ref = _builtins.id(obj)
|
|
566
753
|
if obj_ref in node_refs:
|
|
567
754
|
return {"__ref__": node_refs[obj_ref]}
|
|
568
|
-
node_id =
|
|
569
|
-
node_refs[obj_ref] = node_id
|
|
755
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
570
756
|
result = {
|
|
571
757
|
"__type__": "ListNode",
|
|
572
758
|
"__id__": node_id,
|
|
@@ -574,15 +760,17 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
574
760
|
}
|
|
575
761
|
result["next"] = _serialize(obj.next, depth + 1, node_refs)
|
|
576
762
|
return result
|
|
763
|
+
elif callable(obj):
|
|
764
|
+
# Skip functions entirely - return sentinel
|
|
765
|
+
return _SKIP_SENTINEL
|
|
577
766
|
elif hasattr(obj, '__dict__'):
|
|
578
|
-
obj_ref = id(obj)
|
|
767
|
+
obj_ref = _builtins.id(obj)
|
|
579
768
|
if obj_ref in node_refs:
|
|
580
769
|
return {"__ref__": node_refs[obj_ref]}
|
|
581
|
-
node_id =
|
|
582
|
-
node_refs[obj_ref] = node_id
|
|
770
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
583
771
|
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
584
772
|
result = {
|
|
585
|
-
"__type__":
|
|
773
|
+
"__type__": class_name,
|
|
586
774
|
"__class__": class_name,
|
|
587
775
|
"__id__": node_id,
|
|
588
776
|
}
|
|
@@ -590,26 +778,106 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
590
778
|
raw_fields = getattr(obj, '__dict__', None)
|
|
591
779
|
except Exception:
|
|
592
780
|
raw_fields = None
|
|
593
|
-
if isinstance(raw_fields, dict):
|
|
594
|
-
|
|
781
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
782
|
+
fields = []
|
|
595
783
|
for key, value in raw_fields.items():
|
|
596
784
|
key_str = str(key)
|
|
597
785
|
if key_str.startswith('_'):
|
|
598
786
|
continue
|
|
599
787
|
if callable(value):
|
|
600
788
|
continue
|
|
789
|
+
fields.append((key_str, value))
|
|
790
|
+
for key_str, value in fields[:_MAX_OBJECT_FIELDS]:
|
|
601
791
|
result[key_str] = _serialize(value, depth + 1, node_refs)
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
792
|
+
if len(fields) > _MAX_OBJECT_FIELDS:
|
|
793
|
+
result["__truncated__"] = True
|
|
794
|
+
result["remaining"] = len(fields) - _MAX_OBJECT_FIELDS
|
|
795
|
+
return result
|
|
796
|
+
else:
|
|
797
|
+
repr_str = repr(obj)
|
|
798
|
+
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
799
|
+
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
800
|
+
return _SKIP_SENTINEL
|
|
801
|
+
return repr_str
|
|
802
|
+
|
|
803
|
+
def _serialize_output(obj, depth=0, node_refs=None):
|
|
804
|
+
if node_refs is None:
|
|
805
|
+
node_refs = {}
|
|
806
|
+
if isinstance(obj, (bool, int, str, type(None))):
|
|
807
|
+
return obj
|
|
808
|
+
elif isinstance(obj, float):
|
|
809
|
+
if not math.isfinite(obj):
|
|
810
|
+
if math.isnan(obj):
|
|
811
|
+
return "NaN"
|
|
812
|
+
return "Infinity" if obj > 0 else "-Infinity"
|
|
813
|
+
return obj
|
|
814
|
+
if depth > _MAX_SERIALIZE_DEPTH:
|
|
815
|
+
return "<max depth>"
|
|
816
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
817
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
818
|
+
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
819
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
820
|
+
elif isinstance(obj, _builtins.dict):
|
|
821
|
+
return {str(k): _serialize_output(v, depth + 1, node_refs) for k, v in obj.items()}
|
|
822
|
+
elif isinstance(obj, set):
|
|
823
|
+
try:
|
|
824
|
+
sorted_vals = sorted([_serialize_output(x, depth + 1, node_refs) for x in obj])
|
|
825
|
+
except TypeError:
|
|
826
|
+
sorted_vals = [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
827
|
+
return {"__type__": "set", "values": sorted_vals}
|
|
828
|
+
elif isinstance(obj, TreeNode):
|
|
829
|
+
obj_ref = _builtins.id(obj)
|
|
830
|
+
if obj_ref in node_refs:
|
|
831
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
832
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
833
|
+
result = {
|
|
834
|
+
"__type__": "TreeNode",
|
|
835
|
+
"__id__": node_id,
|
|
836
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
837
|
+
}
|
|
838
|
+
if hasattr(obj, 'left'):
|
|
839
|
+
result["left"] = _serialize_output(obj.left, depth + 1, node_refs)
|
|
840
|
+
if hasattr(obj, 'right'):
|
|
841
|
+
result["right"] = _serialize_output(obj.right, depth + 1, node_refs)
|
|
842
|
+
return result
|
|
843
|
+
elif isinstance(obj, ListNode):
|
|
844
|
+
obj_ref = _builtins.id(obj)
|
|
845
|
+
if obj_ref in node_refs:
|
|
846
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
847
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
848
|
+
result = {
|
|
849
|
+
"__type__": "ListNode",
|
|
850
|
+
"__id__": node_id,
|
|
851
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
852
|
+
}
|
|
853
|
+
result["next"] = _serialize_output(obj.next, depth + 1, node_refs)
|
|
606
854
|
return result
|
|
607
855
|
elif callable(obj):
|
|
608
|
-
# Skip functions entirely - return sentinel
|
|
609
856
|
return _SKIP_SENTINEL
|
|
857
|
+
elif hasattr(obj, '__dict__'):
|
|
858
|
+
obj_ref = _builtins.id(obj)
|
|
859
|
+
if obj_ref in node_refs:
|
|
860
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
861
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
862
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
863
|
+
result = {
|
|
864
|
+
"__type__": class_name,
|
|
865
|
+
"__class__": class_name,
|
|
866
|
+
"__id__": node_id,
|
|
867
|
+
}
|
|
868
|
+
try:
|
|
869
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
870
|
+
except Exception:
|
|
871
|
+
raw_fields = None
|
|
872
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
873
|
+
for key, value in raw_fields.items():
|
|
874
|
+
key_str = str(key)
|
|
875
|
+
if key_str.startswith('_') or callable(value):
|
|
876
|
+
continue
|
|
877
|
+
result[key_str] = _serialize_output(value, depth + 1, node_refs)
|
|
878
|
+
return result
|
|
610
879
|
else:
|
|
611
880
|
repr_str = repr(obj)
|
|
612
|
-
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
613
881
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
614
882
|
return _SKIP_SENTINEL
|
|
615
883
|
return repr_str
|
|
@@ -628,11 +896,11 @@ def _serialize(obj, depth=0):
|
|
|
628
896
|
return obj
|
|
629
897
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
630
898
|
return "<max depth>"
|
|
631
|
-
elif isinstance(obj, (list, tuple)):
|
|
899
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
632
900
|
return [_serialize(x, depth + 1) for x in obj]
|
|
633
901
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
634
902
|
return [_serialize(x, depth + 1) for x in obj]
|
|
635
|
-
elif isinstance(obj, dict):
|
|
903
|
+
elif isinstance(obj, _builtins.dict):
|
|
636
904
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
637
905
|
elif isinstance(obj, set):
|
|
638
906
|
try:
|
|
@@ -652,6 +920,20 @@ def _serialize(obj, depth=0):
|
|
|
652
920
|
return result
|
|
653
921
|
elif callable(obj):
|
|
654
922
|
return None
|
|
923
|
+
elif hasattr(obj, '__dict__'):
|
|
924
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
925
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
926
|
+
try:
|
|
927
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
928
|
+
except Exception:
|
|
929
|
+
raw_fields = None
|
|
930
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
931
|
+
for key, value in raw_fields.items():
|
|
932
|
+
key_str = str(key)
|
|
933
|
+
if key_str.startswith('_') or callable(value):
|
|
934
|
+
continue
|
|
935
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
936
|
+
return result
|
|
655
937
|
else:
|
|
656
938
|
repr_str = repr(obj)
|
|
657
939
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -671,9 +953,9 @@ def _serialize(obj, depth=0, state=None):
|
|
|
671
953
|
if state["nodes"] > 600:
|
|
672
954
|
return "__MAX_NODES__"
|
|
673
955
|
|
|
674
|
-
if isinstance(obj, (list, tuple)):
|
|
956
|
+
if isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
675
957
|
return [_serialize(x, depth + 1, state) for x in obj]
|
|
676
|
-
elif isinstance(obj, dict):
|
|
958
|
+
elif isinstance(obj, _builtins.dict):
|
|
677
959
|
return {str(k): _serialize(v, depth + 1, state) for k, v in obj.items()}
|
|
678
960
|
elif isinstance(obj, set):
|
|
679
961
|
serialized = [_serialize(x, depth + 1, state) for x in obj]
|
|
@@ -683,7 +965,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
683
965
|
pass
|
|
684
966
|
return {"__type__": "set", "values": serialized}
|
|
685
967
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and (hasattr(obj, 'left') or hasattr(obj, 'right')):
|
|
686
|
-
obj_id = id(obj)
|
|
968
|
+
obj_id = _builtins.id(obj)
|
|
687
969
|
if obj_id in state["seen"]:
|
|
688
970
|
return "__CYCLE__"
|
|
689
971
|
state["seen"].add(obj_id)
|
|
@@ -695,7 +977,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
695
977
|
state["seen"].remove(obj_id)
|
|
696
978
|
return result
|
|
697
979
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and hasattr(obj, 'next'):
|
|
698
|
-
obj_id = id(obj)
|
|
980
|
+
obj_id = _builtins.id(obj)
|
|
699
981
|
if obj_id in state["seen"]:
|
|
700
982
|
return "__CYCLE__"
|
|
701
983
|
state["seen"].add(obj_id)
|
|
@@ -712,9 +994,9 @@ def _serialize(obj, depth=0):
|
|
|
712
994
|
return "<max depth>"
|
|
713
995
|
if isinstance(obj, (int, float, str, bool, type(None))):
|
|
714
996
|
return obj
|
|
715
|
-
elif isinstance(obj, (list, tuple)):
|
|
997
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
716
998
|
return [_serialize(x, depth + 1) for x in obj]
|
|
717
|
-
elif isinstance(obj, dict):
|
|
999
|
+
elif isinstance(obj, _builtins.dict):
|
|
718
1000
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
719
1001
|
elif isinstance(obj, set):
|
|
720
1002
|
try:
|
|
@@ -736,6 +1018,926 @@ def _serialize(obj, depth=0):
|
|
|
736
1018
|
return repr(obj)
|
|
737
1019
|
`;
|
|
738
1020
|
var TEMPLATE_PYTHON_SERIALIZE_FUNCTION = TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION;
|
|
1021
|
+
|
|
1022
|
+
// packages/harness-browser/src/runtime-capability-guards.ts
|
|
1023
|
+
function isScriptRequest(functionName) {
|
|
1024
|
+
if (functionName == null) return true;
|
|
1025
|
+
return functionName.trim().length === 0;
|
|
1026
|
+
}
|
|
1027
|
+
function executionStyleLabel(executionStyle) {
|
|
1028
|
+
if (executionStyle === "solution-method") return "solution-method";
|
|
1029
|
+
if (executionStyle === "ops-class") return "ops-class";
|
|
1030
|
+
return "function";
|
|
1031
|
+
}
|
|
1032
|
+
function isExecutionStyleSupported(profile, executionStyle) {
|
|
1033
|
+
const styles = profile.capabilities.execution.styles;
|
|
1034
|
+
if (executionStyle === "solution-method") return styles.solutionMethod;
|
|
1035
|
+
if (executionStyle === "ops-class") return styles.opsClass;
|
|
1036
|
+
return styles.function;
|
|
1037
|
+
}
|
|
1038
|
+
function describeRequest(request) {
|
|
1039
|
+
if (request === "trace") return "tracing";
|
|
1040
|
+
if (request === "interview") return "interview execution";
|
|
1041
|
+
return "execution";
|
|
1042
|
+
}
|
|
1043
|
+
function assertRuntimeRequestSupported(profile, options) {
|
|
1044
|
+
if (options.request === "trace" && !profile.capabilities.tracing.supported) {
|
|
1045
|
+
throw new Error(`Runtime "${profile.language}" does not support tracing.`);
|
|
1046
|
+
}
|
|
1047
|
+
if (options.request === "interview" && !profile.capabilities.execution.styles.interviewMode) {
|
|
1048
|
+
throw new Error(`Runtime "${profile.language}" does not support interview execution.`);
|
|
1049
|
+
}
|
|
1050
|
+
if (!isExecutionStyleSupported(profile, options.executionStyle)) {
|
|
1051
|
+
throw new Error(
|
|
1052
|
+
`Runtime "${profile.language}" does not support execution style "${executionStyleLabel(options.executionStyle)}".`
|
|
1053
|
+
);
|
|
1054
|
+
}
|
|
1055
|
+
if (isScriptRequest(options.functionName) && !profile.capabilities.execution.styles.script) {
|
|
1056
|
+
throw new Error(`Runtime "${profile.language}" does not support script mode ${describeRequest(options.request)}.`);
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
|
|
1060
|
+
// packages/harness-browser/src/runtime-profiles.ts
|
|
1061
|
+
var PYTHON_RUNTIME_PROFILE = {
|
|
1062
|
+
language: "python",
|
|
1063
|
+
maturity: "stable",
|
|
1064
|
+
capabilities: {
|
|
1065
|
+
execution: {
|
|
1066
|
+
styles: {
|
|
1067
|
+
function: true,
|
|
1068
|
+
solutionMethod: true,
|
|
1069
|
+
opsClass: true,
|
|
1070
|
+
script: true,
|
|
1071
|
+
interviewMode: true
|
|
1072
|
+
},
|
|
1073
|
+
timeouts: {
|
|
1074
|
+
clientTimeouts: true,
|
|
1075
|
+
runtimeTimeouts: true
|
|
1076
|
+
}
|
|
1077
|
+
},
|
|
1078
|
+
tracing: {
|
|
1079
|
+
supported: true,
|
|
1080
|
+
events: {
|
|
1081
|
+
line: true,
|
|
1082
|
+
call: true,
|
|
1083
|
+
return: true,
|
|
1084
|
+
exception: true,
|
|
1085
|
+
stdout: true,
|
|
1086
|
+
timeout: true
|
|
1087
|
+
},
|
|
1088
|
+
controls: {
|
|
1089
|
+
maxTraceSteps: true,
|
|
1090
|
+
maxLineEvents: true,
|
|
1091
|
+
maxSingleLineHits: true,
|
|
1092
|
+
maxStoredEvents: true,
|
|
1093
|
+
minimalTrace: true
|
|
1094
|
+
},
|
|
1095
|
+
fidelity: {
|
|
1096
|
+
preciseLineMapping: true,
|
|
1097
|
+
stableFunctionNames: true,
|
|
1098
|
+
callStack: true
|
|
1099
|
+
}
|
|
1100
|
+
},
|
|
1101
|
+
diagnostics: {
|
|
1102
|
+
compileErrors: false,
|
|
1103
|
+
runtimeErrors: true,
|
|
1104
|
+
mappedErrorLines: true,
|
|
1105
|
+
stackTraces: false
|
|
1106
|
+
},
|
|
1107
|
+
structures: {
|
|
1108
|
+
treeNodeRefs: true,
|
|
1109
|
+
listNodeRefs: true,
|
|
1110
|
+
mapSerialization: true,
|
|
1111
|
+
setSerialization: true,
|
|
1112
|
+
graphSerialization: true,
|
|
1113
|
+
cycleReferences: true
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
var JAVASCRIPT_RUNTIME_PROFILE = {
|
|
1118
|
+
language: "javascript",
|
|
1119
|
+
maturity: "stable",
|
|
1120
|
+
capabilities: {
|
|
1121
|
+
execution: {
|
|
1122
|
+
styles: {
|
|
1123
|
+
function: true,
|
|
1124
|
+
solutionMethod: true,
|
|
1125
|
+
opsClass: true,
|
|
1126
|
+
script: true,
|
|
1127
|
+
interviewMode: true
|
|
1128
|
+
},
|
|
1129
|
+
timeouts: {
|
|
1130
|
+
clientTimeouts: true,
|
|
1131
|
+
runtimeTimeouts: false
|
|
1132
|
+
}
|
|
1133
|
+
},
|
|
1134
|
+
tracing: {
|
|
1135
|
+
supported: true,
|
|
1136
|
+
events: {
|
|
1137
|
+
line: true,
|
|
1138
|
+
call: true,
|
|
1139
|
+
return: true,
|
|
1140
|
+
exception: true,
|
|
1141
|
+
stdout: false,
|
|
1142
|
+
timeout: true
|
|
1143
|
+
},
|
|
1144
|
+
controls: {
|
|
1145
|
+
maxTraceSteps: true,
|
|
1146
|
+
maxLineEvents: true,
|
|
1147
|
+
maxSingleLineHits: true,
|
|
1148
|
+
maxStoredEvents: true,
|
|
1149
|
+
minimalTrace: true
|
|
1150
|
+
},
|
|
1151
|
+
fidelity: {
|
|
1152
|
+
preciseLineMapping: true,
|
|
1153
|
+
stableFunctionNames: true,
|
|
1154
|
+
callStack: true
|
|
1155
|
+
}
|
|
1156
|
+
},
|
|
1157
|
+
diagnostics: {
|
|
1158
|
+
compileErrors: false,
|
|
1159
|
+
runtimeErrors: true,
|
|
1160
|
+
mappedErrorLines: false,
|
|
1161
|
+
stackTraces: false
|
|
1162
|
+
},
|
|
1163
|
+
structures: {
|
|
1164
|
+
treeNodeRefs: true,
|
|
1165
|
+
listNodeRefs: true,
|
|
1166
|
+
mapSerialization: true,
|
|
1167
|
+
setSerialization: true,
|
|
1168
|
+
graphSerialization: true,
|
|
1169
|
+
cycleReferences: true
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
var TYPESCRIPT_RUNTIME_PROFILE = {
|
|
1174
|
+
language: "typescript",
|
|
1175
|
+
maturity: "stable",
|
|
1176
|
+
capabilities: {
|
|
1177
|
+
execution: {
|
|
1178
|
+
styles: {
|
|
1179
|
+
function: true,
|
|
1180
|
+
solutionMethod: true,
|
|
1181
|
+
opsClass: true,
|
|
1182
|
+
script: true,
|
|
1183
|
+
interviewMode: true
|
|
1184
|
+
},
|
|
1185
|
+
timeouts: {
|
|
1186
|
+
clientTimeouts: true,
|
|
1187
|
+
runtimeTimeouts: false
|
|
1188
|
+
}
|
|
1189
|
+
},
|
|
1190
|
+
tracing: {
|
|
1191
|
+
supported: true,
|
|
1192
|
+
events: {
|
|
1193
|
+
line: true,
|
|
1194
|
+
call: true,
|
|
1195
|
+
return: true,
|
|
1196
|
+
exception: true,
|
|
1197
|
+
stdout: false,
|
|
1198
|
+
timeout: true
|
|
1199
|
+
},
|
|
1200
|
+
controls: {
|
|
1201
|
+
maxTraceSteps: true,
|
|
1202
|
+
maxLineEvents: true,
|
|
1203
|
+
maxSingleLineHits: true,
|
|
1204
|
+
maxStoredEvents: true,
|
|
1205
|
+
minimalTrace: true
|
|
1206
|
+
},
|
|
1207
|
+
fidelity: {
|
|
1208
|
+
preciseLineMapping: true,
|
|
1209
|
+
stableFunctionNames: true,
|
|
1210
|
+
callStack: true
|
|
1211
|
+
}
|
|
1212
|
+
},
|
|
1213
|
+
diagnostics: {
|
|
1214
|
+
compileErrors: true,
|
|
1215
|
+
runtimeErrors: true,
|
|
1216
|
+
mappedErrorLines: true,
|
|
1217
|
+
stackTraces: false
|
|
1218
|
+
},
|
|
1219
|
+
structures: {
|
|
1220
|
+
treeNodeRefs: true,
|
|
1221
|
+
listNodeRefs: true,
|
|
1222
|
+
mapSerialization: true,
|
|
1223
|
+
setSerialization: true,
|
|
1224
|
+
graphSerialization: true,
|
|
1225
|
+
cycleReferences: true
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
var JAVA_RUNTIME_PROFILE = {
|
|
1230
|
+
language: "java",
|
|
1231
|
+
maturity: "experimental",
|
|
1232
|
+
capabilities: {
|
|
1233
|
+
execution: {
|
|
1234
|
+
styles: {
|
|
1235
|
+
function: true,
|
|
1236
|
+
solutionMethod: true,
|
|
1237
|
+
opsClass: true,
|
|
1238
|
+
script: true,
|
|
1239
|
+
interviewMode: true
|
|
1240
|
+
},
|
|
1241
|
+
timeouts: {
|
|
1242
|
+
clientTimeouts: true,
|
|
1243
|
+
runtimeTimeouts: true
|
|
1244
|
+
}
|
|
1245
|
+
},
|
|
1246
|
+
tracing: {
|
|
1247
|
+
supported: true,
|
|
1248
|
+
events: {
|
|
1249
|
+
line: true,
|
|
1250
|
+
call: true,
|
|
1251
|
+
return: true,
|
|
1252
|
+
exception: true,
|
|
1253
|
+
stdout: false,
|
|
1254
|
+
timeout: true
|
|
1255
|
+
},
|
|
1256
|
+
controls: {
|
|
1257
|
+
maxTraceSteps: true,
|
|
1258
|
+
maxLineEvents: false,
|
|
1259
|
+
maxSingleLineHits: false,
|
|
1260
|
+
maxStoredEvents: true,
|
|
1261
|
+
minimalTrace: false
|
|
1262
|
+
},
|
|
1263
|
+
fidelity: {
|
|
1264
|
+
preciseLineMapping: true,
|
|
1265
|
+
stableFunctionNames: true,
|
|
1266
|
+
callStack: true
|
|
1267
|
+
}
|
|
1268
|
+
},
|
|
1269
|
+
diagnostics: {
|
|
1270
|
+
compileErrors: true,
|
|
1271
|
+
runtimeErrors: true,
|
|
1272
|
+
mappedErrorLines: false,
|
|
1273
|
+
stackTraces: true
|
|
1274
|
+
},
|
|
1275
|
+
structures: {
|
|
1276
|
+
treeNodeRefs: true,
|
|
1277
|
+
listNodeRefs: true,
|
|
1278
|
+
mapSerialization: true,
|
|
1279
|
+
setSerialization: true,
|
|
1280
|
+
graphSerialization: false,
|
|
1281
|
+
cycleReferences: true
|
|
1282
|
+
}
|
|
1283
|
+
},
|
|
1284
|
+
notes: [
|
|
1285
|
+
"Java currently supports the browser-local Java 17 lane for function, solution-method, ops-class, and script-style execution.",
|
|
1286
|
+
"Interview-mode Java reuses the same browser-local execution path and remains experimental.",
|
|
1287
|
+
'Script-style Java uses an empty function name with executionStyle="function" and reads the top-level result variable.'
|
|
1288
|
+
]
|
|
1289
|
+
};
|
|
1290
|
+
var CSHARP_RUNTIME_PROFILE = {
|
|
1291
|
+
language: "csharp",
|
|
1292
|
+
maturity: "experimental",
|
|
1293
|
+
capabilities: {
|
|
1294
|
+
execution: {
|
|
1295
|
+
styles: {
|
|
1296
|
+
function: true,
|
|
1297
|
+
solutionMethod: true,
|
|
1298
|
+
opsClass: true,
|
|
1299
|
+
script: true,
|
|
1300
|
+
interviewMode: true
|
|
1301
|
+
},
|
|
1302
|
+
timeouts: {
|
|
1303
|
+
clientTimeouts: true,
|
|
1304
|
+
runtimeTimeouts: true
|
|
1305
|
+
}
|
|
1306
|
+
},
|
|
1307
|
+
tracing: {
|
|
1308
|
+
supported: true,
|
|
1309
|
+
events: {
|
|
1310
|
+
line: true,
|
|
1311
|
+
call: true,
|
|
1312
|
+
return: true,
|
|
1313
|
+
exception: true,
|
|
1314
|
+
stdout: true,
|
|
1315
|
+
timeout: true
|
|
1316
|
+
},
|
|
1317
|
+
controls: {
|
|
1318
|
+
maxTraceSteps: true,
|
|
1319
|
+
maxLineEvents: true,
|
|
1320
|
+
maxSingleLineHits: true,
|
|
1321
|
+
maxStoredEvents: true,
|
|
1322
|
+
minimalTrace: true
|
|
1323
|
+
},
|
|
1324
|
+
fidelity: {
|
|
1325
|
+
preciseLineMapping: true,
|
|
1326
|
+
stableFunctionNames: true,
|
|
1327
|
+
callStack: true
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
diagnostics: {
|
|
1331
|
+
compileErrors: true,
|
|
1332
|
+
runtimeErrors: true,
|
|
1333
|
+
mappedErrorLines: true,
|
|
1334
|
+
stackTraces: false
|
|
1335
|
+
},
|
|
1336
|
+
structures: {
|
|
1337
|
+
treeNodeRefs: true,
|
|
1338
|
+
listNodeRefs: true,
|
|
1339
|
+
mapSerialization: true,
|
|
1340
|
+
setSerialization: true,
|
|
1341
|
+
graphSerialization: true,
|
|
1342
|
+
cycleReferences: true
|
|
1343
|
+
}
|
|
1344
|
+
},
|
|
1345
|
+
notes: [
|
|
1346
|
+
"C# support is browser-local and experimental.",
|
|
1347
|
+
"C# supports named function-style requests where the browser-local host can bind the named method.",
|
|
1348
|
+
'Script-style C# uses an empty function name with executionStyle="function" and reads the top-level result variable.',
|
|
1349
|
+
"Interview-mode C# uses the same browser-local worker execution path with interview timeout normalization.",
|
|
1350
|
+
"The first C# slice supports public class Solution methods.",
|
|
1351
|
+
"ListNode and TreeNode inputs are hydrated from level-order arrays or object-shaped JSON.",
|
|
1352
|
+
"Dictionary, HashSet, List, and array return values serialize through the browser-local worker.",
|
|
1353
|
+
"Tracing currently supports line, call, return, stdout, and simple local variable write events.",
|
|
1354
|
+
"Structural visualization is added after execution and diagnostics are proven."
|
|
1355
|
+
]
|
|
1356
|
+
};
|
|
1357
|
+
var CPP_RUNTIME_PROFILE = {
|
|
1358
|
+
language: "cpp",
|
|
1359
|
+
maturity: "experimental",
|
|
1360
|
+
capabilities: {
|
|
1361
|
+
execution: {
|
|
1362
|
+
styles: {
|
|
1363
|
+
function: true,
|
|
1364
|
+
solutionMethod: true,
|
|
1365
|
+
opsClass: true,
|
|
1366
|
+
script: true,
|
|
1367
|
+
interviewMode: true
|
|
1368
|
+
},
|
|
1369
|
+
timeouts: {
|
|
1370
|
+
clientTimeouts: true,
|
|
1371
|
+
runtimeTimeouts: true
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
tracing: {
|
|
1375
|
+
supported: true,
|
|
1376
|
+
events: {
|
|
1377
|
+
line: true,
|
|
1378
|
+
call: true,
|
|
1379
|
+
return: true,
|
|
1380
|
+
exception: true,
|
|
1381
|
+
stdout: true,
|
|
1382
|
+
timeout: true
|
|
1383
|
+
},
|
|
1384
|
+
controls: {
|
|
1385
|
+
maxTraceSteps: true,
|
|
1386
|
+
maxLineEvents: true,
|
|
1387
|
+
maxSingleLineHits: true,
|
|
1388
|
+
maxStoredEvents: true,
|
|
1389
|
+
minimalTrace: true
|
|
1390
|
+
},
|
|
1391
|
+
fidelity: {
|
|
1392
|
+
preciseLineMapping: true,
|
|
1393
|
+
stableFunctionNames: true,
|
|
1394
|
+
callStack: true
|
|
1395
|
+
}
|
|
1396
|
+
},
|
|
1397
|
+
diagnostics: {
|
|
1398
|
+
compileErrors: true,
|
|
1399
|
+
runtimeErrors: true,
|
|
1400
|
+
mappedErrorLines: true,
|
|
1401
|
+
stackTraces: false
|
|
1402
|
+
},
|
|
1403
|
+
structures: {
|
|
1404
|
+
treeNodeRefs: true,
|
|
1405
|
+
listNodeRefs: true,
|
|
1406
|
+
mapSerialization: true,
|
|
1407
|
+
setSerialization: true,
|
|
1408
|
+
graphSerialization: true,
|
|
1409
|
+
cycleReferences: true
|
|
1410
|
+
}
|
|
1411
|
+
},
|
|
1412
|
+
notes: [
|
|
1413
|
+
"C++ uses a focused browser-local Clang/LLD/WASI compiler lane with TraceCode-owned execution glue.",
|
|
1414
|
+
"The runtime intentionally does not depend on a generic multi-language container/runtime SDK.",
|
|
1415
|
+
'Script-style C++ uses an empty function name with executionStyle="function"; the snippet must assign a serializable result variable.',
|
|
1416
|
+
"Interview-mode C++ reuses the tracing compiler path with a trace budget and returns a non-trace execution result."
|
|
1417
|
+
]
|
|
1418
|
+
};
|
|
1419
|
+
var LANGUAGE_RUNTIME_PROFILES = {
|
|
1420
|
+
python: PYTHON_RUNTIME_PROFILE,
|
|
1421
|
+
javascript: JAVASCRIPT_RUNTIME_PROFILE,
|
|
1422
|
+
typescript: TYPESCRIPT_RUNTIME_PROFILE,
|
|
1423
|
+
java: JAVA_RUNTIME_PROFILE,
|
|
1424
|
+
csharp: CSHARP_RUNTIME_PROFILE,
|
|
1425
|
+
cpp: CPP_RUNTIME_PROFILE
|
|
1426
|
+
};
|
|
1427
|
+
var SUPPORTED_LANGUAGES = Object.freeze(
|
|
1428
|
+
Object.keys(LANGUAGE_RUNTIME_PROFILES)
|
|
1429
|
+
);
|
|
1430
|
+
function getLanguageRuntimeProfile(language) {
|
|
1431
|
+
const profile = LANGUAGE_RUNTIME_PROFILES[language];
|
|
1432
|
+
if (!profile) {
|
|
1433
|
+
throw new Error(`Runtime profile for language "${language}" is not implemented yet.`);
|
|
1434
|
+
}
|
|
1435
|
+
return profile;
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
// packages/harness-browser/src/python-runtime-client.ts
|
|
1439
|
+
var PythonRuntimeClient = class {
|
|
1440
|
+
constructor(workerClient) {
|
|
1441
|
+
this.workerClient = workerClient;
|
|
1442
|
+
}
|
|
1443
|
+
async init() {
|
|
1444
|
+
return this.workerClient.init();
|
|
1445
|
+
}
|
|
1446
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
1447
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1448
|
+
request: "trace",
|
|
1449
|
+
executionStyle,
|
|
1450
|
+
functionName
|
|
1451
|
+
});
|
|
1452
|
+
return this.workerClient.executeWithTracing(
|
|
1453
|
+
code,
|
|
1454
|
+
functionName,
|
|
1455
|
+
inputs,
|
|
1456
|
+
options,
|
|
1457
|
+
executionStyle
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
1461
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1462
|
+
request: "execute",
|
|
1463
|
+
executionStyle,
|
|
1464
|
+
functionName
|
|
1465
|
+
});
|
|
1466
|
+
return this.workerClient.executeCode(
|
|
1467
|
+
code,
|
|
1468
|
+
functionName,
|
|
1469
|
+
inputs,
|
|
1470
|
+
executionStyle
|
|
1471
|
+
);
|
|
1472
|
+
}
|
|
1473
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
|
|
1474
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1475
|
+
request: "interview",
|
|
1476
|
+
executionStyle,
|
|
1477
|
+
functionName
|
|
1478
|
+
});
|
|
1479
|
+
return this.workerClient.executeCodeInterviewMode(
|
|
1480
|
+
code,
|
|
1481
|
+
functionName,
|
|
1482
|
+
inputs,
|
|
1483
|
+
executionStyle
|
|
1484
|
+
);
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
function createPythonRuntimeClient(workerClient) {
|
|
1488
|
+
return new PythonRuntimeClient(workerClient);
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
// packages/harness-core/src/runtime-trace.ts
|
|
1492
|
+
var RUNTIME_TRACE_SCHEMA_VERSION = "runtime-trace-2026-04-28";
|
|
1493
|
+
function createEmptyRuntimeTrace(language, options = {}) {
|
|
1494
|
+
return {
|
|
1495
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1496
|
+
language,
|
|
1497
|
+
runId: options.runId ?? `${language}:run`,
|
|
1498
|
+
events: [],
|
|
1499
|
+
lineEventCount: 0,
|
|
1500
|
+
traceStepCount: 0
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
// packages/harness-browser/src/runtime-diagnostics.ts
|
|
1505
|
+
var CONSOLE_METHOD_BY_LEVEL = {
|
|
1506
|
+
debug: "debug",
|
|
1507
|
+
info: "info",
|
|
1508
|
+
warn: "warn",
|
|
1509
|
+
error: "error"
|
|
1510
|
+
};
|
|
1511
|
+
function runtimeDiagnosticEvent(params) {
|
|
1512
|
+
return {
|
|
1513
|
+
schema: "tracecode.runtime-diagnostic.v1",
|
|
1514
|
+
source: "harness",
|
|
1515
|
+
...params
|
|
1516
|
+
};
|
|
1517
|
+
}
|
|
1518
|
+
function logRuntimeDiagnostic(level, params, options = {}) {
|
|
1519
|
+
if (options.enabled === false && level !== "error") {
|
|
1520
|
+
return;
|
|
1521
|
+
}
|
|
1522
|
+
const method = CONSOLE_METHOD_BY_LEVEL[level] ?? "info";
|
|
1523
|
+
console[method]("[TraceRuntime]", runtimeDiagnosticEvent(params));
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
// packages/harness-browser/src/pyodide-worker-client.ts
|
|
1527
|
+
var EXECUTION_TIMEOUT_MS = 1e4;
|
|
1528
|
+
var INTERVIEW_MODE_TIMEOUT_MS = 5e3;
|
|
1529
|
+
var TRACING_TIMEOUT_MS = 3e4;
|
|
1530
|
+
var INIT_TIMEOUT_MS = 12e4;
|
|
1531
|
+
var MESSAGE_TIMEOUT_MS = 2e4;
|
|
1532
|
+
var WORKER_READY_TIMEOUT_MS = 1e4;
|
|
1533
|
+
var PythonWorkerClient = class {
|
|
1534
|
+
constructor(options) {
|
|
1535
|
+
this.options = options;
|
|
1536
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
1537
|
+
}
|
|
1538
|
+
worker = null;
|
|
1539
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
1540
|
+
messageId = 0;
|
|
1541
|
+
isInitializing = false;
|
|
1542
|
+
initPromise = null;
|
|
1543
|
+
warmupPromise = null;
|
|
1544
|
+
workerReadyPromise = null;
|
|
1545
|
+
workerReadyResolve = null;
|
|
1546
|
+
workerReadyReject = null;
|
|
1547
|
+
debug;
|
|
1548
|
+
/**
|
|
1549
|
+
* Check if Web Workers are supported
|
|
1550
|
+
*/
|
|
1551
|
+
isSupported() {
|
|
1552
|
+
return typeof Worker !== "undefined";
|
|
1553
|
+
}
|
|
1554
|
+
/**
|
|
1555
|
+
* Get or create the worker instance
|
|
1556
|
+
*/
|
|
1557
|
+
getWorker() {
|
|
1558
|
+
if (this.worker) return this.worker;
|
|
1559
|
+
if (!this.isSupported()) {
|
|
1560
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
1561
|
+
}
|
|
1562
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
1563
|
+
this.workerReadyResolve = resolve;
|
|
1564
|
+
this.workerReadyReject = (error) => reject(error);
|
|
1565
|
+
});
|
|
1566
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
1567
|
+
this.worker = new Worker(workerUrl);
|
|
1568
|
+
this.worker.onmessage = (event) => {
|
|
1569
|
+
const { id, type, payload } = event.data;
|
|
1570
|
+
if (type === "worker-ready") {
|
|
1571
|
+
this.workerReadyResolve?.();
|
|
1572
|
+
this.workerReadyResolve = null;
|
|
1573
|
+
this.workerReadyReject = null;
|
|
1574
|
+
logRuntimeDiagnostic("info", {
|
|
1575
|
+
component: "PythonWorkerClient",
|
|
1576
|
+
runtime: "python",
|
|
1577
|
+
phase: "worker-ready",
|
|
1578
|
+
message: "Python worker is ready."
|
|
1579
|
+
}, { enabled: this.debug });
|
|
1580
|
+
return;
|
|
1581
|
+
}
|
|
1582
|
+
if (this.debug && !id) {
|
|
1583
|
+
logRuntimeDiagnostic("debug", {
|
|
1584
|
+
component: "PythonWorkerClient",
|
|
1585
|
+
runtime: "python",
|
|
1586
|
+
phase: "worker-event",
|
|
1587
|
+
message: "Python worker emitted an unsolicited event.",
|
|
1588
|
+
detail: { type, payload }
|
|
1589
|
+
}, { enabled: this.debug });
|
|
1590
|
+
}
|
|
1591
|
+
if (id) {
|
|
1592
|
+
const pending = this.pendingMessages.get(id);
|
|
1593
|
+
if (pending) {
|
|
1594
|
+
this.pendingMessages.delete(id);
|
|
1595
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1596
|
+
if (type === "error") {
|
|
1597
|
+
pending.reject(new Error(payload.error));
|
|
1598
|
+
} else {
|
|
1599
|
+
logRuntimeDiagnostic("debug", {
|
|
1600
|
+
component: "PythonWorkerClient",
|
|
1601
|
+
runtime: "python",
|
|
1602
|
+
phase: "worker-response",
|
|
1603
|
+
message: "Python worker response received.",
|
|
1604
|
+
detail: { id, type }
|
|
1605
|
+
}, { enabled: this.debug });
|
|
1606
|
+
pending.resolve(payload);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
this.worker.onerror = (error) => {
|
|
1612
|
+
logRuntimeDiagnostic("error", {
|
|
1613
|
+
component: "PythonWorkerClient",
|
|
1614
|
+
runtime: "python",
|
|
1615
|
+
phase: "worker-error",
|
|
1616
|
+
message: "Python worker emitted an error event.",
|
|
1617
|
+
detail: {
|
|
1618
|
+
message: error.message,
|
|
1619
|
+
filename: error.filename,
|
|
1620
|
+
lineno: error.lineno,
|
|
1621
|
+
colno: error.colno
|
|
1622
|
+
}
|
|
1623
|
+
});
|
|
1624
|
+
const workerError = new Error("Worker error");
|
|
1625
|
+
this.workerReadyReject?.(workerError);
|
|
1626
|
+
this.workerReadyResolve = null;
|
|
1627
|
+
this.workerReadyReject = null;
|
|
1628
|
+
for (const [id, pending] of this.pendingMessages) {
|
|
1629
|
+
if (pending.timeoutId) {
|
|
1630
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
1631
|
+
}
|
|
1632
|
+
pending.reject(workerError);
|
|
1633
|
+
this.pendingMessages.delete(id);
|
|
1634
|
+
}
|
|
1635
|
+
};
|
|
1636
|
+
return this.worker;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Wait for worker bootstrap signal with timeout.
|
|
1640
|
+
* Guards against deadlocks when the worker script fails before posting "worker-ready".
|
|
1641
|
+
*/
|
|
1642
|
+
async waitForWorkerReady() {
|
|
1643
|
+
const readyPromise = this.workerReadyPromise;
|
|
1644
|
+
if (!readyPromise) return;
|
|
1645
|
+
await new Promise((resolve, reject) => {
|
|
1646
|
+
let settled = false;
|
|
1647
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1648
|
+
if (settled) return;
|
|
1649
|
+
settled = true;
|
|
1650
|
+
const timeoutError = new Error(
|
|
1651
|
+
`Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS / 1e3)}s)`
|
|
1652
|
+
);
|
|
1653
|
+
logRuntimeDiagnostic("warn", {
|
|
1654
|
+
component: "PythonWorkerClient",
|
|
1655
|
+
runtime: "python",
|
|
1656
|
+
phase: "worker-ready-timeout",
|
|
1657
|
+
message: "Python worker did not send worker-ready before the timeout.",
|
|
1658
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS }
|
|
1659
|
+
}, { enabled: this.debug });
|
|
1660
|
+
this.terminateAndReset(timeoutError);
|
|
1661
|
+
reject(timeoutError);
|
|
1662
|
+
}, WORKER_READY_TIMEOUT_MS);
|
|
1663
|
+
readyPromise.then(() => {
|
|
1664
|
+
if (settled) return;
|
|
1665
|
+
settled = true;
|
|
1666
|
+
globalThis.clearTimeout(timeoutId);
|
|
1667
|
+
resolve();
|
|
1668
|
+
}).catch((error) => {
|
|
1669
|
+
if (settled) return;
|
|
1670
|
+
settled = true;
|
|
1671
|
+
globalThis.clearTimeout(timeoutId);
|
|
1672
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
1673
|
+
});
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
/**
|
|
1677
|
+
* Send a message to the worker and wait for a response
|
|
1678
|
+
*/
|
|
1679
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS) {
|
|
1680
|
+
const worker = this.getWorker();
|
|
1681
|
+
await this.waitForWorkerReady();
|
|
1682
|
+
const id = String(++this.messageId);
|
|
1683
|
+
return new Promise((resolve, reject) => {
|
|
1684
|
+
this.pendingMessages.set(id, {
|
|
1685
|
+
resolve,
|
|
1686
|
+
reject
|
|
1687
|
+
});
|
|
1688
|
+
logRuntimeDiagnostic("debug", {
|
|
1689
|
+
component: "PythonWorkerClient",
|
|
1690
|
+
runtime: "python",
|
|
1691
|
+
phase: "worker-request",
|
|
1692
|
+
message: "Sending request to Python worker.",
|
|
1693
|
+
detail: { id, type }
|
|
1694
|
+
}, { enabled: this.debug });
|
|
1695
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1696
|
+
const pending2 = this.pendingMessages.get(id);
|
|
1697
|
+
if (!pending2) return;
|
|
1698
|
+
this.pendingMessages.delete(id);
|
|
1699
|
+
logRuntimeDiagnostic("warn", {
|
|
1700
|
+
component: "PythonWorkerClient",
|
|
1701
|
+
runtime: "python",
|
|
1702
|
+
phase: "worker-request-timeout",
|
|
1703
|
+
message: "Python worker request timed out.",
|
|
1704
|
+
detail: { id, type, timeoutMs }
|
|
1705
|
+
}, { enabled: this.debug });
|
|
1706
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
1707
|
+
}, timeoutMs);
|
|
1708
|
+
const pending = this.pendingMessages.get(id);
|
|
1709
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
1710
|
+
worker.postMessage({ id, type, payload });
|
|
1711
|
+
});
|
|
1712
|
+
}
|
|
1713
|
+
/**
|
|
1714
|
+
* Execute code with a timeout - terminates worker if execution takes too long
|
|
1715
|
+
*/
|
|
1716
|
+
async executeWithTimeout(executor, timeoutMs = EXECUTION_TIMEOUT_MS) {
|
|
1717
|
+
return new Promise((resolve, reject) => {
|
|
1718
|
+
let settled = false;
|
|
1719
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1720
|
+
if (settled) return;
|
|
1721
|
+
settled = true;
|
|
1722
|
+
logRuntimeDiagnostic("warn", {
|
|
1723
|
+
component: "PythonWorkerClient",
|
|
1724
|
+
runtime: "python",
|
|
1725
|
+
phase: "execution-timeout",
|
|
1726
|
+
message: "Python execution timed out; terminating worker.",
|
|
1727
|
+
detail: { timeoutMs }
|
|
1728
|
+
}, { enabled: this.debug });
|
|
1729
|
+
this.terminateAndReset();
|
|
1730
|
+
const seconds = Math.round(timeoutMs / 1e3);
|
|
1731
|
+
reject(new Error(`Execution timed out (possible infinite loop). Code execution was stopped after ${seconds} seconds.`));
|
|
1732
|
+
}, timeoutMs);
|
|
1733
|
+
executor().then((result) => {
|
|
1734
|
+
if (settled) return;
|
|
1735
|
+
settled = true;
|
|
1736
|
+
globalThis.clearTimeout(timeoutId);
|
|
1737
|
+
resolve(result);
|
|
1738
|
+
}).catch((error) => {
|
|
1739
|
+
if (settled) return;
|
|
1740
|
+
settled = true;
|
|
1741
|
+
globalThis.clearTimeout(timeoutId);
|
|
1742
|
+
reject(error);
|
|
1743
|
+
});
|
|
1744
|
+
});
|
|
1745
|
+
}
|
|
1746
|
+
/**
|
|
1747
|
+
* Terminate the worker and reset state for recreation
|
|
1748
|
+
*/
|
|
1749
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
1750
|
+
this.workerReadyReject?.(reason);
|
|
1751
|
+
if (this.worker) {
|
|
1752
|
+
this.worker.terminate();
|
|
1753
|
+
this.worker = null;
|
|
1754
|
+
}
|
|
1755
|
+
this.initPromise = null;
|
|
1756
|
+
this.warmupPromise = null;
|
|
1757
|
+
this.isInitializing = false;
|
|
1758
|
+
this.workerReadyPromise = null;
|
|
1759
|
+
this.workerReadyResolve = null;
|
|
1760
|
+
for (const [, pending] of this.pendingMessages) {
|
|
1761
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1762
|
+
pending.reject(reason);
|
|
1763
|
+
}
|
|
1764
|
+
this.pendingMessages.clear();
|
|
1765
|
+
}
|
|
1766
|
+
/**
|
|
1767
|
+
* Initialize the Python worker. Runtime loading is lazy unless warmup() is called.
|
|
1768
|
+
*/
|
|
1769
|
+
async init() {
|
|
1770
|
+
if (this.initPromise) {
|
|
1771
|
+
return this.initPromise;
|
|
1772
|
+
}
|
|
1773
|
+
if (this.isInitializing) {
|
|
1774
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1775
|
+
return this.init();
|
|
1776
|
+
}
|
|
1777
|
+
this.isInitializing = true;
|
|
1778
|
+
this.initPromise = (async () => {
|
|
1779
|
+
try {
|
|
1780
|
+
return await this.sendMessage("init", void 0, INIT_TIMEOUT_MS);
|
|
1781
|
+
} catch (error) {
|
|
1782
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1783
|
+
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");
|
|
1784
|
+
if (!shouldRetry) {
|
|
1785
|
+
throw error;
|
|
1786
|
+
}
|
|
1787
|
+
logRuntimeDiagnostic("warn", {
|
|
1788
|
+
component: "PythonWorkerClient",
|
|
1789
|
+
runtime: "python",
|
|
1790
|
+
phase: "init-retry",
|
|
1791
|
+
message: "Python worker init failed; resetting worker and retrying once.",
|
|
1792
|
+
detail: { message }
|
|
1793
|
+
}, { enabled: this.debug });
|
|
1794
|
+
this.terminateAndReset();
|
|
1795
|
+
return this.sendMessage("init", void 0, INIT_TIMEOUT_MS);
|
|
1796
|
+
}
|
|
1797
|
+
})();
|
|
1798
|
+
try {
|
|
1799
|
+
const result = await this.initPromise;
|
|
1800
|
+
return result;
|
|
1801
|
+
} catch (error) {
|
|
1802
|
+
this.initPromise = null;
|
|
1803
|
+
throw error;
|
|
1804
|
+
} finally {
|
|
1805
|
+
this.isInitializing = false;
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
async warmup() {
|
|
1809
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
1810
|
+
this.warmupPromise = (async () => {
|
|
1811
|
+
try {
|
|
1812
|
+
await this.init();
|
|
1813
|
+
return await this.sendMessage("warmup", void 0, INIT_TIMEOUT_MS);
|
|
1814
|
+
} catch (error) {
|
|
1815
|
+
this.warmupPromise = null;
|
|
1816
|
+
throw error;
|
|
1817
|
+
}
|
|
1818
|
+
})();
|
|
1819
|
+
return this.warmupPromise;
|
|
1820
|
+
}
|
|
1821
|
+
/**
|
|
1822
|
+
* Execute Python code with tracing for step-by-step visualization
|
|
1823
|
+
* @param options.maxLineEvents - Max line events before abort (for complexity analysis, use higher values)
|
|
1824
|
+
*/
|
|
1825
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
1826
|
+
await this.init();
|
|
1827
|
+
try {
|
|
1828
|
+
return await this.executeWithTimeout(
|
|
1829
|
+
() => this.sendMessage("execute-with-tracing", {
|
|
1830
|
+
code,
|
|
1831
|
+
functionName,
|
|
1832
|
+
inputs,
|
|
1833
|
+
executionStyle,
|
|
1834
|
+
options
|
|
1835
|
+
}, TRACING_TIMEOUT_MS + 5e3),
|
|
1836
|
+
// Message timeout slightly longer than execution timeout
|
|
1837
|
+
TRACING_TIMEOUT_MS
|
|
1838
|
+
);
|
|
1839
|
+
} catch (error) {
|
|
1840
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1841
|
+
const isClientTimeout = errorMessage.includes("Execution timed out") || errorMessage.includes("possible infinite loop");
|
|
1842
|
+
if (isClientTimeout) {
|
|
1843
|
+
return {
|
|
1844
|
+
success: false,
|
|
1845
|
+
error: errorMessage,
|
|
1846
|
+
trace: createEmptyRuntimeTrace("python", { runId: "python:run", file: "solution.py" }),
|
|
1847
|
+
executionTimeMs: TRACING_TIMEOUT_MS,
|
|
1848
|
+
consoleOutput: [],
|
|
1849
|
+
traceLimitExceeded: true,
|
|
1850
|
+
timeoutReason: "client-timeout",
|
|
1851
|
+
lineEventCount: 0,
|
|
1852
|
+
traceStepCount: 0
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
throw error;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
/**
|
|
1859
|
+
* Execute Python code without tracing (for running tests)
|
|
1860
|
+
*/
|
|
1861
|
+
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
1862
|
+
await this.init();
|
|
1863
|
+
return this.executeWithTimeout(
|
|
1864
|
+
() => this.sendMessage("execute-code", {
|
|
1865
|
+
code,
|
|
1866
|
+
functionName,
|
|
1867
|
+
inputs,
|
|
1868
|
+
executionStyle
|
|
1869
|
+
}, EXECUTION_TIMEOUT_MS + 5e3),
|
|
1870
|
+
EXECUTION_TIMEOUT_MS
|
|
1871
|
+
);
|
|
1872
|
+
}
|
|
1873
|
+
/**
|
|
1874
|
+
* Execute Python code in interview mode - 5 second timeout, generic error messages
|
|
1875
|
+
* Does not reveal which line caused the timeout
|
|
1876
|
+
*/
|
|
1877
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
|
|
1878
|
+
await this.init();
|
|
1879
|
+
try {
|
|
1880
|
+
const result = await this.executeWithTimeout(
|
|
1881
|
+
() => this.sendMessage("execute-code-interview", {
|
|
1882
|
+
code,
|
|
1883
|
+
functionName,
|
|
1884
|
+
inputs,
|
|
1885
|
+
executionStyle
|
|
1886
|
+
}, INTERVIEW_MODE_TIMEOUT_MS + 2e3),
|
|
1887
|
+
INTERVIEW_MODE_TIMEOUT_MS
|
|
1888
|
+
);
|
|
1889
|
+
if (!result.success && result.error) {
|
|
1890
|
+
const normalizedError = result.error.toLowerCase();
|
|
1891
|
+
const isTimeoutOrResourceLimit = normalizedError.includes("timed out") || normalizedError.includes("execution timeout") || normalizedError.includes("infinite loop") || normalizedError.includes("interview_guard_triggered") || normalizedError.includes("memory-limit") || normalizedError.includes("line-limit") || normalizedError.includes("single-line-limit") || normalizedError.includes("recursion-limit");
|
|
1892
|
+
if (isTimeoutOrResourceLimit) {
|
|
1893
|
+
return {
|
|
1894
|
+
success: false,
|
|
1895
|
+
output: null,
|
|
1896
|
+
error: "Time Limit Exceeded",
|
|
1897
|
+
consoleOutput: result.consoleOutput ?? []
|
|
1898
|
+
};
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return result;
|
|
1902
|
+
} catch (error) {
|
|
1903
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1904
|
+
if (errorMsg.includes("timed out") || errorMsg.includes("Execution timeout")) {
|
|
1905
|
+
return {
|
|
1906
|
+
success: false,
|
|
1907
|
+
output: null,
|
|
1908
|
+
error: "Time Limit Exceeded",
|
|
1909
|
+
consoleOutput: []
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
return {
|
|
1913
|
+
success: false,
|
|
1914
|
+
output: null,
|
|
1915
|
+
error: errorMsg,
|
|
1916
|
+
consoleOutput: []
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
/**
|
|
1921
|
+
* Check the status of the worker
|
|
1922
|
+
*/
|
|
1923
|
+
async getStatus() {
|
|
1924
|
+
return this.sendMessage("status");
|
|
1925
|
+
}
|
|
1926
|
+
/**
|
|
1927
|
+
* Analyze Python code using AST (off main thread)
|
|
1928
|
+
* Returns CodeFacts with semantic information about the code
|
|
1929
|
+
*/
|
|
1930
|
+
async analyzeCode(code) {
|
|
1931
|
+
await this.init();
|
|
1932
|
+
return this.sendMessage("analyze-code", { code }, 5e3);
|
|
1933
|
+
}
|
|
1934
|
+
/**
|
|
1935
|
+
* Terminate the worker and clean up resources
|
|
1936
|
+
*/
|
|
1937
|
+
terminate() {
|
|
1938
|
+
this.terminateAndReset();
|
|
1939
|
+
}
|
|
1940
|
+
};
|
|
739
1941
|
export {
|
|
740
1942
|
PYTHON_CLASS_DEFINITIONS,
|
|
741
1943
|
PYTHON_CONVERSION_HELPERS,
|
|
@@ -744,6 +1946,8 @@ export {
|
|
|
744
1946
|
PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
745
1947
|
PYTHON_SERIALIZE_FUNCTION,
|
|
746
1948
|
PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
1949
|
+
PythonWorkerClient as PyodideWorkerClient,
|
|
1950
|
+
PythonWorkerClient,
|
|
747
1951
|
TEMPLATE_PYTHON_CLASS_DEFINITIONS,
|
|
748
1952
|
TEMPLATE_PYTHON_CONVERSION_HELPERS,
|
|
749
1953
|
TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION,
|
|
@@ -751,6 +1955,7 @@ export {
|
|
|
751
1955
|
TEMPLATE_PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
752
1956
|
TEMPLATE_PYTHON_SERIALIZE_FUNCTION,
|
|
753
1957
|
TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
1958
|
+
createPythonRuntimeClient,
|
|
754
1959
|
generateConversionCode,
|
|
755
1960
|
generateInputSetup,
|
|
756
1961
|
generateSolutionScript,
|