odant-work 1.0.54 → 1.0.56
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 +76 -73
- 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/$project/class.js +15 -0
- package/$server/$folder/$class/$structure/$project/handlers/methods/archive/$handler/class.js +23 -0
- package/$server/$folder/$class/$structure/$project/readme.md +14 -0
- package/$server/$folder/$class/$structure/$server/class.js +17 -1
- package/$server/$folder/$class/$structure/$server/handlers/methods/distro/$handler/class.js +288 -0
- 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/form/database/$handler/class.js +1 -1
- package/$server/$folder/$class/$structure/handlers/pages/form/staff/$handler/staff.js +2 -2
- 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/form/object/$handler/object.js +1 -1
- package/$server/$folder/$class/handlers/pages/form/objects/$handler/objects.js +1 -1
- 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/$handler/class.js +21 -10
- 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/pages/form/$handler/form.js +1 -1
- 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/node.js +3 -3
- 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/lib/tree/tree.js +23 -5
- 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/handlers/pages/form/trainer/$handler/trainer.js +26 -1
- package/MODELS/$ai/$folder/$class/$provider/handlers/pages/form/trainer/$handler/trainer.js +8 -1
- 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/PROJECTS/$domain/$folder/$class/$project/class.js +4 -0
- package/PROJECTS/$domain/class.js +4 -0
- package/PROJECTS/$domain/handlers/methods/restore/$handler/class.js +173 -0
- package/PROJECTS/$domain/readme.md +5 -0
- package/SERVICES/$service/$folder/$storage/$service/class.js +8 -8
- package/SERVICES/$service/$folder/$storage/$service/handlers/pages/form/mcp/$handler/mcp.js +22 -4
- package/SERVICES/1C/$service/class.js +209 -0
- package/SERVICES/Bitrix24/$service/class.js +180 -0
- package/SERVICES/CBR/$service/class.js +263 -0
- package/SERVICES/DaData/$service/class.js +352 -0
- package/SERVICES/DuckDuckGo/$service/class.js +368 -367
- package/SERVICES/RuCalendar/$service/class.js +289 -0
- package/SERVICES/SearXNG/$service/class.js +72 -70
- package/SERVICES/Telegram/$service/class.js +77 -21
- package/SERVICES/Weather/$service/class.js +78 -76
- package/SERVICES/Yandex/$service/class.js +122 -120
- package/SERVICES/YandexDisk/$service/class.js +191 -0
- package/SERVICES/readme.md +22 -34
- 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/folder.js +2 -0
- package/sources/client/index.js +32 -32
- package/sources/client/readme.md +16 -16
- package/sources/core.js +91 -91
- package/sources/data/api.js +4 -4
- package/sources/data/choices.js +125 -125
- package/sources/data/classes.js +3 -3
- package/sources/data/db.js +4 -2
- package/sources/data/print.js +1 -1
- package/sources/data/progress.md +25 -0
- package/sources/data/schema.js +3 -3
- package/sources/data/sql-inspector.js +10 -8
- package/sources/host/auto-updater.js +4 -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 +7 -0
- 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/host/watch.js +1 -1
- 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/extensions.js +118 -39
- 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/tools/work/classes.js +1 -1
- package/sources/modules/agent/tools/work/common.js +5 -5
- 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/agent/voice.js +1 -1
- 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/notify/index.js +4 -1
- package/sources/modules/rag/embed-worker.js +36 -36
- package/sources/modules/rag/indexer.js +1 -1
- package/sources/modules/rag/readme.md +70 -70
- package/sources/modules/rag/scope.js +4 -4
- 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 +24 -3
- package/sources/modules/trainer/huggingface.js +73 -11
- package/sources/modules/trainer/index.js +54 -29
- package/sources/modules/trainer/local-engine.js +38 -8
- package/sources/modules/trainer/paths.js +8 -0
- package/sources/modules/trainer/providers.js +14 -0
- package/sources/modules/trainer/worker/local_infer_worker.py +160 -1
- package/sources/readme.md +216 -216
- package/sources/server/access/audit.js +138 -138
- package/sources/server/access/gateway.js +1 -0
- package/sources/server/access/links.js +2 -2
- package/sources/server/access/refs.js +106 -106
- package/sources/server/access/workplaces.js +2 -2
- package/sources/server/assert-class-id.js +23 -23
- package/sources/server/class/archive.js +15 -13
- package/sources/server/class/base-template.js +146 -6
- package/sources/server/class/distro.js +847 -0
- package/sources/server/class/scaffold.js +1 -0
- package/sources/server/class/search.js +1 -1
- package/sources/server/class/security.js +2 -2
- package/sources/server/class.js +51 -22
- package/sources/server/external-source.js +90 -90
- package/sources/server/folder.js +6 -6
- package/sources/server/index.js +12 -12
- package/sources/server/logs.js +5 -4
- 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/server.js +110 -1
- 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
- package/SERVICES/ArgoCD/$service/$folder/$class/$service/class.js +0 -356
- package/SERVICES/ArgoCD/$service/$folder/$class/$service/handlers/pages/form/orders/$handler/class.js +0 -244
- package/SERVICES/ArgoCD/$service/$folder/$class/$service/handlers/pages/form/settings/$handler/class.js +0 -135
- package/SERVICES/ArgoCD/$service/class.js +0 -4
- package/SERVICES/ArgoCD/$service/readme.md +0 -63
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/class.js +0 -10
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/checkDomain/$method/class.js +0 -33
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/provision/$method/class.js +0 -225
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/methods/submitOrder/$method/class.js +0 -77
- package/SERVICES/ArgoCD/PaaS/$service/$folder/$class/$service/readme.md +0 -33
- package/SERVICES/ArgoCD/PaaS/$service/class.js +0 -347
- package/SERVICES/ArgoCD/PaaS/$service/order/pass.order +0 -9
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Создание (сохранение) полного автономного дистрибутива («функционального клона»)
|
|
3
|
+
* прямо из работающей и настроенной системы WORK (`sources/server/class/distro.js`).
|
|
4
|
+
*
|
|
5
|
+
* Что входит в дистрибутив:
|
|
6
|
+
* - Ядро и UI (`sources`, `oda`, `$server`, `scripts`, `rules`, `run.mjs`, `package.json`),
|
|
7
|
+
* презентационные материалы и пользовательская документация (`docs`, `readme.md`, `whitepaper.*`);
|
|
8
|
+
* - Настроенные эталонные модули (`/MODULES/**`) и сервисы (`/SERVICES/**`);
|
|
9
|
+
* - Чистые системные метапапки доменов (`/ORGANIZATIONS/$domain`, `/PROJECTS/$domain`,
|
|
10
|
+
* `/USERS/$users`, `/NODES/$node` / `/NODES/$nodes`) БЕЗ пользователей, организаций и проектов;
|
|
11
|
+
* - Опционально: `node_modules` (для 100% офлайн-запуска без `npm install`);
|
|
12
|
+
* - Опционально: локальные модели ИИ и веса (`/MODELS/Local/*`, `/MODELS/Halogen/*` с `#weights` и `#adapters`);
|
|
13
|
+
* - Опционально: локальный Python-рантайм (`.venv`);
|
|
14
|
+
* - Стартовые скрипты `start.cmd` (Windows) и `start.sh` (Linux/macOS) и чистый `$server/class.js`
|
|
15
|
+
* (чтобы на новой машине первый зарегистрированный пользователь автоматически стал BOSS).
|
|
16
|
+
*
|
|
17
|
+
* Особенности работы с тяжёлыми несжимаемыми весами моделей (`.safetensors`, `.gguf`, `.bin`, `.onnx`):
|
|
18
|
+
* - При сохранении в папку на диске (`mode: 'folder'`) для весов моделей используются жёсткие ссылки
|
|
19
|
+
* (`fs.linkSync` с автоматическим fallback на копирование между разными дисками) — клон с десятками ГБ
|
|
20
|
+
* моделей на том же томе создаётся за 1–2 секунды без дублирования места на диске.
|
|
21
|
+
* - При упаковке в `.zip` (`mode: 'zip'` или `mode: 'zip-file'`) используется потоковый генератор ZIP64,
|
|
22
|
+
* который пишет файлы весов методом `STORE` (0 — без сжатия и без загрузки в RAM), а исходный код
|
|
23
|
+
* сжимает методом `DEFLATE`.
|
|
24
|
+
*/
|
|
25
|
+
import * as fs from 'node:fs';
|
|
26
|
+
import path from 'node:path';
|
|
27
|
+
import zlib from 'node:zlib';
|
|
28
|
+
import { Readable } from 'node:stream';
|
|
29
|
+
import { pipeline } from 'node:stream/promises';
|
|
30
|
+
|
|
31
|
+
const STORE_EXTS = new Set([
|
|
32
|
+
'.safetensors', '.gguf', '.bin', '.onnx', '.pt', '.pth', '.hgn', '.hnpw',
|
|
33
|
+
'.zip', '.tgz', '.gz', '.bz2', '.xz', '.7z', '.whl',
|
|
34
|
+
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.ico',
|
|
35
|
+
'.mp3', '.wav', '.ogg', '.mp4', '.webm', '.pdf', '.woff', '.woff2',
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
const WEIGHT_EXTS = new Set([
|
|
39
|
+
'.safetensors', '.gguf', '.bin', '.onnx', '.pt', '.pth', '.hgn', '.hnpw',
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
/** Корневые файлы, включаемые в дистрибутив. */
|
|
43
|
+
const ALLOWED_ROOT_FILES = new Set([
|
|
44
|
+
'package.json',
|
|
45
|
+
'package-lock.json',
|
|
46
|
+
'run.mjs',
|
|
47
|
+
'favicon.ico',
|
|
48
|
+
'logo.png',
|
|
49
|
+
'sw.js',
|
|
50
|
+
'AGENTS.md',
|
|
51
|
+
'readme.md',
|
|
52
|
+
'whitepaper.md',
|
|
53
|
+
'whitepaper.pdf',
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
/** Корневые папки ядра и документации, всегда включаемые в дистрибутив. */
|
|
57
|
+
const CORE_DIRS = [
|
|
58
|
+
'$server',
|
|
59
|
+
'sources',
|
|
60
|
+
'oda',
|
|
61
|
+
'scripts',
|
|
62
|
+
'rules',
|
|
63
|
+
'docs',
|
|
64
|
+
'MODULES',
|
|
65
|
+
'SERVICES',
|
|
66
|
+
'ORGANIZATIONS/$domain',
|
|
67
|
+
'PROJECTS/$domain',
|
|
68
|
+
'USERS/$users',
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
function normRel(p) {
|
|
72
|
+
return String(p || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Проверить, нужно ли исключить путь из чистого дистрибутива.
|
|
77
|
+
*/
|
|
78
|
+
export function isExcludedFromDistro(relPath, opts = {}) {
|
|
79
|
+
const rel = normRel(relPath);
|
|
80
|
+
if (!rel)
|
|
81
|
+
return false;
|
|
82
|
+
|
|
83
|
+
// 1. Временные файлы, логи, БД, индексы, секреты
|
|
84
|
+
if (rel === '.data' || rel.startsWith('.data/') || rel === 'data' || rel.startsWith('data/'))
|
|
85
|
+
return true;
|
|
86
|
+
if (rel === '.index' || rel.startsWith('.index/'))
|
|
87
|
+
return true;
|
|
88
|
+
if (rel.includes('/.RAG/') || rel.endsWith('/.RAG'))
|
|
89
|
+
return true;
|
|
90
|
+
if (/\.(db|db-wal|db-shm|sqlite|sqlite3|log|tgz|part)$/i.test(rel))
|
|
91
|
+
return true;
|
|
92
|
+
if (rel === '#secret' || rel.startsWith('#secret/') || rel.includes('/#secret/'))
|
|
93
|
+
return true;
|
|
94
|
+
|
|
95
|
+
// 2. Локальные настройки и ключи внутри любых #system
|
|
96
|
+
if (rel.includes('/#system/')) {
|
|
97
|
+
if (rel.endsWith('/email.json') || rel.endsWith('/settings.json') || /\/work\.db/i.test(rel))
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 3. Рабочие файлы, задачи, логи и история внутри точек
|
|
102
|
+
if (rel.includes('/logs/') || rel.endsWith('/logs'))
|
|
103
|
+
return true;
|
|
104
|
+
if (rel.includes('/history/') || rel.endsWith('/history'))
|
|
105
|
+
return true;
|
|
106
|
+
if (/^(\$server)\/(logs|task|xlsx|docx|pdf|pptx)(\/|$)/.test(rel))
|
|
107
|
+
return true;
|
|
108
|
+
if (/\/\$[^/]+\/(DATA|ADMIN|USER|BOSS|work|task|call|xlsx|docx|pdf|pptx)(\/|$)/.test('/' + rel))
|
|
109
|
+
return true;
|
|
110
|
+
|
|
111
|
+
// 4. Временные папки тренера ИИ
|
|
112
|
+
if (rel.includes('/#tmp/') || rel.endsWith('/#tmp') || rel.includes('/#downloads/') || rel.endsWith('/#downloads') || rel.includes('/#cache/') || rel.endsWith('/#cache'))
|
|
113
|
+
return true;
|
|
114
|
+
|
|
115
|
+
// 5. Python .venv внутри sources/modules/*
|
|
116
|
+
if (rel.includes('/.venv/') || rel.endsWith('/.venv')) {
|
|
117
|
+
return !opts.includeVenv;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Подсчитать суммарный размер папки (быстрый синхронный обход).
|
|
125
|
+
*/
|
|
126
|
+
function calcDirStatsSync(absDir, filterFn = null) {
|
|
127
|
+
let bytes = 0;
|
|
128
|
+
let files = 0;
|
|
129
|
+
if (!fs.existsSync(absDir))
|
|
130
|
+
return { bytes, files };
|
|
131
|
+
const stack = [absDir];
|
|
132
|
+
while (stack.length) {
|
|
133
|
+
const cur = stack.pop();
|
|
134
|
+
let entries;
|
|
135
|
+
try {
|
|
136
|
+
entries = fs.readdirSync(cur, { withFileTypes: true });
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
for (const e of entries) {
|
|
142
|
+
const full = path.join(cur, e.name);
|
|
143
|
+
if (filterFn && !filterFn(full, e))
|
|
144
|
+
continue;
|
|
145
|
+
if (e.isDirectory()) {
|
|
146
|
+
stack.push(full);
|
|
147
|
+
}
|
|
148
|
+
else if (e.isFile()) {
|
|
149
|
+
try {
|
|
150
|
+
bytes += fs.statSync(full).size;
|
|
151
|
+
files++;
|
|
152
|
+
}
|
|
153
|
+
catch { /* ignore */ }
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return { bytes, files };
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Собрать список установленных локальных моделей ИИ (`/MODELS/Local/*` и `/MODELS/Halogen/*`).
|
|
162
|
+
*/
|
|
163
|
+
export function scanLocalModelsSync(rootDir = process.cwd()) {
|
|
164
|
+
const models = [];
|
|
165
|
+
const localDir = path.join(rootDir, 'MODELS', 'Local');
|
|
166
|
+
if (fs.existsSync(localDir)) {
|
|
167
|
+
for (const e of fs.readdirSync(localDir, { withFileTypes: true })) {
|
|
168
|
+
if (!e.isDirectory() || e.name.startsWith('$') || e.name.startsWith('.') || e.name.startsWith('#'))
|
|
169
|
+
continue;
|
|
170
|
+
const modAbs = path.join(localDir, e.name);
|
|
171
|
+
const st = calcDirStatsSync(modAbs, (full) => !/\.(part|log)$/i.test(full) && !full.includes('#tmp') && !full.includes('#downloads'));
|
|
172
|
+
models.push({
|
|
173
|
+
id: `Local/${e.name}`,
|
|
174
|
+
name: e.name,
|
|
175
|
+
provider: 'Local',
|
|
176
|
+
relPath: `MODELS/Local/${e.name}`,
|
|
177
|
+
bytes: st.bytes,
|
|
178
|
+
files: st.files,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const halogenDir = path.join(rootDir, 'MODELS', 'Halogen');
|
|
183
|
+
if (fs.existsSync(halogenDir)) {
|
|
184
|
+
const st = calcDirStatsSync(halogenDir, (full) => !/\.(part|log)$/i.test(full) && !full.includes('#tmp') && !full.includes('#downloads'));
|
|
185
|
+
if (st.files > 0) {
|
|
186
|
+
models.push({
|
|
187
|
+
id: 'Halogen',
|
|
188
|
+
name: 'Halogen (Ryzen AI Hybrid)',
|
|
189
|
+
provider: 'Halogen',
|
|
190
|
+
relPath: 'MODELS/Halogen',
|
|
191
|
+
bytes: st.bytes,
|
|
192
|
+
files: st.files,
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return models;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Сформировать полный список файлов `{ relPath, fullPath, size, isWeight }` для включения в дистрибутив.
|
|
201
|
+
*/
|
|
202
|
+
export function collectDistroEntriesSync(rootDir = process.cwd(), opts = {}) {
|
|
203
|
+
const absRoot = path.resolve(rootDir);
|
|
204
|
+
const includeNodeModules = opts.includeNodeModules !== false;
|
|
205
|
+
const includeModels = opts.includeModels !== false;
|
|
206
|
+
const includeVenv = opts.includeVenv === true;
|
|
207
|
+
const selectedModels = Array.isArray(opts.selectedModels) && opts.selectedModels.length
|
|
208
|
+
? new Set(opts.selectedModels.map(String))
|
|
209
|
+
: null;
|
|
210
|
+
|
|
211
|
+
const out = [];
|
|
212
|
+
const seen = new Set();
|
|
213
|
+
|
|
214
|
+
const addFile = (fullPath, relPath) => {
|
|
215
|
+
const norm = normRel(relPath);
|
|
216
|
+
if (!norm || seen.has(norm))
|
|
217
|
+
return;
|
|
218
|
+
// $server/class.js генерируется отдельно без привязки к BOSS текущего сервера
|
|
219
|
+
if (norm === '$server/class.js')
|
|
220
|
+
return;
|
|
221
|
+
if (isExcludedFromDistro(norm, { includeVenv }))
|
|
222
|
+
return;
|
|
223
|
+
let st;
|
|
224
|
+
try {
|
|
225
|
+
st = fs.statSync(fullPath);
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (!st.isFile())
|
|
231
|
+
return;
|
|
232
|
+
seen.add(norm);
|
|
233
|
+
const ext = path.extname(norm).toLowerCase();
|
|
234
|
+
out.push({
|
|
235
|
+
relPath: norm,
|
|
236
|
+
fullPath,
|
|
237
|
+
size: st.size,
|
|
238
|
+
isWeight: WEIGHT_EXTS.has(ext) || norm.includes('/#weights/'),
|
|
239
|
+
storeOnly: STORE_EXTS.has(ext) || st.size > 32 * 1024 * 1024,
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
const walkRelDir = (relDir) => {
|
|
244
|
+
const absDir = path.join(absRoot, relDir);
|
|
245
|
+
if (!fs.existsSync(absDir))
|
|
246
|
+
return;
|
|
247
|
+
const stack = [absDir];
|
|
248
|
+
while (stack.length) {
|
|
249
|
+
const cur = stack.pop();
|
|
250
|
+
let entries;
|
|
251
|
+
try {
|
|
252
|
+
entries = fs.readdirSync(cur, { withFileTypes: true });
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
for (const e of entries) {
|
|
258
|
+
const full = path.join(cur, e.name);
|
|
259
|
+
const rel = normRel(path.relative(absRoot, full));
|
|
260
|
+
if (isExcludedFromDistro(rel, { includeVenv }))
|
|
261
|
+
continue;
|
|
262
|
+
if (e.isDirectory()) {
|
|
263
|
+
stack.push(full);
|
|
264
|
+
}
|
|
265
|
+
else if (e.isFile()) {
|
|
266
|
+
addFile(full, rel);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
// 1. Разрешённые корневые файлы
|
|
273
|
+
for (const fname of ALLOWED_ROOT_FILES) {
|
|
274
|
+
const full = path.join(absRoot, fname);
|
|
275
|
+
if (fs.existsSync(full))
|
|
276
|
+
addFile(full, fname);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// 2. Безопасные файлы из корневого #system (сертификаты и sandbox.json)
|
|
280
|
+
for (const sub of ['#system/certs', '#system/sandbox.json']) {
|
|
281
|
+
const full = path.join(absRoot, sub);
|
|
282
|
+
if (!fs.existsSync(full))
|
|
283
|
+
continue;
|
|
284
|
+
if (fs.statSync(full).isDirectory())
|
|
285
|
+
walkRelDir(sub);
|
|
286
|
+
else
|
|
287
|
+
addFile(full, sub);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// 3. Ядро, UI, модули, сервисы и чистые метапапки доменов
|
|
291
|
+
for (const dir of CORE_DIRS) {
|
|
292
|
+
walkRelDir(dir);
|
|
293
|
+
}
|
|
294
|
+
for (const nodeMeta of ['NODES/$node', 'NODES/$nodes']) {
|
|
295
|
+
if (fs.existsSync(path.join(absRoot, nodeMeta)))
|
|
296
|
+
walkRelDir(nodeMeta);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// 4. Раздел /MODELS (метапапки, шаблоны облачных провайдеров без #secret и выбранные локальные модели)
|
|
300
|
+
const modelsRoot = path.join(absRoot, 'MODELS');
|
|
301
|
+
if (fs.existsSync(modelsRoot)) {
|
|
302
|
+
for (const e of fs.readdirSync(modelsRoot, { withFileTypes: true })) {
|
|
303
|
+
if (!e.isDirectory())
|
|
304
|
+
continue;
|
|
305
|
+
if (e.name === 'odant')
|
|
306
|
+
continue; // внутренний контур разработчика
|
|
307
|
+
if (e.name === 'Local') {
|
|
308
|
+
walkRelDir('MODELS/Local/$provider');
|
|
309
|
+
if (includeModels) {
|
|
310
|
+
const localAbs = path.join(modelsRoot, 'Local');
|
|
311
|
+
for (const me of fs.readdirSync(localAbs, { withFileTypes: true })) {
|
|
312
|
+
if (!me.isDirectory() || me.name.startsWith('$') || me.name.startsWith('.'))
|
|
313
|
+
continue;
|
|
314
|
+
const modKey = `Local/${me.name}`;
|
|
315
|
+
if (selectedModels && !selectedModels.has(modKey) && !selectedModels.has(me.name))
|
|
316
|
+
continue;
|
|
317
|
+
walkRelDir(`MODELS/Local/${me.name}`);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
else if (e.name === 'Halogen') {
|
|
322
|
+
if (includeModels && (!selectedModels || selectedModels.has('Halogen')))
|
|
323
|
+
walkRelDir('MODELS/Halogen');
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
// $domain, $ai и облачные провайдеры (OpenAI, Anthropic, ...) — их #secret отфильтруется в isExcludedFromDistro
|
|
327
|
+
walkRelDir(`MODELS/${e.name}`);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// 5. Опционально node_modules (для полной офлайн-установки)
|
|
333
|
+
if (includeNodeModules && fs.existsSync(path.join(absRoot, 'node_modules'))) {
|
|
334
|
+
const nmRoot = path.join(absRoot, 'node_modules');
|
|
335
|
+
const stack = [nmRoot];
|
|
336
|
+
while (stack.length) {
|
|
337
|
+
const cur = stack.pop();
|
|
338
|
+
let entries;
|
|
339
|
+
try {
|
|
340
|
+
entries = fs.readdirSync(cur, { withFileTypes: true });
|
|
341
|
+
}
|
|
342
|
+
catch {
|
|
343
|
+
continue;
|
|
344
|
+
}
|
|
345
|
+
for (const e of entries) {
|
|
346
|
+
if (e.name === '.cache')
|
|
347
|
+
continue;
|
|
348
|
+
const full = path.join(cur, e.name);
|
|
349
|
+
const rel = normRel(path.relative(absRoot, full));
|
|
350
|
+
if (e.isDirectory()) {
|
|
351
|
+
stack.push(full);
|
|
352
|
+
}
|
|
353
|
+
else if (e.isFile()) {
|
|
354
|
+
let st;
|
|
355
|
+
try { st = fs.statSync(full); }
|
|
356
|
+
catch { continue; }
|
|
357
|
+
seen.add(rel);
|
|
358
|
+
const ext = path.extname(rel).toLowerCase();
|
|
359
|
+
out.push({
|
|
360
|
+
relPath: rel,
|
|
361
|
+
fullPath: full,
|
|
362
|
+
size: st.size,
|
|
363
|
+
isWeight: false,
|
|
364
|
+
storeOnly: STORE_EXTS.has(ext),
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
return out;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Сгенерировать виртуальные файлы чистого клона (`$server/class.js`, `start.cmd`, `start.sh`).
|
|
376
|
+
*/
|
|
377
|
+
export function buildDistroSyntheticFiles() {
|
|
378
|
+
const cleanServerClassJs = `export default {\n icon: "./odant.png",\n}\n`;
|
|
379
|
+
const startCmd = `@echo off\r\nchcp 65001 >nul\r\ncd /d "%~dp0"\r\necho Запуск ODANT-WORK...\r\nnode run.mjs\r\n`;
|
|
380
|
+
const startSh = `#!/usr/bin/env sh\ncd "$(dirname "$0")"\necho "Starting ODANT-WORK..."\nexec node run.mjs\n`;
|
|
381
|
+
return [
|
|
382
|
+
{ relPath: '$server/class.js', content: Buffer.from(cleanServerClassJs, 'utf-8') },
|
|
383
|
+
{ relPath: 'start.cmd', content: Buffer.from(startCmd, 'utf-8') },
|
|
384
|
+
{ relPath: 'start.sh', content: Buffer.from(startSh, 'utf-8'), mode: 0o755 },
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Сохранить дистрибутив напрямую в папку на диске сервера (`mode: 'folder'`).
|
|
390
|
+
* Для тяжёлых файлов весов на том же томе использует мгновенные жёсткие ссылки (`fs.linkSync`).
|
|
391
|
+
*/
|
|
392
|
+
export function exportDistroToFolderSync(rootDir, targetDir, opts = {}) {
|
|
393
|
+
const absRoot = path.resolve(rootDir);
|
|
394
|
+
const absTarget = path.resolve(absRoot, targetDir);
|
|
395
|
+
|
|
396
|
+
if (absTarget === absRoot)
|
|
397
|
+
throw new Error('Целевая папка не может совпадать с рабочей папкой запущенного сервера');
|
|
398
|
+
if (absTarget.startsWith(absRoot + path.sep))
|
|
399
|
+
throw new Error('Укажите папку за пределами рабочей директории сервера (например, ../odant-work-distro)');
|
|
400
|
+
|
|
401
|
+
const entries = collectDistroEntriesSync(absRoot, opts);
|
|
402
|
+
const synthetic = buildDistroSyntheticFiles();
|
|
403
|
+
|
|
404
|
+
fs.mkdirSync(absTarget, { recursive: true });
|
|
405
|
+
|
|
406
|
+
let filesCount = 0;
|
|
407
|
+
let hardlinkedCount = 0;
|
|
408
|
+
let totalBytes = 0;
|
|
409
|
+
|
|
410
|
+
for (const item of entries) {
|
|
411
|
+
const dst = path.join(absTarget, item.relPath);
|
|
412
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
413
|
+
if (fs.existsSync(dst)) {
|
|
414
|
+
try { fs.unlinkSync(dst); }
|
|
415
|
+
catch { /* ignore */ }
|
|
416
|
+
}
|
|
417
|
+
let linked = false;
|
|
418
|
+
if (item.isWeight || item.size >= 1024 * 1024) {
|
|
419
|
+
try {
|
|
420
|
+
fs.linkSync(item.fullPath, dst);
|
|
421
|
+
linked = true;
|
|
422
|
+
hardlinkedCount++;
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
linked = false;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
if (!linked) {
|
|
429
|
+
fs.copyFileSync(item.fullPath, dst);
|
|
430
|
+
}
|
|
431
|
+
filesCount++;
|
|
432
|
+
totalBytes += item.size;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Создаём пустые папки-контейнеры для быстрого старта
|
|
436
|
+
for (const emptyDir of ['ORGANIZATIONS', 'PROJECTS', 'USERS', 'NODES', 'MODELS/Local', '#system']) {
|
|
437
|
+
fs.mkdirSync(path.join(absTarget, emptyDir), { recursive: true });
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
for (const s of synthetic) {
|
|
441
|
+
const dst = path.join(absTarget, s.relPath);
|
|
442
|
+
fs.mkdirSync(path.dirname(dst), { recursive: true });
|
|
443
|
+
fs.writeFileSync(dst, s.content);
|
|
444
|
+
if (s.mode) {
|
|
445
|
+
try { fs.chmodSync(dst, s.mode); }
|
|
446
|
+
catch { /* ignore on Windows */ }
|
|
447
|
+
}
|
|
448
|
+
filesCount++;
|
|
449
|
+
totalBytes += s.content.length;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
return {
|
|
453
|
+
ok: true,
|
|
454
|
+
mode: 'folder',
|
|
455
|
+
targetDir: absTarget,
|
|
456
|
+
filesCount,
|
|
457
|
+
hardlinkedCount,
|
|
458
|
+
totalBytes,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Потоковый генератор ZIP64:
|
|
464
|
+
* - поддерживает файлы и архивы любого размера (> 4 ГБ, спецификация ZIP64);
|
|
465
|
+
* - файлы весов моделей (`storeOnly: true`) отдаёт методом `STORE` (0 — без сжатия, напрямую потоком с диска);
|
|
466
|
+
* - исходники и текстовые файлы сжимает методом `DEFLATE` (8).
|
|
467
|
+
*/
|
|
468
|
+
export function createDistroZipStream(rootDir, opts = {}) {
|
|
469
|
+
const absRoot = path.resolve(rootDir);
|
|
470
|
+
const entries = collectDistroEntriesSync(absRoot, opts);
|
|
471
|
+
const synthetic = buildDistroSyntheticFiles();
|
|
472
|
+
|
|
473
|
+
return Readable.from(generateZip64Chunks(entries, synthetic));
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function dosDateTime(date = new Date()) {
|
|
477
|
+
const year = Math.max(1980, date.getFullYear());
|
|
478
|
+
const month = date.getMonth() + 1;
|
|
479
|
+
const day = date.getDate();
|
|
480
|
+
const hours = date.getHours();
|
|
481
|
+
const minutes = date.getMinutes();
|
|
482
|
+
const seconds = Math.floor(date.getSeconds() / 2);
|
|
483
|
+
const dosTime = (hours << 11) | (minutes << 5) | seconds;
|
|
484
|
+
const dosDate = ((year - 1980) << 9) | (month << 5) | day;
|
|
485
|
+
return { dosTime, dosDate };
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function buildZip64Extra(uncompressedSize, compressedSize, offset = null) {
|
|
489
|
+
const hasOffset = offset !== null;
|
|
490
|
+
const buf = Buffer.alloc(4 + (hasOffset ? 24 : 16));
|
|
491
|
+
buf.writeUInt16LE(0x0001, 0); // Header ID: ZIP64
|
|
492
|
+
buf.writeUInt16LE(hasOffset ? 24 : 16, 2); // Data Size
|
|
493
|
+
buf.writeBigUInt64LE(BigInt(uncompressedSize), 4);
|
|
494
|
+
buf.writeBigUInt64LE(BigInt(compressedSize), 12);
|
|
495
|
+
if (hasOffset)
|
|
496
|
+
buf.writeBigUInt64LE(BigInt(offset), 20);
|
|
497
|
+
return buf;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
async function* generateZip64Chunks(entries, synthetic) {
|
|
501
|
+
const centralDir = [];
|
|
502
|
+
let offset = 0n;
|
|
503
|
+
const { dosTime, dosDate } = dosDateTime();
|
|
504
|
+
|
|
505
|
+
// 1. Синтетические файлы в памяти (start.cmd, start.sh, $server/class.js)
|
|
506
|
+
for (const s of synthetic) {
|
|
507
|
+
const nameBuf = Buffer.from(s.relPath, 'utf-8');
|
|
508
|
+
const rawBuf = s.content;
|
|
509
|
+
const crc = zlib.crc32(rawBuf, 0) >>> 0;
|
|
510
|
+
const compBuf = zlib.deflateRawSync(rawBuf);
|
|
511
|
+
const uncompSize = rawBuf.length;
|
|
512
|
+
const compSize = compBuf.length;
|
|
513
|
+
|
|
514
|
+
const lfh = Buffer.alloc(30);
|
|
515
|
+
lfh.writeUInt32LE(0x04034b50, 0); // Local File Header signature
|
|
516
|
+
lfh.writeUInt16LE(45, 4); // Version needed (4.5 for ZIP64)
|
|
517
|
+
lfh.writeUInt16LE(0x0800, 6); // Flags: UTF-8
|
|
518
|
+
lfh.writeUInt16LE(8, 8); // Method: DEFLATE
|
|
519
|
+
lfh.writeUInt16LE(dosTime, 10);
|
|
520
|
+
lfh.writeUInt16LE(dosDate, 12);
|
|
521
|
+
lfh.writeUInt32LE(crc, 14);
|
|
522
|
+
lfh.writeUInt32LE(compSize, 18);
|
|
523
|
+
lfh.writeUInt32LE(uncompSize, 22);
|
|
524
|
+
lfh.writeUInt16LE(nameBuf.length, 26);
|
|
525
|
+
lfh.writeUInt16LE(0, 28);
|
|
526
|
+
|
|
527
|
+
const localOffset = offset;
|
|
528
|
+
yield lfh;
|
|
529
|
+
yield nameBuf;
|
|
530
|
+
yield compBuf;
|
|
531
|
+
offset += BigInt(lfh.length + nameBuf.length + compBuf.length);
|
|
532
|
+
|
|
533
|
+
centralDir.push({
|
|
534
|
+
nameBuf,
|
|
535
|
+
method: 8,
|
|
536
|
+
flags: 0x0800,
|
|
537
|
+
crc,
|
|
538
|
+
compSize,
|
|
539
|
+
uncompSize,
|
|
540
|
+
localOffset,
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
// 2. Файлы с диска
|
|
545
|
+
for (const item of entries) {
|
|
546
|
+
if (!fs.existsSync(item.fullPath))
|
|
547
|
+
continue;
|
|
548
|
+
const nameBuf = Buffer.from(item.relPath, 'utf-8');
|
|
549
|
+
const localOffset = offset;
|
|
550
|
+
|
|
551
|
+
// Для небольших текстовых файлов (< 8 МБ и не storeOnly) — быстрое сжатие DEFLATE
|
|
552
|
+
if (!item.storeOnly && item.size < 8 * 1024 * 1024) {
|
|
553
|
+
let rawBuf;
|
|
554
|
+
try {
|
|
555
|
+
rawBuf = fs.readFileSync(item.fullPath);
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
const crc = zlib.crc32(rawBuf, 0) >>> 0;
|
|
561
|
+
const compBuf = zlib.deflateRawSync(rawBuf);
|
|
562
|
+
const uncompSize = rawBuf.length;
|
|
563
|
+
const compSize = compBuf.length;
|
|
564
|
+
|
|
565
|
+
const lfh = Buffer.alloc(30);
|
|
566
|
+
lfh.writeUInt32LE(0x04034b50, 0);
|
|
567
|
+
lfh.writeUInt16LE(45, 4);
|
|
568
|
+
lfh.writeUInt16LE(0x0800, 6); // UTF-8
|
|
569
|
+
lfh.writeUInt16LE(8, 8); // DEFLATE
|
|
570
|
+
lfh.writeUInt16LE(dosTime, 10);
|
|
571
|
+
lfh.writeUInt16LE(dosDate, 12);
|
|
572
|
+
lfh.writeUInt32LE(crc, 14);
|
|
573
|
+
lfh.writeUInt32LE(compSize, 18);
|
|
574
|
+
lfh.writeUInt32LE(uncompSize, 22);
|
|
575
|
+
lfh.writeUInt16LE(nameBuf.length, 26);
|
|
576
|
+
lfh.writeUInt16LE(0, 28);
|
|
577
|
+
|
|
578
|
+
yield lfh;
|
|
579
|
+
yield nameBuf;
|
|
580
|
+
yield compBuf;
|
|
581
|
+
offset += BigInt(lfh.length + nameBuf.length + compBuf.length);
|
|
582
|
+
|
|
583
|
+
centralDir.push({
|
|
584
|
+
nameBuf,
|
|
585
|
+
method: 8,
|
|
586
|
+
flags: 0x0800,
|
|
587
|
+
crc,
|
|
588
|
+
compSize,
|
|
589
|
+
uncompSize,
|
|
590
|
+
localOffset,
|
|
591
|
+
});
|
|
592
|
+
continue;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// Для тяжёлых файлов и весов моделей (.safetensors, .gguf, ...) — потоковый STORE (метод 0, без сжатия!)
|
|
596
|
+
// Используем bit 3 (0x0008 — Data Descriptor после тела файла) + bit 11 (0x0800 — UTF-8)
|
|
597
|
+
const flags = 0x0808;
|
|
598
|
+
const lfh = Buffer.alloc(30);
|
|
599
|
+
lfh.writeUInt32LE(0x04034b50, 0);
|
|
600
|
+
lfh.writeUInt16LE(45, 4); // Version 4.5 (ZIP64)
|
|
601
|
+
lfh.writeUInt16LE(flags, 6);
|
|
602
|
+
lfh.writeUInt16LE(0, 8); // Method 0: STORE (без сжатия)
|
|
603
|
+
lfh.writeUInt16LE(dosTime, 10);
|
|
604
|
+
lfh.writeUInt16LE(dosDate, 12);
|
|
605
|
+
lfh.writeUInt32LE(0, 14); // CRC-32 в Data Descriptor
|
|
606
|
+
lfh.writeUInt32LE(0, 18); // Compressed size в Data Descriptor
|
|
607
|
+
lfh.writeUInt32LE(0, 22); // Uncompressed size в Data Descriptor
|
|
608
|
+
lfh.writeUInt16LE(nameBuf.length, 26);
|
|
609
|
+
lfh.writeUInt16LE(0, 28);
|
|
610
|
+
|
|
611
|
+
yield lfh;
|
|
612
|
+
yield nameBuf;
|
|
613
|
+
offset += BigInt(lfh.length + nameBuf.length);
|
|
614
|
+
|
|
615
|
+
let crc = 0;
|
|
616
|
+
let streamedBytes = 0;
|
|
617
|
+
const rs = fs.createReadStream(item.fullPath, { highWaterMark: 4 * 1024 * 1024 });
|
|
618
|
+
for await (const chunk of rs) {
|
|
619
|
+
crc = zlib.crc32(chunk, crc) >>> 0;
|
|
620
|
+
streamedBytes += chunk.length;
|
|
621
|
+
yield chunk;
|
|
622
|
+
offset += BigInt(chunk.length);
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
// ZIP64 Data Descriptor (24 байта: signature 4B + crc 4B + compSize 8B + uncompSize 8B)
|
|
626
|
+
const dd = Buffer.alloc(24);
|
|
627
|
+
dd.writeUInt32LE(0x08074b50, 0);
|
|
628
|
+
dd.writeUInt32LE(crc >>> 0, 4);
|
|
629
|
+
dd.writeBigUInt64LE(BigInt(streamedBytes), 8);
|
|
630
|
+
dd.writeBigUInt64LE(BigInt(streamedBytes), 16);
|
|
631
|
+
yield dd;
|
|
632
|
+
offset += BigInt(dd.length);
|
|
633
|
+
|
|
634
|
+
centralDir.push({
|
|
635
|
+
nameBuf,
|
|
636
|
+
method: 0,
|
|
637
|
+
flags,
|
|
638
|
+
crc: crc >>> 0,
|
|
639
|
+
compSize: streamedBytes,
|
|
640
|
+
uncompSize: streamedBytes,
|
|
641
|
+
localOffset,
|
|
642
|
+
isZip64Descriptor: true,
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// 3. Central Directory
|
|
647
|
+
const cdStartOffset = offset;
|
|
648
|
+
let cdSize = 0n;
|
|
649
|
+
|
|
650
|
+
for (const cd of centralDir) {
|
|
651
|
+
const needZip64 = cd.isZip64Descriptor
|
|
652
|
+
|| cd.compSize >= 0xffffffff
|
|
653
|
+
|| cd.uncompSize >= 0xffffffff
|
|
654
|
+
|| cd.localOffset >= 0xffffffffn;
|
|
655
|
+
const extraBuf = needZip64
|
|
656
|
+
? buildZip64Extra(cd.uncompSize, cd.compSize, cd.localOffset)
|
|
657
|
+
: Buffer.alloc(0);
|
|
658
|
+
|
|
659
|
+
const cdh = Buffer.alloc(46);
|
|
660
|
+
cdh.writeUInt32LE(0x02014b50, 0); // Central directory file header signature
|
|
661
|
+
cdh.writeUInt16LE(45, 4); // Version made by
|
|
662
|
+
cdh.writeUInt16LE(45, 6); // Version needed to extract
|
|
663
|
+
cdh.writeUInt16LE(cd.flags, 8);
|
|
664
|
+
cdh.writeUInt16LE(cd.method, 10);
|
|
665
|
+
cdh.writeUInt16LE(dosTime, 12);
|
|
666
|
+
cdh.writeUInt16LE(dosDate, 14);
|
|
667
|
+
cdh.writeUInt32LE(cd.crc >>> 0, 16);
|
|
668
|
+
cdh.writeUInt32LE(needZip64 ? 0xffffffff : cd.compSize, 20);
|
|
669
|
+
cdh.writeUInt32LE(needZip64 ? 0xffffffff : cd.uncompSize, 24);
|
|
670
|
+
cdh.writeUInt16LE(cd.nameBuf.length, 28);
|
|
671
|
+
cdh.writeUInt16LE(extraBuf.length, 30);
|
|
672
|
+
cdh.writeUInt16LE(0, 32); // Comment length
|
|
673
|
+
cdh.writeUInt16LE(0, 34); // Disk number
|
|
674
|
+
cdh.writeUInt16LE(0, 36); // Internal attrs
|
|
675
|
+
cdh.writeUInt32LE(0, 38); // External attrs
|
|
676
|
+
cdh.writeUInt32LE(needZip64 ? 0xffffffff : Number(cd.localOffset), 42);
|
|
677
|
+
|
|
678
|
+
yield cdh;
|
|
679
|
+
yield cd.nameBuf;
|
|
680
|
+
if (extraBuf.length)
|
|
681
|
+
yield extraBuf;
|
|
682
|
+
const entryLen = BigInt(cdh.length + cd.nameBuf.length + extraBuf.length);
|
|
683
|
+
cdSize += entryLen;
|
|
684
|
+
offset += entryLen;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const totalEntries = BigInt(centralDir.length);
|
|
688
|
+
const eocd64Offset = offset;
|
|
689
|
+
|
|
690
|
+
// 4. ZIP64 End of Central Directory Record (56 байт)
|
|
691
|
+
const eocd64 = Buffer.alloc(56);
|
|
692
|
+
eocd64.writeUInt32LE(0x06064b50, 0);
|
|
693
|
+
eocd64.writeBigUInt64LE(44n, 4); // Size of remaining record
|
|
694
|
+
eocd64.writeUInt16LE(45, 12);
|
|
695
|
+
eocd64.writeUInt16LE(45, 14);
|
|
696
|
+
eocd64.writeUInt32LE(0, 16);
|
|
697
|
+
eocd64.writeUInt32LE(0, 20);
|
|
698
|
+
eocd64.writeBigUInt64LE(totalEntries, 24);
|
|
699
|
+
eocd64.writeBigUInt64LE(totalEntries, 32);
|
|
700
|
+
eocd64.writeBigUInt64LE(cdSize, 40);
|
|
701
|
+
eocd64.writeBigUInt64LE(cdStartOffset, 48);
|
|
702
|
+
yield eocd64;
|
|
703
|
+
|
|
704
|
+
// 5. ZIP64 End of Central Directory Locator (20 байт)
|
|
705
|
+
const locator = Buffer.alloc(20);
|
|
706
|
+
locator.writeUInt32LE(0x07064b50, 0);
|
|
707
|
+
locator.writeUInt32LE(0, 4);
|
|
708
|
+
locator.writeBigUInt64LE(eocd64Offset, 8);
|
|
709
|
+
locator.writeUInt32LE(1, 16);
|
|
710
|
+
yield locator;
|
|
711
|
+
|
|
712
|
+
// 6. Standard End of Central Directory Record (22 байта)
|
|
713
|
+
const eocd = Buffer.alloc(22);
|
|
714
|
+
eocd.writeUInt32LE(0x06054b50, 0);
|
|
715
|
+
eocd.writeUInt16LE(0, 4);
|
|
716
|
+
eocd.writeUInt16LE(0, 6);
|
|
717
|
+
eocd.writeUInt16LE(totalEntries >= 0xffffn ? 0xffff : Number(totalEntries), 8);
|
|
718
|
+
eocd.writeUInt16LE(totalEntries >= 0xffffn ? 0xffff : Number(totalEntries), 10);
|
|
719
|
+
eocd.writeUInt32LE(cdSize >= 0xffffffffn ? 0xffffffff : Number(cdSize), 12);
|
|
720
|
+
eocd.writeUInt32LE(cdStartOffset >= 0xffffffffn ? 0xffffffff : Number(cdStartOffset), 16);
|
|
721
|
+
eocd.writeUInt16LE(0, 20);
|
|
722
|
+
yield eocd;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function parseBoolParam(v, def = true) {
|
|
726
|
+
if (v === undefined || v === null || v === '')
|
|
727
|
+
return def;
|
|
728
|
+
if (typeof v === 'boolean')
|
|
729
|
+
return v;
|
|
730
|
+
const s = String(v).trim().toLowerCase();
|
|
731
|
+
return !(s === 'false' || s === '0' || s === 'no');
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export const serverDistroMethods = {
|
|
735
|
+
/**
|
|
736
|
+
* Получить сводку компонентов и размеров перед созданием дистрибутива (доступно BOSS сервера).
|
|
737
|
+
*/
|
|
738
|
+
async distro_info(params = {}) {
|
|
739
|
+
await this.assertAccess(params, this.constructor.ACCESS_LEVEL.ADMIN);
|
|
740
|
+
const rootDir = path.resolve(this.dir || process.cwd());
|
|
741
|
+
|
|
742
|
+
const coreEntries = collectDistroEntriesSync(rootDir, {
|
|
743
|
+
includeNodeModules: false,
|
|
744
|
+
includeModels: false,
|
|
745
|
+
includeVenv: false,
|
|
746
|
+
});
|
|
747
|
+
const coreBytes = coreEntries.reduce((acc, f) => acc + f.size, 0);
|
|
748
|
+
|
|
749
|
+
const nmDir = path.join(rootDir, 'node_modules');
|
|
750
|
+
const nmStats = fs.existsSync(nmDir)
|
|
751
|
+
? calcDirStatsSync(nmDir, (_full, e) => e.name !== '.cache')
|
|
752
|
+
: { bytes: 0, files: 0 };
|
|
753
|
+
|
|
754
|
+
const models = scanLocalModelsSync(rootDir);
|
|
755
|
+
const modelsBytes = models.reduce((acc, m) => acc + m.bytes, 0);
|
|
756
|
+
|
|
757
|
+
let venvBytes = 0;
|
|
758
|
+
let hasVenv = false;
|
|
759
|
+
const modulesDir = path.join(rootDir, 'sources', 'modules');
|
|
760
|
+
if (fs.existsSync(modulesDir)) {
|
|
761
|
+
for (const e of fs.readdirSync(modulesDir, { withFileTypes: true })) {
|
|
762
|
+
if (!e.isDirectory())
|
|
763
|
+
continue;
|
|
764
|
+
const vDir = path.join(modulesDir, e.name, '.venv');
|
|
765
|
+
if (fs.existsSync(vDir)) {
|
|
766
|
+
hasVenv = true;
|
|
767
|
+
venvBytes += calcDirStatsSync(vDir).bytes;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
const defaultTargetDir = path.resolve(rootDir, '..', 'odant-work-distro');
|
|
773
|
+
const defaultZipPath = path.resolve(rootDir, '..', 'odant-work-distro.zip');
|
|
774
|
+
|
|
775
|
+
return {
|
|
776
|
+
coreBytes,
|
|
777
|
+
coreFiles: coreEntries.length,
|
|
778
|
+
hasNodeModules: nmStats.files > 0,
|
|
779
|
+
nodeModulesBytes: nmStats.bytes,
|
|
780
|
+
models,
|
|
781
|
+
modelsBytes,
|
|
782
|
+
hasVenv,
|
|
783
|
+
venvBytes,
|
|
784
|
+
defaultTargetDir,
|
|
785
|
+
defaultZipPath,
|
|
786
|
+
};
|
|
787
|
+
},
|
|
788
|
+
|
|
789
|
+
/**
|
|
790
|
+
* Создать дистрибутив («функциональный клон») текущей настроенной системы WORK:
|
|
791
|
+
* - `mode: 'folder'` — сохранить готовую папку-клон в `targetDir` на диске сервера (с hardlink для весов моделей);
|
|
792
|
+
* - `mode: 'zip-file'` — сохранить ZIP64-архив в `targetPath` на диске сервера (`STORE` для весов моделей);
|
|
793
|
+
* - `mode: 'zip'` — отдать потоковый ZIP64-архив для скачивания в браузере.
|
|
794
|
+
*/
|
|
795
|
+
async export_distro(params = {}) {
|
|
796
|
+
await this.assertAccess(params, this.constructor.ACCESS_LEVEL.ADMIN);
|
|
797
|
+
const rootDir = path.resolve(this.dir || process.cwd());
|
|
798
|
+
const post = (params.post && typeof params.post === 'object' && !Buffer.isBuffer(params.post)) ? params.post : {};
|
|
799
|
+
|
|
800
|
+
const mode = String(post.mode || params.mode || 'zip').trim();
|
|
801
|
+
const includeNodeModules = parseBoolParam(post.includeNodeModules ?? params.includeNodeModules, true);
|
|
802
|
+
const includeModels = parseBoolParam(post.includeModels ?? params.includeModels, true);
|
|
803
|
+
const includeVenv = parseBoolParam(post.includeVenv ?? params.includeVenv, false);
|
|
804
|
+
const rawSelected = post.selectedModels ?? params.selectedModels;
|
|
805
|
+
const selectedModels = Array.isArray(rawSelected)
|
|
806
|
+
? rawSelected
|
|
807
|
+
: (typeof rawSelected === 'string' && rawSelected.trim() ? rawSelected.split(',').map(s => s.trim()).filter(Boolean) : null);
|
|
808
|
+
|
|
809
|
+
const opts = {
|
|
810
|
+
includeNodeModules,
|
|
811
|
+
includeModels,
|
|
812
|
+
includeVenv,
|
|
813
|
+
selectedModels,
|
|
814
|
+
};
|
|
815
|
+
|
|
816
|
+
if (mode === 'folder') {
|
|
817
|
+
const targetDir = String(post.targetDir || params.targetDir || path.resolve(rootDir, '..', 'odant-work-distro')).trim();
|
|
818
|
+
if (!targetDir)
|
|
819
|
+
throw new Error('Не указана целевая папка для сохранения дистрибутива');
|
|
820
|
+
return exportDistroToFolderSync(rootDir, targetDir, opts);
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
if (mode === 'zip-file') {
|
|
824
|
+
const targetPath = String(post.targetPath || post.targetDir || params.targetPath || path.resolve(rootDir, '..', 'odant-work-distro.zip')).trim();
|
|
825
|
+
if (!targetPath)
|
|
826
|
+
throw new Error('Не указан путь файла .zip для сохранения дистрибутива');
|
|
827
|
+
const absZip = path.resolve(rootDir, targetPath.endsWith('.zip') ? targetPath : `${targetPath}.zip`);
|
|
828
|
+
if (absZip.startsWith(rootDir + path.sep))
|
|
829
|
+
throw new Error('Укажите путь .zip за пределами рабочей директории сервера');
|
|
830
|
+
fs.mkdirSync(path.dirname(absZip), { recursive: true });
|
|
831
|
+
const zipStream = createDistroZipStream(rootDir, opts);
|
|
832
|
+
const ws = fs.createWriteStream(absZip);
|
|
833
|
+
await pipeline(zipStream, ws);
|
|
834
|
+
const st = fs.statSync(absZip);
|
|
835
|
+
return {
|
|
836
|
+
ok: true,
|
|
837
|
+
mode: 'zip-file',
|
|
838
|
+
targetPath: absZip,
|
|
839
|
+
totalBytes: st.size,
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
// mode === 'zip' (потоковое скачивание через браузер)
|
|
844
|
+
params.filename = String(params.filename || 'odant-work-distro.zip');
|
|
845
|
+
return createDistroZipStream(rootDir, opts);
|
|
846
|
+
},
|
|
847
|
+
};
|