@hyzyn/dsh-docker 0.6.4 → 0.7.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.
- package/README.en.md +31 -16
- package/README.md +31 -18
- package/client-src/current-session.js +52 -0
- package/client-src/docker.css +2180 -0
- package/client-src/index.js +6691 -0
- package/client-src/session-target.js +92 -0
- package/client.js +46 -24
- package/lib/docker.d.ts +62 -5
- package/lib/docker.js +287 -48
- package/lib/docker.js.map +1 -1
- package/lib/index.d.ts +19 -1
- package/lib/index.js +595 -80
- package/lib/index.js.map +1 -1
- package/lib/ssh-exec.d.ts +30 -11
- package/lib/ssh-exec.js +360 -143
- package/lib/ssh-exec.js.map +1 -1
- package/package.json +4 -2
- package/scripts/build-client.mjs +33 -0
- package/scripts/client-smoke.mjs +1851 -0
- package/scripts/route-smoke.mjs +1091 -0
- package/scripts/smoke.mjs +874 -0
package/lib/docker.d.ts
CHANGED
|
@@ -31,10 +31,29 @@ export declare function parseIOPair(text: string): {
|
|
|
31
31
|
rx: number | null;
|
|
32
32
|
tx: number | null;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* `--since` 的统一口径(D45):时长(docker 的 Go duration 语法,允许复合如
|
|
36
|
+
* `1h30m`)、Unix 秒或时间戳。events 与 logs 两条路径此前各有一套——events
|
|
37
|
+
* 白名单偏窄(复合 duration 被拒)、logs 完全不校验(docker 的参数错误变成
|
|
38
|
+
* 不可读的报错)。纯校验函数:合法返回原样串,不合法抛错。
|
|
39
|
+
*
|
|
40
|
+
* 与 docker 的口径**双向对齐**(D99):
|
|
41
|
+
* ① duration 支持小数与 `0`——Go 的 `time.ParseDuration` 接受 `1.5h` 与 `0`,
|
|
42
|
+
* 旧正则的 `\d+` 把它们当成非法输入拒了(用户明明写的是合法参数);
|
|
43
|
+
* ② 裸数字仍按 docker 语义当 Unix 秒(`--since 3600` = 一小时前);
|
|
44
|
+
* ③ 时间戳必须**带时间部分**——`2026-09-13` 这种裸日期此前被放行,docker
|
|
45
|
+
* 多半原样报参数错误,不如在这里拒绝;
|
|
46
|
+
* ④ 报错回显原始值,否则调用方(尤其是 agent)不知道是哪一段没通过。
|
|
47
|
+
*/
|
|
48
|
+
export declare function assertSince(value: unknown, field?: string): string;
|
|
34
49
|
export interface PortMapping {
|
|
35
50
|
hostIp?: string;
|
|
36
51
|
hostPort?: number;
|
|
52
|
+
/** 端口区间映射的宿主侧原文(`8000-8005`);单端口映射无此字段。 */
|
|
53
|
+
hostPortRange?: [number, number];
|
|
37
54
|
containerPort: number;
|
|
55
|
+
/** 端口区间映射的容器侧区间(`8000-8005`);单端口映射无此字段。 */
|
|
56
|
+
containerPortRange?: [number, number];
|
|
38
57
|
protocol: string;
|
|
39
58
|
}
|
|
40
59
|
export interface ContainerSummary {
|
|
@@ -84,7 +103,7 @@ export declare function parseExitCode(status: string): number | null;
|
|
|
84
103
|
export declare function deriveState(status: string): string;
|
|
85
104
|
/** 从 ps 的 `.Status` 提取健康态(`Up 2 hours (healthy)` → healthy)。 */
|
|
86
105
|
export declare function deriveHealth(status: string): string | null;
|
|
87
|
-
/** 解析 ps 的 `.Ports` 串:`0.0.0.0:8080->80/tcp, [::]:8080->80/tcp, 9000/tcp`。 */
|
|
106
|
+
/** 解析 ps 的 `.Ports` 串:`0.0.0.0:8080->80/tcp, [::]:8080->80/tcp, 9000/tcp, 0.0.0.0:8000-8005->8000-8005/tcp`。 */
|
|
88
107
|
export declare function parsePorts(text: string): PortMapping[];
|
|
89
108
|
/** `docker ps --format '{{json .}}'` → ContainerSummary[]。 */
|
|
90
109
|
export declare function parsePsJson(text: string): ContainerSummary[];
|
|
@@ -322,6 +341,7 @@ export interface Runner {
|
|
|
322
341
|
run(argv: readonly string[], options?: {
|
|
323
342
|
timeoutMs?: number;
|
|
324
343
|
maxBytes?: number;
|
|
344
|
+
keepTail?: boolean;
|
|
325
345
|
}): Promise<ExecResult>;
|
|
326
346
|
/** 长流(logs --follow):逐块回调,signal 中止;无总超时与输出上限。 */
|
|
327
347
|
stream(argv: readonly string[], handlers: StreamHandlers, signal?: AbortSignal): Promise<StreamResult>;
|
|
@@ -357,16 +377,47 @@ export declare class DockerApi {
|
|
|
357
377
|
});
|
|
358
378
|
/** 探测:docker CLI 是否可用 + daemon 是否可达。 */
|
|
359
379
|
probe(): Promise<ProbeResult>;
|
|
380
|
+
/**
|
|
381
|
+
* assertOk + 截断检查(D13):列表 / 详情类方法拿到的必须是**完整**输出。
|
|
382
|
+
* 只检查 code 的话,「输出被截断」会被当成「本来就这么少」——面板静默少列
|
|
383
|
+
* 容器,inspect 系列更会把截断误报成「对象不存在」,把用户引向错误方向。
|
|
384
|
+
*
|
|
385
|
+
* `alternative` 是**这个调用方真正能执行的替代做法**(D105):agent 改不了插件
|
|
386
|
+
* 设置,「请调大 maxOutputKb」对它不可执行——ps 能改 all、stats 能传 ids、
|
|
387
|
+
* events 能缩小 since。文案里还会回显当前上限(见 truncationHint)。
|
|
388
|
+
*/
|
|
389
|
+
private assertComplete;
|
|
390
|
+
/**
|
|
391
|
+
* 截断提示的统一文案(D105):带上当前上限(KB)与目标标签——只说「超过上限」
|
|
392
|
+
* 无法判断差多少;再拼上调用方的可执行替代做法。
|
|
393
|
+
* 不抛错的路径(imageInspect 的 history,D104)复用同一句话,保持口径一致。
|
|
394
|
+
*/
|
|
395
|
+
private truncationHint;
|
|
360
396
|
listContainers(all: boolean): Promise<ContainerSummary[]>;
|
|
361
397
|
inspect(ids: readonly string[]): Promise<ContainerDetail[]>;
|
|
362
398
|
/**
|
|
363
399
|
* 「需要关注」的容器(0.15.0):先按摘要筛候选(不健康 / 重启中 / 僵死 /
|
|
364
|
-
*
|
|
365
|
-
* 摘要里拿不到(137 也可能是手动 kill),只看摘要会误报。inspect
|
|
400
|
+
* 非零退出),再**分块** `docker inspect` 补权威字段——OOM 与真实退出码在 ps
|
|
401
|
+
* 摘要里拿不到(137 也可能是手动 kill),只看摘要会误报。inspect 失败时退回摘要,
|
|
402
|
+
* 但一定带 `degraded` 信号(D85/D86)。
|
|
403
|
+
*
|
|
404
|
+
* 反复重启(D11):crash-loop 的容器多数时间显示 Up(退避最长 1 分钟,其余
|
|
405
|
+
* 时间在跑),RestartCount 只在 inspect 里有——摘要筛不出来。这里把「刚刚
|
|
406
|
+
* 启动」的运行中容器一并送进 inspect,按「重启计数高 + 刚启动」补捞;补捞有
|
|
407
|
+
* 独立预算(D87):合法候选再多也挤不掉它。
|
|
408
|
+
*
|
|
409
|
+
* 截断在过滤 + 排序**之后**(D12):先切后拍的话,名额被一堆老的非零退出
|
|
410
|
+
* 容器占满时,最严重的 OOM / unhealthy 反而会被切掉;返回值带 total / truncated
|
|
411
|
+
* 截断信号,不静默。
|
|
366
412
|
*/
|
|
367
413
|
attention(options?: {
|
|
368
414
|
limit?: number;
|
|
369
|
-
}): Promise<
|
|
415
|
+
}): Promise<{
|
|
416
|
+
items: AttentionItem[];
|
|
417
|
+
total: number;
|
|
418
|
+
truncated: boolean;
|
|
419
|
+
degraded: boolean;
|
|
420
|
+
}>;
|
|
370
421
|
stats(ids: readonly string[]): Promise<ContainerStats[]>;
|
|
371
422
|
/**
|
|
372
423
|
* 实时统计流:`docker stats`(**不带 --no-stream**)每秒为每个容器输出一行
|
|
@@ -484,7 +535,13 @@ export declare class DockerApi {
|
|
|
484
535
|
truncated: boolean;
|
|
485
536
|
durationMs: number;
|
|
486
537
|
}>;
|
|
487
|
-
/**
|
|
538
|
+
/**
|
|
539
|
+
* 日志:stdout / stderr 分别收,stdout 整段在前、stderr 在后。
|
|
540
|
+
*
|
|
541
|
+
* 注意这不是「按到达顺序合并」(D44 注释纠正):一次性命令的两路输出在
|
|
542
|
+
* run() 里分别累积,时序信息已经丢了;容器交替写两路时快照日志的先后顺序
|
|
543
|
+
* 与真实到达序可能不同。要真实时序请用实时跟随(FOLLOW 流是逐块按到达序推的)。
|
|
544
|
+
*/
|
|
488
545
|
logs(id: string, options?: LogsOptions): Promise<{
|
|
489
546
|
id: string;
|
|
490
547
|
text: string;
|