dsh-remote 0.8.49 → 0.8.51
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.en.md +1 -0
- package/README.md +2 -0
- package/lib/client.js +11 -3
- package/lib/index.js +173 -27
- package/lib/sshconfig.js +256 -15
- package/node_modules/buildcheck/.eslintrc.js +5 -0
- package/node_modules/buildcheck/.github/workflows/ci.yml +88 -0
- package/node_modules/buildcheck/.github/workflows/lint.yml +27 -0
- package/node_modules/buildcheck/.npmignore +3 -0
- package/node_modules/buildcheck/LICENSE +19 -0
- package/node_modules/buildcheck/README.md +106 -0
- package/node_modules/buildcheck/deps/Find-VisualStudio.cs +250 -0
- package/node_modules/buildcheck/lib/findvs.js +361 -0
- package/node_modules/buildcheck/lib/index.js +738 -0
- package/node_modules/buildcheck/package.json +36 -0
- package/node_modules/buildcheck/test/test.js +8 -0
- package/node_modules/cpu-features/.eslintrc.js +5 -0
- package/node_modules/cpu-features/.github/workflows/ci.yml +74 -0
- package/node_modules/cpu-features/.github/workflows/lint.yml +27 -0
- package/node_modules/cpu-features/LICENSE +19 -0
- package/node_modules/cpu-features/README.md +59 -0
- package/node_modules/cpu-features/binding.gyp +16 -0
- package/node_modules/cpu-features/buildcheck.js +32 -0
- package/node_modules/cpu-features/deps/cpu_features/.clang-format +4 -0
- package/node_modules/cpu-features/deps/cpu_features/.dockerignore +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/Dockerfile +5 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/aarch64_linux_cmake.yml +30 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_freebsd_cmake.yml +22 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_bazel.yml +26 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_linux_cmake.yml +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_macos_cmake.yml +43 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/amd64_windows_cmake.yml +25 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/arm_linux_cmake.yml +31 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/clang_format.yml +24 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/mips_linux_cmake.yml +30 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/power_linux_cmake.yml +29 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/riscv_linux_cmake.yml +28 -0
- package/node_modules/cpu-features/deps/cpu_features/.github/workflows/s390x_linux_cmake.yml +27 -0
- package/node_modules/cpu-features/deps/cpu_features/.grenrc.yml +21 -0
- package/node_modules/cpu-features/deps/cpu_features/BUILD.bazel +329 -0
- package/node_modules/cpu-features/deps/cpu_features/CMakeLists.txt +261 -0
- package/node_modules/cpu-features/deps/cpu_features/CONTRIBUTING.md +23 -0
- package/node_modules/cpu-features/deps/cpu_features/LICENSE +230 -0
- package/node_modules/cpu-features/deps/cpu_features/README.md +272 -0
- package/node_modules/cpu-features/deps/cpu_features/WORKSPACE +19 -0
- package/node_modules/cpu-features/deps/cpu_features/bazel/ci/README.md +5 -0
- package/node_modules/cpu-features/deps/cpu_features/bazel/platforms.bzl +11 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesConfig.cmake.in +3 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/CpuFeaturesNdkCompatConfig.cmake.in +3 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/README.md +30 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/Makefile +252 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/README.md +40 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.dot +64 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/docker.svg +312 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/doc/generate_image.sh +7 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/amd64/Dockerfile +48 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/docker/toolchain/Dockerfile +34 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/CMakeLists.txt +22 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/sample/main.cpp +11 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/ci/vagrant/freebsd/Vagrantfile +107 -0
- package/node_modules/cpu-features/deps/cpu_features/cmake/googletest.CMakeLists.txt.in +15 -0
- package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +105 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_cache_info.h +54 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpu_features_macros.h +384 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_aarch64.h +259 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_arm.h +121 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_mips.h +74 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_ppc.h +149 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_riscv.h +72 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_s390x.h +108 -0
- package/node_modules/cpu-features/deps/cpu_features/include/cpuinfo_x86.h +288 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/bit_utils.h +40 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/cpuid_x86.h +37 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/filesystem.h +39 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/hwcaps.h +240 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/stack_line_reader.h +49 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/string_view.h +110 -0
- package/node_modules/cpu-features/deps/cpu_features/include/internal/windows_utils.h +70 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/CMakeLists.txt +60 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/README.md +4 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.c +205 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/cpu-features.h +320 -0
- package/node_modules/cpu-features/deps/cpu_features/ndk_compat/ndk-compat-test.c +12 -0
- package/node_modules/cpu-features/deps/cpu_features/patches/0001-Add-Apple-Silicon-Support.patch +456 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/generate_badges.d +165 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/make_release.sh +75 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/run_integration.sh +490 -0
- package/node_modules/cpu-features/deps/cpu_features/scripts/test_integration.sh +79 -0
- package/node_modules/cpu-features/deps/cpu_features/src/copy.inl +19 -0
- package/node_modules/cpu-features/deps/cpu_features/src/define_introspection.inl +86 -0
- package/node_modules/cpu-features/deps/cpu_features/src/define_introspection_and_hwcaps.inl +26 -0
- package/node_modules/cpu-features/deps/cpu_features/src/equals.inl +22 -0
- package/node_modules/cpu-features/deps/cpu_features/src/filesystem.c +62 -0
- package/node_modules/cpu-features/deps/cpu_features/src/hwcaps.c +169 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64__base_implementation.inl +88 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_linux_or_android.c +79 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_macos_or_iphone.c +82 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_aarch64_windows.c +138 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_arm_linux_or_android.c +212 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_mips_linux_or_android.c +93 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_ppc_linux.c +163 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_riscv_linux.c +111 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_s390x_linux.c +120 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86__base_implementation.inl +2055 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_freebsd.c +68 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_linux_or_android.c +58 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_macos.c +57 -0
- package/node_modules/cpu-features/deps/cpu_features/src/impl_x86_windows.c +58 -0
- package/node_modules/cpu-features/deps/cpu_features/src/stack_line_reader.c +132 -0
- package/node_modules/cpu-features/deps/cpu_features/src/string_view.c +192 -0
- package/node_modules/cpu-features/deps/cpu_features/src/utils/list_cpu_features.c +461 -0
- package/node_modules/cpu-features/deps/cpu_features/test/CMakeLists.txt +114 -0
- package/node_modules/cpu-features/deps/cpu_features/test/bit_utils_test.cc +53 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_aarch64_test.cc +396 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_arm_test.cc +384 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_mips_test.cc +176 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_ppc_test.cc +131 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_riscv_test.cc +180 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_s390x_test.cc +82 -0
- package/node_modules/cpu-features/deps/cpu_features/test/cpuinfo_x86_test.cc +1729 -0
- package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.cc +103 -0
- package/node_modules/cpu-features/deps/cpu_features/test/filesystem_for_testing.h +61 -0
- package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.cc +52 -0
- package/node_modules/cpu-features/deps/cpu_features/test/hwcaps_for_testing.h +31 -0
- package/node_modules/cpu-features/deps/cpu_features/test/stack_line_reader_test.cc +132 -0
- package/node_modules/cpu-features/deps/cpu_features/test/string_view_test.cc +202 -0
- package/node_modules/cpu-features/lib/index.js +5 -0
- package/node_modules/cpu-features/package.json +40 -0
- package/node_modules/cpu-features/src/binding.cc +151 -0
- package/node_modules/cpu-features/test/test.js +12 -0
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -276,6 +276,7 @@ Deploying to a product profile is a separate, explicit action (`./sync.sh`) for
|
|
|
276
276
|
| `webInstallPrefix` | string | `''` | where an automatic deployment installs dsh; empty means `$HOME/.dsh-remote/dsh` (no system directory, no PATH change) |
|
|
277
277
|
| `webInstallVersion` | string | `0.1.5-rc.2` | dsh version an automatic deployment installs; the default is the first that can start the web surface on Linux |
|
|
278
278
|
| `webInstallRegistry` | string | `''` | npm registry for the install; **empty keeps the remote's own config**, so an internal mirror is never overridden |
|
|
279
|
+
| `localTools` | string | `bootstrap` | which `rw_*` tools a LOCAL session (cwd outside every remote mirror) sees (issue #63): `bootstrap` keeps only the configuration loop `rw_machines`/`rw_connect`/`rw_pick_workspace` (the other 19 refuse a local session with "this session is LOCAL", so exposing them just wastes schema budget); `none` hides all `rw_*` (remote setup happens via the settings page only); `all` restores the legacy full surface. REMOTE sessions (cwd inside a mirror) always see everything; an invalid value degrades to `bootstrap` |
|
|
279
280
|
|
|
280
281
|
> The authoritative list is the `Config` schema in `lib/index.js`; this table mirrors it.
|
|
281
282
|
|
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ DSH 的 Web 界面刻意只监听 `127.0.0.1`(CLI 为安全拒绝 `--host 0.0.
|
|
|
53
53
|
- **Windows 主机** —— 自动探测平台并定位 Git Bash,命令经 `bash -s` 走 stdin 执行,不受引号/反斜杠转义困扰(`config.shell` 可指定或设 `native` 关闭);`C:\Users\dev` 与 `/c/Users/dev` 两种写法都接受。
|
|
54
54
|
- **长任务异步化** —— `rw_sync`/`rw_push` 传 `async: true` 返回 `taskId`,可查询进度/结果/取消。
|
|
55
55
|
- **数据跟随 Harness 根目录** —— 机器清单与镜像在 `$DSH_HOME/remote-workspaces`;0.6 之前的数据首次启动自动迁移。
|
|
56
|
+
- **`~/.ssh/config` 是连接四字段的唯一来源**(`0.8.50+`,issue #50)—— 保存机器时把 主机/用户/端口/私钥 写入 `~/.ssh/config` 的受管块(`# dsh-remote: managed` 标记,只动自己的块;你手写的同名 Host 块绝不覆盖,会提示冲突)。之后**改这个文件立即生效**:任何 Host 块点名的主机(含字面 IP),连接都按文件解析(裸 `Host *` 是通用默认,不算点名);机器记录里的副本只做兜底,插件自己的状态(最近工作区/延迟等)仍存注册表。
|
|
56
57
|
- **不改动 `dsh-workspace` 官方代码** —— 全部作为普通插件实现。
|
|
57
58
|
|
|
58
59
|
## 安装
|
|
@@ -257,6 +258,7 @@ scripts/dev-run.sh --status # 是否在运行
|
|
|
257
258
|
| `webInstallPrefix` | string | `''` | 自动部署装到远端的哪个目录;留空用 `$HOME/.dsh-remote/dsh`(不写系统目录、不改 PATH) |
|
|
258
259
|
| `webInstallVersion` | string | `0.1.5-rc.2` | 自动部署安装的 dsh 版本;默认值是第一个在 Linux 上能启动 web 的版本 |
|
|
259
260
|
| `webInstallRegistry` | string | `''` | 安装用的 npm 源;**留空沿用远端自己的配置**,不会覆盖内网镜像 |
|
|
261
|
+
| `localTools` | string | `bootstrap` | 本地 session(cwd 不在远程镜像里)暴露哪些 `rw_*` 工具(issue #63):`bootstrap`=只暴露配置闭环 `rw_machines`/`rw_connect`/`rw_pick_workspace`(其余 19 个在本地 session 必然报 "this session is LOCAL",暴露只是白占 schema);`none`=完全不暴露 `rw_*`(远程配置只能走设置页);`all`=旧的 full 暴露。远程 session(cwd 在镜像里)不受影响,始终全量;非法值按 `bootstrap` 处理 |
|
|
260
262
|
|
|
261
263
|
> 权威清单是 `lib/index.js` 里的 `Config` schema,本表与之一致。
|
|
262
264
|
|
package/lib/client.js
CHANGED
|
@@ -73,6 +73,7 @@ window.__ModuleLoader__.load({
|
|
|
73
73
|
'settings.sshAliasHint': '别名模式:机器只记住「{alias}」这个名字,主机/用户/端口/私钥/跳板每次连接都从 ~/.ssh/config 实时解析(改配置立刻生效)。',
|
|
74
74
|
'settings.useSshConfig': '使用 ~/.ssh/config 别名(只存别名,不存副本)',
|
|
75
75
|
'settings.useSshConfigHint': '留空或保持默认的字段(用户 root、端口 22、私钥、跳板)将从 ~/.ssh/config 实时解析;填了非默认值则覆盖。',
|
|
76
|
+
'settings.saveWritesSshConfig': '保存时会把 主机/用户/端口/私钥 写入 ~/.ssh/config 的受管块(# dsh-remote: managed 标记);此后该文件优先——直接改它立即生效。',
|
|
76
77
|
'settings.sshResolvedTo': '→ {user}@{host}:{port}',
|
|
77
78
|
'settings.sshResolvedNone': '~/.ssh/config 中没有匹配「{alias}」的 Host 条目',
|
|
78
79
|
'settings.sshResolvedWarn': '注意:{msg}',
|
|
@@ -360,6 +361,7 @@ window.__ModuleLoader__.load({
|
|
|
360
361
|
'settings.sshAliasHint': 'Alias mode: the machine remembers only the name "{alias}"; host/user/port/key/jump host are resolved from ~/.ssh/config at every connect, so editing that file takes effect immediately.',
|
|
361
362
|
'settings.useSshConfig': 'Use a ~/.ssh/config alias (keep the alias, not a copy)',
|
|
362
363
|
'settings.useSshConfigHint': 'Fields left empty or at their default (user root, port 22, key, jump host) come from ~/.ssh/config at connect time; a non-default value overrides it.',
|
|
364
|
+
'settings.saveWritesSshConfig': 'Saving writes host/user/port/key into a managed block in ~/.ssh/config (marked # dsh-remote: managed); the file then takes precedence — edit it directly and it takes effect at once.',
|
|
363
365
|
'settings.sshResolvedTo': '→ {user}@{host}:{port}',
|
|
364
366
|
'settings.sshResolvedNone': 'no ~/.ssh/config block matches "{alias}"',
|
|
365
367
|
'settings.sshResolvedWarn': 'Heads-up: {msg}',
|
|
@@ -1269,9 +1271,12 @@ window.__ModuleLoader__.load({
|
|
|
1269
1271
|
React.createElement('div', { style: { display: 'flex', gap: 6, alignItems: 'center', flexWrap: 'wrap' } },
|
|
1270
1272
|
React.createElement('span', { style: { fontWeight: 600 } }, m.name),
|
|
1271
1273
|
React.createElement('code', { style: { fontSize: 12, opacity: 0.8 } },
|
|
1272
|
-
|
|
1273
|
-
:
|
|
1274
|
-
|
|
1274
|
+
(m.sshConfigResolved && m.sshConfigResolved.matched)
|
|
1275
|
+
// Issue #50: shown for literal machines too — a Host
|
|
1276
|
+
// block naming this machine's host now drives it.
|
|
1277
|
+
? (m.host + ' ' + tr('settings.sshResolvedTo', { user: m.sshConfigResolved.username || m.username || '?', host: m.sshConfigResolved.host, port: m.sshConfigResolved.port || m.port }))
|
|
1278
|
+
: (m.useSshConfig ? m.host : (m.username + '@' + m.host + ':' + m.port))),
|
|
1279
|
+
(m.useSshConfig || (m.sshConfigResolved && m.sshConfigResolved.matched)) ? pill('', tr('settings.badgeSshConfig')) : null,
|
|
1275
1280
|
// Issue #51: a machine on the system-OpenSSH backend behaves
|
|
1276
1281
|
// differently enough (auth from ~/.ssh/config, GSSAPI) that
|
|
1277
1282
|
// the row must say so.
|
|
@@ -1314,6 +1319,9 @@ window.__ModuleLoader__.load({
|
|
|
1314
1319
|
row(tr('settings.host'), React.createElement('input', { className: 'dsh-rw-input', value: form.host, onChange: setF('host'), placeholder: form.useSshConfig ? tr('settings.sshImport') + ' Host 别名' : 'IP or hostname', style: inputS }), 'h'),
|
|
1315
1320
|
row(tr('settings.useSshConfig'), React.createElement('input', { type: 'checkbox', checked: !!form.useSshConfig, onChange: setFb('useSshConfig') }), 'sshc'),
|
|
1316
1321
|
form.useSshConfig ? React.createElement('div', { style: { fontSize: 11, opacity: 0.8, marginBottom: 8, lineHeight: 1.5 } }, tr('settings.useSshConfigHint')) : null,
|
|
1322
|
+
// Issue #50: a literal save also touches ~/.ssh/config (managed
|
|
1323
|
+
// block) — say so where the choice is made.
|
|
1324
|
+
!form.useSshConfig ? React.createElement('div', { style: { fontSize: 11, opacity: 0.8, marginBottom: 8, lineHeight: 1.5 } }, tr('settings.saveWritesSshConfig')) : null,
|
|
1317
1325
|
form.useSshConfig ? (() => {
|
|
1318
1326
|
// Preview where the alias points, from the same resolution the
|
|
1319
1327
|
// connect path uses (the host list carries it — issue #38).
|
package/lib/index.js
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import { createHostKeyGuard, isHostKeyKnown as _isHostKeyKnown } from './hostkey.js'
|
|
35
35
|
import { compileIgnore, ignorePatternsFor, DEFAULT_IGNORE } from './ignore.js'
|
|
36
36
|
import { friendlyMessage } from './errors.js'
|
|
37
|
-
import { importableEntries, sshConfigPath, readSshConfigText, resolveMachineSshConfig } from './sshconfig.js'
|
|
37
|
+
import { importableEntries, sshConfigPath, readSshConfigText, resolveMachineSshConfig, resolveLiteralSshConfig, readRawSshConfig, upsertManagedHostBlock, removeManagedHostBlock, writeSshConfig } from './sshconfig.js'
|
|
38
38
|
import { createRemoteFileReference, installFileReferenceOverlay, DEFAULT_EXCLUDED_DIRECTORIES } from './file-reference.js'
|
|
39
39
|
import { getSecret, deleteSecret, platformBackend, persistPassword } from './credential.js'
|
|
40
40
|
import { syncTree, pushTree, loadSyncState, saveSyncState, pushOneFile } from './sync.js'
|
|
@@ -99,6 +99,35 @@ export function win32FolderPickScript() {
|
|
|
99
99
|
)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
/** The rw_* tools a LOCAL session keeps under `localTools: 'bootstrap'`
|
|
103
|
+
* (issue #63): exactly the configuration loop — list machines, connect, pick
|
|
104
|
+
* a workspace. Every other rw_* tool needs a mirror-bound session and refuses
|
|
105
|
+
* a local one with "this session is LOCAL", so keeping it visible only spends
|
|
106
|
+
* schema budget. Exported so the test suite pins the set against the real
|
|
107
|
+
* registrations. */
|
|
108
|
+
export const LOCAL_BOOTSTRAP_TOOLS = ['rw_machines', 'rw_connect', 'rw_pick_workspace']
|
|
109
|
+
|
|
110
|
+
/** Normalize the `localTools` config value (issue #63). Anything unrecognized
|
|
111
|
+
* degrades to the safe default 'bootstrap' rather than disabling the filter
|
|
112
|
+
* (a typo must not silently re-expose the dead surface the user asked to
|
|
113
|
+
* hide) — mirroring how an unknown value would otherwise be mistaken for
|
|
114
|
+
* 'all'. */
|
|
115
|
+
export function normalizeLocalTools(value) {
|
|
116
|
+
const v = String(value || '').trim().toLowerCase()
|
|
117
|
+
return v === 'none' || v === 'all' ? v : 'bootstrap'
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** rw_pick_workspace's closing "what next" sentence (issue #63). In a LOCAL
|
|
121
|
+
* session `rw_sync` cannot run — the mirror path must be opened as a NEW
|
|
122
|
+
* session first, because tool routing keys on the session's cwd and picking
|
|
123
|
+
* a workspace does not change it. Only a mirror-bound (or caller-context-
|
|
124
|
+
* less) session can sync right away. */
|
|
125
|
+
export function pickWorkspaceNextStep(localSession) {
|
|
126
|
+
return localSession
|
|
127
|
+
? 'NOTE: this session is LOCAL — rw_sync and the other remote tools refuse to run here. Open a session whose workspace IS the local mirror path above, then run rw_sync there to download the remote files.'
|
|
128
|
+
: 'Run rw_sync to download its files into the local mirror.'
|
|
129
|
+
}
|
|
130
|
+
|
|
102
131
|
// Web and Desktop share the SSH tools; each optional UI transport is attached
|
|
103
132
|
// reactively below, so service startup order does not drop the JSON routes.
|
|
104
133
|
export const inject = ['tools', 'systemPrompt']
|
|
@@ -235,6 +264,16 @@ export const Config = z.object({
|
|
|
235
264
|
/** npm registry to install from. Empty uses the remote's own npm config, which
|
|
236
265
|
* is what an internal mirror needs to stay in effect. */
|
|
237
266
|
webInstallRegistry: z.string().default(''),
|
|
267
|
+
/** Which rw_* tools a LOCAL session (session cwd is NOT a remote-workspaces
|
|
268
|
+
* mirror) sees (issue #63): `bootstrap` (default) exposes only the
|
|
269
|
+
* configuration loop — rw_machines / rw_connect / rw_pick_workspace — since
|
|
270
|
+
* the other tools can never succeed there (they refuse with "this session
|
|
271
|
+
* is LOCAL") and exposing them only spends ~4k tokens of schema per request;
|
|
272
|
+
* `none` hides every rw_* tool (remote setup then happens via the settings
|
|
273
|
+
* page only); `all` keeps the legacy full surface. A REMOTE session (cwd
|
|
274
|
+
* inside a mirror) always sees all tools, and an invalid value falls back
|
|
275
|
+
* to `bootstrap`. (schemastery 3.18 has no .enum — validated in code.) */
|
|
276
|
+
localTools: z.string().default('bootstrap'),
|
|
238
277
|
})
|
|
239
278
|
|
|
240
279
|
// ── shell / path helpers (pure implementations in lib/paths.js) ───────────
|
|
@@ -431,25 +470,49 @@ export async function apply(ctx, config) {
|
|
|
431
470
|
* keychain lookups and the settings UI keep working.
|
|
432
471
|
*/
|
|
433
472
|
const loggedSshWarnings = new Map()
|
|
434
|
-
const
|
|
435
|
-
//
|
|
436
|
-
//
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
// Warn once per distinct warning set: this runs on every tool call, and an
|
|
442
|
-
// unmatched alias would otherwise fill the log with the same line.
|
|
443
|
-
const signature = resolved.warnings.join(' | ')
|
|
444
|
-
if (signature && loggedSshWarnings.get(resolved.alias) !== signature) {
|
|
445
|
-
loggedSshWarnings.set(resolved.alias, signature)
|
|
473
|
+
const warnSshOnce = (alias, warnings) => {
|
|
474
|
+
// Warn once per distinct warning set: withSshConfig runs on every tool
|
|
475
|
+
// call, and an unmatched alias would otherwise fill the log with the same
|
|
476
|
+
// line.
|
|
477
|
+
const signature = warnings.join(' | ')
|
|
478
|
+
if (signature && loggedSshWarnings.get(alias) !== signature) {
|
|
479
|
+
loggedSshWarnings.set(alias, signature)
|
|
446
480
|
try {
|
|
447
481
|
const logger = typeof ctx.get === 'function' ? ctx.get('logger') : undefined
|
|
448
482
|
if (logger && typeof logger.warn === 'function') {
|
|
449
|
-
logger.warn(`[dsh-remote] ssh-config alias "${
|
|
483
|
+
logger.warn(`[dsh-remote] ssh-config alias "${alias}": ${warnings.join(' ')}`)
|
|
450
484
|
}
|
|
451
485
|
} catch { /* logging is best-effort */ }
|
|
452
486
|
}
|
|
487
|
+
}
|
|
488
|
+
const withSshConfig = (m) => {
|
|
489
|
+
if (!m) return m
|
|
490
|
+
// Issue #50: ~/.ssh/config wins for ANY host it names, not only alias
|
|
491
|
+
// machines. A literal machine's stored host/user/port/key is a COPY that
|
|
492
|
+
// goes stale the moment the file is edited; when a Host block names the
|
|
493
|
+
// machine's host (a bare `Host *` does not name it), the file's values
|
|
494
|
+
// take over and the record fills the gaps.
|
|
495
|
+
if (!m.useSshConfig) {
|
|
496
|
+
const lit = resolveLiteralSshConfig(m, { text: sshConfigText() })
|
|
497
|
+
if (!lit) return m
|
|
498
|
+
warnSshOnce(lit.alias, lit.warnings)
|
|
499
|
+
return {
|
|
500
|
+
...m,
|
|
501
|
+
sshConfigMatched: true,
|
|
502
|
+
sshConfigWarnings: lit.warnings,
|
|
503
|
+
// The name the user typed, kept for the system-OpenSSH backend: ssh
|
|
504
|
+
// must match its Host blocks against exactly this (connectTargetFor).
|
|
505
|
+
sshConfigName: m.host,
|
|
506
|
+
host: lit.host || m.host,
|
|
507
|
+
port: lit.port || m.port,
|
|
508
|
+
username: lit.username || m.username,
|
|
509
|
+
privateKeyPath: lit.privateKeyPath || m.privateKeyPath,
|
|
510
|
+
proxy: lit.proxy || m.proxy,
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
const resolved = resolveMachineSshConfig(m, { text: sshConfigText() })
|
|
514
|
+
if (!resolved) return m
|
|
515
|
+
warnSshOnce(resolved.alias, resolved.warnings)
|
|
453
516
|
return {
|
|
454
517
|
...m,
|
|
455
518
|
sshAlias: resolved.alias,
|
|
@@ -483,7 +546,10 @@ export async function apply(ctx, config) {
|
|
|
483
546
|
* @returns {{host: string, port: number, username: string, privateKeyPath: string, proxy: object|undefined, aliasNative: boolean}}
|
|
484
547
|
*/
|
|
485
548
|
const connectTargetFor = (eff) => {
|
|
486
|
-
|
|
549
|
+
// Issue #50: a LITERAL machine whose host a Host block names is in the same
|
|
550
|
+
// position as an alias machine on the OpenSSH backend — ssh must match its
|
|
551
|
+
// blocks against the ORIGINAL name, so it is handed over verbatim too.
|
|
552
|
+
const aliasNative = !!(eff && isSystemOpenSshBackend(eff) && (eff.useSshConfig || eff.sshConfigMatched))
|
|
487
553
|
if (!aliasNative) {
|
|
488
554
|
return {
|
|
489
555
|
host: String((eff && eff.host) || ''),
|
|
@@ -494,7 +560,7 @@ export async function apply(ctx, config) {
|
|
|
494
560
|
aliasNative: false,
|
|
495
561
|
}
|
|
496
562
|
}
|
|
497
|
-
const alias = String((eff && (eff.sshAlias || eff.host)) || '')
|
|
563
|
+
const alias = String((eff && (eff.sshAlias || eff.sshConfigName || eff.host)) || '')
|
|
498
564
|
return {
|
|
499
565
|
// The alias itself; ssh expands HostName/User/Port/IdentityFile and every
|
|
500
566
|
// other directive while matching that Host block.
|
|
@@ -511,13 +577,14 @@ export async function apply(ctx, config) {
|
|
|
511
577
|
const aliasOf = (m) => (m && m.sshAlias) || (m && m.useSshConfig ? String(m.host || '') : '')
|
|
512
578
|
|
|
513
579
|
/** Machines as the settings UI sees them: secrets stripped, plus the
|
|
514
|
-
* ~/.ssh/config resolution of an alias machine
|
|
515
|
-
*
|
|
516
|
-
*
|
|
580
|
+
* ~/.ssh/config resolution of an alias machine (issue #38) — and, since
|
|
581
|
+
* issue #50, of a LITERAL machine whose host a Host block names, so the row
|
|
582
|
+
* can show that the file now drives it. */
|
|
517
583
|
const machinesForClient = () => machines.map((m) => ({
|
|
518
584
|
...sanitizeMachine(m),
|
|
519
|
-
|
|
520
|
-
|
|
585
|
+
sshConfigResolved: m.useSshConfig
|
|
586
|
+
? resolveMachineSshConfig(m, { text: sshConfigText() })
|
|
587
|
+
: resolveLiteralSshConfig(m, { text: sshConfigText() }),
|
|
521
588
|
}))
|
|
522
589
|
|
|
523
590
|
/**
|
|
@@ -1758,8 +1825,11 @@ export async function apply(ctx, config) {
|
|
|
1758
1825
|
if (!b.bound) persistWorkspace(p)
|
|
1759
1826
|
const local = ensureMirror(p, b.host, b.username, b.port, { alias: b.alias || "" })
|
|
1760
1827
|
startAutoPush(local)
|
|
1828
|
+
// The closing hint depends on where THIS session stands (issue #63):
|
|
1829
|
+
// in a LOCAL session "Run rw_sync" is a dead instruction — rw_sync
|
|
1830
|
+
// refuses a local session — so say the mirror must be OPENED first.
|
|
1761
1831
|
return {
|
|
1762
|
-
text: `Remote workspace set to ${shown} on ${b.username}@${b.host}.\nLocal mirror (native workspace path): ${local}\n\
|
|
1832
|
+
text: `Remote workspace set to ${shown} on ${b.username}@${b.host}.\nLocal mirror (native workspace path): ${local}\n\n${pickWorkspaceNextStep(b.local)}`,
|
|
1763
1833
|
}
|
|
1764
1834
|
},
|
|
1765
1835
|
}),
|
|
@@ -2507,6 +2577,39 @@ export async function apply(ctx, config) {
|
|
|
2507
2577
|
},
|
|
2508
2578
|
})
|
|
2509
2579
|
|
|
2580
|
+
// ── local-session tool visibility (issue #63) ────────────────────────────
|
|
2581
|
+
// All rw_* tools register globally (at registration time there is no session
|
|
2582
|
+
// to consult), but in a LOCAL session the operation tools can never succeed:
|
|
2583
|
+
// bindingFor() refuses them with "this session is LOCAL". Exposing them
|
|
2584
|
+
// anyway costs every local request a few thousand tokens of dead schema.
|
|
2585
|
+
// The `system-prompt/assemble` waterfall is where the final per-request tool
|
|
2586
|
+
// list passes with the calling agent attached, so the SAME cwd test the
|
|
2587
|
+
// prompt section above already performs can trim the list there. A session
|
|
2588
|
+
// whose cwd maps to a mirror keeps the full surface; anything else — a
|
|
2589
|
+
// plain local directory, or a mirror whose meta is missing/unparsable
|
|
2590
|
+
// (resolveMirror reports no binding; bindingFor refuses it as local too) —
|
|
2591
|
+
// is reduced per config.localTools. An assembly without agent/cwd is left
|
|
2592
|
+
// alone, matching bindingFor's "no caller context" semantics. `ctx.on` is
|
|
2593
|
+
// cordis-core, but guard like the other
|
|
2594
|
+
// optional surfaces: a minimal embedding (or a small test double) without
|
|
2595
|
+
// event support simply keeps the legacy full surface.
|
|
2596
|
+
if (typeof ctx.on === 'function') {
|
|
2597
|
+
ctx.on('system-prompt/assemble', async (_assembly, assembleContext, next) => {
|
|
2598
|
+
const assembled = await next()
|
|
2599
|
+
const mode = normalizeLocalTools(config.localTools)
|
|
2600
|
+
if (mode === 'all') return assembled
|
|
2601
|
+
const agent = assembleContext && assembleContext.agent
|
|
2602
|
+
const cwd = agent && agent.session && agent.session.header && agent.session.header.cwd
|
|
2603
|
+
if (!cwd) return assembled // no caller context → not definitively local
|
|
2604
|
+
const { remotePath, machine } = resolveMirrorForLocal(String(cwd))
|
|
2605
|
+
if (remotePath && machine) return assembled // remote session → full surface
|
|
2606
|
+
const tools = (assembled.tools || []).filter(
|
|
2607
|
+
(t) => !t.name || !t.name.startsWith('rw_') || (mode === 'bootstrap' && LOCAL_BOOTSTRAP_TOOLS.includes(t.name)),
|
|
2608
|
+
)
|
|
2609
|
+
return { ...assembled, tools }
|
|
2610
|
+
})
|
|
2611
|
+
}
|
|
2612
|
+
|
|
2510
2613
|
// ── slash commands ─────────────────────────────────────────────────────────
|
|
2511
2614
|
const commands = ctx.get('commands')
|
|
2512
2615
|
if (commands !== undefined) {
|
|
@@ -3090,12 +3193,49 @@ export async function apply(ctx, config) {
|
|
|
3090
3193
|
// alone, so a fresh registry stays "no choice yet" (not an
|
|
3091
3194
|
// explicit none) and a previously-cleared registry stays cleared.
|
|
3092
3195
|
saveMachines(machines, store.currentId, false)
|
|
3196
|
+
// Issue #50: host/user/port/key have ONE home — ~/.ssh/config.
|
|
3197
|
+
// Saving a literal machine upserts a marker-tagged Host block,
|
|
3198
|
+
// so the file and the registry can never drift; the record's
|
|
3199
|
+
// copy remains only as a fallback for a missing/renamed block.
|
|
3200
|
+
// A Host block the USER wrote for the same name is never
|
|
3201
|
+
// touched — the conflict is reported instead. Failures here are
|
|
3202
|
+
// best-effort: the registry copy is already saved.
|
|
3203
|
+
let sshConfigWarning = ''
|
|
3204
|
+
if (!rec.useSshConfig) {
|
|
3205
|
+
try {
|
|
3206
|
+
const raw = readRawSshConfig(sshConfigPath())
|
|
3207
|
+
let next = upsertManagedHostBlock(raw, {
|
|
3208
|
+
alias: rec.host,
|
|
3209
|
+
hostName: rec.host,
|
|
3210
|
+
user: rec.username,
|
|
3211
|
+
port: rec.port,
|
|
3212
|
+
identityFile: rec.privateKeyPath,
|
|
3213
|
+
})
|
|
3214
|
+
// A RENAMED machine leaves the old managed block behind, and
|
|
3215
|
+
// that block is the plugin's own artifact of the edit —
|
|
3216
|
+
// retire it. (Deleting a machine removes nothing: the Host
|
|
3217
|
+
// block is the user's ssh access, not plugin state.)
|
|
3218
|
+
if (prev && prev.host && prev.host !== rec.host && !prev.useSshConfig) {
|
|
3219
|
+
const rm = removeManagedHostBlock(next.text, prev.host)
|
|
3220
|
+
next = { status: rm.status === 'removed' && next.status === 'unchanged' ? 'updated' : next.status, text: rm.text }
|
|
3221
|
+
}
|
|
3222
|
+
if (next.status === 'conflict') {
|
|
3223
|
+
sshConfigWarning = `~/.ssh/config already names "${rec.host}" in a Host block that is not managed by dsh-remote — it was left untouched, and it now wins over the saved copy.`
|
|
3224
|
+
} else if (next.status === 'appended' || next.status === 'updated') {
|
|
3225
|
+
writeSshConfig(next.text, sshConfigPath())
|
|
3226
|
+
sshConfigCache = { text: '', at: 0 }
|
|
3227
|
+
}
|
|
3228
|
+
} catch (sshErr) {
|
|
3229
|
+
sshConfigWarning = `could not update ~/.ssh/config (${String((sshErr && sshErr.message) || sshErr)}); the registry copy was saved.`
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3093
3232
|
return sendJson(res, 200, {
|
|
3094
3233
|
ok: true,
|
|
3095
3234
|
machine: sanitizeMachine(rec),
|
|
3096
3235
|
machines: machinesForClient(),
|
|
3097
3236
|
currentId: store.currentId,
|
|
3098
3237
|
...(warning ? { warning, warningDetail } : {}),
|
|
3238
|
+
...(sshConfigWarning ? { sshConfigWarning } : {}),
|
|
3099
3239
|
})
|
|
3100
3240
|
}
|
|
3101
3241
|
if (action === 'delete') {
|
|
@@ -3154,6 +3294,12 @@ export async function apply(ctx, config) {
|
|
|
3154
3294
|
useSshConfig: true,
|
|
3155
3295
|
}, { text: sshConfigText() })
|
|
3156
3296
|
: null
|
|
3297
|
+
// Issue #50: a LITERAL host named by a Host block resolves through
|
|
3298
|
+
// the file as well — the probe must dial what a real connect would.
|
|
3299
|
+
const literalTarget = !body.useSshConfig
|
|
3300
|
+
? resolveLiteralSshConfig({ host: String(body.host || '') }, { text: sshConfigText() })
|
|
3301
|
+
: null
|
|
3302
|
+
const probeTarget = aliasTarget || literalTarget
|
|
3157
3303
|
// Issue #51: on the system-OpenSSH backend an alias is handed to `ssh`
|
|
3158
3304
|
// VERBATIM (see connectTargetFor) — resolving it here would stop the
|
|
3159
3305
|
// `Host` block from matching, so the ~/.ssh/config settings the probe
|
|
@@ -3161,13 +3307,13 @@ export async function apply(ctx, config) {
|
|
|
3161
3307
|
const probe = createPool({
|
|
3162
3308
|
...config,
|
|
3163
3309
|
backend: probeBackend,
|
|
3164
|
-
host:
|
|
3165
|
-
port:
|
|
3166
|
-
username:
|
|
3310
|
+
host: probeTarget && !probeIsOpenssh ? probeTarget.host : String(body.host || config.host),
|
|
3311
|
+
port: (probeTarget && !probeIsOpenssh && probeTarget.port) ? probeTarget.port : (Number(body.port) || config.port),
|
|
3312
|
+
username: (probeTarget && !probeIsOpenssh && probeTarget.username) ? probeTarget.username : String(body.username || config.username),
|
|
3167
3313
|
password: String(body.password || ''),
|
|
3168
|
-
privateKeyPath: (
|
|
3314
|
+
privateKeyPath: (probeTarget && !probeIsOpenssh && probeTarget.privateKeyPath) ? probeTarget.privateKeyPath : String(body.privateKeyPath || config.privateKeyPath),
|
|
3169
3315
|
passphrase: String(body.passphrase || ''),
|
|
3170
|
-
proxy: (
|
|
3316
|
+
proxy: (probeTarget && !probeIsOpenssh && probeTarget.proxy) ? probeTarget.proxy : (body.proxy && body.proxy.host ? {
|
|
3171
3317
|
host: String(body.proxy.host),
|
|
3172
3318
|
port: Number(body.proxy.port) || 22,
|
|
3173
3319
|
username: String(body.proxy.username || ''),
|