@jiyr0119/dsh-service-console 0.9.0 → 0.10.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/lib/client/dictionaries.js +8 -0
- package/lib/client.js +77 -55
- package/lib/host/config-schema.js +45 -0
- package/lib/host/config.js +80 -27
- package/lib/host/ledger-projection.js +223 -0
- package/lib/host/ownership.js +2 -1
- package/lib/host/process-inspector.js +174 -49
- package/lib/host/service-registry.js +5 -4
- package/lib/host/service-tool.js +3 -1
- package/lib/host/snapshot-cache.js +59 -0
- package/lib/index.js +157 -24
- package/lib/types/client/dictionaries.d.ts +8 -0
- package/lib/types/host/config-schema.d.ts +52 -0
- package/lib/types/host/config.d.ts +27 -2
- package/lib/types/host/ledger-projection.d.ts +98 -0
- package/lib/types/host/process-inspector.d.ts +51 -2
- package/lib/types/host/service-registry.d.ts +1 -1
- package/lib/types/host/service-tool.d.ts +1 -1
- package/lib/types/host/snapshot-cache.d.ts +39 -0
- package/lib/types/host/types.d.ts +9 -0
- package/lib/types/index.d.ts +26 -1
- package/package.json +7 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 插件配置 schema(rc.5 契约:`Config` 由 Loader 校验组合行里的 `config:`)
|
|
3
|
+
*
|
|
4
|
+
* 与 `config.ts` 的关系:
|
|
5
|
+
* - 本文件是**唯一声明**(默认值 + 取值范围 + 类型),供 `cordis.yml` 的 `config:` 行、
|
|
6
|
+
* Loader 校验、以及运行时对 JSON 覆盖文件的二次校验共用。
|
|
7
|
+
* - `config.ts` 负责「默认值 ← UI 覆盖文件 ← 组合行」的合并与读写。
|
|
8
|
+
*
|
|
9
|
+
* 注意:这里**不使用** `.volatile()`。volatile 字段会进入 rc.5 的 Settings → Plugins
|
|
10
|
+
* 表单(写回 profile patch),而我们面板的设置页写的是插件自己的 JSON 文件——两条写入
|
|
11
|
+
* 路径会互相覆盖。保持单一写入者:面板(JSON),组合行只做部署期覆盖。
|
|
12
|
+
*/
|
|
13
|
+
import z from '@deepseek-ai/schemastery';
|
|
14
|
+
/** 自动刷新档位(PRD FR-07:关闭 / 2s / 5s / 10s / 30s) */
|
|
15
|
+
export declare const REFRESH_INTERVAL_CHOICES: readonly number[];
|
|
16
|
+
export declare const Config: z<Schemastery.ObjectS<NoInfer<{
|
|
17
|
+
/** 自动刷新间隔(毫秒,仅上述离散档位;0 表示关闭) */
|
|
18
|
+
refreshInterval: z<number, number, "defined">;
|
|
19
|
+
/** 面板默认范围 */
|
|
20
|
+
defaultScope: z<"conversation" | "workspace" | "machine", "conversation" | "workspace" | "machine", "defined">;
|
|
21
|
+
/** 优雅停止超时(毫秒) */
|
|
22
|
+
gracefulTimeout: z<number, number, "defined">;
|
|
23
|
+
/** 是否展示归属未知的服务 */
|
|
24
|
+
showUnknown: z<boolean, boolean, "defined">;
|
|
25
|
+
/** 允许 SIGKILL 兜底 */
|
|
26
|
+
forceKill: z<boolean, boolean, "defined">;
|
|
27
|
+
/** 关闭面板时是否自动清理(当前恒为 false,保留字段以兼容旧配置文件) */
|
|
28
|
+
autoCleanup: z<boolean, boolean, "defined">;
|
|
29
|
+
/** 一次扫描请求的预算(毫秒):HTTP deadline 与 service_list 的工具预算共用 */
|
|
30
|
+
scanTimeoutMs: z<number, number, "defined">;
|
|
31
|
+
/** 单条宿主命令的预算(毫秒) */
|
|
32
|
+
commandTimeoutMs: z<number, number, "defined">;
|
|
33
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
34
|
+
/** 自动刷新间隔(毫秒,仅上述离散档位;0 表示关闭) */
|
|
35
|
+
refreshInterval: z<number, number, "defined">;
|
|
36
|
+
/** 面板默认范围 */
|
|
37
|
+
defaultScope: z<"conversation" | "workspace" | "machine", "conversation" | "workspace" | "machine", "defined">;
|
|
38
|
+
/** 优雅停止超时(毫秒) */
|
|
39
|
+
gracefulTimeout: z<number, number, "defined">;
|
|
40
|
+
/** 是否展示归属未知的服务 */
|
|
41
|
+
showUnknown: z<boolean, boolean, "defined">;
|
|
42
|
+
/** 允许 SIGKILL 兜底 */
|
|
43
|
+
forceKill: z<boolean, boolean, "defined">;
|
|
44
|
+
/** 关闭面板时是否自动清理(当前恒为 false,保留字段以兼容旧配置文件) */
|
|
45
|
+
autoCleanup: z<boolean, boolean, "defined">;
|
|
46
|
+
/** 一次扫描请求的预算(毫秒):HTTP deadline 与 service_list 的工具预算共用 */
|
|
47
|
+
scanTimeoutMs: z<number, number, "defined">;
|
|
48
|
+
/** 单条宿主命令的预算(毫秒) */
|
|
49
|
+
commandTimeoutMs: z<number, number, "defined">;
|
|
50
|
+
}>>, "plain">;
|
|
51
|
+
/** 校验后的配置类型 */
|
|
52
|
+
export type PluginConfig = ReturnType<typeof Config>;
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
+
import { REFRESH_INTERVAL_CHOICES } from './config-schema';
|
|
1
2
|
import type { Config } from './types';
|
|
3
|
+
export { REFRESH_INTERVAL_CHOICES };
|
|
4
|
+
/** schema 默认值(唯一声明处) */
|
|
2
5
|
export declare const DEFAULT_CONFIG: Config;
|
|
3
|
-
export declare const REFRESH_INTERVAL_CHOICES: readonly number[];
|
|
4
6
|
export declare const CONFIG_LIMITS: Record<string, [number, number]>;
|
|
7
|
+
/**
|
|
8
|
+
* 读取 UI 覆盖文件,并用同一份 schema 校验/补默认值。
|
|
9
|
+
* @returns 合并后的配置(坏文件退化为默认值,不抛)
|
|
10
|
+
*/
|
|
5
11
|
export declare function loadConfigFromFile(): Config;
|
|
6
|
-
|
|
12
|
+
/** 读原始文件(失败返回空对象) */
|
|
13
|
+
export declare function readConfigFile(): Partial<Config>;
|
|
14
|
+
/**
|
|
15
|
+
* schema 校验 + 合并:schema 默认值 ← 组合行(部署基线)← UI 覆盖文件(用户显式选择)。
|
|
16
|
+
*
|
|
17
|
+
* 为什么 UI 覆盖文件优先:rc.5 的 Loader 总是把**补全后的完整** config 传给
|
|
18
|
+
* `apply`,所以「组合行最高」会让文件永远不可达(用户改设置无效)。这里的语义是
|
|
19
|
+
* 「部署行给基线,用户在面板里的显式修改压过它」——面板是该插件唯一的写入者,
|
|
20
|
+
* 不存在两个写入路径互相覆盖的问题(rc.5 的 Settings→Plugins 表单只投影
|
|
21
|
+
* `.volatile()` 字段,本插件未声明 volatile,故不会出现第二个写入者)。
|
|
22
|
+
* @param overrides UI 覆盖文件内容
|
|
23
|
+
* @param rowConfig cordis.yml 组合行里的 `config:`
|
|
24
|
+
*/
|
|
25
|
+
export declare function normalizeConfig(overrides?: Partial<Config>, rowConfig?: Partial<Config>): Config;
|
|
26
|
+
/**
|
|
27
|
+
* 持久化 **UI 覆盖补丁**(不是合并后的配置)。
|
|
28
|
+
* 只写用户真正改过的字段:把合并结果写回文件会把部署行的值冻结成用户覆盖,
|
|
29
|
+
* 之后组合行的修改就再也影响不到运行时。
|
|
30
|
+
*/
|
|
31
|
+
export declare function saveConfigToFile(overrides: Partial<Config>): void;
|
|
7
32
|
export declare function validateConfigPatch(patch: Record<string, unknown>): {
|
|
8
33
|
ok: true;
|
|
9
34
|
next: Partial<Config>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { LedgerEntry } from './types';
|
|
3
|
+
/** 每个会话保留的台账条数上限(旧条目先丢) */
|
|
4
|
+
export declare const MAX_LEDGER_ENTRIES = 200;
|
|
5
|
+
/** 未结算调用(call 已记录、result 还没到)的上限 */
|
|
6
|
+
export declare const MAX_PENDING_CALLS = 32;
|
|
7
|
+
/** 条目保留时长(毫秒):开发服务的归属窗口远小于一天 */
|
|
8
|
+
export declare const LEDGER_TTL_MS: number;
|
|
9
|
+
/** 一次已发起、尚未结算的调用 */
|
|
10
|
+
export interface PendingLaunch {
|
|
11
|
+
/** tool/call 的 callId,或 PTC 的 subCallId */
|
|
12
|
+
id: string;
|
|
13
|
+
at: number;
|
|
14
|
+
command: string;
|
|
15
|
+
cwd: string | null;
|
|
16
|
+
redacted: string;
|
|
17
|
+
}
|
|
18
|
+
/** 台账状态(纯 JSON,projection 的持久化前提) */
|
|
19
|
+
export interface LedgerState {
|
|
20
|
+
/** 会话 id(内核 header),用于归属收窄 */
|
|
21
|
+
sessionKey: string;
|
|
22
|
+
/** 会话创建时的绝对工作目录(bash 未显式给 workdir 时作为 cwd 回退) */
|
|
23
|
+
sessionCwd: string | null;
|
|
24
|
+
entries: LedgerEntry[];
|
|
25
|
+
pending: PendingLaunch[];
|
|
26
|
+
}
|
|
27
|
+
/** 状态 schema:projection 用它在 checkpoint 反序列化时校验(不可信输入) */
|
|
28
|
+
export declare const ledgerStateSchema: z.ZodObject<{
|
|
29
|
+
sessionKey: z.ZodString;
|
|
30
|
+
sessionCwd: z.ZodNullable<z.ZodString>;
|
|
31
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
32
|
+
at: z.ZodNumber;
|
|
33
|
+
command: z.ZodString;
|
|
34
|
+
cwd: z.ZodNullable<z.ZodString>;
|
|
35
|
+
sessionKey: z.ZodNullable<z.ZodString>;
|
|
36
|
+
redacted: z.ZodString;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
pending: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
39
|
+
id: z.ZodString;
|
|
40
|
+
at: z.ZodNumber;
|
|
41
|
+
command: z.ZodString;
|
|
42
|
+
cwd: z.ZodNullable<z.ZodString>;
|
|
43
|
+
redacted: z.ZodString;
|
|
44
|
+
}, z.core.$strip>>>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
/** 折叠需要的事件形状(避免把整个 SessionEvent 联合拖进纯函数) */
|
|
47
|
+
export interface LedgerEventLike {
|
|
48
|
+
readonly type: string;
|
|
49
|
+
readonly time?: number;
|
|
50
|
+
readonly data?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 纯 reducer:一条已提交事件 → 新状态(无关事件返回**同一引用**)。
|
|
54
|
+
* @param redact 命令脱敏函数(注入以便单测;生产用 `redaction.redact`)
|
|
55
|
+
*/
|
|
56
|
+
export declare function foldLedgerEvent(state: LedgerState, event: LedgerEventLike, redact: (command: string) => string | null | undefined): LedgerState;
|
|
57
|
+
/** 初始状态(`init` 用):空台账 + 会话元数据 */
|
|
58
|
+
export declare function initLedgerState(header: {
|
|
59
|
+
id: string;
|
|
60
|
+
cwd?: string;
|
|
61
|
+
}): LedgerState;
|
|
62
|
+
/**
|
|
63
|
+
* 构造 rc.5 的 `ProjectionDefinition`。
|
|
64
|
+
* @param redact 命令脱敏
|
|
65
|
+
* @returns 可直接交给 `ctx.sessionProjections.register(...)` 的定义
|
|
66
|
+
*/
|
|
67
|
+
export declare function createLedgerProjection(redact: (command: string) => string | null | undefined): {
|
|
68
|
+
readonly key: "serviceConsoleLedger";
|
|
69
|
+
readonly stateSchema: z.ZodObject<{
|
|
70
|
+
sessionKey: z.ZodString;
|
|
71
|
+
sessionCwd: z.ZodNullable<z.ZodString>;
|
|
72
|
+
entries: z.ZodArray<z.ZodObject<{
|
|
73
|
+
at: z.ZodNumber;
|
|
74
|
+
command: z.ZodString;
|
|
75
|
+
cwd: z.ZodNullable<z.ZodString>;
|
|
76
|
+
sessionKey: z.ZodNullable<z.ZodString>;
|
|
77
|
+
redacted: z.ZodString;
|
|
78
|
+
}, z.core.$strip>>;
|
|
79
|
+
pending: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
80
|
+
id: z.ZodString;
|
|
81
|
+
at: z.ZodNumber;
|
|
82
|
+
command: z.ZodString;
|
|
83
|
+
cwd: z.ZodNullable<z.ZodString>;
|
|
84
|
+
redacted: z.ZodString;
|
|
85
|
+
}, z.core.$strip>>>;
|
|
86
|
+
}, z.core.$strip>;
|
|
87
|
+
readonly stateVersion: 1;
|
|
88
|
+
readonly init: (header: {
|
|
89
|
+
id: string;
|
|
90
|
+
cwd?: string;
|
|
91
|
+
}) => LedgerState;
|
|
92
|
+
readonly apply: (state: LedgerState, event: LedgerEventLike) => LedgerState;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* 从投影状态里取条目;形状不对时返回空数组(宁可少归属,也不抛)。
|
|
96
|
+
* @param state `stateOf(session)` 的返回值(unknown:可能来自旧版本 checkpoint)
|
|
97
|
+
*/
|
|
98
|
+
export declare function entriesOf(state: unknown, now?: number): LedgerEntry[];
|
|
@@ -3,8 +3,47 @@ export interface CommandResult {
|
|
|
3
3
|
stderr: string;
|
|
4
4
|
code: number | null;
|
|
5
5
|
}
|
|
6
|
-
export type CommandRunner = (command: string, timeoutMs?: number) => CommandResult | Promise<CommandResult>;
|
|
6
|
+
export type CommandRunner = (command: string, timeoutMs?: number, signal?: AbortSignal) => CommandResult | Promise<CommandResult>;
|
|
7
|
+
/**
|
|
8
|
+
* 异步命令执行(可取消):`execFile('/bin/sh', ['-c', …])` + `signal`。
|
|
9
|
+
*
|
|
10
|
+
* 扫描链路上的一切命令都必须走这里——`execFileSync` 无法响应取消,
|
|
11
|
+
* 面板的 8s 超时与模型的 `exec.signal` 都只能等进程自己结束。
|
|
12
|
+
* 取消/超时按「已结束但输出不完整」返回(code 125),由上层记为 partial。
|
|
13
|
+
*/
|
|
14
|
+
export declare function runCommandAsync(command: string, timeoutMs?: number, signal?: AbortSignal): Promise<CommandResult>;
|
|
7
15
|
export declare function runCommand(command: string, timeoutMs?: number): CommandResult;
|
|
16
|
+
export interface LsofFieldProcess {
|
|
17
|
+
pid: number;
|
|
18
|
+
/** lsof `c` 字段(命令名,可能被 lsof 截断到 9 字符;优先用 ps 的 command) */
|
|
19
|
+
command: string;
|
|
20
|
+
/** `n` 字段(LISTEN 扫描里是地址;cwd 扫描里不出现,走 cwd 字段) */
|
|
21
|
+
names: string[];
|
|
22
|
+
/** 仅 `-d cwd` 扫描里出现的 `n` 值 */
|
|
23
|
+
cwd: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 解析 `lsof -F<fields>` 输出(每条记录:p/c/f/n 前缀行)。
|
|
27
|
+
* @param stdout lsof 字段模式输出
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseLsofFieldOutput(stdout: string): LsofFieldProcess[];
|
|
30
|
+
export interface PsCombinedRow {
|
|
31
|
+
pid: number;
|
|
32
|
+
ppid: number;
|
|
33
|
+
pgid: number | null;
|
|
34
|
+
user: string | null;
|
|
35
|
+
lstart: string;
|
|
36
|
+
startedAt: number | null;
|
|
37
|
+
command: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 解析 `ps -o pid=,ppid=,pgid=,lstart=,command= -p <pids>` 的单次合并输出。
|
|
41
|
+
* lstart 固定占 5 个 token(Www Mmm D HH:MM:SS YYYY),command 是余下全部。
|
|
42
|
+
* @param stdout ps 输出
|
|
43
|
+
*/
|
|
44
|
+
export declare function parsePsCombined(stdout: string): PsCombinedRow[];
|
|
45
|
+
/** 地址语法推断协议:`[::1]:80` / `[fe80::1]:80` 视为 tcp6,其余 tcp */
|
|
46
|
+
export declare function protocolOfAddress(address: string): string;
|
|
8
47
|
export declare function parseLstart(str: string): number | null;
|
|
9
48
|
export interface ListenRow {
|
|
10
49
|
command: string;
|
|
@@ -36,6 +75,8 @@ export interface RawProcess {
|
|
|
36
75
|
name: string | null;
|
|
37
76
|
pgid: number | null;
|
|
38
77
|
cwd: string | null;
|
|
78
|
+
/** 进程属主(来自同一次 ps 调用;root 判定用) */
|
|
79
|
+
user: string | null;
|
|
39
80
|
}
|
|
40
81
|
export interface RawListener {
|
|
41
82
|
pid: number;
|
|
@@ -49,5 +90,13 @@ export interface RawScan {
|
|
|
49
90
|
listeners: RawListener[];
|
|
50
91
|
procs: Map<number, RawProcess>;
|
|
51
92
|
partialWarnings: string[];
|
|
93
|
+
/**
|
|
94
|
+
* 监听扫描本身失败时的结构化错误(取消/超时、退出码异常、权限)。
|
|
95
|
+
* 缺省表示扫描成功;上层据此区分「真的没有服务」与「扫不出来」。
|
|
96
|
+
*/
|
|
97
|
+
scanError?: {
|
|
98
|
+
code: 'SCAN_TIMEOUT' | 'SCAN_FAILED' | 'PERMISSION_DENIED';
|
|
99
|
+
message: string;
|
|
100
|
+
} | null;
|
|
52
101
|
}
|
|
53
|
-
export declare function scanRaw(commandRunner?: CommandRunner): Promise<RawScan>;
|
|
102
|
+
export declare function scanRaw(commandRunner?: CommandRunner, signal?: AbortSignal, commandTimeoutMs?: number): Promise<RawScan>;
|
|
@@ -2,4 +2,4 @@ import type { LedgerEntry, Snapshot, WorkspaceLike } from './types';
|
|
|
2
2
|
import { type CommandRunner } from './process-inspector';
|
|
3
3
|
import { type OwnershipContext } from './ownership';
|
|
4
4
|
import { type ProtectionGuard } from './protection';
|
|
5
|
-
export declare function buildSnapshot(ledgers: LedgerEntry[], workspaces: WorkspaceLike[], commandRunner?: CommandRunner, guard?: ProtectionGuard, context?: OwnershipContext): Promise<Snapshot>;
|
|
5
|
+
export declare function buildSnapshot(ledgers: LedgerEntry[], workspaces: WorkspaceLike[], commandRunner?: CommandRunner, guard?: ProtectionGuard, context?: OwnershipContext, signal?: AbortSignal, commandTimeoutMs?: number): Promise<Snapshot>;
|
|
@@ -6,6 +6,6 @@ export interface ServiceToolDeps {
|
|
|
6
6
|
* 提供时「本次对话」归属按台账 sessionKey 收窄,避免同工作区另一会话的
|
|
7
7
|
* 启动记录被误判成本次对话。
|
|
8
8
|
*/
|
|
9
|
-
snapshot(sessionId?: string | null): Promise<Snapshot>;
|
|
9
|
+
snapshot(sessionId?: string | null, signal?: AbortSignal): Promise<Snapshot>;
|
|
10
10
|
}
|
|
11
11
|
export declare function buildServiceTool(deps: ServiceToolDeps): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* M7 · 扫描结果缓存(TTL + single-flight + 出错时保留上次结果)
|
|
3
|
+
*
|
|
4
|
+
* 两个客户端共用同一个扫描:控制台 tab(2–30 s)与 composer pill(30 s)。
|
|
5
|
+
* 一次扫描是 3 条同步/异步 shell 调用,所以在极短窗口内合并重复请求:
|
|
6
|
+
* - TTL 1 s:快于最快的轮询档(2 s),交互式刷新仍即时;
|
|
7
|
+
* - single-flight:同一 key 的并发请求只跑一次;
|
|
8
|
+
* - stale-while-error:扫描瞬时失败时返回上次结果并标记 stale(面板可提示);
|
|
9
|
+
* - `invalidate`:stop/restart 之后立刻失效,避免展示已死服务。
|
|
10
|
+
*/
|
|
11
|
+
export interface CacheHit<T> {
|
|
12
|
+
value: T;
|
|
13
|
+
/** 命中过期但可用的旧值(仅出错时) */
|
|
14
|
+
stale: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SnapshotCacheOptions {
|
|
17
|
+
/** 新鲜期(毫秒) */
|
|
18
|
+
ttlMs?: number;
|
|
19
|
+
/** 出错时允许回退到多久以内的旧值(毫秒) */
|
|
20
|
+
staleWhileErrorMs?: number;
|
|
21
|
+
/** 注入时钟(单测用) */
|
|
22
|
+
now?: () => number;
|
|
23
|
+
}
|
|
24
|
+
export declare class SnapshotCache<T> {
|
|
25
|
+
private readonly entries;
|
|
26
|
+
private readonly inflight;
|
|
27
|
+
private readonly ttlMs;
|
|
28
|
+
private readonly staleWhileErrorMs;
|
|
29
|
+
private readonly now;
|
|
30
|
+
constructor(options?: SnapshotCacheOptions);
|
|
31
|
+
/**
|
|
32
|
+
* 取缓存或加载一次。
|
|
33
|
+
* @param key 缓存键(含 sessionId:归属按调用方会话收窄)
|
|
34
|
+
* @param load 真实加载函数
|
|
35
|
+
*/
|
|
36
|
+
get(key: string, load: () => Promise<T>): Promise<CacheHit<T>>;
|
|
37
|
+
/** 失效一个键(stop/restart 后调用);不传则清空。 */
|
|
38
|
+
invalidate(key?: string): void;
|
|
39
|
+
}
|
|
@@ -33,6 +33,11 @@ export interface Snapshot {
|
|
|
33
33
|
services: Service[];
|
|
34
34
|
partialWarnings: string[];
|
|
35
35
|
ledgerCount: number;
|
|
36
|
+
/** 监听扫描失败时的结构化错误(缺省表示成功) */
|
|
37
|
+
scanError?: {
|
|
38
|
+
code: 'SCAN_TIMEOUT' | 'SCAN_FAILED' | 'PERMISSION_DENIED';
|
|
39
|
+
message: string;
|
|
40
|
+
} | null;
|
|
36
41
|
}
|
|
37
42
|
export interface ApiResult<T = unknown> {
|
|
38
43
|
ok: boolean;
|
|
@@ -56,6 +61,10 @@ export interface Config {
|
|
|
56
61
|
showUnknown: boolean;
|
|
57
62
|
forceKill: boolean;
|
|
58
63
|
autoCleanup: boolean;
|
|
64
|
+
/** 一次扫描请求的预算(毫秒) */
|
|
65
|
+
scanTimeoutMs: number;
|
|
66
|
+
/** 单条宿主命令的预算(毫秒) */
|
|
67
|
+
commandTimeoutMs: number;
|
|
59
68
|
}
|
|
60
69
|
export interface ActionRecord {
|
|
61
70
|
at: number;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { WebServer } from '@deepseek-ai/dsh-host-webserver';
|
|
3
|
+
import type { PluginConfig } from './host/config-schema';
|
|
3
4
|
declare module '@deepseek-ai/cordis' {
|
|
4
5
|
interface Context {
|
|
5
6
|
timer: {
|
|
@@ -10,10 +11,14 @@ declare module '@deepseek-ai/cordis' {
|
|
|
10
11
|
webServer: WebServer;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
/** 错误码 → HTTP 状态(客户端只读信封,但状态码让日志/代理可读) */
|
|
15
|
+
export declare function errorStatus(code: string): number;
|
|
13
16
|
/** 一次请求的来源信息(handler 的第二个参数) */
|
|
14
17
|
export interface RequestInfo {
|
|
15
18
|
/** 调用方是否来自本机回环;变更类操作只允许 true。 */
|
|
16
19
|
loopback: boolean;
|
|
20
|
+
/** 请求取消信号(客户端断开时中止扫描的 shell 子进程) */
|
|
21
|
+
signal: AbortSignal;
|
|
17
22
|
}
|
|
18
23
|
/**
|
|
19
24
|
* 调用方是否来自本机回环。
|
|
@@ -28,6 +33,26 @@ export interface RequestInfo {
|
|
|
28
33
|
export declare function isLoopbackCaller(remoteAddress: string | undefined | null): boolean;
|
|
29
34
|
declare const _default: {
|
|
30
35
|
inject: string[];
|
|
31
|
-
|
|
36
|
+
/** rc.5 契约:组合行里的 `config:` 由 Loader 用这份 schema 校验 */
|
|
37
|
+
Config: import("@deepseek-ai/schemastery").default<Schemastery.ObjectS<NoInfer<{
|
|
38
|
+
refreshInterval: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
39
|
+
defaultScope: import("@deepseek-ai/schemastery").default<"conversation" | "workspace" | "machine", "conversation" | "workspace" | "machine", "defined">;
|
|
40
|
+
gracefulTimeout: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
41
|
+
showUnknown: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
42
|
+
forceKill: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
43
|
+
autoCleanup: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
44
|
+
scanTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
45
|
+
commandTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
46
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
47
|
+
refreshInterval: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
48
|
+
defaultScope: import("@deepseek-ai/schemastery").default<"conversation" | "workspace" | "machine", "conversation" | "workspace" | "machine", "defined">;
|
|
49
|
+
gracefulTimeout: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
50
|
+
showUnknown: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
51
|
+
forceKill: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
52
|
+
autoCleanup: import("@deepseek-ai/schemastery").default<boolean, boolean, "defined">;
|
|
53
|
+
scanTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
54
|
+
commandTimeoutMs: import("@deepseek-ai/schemastery").default<number, number, "defined">;
|
|
55
|
+
}>>, "plain">;
|
|
56
|
+
apply(ctx: Context, rowConfig?: Partial<PluginConfig>): void;
|
|
32
57
|
};
|
|
33
58
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jiyr0119/dsh-service-console",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "DeepSeek Harness 本地开发服务控制台(原生插件):发现监听端口,识别服务归属,安全查看/停止/重启。Local development service console for DSH.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"@deepseek-ai/dsh-client-ui-tool": "0.2.2-rc.5",
|
|
88
88
|
"@deepseek-ai/dsh-host-webserver": "^0.2.2-rc.5",
|
|
89
89
|
"@deepseek-ai/dsh-tools": "^0.2.2-rc.5",
|
|
90
|
+
"@deepseek-ai/schemastery": "~3.19.0",
|
|
90
91
|
"@types/node": "^24.9.0",
|
|
91
92
|
"@types/react": "^18.3.1",
|
|
92
93
|
"lightningcss": "^1.33.0",
|
|
@@ -94,11 +95,14 @@
|
|
|
94
95
|
"react": "^18.2.0",
|
|
95
96
|
"react-dom": "^18.2.0",
|
|
96
97
|
"tsdown": "^0.22.14",
|
|
97
|
-
"typescript": "^5.6.0"
|
|
98
|
+
"typescript": "^5.6.0",
|
|
99
|
+
"zod": "4.6.6"
|
|
98
100
|
},
|
|
99
101
|
"peerDependencies": {
|
|
100
102
|
"@deepseek-ai/cordis": "~4.1.0",
|
|
101
103
|
"@deepseek-ai/dsh-tools": "^0.2.2-rc.5",
|
|
102
|
-
"
|
|
104
|
+
"@deepseek-ai/schemastery": "~3.19.0",
|
|
105
|
+
"react": "^18.2.0",
|
|
106
|
+
"zod": "^4.6.6"
|
|
103
107
|
}
|
|
104
108
|
}
|