koishi-plugin-terminal 1.0.4 → 1.0.6
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/index.d.ts +1 -0
- package/lib/index.js +18 -2
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -30,11 +30,12 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
+
Config: () => Config,
|
|
33
34
|
apply: () => apply,
|
|
34
35
|
name: () => name
|
|
35
36
|
});
|
|
36
37
|
module.exports = __toCommonJS(src_exports);
|
|
37
|
-
var
|
|
38
|
+
var import_koishi2 = require("koishi");
|
|
38
39
|
var pty = __toESM(require("node-pty"));
|
|
39
40
|
var import_node_timers = require("node:timers");
|
|
40
41
|
|
|
@@ -110,6 +111,20 @@ function isInteractiveCommand(command) {
|
|
|
110
111
|
}
|
|
111
112
|
__name(isInteractiveCommand, "isInteractiveCommand");
|
|
112
113
|
|
|
114
|
+
// src/config.ts
|
|
115
|
+
var import_koishi = require("koishi");
|
|
116
|
+
var os = __toESM(require("node:os"));
|
|
117
|
+
var Config = import_koishi.Schema.object({
|
|
118
|
+
admin: import_koishi.Schema.array(String).description("超级管理员用户名单").default([]),
|
|
119
|
+
auth: import_koishi.Schema.number().description("使用本插件所需的最低权限,此外,用户也需要在超级管理员名单中。").min(1).max(4).step(1).default(4),
|
|
120
|
+
root: import_koishi.Schema.string().description("初始工作路径").default(os.homedir()),
|
|
121
|
+
shell: import_koishi.Schema.string().description("Shell路径,留空则自动检测系统默认Shell"),
|
|
122
|
+
timeout: import_koishi.Schema.number().description("超时时长").default(import_koishi.Time.minute),
|
|
123
|
+
cols: import_koishi.Schema.number().description("终端列数").default(80),
|
|
124
|
+
rows: import_koishi.Schema.number().description("终端行数").default(24),
|
|
125
|
+
maxOutputLength: import_koishi.Schema.number().description("单次发送最大输出长度").default(16384)
|
|
126
|
+
});
|
|
127
|
+
|
|
113
128
|
// src/index.ts
|
|
114
129
|
var name = "terminal";
|
|
115
130
|
var map = /* @__PURE__ */ new Map();
|
|
@@ -160,7 +175,7 @@ function apply(ctx, config) {
|
|
|
160
175
|
shellSession.buffer = "";
|
|
161
176
|
if (!output) return;
|
|
162
177
|
const text = output.length > config.maxOutputLength ? output.slice(0, config.maxOutputLength - 1) + "\n ...Truncated output" : output;
|
|
163
|
-
await session.send(
|
|
178
|
+
await session.send(import_koishi2.h.text(text));
|
|
164
179
|
}, "flush");
|
|
165
180
|
const dataDisposable = terminal.onData((data) => {
|
|
166
181
|
shellSession.buffer += data;
|
|
@@ -235,6 +250,7 @@ function apply(ctx, config) {
|
|
|
235
250
|
__name(apply, "apply");
|
|
236
251
|
// Annotate the CommonJS export names for ESM import in node:
|
|
237
252
|
0 && (module.exports = {
|
|
253
|
+
Config,
|
|
238
254
|
apply,
|
|
239
255
|
name
|
|
240
256
|
});
|