dsh-over-ssh 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/README.md +19 -17
  2. package/agents/agent-manifest.json +6 -6
  3. package/agents/linux-amd64/dsh-over-ssh-agent +0 -0
  4. package/agents/linux-arm64/dsh-over-ssh-agent +0 -0
  5. package/lib/client.js +422 -337
  6. package/lib/file-references.js +92 -35
  7. package/lib/fs.js +295 -113
  8. package/lib/index.js +6912 -4330
  9. package/lib/terminal-wrapper.js +9 -4
  10. package/lib/types/src/config.d.ts +156 -9
  11. package/lib/types/src/file-references.d.ts +0 -1
  12. package/lib/types/src/host/app/backend.d.ts +44 -3
  13. package/lib/types/src/host/app/recycle-bin/recycle-bin-contract.d.ts +0 -1
  14. package/lib/types/src/host/app/recycle-bin/recycle-bin-service.d.ts +0 -1
  15. package/lib/types/src/host/app/session-admin/session-admin-contract.d.ts +12 -1
  16. package/lib/types/src/host/app/session-admin/session-admin-service.d.ts +0 -1
  17. package/lib/types/src/host/app/transport/transport-selector.d.ts +0 -1
  18. package/lib/types/src/host/app/transport/transport-service.d.ts +0 -1
  19. package/lib/types/src/host/domain/capability.d.ts +0 -1
  20. package/lib/types/src/host/domain/errors.d.ts +0 -1
  21. package/lib/types/src/host/domain/roots/connection.d.ts +0 -1
  22. package/lib/types/src/host/domain/roots/root.d.ts +24 -9
  23. package/lib/types/src/host/domain/roots/session-roots.d.ts +23 -1
  24. package/lib/types/src/host/domain/roots/ssh-config.d.ts +0 -1
  25. package/lib/types/src/host/domain/session/session-admin.d.ts +0 -1
  26. package/lib/types/src/host/domain/transfer/recycle-bin.d.ts +0 -1
  27. package/lib/types/src/host/domain/transfer/transfer.d.ts +0 -1
  28. package/lib/types/src/host/infra/transport/agent/agent-installer.d.ts +0 -1
  29. package/lib/types/src/host/infra/transport/forward.d.ts +75 -0
  30. package/lib/types/src/host/infra/transport/ssh/ssh2-transport.d.ts +5 -1
  31. package/lib/types/src/host/infra/transport/transport-base.d.ts +0 -1
  32. package/lib/types/src/host/infra/transport/transport.d.ts +42 -2
  33. package/lib/types/src/host/integration/agent/agent-preflight.d.ts +0 -1
  34. package/lib/types/src/host/integration/fs/file-reference-provider.d.ts +0 -1
  35. package/lib/types/src/host/integration/fs/fs-provider.d.ts +18 -3
  36. package/lib/types/src/host/integration/transfer/transfer-service.d.ts +0 -1
  37. package/lib/types/src/index.d.ts +23 -1
  38. package/lib/types/src/local-bridge-refs.d.ts +0 -1
  39. package/lib/types/src/local-bridge.d.ts +0 -1
  40. package/lib/types/src/shared/root-keys.d.ts +120 -0
  41. package/lib/types/src/wiring/helpers.d.ts +0 -1
  42. package/package.json +5 -3
  43. package/lib/types/src/client/controls.d.ts +0 -131
  44. package/lib/types/src/client/core/card-focus-trap.d.ts +0 -45
  45. package/lib/types/src/client/core/controls.d.ts +0 -164
  46. package/lib/types/src/client/core/latest.d.ts +0 -48
  47. package/lib/types/src/client/core/locale.d.ts +0 -38
  48. package/lib/types/src/client/core/message.d.ts +0 -37
  49. package/lib/types/src/client/core/panel-model.d.ts +0 -134
  50. package/lib/types/src/client/core/portal.d.ts +0 -266
  51. package/lib/types/src/client/core/remote.d.ts +0 -84
  52. package/lib/types/src/client/core/styles.d.ts +0 -458
  53. package/lib/types/src/client/file-tree-io.d.ts +0 -19
  54. package/lib/types/src/client/file-tree.d.ts +0 -271
  55. package/lib/types/src/client/flows/directory-browser.d.ts +0 -587
  56. package/lib/types/src/client/flows/session-directory.d.ts +0 -415
  57. package/lib/types/src/client/flows/workspace-directory-flow.d.ts +0 -480
  58. package/lib/types/src/client/locale.d.ts +0 -31
  59. package/lib/types/src/client/panel-model.d.ts +0 -37
  60. package/lib/types/src/client/panel.d.ts +0 -77
  61. package/lib/types/src/client/roots/connection-test.d.ts +0 -69
  62. package/lib/types/src/client/roots/roots-panel-state.d.ts +0 -307
  63. package/lib/types/src/client/roots/roots-panel-view.d.ts +0 -280
  64. package/lib/types/src/client/roots/roots-panel.d.ts +0 -364
  65. package/lib/types/src/client/roots/transfer-panel-view.d.ts +0 -35
  66. package/lib/types/src/client/roots/transfer-panel.d.ts +0 -241
  67. package/lib/types/src/client/roots/transfer-progress.d.ts +0 -67
  68. package/lib/types/src/client/roots-panel-view.d.ts +0 -236
  69. package/lib/types/src/client/roots-panel.d.ts +0 -347
  70. package/lib/types/src/client/session/session-panel-view.d.ts +0 -336
  71. package/lib/types/src/client/session/session-panel.d.ts +0 -322
  72. package/lib/types/src/client/session/session-remote-mark.d.ts +0 -110
  73. package/lib/types/src/client/session/session-row-actions.d.ts +0 -398
  74. package/lib/types/src/client/session-panel.d.ts +0 -152
  75. package/lib/types/src/client/styles.d.ts +0 -252
  76. package/lib/types/src/client/workspace-directory-flow.d.ts +0 -342
  77. package/lib/types/src/fs.d.ts +0 -46
  78. package/lib/types/src/host/app/recycle-bin/recycle-bin-move.d.ts +0 -18
  79. package/lib/types/src/host/app/recycle-bin/recycle-bin-world.d.ts +0 -38
  80. package/lib/types/src/host/app/recycle-bin-contract.d.ts +0 -215
  81. package/lib/types/src/host/app/recycle-bin-move.d.ts +0 -18
  82. package/lib/types/src/host/app/recycle-bin-service.d.ts +0 -45
  83. package/lib/types/src/host/app/recycle-bin-world.d.ts +0 -35
  84. package/lib/types/src/host/app/roots/roots-api-connections.d.ts +0 -49
  85. package/lib/types/src/host/app/roots/roots-api-contract.d.ts +0 -369
  86. package/lib/types/src/host/app/roots/roots-api-directories.d.ts +0 -13
  87. package/lib/types/src/host/app/roots/roots-api-http.d.ts +0 -77
  88. package/lib/types/src/host/app/roots/roots-api-long-poll.d.ts +0 -130
  89. package/lib/types/src/host/app/roots/roots-api-projections.d.ts +0 -102
  90. package/lib/types/src/host/app/roots/roots-api-roots.d.ts +0 -13
  91. package/lib/types/src/host/app/roots/roots-api-state.d.ts +0 -22
  92. package/lib/types/src/host/app/roots/roots-api-transfers.d.ts +0 -26
  93. package/lib/types/src/host/app/roots/roots-api.d.ts +0 -55
  94. package/lib/types/src/host/app/roots/user-roots.d.ts +0 -552
  95. package/lib/types/src/host/app/roots-api-connections.d.ts +0 -49
  96. package/lib/types/src/host/app/roots-api-contract.d.ts +0 -339
  97. package/lib/types/src/host/app/roots-api-directories.d.ts +0 -13
  98. package/lib/types/src/host/app/roots-api-http.d.ts +0 -77
  99. package/lib/types/src/host/app/roots-api-projections.d.ts +0 -102
  100. package/lib/types/src/host/app/roots-api-roots.d.ts +0 -13
  101. package/lib/types/src/host/app/roots-api-state.d.ts +0 -22
  102. package/lib/types/src/host/app/roots-api-support.d.ts +0 -182
  103. package/lib/types/src/host/app/roots-api-transfers.d.ts +0 -13
  104. package/lib/types/src/host/app/roots-api.d.ts +0 -55
  105. package/lib/types/src/host/app/routed-fs.d.ts +0 -239
  106. package/lib/types/src/host/app/serialize.d.ts +0 -37
  107. package/lib/types/src/host/app/session-admin/session-admin-context.d.ts +0 -36
  108. package/lib/types/src/host/app/session-admin/session-admin-delete.d.ts +0 -34
  109. package/lib/types/src/host/app/session-admin-context.d.ts +0 -36
  110. package/lib/types/src/host/app/session-admin-contract.d.ts +0 -214
  111. package/lib/types/src/host/app/session-admin-delete.d.ts +0 -34
  112. package/lib/types/src/host/app/session-admin-service.d.ts +0 -38
  113. package/lib/types/src/host/app/takeover/takeover-plan.d.ts +0 -227
  114. package/lib/types/src/host/app/takeover/takeover-rows.d.ts +0 -55
  115. package/lib/types/src/host/app/transport-selector.d.ts +0 -98
  116. package/lib/types/src/host/app/transport-service.d.ts +0 -75
  117. package/lib/types/src/host/app/user-roots.d.ts +0 -461
  118. package/lib/types/src/host/domain/bin-location.d.ts +0 -79
  119. package/lib/types/src/host/domain/connection.d.ts +0 -95
  120. package/lib/types/src/host/domain/glob-pattern.d.ts +0 -62
  121. package/lib/types/src/host/domain/literal-text.d.ts +0 -63
  122. package/lib/types/src/host/domain/path-grammar.d.ts +0 -84
  123. package/lib/types/src/host/domain/recycle-bin.d.ts +0 -337
  124. package/lib/types/src/host/domain/root.d.ts +0 -74
  125. package/lib/types/src/host/domain/roots/bin-location.d.ts +0 -91
  126. package/lib/types/src/host/domain/roots/route-table.d.ts +0 -102
  127. package/lib/types/src/host/domain/route-table.d.ts +0 -80
  128. package/lib/types/src/host/domain/session/terminal-target.d.ts +0 -136
  129. package/lib/types/src/host/domain/session-admin.d.ts +0 -330
  130. package/lib/types/src/host/domain/shell.d.ts +0 -47
  131. package/lib/types/src/host/domain/ssh-config.d.ts +0 -73
  132. package/lib/types/src/host/domain/terminal-target.d.ts +0 -132
  133. package/lib/types/src/host/domain/tool-requests.d.ts +0 -369
  134. package/lib/types/src/host/domain/transfer.d.ts +0 -260
  135. package/lib/types/src/host/infra/backend/local-backend.d.ts +0 -84
  136. package/lib/types/src/host/infra/backend/local-version.d.ts +0 -43
  137. package/lib/types/src/host/infra/backend/platform-local-backend.d.ts +0 -89
  138. package/lib/types/src/host/infra/backend/remote-backend.d.ts +0 -239
  139. package/lib/types/src/host/infra/cache/lru.d.ts +0 -52
  140. package/lib/types/src/host/infra/cache/versioned.d.ts +0 -77
  141. package/lib/types/src/host/infra/temp-name.d.ts +0 -19
  142. package/lib/types/src/host/infra/transport/agent/agent-protocol-client.d.ts +0 -132
  143. package/lib/types/src/host/infra/transport/agent/agent-protocol-codec.d.ts +0 -140
  144. package/lib/types/src/host/infra/transport/agent/agent-protocol-errors.d.ts +0 -41
  145. package/lib/types/src/host/infra/transport/agent/agent-protocol-frames.d.ts +0 -197
  146. package/lib/types/src/host/infra/transport/agent/agent-protocol-types.d.ts +0 -564
  147. package/lib/types/src/host/infra/transport/agent/agent-transport.d.ts +0 -418
  148. package/lib/types/src/host/infra/transport/agent-installer.d.ts +0 -121
  149. package/lib/types/src/host/infra/transport/agent-protocol-client.d.ts +0 -123
  150. package/lib/types/src/host/infra/transport/agent-protocol-codec.d.ts +0 -131
  151. package/lib/types/src/host/infra/transport/agent-protocol-errors.d.ts +0 -41
  152. package/lib/types/src/host/infra/transport/agent-protocol-frames.d.ts +0 -197
  153. package/lib/types/src/host/infra/transport/agent-protocol-types.d.ts +0 -509
  154. package/lib/types/src/host/infra/transport/agent-transport.d.ts +0 -353
  155. package/lib/types/src/host/infra/transport/alias-transport.d.ts +0 -206
  156. package/lib/types/src/host/infra/transport/askpass-fs.d.ts +0 -20
  157. package/lib/types/src/host/infra/transport/askpass.d.ts +0 -133
  158. package/lib/types/src/host/infra/transport/command-pool.d.ts +0 -61
  159. package/lib/types/src/host/infra/transport/fs-commands.d.ts +0 -140
  160. package/lib/types/src/host/infra/transport/git-status-route.d.ts +0 -63
  161. package/lib/types/src/host/infra/transport/git-status.d.ts +0 -101
  162. package/lib/types/src/host/infra/transport/node-spawn.d.ts +0 -26
  163. package/lib/types/src/host/infra/transport/session-window.d.ts +0 -51
  164. package/lib/types/src/host/infra/transport/shell-quote.d.ts +0 -59
  165. package/lib/types/src/host/infra/transport/ssh/alias-transport.d.ts +0 -206
  166. package/lib/types/src/host/infra/transport/ssh/askpass-fs.d.ts +0 -20
  167. package/lib/types/src/host/infra/transport/ssh/askpass.d.ts +0 -133
  168. package/lib/types/src/host/infra/transport/ssh/shell-quote.d.ts +0 -62
  169. package/lib/types/src/host/infra/transport/ssh/ssh-argv.d.ts +0 -43
  170. package/lib/types/src/host/infra/transport/ssh-argv.d.ts +0 -43
  171. package/lib/types/src/host/infra/transport/ssh2-transport.d.ts +0 -302
  172. package/lib/types/src/host/integration/agent/agent-install-io.d.ts +0 -33
  173. package/lib/types/src/host/integration/agent/askpass-registry.d.ts +0 -66
  174. package/lib/types/src/host/integration/agent-install-io.d.ts +0 -33
  175. package/lib/types/src/host/integration/agent-preflight.d.ts +0 -56
  176. package/lib/types/src/host/integration/anchor-directory.d.ts +0 -56
  177. package/lib/types/src/host/integration/askpass-registry.d.ts +0 -59
  178. package/lib/types/src/host/integration/bin-root-resolver.d.ts +0 -81
  179. package/lib/types/src/host/integration/connection-test.d.ts +0 -73
  180. package/lib/types/src/host/integration/file-reference-provider.d.ts +0 -115
  181. package/lib/types/src/host/integration/fs/git-status-wiring.d.ts +0 -21
  182. package/lib/types/src/host/integration/fs/platform-errors.d.ts +0 -94
  183. package/lib/types/src/host/integration/fs/remote-file-tools.d.ts +0 -369
  184. package/lib/types/src/host/integration/fs/remote-index.d.ts +0 -177
  185. package/lib/types/src/host/integration/fs-provider.d.ts +0 -226
  186. package/lib/types/src/host/integration/lsp/lsp-framing.d.ts +0 -38
  187. package/lib/types/src/host/integration/lsp/lsp-registry.d.ts +0 -67
  188. package/lib/types/src/host/integration/lsp/lsp-session.d.ts +0 -130
  189. package/lib/types/src/host/integration/management-tools.d.ts +0 -64
  190. package/lib/types/src/host/integration/recycle-bin-service.d.ts +0 -247
  191. package/lib/types/src/host/integration/remote/connection-test.d.ts +0 -73
  192. package/lib/types/src/host/integration/remote/remote-face.d.ts +0 -127
  193. package/lib/types/src/host/integration/remote/remote-tool-backend.d.ts +0 -108
  194. package/lib/types/src/host/integration/remote-face.d.ts +0 -127
  195. package/lib/types/src/host/integration/remote-file-tools.d.ts +0 -241
  196. package/lib/types/src/host/integration/remote-home.d.ts +0 -69
  197. package/lib/types/src/host/integration/remote-index.d.ts +0 -165
  198. package/lib/types/src/host/integration/remote-job-tools.d.ts +0 -295
  199. package/lib/types/src/host/integration/remote-tool-backend.d.ts +0 -97
  200. package/lib/types/src/host/integration/remote-tools.d.ts +0 -206
  201. package/lib/types/src/host/integration/root-registry.d.ts +0 -115
  202. package/lib/types/src/host/integration/roots/anchor-directory.d.ts +0 -56
  203. package/lib/types/src/host/integration/roots/bin-root-resolver.d.ts +0 -81
  204. package/lib/types/src/host/integration/roots/remote-home.d.ts +0 -69
  205. package/lib/types/src/host/integration/roots/root-registry.d.ts +0 -144
  206. package/lib/types/src/host/integration/roots/roots-wiring.d.ts +0 -219
  207. package/lib/types/src/host/integration/roots/session-root-index.d.ts +0 -52
  208. package/lib/types/src/host/integration/roots-api.d.ts +0 -407
  209. package/lib/types/src/host/integration/roots-wiring.d.ts +0 -211
  210. package/lib/types/src/host/integration/session/session-api.d.ts +0 -88
  211. package/lib/types/src/host/integration/session/session-bin-lock.d.ts +0 -80
  212. package/lib/types/src/host/integration/session/session-header.d.ts +0 -151
  213. package/lib/types/src/host/integration/session/session-labels.d.ts +0 -56
  214. package/lib/types/src/host/integration/session/session-route-wiring.d.ts +0 -50
  215. package/lib/types/src/host/integration/session-admin-service.d.ts +0 -236
  216. package/lib/types/src/host/integration/session-api.d.ts +0 -81
  217. package/lib/types/src/host/integration/session-bin-lock.d.ts +0 -80
  218. package/lib/types/src/host/integration/session-header.d.ts +0 -118
  219. package/lib/types/src/host/integration/session-labels.d.ts +0 -56
  220. package/lib/types/src/host/integration/session-route-wiring.d.ts +0 -50
  221. package/lib/types/src/host/integration/session-scope.d.ts +0 -113
  222. package/lib/types/src/host/integration/session-tools.d.ts +0 -44
  223. package/lib/types/src/host/integration/strict-arguments.d.ts +0 -79
  224. package/lib/types/src/host/integration/takeover/takeover-api.d.ts +0 -62
  225. package/lib/types/src/host/integration/takeover/takeover-route-wiring.d.ts +0 -60
  226. package/lib/types/src/host/integration/takeover/takeover-service.d.ts +0 -167
  227. package/lib/types/src/host/integration/terminal-manifest.d.ts +0 -94
  228. package/lib/types/src/host/integration/tools/management-tools.d.ts +0 -245
  229. package/lib/types/src/host/integration/tools/remote-job-tools.d.ts +0 -316
  230. package/lib/types/src/host/integration/tools/remote-lsp-tools.d.ts +0 -43
  231. package/lib/types/src/host/integration/tools/remote-tools.d.ts +0 -236
  232. package/lib/types/src/host/integration/tools/session-target.d.ts +0 -52
  233. package/lib/types/src/host/integration/tools/session-tools.d.ts +0 -46
  234. package/lib/types/src/host/integration/tools/strict-arguments.d.ts +0 -79
  235. package/lib/types/src/host/integration/tools/terminal-manifest.d.ts +0 -94
  236. package/lib/types/src/host/integration/transfer/remote-copy.d.ts +0 -66
  237. package/lib/types/src/host/integration/transfer/transfer-adapters.d.ts +0 -48
  238. package/lib/types/src/host/integration/transfer/transfer-tracker.d.ts +0 -106
  239. package/lib/types/src/host/integration/transfer-adapters.d.ts +0 -44
  240. package/lib/types/src/host/integration/transfer-service.d.ts +0 -164
  241. package/lib/types/src/host/integration/transfer-tracker.d.ts +0 -106
  242. package/lib/types/src/host/integration/user-roots.d.ts +0 -461
  243. package/lib/types/src/wiring/connections.d.ts +0 -189
  244. package/lib/types/src/wiring/fs.d.ts +0 -13
  245. package/lib/types/src/wiring/install-memo.d.ts +0 -32
  246. package/lib/types/src/wiring/legacy-dirs.d.ts +0 -62
  247. package/lib/types/src/wiring/package-paths.d.ts +0 -35
  248. package/lib/types/src/wiring/roots.d.ts +0 -21
  249. package/lib/types/src/wiring/state-dir.d.ts +0 -29
  250. package/lib/types/src/wiring/tools.d.ts +0 -35
@@ -1,509 +0,0 @@
1
- /**
2
- * 代理协议的**类型层**:会话/启动器抽象、协议方法请求与响应 DTO、各类默认上限、能力映射。
3
- *
4
- * 从 `agent-transport.ts` 拆出(审计 0077)。放在帧层之上、客户端之下:客户端与传输适配器
5
- * 都需要这些类型,若留在任一侧都会形成环。
6
- *
7
- * @module dsh-remote-workspace/infra/transport/agent-protocol-types
8
- */
9
- import { type RemoteCapabilities } from '../../domain/capability.ts';
10
- import { type ExecRequest, type ExecResult } from './transport.ts';
11
- export interface AgentSession {
12
- /** Send bytes to the agent's stdin. */
13
- write(bytes: Uint8Array): void;
14
- /** Observe stdout bytes. Called once at most; the session keeps ownership of its own handlers. */
15
- onData(callback: (chunk: Uint8Array) => void): void;
16
- /** Observe the remote process's exit. Called once at most. */
17
- onExit(callback: (code: number | null) => void): void;
18
- /** Terminate the session; safe to call more than once. */
19
- close(): void;
20
- }
21
- /** Options handed to a launcher. Kept inert so tests can assert on the launch shape. */
22
- export interface AgentSessionOptions {
23
- /** ssh alias (or `user@host`) that carries the user's own ssh configuration. */
24
- readonly alias: string;
25
- /** Remote command line for the agent; defaults to `<agentPath> --stdio`. */
26
- readonly remoteCommand: string;
27
- /** `ssh` argv *without* the remote command, e.g. `['ssh','-T','-o','BatchMode=yes','gpu01']`. */
28
- readonly sshArgv: readonly string[];
29
- /**
30
- * Extra environment for the `ssh` child, merged over the parent's.
31
- *
32
- * Carries the askpass wiring for password connections (`askpass.ts`): the agent session must authenticate
33
- * exactly like the ladder that installed it, so a password connection needs the helper here too.
34
- */
35
- readonly env?: Record<string, string>;
36
- /** Cancellation for the launch itself. */
37
- readonly signal?: AbortSignal;
38
- }
39
- /** Opens one agent session; injected so tests never start a process. */
40
- export type AgentLauncher = (options: AgentSessionOptions) => Promise<AgentSession>;
41
- /** Run one remote command through the agent. Injected: protocol v1 has no command-execution method. */
42
- export type AgentExecCommand = (request: ExecRequest, signal?: AbortSignal) => Promise<ExecResult>;
43
- /** Construction options for {@link AgentTransport}. */
44
- export interface AgentTransportOptions {
45
- /** Connection id (also the pool key). */
46
- readonly connectionId: string;
47
- /** Session factory; defaults to {@link defaultLauncher} (real `ssh` over `node:child_process`). */
48
- readonly launch?: AgentLauncher;
49
- /** `ssh` argv *without* the remote command. Used by the default launcher. */
50
- readonly sshArgv?: readonly string[];
51
- /** Extra environment for the `ssh` child that carries the session; see {@link AgentSessionOptions.env}. */
52
- readonly env?: Record<string, string>;
53
- /** Remote path of the agent binary; used by the default launcher. */
54
- readonly agentPath?: string;
55
- /** Extra argv inserted after the agent path (before the mode flag). */
56
- readonly agentArgs?: readonly string[];
57
- /**
58
- * Mode flag handed to the agent: {@link DEFAULT_AGENT_MODE} (`--shared`, prefer a resident daemon)
59
- * or {@link STDIO_AGENT_MODE} (`--stdio`, one process per connection).
60
- *
61
- * `--shared` is the default because it is what makes "one agent process serving many sessions" real:
62
- * jobs, LSP sessions and index snapshots are shared instead of duplicated per connection. The agent
63
- * falls back to `--stdio` on its own when no daemon can run, so this does not remove the Tier 2
64
- * capability on hosts where the daemon is unavailable.
65
- */
66
- readonly agentMode?: string;
67
- /** Command runner for {@link AgentTransport.exec}; see the module note about protocol v1. */
68
- readonly execCommand?: AgentExecCommand;
69
- /** Method name used by the default {@link AgentTransport.exec}; defaults to `proc.exec`. */
70
- readonly execMethod?: string;
71
- /** Deadline applied to one request when the caller names none. Default 15 s. */
72
- readonly requestTimeoutMs?: number;
73
- /**
74
- * How many requests may be in flight on this connection. Defaults to
75
- * {@link DEFAULT_AGENT_MAX_IN_FLIGHT} (8), which mirrors the agent's own limit; set `1` to restore the
76
- * old strictly serial behaviour.
77
- */
78
- readonly maxInFlight?: number;
79
- /** Client identifier sent in `hello`; defaults to {@link AGENT_CLIENT_ID}. */
80
- readonly clientId?: string;
81
- /**
82
- * Default session for every request on this connection (`hello.params.sessionId`).
83
- *
84
- * Omitted means the field is not sent at all, so the agent uses its own `"default"` and this connection
85
- * behaves exactly as it did before sessions existed. Set it when several logical sessions share one
86
- * connection: the agent then gives each its own share of the in-flight window, which is what stops one
87
- * session's long request from queueing another's short one (audit 0021: 3502 ms → 0.7 ms).
88
- */
89
- readonly sessionId?: string;
90
- /** Injectable clock (diagnostics and duration measurement). */
91
- readonly now?: () => number;
92
- }
93
- /** One decoded frame. */
94
- export declare const DEFAULT_INDEX_MAX_ENTRIES = 20000;
95
- /** Client-side default for `index.scan` `maxDepth`; mirrors the agent's `index.DefaultMaxDepth`. */
96
- export declare const DEFAULT_INDEX_MAX_DEPTH = 12;
97
- /** Client-side default for `index.scan` / `search.grep` `timeoutMs` (agent: 5000 ms). */
98
- export declare const DEFAULT_INDEX_TIMEOUT_MS = 5000;
99
- /** Client-side default for `search.grep` `maxResults`; mirrors the agent's `search.DefaultMaxResults`. */
100
- export declare const DEFAULT_SEARCH_MAX_RESULTS = 1000;
101
- /** Client-side default for `search.grep` `maxFileBytes` (agent: 8 MiB). */
102
- export declare const DEFAULT_SEARCH_MAX_FILE_BYTES: number;
103
- /** Client-side default for `search.grep` `maxBytesScanned` (agent: 512 MiB). */
104
- export declare const DEFAULT_SEARCH_MAX_BYTES_SCANNED: number;
105
- /** Client-side default for `search.grep` `maxLineBytes` (agent: 1 MiB). */
106
- export declare const DEFAULT_SEARCH_MAX_LINE_BYTES: number;
107
- /** Client-side default for `watch.start` `maxWatches`; mirrors the agent's `watch.DefaultMaxWatches`. */
108
- export declare const DEFAULT_WATCH_MAX_WATCHES = 4096;
109
- /** Client-side default for `watch.start` `debounceMs`; mirrors the agent's `watch.DefaultDebounceMs`. */
110
- export declare const DEFAULT_WATCH_DEBOUNCE_MS = 150;
111
- /** Client-side default for `watch.poll` `timeoutMs`; mirrors the agent's `watch.DefaultPollTimeoutMs`. */
112
- export declare const DEFAULT_WATCH_POLL_TIMEOUT_MS = 1000;
113
- /** Client-side default for `watch.poll` `maxEvents`; mirrors the agent's `watch.DefaultMaxEvents`. */
114
- export declare const DEFAULT_WATCH_MAX_EVENTS = 256;
115
- /** One indexed file (`index.scan` `entries[i]`). */
116
- export interface AgentIndexEntry {
117
- /** Absolute remote path. */
118
- readonly path: string;
119
- /** File size in bytes as reported by the agent (`size`). */
120
- readonly size: number;
121
- /**
122
- * Modification time in **milliseconds** since the epoch, converted from the agent's `mtimeNs`.
123
- * `null` when the agent sent no usable `mtimeNs`.
124
- */
125
- readonly mtimeMs: number | null;
126
- /**
127
- * Whether the entry is a directory. v1's `index.scan` enumerates **files only** and sends no `isDir`,
128
- * so this is `false` unless a future agent adds the field.
129
- */
130
- readonly isDir: boolean;
131
- }
132
- /** Result of {@link AgentTransport.scanIndex} (`index.scan`). */
133
- export interface AgentIndexScanResult {
134
- /** Entries in the order the agent returned them (the agent sorts by path). */
135
- readonly entries: readonly AgentIndexEntry[];
136
- /** `"git-ls-files"` / `"find-bounded"` as reported; `"unknown"` when the agent sent nothing usable. */
137
- readonly strategy: string;
138
- /** True when any of the four bounds (entries / depth / excludes / deadline) fired. */
139
- readonly truncated: boolean;
140
- /** Files enumerated (`scanned` on the wire); `0` when absent. */
141
- readonly filesScanned: number;
142
- /** Per-root problems the agent chose not to fail on (`warnings`); empty when absent. */
143
- readonly warnings: readonly string[];
144
- /** Agent-side duration in ms, or `null` when absent. */
145
- readonly durationMs: number | null;
146
- }
147
- /** {@link AgentTransport.procStart} request. Mirrors the agent's `proc.exec` fields plus an output cap. */
148
- export interface AgentProcStartRequest {
149
- /** A command line; exactly one of `argv`/`script` must be given (the agent refuses both). */
150
- readonly argv?: readonly string[];
151
- /** A shell script, run via `/bin/sh -c` (POSIX) or `cmd /c` (Windows). */
152
- readonly script?: string;
153
- readonly cwd?: string;
154
- readonly env?: Readonly<Record<string, string>>;
155
- /** Text written to stdin, then closed. Mutually exclusive with `stdinBytes`. */
156
- readonly stdin?: string;
157
- /** Bytes written to stdin, then closed (base64 on the wire). Mutually exclusive with `stdin`. */
158
- readonly stdinBytes?: Uint8Array;
159
- /** Keep the stdin pipe open so `proc.stdin` can append input later (审计 0030). */
160
- readonly interactive?: boolean;
161
- /**
162
- * Kill the job after this long. **0 or absent means no limit** - unlike `proc.exec`, where a missing
163
- * timeout means the agent's default.
164
- */
165
- readonly timeoutMs?: number;
166
- /** Retained output cap (the agent's ring buffer drops the oldest bytes past it). */
167
- readonly maxOutputBytes?: number;
168
- /**
169
- * Landlock write fence: when non-empty the job may only write under these roots.
170
- * The agent refuses with `REMOTE_UNSUPPORTED` when it cannot build the fence rather than running unfenced.
171
- */
172
- readonly writeRoots?: readonly string[];
173
- }
174
- /** One background job (`proc.start` / `proc.status` / `proc.list`). */
175
- export interface AgentJobStatus {
176
- readonly id: string;
177
- /** `running` / `exited` / `killed` / `failed`. */
178
- readonly state: string;
179
- readonly command: string;
180
- readonly pid?: number;
181
- readonly exitCode: number;
182
- readonly signal?: string;
183
- readonly timedOut: boolean;
184
- readonly startedMs: number;
185
- readonly durationMs: number;
186
- readonly outputBytes: number;
187
- /** Bytes dropped from the **oldest** end of the ring buffer; non-zero means the output has a hole. */
188
- readonly droppedBytes: number;
189
- }
190
- /** {@link AgentTransport.procKill} result. `killed: false` for a job that had already finished. */
191
- export interface AgentJobKill {
192
- readonly id: string;
193
- readonly killed: boolean;
194
- readonly state: string;
195
- }
196
- /** {@link AgentTransport.procOutput} result. */
197
- export interface AgentJobOutput {
198
- readonly id: string;
199
- readonly state: string;
200
- readonly data: string;
201
- /** Pass this as the next `offset` to get only what is new. */
202
- readonly nextOffset: number;
203
- readonly droppedBytes: number;
204
- readonly totalBytes: number;
205
- /** True when the requested span was already dropped: `data` is not continuous output. */
206
- readonly lost: boolean;
207
- readonly exitCode: number;
208
- readonly signal?: string;
209
- readonly timedOut: boolean;
210
- }
211
- /** {@link AgentTransport.lspStart} request. */
212
- export interface AgentLspStartRequest {
213
- /** The language server executable (a name on PATH or an absolute path). */
214
- readonly command: string;
215
- readonly args?: readonly string[];
216
- /** Working directory - language servers use it to find project config, so it matters. */
217
- readonly cwd?: string;
218
- readonly env?: Readonly<Record<string, string>>;
219
- readonly maxOutputBytes?: number;
220
- }
221
- /** One language-server session (`lsp.start` / `lsp.status` / `lsp.stop`). */
222
- export interface AgentLspStatus {
223
- readonly id: string;
224
- readonly command: string;
225
- /** `running` / `exited`. */
226
- readonly state: string;
227
- readonly pid?: number;
228
- readonly exitCode: number;
229
- readonly startedMs: number;
230
- readonly durationMs: number;
231
- readonly outputBytes: number;
232
- readonly droppedBytes: number;
233
- readonly wroteBytes: number;
234
- /**
235
- * Session that owns this language server (ADR-0011).
236
- *
237
- * With `--shared` the agent's LSP session table is **one global table per daemon** - deliberately,
238
- * because language servers are memory-heavy and one process per connection fights the "low memory"
239
- * goal. Sharing is why `lsp.list`/`lsp.read` can see another session's server, and ownership is why
240
- * `lsp.stop`/`lsp.forget` cannot touch it: an ownerless kill would leave the victim unable to tell
241
- * what happened (it only sees `exited`). Absent on agents that predate ADR-0011.
242
- */
243
- readonly session?: string;
244
- }
245
- /** {@link AgentTransport.lspRead} result. */
246
- export interface AgentLspRead {
247
- readonly id: string;
248
- /** Raw LSP bytes (a `Content-Length`-framed JSON-RPC stream) - the agent does not parse them. */
249
- readonly data: string;
250
- readonly nextOffset: number;
251
- readonly state: string;
252
- readonly droppedBytes: number;
253
- readonly totalBytes: number;
254
- readonly lost: boolean;
255
- }
256
- /** {@link AgentTransport.scanIndex} request. Untyped fields are omitted from the frame, not defaulted. */
257
- export interface AgentIndexScanRequest {
258
- /** Absolute remote roots. Empty is a local `REMOTE_COMMAND_FAILED` (`E_PARAMS` on the wire). */
259
- readonly roots: readonly string[];
260
- /** Entry ceiling; the agent applies {@link DEFAULT_INDEX_MAX_ENTRIES} when omitted or non-positive. */
261
- readonly maxEntries?: number;
262
- /** Depth ceiling; the agent applies {@link DEFAULT_INDEX_MAX_DEPTH} when omitted or non-positive. */
263
- readonly maxDepth?: number;
264
- /** Directory names to skip; omitted means the agent's built-in noise table. */
265
- readonly exclude?: readonly string[];
266
- /** Agent-side deadline; the agent applies {@link DEFAULT_INDEX_TIMEOUT_MS} when omitted or non-positive. */
267
- readonly timeoutMs?: number;
268
- /** `false` forces the standard-library walk (the agent's `preferGit`, diagnostic escape hatch). */
269
- readonly preferGit?: boolean;
270
- }
271
- /** One content match (`search.grep` `matches[i]`). */
272
- export interface AgentSearchMatch {
273
- /** Absolute remote path. */
274
- readonly path: string;
275
- /** 1-based line number as reported. */
276
- readonly line: number;
277
- /** 1-based column as reported; `0` when the agent sent no column (it does send one today). */
278
- readonly column: number;
279
- /** The matched line's text, exactly as the agent sent it. */
280
- readonly text: string;
281
- /** Context lines before the match (`before`); empty when absent. */
282
- readonly before: readonly string[];
283
- /** Context lines after the match (`after`); empty when absent. */
284
- readonly after: readonly string[];
285
- }
286
- /** Result of {@link AgentTransport.searchGrep} (`search.grep`). */
287
- export interface AgentSearchResult {
288
- /** Matches, in the agent's order (path → line → column). */
289
- readonly matches: readonly AgentSearchMatch[];
290
- /** `"in-process"` / `"ripgrep"` as reported; `"unknown"` when the agent sent nothing usable. */
291
- readonly strategy: string;
292
- /** True when any workload bound (results / bytes / deadline / file size) cut the scan short. */
293
- readonly truncated: boolean;
294
- /**
295
- * **Cumulative** events dropped since `watch.start` (`dropped` on the wire). On `search.grep` the
296
- * agent reports no such field, so it is `0`; it exists here only for wire-shape symmetry with
297
- * {@link AgentWatchPollResult} — do not read it as "matches lost".
298
- */
299
- readonly dropped: number;
300
- /** Files actually opened (`filesScanned`); `0` when absent. */
301
- readonly filesScanned: number;
302
- /** Bytes actually read (`bytesScanned`); `0` when absent. */
303
- readonly bytesScanned: number;
304
- /** Non-fatal problems (`warnings`); empty when absent. */
305
- readonly warnings: readonly string[];
306
- /** Agent-side duration in ms, or `null` when absent. */
307
- readonly durationMs: number | null;
308
- /**
309
- * Which workload bounds cut the scan short (`truncatedReasons`), de-duplicated by the agent.
310
- *
311
- * Values are `maxResults` / `bytesScanned` / `maxFileBytes` / `timeout` / `maxEntries`. The list is kept
312
- * **verbatim**: a newer agent may name a bound this client does not know, and dropping it would report a
313
- * truncated scan as an untruncated one. Empty when the agent sent nothing.
314
- */
315
- readonly truncatedReasons: readonly string[];
316
- /**
317
- * Candidate files the request's `include` filters removed, or `undefined` when the agent did not say.
318
- *
319
- * `undefined` and `0` are different facts: `0` means "the filters removed nothing", `undefined` means "this
320
- * agent cannot tell you". Reading a missing field as `0` would invent the first from the second.
321
- */
322
- readonly filesFiltered: number | undefined;
323
- }
324
- /**
325
- * {@link AgentTransport.searchGrep} request.
326
- *
327
- * Note the one place this API deliberately does **not** mirror the wire: the agent's field is
328
- * `caseSensitive` (default `false` = case-insensitive), and this option is its inverse
329
- * (`ignoreCase`, default `true`). The mapping is explicit in {@link AgentTransport.searchGrep}, so
330
- * callers never have to remember which way the flag points.
331
- */
332
- export interface AgentSearchGrepRequest {
333
- /** Absolute remote roots (files or directories). Empty is refused locally with `REMOTE_COMMAND_FAILED`. */
334
- readonly paths: readonly string[];
335
- /** Literal or Go regular expression, depending on `literal`. Empty is a local `REMOTE_COMMAND_FAILED`. */
336
- readonly query: string;
337
- /** `true` (default on the wire) means literal substring matching; `false` means Go regexp. */
338
- readonly literal?: boolean;
339
- /** Case-insensitive matching; **default `true`**, inverted onto the wire's `caseSensitive`. */
340
- readonly ignoreCase?: boolean;
341
- /** Result ceiling; the agent applies {@link DEFAULT_SEARCH_MAX_RESULTS} when omitted or non-positive. */
342
- readonly maxResults?: number;
343
- /** Whole-request byte ceiling; agent default {@link DEFAULT_SEARCH_MAX_BYTES_SCANNED}. */
344
- readonly maxBytesScanned?: number;
345
- /** Per-file byte ceiling; agent default {@link DEFAULT_SEARCH_MAX_FILE_BYTES}. */
346
- readonly maxFileBytes?: number;
347
- /** Per-line byte ceiling; agent default {@link DEFAULT_SEARCH_MAX_LINE_BYTES}. */
348
- readonly maxLineBytes?: number;
349
- /** Agent-side deadline; agent default {@link DEFAULT_INDEX_TIMEOUT_MS}. */
350
- readonly timeoutMs?: number;
351
- /** Context lines around a match; `>0` forces the in-process path (no `rg` delegation). */
352
- readonly contextLines?: number;
353
- /**
354
- * Filename patterns to keep (e.g. `*.cpp`), forwarded as the agent's `include`.
355
- *
356
- * Distinct from {@link paths}: `paths` decides what is **walked**, `include` decides which walked **files**
357
- * are read, and it does not prune directories. Omitted means "no filename filtering" — the agent applies
358
- * none, rather than this layer inventing an empty filter list.
359
- */
360
- readonly include?: readonly string[];
361
- /**
362
- * Drop the ignore rules the agent would otherwise apply: VCS ignores (`.gitignore` / `.ignore` /
363
- * `.rgignore`) and its built-in `index.DefaultExcludes` noise directories.
364
- *
365
- * Omitted means the agent's own default (ignore rules applied), so an older agent that does not know the
366
- * field still behaves exactly as before. The two search paths inside the agent both honour it — see
367
- * `dsh-ssh-agent/internal/search/search.go`.
368
- */
369
- readonly noIgnore?: boolean;
370
- }
371
- /** One filesystem event (`watch.poll` `events[i]`). */
372
- export interface AgentWatchEvent {
373
- /** Absolute remote path. */
374
- readonly path: string;
375
- /** `create` / `write` / `remove` / `rename`; `"unknown"` for a kind this client does not recognise. */
376
- readonly kind: string;
377
- /**
378
- * When the **agent read** the event, in milliseconds since the epoch, converted from `atNs`.
379
- * inotify carries no kernel timestamp, so this is not the moment the change happened; `null` when absent.
380
- */
381
- readonly atMs: number | null;
382
- }
383
- /** Result of {@link AgentTransport.startWatch} (`watch.start`). */
384
- export interface AgentWatchStartResult {
385
- /**
386
- * The watcher this result belongs to, as the agent normalised it (`"default"` when the caller omitted
387
- * `watcherId`). Echoed so a caller sharing one connection can confirm which watcher it touched.
388
- */
389
- readonly watcherId: string;
390
- /** The **roots** actually registered (absolute, deduplicated, ascending) — not every subdirectory. */
391
- readonly watched: readonly string[];
392
- /** True when `maxWatches` (or the kernel's `max_user_watches`) cut registration short. */
393
- readonly truncated: boolean;
394
- /** `"inotify"` today (Linux only); `"unknown"` when the agent sent nothing usable. */
395
- readonly strategy: string;
396
- }
397
- /**
398
- * {@link AgentTransport.startWatch} request.
399
- *
400
- * Calling `start` with the **same** `watcherId` while that watcher runs **replaces** it (the agent stops
401
- * the old one first); if the new start fails, the old watcher is already gone. Different ids are
402
- * independent — that is what lets several sessions share one agent process without one session's
403
- * `watch.start` silently killing another's listener.
404
- */
405
- export interface AgentWatchStartRequest {
406
- /**
407
- * Which watcher to start or replace; omitted means the agent's `"default"` watcher, which is what a
408
- * caller that never sets this has always used. The agent caps a connection at 16 watchers and answers
409
- * `E_TOO_LARGE` beyond that (it never evicts someone else's watcher).
410
- */
411
- readonly watcherId?: string;
412
- /** Absolute remote roots. Empty is a local `REMOTE_COMMAND_FAILED`. Non-absolute roots are `E_PARAMS`. */
413
- readonly roots: readonly string[];
414
- /** Recursively registered **directory** ceiling; agent default {@link DEFAULT_WATCH_MAX_WATCHES}. */
415
- readonly maxWatches?: number;
416
- /** Debounce window for merging same-`(path, kind)` events; agent default {@link DEFAULT_WATCH_DEBOUNCE_MS}. */
417
- readonly debounceMs?: number;
418
- }
419
- /** Result of {@link AgentTransport.pollWatch} (`watch.poll`). */
420
- export interface AgentWatchPollResult {
421
- /** The watcher this poll read from, as the agent normalised it (`"default"` when omitted). */
422
- readonly watcherId: string;
423
- /** Events returned by this poll (possibly empty, and empty is not an error). */
424
- readonly events: readonly AgentWatchEvent[];
425
- /** True when `maxEvents` was hit (more events remain queued) or the kernel queue overflowed. */
426
- readonly truncated: boolean;
427
- /** True when this poll returned because its deadline expired, not because it had events. */
428
- readonly timeout: boolean;
429
- /**
430
- * Events dropped because the agent's queue limit was reached, **cumulative since `watch.start`** —
431
- * never subtract two polls to get a delta, and do not read it as the total number of lost events
432
- * (debounce merging also removes duplicates, which are not counted here).
433
- */
434
- readonly dropped: number;
435
- }
436
- /** {@link AgentTransport.pollWatch} request. */
437
- export interface AgentWatchPollRequest {
438
- /** Which watcher to poll; omitted means the agent's `"default"` watcher. */
439
- readonly watcherId?: string;
440
- /**
441
- * How long the agent may block waiting for events; agent default
442
- * {@link DEFAULT_WATCH_POLL_TIMEOUT_MS}. See {@link AgentTransport.pollWatch}: this occupies the
443
- * connection, and it must stay below the transport's `requestTimeoutMs` or the client deadline fires
444
- * first.
445
- */
446
- readonly timeoutMs?: number;
447
- /** Events per poll; agent default {@link DEFAULT_WATCH_MAX_EVENTS}. The rest stay queued. */
448
- readonly maxEvents?: number;
449
- }
450
- /** Result of {@link AgentTransport.stopWatch} (`watch.stop`). */
451
- export interface AgentWatchStopResult {
452
- /** The watcher this stop targeted, as the agent normalised it (`"default"` when omitted). */
453
- readonly watcherId: string;
454
- /** `true` when a watcher was running, `false` when there was nothing to stop (not an error). */
455
- readonly stopped: boolean;
456
- }
457
- /** The agent's capability record, as the plugin cares about it. */
458
- export interface AgentCapabilities {
459
- /** `"native"` / `"poll"` / `"none"`: only `native` may use `watch.*`. */
460
- readonly watch?: string;
461
- readonly index?: boolean;
462
- readonly atomicWrite?: boolean;
463
- readonly landlock?: string;
464
- readonly git?: boolean;
465
- readonly ripgrep?: boolean;
466
- readonly grep?: boolean;
467
- /** `proc.exec` support. Only `true` may call the command-execution path. */
468
- readonly exec?: boolean;
469
- }
470
- /** Optional metadata a `hello` result may carry beyond the capability bits. */
471
- export interface AgentHelloExtras {
472
- /** `hello.result.agent.os` (`linux`, `darwin`, …). */
473
- readonly os?: string;
474
- /** `hello.result.agent.arch`. */
475
- readonly arch?: string;
476
- /** `hello.result.agent.version`. */
477
- readonly version?: string;
478
- /** Explicit `uname` if a future agent sends one; preferred over the derivation from `os`. */
479
- readonly uname?: string;
480
- }
481
- /**
482
- * Map agent capability bits onto this plugin's {@link RemoteCapabilities}.
483
- *
484
- * Honesty rules followed here, because each one would otherwise be an invented capability:
485
- *
486
- * - a bit the agent did not send is **false**, never assumed;
487
- * - `sha256` stays `null`: the agent computes versions itself and never advertises a digest tool;
488
- * - `base64` / `findMaxDepth` stay `false`: those are Tier 1 shell-tool facts, and the agent does not
489
- * use either command;
490
- * - `posix` is true only for a POSIX `os`;
491
- * - `uname` is derived from `os` (linux→Linux) when the agent sends no explicit `uname`. **That
492
- * derivation is unverified against the wire** (v1 `hello` carries `os`, not `uname`) and is listed as
493
- * an unverified assumption in the module documentation.
494
- */
495
- export declare function capabilitiesFromAgent(caps: AgentCapabilities | undefined, extras?: AgentHelloExtras): RemoteCapabilities;
496
- /**
497
- * The protocol v1 client: framing, request/response correlation and the `hello` handshake.
498
- *
499
- * Scope: **one session, up to {@link maxInFlight} requests in flight**. Requests are pipelined because the
500
- * agent dispatches them concurrently (ADR-0009) and answers by id, so the only thing that must stay
501
- * ordered is the blob stream — and the agent writes a response and its blob inside one critical section,
502
- * which makes blob arrival order equal declaration order. {@link readBlob} therefore binds to the blob
503
- * channel of *its own* control response rather than to a single global slot.
504
- *
505
- * A request that times out or is aborted is not simply forgotten — its response (and its blob) is still on
506
- * the wire, so the client drains it before reporting the failure, and it declares the connection lost when
507
- * it cannot.
508
- */
509
- //# sourceMappingURL=agent-protocol-types.d.ts.map