koishi-plugin-argus 0.1.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/types.d.ts ADDED
@@ -0,0 +1,75 @@
1
+ export interface DisplayInfo {
2
+ id: number | string;
3
+ name?: string;
4
+ width?: number;
5
+ height?: number;
6
+ primary?: boolean;
7
+ }
8
+ /** Client → Server: 上线握手 */
9
+ export interface HelloFrame {
10
+ type: 'hello';
11
+ name: string;
12
+ token: string;
13
+ version?: string;
14
+ displays?: DisplayInfo[];
15
+ defaultDisplay?: number;
16
+ }
17
+ /** Server → Client: 握手响应 */
18
+ export interface HelloAckFrame {
19
+ type: 'hello_ack';
20
+ ok: boolean;
21
+ error?: string;
22
+ }
23
+ /** Server → Client: 请求一次截图 */
24
+ export interface PeekRequestFrame {
25
+ type: 'peek';
26
+ id: string;
27
+ display?: number | string;
28
+ }
29
+ /** Client → Server: 截图结果 */
30
+ export interface PeekResultFrame {
31
+ type: 'peek_result';
32
+ id: string;
33
+ /** PNG/JPEG base64(不带 data: 前缀)。*/
34
+ image: string;
35
+ mime?: string;
36
+ width?: number;
37
+ height?: number;
38
+ display?: number | string;
39
+ }
40
+ /** Client → Server: 截图失败 */
41
+ export interface PeekErrorFrame {
42
+ type: 'peek_error';
43
+ id: string;
44
+ error: string;
45
+ }
46
+ /**
47
+ * Client → Server: 客户端拒绝截图(例如正在全屏游戏 / 全屏应用)。
48
+ * Plugin 收到此帧时不再返回截图,而是返回一段文字提示。
49
+ */
50
+ export interface PeekBusyFrame {
51
+ type: 'peek_busy';
52
+ id: string;
53
+ /** 当前活动应用程序名(如 "League of Legends" / "explorer.exe") */
54
+ app?: string;
55
+ /** 窗口标题 */
56
+ title?: string;
57
+ /** 自定义原因(默认 fullscreen) */
58
+ reason?: 'fullscreen' | string;
59
+ }
60
+ /** 双向心跳 */
61
+ export interface PingFrame {
62
+ type: 'ping';
63
+ t?: number;
64
+ }
65
+ export interface PongFrame {
66
+ type: 'pong';
67
+ t?: number;
68
+ }
69
+ /** Client → Server: 优雅断线 */
70
+ export interface ByeFrame {
71
+ type: 'bye';
72
+ reason?: string;
73
+ }
74
+ export type ClientFrame = HelloFrame | PeekResultFrame | PeekErrorFrame | PeekBusyFrame | PingFrame | PongFrame | ByeFrame;
75
+ export type ServerFrame = HelloAckFrame | PeekRequestFrame | PingFrame | PongFrame;
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "koishi-plugin-argus",
3
+ "description": "百眼巨人 Argus:让群友通过 /peek 命令偷窥你电脑屏幕的 Koishi 插件。",
4
+ "version": "0.1.0",
5
+ "main": "lib/index.cjs",
6
+ "module": "lib/index.mjs",
7
+ "typings": "lib/index.d.ts",
8
+ "types": "lib/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.mjs",
13
+ "require": "./lib/index.cjs"
14
+ },
15
+ "./package.json": "./package.json"
16
+ },
17
+ "type": "module",
18
+ "files": [
19
+ "lib",
20
+ "dist"
21
+ ],
22
+ "license": "MIT",
23
+ "keywords": [
24
+ "chatbot",
25
+ "koishi",
26
+ "plugin",
27
+ "argus",
28
+ "peek",
29
+ "screenshot",
30
+ "remote"
31
+ ],
32
+ "peerDependencies": {
33
+ "@koishijs/plugin-server": "^3.2.7",
34
+ "koishi": "^4.18.9"
35
+ },
36
+ "dependencies": {
37
+ "@jimp/core": "^1.6.0",
38
+ "jimp": "^1.6.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/ws": "^8.5.10",
42
+ "@typescript-eslint/eslint-plugin": "^7.18.1-alpha.3",
43
+ "@typescript-eslint/parser": "^8.45.1-alpha.0",
44
+ "esbuild": "^0.25.10",
45
+ "esbuild-register": "npm:@shigma/esbuild-register@^1.1.1",
46
+ "eslint": "^8.57.1",
47
+ "eslint-config-prettier": "^9.1.2",
48
+ "eslint-config-standard": "^17.1.0",
49
+ "eslint-plugin-import": "^2.32.0",
50
+ "eslint-plugin-n": "^16.6.2",
51
+ "eslint-plugin-prettier": "^5.5.4",
52
+ "eslint-plugin-promise": "^7.2.1",
53
+ "ws": "^8.18.0",
54
+ "yakumo": "^1.0.0",
55
+ "yakumo-esbuild": "^1.0.0",
56
+ "yakumo-mocha": "^1.0.0",
57
+ "yakumo-tsc": "^1.0.0"
58
+ },
59
+ "engines": {
60
+ "node": ">=18.0.0"
61
+ },
62
+ "scripts": {
63
+ "build": "yarn yakumo build",
64
+ "bump": "yarn yakumo version",
65
+ "dep": "yarn yakumo upgrade",
66
+ "pub": "yarn yakumo publish",
67
+ "lint": "yarn eslint src --ext=ts",
68
+ "lint-fix": "yarn eslint src --ext=ts --fix"
69
+ },
70
+ "koishi": {
71
+ "description": {
72
+ "zh": "百眼巨人 Argus:通过 /peek 命令让群友偷窥你的电脑屏幕。"
73
+ },
74
+ "service": {
75
+ "required": [
76
+ "server"
77
+ ]
78
+ }
79
+ },
80
+ "author": "dingyi222666 <dingyi222666@foxmail.com>",
81
+ "homepage": "https://github.com/dingyi222666/koishi-plugin-argus#readme",
82
+ "repository": {
83
+ "type": "git",
84
+ "url": "git+https://github.com/dingyi222666/koishi-plugin-argus.git"
85
+ },
86
+ "bugs": {
87
+ "url": "https://github.com/dingyi222666/koishi-plugin-argus/issues"
88
+ }
89
+ }
package/readme.md ADDED
@@ -0,0 +1,70 @@
1
+ # koishi-plugin-argus
2
+
3
+ > 百眼巨人 Argus —— 让群友通过 `/peek` 命令偷窥你的电脑屏幕。
4
+
5
+ 插件本体作为 WebSocket 服务,配套 CLI 客户端 [`argus-eye`](https://www.npmjs.com/package/argus-eye)
6
+ 连接上来后,群里就能通过命令拉取实时模糊截图。
7
+
8
+ ## 安装
9
+
10
+ ```bash
11
+ npm i koishi-plugin-argus
12
+ ```
13
+
14
+ 依赖 `@koishijs/plugin-server`(需要在 koishi 配置中先启用并指定端口)。
15
+
16
+ ## 使用
17
+
18
+ ### 1. 启用插件
19
+
20
+ 在 koishi 中加载 `argus` 插件,至少配置 `token`:
21
+
22
+ ```yaml
23
+ plugins:
24
+ server:
25
+ port: 5140
26
+ argus:
27
+ token: 'a-strong-secret'
28
+ path: '/argus'
29
+ blur: 40
30
+ ```
31
+
32
+ ### 2. 在你自己的电脑跑 CLI
33
+
34
+ ```bash
35
+ npx argus-eye -s ws://your-koishi-host:5140/argus -t a-strong-secret -n dingyi
36
+ ```
37
+
38
+ ### 3. 群里偷窥
39
+
40
+ ```
41
+ /peek # 在线只有一个客户端时直接截
42
+ /peek dingyi # 指定客户端
43
+ /peek dingyi -d 1 # 指定客户端的某块显示器
44
+ /peek dingyi -b 80 # 临时加大模糊(不能低于 minBlur)
45
+ /peek dingyi -f # 强制重新截图,绕过 5 分钟缓存(需要 forceAuthority)
46
+ /peek --list # 查看在线客户端
47
+ /dingyi # registerAlias=true 时的别名(等价于 /peek dingyi)
48
+ ```
49
+
50
+ 群友连按 `/peek` 时不会让你电脑反复截图:默认 5 分钟内的同一客户端 + 同一显示器,
51
+ 插件会复用上一次的图(消息后面带 `(缓存,剩余 4m12s)` 之类的提示)。
52
+ 如果当时正在玩全屏游戏 / 全屏视频,CLI 会直接返回程序名,群里只会看到一行
53
+ 「客户端「dingyi」正忙:League of Legends」,不会真的把画面发出去。
54
+
55
+ ## 配置项
56
+
57
+ | 字段 | 类型 | 默认 | 说明 |
58
+ | --- | --- | --- | --- |
59
+ | `path` | `string` | `/argus` | WebSocket 挂载路径 |
60
+ | `token` | `string` | `''` | 客户端鉴权 token,必填 |
61
+ | `commandName` | `string` | `peek` | 顶层命令名 |
62
+ | `blur` | `number` | `40` | 默认模糊半径(pixel)|
63
+ | `blurMode` | `'gaussian' \| 'fast'` | `'fast'` | 模糊算法 |
64
+ | `minBlur` | `number` | `10` | 命令里调小模糊时不可低于此值 |
65
+ | `maxImageBytes` | `number` | `8 * 1024 * 1024` | 单张截图大小上限 |
66
+ | `timeout` | `number` | `15000` | 等待客户端响应超时(ms)|
67
+ | `cacheDuration` | `number` | `300000` | 截图缓存时长(ms),默认 5 分钟,0 = 关闭缓存 |
68
+ | `registerAlias` | `boolean` | `true` | 是否给每个客户端注册同名别名 |
69
+ | `authority` | `number` | `1` | 命令所需权限等级 |
70
+ | `forceAuthority` | `number` | `3` | 使用 `-f` 绕过缓存所需权限等级 |