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,62 +0,0 @@
1
- /**
2
- * 一键接管的同源 HTTP 路由:`/api/remote-workspace/takeover`。
3
- *
4
- * 为什么是普通 HTTP 路由而不是 Typert `@Remote` 服务:与 `/api/remote-workspace/roots` 同一个理由
5
- * (见 `roots-api.ts` 模块头与 `doc/02-platform/roots-http-route.md`)—— 带参数的 Remote 描述符需要
6
- * 生成式严格 codec,本仓库无法产出;而面板与路由同源,相对路径 `fetch` 就是正规形态。
7
- *
8
- * 契约:
9
- *
10
- * | 请求 | 回答 |
11
- * |---|---|
12
- * | `GET` | `200 { ok:true, supported, state, rows:[{patchId, loaderEntryId?, enabled, readOnlyReason?}], writable, canApply, canRevert, reason?, manualRows? }` |
13
- * | `POST { action:'apply' }` 且已在接管态 | `200 { ok:true, action, state, changed:[], warnings:[], }`(幂等,不写盘) |
14
- * | `POST { action:'revert' }` 且已在交还态 | 同上 |
15
- * | `POST` 需要改动四行 | `501 { ok:false, reason:'not-restorable', error:'…要写的 YAML 行…', state, changed:[], warnings:[] }` |
16
- * | `POST` 且这台宿主没有 `pluginManager` | `501 { ok:false, reason:'unsupported', … }` |
17
- * | `POST` 且计划要碰的行只读 / 清单缺行 | `409 { ok:false, reason:'read-only' \| 'rows-missing', … }` |
18
- * | 请求体不合法 / 未知 action | `400 { ok:false, error, allowed? }` |
19
- * | 不同源 | `403 { ok:false, error, reason }` |
20
- * | 其它方法 | `405 { ok:false, error }` + `Allow: GET, HEAD, POST` |
21
- *
22
- * **`GET` 永远是 200**(只要同源):`supported:false` 是「这台宿主不能自动切换」的正常回答,
23
- * 不是错误 —— 客户端据此把开关置灰并显示 `reason`。
24
- *
25
- * **`POST` 默认是拒绝的**:见 `takeover-service.ts` 模块头(宿主的写入口既不原子也无法精确还原)。
26
- * 唯一的 200 是「已经在目标态」那种,它一个字节都不写。`error` 里带着用户要手写的那几行 YAML,
27
- * 所以拒绝也是可执行的。
28
- *
29
- * 两条不变量:
30
- * 1. 只有 `action` 一个字段被读(白名单),请求体不会被展开进任何调用;
31
- * 2. 回答里只有行 id 与布尔值:`patchId` 是**规范身份**(用户 `cordis.patch.yml` 里那一行的 id),
32
- * `loaderEntryId` 是 Loader 条目 id(诊断用);`moduleName`、profile 路径与宿主内部标识一律不带出去。
33
- *
34
- * @module dsh-remote-workspace/integration/takeover-api
35
- */
36
- import type { RootsApiRequest, RootsApiResponse } from '../../app/roots/roots-api-contract.ts';
37
- import type { TakeoverService } from './takeover-service.ts';
38
- /** 本插件在这台宿主 HTTP 载体上占用的第二个路径。 */
39
- export declare const TAKEOVER_API_PATH = "/api/remote-workspace/takeover";
40
- /** `POST` 接受的唯一两个 action。 */
41
- export declare const TAKEOVER_ACTIONS: readonly ["apply", "revert"];
42
- /** 请求体上限:一个 `{ action }` 只有几十字节,64 KiB 是天花板不是预算(与 roots 路由同一个常量)。 */
43
- export declare const TAKEOVER_MAX_BODY_BYTES: number;
44
- /** 路由处理器需要的唯一依赖。 */
45
- export interface TakeoverApiDeps {
46
- /** 执行器(宿主 `pluginManager` 的 seam 已在它里面注入)。 */
47
- readonly service: TakeoverService;
48
- }
49
- /** 处理器对:`handle` 永不 reject(reject 会让 socket 没有状态码)。 */
50
- export interface TakeoverApi {
51
- readonly handle: (req: RootsApiRequest, res: RootsApiResponse) => Promise<void>;
52
- /** 不持有资源;路由注册归调用方(wiring)。 */
53
- dispose(): void;
54
- }
55
- /**
56
- * 造路由处理器。
57
- *
58
- * @param deps - 执行器。
59
- * @returns {@link TakeoverApi}。
60
- */
61
- export declare function createTakeoverApi(deps: TakeoverApiDeps): TakeoverApi;
62
- //# sourceMappingURL=takeover-api.d.ts.map
@@ -1,60 +0,0 @@
1
- /**
2
- * 在浏览器载体上拥有接管路由(`/api/remote-workspace/takeover`)。
3
- *
4
- * 与 `roots-wiring.ts` / `session-route-wiring.ts` 同一套 **deferred carrier** 写法,原因也是同一个实测事实:
5
- * 打包运行时 0.2.0-rc.2 上,插件条目激活时 `ctx.get('webServer')` 是 `undefined`(载体行之后才构造),
6
- * 裸 `ctx.get` 会静默漏掉注册,面板每个请求都落到 SPA 回退的 `http-404`,而插件看上去一切正常。
7
- * `ctx.inject(['webServer'], …)` 会在服务出现时回调。
8
- *
9
- * 没有载体的组合(headless)**不是错误**:插件照常工作,只是没有面板数据通道;原因收集成 warning,
10
- * 由入口在 `ctx.logger` 就绪之后打出来。
11
- *
12
- * @module dsh-remote-workspace/integration/takeover-route-wiring
13
- */
14
- import { type TakeoverApi } from './takeover-api.ts';
15
- import { type PluginManagerSeam, type TakeoverService } from './takeover-service.ts';
16
- /** 浏览器 HTTP 载体,窄到本 wiring 唯一用到的方法。 */
17
- export interface TakeoverRouteHost {
18
- register(route: {
19
- readonly kind: 'exact';
20
- readonly path: string;
21
- readonly handler: (req: never, res: never) => Promise<void>;
22
- }): () => void;
23
- }
24
- /** 服务出现时才把载体交出来的提供者(真实实现是 `ctx` 的 `inject`)。 */
25
- export interface TakeoverRouteHostProvider {
26
- inject(names: readonly string[], callback: (scoped: {
27
- get(name: string): unknown;
28
- }) => void | (() => void)): unknown;
29
- }
30
- /** 入口交给 wiring 的全部依赖。 */
31
- export interface TakeoverRouteWiringDeps {
32
- /**
33
- * 宿主 `pluginManager` 的 getter(入口传 `() => ctx.get('pluginManager')`)。
34
- *
35
- * 是 getter 而不是值:服务可能比本插件晚就绪,捕获成 `undefined` 会让一键接管在整个进程里永久不可用。
36
- */
37
- readonly pluginManager: () => PluginManagerSeam | undefined;
38
- /** 私有域里的原版 provider 是否就位;见 {@link TakeoverServiceDeps.localWorld}。 */
39
- readonly localWorld: () => boolean;
40
- /** 延迟到达的 `ctx.webServer` 载体;headless 组合下缺省。 */
41
- readonly webServerProvider?: TakeoverRouteHostProvider | undefined;
42
- }
43
- /** 入口要拿住的东西。 */
44
- export interface TakeoverRouteWiring {
45
- readonly api: TakeoverApi;
46
- readonly service: TakeoverService;
47
- /** 路由可能没注册的原因;由入口在激活后(`ctx.logger` 就绪时)打日志。 */
48
- readonly routeWarnings: () => readonly string[];
49
- /** 延迟载体回调是否跑过(诊断用)。 */
50
- readonly injectRan: () => boolean;
51
- readonly dispose: () => void;
52
- }
53
- /**
54
- * 组装执行器 + 路由,并在载体出现时注册。
55
- *
56
- * @param deps - `pluginManager` 的 getter 与可选的载体提供者。
57
- * @returns {@link TakeoverRouteWiring};卸载时调用 `dispose` 注销路由。
58
- */
59
- export declare function createTakeoverRouteWiring(deps: TakeoverRouteWiringDeps): TakeoverRouteWiring;
60
- //# sourceMappingURL=takeover-route-wiring.d.ts.map
@@ -1,167 +0,0 @@
1
- /**
2
- * 一键接管的宿主侧:**只读地**回答「四行现在是什么组合」,并在能保证安全时执行切换 —— 本实现判断
3
- * 「现在不能」,所以只有读路径(下面「结论」给出三条理由)。
4
- *
5
- * ## 平台事实(0.2.0-rc.2 源码核实,不是推断)
6
- *
7
- * 证据:`.core/src/deepseek-harness-dsh-v0.2.0-rc.2/packages/boot/plugin-manager/src/{index,patch,types}.ts`
8
- * 与 `packages/host/plugin-inventory/src/{index,types}.ts`。
9
- *
10
- * | 事实 | 出处 |
11
- * |---|---|
12
- * | `listPlugins(): Promise<PluginInfo[]>` —— **异步** | `plugin-manager/src/index.ts:256` |
13
- * | `PluginInfo` = `{entryId, moduleName, enabled, fiberPhase, meta}` + **二选一**的 `patchId`(可改)或 `readOnlyReason`(不可改) | `types.ts:29-32`、`plugin-inventory/src/types.ts:17-26` |
14
- * | `enabled` = `!entry.disabled`(**运行中 Loader 条目**的开关);`fiberPhase` 才是「fiber 是否真的在跑」 | `plugin-inventory/src/index.ts:82-96` |
15
- * | 唯一的写入口是 `setPluginEnabled(entryId, enabled)` —— **一次一行**,收 `entryId`;`patchId` 只是宿主内部写 patch 的目标 | `index.ts:425-435` |
16
- * | 写盘的格式**不是公开契约**:rc.2 的 `writePluginEnabled` 命中同名行就就地改 `disabled:`、没有就追加一行(`patch.ts:14-42`);已安装的 0.2.1 writer 还会**删除冗余覆盖**(Lead 核实)。两者都是实现细节,跨版本不一致 |
17
- * | `ChangeResult.application ∈ {applied, restart-required, overridden, failed, cancelled}`;**失败不抛异常** | `index.ts:767-791`、`types.ts:111-136` |
18
- * | `restart-required` ⟺ 没有 `hmr`:patch 已写盘,运行中的图没变 | `index.ts:757-765,776` |
19
- *
20
- * ## 结论:写路径不存在,开关 fail closed
21
- *
22
- * 用户要的是「原样交还」:切过去、再切回来,profile patch 回到**原样**。用受支持的能力做不到,三条独立
23
- * 的理由(都是上面那张表推出来的,不是猜测):
24
- *
25
- * 1. **存不下来**:`listPlugins` 只给运行态生效值(bool),**不返回** profile YAML 的原始覆盖 —— 公开
26
- * 接口里没有「保存原覆盖」的来源;
27
- * 2. **还不回去**:公开接口**不保证**精确还原。`setPluginEnabled` 只接受一个布尔值,写盘格式(就地改、
28
- * 追加、是否顺手删掉冗余覆盖)是实现细节 —— rc.2 只追加/就地改,0.2.1 会删冗余覆盖,跨版本不一致。
29
- * 这种没有契约的写-再写-回去,不能当成「原样」。若原行是 `disabled: !!js <expr>` 这类条件表达式,
30
- * 一次字面量写入就会把它覆盖掉,且无法从 bool 还原;
31
- * 3. **不原子**:一次切换要按序写 6–8 次(见 `takeover-plan.ts` 的顺序说明),宿主没有批量/事务 API;
32
- * 中途失败就留下「两个提供方同时在场」或「一个都没有」的半成品。原子写文件也不等于运行中的插件图
33
- * 原子切换。
34
- *
35
- * 所以本模块**不写** profile:不用内存里的 bool 快照假装「原样恢复」,也不自己碰 `~/.dsh`。
36
- * 它做两件可验证的事:
37
- *
38
- * - **如实报状态**:组合(`enabled`)+ 运行态(`fiberPhase`)分别读,不一致时说出来;
39
- * - **拒绝并交出改法**:会改文件的请求一律 `reason:'not-restorable'`,并把「用户自己该写哪几行」原样
40
- * 交回去({@link manualPatchRows}),由用户在自己的 profile 里决定。
41
- *
42
- * 唯一放行的 `POST` 是**已经处于目标态**的那种:它一个字节都不写,只是回答「已经在那儿了」。
43
- *
44
- * 什么时候能真的自动切换:宿主提供**一次事务**的批量开关(全成或全不成),或提供 profile 覆盖的
45
- * 读回 + 精确还原。两者都没有之前,开关是停用的 —— 这是**已知的产品限制**,不是缺陷。
46
- *
47
- * @module dsh-remote-workspace/integration/takeover-service
48
- */
49
- import { type TakeoverAction, type TakeoverState } from '../../app/takeover/takeover-plan.ts';
50
- import { type PublicTakeoverRow } from '../../app/takeover/takeover-rows.ts';
51
- /**
52
- * 宿主 `pluginManager` 服务里本插件用到的那个方法。
53
- *
54
- * 结构类型而不是 import `@deepseek-ai/dsh-plugin-manager`:那个包不是本仓库的依赖(宿主自带),
55
- * 而这一层只需要读清单 —— 用结构类型既守红线(应用/领域层不碰 `@deepseek-ai/*`),
56
- * 也让测试可以传一个普通对象进来。
57
- *
58
- * **这里没有 `setPluginEnabled`**:写路径已按模块头注释的三条理由关闭。把它留在 seam 上只会诱导后来者
59
- * 用它做一件做不到的事。
60
- */
61
- export interface PluginManagerSeam {
62
- /**
63
- * 宿主当前的行清单(真实实现异步)。本插件只读四行的 `patchId`(规范身份)/ `entryId`(Loader 身份,
64
- * 诊断用)/ `moduleName`(交叉校验)/ `enabled` / `readOnlyReason` / `fiberPhase`。
65
- */
66
- listPlugins(): Promise<unknown> | unknown;
67
- }
68
- /** 私有域的装配结果。 */
69
- export type LocalWorldState = 'ready' | 'missing';
70
- /** `GET` 要的那份状态。 */
71
- export interface TakeoverStatus {
72
- /** `pluginManager` 是否可达(不可达时其余字段仍然自洽)。 */
73
- readonly supported: boolean;
74
- readonly state: TakeoverState;
75
- /**
76
- * 私有域是否装配成功:`ready` 表示原版 `fs-sandbox` / `file-reference-local` 已经在私有域里跑起来,
77
- * 本地路径的写入围栏由平台执行;`missing` 表示 bridge 没拿到它们,路由器退回自己的本地后端。
78
- *
79
- * 单独暴露的理由:这一层装配失败时**没有任何报错**——路由器有兜底,功能看起来正常,只是围栏换了
80
- * 执行者。没有这个字段就只能去翻宿主终端里的 stderr(审计 0100 未验证项)。
81
- */
82
- readonly localWorld: LocalWorldState;
83
- /** 四行中**实际找到**的那几行(缺行时短于 4)。 */
84
- readonly rows: readonly PublicTakeoverRow[];
85
- /**
86
- * 这台宿主**能不能真的执行切换**。
87
- *
88
- * 与 {@link TakeoverStatus.supported} 分开是必要的:`supported:true` 只说明 `pluginManager` 可达,
89
- * 面板若据此把开关画成可操作,用户点了只会得到一条拒绝。本实现没有写路径(模块头「结论」),
90
- * 所以这里恒为 `false`。
91
- */
92
- readonly writable: boolean;
93
- /** 「接管」这个动作现在是否可用:`writable` 为真,且确实有四行需要改。 */
94
- readonly canApply: boolean;
95
- /** 「交还」这个动作现在是否可用:同上,方向相反。 */
96
- readonly canRevert: boolean;
97
- /**
98
- * 状态说明:为什么这台宿主不能自动切换(没有 `pluginManager` / 缺行 / 没有原子且可还原的写入),
99
- * 或者「配置说这样、运行态不是这样」。没有要说的时候不出现。
100
- */
101
- readonly reason?: string;
102
- /**
103
- * 用户自己动手时要写进 `cordis.patch.yml` 的那几行(YAML,原样可粘贴)。
104
- *
105
- * 为什么放在 `GET` 上:开关停用时 UI 永远不会发 `POST`,如果改法只在 `POST` 的 `error` 里,
106
- * 「请按提示手动修改」就会指向一段用户拿不到的内容。方向随当前状态走:`on` 给「交还」的写法,
107
- * 其余给「接管」的写法。已经不需要改时为空,此时整个字段不出现。
108
- */
109
- readonly manualRows?: readonly string[];
110
- }
111
- /** 一次操作失败的原因。 */
112
- export type TakeoverFailure =
113
- /** 这台宿主没有 `pluginManager`。 */
114
- 'unsupported'
115
- /** 计划要碰的行只读。 */
116
- | 'read-only'
117
- /** 插件清单里缺行。 */
118
- | 'rows-missing'
119
- /** 宿主的写入口不能保证原子 + 精确还原 —— 写下去就回不到原样,所以不写。 */
120
- | 'not-restorable';
121
- /** 一次操作的结果。失败也带 `state`,让客户端能说清楚「现在是什么样」。 */
122
- export type TakeoverRunResult = {
123
- readonly ok: true;
124
- readonly action: TakeoverAction;
125
- readonly state: TakeoverState;
126
- /** 与调用前相比真正变了的行;本实现永远为空(它不写)。 */
127
- readonly changed: readonly string[];
128
- readonly warnings: readonly string[];
129
- } | {
130
- readonly ok: false;
131
- readonly reason: TakeoverFailure;
132
- readonly error: string;
133
- readonly state: TakeoverState;
134
- readonly changed: readonly string[];
135
- readonly warnings: readonly string[];
136
- };
137
- /** 执行器对外只暴露两个动作。 */
138
- export interface TakeoverService {
139
- /** 读当前状态(`GET`)。永不抛错:读不到就如实报 `supported:false`。 */
140
- status(): Promise<TakeoverStatus>;
141
- /** 处理一次 apply / revert(`POST`)。不写 profile;不能保证安全时拒绝并给出改法。 */
142
- run(action: TakeoverAction): Promise<TakeoverRunResult>;
143
- }
144
- /** 执行器需要的那一件事。 */
145
- export interface TakeoverServiceDeps {
146
- /** 每次读取,而不是构造时捕获(服务可能晚于本插件就绪)。 */
147
- readonly pluginManager: () => PluginManagerSeam | undefined;
148
- /**
149
- * 私有域里的原版 provider 是否已经就位(`localFs` / `localFileReferences` 可注入)。
150
- *
151
- * 与 `pluginManager` 分开:那一组说的是「配置里的四行」,这一组说的是「运行时那套下沉组合装没装起来」。
152
- * 两者可以同时成立、也可以各自失败,混成一个字段就没法判断是哪一层的问题。
153
- */
154
- readonly localWorld: () => boolean;
155
- }
156
- /** 没有 `pluginManager` 时的说明(`GET` 的 `reason` 与 `POST` 的 `error` 共用)。 */
157
- export declare const UNSUPPORTED_MESSAGE = "\u8FD9\u53F0\u5BBF\u4E3B\u6CA1\u6709 pluginManager \u670D\u52A1\uFF0C\u65E0\u6CD5\u81EA\u52A8\u5207\u6362\u63A5\u7BA1\uFF1B\u8BF7\u624B\u52A8\u4FEE\u6539 profile \u7684 cordis.patch.yml \u540E\u91CD\u542F";
158
- /** 没有「原子 + 可精确还原」的写入口时的说明(`GET` 的 `reason`)。 */
159
- export declare const NOT_RESTORABLE_REASON = "\u5BBF\u4E3B\u7684 pluginManager \u53EA\u80FD\u4E00\u6B21\u6539\u4E00\u884C\uFF0C\u800C\u4E14\u516C\u5F00\u63A5\u53E3\u4E0D\u4FDD\u8BC1\u628A profile patch \u7CBE\u786E\u8FD8\u539F\uFF08listPlugins \u4E0D\u8FD4\u56DE\u539F\u59CB\u8986\u76D6\uFF0CsetPluginEnabled \u53EA\u6536\u4E00\u4E2A\u5E03\u5C14\u503C\uFF0C\u4E5F\u6CA1\u6709\u6279\u91CF/\u4E8B\u52A1\u63A5\u53E3\uFF09\u3002\u6CA1\u6709\u8FD8\u539F\u4FDD\u8BC1\u5C31\u4E0D\u8BE5\u66FF\u4F60\u6539\u6587\u4EF6\uFF0C\u56E0\u6B64\u672C\u63D2\u4EF6\u4E0D\u81EA\u52A8\u6539 profile\uFF1B\u8BF7\u6309\u63D0\u793A\u624B\u52A8\u4FEE\u6539 cordis.patch.yml\u3002";
160
- /**
161
- * 造一个执行器。
162
- *
163
- * @param deps - 宿主 `pluginManager` 的 getter。
164
- * @returns {@link TakeoverService}。
165
- */
166
- export declare function createTakeoverService(deps: TakeoverServiceDeps): TakeoverService;
167
- //# sourceMappingURL=takeover-service.d.ts.map
@@ -1,94 +0,0 @@
1
- /**
2
- * The files a terminal wrapper reads: the root manifest and per-session state.
3
- *
4
- * The wrapper is a **separate process** launched by the platform's terminal controller, so it cannot ask the
5
- * host anything over IPC — it reads two small JSON files instead:
6
- *
7
- * - `roots.json` — every remote root with its local anchor and its already-credential-resolved ssh argv;
8
- * - `state/<sessionId>.json` — the remote target of one session, written when the host resolves it.
9
- *
10
- * Writes are atomic (temp file + rename) because the wrapper may read them at any moment, and a half-written
11
- * JSON must never decide where the user's terminal goes.
12
- *
13
- * @module dsh-remote-workspace/integration/terminal-manifest
14
- */
15
- import { type ManifestRoot, type RootManifest, type SessionState, type SshInvocation } from '../domain/terminal-target.ts';
16
- /**
17
- * Build the ssh invocation the terminal wrapper spawns for one connection.
18
- *
19
- * Deliberately shared with the entry **and** with the real-host verification: a hand-written copy is exactly
20
- * how a wrapper ends up connecting as the local user instead of the configured one (the verification script
21
- * hit that: `ssh host` used `yerier@…` and was refused, because the manifest lacked `-l root`).
22
- *
23
- * Difference from the alias transport: terminals are interactive, so a password connection must be allowed to
24
- * prompt (`BatchMode=no`) — an agent-authenticated one must not.
25
- *
26
- * @param profile - connection facts (host, alias, port, user, auth).
27
- * @param limits - resolved plugin limits (`knownHostsFile`, `connectTimeoutMs`).
28
- * @returns destination plus credential arguments.
29
- */
30
- export declare function sshInvocationFor(profile: {
31
- readonly host: string;
32
- readonly alias?: string;
33
- readonly port?: number;
34
- readonly user?: string;
35
- readonly authKind: 'agent' | 'key' | 'password';
36
- readonly identityFile?: string;
37
- readonly connectTimeoutMs?: number;
38
- }, limits?: {
39
- readonly knownHostsFile?: string;
40
- readonly connectTimeoutMs?: number;
41
- }): SshInvocation;
42
- /** File-system surface, injected so tests never touch the developer's home directory. */
43
- export interface ManifestIo {
44
- readFile(path: string): Promise<string>;
45
- writeFile(path: string, data: string): Promise<void>;
46
- mkdir(path: string): Promise<void>;
47
- rename(from: string, to: string): Promise<void>;
48
- remove(path: string): Promise<void>;
49
- list(dir: string): Promise<readonly string[]>;
50
- }
51
- /** Real file-system binding. */
52
- export declare const nodeManifestIo: ManifestIo;
53
- /**
54
- * Turn a session id into a safe file name.
55
- *
56
- * Session ids are host-chosen strings and may contain separators or colons; the name is sanitized and given a
57
- * short hash suffix so two distinct ids can never collide onto one file.
58
- *
59
- * @param sessionId - raw session id.
60
- * @returns a file name (no directory part) unique to that id.
61
- */
62
- export declare function sessionFileName(sessionId: string): string;
63
- /** Reads and writes the wrapper's manifest files. */
64
- export declare class TerminalManifestStore {
65
- #private;
66
- /**
67
- * @param options - `dir` is the plugin state directory (usually `~/.dsh/ssh-dev`).
68
- */
69
- constructor(options: {
70
- readonly dir: string;
71
- readonly io?: ManifestIo;
72
- });
73
- /** Absolute path of the root manifest. */
74
- get manifestPath(): string;
75
- /** Absolute path of one session's state file. */
76
- statePath(sessionId: string): string;
77
- /**
78
- * Replace the whole root manifest.
79
- *
80
- * @param roots - remote roots the terminal wrapper may target.
81
- */
82
- writeRoots(roots: readonly ManifestRoot[]): Promise<void>;
83
- /** Read the root manifest; `undefined` when missing, malformed, or from another format version. */
84
- readRoots(): Promise<RootManifest | undefined>;
85
- /** Record one session's remote target. */
86
- writeSession(state: SessionState): Promise<void>;
87
- /** Read one session's target; `undefined` when missing or malformed. */
88
- readSession(sessionId: string): Promise<SessionState | undefined>;
89
- /** Remove one session's state (session closed); missing files are not an error. */
90
- forgetSession(sessionId: string): Promise<void>;
91
- /** Every readable session state (used by the wrapper when it has no session id). */
92
- listSessions(): Promise<readonly SessionState[]>;
93
- }
94
- //# sourceMappingURL=terminal-manifest.d.ts.map
@@ -1,245 +0,0 @@
1
- /**
2
- * The management tool surface: `remote_transfer` (upload/download) and `remote_delete` (recycle/permanent).
3
- *
4
- * `remote_delete` is the reason this module exists separately from `remote-tools.ts`: a **permanent** delete
5
- * bypasses `ctx.fs` and cannot be undone, so it goes through the platform's pre-execute waterfall and is
6
- * answered with `ask` (which the registry turns into a denial when the composition has no approval surface —
7
- * fail closed). Recycle mode is an ordinary call: it is recoverable and `undo` exists.
8
- *
9
- * @module dsh-over-ssh/integration/management-tools
10
- */
11
- import type { Context } from '@deepseek-ai/cordis';
12
- import { type ToolDefinition } from '@deepseek-ai/dsh-tools';
13
- import { type SessionRootOutcome } from '../../domain/roots/session-roots.ts';
14
- import type { DiscardResult } from '../../app/recycle-bin/recycle-bin-service.ts';
15
- import type { RemoteCopyOutcome } from '../transfer/remote-copy.ts';
16
- import type { RemoteEnvResult } from '../../infra/transport/transport.ts';
17
- import type { TransferResult } from '../transfer/transfer-service.ts';
18
- /** Where one call lands. */
19
- export interface ManagementTarget {
20
- readonly connectionId: string;
21
- /** Backend-absolute root path. */
22
- readonly root: string;
23
- }
24
- /** What {@link formatCopy} renders: the tool's output shape. */
25
- export interface RemoteCopyView {
26
- readonly from: string;
27
- readonly to: string;
28
- readonly bytes: number;
29
- readonly via: 'server' | 'relay';
30
- readonly durationMs: number;
31
- /** 递归复制才有:各类型条目数。 */
32
- readonly files?: number;
33
- readonly dirs?: number;
34
- readonly symlinks?: number;
35
- }
36
- /** One entry as the bin listing shows it. */
37
- export interface TrashEntryView {
38
- readonly id: string;
39
- /** Absolute path the entry was deleted from; restoring puts it back here. */
40
- readonly path: string;
41
- readonly deletedAtMs: number;
42
- readonly sizeBytes: number;
43
- readonly isDirectory: boolean;
44
- }
45
- /**
46
- * What {@link ManagementToolBackend.restore} answers.
47
- *
48
- * One tool, three verbs: look at the bin, put one entry back, or undo the newest discard. They are one union
49
- * rather than three tools because they share every argument and differ only in which is omitted.
50
- */
51
- export type RestoreOutcome = {
52
- readonly kind: 'listed';
53
- readonly entries: readonly TrashEntryView[];
54
- } | {
55
- readonly kind: 'restored';
56
- readonly id: string;
57
- readonly path: string;
58
- readonly verified: boolean;
59
- } | {
60
- readonly kind: 'undone';
61
- readonly action: 'discard' | 'restore';
62
- readonly id: string;
63
- readonly message: string;
64
- };
65
- /** What the tools need, injected so the definitions stay testable without transports. */
66
- export interface ManagementToolBackend {
67
- /** Resolve the calling agent's working directory to a remote root. */
68
- resolve(cwd: string): ManagementTarget | undefined;
69
- /**
70
- * The remote directory this session added with 「添加目录」, when the cwd itself names no remote root.
71
- *
72
- * Same hook as the other tool backends (audit 0086 added it to `remote_exec`/`remote_grep`/`remote_glob` and
73
- * left transfer/delete behind, so a local-cwd session could not upload to a directory it had just added).
74
- * Optional so every existing composition and test keeps working.
75
- *
76
- * @param cwd - the agent's session cwd, used as the workspace identity the add action wrote.
77
- * @returns the single added remote root, a refusal naming several, or `none`.
78
- */
79
- resolveSessionRoot?(cwd: string, sessionId?: string): SessionRootOutcome;
80
- /** Run one upload or download. */
81
- transfer(request: {
82
- readonly target: ManagementTarget;
83
- readonly direction: 'upload' | 'download';
84
- readonly localPath: string;
85
- readonly remotePath: string;
86
- /**
87
- * Continue from whatever prefix already exists at the destination instead of starting over.
88
- *
89
- * The service has supported this since it was written, but the tool never asked for it, so the "resumable"
90
- * in the description was a promise the model could not reach (audit 0097).
91
- */
92
- readonly resume: boolean;
93
- /** Chunks in flight at once; `undefined` means the service default, `1` means sequential. */
94
- readonly concurrency: number | undefined;
95
- /**
96
- * Version token (`remote_stat`/`remote_read`'s `version`) the remote target must still have.
97
- *
98
- * Upload only. Without any guard the tool refuses to overwrite an existing remote file, because that is
99
- * the one operation that silently destroys someone else's work (the same stance `remote_write` takes).
100
- */
101
- readonly expectedVersion?: string | undefined;
102
- /** Content digest the remote target must currently have; passed down to the guarded first write. */
103
- readonly expectedSha256?: string | undefined;
104
- /** Overwrite an existing remote target without any guard. Upload only, and deliberately explicit. */
105
- readonly force?: boolean | undefined;
106
- readonly signal: AbortSignal;
107
- }): Promise<TransferResult>;
108
- /**
109
- * Metadata of the remote destination, for the upload guard above.
110
- *
111
- * Optional so a composition (or a test double) that predates the guard keeps working; absent means the
112
- * tool cannot prove anything about the target and leaves the check to the service layer.
113
- */
114
- statRemote?(target: ManagementTarget, absolute: string): Promise<{
115
- readonly exists: boolean;
116
- readonly version: string;
117
- readonly size: number;
118
- }>;
119
- /** Discard one path, into the bin or permanently. */
120
- discard(request: {
121
- readonly target: ManagementTarget;
122
- readonly path: string;
123
- readonly mode: 'recycle' | 'permanent';
124
- readonly signal: AbortSignal;
125
- }): Promise<DiscardResult>;
126
- /**
127
- * Look at the bin, restore one entry, or undo the newest discard.
128
- *
129
- * The bin service has had `list` / `restore` / `undo` since it was written; only `discard` was ever exposed,
130
- * so a model could delete and then had no way to put anything back (audit 0097).
131
- */
132
- restore(request: {
133
- readonly target: ManagementTarget;
134
- /** Entry to restore; `undefined` means "undo the newest discard". */
135
- readonly id: string | undefined;
136
- /** When true, only report what the bin holds. */
137
- readonly list: boolean;
138
- readonly signal: AbortSignal;
139
- }): Promise<RestoreOutcome>;
140
- /**
141
- * Copy one remote file to another path.
142
- *
143
- * The service prefers a server-side copy, so on a Tier 2 connection the bytes never leave the remote host;
144
- * the outcome says which path was taken rather than leaving the caller to assume.
145
- */
146
- copy(request: {
147
- readonly target: ManagementTarget;
148
- readonly from: string;
149
- readonly to: string;
150
- readonly overwrite: boolean;
151
- readonly recursive?: boolean;
152
- readonly signal: AbortSignal;
153
- }): Promise<RemoteCopyOutcome>;
154
- /**
155
- * 采样远端环境;`undefined` 表示这条连接不支持探测(Tier 1)。
156
- *
157
- * 返回 `undefined` 而不是抛错:没有探测能力不是失败,只是没有答案,工具应当如实说明而不是报错。
158
- */
159
- probeEnv(connectionId: string, refresh: boolean, signal: AbortSignal): Promise<RemoteEnvResult | undefined>;
160
- }
161
- /** Human summary of a finished transfer. */
162
- export declare function formatTransfer(result: TransferResult): string;
163
- /**
164
- * What {@link formatDiscard} renders: the tool's **output** shape, not the service's.
165
- *
166
- * These are not the same object. `execute` projects `DiscardResult` onto the declared schema, where the bin
167
- * entry becomes a flat `entryId` string; the renderer used to read `entry.id` off that projection and therefore
168
- * always printed "(无条目)" for a recycle delete whose id was right there in the structured value (audit 0097).
169
- */
170
- export interface DiscardView {
171
- readonly mode: 'recycle' | 'permanent';
172
- readonly recoverable: boolean;
173
- readonly verified: boolean;
174
- /** The bin entry id, present exactly for a recycle delete that produced an entry. */
175
- readonly entryId?: string | undefined;
176
- readonly warning?: string | undefined;
177
- }
178
- /** Human summary of a discard. */
179
- export declare function formatDiscard(result: DiscardView): string;
180
- /**
181
- * What {@link formatRestore} renders: the tool's **output** shape, not the service's.
182
- *
183
- * `execute` projects {@link RestoreOutcome} onto the declared schema, which renames the discriminant from
184
- * `kind` to `action`. A renderer reading `kind` matches no branch, falls through to the last one, and
185
- * describes the wrong outcome with `undefined` fields — seen live: `list: true` rendered as
186
- * "已恢复 undefined → undefined" (audit 0097).
187
- */
188
- export interface RestoreView {
189
- readonly action: 'listed' | 'restored' | 'undone';
190
- readonly entries?: readonly TrashEntryView[] | undefined;
191
- readonly id?: string | undefined;
192
- readonly path?: string | undefined;
193
- readonly verified?: boolean | undefined;
194
- readonly message?: string | undefined;
195
- }
196
- /** Human summary of a bin listing, a restore, or an undo. */
197
- export declare function formatRestore(result: RestoreView): string;
198
- /** Human summary of a remote-to-remote copy. */
199
- export declare function formatCopy(result: RemoteCopyView): string;
200
- /**
201
- * `remote_env` 的**输出**形状。
202
- *
203
- * 与 `RemoteEnvResult` 分开是必要的:渲染器拿到的是输出 schema 的值,不是内部结果。早先直接
204
- * 复用内部类型,渲染时访问 `tools`(输出里没有这个字段)当场抛错——类型对不上,运行期才暴露。
205
- */
206
- export interface RemoteEnvView {
207
- readonly os: string;
208
- readonly arch: string;
209
- readonly cpus: number;
210
- readonly user: string;
211
- readonly uid: number;
212
- readonly home: string;
213
- readonly probedAt: number;
214
- readonly available: readonly string[];
215
- readonly missing: readonly string[];
216
- readonly kernel?: string | undefined;
217
- readonly distro?: string | undefined;
218
- readonly shell?: string | undefined;
219
- readonly memTotalBytes?: number | undefined;
220
- readonly memAvailableBytes?: number | undefined;
221
- readonly diskFreeBytes?: number | undefined;
222
- readonly diskTotalBytes?: number | undefined;
223
- }
224
- /** Render one environment sample for the model. */
225
- export declare function formatEnv(result: RemoteEnvView): string;
226
- /**
227
- * Build the two definitions.
228
- *
229
- * @param backend - injected implementations.
230
- * @returns definitions ready for `ctx.tools.register`.
231
- */
232
- export declare function managementToolDefinitions(backend: ManagementToolBackend): ToolDefinition[];
233
- /**
234
- * Gate irreversible deletions behind the platform's approval surface.
235
- *
236
- * A **denial by default** is deliberate: when the composition has no approval support, the registry turns
237
- * `ask` into a denial, which is the right outcome for an operation that bypasses `ctx.fs` and cannot be undone.
238
- *
239
- * @param ctx - host context with the `tools` service.
240
- * @returns a disposer removing the gate.
241
- */
242
- export declare function permanentDeleteGate(ctx: Context): () => void;
243
- /** Register both tools and the gate. */
244
- export declare function registerManagementTools(ctx: Context, backend: ManagementToolBackend): () => void;
245
- //# sourceMappingURL=management-tools.d.ts.map