@galaxy-blackhole/blackhole-harness 0.1.0 → 0.1.2
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/apps/cli/lib/main.js +548 -261
- package/apps/cli/src/mount-gate.ts +492 -0
- package/apps/cli/src/mount.ts +30 -7
- package/apps/cli/src/paths.ts +7 -1
- package/apps/cli/src/prebuilt.ts +4 -1
- package/apps/cli/src/runtime.ts +8 -4
- package/package.json +1 -1
- package/packages/client/connection/lib/types/client/api.d.ts +58 -0
- package/packages/client/connection/lib/types/client/connection.d.ts +127 -0
- package/packages/client/connection/lib/types/client/plugin.d.ts +110 -0
- package/packages/client/connection/lib/types/client/rpc.d.ts +26 -0
- package/packages/client/connection/lib/types/client/socket.d.ts +32 -0
- package/packages/client/connection/lib/types/client.d.ts +17 -0
- package/packages/client/connection/lib/types/host/browser-auth.d.ts +122 -0
- package/packages/client/connection/lib/types/host/index.d.ts +44 -0
- package/packages/client/connection/lib/types/host/loopback.d.ts +16 -0
- package/packages/client/connection/lib/types/host/rpc-host.d.ts +310 -0
- package/packages/client/connection/lib/types/host/rpc-schema.d.ts +89 -0
- package/packages/client/connection/lib/types/host/trust.d.ts +92 -0
- package/packages/client/connection/lib/types/ids.d.ts +33 -0
- package/packages/client/connection/lib/types/index.d.ts +20 -0
- package/packages/client/connection/lib/types/recovery-config.d.ts +29 -0
- package/packages/client/connection/lib/types/rpc-id.d.ts +34 -0
- package/packages/client/settings-about/lib/types/client.d.ts +14 -0
- package/packages/client/settings-about/lib/types/index.d.ts +22 -0
- package/packages/client/settings-about/lib/types/locales.d.ts +17 -0
- package/packages/client/settings-about/lib/types/zalo-data.d.ts +11 -0
- package/packages/client/ui-primitives/lib/types/artwork-dynamic.d.ts +14 -0
- package/packages/client/ui-primitives/lib/types/artwork-part-1.d.ts +10 -0
- package/packages/client/ui-primitives/lib/types/artwork-part-2.d.ts +10 -0
- package/packages/client/ui-primitives/lib/types/artwork-part-3.d.ts +10 -0
- package/packages/client/ui-primitives/lib/types/artwork-part-4.d.ts +10 -0
- package/packages/client/ui-primitives/lib/types/artwork-registry.d.ts +29 -0
- package/packages/client/ui-primitives/lib/types/artwork-render.d.ts +29 -0
- package/packages/client/ui-primitives/lib/types/artwork-types.d.ts +76 -0
- package/packages/client/ui-primitives/lib/types/brand.d.ts +59 -0
- package/packages/client/ui-primitives/lib/types/gbh-icon-specs.d.ts +26 -0
- package/packages/client/ui-primitives/lib/types/gbh-icon.d.ts +37 -0
- package/packages/client/ui-primitives/lib/types/index.d.ts +42 -0
- package/packages/client/ui-schedule/lib/types/client.d.ts +9 -0
- package/packages/client/ui-schedule/lib/types/ids.d.ts +74 -0
- package/packages/client/ui-schedule/lib/types/index.d.ts +20 -0
- package/packages/client/ui-schedule/lib/types/manifest.d.ts +62 -0
- package/packages/client/ui-settings-general/lib/types/badge.d.ts +9 -0
- package/packages/client/ui-settings-general/lib/types/client.d.ts +9 -0
- package/packages/client/ui-settings-general/lib/types/desktop-update.d.ts +93 -0
- package/packages/client/ui-settings-general/lib/types/dictionaries.d.ts +16 -0
- package/packages/client/ui-settings-general/lib/types/document-store.d.ts +68 -0
- package/packages/client/ui-settings-general/lib/types/ids.d.ts +11 -0
- package/packages/client/ui-settings-general/lib/types/index.d.ts +101 -0
- package/packages/client/ui-settings-general/lib/types/items.d.ts +24 -0
- package/packages/client/ui-settings-general/lib/types/locales-vi.d.ts +14 -0
- package/packages/client/ui-settings-general/lib/types/overlay.d.ts +30 -0
- package/packages/client/ui-settings-general/lib/types/panel.d.ts +9 -0
- package/packages/client/ui-settings-general/lib/types/plugin.d.ts +103 -0
- package/packages/client/ui-settings-general/lib/types/sections.d.ts +9 -0
- package/packages/client/ui-settings-general/lib/types/settings-css.d.ts +41 -0
- package/packages/client/ui-settings-general/lib/types/settings-panel.d.ts +22 -0
- package/packages/client/ui-settings-general/lib/types/settings-root.d.ts +21 -0
- package/packages/client/ui-settings-general/lib/types/settings-store.d.ts +55 -0
- package/packages/client/ui-settings-general/lib/types/shell-parts.d.ts +31 -0
- package/packages/client/ui-settings-general/lib/types/store.d.ts +29 -0
- package/packages/client/ui-settings-general/lib/types/trigger.d.ts +9 -0
- package/packages/client/ui-settings-general/lib/types/types.d.ts +137 -0
- package/packages/client/ui-settings-session-log/lib/types/client.d.ts +9 -0
- package/packages/client/ui-settings-session-log/lib/types/index.d.ts +19 -0
- package/packages/client/ui-settings-session-log/lib/types/locales-vi.d.ts +14 -0
- package/packages/client/ui-settings-session-log/lib/types/locales.d.ts +23 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/class-names.d.ts +89 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/client.d.ts +9 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/clsx.d.ts +13 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/code/code-body.d.ts +40 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/config.d.ts +46 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/css-inject.d.ts +22 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/css-registry.d.ts +22 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/definition.d.ts +22 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/contract.d.ts +13 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/lines.d.ts +46 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/registry.d.ts +75 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/resource-group.d.ts +43 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/suffix.d.ts +25 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/tab-lifetime.d.ts +15 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/document/unviewable.d.ts +21 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/excel/error.d.ts +18 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/excel/excel-kind.d.ts +34 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/excel/format.d.ts +13 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/excel/lazy-excel-body.d.ts +20 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/face.d.ts +125 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/failure-line.d.ts +37 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/basic-document.d.ts +15 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/bootstrap.d.ts +30 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/bytes.d.ts +21 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/html-body.d.ts +49 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/pack.d.ts +46 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/html/read-relative.d.ts +18 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/ids.d.ts +110 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/image/image-body.d.ts +80 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/index.d.ts +86 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/kinds.d.ts +90 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/loading-indicator.d.ts +30 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/locales-vi.d.ts +57 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/locales.d.ts +168 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/markdown/frontmatter.d.ts +22 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/markdown/markdown-body.d.ts +43 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/markdown/path-images.d.ts +14 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/cache.d.ts +116 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/face.d.ts +51 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/font-notice.d.ts +36 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/office-body.d.ts +71 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/office-font-action.d.ts +35 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/office-kind.d.ts +49 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/office/store.d.ts +30 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/pdf/lazy-pdf-body.d.ts +20 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/pdf/store.d.ts +21 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/plugin.d.ts +28 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/rpc.d.ts +20 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/store.d.ts +69 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/text-body.d.ts +34 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/text-preview.d.ts +163 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/text-title.d.ts +30 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/types.d.ts +193 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/workspace-path.d.ts +80 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/zoom/controls.d.ts +65 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/zoom/store.d.ts +17 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/zoom/types.d.ts +26 -0
- package/packages/client/ui-sidebar-documentpreview/lib/types/zoom/viewport.d.ts +51 -0
- package/packages/client/ui-theme/lib/types/boot-theme.d.ts +41 -0
- package/packages/client/ui-theme/lib/types/class-names.d.ts +53 -0
- package/packages/client/ui-theme/lib/types/client.d.ts +9 -0
- package/packages/client/ui-theme/lib/types/clsx.d.ts +15 -0
- package/packages/client/ui-theme/lib/types/ids.d.ts +21 -0
- package/packages/client/ui-theme/lib/types/index.d.ts +108 -0
- package/packages/client/ui-theme/lib/types/locales.d.ts +100 -0
- package/packages/client/ui-theme/lib/types/plugin.d.ts +73 -0
- package/packages/client/ui-theme/lib/types/rows.d.ts +123 -0
- package/packages/client/ui-theme/lib/types/settings-store.d.ts +46 -0
- package/packages/client/ui-theme/lib/types/styles.d.ts +42 -0
- package/packages/client/ui-theme/lib/types/theme-runtime.d.ts +256 -0
- package/packages/client/ui-theme/lib/types/theme-settings.d.ts +112 -0
- package/packages/host/agent-instructions/lib/types/config.d.ts +69 -0
- package/packages/host/agent-instructions/lib/types/digest.d.ts +14 -0
- package/packages/host/agent-instructions/lib/types/files.d.ts +171 -0
- package/packages/host/agent-instructions/lib/types/index.d.ts +28 -0
- package/packages/host/agent-instructions/lib/types/render.d.ts +150 -0
- package/packages/host/agent-instructions/lib/types/service.d.ts +11 -0
- package/packages/host/agent-instructions/lib/types/state.d.ts +114 -0
- package/packages/host/agent-preset/lib/types/index.d.ts +86 -0
- package/packages/host/agent-preset/lib/types/preset-redirect.d.ts +82 -0
- package/packages/host/agent-preset-registry/lib/index.js +9 -9
- package/packages/host/agent-preset-registry/lib/types/composition-inventory.d.ts +53 -0
- package/packages/host/agent-preset-registry/lib/types/definition.d.ts +13 -0
- package/packages/host/agent-preset-registry/lib/types/display.d.ts +34 -0
- package/packages/host/agent-preset-registry/lib/types/display.js +1 -1
- package/packages/host/agent-preset-registry/lib/types/index.d.ts +230 -0
- package/packages/host/agent-preset-registry/lib/types/mount.d.ts +73 -0
- package/packages/host/agent-preset-registry/lib/types/nested-mount.d.ts +81 -0
- package/packages/host/agent-preset-registry/lib/types/session.d.ts +37 -0
- package/packages/host/agent-preset-registry/lib/types/types.d.ts +174 -0
- package/packages/host/api-workspace-controller/lib/types/client.d.ts +8 -0
- package/packages/host/api-workspace-controller/lib/types/commands.d.ts +117 -0
- package/packages/host/api-workspace-controller/lib/types/defaults.d.ts +56 -0
- package/packages/host/api-workspace-controller/lib/types/directory-picker.d.ts +117 -0
- package/packages/host/api-workspace-controller/lib/types/feed.d.ts +102 -0
- package/packages/host/api-workspace-controller/lib/types/ids.d.ts +35 -0
- package/packages/host/api-workspace-controller/lib/types/index.d.ts +29 -0
- package/packages/host/api-workspace-controller/lib/types/service.d.ts +130 -0
- package/packages/host/api-workspace-controller/lib/types/types.d.ts +192 -0
- package/packages/host/api-workspace-controller/lib/types/workspace-seam.d.ts +50 -0
- package/packages/host/authorization/lib/types/errors.d.ts +36 -0
- package/packages/host/authorization/lib/types/index.d.ts +19 -0
- package/packages/host/authorization/lib/types/service.d.ts +123 -0
- package/packages/host/authorization/lib/types/types.d.ts +162 -0
- package/packages/host/bundle-labels/lib/types/bundle-experimental-gbh.d.ts +15 -0
- package/packages/host/bundle-labels/lib/types/bundle-icons.d.ts +14 -0
- package/packages/host/bundle-labels/lib/types/bundle-meta-vi.d.ts +53 -0
- package/packages/host/bundle-labels/lib/types/index.d.ts +19 -0
- package/packages/host/command-goal/lib/types/index.d.ts +32 -0
- package/packages/host/config-editor/lib/types/index.d.ts +17 -0
- package/packages/host/config-editor/lib/types/patch.d.ts +49 -0
- package/packages/host/config-editor/lib/types/service.d.ts +47 -0
- package/packages/host/config-editor/lib/types/types.d.ts +43 -0
- package/packages/host/cordis-host-runner/lib/types/guard.d.ts +55 -0
- package/packages/host/cordis-host-runner/lib/types/index.d.ts +33 -0
- package/packages/host/cordis-host-runner/lib/types/inspect-registry.d.ts +103 -0
- package/packages/host/cordis-host-runner/lib/types/lifecycle.d.ts +31 -0
- package/packages/host/cordis-host-runner/lib/types/registry.d.ts +272 -0
- package/packages/host/cordis-host-runner/lib/types/sandbox.d.ts +51 -0
- package/packages/host/cordis-host-runner/lib/types/service-support.d.ts +234 -0
- package/packages/host/cordis-host-runner/lib/types/service.d.ts +254 -0
- package/packages/host/cordis-host-runner/lib/types/types.d.ts +457 -0
- package/packages/host/deepseek-llm-api-extensions/lib/types/index.d.ts +23 -0
- package/packages/host/deepseek-llm-api-extensions/lib/types/registry.d.ts +38 -0
- package/packages/host/deepseek-llm-api-extensions/lib/types/types.d.ts +56 -0
- package/packages/host/experimental-agent-team/lib/types/activity.d.ts +23 -0
- package/packages/host/experimental-agent-team/lib/types/error.d.ts +14 -0
- package/packages/host/experimental-agent-team/lib/types/index.d.ts +45 -0
- package/packages/host/experimental-agent-team/lib/types/journal.d.ts +39 -0
- package/packages/host/experimental-agent-team/lib/types/lifecycle.d.ts +44 -0
- package/packages/host/experimental-agent-team/lib/types/persisted.d.ts +40 -0
- package/packages/host/experimental-agent-team/lib/types/projection.d.ts +123 -0
- package/packages/host/experimental-agent-team/lib/types/roster.d.ts +200 -0
- package/packages/host/experimental-agent-team/lib/types/service.d.ts +157 -0
- package/packages/host/experimental-agent-team/lib/types/session-message.d.ts +18 -0
- package/packages/host/experimental-agent-team/lib/types/task-board.d.ts +99 -0
- package/packages/host/experimental-agent-team/lib/types/task-graph.d.ts +24 -0
- package/packages/host/experimental-agent-team/lib/types/task-view.d.ts +12 -0
- package/packages/host/experimental-agent-team/lib/types/team-seams.d.ts +22 -0
- package/packages/host/experimental-agent-team/lib/types/types.d.ts +310 -0
- package/packages/host/experimental-agent-team/lib/types/validation.d.ts +11 -0
- package/packages/host/experimental-api-speech-to-text/lib/types/index.d.ts +102 -0
- package/packages/host/experimental-api-speech-to-text/lib/types/typert-host.d.ts +29 -0
- package/packages/host/experimental-api-speech-to-text/lib/types/typert-remote-client.d.ts +2 -0
- package/packages/host/experimental-api-speech-to-text/lib/types/types.d.ts +39 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/config.d.ts +52 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/download-error.d.ts +34 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/index.d.ts +29 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/input.d.ts +13 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/model-sources.d.ts +8 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/recognizer.d.ts +145 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/runtime.d.ts +84 -0
- package/packages/host/experimental-speech-to-text-sensevoice/lib/types/worker.d.ts +1 -0
- package/packages/host/experimental-translator/lib/types/deepseek.d.ts +47 -0
- package/packages/host/experimental-translator/lib/types/error.d.ts +24 -0
- package/packages/host/experimental-translator/lib/types/index.d.ts +25 -0
- package/packages/host/experimental-translator/lib/types/plugin.d.ts +128 -0
- package/packages/host/experimental-translator/lib/types/provider.d.ts +16 -0
- package/packages/host/experimental-translator/lib/types/storage.d.ts +77 -0
- package/packages/host/experimental-translator/lib/types/types.d.ts +128 -0
- package/packages/host/file-reference-local/lib/types/index.d.ts +71 -0
- package/packages/host/file-reference-local/lib/types/search.d.ts +121 -0
- package/packages/host/file-reference-local/lib/types/types.d.ts +171 -0
- package/packages/host/fs-sandbox/lib/types/containment.d.ts +20 -0
- package/packages/host/fs-sandbox/lib/types/index.d.ts +98 -0
- package/packages/host/goal-round-driver/lib/types/index.d.ts +31 -0
- package/packages/host/goal-round-driver/lib/types/prompt.d.ts +17 -0
- package/packages/host/goal-round-driver/lib/types/types.d.ts +88 -0
- package/packages/host/hmr/lib/types/config.d.ts +22 -0
- package/packages/host/hmr/lib/types/error.d.ts +42 -0
- package/packages/host/hmr/lib/types/ignore.d.ts +13 -0
- package/packages/host/hmr/lib/types/index.d.ts +28 -0
- package/packages/host/hmr/lib/types/loader-cache.d.ts +165 -0
- package/packages/host/hmr/lib/types/module-files.d.ts +63 -0
- package/packages/host/hmr/lib/types/package-manifests.d.ts +161 -0
- package/packages/host/hmr/lib/types/profile-apply.d.ts +41 -0
- package/packages/host/hmr/lib/types/service.d.ts +253 -0
- package/packages/host/hmr/lib/types/watch-config.d.ts +26 -0
- package/packages/host/image-offload/lib/types/freeze.d.ts +15 -0
- package/packages/host/image-offload/lib/types/image-offload.d.ts +19 -0
- package/packages/host/image-offload/lib/types/index.d.ts +35 -0
- package/packages/host/image-offload/lib/types/project-message.d.ts +17 -0
- package/packages/host/image-offload/lib/types/projection.d.ts +11 -0
- package/packages/host/image-offload/lib/types/types.d.ts +148 -0
- package/packages/host/jobs-local/lib/types/events.d.ts +76 -0
- package/packages/host/jobs-local/lib/types/index.d.ts +33 -0
- package/packages/host/jobs-local/lib/types/pump.d.ts +45 -0
- package/packages/host/jobs-local/lib/types/registry.d.ts +305 -0
- package/packages/host/jobs-local/lib/types/ring.d.ts +39 -0
- package/packages/host/jobs-local/lib/types/types.d.ts +91 -0
- package/packages/host/lazy-require/lib/types/index.d.ts +8 -0
- package/packages/host/llm/lib/types/adapter-failure.d.ts +22 -0
- package/packages/host/llm/lib/types/api-key.d.ts +31 -0
- package/packages/host/llm/lib/types/assembler.d.ts +76 -0
- package/packages/host/llm/lib/types/assistant-stream.d.ts +168 -0
- package/packages/host/llm/lib/types/attribution.d.ts +45 -0
- package/packages/host/llm/lib/types/brand.d.ts +54 -0
- package/packages/host/llm/lib/types/call-config.d.ts +73 -0
- package/packages/host/llm/lib/types/content.d.ts +149 -0
- package/packages/host/llm/lib/types/error.d.ts +97 -0
- package/packages/host/llm/lib/types/index.d.ts +61 -0
- package/packages/host/llm/lib/types/message.d.ts +274 -0
- package/packages/host/llm/lib/types/retry-policy.d.ts +81 -0
- package/packages/host/llm/lib/types/service.d.ts +321 -0
- package/packages/host/llm/lib/types/stream-seam.d.ts +19 -0
- package/packages/host/llm/lib/types/typert-host.d.ts +47 -0
- package/packages/host/llm/lib/types/typert-remote-client.d.ts +2 -0
- package/packages/host/llm/lib/types/types.d.ts +551 -0
- package/packages/host/llm-pi-ai/package.json +3 -0
- package/packages/host/mcp-resources/lib/types/index.d.ts +62 -0
- package/packages/host/mcp-resources/lib/types/render.d.ts +18 -0
- package/packages/host/mcp-resources/lib/types/tools.d.ts +23 -0
- package/packages/host/mcp-resources/lib/types/types.d.ts +35 -0
- package/packages/host/message-feedback/lib/types/index.d.ts +19 -0
- package/packages/host/message-feedback/lib/types/schema.d.ts +89 -0
- package/packages/host/message-feedback/lib/types/service.d.ts +94 -0
- package/packages/host/message-feedback/lib/types/types.d.ts +207 -0
- package/packages/host/otel/lib/types/event-log.d.ts +66 -0
- package/packages/host/otel/lib/types/event-transport.d.ts +9 -0
- package/packages/host/otel/lib/types/index.d.ts +49 -0
- package/packages/host/otel/lib/types/session-log.d.ts +144 -0
- package/packages/host/otel/lib/types/transport.d.ts +33 -0
- package/packages/host/persona/lib/types/index.d.ts +52 -0
- package/packages/host/plugin-inventory/lib/types/gateway.d.ts +32 -0
- package/packages/host/plugin-inventory/lib/types/index.d.ts +17 -0
- package/packages/host/plugin-inventory/lib/types/inventory.d.ts +18 -0
- package/packages/host/plugin-inventory/lib/types/types.d.ts +79 -0
- package/packages/host/plugin-manager/lib/types/build-approval.d.ts +37 -0
- package/packages/host/plugin-manager/lib/types/bundle-rename.d.ts +70 -0
- package/packages/host/plugin-manager/lib/types/catalog-thu-nghiem.d.ts +49 -0
- package/packages/host/plugin-manager/lib/types/failure.d.ts +32 -0
- package/packages/host/plugin-manager/lib/types/github-connection.d.ts +37 -0
- package/packages/host/plugin-manager/lib/types/index.d.ts +55 -0
- package/packages/host/plugin-manager/lib/types/install-failure.d.ts +28 -0
- package/packages/host/plugin-manager/lib/types/install-spec.d.ts +57 -0
- package/packages/host/plugin-manager/lib/types/list-bundles.d.ts +26 -0
- package/packages/host/plugin-manager/lib/types/manager-support.d.ts +164 -0
- package/packages/host/plugin-manager/lib/types/manager.d.ts +217 -0
- package/packages/host/plugin-manager/lib/types/meta-bundle.d.ts +22 -0
- package/packages/host/plugin-manager/lib/types/official-install-target.d.ts +25 -0
- package/packages/host/plugin-manager/lib/types/operations.d.ts +160 -0
- package/packages/host/plugin-manager/lib/types/origin.d.ts +45 -0
- package/packages/host/plugin-manager/lib/types/patch.d.ts +32 -0
- package/packages/host/plugin-manager/lib/types/registry.d.ts +47 -0
- package/packages/host/plugin-manager/lib/types/run-tree.d.ts +53 -0
- package/packages/host/plugin-manager/lib/types/tools.d.ts +19 -0
- package/packages/host/plugin-manager/lib/types/types.d.ts +318 -0
- package/packages/host/plugin-market/lib/types/ids.d.ts +17 -0
- package/packages/host/plugin-market/lib/types/index-url.d.ts +9 -0
- package/packages/host/plugin-market/lib/types/index.d.ts +64 -0
- package/packages/host/plugin-market/lib/types/nested-rows.d.ts +32 -0
- package/packages/host/plugin-market/lib/types/parse-thread.d.ts +11 -0
- package/packages/host/plugin-market/lib/types/parse.d.ts +33 -0
- package/packages/host/plugin-market/lib/types/search.d.ts +33 -0
- package/packages/host/plugin-market/lib/types/service.d.ts +144 -0
- package/packages/host/plugin-market/lib/types/tools.d.ts +10 -0
- package/packages/host/plugin-market/lib/types/typert-host.d.ts +41 -0
- package/packages/host/plugin-market/lib/types/typert-remote-client.d.ts +2 -0
- package/packages/host/plugin-market/lib/types/types.d.ts +155 -0
- package/packages/host/plugin-market/lib/types/worker.d.ts +1 -0
- package/packages/host/pwsh-sandbox/lib/types/helpers.d.ts +47 -0
- package/packages/host/pwsh-sandbox/lib/types/index.d.ts +92 -0
- package/packages/host/sandbox-policy/lib/types/index.d.ts +73 -0
- package/packages/host/sandbox-policy/lib/types/policy.d.ts +102 -0
- package/packages/host/sandbox-policy/lib/types/session-mode.d.ts +30 -0
- package/packages/host/sandbox-seam/lib/types/diagnostics.d.ts +37 -0
- package/packages/host/sandbox-seam/lib/types/escalation.d.ts +118 -0
- package/packages/host/sandbox-seam/lib/types/index.d.ts +79 -0
- package/packages/host/sandbox-seam/lib/types/roots.d.ts +27 -0
- package/packages/host/sandbox-seam/lib/types/types.d.ts +69 -0
- package/packages/host/schedule/lib/types/codec.d.ts +254 -0
- package/packages/host/schedule/lib/types/delivery-history.d.ts +30 -0
- package/packages/host/schedule/lib/types/framing.d.ts +34 -0
- package/packages/host/schedule/lib/types/index.d.ts +37 -0
- package/packages/host/schedule/lib/types/occurrence.d.ts +137 -0
- package/packages/host/schedule/lib/types/records.d.ts +144 -0
- package/packages/host/schedule/lib/types/runtime.d.ts +101 -0
- package/packages/host/schedule/lib/types/service.d.ts +162 -0
- package/packages/host/schedule/lib/types/storage.d.ts +50 -0
- package/packages/host/schedule/lib/types/types.d.ts +550 -0
- package/packages/host/schedule/lib/types/update.d.ts +33 -0
- package/packages/host/session/lib/index.js +15 -15
- package/packages/host/session/lib/types/events.d.ts +206 -0
- package/packages/host/session/lib/types/fork.d.ts +27 -0
- package/packages/host/session/lib/types/fork.js +3 -3
- package/packages/host/session/lib/types/index.d.ts +50 -0
- package/packages/host/session/lib/types/known-event-types.d.ts +12 -0
- package/packages/host/session/lib/types/preparation.d.ts +34 -0
- package/packages/host/session/lib/types/repair.d.ts +93 -0
- package/packages/host/session/lib/types/request-header.d.ts +46 -0
- package/packages/host/session/lib/types/seq-ranges.d.ts +14 -0
- package/packages/host/session/lib/types/session.d.ts +262 -0
- package/packages/host/session/lib/types/store.d.ts +186 -0
- package/packages/host/session/lib/types/surface.d.ts +184 -0
- package/packages/host/session/lib/types/surface.js +3 -3
- package/packages/host/session/lib/types/tool-history.d.ts +51 -0
- package/packages/host/session/lib/types/types.d.ts +590 -0
- package/packages/host/session/lib/types/types.js +1 -1
- package/packages/host/session-checkpoint-policy/lib/types/index.d.ts +27 -0
- package/packages/host/session-checkpoint-policy/lib/types/result.d.ts +15 -0
- package/packages/host/session-checkpoint-policy/lib/types/types.d.ts +118 -0
- package/packages/host/session-delete/lib/types/index.d.ts +32 -0
- package/packages/host/session-delete/lib/types/service.d.ts +109 -0
- package/packages/host/session-delete/lib/types/types.d.ts +51 -0
- package/packages/host/session-log/lib/types/acceptance.d.ts +18 -0
- package/packages/host/session-log/lib/types/index.d.ts +48 -0
- package/packages/host/session-log/lib/types/seams.d.ts +65 -0
- package/packages/host/session-log/lib/types/types.d.ts +132 -0
- package/packages/host/session-log/lib/types/wire.d.ts +35 -0
- package/packages/host/session-log-export/lib/types/archive.d.ts +74 -0
- package/packages/host/session-log-export/lib/types/client.d.ts +197 -0
- package/packages/host/session-log-export/lib/types/index.d.ts +42 -0
- package/packages/host/session-log-export/lib/types/routes.d.ts +12 -0
- package/packages/host/session-log-export/lib/types/types.d.ts +99 -0
- package/packages/host/session-reference/lib/types/config.d.ts +36 -0
- package/packages/host/session-reference/lib/types/index.d.ts +32 -0
- package/packages/host/session-reference/lib/types/projection.d.ts +49 -0
- package/packages/host/session-reference/lib/types/serialization.d.ts +14 -0
- package/packages/host/session-reference/lib/types/service.d.ts +258 -0
- package/packages/host/session-reference/lib/types/spill.d.ts +64 -0
- package/packages/host/session-reference/lib/types/typert-host.d.ts +38 -0
- package/packages/host/session-reference/lib/types/typert-remote-client.d.ts +2 -0
- package/packages/host/session-reference/lib/types/types.d.ts +13 -0
- package/packages/host/session-reference/lib/types/uri.d.ts +65 -0
- package/packages/host/settings/lib/types/index.d.ts +24 -0
- package/packages/host/settings/lib/types/paths.d.ts +37 -0
- package/packages/host/settings/lib/types/redact.d.ts +15 -0
- package/packages/host/settings/lib/types/schema.d.ts +25 -0
- package/packages/host/settings/lib/types/service.d.ts +105 -0
- package/packages/host/settings/lib/types/types.d.ts +221 -0
- package/packages/host/spill-local/lib/types/cleanup.d.ts +53 -0
- package/packages/host/spill-local/lib/types/index.d.ts +117 -0
- package/packages/host/spill-local/lib/types/store.d.ts +58 -0
- package/packages/host/spill-policy/lib/types/index.d.ts +41 -0
- package/packages/host/spill-policy/lib/types/notice.d.ts +23 -0
- package/packages/host/spill-policy/lib/types/retention.d.ts +33 -0
- package/packages/host/spill-policy/lib/types/types.d.ts +201 -0
- package/packages/host/subagent-spawn-in-process/lib/types/index.d.ts +35 -0
- package/packages/host/subagent-spawn-in-process/lib/types/provider.d.ts +48 -0
- package/packages/host/token-meter/lib/types/breakdown-projection.d.ts +143 -0
- package/packages/host/token-meter/lib/types/client.d.ts +10 -0
- package/packages/host/token-meter/lib/types/estimate.d.ts +51 -0
- package/packages/host/token-meter/lib/types/index.d.ts +111 -0
- package/packages/host/token-meter/lib/types/route-pricing.d.ts +74 -0
- package/packages/host/token-meter/lib/types/session-event-augmentation.d.ts +95 -0
- package/packages/host/token-meter/lib/types/surface-fold.d.ts +79 -0
- package/packages/host/token-meter/lib/types/surface-projection.d.ts +55 -0
- package/packages/host/token-meter/lib/types/turn-usage.d.ts +43 -0
- package/packages/host/token-meter/lib/types/types.d.ts +48 -0
- package/packages/host/token-meter/lib/types/usage-projection.d.ts +173 -0
- package/packages/host/tool-goal/lib/types/authority.d.ts +55 -0
- package/packages/host/tool-goal/lib/types/index.d.ts +51 -0
- package/packages/host/tool-goal/lib/types/seams.d.ts +62 -0
- package/packages/host/tool-goal/lib/types/wrapup.d.ts +17 -0
- package/packages/host/tool-skill/lib/types/config.d.ts +39 -0
- package/packages/host/tool-skill/lib/types/index.d.ts +202 -0
- package/packages/host/tool-working-directory/lib/types/index.d.ts +22 -0
- package/packages/host/web-search/lib/types/index.d.ts +194 -0
- package/packages/host/workspace/lib/types/entity.d.ts +129 -0
- package/packages/host/workspace/lib/types/errors.d.ts +62 -0
- package/packages/host/workspace/lib/types/index.d.ts +42 -0
- package/packages/host/workspace/lib/types/paths.d.ts +28 -0
- package/packages/host/workspace/lib/types/registry.d.ts +318 -0
- package/packages/host/workspace/lib/types/seams.d.ts +177 -0
- package/packages/host/workspace/lib/types/spec.d.ts +94 -0
- package/packages/host/workspace/lib/types/types.d.ts +133 -0
- package/prepare.mjs +18 -1
- package/profiles/blackhole/app.patch.yml +0 -109
- package/packages/host/gbh-libreoffice-kit-darwin-x64/package.json +0 -26
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/autotext/mytexts.bau +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/config/autotbl.fmt +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/database/biblio/biblio.dbf +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/database/biblio/biblio.dbt +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/database/biblio.odb +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/database/evolocal.odb +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/gallery/sg30.sdv +0 -0
- package/packages/host/gbh-libreoffice-kit-darwin-x64/program/LibreOfficeDev.app/Contents/Resources/presets/gallery/sg30.thm +0 -0
package/apps/cli/lib/main.js
CHANGED
|
@@ -33,7 +33,8 @@ import { fileURLToPath } from "node:url";
|
|
|
33
33
|
var cacheKernel;
|
|
34
34
|
var DEFAULT_PORT = 5439;
|
|
35
35
|
var LOOPBACK_HOST = "127.0.0.1";
|
|
36
|
-
var MIN_NODE_MAJOR =
|
|
36
|
+
var MIN_NODE_MAJOR = 22;
|
|
37
|
+
var MIN_NODE_MINOR = 6;
|
|
37
38
|
var DEFAULT_PROFILE = "blackhole";
|
|
38
39
|
var ORACLE_PORT = 4001;
|
|
39
40
|
function galaxyRoot() {
|
|
@@ -102,14 +103,14 @@ function dshManifestPath() {
|
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
// apps/cli/src/host.ts
|
|
105
|
-
import { spawn, spawnSync as
|
|
106
|
-
import { existsSync as
|
|
106
|
+
import { spawn, spawnSync as spawnSync4 } from "node:child_process";
|
|
107
|
+
import { existsSync as existsSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
107
108
|
|
|
108
109
|
// apps/cli/src/mount.ts
|
|
109
|
-
import { spawnSync } from "node:child_process";
|
|
110
|
+
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
110
111
|
import { tmpdir } from "node:os";
|
|
111
|
-
import { createHash as
|
|
112
|
-
import { cpSync as cpSync3, existsSync as
|
|
112
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
113
|
+
import { cpSync as cpSync3, existsSync as existsSync7, lstatSync as lstatSync4, mkdirSync as mkdirSync3, mkdtempSync, readFileSync as readFileSync5, readdirSync as readdirSync5, realpathSync as realpathSync2, rmSync as rmSync3, statSync as statSync3, symlinkSync as symlinkSync3, writeFileSync as writeFileSync4 } from "node:fs";
|
|
113
114
|
|
|
114
115
|
// tools/p1b/denta-profile.ts
|
|
115
116
|
import { createHash } from "node:crypto";
|
|
@@ -337,7 +338,7 @@ if (false)
|
|
|
337
338
|
;
|
|
338
339
|
|
|
339
340
|
// apps/cli/src/mount.ts
|
|
340
|
-
import { dirname as dirname5, join as
|
|
341
|
+
import { dirname as dirname5, join as join7, relative } from "node:path";
|
|
341
342
|
|
|
342
343
|
// apps/cli/src/self-links.ts
|
|
343
344
|
import { existsSync as existsSync3, lstatSync as lstatSync2, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync2, symlinkSync } from "node:fs";
|
|
@@ -381,17 +382,288 @@ function linkSelfPackages() {
|
|
|
381
382
|
return added;
|
|
382
383
|
}
|
|
383
384
|
|
|
384
|
-
// apps/cli/src/mount-
|
|
385
|
+
// apps/cli/src/mount-gate.ts
|
|
386
|
+
import { spawnSync } from "node:child_process";
|
|
385
387
|
import { createHash as createHash2 } from "node:crypto";
|
|
386
|
-
import {
|
|
387
|
-
import {
|
|
388
|
+
import { existsSync as existsSync4, readFileSync as readFileSync3, readdirSync as readdirSync3, statSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
389
|
+
import { homedir as homedir2 } from "node:os";
|
|
390
|
+
import { join as join4 } from "node:path";
|
|
391
|
+
var CACHE_NAME = ".gbh-mount-gate.json";
|
|
392
|
+
var CACHE_VERSION = 1;
|
|
393
|
+
var GATE_SOURCES = [
|
|
394
|
+
"tools/check/rows.ts",
|
|
395
|
+
"tools/check/rows-scan.ts",
|
|
396
|
+
"tools/check/dangling.ts",
|
|
397
|
+
"tools/check/row-ids.ts",
|
|
398
|
+
"tools/check/surface.ts",
|
|
399
|
+
"tools/scaffold/lib.ts",
|
|
400
|
+
"apps/cli/src/paths.ts",
|
|
401
|
+
"apps/cli/src/mount-gate.ts"
|
|
402
|
+
];
|
|
403
|
+
function isBunProcess() {
|
|
404
|
+
if (typeof globalThis.Bun !== "undefined")
|
|
405
|
+
return true;
|
|
406
|
+
return typeof process.versions.bun === "string";
|
|
407
|
+
}
|
|
408
|
+
function scriptNeedsBun(source) {
|
|
409
|
+
if (!/\bBun\s*\./u.test(source))
|
|
410
|
+
return false;
|
|
411
|
+
return !/typeof\s+Bun\b/u.test(source);
|
|
412
|
+
}
|
|
413
|
+
function readScriptSource(script) {
|
|
414
|
+
try {
|
|
415
|
+
return readFileSync3(script, "utf8");
|
|
416
|
+
} catch {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function isFile(path) {
|
|
421
|
+
try {
|
|
422
|
+
return statSync(path).isFile();
|
|
423
|
+
} catch {
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
function findBun(env = process.env, exists = isFile) {
|
|
428
|
+
const pinned = (env.GBH_BUN ?? "").trim();
|
|
429
|
+
if (pinned !== "" && exists(pinned))
|
|
430
|
+
return pinned;
|
|
431
|
+
const home = env.HOME ?? homedir2();
|
|
432
|
+
const candidates = [join4(home, ".bun", "bin", "bun"), "/opt/homebrew/bin/bun", "/usr/local/bin/bun"];
|
|
433
|
+
for (const candidate of candidates)
|
|
434
|
+
if (exists(candidate))
|
|
435
|
+
return candidate;
|
|
436
|
+
for (const dir of (env.PATH ?? "").split(":")) {
|
|
437
|
+
if (dir === "")
|
|
438
|
+
continue;
|
|
439
|
+
const candidate = join4(dir, "bun");
|
|
440
|
+
if (exists(candidate))
|
|
441
|
+
return candidate;
|
|
442
|
+
}
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
function nodeScriptCommand(script, execPath = process.execPath, extra = []) {
|
|
446
|
+
return { command: execPath, args: ["--experimental-strip-types", script, ...extra], runtime: "node", source: "process.execPath" };
|
|
447
|
+
}
|
|
448
|
+
function bunScriptCommand(bunPath, script, extra = [], source = "bun") {
|
|
449
|
+
return { command: bunPath, args: ["run", script, ...extra], runtime: "bun", source };
|
|
450
|
+
}
|
|
451
|
+
function bunOnlyCommand(script, extra = [], env = process.env) {
|
|
452
|
+
if (isBunProcess())
|
|
453
|
+
return bunScriptCommand(process.execPath, script, extra, "process.execPath (Bun)");
|
|
454
|
+
const bun = findBun(env);
|
|
455
|
+
return bun === undefined ? undefined : bunScriptCommand(bun, script, extra, bun);
|
|
456
|
+
}
|
|
457
|
+
function spawnScript(command, cwd, timeoutMs) {
|
|
458
|
+
const result = spawnSync(command.command, command.args, { cwd, encoding: "utf8", timeout: timeoutMs });
|
|
459
|
+
return {
|
|
460
|
+
output: (result.stdout ?? "") + (result.stderr ?? ""),
|
|
461
|
+
status: result.status,
|
|
462
|
+
...result.error === undefined ? {} : { error: String(result.error) }
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
function hasVerdictTable(output) {
|
|
466
|
+
return /^\| Package \|/mu.test(output);
|
|
467
|
+
}
|
|
468
|
+
function hashFile(hash, path, label) {
|
|
469
|
+
hash.update(label);
|
|
470
|
+
if (!existsSync4(path)) {
|
|
471
|
+
hash.update("missing");
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
hash.update(readFileSync3(path));
|
|
475
|
+
}
|
|
476
|
+
function hashStat(hash, path, label) {
|
|
477
|
+
try {
|
|
478
|
+
const st = statSync(path);
|
|
479
|
+
hash.update(label + ":" + String(st.size) + ":" + String(Math.trunc(st.mtimeMs)));
|
|
480
|
+
} catch {
|
|
481
|
+
hash.update(label + ":missing");
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
function hashTree(hash, base, label) {
|
|
485
|
+
let count = 0;
|
|
486
|
+
const walk = (dir) => {
|
|
487
|
+
let names;
|
|
488
|
+
try {
|
|
489
|
+
names = readdirSync3(dir).sort();
|
|
490
|
+
} catch {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
for (const name of names) {
|
|
494
|
+
if (name === "node_modules" || name.startsWith("."))
|
|
495
|
+
continue;
|
|
496
|
+
const abs = join4(dir, name);
|
|
497
|
+
let st;
|
|
498
|
+
try {
|
|
499
|
+
st = statSync(abs);
|
|
500
|
+
} catch {
|
|
501
|
+
continue;
|
|
502
|
+
}
|
|
503
|
+
if (st.isDirectory())
|
|
504
|
+
walk(abs);
|
|
505
|
+
else {
|
|
506
|
+
hash.update(label + "/" + abs.slice(base.length) + ":" + String(st.size) + ":" + String(Math.trunc(st.mtimeMs)));
|
|
507
|
+
count += 1;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
walk(base);
|
|
512
|
+
return count;
|
|
513
|
+
}
|
|
514
|
+
function rowPackageDirs(repo) {
|
|
515
|
+
const out = [];
|
|
516
|
+
for (const area of ["host", "client"]) {
|
|
517
|
+
const dir = join4(repo, "packages", area);
|
|
518
|
+
let names;
|
|
519
|
+
try {
|
|
520
|
+
names = readdirSync3(dir).sort();
|
|
521
|
+
} catch {
|
|
522
|
+
continue;
|
|
523
|
+
}
|
|
524
|
+
for (const name of names) {
|
|
525
|
+
const pkgDir = join4(dir, name);
|
|
526
|
+
if (!existsSync4(join4(pkgDir, "package.json")))
|
|
527
|
+
continue;
|
|
528
|
+
try {
|
|
529
|
+
const json = JSON.parse(readFileSync3(join4(pkgDir, "package.json"), "utf8"));
|
|
530
|
+
if (json.gbh?.row !== undefined)
|
|
531
|
+
out.push(pkgDir);
|
|
532
|
+
} catch {}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return out;
|
|
536
|
+
}
|
|
537
|
+
function gateFingerprint(repo, home, mode) {
|
|
538
|
+
const hash = createHash2("sha256");
|
|
539
|
+
hash.update("gbh-mount-gate:" + String(CACHE_VERSION) + ":" + mode + ":node" + process.versions.node);
|
|
540
|
+
hash.update("home:" + home);
|
|
541
|
+
for (const rel of GATE_SOURCES)
|
|
542
|
+
hashFile(hash, join4(repo, rel), rel);
|
|
543
|
+
hashFile(hash, join4(repo, "docs", "PARITY-MATRIX.md"), "docs/PARITY-MATRIX.md");
|
|
544
|
+
hashFile(hash, join4(home, "app.patch.yml"), "app.patch.yml");
|
|
545
|
+
const stock = join4(repo, "apps", "host", "node_modules", "@deepseek-ai");
|
|
546
|
+
let stockNames = [];
|
|
547
|
+
try {
|
|
548
|
+
stockNames = readdirSync3(stock).sort();
|
|
549
|
+
} catch {}
|
|
550
|
+
for (const name of stockNames)
|
|
551
|
+
hashStat(hash, join4(stock, name, "package.json"), "@deepseek-ai/" + name);
|
|
552
|
+
const profileModules = join4(home, "profiles", "node_modules");
|
|
553
|
+
for (const pkgDir of rowPackageDirs(repo)) {
|
|
554
|
+
hash.update("pkg:" + pkgDir.slice(repo.length));
|
|
555
|
+
const manifest = readFileSync3(join4(pkgDir, "package.json"), "utf8");
|
|
556
|
+
hash.update("package.json");
|
|
557
|
+
hash.update(manifest);
|
|
558
|
+
hashStat(hash, join4(pkgDir, "build.ts"), "build.ts");
|
|
559
|
+
hashStat(hash, join4(pkgDir, "lib", "index.js"), "lib/index.js");
|
|
560
|
+
hashStat(hash, join4(pkgDir, "lib", "client.js"), "lib/client.js");
|
|
561
|
+
hashTree(hash, join4(pkgDir, "src"), "src");
|
|
562
|
+
const name = JSON.parse(manifest).name ?? "";
|
|
563
|
+
if (name !== "") {
|
|
564
|
+
hashStat(hash, join4(profileModules, name, "lib", "index.js"), "profile/index.js");
|
|
565
|
+
hashStat(hash, join4(profileModules, name, "lib", "client.js"), "profile/client.js");
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
return hash.digest("hex");
|
|
569
|
+
}
|
|
570
|
+
function readGateCache(home, key) {
|
|
571
|
+
try {
|
|
572
|
+
const parsed = JSON.parse(readFileSync3(join4(home, CACHE_NAME), "utf8"));
|
|
573
|
+
if (parsed.version !== CACHE_VERSION || parsed.key !== key || typeof parsed.output !== "string")
|
|
574
|
+
return;
|
|
575
|
+
if (!hasVerdictTable(parsed.output))
|
|
576
|
+
return;
|
|
577
|
+
return { output: parsed.output, runtime: typeof parsed.runtime === "string" ? parsed.runtime : "gate" };
|
|
578
|
+
} catch {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function writeGateCache(home, key, output, runtime = "gate") {
|
|
583
|
+
try {
|
|
584
|
+
writeFileSync2(join4(home, CACHE_NAME), JSON.stringify({ version: CACHE_VERSION, key, output, runtime, savedAt: new Date().toISOString() }) + `
|
|
585
|
+
`, "utf8");
|
|
586
|
+
} catch {}
|
|
587
|
+
}
|
|
588
|
+
function runMountGate(options) {
|
|
589
|
+
const started2 = performance.now();
|
|
590
|
+
const env = options.env ?? process.env;
|
|
591
|
+
const refresh = options.refresh === true || (env.GBH_GATE_REFRESH ?? "").trim() === "1";
|
|
592
|
+
const bunProcess = options.bunProcess ?? isBunProcess();
|
|
593
|
+
const execPath = options.execPath ?? process.execPath;
|
|
594
|
+
const run = options.run ?? spawnScript;
|
|
595
|
+
const timeoutMs = options.timeoutMs ?? 120000;
|
|
596
|
+
const mode = bunProcess ? "bun-build" : "node-prebuilt";
|
|
597
|
+
let key;
|
|
598
|
+
try {
|
|
599
|
+
key = gateFingerprint(options.cwd, options.home, mode);
|
|
600
|
+
} catch {
|
|
601
|
+
key = undefined;
|
|
602
|
+
}
|
|
603
|
+
if (!refresh && key !== undefined) {
|
|
604
|
+
const cached = readGateCache(options.home, key);
|
|
605
|
+
if (cached !== undefined) {
|
|
606
|
+
return { output: cached.output, detail: "cache · " + cached.runtime + " (nguon khong doi) · " + (performance.now() - started2).toFixed(0) + " ms", cached: true, ms: performance.now() - started2 };
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
const describe = (command, result, extra = "") => {
|
|
610
|
+
const ms2 = performance.now() - started2;
|
|
611
|
+
const detail = command.runtime + " (" + command.source + ") · " + ms2.toFixed(0) + " ms" + extra;
|
|
612
|
+
return { output: result.output, detail, cached: false, ms: ms2 };
|
|
613
|
+
};
|
|
614
|
+
if (bunProcess) {
|
|
615
|
+
const command = bunScriptCommand(execPath, options.script, [], "process.execPath (Bun)");
|
|
616
|
+
const result = run(command, options.cwd, timeoutMs);
|
|
617
|
+
if (hasVerdictTable(result.output)) {
|
|
618
|
+
if (key !== undefined)
|
|
619
|
+
writeGateCache(options.home, key, result.output, command.runtime);
|
|
620
|
+
return describe(command, result);
|
|
621
|
+
}
|
|
622
|
+
return { ...describe(command, result), warning: "cong chan mount loi: " + (result.error ?? (result.output.trim().slice(0, 200) || "khong ro")) };
|
|
623
|
+
}
|
|
624
|
+
const source = options.scriptSource ?? readScriptSource(options.script);
|
|
625
|
+
const requiresBun = source !== undefined && scriptNeedsBun(source);
|
|
626
|
+
const node = nodeScriptCommand(options.script, execPath);
|
|
627
|
+
const nodeResult = requiresBun ? undefined : run(node, options.cwd, timeoutMs);
|
|
628
|
+
if (nodeResult !== undefined && hasVerdictTable(nodeResult.output)) {
|
|
629
|
+
if (key !== undefined)
|
|
630
|
+
writeGateCache(options.home, key, nodeResult.output, node.runtime);
|
|
631
|
+
return describe(node, nodeResult);
|
|
632
|
+
}
|
|
633
|
+
const bunPath = (options.findBunPath ?? (() => findBun(env)))();
|
|
634
|
+
if (bunPath !== undefined) {
|
|
635
|
+
const bun = bunScriptCommand(bunPath, options.script, [], bunPath);
|
|
636
|
+
const bunResult = run(bun, options.cwd, timeoutMs);
|
|
637
|
+
if (hasVerdictTable(bunResult.output)) {
|
|
638
|
+
if (key !== undefined)
|
|
639
|
+
writeGateCache(options.home, key, bunResult.output, bun.runtime);
|
|
640
|
+
return describe(bun, bunResult, requiresBun ? " · script can bun" : " · node loi nen dung bun");
|
|
641
|
+
}
|
|
642
|
+
return { ...describe(bun, bunResult), warning: "cong chan mount loi: " + (bunResult.error ?? (bunResult.output.trim().slice(0, 200) || "khong ro")) };
|
|
643
|
+
}
|
|
644
|
+
const ms = performance.now() - started2;
|
|
645
|
+
const loiNode = nodeResult === undefined ? "" : (nodeResult.error ?? (nodeResult.output.trim().split(String.fromCharCode(10))[0] ?? "")).slice(0, 160);
|
|
646
|
+
const viSao = requiresBun ? "script " + options.script + " dùng API bun (Bun.build) nên Node không chạy được" : "node không chạy được " + options.script + (loiNode === "" ? "" : " (" + loiNode + ")");
|
|
647
|
+
return {
|
|
648
|
+
output: nodeResult?.output ?? "",
|
|
649
|
+
detail: requiresBun ? "bo qua node (script can bun) · " + ms.toFixed(0) + " ms" : "node (" + node.source + ") · " + ms.toFixed(0) + " ms",
|
|
650
|
+
warning: "cổng chặn mount bị bỏ qua: " + viSao + " và máy không có bun — cài bun hoặc đặt GBH_BUN=<đường dẫn bun>",
|
|
651
|
+
cached: false,
|
|
652
|
+
ms
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// apps/cli/src/mount-copy.ts
|
|
657
|
+
import { createHash as createHash3 } from "node:crypto";
|
|
658
|
+
import { cpSync, existsSync as existsSync5, lstatSync as lstatSync3, readdirSync as readdirSync4, readFileSync as readFileSync4, rmSync, realpathSync, writeFileSync as writeFileSync3 } from "node:fs";
|
|
659
|
+
import { dirname as dirname3, join as join5, sep } from "node:path";
|
|
388
660
|
function trungNguon(dich, nguon) {
|
|
389
661
|
const giai = (p) => {
|
|
390
662
|
try {
|
|
391
663
|
return realpathSync(p);
|
|
392
664
|
} catch {
|
|
393
665
|
try {
|
|
394
|
-
return
|
|
666
|
+
return join5(realpathSync(dirname3(p)), p.slice(p.lastIndexOf("/") + 1));
|
|
395
667
|
} catch {
|
|
396
668
|
return null;
|
|
397
669
|
}
|
|
@@ -404,16 +676,16 @@ function trungNguon(dich, nguon) {
|
|
|
404
676
|
return a === b || a.startsWith(b + sep) || b.startsWith(a + sep);
|
|
405
677
|
}
|
|
406
678
|
function vanTayCay(goc) {
|
|
407
|
-
const hash =
|
|
679
|
+
const hash = createHash3("sha256");
|
|
408
680
|
const duyet = (thuMuc) => {
|
|
409
681
|
let muc = [];
|
|
410
682
|
try {
|
|
411
|
-
muc =
|
|
683
|
+
muc = readdirSync4(thuMuc).sort();
|
|
412
684
|
} catch {
|
|
413
685
|
return;
|
|
414
686
|
}
|
|
415
687
|
for (const ten of muc) {
|
|
416
|
-
const duong =
|
|
688
|
+
const duong = join5(thuMuc, ten);
|
|
417
689
|
let thongTin;
|
|
418
690
|
try {
|
|
419
691
|
thongTin = lstatSync3(duong);
|
|
@@ -442,36 +714,36 @@ function vanTayCay(goc) {
|
|
|
442
714
|
function chepThuMucCon(dich, nguon, ten) {
|
|
443
715
|
if (trungNguon(dich, nguon))
|
|
444
716
|
return false;
|
|
445
|
-
const src =
|
|
446
|
-
if (!
|
|
717
|
+
const src = join5(nguon, ten);
|
|
718
|
+
if (!existsSync5(src))
|
|
447
719
|
return false;
|
|
448
|
-
const dest =
|
|
720
|
+
const dest = join5(dich, ten);
|
|
449
721
|
if (trungNguon(dest, src)) {
|
|
450
722
|
if (process.env.BH_TRACE === "1")
|
|
451
723
|
console.log("[trace] bo qua chep " + ten + " (dich la symlink ve nguon): " + dest);
|
|
452
724
|
return false;
|
|
453
725
|
}
|
|
454
|
-
const stampPath =
|
|
726
|
+
const stampPath = join5(dich, ".gbh-copy-" + ten + ".stamp");
|
|
455
727
|
const vanTay = vanTayCay(src);
|
|
456
|
-
if (
|
|
728
|
+
if (existsSync5(dest)) {
|
|
457
729
|
try {
|
|
458
|
-
if (
|
|
730
|
+
if (readFileSync4(stampPath, "utf8").trim() === vanTay)
|
|
459
731
|
return false;
|
|
460
732
|
} catch {}
|
|
461
733
|
}
|
|
462
734
|
rmSync(dest, { recursive: true, force: true });
|
|
463
735
|
cpSync(src, dest, { recursive: true });
|
|
464
736
|
try {
|
|
465
|
-
|
|
737
|
+
writeFileSync3(stampPath, vanTay + `
|
|
466
738
|
`);
|
|
467
739
|
} catch {}
|
|
468
740
|
return true;
|
|
469
741
|
}
|
|
470
742
|
function chiCoKhaiKieu(thuMucGoi) {
|
|
471
|
-
const t =
|
|
472
|
-
if (!
|
|
743
|
+
const t = join5(thuMucGoi, "lib", "types");
|
|
744
|
+
if (!existsSync5(t))
|
|
473
745
|
return false;
|
|
474
|
-
const ds =
|
|
746
|
+
const ds = readdirSync4(t);
|
|
475
747
|
return ds.length > 0 && ds.every((f) => f.endsWith(".d.ts"));
|
|
476
748
|
}
|
|
477
749
|
|
|
@@ -618,10 +890,10 @@ function readPeers(gbh) {
|
|
|
618
890
|
}
|
|
619
891
|
|
|
620
892
|
// apps/cli/src/prebuilt.ts
|
|
621
|
-
import { cpSync as cpSync2, existsSync as
|
|
622
|
-
import { dirname as dirname4, join as
|
|
893
|
+
import { cpSync as cpSync2, existsSync as existsSync6, mkdirSync as mkdirSync2, readlinkSync, rmSync as rmSync2, statSync as statSync2, symlinkSync as symlinkSync2 } from "node:fs";
|
|
894
|
+
import { dirname as dirname4, join as join6, resolve as resolve2 } from "node:path";
|
|
623
895
|
function embeddedHost() {
|
|
624
|
-
return
|
|
896
|
+
return existsSync6(join6(repoRoot(), ".gbh-embedded"));
|
|
625
897
|
}
|
|
626
898
|
function prebuiltLibs(env = process.env, embedded = embeddedHost()) {
|
|
627
899
|
const flag = (env.GBH_PREBUILT_LIB ?? "").trim();
|
|
@@ -632,16 +904,18 @@ function prebuiltLibs(env = process.env, embedded = embeddedHost()) {
|
|
|
632
904
|
return embedded;
|
|
633
905
|
}
|
|
634
906
|
function buildRuntimeAvailable() {
|
|
635
|
-
|
|
907
|
+
if (typeof globalThis.Bun !== "undefined")
|
|
908
|
+
return true;
|
|
909
|
+
return typeof process.versions.bun === "string";
|
|
636
910
|
}
|
|
637
911
|
function ensureLink(link, target) {
|
|
638
912
|
try {
|
|
639
913
|
const current = readlinkSync(link);
|
|
640
|
-
if (
|
|
914
|
+
if (existsSync6(resolve2(dirname4(link), current)))
|
|
641
915
|
return false;
|
|
642
916
|
rmSync2(link, { force: true });
|
|
643
917
|
} catch {
|
|
644
|
-
if (
|
|
918
|
+
if (existsSync6(link))
|
|
645
919
|
return false;
|
|
646
920
|
}
|
|
647
921
|
try {
|
|
@@ -653,14 +927,14 @@ function ensureLink(link, target) {
|
|
|
653
927
|
}
|
|
654
928
|
}
|
|
655
929
|
function installPrebuiltLib(sourceDir, libDir) {
|
|
656
|
-
const source =
|
|
657
|
-
const entry = ["index.js", "client.js"].map((name) =>
|
|
930
|
+
const source = join6(sourceDir, "lib");
|
|
931
|
+
const entry = ["index.js", "client.js"].map((name) => join6(source, name)).find((file) => existsSync6(file));
|
|
658
932
|
if (entry === undefined)
|
|
659
933
|
return false;
|
|
660
934
|
try {
|
|
661
|
-
const c_ =
|
|
662
|
-
const đ_ch =
|
|
663
|
-
if (
|
|
935
|
+
const c_ = statSync2(entry).mtimeMs;
|
|
936
|
+
const đ_ch = join6(libDir, entry.slice(source.length + 1));
|
|
937
|
+
if (existsSync6(đ_ch) && statSync2(đ_ch).mtimeMs >= c_)
|
|
664
938
|
return false;
|
|
665
939
|
mkdirSync2(libDir, { recursive: true });
|
|
666
940
|
cpSync2(source, libDir, { recursive: true, force: true });
|
|
@@ -726,28 +1000,34 @@ function parseRowVerdicts(output) {
|
|
|
726
1000
|
}
|
|
727
1001
|
function blockedPackages() {
|
|
728
1002
|
const blocked = new Map;
|
|
729
|
-
const script =
|
|
730
|
-
if (!
|
|
1003
|
+
const script = join7(repoRoot(), "tools", "check", "rows.ts");
|
|
1004
|
+
if (!existsSync7(script)) {
|
|
1005
|
+
console.warn("[bh] cổng chặn mount bị bỏ qua vì thiếu " + script + " — bản đóng gói không kèm tools/check; đặt GBH_REPO_ROOT về repo để bật cổng");
|
|
731
1006
|
return blocked;
|
|
732
|
-
|
|
733
|
-
const
|
|
734
|
-
|
|
1007
|
+
}
|
|
1008
|
+
const gate = timePhase("cong chan mount", () => runMountGate({ script, cwd: repoRoot(), home: appHome() }));
|
|
1009
|
+
console.log("[bh] cổng chặn mount: " + gate.detail);
|
|
1010
|
+
if (gate.warning !== undefined)
|
|
1011
|
+
console.warn("[bh] " + gate.warning);
|
|
1012
|
+
const verdicts = parseRowVerdicts(gate.output);
|
|
735
1013
|
for (const verdict of verdicts) {
|
|
736
1014
|
if (verdict.level === "chan")
|
|
737
1015
|
continue;
|
|
738
1016
|
console.log("[bh] " + verdict.pkg + ": " + verdict.level + ", van mount — " + verdict.reason);
|
|
739
1017
|
}
|
|
740
1018
|
for (const verdict of verdicts) {
|
|
741
|
-
if (verdict.level
|
|
742
|
-
|
|
1019
|
+
if (verdict.level !== "chan")
|
|
1020
|
+
continue;
|
|
1021
|
+
blocked.set(verdict.pkg, verdict.reason);
|
|
1022
|
+
console.warn("[bh] CHẶN mount " + verdict.pkg + " — " + verdict.reason);
|
|
743
1023
|
}
|
|
744
1024
|
return blocked;
|
|
745
1025
|
}
|
|
746
1026
|
function rewritePackages() {
|
|
747
|
-
const root =
|
|
1027
|
+
const root = join7(repoRoot(), "packages");
|
|
748
1028
|
const found = [];
|
|
749
1029
|
for (const dir of findPackageDirs(root)) {
|
|
750
|
-
const text =
|
|
1030
|
+
const text = readFileSync5(join7(dir, "package.json"), "utf8");
|
|
751
1031
|
const metadata = parseGbhMetadata(text);
|
|
752
1032
|
const nested = readNestedDeclaration(text);
|
|
753
1033
|
if (metadata?.row === undefined && nested === undefined)
|
|
@@ -764,7 +1044,7 @@ function rewritePackages() {
|
|
|
764
1044
|
specifier,
|
|
765
1045
|
sourceDir: dir,
|
|
766
1046
|
peers: [...new Set(["@deepseek-ai/cordis", "@deepseek-ai/schemastery", ...metadata?.peers ?? []])],
|
|
767
|
-
reference:
|
|
1047
|
+
reference: join7(relative(repoRoot(), dir), "README.md"),
|
|
768
1048
|
...metadata?.row === undefined ? {} : { row: metadata.row },
|
|
769
1049
|
...nested === undefined ? {} : { nested },
|
|
770
1050
|
...nested?.hostAliases === undefined ? {} : { hostAliases: nested.hostAliases }
|
|
@@ -777,7 +1057,7 @@ function findPackageDirs(root) {
|
|
|
777
1057
|
const walk = (dir) => {
|
|
778
1058
|
let entries;
|
|
779
1059
|
try {
|
|
780
|
-
entries =
|
|
1060
|
+
entries = readdirSync5(dir).sort();
|
|
781
1061
|
} catch {
|
|
782
1062
|
return;
|
|
783
1063
|
}
|
|
@@ -786,9 +1066,9 @@ function findPackageDirs(root) {
|
|
|
786
1066
|
for (const entry of entries) {
|
|
787
1067
|
if (entry === "node_modules" || entry === "lib" || entry === "dist" || entry.startsWith("."))
|
|
788
1068
|
continue;
|
|
789
|
-
const child =
|
|
1069
|
+
const child = join7(dir, entry);
|
|
790
1070
|
try {
|
|
791
|
-
if (
|
|
1071
|
+
if (statSync3(child).isDirectory())
|
|
792
1072
|
walk(child);
|
|
793
1073
|
} catch {}
|
|
794
1074
|
}
|
|
@@ -797,7 +1077,7 @@ function findPackageDirs(root) {
|
|
|
797
1077
|
return out;
|
|
798
1078
|
}
|
|
799
1079
|
function profileModulesDir() {
|
|
800
|
-
return
|
|
1080
|
+
return join7(appHome(), "profiles", "node_modules");
|
|
801
1081
|
}
|
|
802
1082
|
function kernelModulesDir2() {
|
|
803
1083
|
return kernelModulesDir();
|
|
@@ -806,39 +1086,42 @@ function buildIfStale(pkg, libDir) {
|
|
|
806
1086
|
if (prebuiltLibs())
|
|
807
1087
|
return installPrebuiltLib(pkg.sourceDir, libDir);
|
|
808
1088
|
if (embeddedHost())
|
|
809
|
-
return
|
|
810
|
-
if (!buildRuntimeAvailable() && (
|
|
1089
|
+
return existsSync7(join7(libDir, "index.js"));
|
|
1090
|
+
if (!buildRuntimeAvailable() && (existsSync7(join7(pkg.sourceDir, "lib", "index.js")) || existsSync7(join7(pkg.sourceDir, "lib", "client.js")))) {
|
|
811
1091
|
return installPrebuiltLib(pkg.sourceDir, libDir);
|
|
812
1092
|
}
|
|
813
|
-
if (process.env.BH_SKIP_BUILD === "1" &&
|
|
1093
|
+
if (process.env.BH_SKIP_BUILD === "1" && existsSync7(join7(libDir, "index.js")))
|
|
814
1094
|
return false;
|
|
815
|
-
const hasClientSource =
|
|
1095
|
+
const hasClientSource = existsSync7(join7(pkg.sourceDir, "src", "client.ts"));
|
|
816
1096
|
const outputs = hasClientSource ? ["index.js", "client.js"] : ["index.js"];
|
|
817
|
-
const stampPath =
|
|
1097
|
+
const stampPath = join7(libDir, ".gbh-build-stamp");
|
|
818
1098
|
const stamp = sourceStamp(pkg.sourceDir);
|
|
819
|
-
const previous2 =
|
|
820
|
-
const missingOutput = outputs.some((file) => !
|
|
1099
|
+
const previous2 = existsSync7(stampPath) ? readFileSync5(stampPath, "utf8").trim() : "";
|
|
1100
|
+
const missingOutput = outputs.some((file) => !existsSync7(join7(libDir, file)));
|
|
821
1101
|
if (!missingOutput && previous2 === stamp)
|
|
822
1102
|
return false;
|
|
823
|
-
const thuMucTypes =
|
|
1103
|
+
const thuMucTypes = join7(libDir, "types");
|
|
824
1104
|
let banSaoTypes;
|
|
825
|
-
if (
|
|
1105
|
+
if (existsSync7(thuMucTypes)) {
|
|
826
1106
|
try {
|
|
827
|
-
banSaoTypes = mkdtempSync(
|
|
828
|
-
cpSync3(thuMucTypes,
|
|
1107
|
+
banSaoTypes = mkdtempSync(join7(tmpdir(), "gbh-types-"));
|
|
1108
|
+
cpSync3(thuMucTypes, join7(banSaoTypes, "types"), { recursive: true });
|
|
829
1109
|
} catch (error) {
|
|
830
1110
|
banSaoTypes = undefined;
|
|
831
1111
|
console.log("[bh] canh bao: khong snapshot duoc lib/types cua " + pkg.specifier + " (" + String(error).slice(0, 80) + ")");
|
|
832
1112
|
}
|
|
833
1113
|
}
|
|
834
|
-
const
|
|
1114
|
+
const build = bunOnlyCommand(join7(pkg.sourceDir, "build.ts"), [libDir]);
|
|
1115
|
+
if (build === undefined)
|
|
1116
|
+
throw new Error("khong build duoc " + pkg.specifier + ": thieu bun — cài bun hoặc đặt GBH_BUN");
|
|
1117
|
+
const result = spawnSync2(build.command, build.args, {
|
|
835
1118
|
cwd: pkg.sourceDir,
|
|
836
1119
|
encoding: "utf8",
|
|
837
1120
|
timeout: 60000
|
|
838
1121
|
});
|
|
839
1122
|
if (banSaoTypes !== undefined) {
|
|
840
1123
|
try {
|
|
841
|
-
cpSync3(
|
|
1124
|
+
cpSync3(join7(banSaoTypes, "types"), thuMucTypes, { recursive: true, force: true });
|
|
842
1125
|
} catch (error) {
|
|
843
1126
|
console.log("[bh] canh bao: khong phuc hoi duoc lib/types cua " + pkg.specifier + " (" + String(error).slice(0, 80) + ")");
|
|
844
1127
|
}
|
|
@@ -850,43 +1133,43 @@ function buildIfStale(pkg, libDir) {
|
|
|
850
1133
|
throw new Error("khong build duoc " + pkg.specifier + ": " + (result.stderr.trim() || result.stdout.trim() || "loi khong ro"));
|
|
851
1134
|
}
|
|
852
1135
|
mkdirSync3(libDir, { recursive: true });
|
|
853
|
-
|
|
1136
|
+
writeFileSync4(stampPath, stamp + `
|
|
854
1137
|
`, "utf8");
|
|
855
1138
|
return true;
|
|
856
1139
|
}
|
|
857
1140
|
function sourceStamp(sourceDir) {
|
|
858
|
-
const hash =
|
|
1141
|
+
const hash = createHash4("sha256");
|
|
859
1142
|
const files = [];
|
|
860
1143
|
const walk = (dir) => {
|
|
861
|
-
if (!
|
|
1144
|
+
if (!existsSync7(dir))
|
|
862
1145
|
return;
|
|
863
|
-
for (const name of
|
|
1146
|
+
for (const name of readdirSync5(dir).sort()) {
|
|
864
1147
|
if (name === "node_modules")
|
|
865
1148
|
continue;
|
|
866
|
-
const abs =
|
|
867
|
-
if (
|
|
1149
|
+
const abs = join7(dir, name);
|
|
1150
|
+
if (statSync3(abs).isDirectory())
|
|
868
1151
|
walk(abs);
|
|
869
1152
|
else
|
|
870
1153
|
files.push(abs);
|
|
871
1154
|
}
|
|
872
1155
|
};
|
|
873
|
-
walk(
|
|
874
|
-
const buildTs =
|
|
875
|
-
if (
|
|
1156
|
+
walk(join7(sourceDir, "src"));
|
|
1157
|
+
const buildTs = join7(sourceDir, "build.ts");
|
|
1158
|
+
if (existsSync7(buildTs))
|
|
876
1159
|
files.push(buildTs);
|
|
877
1160
|
for (const abs of files.sort()) {
|
|
878
1161
|
hash.update(abs.slice(sourceDir.length));
|
|
879
1162
|
hash.update("\x00");
|
|
880
|
-
hash.update(
|
|
1163
|
+
hash.update(readFileSync5(abs));
|
|
881
1164
|
hash.update("\x00");
|
|
882
1165
|
}
|
|
883
1166
|
return hash.digest("hex");
|
|
884
1167
|
}
|
|
885
1168
|
function mountRewritePackage(pkg) {
|
|
886
|
-
const dir =
|
|
1169
|
+
const dir = join7(profileModulesDir(), pkg.specifier);
|
|
887
1170
|
const peers = [];
|
|
888
1171
|
try {
|
|
889
|
-
if (!
|
|
1172
|
+
if (!existsSync7(join7(pkg.sourceDir, "package.json"))) {
|
|
890
1173
|
return { specifier: pkg.specifier, row: pkg.row, dir, built: false, peers, ok: false, detail: "thieu nguon " + pkg.sourceDir };
|
|
891
1174
|
}
|
|
892
1175
|
const trace = process.env.BH_TRACE === "1" ? (step) => {
|
|
@@ -896,15 +1179,15 @@ function mountRewritePackage(pkg) {
|
|
|
896
1179
|
let built = false;
|
|
897
1180
|
let buildError = "";
|
|
898
1181
|
try {
|
|
899
|
-
built = buildIfStale(pkg,
|
|
1182
|
+
built = buildIfStale(pkg, join7(dir, "lib"));
|
|
900
1183
|
} catch (error) {
|
|
901
1184
|
buildError = String(error);
|
|
902
1185
|
}
|
|
903
1186
|
if (buildError !== "") {
|
|
904
|
-
const repoLib =
|
|
905
|
-
if (
|
|
906
|
-
mkdirSync3(
|
|
907
|
-
cpSync3(repoLib,
|
|
1187
|
+
const repoLib = join7(pkg.sourceDir, "lib");
|
|
1188
|
+
if (existsSync7(join7(repoLib, "index.js"))) {
|
|
1189
|
+
mkdirSync3(join7(dir, "lib"), { recursive: true });
|
|
1190
|
+
cpSync3(repoLib, join7(dir, "lib"), { recursive: true });
|
|
908
1191
|
if (!embeddedHost())
|
|
909
1192
|
console.log("[bh] " + pkg.specifier + ": dung artefact co san trong repo (build loi: " + buildError.slice(0, 120) + ")");
|
|
910
1193
|
} else {
|
|
@@ -913,23 +1196,23 @@ function mountRewritePackage(pkg) {
|
|
|
913
1196
|
}
|
|
914
1197
|
trace("build xong built=" + String(built));
|
|
915
1198
|
mkdirSync3(dir, { recursive: true });
|
|
916
|
-
const manifestNguon =
|
|
917
|
-
const manifestDich =
|
|
918
|
-
if (!
|
|
919
|
-
|
|
1199
|
+
const manifestNguon = readFileSync5(join7(pkg.sourceDir, "package.json"), "utf8");
|
|
1200
|
+
const manifestDich = join7(dir, "package.json");
|
|
1201
|
+
if (!existsSync7(manifestDich) || readFileSync5(manifestDich, "utf8") !== manifestNguon)
|
|
1202
|
+
writeFileSync4(manifestDich, manifestNguon);
|
|
920
1203
|
chepThuMucCon(dir, pkg.sourceDir, "locale");
|
|
921
1204
|
chepThuMucCon(dir, pkg.sourceDir, "assets");
|
|
922
1205
|
chepThuMucCon(dir, pkg.sourceDir, "runtime");
|
|
923
1206
|
for (const ten of ["icon.svg", "icon.png"]) {
|
|
924
|
-
const nguonIcon =
|
|
925
|
-
if (
|
|
926
|
-
cpSync3(nguonIcon,
|
|
1207
|
+
const nguonIcon = join7(pkg.sourceDir, ten);
|
|
1208
|
+
if (existsSync7(nguonIcon))
|
|
1209
|
+
cpSync3(nguonIcon, join7(dir, ten));
|
|
927
1210
|
}
|
|
928
1211
|
trace("chuan bi peer " + String(pkg.peers.length));
|
|
929
1212
|
for (const peer of pkg.peers) {
|
|
930
|
-
const link =
|
|
931
|
-
const source =
|
|
932
|
-
if (!
|
|
1213
|
+
const link = join7(profileModulesDir(), peer);
|
|
1214
|
+
const source = join7(kernelModulesDir2(), peer);
|
|
1215
|
+
if (!existsSync7(source)) {
|
|
933
1216
|
if (peer.startsWith("@galaxy-blackhole/"))
|
|
934
1217
|
continue;
|
|
935
1218
|
return { specifier: pkg.specifier, row: pkg.row, dir, built, peers, ok: false, detail: "thieu peer trong kernel: " + source };
|
|
@@ -949,21 +1232,21 @@ function linkInfrastructurePackages() {
|
|
|
949
1232
|
const linked = [];
|
|
950
1233
|
const modules = profileModulesDir();
|
|
951
1234
|
for (const ten of ["cordis", "schemastery", "cosmokit"]) {
|
|
952
|
-
const nguon =
|
|
953
|
-
const manifest =
|
|
954
|
-
if (!
|
|
1235
|
+
const nguon = join7(repoRoot(), "packages", "host", ten);
|
|
1236
|
+
const manifest = join7(nguon, "package.json");
|
|
1237
|
+
if (!existsSync7(manifest))
|
|
955
1238
|
continue;
|
|
956
1239
|
let specifier;
|
|
957
1240
|
try {
|
|
958
|
-
specifier = JSON.parse(
|
|
1241
|
+
specifier = JSON.parse(readFileSync5(manifest, "utf8")).name;
|
|
959
1242
|
} catch {
|
|
960
1243
|
continue;
|
|
961
1244
|
}
|
|
962
1245
|
if (typeof specifier !== "string")
|
|
963
1246
|
continue;
|
|
964
|
-
const link =
|
|
1247
|
+
const link = join7(modules, specifier);
|
|
965
1248
|
try {
|
|
966
|
-
if (
|
|
1249
|
+
if (existsSync7(link) || lstatSync4(link).isSymbolicLink())
|
|
967
1250
|
continue;
|
|
968
1251
|
} catch {}
|
|
969
1252
|
try {
|
|
@@ -981,10 +1264,10 @@ function linkInfrastructurePackages() {
|
|
|
981
1264
|
function linkNativeAddonPackages() {
|
|
982
1265
|
const linked = [];
|
|
983
1266
|
const nguonModules = kernelModulesDir2();
|
|
984
|
-
const thuMucStock =
|
|
1267
|
+
const thuMucStock = join7(nguonModules, "@deepseek-ai");
|
|
985
1268
|
let ten = [];
|
|
986
1269
|
try {
|
|
987
|
-
ten =
|
|
1270
|
+
ten = readdirSync5(thuMucStock);
|
|
988
1271
|
} catch {
|
|
989
1272
|
return linked;
|
|
990
1273
|
}
|
|
@@ -992,10 +1275,10 @@ function linkNativeAddonPackages() {
|
|
|
992
1275
|
for (const goi of ten) {
|
|
993
1276
|
if (!mau.test(goi))
|
|
994
1277
|
continue;
|
|
995
|
-
const nguon =
|
|
996
|
-
const link =
|
|
1278
|
+
const nguon = join7(thuMucStock, goi);
|
|
1279
|
+
const link = join7(profileModulesDir(), "@deepseek-ai", goi);
|
|
997
1280
|
try {
|
|
998
|
-
if (
|
|
1281
|
+
if (existsSync7(link))
|
|
999
1282
|
continue;
|
|
1000
1283
|
} catch {}
|
|
1001
1284
|
try {
|
|
@@ -1013,10 +1296,10 @@ function linkNativeAddonPackages() {
|
|
|
1013
1296
|
function ensureRewriteMounts() {
|
|
1014
1297
|
linkSelfPackages();
|
|
1015
1298
|
const disabled = (process.env.GBH_DISABLE_REWRITES ?? "").trim() !== "";
|
|
1016
|
-
const blocked = blockedPackages();
|
|
1299
|
+
const blocked = disabled ? new Map : blockedPackages();
|
|
1017
1300
|
const results = rewritePackages().map((pkg) => disabled ? {
|
|
1018
1301
|
specifier: pkg.specifier,
|
|
1019
|
-
dir:
|
|
1302
|
+
dir: join7(profileModulesDir(), pkg.specifier),
|
|
1020
1303
|
built: false,
|
|
1021
1304
|
peers: [],
|
|
1022
1305
|
ok: false,
|
|
@@ -1024,7 +1307,7 @@ function ensureRewriteMounts() {
|
|
|
1024
1307
|
} : blocked.has(pkg.specifier) ? {
|
|
1025
1308
|
specifier: pkg.specifier,
|
|
1026
1309
|
row: pkg.row,
|
|
1027
|
-
dir:
|
|
1310
|
+
dir: join7(profileModulesDir(), pkg.specifier),
|
|
1028
1311
|
built: false,
|
|
1029
1312
|
peers: [],
|
|
1030
1313
|
ok: false,
|
|
@@ -1047,30 +1330,30 @@ function chepIconVaoProfile() {
|
|
|
1047
1330
|
let soIcon = 0;
|
|
1048
1331
|
const gocProfile = profileModulesDir();
|
|
1049
1332
|
for (const nhom of ["host", "client", "tools"]) {
|
|
1050
|
-
const thuMuc =
|
|
1333
|
+
const thuMuc = join7(repoRoot(), "packages", nhom);
|
|
1051
1334
|
let ten = [];
|
|
1052
1335
|
try {
|
|
1053
|
-
ten =
|
|
1336
|
+
ten = readdirSync5(thuMuc);
|
|
1054
1337
|
} catch {
|
|
1055
1338
|
continue;
|
|
1056
1339
|
}
|
|
1057
1340
|
for (const goi of ten) {
|
|
1058
|
-
const nguonDir =
|
|
1341
|
+
const nguonDir = join7(thuMuc, goi);
|
|
1059
1342
|
let tenGoi;
|
|
1060
1343
|
try {
|
|
1061
|
-
tenGoi = JSON.parse(
|
|
1344
|
+
tenGoi = JSON.parse(readFileSync5(join7(nguonDir, "package.json"), "utf8")).name;
|
|
1062
1345
|
} catch {
|
|
1063
1346
|
continue;
|
|
1064
1347
|
}
|
|
1065
1348
|
if (typeof tenGoi !== "string")
|
|
1066
1349
|
continue;
|
|
1067
|
-
const dichDir =
|
|
1350
|
+
const dichDir = join7(gocProfile, tenGoi);
|
|
1068
1351
|
for (const f of ["icon.svg", "icon.png"]) {
|
|
1069
|
-
const nguon =
|
|
1070
|
-
if (!
|
|
1352
|
+
const nguon = join7(nguonDir, f);
|
|
1353
|
+
if (!existsSync7(nguon))
|
|
1071
1354
|
continue;
|
|
1072
1355
|
try {
|
|
1073
|
-
cpSync3(nguon,
|
|
1356
|
+
cpSync3(nguon, join7(dichDir, f));
|
|
1074
1357
|
soIcon += 1;
|
|
1075
1358
|
} catch {
|
|
1076
1359
|
continue;
|
|
@@ -1083,18 +1366,18 @@ function chepIconVaoProfile() {
|
|
|
1083
1366
|
return soIcon;
|
|
1084
1367
|
}
|
|
1085
1368
|
function vaMatApiLlmDeepSeek() {
|
|
1086
|
-
const stock =
|
|
1087
|
-
if (!
|
|
1369
|
+
const stock = join7(kernelModulesDir2(), "@deepseek-ai", "dsh-llm-deepseek", "lib", "index.js");
|
|
1370
|
+
if (!existsSync7(stock))
|
|
1088
1371
|
return 0;
|
|
1089
1372
|
let soTep = 0;
|
|
1090
|
-
const gocProfile =
|
|
1373
|
+
const gocProfile = join7(profileModulesDir(), "@galaxy-blackhole");
|
|
1091
1374
|
for (const goi of ["gbh-llm-deepseek-account", "gbh-llm-deepseek-api-key"]) {
|
|
1092
|
-
const tep =
|
|
1093
|
-
if (!
|
|
1375
|
+
const tep = join7(gocProfile, goi, "lib", "index.js");
|
|
1376
|
+
if (!existsSync7(tep))
|
|
1094
1377
|
continue;
|
|
1095
1378
|
let text = "";
|
|
1096
1379
|
try {
|
|
1097
|
-
text =
|
|
1380
|
+
text = readFileSync5(tep, "utf8");
|
|
1098
1381
|
} catch {
|
|
1099
1382
|
continue;
|
|
1100
1383
|
}
|
|
@@ -1102,7 +1385,7 @@ function vaMatApiLlmDeepSeek() {
|
|
|
1102
1385
|
if (sau === text)
|
|
1103
1386
|
continue;
|
|
1104
1387
|
try {
|
|
1105
|
-
|
|
1388
|
+
writeFileSync4(tep, sau);
|
|
1106
1389
|
soTep += 1;
|
|
1107
1390
|
} catch {
|
|
1108
1391
|
continue;
|
|
@@ -1113,7 +1396,7 @@ function vaMatApiLlmDeepSeek() {
|
|
|
1113
1396
|
return soTep;
|
|
1114
1397
|
}
|
|
1115
1398
|
function suaIdTrongProfile() {
|
|
1116
|
-
const thuMuc =
|
|
1399
|
+
const thuMuc = join7(profileModulesDir(), "@galaxy-blackhole");
|
|
1117
1400
|
try {
|
|
1118
1401
|
const force = (process.env.GBH_FORCE_REWRITE ?? "").trim() === "1";
|
|
1119
1402
|
const kq = suaIdProfile(thuMuc, repoRoot(), { force });
|
|
@@ -1125,37 +1408,37 @@ function suaIdTrongProfile() {
|
|
|
1125
1408
|
}
|
|
1126
1409
|
}
|
|
1127
1410
|
function mountLocalBundles() {
|
|
1128
|
-
const root =
|
|
1129
|
-
if (!
|
|
1411
|
+
const root = join7(repoRoot(), "packages", "host");
|
|
1412
|
+
if (!existsSync7(root))
|
|
1130
1413
|
return [];
|
|
1131
1414
|
const copied = [];
|
|
1132
|
-
for (const entry of
|
|
1415
|
+
for (const entry of readdirSync5(root, { withFileTypes: true })) {
|
|
1133
1416
|
if (!entry.isDirectory() || !entry.name.startsWith("bundle-"))
|
|
1134
1417
|
continue;
|
|
1135
|
-
const source =
|
|
1136
|
-
const manifestPath =
|
|
1137
|
-
if (!
|
|
1418
|
+
const source = join7(root, entry.name);
|
|
1419
|
+
const manifestPath = join7(source, "package.json");
|
|
1420
|
+
if (!existsSync7(manifestPath))
|
|
1138
1421
|
continue;
|
|
1139
1422
|
let specifier;
|
|
1140
1423
|
try {
|
|
1141
|
-
const manifest = JSON.parse(
|
|
1424
|
+
const manifest = JSON.parse(readFileSync5(manifestPath, "utf8"));
|
|
1142
1425
|
if (typeof manifest.name !== "string")
|
|
1143
1426
|
continue;
|
|
1144
1427
|
specifier = manifest.name;
|
|
1145
1428
|
} catch {
|
|
1146
1429
|
continue;
|
|
1147
1430
|
}
|
|
1148
|
-
const dir =
|
|
1431
|
+
const dir = join7(profileModulesDir(), specifier);
|
|
1149
1432
|
mkdirSync3(dir, { recursive: true });
|
|
1150
1433
|
for (const file of ["package.json", "cordis.patch.yml"]) {
|
|
1151
|
-
const from =
|
|
1152
|
-
if (!
|
|
1434
|
+
const from = join7(source, file);
|
|
1435
|
+
if (!existsSync7(from))
|
|
1153
1436
|
continue;
|
|
1154
|
-
const to =
|
|
1155
|
-
const text =
|
|
1156
|
-
if (
|
|
1437
|
+
const to = join7(dir, file);
|
|
1438
|
+
const text = readFileSync5(from, "utf8");
|
|
1439
|
+
if (existsSync7(to) && readFileSync5(to, "utf8") === text)
|
|
1157
1440
|
continue;
|
|
1158
|
-
|
|
1441
|
+
writeFileSync4(to, text);
|
|
1159
1442
|
}
|
|
1160
1443
|
copied.push(specifier);
|
|
1161
1444
|
}
|
|
@@ -1168,7 +1451,7 @@ function applyHostAliases(results) {
|
|
|
1168
1451
|
continue;
|
|
1169
1452
|
const aliases = [...result.row?.hostAliases ?? [], ...result.hostAliases ?? []];
|
|
1170
1453
|
for (const alias of aliases) {
|
|
1171
|
-
const link =
|
|
1454
|
+
const link = join7(profileModulesDir(), alias);
|
|
1172
1455
|
try {
|
|
1173
1456
|
mkdirSync3(dirname5(link), { recursive: true });
|
|
1174
1457
|
rmSync3(link, { recursive: true, force: true });
|
|
@@ -1187,21 +1470,21 @@ function linkMoiGoiGbh() {
|
|
|
1187
1470
|
let tao = 0;
|
|
1188
1471
|
const modules = profileModulesDir();
|
|
1189
1472
|
for (const tang of ["host", "client", "tools"]) {
|
|
1190
|
-
const goc =
|
|
1191
|
-
if (!
|
|
1473
|
+
const goc = join7(repoRoot(), "packages", tang);
|
|
1474
|
+
if (!existsSync7(goc))
|
|
1192
1475
|
continue;
|
|
1193
|
-
for (const ten of
|
|
1194
|
-
const pj =
|
|
1195
|
-
if (!
|
|
1476
|
+
for (const ten of readdirSync5(goc)) {
|
|
1477
|
+
const pj = join7(goc, ten, "package.json");
|
|
1478
|
+
if (!existsSync7(pj))
|
|
1196
1479
|
continue;
|
|
1197
1480
|
try {
|
|
1198
|
-
const meta = JSON.parse(
|
|
1481
|
+
const meta = JSON.parse(readFileSync5(pj, "utf8"));
|
|
1199
1482
|
const tenGoi = meta.name ?? "";
|
|
1200
1483
|
if (!tenGoi.startsWith("@galaxy-blackhole/"))
|
|
1201
1484
|
continue;
|
|
1202
1485
|
const ngan = tenGoi.slice("@galaxy-blackhole/".length);
|
|
1203
|
-
const link =
|
|
1204
|
-
if (!ensureLink(link,
|
|
1486
|
+
const link = join7(modules, "@galaxy-blackhole", ngan);
|
|
1487
|
+
if (!ensureLink(link, join7(goc, ten)))
|
|
1205
1488
|
continue;
|
|
1206
1489
|
tao += 1;
|
|
1207
1490
|
} catch {
|
|
@@ -1227,13 +1510,13 @@ function applyProvenanceAliases() {
|
|
|
1227
1510
|
"@deepseek-ai/node-addon-system"
|
|
1228
1511
|
]);
|
|
1229
1512
|
for (const tier of ["host", "client"]) {
|
|
1230
|
-
const goc =
|
|
1231
|
-
if (!
|
|
1513
|
+
const goc = join7(REPO_ROOT, "packages", tier);
|
|
1514
|
+
if (!existsSync7(goc))
|
|
1232
1515
|
continue;
|
|
1233
|
-
for (const ten of
|
|
1234
|
-
const dir =
|
|
1516
|
+
for (const ten of readdirSync5(goc)) {
|
|
1517
|
+
const dir = join7(goc, ten);
|
|
1235
1518
|
try {
|
|
1236
|
-
const manifest = JSON.parse(
|
|
1519
|
+
const manifest = JSON.parse(readFileSync5(join7(dir, "package.json"), "utf8"));
|
|
1237
1520
|
const ours = typeof manifest.name === "string" ? manifest.name : "";
|
|
1238
1521
|
if (!ours.startsWith("@galaxy-blackhole/"))
|
|
1239
1522
|
continue;
|
|
@@ -1250,23 +1533,23 @@ function applyProvenanceAliases() {
|
|
|
1250
1533
|
}
|
|
1251
1534
|
const tenNgan = ours.replace("@galaxy-blackhole/", "").replace(/^gbh-/, "").replace(/^host-/, "");
|
|
1252
1535
|
for (const ung of ["@deepseek-ai/dsh-" + tenNgan, "@deepseek-ai/dsh-host-" + tenNgan]) {
|
|
1253
|
-
const thuMucKernel =
|
|
1254
|
-
if (
|
|
1536
|
+
const thuMucKernel = join7(kernelModulesDir2(), ung);
|
|
1537
|
+
if (existsSync7(thuMucKernel))
|
|
1255
1538
|
stocks.push(ung);
|
|
1256
1539
|
}
|
|
1257
|
-
const dichProfile =
|
|
1258
|
-
if (!
|
|
1540
|
+
const dichProfile = join7(modules, ours);
|
|
1541
|
+
if (!existsSync7(dichProfile) && !existsSync7(join7(dir, "lib")))
|
|
1259
1542
|
continue;
|
|
1260
|
-
const dich =
|
|
1543
|
+
const dich = existsSync7(dichProfile) ? dichProfile : dir;
|
|
1261
1544
|
for (const stock of stocks) {
|
|
1262
1545
|
if (!stock.startsWith("@deepseek-ai/") || CAM.has(stock))
|
|
1263
1546
|
continue;
|
|
1264
|
-
const link =
|
|
1547
|
+
const link = join7(modules, stock);
|
|
1265
1548
|
try {
|
|
1266
|
-
const thuMucKernelTruoc =
|
|
1267
|
-
const nguonTruoc = chiCoKhaiKieu(dir) &&
|
|
1549
|
+
const thuMucKernelTruoc = join7(kernelModulesDir2(), stock);
|
|
1550
|
+
const nguonTruoc = chiCoKhaiKieu(dir) && existsSync7(thuMucKernelTruoc) ? thuMucKernelTruoc : dich;
|
|
1268
1551
|
const dichThat = realpathSync2(nguonTruoc);
|
|
1269
|
-
if (
|
|
1552
|
+
if (existsSync7(link)) {
|
|
1270
1553
|
const hienTai = lstatSync4(link).isSymbolicLink() ? realpathSync2(link) : undefined;
|
|
1271
1554
|
if (hienTai !== undefined && hienTai === dichThat)
|
|
1272
1555
|
continue;
|
|
@@ -1279,8 +1562,8 @@ function applyProvenanceAliases() {
|
|
|
1279
1562
|
}
|
|
1280
1563
|
mkdirSync3(dirname5(link), { recursive: true });
|
|
1281
1564
|
rmSync3(link, { recursive: true, force: true });
|
|
1282
|
-
const thuMucKernel =
|
|
1283
|
-
const nguonAlias = chiCoKhaiKieu(dir) &&
|
|
1565
|
+
const thuMucKernel = join7(kernelModulesDir2(), stock);
|
|
1566
|
+
const nguonAlias = chiCoKhaiKieu(dir) && existsSync7(thuMucKernel) ? thuMucKernel : dich;
|
|
1284
1567
|
symlinkSync3(realpathSync2(nguonAlias), link, "dir");
|
|
1285
1568
|
applied.push(stock + " -> " + ours);
|
|
1286
1569
|
} catch {
|
|
@@ -1298,10 +1581,10 @@ function applyProvenanceAliases() {
|
|
|
1298
1581
|
}
|
|
1299
1582
|
|
|
1300
1583
|
// apps/cli/src/profile.ts
|
|
1301
|
-
import { createHash as
|
|
1302
|
-
import { existsSync as
|
|
1303
|
-
import { homedir as
|
|
1304
|
-
import { dirname as dirname6, join as
|
|
1584
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
1585
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync4, readdirSync as readdirSync6, readFileSync as readFileSync6, renameSync, writeFileSync as writeFileSync5 } from "node:fs";
|
|
1586
|
+
import { homedir as homedir3 } from "node:os";
|
|
1587
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
1305
1588
|
var DEFAULT_FEATURE_BUNDLES = [
|
|
1306
1589
|
"@galaxy-blackhole/gbh-plugin-market-bundle",
|
|
1307
1590
|
"@galaxy-blackhole/gbh-terminal-bundle",
|
|
@@ -1327,12 +1610,12 @@ autoInstallPeers: false
|
|
|
1327
1610
|
function expandTildeInScalars(text, home) {
|
|
1328
1611
|
return text.replace(/(["'])(~[^"']*)\1/gu, (_match, quote, scalar) => {
|
|
1329
1612
|
const suffix = scalar.startsWith("~/") ? scalar.slice(2) : "";
|
|
1330
|
-
return `${quote}${suffix === "" ? home :
|
|
1613
|
+
return `${quote}${suffix === "" ? home : join8(home, suffix)}${quote}`;
|
|
1331
1614
|
});
|
|
1332
1615
|
}
|
|
1333
1616
|
function readTemplate(file) {
|
|
1334
1617
|
try {
|
|
1335
|
-
return
|
|
1618
|
+
return readFileSync6(join8(profileTemplateDir(), file), "utf8");
|
|
1336
1619
|
} catch {
|
|
1337
1620
|
return;
|
|
1338
1621
|
}
|
|
@@ -1343,28 +1626,28 @@ function ensureProfile(name = DEFAULT_PROFILE) {
|
|
|
1343
1626
|
const created = [];
|
|
1344
1627
|
const updated = [];
|
|
1345
1628
|
const reused = [];
|
|
1346
|
-
const cordisPath =
|
|
1347
|
-
if (!
|
|
1348
|
-
|
|
1629
|
+
const cordisPath = join8(dir, "cordis.yml");
|
|
1630
|
+
if (!existsSync8(cordisPath)) {
|
|
1631
|
+
writeFileSync5(cordisPath, readTemplate("cordis.yml") ?? `# dsh profile root — an empty entry list.
|
|
1349
1632
|
[]
|
|
1350
1633
|
`);
|
|
1351
1634
|
created.push("cordis.yml");
|
|
1352
1635
|
} else {
|
|
1353
1636
|
reused.push("cordis.yml");
|
|
1354
1637
|
}
|
|
1355
|
-
const patchPath =
|
|
1356
|
-
if (!
|
|
1638
|
+
const patchPath = join8(dir, "cordis.patch.yml");
|
|
1639
|
+
if (!existsSync8(patchPath)) {
|
|
1357
1640
|
const template = readTemplate("cordis.patch.yml");
|
|
1358
|
-
|
|
1359
|
-
` : expandTildeInScalars(template,
|
|
1641
|
+
writeFileSync5(patchPath, template === undefined ? `[]
|
|
1642
|
+
` : expandTildeInScalars(template, homedir3()));
|
|
1360
1643
|
created.push("cordis.patch.yml");
|
|
1361
1644
|
} else {
|
|
1362
1645
|
reused.push("cordis.patch.yml");
|
|
1363
1646
|
}
|
|
1364
|
-
const manifestPath =
|
|
1647
|
+
const manifestPath = join8(dir, "package.json");
|
|
1365
1648
|
const manifest = (() => {
|
|
1366
1649
|
try {
|
|
1367
|
-
return JSON.parse(
|
|
1650
|
+
return JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
1368
1651
|
} catch {
|
|
1369
1652
|
return {};
|
|
1370
1653
|
}
|
|
@@ -1373,7 +1656,7 @@ function ensureProfile(name = DEFAULT_PROFILE) {
|
|
|
1373
1656
|
const current = Array.isArray(declared) ? declared.map(String) : [];
|
|
1374
1657
|
const extra = (() => {
|
|
1375
1658
|
try {
|
|
1376
|
-
const raw =
|
|
1659
|
+
const raw = readFileSync6(join8(dir, "extra-bundles.json"), "utf8");
|
|
1377
1660
|
const parsed = JSON.parse(raw);
|
|
1378
1661
|
return Array.isArray(parsed) ? parsed.map(String) : [];
|
|
1379
1662
|
} catch {
|
|
@@ -1386,23 +1669,23 @@ function ensureProfile(name = DEFAULT_PROFILE) {
|
|
|
1386
1669
|
"@deepseek-ai/dsh-subagent-codex"
|
|
1387
1670
|
]);
|
|
1388
1671
|
const giuLai = dungBundleTa ? current.filter((ten) => !ten.startsWith("@deepseek-ai/dsh-") || BUNDLE_STOCK_CON_GIU.has(ten)) : current;
|
|
1389
|
-
const bundles =
|
|
1390
|
-
if (!
|
|
1391
|
-
|
|
1672
|
+
const bundles = existsSync8(manifestPath) ? [...new Set([...APP_PROFILE_BUNDLES, ...giuLai, ...extra])] : [...new Set([...APP_PROFILE_BUNDLES, ...DEFAULT_FEATURE_BUNDLES, ...extra])];
|
|
1673
|
+
if (!existsSync8(manifestPath)) {
|
|
1674
|
+
writeFileSync5(manifestPath, JSON.stringify(manifestOf(name, manifest, bundles), null, 2) + `
|
|
1392
1675
|
`);
|
|
1393
1676
|
created.push("package.json");
|
|
1394
1677
|
} else if (current.join(`
|
|
1395
1678
|
`) !== bundles.join(`
|
|
1396
1679
|
`)) {
|
|
1397
|
-
|
|
1680
|
+
writeFileSync5(manifestPath, JSON.stringify(manifestOf(name, manifest, bundles), null, 2) + `
|
|
1398
1681
|
`);
|
|
1399
1682
|
updated.push("package.json");
|
|
1400
1683
|
} else {
|
|
1401
1684
|
reused.push("package.json");
|
|
1402
1685
|
}
|
|
1403
|
-
const workspacePath =
|
|
1404
|
-
if (!
|
|
1405
|
-
|
|
1686
|
+
const workspacePath = join8(dir, "pnpm-workspace.yaml");
|
|
1687
|
+
if (!existsSync8(workspacePath)) {
|
|
1688
|
+
writeFileSync5(workspacePath, PNPM_WORKSPACE);
|
|
1406
1689
|
created.push("pnpm-workspace.yaml");
|
|
1407
1690
|
} else {
|
|
1408
1691
|
reused.push("pnpm-workspace.yaml");
|
|
@@ -1422,28 +1705,28 @@ function manifestOf(name, manifest, bundles) {
|
|
|
1422
1705
|
var BRAND_BLOCK = "brand-galaxy";
|
|
1423
1706
|
function readKernelBundlePatches() {
|
|
1424
1707
|
const out = [];
|
|
1425
|
-
const kernel =
|
|
1426
|
-
if (!
|
|
1708
|
+
const kernel = join8(kernelModulesDir(), "@deepseek-ai");
|
|
1709
|
+
if (!existsSync8(kernel))
|
|
1427
1710
|
return out;
|
|
1428
1711
|
let entries;
|
|
1429
1712
|
try {
|
|
1430
|
-
entries =
|
|
1713
|
+
entries = readdirSync6(kernel).sort();
|
|
1431
1714
|
} catch {
|
|
1432
1715
|
return out;
|
|
1433
1716
|
}
|
|
1434
1717
|
for (const name of entries) {
|
|
1435
|
-
const manifestPath =
|
|
1436
|
-
if (!
|
|
1718
|
+
const manifestPath = join8(kernel, name, "package.json");
|
|
1719
|
+
if (!existsSync8(manifestPath))
|
|
1437
1720
|
continue;
|
|
1438
1721
|
try {
|
|
1439
|
-
const manifest = JSON.parse(
|
|
1722
|
+
const manifest = JSON.parse(readFileSync6(manifestPath, "utf8"));
|
|
1440
1723
|
const patch = manifest.dsh?.bundle?.patch;
|
|
1441
1724
|
if (typeof patch !== "string" || patch.trim() === "")
|
|
1442
1725
|
continue;
|
|
1443
|
-
const patchPath =
|
|
1444
|
-
if (!
|
|
1726
|
+
const patchPath = join8(kernel, name, patch);
|
|
1727
|
+
if (!existsSync8(patchPath))
|
|
1445
1728
|
continue;
|
|
1446
|
-
out.push(
|
|
1729
|
+
out.push(readFileSync6(patchPath, "utf8"));
|
|
1447
1730
|
} catch {
|
|
1448
1731
|
continue;
|
|
1449
1732
|
}
|
|
@@ -1452,14 +1735,14 @@ function readKernelBundlePatches() {
|
|
|
1452
1735
|
}
|
|
1453
1736
|
function readParityTemplate() {
|
|
1454
1737
|
try {
|
|
1455
|
-
return
|
|
1738
|
+
return readFileSync6(parityTemplatePath(), "utf8");
|
|
1456
1739
|
} catch {
|
|
1457
1740
|
return "";
|
|
1458
1741
|
}
|
|
1459
1742
|
}
|
|
1460
1743
|
function readPresetRedirectPatch() {
|
|
1461
1744
|
try {
|
|
1462
|
-
const text =
|
|
1745
|
+
const text = readFileSync6(join8(profileTemplateDir(), "preset-redirect.patch.yml"), "utf8");
|
|
1463
1746
|
return text.split(`
|
|
1464
1747
|
`).filter((line) => !line.startsWith("#")).join(`
|
|
1465
1748
|
`).trim();
|
|
@@ -1616,19 +1899,19 @@ function renderGroupRewriteBlocksSingle(text, nested) {
|
|
|
1616
1899
|
}
|
|
1617
1900
|
function bundleDefinedNames() {
|
|
1618
1901
|
const ten = new Set;
|
|
1619
|
-
const goc =
|
|
1620
|
-
if (!
|
|
1902
|
+
const goc = join8(repoRoot(), "packages", "host", "bundle");
|
|
1903
|
+
if (!existsSync8(goc))
|
|
1621
1904
|
return ten;
|
|
1622
1905
|
const duyet = (dir) => {
|
|
1623
|
-
for (const entry of
|
|
1624
|
-
const duong =
|
|
1906
|
+
for (const entry of readdirSync6(dir, { withFileTypes: true })) {
|
|
1907
|
+
const duong = join8(dir, entry.name);
|
|
1625
1908
|
if (entry.isDirectory()) {
|
|
1626
1909
|
duyet(duong);
|
|
1627
1910
|
continue;
|
|
1628
1911
|
}
|
|
1629
1912
|
if (!entry.name.endsWith(".yml"))
|
|
1630
1913
|
continue;
|
|
1631
|
-
for (const m of
|
|
1914
|
+
for (const m of readFileSync6(duong, "utf8").matchAll(new RegExp("name: '([^']+)'", "gu")))
|
|
1632
1915
|
ten.add(String(m[1]));
|
|
1633
1916
|
}
|
|
1634
1917
|
};
|
|
@@ -1649,7 +1932,7 @@ function writeAppPatch(options = {}) {
|
|
|
1649
1932
|
});
|
|
1650
1933
|
const nested = (options.rewrites ?? []).filter((mount) => mount.ok).filter((mount) => !trongBundle.has(mount.specifier)).filter((mount) => !trongBundle.has(mount.specifier)).flatMap((mount) => {
|
|
1651
1934
|
try {
|
|
1652
|
-
const manifest = JSON.parse(
|
|
1935
|
+
const manifest = JSON.parse(readFileSync6(join8(mount.dir, "package.json"), "utf8"));
|
|
1653
1936
|
const stockId = manifest.gbh?.nested?.stockId;
|
|
1654
1937
|
if (typeof stockId !== "string" || stockId === "")
|
|
1655
1938
|
return [];
|
|
@@ -1692,38 +1975,38 @@ function writeAppPatch(options = {}) {
|
|
|
1692
1975
|
`);
|
|
1693
1976
|
const overridden = (process.env.GBH_HOME ?? "").trim() !== "";
|
|
1694
1977
|
const dich = overridden ? [appPatchPath()] : [appPatchPath(), repoAppPatchPath()];
|
|
1695
|
-
const stamp =
|
|
1978
|
+
const stamp = createHash5("sha256").update(text).digest("hex");
|
|
1696
1979
|
const stampPath = appPatchStampPath();
|
|
1697
|
-
const stampCu =
|
|
1698
|
-
if (stampCu === stamp && dich.every((file) =>
|
|
1980
|
+
const stampCu = existsSync8(stampPath) ? readFileSync6(stampPath, "utf8").trim() : "";
|
|
1981
|
+
if (stampCu === stamp && dich.every((file) => existsSync8(file)))
|
|
1699
1982
|
return appPatchPath();
|
|
1700
1983
|
for (const file of dich) {
|
|
1701
1984
|
try {
|
|
1702
1985
|
mkdirSync4(dirname6(file), { recursive: true });
|
|
1703
1986
|
const tam = `${file}.tmp-${process.pid}`;
|
|
1704
|
-
|
|
1987
|
+
writeFileSync5(tam, text);
|
|
1705
1988
|
renameSync(tam, file);
|
|
1706
1989
|
} catch (error) {
|
|
1707
1990
|
console.warn(`[bh] khong ghi duoc ${file}: ${String(error)}`);
|
|
1708
1991
|
}
|
|
1709
1992
|
}
|
|
1710
1993
|
try {
|
|
1711
|
-
|
|
1994
|
+
writeFileSync5(stampPath, stamp + `
|
|
1712
1995
|
`);
|
|
1713
1996
|
} catch {}
|
|
1714
1997
|
return appPatchPath();
|
|
1715
1998
|
}
|
|
1716
1999
|
|
|
1717
2000
|
// apps/cli/src/runtime.ts
|
|
1718
|
-
import { spawnSync as
|
|
1719
|
-
import { existsSync as
|
|
1720
|
-
import { homedir as
|
|
1721
|
-
import { join as
|
|
2001
|
+
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
2002
|
+
import { existsSync as existsSync9, readdirSync as readdirSync7, readFileSync as readFileSync7 } from "node:fs";
|
|
2003
|
+
import { homedir as homedir4 } from "node:os";
|
|
2004
|
+
import { join as join9 } from "node:path";
|
|
1722
2005
|
var cached;
|
|
1723
2006
|
var rejected = [];
|
|
1724
2007
|
function readManifestVersion(manifestPath) {
|
|
1725
2008
|
try {
|
|
1726
|
-
const parsed = JSON.parse(
|
|
2009
|
+
const parsed = JSON.parse(readFileSync7(manifestPath, "utf8"));
|
|
1727
2010
|
const version = parsed.version;
|
|
1728
2011
|
return typeof version === "string" ? version : undefined;
|
|
1729
2012
|
} catch {
|
|
@@ -1734,10 +2017,10 @@ function harnessVersion() {
|
|
|
1734
2017
|
return readManifestVersion(dshManifestPath());
|
|
1735
2018
|
}
|
|
1736
2019
|
function harnessInstalled() {
|
|
1737
|
-
return
|
|
2020
|
+
return existsSync9(dshBinPath());
|
|
1738
2021
|
}
|
|
1739
2022
|
function probeNodeVersion(bin) {
|
|
1740
|
-
const probe =
|
|
2023
|
+
const probe = spawnSync3(bin, ["--version"], { encoding: "utf8", timeout: 8000 });
|
|
1741
2024
|
if (probe.error !== undefined || probe.status !== 0)
|
|
1742
2025
|
return;
|
|
1743
2026
|
const match = /v?(\d+)\.\d+\.\d+/.exec(`${probe.stdout ?? ""}${probe.stderr ?? ""}`);
|
|
@@ -1750,15 +2033,15 @@ function nodeCandidates() {
|
|
|
1750
2033
|
const explicit = process.env.GBH_NODE?.trim();
|
|
1751
2034
|
if (explicit !== undefined && explicit !== "")
|
|
1752
2035
|
candidates.push({ bin: explicit, source: "GBH_NODE" });
|
|
1753
|
-
const nvmRoot =
|
|
2036
|
+
const nvmRoot = join9(homedir4(), ".nvm", "versions", "node");
|
|
1754
2037
|
try {
|
|
1755
|
-
const versions =
|
|
2038
|
+
const versions = readdirSync7(nvmRoot).filter((name) => /^v\d+\.\d+\.\d+$/.test(name)).sort((left, right) => {
|
|
1756
2039
|
const [leftMajor, leftMinor] = left.slice(1).split(".").map(Number);
|
|
1757
2040
|
const [rightMajor, rightMinor] = right.slice(1).split(".").map(Number);
|
|
1758
2041
|
return (rightMajor ?? 0) - (leftMajor ?? 0) || (rightMinor ?? 0) - (leftMinor ?? 0);
|
|
1759
2042
|
});
|
|
1760
2043
|
for (const version of versions)
|
|
1761
|
-
candidates.push({ bin:
|
|
2044
|
+
candidates.push({ bin: join9(nvmRoot, version, "bin", "node"), source: `nvm ${version}` });
|
|
1762
2045
|
} catch {}
|
|
1763
2046
|
candidates.push({ bin: "node", source: "PATH" });
|
|
1764
2047
|
candidates.push({ bin: "/usr/local/bin/node", source: "system" });
|
|
@@ -1770,7 +2053,7 @@ function resolveNodeRuntime() {
|
|
|
1770
2053
|
return cached;
|
|
1771
2054
|
rejected = [];
|
|
1772
2055
|
for (const candidate of nodeCandidates()) {
|
|
1773
|
-
if (candidate.bin !== "node" && !
|
|
2056
|
+
if (candidate.bin !== "node" && !existsSync9(candidate.bin)) {
|
|
1774
2057
|
rejected.push({ bin: candidate.bin, reason: "not found" });
|
|
1775
2058
|
continue;
|
|
1776
2059
|
}
|
|
@@ -1779,9 +2062,13 @@ function resolveNodeRuntime() {
|
|
|
1779
2062
|
rejected.push({ bin: candidate.bin, reason: "did not answer --version (known silent failure)" });
|
|
1780
2063
|
continue;
|
|
1781
2064
|
}
|
|
1782
|
-
const major =
|
|
1783
|
-
if (major < MIN_NODE_MAJOR) {
|
|
1784
|
-
rejected.push({
|
|
2065
|
+
const [major = 0, minor = 0] = version.slice(1).split(".").map((part) => Number(part));
|
|
2066
|
+
if (major < MIN_NODE_MAJOR || major === MIN_NODE_MAJOR && minor < MIN_NODE_MINOR) {
|
|
2067
|
+
rejected.push({
|
|
2068
|
+
bin: candidate.bin,
|
|
2069
|
+
version,
|
|
2070
|
+
reason: `below the required v${MIN_NODE_MAJOR}.${MIN_NODE_MINOR}`
|
|
2071
|
+
});
|
|
1785
2072
|
continue;
|
|
1786
2073
|
}
|
|
1787
2074
|
cached = { bin: candidate.bin, version, major, source: candidate.source };
|
|
@@ -1821,7 +2108,7 @@ function describeLaunch(launch) {
|
|
|
1821
2108
|
}
|
|
1822
2109
|
function resolveLaunch(options, mode = "boot") {
|
|
1823
2110
|
const bin = dshBinPath();
|
|
1824
|
-
if (!
|
|
2111
|
+
if (!existsSync10(bin)) {
|
|
1825
2112
|
throw new Error(`harness runtime not found at ${bin} — run: bun install --cwd apps/host`);
|
|
1826
2113
|
}
|
|
1827
2114
|
const node = resolveNodeRuntime();
|
|
@@ -1895,7 +2182,7 @@ function spawnHost(options) {
|
|
|
1895
2182
|
`);
|
|
1896
2183
|
const name = options.port === DEFAULT_PORT ? "ready-url.txt" : `ready-url-${options.port}.txt`;
|
|
1897
2184
|
try {
|
|
1898
|
-
|
|
2185
|
+
writeFileSync6(launch.home + "/" + name, url);
|
|
1899
2186
|
} catch {}
|
|
1900
2187
|
resolve3(url);
|
|
1901
2188
|
});
|
|
@@ -1920,7 +2207,7 @@ function spawnHost(options) {
|
|
|
1920
2207
|
}
|
|
1921
2208
|
function runDumpConfig(options = {}) {
|
|
1922
2209
|
const launch = resolveLaunch(defaultHostOptions({ profile: options.profile, extraPatches: options.extraPatches }), "dump");
|
|
1923
|
-
const result =
|
|
2210
|
+
const result = spawnSync4(launch.node, launch.args, {
|
|
1924
2211
|
cwd: repoRoot(),
|
|
1925
2212
|
env: hostChildEnv(launch.home),
|
|
1926
2213
|
stdio: "inherit"
|
|
@@ -1929,15 +2216,15 @@ function runDumpConfig(options = {}) {
|
|
|
1929
2216
|
}
|
|
1930
2217
|
|
|
1931
2218
|
// apps/cli/src/doctor.ts
|
|
1932
|
-
import { existsSync as
|
|
1933
|
-
import { join as
|
|
2219
|
+
import { existsSync as existsSync11, readFileSync as readFileSync8, statSync as statSync4 } from "node:fs";
|
|
2220
|
+
import { join as join11 } from "node:path";
|
|
1934
2221
|
|
|
1935
2222
|
// apps/cli/src/oracle.ts
|
|
1936
|
-
import { spawnSync as
|
|
2223
|
+
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
1937
2224
|
import { resolve as resolve3 } from "node:path";
|
|
1938
2225
|
function run(command, args) {
|
|
1939
2226
|
try {
|
|
1940
|
-
const probe =
|
|
2227
|
+
const probe = spawnSync5(command, args, { encoding: "utf8", timeout: 5000 });
|
|
1941
2228
|
return probe.status === 0 ? probe.stdout ?? "" : undefined;
|
|
1942
2229
|
} catch {
|
|
1943
2230
|
return;
|
|
@@ -1967,7 +2254,7 @@ function findOracle(port = ORACLE_PORT) {
|
|
|
1967
2254
|
}
|
|
1968
2255
|
|
|
1969
2256
|
// apps/cli/src/port.ts
|
|
1970
|
-
import { spawnSync as
|
|
2257
|
+
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
1971
2258
|
import { createServer } from "node:net";
|
|
1972
2259
|
function isPortAvailable(port, host = LOOPBACK_HOST) {
|
|
1973
2260
|
if (port === 0)
|
|
@@ -1985,7 +2272,7 @@ function isPortAvailable(port, host = LOOPBACK_HOST) {
|
|
|
1985
2272
|
});
|
|
1986
2273
|
}
|
|
1987
2274
|
function portOwnerHint(port) {
|
|
1988
|
-
const probe =
|
|
2275
|
+
const probe = spawnSync6("lsof", ["-nP", `-iTCP:${port}`, "-sTCP:LISTEN"], { encoding: "utf8", timeout: 5000 });
|
|
1989
2276
|
const row = (probe.stdout ?? "").split(`
|
|
1990
2277
|
`).find((line, index) => index > 0 && line.trim() !== "");
|
|
1991
2278
|
if (probe.status !== 0 || row === undefined)
|
|
@@ -1995,9 +2282,9 @@ function portOwnerHint(port) {
|
|
|
1995
2282
|
}
|
|
1996
2283
|
|
|
1997
2284
|
// apps/cli/src/home-guard.ts
|
|
1998
|
-
import { createHash as
|
|
1999
|
-
import { lstatSync as lstatSync5, readdirSync as
|
|
2000
|
-
import { join as
|
|
2285
|
+
import { createHash as createHash6 } from "node:crypto";
|
|
2286
|
+
import { lstatSync as lstatSync5, readdirSync as readdirSync8, readlinkSync as readlinkSync2 } from "node:fs";
|
|
2287
|
+
import { join as join10 } from "node:path";
|
|
2001
2288
|
function linkTarget(path) {
|
|
2002
2289
|
try {
|
|
2003
2290
|
return readlinkSync2(path);
|
|
@@ -2008,13 +2295,13 @@ function linkTarget(path) {
|
|
|
2008
2295
|
function walk(root, dir, lines, totals) {
|
|
2009
2296
|
let entries;
|
|
2010
2297
|
try {
|
|
2011
|
-
entries =
|
|
2298
|
+
entries = readdirSync8(dir, { withFileTypes: true });
|
|
2012
2299
|
} catch (error) {
|
|
2013
2300
|
lines.push(`${dir}|${-1}|unreadable|${String(error)}`);
|
|
2014
2301
|
return;
|
|
2015
2302
|
}
|
|
2016
2303
|
for (const entry of entries.sort((left, right) => left.name < right.name ? -1 : left.name > right.name ? 1 : 0)) {
|
|
2017
|
-
const path =
|
|
2304
|
+
const path = join10(dir, entry.name);
|
|
2018
2305
|
const relative2 = path.slice(root.length + 1);
|
|
2019
2306
|
let stat;
|
|
2020
2307
|
try {
|
|
@@ -2044,7 +2331,7 @@ function snapshotTree(root) {
|
|
|
2044
2331
|
entries: totals.entries,
|
|
2045
2332
|
bytes: totals.bytes,
|
|
2046
2333
|
newestMtimeMs: totals.newestMtimeMs,
|
|
2047
|
-
hash:
|
|
2334
|
+
hash: createHash6("sha256").update(sorted.join(`
|
|
2048
2335
|
`)).digest("hex"),
|
|
2049
2336
|
lines: sorted
|
|
2050
2337
|
};
|
|
@@ -2053,7 +2340,7 @@ function snapshotTree(root) {
|
|
|
2053
2340
|
// apps/cli/src/doctor.ts
|
|
2054
2341
|
function profileRootIsEmpty(file) {
|
|
2055
2342
|
try {
|
|
2056
|
-
const body =
|
|
2343
|
+
const body = readFileSync8(file, "utf8").split(`
|
|
2057
2344
|
`).filter((line) => !line.trim().startsWith("#")).join(`
|
|
2058
2345
|
`).trim();
|
|
2059
2346
|
return body === "[]";
|
|
@@ -2063,7 +2350,7 @@ function profileRootIsEmpty(file) {
|
|
|
2063
2350
|
}
|
|
2064
2351
|
function pinnedCredentialsPath(patchPath) {
|
|
2065
2352
|
try {
|
|
2066
|
-
return /path:\s*"([^"]+)"/u.exec(
|
|
2353
|
+
return /path:\s*"([^"]+)"/u.exec(readFileSync8(patchPath, "utf8"))?.[1];
|
|
2067
2354
|
} catch {
|
|
2068
2355
|
return;
|
|
2069
2356
|
}
|
|
@@ -2078,7 +2365,7 @@ async function buildDoctorReport(port = DEFAULT_PORT) {
|
|
|
2078
2365
|
}
|
|
2079
2366
|
const declaredPin = (() => {
|
|
2080
2367
|
try {
|
|
2081
|
-
const manifest = JSON.parse(
|
|
2368
|
+
const manifest = JSON.parse(readFileSync8(join11(repoRoot(), "apps", "host", "package.json"), "utf8"));
|
|
2082
2369
|
return manifest.dependencies?.["@deepseek-ai/dsh"];
|
|
2083
2370
|
} catch {
|
|
2084
2371
|
return;
|
|
@@ -2110,19 +2397,19 @@ async function buildDoctorReport(port = DEFAULT_PORT) {
|
|
|
2110
2397
|
lines.push({ status: "OK", label: `oracle :${oracle.port}`, detail: `pid ${oracle.pid} version ${oracle.version ?? "?"} ${oracle.home ?? ""}`.trim() });
|
|
2111
2398
|
}
|
|
2112
2399
|
const home = appHome();
|
|
2113
|
-
lines.push(
|
|
2400
|
+
lines.push(existsSync11(home) ? { status: "OK", label: "app home", detail: `${home} (DSH_HOME, KHONG dung ${join11(galaxyRoot(), "gbh")})` } : { status: "MISS", label: "app home", detail: `${home} — se tao khi boot` });
|
|
2114
2401
|
const seeded = ensureProfile();
|
|
2115
2402
|
lines.push({
|
|
2116
|
-
status: profileRootIsEmpty(
|
|
2403
|
+
status: profileRootIsEmpty(join11(seeded.dir, "cordis.yml")) ? "OK" : "WARN",
|
|
2117
2404
|
label: "profile",
|
|
2118
|
-
detail: `${
|
|
2405
|
+
detail: `${join11(seeded.dir, "cordis.yml")} = [] · ${seeded.bundles.length} bundle`
|
|
2119
2406
|
});
|
|
2120
2407
|
const credentials = credentialsPath();
|
|
2121
|
-
lines.push(
|
|
2408
|
+
lines.push(existsSync11(credentials) ? { status: "OK", label: "shared credentials", detail: `${credentials} · ${statSync4(credentials).size} bytes (noi dung khong in)` } : { status: "MISS", label: "shared credentials", detail: `${credentials} chua co (nguoi dung tao khi dang nhap)` });
|
|
2122
2409
|
const pinned = pinnedCredentialsPath(appPatchPath());
|
|
2123
2410
|
lines.push(pinned === credentials ? { status: "OK", label: "app patch", detail: `credentials.config.path -> ${pinned}` } : { status: "WARN", label: "app patch", detail: `${appPatchPath()} -> ${pinned ?? "(chua sinh)"} (mong doi ${credentials})` });
|
|
2124
|
-
const gbh =
|
|
2125
|
-
if (
|
|
2411
|
+
const gbh = join11(galaxyRoot(), "gbh");
|
|
2412
|
+
if (existsSync11(gbh)) {
|
|
2126
2413
|
const snapshot = snapshotTree(gbh);
|
|
2127
2414
|
lines.push({ status: "OK", label: "home isolation", detail: `${gbh} chi doc · ${snapshot.entries} entry · hash ${snapshot.hash.slice(0, 12)}` });
|
|
2128
2415
|
} else {
|
|
@@ -2145,24 +2432,24 @@ ket qua: DO — ${failed.map((line) => line.label).join(", ")}`);
|
|
|
2145
2432
|
}
|
|
2146
2433
|
|
|
2147
2434
|
// apps/cli/src/auto-migrate.ts
|
|
2148
|
-
import { existsSync as
|
|
2149
|
-
import { join as
|
|
2435
|
+
import { existsSync as existsSync13, readFileSync as readFileSync9, writeFileSync as writeFileSync7 } from "node:fs";
|
|
2436
|
+
import { join as join13 } from "node:path";
|
|
2150
2437
|
|
|
2151
2438
|
// apps/cli/src/migrate.ts
|
|
2152
|
-
import { copyFileSync, existsSync as
|
|
2153
|
-
import { homedir as
|
|
2154
|
-
import { dirname as dirname7, join as
|
|
2439
|
+
import { copyFileSync, existsSync as existsSync12, mkdirSync as mkdirSync5, readdirSync as readdirSync9, statSync as statSync5 } from "node:fs";
|
|
2440
|
+
import { homedir as homedir5 } from "node:os";
|
|
2441
|
+
import { dirname as dirname7, join as join12, relative as relative2 } from "node:path";
|
|
2155
2442
|
var MIGRATE_AREAS = ["sessions", "storages", "attachments"];
|
|
2156
2443
|
var BO_QUA = new Set(["session.lock", ".DS_Store"]);
|
|
2157
2444
|
function lietKeTep(goc) {
|
|
2158
|
-
if (!
|
|
2445
|
+
if (!existsSync12(goc))
|
|
2159
2446
|
return [];
|
|
2160
2447
|
const ketQua = [];
|
|
2161
2448
|
const duyet = (thuMuc) => {
|
|
2162
|
-
for (const muc of
|
|
2449
|
+
for (const muc of readdirSync9(thuMuc, { withFileTypes: true })) {
|
|
2163
2450
|
if (BO_QUA.has(muc.name))
|
|
2164
2451
|
continue;
|
|
2165
|
-
const duong =
|
|
2452
|
+
const duong = join12(thuMuc, muc.name);
|
|
2166
2453
|
if (muc.isDirectory())
|
|
2167
2454
|
duyet(duong);
|
|
2168
2455
|
else if (muc.isFile())
|
|
@@ -2179,25 +2466,25 @@ function migrateHome(options) {
|
|
|
2179
2466
|
const baoCao = [];
|
|
2180
2467
|
const missing = [];
|
|
2181
2468
|
for (const area of areas) {
|
|
2182
|
-
const nguon =
|
|
2183
|
-
if (!
|
|
2469
|
+
const nguon = join12(options.from, area);
|
|
2470
|
+
if (!existsSync12(nguon)) {
|
|
2184
2471
|
missing.push(area);
|
|
2185
2472
|
continue;
|
|
2186
2473
|
}
|
|
2187
2474
|
const muc = { area, copied: 0, skipped: 0, bytes: 0 };
|
|
2188
2475
|
for (const tep of lietKeTep(nguon)) {
|
|
2189
|
-
const dich =
|
|
2190
|
-
if (
|
|
2476
|
+
const dich = join12(options.to, area, tep);
|
|
2477
|
+
if (existsSync12(dich)) {
|
|
2191
2478
|
muc.skipped += 1;
|
|
2192
2479
|
continue;
|
|
2193
2480
|
}
|
|
2194
|
-
const co =
|
|
2481
|
+
const co = statSync5(join12(nguon, tep)).size;
|
|
2195
2482
|
muc.copied += 1;
|
|
2196
2483
|
muc.bytes += co;
|
|
2197
2484
|
if (dryRun)
|
|
2198
2485
|
continue;
|
|
2199
2486
|
mkdirSync5(dirname7(dich), { recursive: true });
|
|
2200
|
-
copyFileSync(
|
|
2487
|
+
copyFileSync(join12(nguon, tep), dich);
|
|
2201
2488
|
}
|
|
2202
2489
|
baoCao.push(muc);
|
|
2203
2490
|
}
|
|
@@ -2205,11 +2492,11 @@ function migrateHome(options) {
|
|
|
2205
2492
|
return { from: options.from, to: options.to, dryRun, areas: baoCao, missing, ...tong };
|
|
2206
2493
|
}
|
|
2207
2494
|
function defaultOldHome() {
|
|
2208
|
-
return
|
|
2495
|
+
return join12(homedir5(), ".galaxy", "gbh");
|
|
2209
2496
|
}
|
|
2210
2497
|
function defaultNewHome() {
|
|
2211
2498
|
const tuBien = process.env["GBH_HOME"];
|
|
2212
|
-
return tuBien === undefined || tuBien.trim() === "" ?
|
|
2499
|
+
return tuBien === undefined || tuBien.trim() === "" ? join12(homedir5(), ".galaxy", "blackhole") : tuBien;
|
|
2213
2500
|
}
|
|
2214
2501
|
|
|
2215
2502
|
// apps/cli/src/auto-migrate.ts
|
|
@@ -2231,19 +2518,19 @@ function ghiCoDiTru(noiDung) {
|
|
|
2231
2518
|
`;
|
|
2232
2519
|
}
|
|
2233
2520
|
function autoMigrate(options) {
|
|
2234
|
-
const credentialsPath2 =
|
|
2235
|
-
const noiDung =
|
|
2521
|
+
const credentialsPath2 = join13(options.galaxyRoot, CREDENTIALS_FILE);
|
|
2522
|
+
const noiDung = existsSync13(credentialsPath2) ? readFileSync9(credentialsPath2, "utf8") : "";
|
|
2236
2523
|
const daTung = daDiTru(noiDung);
|
|
2237
2524
|
const cu = options.from ?? defaultOldHome();
|
|
2238
2525
|
const moi = options.to ?? defaultNewHome();
|
|
2239
|
-
if (!
|
|
2526
|
+
if (!existsSync13(join13(cu, "sessions"))) {
|
|
2240
2527
|
return { ran: false, reason: "home cũ không có sessions", credentialsPath: credentialsPath2 };
|
|
2241
2528
|
}
|
|
2242
2529
|
if (cu === moi)
|
|
2243
2530
|
return { ran: false, reason: "home cũ trùng home mới", credentialsPath: credentialsPath2 };
|
|
2244
2531
|
const report = migrateHome({ from: cu, to: moi, dryRun: options.dryRun === true });
|
|
2245
2532
|
if (options.dryRun !== true && (report.copied > 0 || !daTung)) {
|
|
2246
|
-
|
|
2533
|
+
writeFileSync7(credentialsPath2, ghiCoDiTru(noiDung));
|
|
2247
2534
|
}
|
|
2248
2535
|
return { ran: true, report, credentialsPath: credentialsPath2 };
|
|
2249
2536
|
}
|