@jingyi0605/codingns4dsh 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1114 -0
- package/assets/provider-icons/claude-code.png +0 -0
- package/assets/provider-icons/codex.png +0 -0
- package/assets/provider-icons/command-code.svg +5 -0
- package/assets/provider-icons/deepseek-harness.svg +9 -0
- package/assets/provider-icons/gemini.png +0 -0
- package/assets/provider-icons/grok.png +0 -0
- package/assets/provider-icons/kimi.png +0 -0
- package/assets/provider-icons/opencode.png +0 -0
- package/assets/provider-icons/pi.svg +7 -0
- package/data/build/dist/bootstrap/dsh-connection-adapter.d.ts +97 -0
- package/data/build/dist/bootstrap/dsh-connection-adapter.js +169 -0
- package/data/build/dist/bootstrap/index.d.ts +38 -0
- package/data/build/dist/bootstrap/index.js +44 -0
- package/data/build/dist/client/account-bar.d.ts +9 -0
- package/data/build/dist/client/account-bar.js +398 -0
- package/data/build/dist/client/bundle.js +26167 -0
- package/data/build/dist/client/cli-catalog.d.ts +24 -0
- package/data/build/dist/client/cli-catalog.js +108 -0
- package/data/build/dist/client/cli-slots.d.ts +38 -0
- package/data/build/dist/client/cli-slots.js +297 -0
- package/data/build/dist/client/debug/ui.d.ts +12 -0
- package/data/build/dist/client/debug/ui.js +451 -0
- package/data/build/dist/client/dsh-h5-bootstrap.d.ts +64 -0
- package/data/build/dist/client/dsh-h5-bootstrap.js +293 -0
- package/data/build/dist/client/dsh-runtime-version.d.ts +3 -0
- package/data/build/dist/client/dsh-runtime-version.js +11 -0
- package/data/build/dist/client/external-tool-stream.d.ts +24 -0
- package/data/build/dist/client/external-tool-stream.js +114 -0
- package/data/build/dist/client/features/cli-adapters.d.ts +7 -0
- package/data/build/dist/client/features/cli-adapters.js +215 -0
- package/data/build/dist/client/features/debug.d.ts +4 -0
- package/data/build/dist/client/features/debug.js +24 -0
- package/data/build/dist/client/features/index.d.ts +33 -0
- package/data/build/dist/client/features/index.js +44 -0
- package/data/build/dist/client/features/lan-access-panel.d.ts +5 -0
- package/data/build/dist/client/features/lan-access-panel.js +146 -0
- package/data/build/dist/client/features/lan-access.d.ts +9 -0
- package/data/build/dist/client/features/lan-access.js +30 -0
- package/data/build/dist/client/features/login-protection-panel.d.ts +5 -0
- package/data/build/dist/client/features/login-protection-panel.js +91 -0
- package/data/build/dist/client/features/login-protection-session.d.ts +6 -0
- package/data/build/dist/client/features/login-protection-session.js +25 -0
- package/data/build/dist/client/features/login-protection.d.ts +4 -0
- package/data/build/dist/client/features/login-protection.js +23 -0
- package/data/build/dist/client/features/reverse-proxy-panel.d.ts +9 -0
- package/data/build/dist/client/features/reverse-proxy-panel.js +159 -0
- package/data/build/dist/client/features/reverse-proxy.d.ts +12 -0
- package/data/build/dist/client/features/reverse-proxy.js +112 -0
- package/data/build/dist/client/features/terminal-enhancement-panel.d.ts +5 -0
- package/data/build/dist/client/features/terminal-enhancement-panel.js +160 -0
- package/data/build/dist/client/features/terminal-enhancement.d.ts +4 -0
- package/data/build/dist/client/features/terminal-enhancement.js +24 -0
- package/data/build/dist/client/features/types.d.ts +58 -0
- package/data/build/dist/client/features/types.js +2 -0
- package/data/build/dist/client/features/workspace-session-enhancement-panel.d.ts +5 -0
- package/data/build/dist/client/features/workspace-session-enhancement-panel.js +66 -0
- package/data/build/dist/client/features/workspace-session-enhancement.d.ts +4 -0
- package/data/build/dist/client/features/workspace-session-enhancement.js +101 -0
- package/data/build/dist/client/h5-bootstrap-entry.d.ts +2 -0
- package/data/build/dist/client/h5-bootstrap-entry.js +17 -0
- package/data/build/dist/client/index.d.ts +31 -0
- package/data/build/dist/client/index.js +98 -0
- package/data/build/dist/client/lan-access.d.ts +28 -0
- package/data/build/dist/client/lan-access.js +68 -0
- package/data/build/dist/client/locale.d.ts +20 -0
- package/data/build/dist/client/locale.js +393 -0
- package/data/build/dist/client/provider-icon-assets.d.ts +2 -0
- package/data/build/dist/client/provider-icon-assets.js +23 -0
- package/data/build/dist/client/provider-icons.d.ts +19 -0
- package/data/build/dist/client/provider-icons.js +39 -0
- package/data/build/dist/client/remote-web-context.d.ts +57 -0
- package/data/build/dist/client/remote-web-context.js +939 -0
- package/data/build/dist/client/session-adapter-cache.d.ts +18 -0
- package/data/build/dist/client/session-adapter-cache.js +84 -0
- package/data/build/dist/client/settings-bridge.d.ts +32 -0
- package/data/build/dist/client/settings-bridge.js +126 -0
- package/data/build/dist/client/settings-section.d.ts +30 -0
- package/data/build/dist/client/settings-section.js +93 -0
- package/data/build/dist/client/subscription-slot.d.ts +18 -0
- package/data/build/dist/client/subscription-slot.js +223 -0
- package/data/build/dist/client/terminal/index.d.ts +4 -0
- package/data/build/dist/client/terminal/index.js +3 -0
- package/data/build/dist/client/terminal/model.d.ts +116 -0
- package/data/build/dist/client/terminal/model.js +435 -0
- package/data/build/dist/client/terminal/styles.d.ts +21 -0
- package/data/build/dist/client/terminal/styles.js +51 -0
- package/data/build/dist/client/terminal/ui.d.ts +19 -0
- package/data/build/dist/client/terminal/ui.js +257 -0
- package/data/build/dist/client/terminal/xterm-view.d.ts +13 -0
- package/data/build/dist/client/terminal/xterm-view.js +213 -0
- package/data/build/dist/client/theme.d.ts +56 -0
- package/data/build/dist/client/theme.js +186 -0
- package/data/build/dist/client/workspace-session-archive-dom.d.ts +29 -0
- package/data/build/dist/client/workspace-session-archive-dom.js +525 -0
- package/data/build/dist/client/workspace-session-fiber.d.ts +3 -0
- package/data/build/dist/client/workspace-session-fiber.js +33 -0
- package/data/build/dist/client/workspace-session-logo-dom.d.ts +26 -0
- package/data/build/dist/client/workspace-session-logo-dom.js +128 -0
- package/data/build/dist/features/index.d.ts +3 -0
- package/data/build/dist/features/index.js +2 -0
- package/data/build/dist/features/registry.d.ts +74 -0
- package/data/build/dist/features/registry.js +382 -0
- package/data/build/dist/features/resource-scope/index.d.ts +39 -0
- package/data/build/dist/features/resource-scope/index.js +161 -0
- package/data/build/dist/host/auth-session.d.ts +42 -0
- package/data/build/dist/host/auth-session.js +186 -0
- package/data/build/dist/host/cli-adapters/claude-driver.d.ts +14 -0
- package/data/build/dist/host/cli-adapters/claude-driver.js +103 -0
- package/data/build/dist/host/cli-adapters/codex-driver.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/codex-driver.js +534 -0
- package/data/build/dist/host/cli-adapters/command-code-driver.d.ts +38 -0
- package/data/build/dist/host/cli-adapters/command-code-driver.js +394 -0
- package/data/build/dist/host/cli-adapters/command-code-subscription.d.ts +19 -0
- package/data/build/dist/host/cli-adapters/command-code-subscription.js +126 -0
- package/data/build/dist/host/cli-adapters/driver.d.ts +41 -0
- package/data/build/dist/host/cli-adapters/driver.js +2 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.d.ts +37 -0
- package/data/build/dist/host/cli-adapters/dsh-message-projector.js +180 -0
- package/data/build/dist/host/cli-adapters/dsh-tool-history.d.ts +48 -0
- package/data/build/dist/host/cli-adapters/dsh-tool-history.js +373 -0
- package/data/build/dist/host/cli-adapters/feature.d.ts +7 -0
- package/data/build/dist/host/cli-adapters/feature.js +335 -0
- package/data/build/dist/host/cli-adapters/gemini-driver.d.ts +24 -0
- package/data/build/dist/host/cli-adapters/gemini-driver.js +427 -0
- package/data/build/dist/host/cli-adapters/grok-driver.d.ts +38 -0
- package/data/build/dist/host/cli-adapters/grok-driver.js +372 -0
- package/data/build/dist/host/cli-adapters/http-sse-client.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/http-sse-client.js +99 -0
- package/data/build/dist/host/cli-adapters/interaction-events.d.ts +11 -0
- package/data/build/dist/host/cli-adapters/interaction-events.js +80 -0
- package/data/build/dist/host/cli-adapters/json-rpc-process.d.ts +65 -0
- package/data/build/dist/host/cli-adapters/json-rpc-process.js +256 -0
- package/data/build/dist/host/cli-adapters/kimi-driver.d.ts +21 -0
- package/data/build/dist/host/cli-adapters/kimi-driver.js +382 -0
- package/data/build/dist/host/cli-adapters/model-catalog.d.ts +22 -0
- package/data/build/dist/host/cli-adapters/model-catalog.js +89 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.d.ts +55 -0
- package/data/build/dist/host/cli-adapters/opencode-driver.js +728 -0
- package/data/build/dist/host/cli-adapters/pi-driver.d.ts +43 -0
- package/data/build/dist/host/cli-adapters/pi-driver.js +312 -0
- package/data/build/dist/host/cli-adapters/process-utils.d.ts +16 -0
- package/data/build/dist/host/cli-adapters/process-utils.js +27 -0
- package/data/build/dist/host/cli-adapters/provider-subscription.d.ts +82 -0
- package/data/build/dist/host/cli-adapters/provider-subscription.js +610 -0
- package/data/build/dist/host/cli-adapters/registry.d.ts +95 -0
- package/data/build/dist/host/cli-adapters/registry.js +659 -0
- package/data/build/dist/host/cli-adapters/rpc-driver-utils.d.ts +24 -0
- package/data/build/dist/host/cli-adapters/rpc-driver-utils.js +119 -0
- package/data/build/dist/host/cli-adapters/session-probe.d.ts +20 -0
- package/data/build/dist/host/cli-adapters/session-probe.js +139 -0
- package/data/build/dist/host/cli-adapters/session-store.d.ts +68 -0
- package/data/build/dist/host/cli-adapters/session-store.js +180 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.d.ts +45 -0
- package/data/build/dist/host/cli-adapters/standard-stream-driver.js +205 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.d.ts +25 -0
- package/data/build/dist/host/cli-adapters/stream-normalizer.js +83 -0
- package/data/build/dist/host/cli-adapters/tool-observation.d.ts +9 -0
- package/data/build/dist/host/cli-adapters/tool-observation.js +39 -0
- package/data/build/dist/host/control-api-client.d.ts +84 -0
- package/data/build/dist/host/control-api-client.js +130 -0
- package/data/build/dist/host/credential-store.d.ts +54 -0
- package/data/build/dist/host/credential-store.js +114 -0
- package/data/build/dist/host/debug.d.ts +79 -0
- package/data/build/dist/host/debug.js +295 -0
- package/data/build/dist/host/dsh-device-runtime.d.ts +39 -0
- package/data/build/dist/host/dsh-device-runtime.js +118 -0
- package/data/build/dist/host/dsh-gateway-feature.d.ts +5 -0
- package/data/build/dist/host/dsh-gateway-feature.js +55 -0
- package/data/build/dist/host/dsh-runtime-version.d.ts +12 -0
- package/data/build/dist/host/dsh-runtime-version.js +69 -0
- package/data/build/dist/host/features/auth.d.ts +11 -0
- package/data/build/dist/host/features/auth.js +273 -0
- package/data/build/dist/host/features/debug.d.ts +5 -0
- package/data/build/dist/host/features/debug.js +90 -0
- package/data/build/dist/host/features/host-status.d.ts +12 -0
- package/data/build/dist/host/features/host-status.js +54 -0
- package/data/build/dist/host/features/index.d.ts +19 -0
- package/data/build/dist/host/features/index.js +29 -0
- package/data/build/dist/host/features/lan-access-dsh.d.ts +8 -0
- package/data/build/dist/host/features/lan-access-dsh.js +45 -0
- package/data/build/dist/host/features/terminal-process.d.ts +5 -0
- package/data/build/dist/host/features/terminal-process.js +110 -0
- package/data/build/dist/host/features/terminal-status.d.ts +18 -0
- package/data/build/dist/host/features/terminal-status.js +56 -0
- package/data/build/dist/host/features/types.d.ts +41 -0
- package/data/build/dist/host/features/types.js +2 -0
- package/data/build/dist/host/index.d.ts +43 -0
- package/data/build/dist/host/index.js +135 -0
- package/data/build/dist/host/lan-access-dsh.d.ts +83 -0
- package/data/build/dist/host/lan-access-dsh.js +831 -0
- package/data/build/dist/host/native-session-bridge.d.ts +130 -0
- package/data/build/dist/host/native-session-bridge.js +317 -0
- package/data/build/dist/host/relay-tunnel-runtime.d.ts +97 -0
- package/data/build/dist/host/relay-tunnel-runtime.js +361 -0
- package/data/build/dist/host/remote-web-runtime.d.ts +78 -0
- package/data/build/dist/host/remote-web-runtime.js +559 -0
- package/data/build/dist/host/rpc-table.d.ts +32 -0
- package/data/build/dist/host/rpc-table.js +47 -0
- package/data/build/dist/host/rpc.d.ts +18 -0
- package/data/build/dist/host/rpc.js +248 -0
- package/data/build/dist/host/settings.d.ts +19 -0
- package/data/build/dist/host/settings.js +80 -0
- package/data/build/dist/host/terminal/attachment-registry.d.ts +17 -0
- package/data/build/dist/host/terminal/attachment-registry.js +49 -0
- package/data/build/dist/host/terminal/backends/conpty-backend.d.ts +39 -0
- package/data/build/dist/host/terminal/backends/conpty-backend.js +160 -0
- package/data/build/dist/host/terminal/backends/local-pty-backend.d.ts +36 -0
- package/data/build/dist/host/terminal/backends/local-pty-backend.js +178 -0
- package/data/build/dist/host/terminal/backends/tmux-backend.d.ts +40 -0
- package/data/build/dist/host/terminal/backends/tmux-backend.js +191 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-client.d.ts +27 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-client.js +154 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-process.d.ts +10 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-process.js +147 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-protocol.d.ts +92 -0
- package/data/build/dist/host/terminal/broker/conpty-broker-protocol.js +134 -0
- package/data/build/dist/host/terminal/controller-factory.d.ts +37 -0
- package/data/build/dist/host/terminal/controller-factory.js +82 -0
- package/data/build/dist/host/terminal/index.d.ts +17 -0
- package/data/build/dist/host/terminal/index.js +17 -0
- package/data/build/dist/host/terminal/runtime-adapter.d.ts +77 -0
- package/data/build/dist/host/terminal/runtime-adapter.js +18 -0
- package/data/build/dist/host/terminal/runtime-manager.d.ts +41 -0
- package/data/build/dist/host/terminal/runtime-manager.js +179 -0
- package/data/build/dist/host/terminal/shell-detection.d.ts +23 -0
- package/data/build/dist/host/terminal/shell-detection.js +105 -0
- package/data/build/dist/host/terminal/startup.d.ts +33 -0
- package/data/build/dist/host/terminal/startup.js +100 -0
- package/data/build/dist/host/terminal/terminal-controller.d.ts +78 -0
- package/data/build/dist/host/terminal/terminal-controller.js +324 -0
- package/data/build/dist/host/terminal/terminal-process-service.d.ts +30 -0
- package/data/build/dist/host/terminal/terminal-process-service.js +194 -0
- package/data/build/dist/host/terminal/terminal-process-store.d.ts +45 -0
- package/data/build/dist/host/terminal/terminal-process-store.js +183 -0
- package/data/build/dist/host/terminal/terminal-service.d.ts +87 -0
- package/data/build/dist/host/terminal/terminal-service.js +528 -0
- package/data/build/dist/host/terminal/terminal-store.d.ts +49 -0
- package/data/build/dist/host/terminal/terminal-store.js +242 -0
- package/data/build/dist/index.d.ts +37 -0
- package/data/build/dist/index.js +26 -0
- package/data/build/dist/shared/contracts/auth.d.ts +122 -0
- package/data/build/dist/shared/contracts/auth.js +8 -0
- package/data/build/dist/shared/contracts/cli-adapter.d.ts +192 -0
- package/data/build/dist/shared/contracts/cli-adapter.js +2 -0
- package/data/build/dist/shared/contracts/command-code.d.ts +5 -0
- package/data/build/dist/shared/contracts/command-code.js +2 -0
- package/data/build/dist/shared/contracts/config.d.ts +113 -0
- package/data/build/dist/shared/contracts/config.js +86 -0
- package/data/build/dist/shared/contracts/debug-config.d.ts +28 -0
- package/data/build/dist/shared/contracts/debug-config.js +78 -0
- package/data/build/dist/shared/contracts/debug.d.ts +75 -0
- package/data/build/dist/shared/contracts/debug.js +121 -0
- package/data/build/dist/shared/contracts/dsh-device.d.ts +72 -0
- package/data/build/dist/shared/contracts/dsh-device.js +2 -0
- package/data/build/dist/shared/contracts/errors.d.ts +33 -0
- package/data/build/dist/shared/contracts/errors.js +41 -0
- package/data/build/dist/shared/contracts/feature.d.ts +71 -0
- package/data/build/dist/shared/contracts/feature.js +2 -0
- package/data/build/dist/shared/contracts/host-status.d.ts +14 -0
- package/data/build/dist/shared/contracts/host-status.js +2 -0
- package/data/build/dist/shared/contracts/lan-access-dsh.d.ts +30 -0
- package/data/build/dist/shared/contracts/lan-access-dsh.js +2 -0
- package/data/build/dist/shared/contracts/peer-host.d.ts +37 -0
- package/data/build/dist/shared/contracts/peer-host.js +9 -0
- package/data/build/dist/shared/contracts/signaling.d.ts +67 -0
- package/data/build/dist/shared/contracts/signaling.js +2 -0
- package/data/build/dist/shared/contracts/subscription.d.ts +69 -0
- package/data/build/dist/shared/contracts/subscription.js +2 -0
- package/data/build/dist/shared/contracts/terminal-process.d.ts +65 -0
- package/data/build/dist/shared/contracts/terminal-process.js +2 -0
- package/data/build/dist/shared/contracts/terminal.d.ts +127 -0
- package/data/build/dist/shared/contracts/terminal.js +2 -0
- package/data/build/dist/shared/contracts/transport.d.ts +45 -0
- package/data/build/dist/shared/contracts/transport.js +3 -0
- package/data/build/dist/shared/contracts/version.d.ts +19 -0
- package/data/build/dist/shared/contracts/version.js +74 -0
- package/data/build/dist/shared/index.d.ts +22 -0
- package/data/build/dist/shared/index.js +9 -0
- package/data/build/dist/transport/carrier.d.ts +38 -0
- package/data/build/dist/transport/carrier.js +268 -0
- package/data/build/dist/transport/debug.d.ts +22 -0
- package/data/build/dist/transport/debug.js +57 -0
- package/data/build/dist/transport/dsh-envelope.d.ts +41 -0
- package/data/build/dist/transport/dsh-envelope.js +107 -0
- package/data/build/dist/transport/dsh-gateway.d.ts +64 -0
- package/data/build/dist/transport/dsh-gateway.js +254 -0
- package/data/build/dist/transport/dsh-session.d.ts +55 -0
- package/data/build/dist/transport/dsh-session.js +256 -0
- package/data/build/dist/transport/dsh-transport.d.ts +57 -0
- package/data/build/dist/transport/dsh-transport.js +125 -0
- package/data/build/dist/transport/frame.d.ts +132 -0
- package/data/build/dist/transport/frame.js +168 -0
- package/data/build/dist/transport/index.d.ts +11 -0
- package/data/build/dist/transport/index.js +11 -0
- package/data/build/dist/transport/multiplexer.d.ts +63 -0
- package/data/build/dist/transport/multiplexer.js +323 -0
- package/data/build/dist/transport/webrtc-client.d.ts +65 -0
- package/data/build/dist/transport/webrtc-client.js +255 -0
- package/data/build/dist/transport/webrtc-host.d.ts +58 -0
- package/data/build/dist/transport/webrtc-host.js +252 -0
- package/data/build/dist/typert.host.d.ts +25 -0
- package/data/build/dist/typert.host.js +150 -0
- package/dsh.bundle.patch +12 -0
- package/package.json +135 -0
- package/profile/README.md +27 -0
- package/profile/cordis.patch.yml +2 -0
- package/profile/package.json +20 -0
- package/profile/scripts/check-dsh-install.mjs +71 -0
- package/profile/version.json +5 -0
- package/scripts/check-dsh-install.mjs +88 -0
- package/version.json +6 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { createLanAccessDshRpcHandler, createNodeLanAccessDshRuntime, FileLanAccessDshLoginStore, LanAccessDshProxy } from '../lan-access-dsh.js';
|
|
2
|
+
/** Host 侧“局域网访问 DSH”模块,只管理一条 DSH Web 监听映射。 */
|
|
3
|
+
export function createLanAccessDshFeature(options = {}) {
|
|
4
|
+
return {
|
|
5
|
+
descriptor: {
|
|
6
|
+
name: 'lanAccessDsh',
|
|
7
|
+
version: '0.2.0',
|
|
8
|
+
enabledByDefault: true,
|
|
9
|
+
dependencies: [],
|
|
10
|
+
runtime: 'host',
|
|
11
|
+
},
|
|
12
|
+
async start(context) {
|
|
13
|
+
const runtime = options.runtime ?? createNodeLanAccessDshRuntime(context.services.dshWebPort);
|
|
14
|
+
const proxy = new LanAccessDshProxy(runtime, context.services.dshWebAuthenticatedUrl);
|
|
15
|
+
const settings = context.services.settings;
|
|
16
|
+
const loginStore = new FileLanAccessDshLoginStore();
|
|
17
|
+
const loginConfig = await loginStore.read();
|
|
18
|
+
proxy.setLoginConfig(loginConfig);
|
|
19
|
+
context.resources.add(context.services.rpc.register('lanAccessDsh', createLanAccessDshRpcHandler(proxy, settings, loginStore)));
|
|
20
|
+
if (settings !== undefined) {
|
|
21
|
+
const autoStart = async (value) => {
|
|
22
|
+
if (!value.lanAccessDsh.autoStart)
|
|
23
|
+
return;
|
|
24
|
+
try {
|
|
25
|
+
await proxy.start({ ...toStartInput(value.lanAccessDsh), ...(loginConfig === null ? {} : { login: loginConfig }) });
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
// 自动启动失败不能阻断 DSH,其它功能仍应正常可用;用户仍可在卡片中手动重试。
|
|
29
|
+
console.error('codingns4dsh: 局域网访问 DSH 自动启动失败', error);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
await autoStart(settings.get());
|
|
33
|
+
}
|
|
34
|
+
context.resources.add(() => proxy.close());
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function toStartInput(value) {
|
|
39
|
+
return {
|
|
40
|
+
listenHost: value.listenHost,
|
|
41
|
+
listenPort: value.listenPort,
|
|
42
|
+
...(value.dshPort > 0 ? { dshPort: value.dshPort } : {}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=lan-access-dsh.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FeatureModule } from '../../shared/contracts/feature.js';
|
|
2
|
+
import type { CodingNsHostServices } from './types.js';
|
|
3
|
+
/** 为后续 Debug 面板提供终端 PTY 启动项和进程实例的 Host RPC。 */
|
|
4
|
+
export declare function createTerminalProcessFeature(): FeatureModule<CodingNsHostServices>;
|
|
5
|
+
//# sourceMappingURL=terminal-process.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { CodingNsRpcError } from '../rpc-table.js';
|
|
2
|
+
/** 为后续 Debug 面板提供终端 PTY 启动项和进程实例的 Host RPC。 */
|
|
3
|
+
export function createTerminalProcessFeature() {
|
|
4
|
+
return {
|
|
5
|
+
descriptor: {
|
|
6
|
+
name: 'terminalProcess',
|
|
7
|
+
version: '0.1.0',
|
|
8
|
+
enabledByDefault: true,
|
|
9
|
+
dependencies: [],
|
|
10
|
+
runtime: 'host',
|
|
11
|
+
},
|
|
12
|
+
start(context) {
|
|
13
|
+
const service = context.services.terminalProcesses;
|
|
14
|
+
context.resources.add(context.services.rpc.register('terminalProcess', (action, payload) => {
|
|
15
|
+
if (service === undefined)
|
|
16
|
+
throw new CodingNsRpcError('CODINGNS_TERMINAL_PROCESS_UNAVAILABLE', '终端进程服务未装配');
|
|
17
|
+
switch (action) {
|
|
18
|
+
case 'profile/list': {
|
|
19
|
+
const input = optionalWorkspaceId(payload);
|
|
20
|
+
return service.listProfiles(input);
|
|
21
|
+
}
|
|
22
|
+
case 'profile/create':
|
|
23
|
+
return service.createProfile(parseProfileInput(payload));
|
|
24
|
+
case 'profile/delete': {
|
|
25
|
+
const input = objectFields(payload, ['workspaceId', 'profileId']);
|
|
26
|
+
return service.deleteProfile(requiredString(input.workspaceId, 'workspaceId'), requiredString(input.profileId, 'profileId'));
|
|
27
|
+
}
|
|
28
|
+
case 'launch':
|
|
29
|
+
return service.launch(parseLaunchRequest(payload));
|
|
30
|
+
case 'runtime/list':
|
|
31
|
+
return service.listInstances(optionalWorkspaceId(payload));
|
|
32
|
+
case 'runtime/get':
|
|
33
|
+
return service.getInstance(requiredString(objectFields(payload, ['instanceId']).instanceId, 'instanceId')) ?? null;
|
|
34
|
+
case 'runtime/stop':
|
|
35
|
+
return service.stop(requiredString(objectFields(payload, ['instanceId']).instanceId, 'instanceId'));
|
|
36
|
+
default:
|
|
37
|
+
throw new CodingNsRpcError('CODINGNS_RPC_NOT_FOUND', `未知终端进程 RPC: terminalProcess/${action}`);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function parseProfileInput(value) {
|
|
44
|
+
const input = objectFields(value, ['id', 'workspaceId', 'name', 'cwdRelative', 'command', 'shell', 'runtimeType']);
|
|
45
|
+
const shell = objectFields(input.shell, ['profileId', 'path', 'args', 'name']);
|
|
46
|
+
if (!Array.isArray(shell.args) || shell.args.some((item) => typeof item !== 'string'))
|
|
47
|
+
throw new TypeError('shell.args 无效');
|
|
48
|
+
if (input.runtimeType !== 'local-pty' && input.runtimeType !== 'tmux' && input.runtimeType !== 'conpty-powershell' && input.runtimeType !== 'conpty-cmd' && input.runtimeType !== 'conpty-git-bash')
|
|
49
|
+
throw new TypeError('runtimeType 无效');
|
|
50
|
+
const args = input.args === undefined ? [] : input.args;
|
|
51
|
+
if (!Array.isArray(args) || args.some((item) => typeof item !== 'string'))
|
|
52
|
+
throw new TypeError('args 无效');
|
|
53
|
+
const env = input.env === undefined ? {} : input.env;
|
|
54
|
+
if (!isRecord(env) || Object.values(env).some((item) => typeof item !== 'string'))
|
|
55
|
+
throw new TypeError('env 无效');
|
|
56
|
+
return {
|
|
57
|
+
id: requiredString(input.id, 'id'),
|
|
58
|
+
workspaceId: requiredString(input.workspaceId, 'workspaceId'),
|
|
59
|
+
name: requiredString(input.name, 'name'),
|
|
60
|
+
cwdRelative: requiredString(input.cwdRelative, 'cwdRelative'),
|
|
61
|
+
command: requiredString(input.command, 'command'),
|
|
62
|
+
args,
|
|
63
|
+
env,
|
|
64
|
+
shell: {
|
|
65
|
+
profileId: shell.profileId,
|
|
66
|
+
path: requiredString(shell.path, 'shell.path'),
|
|
67
|
+
args: shell.args,
|
|
68
|
+
name: requiredString(shell.name, 'shell.name'),
|
|
69
|
+
},
|
|
70
|
+
runtimeType: input.runtimeType,
|
|
71
|
+
runtimeMode: 'pty',
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function parseLaunchRequest(value) {
|
|
75
|
+
const input = objectFields(value, ['workspaceId', 'profileId', 'cols', 'rows']);
|
|
76
|
+
return {
|
|
77
|
+
workspaceId: requiredString(input.workspaceId, 'workspaceId'),
|
|
78
|
+
profileId: requiredString(input.profileId, 'profileId'),
|
|
79
|
+
...(input.dshSessionId === undefined ? {} : { dshSessionId: requiredString(input.dshSessionId, 'dshSessionId') }),
|
|
80
|
+
...(input.terminalId === undefined ? {} : { terminalId: requiredString(input.terminalId, 'terminalId') }),
|
|
81
|
+
cols: requiredInteger(input.cols, 'cols'),
|
|
82
|
+
rows: requiredInteger(input.rows, 'rows'),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function optionalWorkspaceId(value) {
|
|
86
|
+
if (value === undefined || value === null)
|
|
87
|
+
return undefined;
|
|
88
|
+
const input = objectFields(value, ['workspaceId']);
|
|
89
|
+
return input.workspaceId === undefined ? undefined : requiredString(input.workspaceId, 'workspaceId');
|
|
90
|
+
}
|
|
91
|
+
function objectFields(value, fields) {
|
|
92
|
+
if (!isRecord(value))
|
|
93
|
+
throw new TypeError('终端进程 RPC 参数必须是对象');
|
|
94
|
+
for (const field of fields)
|
|
95
|
+
if (!(field in value))
|
|
96
|
+
throw new TypeError(`终端进程 RPC 缺少字段: ${field}`);
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
function requiredString(value, field) {
|
|
100
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
101
|
+
throw new TypeError(`${field} 必须是非空字符串`);
|
|
102
|
+
return value.trim();
|
|
103
|
+
}
|
|
104
|
+
function requiredInteger(value, field) {
|
|
105
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value))
|
|
106
|
+
throw new TypeError(`${field} 必须是整数`);
|
|
107
|
+
return value;
|
|
108
|
+
}
|
|
109
|
+
function isRecord(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|
|
110
|
+
//# sourceMappingURL=terminal-process.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FeatureModule } from '../../shared/contracts/feature.js';
|
|
2
|
+
import type { CodingNsTerminalStatus } from '../../shared/contracts/terminal.js';
|
|
3
|
+
import { type DetectedTerminalShell } from '../terminal/shell-detection.js';
|
|
4
|
+
import type { CodingNsHostServices } from './types.js';
|
|
5
|
+
export interface TerminalStatusFeatureOptions {
|
|
6
|
+
readonly platform?: string;
|
|
7
|
+
readonly controllerMode?: CodingNsTerminalStatus['controllerMode'];
|
|
8
|
+
readonly effectiveEnabled?: boolean;
|
|
9
|
+
readonly detectShells?: () => readonly DetectedTerminalShell[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 向设置页报告 Host 的真实平台能力和当前 controller 模式。
|
|
13
|
+
*
|
|
14
|
+
* 基线与强化模式都由插件自有 controller 提供 webTerminals;该状态描述的是
|
|
15
|
+
* 当前进程实际采用的 backend,不能用设置里下次启动的目标值冒充生效状态。
|
|
16
|
+
*/
|
|
17
|
+
export declare function createTerminalStatusFeature(options?: TerminalStatusFeatureOptions): FeatureModule<CodingNsHostServices>;
|
|
18
|
+
//# sourceMappingURL=terminal-status.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { detectTerminalShells, resolveTerminalShell, } from '../terminal/shell-detection.js';
|
|
2
|
+
import { CodingNsRpcError } from '../rpc-table.js';
|
|
3
|
+
/**
|
|
4
|
+
* 向设置页报告 Host 的真实平台能力和当前 controller 模式。
|
|
5
|
+
*
|
|
6
|
+
* 基线与强化模式都由插件自有 controller 提供 webTerminals;该状态描述的是
|
|
7
|
+
* 当前进程实际采用的 backend,不能用设置里下次启动的目标值冒充生效状态。
|
|
8
|
+
*/
|
|
9
|
+
export function createTerminalStatusFeature(options = {}) {
|
|
10
|
+
const platform = options.platform ?? process.platform;
|
|
11
|
+
const controllerMode = options.controllerMode ?? 'baseline';
|
|
12
|
+
const effectiveEnabled = options.effectiveEnabled ?? controllerMode === 'enhanced';
|
|
13
|
+
const detectShells = options.detectShells ?? (() => detectTerminalShells({ platform }));
|
|
14
|
+
return {
|
|
15
|
+
descriptor: {
|
|
16
|
+
name: 'terminalStatus',
|
|
17
|
+
version: '0.1.0',
|
|
18
|
+
enabledByDefault: true,
|
|
19
|
+
dependencies: [],
|
|
20
|
+
runtime: 'host',
|
|
21
|
+
},
|
|
22
|
+
start(context) {
|
|
23
|
+
context.resources.add(context.services.rpc.register('terminal', (action) => {
|
|
24
|
+
if (action !== 'status') {
|
|
25
|
+
throw new CodingNsRpcError('CODINGNS_RPC_NOT_FOUND', `未知 Codingns4DSH RPC: terminal/${action}`);
|
|
26
|
+
}
|
|
27
|
+
const shells = detectShells();
|
|
28
|
+
const requested = context.services.settings?.get().terminalEnhancement.defaultProfile ?? 'system';
|
|
29
|
+
const available = shells.filter((shell) => shell.available && shell.path !== null);
|
|
30
|
+
let resolved = null;
|
|
31
|
+
try {
|
|
32
|
+
resolved = resolveTerminalShell(requested, shells, platform);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// 没有可用 shell 时仍返回诊断快照,让设置页能明确显示空列表。
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
platform: normalizePlatform(platform),
|
|
39
|
+
controllerMode,
|
|
40
|
+
effectiveEnabled,
|
|
41
|
+
profiles: available.map((shell) => ({
|
|
42
|
+
profileId: shell.profileId,
|
|
43
|
+
name: shell.displayName,
|
|
44
|
+
path: shell.path,
|
|
45
|
+
})),
|
|
46
|
+
resolvedProfileId: resolved?.resolvedProfileId ?? null,
|
|
47
|
+
...(resolved?.fallbackReason === undefined ? {} : { fallbackReason: resolved.fallbackReason }),
|
|
48
|
+
};
|
|
49
|
+
}));
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function normalizePlatform(platform) {
|
|
54
|
+
return platform === 'darwin' || platform === 'linux' || platform === 'win32' ? platform : 'unsupported';
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=terminal-status.js.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CodingNsRpcTable } from '../rpc-table.js';
|
|
2
|
+
import type { SettingsProvider, SettingsScope } from '@deepseek-ai/dsh-settings';
|
|
3
|
+
import type { CodingNsSettings } from '../../shared/contracts/config.js';
|
|
4
|
+
import type { CodingNsNativeSessionBridge } from '../native-session-bridge.js';
|
|
5
|
+
import type { TerminalProcessService } from '../terminal/terminal-process-service.js';
|
|
6
|
+
import type { DebugWorkspaceService } from '../debug.js';
|
|
7
|
+
export interface CodingNsHostEvents {
|
|
8
|
+
on(name: string, listener: (...args: any[]) => any): unknown;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Host 侧功能模块可用的服务集合。
|
|
12
|
+
*
|
|
13
|
+
* 模块在 start 中通过 context.services 取用;未来接入工作区、终端或进程能力时
|
|
14
|
+
* 在这里增加字段,模块数量本身不改变这个契约的形状。
|
|
15
|
+
*/
|
|
16
|
+
export interface CodingNsHostServices {
|
|
17
|
+
readonly rpc: CodingNsRpcTable;
|
|
18
|
+
/** 当前 DSH 宿主的真实版本;由 Host 入口启动门禁解析并向功能模块传递。 */
|
|
19
|
+
readonly dshVersion?: string;
|
|
20
|
+
/** 持久化设置;测试或嵌入式调用未提供时,局域网映射仍可手动启动。 */
|
|
21
|
+
readonly settings?: SettingsScope<CodingNsSettings>;
|
|
22
|
+
/** Host 设置提供器,供远程设置 RPC 做版本校验和持久化写入。 */
|
|
23
|
+
readonly settingsProvider?: SettingsProvider;
|
|
24
|
+
/** 当前 DSH Web 服务实际监听端口,用于自动定位本机 DSH。 */
|
|
25
|
+
readonly dshWebPort?: number;
|
|
26
|
+
/** DSH 官方生成的一次性 Web 认证 URL;只留在 Host 内部完成 Cookie 交换。 */
|
|
27
|
+
readonly dshWebAuthenticatedUrl?: string;
|
|
28
|
+
/** DSH 事件总线;CLI 模块用它接入 llm/stream,测试环境可以不提供。 */
|
|
29
|
+
readonly events?: CodingNsHostEvents;
|
|
30
|
+
/** DSH 原生会话桥接;不可用时为 undefined,插件不因此阻断启动。 */
|
|
31
|
+
readonly nativeSessions?: CodingNsNativeSessionBridge;
|
|
32
|
+
/** 终端启动项和 PTY 进程服务;只由 Host RPC 使用。 */
|
|
33
|
+
readonly terminalProcesses?: TerminalProcessService;
|
|
34
|
+
/** Workspace 级调试服务;只使用 Host 解析出的根目录。 */
|
|
35
|
+
readonly debug?: DebugWorkspaceService;
|
|
36
|
+
/** Debug 模块启用时注册其专属 Fetch 路由,停用时由模块资源注销。 */
|
|
37
|
+
readonly registerDebugProxyRoute?: (handler: (request: Request) => Promise<Response>) => () => Promise<void>;
|
|
38
|
+
/** 由 Host 权威解析 Workspace ID,Client 不可覆盖。 */
|
|
39
|
+
readonly resolveWorkspaceRoot?: (workspaceId: string) => string | null;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSH Host 入口。
|
|
3
|
+
*
|
|
4
|
+
* Host 侧能力全部以功能模块形式交给 FeatureRegistry 管理:依赖顺序、启停和
|
|
5
|
+
* 资源释放由注册表负责,设置里的模块开关通过 watch 驱动 reconcile。入口本身
|
|
6
|
+
* 只负责装配,不承载任何具体业务逻辑,因此新增模块不需要修改这个文件。
|
|
7
|
+
*/
|
|
8
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
9
|
+
export declare function apply(ctx?: Context): void;
|
|
10
|
+
export { HOST_FEATURES, createAuthFeature, createLanAccessDshFeature, createTerminalStatusFeature, createHostFeatures, createCliAdaptersFeature, createTerminalProcessFeature, } from './features/index.js';
|
|
11
|
+
export type { CodingNsHostServices } from './features/index.js';
|
|
12
|
+
export { CodingNsSettingsSchema, registerCodingNsSettings } from './settings.js';
|
|
13
|
+
export { createCodingNsRpcHandler, createCodingNsSettingsRpcHandler, registerCodingNsRpc } from './rpc.js';
|
|
14
|
+
export { DebugWorkspaceService, NodeDebugPortInspector, type DebugPortCheck, type DebugPortInspector, type DebugPortProcess, type DebugProxyBinding, } from './debug.js';
|
|
15
|
+
export { CodingNsRpcError, CodingNsRpcTable, type CodingNsRpcHandler, type CodingNsRpcTarget, } from './rpc-table.js';
|
|
16
|
+
export { CodingNsAuthSession } from './auth-session.js';
|
|
17
|
+
export { createCodingNsNativeSessionBridge, type CodingNsNativeSessionBridge, type CodingNsNativeSessionController, type CodingNsNativeSessionStore, type CodingNsNativeWorkspaceController, type CodingNsNativeRequestContext, } from './native-session-bridge.js';
|
|
18
|
+
export { CommandCodeDriver } from './cli-adapters/command-code-driver.js';
|
|
19
|
+
export { CommandCodeSubscriptionService, readCommandCodeApiKey } from './cli-adapters/command-code-subscription.js';
|
|
20
|
+
export { ProviderSubscriptionService, CodexSubscriptionService, ClaudeCodeSubscriptionService, Sub2ApiUsageService, OpenCodeSubscriptionService, type Sub2ApiSource, type Sub2ApiUsageOptions, } from './cli-adapters/provider-subscription.js';
|
|
21
|
+
export { ClaudeCodeDriver } from './cli-adapters/claude-driver.js';
|
|
22
|
+
export { KimiCliDriver } from './cli-adapters/kimi-driver.js';
|
|
23
|
+
export { GeminiCliDriver } from './cli-adapters/gemini-driver.js';
|
|
24
|
+
export { PiAgentDriver } from './cli-adapters/pi-driver.js';
|
|
25
|
+
export { CodexAppServerDriver } from './cli-adapters/codex-driver.js';
|
|
26
|
+
export { OpenCodeDriver } from './cli-adapters/opencode-driver.js';
|
|
27
|
+
export { GrokBuildDriver } from './cli-adapters/grok-driver.js';
|
|
28
|
+
export { StandardStreamDriver } from './cli-adapters/standard-stream-driver.js';
|
|
29
|
+
export { JsonRpcProcess } from './cli-adapters/json-rpc-process.js';
|
|
30
|
+
export { HttpSseClient } from './cli-adapters/http-sse-client.js';
|
|
31
|
+
export { CodingNsCliAdapterRegistry } from './cli-adapters/registry.js';
|
|
32
|
+
export { CodingNsCliSessionStore, type CodingNsCliSessionPersistence, type CodingNsCliSessionPatch, type CodingNsCliProviderStatePatch, type CodingNsCliSessionStoreOptions, } from './cli-adapters/session-store.js';
|
|
33
|
+
export type { CodingNsCliDriver, CodingNsCliSessionProbeInput, CodingNsCliSessionProbeResult, CodingNsCliSessionProbeState, } from './cli-adapters/driver.js';
|
|
34
|
+
export { CODINGNS_CONTROL_API_PATHS, CodingNsControlApiError, HttpCodingNsControlApiClient, type CodingNsControlApiClient, type CodingNsControlClient, type HttpCodingNsControlApiClientOptions, } from './control-api-client.js';
|
|
35
|
+
export { InMemoryCodingNsCredentialStore, FileCodingNsCredentialStore, InMemoryDshDeviceCredentialStore, FileDshDeviceCredentialStore, type CodingNsCredentialStore, type HostCredentialRecord, type DshDeviceCredentialStore, } from './credential-store.js';
|
|
36
|
+
export { startDshHostDeviceRuntime, type DshHostDeviceRuntime, type DshHostDeviceRuntimeOptions, } from './dsh-device-runtime.js';
|
|
37
|
+
export { createDshRpcGatewayFeature } from './dsh-gateway-feature.js';
|
|
38
|
+
export { createLocalDshWebRuntimeProvider, createRemoteWebRuntimeFeature, type DshWebAsset, type DshWebBoot, type DshWebRuntimeProvider, type DshWebSession, type DshWebSocketLike, type LocalDshWebRuntimeProviderOptions, type RemoteWebRuntimeFeatureOptions, } from './remote-web-runtime.js';
|
|
39
|
+
export type { LoginByEmailResponse, RefreshTokenRequest, RefreshTokenResponse, } from './control-api-client.js';
|
|
40
|
+
export { LanAccessDshError, LanAccessDshProxy, FileLanAccessDshLoginStore, InMemoryLanAccessDshLoginStore, createLanAccessDshRpcHandler, createNodeLanAccessDshRuntime, normalizeLanAccessDshConfig, openLoginProtectionSession, verifyLoginProtectionSession, type LanAccessDshRuntime, type LanAccessDshStream, type LanAccessDshLoginRecord, type LanAccessDshLoginStore, } from './lan-access-dsh.js';
|
|
41
|
+
export { CODINGNS_TUNNEL_DATA_CHANNEL_LABEL, FileHostDtlsIdentityStore, createRegisteredHostSignalingSocket, createWeriftPeerConnectionFactory, ensureHostDtlsIdentity, formatHostDtlsFingerprint, generateHostDtlsIdentity, startHostRelayRuntime, type HostDtlsIdentityMaterial, type HostDtlsIdentityStore, type HostRelayRuntime, type HostRelayRuntimeOptions, type HostRelaySession, type HostSignalingSocket, } from './relay-tunnel-runtime.js';
|
|
42
|
+
export * from './terminal/index.js';
|
|
43
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { FeatureRegistry } from '../features/registry.js';
|
|
2
|
+
import { captureRestartFeatureStates, enabledFeatureNames } from '../shared/contracts/config.js';
|
|
3
|
+
import { HOST_FEATURES, createHostFeatures } from './features/index.js';
|
|
4
|
+
import { registerCodingNsRpc } from './rpc.js';
|
|
5
|
+
import { CodingNsRpcTable } from './rpc-table.js';
|
|
6
|
+
import { registerCodingNsSettings } from './settings.js';
|
|
7
|
+
import { createCodingNsNativeSessionBridge } from './native-session-bridge.js';
|
|
8
|
+
import { installTerminalController } from './terminal/startup.js';
|
|
9
|
+
import { DebugWorkspaceService } from './debug.js';
|
|
10
|
+
import { detectRuntimeDshVersion, DSH_VERSION_INJECTION_NAME } from './dsh-runtime-version.js';
|
|
11
|
+
export function apply(ctx) {
|
|
12
|
+
if (ctx === undefined)
|
|
13
|
+
return;
|
|
14
|
+
const dshVersion = detectRuntimeDshVersion();
|
|
15
|
+
console.error('codingns4dsh: host apply entered');
|
|
16
|
+
ctx.inject(['settings', 'connection', 'webServer'], async (hostCtx) => {
|
|
17
|
+
console.error('codingns4dsh: host inject ready', {
|
|
18
|
+
hasConnection: hostCtx.connection !== undefined,
|
|
19
|
+
});
|
|
20
|
+
const webServerPort = hostCtx.webServer.port;
|
|
21
|
+
// LAN 入口和中继 Web 页面可能使用非 loopback URL,但它们都已经经过
|
|
22
|
+
// DSH Host 的认证边界并回到本机 Host。通过启动页注入 transport 所有权,
|
|
23
|
+
// 让 DSH 原生 ui-settings 保持 host 模式,而不是错误降级为 memory 模式。
|
|
24
|
+
const indexInjectionEvents = hostCtx;
|
|
25
|
+
indexInjectionEvents.on('webserver/index-inject', (table) => {
|
|
26
|
+
table.push({ kind: 'global', name: '__DSH_TRANSPORT__', value: { ownsHost: true } });
|
|
27
|
+
table.push({ kind: 'global', name: DSH_VERSION_INJECTION_NAME, value: dshVersion });
|
|
28
|
+
});
|
|
29
|
+
const settings = registerCodingNsSettings(hostCtx);
|
|
30
|
+
// controller 必须在功能模块和浏览器 Client 开始消费状态前完成装配。
|
|
31
|
+
// 工厂在本次启动只读取一次开关,设置 watcher 不会热切同名 service。
|
|
32
|
+
const terminal = await installTerminalController(hostCtx, settings, hostCtx.settings, {
|
|
33
|
+
resolveWorkspaceRoot: (workspaceId) => resolveWorkspaceRoot(hostCtx, workspaceId),
|
|
34
|
+
});
|
|
35
|
+
const services = {
|
|
36
|
+
rpc: new CodingNsRpcTable(),
|
|
37
|
+
dshVersion,
|
|
38
|
+
settings,
|
|
39
|
+
settingsProvider: hostCtx.settings,
|
|
40
|
+
dshWebPort: webServerPort,
|
|
41
|
+
dshWebAuthenticatedUrl: hostCtx.connection.authenticatedUrl(`http://127.0.0.1:${String(webServerPort)}`),
|
|
42
|
+
events: { on: hostCtx.on.bind(hostCtx) },
|
|
43
|
+
nativeSessions: createCodingNsNativeSessionBridge(hostCtx),
|
|
44
|
+
terminalProcesses: terminal.processService,
|
|
45
|
+
resolveWorkspaceRoot: (workspaceId) => resolveWorkspaceRoot(hostCtx, workspaceId),
|
|
46
|
+
registerDebugProxyRoute: (handler) => hostCtx.connection.fetch.register({
|
|
47
|
+
path: '/api/codingns/debug-proxy',
|
|
48
|
+
methods: ['GET', 'HEAD', 'POST'],
|
|
49
|
+
requestBody: 'streaming',
|
|
50
|
+
fetch: handler,
|
|
51
|
+
}),
|
|
52
|
+
};
|
|
53
|
+
const debug = new DebugWorkspaceService({
|
|
54
|
+
resolveWorkspaceRoot: (workspaceId) => resolveWorkspaceRoot(hostCtx, workspaceId),
|
|
55
|
+
terminalProcesses: terminal.processService,
|
|
56
|
+
});
|
|
57
|
+
const servicesWithDebug = { ...services, debug };
|
|
58
|
+
const registry = new FeatureRegistry(servicesWithDebug);
|
|
59
|
+
registry.registerMany(createHostFeatures({
|
|
60
|
+
terminalStatus: {
|
|
61
|
+
controllerMode: terminal.mode,
|
|
62
|
+
effectiveEnabled: terminal.mode === 'enhanced',
|
|
63
|
+
},
|
|
64
|
+
}));
|
|
65
|
+
registry.validate();
|
|
66
|
+
const restartStates = captureRestartFeatureStates(registry.descriptors(), settings.get(), dshVersion);
|
|
67
|
+
try {
|
|
68
|
+
registerCodingNsRpc(hostCtx, services.rpc, services.settingsProvider);
|
|
69
|
+
console.error('codingns4dsh: host RPC registration requested');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error('codingns4dsh: host RPC registration failed', error);
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
hostCtx.effect(() => {
|
|
76
|
+
const sync = () => {
|
|
77
|
+
void registry
|
|
78
|
+
.reconcile(enabledFeatureNames(registry.descriptors(), settings.get(), restartStates, dshVersion))
|
|
79
|
+
.catch((error) => {
|
|
80
|
+
console.error('codingns4dsh: 功能模块状态同步失败', error);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
sync();
|
|
84
|
+
return settings.watch(sync);
|
|
85
|
+
}, 'codingns4dsh: 功能模块启停同步');
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function resolveWorkspaceRoot(ctx, workspaceId) {
|
|
89
|
+
try {
|
|
90
|
+
const registry = ctx.get('workspaceRegistry');
|
|
91
|
+
const entry = registry?.list?.().find((candidate) => candidate.id === workspaceId);
|
|
92
|
+
if (entry === undefined)
|
|
93
|
+
return null;
|
|
94
|
+
for (const key of ['rootPath', 'path', 'cwd', 'directory']) {
|
|
95
|
+
const value = entry[key];
|
|
96
|
+
if (typeof value === 'string' && value.trim() !== '')
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Workspace Registry 还未装配时由启动服务返回可读的不可用错误。
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
export { HOST_FEATURES, createAuthFeature, createLanAccessDshFeature, createTerminalStatusFeature, createHostFeatures, createCliAdaptersFeature, createTerminalProcessFeature, } from './features/index.js';
|
|
106
|
+
export { CodingNsSettingsSchema, registerCodingNsSettings } from './settings.js';
|
|
107
|
+
export { createCodingNsRpcHandler, createCodingNsSettingsRpcHandler, registerCodingNsRpc } from './rpc.js';
|
|
108
|
+
export { DebugWorkspaceService, NodeDebugPortInspector, } from './debug.js';
|
|
109
|
+
export { CodingNsRpcError, CodingNsRpcTable, } from './rpc-table.js';
|
|
110
|
+
export { CodingNsAuthSession } from './auth-session.js';
|
|
111
|
+
export { createCodingNsNativeSessionBridge, } from './native-session-bridge.js';
|
|
112
|
+
export { CommandCodeDriver } from './cli-adapters/command-code-driver.js';
|
|
113
|
+
export { CommandCodeSubscriptionService, readCommandCodeApiKey } from './cli-adapters/command-code-subscription.js';
|
|
114
|
+
export { ProviderSubscriptionService, CodexSubscriptionService, ClaudeCodeSubscriptionService, Sub2ApiUsageService, OpenCodeSubscriptionService, } from './cli-adapters/provider-subscription.js';
|
|
115
|
+
export { ClaudeCodeDriver } from './cli-adapters/claude-driver.js';
|
|
116
|
+
export { KimiCliDriver } from './cli-adapters/kimi-driver.js';
|
|
117
|
+
export { GeminiCliDriver } from './cli-adapters/gemini-driver.js';
|
|
118
|
+
export { PiAgentDriver } from './cli-adapters/pi-driver.js';
|
|
119
|
+
export { CodexAppServerDriver } from './cli-adapters/codex-driver.js';
|
|
120
|
+
export { OpenCodeDriver } from './cli-adapters/opencode-driver.js';
|
|
121
|
+
export { GrokBuildDriver } from './cli-adapters/grok-driver.js';
|
|
122
|
+
export { StandardStreamDriver } from './cli-adapters/standard-stream-driver.js';
|
|
123
|
+
export { JsonRpcProcess } from './cli-adapters/json-rpc-process.js';
|
|
124
|
+
export { HttpSseClient } from './cli-adapters/http-sse-client.js';
|
|
125
|
+
export { CodingNsCliAdapterRegistry } from './cli-adapters/registry.js';
|
|
126
|
+
export { CodingNsCliSessionStore, } from './cli-adapters/session-store.js';
|
|
127
|
+
export { CODINGNS_CONTROL_API_PATHS, CodingNsControlApiError, HttpCodingNsControlApiClient, } from './control-api-client.js';
|
|
128
|
+
export { InMemoryCodingNsCredentialStore, FileCodingNsCredentialStore, InMemoryDshDeviceCredentialStore, FileDshDeviceCredentialStore, } from './credential-store.js';
|
|
129
|
+
export { startDshHostDeviceRuntime, } from './dsh-device-runtime.js';
|
|
130
|
+
export { createDshRpcGatewayFeature } from './dsh-gateway-feature.js';
|
|
131
|
+
export { createLocalDshWebRuntimeProvider, createRemoteWebRuntimeFeature, } from './remote-web-runtime.js';
|
|
132
|
+
export { LanAccessDshError, LanAccessDshProxy, FileLanAccessDshLoginStore, InMemoryLanAccessDshLoginStore, createLanAccessDshRpcHandler, createNodeLanAccessDshRuntime, normalizeLanAccessDshConfig, openLoginProtectionSession, verifyLoginProtectionSession, } from './lan-access-dsh.js';
|
|
133
|
+
export { CODINGNS_TUNNEL_DATA_CHANNEL_LABEL, FileHostDtlsIdentityStore, createRegisteredHostSignalingSocket, createWeriftPeerConnectionFactory, ensureHostDtlsIdentity, formatHostDtlsFingerprint, generateHostDtlsIdentity, startHostRelayRuntime, } from './relay-tunnel-runtime.js';
|
|
134
|
+
export * from './terminal/index.js';
|
|
135
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { SettingsScope } from '@deepseek-ai/dsh-settings';
|
|
2
|
+
import type { CodingNsSettings, LanAccessDshLoginSettings, LoginProtectionScopes } from '../shared/contracts/config.js';
|
|
3
|
+
import type { LanAccessDshConfig, LanAccessDshLoginConfig, LanAccessDshSnapshot } from '../shared/contracts/lan-access-dsh.js';
|
|
4
|
+
export interface LanAccessDshStream {
|
|
5
|
+
pipe(destination: LanAccessDshStream): LanAccessDshStream;
|
|
6
|
+
destroy(error?: Error): void;
|
|
7
|
+
once(event: 'error' | 'close' | 'connect', listener: (...args: unknown[]) => void): LanAccessDshStream;
|
|
8
|
+
}
|
|
9
|
+
export interface LanAccessDshRuntime {
|
|
10
|
+
listListenHosts(): readonly string[];
|
|
11
|
+
detectDshPorts(): Promise<readonly number[]>;
|
|
12
|
+
listen(config: LanAccessDshConfig, onConnection: (socket: LanAccessDshStream) => void): Promise<{
|
|
13
|
+
actualPort: number;
|
|
14
|
+
close: () => Promise<void>;
|
|
15
|
+
}>;
|
|
16
|
+
connect(dshPort: number, onConnect: (socket: LanAccessDshStream) => void, onError: (error: Error) => void): void;
|
|
17
|
+
}
|
|
18
|
+
export interface LanAccessDshLoginRecord extends LanAccessDshLoginConfig {
|
|
19
|
+
}
|
|
20
|
+
export interface LanAccessDshLoginStore {
|
|
21
|
+
read(): Promise<LanAccessDshLoginRecord | null>;
|
|
22
|
+
write(record: LanAccessDshLoginRecord): Promise<void>;
|
|
23
|
+
clear(): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/** 浏览器中继只携带短期签名票据,密码哈希和签名密钥始终留在 Host。 */
|
|
26
|
+
export declare function openLoginProtectionSession(store: LanAccessDshLoginStore, username: string, password: string, scope: keyof LoginProtectionScopes): Promise<{
|
|
27
|
+
token: string;
|
|
28
|
+
expiresAt: string;
|
|
29
|
+
}>;
|
|
30
|
+
/** 校验中继票据;配置关闭或未覆盖该范围时保持向后兼容,直接放行。 */
|
|
31
|
+
export declare function verifyLoginProtectionSession(store: LanAccessDshLoginStore, token: string | undefined, scope: keyof LoginProtectionScopes): Promise<boolean>;
|
|
32
|
+
/** 测试和嵌入式宿主使用的内存凭据存储。 */
|
|
33
|
+
export declare class InMemoryLanAccessDshLoginStore implements LanAccessDshLoginStore {
|
|
34
|
+
private value;
|
|
35
|
+
read(): Promise<LanAccessDshLoginRecord | null>;
|
|
36
|
+
write(record: LanAccessDshLoginRecord): Promise<void>;
|
|
37
|
+
clear(): Promise<void>;
|
|
38
|
+
}
|
|
39
|
+
/** 登录保护凭据与 Codingns4DSH refresh token 分离保存,文件权限限制为当前用户。 */
|
|
40
|
+
export declare class FileLanAccessDshLoginStore implements LanAccessDshLoginStore {
|
|
41
|
+
private readonly filePath;
|
|
42
|
+
constructor(filePath?: string);
|
|
43
|
+
read(): Promise<LanAccessDshLoginRecord | null>;
|
|
44
|
+
write(record: LanAccessDshLoginRecord): Promise<void>;
|
|
45
|
+
clear(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/** Host 侧默认运行时:枚举网卡、读取 DSH 启动参数并建立 TCP 转发。 */
|
|
48
|
+
export declare function createNodeLanAccessDshRuntime(dshWebPort?: number): LanAccessDshRuntime;
|
|
49
|
+
/** 管理唯一一条“监听地址/端口 -> 当前 DSH Web 端口”的映射。 */
|
|
50
|
+
export declare class LanAccessDshProxy {
|
|
51
|
+
private readonly runtime;
|
|
52
|
+
private readonly authenticatedUrl?;
|
|
53
|
+
private active;
|
|
54
|
+
private detectedDshPorts;
|
|
55
|
+
private loginConfig;
|
|
56
|
+
/** 当前进程内主动退出的会话;正常会话由签名令牌承载,可跨代理重建复用。 */
|
|
57
|
+
private readonly revokedSessions;
|
|
58
|
+
private upstreamCookie;
|
|
59
|
+
constructor(runtime?: LanAccessDshRuntime, authenticatedUrl?: string | undefined);
|
|
60
|
+
listenHosts(): readonly string[];
|
|
61
|
+
detect(): Promise<readonly number[]>;
|
|
62
|
+
start(input: Partial<LanAccessDshConfig>): Promise<LanAccessDshSnapshot>;
|
|
63
|
+
stop(): Promise<void>;
|
|
64
|
+
close(): Promise<void>;
|
|
65
|
+
get(): LanAccessDshSnapshot | null;
|
|
66
|
+
setLoginConfig(config: LanAccessDshLoginConfig | null): void;
|
|
67
|
+
loginSettings(): LanAccessDshLoginSettings;
|
|
68
|
+
private resolveDetectedPort;
|
|
69
|
+
private accept;
|
|
70
|
+
private snapshot;
|
|
71
|
+
private authorize;
|
|
72
|
+
/** DSH 启动时的认证 URL 只在 Host 内交换一次 Cookie,绝不下发到浏览器。 */
|
|
73
|
+
private takeOverDshWebToken;
|
|
74
|
+
}
|
|
75
|
+
/** 改写请求中的 Host、Origin,并关闭普通 HTTP 上游连接。 */
|
|
76
|
+
export declare function rewriteLanAccessDshRequestHeaders(input: Uint8Array, targetAuthority: string, upstreamCookie?: string): Uint8Array;
|
|
77
|
+
export declare class LanAccessDshError extends Error {
|
|
78
|
+
readonly code: 'LAN_ACCESS_DSH_INVALID' | 'DSH_PORT_NOT_FOUND' | 'DSH_PORT_AMBIGUOUS';
|
|
79
|
+
constructor(code: 'LAN_ACCESS_DSH_INVALID' | 'DSH_PORT_NOT_FOUND' | 'DSH_PORT_AMBIGUOUS', message: string);
|
|
80
|
+
}
|
|
81
|
+
export declare function normalizeLanAccessDshConfig(value: Partial<LanAccessDshConfig>, allowedListenHosts?: readonly string[]): LanAccessDshConfig;
|
|
82
|
+
export declare function createLanAccessDshRpcHandler(proxy: LanAccessDshProxy, settings?: SettingsScope<CodingNsSettings>, loginStore?: LanAccessDshLoginStore): (action: string, payload: unknown) => unknown | Promise<unknown>;
|
|
83
|
+
//# sourceMappingURL=lan-access-dsh.d.ts.map
|