@lengmoxxl/sdk 0.1.7 → 0.1.8
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 +12 -6
- package/dist/connection.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -62,8 +62,9 @@ SDK 连接本机或 SSH 机器上的旺财后台进程,提供终端、文件
|
|
|
62
62
|
## 工作区协议
|
|
63
63
|
|
|
64
64
|
放入 init.ts `workspaces` 的插件用 `ui.handle` 提供:`workspaces()`(`WorkspaceRow[]`,
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
按显示顺序;宿主可能把行画进它自己的分组,组内仍按此顺序)、
|
|
66
|
+
`workspace-menu()`(`WorkspaceMenuItem[]`)、`workspace-create({ key })`(返回 `{ id }`)、
|
|
67
|
+
`workspace-select({ id })`、`workspace-close({ id })`、
|
|
67
68
|
`workspace-rename({ id, name })`(名字为空表示交回 provider 自己跟随的名字)、
|
|
68
69
|
`workspace-move({ id, before? })`(`before` 是目标工作区 id,不是索引;省略为末尾,且只
|
|
69
70
|
允许同一 provider 内拖动)。
|
|
@@ -71,12 +72,16 @@ SDK 连接本机或 SSH 机器上的旺财后台进程,提供终端、文件
|
|
|
71
72
|
provider 要保证工作区 id 在所有 provider 的行中唯一识别;`error` 由 provider 给出并在重试成功后清除,
|
|
72
73
|
宿主不禁用带 `error` 的菜单项。
|
|
73
74
|
|
|
75
|
+
`WorkspaceRow.status` 是那行里 agent 的状态,写 `'idle'`、`'working'` 或 `'finished'`,缺省按
|
|
76
|
+
`'idle'` 画;宿主把它在行末画成一个图标,点 `'finished'` 的图标只在窗口里清成 `'idle'`(provider
|
|
77
|
+
自己那份不变),那一行报出别的状态之后再报 `'finished'` 才会重新画出来。
|
|
78
|
+
|
|
74
79
|
约定的公共主题:`workspaces`(行变化,App 重新请求列表)、`workspace:active`
|
|
75
80
|
(`WorkspaceActive | null`,provider 发布)、`workspace:query`(视图请求 provider 再发布
|
|
76
81
|
当前工作区)、`onclick`(`FileClick`)。
|
|
77
82
|
|
|
78
|
-
字段类型见 SDK 导出的 `WorkspaceRow`、`WorkspaceMenuItem`、`Machine
|
|
79
|
-
与 `FileClick`,定义在 `sdk/types.ts`。
|
|
83
|
+
字段类型见 SDK 导出的 `WorkspaceRow`、`WorkspaceStatus`、`WorkspaceMenuItem`、`Machine`、
|
|
84
|
+
`WorkspaceActive` 与 `FileClick`,定义在 `sdk/types.ts`。
|
|
80
85
|
|
|
81
86
|
## 机器、终端与子进程
|
|
82
87
|
|
|
@@ -89,8 +94,9 @@ provider 要保证工作区 id 在所有 provider 的行中唯一识别;`error
|
|
|
89
94
|
断线会自动重连并重新 attach 已挂载的终端、进程与文件订阅,失败的请求与输入不自动重放,后台进程重启时
|
|
90
95
|
旧 Pty 与进程失效。
|
|
91
96
|
|
|
92
|
-
`connection.pty`:`list()`、`cwd(id)`、`create(size?,
|
|
93
|
-
|
|
97
|
+
`connection.pty`:`list()`、`cwd(id)`、`create(size?, options?)`(默认 24 行 80 列;`options.cwd` 用绝对
|
|
98
|
+
目录,省略时在后台进程的 HOME 下启动;`options.env` 是额外给这个 shell 的环境变量,值都是字符串)、
|
|
99
|
+
`attach(id)`(复用句柄)、`close(id)`(结束 shell 与后台子孙进程)。
|
|
94
100
|
|
|
95
101
|
`Size` 用整数:rows 2–300,cols 2–500。
|
|
96
102
|
|
package/dist/connection.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionOptions, MachineState, Session, Size, DirectoryEntry, ExecOptions, ExecResult, ProcessInfo, FileChanges, WatchOptions } from './types';
|
|
1
|
+
import type { ConnectionOptions, MachineState, Session, Size, PtyOptions, DirectoryEntry, ExecOptions, ExecResult, ProcessInfo, FileChanges, WatchOptions } from './types';
|
|
2
2
|
import { Process } from './process';
|
|
3
3
|
import { Pty } from './pty';
|
|
4
4
|
export declare class MachineConnection {
|
|
@@ -32,7 +32,7 @@ export declare class MachineConnection {
|
|
|
32
32
|
pty: {
|
|
33
33
|
list: () => Promise<Session[]>;
|
|
34
34
|
cwd: (id: string) => Promise<string>;
|
|
35
|
-
create: (size?: Size,
|
|
35
|
+
create: (size?: Size, options?: PtyOptions) => Promise<Session>;
|
|
36
36
|
attach: (id: string) => Promise<Pty>;
|
|
37
37
|
close: (id: string) => Promise<void>;
|
|
38
38
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -260,7 +260,7 @@ var MachineConnection = class {
|
|
|
260
260
|
pty = {
|
|
261
261
|
list: () => this.request("list"),
|
|
262
262
|
cwd: (id) => this.request("cwd", { session_id: id }),
|
|
263
|
-
create: (size = { rows: 24, cols: 80 },
|
|
263
|
+
create: (size = { rows: 24, cols: 80 }, options = {}) => this.request("create", { ...size, ...options }),
|
|
264
264
|
attach: async (id) => {
|
|
265
265
|
const existing = this.terminals.get(id);
|
|
266
266
|
if (existing) return existing;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MachineConnection } from './connection';
|
|
2
2
|
import type { ConnectionOptions } from './types';
|
|
3
3
|
export { agentCommand } from './agent';
|
|
4
|
-
export type { ConnectionOptions, FileClick, Machine, MachineState, Session, Size, Output, Snapshot, TerminalEvent, DirectoryEntry, FileChanges, WatchOptions, ExecOptions, ExecResult, ProcessEvent, ProcessInfo, ProcessOutput, InstallAgent, Profile, Theme, WorkspaceActive, WorkspaceRow, WorkspaceMenuItem } from './types';
|
|
4
|
+
export type { ConnectionOptions, FileClick, Machine, MachineState, Session, Size, PtyOptions, Output, Snapshot, TerminalEvent, DirectoryEntry, FileChanges, WatchOptions, ExecOptions, ExecResult, ProcessEvent, ProcessInfo, ProcessOutput, InstallAgent, Profile, Theme, WorkspaceActive, WorkspaceRow, WorkspaceStatus, WorkspaceMenuItem } from './types';
|
|
5
5
|
export type { MachineConnection } from './connection';
|
|
6
6
|
export type { Process } from './process';
|
|
7
7
|
export type { Pty } from './pty';
|
package/dist/types.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export type InstallAgent = (host: string, signal?: AbortSignal) => Promise<void>
|
|
|
4
4
|
* The workspace protocol. A plugin that init.ts lists under `workspaces` is a workspace provider, and
|
|
5
5
|
* the app drives it through these `ui` methods:
|
|
6
6
|
*
|
|
7
|
-
* workspaces() -> WorkspaceRow[] one flat row per workspace, in draw order
|
|
7
|
+
* workspaces() -> WorkspaceRow[] one flat row per workspace, in draw order; the window may
|
|
8
|
+
* draw rows under groups of its own, whose rows keep this order
|
|
8
9
|
* workspace-menu() -> WorkspaceMenuItem[] what the menu offers to open; an entry that carries
|
|
9
10
|
* an error stays listed with its reason, and a click retries it
|
|
10
11
|
* workspace-create({ key }) -> { id: string } the id of the workspace it made
|
|
@@ -20,11 +21,14 @@ export type InstallAgent = (host: string, signal?: AbortSignal) => Promise<void>
|
|
|
20
21
|
* 'workspace:active' the workspace in front, or null; published by its provider
|
|
21
22
|
* 'workspace:query' a view asks for 'workspace:active' again
|
|
22
23
|
*/
|
|
24
|
+
/** What the agent in a workspace is doing, which the app draws at the right end of its row. */
|
|
25
|
+
export type WorkspaceStatus = 'idle' | 'working' | 'finished';
|
|
23
26
|
export interface WorkspaceRow {
|
|
24
27
|
id: string;
|
|
25
28
|
label: string;
|
|
26
29
|
machine: string;
|
|
27
30
|
running: boolean;
|
|
31
|
+
status?: WorkspaceStatus;
|
|
28
32
|
}
|
|
29
33
|
export interface WorkspaceMenuItem {
|
|
30
34
|
key: string;
|
|
@@ -67,6 +71,11 @@ export interface Size {
|
|
|
67
71
|
rows: number;
|
|
68
72
|
cols: number;
|
|
69
73
|
}
|
|
74
|
+
/** What a session is created with: the directory its shell opens in, and what it is told besides the node's environment. */
|
|
75
|
+
export interface PtyOptions {
|
|
76
|
+
cwd?: string;
|
|
77
|
+
env?: Record<string, string>;
|
|
78
|
+
}
|
|
70
79
|
export interface Session extends Size {
|
|
71
80
|
id: string;
|
|
72
81
|
title: string;
|