@artenx/dshb 0.1.31 → 0.1.33

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 (36) hide show
  1. package/lib/client.js +133 -22
  2. package/lib/client.js.map +1 -1
  3. package/lib/core/index.js +6 -1
  4. package/lib/core/index.js.map +1 -1
  5. package/lib/core/sync/coordinator.d.ts +2 -2
  6. package/lib/core/sync/coordinator.js +23 -6
  7. package/lib/core/sync/coordinator.js.map +1 -1
  8. package/lib/core/sync/internal-routes.d.ts +1 -1
  9. package/lib/core/sync/internal-routes.js +80 -4
  10. package/lib/core/sync/internal-routes.js.map +1 -1
  11. package/lib/core/sync/offline-archive.d.ts +1 -1
  12. package/lib/core/sync/offline-archive.js +1 -1
  13. package/lib/core/sync/offline-routes.js +1 -1
  14. package/lib/core/sync/protocol.d.ts +2 -2
  15. package/lib/core/sync/protocol.js +4 -1
  16. package/lib/core/sync/protocol.js.map +1 -1
  17. package/lib/core/sync/remote-helper.js +107 -76
  18. package/lib/core/sync/remote-helper.js.map +1 -1
  19. package/lib/core/sync/routes.d.ts +1 -1
  20. package/lib/core/sync/routes.js +61 -1
  21. package/lib/core/sync/routes.js.map +1 -1
  22. package/lib/core/sync/session-routes.d.ts +1 -1
  23. package/lib/core/sync/session-routes.js +1 -1
  24. package/lib/core/sync/session-sync.d.ts +2 -2
  25. package/lib/core/sync/session-sync.js +2 -2
  26. package/lib/core/sync/ssh-transport.d.ts +2 -2
  27. package/lib/core/sync/ssh-transport.js +267 -3
  28. package/lib/core/sync/ssh-transport.js.map +1 -1
  29. package/lib/{protocol-KaWZArY8.d.ts → protocol-DJ0zyVlB.d.ts} +5 -2
  30. package/lib/{session-sync-Zfo1Q-qT.d.ts → session-sync-BuOJvFxK.d.ts} +54 -2
  31. package/lib/{session-sync-BQt3HXkp.js → session-sync-CIqjuWkh.js} +455 -48
  32. package/lib/session-sync-CIqjuWkh.js.map +1 -0
  33. package/lib/ssh-transport-C7povM0s.d.ts +115 -0
  34. package/package.json +1 -1
  35. package/lib/session-sync-BQt3HXkp.js.map +0 -1
  36. package/lib/ssh-transport-Cfb_nwkY.d.ts +0 -65
@@ -0,0 +1,115 @@
1
+ import { a as SyncPeer } from "./model-BP7Gw1yk.js";
2
+ import { i as SyncNodeManifest, t as SyncNodeApplyResult } from "./node-sync-3Z9QLz2n.js";
3
+ import { SyncPeerManager, SyncPeerSecrets } from "./core/sync/peer-manager.js";
4
+ import { r as SyncHostKeyChallenges, t as SyncHostKeyChallengeError } from "./host-key-C5afhAUd.js";
5
+ import { d as SyncFrame } from "./protocol-DJ0zyVlB.js";
6
+ import { a as SyncSessionBundle, d as SyncSessionManifest, i as SyncSessionApplyResult, l as SyncSessionEventPrefix, p as SyncSessionObject } from "./session-sync-BuOJvFxK.js";
7
+ import { Client, ClientChannel, ConnectConfig } from "ssh2";
8
+ //#region src/core/sync/ssh-transport.d.ts
9
+ type SyncSshErrorCategory = 'auth' | 'network' | 'hostkey' | 'timeout' | 'helper' | 'protocol';
10
+ declare class SyncSshProbeError extends Error {
11
+ readonly category: SyncSshErrorCategory;
12
+ constructor(category: SyncSshErrorCategory);
13
+ }
14
+ declare class SyncSessionDeltaPrefixError extends Error {
15
+ constructor();
16
+ }
17
+ interface SyncRemoteHandshake {
18
+ protocolVersion: number;
19
+ instanceId: string;
20
+ capabilities: string[];
21
+ }
22
+ interface SyncRemoteNodeManifest extends SyncNodeManifest {
23
+ capabilities?: string[];
24
+ }
25
+ declare class SyncSshSession {
26
+ private readonly client;
27
+ private readonly channel;
28
+ private readonly decoder;
29
+ private readonly closeSignal;
30
+ private reading;
31
+ private closed;
32
+ private inputEnded;
33
+ private nextDataSequence;
34
+ private pendingError;
35
+ constructor(client: Client, channel: ClientChannel);
36
+ sendControl(value: Record<string, unknown>): Promise<void>;
37
+ sendData(sequence: number, data: Buffer): Promise<void>;
38
+ endInput(): void;
39
+ readFrames(idleTimeoutMs?: number): AsyncGenerator<SyncFrame>;
40
+ close(): void;
41
+ private write;
42
+ }
43
+ declare function buildSyncSshConnectConfig(peer: SyncPeer, secrets: SyncPeerSecrets, challenges: SyncHostKeyChallenges, onChallenge: (error: SyncHostKeyChallengeError) => void): ConnectConfig;
44
+ declare class SyncSshTransport {
45
+ private readonly peerManager;
46
+ private readonly hostKeyChallenges;
47
+ constructor(peerManager: SyncPeerManager);
48
+ probe(peerId: string): Promise<SyncRemoteHandshake>;
49
+ openSession(peerId: string): Promise<{
50
+ peer: SyncPeer;
51
+ session: SyncSshSession;
52
+ }>;
53
+ fetchNodeManifest(peerId: string): Promise<SyncRemoteNodeManifest>;
54
+ applyNodeManifest(peerId: string, records: SyncNodeManifest['records'], sourceName: string): Promise<SyncNodeApplyResult>;
55
+ fetchSessionBundle(peerId: string): Promise<SyncSessionBundle>;
56
+ fetchSessionManifest(peerId: string): Promise<SyncSessionManifest>;
57
+ fetchSessionEntries(peerId: string, keys: readonly string[], manifestDigest: string, prefixes?: readonly SyncSessionEventPrefix[], deferredObjects?: boolean): Promise<SyncSessionBundle>;
58
+ applySessionBundle(peerId: string, bundle: SyncSessionBundle, sourceName: string): Promise<SyncSessionApplyResult>;
59
+ trustObservedHostKey(peerId: string): Promise<void>;
60
+ /**
61
+ * 拉取带外对象流:响应以帧流形式逐块 yield,调用方(收件箱)边收边落盘,
62
+ * 内存 O(单帧)。会话在流结束/出错时关闭(生成器 finally)。
63
+ */
64
+ fetchSessionObjects(peerId: string, objects: readonly SyncSessionObject[]): AsyncGenerator<Uint8Array>;
65
+ /**
66
+ * 推送带外对象流:把帧流按 1MB 分块写入请求体,逐块经 SSH 发送;
67
+ * 对端流式落盘收件箱后返回 JSON 摘要。
68
+ */
69
+ pushSessionObjects(peerId: string, frames: AsyncIterable<Uint8Array>): Promise<void>;
70
+ private fetchDataOperation;
71
+ private requestHandshake;
72
+ }
73
+ interface SyncRemoteProbeDraft {
74
+ host: string;
75
+ port: number;
76
+ username: string;
77
+ authKind: 'password' | 'key';
78
+ }
79
+ interface SyncRemoteProbeProfile {
80
+ name: string;
81
+ dshbInstalled: boolean;
82
+ home: string;
83
+ }
84
+ interface SyncRemoteProbeHandshake {
85
+ port: number;
86
+ instanceId: string;
87
+ }
88
+ interface SyncRemoteProbeResult {
89
+ homes: string[];
90
+ profiles: SyncRemoteProbeProfile[];
91
+ /** 握手命中的全部端口(同机多实例时可能有多个;配置端口的命中排最前)。 */
92
+ handshakes: SyncRemoteProbeHandshake[];
93
+ webPort?: number;
94
+ instanceId?: string;
95
+ processHints: string[];
96
+ hostKeyFingerprint: string;
97
+ }
98
+ declare const REMOTE_PROBE_BEGIN_MARKER = "DSHB_PROBE_BEGIN";
99
+ declare const REMOTE_PROBE_END_MARKER = "DSHB_PROBE_END";
100
+ /**
101
+ * 生成远端发现脚本:纯 POSIX sh + 远端 node(DSH 所在机器必然有 node)。
102
+ * 三个动作:① 多候选定位 DSH_HOME(含桌面版常见路径);② 列出 profiles 及
103
+ * dshb 安装标记;③ 握手探测真实 Web 端口(仅远端回环,桌面版 127.0.0.1:3080
104
+ * 即可命中)。输出以 BEGIN/END 标记包裹,逐行 "key value"。
105
+ */
106
+ declare function buildRemoteProbeScript(dshHome?: string, preferredWebPort?: number): string;
107
+ /** 解析探测输出:仅在 BEGIN/END 标记之间取行,容忍未知行。 */
108
+ declare function parseRemoteProbeOutput(output: string, hostKeyFingerprint: string, preferredWebPort?: number): SyncRemoteProbeResult;
109
+ declare class SyncRemoteProbe {
110
+ /** 探测远端:SSH 登录 + 单次 exec 发现脚本;主机密钥自动接受(只读发现,指纹随结果返回)。 */
111
+ probeRemote(draft: SyncRemoteProbeDraft, secrets: SyncPeerSecrets, preferredWebPort?: number): Promise<SyncRemoteProbeResult>;
112
+ }
113
+ //#endregion
114
+ export { parseRemoteProbeOutput as _, SyncRemoteProbe as a, SyncRemoteProbeProfile as c, SyncSshErrorCategory as d, SyncSshProbeError as f, buildSyncSshConnectConfig as g, buildRemoteProbeScript as h, SyncRemoteNodeManifest as i, SyncRemoteProbeResult as l, SyncSshTransport as m, REMOTE_PROBE_END_MARKER as n, SyncRemoteProbeDraft as o, SyncSshSession as p, SyncRemoteHandshake as r, SyncRemoteProbeHandshake as s, REMOTE_PROBE_BEGIN_MARKER as t, SyncSessionDeltaPrefixError as u };
115
+ //# sourceMappingURL=ssh-transport-C7povM0s.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@artenx/dshb",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "Routes DSH filesystem, shell, subprocess, and PTY operations to local, SSH, and Docker execution nodes, with a node registry, an authentication gate, a mobile-aware management UI, and per-workspace custom project instructions.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",