pi-usereq 0.4.0
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/.g.conf +20 -0
- package/.github/workflows/release-npm.yml +131 -0
- package/.gitignore +270 -0
- package/CHANGELOG.md +221 -0
- package/LICENSE +674 -0
- package/README.md +260 -0
- package/TODO.md +20 -0
- package/docs/pi.dev/agent-document-manifest.json +6399 -0
- package/docs/pi.dev/coding-agent-docs/compaction.md +394 -0
- package/docs/pi.dev/coding-agent-docs/custom-provider.md +596 -0
- package/docs/pi.dev/coding-agent-docs/development.md +71 -0
- package/docs/pi.dev/coding-agent-docs/extensions.md +2262 -0
- package/docs/pi.dev/coding-agent-docs/images/doom-extension.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/exy.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/interactive-mode.png +0 -0
- package/docs/pi.dev/coding-agent-docs/images/tree-view.png +0 -0
- package/docs/pi.dev/coding-agent-docs/json.md +82 -0
- package/docs/pi.dev/coding-agent-docs/keybindings.md +175 -0
- package/docs/pi.dev/coding-agent-docs/models.md +392 -0
- package/docs/pi.dev/coding-agent-docs/packages.md +218 -0
- package/docs/pi.dev/coding-agent-docs/prompt-templates.md +67 -0
- package/docs/pi.dev/coding-agent-docs/providers.md +195 -0
- package/docs/pi.dev/coding-agent-docs/rpc.md +1377 -0
- package/docs/pi.dev/coding-agent-docs/sdk.md +1124 -0
- package/docs/pi.dev/coding-agent-docs/session.md +412 -0
- package/docs/pi.dev/coding-agent-docs/settings.md +247 -0
- package/docs/pi.dev/coding-agent-docs/shell-aliases.md +13 -0
- package/docs/pi.dev/coding-agent-docs/skills.md +232 -0
- package/docs/pi.dev/coding-agent-docs/terminal-setup.md +106 -0
- package/docs/pi.dev/coding-agent-docs/termux.md +127 -0
- package/docs/pi.dev/coding-agent-docs/themes.md +295 -0
- package/docs/pi.dev/coding-agent-docs/tmux.md +61 -0
- package/docs/pi.dev/coding-agent-docs/tree.md +231 -0
- package/docs/pi.dev/coding-agent-docs/tui.md +887 -0
- package/docs/pi.dev/coding-agent-docs/windows.md +17 -0
- package/docs/pi.dev/mom-docs/artifacts-server.md +475 -0
- package/docs/pi.dev/mom-docs/events.md +307 -0
- package/docs/pi.dev/mom-docs/new.md +970 -0
- package/docs/pi.dev/mom-docs/sandbox.md +153 -0
- package/docs/pi.dev/mom-docs/slack-bot-minimal-guide.md +399 -0
- package/docs/pi.dev/mom-docs/v86.md +319 -0
- package/docs/pi.dev/pods-docs/gml-4.5.md +189 -0
- package/docs/pi.dev/pods-docs/gpt-oss.md +233 -0
- package/docs/pi.dev/pods-docs/implementation-plan.md +183 -0
- package/docs/pi.dev/pods-docs/kimi-k2.md +197 -0
- package/docs/pi.dev/pods-docs/models.md +116 -0
- package/docs/pi.dev/pods-docs/plan.md +166 -0
- package/docs/pi.dev/pods-docs/qwen3-coder.md +132 -0
- package/images/flowchart-bw.png +0 -0
- package/images/flowchart-bw.svg +102 -0
- package/images/flowchart.md +100 -0
- package/images/flowchart.png +0 -0
- package/images/flowchart.svg +3 -0
- package/package.json +46 -0
- package/req/docs/REFERENCES.md +4554 -0
- package/req/docs/REQUIREMENTS.md +475 -0
- package/req/docs/WORKFLOW.md +1059 -0
- package/scripts/debug-extension.ts +497 -0
- package/scripts/lib/extension-debug-harness.ts +450 -0
- package/scripts/lib/recording-extension-api.ts +786 -0
- package/scripts/lib/sdk-smoke.ts +503 -0
- package/scripts/pi-usereq-debug.sh +330 -0
- package/scripts/tool-args-to-params.ts +208 -0
- package/src/cli.ts +349 -0
- package/src/core/agent-tool-json.ts +621 -0
- package/src/core/compress-files.ts +72 -0
- package/src/core/compress-payload.ts +648 -0
- package/src/core/compress.ts +464 -0
- package/src/core/config.ts +272 -0
- package/src/core/doxygen-parser.ts +318 -0
- package/src/core/errors.ts +31 -0
- package/src/core/extension-status.ts +660 -0
- package/src/core/find-constructs.ts +319 -0
- package/src/core/find-payload.ts +915 -0
- package/src/core/generate-markdown.ts +120 -0
- package/src/core/path-context.ts +196 -0
- package/src/core/pi-notify.ts +430 -0
- package/src/core/pi-usereq-tools.ts +140 -0
- package/src/core/prompts.ts +184 -0
- package/src/core/reference-payload.ts +818 -0
- package/src/core/resources.ts +63 -0
- package/src/core/runtime-project-paths.ts +99 -0
- package/src/core/settings-menu.ts +233 -0
- package/src/core/source-analyzer.ts +1721 -0
- package/src/core/static-check.ts +674 -0
- package/src/core/token-counter.ts +729 -0
- package/src/core/tool-runner.ts +717 -0
- package/src/core/utils.ts +185 -0
- package/src/index.ts +2209 -0
- package/src/resources/guidelines/Google_C++_Style_Guide.md +3711 -0
- package/src/resources/guidelines/Google_Python_Style_Guide.md +3709 -0
- package/src/resources/prompts/analyze.md +130 -0
- package/src/resources/prompts/change.md +227 -0
- package/src/resources/prompts/check.md +139 -0
- package/src/resources/prompts/cover.md +219 -0
- package/src/resources/prompts/create.md +104 -0
- package/src/resources/prompts/fix.md +221 -0
- package/src/resources/prompts/flowchart.md +220 -0
- package/src/resources/prompts/implement.md +163 -0
- package/src/resources/prompts/new.md +226 -0
- package/src/resources/prompts/readme.md +182 -0
- package/src/resources/prompts/recreate.md +213 -0
- package/src/resources/prompts/refactor.md +213 -0
- package/src/resources/prompts/references.md +100 -0
- package/src/resources/prompts/renumber.md +119 -0
- package/src/resources/prompts/workflow.md +202 -0
- package/src/resources/prompts/write.md +99 -0
- package/src/resources/sounds/Machine-alert-beep-sound-effect.mp3 +0 -0
- package/src/resources/sounds/Soft-high-tech-notification-sound-effect.mp3 +0 -0
- package/src/resources/templates/Document_Source_Code_in_Doxygen_Style.md +130 -0
- package/src/resources/templates/HDT_Test_Authoring_Guide.md +318 -0
- package/src/resources/templates/Requirements_Template.md +78 -0
- package/tests/attended-results-scenarios.ts +758 -0
- package/tests/attended-results.test.ts +39 -0
- package/tests/cli-command-option-parity.test.ts +815 -0
- package/tests/debug-extension-harness.test.ts +463 -0
- package/tests/extension-registration.test.ts +2006 -0
- package/tests/fixtures/fixture_c.c +361 -0
- package/tests/fixtures/fixture_cpp.cpp +407 -0
- package/tests/fixtures/fixture_csharp.cs +411 -0
- package/tests/fixtures/fixture_elixir.ex +409 -0
- package/tests/fixtures/fixture_go.go +341 -0
- package/tests/fixtures/fixture_haskell.hs +250 -0
- package/tests/fixtures/fixture_java.java +430 -0
- package/tests/fixtures/fixture_javascript.js +383 -0
- package/tests/fixtures/fixture_kotlin.kt +451 -0
- package/tests/fixtures/fixture_lua.lua +276 -0
- package/tests/fixtures/fixture_perl.pl +310 -0
- package/tests/fixtures/fixture_php.php +433 -0
- package/tests/fixtures/fixture_python.py +502 -0
- package/tests/fixtures/fixture_ruby.rb +345 -0
- package/tests/fixtures/fixture_rust.rs +380 -0
- package/tests/fixtures/fixture_scala.scala +398 -0
- package/tests/fixtures/fixture_shell.sh +276 -0
- package/tests/fixtures/fixture_swift.swift +397 -0
- package/tests/fixtures/fixture_typescript.ts +434 -0
- package/tests/fixtures/fixture_zig.zig +295 -0
- package/tests/fixtures_attended_results/project/compress-line-numbers.json +5 -0
- package/tests/fixtures_attended_results/project/compress.json +5 -0
- package/tests/fixtures_attended_results/project/enable-static-check-invalid-command.json +5 -0
- package/tests/fixtures_attended_results/project/enable-static-check-valid.json +5 -0
- package/tests/fixtures_attended_results/project/files-static-check.json +5 -0
- package/tests/fixtures_attended_results/project/find-line-numbers.json +5 -0
- package/tests/fixtures_attended_results/project/find.json +5 -0
- package/tests/fixtures_attended_results/project/get-base-path.json +5 -0
- package/tests/fixtures_attended_results/project/git-check-clean.json +5 -0
- package/tests/fixtures_attended_results/project/git-check-dirty.json +5 -0
- package/tests/fixtures_attended_results/project/git-path.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-create-invalid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-create-valid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-delete-nonexistent.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-delete-valid.json +5 -0
- package/tests/fixtures_attended_results/project/git-wt-name.json +5 -0
- package/tests/fixtures_attended_results/project/references.json +5 -0
- package/tests/fixtures_attended_results/project/static-check.json +5 -0
- package/tests/fixtures_attended_results/project/tokens.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-compress-line-numbers/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-find-line-numbers/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-references/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/files-tokens/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-command/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-dummy/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-pylance/fixture_zig.zig.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_c.c.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_cpp.cpp.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_csharp.cs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_elixir.ex.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_go.go.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_haskell.hs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_java.java.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_javascript.js.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_kotlin.kt.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_lua.lua.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_perl.pl.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_php.php.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_python.py.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_ruby.rb.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_rust.rs.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_scala.scala.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_shell.sh.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_swift.swift.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_typescript.ts.json +5 -0
- package/tests/fixtures_attended_results/standalone/test-static-check-ruff/fixture_zig.zig.json +5 -0
- package/tests/helpers.ts +204 -0
- package/tests/oracle-project.test.ts +63 -0
- package/tests/oracle-standalone.test.ts +48 -0
- package/tests/prompt-rendering.test.ts +66 -0
- package/tests/release-workflow.test.ts +133 -0
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
# v86 Sandbox Evaluation
|
|
2
|
+
|
|
3
|
+
v86 is an x86 emulator written in JavaScript/WebAssembly that can run Linux in the browser or Node.js. This document details our evaluation for using it as a sandboxed execution environment.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
- **What it is**: x86 PC emulator (32-bit, Pentium 4 level)
|
|
8
|
+
- **How it works**: Translates machine code to WebAssembly at runtime
|
|
9
|
+
- **Guest OS**: Alpine Linux 3.21 (32-bit x86)
|
|
10
|
+
- **Available packages**: Node.js 22, Python 3.12, git, curl, etc. (full Alpine repos)
|
|
11
|
+
|
|
12
|
+
## Key Findings
|
|
13
|
+
|
|
14
|
+
### What Works
|
|
15
|
+
|
|
16
|
+
| Feature | Status | Notes |
|
|
17
|
+
|---------|--------|-------|
|
|
18
|
+
| Outbound TCP | ✅ | HTTP, HTTPS, TLS all work |
|
|
19
|
+
| Outbound UDP | ✅ | DNS queries work |
|
|
20
|
+
| WebSocket client | ✅ | Can connect to external WebSocket servers |
|
|
21
|
+
| File I/O | ✅ | 9p filesystem for host<->guest file exchange |
|
|
22
|
+
| State save/restore | ✅ | ~80-100MB state files, instant resume |
|
|
23
|
+
| Package persistence | ✅ | Installed packages persist in saved state |
|
|
24
|
+
| npm install | ✅ | Works (outbound HTTPS) |
|
|
25
|
+
| git clone | ✅ | Works (outbound HTTPS) |
|
|
26
|
+
|
|
27
|
+
### What Doesn't Work
|
|
28
|
+
|
|
29
|
+
| Feature | Status | Notes |
|
|
30
|
+
|---------|--------|-------|
|
|
31
|
+
| Inbound connections | ❌ | VM is behind NAT (10.0.2.x), needs port forwarding |
|
|
32
|
+
| ICMP ping | ❌ | Userspace network stack limitation |
|
|
33
|
+
| 64-bit | ❌ | v86 only emulates 32-bit x86 |
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
┌─────────────────────────────────────────────────────────┐
|
|
39
|
+
│ Host (Node.js) │
|
|
40
|
+
│ │
|
|
41
|
+
│ ┌──────────────┐ ┌─────────────────────────────┐ │
|
|
42
|
+
│ │ rootlessRelay│◄───►│ v86 │ │
|
|
43
|
+
│ │ (WebSocket) │ │ ┌─────────────────────┐ │ │
|
|
44
|
+
│ │ │ │ │ Alpine Linux │ │ │
|
|
45
|
+
│ │ - DHCP │ │ │ - Node.js 22 │ │ │
|
|
46
|
+
│ │ - DNS proxy │ │ │ - Python 3.12 │ │ │
|
|
47
|
+
│ │ - NAT │ │ │ - etc. │ │ │
|
|
48
|
+
│ └──────────────┘ │ └─────────────────────┘ │ │
|
|
49
|
+
│ │ │ │ │ │
|
|
50
|
+
│ │ │ 9p filesystem │ │
|
|
51
|
+
│ ▼ │ │ │ │
|
|
52
|
+
│ Internet │ ▼ │ │
|
|
53
|
+
│ │ Host filesystem │ │
|
|
54
|
+
│ └─────────────────────────────┘ │
|
|
55
|
+
└─────────────────────────────────────────────────────────┘
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Components & Sizes
|
|
59
|
+
|
|
60
|
+
| Component | Size | Purpose |
|
|
61
|
+
|-----------|------|---------|
|
|
62
|
+
| v86.wasm | ~2 MB | x86 emulator |
|
|
63
|
+
| libv86.mjs | ~330 KB | JavaScript runtime |
|
|
64
|
+
| seabios.bin | ~128 KB | BIOS |
|
|
65
|
+
| vgabios.bin | ~36 KB | VGA BIOS |
|
|
66
|
+
| Alpine rootfs | ~57 MB | Compressed filesystem (loaded on-demand) |
|
|
67
|
+
| alpine-fs.json | ~160 KB | Filesystem index |
|
|
68
|
+
| rootlessRelay | ~75 KB | Network relay |
|
|
69
|
+
| **Total** | **~60 MB** | Without saved state |
|
|
70
|
+
| Saved state | ~80-100 MB | Optional, for instant resume |
|
|
71
|
+
|
|
72
|
+
## Installation
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm install v86 ws
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Building the Alpine Image
|
|
79
|
+
|
|
80
|
+
v86 provides Docker tooling to build the Alpine image:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/copy/v86.git
|
|
84
|
+
cd v86/tools/docker/alpine
|
|
85
|
+
|
|
86
|
+
# Edit Dockerfile to add packages:
|
|
87
|
+
# ENV ADDPKGS=nodejs,npm,python3,git,curl
|
|
88
|
+
|
|
89
|
+
./build.sh
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
This creates:
|
|
93
|
+
- `images/alpine-fs.json` - Filesystem index
|
|
94
|
+
- `images/alpine-rootfs-flat/` - Compressed file chunks
|
|
95
|
+
|
|
96
|
+
## Network Relay Setup
|
|
97
|
+
|
|
98
|
+
v86 needs a network relay for TCP/UDP connectivity. We use rootlessRelay:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
git clone https://github.com/obegron/rootlessRelay.git
|
|
102
|
+
cd rootlessRelay
|
|
103
|
+
npm install
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Required Patches for Host Access
|
|
107
|
+
|
|
108
|
+
To allow the VM to connect to host services via the gateway IP (10.0.2.2), apply these patches to `relay.js`:
|
|
109
|
+
|
|
110
|
+
**Patch 1: Disable reverse TCP handling for gateway (line ~684)**
|
|
111
|
+
```javascript
|
|
112
|
+
// Change:
|
|
113
|
+
if (protocol === 6 && dstIP === GATEWAY_IP) {
|
|
114
|
+
this.handleReverseTCP(ipPacket);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// To:
|
|
119
|
+
if (false && protocol === 6 && dstIP === GATEWAY_IP) { // PATCHED
|
|
120
|
+
this.handleReverseTCP(ipPacket);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Patch 2: Redirect gateway TCP to localhost (line ~792)**
|
|
126
|
+
```javascript
|
|
127
|
+
// Change:
|
|
128
|
+
const socket = net.connect(dstPort, dstIP, () => {
|
|
129
|
+
|
|
130
|
+
// To:
|
|
131
|
+
const actualDstIP = dstIP === GATEWAY_IP ? "127.0.0.1" : dstIP;
|
|
132
|
+
const socket = net.connect(dstPort, actualDstIP, () => {
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Patch 3: Redirect gateway UDP to localhost (lines ~1431 and ~1449)**
|
|
136
|
+
```javascript
|
|
137
|
+
// Change:
|
|
138
|
+
this.udpSocket.send(payload, dstPort, dstIP, (err) => {
|
|
139
|
+
|
|
140
|
+
// To:
|
|
141
|
+
const actualUdpDstIP = dstIP === GATEWAY_IP ? "127.0.0.1" : dstIP;
|
|
142
|
+
this.udpSocket.send(payload, dstPort, actualUdpDstIP, (err) => {
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Starting the Relay
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
ENABLE_WSS=false LOG_LEVEL=1 node relay.js
|
|
149
|
+
# Listens on ws://127.0.0.1:8086/
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Basic Usage
|
|
153
|
+
|
|
154
|
+
```javascript
|
|
155
|
+
import { V86 } from "v86";
|
|
156
|
+
import path from "node:path";
|
|
157
|
+
|
|
158
|
+
const emulator = new V86({
|
|
159
|
+
wasm_path: path.join(__dirname, "node_modules/v86/build/v86.wasm"),
|
|
160
|
+
bios: { url: path.join(__dirname, "bios/seabios.bin") },
|
|
161
|
+
vga_bios: { url: path.join(__dirname, "bios/vgabios.bin") },
|
|
162
|
+
filesystem: {
|
|
163
|
+
basefs: path.join(__dirname, "images/alpine-fs.json"),
|
|
164
|
+
baseurl: path.join(__dirname, "images/alpine-rootfs-flat/"),
|
|
165
|
+
},
|
|
166
|
+
autostart: true,
|
|
167
|
+
memory_size: 512 * 1024 * 1024,
|
|
168
|
+
bzimage_initrd_from_filesystem: true,
|
|
169
|
+
cmdline: "rw root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose modules=virtio_pci tsc=reliable console=ttyS0",
|
|
170
|
+
net_device: {
|
|
171
|
+
type: "virtio",
|
|
172
|
+
relay_url: "ws://127.0.0.1:8086/",
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Capture output
|
|
177
|
+
emulator.add_listener("serial0-output-byte", (byte) => {
|
|
178
|
+
process.stdout.write(String.fromCharCode(byte));
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
// Send commands
|
|
182
|
+
emulator.serial0_send("echo hello\n");
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Communication Methods
|
|
186
|
+
|
|
187
|
+
### 1. Serial Console (stdin/stdout)
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
// Send command
|
|
191
|
+
emulator.serial0_send("ls -la\n");
|
|
192
|
+
|
|
193
|
+
// Receive output
|
|
194
|
+
let output = "";
|
|
195
|
+
emulator.add_listener("serial0-output-byte", (byte) => {
|
|
196
|
+
output += String.fromCharCode(byte);
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### 2. 9p Filesystem (file I/O)
|
|
201
|
+
|
|
202
|
+
```javascript
|
|
203
|
+
// Write file to VM
|
|
204
|
+
const data = new TextEncoder().encode("#!/bin/sh\necho hello\n");
|
|
205
|
+
await emulator.create_file("/tmp/script.sh", data);
|
|
206
|
+
|
|
207
|
+
// Read file from VM
|
|
208
|
+
const result = await emulator.read_file("/tmp/output.txt");
|
|
209
|
+
console.log(new TextDecoder().decode(result));
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### 3. Network (TCP to host services)
|
|
213
|
+
|
|
214
|
+
From inside the VM, connect to `10.0.2.2:PORT` to reach `localhost:PORT` on the host (requires patched relay).
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# Inside VM
|
|
218
|
+
wget http://10.0.2.2:8080/ # Connects to host's localhost:8080
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## State Save/Restore
|
|
222
|
+
|
|
223
|
+
```javascript
|
|
224
|
+
// Save state (includes all installed packages, files, etc.)
|
|
225
|
+
const state = await emulator.save_state();
|
|
226
|
+
fs.writeFileSync("vm-state.bin", Buffer.from(state));
|
|
227
|
+
|
|
228
|
+
// Restore state (instant resume, ~2 seconds)
|
|
229
|
+
const stateBuffer = fs.readFileSync("vm-state.bin");
|
|
230
|
+
await emulator.restore_state(stateBuffer.buffer);
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Network Setup Inside VM
|
|
234
|
+
|
|
235
|
+
After boot, run these commands to enable networking:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
modprobe virtio-net
|
|
239
|
+
ip link set eth0 up
|
|
240
|
+
udhcpc -i eth0
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
Or as a one-liner:
|
|
244
|
+
```bash
|
|
245
|
+
modprobe virtio-net && ip link set eth0 up && udhcpc -i eth0
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
The VM will get IP `10.0.2.15` (or similar) via DHCP from the relay.
|
|
249
|
+
|
|
250
|
+
## Performance
|
|
251
|
+
|
|
252
|
+
| Metric | Value |
|
|
253
|
+
|--------|-------|
|
|
254
|
+
| Cold boot | ~20-25 seconds |
|
|
255
|
+
| State restore | ~2-3 seconds |
|
|
256
|
+
| Memory usage | ~512 MB (configurable) |
|
|
257
|
+
|
|
258
|
+
## Typical Workflow for Mom
|
|
259
|
+
|
|
260
|
+
1. **First run**:
|
|
261
|
+
- Start rootlessRelay
|
|
262
|
+
- Boot v86 with Alpine (~25s)
|
|
263
|
+
- Setup network
|
|
264
|
+
- Install needed packages (`apk add nodejs npm python3 git`)
|
|
265
|
+
- Save state
|
|
266
|
+
|
|
267
|
+
2. **Subsequent runs**:
|
|
268
|
+
- Start rootlessRelay
|
|
269
|
+
- Restore saved state (~2s)
|
|
270
|
+
- Ready to execute commands
|
|
271
|
+
|
|
272
|
+
3. **Command execution**:
|
|
273
|
+
- Send commands via `serial0_send()`
|
|
274
|
+
- Capture output via `serial0-output-byte` listener
|
|
275
|
+
- Exchange files via 9p filesystem
|
|
276
|
+
|
|
277
|
+
## Alternative: fetch Backend (No Relay Needed)
|
|
278
|
+
|
|
279
|
+
For HTTP-only networking, v86 has a built-in `fetch` backend:
|
|
280
|
+
|
|
281
|
+
```javascript
|
|
282
|
+
net_device: {
|
|
283
|
+
type: "virtio",
|
|
284
|
+
relay_url: "fetch",
|
|
285
|
+
}
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
This uses the browser/Node.js `fetch()` API for HTTP requests. Limitations:
|
|
289
|
+
- Only HTTP/HTTPS (no raw TCP/UDP)
|
|
290
|
+
- No WebSocket
|
|
291
|
+
- Host access via `http://<port>.external` (e.g., `http://8080.external`)
|
|
292
|
+
|
|
293
|
+
## Files Reference
|
|
294
|
+
|
|
295
|
+
After building, you need these files:
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
project/
|
|
299
|
+
├── node_modules/v86/build/
|
|
300
|
+
│ ├── v86.wasm
|
|
301
|
+
│ └── libv86.mjs
|
|
302
|
+
├── bios/
|
|
303
|
+
│ ├── seabios.bin
|
|
304
|
+
│ └── vgabios.bin
|
|
305
|
+
├── images/
|
|
306
|
+
│ ├── alpine-fs.json
|
|
307
|
+
│ └── alpine-rootfs-flat/
|
|
308
|
+
│ └── *.bin.zst (many files)
|
|
309
|
+
└── rootlessRelay/
|
|
310
|
+
└── relay.js (patched)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
## Resources
|
|
314
|
+
|
|
315
|
+
- [v86 GitHub](https://github.com/copy/v86)
|
|
316
|
+
- [v86 Networking Docs](https://github.com/copy/v86/blob/master/docs/networking.md)
|
|
317
|
+
- [v86 Alpine Setup](https://github.com/copy/v86/tree/master/tools/docker/alpine)
|
|
318
|
+
- [rootlessRelay](https://github.com/obegron/rootlessRelay)
|
|
319
|
+
- [v86 npm package](https://www.npmjs.com/package/v86)
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# GLM-4.5
|
|
2
|
+
|
|
3
|
+
[中文阅读](./README_zh.md)
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
<img src=resources/logo.svg width="15%"/>
|
|
7
|
+
</div>
|
|
8
|
+
<p align="center">
|
|
9
|
+
👋 Join our <a href="resources/WECHAT.md" target="_blank">WeChat</a> or <a href="https://discord.gg/QR7SARHRxK" target="_blank">Discord</a> community.
|
|
10
|
+
<br>
|
|
11
|
+
📖 Check out the GLM-4.5 <a href="https://z.ai/blog/glm-4.5" target="_blank">technical blog</a>.
|
|
12
|
+
<br>
|
|
13
|
+
📍 Use GLM-4.5 API services on <a href="https://docs.z.ai/guides/llm/glm-4.5">Z.ai API Platform (Global)</a> or <br> <a href="https://docs.bigmodel.cn/cn/guide/models/text/glm-4.5">Zhipu AI Open Platform (Mainland China)</a>.
|
|
14
|
+
<br>
|
|
15
|
+
👉 One click to <a href="https://chat.z.ai">GLM-4.5</a>.
|
|
16
|
+
</p>
|
|
17
|
+
|
|
18
|
+
## Model Introduction
|
|
19
|
+
|
|
20
|
+
The **GLM-4.5** series models are foundation models designed for intelligent agents. GLM-4.5 has **355** billion total
|
|
21
|
+
parameters with **32** billion active parameters, while GLM-4.5-Air adopts a more compact design with **106** billion
|
|
22
|
+
total parameters and **12** billion active parameters. GLM-4.5 models unify reasoning, coding, and intelligent agent
|
|
23
|
+
capabilities to meet the complex demands of intelligent agent applications.
|
|
24
|
+
|
|
25
|
+
Both GLM-4.5 and GLM-4.5-Air are hybrid reasoning models that provide two modes: thinking mode for complex reasoning and
|
|
26
|
+
tool usage, and non-thinking mode for immediate responses.
|
|
27
|
+
|
|
28
|
+
We have open-sourced the base models, hybrid reasoning models, and FP8 versions of the hybrid reasoning models for both
|
|
29
|
+
GLM-4.5 and GLM-4.5-Air. They are released under the MIT open-source license and can be used commercially and for
|
|
30
|
+
secondary development.
|
|
31
|
+
|
|
32
|
+
As demonstrated in our comprehensive evaluation across 12 industry-standard benchmarks, GLM-4.5 achieves exceptional
|
|
33
|
+
performance with a score of **63.2**, in the **3rd** place among all the proprietary and open-source models. Notably,
|
|
34
|
+
GLM-4.5-Air delivers competitive results at **59.8** while maintaining superior efficiency.
|
|
35
|
+
|
|
36
|
+

|
|
37
|
+
|
|
38
|
+
For more eval results, show cases, and technical details, please visit
|
|
39
|
+
our [technical blog](https://z.ai/blog/glm-4.5). The technical report will be released soon.
|
|
40
|
+
|
|
41
|
+
The model code, tool parser and reasoning parser can be found in the implementation
|
|
42
|
+
of [transformers](https://github.com/huggingface/transformers/tree/main/src/transformers/models/glm4_moe), [vLLM](https://github.com/vllm-project/vllm/blob/main/vllm/model_executor/models/glm4_moe_mtp.py)
|
|
43
|
+
and [SGLang](https://github.com/sgl-project/sglang/blob/main/python/sglang/srt/models/glm4_moe.py).
|
|
44
|
+
|
|
45
|
+
## Model Downloads
|
|
46
|
+
|
|
47
|
+
You can directly experience the model on [Hugging Face](https://huggingface.co/spaces/zai-org/GLM-4.5-Space)
|
|
48
|
+
or [ModelScope](https://modelscope.cn/studios/ZhipuAI/GLM-4.5-Demo) or download the model by following the links below.
|
|
49
|
+
|
|
50
|
+
| Model | Download Links | Model Size | Precision |
|
|
51
|
+
|------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|------------|-----------|
|
|
52
|
+
| GLM-4.5 | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5) | 355B-A32B | BF16 |
|
|
53
|
+
| GLM-4.5-Air | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5-Air)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air) | 106B-A12B | BF16 |
|
|
54
|
+
| GLM-4.5-FP8 | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5-FP8)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5-FP8) | 355B-A32B | FP8 |
|
|
55
|
+
| GLM-4.5-Air-FP8 | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5-Air-FP8)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-FP8) | 106B-A12B | FP8 |
|
|
56
|
+
| GLM-4.5-Base | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5-Base)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Base) | 355B-A32B | BF16 |
|
|
57
|
+
| GLM-4.5-Air-Base | [🤗 Hugging Face](https://huggingface.co/zai-org/GLM-4.5-Air-Base)<br> [🤖 ModelScope](https://modelscope.cn/models/ZhipuAI/GLM-4.5-Air-Base) | 106B-A12B | BF16 |
|
|
58
|
+
|
|
59
|
+
## System Requirements
|
|
60
|
+
|
|
61
|
+
### Inference
|
|
62
|
+
|
|
63
|
+
We provide minimum and recommended configurations for "full-featured" model inference. The data in the table below is
|
|
64
|
+
based on the following conditions:
|
|
65
|
+
|
|
66
|
+
1. All models use MTP layers and specify
|
|
67
|
+
`--speculative-num-steps 3 --speculative-eagle-topk 1 --speculative-num-draft-tokens 4` to ensure competitive
|
|
68
|
+
inference speed.
|
|
69
|
+
2. The `cpu-offload` parameter is not used.
|
|
70
|
+
3. Inference batch size does not exceed `8`.
|
|
71
|
+
4. All are executed on devices that natively support FP8 inference, ensuring both weights and cache are in FP8 format.
|
|
72
|
+
5. Server memory must exceed `1T` to ensure normal model loading and operation.
|
|
73
|
+
|
|
74
|
+
The models can run under the configurations in the table below:
|
|
75
|
+
|
|
76
|
+
| Model | Precision | GPU Type and Count | Test Framework |
|
|
77
|
+
|-------------|-----------|----------------------|----------------|
|
|
78
|
+
| GLM-4.5 | BF16 | H100 x 16 / H200 x 8 | sglang |
|
|
79
|
+
| GLM-4.5 | FP8 | H100 x 8 / H200 x 4 | sglang |
|
|
80
|
+
| GLM-4.5-Air | BF16 | H100 x 4 / H200 x 2 | sglang |
|
|
81
|
+
| GLM-4.5-Air | FP8 | H100 x 2 / H200 x 1 | sglang |
|
|
82
|
+
|
|
83
|
+
Under the configurations in the table below, the models can utilize their full 128K context length:
|
|
84
|
+
|
|
85
|
+
| Model | Precision | GPU Type and Count | Test Framework |
|
|
86
|
+
|-------------|-----------|-----------------------|----------------|
|
|
87
|
+
| GLM-4.5 | BF16 | H100 x 32 / H200 x 16 | sglang |
|
|
88
|
+
| GLM-4.5 | FP8 | H100 x 16 / H200 x 8 | sglang |
|
|
89
|
+
| GLM-4.5-Air | BF16 | H100 x 8 / H200 x 4 | sglang |
|
|
90
|
+
| GLM-4.5-Air | FP8 | H100 x 4 / H200 x 2 | sglang |
|
|
91
|
+
|
|
92
|
+
### Fine-tuning
|
|
93
|
+
|
|
94
|
+
The code can run under the configurations in the table below
|
|
95
|
+
using [Llama Factory](https://github.com/hiyouga/LLaMA-Factory):
|
|
96
|
+
|
|
97
|
+
| Model | GPU Type and Count | Strategy | Batch Size (per GPU) |
|
|
98
|
+
|-------------|--------------------|----------|----------------------|
|
|
99
|
+
| GLM-4.5 | H100 x 16 | Lora | 1 |
|
|
100
|
+
| GLM-4.5-Air | H100 x 4 | Lora | 1 |
|
|
101
|
+
|
|
102
|
+
The code can run under the configurations in the table below using [Swift](https://github.com/modelscope/ms-swift):
|
|
103
|
+
|
|
104
|
+
| Model | GPU Type and Count | Strategy | Batch Size (per GPU) |
|
|
105
|
+
|-------------|--------------------|----------|----------------------|
|
|
106
|
+
| GLM-4.5 | H20 (96GiB) x 16 | Lora | 1 |
|
|
107
|
+
| GLM-4.5-Air | H20 (96GiB) x 4 | Lora | 1 |
|
|
108
|
+
| GLM-4.5 | H20 (96GiB) x 128 | SFT | 1 |
|
|
109
|
+
| GLM-4.5-Air | H20 (96GiB) x 32 | SFT | 1 |
|
|
110
|
+
| GLM-4.5 | H20 (96GiB) x 128 | RL | 1 |
|
|
111
|
+
| GLM-4.5-Air | H20 (96GiB) x 32 | RL | 1 |
|
|
112
|
+
|
|
113
|
+
## Quick Start
|
|
114
|
+
|
|
115
|
+
Please install the required packages according to `requirements.txt`.
|
|
116
|
+
|
|
117
|
+
```shell
|
|
118
|
+
pip install -r requirements.txt
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### transformers
|
|
122
|
+
|
|
123
|
+
Please refer to the `trans_infer_cli.py` code in the `inference` folder.
|
|
124
|
+
|
|
125
|
+
### vLLM
|
|
126
|
+
|
|
127
|
+
+ Both BF16 and FP8 can be started with the following code:
|
|
128
|
+
|
|
129
|
+
```shell
|
|
130
|
+
vllm serve zai-org/GLM-4.5-Air \
|
|
131
|
+
--tensor-parallel-size 8 \
|
|
132
|
+
--tool-call-parser glm45 \
|
|
133
|
+
--reasoning-parser glm45 \
|
|
134
|
+
--enable-auto-tool-choice \
|
|
135
|
+
--served-model-name glm-4.5-air
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
If you're using 8x H100 GPUs and encounter insufficient memory when running the GLM-4.5 model, you'll need
|
|
139
|
+
`--cpu-offload-gb 16` (only applicable to vLLM).
|
|
140
|
+
|
|
141
|
+
If you encounter `flash infer` issues, use `VLLM_ATTENTION_BACKEND=XFORMERS` as a temporary replacement. You can also
|
|
142
|
+
specify `TORCH_CUDA_ARCH_LIST='9.0+PTX'` to use `flash infer` (different GPUs have different TORCH_CUDA_ARCH_LIST
|
|
143
|
+
values, please check accordingly).
|
|
144
|
+
|
|
145
|
+
### SGLang
|
|
146
|
+
|
|
147
|
+
+ BF16
|
|
148
|
+
|
|
149
|
+
```shell
|
|
150
|
+
python3 -m sglang.launch_server \
|
|
151
|
+
--model-path zai-org/GLM-4.5-Air \
|
|
152
|
+
--tp-size 8 \
|
|
153
|
+
--tool-call-parser glm45 \
|
|
154
|
+
--reasoning-parser glm45 \
|
|
155
|
+
--speculative-algorithm EAGLE \
|
|
156
|
+
--speculative-num-steps 3 \
|
|
157
|
+
--speculative-eagle-topk 1 \
|
|
158
|
+
--speculative-num-draft-tokens 4 \
|
|
159
|
+
--mem-fraction-static 0.7 \
|
|
160
|
+
--served-model-name glm-4.5-air \
|
|
161
|
+
--host 0.0.0.0 \
|
|
162
|
+
--port 8000
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
+ FP8
|
|
166
|
+
|
|
167
|
+
```shell
|
|
168
|
+
python3 -m sglang.launch_server \
|
|
169
|
+
--model-path zai-org/GLM-4.5-Air-FP8 \
|
|
170
|
+
--tp-size 4 \
|
|
171
|
+
--tool-call-parser glm45 \
|
|
172
|
+
--reasoning-parser glm45 \
|
|
173
|
+
--speculative-algorithm EAGLE \
|
|
174
|
+
--speculative-num-steps 3 \
|
|
175
|
+
--speculative-eagle-topk 1 \
|
|
176
|
+
--speculative-num-draft-tokens 4 \
|
|
177
|
+
--mem-fraction-static 0.7 \
|
|
178
|
+
--disable-shared-experts-fusion \
|
|
179
|
+
--served-model-name glm-4.5-air-fp8 \
|
|
180
|
+
--host 0.0.0.0 \
|
|
181
|
+
--port 8000
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Request Parameter Instructions
|
|
185
|
+
|
|
186
|
+
+ When using `vLLM` and `SGLang`, thinking mode is enabled by default when sending requests. If you want to disable the
|
|
187
|
+
thinking switch, you need to add the `extra_body={"chat_template_kwargs": {"enable_thinking": False}}` parameter.
|
|
188
|
+
+ Both support tool calling. Please use OpenAI-style tool description format for calls.
|
|
189
|
+
+ For specific code, please refer to `api_request.py` in the `inference` folder.
|