super-dsh 0.3.0-e → 0.3.0-g
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/README.md +13 -55
- package/client/index.js +141 -10
- package/cordis.patch.yml +6 -3
- package/package.json +12 -5
- package/remote/file-worker.js +341 -0
- package/remote/plugin.d.ts +523 -0
- package/remote/plugin.js +4979 -0
- package/remote/provenance.json +64 -0
- package/superd-hub/dist/a2a-row.d.ts +18 -2
- package/superd-hub/dist/a2a-row.js +11 -69
- package/superd-hub/dist/bundle-setup.d.ts +16 -6
- package/superd-hub/dist/bundle-setup.js +84 -148
- package/superd-hub/dist/client/companion-api.d.ts +5 -0
- package/superd-hub/dist/client/companion-api.js +30 -0
- package/superd-hub/dist/companion-contract.d.ts +9 -0
- package/superd-hub/dist/companion-contract.js +1 -0
- package/superd-hub/dist/companions.d.ts +30 -0
- package/superd-hub/dist/companions.js +209 -0
- package/superd-hub/dist/exec-pty-framing.d.ts +3 -1
- package/superd-hub/dist/exec-pty-framing.js +12 -4
- package/superd-hub/dist/exec-pty-session.d.ts +2 -0
- package/superd-hub/dist/exec-pty-session.js +7 -13
- package/superd-hub/dist/exec.d.ts +5 -2
- package/superd-hub/dist/exec.js +34 -54
- package/superd-hub/dist/fusion-transport.js +1 -0
- package/superd-hub/dist/gateway.js +24 -11
- package/superd-hub/dist/hub-tool.d.ts +3 -0
- package/superd-hub/dist/hub-tool.js +13 -5
- package/superd-hub/dist/remote-file-rpc.d.ts +20 -0
- package/superd-hub/dist/remote-file-rpc.js +574 -0
- package/superd-hub/dist/remote-job-client.d.ts +3 -0
- package/superd-hub/dist/remote-job-client.js +197 -0
- package/superd-hub/dist/remote-job-rpc.d.ts +21 -0
- package/superd-hub/dist/remote-job-rpc.js +155 -0
- package/superd-hub/dist/remote-provider.d.ts +13 -0
- package/superd-hub/dist/remote-provider.js +151 -0
- package/superd-hub/dist/remote-row.d.ts +6 -0
- package/superd-hub/dist/remote-row.js +13 -0
- package/superd-hub/lib/client/index.js +141 -10
- package/superd-hub/package.json +1 -2
- package/superd-hub/scripts/register-companion.mjs +0 -100
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
+
import { Readable, Writable } from "node:stream";
|
|
3
|
+
import { ToolRunContext } from "@deepseek-ai/dsh-tools";
|
|
4
|
+
import { NativeConfigSchema } from "@deepseek-ai/dsh-app-boot";
|
|
5
|
+
import { JobId, JobRegistry } from "@deepseek-ai/dsh-jobs";
|
|
6
|
+
|
|
7
|
+
//#region third_party/schemastery/node_modules/@standard-schema/spec/dist/index.d.ts
|
|
8
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
9
|
+
interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
10
|
+
/** The Standard properties. */
|
|
11
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
12
|
+
}
|
|
13
|
+
declare namespace StandardTypedV1 {
|
|
14
|
+
/** The Standard Typed properties interface. */
|
|
15
|
+
interface Props<Input = unknown, Output = Input> {
|
|
16
|
+
/** The version number of the standard. */
|
|
17
|
+
readonly version: 1;
|
|
18
|
+
/** The vendor name of the schema library. */
|
|
19
|
+
readonly vendor: string;
|
|
20
|
+
/** Inferred types associated with the schema. */
|
|
21
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
22
|
+
}
|
|
23
|
+
/** The Standard Typed types interface. */
|
|
24
|
+
interface Types<Input = unknown, Output = Input> {
|
|
25
|
+
/** The input type of the schema. */
|
|
26
|
+
readonly input: Input;
|
|
27
|
+
/** The output type of the schema. */
|
|
28
|
+
readonly output: Output;
|
|
29
|
+
}
|
|
30
|
+
/** Infers the input type of a Standard Typed. */
|
|
31
|
+
type InferInput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
32
|
+
/** Infers the output type of a Standard Typed. */
|
|
33
|
+
type InferOutput<Schema extends StandardTypedV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
34
|
+
}
|
|
35
|
+
/** The Standard Schema interface. */
|
|
36
|
+
interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
37
|
+
/** The Standard Schema properties. */
|
|
38
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
39
|
+
}
|
|
40
|
+
declare namespace StandardSchemaV1 {
|
|
41
|
+
/** The Standard Schema properties interface. */
|
|
42
|
+
interface Props<Input = unknown, Output = Input> extends StandardTypedV1.Props<Input, Output> {
|
|
43
|
+
/** Validates unknown input values. */
|
|
44
|
+
readonly validate: (value: unknown, options?: StandardSchemaV1.Options | undefined) => Result<Output> | Promise<Result<Output>>;
|
|
45
|
+
}
|
|
46
|
+
/** The result interface of the validate function. */
|
|
47
|
+
type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
48
|
+
/** The result interface if validation succeeds. */
|
|
49
|
+
interface SuccessResult<Output> {
|
|
50
|
+
/** The typed output value. */
|
|
51
|
+
readonly value: Output;
|
|
52
|
+
/** A falsy value for `issues` indicates success. */
|
|
53
|
+
readonly issues?: undefined;
|
|
54
|
+
}
|
|
55
|
+
interface Options {
|
|
56
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
57
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
58
|
+
}
|
|
59
|
+
/** The result interface if validation fails. */
|
|
60
|
+
interface FailureResult {
|
|
61
|
+
/** The issues of failed validation. */
|
|
62
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
63
|
+
}
|
|
64
|
+
/** The issue interface of the failure output. */
|
|
65
|
+
interface Issue {
|
|
66
|
+
/** The error message of the issue. */
|
|
67
|
+
readonly message: string;
|
|
68
|
+
/** The path of the issue, if any. */
|
|
69
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
70
|
+
}
|
|
71
|
+
/** The path segment interface of the issue. */
|
|
72
|
+
interface PathSegment {
|
|
73
|
+
/** The key representing a path segment. */
|
|
74
|
+
readonly key: PropertyKey;
|
|
75
|
+
}
|
|
76
|
+
/** The Standard types interface. */
|
|
77
|
+
interface Types<Input = unknown, Output = Input> extends StandardTypedV1.Types<Input, Output> {}
|
|
78
|
+
/** Infers the input type of a Standard. */
|
|
79
|
+
type InferInput<Schema extends StandardTypedV1> = StandardTypedV1.InferInput<Schema>;
|
|
80
|
+
/** Infers the output type of a Standard. */
|
|
81
|
+
type InferOutput<Schema extends StandardTypedV1> = StandardTypedV1.InferOutput<Schema>;
|
|
82
|
+
}
|
|
83
|
+
/** The Standard JSON Schema interface. */
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/remote/ssh-targets.d.ts
|
|
86
|
+
/** Origin-owned identity reference, never key contents or a persistent credential store. */
|
|
87
|
+
interface SshConnection {
|
|
88
|
+
readonly host: string;
|
|
89
|
+
readonly user?: string;
|
|
90
|
+
readonly port?: number;
|
|
91
|
+
readonly key?: string;
|
|
92
|
+
readonly proxyJump?: string;
|
|
93
|
+
}
|
|
94
|
+
/** One instance per Agent-owned driver; destroyed with its Agent/plugin owners. */
|
|
95
|
+
declare class SshTargets {
|
|
96
|
+
private readonly targets;
|
|
97
|
+
register(label: string, connection: SshConnection): SshConnection;
|
|
98
|
+
get(label: string): SshConnection | undefined;
|
|
99
|
+
entries(): ReadonlyArray<readonly [string, SshConnection]>;
|
|
100
|
+
clear(): void;
|
|
101
|
+
}
|
|
102
|
+
/** Shared by execution, probes and file/relay consumers. extraArgs is trusted
|
|
103
|
+
* internal SSH argv (e.g. forwarding), never a model-provided shell string. */
|
|
104
|
+
declare function sshArgv(connection: SshConnection, options?: {
|
|
105
|
+
tty?: boolean;
|
|
106
|
+
extraArgs?: readonly string[];
|
|
107
|
+
command?: string;
|
|
108
|
+
}): string[];
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/remote/copy.d.ts
|
|
111
|
+
interface CopyRequest {
|
|
112
|
+
src: string;
|
|
113
|
+
dst: string;
|
|
114
|
+
verify?: boolean;
|
|
115
|
+
mkdir?: boolean;
|
|
116
|
+
}
|
|
117
|
+
interface TransferReceipt {
|
|
118
|
+
action: 'copy';
|
|
119
|
+
src: string;
|
|
120
|
+
dst: string;
|
|
121
|
+
verified: boolean;
|
|
122
|
+
sourceDigest?: string;
|
|
123
|
+
destinationDigest?: string;
|
|
124
|
+
bytes: number;
|
|
125
|
+
entries: number;
|
|
126
|
+
scratch?: string;
|
|
127
|
+
scope: 'transferred entries';
|
|
128
|
+
error?: string;
|
|
129
|
+
}
|
|
130
|
+
//#endregion
|
|
131
|
+
//#region src/remote/ssh-relay.d.ts
|
|
132
|
+
type SshBuilder = typeof sshArgv;
|
|
133
|
+
interface CommandResult {
|
|
134
|
+
exit: number | null;
|
|
135
|
+
stdout: string;
|
|
136
|
+
stderr: string;
|
|
137
|
+
outputTruncated: boolean;
|
|
138
|
+
}
|
|
139
|
+
interface RelayOptions {
|
|
140
|
+
ssh?: SshBuilder;
|
|
141
|
+
ports?: {
|
|
142
|
+
destination: number;
|
|
143
|
+
origin: number;
|
|
144
|
+
source: number;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
interface Relay {
|
|
148
|
+
url: string;
|
|
149
|
+
/** Runs sender under a lease-owned remote supervisor, never downstream SSH. */
|
|
150
|
+
run(argv: string[]): Promise<CommandResult>;
|
|
151
|
+
}
|
|
152
|
+
declare function withSshRelay<T>(source: SshConnection, destination: SshConnection, targetPath: string, signal: AbortSignal, run: (relay: Relay) => Promise<T>, options?: RelayOptions): Promise<T>;
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/remote/rsync.d.ts
|
|
155
|
+
interface RsyncRequest {
|
|
156
|
+
src: string;
|
|
157
|
+
dst: string;
|
|
158
|
+
dryRun?: boolean;
|
|
159
|
+
delete?: boolean;
|
|
160
|
+
excludes?: readonly string[];
|
|
161
|
+
preserve?: boolean;
|
|
162
|
+
}
|
|
163
|
+
interface RsyncEndpoint {
|
|
164
|
+
path: string;
|
|
165
|
+
connection?: SshConnection;
|
|
166
|
+
}
|
|
167
|
+
interface RsyncReceipt extends CommandResult {
|
|
168
|
+
action: 'rsync';
|
|
169
|
+
src: string;
|
|
170
|
+
dst: string;
|
|
171
|
+
dryRun: boolean;
|
|
172
|
+
delete: boolean;
|
|
173
|
+
preserve: boolean;
|
|
174
|
+
itemizedChanges: string[];
|
|
175
|
+
literalBytes?: number;
|
|
176
|
+
matchedBytes?: number;
|
|
177
|
+
sentBytes?: number;
|
|
178
|
+
receivedBytes?: number;
|
|
179
|
+
transferredBytes?: number;
|
|
180
|
+
}
|
|
181
|
+
declare function runRsync(request: RsyncRequest, source: RsyncEndpoint, destination: RsyncEndpoint, signal: AbortSignal, options?: RelayOptions): Promise<RsyncReceipt>;
|
|
182
|
+
//#endregion
|
|
183
|
+
//#region src/remote/target.d.ts
|
|
184
|
+
/** 解析后的传输计划:三种 CLI 传输之一。 */
|
|
185
|
+
type TargetPlan = {
|
|
186
|
+
kind: 'ssh';
|
|
187
|
+
host: string;
|
|
188
|
+
connection?: SshConnection;
|
|
189
|
+
} | {
|
|
190
|
+
kind: 'docker';
|
|
191
|
+
container: string;
|
|
192
|
+
} | {
|
|
193
|
+
kind: 'incus';
|
|
194
|
+
container: string;
|
|
195
|
+
};
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/remote/process.d.ts
|
|
198
|
+
declare const PROCESS_CLEANUP_BOUND_MS: number;
|
|
199
|
+
interface ProcessOptions {
|
|
200
|
+
stdin?: string;
|
|
201
|
+
timeoutSec?: number;
|
|
202
|
+
cwd?: string;
|
|
203
|
+
/** Hub retains raw bytes; native transports retain decoded UTF16 units. */
|
|
204
|
+
unit?: 'bytes' | 'utf16';
|
|
205
|
+
onOutput?: () => void;
|
|
206
|
+
}
|
|
207
|
+
/** Real detached process. Completion includes group cleanup, even after its leader closes. */
|
|
208
|
+
declare function startBinaryProcess(argv: string[], options?: Pick<ProcessOptions, 'cwd' | 'timeoutSec'>): {
|
|
209
|
+
stdout: Readable;
|
|
210
|
+
stderr: Readable;
|
|
211
|
+
stdin: Writable;
|
|
212
|
+
cancel(): void;
|
|
213
|
+
done: RemoteProcess['done'];
|
|
214
|
+
diagnostic(): string | undefined;
|
|
215
|
+
};
|
|
216
|
+
/** Text adapter over the same owned process-group lifecycle as binary pipelines. */
|
|
217
|
+
declare function startOneShot(argv: string[], options?: ProcessOptions): RemoteProcess;
|
|
218
|
+
//#endregion
|
|
219
|
+
//#region src/remote/oneshot.d.ts
|
|
220
|
+
interface OneShotOptions {
|
|
221
|
+
stdin?: string;
|
|
222
|
+
timeoutSec?: number;
|
|
223
|
+
}
|
|
224
|
+
interface OneShotResult {
|
|
225
|
+
exit: number | null;
|
|
226
|
+
timedOut: boolean;
|
|
227
|
+
stdout: string;
|
|
228
|
+
stderr: string;
|
|
229
|
+
durationMs: number;
|
|
230
|
+
outputStats?: StreamOutputStats;
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
//#region src/remote/status.d.ts
|
|
234
|
+
interface ProbeOptions {
|
|
235
|
+
connectTimeoutSec?: number;
|
|
236
|
+
hardTimeoutSec?: number;
|
|
237
|
+
runner?: (argv: string[], opts?: OneShotOptions) => Promise<OneShotResult>;
|
|
238
|
+
}
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region src/remote/roster.d.ts
|
|
241
|
+
interface RosterOptions {
|
|
242
|
+
byosshLabels?: readonly string[];
|
|
243
|
+
/** 测试缝:替代 runOneShot 的容器扫描执行器。 */
|
|
244
|
+
runner?: (argv: string[], opts?: OneShotOptions) => Promise<OneShotResult>;
|
|
245
|
+
/** 测试缝:替代 ~/.ssh/config 读取。 */
|
|
246
|
+
readSshConfig?: () => Promise<string>;
|
|
247
|
+
hardTimeoutSec?: number;
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/remote/driver.d.ts
|
|
251
|
+
type RemoteCallParams = RemoteInput;
|
|
252
|
+
interface RemoteCallResult {
|
|
253
|
+
mode: 'oneshot' | 'pty';
|
|
254
|
+
target: string;
|
|
255
|
+
exit: number | null;
|
|
256
|
+
cwd: string | null;
|
|
257
|
+
timedOut: boolean;
|
|
258
|
+
reconnected: boolean;
|
|
259
|
+
stdout: string;
|
|
260
|
+
stderr?: string;
|
|
261
|
+
durationMs: number;
|
|
262
|
+
truncated?: number;
|
|
263
|
+
outputStats?: StreamOutputStats;
|
|
264
|
+
outputStatsUnavailable?: boolean;
|
|
265
|
+
/** `byop:<label>` 调用面:本会话的 label(模型自选、即复用入口)。transport target 会话不带。 */
|
|
266
|
+
session?: string;
|
|
267
|
+
/** 引导/教学行(同 label 重复给 spawn 时的「可省略 spawn」提示等);无则省略。 */
|
|
268
|
+
notice?: string;
|
|
269
|
+
}
|
|
270
|
+
interface RemoteAuditRecord {
|
|
271
|
+
target: string;
|
|
272
|
+
cmd: string;
|
|
273
|
+
cwd?: string;
|
|
274
|
+
exit?: number | null;
|
|
275
|
+
durationMs?: number;
|
|
276
|
+
error?: string;
|
|
277
|
+
}
|
|
278
|
+
interface RemoteDriverOptions {
|
|
279
|
+
/** Fixture transport seam; normal consumers use the canonical native SSH builder. */
|
|
280
|
+
rsyncSshArgv?: SshBuilder;
|
|
281
|
+
getHub?: () => HubRemoteTransport | undefined;
|
|
282
|
+
execTimeoutSec?: number;
|
|
283
|
+
idleTtlSec?: number;
|
|
284
|
+
maxOutputChars?: number;
|
|
285
|
+
onAudit?: (r: RemoteAuditRecord) => void;
|
|
286
|
+
oneshotArgvFor?: (plan: TargetPlan, cmd: string) => string[];
|
|
287
|
+
ptyArgvFor?: (plan: TargetPlan) => string[];
|
|
288
|
+
spawnArgvFor?: (spawnCommand: string) => string[];
|
|
289
|
+
probeRunner?: ProbeOptions['runner'];
|
|
290
|
+
/** 测试缝:roster 扫描执行器(bare-name 解析复用)。 */
|
|
291
|
+
rosterRunner?: RosterOptions['runner'];
|
|
292
|
+
/** 测试缝:ssh config 读取(bare-name 解析复用)。 */
|
|
293
|
+
sshConfigReader?: () => Promise<string>;
|
|
294
|
+
}
|
|
295
|
+
/** 双轨调度器(spec §七 Phase 2):参数校验 → 路由 → oneshot 子进程 / pty 会话池。 */
|
|
296
|
+
declare class RemoteDriver {
|
|
297
|
+
private readonly opts;
|
|
298
|
+
private readonly sshTargets;
|
|
299
|
+
private readonly pool;
|
|
300
|
+
private readonly hubOwner;
|
|
301
|
+
private readonly hubProviders;
|
|
302
|
+
private readonly processes;
|
|
303
|
+
private readonly starting;
|
|
304
|
+
private readonly fileAbort;
|
|
305
|
+
private disposed;
|
|
306
|
+
private disposal;
|
|
307
|
+
constructor(opts?: RemoteDriverOptions);
|
|
308
|
+
call(params: RemoteCallParams, callCtx?: {
|
|
309
|
+
sessionKey?: string;
|
|
310
|
+
}): Promise<RemoteCallResult>;
|
|
311
|
+
copy(request: CopyRequest, signal: AbortSignal, callCtx?: {
|
|
312
|
+
sessionKey?: string;
|
|
313
|
+
}): Promise<TransferReceipt>;
|
|
314
|
+
rsync(request: RsyncRequest, signal: AbortSignal, callCtx?: {
|
|
315
|
+
sessionKey?: string;
|
|
316
|
+
}): Promise<RsyncReceipt>;
|
|
317
|
+
/** Only called from JobSpec.run: admission precedes local file reads and discovery. */
|
|
318
|
+
start(input: RemoteInput, signal: AbortSignal): Promise<RemoteProcess>;
|
|
319
|
+
private startPrepared;
|
|
320
|
+
private nativeProcess;
|
|
321
|
+
private own;
|
|
322
|
+
/** Ruling 16/17:on-demand 探测 + 会话层,两行如实陈述。 */
|
|
323
|
+
/**
|
|
324
|
+
* Ruling P20 + PTY 候选表末位:裸名按名匹配——ssh config 字面 host → docker → incus(本地廉价扫描,
|
|
325
|
+
* 撞名 ssh 优先),三段全不中再看池内活 PTY label,最后才是默认 ssh(交原生错误)。
|
|
326
|
+
* 位置即优先级:现有三段一位不挪。选择器前缀的 target 不经此路径。
|
|
327
|
+
*/
|
|
328
|
+
private resolveBareName;
|
|
329
|
+
/** Ruling P19:roster = 注意力入口——本地廉价扫描(ssh config/docker ps/incus list + 池内活会话),零拨号。
|
|
330
|
+
* 活的 pty 会话按调用方 agent session 过滤(2026-10-03 裁决):ssh/docker/incus 是**公共静态配置**,
|
|
331
|
+
* 而活会话是**操作环境**——复用别的 agent 留下的 shell 等于继承未知状态,且两个 agent 各开一条线
|
|
332
|
+
* 的代价可忽略。BYO-PTY 天然是活的,于是自然落进这个 scope,无需另立规则。 */
|
|
333
|
+
roster(callCtx?: {
|
|
334
|
+
sessionKey?: string;
|
|
335
|
+
}): Promise<string>;
|
|
336
|
+
status(target: string, callCtx?: {
|
|
337
|
+
sessionKey?: string;
|
|
338
|
+
}): Promise<string>;
|
|
339
|
+
/** PTY 状态行:纯池内读取,零拨号(label 从来不是可拨目标)。 */
|
|
340
|
+
private ptyStatus;
|
|
341
|
+
/** Ruling 13:审计 best-effort——钩子抛错不得影响命令路径(成功被毒化成失败+双重审计)。 */
|
|
342
|
+
private audit;
|
|
343
|
+
/** Registration never dials; response reveals labels only, not credentials. */
|
|
344
|
+
registerSsh(target: string, connection: SshConnection): string;
|
|
345
|
+
private byosshPlan;
|
|
346
|
+
/** Single target resolver for later copy/rsync; BYO identities cannot be
|
|
347
|
+
* independently re-resolved through the origin's alias table. */
|
|
348
|
+
resolveConnectionTarget(target: string, callCtx?: {
|
|
349
|
+
sessionKey?: string;
|
|
350
|
+
}): Promise<TargetPlan>;
|
|
351
|
+
private route;
|
|
352
|
+
private execute;
|
|
353
|
+
/** BYO-PTY 通道:label 即池键(agent 前缀之外),spawn 只在 label 尚不存在时被接受。
|
|
354
|
+
* 三分支 —— 建(无会话)/ 复用(无 spawn,或有 spawn 且与创建来源相同)/ **冲突(有 spawn 且来源不同:不执行任何命令)**。 */
|
|
355
|
+
private ptyCall;
|
|
356
|
+
hasHub(): boolean;
|
|
357
|
+
private requireHub;
|
|
358
|
+
private assertOpen;
|
|
359
|
+
dispose(): Promise<void>;
|
|
360
|
+
}
|
|
361
|
+
//#endregion
|
|
362
|
+
//#region src/remote/hub-contract.d.ts
|
|
363
|
+
interface RemoteInput {
|
|
364
|
+
target?: string;
|
|
365
|
+
spawn?: string;
|
|
366
|
+
ssh?: SshConnection;
|
|
367
|
+
cmd?: string;
|
|
368
|
+
script?: string;
|
|
369
|
+
stdin?: string;
|
|
370
|
+
mode?: 'oneshot' | 'pty';
|
|
371
|
+
timeout?: number;
|
|
372
|
+
}
|
|
373
|
+
interface PreparedRemoteInput {
|
|
374
|
+
target: string;
|
|
375
|
+
spawn?: string;
|
|
376
|
+
ssh?: SshConnection;
|
|
377
|
+
cmd: string;
|
|
378
|
+
stdin?: string;
|
|
379
|
+
mode?: 'oneshot' | 'pty';
|
|
380
|
+
timeout?: number;
|
|
381
|
+
}
|
|
382
|
+
/** Counters exclude diagnostic banners. dropped is ring eviction; total-returned is all omitted output. */
|
|
383
|
+
type OutputStats = {
|
|
384
|
+
unit: 'utf16' | 'bytes';
|
|
385
|
+
total: number;
|
|
386
|
+
retained: number;
|
|
387
|
+
dropped: number;
|
|
388
|
+
returned: number;
|
|
389
|
+
retentionLimit: number;
|
|
390
|
+
};
|
|
391
|
+
type StreamOutputStats = {
|
|
392
|
+
stdout: OutputStats;
|
|
393
|
+
stderr?: OutputStats;
|
|
394
|
+
};
|
|
395
|
+
interface RemoteProcess {
|
|
396
|
+
cancel(reason?: string): void;
|
|
397
|
+
done: Promise<{
|
|
398
|
+
exit: number | null;
|
|
399
|
+
timedOut: boolean;
|
|
400
|
+
durationMs: number;
|
|
401
|
+
cancelled?: boolean;
|
|
402
|
+
}>;
|
|
403
|
+
/** diagnostic is executor-generated text, not process output; excluded from byte cursor and counters. */
|
|
404
|
+
read(channel: 'stdout' | 'stderr', fromByte: number): {
|
|
405
|
+
text: string;
|
|
406
|
+
nextOffset: number;
|
|
407
|
+
lossy: boolean;
|
|
408
|
+
stats?: OutputStats;
|
|
409
|
+
diagnostic?: string;
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
interface BinaryFileEndpoint {
|
|
413
|
+
exportTree(path: string, signal: AbortSignal): Promise<NodeJS.ReadableStream>;
|
|
414
|
+
importTree(path: string, source: NodeJS.ReadableStream, options: {
|
|
415
|
+
mkdir: boolean;
|
|
416
|
+
signal: AbortSignal;
|
|
417
|
+
}): Promise<void>;
|
|
418
|
+
digest(path: string, signal: AbortSignal, selection?: readonly string[]): Promise<{
|
|
419
|
+
sha256: string;
|
|
420
|
+
bytes: number;
|
|
421
|
+
entries: number;
|
|
422
|
+
}>;
|
|
423
|
+
}
|
|
424
|
+
interface HubTarget {
|
|
425
|
+
id: string;
|
|
426
|
+
label: string;
|
|
427
|
+
execEnabled: boolean;
|
|
428
|
+
}
|
|
429
|
+
interface HubRemoteTransport {
|
|
430
|
+
protocol: 1;
|
|
431
|
+
listTargets(): readonly HubTarget[];
|
|
432
|
+
start(machine: string, input: PreparedRemoteInput, owner: string): Promise<RemoteProcess>;
|
|
433
|
+
pty(machine: string, cmd: string, owner: string, options: {
|
|
434
|
+
stdin?: string;
|
|
435
|
+
timeout?: number;
|
|
436
|
+
}): Promise<RemoteCallResult>;
|
|
437
|
+
fileEndpoint(machine: string): BinaryFileEndpoint;
|
|
438
|
+
releaseOwner(owner: string): Promise<void>;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/remote/output-ring.d.ts
|
|
442
|
+
/** Byte-addressed decoded output: mid-codepoint cursors skip forward and explicitly report loss. */
|
|
443
|
+
declare function readUtf8Tail(bytes: Buffer, totalBytes: number, fromByte: number): {
|
|
444
|
+
text: string;
|
|
445
|
+
nextOffset: number;
|
|
446
|
+
lossy: boolean;
|
|
447
|
+
};
|
|
448
|
+
/** Native/PTY retention is UTF16 units; cursor offsets remain real UTF8 bytes. Input is decoded text. */
|
|
449
|
+
declare class Utf16TailRing {
|
|
450
|
+
readonly capacity: number;
|
|
451
|
+
text: string;
|
|
452
|
+
total: number;
|
|
453
|
+
private totalBytes;
|
|
454
|
+
constructor(capacity?: number);
|
|
455
|
+
push(text: string): void;
|
|
456
|
+
stats(returned?: number): OutputStats;
|
|
457
|
+
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
458
|
+
}
|
|
459
|
+
/** Raw byte retention for Hub oneshot. Tail/read starts skip partial UTF8 prefixes, never invent replacement characters. */
|
|
460
|
+
declare class ByteTailRing {
|
|
461
|
+
readonly capacity: number;
|
|
462
|
+
total: number;
|
|
463
|
+
private chunks;
|
|
464
|
+
private retained;
|
|
465
|
+
constructor(capacity?: number);
|
|
466
|
+
push(chunk: Buffer): void;
|
|
467
|
+
tail(maxBytes?: number): Buffer;
|
|
468
|
+
stats(returned?: number): OutputStats;
|
|
469
|
+
read(fromByte: number): ReturnType<typeof readUtf8Tail>;
|
|
470
|
+
}
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/remote/jobs.d.ts
|
|
473
|
+
declare module '@deepseek-ai/dsh-jobs' {
|
|
474
|
+
interface JobKindMap {
|
|
475
|
+
remote: 'remote';
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
/** No preparation or discovery before the official registry's admission. */
|
|
479
|
+
declare function startRemoteJob(registry: JobRegistry, input: RemoteInput, exec: ToolRunContext, driver: RemoteDriver): JobId;
|
|
480
|
+
//#endregion
|
|
481
|
+
//#region src/remote/archive.d.ts
|
|
482
|
+
declare const FILE_FRAME_BYTES: number;
|
|
483
|
+
declare const FILE_MAX_ENTRIES = 10000;
|
|
484
|
+
declare const FILE_MAX_METADATA: number;
|
|
485
|
+
declare function checkAbsolute(p: string): void;
|
|
486
|
+
declare function checkSelection(selection: readonly string[]): void;
|
|
487
|
+
/** Internal worker ownership hooks, not a second endpoint contract. */
|
|
488
|
+
interface LocalFileResources {
|
|
489
|
+
receiveRoot?: string;
|
|
490
|
+
temporary?(path: string, active: boolean): Promise<void>;
|
|
491
|
+
}
|
|
492
|
+
declare function localFileEndpoint(resources?: LocalFileResources): BinaryFileEndpoint;
|
|
493
|
+
//#endregion
|
|
494
|
+
//#region src/remote/file-worker.d.ts
|
|
495
|
+
declare function runFileWorker(request: {
|
|
496
|
+
action: 'export' | 'import' | 'digest';
|
|
497
|
+
path: string;
|
|
498
|
+
mkdir: boolean;
|
|
499
|
+
root: string;
|
|
500
|
+
selected: boolean;
|
|
501
|
+
}): Promise<void>;
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/remote/plugin.d.ts
|
|
504
|
+
declare const name = "dashr-remote";
|
|
505
|
+
declare const inject: string[];
|
|
506
|
+
/** 运行参数旋钮(Ruling P18):无别名表面——容器一律显式 'docker:' / 'incus:' 前缀。 */
|
|
507
|
+
interface RemoteRowConfig {
|
|
508
|
+
execTimeoutSec: number;
|
|
509
|
+
idleTtlSec: number;
|
|
510
|
+
maxOutputChars: number;
|
|
511
|
+
}
|
|
512
|
+
type RemoteConfigValidator = ((value?: unknown) => RemoteRowConfig) & StandardSchemaV1<unknown, RemoteRowConfig> & NativeConfigSchema;
|
|
513
|
+
declare const Config: RemoteConfigValidator;
|
|
514
|
+
/** MUST stay an arrow(RM0 plugin.ts 同注:function 声明会被 cordis 当构造器 new 掉,返回的 disposer 丢失)。 */
|
|
515
|
+
declare const apply: (ctx: Context, config: RemoteRowConfig) => (() => void);
|
|
516
|
+
declare const _default: {
|
|
517
|
+
name: string;
|
|
518
|
+
inject: string[];
|
|
519
|
+
Config: RemoteConfigValidator;
|
|
520
|
+
apply: (ctx: Context, config: RemoteRowConfig) => (() => void);
|
|
521
|
+
};
|
|
522
|
+
//#endregion
|
|
523
|
+
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, SshTargets, type StreamOutputStats, Utf16TailRing, apply, checkAbsolute, checkSelection, _default as default, inject, localFileEndpoint, name, readUtf8Tail, runFileWorker, runRsync, sshArgv, startBinaryProcess, startOneShot, startRemoteJob, withSshRelay };
|