@tracecode/harness 0.6.6 → 0.7.0-beta8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -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 +6169 -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 +907 -0
- package/workers/java/java-worker.js +2161 -177
- package/workers/java/src/harness/browser/JavaRewriteLibrary.java +1659 -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 +1414 -0
- package/workers/javascript/javascript-libraries-entry.js +71 -0
- package/workers/javascript/javascript-worker.js +2055 -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.cjs
CHANGED
|
@@ -27,6 +27,8 @@ __export(src_exports, {
|
|
|
27
27
|
PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION: () => PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
28
28
|
PYTHON_SERIALIZE_FUNCTION: () => PYTHON_SERIALIZE_FUNCTION,
|
|
29
29
|
PYTHON_TRACE_SERIALIZE_FUNCTION: () => PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
30
|
+
PyodideWorkerClient: () => PythonWorkerClient,
|
|
31
|
+
PythonWorkerClient: () => PythonWorkerClient,
|
|
30
32
|
TEMPLATE_PYTHON_CLASS_DEFINITIONS: () => TEMPLATE_PYTHON_CLASS_DEFINITIONS,
|
|
31
33
|
TEMPLATE_PYTHON_CONVERSION_HELPERS: () => TEMPLATE_PYTHON_CONVERSION_HELPERS,
|
|
32
34
|
TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION: () => TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION,
|
|
@@ -34,6 +36,7 @@ __export(src_exports, {
|
|
|
34
36
|
TEMPLATE_PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION: () => TEMPLATE_PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
35
37
|
TEMPLATE_PYTHON_SERIALIZE_FUNCTION: () => TEMPLATE_PYTHON_SERIALIZE_FUNCTION,
|
|
36
38
|
TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION: () => TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
39
|
+
createPythonRuntimeClient: () => createPythonRuntimeClient,
|
|
37
40
|
generateConversionCode: () => generateConversionCode,
|
|
38
41
|
generateInputSetup: () => generateInputSetup,
|
|
39
42
|
generateSolutionScript: () => generateSolutionScript,
|
|
@@ -106,12 +109,39 @@ class ListNode:
|
|
|
106
109
|
def __repr__(self):
|
|
107
110
|
return f"ListNode({getattr(self, 'val', getattr(self, 'value', None))})"
|
|
108
111
|
`;
|
|
109
|
-
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";
|
|
112
|
+
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";
|
|
110
113
|
var PYTHON_TRACE_SERIALIZE_FUNCTION = `
|
|
111
114
|
# Sentinel to mark skipped values (functions, etc.) - distinct from None
|
|
112
115
|
_SKIP_SENTINEL = "__TRACECODE_SKIP__"
|
|
113
116
|
_MAX_SERIALIZE_DEPTH = 48
|
|
117
|
+
_MAX_SERIALIZED_ITEMS = 64
|
|
114
118
|
_MAX_OBJECT_FIELDS = 32
|
|
119
|
+
_tracecode_global_object_refs = {}
|
|
120
|
+
_tracecode_next_object_ref_id = 0
|
|
121
|
+
|
|
122
|
+
def _tracecode_ref_id(obj_ref, node_refs):
|
|
123
|
+
global _tracecode_next_object_ref_id
|
|
124
|
+
if obj_ref in node_refs:
|
|
125
|
+
return node_refs[obj_ref]
|
|
126
|
+
if obj_ref in _tracecode_global_object_refs:
|
|
127
|
+
node_id = _tracecode_global_object_refs[obj_ref]
|
|
128
|
+
else:
|
|
129
|
+
node_id = f"ref-{_tracecode_next_object_ref_id}"
|
|
130
|
+
_tracecode_global_object_refs[obj_ref] = node_id
|
|
131
|
+
_tracecode_next_object_ref_id += 1
|
|
132
|
+
node_refs[obj_ref] = node_id
|
|
133
|
+
return node_id
|
|
134
|
+
|
|
135
|
+
def _truncation_marker(total, emitted):
|
|
136
|
+
return {"__truncated__": True, "remaining": max(0, total - emitted)}
|
|
137
|
+
|
|
138
|
+
def _serialize_sequence(values, depth, node_refs):
|
|
139
|
+
values_list = _builtins.list(values)
|
|
140
|
+
emitted = min(len(values_list), _MAX_SERIALIZED_ITEMS)
|
|
141
|
+
result = [_serialize(x, depth + 1, node_refs) for x in values_list[:emitted]]
|
|
142
|
+
if emitted < len(values_list):
|
|
143
|
+
result.append(_truncation_marker(len(values_list), emitted))
|
|
144
|
+
return result
|
|
115
145
|
|
|
116
146
|
def _serialize(obj, depth=0, node_refs=None):
|
|
117
147
|
if node_refs is None:
|
|
@@ -126,25 +156,36 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
126
156
|
return obj
|
|
127
157
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
128
158
|
return "<max depth>"
|
|
129
|
-
elif isinstance(obj, (list, tuple)):
|
|
130
|
-
return
|
|
159
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
160
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
131
161
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
132
|
-
return
|
|
133
|
-
elif isinstance(obj, dict):
|
|
134
|
-
|
|
162
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
163
|
+
elif isinstance(obj, _builtins.dict):
|
|
164
|
+
items = _builtins.list(obj.items())
|
|
165
|
+
emitted = min(len(items), _MAX_SERIALIZED_ITEMS)
|
|
166
|
+
result = {str(k): _serialize(v, depth + 1, node_refs) for k, v in items[:emitted]}
|
|
167
|
+
if emitted < len(items):
|
|
168
|
+
result["__truncated__"] = True
|
|
169
|
+
result["remaining"] = len(items) - emitted
|
|
170
|
+
return result
|
|
135
171
|
elif isinstance(obj, set):
|
|
136
172
|
# Use try/except for sorting to handle heterogeneous sets
|
|
173
|
+
values = _builtins.list(obj)
|
|
174
|
+
emitted = min(len(values), _MAX_SERIALIZED_ITEMS)
|
|
137
175
|
try:
|
|
138
|
-
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in
|
|
176
|
+
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in values[:emitted]])
|
|
139
177
|
except TypeError:
|
|
140
|
-
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in
|
|
141
|
-
|
|
178
|
+
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in values[:emitted]]
|
|
179
|
+
result = {"__type__": "set", "values": sorted_vals}
|
|
180
|
+
if emitted < len(values):
|
|
181
|
+
result["__truncated__"] = True
|
|
182
|
+
result["remaining"] = len(values) - emitted
|
|
183
|
+
return result
|
|
142
184
|
elif isinstance(obj, TreeNode):
|
|
143
|
-
obj_ref = id(obj)
|
|
185
|
+
obj_ref = _builtins.id(obj)
|
|
144
186
|
if obj_ref in node_refs:
|
|
145
187
|
return {"__ref__": node_refs[obj_ref]}
|
|
146
|
-
node_id =
|
|
147
|
-
node_refs[obj_ref] = node_id
|
|
188
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
148
189
|
result = {
|
|
149
190
|
"__type__": "TreeNode",
|
|
150
191
|
"__id__": node_id,
|
|
@@ -156,11 +197,10 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
156
197
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
157
198
|
return result
|
|
158
199
|
elif isinstance(obj, ListNode):
|
|
159
|
-
obj_ref = id(obj)
|
|
200
|
+
obj_ref = _builtins.id(obj)
|
|
160
201
|
if obj_ref in node_refs:
|
|
161
202
|
return {"__ref__": node_refs[obj_ref]}
|
|
162
|
-
node_id =
|
|
163
|
-
node_refs[obj_ref] = node_id
|
|
203
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
164
204
|
result = {
|
|
165
205
|
"__type__": "ListNode",
|
|
166
206
|
"__id__": node_id,
|
|
@@ -168,15 +208,17 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
168
208
|
}
|
|
169
209
|
result["next"] = _serialize(obj.next, depth + 1, node_refs)
|
|
170
210
|
return result
|
|
211
|
+
elif callable(obj):
|
|
212
|
+
# Skip functions entirely - return sentinel
|
|
213
|
+
return _SKIP_SENTINEL
|
|
171
214
|
elif hasattr(obj, '__dict__'):
|
|
172
|
-
obj_ref = id(obj)
|
|
215
|
+
obj_ref = _builtins.id(obj)
|
|
173
216
|
if obj_ref in node_refs:
|
|
174
217
|
return {"__ref__": node_refs[obj_ref]}
|
|
175
|
-
node_id =
|
|
176
|
-
node_refs[obj_ref] = node_id
|
|
218
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
177
219
|
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
178
220
|
result = {
|
|
179
|
-
"__type__":
|
|
221
|
+
"__type__": class_name,
|
|
180
222
|
"__class__": class_name,
|
|
181
223
|
"__id__": node_id,
|
|
182
224
|
}
|
|
@@ -184,26 +226,106 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
184
226
|
raw_fields = getattr(obj, '__dict__', None)
|
|
185
227
|
except Exception:
|
|
186
228
|
raw_fields = None
|
|
187
|
-
if isinstance(raw_fields, dict):
|
|
188
|
-
|
|
229
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
230
|
+
fields = []
|
|
189
231
|
for key, value in raw_fields.items():
|
|
190
232
|
key_str = str(key)
|
|
191
233
|
if key_str.startswith('_'):
|
|
192
234
|
continue
|
|
193
235
|
if callable(value):
|
|
194
236
|
continue
|
|
237
|
+
fields.append((key_str, value))
|
|
238
|
+
for key_str, value in fields[:_MAX_OBJECT_FIELDS]:
|
|
195
239
|
result[key_str] = _serialize(value, depth + 1, node_refs)
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
240
|
+
if len(fields) > _MAX_OBJECT_FIELDS:
|
|
241
|
+
result["__truncated__"] = True
|
|
242
|
+
result["remaining"] = len(fields) - _MAX_OBJECT_FIELDS
|
|
243
|
+
return result
|
|
244
|
+
else:
|
|
245
|
+
repr_str = repr(obj)
|
|
246
|
+
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
247
|
+
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
248
|
+
return _SKIP_SENTINEL
|
|
249
|
+
return repr_str
|
|
250
|
+
|
|
251
|
+
def _serialize_output(obj, depth=0, node_refs=None):
|
|
252
|
+
if node_refs is None:
|
|
253
|
+
node_refs = {}
|
|
254
|
+
if isinstance(obj, (bool, int, str, type(None))):
|
|
255
|
+
return obj
|
|
256
|
+
elif isinstance(obj, float):
|
|
257
|
+
if not math.isfinite(obj):
|
|
258
|
+
if math.isnan(obj):
|
|
259
|
+
return "NaN"
|
|
260
|
+
return "Infinity" if obj > 0 else "-Infinity"
|
|
261
|
+
return obj
|
|
262
|
+
if depth > _MAX_SERIALIZE_DEPTH:
|
|
263
|
+
return "<max depth>"
|
|
264
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
265
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
266
|
+
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
267
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
268
|
+
elif isinstance(obj, _builtins.dict):
|
|
269
|
+
return {str(k): _serialize_output(v, depth + 1, node_refs) for k, v in obj.items()}
|
|
270
|
+
elif isinstance(obj, set):
|
|
271
|
+
try:
|
|
272
|
+
sorted_vals = sorted([_serialize_output(x, depth + 1, node_refs) for x in obj])
|
|
273
|
+
except TypeError:
|
|
274
|
+
sorted_vals = [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
275
|
+
return {"__type__": "set", "values": sorted_vals}
|
|
276
|
+
elif isinstance(obj, TreeNode):
|
|
277
|
+
obj_ref = _builtins.id(obj)
|
|
278
|
+
if obj_ref in node_refs:
|
|
279
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
280
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
281
|
+
result = {
|
|
282
|
+
"__type__": "TreeNode",
|
|
283
|
+
"__id__": node_id,
|
|
284
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
285
|
+
}
|
|
286
|
+
if hasattr(obj, 'left'):
|
|
287
|
+
result["left"] = _serialize_output(obj.left, depth + 1, node_refs)
|
|
288
|
+
if hasattr(obj, 'right'):
|
|
289
|
+
result["right"] = _serialize_output(obj.right, depth + 1, node_refs)
|
|
290
|
+
return result
|
|
291
|
+
elif isinstance(obj, ListNode):
|
|
292
|
+
obj_ref = _builtins.id(obj)
|
|
293
|
+
if obj_ref in node_refs:
|
|
294
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
295
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
296
|
+
result = {
|
|
297
|
+
"__type__": "ListNode",
|
|
298
|
+
"__id__": node_id,
|
|
299
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
300
|
+
}
|
|
301
|
+
result["next"] = _serialize_output(obj.next, depth + 1, node_refs)
|
|
200
302
|
return result
|
|
201
303
|
elif callable(obj):
|
|
202
|
-
# Skip functions entirely - return sentinel
|
|
203
304
|
return _SKIP_SENTINEL
|
|
305
|
+
elif hasattr(obj, '__dict__'):
|
|
306
|
+
obj_ref = _builtins.id(obj)
|
|
307
|
+
if obj_ref in node_refs:
|
|
308
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
309
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
310
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
311
|
+
result = {
|
|
312
|
+
"__type__": class_name,
|
|
313
|
+
"__class__": class_name,
|
|
314
|
+
"__id__": node_id,
|
|
315
|
+
}
|
|
316
|
+
try:
|
|
317
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
318
|
+
except Exception:
|
|
319
|
+
raw_fields = None
|
|
320
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
321
|
+
for key, value in raw_fields.items():
|
|
322
|
+
key_str = str(key)
|
|
323
|
+
if key_str.startswith('_') or callable(value):
|
|
324
|
+
continue
|
|
325
|
+
result[key_str] = _serialize_output(value, depth + 1, node_refs)
|
|
326
|
+
return result
|
|
204
327
|
else:
|
|
205
328
|
repr_str = repr(obj)
|
|
206
|
-
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
207
329
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
208
330
|
return _SKIP_SENTINEL
|
|
209
331
|
return repr_str
|
|
@@ -222,11 +344,11 @@ def _serialize(obj, depth=0):
|
|
|
222
344
|
return obj
|
|
223
345
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
224
346
|
return "<max depth>"
|
|
225
|
-
elif isinstance(obj, (list, tuple)):
|
|
347
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
226
348
|
return [_serialize(x, depth + 1) for x in obj]
|
|
227
349
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
228
350
|
return [_serialize(x, depth + 1) for x in obj]
|
|
229
|
-
elif isinstance(obj, dict):
|
|
351
|
+
elif isinstance(obj, _builtins.dict):
|
|
230
352
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
231
353
|
elif isinstance(obj, set):
|
|
232
354
|
try:
|
|
@@ -246,6 +368,20 @@ def _serialize(obj, depth=0):
|
|
|
246
368
|
return result
|
|
247
369
|
elif callable(obj):
|
|
248
370
|
return None
|
|
371
|
+
elif hasattr(obj, '__dict__'):
|
|
372
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
373
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
374
|
+
try:
|
|
375
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
376
|
+
except Exception:
|
|
377
|
+
raw_fields = None
|
|
378
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
379
|
+
for key, value in raw_fields.items():
|
|
380
|
+
key_str = str(key)
|
|
381
|
+
if key_str.startswith('_') or callable(value):
|
|
382
|
+
continue
|
|
383
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
384
|
+
return result
|
|
249
385
|
else:
|
|
250
386
|
repr_str = repr(obj)
|
|
251
387
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -265,9 +401,9 @@ def _serialize(obj, depth=0, state=None):
|
|
|
265
401
|
if state["nodes"] > 600:
|
|
266
402
|
return "__MAX_NODES__"
|
|
267
403
|
|
|
268
|
-
if isinstance(obj, (list, tuple)):
|
|
404
|
+
if isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
269
405
|
return [_serialize(x, depth + 1, state) for x in obj]
|
|
270
|
-
elif isinstance(obj, dict):
|
|
406
|
+
elif isinstance(obj, _builtins.dict):
|
|
271
407
|
return {str(k): _serialize(v, depth + 1, state) for k, v in obj.items()}
|
|
272
408
|
elif isinstance(obj, set):
|
|
273
409
|
serialized = [_serialize(x, depth + 1, state) for x in obj]
|
|
@@ -277,7 +413,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
277
413
|
pass
|
|
278
414
|
return {"__type__": "set", "values": serialized}
|
|
279
415
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and (hasattr(obj, 'left') or hasattr(obj, 'right')):
|
|
280
|
-
obj_id = id(obj)
|
|
416
|
+
obj_id = _builtins.id(obj)
|
|
281
417
|
if obj_id in state["seen"]:
|
|
282
418
|
return "__CYCLE__"
|
|
283
419
|
state["seen"].add(obj_id)
|
|
@@ -289,7 +425,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
289
425
|
state["seen"].remove(obj_id)
|
|
290
426
|
return result
|
|
291
427
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and hasattr(obj, 'next'):
|
|
292
|
-
obj_id = id(obj)
|
|
428
|
+
obj_id = _builtins.id(obj)
|
|
293
429
|
if obj_id in state["seen"]:
|
|
294
430
|
return "__CYCLE__"
|
|
295
431
|
state["seen"].add(obj_id)
|
|
@@ -306,9 +442,9 @@ def _serialize(obj, depth=0):
|
|
|
306
442
|
return "<max depth>"
|
|
307
443
|
if isinstance(obj, (int, float, str, bool, type(None))):
|
|
308
444
|
return obj
|
|
309
|
-
elif isinstance(obj, (list, tuple)):
|
|
445
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
310
446
|
return [_serialize(x, depth + 1) for x in obj]
|
|
311
|
-
elif isinstance(obj, dict):
|
|
447
|
+
elif isinstance(obj, _builtins.dict):
|
|
312
448
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
313
449
|
elif isinstance(obj, set):
|
|
314
450
|
try:
|
|
@@ -343,11 +479,11 @@ def _serialize(obj, depth=0):
|
|
|
343
479
|
return obj
|
|
344
480
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
345
481
|
return "<max depth>"
|
|
346
|
-
elif isinstance(obj, (list, tuple)):
|
|
482
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
347
483
|
return [_serialize(x, depth + 1) for x in obj]
|
|
348
484
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
349
485
|
return [_serialize(x, depth + 1) for x in obj]
|
|
350
|
-
elif isinstance(obj, dict):
|
|
486
|
+
elif isinstance(obj, _builtins.dict):
|
|
351
487
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
352
488
|
elif isinstance(obj, set):
|
|
353
489
|
try:
|
|
@@ -367,6 +503,20 @@ def _serialize(obj, depth=0):
|
|
|
367
503
|
return result
|
|
368
504
|
elif callable(obj):
|
|
369
505
|
return None
|
|
506
|
+
elif hasattr(obj, '__dict__'):
|
|
507
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
508
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
509
|
+
try:
|
|
510
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
511
|
+
except Exception:
|
|
512
|
+
raw_fields = None
|
|
513
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
514
|
+
for key, value in raw_fields.items():
|
|
515
|
+
key_str = str(key)
|
|
516
|
+
if key_str.startswith('_') or callable(value):
|
|
517
|
+
continue
|
|
518
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
519
|
+
return result
|
|
370
520
|
else:
|
|
371
521
|
repr_str = repr(obj)
|
|
372
522
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -415,7 +565,9 @@ function generateSolutionScript(solutionCode, functionName, inputs) {
|
|
|
415
565
|
const paramList = Object.keys(inputs).map((key) => `${key}=${key}`).join(", ");
|
|
416
566
|
return `
|
|
417
567
|
import json
|
|
568
|
+
import math
|
|
418
569
|
import sys
|
|
570
|
+
import builtins as _builtins
|
|
419
571
|
from typing import *
|
|
420
572
|
|
|
421
573
|
${PYTHON_CLASS_DEFINITIONS}
|
|
@@ -529,7 +681,7 @@ def _ensure_node_value_aliases(node):
|
|
|
529
681
|
def _dict_to_tree(d):
|
|
530
682
|
if d is None:
|
|
531
683
|
return None
|
|
532
|
-
if not isinstance(d, dict):
|
|
684
|
+
if not isinstance(d, _builtins.dict):
|
|
533
685
|
return d
|
|
534
686
|
if 'val' not in d and 'value' not in d:
|
|
535
687
|
return d
|
|
@@ -544,7 +696,7 @@ def _dict_to_list(d, _refs=None):
|
|
|
544
696
|
_refs = {}
|
|
545
697
|
if d is None:
|
|
546
698
|
return None
|
|
547
|
-
if not isinstance(d, dict):
|
|
699
|
+
if not isinstance(d, _builtins.dict):
|
|
548
700
|
return d
|
|
549
701
|
if '__ref__' in d:
|
|
550
702
|
return _refs.get(d.get('__ref__'))
|
|
@@ -553,7 +705,7 @@ def _dict_to_list(d, _refs=None):
|
|
|
553
705
|
node = ListNode(d.get('val', d.get('value', 0)))
|
|
554
706
|
_ensure_node_value_aliases(node)
|
|
555
707
|
node_id = d.get('__id__')
|
|
556
|
-
if isinstance(node_id, str) and node_id:
|
|
708
|
+
if isinstance(node_id, _builtins.str) and node_id:
|
|
557
709
|
_refs[node_id] = node
|
|
558
710
|
node.next = _dict_to_list(d.get('next'), _refs)
|
|
559
711
|
return node
|
|
@@ -562,7 +714,34 @@ var TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION = `
|
|
|
562
714
|
# Sentinel to mark skipped values (functions, etc.) - distinct from None
|
|
563
715
|
_SKIP_SENTINEL = "__TRACECODE_SKIP__"
|
|
564
716
|
_MAX_SERIALIZE_DEPTH = 48
|
|
717
|
+
_MAX_SERIALIZED_ITEMS = 64
|
|
565
718
|
_MAX_OBJECT_FIELDS = 32
|
|
719
|
+
_tracecode_global_object_refs = {}
|
|
720
|
+
_tracecode_next_object_ref_id = 0
|
|
721
|
+
|
|
722
|
+
def _tracecode_ref_id(obj_ref, node_refs):
|
|
723
|
+
global _tracecode_next_object_ref_id
|
|
724
|
+
if obj_ref in node_refs:
|
|
725
|
+
return node_refs[obj_ref]
|
|
726
|
+
if obj_ref in _tracecode_global_object_refs:
|
|
727
|
+
node_id = _tracecode_global_object_refs[obj_ref]
|
|
728
|
+
else:
|
|
729
|
+
node_id = f"ref-{_tracecode_next_object_ref_id}"
|
|
730
|
+
_tracecode_global_object_refs[obj_ref] = node_id
|
|
731
|
+
_tracecode_next_object_ref_id += 1
|
|
732
|
+
node_refs[obj_ref] = node_id
|
|
733
|
+
return node_id
|
|
734
|
+
|
|
735
|
+
def _truncation_marker(total, emitted):
|
|
736
|
+
return {"__truncated__": True, "remaining": max(0, total - emitted)}
|
|
737
|
+
|
|
738
|
+
def _serialize_sequence(values, depth, node_refs):
|
|
739
|
+
values_list = _builtins.list(values)
|
|
740
|
+
emitted = min(len(values_list), _MAX_SERIALIZED_ITEMS)
|
|
741
|
+
result = [_serialize(x, depth + 1, node_refs) for x in values_list[:emitted]]
|
|
742
|
+
if emitted < len(values_list):
|
|
743
|
+
result.append(_truncation_marker(len(values_list), emitted))
|
|
744
|
+
return result
|
|
566
745
|
|
|
567
746
|
def _serialize(obj, depth=0, node_refs=None):
|
|
568
747
|
if node_refs is None:
|
|
@@ -577,25 +756,36 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
577
756
|
return obj
|
|
578
757
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
579
758
|
return "<max depth>"
|
|
580
|
-
elif isinstance(obj, (list, tuple)):
|
|
581
|
-
return
|
|
759
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
760
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
582
761
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
583
|
-
return
|
|
584
|
-
elif isinstance(obj, dict):
|
|
585
|
-
|
|
762
|
+
return _serialize_sequence(obj, depth, node_refs)
|
|
763
|
+
elif isinstance(obj, _builtins.dict):
|
|
764
|
+
items = _builtins.list(obj.items())
|
|
765
|
+
emitted = min(len(items), _MAX_SERIALIZED_ITEMS)
|
|
766
|
+
result = {str(k): _serialize(v, depth + 1, node_refs) for k, v in items[:emitted]}
|
|
767
|
+
if emitted < len(items):
|
|
768
|
+
result["__truncated__"] = True
|
|
769
|
+
result["remaining"] = len(items) - emitted
|
|
770
|
+
return result
|
|
586
771
|
elif isinstance(obj, set):
|
|
587
772
|
# Use try/except for sorting to handle heterogeneous sets
|
|
773
|
+
values = _builtins.list(obj)
|
|
774
|
+
emitted = min(len(values), _MAX_SERIALIZED_ITEMS)
|
|
588
775
|
try:
|
|
589
|
-
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in
|
|
776
|
+
sorted_vals = sorted([_serialize(x, depth + 1, node_refs) for x in values[:emitted]])
|
|
590
777
|
except TypeError:
|
|
591
|
-
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in
|
|
592
|
-
|
|
778
|
+
sorted_vals = [_serialize(x, depth + 1, node_refs) for x in values[:emitted]]
|
|
779
|
+
result = {"__type__": "set", "values": sorted_vals}
|
|
780
|
+
if emitted < len(values):
|
|
781
|
+
result["__truncated__"] = True
|
|
782
|
+
result["remaining"] = len(values) - emitted
|
|
783
|
+
return result
|
|
593
784
|
elif isinstance(obj, TreeNode):
|
|
594
|
-
obj_ref = id(obj)
|
|
785
|
+
obj_ref = _builtins.id(obj)
|
|
595
786
|
if obj_ref in node_refs:
|
|
596
787
|
return {"__ref__": node_refs[obj_ref]}
|
|
597
|
-
node_id =
|
|
598
|
-
node_refs[obj_ref] = node_id
|
|
788
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
599
789
|
result = {
|
|
600
790
|
"__type__": "TreeNode",
|
|
601
791
|
"__id__": node_id,
|
|
@@ -607,11 +797,10 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
607
797
|
result["right"] = _serialize(obj.right, depth + 1, node_refs)
|
|
608
798
|
return result
|
|
609
799
|
elif isinstance(obj, ListNode):
|
|
610
|
-
obj_ref = id(obj)
|
|
800
|
+
obj_ref = _builtins.id(obj)
|
|
611
801
|
if obj_ref in node_refs:
|
|
612
802
|
return {"__ref__": node_refs[obj_ref]}
|
|
613
|
-
node_id =
|
|
614
|
-
node_refs[obj_ref] = node_id
|
|
803
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
615
804
|
result = {
|
|
616
805
|
"__type__": "ListNode",
|
|
617
806
|
"__id__": node_id,
|
|
@@ -619,15 +808,17 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
619
808
|
}
|
|
620
809
|
result["next"] = _serialize(obj.next, depth + 1, node_refs)
|
|
621
810
|
return result
|
|
811
|
+
elif callable(obj):
|
|
812
|
+
# Skip functions entirely - return sentinel
|
|
813
|
+
return _SKIP_SENTINEL
|
|
622
814
|
elif hasattr(obj, '__dict__'):
|
|
623
|
-
obj_ref = id(obj)
|
|
815
|
+
obj_ref = _builtins.id(obj)
|
|
624
816
|
if obj_ref in node_refs:
|
|
625
817
|
return {"__ref__": node_refs[obj_ref]}
|
|
626
|
-
node_id =
|
|
627
|
-
node_refs[obj_ref] = node_id
|
|
818
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
628
819
|
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
629
820
|
result = {
|
|
630
|
-
"__type__":
|
|
821
|
+
"__type__": class_name,
|
|
631
822
|
"__class__": class_name,
|
|
632
823
|
"__id__": node_id,
|
|
633
824
|
}
|
|
@@ -635,26 +826,106 @@ def _serialize(obj, depth=0, node_refs=None):
|
|
|
635
826
|
raw_fields = getattr(obj, '__dict__', None)
|
|
636
827
|
except Exception:
|
|
637
828
|
raw_fields = None
|
|
638
|
-
if isinstance(raw_fields, dict):
|
|
639
|
-
|
|
829
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
830
|
+
fields = []
|
|
640
831
|
for key, value in raw_fields.items():
|
|
641
832
|
key_str = str(key)
|
|
642
833
|
if key_str.startswith('_'):
|
|
643
834
|
continue
|
|
644
835
|
if callable(value):
|
|
645
836
|
continue
|
|
837
|
+
fields.append((key_str, value))
|
|
838
|
+
for key_str, value in fields[:_MAX_OBJECT_FIELDS]:
|
|
646
839
|
result[key_str] = _serialize(value, depth + 1, node_refs)
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
840
|
+
if len(fields) > _MAX_OBJECT_FIELDS:
|
|
841
|
+
result["__truncated__"] = True
|
|
842
|
+
result["remaining"] = len(fields) - _MAX_OBJECT_FIELDS
|
|
843
|
+
return result
|
|
844
|
+
else:
|
|
845
|
+
repr_str = repr(obj)
|
|
846
|
+
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
847
|
+
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
848
|
+
return _SKIP_SENTINEL
|
|
849
|
+
return repr_str
|
|
850
|
+
|
|
851
|
+
def _serialize_output(obj, depth=0, node_refs=None):
|
|
852
|
+
if node_refs is None:
|
|
853
|
+
node_refs = {}
|
|
854
|
+
if isinstance(obj, (bool, int, str, type(None))):
|
|
855
|
+
return obj
|
|
856
|
+
elif isinstance(obj, float):
|
|
857
|
+
if not math.isfinite(obj):
|
|
858
|
+
if math.isnan(obj):
|
|
859
|
+
return "NaN"
|
|
860
|
+
return "Infinity" if obj > 0 else "-Infinity"
|
|
861
|
+
return obj
|
|
862
|
+
if depth > _MAX_SERIALIZE_DEPTH:
|
|
863
|
+
return "<max depth>"
|
|
864
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
865
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
866
|
+
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
867
|
+
return [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
868
|
+
elif isinstance(obj, _builtins.dict):
|
|
869
|
+
return {str(k): _serialize_output(v, depth + 1, node_refs) for k, v in obj.items()}
|
|
870
|
+
elif isinstance(obj, set):
|
|
871
|
+
try:
|
|
872
|
+
sorted_vals = sorted([_serialize_output(x, depth + 1, node_refs) for x in obj])
|
|
873
|
+
except TypeError:
|
|
874
|
+
sorted_vals = [_serialize_output(x, depth + 1, node_refs) for x in obj]
|
|
875
|
+
return {"__type__": "set", "values": sorted_vals}
|
|
876
|
+
elif isinstance(obj, TreeNode):
|
|
877
|
+
obj_ref = _builtins.id(obj)
|
|
878
|
+
if obj_ref in node_refs:
|
|
879
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
880
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
881
|
+
result = {
|
|
882
|
+
"__type__": "TreeNode",
|
|
883
|
+
"__id__": node_id,
|
|
884
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
885
|
+
}
|
|
886
|
+
if hasattr(obj, 'left'):
|
|
887
|
+
result["left"] = _serialize_output(obj.left, depth + 1, node_refs)
|
|
888
|
+
if hasattr(obj, 'right'):
|
|
889
|
+
result["right"] = _serialize_output(obj.right, depth + 1, node_refs)
|
|
890
|
+
return result
|
|
891
|
+
elif isinstance(obj, ListNode):
|
|
892
|
+
obj_ref = _builtins.id(obj)
|
|
893
|
+
if obj_ref in node_refs:
|
|
894
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
895
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
896
|
+
result = {
|
|
897
|
+
"__type__": "ListNode",
|
|
898
|
+
"__id__": node_id,
|
|
899
|
+
"val": _serialize_output(getattr(obj, 'val', getattr(obj, 'value', None)), depth + 1, node_refs),
|
|
900
|
+
}
|
|
901
|
+
result["next"] = _serialize_output(obj.next, depth + 1, node_refs)
|
|
651
902
|
return result
|
|
652
903
|
elif callable(obj):
|
|
653
|
-
# Skip functions entirely - return sentinel
|
|
654
904
|
return _SKIP_SENTINEL
|
|
905
|
+
elif hasattr(obj, '__dict__'):
|
|
906
|
+
obj_ref = _builtins.id(obj)
|
|
907
|
+
if obj_ref in node_refs:
|
|
908
|
+
return {"__ref__": node_refs[obj_ref]}
|
|
909
|
+
node_id = _tracecode_ref_id(obj_ref, node_refs)
|
|
910
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
911
|
+
result = {
|
|
912
|
+
"__type__": class_name,
|
|
913
|
+
"__class__": class_name,
|
|
914
|
+
"__id__": node_id,
|
|
915
|
+
}
|
|
916
|
+
try:
|
|
917
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
918
|
+
except Exception:
|
|
919
|
+
raw_fields = None
|
|
920
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
921
|
+
for key, value in raw_fields.items():
|
|
922
|
+
key_str = str(key)
|
|
923
|
+
if key_str.startswith('_') or callable(value):
|
|
924
|
+
continue
|
|
925
|
+
result[key_str] = _serialize_output(value, depth + 1, node_refs)
|
|
926
|
+
return result
|
|
655
927
|
else:
|
|
656
928
|
repr_str = repr(obj)
|
|
657
|
-
# Filter out function-like representations (e.g., <function foo at 0x...>)
|
|
658
929
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
659
930
|
return _SKIP_SENTINEL
|
|
660
931
|
return repr_str
|
|
@@ -673,11 +944,11 @@ def _serialize(obj, depth=0):
|
|
|
673
944
|
return obj
|
|
674
945
|
if depth > _MAX_SERIALIZE_DEPTH:
|
|
675
946
|
return "<max depth>"
|
|
676
|
-
elif isinstance(obj, (list, tuple)):
|
|
947
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
677
948
|
return [_serialize(x, depth + 1) for x in obj]
|
|
678
949
|
elif getattr(obj, '__class__', None) and getattr(obj.__class__, '__name__', '') == 'deque':
|
|
679
950
|
return [_serialize(x, depth + 1) for x in obj]
|
|
680
|
-
elif isinstance(obj, dict):
|
|
951
|
+
elif isinstance(obj, _builtins.dict):
|
|
681
952
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
682
953
|
elif isinstance(obj, set):
|
|
683
954
|
try:
|
|
@@ -697,6 +968,20 @@ def _serialize(obj, depth=0):
|
|
|
697
968
|
return result
|
|
698
969
|
elif callable(obj):
|
|
699
970
|
return None
|
|
971
|
+
elif hasattr(obj, '__dict__'):
|
|
972
|
+
class_name = getattr(getattr(obj, '__class__', None), '__name__', 'object')
|
|
973
|
+
result = {"__type__": class_name, "__class__": class_name}
|
|
974
|
+
try:
|
|
975
|
+
raw_fields = getattr(obj, '__dict__', None)
|
|
976
|
+
except Exception:
|
|
977
|
+
raw_fields = None
|
|
978
|
+
if isinstance(raw_fields, _builtins.dict):
|
|
979
|
+
for key, value in raw_fields.items():
|
|
980
|
+
key_str = str(key)
|
|
981
|
+
if key_str.startswith('_') or callable(value):
|
|
982
|
+
continue
|
|
983
|
+
result[key_str] = _serialize(value, depth + 1)
|
|
984
|
+
return result
|
|
700
985
|
else:
|
|
701
986
|
repr_str = repr(obj)
|
|
702
987
|
if repr_str.startswith('<') and repr_str.endswith('>'):
|
|
@@ -716,9 +1001,9 @@ def _serialize(obj, depth=0, state=None):
|
|
|
716
1001
|
if state["nodes"] > 600:
|
|
717
1002
|
return "__MAX_NODES__"
|
|
718
1003
|
|
|
719
|
-
if isinstance(obj, (list, tuple)):
|
|
1004
|
+
if isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
720
1005
|
return [_serialize(x, depth + 1, state) for x in obj]
|
|
721
|
-
elif isinstance(obj, dict):
|
|
1006
|
+
elif isinstance(obj, _builtins.dict):
|
|
722
1007
|
return {str(k): _serialize(v, depth + 1, state) for k, v in obj.items()}
|
|
723
1008
|
elif isinstance(obj, set):
|
|
724
1009
|
serialized = [_serialize(x, depth + 1, state) for x in obj]
|
|
@@ -728,7 +1013,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
728
1013
|
pass
|
|
729
1014
|
return {"__type__": "set", "values": serialized}
|
|
730
1015
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and (hasattr(obj, 'left') or hasattr(obj, 'right')):
|
|
731
|
-
obj_id = id(obj)
|
|
1016
|
+
obj_id = _builtins.id(obj)
|
|
732
1017
|
if obj_id in state["seen"]:
|
|
733
1018
|
return "__CYCLE__"
|
|
734
1019
|
state["seen"].add(obj_id)
|
|
@@ -740,7 +1025,7 @@ def _serialize(obj, depth=0, state=None):
|
|
|
740
1025
|
state["seen"].remove(obj_id)
|
|
741
1026
|
return result
|
|
742
1027
|
elif (hasattr(obj, 'val') or hasattr(obj, 'value')) and hasattr(obj, 'next'):
|
|
743
|
-
obj_id = id(obj)
|
|
1028
|
+
obj_id = _builtins.id(obj)
|
|
744
1029
|
if obj_id in state["seen"]:
|
|
745
1030
|
return "__CYCLE__"
|
|
746
1031
|
state["seen"].add(obj_id)
|
|
@@ -757,9 +1042,9 @@ def _serialize(obj, depth=0):
|
|
|
757
1042
|
return "<max depth>"
|
|
758
1043
|
if isinstance(obj, (int, float, str, bool, type(None))):
|
|
759
1044
|
return obj
|
|
760
|
-
elif isinstance(obj, (list, tuple)):
|
|
1045
|
+
elif isinstance(obj, (_builtins.list, _builtins.tuple)):
|
|
761
1046
|
return [_serialize(x, depth + 1) for x in obj]
|
|
762
|
-
elif isinstance(obj, dict):
|
|
1047
|
+
elif isinstance(obj, _builtins.dict):
|
|
763
1048
|
return {str(k): _serialize(v, depth + 1) for k, v in obj.items()}
|
|
764
1049
|
elif isinstance(obj, set):
|
|
765
1050
|
try:
|
|
@@ -781,6 +1066,926 @@ def _serialize(obj, depth=0):
|
|
|
781
1066
|
return repr(obj)
|
|
782
1067
|
`;
|
|
783
1068
|
var TEMPLATE_PYTHON_SERIALIZE_FUNCTION = TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION;
|
|
1069
|
+
|
|
1070
|
+
// packages/harness-browser/src/runtime-capability-guards.ts
|
|
1071
|
+
function isScriptRequest(functionName) {
|
|
1072
|
+
if (functionName == null) return true;
|
|
1073
|
+
return functionName.trim().length === 0;
|
|
1074
|
+
}
|
|
1075
|
+
function executionStyleLabel(executionStyle) {
|
|
1076
|
+
if (executionStyle === "solution-method") return "solution-method";
|
|
1077
|
+
if (executionStyle === "ops-class") return "ops-class";
|
|
1078
|
+
return "function";
|
|
1079
|
+
}
|
|
1080
|
+
function isExecutionStyleSupported(profile, executionStyle) {
|
|
1081
|
+
const styles = profile.capabilities.execution.styles;
|
|
1082
|
+
if (executionStyle === "solution-method") return styles.solutionMethod;
|
|
1083
|
+
if (executionStyle === "ops-class") return styles.opsClass;
|
|
1084
|
+
return styles.function;
|
|
1085
|
+
}
|
|
1086
|
+
function describeRequest(request) {
|
|
1087
|
+
if (request === "trace") return "tracing";
|
|
1088
|
+
if (request === "interview") return "interview execution";
|
|
1089
|
+
return "execution";
|
|
1090
|
+
}
|
|
1091
|
+
function assertRuntimeRequestSupported(profile, options) {
|
|
1092
|
+
if (options.request === "trace" && !profile.capabilities.tracing.supported) {
|
|
1093
|
+
throw new Error(`Runtime "${profile.language}" does not support tracing.`);
|
|
1094
|
+
}
|
|
1095
|
+
if (options.request === "interview" && !profile.capabilities.execution.styles.interviewMode) {
|
|
1096
|
+
throw new Error(`Runtime "${profile.language}" does not support interview execution.`);
|
|
1097
|
+
}
|
|
1098
|
+
if (!isExecutionStyleSupported(profile, options.executionStyle)) {
|
|
1099
|
+
throw new Error(
|
|
1100
|
+
`Runtime "${profile.language}" does not support execution style "${executionStyleLabel(options.executionStyle)}".`
|
|
1101
|
+
);
|
|
1102
|
+
}
|
|
1103
|
+
if (isScriptRequest(options.functionName) && !profile.capabilities.execution.styles.script) {
|
|
1104
|
+
throw new Error(`Runtime "${profile.language}" does not support script mode ${describeRequest(options.request)}.`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
// packages/harness-browser/src/runtime-profiles.ts
|
|
1109
|
+
var PYTHON_RUNTIME_PROFILE = {
|
|
1110
|
+
language: "python",
|
|
1111
|
+
maturity: "stable",
|
|
1112
|
+
capabilities: {
|
|
1113
|
+
execution: {
|
|
1114
|
+
styles: {
|
|
1115
|
+
function: true,
|
|
1116
|
+
solutionMethod: true,
|
|
1117
|
+
opsClass: true,
|
|
1118
|
+
script: true,
|
|
1119
|
+
interviewMode: true
|
|
1120
|
+
},
|
|
1121
|
+
timeouts: {
|
|
1122
|
+
clientTimeouts: true,
|
|
1123
|
+
runtimeTimeouts: true
|
|
1124
|
+
}
|
|
1125
|
+
},
|
|
1126
|
+
tracing: {
|
|
1127
|
+
supported: true,
|
|
1128
|
+
events: {
|
|
1129
|
+
line: true,
|
|
1130
|
+
call: true,
|
|
1131
|
+
return: true,
|
|
1132
|
+
exception: true,
|
|
1133
|
+
stdout: true,
|
|
1134
|
+
timeout: true
|
|
1135
|
+
},
|
|
1136
|
+
controls: {
|
|
1137
|
+
maxTraceSteps: true,
|
|
1138
|
+
maxLineEvents: true,
|
|
1139
|
+
maxSingleLineHits: true,
|
|
1140
|
+
maxStoredEvents: true,
|
|
1141
|
+
minimalTrace: true
|
|
1142
|
+
},
|
|
1143
|
+
fidelity: {
|
|
1144
|
+
preciseLineMapping: true,
|
|
1145
|
+
stableFunctionNames: true,
|
|
1146
|
+
callStack: true
|
|
1147
|
+
}
|
|
1148
|
+
},
|
|
1149
|
+
diagnostics: {
|
|
1150
|
+
compileErrors: false,
|
|
1151
|
+
runtimeErrors: true,
|
|
1152
|
+
mappedErrorLines: true,
|
|
1153
|
+
stackTraces: false
|
|
1154
|
+
},
|
|
1155
|
+
structures: {
|
|
1156
|
+
treeNodeRefs: true,
|
|
1157
|
+
listNodeRefs: true,
|
|
1158
|
+
mapSerialization: true,
|
|
1159
|
+
setSerialization: true,
|
|
1160
|
+
graphSerialization: true,
|
|
1161
|
+
cycleReferences: true
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
var JAVASCRIPT_RUNTIME_PROFILE = {
|
|
1166
|
+
language: "javascript",
|
|
1167
|
+
maturity: "stable",
|
|
1168
|
+
capabilities: {
|
|
1169
|
+
execution: {
|
|
1170
|
+
styles: {
|
|
1171
|
+
function: true,
|
|
1172
|
+
solutionMethod: true,
|
|
1173
|
+
opsClass: true,
|
|
1174
|
+
script: true,
|
|
1175
|
+
interviewMode: true
|
|
1176
|
+
},
|
|
1177
|
+
timeouts: {
|
|
1178
|
+
clientTimeouts: true,
|
|
1179
|
+
runtimeTimeouts: false
|
|
1180
|
+
}
|
|
1181
|
+
},
|
|
1182
|
+
tracing: {
|
|
1183
|
+
supported: true,
|
|
1184
|
+
events: {
|
|
1185
|
+
line: true,
|
|
1186
|
+
call: true,
|
|
1187
|
+
return: true,
|
|
1188
|
+
exception: true,
|
|
1189
|
+
stdout: false,
|
|
1190
|
+
timeout: true
|
|
1191
|
+
},
|
|
1192
|
+
controls: {
|
|
1193
|
+
maxTraceSteps: true,
|
|
1194
|
+
maxLineEvents: true,
|
|
1195
|
+
maxSingleLineHits: true,
|
|
1196
|
+
maxStoredEvents: true,
|
|
1197
|
+
minimalTrace: true
|
|
1198
|
+
},
|
|
1199
|
+
fidelity: {
|
|
1200
|
+
preciseLineMapping: true,
|
|
1201
|
+
stableFunctionNames: true,
|
|
1202
|
+
callStack: true
|
|
1203
|
+
}
|
|
1204
|
+
},
|
|
1205
|
+
diagnostics: {
|
|
1206
|
+
compileErrors: false,
|
|
1207
|
+
runtimeErrors: true,
|
|
1208
|
+
mappedErrorLines: false,
|
|
1209
|
+
stackTraces: false
|
|
1210
|
+
},
|
|
1211
|
+
structures: {
|
|
1212
|
+
treeNodeRefs: true,
|
|
1213
|
+
listNodeRefs: true,
|
|
1214
|
+
mapSerialization: true,
|
|
1215
|
+
setSerialization: true,
|
|
1216
|
+
graphSerialization: true,
|
|
1217
|
+
cycleReferences: true
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
var TYPESCRIPT_RUNTIME_PROFILE = {
|
|
1222
|
+
language: "typescript",
|
|
1223
|
+
maturity: "stable",
|
|
1224
|
+
capabilities: {
|
|
1225
|
+
execution: {
|
|
1226
|
+
styles: {
|
|
1227
|
+
function: true,
|
|
1228
|
+
solutionMethod: true,
|
|
1229
|
+
opsClass: true,
|
|
1230
|
+
script: true,
|
|
1231
|
+
interviewMode: true
|
|
1232
|
+
},
|
|
1233
|
+
timeouts: {
|
|
1234
|
+
clientTimeouts: true,
|
|
1235
|
+
runtimeTimeouts: false
|
|
1236
|
+
}
|
|
1237
|
+
},
|
|
1238
|
+
tracing: {
|
|
1239
|
+
supported: true,
|
|
1240
|
+
events: {
|
|
1241
|
+
line: true,
|
|
1242
|
+
call: true,
|
|
1243
|
+
return: true,
|
|
1244
|
+
exception: true,
|
|
1245
|
+
stdout: false,
|
|
1246
|
+
timeout: true
|
|
1247
|
+
},
|
|
1248
|
+
controls: {
|
|
1249
|
+
maxTraceSteps: true,
|
|
1250
|
+
maxLineEvents: true,
|
|
1251
|
+
maxSingleLineHits: true,
|
|
1252
|
+
maxStoredEvents: true,
|
|
1253
|
+
minimalTrace: true
|
|
1254
|
+
},
|
|
1255
|
+
fidelity: {
|
|
1256
|
+
preciseLineMapping: true,
|
|
1257
|
+
stableFunctionNames: true,
|
|
1258
|
+
callStack: true
|
|
1259
|
+
}
|
|
1260
|
+
},
|
|
1261
|
+
diagnostics: {
|
|
1262
|
+
compileErrors: true,
|
|
1263
|
+
runtimeErrors: true,
|
|
1264
|
+
mappedErrorLines: true,
|
|
1265
|
+
stackTraces: false
|
|
1266
|
+
},
|
|
1267
|
+
structures: {
|
|
1268
|
+
treeNodeRefs: true,
|
|
1269
|
+
listNodeRefs: true,
|
|
1270
|
+
mapSerialization: true,
|
|
1271
|
+
setSerialization: true,
|
|
1272
|
+
graphSerialization: true,
|
|
1273
|
+
cycleReferences: true
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
var JAVA_RUNTIME_PROFILE = {
|
|
1278
|
+
language: "java",
|
|
1279
|
+
maturity: "experimental",
|
|
1280
|
+
capabilities: {
|
|
1281
|
+
execution: {
|
|
1282
|
+
styles: {
|
|
1283
|
+
function: true,
|
|
1284
|
+
solutionMethod: true,
|
|
1285
|
+
opsClass: true,
|
|
1286
|
+
script: true,
|
|
1287
|
+
interviewMode: true
|
|
1288
|
+
},
|
|
1289
|
+
timeouts: {
|
|
1290
|
+
clientTimeouts: true,
|
|
1291
|
+
runtimeTimeouts: true
|
|
1292
|
+
}
|
|
1293
|
+
},
|
|
1294
|
+
tracing: {
|
|
1295
|
+
supported: true,
|
|
1296
|
+
events: {
|
|
1297
|
+
line: true,
|
|
1298
|
+
call: true,
|
|
1299
|
+
return: true,
|
|
1300
|
+
exception: true,
|
|
1301
|
+
stdout: false,
|
|
1302
|
+
timeout: true
|
|
1303
|
+
},
|
|
1304
|
+
controls: {
|
|
1305
|
+
maxTraceSteps: true,
|
|
1306
|
+
maxLineEvents: false,
|
|
1307
|
+
maxSingleLineHits: false,
|
|
1308
|
+
maxStoredEvents: true,
|
|
1309
|
+
minimalTrace: false
|
|
1310
|
+
},
|
|
1311
|
+
fidelity: {
|
|
1312
|
+
preciseLineMapping: true,
|
|
1313
|
+
stableFunctionNames: true,
|
|
1314
|
+
callStack: true
|
|
1315
|
+
}
|
|
1316
|
+
},
|
|
1317
|
+
diagnostics: {
|
|
1318
|
+
compileErrors: true,
|
|
1319
|
+
runtimeErrors: true,
|
|
1320
|
+
mappedErrorLines: false,
|
|
1321
|
+
stackTraces: true
|
|
1322
|
+
},
|
|
1323
|
+
structures: {
|
|
1324
|
+
treeNodeRefs: true,
|
|
1325
|
+
listNodeRefs: true,
|
|
1326
|
+
mapSerialization: true,
|
|
1327
|
+
setSerialization: true,
|
|
1328
|
+
graphSerialization: false,
|
|
1329
|
+
cycleReferences: true
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
notes: [
|
|
1333
|
+
"Java currently supports the browser-local Java 17 lane for function, solution-method, ops-class, and script-style execution.",
|
|
1334
|
+
"Interview-mode Java reuses the same browser-local execution path and remains experimental.",
|
|
1335
|
+
'Script-style Java uses an empty function name with executionStyle="function" and reads the top-level result variable.'
|
|
1336
|
+
]
|
|
1337
|
+
};
|
|
1338
|
+
var CSHARP_RUNTIME_PROFILE = {
|
|
1339
|
+
language: "csharp",
|
|
1340
|
+
maturity: "experimental",
|
|
1341
|
+
capabilities: {
|
|
1342
|
+
execution: {
|
|
1343
|
+
styles: {
|
|
1344
|
+
function: true,
|
|
1345
|
+
solutionMethod: true,
|
|
1346
|
+
opsClass: true,
|
|
1347
|
+
script: true,
|
|
1348
|
+
interviewMode: true
|
|
1349
|
+
},
|
|
1350
|
+
timeouts: {
|
|
1351
|
+
clientTimeouts: true,
|
|
1352
|
+
runtimeTimeouts: true
|
|
1353
|
+
}
|
|
1354
|
+
},
|
|
1355
|
+
tracing: {
|
|
1356
|
+
supported: true,
|
|
1357
|
+
events: {
|
|
1358
|
+
line: true,
|
|
1359
|
+
call: true,
|
|
1360
|
+
return: true,
|
|
1361
|
+
exception: true,
|
|
1362
|
+
stdout: true,
|
|
1363
|
+
timeout: true
|
|
1364
|
+
},
|
|
1365
|
+
controls: {
|
|
1366
|
+
maxTraceSteps: true,
|
|
1367
|
+
maxLineEvents: true,
|
|
1368
|
+
maxSingleLineHits: true,
|
|
1369
|
+
maxStoredEvents: true,
|
|
1370
|
+
minimalTrace: true
|
|
1371
|
+
},
|
|
1372
|
+
fidelity: {
|
|
1373
|
+
preciseLineMapping: true,
|
|
1374
|
+
stableFunctionNames: true,
|
|
1375
|
+
callStack: true
|
|
1376
|
+
}
|
|
1377
|
+
},
|
|
1378
|
+
diagnostics: {
|
|
1379
|
+
compileErrors: true,
|
|
1380
|
+
runtimeErrors: true,
|
|
1381
|
+
mappedErrorLines: true,
|
|
1382
|
+
stackTraces: false
|
|
1383
|
+
},
|
|
1384
|
+
structures: {
|
|
1385
|
+
treeNodeRefs: true,
|
|
1386
|
+
listNodeRefs: true,
|
|
1387
|
+
mapSerialization: true,
|
|
1388
|
+
setSerialization: true,
|
|
1389
|
+
graphSerialization: true,
|
|
1390
|
+
cycleReferences: true
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
notes: [
|
|
1394
|
+
"C# support is browser-local and experimental.",
|
|
1395
|
+
"C# supports named function-style requests where the browser-local host can bind the named method.",
|
|
1396
|
+
'Script-style C# uses an empty function name with executionStyle="function" and reads the top-level result variable.',
|
|
1397
|
+
"Interview-mode C# uses the same browser-local worker execution path with interview timeout normalization.",
|
|
1398
|
+
"The first C# slice supports public class Solution methods.",
|
|
1399
|
+
"ListNode and TreeNode inputs are hydrated from level-order arrays or object-shaped JSON.",
|
|
1400
|
+
"Dictionary, HashSet, List, and array return values serialize through the browser-local worker.",
|
|
1401
|
+
"Tracing currently supports line, call, return, stdout, and simple local variable write events.",
|
|
1402
|
+
"Structural visualization is added after execution and diagnostics are proven."
|
|
1403
|
+
]
|
|
1404
|
+
};
|
|
1405
|
+
var CPP_RUNTIME_PROFILE = {
|
|
1406
|
+
language: "cpp",
|
|
1407
|
+
maturity: "experimental",
|
|
1408
|
+
capabilities: {
|
|
1409
|
+
execution: {
|
|
1410
|
+
styles: {
|
|
1411
|
+
function: true,
|
|
1412
|
+
solutionMethod: true,
|
|
1413
|
+
opsClass: true,
|
|
1414
|
+
script: true,
|
|
1415
|
+
interviewMode: true
|
|
1416
|
+
},
|
|
1417
|
+
timeouts: {
|
|
1418
|
+
clientTimeouts: true,
|
|
1419
|
+
runtimeTimeouts: true
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
tracing: {
|
|
1423
|
+
supported: true,
|
|
1424
|
+
events: {
|
|
1425
|
+
line: true,
|
|
1426
|
+
call: true,
|
|
1427
|
+
return: true,
|
|
1428
|
+
exception: true,
|
|
1429
|
+
stdout: true,
|
|
1430
|
+
timeout: true
|
|
1431
|
+
},
|
|
1432
|
+
controls: {
|
|
1433
|
+
maxTraceSteps: true,
|
|
1434
|
+
maxLineEvents: true,
|
|
1435
|
+
maxSingleLineHits: true,
|
|
1436
|
+
maxStoredEvents: true,
|
|
1437
|
+
minimalTrace: true
|
|
1438
|
+
},
|
|
1439
|
+
fidelity: {
|
|
1440
|
+
preciseLineMapping: true,
|
|
1441
|
+
stableFunctionNames: true,
|
|
1442
|
+
callStack: true
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
diagnostics: {
|
|
1446
|
+
compileErrors: true,
|
|
1447
|
+
runtimeErrors: true,
|
|
1448
|
+
mappedErrorLines: true,
|
|
1449
|
+
stackTraces: false
|
|
1450
|
+
},
|
|
1451
|
+
structures: {
|
|
1452
|
+
treeNodeRefs: true,
|
|
1453
|
+
listNodeRefs: true,
|
|
1454
|
+
mapSerialization: true,
|
|
1455
|
+
setSerialization: true,
|
|
1456
|
+
graphSerialization: true,
|
|
1457
|
+
cycleReferences: true
|
|
1458
|
+
}
|
|
1459
|
+
},
|
|
1460
|
+
notes: [
|
|
1461
|
+
"C++ uses a focused browser-local Clang/LLD/WASI compiler lane with TraceCode-owned execution glue.",
|
|
1462
|
+
"The runtime intentionally does not depend on a generic multi-language container/runtime SDK.",
|
|
1463
|
+
'Script-style C++ uses an empty function name with executionStyle="function"; the snippet must assign a serializable result variable.',
|
|
1464
|
+
"Interview-mode C++ reuses the tracing compiler path with a trace budget and returns a non-trace execution result."
|
|
1465
|
+
]
|
|
1466
|
+
};
|
|
1467
|
+
var LANGUAGE_RUNTIME_PROFILES = {
|
|
1468
|
+
python: PYTHON_RUNTIME_PROFILE,
|
|
1469
|
+
javascript: JAVASCRIPT_RUNTIME_PROFILE,
|
|
1470
|
+
typescript: TYPESCRIPT_RUNTIME_PROFILE,
|
|
1471
|
+
java: JAVA_RUNTIME_PROFILE,
|
|
1472
|
+
csharp: CSHARP_RUNTIME_PROFILE,
|
|
1473
|
+
cpp: CPP_RUNTIME_PROFILE
|
|
1474
|
+
};
|
|
1475
|
+
var SUPPORTED_LANGUAGES = Object.freeze(
|
|
1476
|
+
Object.keys(LANGUAGE_RUNTIME_PROFILES)
|
|
1477
|
+
);
|
|
1478
|
+
function getLanguageRuntimeProfile(language) {
|
|
1479
|
+
const profile = LANGUAGE_RUNTIME_PROFILES[language];
|
|
1480
|
+
if (!profile) {
|
|
1481
|
+
throw new Error(`Runtime profile for language "${language}" is not implemented yet.`);
|
|
1482
|
+
}
|
|
1483
|
+
return profile;
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
// packages/harness-browser/src/python-runtime-client.ts
|
|
1487
|
+
var PythonRuntimeClient = class {
|
|
1488
|
+
constructor(workerClient) {
|
|
1489
|
+
this.workerClient = workerClient;
|
|
1490
|
+
}
|
|
1491
|
+
async init() {
|
|
1492
|
+
return this.workerClient.init();
|
|
1493
|
+
}
|
|
1494
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
1495
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1496
|
+
request: "trace",
|
|
1497
|
+
executionStyle,
|
|
1498
|
+
functionName
|
|
1499
|
+
});
|
|
1500
|
+
return this.workerClient.executeWithTracing(
|
|
1501
|
+
code,
|
|
1502
|
+
functionName,
|
|
1503
|
+
inputs,
|
|
1504
|
+
options,
|
|
1505
|
+
executionStyle
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
1509
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1510
|
+
request: "execute",
|
|
1511
|
+
executionStyle,
|
|
1512
|
+
functionName
|
|
1513
|
+
});
|
|
1514
|
+
return this.workerClient.executeCode(
|
|
1515
|
+
code,
|
|
1516
|
+
functionName,
|
|
1517
|
+
inputs,
|
|
1518
|
+
executionStyle
|
|
1519
|
+
);
|
|
1520
|
+
}
|
|
1521
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
|
|
1522
|
+
assertRuntimeRequestSupported(getLanguageRuntimeProfile("python"), {
|
|
1523
|
+
request: "interview",
|
|
1524
|
+
executionStyle,
|
|
1525
|
+
functionName
|
|
1526
|
+
});
|
|
1527
|
+
return this.workerClient.executeCodeInterviewMode(
|
|
1528
|
+
code,
|
|
1529
|
+
functionName,
|
|
1530
|
+
inputs,
|
|
1531
|
+
executionStyle
|
|
1532
|
+
);
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
function createPythonRuntimeClient(workerClient) {
|
|
1536
|
+
return new PythonRuntimeClient(workerClient);
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
// packages/harness-core/src/runtime-trace.ts
|
|
1540
|
+
var RUNTIME_TRACE_SCHEMA_VERSION = "runtime-trace-2026-04-28";
|
|
1541
|
+
function createEmptyRuntimeTrace(language, options = {}) {
|
|
1542
|
+
return {
|
|
1543
|
+
schemaVersion: RUNTIME_TRACE_SCHEMA_VERSION,
|
|
1544
|
+
language,
|
|
1545
|
+
runId: options.runId ?? `${language}:run`,
|
|
1546
|
+
events: [],
|
|
1547
|
+
lineEventCount: 0,
|
|
1548
|
+
traceStepCount: 0
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
// packages/harness-browser/src/runtime-diagnostics.ts
|
|
1553
|
+
var CONSOLE_METHOD_BY_LEVEL = {
|
|
1554
|
+
debug: "debug",
|
|
1555
|
+
info: "info",
|
|
1556
|
+
warn: "warn",
|
|
1557
|
+
error: "error"
|
|
1558
|
+
};
|
|
1559
|
+
function runtimeDiagnosticEvent(params) {
|
|
1560
|
+
return {
|
|
1561
|
+
schema: "tracecode.runtime-diagnostic.v1",
|
|
1562
|
+
source: "harness",
|
|
1563
|
+
...params
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
function logRuntimeDiagnostic(level, params, options = {}) {
|
|
1567
|
+
if (options.enabled === false && level !== "error") {
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
const method = CONSOLE_METHOD_BY_LEVEL[level] ?? "info";
|
|
1571
|
+
console[method]("[TraceRuntime]", runtimeDiagnosticEvent(params));
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
// packages/harness-browser/src/pyodide-worker-client.ts
|
|
1575
|
+
var EXECUTION_TIMEOUT_MS = 1e4;
|
|
1576
|
+
var INTERVIEW_MODE_TIMEOUT_MS = 5e3;
|
|
1577
|
+
var TRACING_TIMEOUT_MS = 3e4;
|
|
1578
|
+
var INIT_TIMEOUT_MS = 12e4;
|
|
1579
|
+
var MESSAGE_TIMEOUT_MS = 2e4;
|
|
1580
|
+
var WORKER_READY_TIMEOUT_MS = 1e4;
|
|
1581
|
+
var PythonWorkerClient = class {
|
|
1582
|
+
constructor(options) {
|
|
1583
|
+
this.options = options;
|
|
1584
|
+
this.debug = options.debug ?? process.env.NODE_ENV === "development";
|
|
1585
|
+
}
|
|
1586
|
+
worker = null;
|
|
1587
|
+
pendingMessages = /* @__PURE__ */ new Map();
|
|
1588
|
+
messageId = 0;
|
|
1589
|
+
isInitializing = false;
|
|
1590
|
+
initPromise = null;
|
|
1591
|
+
warmupPromise = null;
|
|
1592
|
+
workerReadyPromise = null;
|
|
1593
|
+
workerReadyResolve = null;
|
|
1594
|
+
workerReadyReject = null;
|
|
1595
|
+
debug;
|
|
1596
|
+
/**
|
|
1597
|
+
* Check if Web Workers are supported
|
|
1598
|
+
*/
|
|
1599
|
+
isSupported() {
|
|
1600
|
+
return typeof Worker !== "undefined";
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1603
|
+
* Get or create the worker instance
|
|
1604
|
+
*/
|
|
1605
|
+
getWorker() {
|
|
1606
|
+
if (this.worker) return this.worker;
|
|
1607
|
+
if (!this.isSupported()) {
|
|
1608
|
+
throw new Error("Web Workers are not supported in this environment");
|
|
1609
|
+
}
|
|
1610
|
+
this.workerReadyPromise = new Promise((resolve, reject) => {
|
|
1611
|
+
this.workerReadyResolve = resolve;
|
|
1612
|
+
this.workerReadyReject = (error) => reject(error);
|
|
1613
|
+
});
|
|
1614
|
+
const workerUrl = this.debug && !this.options.workerUrl.includes("?") ? `${this.options.workerUrl}?dev=${Date.now()}` : this.options.workerUrl;
|
|
1615
|
+
this.worker = new Worker(workerUrl);
|
|
1616
|
+
this.worker.onmessage = (event) => {
|
|
1617
|
+
const { id, type, payload } = event.data;
|
|
1618
|
+
if (type === "worker-ready") {
|
|
1619
|
+
this.workerReadyResolve?.();
|
|
1620
|
+
this.workerReadyResolve = null;
|
|
1621
|
+
this.workerReadyReject = null;
|
|
1622
|
+
logRuntimeDiagnostic("info", {
|
|
1623
|
+
component: "PythonWorkerClient",
|
|
1624
|
+
runtime: "python",
|
|
1625
|
+
phase: "worker-ready",
|
|
1626
|
+
message: "Python worker is ready."
|
|
1627
|
+
}, { enabled: this.debug });
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1630
|
+
if (this.debug && !id) {
|
|
1631
|
+
logRuntimeDiagnostic("debug", {
|
|
1632
|
+
component: "PythonWorkerClient",
|
|
1633
|
+
runtime: "python",
|
|
1634
|
+
phase: "worker-event",
|
|
1635
|
+
message: "Python worker emitted an unsolicited event.",
|
|
1636
|
+
detail: { type, payload }
|
|
1637
|
+
}, { enabled: this.debug });
|
|
1638
|
+
}
|
|
1639
|
+
if (id) {
|
|
1640
|
+
const pending = this.pendingMessages.get(id);
|
|
1641
|
+
if (pending) {
|
|
1642
|
+
this.pendingMessages.delete(id);
|
|
1643
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1644
|
+
if (type === "error") {
|
|
1645
|
+
pending.reject(new Error(payload.error));
|
|
1646
|
+
} else {
|
|
1647
|
+
logRuntimeDiagnostic("debug", {
|
|
1648
|
+
component: "PythonWorkerClient",
|
|
1649
|
+
runtime: "python",
|
|
1650
|
+
phase: "worker-response",
|
|
1651
|
+
message: "Python worker response received.",
|
|
1652
|
+
detail: { id, type }
|
|
1653
|
+
}, { enabled: this.debug });
|
|
1654
|
+
pending.resolve(payload);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
};
|
|
1659
|
+
this.worker.onerror = (error) => {
|
|
1660
|
+
logRuntimeDiagnostic("error", {
|
|
1661
|
+
component: "PythonWorkerClient",
|
|
1662
|
+
runtime: "python",
|
|
1663
|
+
phase: "worker-error",
|
|
1664
|
+
message: "Python worker emitted an error event.",
|
|
1665
|
+
detail: {
|
|
1666
|
+
message: error.message,
|
|
1667
|
+
filename: error.filename,
|
|
1668
|
+
lineno: error.lineno,
|
|
1669
|
+
colno: error.colno
|
|
1670
|
+
}
|
|
1671
|
+
});
|
|
1672
|
+
const workerError = new Error("Worker error");
|
|
1673
|
+
this.workerReadyReject?.(workerError);
|
|
1674
|
+
this.workerReadyResolve = null;
|
|
1675
|
+
this.workerReadyReject = null;
|
|
1676
|
+
for (const [id, pending] of this.pendingMessages) {
|
|
1677
|
+
if (pending.timeoutId) {
|
|
1678
|
+
globalThis.clearTimeout(pending.timeoutId);
|
|
1679
|
+
}
|
|
1680
|
+
pending.reject(workerError);
|
|
1681
|
+
this.pendingMessages.delete(id);
|
|
1682
|
+
}
|
|
1683
|
+
};
|
|
1684
|
+
return this.worker;
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* Wait for worker bootstrap signal with timeout.
|
|
1688
|
+
* Guards against deadlocks when the worker script fails before posting "worker-ready".
|
|
1689
|
+
*/
|
|
1690
|
+
async waitForWorkerReady() {
|
|
1691
|
+
const readyPromise = this.workerReadyPromise;
|
|
1692
|
+
if (!readyPromise) return;
|
|
1693
|
+
await new Promise((resolve, reject) => {
|
|
1694
|
+
let settled = false;
|
|
1695
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1696
|
+
if (settled) return;
|
|
1697
|
+
settled = true;
|
|
1698
|
+
const timeoutError = new Error(
|
|
1699
|
+
`Python worker failed to initialize in time (${Math.round(WORKER_READY_TIMEOUT_MS / 1e3)}s)`
|
|
1700
|
+
);
|
|
1701
|
+
logRuntimeDiagnostic("warn", {
|
|
1702
|
+
component: "PythonWorkerClient",
|
|
1703
|
+
runtime: "python",
|
|
1704
|
+
phase: "worker-ready-timeout",
|
|
1705
|
+
message: "Python worker did not send worker-ready before the timeout.",
|
|
1706
|
+
detail: { timeoutMs: WORKER_READY_TIMEOUT_MS }
|
|
1707
|
+
}, { enabled: this.debug });
|
|
1708
|
+
this.terminateAndReset(timeoutError);
|
|
1709
|
+
reject(timeoutError);
|
|
1710
|
+
}, WORKER_READY_TIMEOUT_MS);
|
|
1711
|
+
readyPromise.then(() => {
|
|
1712
|
+
if (settled) return;
|
|
1713
|
+
settled = true;
|
|
1714
|
+
globalThis.clearTimeout(timeoutId);
|
|
1715
|
+
resolve();
|
|
1716
|
+
}).catch((error) => {
|
|
1717
|
+
if (settled) return;
|
|
1718
|
+
settled = true;
|
|
1719
|
+
globalThis.clearTimeout(timeoutId);
|
|
1720
|
+
reject(error instanceof Error ? error : new Error(String(error)));
|
|
1721
|
+
});
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Send a message to the worker and wait for a response
|
|
1726
|
+
*/
|
|
1727
|
+
async sendMessage(type, payload, timeoutMs = MESSAGE_TIMEOUT_MS) {
|
|
1728
|
+
const worker = this.getWorker();
|
|
1729
|
+
await this.waitForWorkerReady();
|
|
1730
|
+
const id = String(++this.messageId);
|
|
1731
|
+
return new Promise((resolve, reject) => {
|
|
1732
|
+
this.pendingMessages.set(id, {
|
|
1733
|
+
resolve,
|
|
1734
|
+
reject
|
|
1735
|
+
});
|
|
1736
|
+
logRuntimeDiagnostic("debug", {
|
|
1737
|
+
component: "PythonWorkerClient",
|
|
1738
|
+
runtime: "python",
|
|
1739
|
+
phase: "worker-request",
|
|
1740
|
+
message: "Sending request to Python worker.",
|
|
1741
|
+
detail: { id, type }
|
|
1742
|
+
}, { enabled: this.debug });
|
|
1743
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1744
|
+
const pending2 = this.pendingMessages.get(id);
|
|
1745
|
+
if (!pending2) return;
|
|
1746
|
+
this.pendingMessages.delete(id);
|
|
1747
|
+
logRuntimeDiagnostic("warn", {
|
|
1748
|
+
component: "PythonWorkerClient",
|
|
1749
|
+
runtime: "python",
|
|
1750
|
+
phase: "worker-request-timeout",
|
|
1751
|
+
message: "Python worker request timed out.",
|
|
1752
|
+
detail: { id, type, timeoutMs }
|
|
1753
|
+
}, { enabled: this.debug });
|
|
1754
|
+
pending2.reject(new Error(`Worker request timed out: ${type}`));
|
|
1755
|
+
}, timeoutMs);
|
|
1756
|
+
const pending = this.pendingMessages.get(id);
|
|
1757
|
+
if (pending) pending.timeoutId = timeoutId;
|
|
1758
|
+
worker.postMessage({ id, type, payload });
|
|
1759
|
+
});
|
|
1760
|
+
}
|
|
1761
|
+
/**
|
|
1762
|
+
* Execute code with a timeout - terminates worker if execution takes too long
|
|
1763
|
+
*/
|
|
1764
|
+
async executeWithTimeout(executor, timeoutMs = EXECUTION_TIMEOUT_MS) {
|
|
1765
|
+
return new Promise((resolve, reject) => {
|
|
1766
|
+
let settled = false;
|
|
1767
|
+
const timeoutId = globalThis.setTimeout(() => {
|
|
1768
|
+
if (settled) return;
|
|
1769
|
+
settled = true;
|
|
1770
|
+
logRuntimeDiagnostic("warn", {
|
|
1771
|
+
component: "PythonWorkerClient",
|
|
1772
|
+
runtime: "python",
|
|
1773
|
+
phase: "execution-timeout",
|
|
1774
|
+
message: "Python execution timed out; terminating worker.",
|
|
1775
|
+
detail: { timeoutMs }
|
|
1776
|
+
}, { enabled: this.debug });
|
|
1777
|
+
this.terminateAndReset();
|
|
1778
|
+
const seconds = Math.round(timeoutMs / 1e3);
|
|
1779
|
+
reject(new Error(`Execution timed out (possible infinite loop). Code execution was stopped after ${seconds} seconds.`));
|
|
1780
|
+
}, timeoutMs);
|
|
1781
|
+
executor().then((result) => {
|
|
1782
|
+
if (settled) return;
|
|
1783
|
+
settled = true;
|
|
1784
|
+
globalThis.clearTimeout(timeoutId);
|
|
1785
|
+
resolve(result);
|
|
1786
|
+
}).catch((error) => {
|
|
1787
|
+
if (settled) return;
|
|
1788
|
+
settled = true;
|
|
1789
|
+
globalThis.clearTimeout(timeoutId);
|
|
1790
|
+
reject(error);
|
|
1791
|
+
});
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
/**
|
|
1795
|
+
* Terminate the worker and reset state for recreation
|
|
1796
|
+
*/
|
|
1797
|
+
terminateAndReset(reason = new Error("Worker was terminated")) {
|
|
1798
|
+
this.workerReadyReject?.(reason);
|
|
1799
|
+
if (this.worker) {
|
|
1800
|
+
this.worker.terminate();
|
|
1801
|
+
this.worker = null;
|
|
1802
|
+
}
|
|
1803
|
+
this.initPromise = null;
|
|
1804
|
+
this.warmupPromise = null;
|
|
1805
|
+
this.isInitializing = false;
|
|
1806
|
+
this.workerReadyPromise = null;
|
|
1807
|
+
this.workerReadyResolve = null;
|
|
1808
|
+
for (const [, pending] of this.pendingMessages) {
|
|
1809
|
+
if (pending.timeoutId) globalThis.clearTimeout(pending.timeoutId);
|
|
1810
|
+
pending.reject(reason);
|
|
1811
|
+
}
|
|
1812
|
+
this.pendingMessages.clear();
|
|
1813
|
+
}
|
|
1814
|
+
/**
|
|
1815
|
+
* Initialize the Python worker. Runtime loading is lazy unless warmup() is called.
|
|
1816
|
+
*/
|
|
1817
|
+
async init() {
|
|
1818
|
+
if (this.initPromise) {
|
|
1819
|
+
return this.initPromise;
|
|
1820
|
+
}
|
|
1821
|
+
if (this.isInitializing) {
|
|
1822
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1823
|
+
return this.init();
|
|
1824
|
+
}
|
|
1825
|
+
this.isInitializing = true;
|
|
1826
|
+
this.initPromise = (async () => {
|
|
1827
|
+
try {
|
|
1828
|
+
return await this.sendMessage("init", void 0, INIT_TIMEOUT_MS);
|
|
1829
|
+
} catch (error) {
|
|
1830
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1831
|
+
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");
|
|
1832
|
+
if (!shouldRetry) {
|
|
1833
|
+
throw error;
|
|
1834
|
+
}
|
|
1835
|
+
logRuntimeDiagnostic("warn", {
|
|
1836
|
+
component: "PythonWorkerClient",
|
|
1837
|
+
runtime: "python",
|
|
1838
|
+
phase: "init-retry",
|
|
1839
|
+
message: "Python worker init failed; resetting worker and retrying once.",
|
|
1840
|
+
detail: { message }
|
|
1841
|
+
}, { enabled: this.debug });
|
|
1842
|
+
this.terminateAndReset();
|
|
1843
|
+
return this.sendMessage("init", void 0, INIT_TIMEOUT_MS);
|
|
1844
|
+
}
|
|
1845
|
+
})();
|
|
1846
|
+
try {
|
|
1847
|
+
const result = await this.initPromise;
|
|
1848
|
+
return result;
|
|
1849
|
+
} catch (error) {
|
|
1850
|
+
this.initPromise = null;
|
|
1851
|
+
throw error;
|
|
1852
|
+
} finally {
|
|
1853
|
+
this.isInitializing = false;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
async warmup() {
|
|
1857
|
+
if (this.warmupPromise) return this.warmupPromise;
|
|
1858
|
+
this.warmupPromise = (async () => {
|
|
1859
|
+
try {
|
|
1860
|
+
await this.init();
|
|
1861
|
+
return await this.sendMessage("warmup", void 0, INIT_TIMEOUT_MS);
|
|
1862
|
+
} catch (error) {
|
|
1863
|
+
this.warmupPromise = null;
|
|
1864
|
+
throw error;
|
|
1865
|
+
}
|
|
1866
|
+
})();
|
|
1867
|
+
return this.warmupPromise;
|
|
1868
|
+
}
|
|
1869
|
+
/**
|
|
1870
|
+
* Execute Python code with tracing for step-by-step visualization
|
|
1871
|
+
* @param options.maxLineEvents - Max line events before abort (for complexity analysis, use higher values)
|
|
1872
|
+
*/
|
|
1873
|
+
async executeWithTracing(code, functionName, inputs, options, executionStyle = "function") {
|
|
1874
|
+
await this.init();
|
|
1875
|
+
try {
|
|
1876
|
+
return await this.executeWithTimeout(
|
|
1877
|
+
() => this.sendMessage("execute-with-tracing", {
|
|
1878
|
+
code,
|
|
1879
|
+
functionName,
|
|
1880
|
+
inputs,
|
|
1881
|
+
executionStyle,
|
|
1882
|
+
options
|
|
1883
|
+
}, TRACING_TIMEOUT_MS + 5e3),
|
|
1884
|
+
// Message timeout slightly longer than execution timeout
|
|
1885
|
+
TRACING_TIMEOUT_MS
|
|
1886
|
+
);
|
|
1887
|
+
} catch (error) {
|
|
1888
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
1889
|
+
const isClientTimeout = errorMessage.includes("Execution timed out") || errorMessage.includes("possible infinite loop");
|
|
1890
|
+
if (isClientTimeout) {
|
|
1891
|
+
return {
|
|
1892
|
+
success: false,
|
|
1893
|
+
error: errorMessage,
|
|
1894
|
+
trace: createEmptyRuntimeTrace("python", { runId: "python:run", file: "solution.py" }),
|
|
1895
|
+
executionTimeMs: TRACING_TIMEOUT_MS,
|
|
1896
|
+
consoleOutput: [],
|
|
1897
|
+
traceLimitExceeded: true,
|
|
1898
|
+
timeoutReason: "client-timeout",
|
|
1899
|
+
lineEventCount: 0,
|
|
1900
|
+
traceStepCount: 0
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
throw error;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
/**
|
|
1907
|
+
* Execute Python code without tracing (for running tests)
|
|
1908
|
+
*/
|
|
1909
|
+
async executeCode(code, functionName, inputs, executionStyle = "function") {
|
|
1910
|
+
await this.init();
|
|
1911
|
+
return this.executeWithTimeout(
|
|
1912
|
+
() => this.sendMessage("execute-code", {
|
|
1913
|
+
code,
|
|
1914
|
+
functionName,
|
|
1915
|
+
inputs,
|
|
1916
|
+
executionStyle
|
|
1917
|
+
}, EXECUTION_TIMEOUT_MS + 5e3),
|
|
1918
|
+
EXECUTION_TIMEOUT_MS
|
|
1919
|
+
);
|
|
1920
|
+
}
|
|
1921
|
+
/**
|
|
1922
|
+
* Execute Python code in interview mode - 5 second timeout, generic error messages
|
|
1923
|
+
* Does not reveal which line caused the timeout
|
|
1924
|
+
*/
|
|
1925
|
+
async executeCodeInterviewMode(code, functionName, inputs, executionStyle = "function") {
|
|
1926
|
+
await this.init();
|
|
1927
|
+
try {
|
|
1928
|
+
const result = await this.executeWithTimeout(
|
|
1929
|
+
() => this.sendMessage("execute-code-interview", {
|
|
1930
|
+
code,
|
|
1931
|
+
functionName,
|
|
1932
|
+
inputs,
|
|
1933
|
+
executionStyle
|
|
1934
|
+
}, INTERVIEW_MODE_TIMEOUT_MS + 2e3),
|
|
1935
|
+
INTERVIEW_MODE_TIMEOUT_MS
|
|
1936
|
+
);
|
|
1937
|
+
if (!result.success && result.error) {
|
|
1938
|
+
const normalizedError = result.error.toLowerCase();
|
|
1939
|
+
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");
|
|
1940
|
+
if (isTimeoutOrResourceLimit) {
|
|
1941
|
+
return {
|
|
1942
|
+
success: false,
|
|
1943
|
+
output: null,
|
|
1944
|
+
error: "Time Limit Exceeded",
|
|
1945
|
+
consoleOutput: result.consoleOutput ?? []
|
|
1946
|
+
};
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
return result;
|
|
1950
|
+
} catch (error) {
|
|
1951
|
+
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
1952
|
+
if (errorMsg.includes("timed out") || errorMsg.includes("Execution timeout")) {
|
|
1953
|
+
return {
|
|
1954
|
+
success: false,
|
|
1955
|
+
output: null,
|
|
1956
|
+
error: "Time Limit Exceeded",
|
|
1957
|
+
consoleOutput: []
|
|
1958
|
+
};
|
|
1959
|
+
}
|
|
1960
|
+
return {
|
|
1961
|
+
success: false,
|
|
1962
|
+
output: null,
|
|
1963
|
+
error: errorMsg,
|
|
1964
|
+
consoleOutput: []
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
}
|
|
1968
|
+
/**
|
|
1969
|
+
* Check the status of the worker
|
|
1970
|
+
*/
|
|
1971
|
+
async getStatus() {
|
|
1972
|
+
return this.sendMessage("status");
|
|
1973
|
+
}
|
|
1974
|
+
/**
|
|
1975
|
+
* Analyze Python code using AST (off main thread)
|
|
1976
|
+
* Returns CodeFacts with semantic information about the code
|
|
1977
|
+
*/
|
|
1978
|
+
async analyzeCode(code) {
|
|
1979
|
+
await this.init();
|
|
1980
|
+
return this.sendMessage("analyze-code", { code }, 5e3);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Terminate the worker and clean up resources
|
|
1984
|
+
*/
|
|
1985
|
+
terminate() {
|
|
1986
|
+
this.terminateAndReset();
|
|
1987
|
+
}
|
|
1988
|
+
};
|
|
784
1989
|
// Annotate the CommonJS export names for ESM import in node:
|
|
785
1990
|
0 && (module.exports = {
|
|
786
1991
|
PYTHON_CLASS_DEFINITIONS,
|
|
@@ -790,6 +1995,8 @@ var TEMPLATE_PYTHON_SERIALIZE_FUNCTION = TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCT
|
|
|
790
1995
|
PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
791
1996
|
PYTHON_SERIALIZE_FUNCTION,
|
|
792
1997
|
PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
1998
|
+
PyodideWorkerClient,
|
|
1999
|
+
PythonWorkerClient,
|
|
793
2000
|
TEMPLATE_PYTHON_CLASS_DEFINITIONS,
|
|
794
2001
|
TEMPLATE_PYTHON_CONVERSION_HELPERS,
|
|
795
2002
|
TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCTION,
|
|
@@ -797,6 +2004,7 @@ var TEMPLATE_PYTHON_SERIALIZE_FUNCTION = TEMPLATE_PYTHON_EXECUTE_SERIALIZE_FUNCT
|
|
|
797
2004
|
TEMPLATE_PYTHON_PRACTICE_MATERIALIZE_SERIALIZE_FUNCTION,
|
|
798
2005
|
TEMPLATE_PYTHON_SERIALIZE_FUNCTION,
|
|
799
2006
|
TEMPLATE_PYTHON_TRACE_SERIALIZE_FUNCTION,
|
|
2007
|
+
createPythonRuntimeClient,
|
|
800
2008
|
generateConversionCode,
|
|
801
2009
|
generateInputSetup,
|
|
802
2010
|
generateSolutionScript,
|