dsh-over-ssh 0.1.0 → 0.1.1

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.
Files changed (247) hide show
  1. package/README.md +10 -10
  2. package/agents/agent-manifest.json +1 -1
  3. package/lib/client.js +363 -314
  4. package/lib/file-references.js +80 -35
  5. package/lib/fs.js +158 -75
  6. package/lib/index.js +4103 -3397
  7. package/lib/terminal-wrapper.js +9 -4
  8. package/lib/types/src/config.d.ts +80 -9
  9. package/lib/types/src/file-references.d.ts +0 -1
  10. package/lib/types/src/host/app/backend.d.ts +9 -1
  11. package/lib/types/src/host/app/recycle-bin/recycle-bin-contract.d.ts +0 -1
  12. package/lib/types/src/host/app/recycle-bin/recycle-bin-service.d.ts +0 -1
  13. package/lib/types/src/host/app/session-admin/session-admin-contract.d.ts +12 -1
  14. package/lib/types/src/host/app/session-admin/session-admin-service.d.ts +0 -1
  15. package/lib/types/src/host/app/transport/transport-selector.d.ts +0 -1
  16. package/lib/types/src/host/app/transport/transport-service.d.ts +0 -1
  17. package/lib/types/src/host/domain/capability.d.ts +0 -1
  18. package/lib/types/src/host/domain/errors.d.ts +0 -1
  19. package/lib/types/src/host/domain/roots/connection.d.ts +0 -1
  20. package/lib/types/src/host/domain/roots/root.d.ts +24 -9
  21. package/lib/types/src/host/domain/roots/session-roots.d.ts +0 -1
  22. package/lib/types/src/host/domain/roots/ssh-config.d.ts +0 -1
  23. package/lib/types/src/host/domain/session/session-admin.d.ts +0 -1
  24. package/lib/types/src/host/domain/transfer/recycle-bin.d.ts +0 -1
  25. package/lib/types/src/host/domain/transfer/transfer.d.ts +0 -1
  26. package/lib/types/src/host/infra/transport/agent/agent-installer.d.ts +0 -1
  27. package/lib/types/src/host/infra/transport/ssh/ssh2-transport.d.ts +0 -1
  28. package/lib/types/src/host/infra/transport/transport-base.d.ts +0 -1
  29. package/lib/types/src/host/infra/transport/transport.d.ts +16 -2
  30. package/lib/types/src/host/integration/agent/agent-preflight.d.ts +0 -1
  31. package/lib/types/src/host/integration/fs/file-reference-provider.d.ts +0 -1
  32. package/lib/types/src/host/integration/fs/fs-provider.d.ts +0 -2
  33. package/lib/types/src/host/integration/transfer/transfer-service.d.ts +0 -1
  34. package/lib/types/src/index.d.ts +23 -1
  35. package/lib/types/src/local-bridge-refs.d.ts +0 -1
  36. package/lib/types/src/local-bridge.d.ts +0 -1
  37. package/lib/types/src/shared/root-keys.d.ts +120 -0
  38. package/lib/types/src/wiring/helpers.d.ts +0 -1
  39. package/package.json +5 -3
  40. package/lib/types/src/client/controls.d.ts +0 -131
  41. package/lib/types/src/client/core/card-focus-trap.d.ts +0 -45
  42. package/lib/types/src/client/core/controls.d.ts +0 -164
  43. package/lib/types/src/client/core/latest.d.ts +0 -48
  44. package/lib/types/src/client/core/locale.d.ts +0 -38
  45. package/lib/types/src/client/core/message.d.ts +0 -37
  46. package/lib/types/src/client/core/panel-model.d.ts +0 -134
  47. package/lib/types/src/client/core/portal.d.ts +0 -266
  48. package/lib/types/src/client/core/remote.d.ts +0 -84
  49. package/lib/types/src/client/core/styles.d.ts +0 -458
  50. package/lib/types/src/client/file-tree-io.d.ts +0 -19
  51. package/lib/types/src/client/file-tree.d.ts +0 -271
  52. package/lib/types/src/client/flows/directory-browser.d.ts +0 -587
  53. package/lib/types/src/client/flows/session-directory.d.ts +0 -415
  54. package/lib/types/src/client/flows/workspace-directory-flow.d.ts +0 -480
  55. package/lib/types/src/client/locale.d.ts +0 -31
  56. package/lib/types/src/client/panel-model.d.ts +0 -37
  57. package/lib/types/src/client/panel.d.ts +0 -77
  58. package/lib/types/src/client/roots/connection-test.d.ts +0 -69
  59. package/lib/types/src/client/roots/roots-panel-state.d.ts +0 -307
  60. package/lib/types/src/client/roots/roots-panel-view.d.ts +0 -280
  61. package/lib/types/src/client/roots/roots-panel.d.ts +0 -364
  62. package/lib/types/src/client/roots/transfer-panel-view.d.ts +0 -35
  63. package/lib/types/src/client/roots/transfer-panel.d.ts +0 -241
  64. package/lib/types/src/client/roots/transfer-progress.d.ts +0 -67
  65. package/lib/types/src/client/roots-panel-view.d.ts +0 -236
  66. package/lib/types/src/client/roots-panel.d.ts +0 -347
  67. package/lib/types/src/client/session/session-panel-view.d.ts +0 -336
  68. package/lib/types/src/client/session/session-panel.d.ts +0 -322
  69. package/lib/types/src/client/session/session-remote-mark.d.ts +0 -110
  70. package/lib/types/src/client/session/session-row-actions.d.ts +0 -398
  71. package/lib/types/src/client/session-panel.d.ts +0 -152
  72. package/lib/types/src/client/styles.d.ts +0 -252
  73. package/lib/types/src/client/workspace-directory-flow.d.ts +0 -342
  74. package/lib/types/src/fs.d.ts +0 -46
  75. package/lib/types/src/host/app/recycle-bin/recycle-bin-move.d.ts +0 -18
  76. package/lib/types/src/host/app/recycle-bin/recycle-bin-world.d.ts +0 -38
  77. package/lib/types/src/host/app/recycle-bin-contract.d.ts +0 -215
  78. package/lib/types/src/host/app/recycle-bin-move.d.ts +0 -18
  79. package/lib/types/src/host/app/recycle-bin-service.d.ts +0 -45
  80. package/lib/types/src/host/app/recycle-bin-world.d.ts +0 -35
  81. package/lib/types/src/host/app/roots/roots-api-connections.d.ts +0 -49
  82. package/lib/types/src/host/app/roots/roots-api-contract.d.ts +0 -369
  83. package/lib/types/src/host/app/roots/roots-api-directories.d.ts +0 -13
  84. package/lib/types/src/host/app/roots/roots-api-http.d.ts +0 -77
  85. package/lib/types/src/host/app/roots/roots-api-long-poll.d.ts +0 -130
  86. package/lib/types/src/host/app/roots/roots-api-projections.d.ts +0 -102
  87. package/lib/types/src/host/app/roots/roots-api-roots.d.ts +0 -13
  88. package/lib/types/src/host/app/roots/roots-api-state.d.ts +0 -22
  89. package/lib/types/src/host/app/roots/roots-api-transfers.d.ts +0 -26
  90. package/lib/types/src/host/app/roots/roots-api.d.ts +0 -55
  91. package/lib/types/src/host/app/roots/user-roots.d.ts +0 -552
  92. package/lib/types/src/host/app/roots-api-connections.d.ts +0 -49
  93. package/lib/types/src/host/app/roots-api-contract.d.ts +0 -339
  94. package/lib/types/src/host/app/roots-api-directories.d.ts +0 -13
  95. package/lib/types/src/host/app/roots-api-http.d.ts +0 -77
  96. package/lib/types/src/host/app/roots-api-projections.d.ts +0 -102
  97. package/lib/types/src/host/app/roots-api-roots.d.ts +0 -13
  98. package/lib/types/src/host/app/roots-api-state.d.ts +0 -22
  99. package/lib/types/src/host/app/roots-api-support.d.ts +0 -182
  100. package/lib/types/src/host/app/roots-api-transfers.d.ts +0 -13
  101. package/lib/types/src/host/app/roots-api.d.ts +0 -55
  102. package/lib/types/src/host/app/routed-fs.d.ts +0 -239
  103. package/lib/types/src/host/app/serialize.d.ts +0 -37
  104. package/lib/types/src/host/app/session-admin/session-admin-context.d.ts +0 -36
  105. package/lib/types/src/host/app/session-admin/session-admin-delete.d.ts +0 -34
  106. package/lib/types/src/host/app/session-admin-context.d.ts +0 -36
  107. package/lib/types/src/host/app/session-admin-contract.d.ts +0 -214
  108. package/lib/types/src/host/app/session-admin-delete.d.ts +0 -34
  109. package/lib/types/src/host/app/session-admin-service.d.ts +0 -38
  110. package/lib/types/src/host/app/takeover/takeover-plan.d.ts +0 -227
  111. package/lib/types/src/host/app/takeover/takeover-rows.d.ts +0 -55
  112. package/lib/types/src/host/app/transport-selector.d.ts +0 -98
  113. package/lib/types/src/host/app/transport-service.d.ts +0 -75
  114. package/lib/types/src/host/app/user-roots.d.ts +0 -461
  115. package/lib/types/src/host/domain/bin-location.d.ts +0 -79
  116. package/lib/types/src/host/domain/connection.d.ts +0 -95
  117. package/lib/types/src/host/domain/glob-pattern.d.ts +0 -62
  118. package/lib/types/src/host/domain/literal-text.d.ts +0 -63
  119. package/lib/types/src/host/domain/path-grammar.d.ts +0 -84
  120. package/lib/types/src/host/domain/recycle-bin.d.ts +0 -337
  121. package/lib/types/src/host/domain/root.d.ts +0 -74
  122. package/lib/types/src/host/domain/roots/bin-location.d.ts +0 -91
  123. package/lib/types/src/host/domain/roots/route-table.d.ts +0 -102
  124. package/lib/types/src/host/domain/route-table.d.ts +0 -80
  125. package/lib/types/src/host/domain/session/terminal-target.d.ts +0 -136
  126. package/lib/types/src/host/domain/session-admin.d.ts +0 -330
  127. package/lib/types/src/host/domain/shell.d.ts +0 -47
  128. package/lib/types/src/host/domain/ssh-config.d.ts +0 -73
  129. package/lib/types/src/host/domain/terminal-target.d.ts +0 -132
  130. package/lib/types/src/host/domain/tool-requests.d.ts +0 -369
  131. package/lib/types/src/host/domain/transfer.d.ts +0 -260
  132. package/lib/types/src/host/infra/backend/local-backend.d.ts +0 -84
  133. package/lib/types/src/host/infra/backend/local-version.d.ts +0 -43
  134. package/lib/types/src/host/infra/backend/platform-local-backend.d.ts +0 -89
  135. package/lib/types/src/host/infra/backend/remote-backend.d.ts +0 -239
  136. package/lib/types/src/host/infra/cache/lru.d.ts +0 -52
  137. package/lib/types/src/host/infra/cache/versioned.d.ts +0 -77
  138. package/lib/types/src/host/infra/temp-name.d.ts +0 -19
  139. package/lib/types/src/host/infra/transport/agent/agent-protocol-client.d.ts +0 -132
  140. package/lib/types/src/host/infra/transport/agent/agent-protocol-codec.d.ts +0 -140
  141. package/lib/types/src/host/infra/transport/agent/agent-protocol-errors.d.ts +0 -41
  142. package/lib/types/src/host/infra/transport/agent/agent-protocol-frames.d.ts +0 -197
  143. package/lib/types/src/host/infra/transport/agent/agent-protocol-types.d.ts +0 -564
  144. package/lib/types/src/host/infra/transport/agent/agent-transport.d.ts +0 -418
  145. package/lib/types/src/host/infra/transport/agent-installer.d.ts +0 -121
  146. package/lib/types/src/host/infra/transport/agent-protocol-client.d.ts +0 -123
  147. package/lib/types/src/host/infra/transport/agent-protocol-codec.d.ts +0 -131
  148. package/lib/types/src/host/infra/transport/agent-protocol-errors.d.ts +0 -41
  149. package/lib/types/src/host/infra/transport/agent-protocol-frames.d.ts +0 -197
  150. package/lib/types/src/host/infra/transport/agent-protocol-types.d.ts +0 -509
  151. package/lib/types/src/host/infra/transport/agent-transport.d.ts +0 -353
  152. package/lib/types/src/host/infra/transport/alias-transport.d.ts +0 -206
  153. package/lib/types/src/host/infra/transport/askpass-fs.d.ts +0 -20
  154. package/lib/types/src/host/infra/transport/askpass.d.ts +0 -133
  155. package/lib/types/src/host/infra/transport/command-pool.d.ts +0 -61
  156. package/lib/types/src/host/infra/transport/fs-commands.d.ts +0 -140
  157. package/lib/types/src/host/infra/transport/git-status-route.d.ts +0 -63
  158. package/lib/types/src/host/infra/transport/git-status.d.ts +0 -101
  159. package/lib/types/src/host/infra/transport/node-spawn.d.ts +0 -26
  160. package/lib/types/src/host/infra/transport/session-window.d.ts +0 -51
  161. package/lib/types/src/host/infra/transport/shell-quote.d.ts +0 -59
  162. package/lib/types/src/host/infra/transport/ssh/alias-transport.d.ts +0 -206
  163. package/lib/types/src/host/infra/transport/ssh/askpass-fs.d.ts +0 -20
  164. package/lib/types/src/host/infra/transport/ssh/askpass.d.ts +0 -133
  165. package/lib/types/src/host/infra/transport/ssh/shell-quote.d.ts +0 -62
  166. package/lib/types/src/host/infra/transport/ssh/ssh-argv.d.ts +0 -43
  167. package/lib/types/src/host/infra/transport/ssh-argv.d.ts +0 -43
  168. package/lib/types/src/host/infra/transport/ssh2-transport.d.ts +0 -302
  169. package/lib/types/src/host/integration/agent/agent-install-io.d.ts +0 -33
  170. package/lib/types/src/host/integration/agent/askpass-registry.d.ts +0 -66
  171. package/lib/types/src/host/integration/agent-install-io.d.ts +0 -33
  172. package/lib/types/src/host/integration/agent-preflight.d.ts +0 -56
  173. package/lib/types/src/host/integration/anchor-directory.d.ts +0 -56
  174. package/lib/types/src/host/integration/askpass-registry.d.ts +0 -59
  175. package/lib/types/src/host/integration/bin-root-resolver.d.ts +0 -81
  176. package/lib/types/src/host/integration/connection-test.d.ts +0 -73
  177. package/lib/types/src/host/integration/file-reference-provider.d.ts +0 -115
  178. package/lib/types/src/host/integration/fs/git-status-wiring.d.ts +0 -21
  179. package/lib/types/src/host/integration/fs/platform-errors.d.ts +0 -94
  180. package/lib/types/src/host/integration/fs/remote-file-tools.d.ts +0 -369
  181. package/lib/types/src/host/integration/fs/remote-index.d.ts +0 -177
  182. package/lib/types/src/host/integration/fs-provider.d.ts +0 -226
  183. package/lib/types/src/host/integration/lsp/lsp-framing.d.ts +0 -38
  184. package/lib/types/src/host/integration/lsp/lsp-registry.d.ts +0 -67
  185. package/lib/types/src/host/integration/lsp/lsp-session.d.ts +0 -130
  186. package/lib/types/src/host/integration/management-tools.d.ts +0 -64
  187. package/lib/types/src/host/integration/recycle-bin-service.d.ts +0 -247
  188. package/lib/types/src/host/integration/remote/connection-test.d.ts +0 -73
  189. package/lib/types/src/host/integration/remote/remote-face.d.ts +0 -127
  190. package/lib/types/src/host/integration/remote/remote-tool-backend.d.ts +0 -108
  191. package/lib/types/src/host/integration/remote-face.d.ts +0 -127
  192. package/lib/types/src/host/integration/remote-file-tools.d.ts +0 -241
  193. package/lib/types/src/host/integration/remote-home.d.ts +0 -69
  194. package/lib/types/src/host/integration/remote-index.d.ts +0 -165
  195. package/lib/types/src/host/integration/remote-job-tools.d.ts +0 -295
  196. package/lib/types/src/host/integration/remote-tool-backend.d.ts +0 -97
  197. package/lib/types/src/host/integration/remote-tools.d.ts +0 -206
  198. package/lib/types/src/host/integration/root-registry.d.ts +0 -115
  199. package/lib/types/src/host/integration/roots/anchor-directory.d.ts +0 -56
  200. package/lib/types/src/host/integration/roots/bin-root-resolver.d.ts +0 -81
  201. package/lib/types/src/host/integration/roots/remote-home.d.ts +0 -69
  202. package/lib/types/src/host/integration/roots/root-registry.d.ts +0 -144
  203. package/lib/types/src/host/integration/roots/roots-wiring.d.ts +0 -219
  204. package/lib/types/src/host/integration/roots/session-root-index.d.ts +0 -52
  205. package/lib/types/src/host/integration/roots-api.d.ts +0 -407
  206. package/lib/types/src/host/integration/roots-wiring.d.ts +0 -211
  207. package/lib/types/src/host/integration/session/session-api.d.ts +0 -88
  208. package/lib/types/src/host/integration/session/session-bin-lock.d.ts +0 -80
  209. package/lib/types/src/host/integration/session/session-header.d.ts +0 -151
  210. package/lib/types/src/host/integration/session/session-labels.d.ts +0 -56
  211. package/lib/types/src/host/integration/session/session-route-wiring.d.ts +0 -50
  212. package/lib/types/src/host/integration/session-admin-service.d.ts +0 -236
  213. package/lib/types/src/host/integration/session-api.d.ts +0 -81
  214. package/lib/types/src/host/integration/session-bin-lock.d.ts +0 -80
  215. package/lib/types/src/host/integration/session-header.d.ts +0 -118
  216. package/lib/types/src/host/integration/session-labels.d.ts +0 -56
  217. package/lib/types/src/host/integration/session-route-wiring.d.ts +0 -50
  218. package/lib/types/src/host/integration/session-scope.d.ts +0 -113
  219. package/lib/types/src/host/integration/session-tools.d.ts +0 -44
  220. package/lib/types/src/host/integration/strict-arguments.d.ts +0 -79
  221. package/lib/types/src/host/integration/takeover/takeover-api.d.ts +0 -62
  222. package/lib/types/src/host/integration/takeover/takeover-route-wiring.d.ts +0 -60
  223. package/lib/types/src/host/integration/takeover/takeover-service.d.ts +0 -167
  224. package/lib/types/src/host/integration/terminal-manifest.d.ts +0 -94
  225. package/lib/types/src/host/integration/tools/management-tools.d.ts +0 -245
  226. package/lib/types/src/host/integration/tools/remote-job-tools.d.ts +0 -316
  227. package/lib/types/src/host/integration/tools/remote-lsp-tools.d.ts +0 -43
  228. package/lib/types/src/host/integration/tools/remote-tools.d.ts +0 -236
  229. package/lib/types/src/host/integration/tools/session-target.d.ts +0 -52
  230. package/lib/types/src/host/integration/tools/session-tools.d.ts +0 -46
  231. package/lib/types/src/host/integration/tools/strict-arguments.d.ts +0 -79
  232. package/lib/types/src/host/integration/tools/terminal-manifest.d.ts +0 -94
  233. package/lib/types/src/host/integration/transfer/remote-copy.d.ts +0 -66
  234. package/lib/types/src/host/integration/transfer/transfer-adapters.d.ts +0 -48
  235. package/lib/types/src/host/integration/transfer/transfer-tracker.d.ts +0 -106
  236. package/lib/types/src/host/integration/transfer-adapters.d.ts +0 -44
  237. package/lib/types/src/host/integration/transfer-service.d.ts +0 -164
  238. package/lib/types/src/host/integration/transfer-tracker.d.ts +0 -106
  239. package/lib/types/src/host/integration/user-roots.d.ts +0 -461
  240. package/lib/types/src/wiring/connections.d.ts +0 -189
  241. package/lib/types/src/wiring/fs.d.ts +0 -13
  242. package/lib/types/src/wiring/install-memo.d.ts +0 -32
  243. package/lib/types/src/wiring/legacy-dirs.d.ts +0 -62
  244. package/lib/types/src/wiring/package-paths.d.ts +0 -35
  245. package/lib/types/src/wiring/roots.d.ts +0 -21
  246. package/lib/types/src/wiring/state-dir.d.ts +0 -29
  247. package/lib/types/src/wiring/tools.d.ts +0 -35
@@ -1,79 +0,0 @@
1
- /**
2
- * Where a root's **file-level recycle bin** lives, and how to tell whether that place is usable.
3
- *
4
- * The bin used to sit at `<root>/.dsh-remote-workspace/trash` — inside the caller's own repository, so every
5
- * `git status` and `git add .` saw the bytes someone had just "safely deleted". Moving it out is not a matter
6
- * of changing a default (audit 0064 §3): the router refuses any path that is not inside a registered root, so
7
- * the new location has to be *registered* as a root of its own — one that is deliberately **not** listed
8
- * anywhere the user looks. The placement rules live here, as pure functions, because they are the part that
9
- * must be identical for every root and every world.
10
- *
11
- * Two constraints decide the location, and both are hard:
12
- *
13
- * 1. **Same device as the root.** The bin's whole guarantee is "move first, then confirm", and a cross-device
14
- * `rename` is refused outright rather than degraded to a copy (`fs-commands.ts`), because a copy can fail
15
- * half way and leave the bytes neither here nor there. The file-level bin has no copy fallback. So the bin
16
- * must be on the root's own filesystem.
17
- * 2. **Outside the repository, but not somewhere unguessable.** `$HOME` looks tidy and is the wrong answer:
18
- * on the site this plugin was built against the login home is `/home1/<user>` while projects live under
19
- * `/srv` or `/mnt`, which are usually separate mounts (NFS/automount) — so a home-based bin would make
20
- * **every** delete fail with `cross-device`. The root's own **parent** is the closest directory that is
21
- * almost always on the same filesystem.
22
- *
23
- * @module dsh-remote-workspace/domain/bin-location
24
- */
25
- import { type RootRef } from './root.ts';
26
- /** The bin directory name used when the caller configures none (`binDir`). */
27
- export declare const DEFAULT_BIN_DIR = ".dsh-remote-workspace/trash";
28
- /**
29
- * The root's own directory, in the spelling that world uses.
30
- *
31
- * Remote paths are always POSIX and are normalised as such; a local path is normalised by the host's rules
32
- * (which is what makes `D:\work\a` and `D:/work/a` the same directory on Windows).
33
- *
34
- * @param root - the root whose directory is wanted.
35
- * @returns a `/`-separated path.
36
- */
37
- export declare function rootDirectory(root: RootRef): string;
38
- /**
39
- * The bin directory **inside** the root — the historical location, kept as the documented fallback.
40
- *
41
- * @param root - the root being served.
42
- * @param binDir - configured directory name, relative to the root.
43
- * @returns the absolute bin directory.
44
- */
45
- export declare function binRootInsideRoot(root: RootRef, binDir?: string): string;
46
- /**
47
- * A stable, filesystem-safe directory name for one root's bin.
48
- *
49
- * Two roots can share a parent (and even a basename, across connections), so the name carries a hash of the
50
- * root's identity rather than only its last segment. Stable across runs: the bin directory must be findable
51
- * again after a restart, and an unstable name would silently orphan every deleted byte.
52
- *
53
- * @param root - the root being served.
54
- * @returns a name such as `work-1f3a9c02`.
55
- */
56
- export declare function binRootSlug(root: RootRef): string;
57
- /**
58
- * The bin directory **beside** the root, under its parent.
59
- *
60
- * The parent is used rather than `$HOME` because it is almost always the root's own filesystem, which is the
61
- * one property the bin cannot do without. `binDir` keeps its configured name so the plugin's footprint reads
62
- * the same as before; the per-root slug keeps two roots in one parent apart.
63
- *
64
- * @param root - the root being served.
65
- * @param binDir - configured directory name, relative to the parent.
66
- * @returns the absolute bin directory, or `undefined` when the root has no usable parent (it *is* `/`).
67
- */
68
- export declare function binRootBesideRoot(root: RootRef, binDir?: string): string | undefined;
69
- /**
70
- * The directory a same-device check must compare the bin directory against.
71
- *
72
- * The bin is created by the plugin, so on the first delete it may not exist yet; the parent is what has to be
73
- * on the same filesystem, and it always exists (it contains the root).
74
- *
75
- * @param root - the root being served.
76
- * @returns the absolute parent directory, or `undefined` for a root with no parent.
77
- */
78
- export declare function binParentDirectory(root: RootRef): string | undefined;
79
- //# sourceMappingURL=bin-location.d.ts.map
@@ -1,95 +0,0 @@
1
- /**
2
- * Connection profiles and their validation.
3
- *
4
- * A profile never carries secret material: a password is referenced by credential key and
5
- * resolved from `ctx.credentials` per operation.
6
- *
7
- * @module dsh-remote-workspace/domain/connection
8
- */
9
- import type { SshConfigImportDraft } from './ssh-config.ts';
10
- /** How the transport reaches the host. `agent` is the opt-in Tier 2 proxy (launched over the system ssh). */
11
- export type TransportKind = 'alias' | 'ssh2' | 'agent';
12
- /** Host key verification policy. */
13
- export type HostKeyPolicy = 'strict' | 'accept-new';
14
- /** Authentication method. */
15
- export type AuthSpec = {
16
- readonly kind: 'agent';
17
- } | {
18
- readonly kind: 'key';
19
- readonly keyPath: string;
20
- readonly hasPassphrase: boolean;
21
- } | {
22
- readonly kind: 'password';
23
- readonly credentialKey: string;
24
- };
25
- /** One saved connection. */
26
- export interface ConnectionProfile {
27
- /** Stable slug used inside `ssh://` paths and as the pool key. */
28
- readonly id: string;
29
- /** Human-facing name. */
30
- readonly name: string;
31
- /** Transport implementation. */
32
- readonly transport: TransportKind;
33
- /** Host name used by the ssh2 transport, and by alias transport only for diagnostics. */
34
- readonly host: string;
35
- readonly port: number;
36
- readonly user: string;
37
- /** OpenSSH alias; required by the alias transport. */
38
- readonly alias?: string;
39
- readonly auth: AuthSpec;
40
- /** ProxyJump chain, applied through `-J` (ssh2) or the alias (config). */
41
- readonly proxyJump: readonly string[];
42
- readonly hostKeyPolicy: HostKeyPolicy;
43
- /** Remote directory used as the default root when creating a remote workspace. */
44
- readonly remoteDefaultRoot?: string;
45
- readonly connectTimeoutMs: number;
46
- readonly commandTimeoutMs: number;
47
- readonly keepAliveSeconds: number;
48
- }
49
- /** Defaults for a new connection. */
50
- export declare const CONNECTION_DEFAULTS: {
51
- readonly port: 22;
52
- readonly connectTimeoutMs: 15000;
53
- readonly commandTimeoutMs: 30000;
54
- readonly keepAliveSeconds: 60;
55
- };
56
- /** Whether a string can name a value in the credential store. */
57
- export declare function isValidCredentialRef(value: string): boolean;
58
- /**
59
- * Derive the credential-reference name that holds one connection's password.
60
- *
61
- * The platform names stored values with a POSIX identifier, so a user-chosen name — `腾讯云` included —
62
- * cannot be used verbatim. The derivation keeps whatever ASCII is readable and then appends a 64-bit digest
63
- * of the **exact** id: readable enough to find in the credentials file, and collision-free between two names
64
- * that sanitise to the same slug (`a b` and `a_b`). It is a pure function of the id, so re-adding the same
65
- * name reuses one stored secret instead of accumulating orphans.
66
- *
67
- * @param connectionId - the user's connection name.
68
- * @returns a name satisfying {@link isValidCredentialRef}.
69
- */
70
- export declare function credentialRefFor(connectionId: string): string;
71
- /**
72
- * Validate untrusted input into a connection profile.
73
- *
74
- * Misconfiguration fails loudly at this boundary, so the rest of the plugin can treat a
75
- * `ConnectionProfile` as trustworthy.
76
- *
77
- * @param input - candidate value (settings JSON, import draft or test fixture).
78
- * @returns the validated profile.
79
- * @throws SshDevError with code `CONNECTION_INVALID`.
80
- */
81
- export declare function validateConnectionProfile(input: unknown): ConnectionProfile;
82
- /**
83
- * Turn one importable `~/.ssh/config` alias into a profile.
84
- *
85
- * The alias transport inherits user/port/identity/proxy settings from the alias itself, so
86
- * the draft's explicit values are kept only for display and for the ssh2 fallback.
87
- *
88
- * @param id - connection id assigned by the caller (keeps this function deterministic).
89
- * @param draft - one draft from {@link importableEntries}.
90
- * @returns the validated profile.
91
- */
92
- export declare function profileFromImportDraft(id: string, draft: SshConfigImportDraft): ConnectionProfile;
93
- /** One-line summary used by diagnostics and the settings list. */
94
- export declare function connectionSummary(profile: ConnectionProfile): string;
95
- //# sourceMappingURL=connection.d.ts.map
@@ -1,62 +0,0 @@
1
- /**
2
- * Glob patterns, matched the way the Tier 2 agent matches them.
3
- *
4
- * Why this module exists: `remote_glob` used to mean two different things depending on which transport answered.
5
- * The Tier 2 agent delegates to Go's `doublestar`, while the Tier 1 fallback ran a literal substring test
6
- * (`path.includes(pattern)`), so `*.cpp` matched nothing on one tier and every `.cpp` on the other, and the
7
- * tool description described only the substring half. The two behaviours were introduced by different audits
8
- * (0052 P3 chose substring, 0030 added the Go fast path) and nothing compared them afterwards.
9
- *
10
- * The rules below are a port of `dsh-over-ssh-agent/internal/agent/glob_semantics_test.go`, and that same table is
11
- * mirrored in this module's test. A divergence between the two implementations is therefore a test failure on
12
- * one side or the other, instead of a surprise for whoever happens to run on the other tier.
13
- *
14
- * The language:
15
- *
16
- * - A pattern **without** `/` matches the basename at any depth (`*.h` finds `app/include/header.h`).
17
- * - A pattern **with** `/` is anchored at the enumerated root, and `*` never crosses a `/`.
18
- * - `**` as a whole segment crosses zero or more segments: `**\/a` matches `a`, `x/a`, `x/y/a`; `a/**`
19
- * matches `a` itself as well as everything below it. `**` inside a segment (`a**b`) behaves like `*`.
20
- * - `?` is one character other than `/`.
21
- * - `[...]` is a character class; a leading `!` or `^` negates it.
22
- * - `{a,b}` alternates (and `{a}` is just `a`).
23
- * - `\x` is a literal `x`.
24
- * - An unclosed `[` or `{` **throws**: a caller who wrote a broken pattern must be told, because an empty
25
- * result would otherwise read as "no such file".
26
- *
27
- * Matching is case-sensitive, like `doublestar`. Paths are `/`-separated and **relative to the enumerated
28
- * root** — the caller normalizes them, so this module needs no filesystem knowledge and stays offline-testable.
29
- *
30
- * @module dsh-over-ssh/domain/glob-pattern
31
- */
32
- /** A pattern that cannot be compiled; the message names the offending construct. */
33
- export declare class GlobPatternError extends Error {
34
- constructor(message: string);
35
- }
36
- /** One compiled pattern. */
37
- export interface CompiledGlob {
38
- /** The pattern as the caller wrote it. */
39
- readonly pattern: string;
40
- /**
41
- * True when the pattern has no `/`, so it is matched against the basename at any depth.
42
- *
43
- * The test is on the **raw** pattern, matching the agent (`!strings.Contains(pattern, "/")`): a `/` inside
44
- * braces still anchors the pattern.
45
- */
46
- readonly basenameOnly: boolean;
47
- /**
48
- * Whether one root-relative path matches.
49
- *
50
- * @param relativePath - `/`-separated path relative to the enumerated root.
51
- */
52
- matches(relativePath: string): boolean;
53
- }
54
- /**
55
- * Compile one glob pattern.
56
- *
57
- * @param pattern - the pattern as the caller wrote it.
58
- * @returns the compiled pattern.
59
- * @throws GlobPatternError when the pattern is not a valid glob.
60
- */
61
- export declare function compileGlob(pattern: string): CompiledGlob;
62
- //# sourceMappingURL=glob-pattern.d.ts.map
@@ -1,63 +0,0 @@
1
- /**
2
- * Literal string helpers shared by the two write paths.
3
- *
4
- * The plugin has **three** literal edit call sites — `app/routed-fs.ts` (the path-based `FileSystem`
5
- * surface), `integration/fs/fs-provider.ts` (the core `ctx.fs` provider) and
6
- * `integration/fs/remote-file-tools.ts` (`remote_edit`) — because the seams were written separately. They
7
- * must agree on what "the requested text appears N times" means and on what "replace it" produces, or the
8
- * same edit is ambiguous through one seam and corrupting through another.
9
- *
10
- * They already diverged twice. First on counting: each carried its **own** private `countOccurrences`,
11
- * and only one of the two guarded the empty needle — without that guard `indexOf('')` returns `0` forever,
12
- * so the unguarded copy was an **infinite loop** (audit 0057 §11 #4, latent because a caller happened to
13
- * reject the empty needle first). Then on replacing: two of the three used
14
- * `source.replace(needle, replacement)`, whose **string** replacement expands `$&`, `` $` ``, `$'` and
15
- * `$$` — so a replacement containing `$$` (a shell PID in a Makefile, say) was written back as `$`, and on
16
- * the Tier 1 fallback path that corrupted the remote file (audit 2026-10-31 P1). One implementation each,
17
- * in the domain layer, removes the possibility of a further divergence.
18
- *
19
- * @module dsh-over-ssh/domain/literal-text
20
- */
21
- /**
22
- * Count non-overlapping occurrences of a literal needle.
23
- *
24
- * **An empty needle returns 0, never "matches everywhere".** That is not a style choice: the loop below
25
- * advances by `needle.length`, so a zero-length needle would never advance and the loop would never end.
26
- * Returning 0 keeps the "0 occurrences ⇒ the text was not found" branch in the callers correct, which is
27
- * the answer an empty search deserves.
28
- *
29
- * Occurrences are non-overlapping: `countOccurrences('aaaa', 'aa') === 2`, matching what
30
- * `String.prototype.split(needle).length - 1` (the replacement the callers use) would produce.
31
- *
32
- * @param haystack - the text to search.
33
- * @param needle - the literal text to count; treated verbatim, never as a pattern.
34
- * @returns how many times `needle` occurs, or 0 when `needle` is empty.
35
- */
36
- export declare function countOccurrences(haystack: string, needle: string): number;
37
- /** What one literal replacement produced. */
38
- export interface LiteralReplacement {
39
- /** The text after the replacement. */
40
- readonly text: string;
41
- /** How many occurrences were replaced (`all ? occurrences : 1`), or `0` when the needle is absent. */
42
- readonly replacements: number;
43
- }
44
- /**
45
- * Replace occurrences of a literal needle, **verbatim on both sides**.
46
- *
47
- * The replacement text is spliced in by index (single) or joined from `split` (all), never passed to
48
- * `String.prototype.replace` as a string replacement: that overload expands `$&`, `` $` ``, `$'` and `$$`,
49
- * so `new: '$$'` would be written as `$`. Splicing is the only way to make "the replacement is inserted
50
- * verbatim" true for a caller that has no idea what a `$` means to JavaScript.
51
- *
52
- * Total by construction: an empty or absent needle replaces nothing and returns the source unchanged, so a
53
- * caller cannot turn a policy question ("should this have matched?") into a corrupted file. Every caller
54
- * validates the occurrence count *before* calling this.
55
- *
56
- * @param source - the text to edit.
57
- * @param needle - literal text to find; treated verbatim, never as a pattern.
58
- * @param replacement - text to insert; no `$` expansion of any kind.
59
- * @param all - replace every occurrence, or only the first.
60
- * @returns the new text plus how many occurrences were replaced.
61
- */
62
- export declare function replaceLiteral(source: string, needle: string, replacement: string, all: boolean): LiteralReplacement;
63
- //# sourceMappingURL=literal-text.d.ts.map
@@ -1,84 +0,0 @@
1
- /**
2
- * The model-facing path grammar for remote roots.
3
- *
4
- * Remote files are addressed as `ssh://<connectionId>/<absolute remote path>` so that a
5
- * POSIX remote path can never be confused with a local POSIX path. Local anchor directories
6
- * are an implementation detail of the workspace requirement (a workspace path must exist
7
- * locally); they are not part of the model-facing grammar.
8
- *
9
- * @module dsh-over-ssh/domain/path-grammar
10
- */
11
- /** The scheme that marks a remote path. */
12
- export declare const SSH_SCHEME = "ssh://";
13
- /** A parsed `ssh://` reference. */
14
- export interface RemotePathRef {
15
- /** Connection id (slug). */
16
- readonly connectionId: string;
17
- /** Absolute POSIX path on that host. */
18
- readonly path: string;
19
- }
20
- /** Whether a string is written in the remote grammar. */
21
- export declare function isSshPath(input: string): boolean;
22
- /** Validate a connection id slug. */
23
- export declare function isValidConnectionId(id: string): boolean;
24
- /**
25
- * Parse `ssh://<connectionId>/<absolute path>`.
26
- *
27
- * @param input - candidate reference.
28
- * @returns the parsed reference, or `undefined` when the input is not in the grammar.
29
- * @throws SshDevError when the input uses the scheme but is malformed.
30
- */
31
- export declare function parseSshPath(input: string): RemotePathRef | undefined;
32
- /** Format a remote reference into the model-facing grammar. */
33
- export declare function formatSshPath(connectionId: string, remotePath: string): string;
34
- /**
35
- * Normalize an absolute POSIX path: collapse repeated separators, resolve `.` and `..`,
36
- * and reject relative spellings. Trailing separators are dropped except for the root.
37
- *
38
- * @param path - absolute POSIX path.
39
- * @returns the normalized absolute path.
40
- * @throws SshDevError when the path is not absolute.
41
- */
42
- export declare function normalizeRemotePath(path: string): string;
43
- /**
44
- * Join a relative spelling onto an absolute remote base, then normalize.
45
- *
46
- * @param base - absolute POSIX base directory.
47
- * @param relative - relative spelling, optionally containing `.`/`..`.
48
- * @returns the normalized absolute path.
49
- */
50
- export declare function joinRemotePath(base: string, relative: string): string;
51
- /**
52
- * Whether `candidate` is `root` itself or a descendant of it, compared per path segment
53
- * (so `/srv/appdata` is not contained by `/srv/app`).
54
- *
55
- * @param root - absolute POSIX directory.
56
- * @param candidate - absolute POSIX path.
57
- * @returns whether the candidate is inside the root.
58
- */
59
- export declare function remotePathContains(root: string, candidate: string): boolean;
60
- /**
61
- * The parent directory of an absolute remote path; the root's parent is the root.
62
- *
63
- * @param path - absolute POSIX path.
64
- * @returns the normalized parent directory.
65
- */
66
- export declare function remoteDirname(path: string): string;
67
- /**
68
- * The final segment of an absolute remote path; the root yields an empty string.
69
- *
70
- * @param path - absolute POSIX path.
71
- * @returns the final segment.
72
- */
73
- export declare function remoteBasename(path: string): string;
74
- /**
75
- * Whether `candidate` is a descendant of one of the roots, returning the longest match.
76
- *
77
- * Longest-prefix matching is what keeps nested roots (`/srv` and `/srv/app`) unambiguous.
78
- *
79
- * @param roots - absolute POSIX roots to test.
80
- * @param candidate - absolute POSIX path.
81
- * @returns the matched root, or `undefined` when nothing contains the candidate.
82
- */
83
- export declare function longestContainingRoot(roots: readonly string[], candidate: string): string | undefined;
84
- //# sourceMappingURL=path-grammar.d.ts.map