odant-work 1.0.41 → 1.0.43
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/#system/certs/russian_trusted_root_ca.pem +32 -32
- package/#system/mail.json.example +9 -9
- package/#system/package-manifest.json +15 -15
- package/#system/settings.json.example +3 -3
- package/$server/$folder/$class/$device/class.js +2 -2
- package/$server/$folder/$class/$domain/class.js +4 -4
- package/$server/$folder/$class/$domain/readme.md +5 -5
- package/$server/$folder/$class/$handler/$task/class.js +2 -2
- package/$server/$folder/$class/$handler/$trigger/class.js +3 -3
- package/$server/$folder/$class/$handler/class.js +9 -9
- package/$server/$folder/$class/$handler/handlers/pages/editor/$handler/class.js +5 -5
- package/$server/$folder/$class/$handler/readme.md +23 -23
- package/$server/$folder/$class/$service/$class/$service/class.js +3 -3
- package/$server/$folder/$class/$structure/$base/class.js +9 -9
- package/$server/$folder/$class/$structure/$user/class.js +2 -2
- package/$server/$folder/$class/$structure/handlers/pages/explorer/$handler/class.js +4 -4
- package/$server/$folder/$class/$structure/handlers/pages/form/calendar/$handler/readme.md +40 -40
- package/$server/$folder/$class/$structure/handlers/pages/site/$handler/readme.md +34 -34
- package/$server/$folder/$class/ai/config.js +19 -19
- package/$server/$folder/$class/ai/prompt/$method/class.js +41 -41
- package/$server/$folder/$class/ai/skills/approval-flow.md +14 -14
- package/$server/$folder/$class/ai/skills/backup-check.md +13 -13
- package/$server/$folder/$class/ai/skills/computer.md +27 -27
- package/$server/$folder/$class/ai/skills/delegate-task.md +15 -15
- package/$server/$folder/$class/ai/skills/external-signup.md +14 -14
- package/$server/$folder/$class/ai/skills/lan-inventory.md +16 -16
- package/$server/$folder/$class/ai/skills/onboarding.md +15 -15
- package/$server/$folder/$class/ai/skills/orchestration.md +41 -41
- package/$server/$folder/$class/handlers/pages/form/builder/$handler/builder.js +259 -259
- package/$server/$folder/$class/handlers/pages/form/editor/$handler/editor.js +19 -19
- package/$server/$folder/$class/handlers/pages/storage/$handler/storage.js +20 -20
- package/$server/$folder/$file/$audio/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$audio/handlers/preview/$handler/preview.js +88 -88
- package/$server/$folder/$file/$call/class.js +10 -10
- package/$server/$folder/$file/$call/handlers/preview/$handler/class.js +4 -4
- package/$server/$folder/$file/$call/triggers/on_save/$trigger/class.js +48 -48
- package/$server/$folder/$file/$data/class.js +16 -16
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/class.js +5 -5
- package/$server/$folder/$file/$data/handlers/pages/form/editor/$handler/editor.js +26 -26
- package/$server/$folder/$file/$devs/$js/class.js +2 -2
- package/$server/$folder/$file/$devs/$json/class.js +2 -2
- package/$server/$folder/$file/$devs/$ts/class.js +2 -2
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$devs/handlers/pages/form/file/$handler/file.js +30 -30
- package/$server/$folder/$file/$eml/class.js +17 -17
- package/$server/$folder/$file/$eml/triggers/on_save/$trigger/class.js +97 -97
- package/$server/$folder/$file/$ics/class.js +44 -44
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$ics/handlers/pages/form/file/$handler/file.js +10 -10
- package/$server/$folder/$file/$ics/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$ics/handlers/preview/$handler/preview.js +67 -67
- package/$server/$folder/$file/$ics/readme.md +21 -21
- package/$server/$folder/$file/$image/$svg/class.js +11 -11
- package/$server/$folder/$file/$image/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$image/handlers/preview/$handler/preview.js +33 -33
- package/$server/$folder/$file/$ipynb/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$logs/class.js +39 -39
- package/$server/$folder/$file/$logs/handlers/methods/txt-test/$handler/class.js +4 -4
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/$md/handlers/pages/form/file/$handler/file.js +63 -63
- package/$server/$folder/$file/$office/$outlook/$ics/class.js +227 -227
- package/$server/$folder/$file/$office/$word/$rtf/template.rtf +159 -159
- package/$server/$folder/$file/$task/handlers/pages/form/file/$handler/ui/voice-ui.js +94 -94
- package/$server/$folder/$file/$task/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$task/progress.md +20 -20
- package/$server/$folder/$file/$task/readme.md +32 -32
- package/$server/$folder/$file/$txt/handlers/preview/$handler/class.js +3 -3
- package/$server/$folder/$file/$txt/handlers/preview/$handler/preview.js +41 -41
- package/$server/$folder/$file/$video/handlers/preview/$handler/class.js +4 -4
- package/$server/$folder/$file/$video/handlers/preview/$handler/preview.js +13 -13
- package/$server/$folder/$file/class.js +2 -2
- package/$server/$folder/$file/handlers/methods/download/$handler/class.js +2 -2
- package/$server/$folder/$file/handlers/methods/download/$handler/download.js +4 -4
- package/$server/$folder/$file/handlers/pages/form/$handler/class.js +2 -2
- package/$server/$folder/$file/handlers/pages/form/file/$handler/class.js +3 -3
- package/$server/$folder/$file/handlers/pages/form/file/$handler/file.js +28 -28
- package/$server/$folder/$file/readme.md +31 -31
- package/$server/$folder/class.js +11 -11
- package/$server/$folder/handlers/methods/create/progress.md +15 -15
- package/$server/$folder/handlers/pages/form/$handler/class.js +5 -5
- package/$server/$folder/handlers/readme.md +24 -24
- package/$server/$folder/lib/calendar-form/calendar-form.js +296 -296
- package/$server/$folder/lib/dialogs/confirm/confirm.js +30 -30
- package/$server/$folder/lib/dialogs/input/input.js +57 -57
- package/$server/$folder/lib/email/settings.js +82 -82
- package/$server/$folder/lib/file-viewer/file-viewer.js +8 -8
- package/$server/$folder/lib/icon/user/user.js +6 -6
- package/$server/$folder/lib/item-data-grid/item-data-grid.js +48 -48
- package/$server/$folder/lib/item-form/item-form.js +84 -84
- package/$server/$folder/lib/menu/progress.md +13 -13
- package/$server/$folder/lib/menu/readme.md +29 -29
- package/$server/$folder/lib/node/progress.md +13 -13
- package/$server/$folder/lib/node/readme.md +29 -29
- package/$server/$folder/lib/pack/pack.js +4 -4
- package/$server/$folder/lib/prompt-bar/progress.md +13 -13
- package/$server/$folder/lib/security/admin/admin.js +30 -30
- package/$server/$folder/lib/site-loc/readme.md +16 -16
- package/$server/$folder/lib/site-loc/site-loc.js +80 -80
- package/$server/$folder/lib/tree/progress.md +16 -16
- package/$server/$folder/readme.md +18 -18
- package/$server/readme.md +13 -13
- package/.cursor/rules/work.mdc +8 -8
- package/.github/workflows/ci.yml +39 -39
- package/MODELS/$ai/$folder/$class/$ai/class.js +18 -8
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +73 -93
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +19 -41
- package/MODELS/$ai/$folder/$class/$provider/readme.md +16 -16
- package/MODELS/GigaChat/$provider/readme.md +24 -24
- package/MODULES/Register/$module/$folder/$class/$register/class.js +4 -4
- package/MODULES/Register/$module/$folder/$class/$struct/class.js +4 -4
- package/MODULES/Register/CATALOGS/$catalog/$folder/$class/$virtual/class.js +14 -14
- package/MODULES/Register/CATALOGS//320/241/321/203/320/261/321/212/320/265/320/272/321/202/321/213//320/244/320/270/320/267. /320/273/320/270/321/206/320/260/$catalog/class.js" +11 -11
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +40 -40
- package/MODULES/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +56 -56
- package/MODULES/Register/REGISTER/$register/$folder/$class/$account/class.js +18 -18
- package/MODULES/Register/REGISTER/$register/$folder/$class/$register/class.js +11 -11
- package/MODULES/Register/REGISTER/68/01/$account/class.js +1 -1
- package/MODULES/Register/REGISTER/68/02/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/320/276/320/262/321/213/320/271 /321/200/320/265/320/267/320/265/321/200/320/262/$account/class.js" +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/222 /320/276/321/202/320/277/321/203/321/201/320/272/320/265/$account/class.js" +1 -1
- package/MODULES/Register/REGISTER//320/232/320/260/320/264/321/200/321/213//320/240/320/260/320/261/320/276/321/202/320/260/321/216/321/202/$account/class.js +1 -1
- package/MODULES/Register/REGISTER//320/242/320/265/321/205/320/275/320/270/321/207/320/265/321/201/320/272/320/270/320/271/$account/class.js +1 -1
- package/MODULES/Register/STRUCTS/$struct/$folder/$class/$struct/class.js +4 -4
- package/MODULES/Register/STRUCTS/$struct/class.js +4 -4
- package/MODULES/Register/STRUCTS//320/220/320/264/321/200/320/265/321/201/$struct/class.js +11 -11
- package/MODULES/Register/STRUCTS//320/225/320/264/320/270/320/275/320/270/321/206/320/260 /320/270/320/267/320/274/320/265/321/200/320/265/320/275/320/270/321/217/$struct/class.js" +11 -11
- package/MODULES/Register/STRUCTS//320/237/320/260/321/201/320/277/320/276/321/200/321/202/$struct/class.js +11 -11
- package/NODES/$node/$folder/$class/$node/class.js +35 -35
- package/NODES/$node/class.js +5 -5
- package/NODES/$node/handlers/pages/form/network/$handler/class.js +5 -5
- package/NODES/$node/handlers/pages/form/network/$handler/network.js +110 -110
- package/NODES/teewtew/$node/class.js +2 -2
- package/NODES/work.odant.org/$node/class.js +3 -3
- package/ORGANIZATIONS/$domain/$folder/$class/$base/$folder/$class/$structure/$base/class.js +17 -17
- package/ORGANIZATIONS/$domain/$folder/$class/$base/class.js +4 -4
- package/SERVICES/$service/$folder/$storage/$service/class.js +8 -8
- package/SERVICES/ArgoCD/$service/$folder/$class/$service/class.js +356 -356
- package/SERVICES/ArgoCD/$service/$folder/$class/$service/handlers/pages/form/orders/$handler/class.js +244 -244
- package/SERVICES/ArgoCD/$service/class.js +4 -4
- package/SERVICES/ArgoCD/$service/readme.md +63 -63
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/class.js +10 -10
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/checkDomain/$method/class.js +33 -33
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/provision/$method/class.js +225 -225
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/submitOrder/$method/class.js +77 -77
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/readme.md +33 -33
- package/SERVICES/ArgoCD/PaaS/$service/class.js +347 -347
- package/SERVICES/ArgoCD/PaaS/$service/order/pass.order +8 -8
- package/SERVICES/DuckDuckGo/$service/class.js +367 -367
- package/SERVICES/SearXNG/$service/class.js +70 -70
- package/SERVICES/Telegram/$service/class.js +114 -114
- package/SERVICES/Weather/$service/class.js +76 -76
- package/SERVICES/Yandex/$service/class.js +120 -120
- package/SERVICES/readme.md +43 -43
- package/USERS/$users/class.js +2 -2
- package/eslint.config.js +51 -51
- package/jsconfig.json +37 -37
- package/oda/benchmarks/dbmon/lib/ENV.js +213 -213
- package/oda/benchmarks/dbmon/lib/ga.js +11 -11
- package/oda/benchmarks/dbmon/lib/memory-stats.js +105 -105
- package/oda/benchmarks/dbmon/lib/monitor.js +69 -69
- package/oda/benchmarks/sierpinski/sierpinski.js +149 -149
- package/oda/components/editors/code-editor/code-editor.js +387 -387
- package/oda/components/editors/code-editor/src/ace.js +16 -16
- package/oda/components/editors/code-editor/src/beautify-css.js +1625 -1625
- package/oda/components/editors/code-editor/src/beautify-html.js +3122 -3122
- package/oda/components/editors/code-editor/src/beautify.js +4005 -4005
- package/oda/components/editors/code-editor/src/ext-beautify.js +7 -7
- package/oda/components/editors/code-editor/src/ext-code_lens.js +7 -7
- package/oda/components/editors/code-editor/src/ext-elastic_tabstops_lite.js +7 -7
- package/oda/components/editors/code-editor/src/ext-emmet.js +7 -7
- package/oda/components/editors/code-editor/src/ext-error_marker.js +7 -7
- package/oda/components/editors/code-editor/src/ext-hardwrap.js +7 -7
- package/oda/components/editors/code-editor/src/ext-keybinding_menu.js +7 -7
- package/oda/components/editors/code-editor/src/ext-language_tools.js +7 -7
- package/oda/components/editors/code-editor/src/ext-linking.js +7 -7
- package/oda/components/editors/code-editor/src/ext-modelist.js +7 -7
- package/oda/components/editors/code-editor/src/ext-options.js +7 -7
- package/oda/components/editors/code-editor/src/ext-prompt.js +7 -7
- package/oda/components/editors/code-editor/src/ext-rtl.js +7 -7
- package/oda/components/editors/code-editor/src/ext-searchbox.js +7 -7
- package/oda/components/editors/code-editor/src/ext-settings_menu.js +7 -7
- package/oda/components/editors/code-editor/src/ext-spellcheck.js +7 -7
- package/oda/components/editors/code-editor/src/ext-split.js +7 -7
- package/oda/components/editors/code-editor/src/ext-static_highlight.js +7 -7
- package/oda/components/editors/code-editor/src/ext-statusbar.js +7 -7
- package/oda/components/editors/code-editor/src/ext-textarea.js +7 -7
- package/oda/components/editors/code-editor/src/ext-themelist.js +7 -7
- package/oda/components/editors/code-editor/src/ext-whitespace.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-emacs.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-sublime.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-vim.js +7 -7
- package/oda/components/editors/code-editor/src/keybinding-vscode.js +7 -7
- package/oda/components/editors/code-editor/src/mode-css.js +7 -7
- package/oda/components/editors/code-editor/src/mode-html.js +7 -7
- package/oda/components/editors/code-editor/src/mode-javascript.js +7 -7
- package/oda/components/editors/code-editor/src/mode-json.js +7 -7
- package/oda/components/editors/code-editor/src/mode-markdown.js +7 -7
- package/oda/components/editors/code-editor/src/mode-svg.js +7 -7
- package/oda/components/editors/code-editor/src/mode-text.js +7 -7
- package/oda/components/editors/code-editor/src/mode-xml.js +7 -7
- package/oda/components/editors/code-editor/src/mode-xquery.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/css.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/html.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/javascript.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/json.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/markdown.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/svg.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/text.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/xml.js +7 -7
- package/oda/components/editors/code-editor/src/snippets/xquery.js +7 -7
- package/oda/components/editors/code-editor/src/theme-solarized_dark.js +7 -7
- package/oda/components/editors/code-editor/src/theme-solarized_light.js +7 -7
- package/oda/components/editors/markdown/markdown-editor/lib/font-awesome.min.css +3 -3
- package/oda/components/editors/markdown/markdown-editor/lib/readme.md +332 -332
- package/oda/components/editors/markdown/markdown-editor/markdown-editor.js +78 -78
- package/oda/components/editors/markdown/markdown-viewer/test.md +239 -239
- package/oda/components/editors/markdown/markdown.js +76 -76
- package/oda/components/inputs/block/readme.md +39 -39
- package/oda/components/inputs/checkbox/checkbox.js +92 -92
- package/oda/components/inputs/color/color.js +83 -83
- package/oda/components/inputs/date/date.js +40 -40
- package/oda/components/inputs/input/input.js +219 -219
- package/oda/components/inputs/link/readme.md +42 -42
- package/oda/components/inputs/markdown-input/markdown-input.js +77 -77
- package/oda/components/inputs/numeric/numeric.js +141 -141
- package/oda/components/inputs/table-input/readme.md +39 -39
- package/oda/components/inputs/text/text.js +88 -88
- package/oda/components/inputs/toggle/toggle.js +101 -101
- package/oda/components/layouts/hexagon-layout/hexagon-layout.js +218 -218
- package/oda/components/menus/menu/index_old.html +140 -140
- package/oda/components/menus/menu/menu.js +238 -238
- package/oda/components/structure/controls-map.js +56 -56
- package/oda/components/structure/controls.js +29 -29
- package/oda/components/structure/readme.md +31 -31
- package/oda/components/structure/structure.js +64 -64
- package/oda/components/table/index.html +210 -210
- package/oda/components/table/lib/coerce.js +68 -68
- package/oda/components/table/lib/column.js +568 -568
- package/oda/components/table/readme.md +120 -120
- package/oda/components/table/router.js +86 -86
- package/oda/components/table/settings.js +89 -89
- package/oda/index.html +159 -159
- package/oda/tools/icons/icons-set/icons-set.js +60 -60
- package/oda/tools/icons/lib/svg/_makeSVG.html +41 -41
- package/oda/tools/icons/lib/svg/aws.svg +2679 -2679
- package/oda/tools/icons/lib/svg/info.json +46 -46
- package/oda/tools/jupyter/demo.ipynb +160 -160
- package/oda/tools/jupyter/lib/print_elements.js +73 -73
- package/oda/tools/jupyter/test-2.ipynb +305 -305
- package/oda/tools/jupyter/test.ipynb +603 -603
- package/oda/tools/styles/adoptedStyleSheets.js +333 -333
- package/oda/tools/tester/device-preview/devices.json +9 -9
- package/opencode.json +9 -9
- package/package.json +1 -1
- package/publish.cmd +2 -2
- package/readme.md +164 -164
- package/rules/rules.md +445 -445
- package/scripts/SYNC-README.md +107 -107
- package/scripts/agent-eval.mjs +223 -223
- package/scripts/dump-svn-chat.mjs +9 -9
- package/scripts/extract-chat-day.mjs +21 -21
- package/scripts/rag-bench.mjs +166 -166
- package/scripts/restore-chat.mjs +166 -166
- package/scripts/sync-svn-git.bat +129 -129
- package/scripts/test-merge.mjs +75 -75
- package/scripts/work-desktop-bridge.mjs +101 -101
- package/sources/client/field.js +168 -168
- package/sources/client/index.js +32 -32
- package/sources/client/readme.md +16 -16
- package/sources/core.js +91 -91
- package/sources/data/choices.js +125 -125
- package/sources/data/progress.md +12 -0
- package/sources/host/auto-updater.js +12 -1
- package/sources/host/babel-merge.js +353 -353
- package/sources/host/config.js +48 -48
- package/sources/host/email-utils.js +269 -269
- package/sources/host/http-server.js +1 -1
- package/sources/host/index-db.js +94 -94
- package/sources/host/net-guard.js +228 -228
- package/sources/host/package-install.js +63 -63
- package/sources/host/progress.md +14 -14
- package/sources/host/push.js +86 -86
- package/sources/host/readme.md +41 -41
- package/sources/host/secret-box.js +93 -93
- package/sources/host/server-id.js +26 -26
- package/sources/host/stun.js +33 -33
- package/sources/host/tls-ca.js +60 -60
- package/sources/host/vapid.js +14 -14
- package/sources/index.html +49 -49
- package/sources/manifest.json +49 -49
- package/sources/modules/a2a/server.js +608 -608
- package/sources/modules/agent/connections.js +442 -442
- package/sources/modules/agent/diff.js +69 -69
- package/sources/modules/agent/eval.js +222 -222
- package/sources/modules/agent/hooks.js +131 -131
- package/sources/modules/agent/log.js +43 -43
- package/sources/modules/agent/mcp-pool.js +253 -253
- package/sources/modules/agent/plugins.js +343 -343
- package/sources/modules/agent/recovery.js +89 -89
- package/sources/modules/agent/taint.js +100 -100
- package/sources/modules/agent/tools/branch.js +311 -311
- package/sources/modules/agent/tools/browser.js +254 -254
- package/sources/modules/agent/tools/computer.js +120 -120
- package/sources/modules/agent/tools/connect.js +316 -316
- package/sources/modules/agent/tools/dev/lsp.js +334 -334
- package/sources/modules/agent/tools/dev/patch.js +564 -564
- package/sources/modules/agent/tools/memory.js +153 -153
- package/sources/modules/agent/tools/os-files.js +358 -358
- package/sources/modules/agent/tools/plugins.js +80 -80
- package/sources/modules/agent/tools/sandbox.js +268 -268
- package/sources/modules/agent/types.d.ts +183 -183
- package/sources/modules/agent/undo.js +254 -254
- package/sources/modules/agent/util.js +179 -179
- package/sources/modules/contacts/contacts.js +200 -200
- package/sources/modules/contacts/index.html +546 -546
- package/sources/modules/lan/discovery.js +192 -192
- package/sources/modules/lan/store.js +62 -62
- package/sources/modules/mcp/readme.md +70 -70
- package/sources/modules/mcp/server.js +525 -525
- package/sources/modules/mcp/tokens.js +140 -140
- package/sources/modules/nodes/identity.js +123 -123
- package/sources/modules/nodes/inbound.js +172 -172
- package/sources/modules/nodes/outbound.js +105 -105
- package/sources/modules/nodes/signing.js +71 -71
- package/sources/modules/rag/embed-worker.js +36 -36
- package/sources/modules/rag/readme.md +70 -70
- package/sources/modules/readme.md +21 -21
- package/sources/modules/sandbox/config.js +74 -74
- package/sources/modules/sandbox/driver.js +100 -100
- package/sources/modules/sandbox/images/work-computer/Dockerfile +34 -34
- package/sources/modules/sandbox/images/work-computer/entrypoint.sh +24 -24
- package/sources/modules/sandbox/manager.js +1089 -1089
- package/sources/modules/sandbox/readme.md +63 -63
- package/sources/modules/sandbox/vnc-proxy.js +296 -296
- package/sources/modules/trainer/halogen.js +671 -25
- package/sources/modules/trainer/huggingface.js +28 -2
- package/sources/modules/trainer/index.js +149 -6
- package/sources/modules/trainer/local-engine.js +366 -155
- package/sources/modules/trainer/worker/local_infer_worker.py +141 -19
- package/sources/readme.md +216 -216
- package/sources/server/access/audit.js +138 -138
- package/sources/server/access/refs.js +106 -106
- package/sources/server/assert-class-id.js +23 -23
- package/sources/server/external-source.js +90 -90
- package/sources/server/index.js +12 -12
- package/sources/server/memory-mark.js +34 -34
- package/sources/server/readme.md +110 -110
- package/sources/server/safe-node-name.js +67 -67
- package/sources/server/upload-mark.js +24 -24
- package/sources/server/zip-guard.js +81 -81
- package/sources/tester.html +54 -54
- package/whitepaper.md +568 -568
|
@@ -480,6 +480,7 @@ const BACKEND_LOG_TAIL_CHARS = 8192;
|
|
|
480
480
|
let _managedProc = null;
|
|
481
481
|
let _managedInfo = null;
|
|
482
482
|
let _lastManagedExit = null;
|
|
483
|
+
let _lastSpeculationFallback = null;
|
|
483
484
|
|
|
484
485
|
function appendLogTail(prev, chunk) {
|
|
485
486
|
const text = prev + (Buffer.isBuffer(chunk) ? chunk.toString('utf-8') : String(chunk || ''));
|
|
@@ -489,8 +490,9 @@ function appendLogTail(prev, chunk) {
|
|
|
489
490
|
function attachManagedBackendProcess(proc, meta = {}) {
|
|
490
491
|
_managedProc = proc;
|
|
491
492
|
_lastManagedExit = null;
|
|
493
|
+
const { onEarlyExit, ...info } = meta || {};
|
|
492
494
|
const state = {
|
|
493
|
-
...
|
|
495
|
+
...info,
|
|
494
496
|
pid: proc?.pid,
|
|
495
497
|
startedAt: Date.now(),
|
|
496
498
|
stdout: '',
|
|
@@ -519,10 +521,18 @@ function attachManagedBackendProcess(proc, meta = {}) {
|
|
|
519
521
|
errorMessage: state.errorMessage,
|
|
520
522
|
exitedAt: Date.now(),
|
|
521
523
|
};
|
|
524
|
+
const earlyExit = Date.now() - state.startedAt < 30000 && code !== 0;
|
|
522
525
|
if (_managedProc === proc) {
|
|
523
526
|
_managedProc = null;
|
|
524
527
|
_managedInfo = null;
|
|
525
528
|
}
|
|
529
|
+
// Движок мог не принять новый флаг спекуляции — отдаём управление повторному запуску без него.
|
|
530
|
+
if (earlyExit && typeof onEarlyExit === 'function') {
|
|
531
|
+
setTimeout(() => {
|
|
532
|
+
try { onEarlyExit(code); }
|
|
533
|
+
catch { /* ignore */ }
|
|
534
|
+
}, 250);
|
|
535
|
+
}
|
|
526
536
|
});
|
|
527
537
|
return state;
|
|
528
538
|
}
|
|
@@ -1000,6 +1010,100 @@ function httpGetJson(urlStr, headers = {}, timeoutMs = 2500) {
|
|
|
1000
1010
|
});
|
|
1001
1011
|
}
|
|
1002
1012
|
|
|
1013
|
+
/**
|
|
1014
|
+
* Разобрать счётчики Prometheus из `GET /metrics` сервера `bubo.exe` / `gufo.exe` / `llama-server`.
|
|
1015
|
+
*/
|
|
1016
|
+
export function parseHalogenPrometheusText(rawText = '') {
|
|
1017
|
+
const pick = (names) => {
|
|
1018
|
+
for (const name of names) {
|
|
1019
|
+
const esc = name.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
1020
|
+
const m = new RegExp(`^${esc}(?:\\{[^}]*\\})?\\s+([+-]?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?)`, 'm').exec(rawText);
|
|
1021
|
+
if (m) {
|
|
1022
|
+
const v = Number(m[1]);
|
|
1023
|
+
if (Number.isFinite(v))
|
|
1024
|
+
return v;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
return null;
|
|
1028
|
+
};
|
|
1029
|
+
const decodeTokens = pick(['llamacpp:tokens_predicted_total', 'tokens_predicted_total']);
|
|
1030
|
+
const decodeSeconds = pick(['llamacpp:tokens_predicted_seconds_total', 'tokens_predicted_seconds_total']);
|
|
1031
|
+
const prefillTokens = pick(['llamacpp:prompt_tokens_total', 'prompt_tokens_total']);
|
|
1032
|
+
const prefillSeconds = pick(['llamacpp:prompt_seconds_total', 'prompt_seconds_total']);
|
|
1033
|
+
const cachedTokens = pick(['llamacpp:prompt_tokens_cached_total', 'prompt_tokens_cached_total']);
|
|
1034
|
+
const draftRounds = pick(['llamacpp:spec_decode_num_drafts_total', 'spec_decode_num_drafts_total']);
|
|
1035
|
+
const draftTokens = pick(['llamacpp:spec_decode_num_draft_tokens_total', 'spec_decode_num_draft_tokens_total']);
|
|
1036
|
+
const acceptedTokens = pick(['llamacpp:spec_decode_num_accepted_tokens_total', 'spec_decode_num_accepted_tokens_total']);
|
|
1037
|
+
if (decodeTokens === null && draftTokens === null && prefillTokens === null)
|
|
1038
|
+
return null;
|
|
1039
|
+
return {
|
|
1040
|
+
decodeTokens: decodeTokens ?? 0,
|
|
1041
|
+
decodeSeconds: decodeSeconds ?? 0,
|
|
1042
|
+
prefillTokens: prefillTokens ?? 0,
|
|
1043
|
+
prefillSeconds: prefillSeconds ?? 0,
|
|
1044
|
+
cachedTokens: cachedTokens ?? 0,
|
|
1045
|
+
draftRounds: draftRounds ?? 0,
|
|
1046
|
+
draftTokens: draftTokens ?? 0,
|
|
1047
|
+
acceptedTokens: acceptedTokens ?? 0,
|
|
1048
|
+
};
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
/** Считать снимок счётчиков `:8731/metrics` (безопасно возвращает `null`, если эндпоинт недоступен). */
|
|
1052
|
+
export async function readHalogenMetrics(baseUrl = HALOGEN_DEFAULT_BASE_URL, { fetchJson = httpGetJson } = {}) {
|
|
1053
|
+
let origin = `http://127.0.0.1:${HALOGEN_DEFAULT_PORT}`;
|
|
1054
|
+
try { origin = new URL(baseUrl).origin; }
|
|
1055
|
+
catch { /* default */ }
|
|
1056
|
+
try {
|
|
1057
|
+
const res = await fetchJson(`${origin}/metrics`, { Accept: 'text/plain' }, 2000);
|
|
1058
|
+
const text = typeof res === 'string' ? res : String(res?.text || '');
|
|
1059
|
+
return text ? parseHalogenPrometheusText(text) : null;
|
|
1060
|
+
}
|
|
1061
|
+
catch {
|
|
1062
|
+
return null;
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
/** Вычислить дельту скорости декодирования и КПД спекуляции MTP между двумя снимками `/metrics`. */
|
|
1067
|
+
export function computeHalogenMetricsDelta(before, after) {
|
|
1068
|
+
if (!after)
|
|
1069
|
+
return null;
|
|
1070
|
+
const b = before || {
|
|
1071
|
+
decodeTokens: 0, decodeSeconds: 0, prefillTokens: 0, prefillSeconds: 0,
|
|
1072
|
+
cachedTokens: 0, draftRounds: 0, draftTokens: 0, acceptedTokens: 0,
|
|
1073
|
+
};
|
|
1074
|
+
const dDecodeTokens = Math.max(0, after.decodeTokens - b.decodeTokens);
|
|
1075
|
+
const dDecodeSeconds = Math.max(0, after.decodeSeconds - b.decodeSeconds);
|
|
1076
|
+
const dPrefillTokens = Math.max(0, after.prefillTokens - b.prefillTokens);
|
|
1077
|
+
const dPrefillSeconds = Math.max(0, after.prefillSeconds - b.prefillSeconds);
|
|
1078
|
+
const dDraftRounds = Math.max(0, after.draftRounds - b.draftRounds);
|
|
1079
|
+
const dDraftTokens = Math.max(0, after.draftTokens - b.draftTokens);
|
|
1080
|
+
const dAccepted = Math.max(0, after.acceptedTokens - b.acceptedTokens);
|
|
1081
|
+
|
|
1082
|
+
const serverDecodeTokPerSec = (dDecodeTokens > 0 && dDecodeSeconds > 0.005)
|
|
1083
|
+
? +(dDecodeTokens / dDecodeSeconds).toFixed(1)
|
|
1084
|
+
: 0;
|
|
1085
|
+
const serverPrefillTokPerSec = (dPrefillTokens > 0 && dPrefillSeconds > 0.005)
|
|
1086
|
+
? +(dPrefillTokens / dPrefillSeconds).toFixed(1)
|
|
1087
|
+
: 0;
|
|
1088
|
+
const mtpAcceptPct = dDraftTokens > 0
|
|
1089
|
+
? Math.round((dAccepted / dDraftTokens) * 100)
|
|
1090
|
+
: null;
|
|
1091
|
+
const mtpTokensPerStep = dDraftRounds > 0
|
|
1092
|
+
? +((dDraftRounds + dAccepted) / dDraftRounds).toFixed(2)
|
|
1093
|
+
: null;
|
|
1094
|
+
|
|
1095
|
+
return {
|
|
1096
|
+
decodeTokens: dDecodeTokens,
|
|
1097
|
+
serverDecodeTokPerSec,
|
|
1098
|
+
serverPrefillTokPerSec,
|
|
1099
|
+
draftRounds: dDraftRounds,
|
|
1100
|
+
draftTokens: dDraftTokens,
|
|
1101
|
+
acceptedTokens: dAccepted,
|
|
1102
|
+
mtpAcceptPct,
|
|
1103
|
+
mtpTokensPerStep,
|
|
1104
|
+
};
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1003
1107
|
/**
|
|
1004
1108
|
* Опросить живой сервер на порту `:8731` (Linux `halogen-flash-server`, Windows `Halowin Bubo` / `Gufo` / `Strata`
|
|
1005
1109
|
* или `llama-server`) по служебным маршрутам:
|
|
@@ -1100,6 +1204,8 @@ export async function probeHalogenServer(baseUrl = HALOGEN_DEFAULT_BASE_URL, { f
|
|
|
1100
1204
|
? handlesRaw
|
|
1101
1205
|
: listHalogenSessionHandles(),
|
|
1102
1206
|
managedProcess: _managedInfo,
|
|
1207
|
+
speculation: _managedInfo?.speculation || null,
|
|
1208
|
+
speculationFallback: _lastSpeculationFallback,
|
|
1103
1209
|
windowsEnv: inspectWindowsHalogenEnvironment({ rootDir }),
|
|
1104
1210
|
};
|
|
1105
1211
|
}
|
|
@@ -1401,6 +1507,432 @@ export async function prepareWindowsBuboRuntime({
|
|
|
1401
1507
|
}
|
|
1402
1508
|
}
|
|
1403
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* Настройки движка Halowin Bubo по умолчанию:
|
|
1512
|
+
* - `profile: 'default'` — 1 сессия, контекст 200K, 8.6 ГБ RAM-кэш снимков и максимальная скорость спекуляции;
|
|
1513
|
+
* - `mtpDraftVocab: 'auto'` — автопереключение словаря черновика MTP латиница ↔ кириллица (без просадки на русском тексте);
|
|
1514
|
+
* - `draftMax: 7` — штатная глубина черновика Bubo (`--draft-tokens 7`);
|
|
1515
|
+
* - `npuPrefill: true` — задействование Ryzen AI NPU для чтения длинных промптов (при наличии драйвера AMD XRT).
|
|
1516
|
+
*/
|
|
1517
|
+
export const DEFAULT_ENGINE_SETTINGS = Object.freeze({
|
|
1518
|
+
speculation: 'auto',
|
|
1519
|
+
draftMax: 7,
|
|
1520
|
+
promptLookup: 'auto',
|
|
1521
|
+
profile: 'default',
|
|
1522
|
+
mtpDraftVocab: 'auto',
|
|
1523
|
+
npuPrefill: true,
|
|
1524
|
+
});
|
|
1525
|
+
|
|
1526
|
+
const ENGINE_STATE_MODES = ['auto', 'on', 'off'];
|
|
1527
|
+
const ENGINE_PROFILES = ['default', 'subagents', 'exact', 'stock', 'vanilla'];
|
|
1528
|
+
|
|
1529
|
+
function clampInt(value, min, max, fallback) {
|
|
1530
|
+
const n = Number(value);
|
|
1531
|
+
if (!Number.isFinite(n))
|
|
1532
|
+
return fallback;
|
|
1533
|
+
return Math.min(max, Math.max(min, Math.round(n)));
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/** Файл настроек движка (`MODELS/Local/$provider/#runtime/engine.json`). */
|
|
1537
|
+
export function engineSettingsFile(rootDir = process.cwd()) {
|
|
1538
|
+
return path.join(localRuntimeDir(rootDir), 'engine.json');
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1541
|
+
/** Файл состояния запущенного процесса движка (`MODELS/Local/$provider/#runtime/engine-state.json`). */
|
|
1542
|
+
export function engineStateFile(rootDir = process.cwd()) {
|
|
1543
|
+
return path.join(localRuntimeDir(rootDir), 'engine-state.json');
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1546
|
+
export function readEngineStateSync(rootDir = process.cwd()) {
|
|
1547
|
+
try {
|
|
1548
|
+
return JSON.parse(fs.readFileSync(engineStateFile(rootDir), 'utf8')) || null;
|
|
1549
|
+
}
|
|
1550
|
+
catch {
|
|
1551
|
+
return null;
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
export function writeEngineStateSync(rootDir = process.cwd(), state = {}) {
|
|
1556
|
+
try {
|
|
1557
|
+
fs.mkdirSync(localRuntimeDir(rootDir), { recursive: true });
|
|
1558
|
+
fs.writeFileSync(engineStateFile(rootDir), JSON.stringify(state, null, 2), 'utf8');
|
|
1559
|
+
}
|
|
1560
|
+
catch { /* ignore */ }
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
/** Прочитать сохранённые настройки движка (с валидацией значений). */
|
|
1564
|
+
export function readEngineSettings(rootDir = process.cwd()) {
|
|
1565
|
+
let saved = {};
|
|
1566
|
+
try {
|
|
1567
|
+
saved = JSON.parse(fs.readFileSync(engineSettingsFile(rootDir), 'utf8')) || {};
|
|
1568
|
+
}
|
|
1569
|
+
catch { saved = {}; }
|
|
1570
|
+
const mode = v => ENGINE_STATE_MODES.includes(String(v || '')) ? String(v) : '';
|
|
1571
|
+
const savedProfile = ENGINE_PROFILES.includes(String(saved.profile || '')) ? String(saved.profile) : '';
|
|
1572
|
+
const profile = (saved.profileExplicit && savedProfile) ? savedProfile : DEFAULT_ENGINE_SETTINGS.profile;
|
|
1573
|
+
return {
|
|
1574
|
+
speculation: mode(saved.speculation) || DEFAULT_ENGINE_SETTINGS.speculation,
|
|
1575
|
+
promptLookup: mode(saved.promptLookup) || DEFAULT_ENGINE_SETTINGS.promptLookup,
|
|
1576
|
+
draftMax: clampInt(saved.draftMax, 1, 32, DEFAULT_ENGINE_SETTINGS.draftMax),
|
|
1577
|
+
profile,
|
|
1578
|
+
profileExplicit: Boolean(saved.profileExplicit && savedProfile),
|
|
1579
|
+
mtpDraftVocab: ['auto', 'latin', 'full'].includes(String(saved.mtpDraftVocab || '')) ? String(saved.mtpDraftVocab) : 'auto',
|
|
1580
|
+
npuPrefill: saved.npuPrefill !== false,
|
|
1581
|
+
updatedAt: Number(saved.updatedAt) || 0,
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
/** Сохранить настройки движка (частичное обновление). */
|
|
1586
|
+
export function writeEngineSettings(rootDir = process.cwd(), patch = {}) {
|
|
1587
|
+
const current = readEngineSettings(rootDir);
|
|
1588
|
+
const hasExplicitProfile = Boolean(patch && typeof patch.profile === 'string' && ENGINE_PROFILES.includes(patch.profile));
|
|
1589
|
+
const merged = {
|
|
1590
|
+
...current,
|
|
1591
|
+
...(patch && typeof patch === 'object' ? patch : {}),
|
|
1592
|
+
profileExplicit: hasExplicitProfile ? true : current.profileExplicit,
|
|
1593
|
+
updatedAt: Date.now(),
|
|
1594
|
+
};
|
|
1595
|
+
fs.mkdirSync(localRuntimeDir(rootDir), { recursive: true });
|
|
1596
|
+
fs.writeFileSync(engineSettingsFile(rootDir), JSON.stringify(merged, null, 2), 'utf8');
|
|
1597
|
+
return readEngineSettings(rootDir);
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
/** Разобрать список поддерживаемых флагов CLI из текста `--help` движка. */
|
|
1601
|
+
export function parseEngineHelpFlags(text) {
|
|
1602
|
+
const out = new Set();
|
|
1603
|
+
for (const m of String(text || '').matchAll(/(?:^|[\s,;|[(=])(--[a-z][a-z0-9-]{1,40})/gi))
|
|
1604
|
+
out.add(m[1].toLowerCase());
|
|
1605
|
+
return [...out];
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
function engineCapabilitiesFile(rootDir = process.cwd()) {
|
|
1609
|
+
return path.join(localCacheDir(rootDir), 'engine-capabilities.json');
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1612
|
+
/** Прочитать закэшированные возможности движка (без запуска процесса). */
|
|
1613
|
+
export function readEngineCapabilitiesSync(rootDir = process.cwd(), exePath = '') {
|
|
1614
|
+
try {
|
|
1615
|
+
const raw = JSON.parse(fs.readFileSync(engineCapabilitiesFile(rootDir), 'utf8'));
|
|
1616
|
+
if (Array.isArray(raw?.flags) && (!exePath || raw.exePath === exePath))
|
|
1617
|
+
return raw;
|
|
1618
|
+
}
|
|
1619
|
+
catch { /* нет кэша */ }
|
|
1620
|
+
return null;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
function captureProcessOutput(cmd, args, spawnImpl, timeoutMs) {
|
|
1624
|
+
return new Promise(resolve => {
|
|
1625
|
+
let text = '';
|
|
1626
|
+
let done = false;
|
|
1627
|
+
const finish = () => {
|
|
1628
|
+
if (!done) {
|
|
1629
|
+
done = true;
|
|
1630
|
+
resolve(text);
|
|
1631
|
+
}
|
|
1632
|
+
};
|
|
1633
|
+
try {
|
|
1634
|
+
const proc = spawnImpl(cmd, args, { windowsHide: true, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
1635
|
+
const timer = setTimeout(() => {
|
|
1636
|
+
try { proc?.kill?.(); } catch { /* ignore */ }
|
|
1637
|
+
finish();
|
|
1638
|
+
}, timeoutMs);
|
|
1639
|
+
proc?.stdout?.on?.('data', d => { text += String(d); if (text.length > 40000) text = text.slice(-40000); });
|
|
1640
|
+
proc?.stderr?.on?.('data', d => { text += String(d); if (text.length > 40000) text = text.slice(-40000); });
|
|
1641
|
+
proc?.on?.('error', () => { clearTimeout(timer); finish(); });
|
|
1642
|
+
proc?.on?.('close', () => { clearTimeout(timer); finish(); });
|
|
1643
|
+
}
|
|
1644
|
+
catch {
|
|
1645
|
+
finish();
|
|
1646
|
+
}
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* Определить возможности `bubo.exe serve llm` по его `--help` (с кэшем на 7 дней).
|
|
1652
|
+
*/
|
|
1653
|
+
export async function inspectEngineCapabilities({
|
|
1654
|
+
rootDir = process.cwd(),
|
|
1655
|
+
exePath = '',
|
|
1656
|
+
spawnImpl = spawn,
|
|
1657
|
+
timeoutMs = 9000,
|
|
1658
|
+
maxAgeMs = 7 * 24 * 60 * 60 * 1000,
|
|
1659
|
+
force = false,
|
|
1660
|
+
} = {}) {
|
|
1661
|
+
if (!exePath)
|
|
1662
|
+
return null;
|
|
1663
|
+
const cached = readEngineCapabilitiesSync(rootDir, exePath);
|
|
1664
|
+
if (!force && cached && Date.now() - Number(cached.checkedAt || 0) < maxAgeMs)
|
|
1665
|
+
return { ...cached, cached: true };
|
|
1666
|
+
|
|
1667
|
+
let helpText = '';
|
|
1668
|
+
for (const args of [['serve', 'llm', '--help'], ['--help'], ['serve', '--help']]) {
|
|
1669
|
+
helpText = await captureProcessOutput(exePath, args, spawnImpl, timeoutMs);
|
|
1670
|
+
if (parseEngineHelpFlags(helpText).length)
|
|
1671
|
+
break;
|
|
1672
|
+
}
|
|
1673
|
+
const flags = parseEngineHelpFlags(helpText);
|
|
1674
|
+
const result = {
|
|
1675
|
+
exePath,
|
|
1676
|
+
flags,
|
|
1677
|
+
known: flags.length > 0,
|
|
1678
|
+
speculative: flags.includes('--speculative'),
|
|
1679
|
+
mtpDraftVocabFlag: flags.includes('--mtp-draft-vocab'),
|
|
1680
|
+
draftTokensFlag: flags.includes('--draft-tokens'),
|
|
1681
|
+
promptLookupFlag: flags.includes('--prompt-lookup'),
|
|
1682
|
+
noPromptLookupFlag: flags.includes('--no-prompt-lookup'),
|
|
1683
|
+
draftMaxFlag: flags.includes('--draft-tokens') || flags.includes('--draft-max'),
|
|
1684
|
+
lookupFlag: flags.includes('--prompt-lookup')
|
|
1685
|
+
? '--prompt-lookup'
|
|
1686
|
+
: (flags.includes('--lookup-cache-dynamic') ? '--lookup-cache-dynamic' : ''),
|
|
1687
|
+
checkedAt: Date.now(),
|
|
1688
|
+
helpText: helpText.slice(-4000),
|
|
1689
|
+
};
|
|
1690
|
+
try {
|
|
1691
|
+
fs.mkdirSync(path.dirname(engineCapabilitiesFile(rootDir)), { recursive: true });
|
|
1692
|
+
fs.writeFileSync(engineCapabilitiesFile(rootDir), JSON.stringify(result, null, 2), 'utf8');
|
|
1693
|
+
}
|
|
1694
|
+
catch { /* кэш не критичен */ }
|
|
1695
|
+
return { ...result, cached: false };
|
|
1696
|
+
}
|
|
1697
|
+
|
|
1698
|
+
/**
|
|
1699
|
+
* Собрать аргументы и переменные окружения `bubo.exe` для спекулятивного декодирования (по спецификации Bubo v0.1.2):
|
|
1700
|
+
* - `--mtp-model` + `--twin-model` (`GUFO_DENSE_TWIN_MODEL`) + `--draft-head-model` (`GUFO_DRAFT_OUT_MODEL`);
|
|
1701
|
+
* - `--speculative mtp` и `--mtp-draft-vocab auto` (критично для русского текста и кода одновременно);
|
|
1702
|
+
* - `--prompt-lookup` включён в Bubo с MTP по умолчанию (или отключается через `--no-prompt-lookup`).
|
|
1703
|
+
*/
|
|
1704
|
+
export function resolveSpeculationPlan({
|
|
1705
|
+
settings = {},
|
|
1706
|
+
capabilities = null,
|
|
1707
|
+
sidecars = {},
|
|
1708
|
+
hasManifest = false,
|
|
1709
|
+
lookupPath = '',
|
|
1710
|
+
} = {}) {
|
|
1711
|
+
const cfg = { ...DEFAULT_ENGINE_SETTINGS, ...(settings || {}) };
|
|
1712
|
+
const flags = new Set((capabilities?.flags || []).map(f => String(f).toLowerCase()));
|
|
1713
|
+
const capsKnown = flags.size > 0;
|
|
1714
|
+
const mtp = Boolean(sidecars?.mtpModel);
|
|
1715
|
+
const twin = Boolean(sidecars?.twinModel);
|
|
1716
|
+
const draftHead = Boolean(sidecars?.draftHeadModel);
|
|
1717
|
+
const args = [];
|
|
1718
|
+
const envVars = {};
|
|
1719
|
+
const reasons = [];
|
|
1720
|
+
let enabled = false;
|
|
1721
|
+
let promptLookup = false;
|
|
1722
|
+
|
|
1723
|
+
if (cfg.speculation === 'off') {
|
|
1724
|
+
if (flags.has('--no-mtp'))
|
|
1725
|
+
args.push('--no-mtp');
|
|
1726
|
+
if (flags.has('--no-twin'))
|
|
1727
|
+
args.push('--no-twin');
|
|
1728
|
+
if (flags.has('--no-draft-head'))
|
|
1729
|
+
args.push('--no-draft-head');
|
|
1730
|
+
reasons.push('Спекулятивное декодирование отключено — используется только основная модель.');
|
|
1731
|
+
}
|
|
1732
|
+
else if (!mtp) {
|
|
1733
|
+
reasons.push('Файл MTP-предсказателя (mtp-*.gguf) не найден в $ai/#weights — спекуляция недоступна.');
|
|
1734
|
+
}
|
|
1735
|
+
else {
|
|
1736
|
+
args.push('--mtp-model', sidecars.mtpModel);
|
|
1737
|
+
if (twin) {
|
|
1738
|
+
args.push('--twin-model', sidecars.twinModel);
|
|
1739
|
+
envVars.GUFO_DENSE_TWIN_MODEL = sidecars.twinModel;
|
|
1740
|
+
}
|
|
1741
|
+
if (draftHead) {
|
|
1742
|
+
args.push('--draft-head-model', sidecars.draftHeadModel);
|
|
1743
|
+
envVars.GUFO_DRAFT_OUT_MODEL = sidecars.draftHeadModel;
|
|
1744
|
+
}
|
|
1745
|
+
if (!capsKnown || flags.has('--speculative')) {
|
|
1746
|
+
if (flags.has('--speculative'))
|
|
1747
|
+
args.push('--speculative', 'mtp');
|
|
1748
|
+
enabled = true;
|
|
1749
|
+
}
|
|
1750
|
+
// Автопереключение словаря черновика латиница ↔ кириллица снимает просадку скорости на русском языке
|
|
1751
|
+
const vocabMode = cfg.mtpDraftVocab || 'auto';
|
|
1752
|
+
if (!capsKnown || flags.has('--mtp-draft-vocab')) {
|
|
1753
|
+
args.push('--mtp-draft-vocab', vocabMode);
|
|
1754
|
+
}
|
|
1755
|
+
if (cfg.speculation === 'on') {
|
|
1756
|
+
const dTok = String(clampInt(cfg.draftMax, 1, 32, DEFAULT_ENGINE_SETTINGS.draftMax));
|
|
1757
|
+
if (flags.has('--draft-tokens'))
|
|
1758
|
+
args.push('--draft-tokens', dTok);
|
|
1759
|
+
else if (flags.has('--draft-max'))
|
|
1760
|
+
args.push('--draft-max', dTok);
|
|
1761
|
+
}
|
|
1762
|
+
if (cfg.promptLookup === 'off') {
|
|
1763
|
+
if (flags.has('--no-prompt-lookup'))
|
|
1764
|
+
args.push('--no-prompt-lookup');
|
|
1765
|
+
}
|
|
1766
|
+
else {
|
|
1767
|
+
promptLookup = true;
|
|
1768
|
+
if (!hasManifest && flags.has('--lookup-cache-dynamic') && !flags.has('--prompt-lookup') && lookupPath) {
|
|
1769
|
+
args.push('--lookup-cache-dynamic', lookupPath);
|
|
1770
|
+
}
|
|
1771
|
+
}
|
|
1772
|
+
reasons.push(
|
|
1773
|
+
`Активен полный стек спекуляции Bubo: MTP${twin ? ' + Dense Twin' : ''}${draftHead ? ' + Q4_K Draft Head' : ''} (словарь черновика: ${vocabMode}).`
|
|
1774
|
+
);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
const mode = cfg.speculation === 'off'
|
|
1778
|
+
? 'off'
|
|
1779
|
+
: (!mtp ? 'unavailable' : (capsKnown && flags.has('--speculative') ? 'explicit' : 'weights-only'));
|
|
1780
|
+
const parts = [
|
|
1781
|
+
mtp && mode !== 'off'
|
|
1782
|
+
? `MTP${twin ? ' + Twin' : ''}${draftHead ? ' + Draft Head' : ''} (vocab: ${cfg.mtpDraftVocab || 'auto'})`
|
|
1783
|
+
: 'MTP выключен',
|
|
1784
|
+
promptLookup ? 'Prompt Lookup вкл.' : 'Prompt Lookup выкл.',
|
|
1785
|
+
].filter(Boolean);
|
|
1786
|
+
|
|
1787
|
+
return {
|
|
1788
|
+
mode,
|
|
1789
|
+
enabled: Boolean(mtp && mode !== 'off'),
|
|
1790
|
+
promptLookup,
|
|
1791
|
+
sidecars: {
|
|
1792
|
+
mtp: Boolean(mtp),
|
|
1793
|
+
twin: Boolean(twin),
|
|
1794
|
+
draftHead: Boolean(draftHead),
|
|
1795
|
+
},
|
|
1796
|
+
capabilitiesKnown: capsKnown,
|
|
1797
|
+
args,
|
|
1798
|
+
envVars,
|
|
1799
|
+
reasons,
|
|
1800
|
+
summary: parts.join(' · '),
|
|
1801
|
+
settings: { ...cfg },
|
|
1802
|
+
};
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
export function computeBuboLaunchSignature({
|
|
1806
|
+
exePath = '',
|
|
1807
|
+
port = HALOGEN_DEFAULT_PORT,
|
|
1808
|
+
modelPath = '',
|
|
1809
|
+
sidecars = null,
|
|
1810
|
+
profile = 'default',
|
|
1811
|
+
mtpDraftVocab = 'auto',
|
|
1812
|
+
speculation = 'auto',
|
|
1813
|
+
npuPrefill = false,
|
|
1814
|
+
} = {}) {
|
|
1815
|
+
const raw = JSON.stringify({
|
|
1816
|
+
schema: 'bubo-v2.1',
|
|
1817
|
+
exePath,
|
|
1818
|
+
port: Number(port) || HALOGEN_DEFAULT_PORT,
|
|
1819
|
+
modelPath,
|
|
1820
|
+
mtp: sidecars?.mtpModel || '',
|
|
1821
|
+
twin: sidecars?.twinModel || '',
|
|
1822
|
+
draftHead: sidecars?.draftHeadModel || '',
|
|
1823
|
+
mmproj: sidecars?.mmprojModel || '',
|
|
1824
|
+
profile,
|
|
1825
|
+
mtpDraftVocab,
|
|
1826
|
+
speculation,
|
|
1827
|
+
npuPrefill: Boolean(npuPrefill),
|
|
1828
|
+
});
|
|
1829
|
+
return crypto.createHash('sha256').update(raw).digest('hex').slice(0, 16);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
async function stopStaleBuboProcess({ rootDir = process.cwd(), port = HALOGEN_DEFAULT_PORT, winEnv = null } = {}) {
|
|
1833
|
+
stopHalogenBackend();
|
|
1834
|
+
const prevState = readEngineStateSync(rootDir);
|
|
1835
|
+
if (prevState?.pid && Number.isInteger(prevState.pid) && prevState.pid > 0 && prevState.pid !== process.pid) {
|
|
1836
|
+
try { process.kill(prevState.pid); } catch { /* уже завершён */ }
|
|
1837
|
+
}
|
|
1838
|
+
if (os.platform() === 'win32' && winEnv?.buboExePath && fs.existsSync(winEnv.buboExePath)) {
|
|
1839
|
+
await captureProcessOutput(winEnv.buboExePath, ['stop'], spawn, 3000).catch(() => '');
|
|
1840
|
+
}
|
|
1841
|
+
// Если старый bubo.exe запущен другим экземпляром WORK на этом же порту — аккуратно завершаем именно bubo/gufo на нашем порту
|
|
1842
|
+
if (os.platform() === 'win32') {
|
|
1843
|
+
const psCmd = `$c = Get-NetTCPConnection -LocalPort ${Number(port)} -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1; if ($c) { $p = Get-Process -Id $c.OwningProcess -ErrorAction SilentlyContinue; if ($p -and $p.ProcessName -match '^(bubo|gufo)$') { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue } }`;
|
|
1844
|
+
await captureProcessOutput('powershell.exe', ['-NoProfile', '-Command', psCmd], spawn, 4000).catch(() => '');
|
|
1845
|
+
}
|
|
1846
|
+
const deadline = Date.now() + 8000;
|
|
1847
|
+
while (Date.now() < deadline) {
|
|
1848
|
+
const pr = await probeHalogenServer(`http://127.0.0.1:${port}/v1/chat/completions`, { rootDir }).catch(() => ({ online: false }));
|
|
1849
|
+
if (!pr?.online)
|
|
1850
|
+
break;
|
|
1851
|
+
await new Promise(r => setTimeout(r, 250));
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Полное описание контура спекулятивного декодирования для UI: сохранённые настройки,
|
|
1857
|
+
* найденные веса (MTP / Dense twin / Draft head / Vision mmproj), возможности движка и итоговые флаги.
|
|
1858
|
+
*/
|
|
1859
|
+
export async function describeEngineSetup({
|
|
1860
|
+
rootDir = process.cwd(),
|
|
1861
|
+
settings = null,
|
|
1862
|
+
capabilities = undefined,
|
|
1863
|
+
forceCapabilities = false,
|
|
1864
|
+
} = {}) {
|
|
1865
|
+
const winEnv = inspectWindowsHalogenEnvironment({ rootDir });
|
|
1866
|
+
const gguf = findLocalGgufModel(rootDir);
|
|
1867
|
+
const weightsDir = gguf ? path.dirname(gguf) : modelWeightsDir(rootDir, 'Qwen3.8-Flash-Next', 'Local');
|
|
1868
|
+
const sidecars = resolveBuboModelFiles(weightsDir);
|
|
1869
|
+
const hasManifest = Boolean(gguf && fs.existsSync(path.join(path.dirname(gguf), 'bubo-package.json')));
|
|
1870
|
+
const cfg = { ...readEngineSettings(rootDir), ...(settings || {}) };
|
|
1871
|
+
const exePath = winEnv.buboExePath || winEnv.gufoExePath || '';
|
|
1872
|
+
const caps = capabilities !== undefined
|
|
1873
|
+
? capabilities
|
|
1874
|
+
: (readEngineCapabilitiesSync(rootDir, exePath)
|
|
1875
|
+
|| (forceCapabilities ? await inspectEngineCapabilities({ rootDir, exePath, force: true }) : null));
|
|
1876
|
+
const plan = resolveSpeculationPlan({
|
|
1877
|
+
settings: cfg,
|
|
1878
|
+
capabilities: caps,
|
|
1879
|
+
sidecars,
|
|
1880
|
+
hasManifest,
|
|
1881
|
+
lookupPath: path.join(localCacheDir(rootDir), 'lookup.bin'),
|
|
1882
|
+
});
|
|
1883
|
+
const describeFile = p => {
|
|
1884
|
+
if (!p)
|
|
1885
|
+
return null;
|
|
1886
|
+
let sizeGb = 0;
|
|
1887
|
+
try { sizeGb = +((fs.statSync(p).size || 0) / (1024 ** 3)).toFixed(2); }
|
|
1888
|
+
catch { /* ignore */ }
|
|
1889
|
+
return { path: p, name: path.basename(p), sizeGb };
|
|
1890
|
+
};
|
|
1891
|
+
const stateOnDisk = readEngineStateSync(rootDir);
|
|
1892
|
+
return {
|
|
1893
|
+
settings: cfg,
|
|
1894
|
+
weightsDir,
|
|
1895
|
+
mainModel: describeFile(gguf),
|
|
1896
|
+
sidecars: {
|
|
1897
|
+
mtp: describeFile(sidecars?.mtpModel),
|
|
1898
|
+
twin: describeFile(sidecars?.twinModel),
|
|
1899
|
+
draftHead: describeFile(sidecars?.draftHeadModel),
|
|
1900
|
+
mmproj: describeFile(sidecars?.mmprojModel),
|
|
1901
|
+
},
|
|
1902
|
+
plan,
|
|
1903
|
+
hasManifest,
|
|
1904
|
+
capabilities: caps ? {
|
|
1905
|
+
known: Boolean(caps.known),
|
|
1906
|
+
speculative: Boolean(caps.speculative),
|
|
1907
|
+
draftMax: Boolean(caps.draftMaxFlag),
|
|
1908
|
+
lookupFlag: caps.lookupFlag || '',
|
|
1909
|
+
cached: Boolean(caps.cached),
|
|
1910
|
+
checkedAt: caps.checkedAt || 0,
|
|
1911
|
+
flags: caps.flags || [],
|
|
1912
|
+
} : null,
|
|
1913
|
+
engine: {
|
|
1914
|
+
installed: Boolean(winEnv.buboInstalled || winEnv.gufoInstalled),
|
|
1915
|
+
runtime: winEnv.buboInstalled ? 'bubo.exe' : (winEnv.gufoInstalled ? 'gufo.exe' : ''),
|
|
1916
|
+
exePath,
|
|
1917
|
+
npuReady: Boolean(winEnv.npuDriverInstalled && winEnv.npuKernelsPresent),
|
|
1918
|
+
},
|
|
1919
|
+
running: _managedInfo ? {
|
|
1920
|
+
runtime: _managedInfo.runtime,
|
|
1921
|
+
profile: _managedInfo.profile || cfg.profile,
|
|
1922
|
+
npuPrefill: Boolean(_managedInfo.npuPrefill),
|
|
1923
|
+
speculation: _managedInfo.speculation || plan,
|
|
1924
|
+
startedAt: _managedInfo.startedAt,
|
|
1925
|
+
} : (stateOnDisk?.pid ? {
|
|
1926
|
+
runtime: stateOnDisk.runtime || 'bubo',
|
|
1927
|
+
profile: stateOnDisk.profile || cfg.profile,
|
|
1928
|
+
npuPrefill: Boolean(stateOnDisk.npuPrefill),
|
|
1929
|
+
speculation: plan,
|
|
1930
|
+
startedAt: stateOnDisk.startedAt || 0,
|
|
1931
|
+
} : null),
|
|
1932
|
+
fallback: null,
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1404
1936
|
/**
|
|
1405
1937
|
* Запустить локальный сервер на порту 8731:
|
|
1406
1938
|
* - На Windows 11: приоритетный запуск нативного `bubo.exe serve llm` (Halowin Bubo / Gufo ROCm 10.0 `gfx1151` + XRT NPU)
|
|
@@ -1411,9 +1943,11 @@ export async function startHalogenBackend({
|
|
|
1411
1943
|
rootDir = process.cwd(),
|
|
1412
1944
|
port = HALOGEN_DEFAULT_PORT,
|
|
1413
1945
|
modelPath = '',
|
|
1414
|
-
profile = '
|
|
1415
|
-
npuPrefill =
|
|
1946
|
+
profile = '',
|
|
1947
|
+
npuPrefill = null,
|
|
1416
1948
|
spawnImpl = spawn,
|
|
1949
|
+
settings = null,
|
|
1950
|
+
capabilities = undefined,
|
|
1417
1951
|
} = {}) {
|
|
1418
1952
|
const probe = await probeHalogenServer(`http://127.0.0.1:${port}/v1/chat/completions`, { rootDir });
|
|
1419
1953
|
if (probe.online) {
|
|
@@ -1450,28 +1984,52 @@ export async function startHalogenBackend({
|
|
|
1450
1984
|
const manifestCandidate = ggufPath ? path.join(path.dirname(ggufPath), 'bubo-package.json') : '';
|
|
1451
1985
|
const hasBuboManifest = Boolean(manifestCandidate && fs.existsSync(manifestCandidate));
|
|
1452
1986
|
|
|
1987
|
+
const engineSettings = { ...readEngineSettings(rootDir), ...(settings || {}) };
|
|
1988
|
+
const activeProfile = profile || engineSettings.profile || DEFAULT_ENGINE_SETTINGS.profile;
|
|
1989
|
+
const prefillEnabled = npuPrefill === null ? engineSettings.npuPrefill !== false : Boolean(npuPrefill);
|
|
1990
|
+
const effectiveNpuPrefill = Boolean(prefillEnabled && winEnv.npuDriverInstalled && winEnv.npuKernelsPresent && activeProfile !== 'exact' && activeProfile !== 'stock' && activeProfile !== 'vanilla');
|
|
1991
|
+
|
|
1453
1992
|
// 1. Приоритет №1 на Windows: нативный движок Halowin Bubo (`bubo.exe serve llm` на ROCm 10.0.0 gfx1151 + Ryzen AI NPU)
|
|
1454
1993
|
if (winEnv.buboInstalled && ggufPath && fs.existsSync(ggufPath)) {
|
|
1455
1994
|
try {
|
|
1995
|
+
const caps = capabilities !== undefined
|
|
1996
|
+
? capabilities
|
|
1997
|
+
: await inspectEngineCapabilities({ rootDir, exePath: winEnv.buboExePath, spawnImpl });
|
|
1998
|
+
const plan = resolveSpeculationPlan({
|
|
1999
|
+
settings: engineSettings,
|
|
2000
|
+
capabilities: caps,
|
|
2001
|
+
sidecars: resolvedSidecars || {},
|
|
2002
|
+
hasManifest: hasBuboManifest,
|
|
2003
|
+
lookupPath: path.join(cacheDir, 'lookup.bin'),
|
|
2004
|
+
});
|
|
1456
2005
|
const args = [
|
|
1457
2006
|
'serve', 'llm',
|
|
1458
2007
|
'--host', '127.0.0.1',
|
|
1459
2008
|
'--port', String(port),
|
|
1460
2009
|
'--model', ggufPath,
|
|
1461
2010
|
...(hasBuboManifest ? ['--manifest', manifestCandidate, '--cache-disk', path.join(cacheDir, 'disk')] : []),
|
|
1462
|
-
...(resolvedSidecars?.mtpModel ? ['--mtp-model', resolvedSidecars.mtpModel] : []),
|
|
1463
2011
|
...(resolvedSidecars?.mmprojModel ? ['--mmproj', resolvedSidecars.mmprojModel] : []),
|
|
1464
|
-
...
|
|
1465
|
-
...(resolvedSidecars?.draftHeadModel ? ['--draft-head-model', resolvedSidecars.draftHeadModel] : []),
|
|
2012
|
+
...plan.args,
|
|
1466
2013
|
'--served-model-name', 'halogen-qwen3.8-flash-next',
|
|
1467
|
-
'--profile',
|
|
2014
|
+
'--profile', activeProfile,
|
|
1468
2015
|
];
|
|
1469
|
-
if (
|
|
2016
|
+
if (effectiveNpuPrefill) {
|
|
1470
2017
|
args.push('--npu-prefill', 'on');
|
|
1471
2018
|
}
|
|
2019
|
+
const signature = computeBuboLaunchSignature({
|
|
2020
|
+
exePath: winEnv.buboExePath,
|
|
2021
|
+
port,
|
|
2022
|
+
modelPath: ggufPath,
|
|
2023
|
+
sidecars: resolvedSidecars,
|
|
2024
|
+
profile: activeProfile,
|
|
2025
|
+
mtpDraftVocab: engineSettings.mtpDraftVocab || 'auto',
|
|
2026
|
+
speculation: engineSettings.speculation || 'auto',
|
|
2027
|
+
npuPrefill: effectiveNpuPrefill,
|
|
2028
|
+
});
|
|
1472
2029
|
const env = {
|
|
1473
2030
|
...process.env,
|
|
1474
2031
|
...(winEnv.rocmRuntimeDir ? { BUBO_RUNTIME_DIR: winEnv.rocmRuntimeDir } : {}),
|
|
2032
|
+
...(plan.envVars || {}),
|
|
1475
2033
|
};
|
|
1476
2034
|
const proc = spawnImpl(winEnv.buboExePath, args, {
|
|
1477
2035
|
cwd: path.dirname(winEnv.buboExePath),
|
|
@@ -1485,7 +2043,21 @@ export async function startHalogenBackend({
|
|
|
1485
2043
|
port,
|
|
1486
2044
|
modelPath: ggufPath,
|
|
1487
2045
|
runtime: 'bubo',
|
|
1488
|
-
npuPrefill:
|
|
2046
|
+
npuPrefill: effectiveNpuPrefill,
|
|
2047
|
+
profile: activeProfile,
|
|
2048
|
+
signature,
|
|
2049
|
+
args,
|
|
2050
|
+
speculation: plan,
|
|
2051
|
+
});
|
|
2052
|
+
writeEngineStateSync(rootDir, {
|
|
2053
|
+
pid: proc?.pid || null,
|
|
2054
|
+
port,
|
|
2055
|
+
runtime: 'bubo',
|
|
2056
|
+
profile: activeProfile,
|
|
2057
|
+
npuPrefill: effectiveNpuPrefill,
|
|
2058
|
+
signature,
|
|
2059
|
+
args,
|
|
2060
|
+
startedAt: Date.now(),
|
|
1489
2061
|
});
|
|
1490
2062
|
return {
|
|
1491
2063
|
started: true,
|
|
@@ -1493,8 +2065,14 @@ export async function startHalogenBackend({
|
|
|
1493
2065
|
runtime: 'bubo.exe (AMD ROCm 10.0.0 gfx1151)',
|
|
1494
2066
|
pid: proc.pid,
|
|
1495
2067
|
port,
|
|
2068
|
+
signature,
|
|
1496
2069
|
modelPath: ggufPath,
|
|
1497
2070
|
windowsEnv: winEnv,
|
|
2071
|
+
speculation: {
|
|
2072
|
+
...plan,
|
|
2073
|
+
appliedArgs: plan.args,
|
|
2074
|
+
},
|
|
2075
|
+
capabilities: caps ? { known: caps.known, flags: caps.flags, cached: Boolean(caps.cached) } : null,
|
|
1498
2076
|
};
|
|
1499
2077
|
}
|
|
1500
2078
|
catch { /* try next runtime */ }
|
|
@@ -1503,6 +2081,7 @@ export async function startHalogenBackend({
|
|
|
1503
2081
|
// 2. Приоритет №2 на Windows: нативный Gufo (`gufo.exe serve --port 8731 llm`)
|
|
1504
2082
|
if (winEnv.gufoInstalled && ggufPath && fs.existsSync(ggufPath)) {
|
|
1505
2083
|
try {
|
|
2084
|
+
const gufoSpeculation = engineSettings.speculation !== 'off' && Boolean(resolvedSidecars?.mtpModel);
|
|
1506
2085
|
const args = [
|
|
1507
2086
|
'serve',
|
|
1508
2087
|
'--host', '127.0.0.1',
|
|
@@ -1510,7 +2089,8 @@ export async function startHalogenBackend({
|
|
|
1510
2089
|
'llm',
|
|
1511
2090
|
'--model', ggufPath,
|
|
1512
2091
|
'--served-model-name', 'halogen-qwen3.8-flash-next',
|
|
1513
|
-
'--speculative', 'mtp',
|
|
2092
|
+
...(gufoSpeculation ? ['--speculative', 'mtp'] : []),
|
|
2093
|
+
...(gufoSpeculation && resolvedSidecars?.mmprojModel ? ['--mmproj', resolvedSidecars.mmprojModel] : []),
|
|
1514
2094
|
];
|
|
1515
2095
|
const proc = spawnImpl(winEnv.gufoExePath, args, {
|
|
1516
2096
|
cwd: path.dirname(winEnv.gufoExePath),
|
|
@@ -1523,6 +2103,13 @@ export async function startHalogenBackend({
|
|
|
1523
2103
|
port,
|
|
1524
2104
|
modelPath: ggufPath,
|
|
1525
2105
|
runtime: 'gufo',
|
|
2106
|
+
args,
|
|
2107
|
+
speculation: {
|
|
2108
|
+
mode: gufoSpeculation ? 'explicit' : 'off',
|
|
2109
|
+
enabled: gufoSpeculation,
|
|
2110
|
+
summary: gufoSpeculation ? 'MTP включён (--speculative mtp)' : 'MTP выключен',
|
|
2111
|
+
args: gufoSpeculation ? ['--speculative', 'mtp'] : [],
|
|
2112
|
+
},
|
|
1526
2113
|
});
|
|
1527
2114
|
return {
|
|
1528
2115
|
started: true,
|
|
@@ -1595,6 +2182,7 @@ export function stopHalogenBackend() {
|
|
|
1595
2182
|
_managedProc = null;
|
|
1596
2183
|
_managedInfo = null;
|
|
1597
2184
|
_lastManagedExit = null;
|
|
2185
|
+
_lastSpeculationFallback = null;
|
|
1598
2186
|
return { stopped: true };
|
|
1599
2187
|
}
|
|
1600
2188
|
|
|
@@ -1618,23 +2206,63 @@ export async function ensureHalogenBackendRunning({
|
|
|
1618
2206
|
}
|
|
1619
2207
|
catch { /* default */ }
|
|
1620
2208
|
|
|
1621
|
-
const probe1 = await probeHalogenServer(baseUrl, { rootDir });
|
|
1622
|
-
if (probe1.online) {
|
|
1623
|
-
return {
|
|
1624
|
-
ready: true,
|
|
1625
|
-
alreadyRunning: true,
|
|
1626
|
-
mode: probe1.mode,
|
|
1627
|
-
origin: probe1.origin,
|
|
1628
|
-
};
|
|
1629
|
-
}
|
|
1630
|
-
|
|
1631
|
-
// Проверка на несовместимые Linux-веса (.hgn / .hnpw) на Windows
|
|
1632
2209
|
const modelFolderName = String(ai?.id || ai?.path || '').split('/').filter(Boolean).pop() || '';
|
|
1633
2210
|
const candidateWeightsDir = ai?.weightsDir
|
|
1634
2211
|
? path.resolve(rootDir, ai.weightsDir)
|
|
1635
2212
|
: (modelFolderName ? modelWeightsDir(rootDir, modelFolderName, 'Local') : '');
|
|
1636
2213
|
const wInsp = candidateWeightsDir ? inspectWeightsDirectorySync(candidateWeightsDir, platform) : null;
|
|
1637
|
-
|
|
2214
|
+
let winEnv = inspectWindowsHalogenEnvironment({ rootDir });
|
|
2215
|
+
|
|
2216
|
+
const explicitGguf = (wInsp?.hasGguf && candidateWeightsDir)
|
|
2217
|
+
? (resolveBuboModelFiles(candidateWeightsDir).mainModel || '')
|
|
2218
|
+
: '';
|
|
2219
|
+
const targetGguf = (explicitGguf && fs.existsSync(explicitGguf)) ? explicitGguf : findLocalGgufModel(rootDir);
|
|
2220
|
+
|
|
2221
|
+
const probe1 = await probeHalogenServer(baseUrl, { rootDir });
|
|
2222
|
+
if (probe1.online) {
|
|
2223
|
+
// Если на Windows запущен старый процесс bubo.exe с прежними параметрами (например, --profile subagents с latin-словарём),
|
|
2224
|
+
// автоматически перезапускаем его с актуальной сигнатурой флагов.
|
|
2225
|
+
if (
|
|
2226
|
+
platform === 'win32'
|
|
2227
|
+
&& probe1.mode === 'bubo-windows'
|
|
2228
|
+
&& winEnv.buboInstalled
|
|
2229
|
+
&& targetGguf
|
|
2230
|
+
&& fs.existsSync(targetGguf)
|
|
2231
|
+
&& spawnImpl === spawn
|
|
2232
|
+
) {
|
|
2233
|
+
const cfg = readEngineSettings(rootDir);
|
|
2234
|
+
const activeProfile = cfg.profile || DEFAULT_ENGINE_SETTINGS.profile;
|
|
2235
|
+
const effectiveNpu = Boolean(cfg.npuPrefill !== false && winEnv.npuDriverInstalled && winEnv.npuKernelsPresent && activeProfile !== 'exact' && activeProfile !== 'stock' && activeProfile !== 'vanilla');
|
|
2236
|
+
const targetSig = computeBuboLaunchSignature({
|
|
2237
|
+
exePath: winEnv.buboExePath,
|
|
2238
|
+
port,
|
|
2239
|
+
modelPath: targetGguf,
|
|
2240
|
+
sidecars: resolveBuboModelFiles(path.dirname(targetGguf)),
|
|
2241
|
+
profile: activeProfile,
|
|
2242
|
+
mtpDraftVocab: cfg.mtpDraftVocab || 'auto',
|
|
2243
|
+
speculation: cfg.speculation || 'auto',
|
|
2244
|
+
npuPrefill: effectiveNpu,
|
|
2245
|
+
});
|
|
2246
|
+
const currentSig = _managedInfo?.signature || readEngineStateSync(rootDir)?.signature || '';
|
|
2247
|
+
if (currentSig === targetSig) {
|
|
2248
|
+
return {
|
|
2249
|
+
ready: true,
|
|
2250
|
+
alreadyRunning: true,
|
|
2251
|
+
mode: probe1.mode,
|
|
2252
|
+
origin: probe1.origin,
|
|
2253
|
+
};
|
|
2254
|
+
}
|
|
2255
|
+
await stopStaleBuboProcess({ rootDir, port, winEnv });
|
|
2256
|
+
}
|
|
2257
|
+
else {
|
|
2258
|
+
return {
|
|
2259
|
+
ready: true,
|
|
2260
|
+
alreadyRunning: true,
|
|
2261
|
+
mode: probe1.mode,
|
|
2262
|
+
origin: probe1.origin,
|
|
2263
|
+
};
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
1638
2266
|
|
|
1639
2267
|
if (platform === 'win32' && wInsp?.incompatibleOnPlatform) {
|
|
1640
2268
|
return {
|
|
@@ -1650,9 +2278,27 @@ export async function ensureHalogenBackendRunning({
|
|
|
1650
2278
|
|
|
1651
2279
|
_backendStartPromise = (async () => {
|
|
1652
2280
|
try {
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
2281
|
+
// Автоматическая развёртка рантайма Halowin Bubo + ROCm 10.0, если веса GGUF уже лежат на диске
|
|
2282
|
+
if (
|
|
2283
|
+
platform === 'win32'
|
|
2284
|
+
&& targetGguf
|
|
2285
|
+
&& fs.existsSync(targetGguf)
|
|
2286
|
+
&& !winEnv.buboInstalled
|
|
2287
|
+
&& !winEnv.gufoInstalled
|
|
2288
|
+
&& spawnImpl === spawn
|
|
2289
|
+
&& process.env.WORK_DISABLE_AUTO_BUBO !== '1'
|
|
2290
|
+
) {
|
|
2291
|
+
const prep = await prepareWindowsBuboRuntime({ rootDir, step: 'runtime', spawnImpl });
|
|
2292
|
+
if (!prep.ok) {
|
|
2293
|
+
return {
|
|
2294
|
+
ready: false,
|
|
2295
|
+
code: 'RUNTIME_INSTALL_FAILED',
|
|
2296
|
+
reason: `Не удалось автоматически развернуть движок Halowin Bubo: ${prep.error || 'нет доступа к сети'}`,
|
|
2297
|
+
windowsEnv: prep.windowsEnv || winEnv,
|
|
2298
|
+
};
|
|
2299
|
+
}
|
|
2300
|
+
winEnv = prep.windowsEnv || inspectWindowsHalogenEnvironment({ rootDir });
|
|
2301
|
+
}
|
|
1656
2302
|
|
|
1657
2303
|
const startRes = await startHalogenBackend({
|
|
1658
2304
|
rootDir,
|