@lengmoxxl/sdk 0.1.7 → 0.1.9

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 CHANGED
@@ -22,25 +22,24 @@ SDK 连接本机或 SSH 机器上的旺财后台进程,提供终端、文件
22
22
  `ui.handle` 注册的方法名不能含 `:`;`ui.publish` 与 `ui.subscribe` 的主题由宿主加插件 id 前缀,
23
23
  `global` 用原始主题,自定义主题要自己加命名空间(如 `directory-demo:opened`)。
24
24
 
25
- `connect({})` 连接本机,`connect({ host })` 连接 SSH;`env` 是那台机器上节点启动时的环境。
26
-
27
- 宿主为相同机器复用连接并计数,每次取得连接对应一次 `disconnect()`。
25
+ `Bus`:`publish(topic, data): Promise<void>`、`subscribe<T>(topic, callback): () => void`。
28
26
 
29
27
  `Dispose = () => void | Promise<void>`,卸载时清理资源,不要关闭用户仍要保留的 PTY。
30
28
 
31
- `Bus`:`publish(topic, data): Promise<void>`、`subscribe<T>(topic, callback): () => void`。
29
+ `connect({})` 连接本机,`connect({ host })` 连接 SSH;`env` 是那台机器上节点启动时的环境。
30
+ 宿主为相同机器复用连接并计数,每次取得连接对应一次 `disconnect()`。
32
31
 
33
32
  `host.dataDirectory` 默认 `~/.local/share/wangcai/data/<plugin-id>`。
34
33
 
35
- `host.config` 是浅合并,避免把自定义字段命名为 `theme`,配色键见
36
- [README 主题参数](../README.md#主题参数)。
37
-
38
34
  ## 标签页
39
35
 
40
- `host.tabs({ id, title, tooltip?, workspaceId?, onClose?, mount })`:`id`、`title` 必填,
41
- `tooltip?` 是标签上的悬停提示(缺省用 `title`),`workspaceId` 缺省用当前工作区;
42
- `mount(container)` 返回的 `TabContent.dispose` 必填,`onSelect?` 在选中、工作区刷新或侧栏重新显示时
43
- 都可能调用,`onClose?` 在移除标签页时先于 `dispose` 调用。
36
+ `host.tabs({ id, title, tooltip?, workspaceId?, onClose?, mount })`:`id`、`title` 必填。
37
+ `tooltip` 是标签上的悬停提示,缺省用 `title`;`workspaceId` 缺省用当前工作区。
38
+
39
+ `mount(container)` 返回的 `TabContent.dispose` 必填,用于清理标签页资源。
40
+ `onClose?` 在移除标签页时先于 `dispose` 调用。
41
+
42
+ `onSelect?` 在选中、工作区刷新或侧栏重新显示时都可能调用。
44
43
 
45
44
  相同插件 id、工作区 id、标签 id 再次调用 `host.tabs` 会复用并选中;尚无工作区时打开的标签页
46
45
  会在第一个工作区激活时绑定到它。
@@ -56,29 +55,51 @@ SDK 连接本机或 SSH 机器上的旺财后台进程,提供终端、文件
56
55
 
57
56
  ## 插件配置
58
57
 
58
+ `host.config` 是浅合并,避免把自定义字段命名为 `theme`,配色键见
59
+ [README 主题参数](../README.md#主题参数)。
60
+
59
61
  插件 `config` 是嵌套对象,叶子声明 `type` 与可选 `default`;宿主只保留 schema 声明的键,
60
62
  缺失或类型不符时取 default,`array` 内部条目由插件自己验证。
61
63
 
62
64
  ## 工作区协议
63
65
 
64
- 放入 init.ts `workspaces` 的插件用 `ui.handle` 提供:`workspaces()`(`WorkspaceRow[]`,
65
- 按显示顺序)、`workspace-menu()`(`WorkspaceMenuItem[]`)、`workspace-create({ key })`
66
- (返回 `{ id }`)、`workspace-select({ id })`、`workspace-close({ id })`、
67
- `workspace-rename({ id, name })`(名字为空表示交回 provider 自己跟随的名字)、
68
- `workspace-move({ id, before? })`(`before` 是目标工作区 id,不是索引;省略为末尾,且只
69
- 允许同一 provider 内拖动)。
66
+ 放入 init.ts `workspaces` 的插件用 `ui.handle` 提供以下方法:
67
+
68
+ | 方法 | 返回值或约定 |
69
+ | --- | --- |
70
+ | `workspaces()` | 返回 `WorkspaceRow[]`,按显示顺序;宿主分组后,组内仍保持此顺序 |
71
+ | `workspace-menu()` | 返回 `WorkspaceMenuItem[]` |
72
+ | `workspace-create({ key })` | 返回 `{ id }` |
73
+ | `workspace-select({ id })` | 选中工作区 |
74
+ | `workspace-close({ id })` | 关闭工作区 |
75
+ | `workspace-rename({ id, name })` | 名字为空表示交回 provider 自己跟随的名字 |
76
+ | `workspace-move({ id, before? })` | `before` 是目标工作区 id,不是索引;省略为末尾,只允许同一 provider 内拖动 |
77
+
78
+ provider 要保证工作区 id 在所有 provider 的行中唯一识别。
70
79
 
71
- provider 要保证工作区 id 在所有 provider 的行中唯一识别;`error` 由 provider 给出并在重试成功后清除,
72
- 宿主不禁用带 `error` 的菜单项。
80
+ `error` 由 provider 给出并在重试成功后清除,宿主不禁用带 `error` 的菜单项。
73
81
 
74
- 约定的公共主题:`workspaces`(行变化,App 重新请求列表)、`workspace:active`
75
- (`WorkspaceActive | null`,provider 发布)、`workspace:query`(视图请求 provider 再发布
76
- 当前工作区)、`onclick`(`FileClick`)。
82
+ `WorkspaceRow.status` 是工作区里 agent 的状态,取 `'idle'`、`'working'` 或 `'finished'`,
83
+ 缺省为 `'idle'`,宿主在行末显示状态图标。
77
84
 
78
- 字段类型见 SDK 导出的 `WorkspaceRow`、`WorkspaceMenuItem`、`Machine`、`WorkspaceActive`
79
- 与 `FileClick`,定义在 `sdk/types.ts`。
85
+ 点击工作区行或行末图标,只会在窗口里将状态清成 `'idle'`,不修改 provider 的状态。
86
+ 该工作区报出其他状态后,再报 `'finished'` 才会重新显示完成状态。
80
87
 
81
- ## 机器、终端与子进程
88
+ 公共主题约定如下:
89
+
90
+ | 主题 | 数据或约定 |
91
+ | --- | --- |
92
+ | `workspaces` | 行变化时发布,App 重新请求列表 |
93
+ | `workspace:active` | provider 发布 `WorkspaceActive \| null` |
94
+ | `workspace:query` | 视图请求 provider 再发布当前工作区 |
95
+ | `onclick` | `FileClick` |
96
+
97
+ 字段类型见 SDK 导出的 `WorkspaceRow`、`WorkspaceStatus`、`WorkspaceMenuItem`、`Machine`、
98
+ `WorkspaceActive` 与 `FileClick`,定义在 `sdk/types.ts`。
99
+
100
+ ## 机器接口
101
+
102
+ ### 连接与重连
82
103
 
83
104
  `MachineConnection`:`ready`(首次连接就绪)、`state`、`port`(本地 loopback 端口,SSH 时
84
105
  为转发端口)、`onState(callback)`、`retain()`(连接层使用)、`disconnect()`,以及 `pty`、`fs`、
@@ -89,10 +110,22 @@ provider 要保证工作区 id 在所有 provider 的行中唯一识别;`error
89
110
  断线会自动重连并重新 attach 已挂载的终端、进程与文件订阅,失败的请求与输入不自动重放,后台进程重启时
90
111
  旧 Pty 与进程失效。
91
112
 
92
- `connection.pty`:`list()`、`cwd(id)`、`create(size?, cwd?)`(默认 24 行 80 列;cwd 用绝对目录,
93
- 省略时在后台进程的 HOME 下启动)、`attach(id)`(复用句柄)、`close(id)`(结束 shell 与后台子孙进程)。
113
+ ### 终端(PTY)
114
+
115
+ `connection.pty` 提供以下方法:
116
+
117
+ | 方法 | 作用 |
118
+ | --- | --- |
119
+ | `list()` | 列出会话 |
120
+ | `cwd(id)` | 查询会话工作目录 |
121
+ | `create(size?, options?)` | 创建终端会话 |
122
+ | `attach(id)` | 挂载会话,复用句柄 |
123
+ | `close(id)` | 结束 shell 与后台子孙进程 |
124
+
125
+ `create` 默认使用 24 行 80 列。`size` 使用 `Size`,字段为整数:rows 2–300,cols 2–500。
94
126
 
95
- `Size` 用整数:rows 2–300,cols 2–500。
127
+ `options.cwd` 使用绝对目录,省略时在后台进程的 HOME 下启动;
128
+ `options.env` 是额外给这个 shell 的环境变量,值都是字符串。
96
129
 
97
130
  `Session` 有 `id, title`、`pid, rows, cols`、`exit_code: number | null`。
98
131
 
@@ -105,27 +138,41 @@ provider 要保证工作区 id 在所有 provider 的行中唯一识别;`error
105
138
 
106
139
  `receive` 与 `release(error?)` 由连接层使用。
107
140
 
141
+ ### 文件
142
+
108
143
  `connection.fs`:`stat(path)` 返回 `{ isDirectory: boolean } | null`、`readDirectory(path)` 返回
109
144
  `DirectoryEntry[]`(`{ name, isDirectory }`)、`readFile(path)` 返回原始字节。
110
145
 
111
146
  路径为绝对路径,`readFile` 上限 16 MiB;SDK 不提供写入、删除或上传接口。
112
147
 
113
- `connection.fs.watch(path, options, callback)` 订阅该路径的变化,`options.recursive` 决定是否含子目录,
114
- 返回的 `() => void` 关闭订阅。回调收到的是 `FileChanges = { created, modified, removed }`,一个安静窗口
115
- (约 200ms 没新事件,最长 2 秒)一批,路径按订阅时给的根路径书写;连接彻底关闭(最后一个持有者
116
- `disconnect()`)时一并结束。macOS 走 FSEvents,创建与删除多数时候报成 `modified`;Linux 走 inotify,
117
- 三类齐全。
148
+ `connection.fs.watch(path, options, callback)` 订阅该路径的变化,`options.recursive` 决定是否含子目录。
149
+ 返回的 `() => void` 关闭订阅;连接彻底关闭(最后一个持有者 `disconnect()`)时,订阅也随之结束。
150
+
151
+ 回调收到 `FileChanges = { created, modified, removed }`,路径按订阅时给的根路径书写。
152
+ 事件按安静窗口批量投递:约 200ms 没有新事件时发出一批,最长等待 2 秒。
153
+
154
+ macOS 使用 FSEvents,创建与删除多数时候报成 `modified`;Linux 使用 inotify,三类事件齐全。
155
+
156
+ ### 短期命令(exec)
157
+
158
+ `connection.subprocess.exec(program, args, options)`:`args` 是独立 argv,不经 shell 展开;
159
+ `options.cwd` 是绝对工作目录,`options.env` 覆盖继承的环境变量。
118
160
 
119
- `connection.subprocess.exec(program, args, options)`:`args` 是独立 argv(不经 shell 展开),
120
- `options.cwd` 是绝对工作目录,`options.env` 覆盖继承的环境变量;返回
121
- `{ stdout: Uint8Array; stderr: Uint8Array; code: number }`。非零退出码仍返回结果,无法启动、
122
- 超时、输出超限或被信号终止时 reject;stdin 关闭,长时间或交互用 `subprocess.spawn` 或 PTY。
161
+ 返回 `{ stdout: Uint8Array; stderr: Uint8Array; code: number }`,非零退出码仍返回结果。
162
+ 无法启动、超时、输出超限或被信号终止时 reject。
123
163
 
124
- 执行上限 15 秒,SDK 等待响应上限 20 秒,stdout 与 stderr 各最多 8 MiB,断线取消未完成的 exec。
164
+ stdin 关闭,执行上限 15 秒,SDK 等待响应上限 20 秒,stdout 与 stderr 各最多 8 MiB;
165
+ 断线取消未完成的 exec。长时间或交互操作用 `subprocess.spawn` 或 PTY。
166
+
167
+ ### 长期进程(spawn)
125
168
 
126
169
  `connection.subprocess.spawn(program, args, options)`(`options` 同 `exec`)启动一个
127
- 长期存活的进程,stdin、stdout、stderr 都是管道,返回 `ProcessInfo = { id, pid, exit_code }`;
128
- `attach(id)` 复用句柄(未 attach 前不接收输出),`close(id)` 结束进程及其进程组;进程归后台进程所有,除 `close` 外,只有起它或最后 `attach` 它的那条连接断开后 60 秒内没有连接再 `attach`,节点才会自己收回。
170
+ 长期存活的进程,stdin、stdout、stderr 都是管道,返回 `ProcessInfo = { id, pid, exit_code }`。
171
+
172
+ `attach(id)` 复用句柄,未 attach 前不接收输出;`close(id)` 结束进程及其进程组。
173
+
174
+ 进程归后台进程所有。除显式 `close` 外,只有启动它或最后 attach 它的那条连接断开后,
175
+ 60 秒内没有任何连接再 attach,该进程才会被节点自动回收。
129
176
 
130
177
  `Process`:`id`、`onData(callback)`、`onExit(callback)`、`write(data)`。
131
178
 
@@ -159,3 +206,9 @@ connection.disconnect();
159
206
  `agentCommand(command, env)` 返回拼接后的 shell 命令:在 PATH 前加入远端 `$HOME/.local/bin`,
160
207
  再带上当前进程的 WANGCAI_HOME 与配置要求的环境;值里的 `$NAME` 留给远端 shell 展开。命令本身
161
208
  不转义,只传可信内容。
209
+ ## 壳与内核的约定
210
+
211
+ `@lengmoxxl/sdk/bridge` 是壳(App)与业务内核共享的那份契约:窗口的三个 scheme、桥的两个 channel、
212
+ 壳向窗口发的 topic、界面字体、安装阶段与跨桥的类型,以及 `contractVersion` —— 内核启动时把它报给壳,
213
+ 壳据此拒绝一个面向旧契约的构建。壳与内核各取一份 SDK,所以改这份契约要发新版本,两边对不上时靠这个
214
+ 版本号发现。插件不需要它:插件用到的是上文列出的上下文。
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // bridge.ts
21
+ var bridge_exports = {};
22
+ __export(bridge_exports, {
23
+ contractVersion: () => contractVersion,
24
+ corePageTopic: () => corePageTopic,
25
+ coreScheme: () => coreScheme,
26
+ coreStatusTopic: () => coreStatusTopic,
27
+ fullscreenTopic: () => fullscreenTopic,
28
+ installStatusesTopic: () => installStatusesTopic,
29
+ link: () => link,
30
+ pluginPageTopic: () => pluginPageTopic,
31
+ pluginScheme: () => pluginScheme,
32
+ pluginsHost: () => pluginsHost,
33
+ pluginsUrl: () => pluginsUrl,
34
+ previewMessage: () => previewMessage,
35
+ previewScheme: () => previewScheme,
36
+ previewUrl: () => previewUrl,
37
+ stageNames: () => stageNames,
38
+ uiFont: () => uiFont
39
+ });
40
+ module.exports = __toCommonJS(bridge_exports);
41
+ var contractVersion = 1;
42
+ var uiFont = '"DejaVuSansM Nerd Font Mono", monospace';
43
+ var coreScheme = "wangcai-core";
44
+ var pluginScheme = "wangcai-plugin";
45
+ var previewScheme = "wangcai-preview";
46
+ var pluginsHost = "plugins";
47
+ var pluginsUrl = `${pluginScheme}://${pluginsHost}/`;
48
+ var previewUrl = `${previewScheme}://preview/`;
49
+ var previewMessage = "wangcai-preview";
50
+ var link = { invoke: "wangcai:invoke", channel: "wangcai:channel" };
51
+ var pluginPageTopic = "plugin-page";
52
+ var installStatusesTopic = "install-statuses";
53
+ var corePageTopic = "core-page";
54
+ var coreStatusTopic = "core-status";
55
+ var fullscreenTopic = "fullscreen";
56
+ var stageNames = { cloning: "\u514B\u9686\u4E2D", updating: "\u540C\u6B65\u4E2D", installing: "\u5B89\u88C5\u4F9D\u8D56", building: "\u6784\u5EFA\u4E2D", ready: "\u5C31\u7EEA", failed: "\u5931\u8D25" };
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ contractVersion,
60
+ corePageTopic,
61
+ coreScheme,
62
+ coreStatusTopic,
63
+ fullscreenTopic,
64
+ installStatusesTopic,
65
+ link,
66
+ pluginPageTopic,
67
+ pluginScheme,
68
+ pluginsHost,
69
+ pluginsUrl,
70
+ previewMessage,
71
+ previewScheme,
72
+ previewUrl,
73
+ stageNames,
74
+ uiFont
75
+ });
@@ -0,0 +1,60 @@
1
+ export declare const contractVersion = 1;
2
+ export declare const uiFont = "\"DejaVuSansM Nerd Font Mono\", monospace";
3
+ export declare const coreScheme = "wangcai-core";
4
+ export declare const pluginScheme = "wangcai-plugin";
5
+ export declare const previewScheme = "wangcai-preview";
6
+ export declare const pluginsHost = "plugins";
7
+ export declare const pluginsUrl = "wangcai-plugin://plugins/";
8
+ export declare const previewUrl = "wangcai-preview://preview/";
9
+ export declare const previewMessage = "wangcai-preview";
10
+ export declare const link: {
11
+ readonly invoke: "wangcai:invoke";
12
+ readonly channel: "wangcai:channel";
13
+ };
14
+ export declare const pluginPageTopic = "plugin-page";
15
+ export declare const installStatusesTopic = "install-statuses";
16
+ export declare const corePageTopic = "core-page";
17
+ export declare const coreStatusTopic = "core-status";
18
+ export declare const fullscreenTopic = "fullscreen";
19
+ /** How a run reaches the network: `proxy` is an http://, https:// or socks5:// address, and `mirror` is a
20
+ * prefix every https://github.com/ URL goes out through. */
21
+ export interface Network {
22
+ proxy?: string;
23
+ mirror?: string;
24
+ }
25
+ /** A plugin that is built and ready: where its files are, and how init.ts named it. */
26
+ export interface PluginEntry {
27
+ id: string;
28
+ workspaces: boolean;
29
+ directory: string;
30
+ config?: Record<string, unknown>;
31
+ }
32
+ /** What the window is told about a plugin that was loaded: its settings, its files, and why it failed. */
33
+ export interface PluginInfo {
34
+ id: string;
35
+ config: Record<string, unknown>;
36
+ ui?: string;
37
+ css?: string;
38
+ error?: string;
39
+ workspaces?: boolean;
40
+ }
41
+ export type InstallStage = 'cloning' | 'updating' | 'installing' | 'building' | 'ready' | 'failed';
42
+ export interface InstallStatus {
43
+ id: string;
44
+ stage: InstallStage;
45
+ message?: string;
46
+ }
47
+ export type CoreStatus = Omit<InstallStatus, 'id'>;
48
+ export declare const stageNames: Record<InstallStage, string>;
49
+ export interface WorkspaceGroup {
50
+ id: string;
51
+ name: string;
52
+ collapsed: boolean;
53
+ workspaces: string[];
54
+ after?: number;
55
+ }
56
+ /** What the shell's preload hands the window. */
57
+ export interface PluginBridge {
58
+ call(method: string, ...args: unknown[]): Promise<any>;
59
+ subscribe(event: string, callback: (data: unknown) => void): () => void;
60
+ }
@@ -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, cwd?: string) => Promise<Session>;
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 }, cwd) => this.request("create", { ...size, cwd }),
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lengmoxxl/sdk",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "Client SDK for WangCai: connect to a local or remote machine and drive its pty, files and git",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -29,6 +29,10 @@
29
29
  "types": "./dist/index.d.ts",
30
30
  "default": "./dist/index.cjs"
31
31
  },
32
+ "./bridge": {
33
+ "types": "./dist/bridge.d.ts",
34
+ "default": "./dist/bridge.cjs"
35
+ },
32
36
  "./channel": {
33
37
  "types": "./dist/channel.d.ts"
34
38
  },
@@ -39,7 +43,7 @@
39
43
  "registry": "https://registry.npmjs.org/"
40
44
  },
41
45
  "scripts": {
42
- "build": "esbuild index.ts --outfile=dist/index.cjs --bundle --platform=node --target=node22 --packages=external && tsc",
46
+ "build": "esbuild index.ts --outfile=dist/index.cjs --bundle --platform=node --target=node22 --packages=external && esbuild bridge.ts --outfile=dist/bridge.cjs --bundle --platform=node --target=node22 --packages=external && tsc",
43
47
  "prepack": "npm run build",
44
48
  "typecheck": "tsc --noEmit"
45
49
  },