super-dsh 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-agy/dist/agent.d.ts +4 -1
- package/agent-agy/dist/agent.js +15 -1
- package/agent-agy/dist/index.js +5 -8
- package/agent-agy/package.json +6 -6
- package/agent-agy-sdk/dist/agent.d.ts +4 -1
- package/agent-agy-sdk/dist/agent.js +15 -1
- package/agent-agy-sdk/dist/index.js +5 -8
- package/agent-agy-sdk/package.json +5 -5
- package/agent-claude/dist/agent.js +15 -1
- package/agent-claude/package.json +8 -8
- package/agent-codex/dist/agent.js +15 -1
- package/agent-codex/package.json +7 -7
- package/agent-codex-sdk/dist/agent.js +15 -1
- package/agent-codex-sdk/dist/index.js +5 -11
- package/agent-codex-sdk/package.json +7 -7
- package/agent-hermes/dist/agent.js +15 -1
- package/agent-hermes/dist/index.js +5 -8
- package/agent-hermes/package.json +7 -7
- package/agent-omp/dist/agent.js +26 -2
- package/agent-omp/package.json +8 -8
- package/agent-omp-sdk/dist/agent.d.ts +4 -1
- package/agent-omp-sdk/dist/agent.js +15 -1
- package/agent-omp-sdk/package.json +8 -8
- package/agent-pi/dist/agent.js +20 -2
- package/agent-pi/dist/index.js +5 -11
- package/agent-pi/package.json +7 -7
- package/package.json +21 -21
- package/remote/hub-pty-pump.mjs +97 -0
- package/remote/plugin.d.ts +406 -203
- package/remote/plugin.js +631 -319
- package/remote/provenance.json +15 -12
- package/superd-hub/dist/agent-model-face.d.ts +93 -0
- package/superd-hub/dist/agent-model-face.js +113 -0
- package/superd-hub/dist/exec.d.ts +3 -2
- package/superd-hub/dist/exec.js +6 -5
- package/superd-hub/dist/hub-tool.d.ts +1 -1
- package/superd-hub/dist/hub-tool.js +6 -6
- package/superd-hub/dist/index.d.ts +1 -0
- package/superd-hub/dist/index.js +1 -0
- package/superd-hub/dist/remote-provider.js +70 -36
- package/superd-hub/dist/world-entry.js +30 -0
- package/superd-hub/package.json +14 -10
- package/superd-hub/dist/exec-pty-channel.d.ts +0 -58
- package/superd-hub/dist/exec-pty-channel.js +0 -162
- package/superd-hub/dist/exec-pty-framing.d.ts +0 -34
- package/superd-hub/dist/exec-pty-framing.js +0 -89
- package/superd-hub/dist/exec-pty-session.d.ts +0 -78
- package/superd-hub/dist/exec-pty-session.js +0 -228
package/remote/plugin.d.ts
CHANGED
|
@@ -100,6 +100,393 @@ declare function sshArgv(connection: SshConnection, options?: {
|
|
|
100
100
|
command?: string;
|
|
101
101
|
}): string[];
|
|
102
102
|
//#endregion
|
|
103
|
+
//#region src/remote/hub-contract.d.ts
|
|
104
|
+
/** Owned structural boundary. Better never imports or depends on Super. */
|
|
105
|
+
interface RemoteInput {
|
|
106
|
+
target?: string;
|
|
107
|
+
spawn?: string;
|
|
108
|
+
ssh?: SshConnection;
|
|
109
|
+
cmd?: string;
|
|
110
|
+
scriptPath?: string;
|
|
111
|
+
stdin?: string;
|
|
112
|
+
mode?: 'oneshot' | 'pty';
|
|
113
|
+
timeout?: number;
|
|
114
|
+
}
|
|
115
|
+
interface PreparedRemoteInput {
|
|
116
|
+
target?: string;
|
|
117
|
+
spawn?: string;
|
|
118
|
+
ssh?: SshConnection;
|
|
119
|
+
cmd: string;
|
|
120
|
+
stdin?: string;
|
|
121
|
+
mode?: 'oneshot' | 'pty';
|
|
122
|
+
timeout?: number;
|
|
123
|
+
}
|
|
124
|
+
/** Counters exclude diagnostic banners. dropped is ring eviction; total-returned is all omitted output. */
|
|
125
|
+
type OutputStats = {
|
|
126
|
+
unit: 'utf16' | 'bytes';
|
|
127
|
+
total: number;
|
|
128
|
+
retained: number;
|
|
129
|
+
dropped: number;
|
|
130
|
+
returned: number;
|
|
131
|
+
retentionLimit: number;
|
|
132
|
+
};
|
|
133
|
+
type StreamOutputStats = {
|
|
134
|
+
stdout: OutputStats;
|
|
135
|
+
stderr?: OutputStats;
|
|
136
|
+
};
|
|
137
|
+
interface RemoteProcess {
|
|
138
|
+
cancel(reason?: string): void;
|
|
139
|
+
done: Promise<{
|
|
140
|
+
exit: number | null;
|
|
141
|
+
timedOut: boolean;
|
|
142
|
+
durationMs: number;
|
|
143
|
+
cancelled?: boolean;
|
|
144
|
+
}>;
|
|
145
|
+
/** diagnostic is executor-generated text, not process output; excluded from byte cursor and counters. */
|
|
146
|
+
read(channel: 'stdout' | 'stderr', fromByte: number): {
|
|
147
|
+
text: string;
|
|
148
|
+
nextOffset: number;
|
|
149
|
+
lossy: boolean;
|
|
150
|
+
stats?: OutputStats;
|
|
151
|
+
diagnostic?: string;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
interface BinaryFileEndpoint {
|
|
155
|
+
exportTree(path: string, signal: AbortSignal): Promise<NodeJS.ReadableStream>;
|
|
156
|
+
importTree(path: string, source: NodeJS.ReadableStream, options: {
|
|
157
|
+
mkdir: boolean;
|
|
158
|
+
signal: AbortSignal;
|
|
159
|
+
}): Promise<void>;
|
|
160
|
+
digest(path: string, signal: AbortSignal, selection?: readonly string[]): Promise<{
|
|
161
|
+
sha256: string;
|
|
162
|
+
bytes: number;
|
|
163
|
+
entries: number;
|
|
164
|
+
}>;
|
|
165
|
+
}
|
|
166
|
+
interface HubTarget {
|
|
167
|
+
id: string;
|
|
168
|
+
label: string;
|
|
169
|
+
execEnabled: boolean;
|
|
170
|
+
}
|
|
171
|
+
interface HubRemoteTransport {
|
|
172
|
+
protocol: 1;
|
|
173
|
+
listTargets(): readonly HubTarget[];
|
|
174
|
+
start(machine: string, input: PreparedRemoteInput, owner: string): Promise<RemoteProcess>;
|
|
175
|
+
/** Hub PTY 端点(0.3.2-c):url = ws(s)://<origin>/api/superd/exec/pty;cookie = pairing 凭据;
|
|
176
|
+
* wsPath = transport 侧(superd-hub 上下文,分叉的 proven 解析链)解析好的 ws 模块绝对路径。 */
|
|
177
|
+
ptyEndpoint(machine: string): {
|
|
178
|
+
url: string;
|
|
179
|
+
cookie: string;
|
|
180
|
+
wsPath: string;
|
|
181
|
+
};
|
|
182
|
+
fileEndpoint(machine: string): BinaryFileEndpoint;
|
|
183
|
+
releaseOwner(owner: string): Promise<void>;
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/remote/output-ring.d.ts
|
|
187
|
+
/** Byte-addressed decoded output: mid-codepoint cursors skip forward and explicitly report loss. */
|
|
188
|
+
declare function readUtf8Tail(bytes: Buffer, totalBytes: number, fromByte: number): {
|
|
189
|
+
text: string;
|
|
190
|
+
nextOffset: number;
|
|
191
|
+
lossy: boolean;
|
|
192
|
+
};
|
|
193
|
+
/** Native/PTY retention is UTF16 units; cursor offsets remain real UTF8 bytes. Input is decoded text. */
|
|
194
|
+
declare class Utf16TailRing {
|
|
195
|
+
readonly capacity: number;
|
|
196
|
+
text: string;
|
|
197
|
+
total: number;
|
|
198
|
+
private totalBytes;
|
|
199
|
+
constructor(capacity?: number);
|
|
200
|
+
push(text: string): void;
|
|
201
|
+
stats(returned?: number): OutputStats;
|
|
202
|
+
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
203
|
+
}
|
|
204
|
+
/** Raw byte retention for Hub oneshot. Tail/read starts skip partial UTF8 prefixes, never invent replacement characters. */
|
|
205
|
+
declare class ByteTailRing {
|
|
206
|
+
readonly capacity: number;
|
|
207
|
+
total: number;
|
|
208
|
+
private chunks;
|
|
209
|
+
private retained;
|
|
210
|
+
constructor(capacity?: number);
|
|
211
|
+
push(chunk: Buffer): void;
|
|
212
|
+
tail(maxBytes?: number): Buffer;
|
|
213
|
+
stats(returned?: number): OutputStats;
|
|
214
|
+
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
//#region src/remote/process.d.ts
|
|
218
|
+
declare const PROCESS_CLEANUP_BOUND_MS: number;
|
|
219
|
+
interface ProcessOptions {
|
|
220
|
+
stdin?: string;
|
|
221
|
+
timeoutSec?: number;
|
|
222
|
+
cwd?: string;
|
|
223
|
+
/** Hub retains raw bytes; native transports retain decoded UTF16 units. */
|
|
224
|
+
unit?: 'bytes' | 'utf16';
|
|
225
|
+
onOutput?: () => void;
|
|
226
|
+
/** Overlay on process.env (tool-built values only, e.g. RSYNC_RSH). */
|
|
227
|
+
env?: NodeJS.ProcessEnv;
|
|
228
|
+
}
|
|
229
|
+
/** Real detached process. Completion includes group cleanup, even after its leader closes. */
|
|
230
|
+
declare function startBinaryProcess(argv: string[], options?: Pick<ProcessOptions, 'cwd' | 'timeoutSec' | 'env'>): {
|
|
231
|
+
stdout: Readable;
|
|
232
|
+
stderr: Readable;
|
|
233
|
+
stdin: Writable;
|
|
234
|
+
cancel(): void;
|
|
235
|
+
done: RemoteProcess['done'];
|
|
236
|
+
diagnostic(): string | undefined;
|
|
237
|
+
};
|
|
238
|
+
/** Text adapter over the same owned process-group lifecycle as binary pipelines. */
|
|
239
|
+
declare function startOneShot(argv: string[], options?: ProcessOptions): RemoteProcess;
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/remote/nonce-framing.d.ts
|
|
242
|
+
/** 0.3.2-e:自有 30K 返回窗口已删(原生 agent runtime 的 spill/输出保护接管模型上下文
|
|
243
|
+
* 尺寸)。本 helper 只做 retention 披露:ring 留存(4M UTF-16 / 4MiB bytes)未驱逐时
|
|
244
|
+
* 全量透传(returned=retained,无 banner);驱逐(dropped>0,仅 >4M 输出发生)时打一行
|
|
245
|
+
* banner 且 truncated=原始总量。text 已是 ring 尾部,不再二次裁剪。 */
|
|
246
|
+
declare function disclose(text: string, stats?: OutputStats): {
|
|
247
|
+
text: string;
|
|
248
|
+
truncated?: number;
|
|
249
|
+
stats?: OutputStats;
|
|
250
|
+
};
|
|
251
|
+
interface EnvDelta {
|
|
252
|
+
added: string[];
|
|
253
|
+
changed: string[];
|
|
254
|
+
removed: string[];
|
|
255
|
+
}
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/remote/pty-session.d.ts
|
|
258
|
+
interface PtySessionOptions {
|
|
259
|
+
key: string;
|
|
260
|
+
argv: string[];
|
|
261
|
+
/** Workbench 身份(§3):自动 id(p-xxxx)+ 可选 label + connection 展示名(ssh:dev4 / docker:c / BYOP)。 */
|
|
262
|
+
id: string;
|
|
263
|
+
label?: string;
|
|
264
|
+
connection: string;
|
|
265
|
+
byo?: boolean;
|
|
266
|
+
/** connection 来自 BYO ssh 身份(card 面标 `(built on)`,与 roster 同词)。 */
|
|
267
|
+
builtOn?: boolean;
|
|
268
|
+
/** spawn 原文(BYO 会话存档;v2 无 spec 对比——不再参与复用判定,仅供回执/账本溯源)。 */
|
|
269
|
+
origin?: string;
|
|
270
|
+
idleTtlSec: number;
|
|
271
|
+
initTimeoutSec?: number;
|
|
272
|
+
/** 池回调:会话彻底出池(dispose)时触发;进程意外死亡不出池(Ruling 7)。 */
|
|
273
|
+
onDead?: () => void;
|
|
274
|
+
}
|
|
275
|
+
interface PtyDispatchOptions {
|
|
276
|
+
stdin?: string;
|
|
277
|
+
timeoutSec?: number; /** 账本键:driver 分配(background 通道预传入 registry jobId;同步命令同格式本地生成)——一个命令永远只有一个 id。 */
|
|
278
|
+
commandId: string; /** P5:立即回执 running job,不等帧(run_in_background 与超时 handoff 共用同一条 job 通道)。 */
|
|
279
|
+
background?: boolean; /** background 通道预传入的 registry jobId(此时与 commandId 字面相等):账本与 input 回执如实携带,免 driver 侧二次回填。 */
|
|
280
|
+
jobId?: string;
|
|
281
|
+
}
|
|
282
|
+
/** §3.3(2026-10-25)interactive-stdin:input 动作的选项与回执(写入成功才回执)。 */
|
|
283
|
+
interface PtyInputOptions {
|
|
284
|
+
stdin: string;
|
|
285
|
+
commandId?: string;
|
|
286
|
+
}
|
|
287
|
+
interface PtyInputReceipt {
|
|
288
|
+
/** 模型面会话名(pty:<id>)。 */
|
|
289
|
+
session: string;
|
|
290
|
+
commandId: string;
|
|
291
|
+
/** 存在官方 job 时才有(background 预传 / timeout handoff 收养回填)。 */
|
|
292
|
+
jobId?: string;
|
|
293
|
+
/** 实际写入的 UTF-8 字节数。 */
|
|
294
|
+
writtenBytes: number;
|
|
295
|
+
}
|
|
296
|
+
/** detached job 的完成结果(frame 或会话死亡时结算;与 dispatch 回执同构)。 */
|
|
297
|
+
interface PtyJobResult {
|
|
298
|
+
output: string;
|
|
299
|
+
outputStats?: StreamOutputStats;
|
|
300
|
+
exit: number | null;
|
|
301
|
+
cwd: string | null;
|
|
302
|
+
timedOut: boolean;
|
|
303
|
+
commandId: string;
|
|
304
|
+
envDelta?: EnvDelta;
|
|
305
|
+
}
|
|
306
|
+
/** P4/P5(2026-10-19)running job 句柄:byte-cursor 增量读 + P8 显式中断 + 完成时帧结算。 */
|
|
307
|
+
interface PtyRunningJob {
|
|
308
|
+
/** 账本键:与 jobId 同构(background 通道预传入 registry id;同步完成命令用同格式生成 id)。 */
|
|
309
|
+
commandId: string;
|
|
310
|
+
/** Byte-cursor incremental read over the command's merged output (tail-ring retention; lossy reports eviction). */
|
|
311
|
+
read: (fromByte: number) => {
|
|
312
|
+
text: string;
|
|
313
|
+
nextOffset: number;
|
|
314
|
+
lossy: boolean;
|
|
315
|
+
};
|
|
316
|
+
stats: () => OutputStats;
|
|
317
|
+
/** P8 两段式 ^C 中断(会话存活;trap-INT 走宽限 group-kill 兜底)。 */
|
|
318
|
+
interrupt: () => void;
|
|
319
|
+
/** Settles on the exit frame, or with exit null when the session dies. */
|
|
320
|
+
done: Promise<PtyJobResult>;
|
|
321
|
+
}
|
|
322
|
+
interface PtyDispatchResult {
|
|
323
|
+
output: string;
|
|
324
|
+
outputStats?: StreamOutputStats;
|
|
325
|
+
exit: number | null;
|
|
326
|
+
cwd: string | null;
|
|
327
|
+
timedOut: boolean;
|
|
328
|
+
reconnected: boolean;
|
|
329
|
+
durationMs: number;
|
|
330
|
+
commandId: string;
|
|
331
|
+
/** env delta(E 帧侧信道):只回名字 + 变动标记,值不回传;init 侧信道失败时省略。 */
|
|
332
|
+
envDelta?: EnvDelta;
|
|
333
|
+
/** P4/P5:true = 命令仍在前台运行,本回执是 handoff(job 句柄随行)。 */
|
|
334
|
+
running?: boolean;
|
|
335
|
+
job?: PtyRunningJob;
|
|
336
|
+
}
|
|
337
|
+
/** 账本条目(§5):commandId / 摘要 / exit / 耗时;保留最近 20 条(user 定案)。 */
|
|
338
|
+
interface LedgerEntry {
|
|
339
|
+
commandId: string;
|
|
340
|
+
jobId?: string;
|
|
341
|
+
summary: string;
|
|
342
|
+
exit: number | null;
|
|
343
|
+
durationMs: number;
|
|
344
|
+
running: boolean;
|
|
345
|
+
}
|
|
346
|
+
type PtyState = 'cold' | 'starting' | 'ready' | 'dead' | 'disposed';
|
|
347
|
+
/** 会话运行时快照(status 面消费,Ruling 16 词汇源)。 */
|
|
348
|
+
interface SessionSnapshot {
|
|
349
|
+
state: PtyState;
|
|
350
|
+
busy: boolean;
|
|
351
|
+
idleMs: number | null;
|
|
352
|
+
pid: number | null;
|
|
353
|
+
}
|
|
354
|
+
declare class PtySession {
|
|
355
|
+
private readonly opts;
|
|
356
|
+
private proc;
|
|
357
|
+
private state;
|
|
358
|
+
private startPromise;
|
|
359
|
+
private idleTimer;
|
|
360
|
+
private onChunk;
|
|
361
|
+
private deathWaiters;
|
|
362
|
+
private diag;
|
|
363
|
+
private inFlight;
|
|
364
|
+
/** P4/P5:当前占用前台的 detached job(background/超时 handoff)。非 null 时新命令拒绝(Q6)。 */
|
|
365
|
+
private detachedJob;
|
|
366
|
+
/** §3.2(2026-10-25):当前占用会话的命令——dispatch 同步占位,settle/cleanup 释放;input 的唯一写入对象。 */
|
|
367
|
+
private activeCommand;
|
|
368
|
+
/** 账本(§5):本会话最近 20 条命令(FIFO,超出丢最旧)。 */
|
|
369
|
+
private ledger;
|
|
370
|
+
/** env 侧信道基线(init E 帧);undefined = 侧信道不可用(不报假 delta)。 */
|
|
371
|
+
private envBaseline;
|
|
372
|
+
/** idle 起点(ready / settle 时重置);null = 尚无 idle 时钟(cold 或已 dispose)。 */
|
|
373
|
+
private idleSince;
|
|
374
|
+
/** 意外死亡后的回收定时器(R2):ready 过的会话先留池供 reconnect,超时仍无人寻址则出池。 */
|
|
375
|
+
private deathTimer;
|
|
376
|
+
private lastCwdSeen;
|
|
377
|
+
/** 是否曾成功初始化(ready 过)。决定死亡语义:ready 过 → reconnect(留池);从未 ready → 出池(见 start())。 */
|
|
378
|
+
private everReady;
|
|
379
|
+
private disposal;
|
|
380
|
+
private procClose;
|
|
381
|
+
private groupCleanup;
|
|
382
|
+
constructor(opts: PtySessionOptions);
|
|
383
|
+
get sessionState(): PtyState;
|
|
384
|
+
/** 池键(driver 的 ttl/inspect 用)。 */
|
|
385
|
+
get key(): string;
|
|
386
|
+
/** 最近帧 cwd(card 面);从未执行过 = null。 */
|
|
387
|
+
get lastCwd(): string | null;
|
|
388
|
+
/** 占用前台的 detached job 的 commandId(无 = null;close 拒绝与 busy 文案共用)。 */
|
|
389
|
+
get detachedCommandId(): string | null;
|
|
390
|
+
/** job 通道收养后回填 jobId(timeout handoff 时 registry id ≠ commandId,账本如实记录两者);运行中的命令同步携带(input 回执用)。 */
|
|
391
|
+
attachJob(commandId: string, jobId: string): void;
|
|
392
|
+
/** Workbench 身份(§3):id + 可选 label + connection + byo 标记。 */
|
|
393
|
+
get identity(): {
|
|
394
|
+
id: string;
|
|
395
|
+
label?: string;
|
|
396
|
+
connection: string;
|
|
397
|
+
byo: boolean;
|
|
398
|
+
builtOn: boolean;
|
|
399
|
+
};
|
|
400
|
+
/** 账本快照(session card 面,只读)。 */
|
|
401
|
+
ledgerSnapshot(): readonly LedgerEntry[];
|
|
402
|
+
/** spawn 创建原文(仅 BYO 会话;v2 起仅存档,不参与复用判定)。 */
|
|
403
|
+
get origin(): string | undefined;
|
|
404
|
+
/** status 面快照:state + busy(有命令在跑)+ idleMs(上次 settle 至今)+ pid(进程组头,kill 兜底可观测)。 */
|
|
405
|
+
get snapshot(): SessionSnapshot;
|
|
406
|
+
/** 预热创建(创建形无 cmd):真正拨号到 init 帧——「会话已就绪」必须是真的,
|
|
407
|
+
* 而且只有 ready 过才挂 idle 回收(cold 会话没有 timer,会永远占配额)。 */
|
|
408
|
+
warm(): Promise<void>;
|
|
409
|
+
/** 同一会话命令占位制(2026-10-25 interactive-stdin 轮):dispatch 入口**同步**建立
|
|
410
|
+
* 命令占位(activeCommand + inFlight + 账本条目)——上一条命令仍在运行(同步等待 /
|
|
411
|
+
* 等输入 / detached job)时新 cmd 立即 E_SESSION_BUSY;原「纯同步并发排 FIFO」语义
|
|
412
|
+
* 废除(排队会让等输入的命令与补输入动作互相卡死,也给 busy 留下绕行窗口)。
|
|
413
|
+
* P4/P5:超时不杀命令而是 handoff 成 running job;background 立即回执;P8 显式
|
|
414
|
+
* interrupt 保留在 job.interrupt;死亡/冷态先重启(reconnect 语义不变)。 */
|
|
415
|
+
dispatch(cmd: string, dOpts: PtyDispatchOptions): Promise<PtyDispatchResult>;
|
|
416
|
+
/** §3.1(2026-10-25)interactive-stdin:向当前运行中的命令追加 stdin——只写既有通道
|
|
417
|
+
* 与身份,不新建命令、账本条目或输出游标;不重连、不重放(dead/disposed 明确拒绝)。
|
|
418
|
+
* 校验与写入全同步:多次 input 按调用顺序整段写入不交错;写入失败如实抛错(私有
|
|
419
|
+
* write() 的静默忽略不适用于回执语义)。stdin:"" 是零字节写入,不是 EOF。 */
|
|
420
|
+
input(options: PtyInputOptions): Promise<PtyInputReceipt>;
|
|
421
|
+
/** TTL / row teardown:尽力 exit,1s 后杀组,出池。 */
|
|
422
|
+
dispose(): Promise<void>;
|
|
423
|
+
private write;
|
|
424
|
+
private start;
|
|
425
|
+
private doStart;
|
|
426
|
+
private markDead;
|
|
427
|
+
private resetIdleTimer;
|
|
428
|
+
private clearIdleTimer;
|
|
429
|
+
/** 意外死亡后的回收:留池只换取一次 reconnect 机会,不得超过一段 idle TTL(R2 复核 P0)。
|
|
430
|
+
* 否则死会话永久占 label + 永久计入 10 配额,Agent 再也开不出新会话。 */
|
|
431
|
+
private armDeathReaper;
|
|
432
|
+
private clearDeathTimer;
|
|
433
|
+
private killTree;
|
|
434
|
+
/** A direct child's close is not proof that its detached process group is gone. */
|
|
435
|
+
private reapGroup;
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
//#region src/remote/target.d.ts
|
|
439
|
+
/** 解析后的传输计划:三种 CLI 传输之一。 */
|
|
440
|
+
type TargetPlan = {
|
|
441
|
+
kind: 'ssh';
|
|
442
|
+
host: string;
|
|
443
|
+
connection?: SshConnection;
|
|
444
|
+
} | {
|
|
445
|
+
kind: 'docker';
|
|
446
|
+
container: string;
|
|
447
|
+
} | {
|
|
448
|
+
kind: 'incus';
|
|
449
|
+
container: string;
|
|
450
|
+
};
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/remote/helper.d.ts
|
|
453
|
+
interface HelperManifest {
|
|
454
|
+
format: 1;
|
|
455
|
+
name: string;
|
|
456
|
+
ver: string;
|
|
457
|
+
protocol: number;
|
|
458
|
+
targets: Record<string, {
|
|
459
|
+
file: string;
|
|
460
|
+
bytes: number;
|
|
461
|
+
sha256: string;
|
|
462
|
+
}>;
|
|
463
|
+
}
|
|
464
|
+
interface HelperAssets {
|
|
465
|
+
dir: string;
|
|
466
|
+
manifest: HelperManifest;
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/remote/transports.d.ts
|
|
470
|
+
/** Hub PTY 端点事实(ptyEndpoint 的返回形;结构类型,不引 superd-hub)。wsPath 由 transport
|
|
471
|
+
* 侧解析成绝对路径(superd-hub 上下文 = 分叉验证过的解析链;闭包/泵内绝不做按名解析赌注)。 */
|
|
472
|
+
interface HubPtyEndpoint {
|
|
473
|
+
url: string;
|
|
474
|
+
cookie: string;
|
|
475
|
+
wsPath: string;
|
|
476
|
+
}
|
|
477
|
+
/** Hub PTY(0.3.2-c;0.3.2-d F4 修正):会话子进程 = 本地 `script` PTY 托管的 WS 字节泵
|
|
478
|
+
* (hub-pty-pump.mjs)。与 docker exec 的嵌套 PTY 同形,但泵是哑 node 子进程、不像
|
|
479
|
+
* `ssh -tt` / `docker exec -it` 那样作为前台子进程自己把本地 tty 置 raw——所以本地包装必须
|
|
480
|
+
* `stty raw`:canonical+ISIG 下 0x03 在本地变 SIGINT 杀泵、0x04 变 EOF 结束泵 stdin
|
|
481
|
+
* (F4:input ^C/^D 与 job_kill 会打死整条会话)。raw 只作用于本地半段;对端 script PTY
|
|
482
|
+
* 保持 canonical,^C/^D 在对端产生 SIGINT/EOF 正是我们要的语义(字节原样过线,解释权在
|
|
483
|
+
* 对端)。kill 链 session 组杀 → 泵死 → WS 关 → 对端组杀,双向自然闭合。连接事实走 wrapper
|
|
484
|
+
* 内 env 赋值(cookie 不进 argv、不落 ps)。 */
|
|
485
|
+
declare function buildHubPtyArgv(endpoint: HubPtyEndpoint, assets: {
|
|
486
|
+
pumpPath: string;
|
|
487
|
+
nodePath?: string;
|
|
488
|
+
}): string[];
|
|
489
|
+
//#endregion
|
|
103
490
|
//#region src/remote/copy.d.ts
|
|
104
491
|
interface CopyRequest {
|
|
105
492
|
src: string;
|
|
@@ -126,20 +513,6 @@ interface TransferReceipt {
|
|
|
126
513
|
error?: string;
|
|
127
514
|
}
|
|
128
515
|
//#endregion
|
|
129
|
-
//#region src/remote/target.d.ts
|
|
130
|
-
/** 解析后的传输计划:三种 CLI 传输之一。 */
|
|
131
|
-
type TargetPlan = {
|
|
132
|
-
kind: 'ssh';
|
|
133
|
-
host: string;
|
|
134
|
-
connection?: SshConnection;
|
|
135
|
-
} | {
|
|
136
|
-
kind: 'docker';
|
|
137
|
-
container: string;
|
|
138
|
-
} | {
|
|
139
|
-
kind: 'incus';
|
|
140
|
-
container: string;
|
|
141
|
-
};
|
|
142
|
-
//#endregion
|
|
143
516
|
//#region src/remote/native-copy.d.ts
|
|
144
517
|
interface NativeCopyReceipt {
|
|
145
518
|
action: 'copy';
|
|
@@ -224,82 +597,6 @@ interface RsyncReceipt extends RunResult {
|
|
|
224
597
|
*/
|
|
225
598
|
declare function runRsync(request: RsyncRequest, source: RsyncEndpoint, destination: RsyncEndpoint, signal: AbortSignal, options?: RelayRsyncOptions): Promise<RsyncReceipt>;
|
|
226
599
|
//#endregion
|
|
227
|
-
//#region src/remote/helper.d.ts
|
|
228
|
-
interface HelperManifest {
|
|
229
|
-
format: 1;
|
|
230
|
-
name: string;
|
|
231
|
-
ver: string;
|
|
232
|
-
protocol: number;
|
|
233
|
-
targets: Record<string, {
|
|
234
|
-
file: string;
|
|
235
|
-
bytes: number;
|
|
236
|
-
sha256: string;
|
|
237
|
-
}>;
|
|
238
|
-
}
|
|
239
|
-
interface HelperAssets {
|
|
240
|
-
dir: string;
|
|
241
|
-
manifest: HelperManifest;
|
|
242
|
-
}
|
|
243
|
-
//#endregion
|
|
244
|
-
//#region src/remote/nonce-framing.d.ts
|
|
245
|
-
interface EnvDelta {
|
|
246
|
-
added: string[];
|
|
247
|
-
changed: string[];
|
|
248
|
-
removed: string[];
|
|
249
|
-
}
|
|
250
|
-
//#endregion
|
|
251
|
-
//#region src/remote/pty-session.d.ts
|
|
252
|
-
/** detached job 的完成结果(frame 或会话死亡时结算;与 dispatch 回执同构)。 */
|
|
253
|
-
interface PtyJobResult {
|
|
254
|
-
output: string;
|
|
255
|
-
outputStats?: StreamOutputStats;
|
|
256
|
-
exit: number | null;
|
|
257
|
-
cwd: string | null;
|
|
258
|
-
timedOut: boolean;
|
|
259
|
-
commandId: string;
|
|
260
|
-
envDelta?: EnvDelta;
|
|
261
|
-
}
|
|
262
|
-
/** P4/P5(2026-10-19)running job 句柄:byte-cursor 增量读 + P8 显式中断 + 完成时帧结算。 */
|
|
263
|
-
interface PtyRunningJob {
|
|
264
|
-
/** 账本键:与 jobId 同构(background 通道预传入 registry id;同步完成命令用同格式生成 id)。 */
|
|
265
|
-
commandId: string;
|
|
266
|
-
/** Byte-cursor incremental read over the command's merged output (tail-ring retention; lossy reports eviction). */
|
|
267
|
-
read: (fromByte: number) => {
|
|
268
|
-
text: string;
|
|
269
|
-
nextOffset: number;
|
|
270
|
-
lossy: boolean;
|
|
271
|
-
};
|
|
272
|
-
stats: () => OutputStats;
|
|
273
|
-
/** P8 两段式 ^C 中断(会话存活;trap-INT 走宽限 group-kill 兜底)。 */
|
|
274
|
-
interrupt: () => void;
|
|
275
|
-
/** Settles on the exit frame, or with exit null when the session dies. */
|
|
276
|
-
done: Promise<PtyJobResult>;
|
|
277
|
-
}
|
|
278
|
-
//#endregion
|
|
279
|
-
//#region src/remote/process.d.ts
|
|
280
|
-
declare const PROCESS_CLEANUP_BOUND_MS: number;
|
|
281
|
-
interface ProcessOptions {
|
|
282
|
-
stdin?: string;
|
|
283
|
-
timeoutSec?: number;
|
|
284
|
-
cwd?: string;
|
|
285
|
-
/** Hub retains raw bytes; native transports retain decoded UTF16 units. */
|
|
286
|
-
unit?: 'bytes' | 'utf16';
|
|
287
|
-
onOutput?: () => void;
|
|
288
|
-
/** Overlay on process.env (tool-built values only, e.g. RSYNC_RSH). */
|
|
289
|
-
env?: NodeJS.ProcessEnv;
|
|
290
|
-
}
|
|
291
|
-
/** Real detached process. Completion includes group cleanup, even after its leader closes. */
|
|
292
|
-
declare function startBinaryProcess(argv: string[], options?: Pick<ProcessOptions, 'cwd' | 'timeoutSec' | 'env'>): {
|
|
293
|
-
stdout: Readable;
|
|
294
|
-
stderr: Readable;
|
|
295
|
-
stdin: Writable;
|
|
296
|
-
cancel(): void;
|
|
297
|
-
done: RemoteProcess['done'];
|
|
298
|
-
diagnostic(): string | undefined;
|
|
299
|
-
};
|
|
300
|
-
/** Text adapter over the same owned process-group lifecycle as binary pipelines. */
|
|
301
|
-
declare function startOneShot(argv: string[], options?: ProcessOptions): RemoteProcess;
|
|
302
|
-
//#endregion
|
|
303
600
|
//#region src/remote/oneshot.d.ts
|
|
304
601
|
interface OneShotOptions {
|
|
305
602
|
stdin?: string;
|
|
@@ -380,13 +677,14 @@ interface RemoteDriverOptions {
|
|
|
380
677
|
getHub?: () => HubRemoteTransport | undefined;
|
|
381
678
|
execTimeoutSec?: number;
|
|
382
679
|
idleTtlSec?: number;
|
|
383
|
-
maxOutputChars?: number;
|
|
384
680
|
onAudit?: (r: RemoteAuditRecord) => void;
|
|
385
681
|
oneshotArgvFor?: (plan: TargetPlan, cmd: string, options: {
|
|
386
682
|
cleanupTag?: string;
|
|
387
683
|
}) => string[];
|
|
388
684
|
ptyArgvFor?: (plan: TargetPlan) => string[];
|
|
389
685
|
spawnArgvFor?: (spawnCommand: string) => string[];
|
|
686
|
+
/** 测试/验收缝:hub PTY 泵 argv(默认 buildHubPtyArgv + 宿主树 ws 解析)。 */
|
|
687
|
+
hubPtyArgvFor?: (endpoint: HubPtyEndpoint) => string[];
|
|
390
688
|
probeRunner?: ProbeOptions['runner'];
|
|
391
689
|
/** 测试/验收缝:helper 资产来源(默认 lib 旁挂 helper-bin);显式 null 强制 shim 路径。 */
|
|
392
690
|
helperAssetsFor?: () => HelperAssets | null;
|
|
@@ -395,6 +693,12 @@ interface RemoteDriverOptions {
|
|
|
395
693
|
/** 测试缝:ssh config 读取(裸名解析复用)。 */
|
|
396
694
|
sshConfigReader?: () => Promise<string>;
|
|
397
695
|
}
|
|
696
|
+
/** hub PTY 泵资产:pump 与本模块同目录(npm 包与 Super 闭包同构,helper.ts 同款纪律)。
|
|
697
|
+
* ws 模块路径由 transport 侧(superd-hub 上下文,分叉的 proven 解析链)解析后经
|
|
698
|
+
* ptyEndpoint 传入——闭包自身子树无可解析的 ws,按名解析不在闭包里做(0.3.2-c 定稿)。 */
|
|
699
|
+
declare function hubPtyAssets(): {
|
|
700
|
+
pumpPath: string;
|
|
701
|
+
};
|
|
398
702
|
/** 双轨调度器:参数校验 → 目标语法(parseTargetForm)→ 统一 label 池 → oneshot 子进程 / pty 会话池。 */
|
|
399
703
|
declare class RemoteDriver {
|
|
400
704
|
private readonly opts;
|
|
@@ -482,6 +786,16 @@ declare class RemoteDriver {
|
|
|
482
786
|
};
|
|
483
787
|
/** job 通道收养回填(timeout handoff 时 registry id ≠ commandId,账本记录两者)。 */
|
|
484
788
|
attachPtyJob(commandId: string, jobId: string, sessionKey: string): void;
|
|
789
|
+
/** §3.1(2026-10-25)interactive-stdin:input 动作——向已有 live PTY 的当前运行命令
|
|
790
|
+
* 追加 stdin。只解析池内已存在的会话(pty:<id|label> / 裸 label 命中 pty 项),
|
|
791
|
+
* 不触发发现、拨号、创建或重连;machine target 与创建形(:pty 后缀,含 hub:<m4>:pty)
|
|
792
|
+
* 一律明确拒绝并给出可恢复指引。回执附 connection/label 供工具层渲染。 */
|
|
793
|
+
input(target: string, options: PtyInputOptions, callCtx?: {
|
|
794
|
+
sessionKey?: string;
|
|
795
|
+
}): Promise<PtyInputReceipt & {
|
|
796
|
+
connection: string;
|
|
797
|
+
label?: string;
|
|
798
|
+
}>;
|
|
485
799
|
private dispatchPty;
|
|
486
800
|
/** 预热(创建形无 cmd)回执:§3——无 commandId/envDelta;timeout 忽略。 */
|
|
487
801
|
private warmReceipt;
|
|
@@ -512,116 +826,6 @@ declare class RemoteDriver {
|
|
|
512
826
|
dispose(): Promise<void>;
|
|
513
827
|
}
|
|
514
828
|
//#endregion
|
|
515
|
-
//#region src/remote/hub-contract.d.ts
|
|
516
|
-
interface RemoteInput {
|
|
517
|
-
target?: string;
|
|
518
|
-
spawn?: string;
|
|
519
|
-
ssh?: SshConnection;
|
|
520
|
-
cmd?: string;
|
|
521
|
-
scriptPath?: string;
|
|
522
|
-
stdin?: string;
|
|
523
|
-
mode?: 'oneshot' | 'pty';
|
|
524
|
-
timeout?: number;
|
|
525
|
-
}
|
|
526
|
-
interface PreparedRemoteInput {
|
|
527
|
-
target?: string;
|
|
528
|
-
spawn?: string;
|
|
529
|
-
ssh?: SshConnection;
|
|
530
|
-
cmd: string;
|
|
531
|
-
stdin?: string;
|
|
532
|
-
mode?: 'oneshot' | 'pty';
|
|
533
|
-
timeout?: number;
|
|
534
|
-
}
|
|
535
|
-
/** Counters exclude diagnostic banners. dropped is ring eviction; total-returned is all omitted output. */
|
|
536
|
-
type OutputStats = {
|
|
537
|
-
unit: 'utf16' | 'bytes';
|
|
538
|
-
total: number;
|
|
539
|
-
retained: number;
|
|
540
|
-
dropped: number;
|
|
541
|
-
returned: number;
|
|
542
|
-
retentionLimit: number;
|
|
543
|
-
};
|
|
544
|
-
type StreamOutputStats = {
|
|
545
|
-
stdout: OutputStats;
|
|
546
|
-
stderr?: OutputStats;
|
|
547
|
-
};
|
|
548
|
-
interface RemoteProcess {
|
|
549
|
-
cancel(reason?: string): void;
|
|
550
|
-
done: Promise<{
|
|
551
|
-
exit: number | null;
|
|
552
|
-
timedOut: boolean;
|
|
553
|
-
durationMs: number;
|
|
554
|
-
cancelled?: boolean;
|
|
555
|
-
}>;
|
|
556
|
-
/** diagnostic is executor-generated text, not process output; excluded from byte cursor and counters. */
|
|
557
|
-
read(channel: 'stdout' | 'stderr', fromByte: number): {
|
|
558
|
-
text: string;
|
|
559
|
-
nextOffset: number;
|
|
560
|
-
lossy: boolean;
|
|
561
|
-
stats?: OutputStats;
|
|
562
|
-
diagnostic?: string;
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
interface BinaryFileEndpoint {
|
|
566
|
-
exportTree(path: string, signal: AbortSignal): Promise<NodeJS.ReadableStream>;
|
|
567
|
-
importTree(path: string, source: NodeJS.ReadableStream, options: {
|
|
568
|
-
mkdir: boolean;
|
|
569
|
-
signal: AbortSignal;
|
|
570
|
-
}): Promise<void>;
|
|
571
|
-
digest(path: string, signal: AbortSignal, selection?: readonly string[]): Promise<{
|
|
572
|
-
sha256: string;
|
|
573
|
-
bytes: number;
|
|
574
|
-
entries: number;
|
|
575
|
-
}>;
|
|
576
|
-
}
|
|
577
|
-
interface HubTarget {
|
|
578
|
-
id: string;
|
|
579
|
-
label: string;
|
|
580
|
-
execEnabled: boolean;
|
|
581
|
-
}
|
|
582
|
-
interface HubRemoteTransport {
|
|
583
|
-
protocol: 1;
|
|
584
|
-
listTargets(): readonly HubTarget[];
|
|
585
|
-
start(machine: string, input: PreparedRemoteInput, owner: string): Promise<RemoteProcess>;
|
|
586
|
-
pty(machine: string, cmd: string, owner: string, options: {
|
|
587
|
-
stdin?: string;
|
|
588
|
-
timeout?: number;
|
|
589
|
-
}): Promise<RemoteCallResult>;
|
|
590
|
-
fileEndpoint(machine: string): BinaryFileEndpoint;
|
|
591
|
-
releaseOwner(owner: string): Promise<void>;
|
|
592
|
-
}
|
|
593
|
-
//#endregion
|
|
594
|
-
//#region src/remote/output-ring.d.ts
|
|
595
|
-
/** Byte-addressed decoded output: mid-codepoint cursors skip forward and explicitly report loss. */
|
|
596
|
-
declare function readUtf8Tail(bytes: Buffer, totalBytes: number, fromByte: number): {
|
|
597
|
-
text: string;
|
|
598
|
-
nextOffset: number;
|
|
599
|
-
lossy: boolean;
|
|
600
|
-
};
|
|
601
|
-
/** Native/PTY retention is UTF16 units; cursor offsets remain real UTF8 bytes. Input is decoded text. */
|
|
602
|
-
declare class Utf16TailRing {
|
|
603
|
-
readonly capacity: number;
|
|
604
|
-
text: string;
|
|
605
|
-
total: number;
|
|
606
|
-
private totalBytes;
|
|
607
|
-
constructor(capacity?: number);
|
|
608
|
-
push(text: string): void;
|
|
609
|
-
stats(returned?: number): OutputStats;
|
|
610
|
-
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
611
|
-
}
|
|
612
|
-
/** Raw byte retention for Hub oneshot. Tail/read starts skip partial UTF8 prefixes, never invent replacement characters. */
|
|
613
|
-
declare class ByteTailRing {
|
|
614
|
-
readonly capacity: number;
|
|
615
|
-
total: number;
|
|
616
|
-
private chunks;
|
|
617
|
-
private retained;
|
|
618
|
-
constructor(capacity?: number);
|
|
619
|
-
push(chunk: Buffer): void;
|
|
620
|
-
tail(maxBytes?: number): Buffer;
|
|
621
|
-
stats(returned?: number): OutputStats;
|
|
622
|
-
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
623
|
-
}
|
|
624
|
-
//#endregion
|
|
625
829
|
//#region src/remote/jobs.d.ts
|
|
626
830
|
declare module '@deepseek-ai/dsh-jobs' {
|
|
627
831
|
interface JobKindMap {
|
|
@@ -660,7 +864,6 @@ declare const inject: string[];
|
|
|
660
864
|
interface RemoteRowConfig {
|
|
661
865
|
execTimeoutSec: number;
|
|
662
866
|
idleTtlSec: number;
|
|
663
|
-
maxOutputChars: number;
|
|
664
867
|
}
|
|
665
868
|
type RemoteConfigValidator = ((value?: unknown) => RemoteRowConfig) & StandardSchemaV1<unknown, RemoteRowConfig> & NativeConfigSchema;
|
|
666
869
|
declare const Config: RemoteConfigValidator;
|
|
@@ -673,4 +876,4 @@ declare const _default: {
|
|
|
673
876
|
apply: (ctx: Context, config: RemoteRowConfig) => (() => void);
|
|
674
877
|
};
|
|
675
878
|
//#endregion
|
|
676
|
-
export { type BinaryFileEndpoint, ByteTailRing, Config, FILE_FRAME_BYTES, FILE_MAX_ENTRIES, FILE_MAX_METADATA, type HubRemoteTransport, type HubTarget, type OutputStats, PROCESS_CLEANUP_BOUND_MS, type PreparedRemoteInput, RemoteConfigValidator, type RemoteInput, type RemoteProcess, RemoteRowConfig, type RsyncEndpoint, type RsyncReceipt, type RsyncRequest, type SshConnection, type StreamOutputStats, Utf16TailRing, apply, checkAbsolute, checkSelection, _default as default, inject, localFileEndpoint, name, readUtf8Tail, runFileWorker, runRsync, sshArgv, startBinaryProcess, startOneShot, startRemoteJob };
|
|
879
|
+
export { type BinaryFileEndpoint, ByteTailRing, Config, FILE_FRAME_BYTES, FILE_MAX_ENTRIES, FILE_MAX_METADATA, type HubPtyEndpoint, type HubRemoteTransport, type HubTarget, type OutputStats, PROCESS_CLEANUP_BOUND_MS, type PreparedRemoteInput, type PtyDispatchResult, PtySession, RemoteConfigValidator, type RemoteInput, type RemoteProcess, RemoteRowConfig, type RsyncEndpoint, type RsyncReceipt, type RsyncRequest, type SshConnection, type StreamOutputStats, Utf16TailRing, apply, buildHubPtyArgv, checkAbsolute, checkSelection, _default as default, disclose, hubPtyAssets, inject, localFileEndpoint, name, readUtf8Tail, runFileWorker, runRsync, sshArgv, startBinaryProcess, startOneShot, startRemoteJob };
|