liangzimixin 0.3.82 → 0.3.84
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/dist/index.cjs +92 -22
- package/dist/index.d.cts +2 -1
- package/dist/package.json +3 -1
- package/dist/setup-entry.cjs +94 -22
- package/package.json +3 -1
- package/scripts/liangzimixin_install.bat +1 -1
- package/scripts/liangzimixin_install.sh +1 -1
package/dist/index.cjs
CHANGED
|
@@ -39,8 +39,8 @@ __export(index_exports, {
|
|
|
39
39
|
startPlugin: () => startPlugin
|
|
40
40
|
});
|
|
41
41
|
module.exports = __toCommonJS(index_exports);
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var import_node_path4 = require("path");
|
|
43
|
+
var import_node_os2 = require("os");
|
|
44
44
|
|
|
45
45
|
// node_modules/zod/v4/classic/external.js
|
|
46
46
|
var external_exports = {};
|
|
@@ -14011,28 +14011,93 @@ var FileServiceError = class extends Error {
|
|
|
14011
14011
|
};
|
|
14012
14012
|
|
|
14013
14013
|
// src/logger.ts
|
|
14014
|
+
var import_node_fs = require("fs");
|
|
14015
|
+
var import_node_path = require("path");
|
|
14016
|
+
var import_node_os = require("os");
|
|
14017
|
+
var import_node_util = require("util");
|
|
14018
|
+
var import_winston = __toESM(require("winston"), 1);
|
|
14019
|
+
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
14014
14020
|
var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
14021
|
+
var LOG_DIR = (0, import_node_path.join)((0, import_node_os.homedir)(), TOKEN_STORE_DIR, "logs");
|
|
14022
|
+
var fileTransportAvailable = true;
|
|
14023
|
+
try {
|
|
14024
|
+
(0, import_node_fs.mkdirSync)(LOG_DIR, { recursive: true, mode: 448 });
|
|
14025
|
+
} catch (err) {
|
|
14026
|
+
fileTransportAvailable = false;
|
|
14027
|
+
console.warn(
|
|
14028
|
+
`[${LOG_PREFIX}:logger] \u26A0 \u65E0\u6CD5\u521B\u5EFA\u65E5\u5FD7\u76EE\u5F55 ${LOG_DIR}\uFF0C\u964D\u7EA7\u4E3A\u4EC5\u63A7\u5236\u53F0\u8F93\u51FA:`,
|
|
14029
|
+
err.message
|
|
14030
|
+
);
|
|
14031
|
+
}
|
|
14032
|
+
function createPrintFormat(includeTimestamp) {
|
|
14033
|
+
return import_winston.default.format.printf(({ level, message, timestamp, namespace, args }) => {
|
|
14034
|
+
const prefix = `[${LOG_PREFIX}:${namespace}]`;
|
|
14035
|
+
const extra = Array.isArray(args) && args.length > 0 ? " " + args.map(
|
|
14036
|
+
(a) => typeof a === "object" && a !== null ? a instanceof Error ? a.stack || a.message : (0, import_node_util.inspect)(a, { depth: 5 }) : String(a)
|
|
14037
|
+
).join(" ") : "";
|
|
14038
|
+
if (includeTimestamp) {
|
|
14039
|
+
return `${timestamp} [${level}] ${prefix} ${message}${extra}`;
|
|
14040
|
+
}
|
|
14041
|
+
return `[${level}] ${prefix} ${message}${extra}`;
|
|
14042
|
+
});
|
|
14043
|
+
}
|
|
14044
|
+
var transports = [
|
|
14045
|
+
// Console Transport: 保持原有控制台输出风格并配置错误输出流
|
|
14046
|
+
new import_winston.default.transports.Console({
|
|
14047
|
+
stderrLevels: ["error", "warn"],
|
|
14048
|
+
format: import_winston.default.format.combine(
|
|
14049
|
+
import_winston.default.format.colorize({ level: true }),
|
|
14050
|
+
createPrintFormat(false)
|
|
14051
|
+
)
|
|
14052
|
+
})
|
|
14053
|
+
];
|
|
14054
|
+
if (fileTransportAvailable) {
|
|
14055
|
+
transports.push(
|
|
14056
|
+
new import_winston_daily_rotate_file.default({
|
|
14057
|
+
dirname: LOG_DIR,
|
|
14058
|
+
filename: "app-%DATE%",
|
|
14059
|
+
extension: ".log",
|
|
14060
|
+
datePattern: "YYYY-MM-DD",
|
|
14061
|
+
maxFiles: "14d",
|
|
14062
|
+
maxSize: "20m",
|
|
14063
|
+
options: { flags: "a", mode: 384 },
|
|
14064
|
+
format: import_winston.default.format.combine(
|
|
14065
|
+
createPrintFormat(true)
|
|
14066
|
+
)
|
|
14067
|
+
})
|
|
14068
|
+
);
|
|
14069
|
+
}
|
|
14070
|
+
transports.forEach((t) => t.on("error", (err) => console.error("Winston transport error:", err)));
|
|
14071
|
+
var rootLogger = import_winston.default.createLogger({
|
|
14072
|
+
level: "debug",
|
|
14073
|
+
// 根级别设为最宽松,由子 logger 的 minLevel 控制实际过滤
|
|
14074
|
+
// 使用 winston 默认 npm levels (error:0, warn:1, info:2, verbose:3, debug:4, silly:5)
|
|
14075
|
+
// 我们的 LOG_LEVELS 仅用于 createLogger 包装器的手动过滤
|
|
14076
|
+
format: import_winston.default.format.combine(
|
|
14077
|
+
import_winston.default.format.timestamp()
|
|
14078
|
+
),
|
|
14079
|
+
transports
|
|
14080
|
+
});
|
|
14015
14081
|
function createLogger(namespace, level = "info") {
|
|
14016
|
-
const prefix = `[${LOG_PREFIX}:${namespace}]`;
|
|
14017
14082
|
const minLevel = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
14018
14083
|
return {
|
|
14019
14084
|
debug(msg, ...args) {
|
|
14020
14085
|
if (minLevel <= LOG_LEVELS.debug) {
|
|
14021
|
-
|
|
14086
|
+
rootLogger.log("debug", msg, { namespace, args });
|
|
14022
14087
|
}
|
|
14023
14088
|
},
|
|
14024
14089
|
info(msg, ...args) {
|
|
14025
14090
|
if (minLevel <= LOG_LEVELS.info) {
|
|
14026
|
-
|
|
14091
|
+
rootLogger.log("info", msg, { namespace, args });
|
|
14027
14092
|
}
|
|
14028
14093
|
},
|
|
14029
14094
|
warn(msg, ...args) {
|
|
14030
14095
|
if (minLevel <= LOG_LEVELS.warn) {
|
|
14031
|
-
|
|
14096
|
+
rootLogger.log("warn", msg, { namespace, args });
|
|
14032
14097
|
}
|
|
14033
14098
|
},
|
|
14034
14099
|
error(msg, ...args) {
|
|
14035
|
-
|
|
14100
|
+
rootLogger.log("error", msg, { namespace, args });
|
|
14036
14101
|
}
|
|
14037
14102
|
};
|
|
14038
14103
|
}
|
|
@@ -15325,6 +15390,11 @@ ${body}` : body || raw.content;
|
|
|
15325
15390
|
text = c?.text ?? raw.content;
|
|
15326
15391
|
break;
|
|
15327
15392
|
}
|
|
15393
|
+
case "reference": {
|
|
15394
|
+
const c = parsed;
|
|
15395
|
+
text = c?.contentText ?? raw.content;
|
|
15396
|
+
break;
|
|
15397
|
+
}
|
|
15328
15398
|
default:
|
|
15329
15399
|
text = raw.content;
|
|
15330
15400
|
}
|
|
@@ -16375,8 +16445,8 @@ var quantumImPlugin = {
|
|
|
16375
16445
|
};
|
|
16376
16446
|
|
|
16377
16447
|
// src/crypto/quantum-plug.ts
|
|
16378
|
-
var
|
|
16379
|
-
var
|
|
16448
|
+
var import_node_fs2 = require("fs");
|
|
16449
|
+
var import_node_path2 = require("path");
|
|
16380
16450
|
var log17 = createLogger("crypto/quantum-plug");
|
|
16381
16451
|
var KMS_URLS = {
|
|
16382
16452
|
test: "https://cmsp.zdxlz.com:8552",
|
|
@@ -16384,13 +16454,13 @@ var KMS_URLS = {
|
|
|
16384
16454
|
production: "https://cmsp.zdxlz.com:8552"
|
|
16385
16455
|
};
|
|
16386
16456
|
function getSdkDir() {
|
|
16387
|
-
return (0,
|
|
16457
|
+
return (0, import_node_path2.resolve)(__dirname, "quantum-sdk");
|
|
16388
16458
|
}
|
|
16389
16459
|
function writeQuantumConfig(config2) {
|
|
16390
16460
|
const sdkDir = getSdkDir();
|
|
16391
|
-
const configPath = (0,
|
|
16392
|
-
(0,
|
|
16393
|
-
(0,
|
|
16461
|
+
const configPath = (0, import_node_path2.join)(sdkDir, "quantum.json");
|
|
16462
|
+
(0, import_node_fs2.mkdirSync)(sdkDir, { recursive: true });
|
|
16463
|
+
(0, import_node_fs2.writeFileSync)(configPath, JSON.stringify(config2, null, 2), "utf-8");
|
|
16394
16464
|
log17.info("quantum.json written", { path: configPath });
|
|
16395
16465
|
}
|
|
16396
16466
|
function createQuantumPlug() {
|
|
@@ -16398,7 +16468,7 @@ function createQuantumPlug() {
|
|
|
16398
16468
|
function loadSdk() {
|
|
16399
16469
|
if (sdk) return sdk;
|
|
16400
16470
|
try {
|
|
16401
|
-
const sdkPath = (0,
|
|
16471
|
+
const sdkPath = (0, import_node_path2.resolve)(__dirname, "quantum-sdk", "index.cjs");
|
|
16402
16472
|
sdk = require(sdkPath);
|
|
16403
16473
|
log17.info("Quantum SDK loaded \u2713");
|
|
16404
16474
|
return sdk;
|
|
@@ -16411,8 +16481,8 @@ function createQuantumPlug() {
|
|
|
16411
16481
|
return {
|
|
16412
16482
|
async init() {
|
|
16413
16483
|
const s = loadSdk();
|
|
16414
|
-
const sdkLogDir = (0,
|
|
16415
|
-
(0,
|
|
16484
|
+
const sdkLogDir = (0, import_node_path2.resolve)(__dirname, "quantum-sdk", "log");
|
|
16485
|
+
(0, import_node_fs2.mkdirSync)(sdkLogDir, { recursive: true });
|
|
16416
16486
|
await s.init();
|
|
16417
16487
|
log17.info("Quantum SDK initialized \u2713");
|
|
16418
16488
|
},
|
|
@@ -16816,8 +16886,8 @@ var OAuthClient = class {
|
|
|
16816
16886
|
|
|
16817
16887
|
// src/auth/token-store.ts
|
|
16818
16888
|
var import_promises = require("fs/promises");
|
|
16819
|
-
var
|
|
16820
|
-
var
|
|
16889
|
+
var import_node_fs3 = require("fs");
|
|
16890
|
+
var import_node_path3 = require("path");
|
|
16821
16891
|
var import_node_crypto2 = require("crypto");
|
|
16822
16892
|
var log20 = createLogger("auth/token-store");
|
|
16823
16893
|
var TokenStore = class {
|
|
@@ -16842,7 +16912,7 @@ var TokenStore = class {
|
|
|
16842
16912
|
*/
|
|
16843
16913
|
async ensureDir() {
|
|
16844
16914
|
if (this.dirEnsured) return;
|
|
16845
|
-
if (!(0,
|
|
16915
|
+
if (!(0, import_node_fs3.existsSync)(this.storageDir)) {
|
|
16846
16916
|
await (0, import_promises.mkdir)(this.storageDir, { recursive: true, mode: 448 });
|
|
16847
16917
|
log20.debug("Storage directory created", { dir: this.storageDir });
|
|
16848
16918
|
}
|
|
@@ -16853,7 +16923,7 @@ var TokenStore = class {
|
|
|
16853
16923
|
* @param key - 存储键名 (如 'token', 'credentials')
|
|
16854
16924
|
*/
|
|
16855
16925
|
filePath(key) {
|
|
16856
|
-
return (0,
|
|
16926
|
+
return (0, import_node_path3.join)(this.storageDir, `${key}.enc`);
|
|
16857
16927
|
}
|
|
16858
16928
|
/**
|
|
16859
16929
|
* 保存 Token — 加密写入文件
|
|
@@ -16902,7 +16972,7 @@ var TokenStore = class {
|
|
|
16902
16972
|
*/
|
|
16903
16973
|
async load(key) {
|
|
16904
16974
|
const filePath = this.filePath(key);
|
|
16905
|
-
if (!(0,
|
|
16975
|
+
if (!(0, import_node_fs3.existsSync)(filePath)) {
|
|
16906
16976
|
log20.debug("Token file not found", { key, path: filePath });
|
|
16907
16977
|
return null;
|
|
16908
16978
|
}
|
|
@@ -18684,7 +18754,7 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
18684
18754
|
appId: accountConfig.appId,
|
|
18685
18755
|
appSecret: accountConfig.appSecret
|
|
18686
18756
|
});
|
|
18687
|
-
const tokenStorePath = (0,
|
|
18757
|
+
const tokenStorePath = (0, import_node_path4.join)((0, import_node_os2.homedir)(), TOKEN_STORE_DIR, "tokens", accountConfig.appId);
|
|
18688
18758
|
const tokenStore = new TokenStore(tokenStorePath, cryptoEngine);
|
|
18689
18759
|
const tokenManager = new TokenManager({
|
|
18690
18760
|
oauthClient,
|
package/dist/index.d.cts
CHANGED
|
@@ -173,7 +173,7 @@ interface InboundMessage {
|
|
|
173
173
|
/** 发送者显示名称 (用于日志和 SDK 信封) */
|
|
174
174
|
senderName?: string;
|
|
175
175
|
/** 消息类型 — 决定 content JSON 结构、加密策略和处理流程 */
|
|
176
|
-
msgType: 'text' | 'markdown' | 'image' | 'file' | 'voice' | 'video' | 'system';
|
|
176
|
+
msgType: 'text' | 'markdown' | 'image' | 'file' | 'voice' | 'video' | 'system' | 'reference';
|
|
177
177
|
/**
|
|
178
178
|
* 消息内容 (JSON 字符串,解密后)
|
|
179
179
|
*
|
|
@@ -185,6 +185,7 @@ interface InboundMessage {
|
|
|
185
185
|
* - voice: `{"fileId": "xxx", "duration": 2914.23}`
|
|
186
186
|
* - video: `{"fileId": "xxx", "duration": 5291667.32, "width": 1200}`
|
|
187
187
|
* - system: `{"text": "用户已加入会话"}`
|
|
188
|
+
* - reference: `{"contentText": "回复文本"}` (refMsgId 本期忽略)
|
|
188
189
|
*/
|
|
189
190
|
content: string;
|
|
190
191
|
/** 原始内容 (解密前,用于调试和审计) */
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liangzimixin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.84",
|
|
4
4
|
"description": "Quantum-encrypted IM channel plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.cjs",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"format:check": "prettier --check src/**/*.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"winston": "^3.19.0",
|
|
28
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
27
29
|
"ws": "^8.19.0"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
package/dist/setup-entry.cjs
CHANGED
|
@@ -58,6 +58,14 @@ var FileServiceError = class extends Error {
|
|
|
58
58
|
}
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
// src/logger.ts
|
|
62
|
+
var import_node_fs = require("fs");
|
|
63
|
+
var import_node_path = require("path");
|
|
64
|
+
var import_node_os = require("os");
|
|
65
|
+
var import_node_util = require("util");
|
|
66
|
+
var import_winston = __toESM(require("winston"), 1);
|
|
67
|
+
var import_winston_daily_rotate_file = __toESM(require("winston-daily-rotate-file"), 1);
|
|
68
|
+
|
|
61
69
|
// src/constants.ts
|
|
62
70
|
var CHANNEL_ID = "liangzimixin";
|
|
63
71
|
var LOG_PREFIX = CHANNEL_ID;
|
|
@@ -75,27 +83,86 @@ var HINT_PLAINTEXT_NOT_SUPPORTED = "\u60A8\u7684\u63D2\u4EF6\u5DF2\u5F00\u542F\u
|
|
|
75
83
|
|
|
76
84
|
// src/logger.ts
|
|
77
85
|
var LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3 };
|
|
86
|
+
var LOG_DIR = (0, import_node_path.join)((0, import_node_os.homedir)(), TOKEN_STORE_DIR, "logs");
|
|
87
|
+
var fileTransportAvailable = true;
|
|
88
|
+
try {
|
|
89
|
+
(0, import_node_fs.mkdirSync)(LOG_DIR, { recursive: true, mode: 448 });
|
|
90
|
+
} catch (err) {
|
|
91
|
+
fileTransportAvailable = false;
|
|
92
|
+
console.warn(
|
|
93
|
+
`[${LOG_PREFIX}:logger] \u26A0 \u65E0\u6CD5\u521B\u5EFA\u65E5\u5FD7\u76EE\u5F55 ${LOG_DIR}\uFF0C\u964D\u7EA7\u4E3A\u4EC5\u63A7\u5236\u53F0\u8F93\u51FA:`,
|
|
94
|
+
err.message
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
function createPrintFormat(includeTimestamp) {
|
|
98
|
+
return import_winston.default.format.printf(({ level, message, timestamp, namespace, args }) => {
|
|
99
|
+
const prefix = `[${LOG_PREFIX}:${namespace}]`;
|
|
100
|
+
const extra = Array.isArray(args) && args.length > 0 ? " " + args.map(
|
|
101
|
+
(a) => typeof a === "object" && a !== null ? a instanceof Error ? a.stack || a.message : (0, import_node_util.inspect)(a, { depth: 5 }) : String(a)
|
|
102
|
+
).join(" ") : "";
|
|
103
|
+
if (includeTimestamp) {
|
|
104
|
+
return `${timestamp} [${level}] ${prefix} ${message}${extra}`;
|
|
105
|
+
}
|
|
106
|
+
return `[${level}] ${prefix} ${message}${extra}`;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
var transports = [
|
|
110
|
+
// Console Transport: 保持原有控制台输出风格并配置错误输出流
|
|
111
|
+
new import_winston.default.transports.Console({
|
|
112
|
+
stderrLevels: ["error", "warn"],
|
|
113
|
+
format: import_winston.default.format.combine(
|
|
114
|
+
import_winston.default.format.colorize({ level: true }),
|
|
115
|
+
createPrintFormat(false)
|
|
116
|
+
)
|
|
117
|
+
})
|
|
118
|
+
];
|
|
119
|
+
if (fileTransportAvailable) {
|
|
120
|
+
transports.push(
|
|
121
|
+
new import_winston_daily_rotate_file.default({
|
|
122
|
+
dirname: LOG_DIR,
|
|
123
|
+
filename: "app-%DATE%",
|
|
124
|
+
extension: ".log",
|
|
125
|
+
datePattern: "YYYY-MM-DD",
|
|
126
|
+
maxFiles: "14d",
|
|
127
|
+
maxSize: "20m",
|
|
128
|
+
options: { flags: "a", mode: 384 },
|
|
129
|
+
format: import_winston.default.format.combine(
|
|
130
|
+
createPrintFormat(true)
|
|
131
|
+
)
|
|
132
|
+
})
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
transports.forEach((t) => t.on("error", (err) => console.error("Winston transport error:", err)));
|
|
136
|
+
var rootLogger = import_winston.default.createLogger({
|
|
137
|
+
level: "debug",
|
|
138
|
+
// 根级别设为最宽松,由子 logger 的 minLevel 控制实际过滤
|
|
139
|
+
// 使用 winston 默认 npm levels (error:0, warn:1, info:2, verbose:3, debug:4, silly:5)
|
|
140
|
+
// 我们的 LOG_LEVELS 仅用于 createLogger 包装器的手动过滤
|
|
141
|
+
format: import_winston.default.format.combine(
|
|
142
|
+
import_winston.default.format.timestamp()
|
|
143
|
+
),
|
|
144
|
+
transports
|
|
145
|
+
});
|
|
78
146
|
function createLogger(namespace, level = "info") {
|
|
79
|
-
const prefix = `[${LOG_PREFIX}:${namespace}]`;
|
|
80
147
|
const minLevel = LOG_LEVELS[level] ?? LOG_LEVELS.info;
|
|
81
148
|
return {
|
|
82
149
|
debug(msg, ...args) {
|
|
83
150
|
if (minLevel <= LOG_LEVELS.debug) {
|
|
84
|
-
|
|
151
|
+
rootLogger.log("debug", msg, { namespace, args });
|
|
85
152
|
}
|
|
86
153
|
},
|
|
87
154
|
info(msg, ...args) {
|
|
88
155
|
if (minLevel <= LOG_LEVELS.info) {
|
|
89
|
-
|
|
156
|
+
rootLogger.log("info", msg, { namespace, args });
|
|
90
157
|
}
|
|
91
158
|
},
|
|
92
159
|
warn(msg, ...args) {
|
|
93
160
|
if (minLevel <= LOG_LEVELS.warn) {
|
|
94
|
-
|
|
161
|
+
rootLogger.log("warn", msg, { namespace, args });
|
|
95
162
|
}
|
|
96
163
|
},
|
|
97
164
|
error(msg, ...args) {
|
|
98
|
-
|
|
165
|
+
rootLogger.log("error", msg, { namespace, args });
|
|
99
166
|
}
|
|
100
167
|
};
|
|
101
168
|
}
|
|
@@ -1326,8 +1393,8 @@ var quantumImOutbound = {
|
|
|
1326
1393
|
};
|
|
1327
1394
|
|
|
1328
1395
|
// src/index.ts
|
|
1329
|
-
var
|
|
1330
|
-
var
|
|
1396
|
+
var import_node_path4 = require("path");
|
|
1397
|
+
var import_node_os2 = require("os");
|
|
1331
1398
|
|
|
1332
1399
|
// node_modules/zod/v4/classic/external.js
|
|
1333
1400
|
var external_exports = {};
|
|
@@ -15252,8 +15319,8 @@ function buildPluginConfig(accountConfig, internalOverrides) {
|
|
|
15252
15319
|
}
|
|
15253
15320
|
|
|
15254
15321
|
// src/crypto/quantum-plug.ts
|
|
15255
|
-
var
|
|
15256
|
-
var
|
|
15322
|
+
var import_node_fs2 = require("fs");
|
|
15323
|
+
var import_node_path2 = require("path");
|
|
15257
15324
|
var log8 = createLogger("crypto/quantum-plug");
|
|
15258
15325
|
var KMS_URLS = {
|
|
15259
15326
|
test: "https://cmsp.zdxlz.com:8552",
|
|
@@ -15261,13 +15328,13 @@ var KMS_URLS = {
|
|
|
15261
15328
|
production: "https://cmsp.zdxlz.com:8552"
|
|
15262
15329
|
};
|
|
15263
15330
|
function getSdkDir() {
|
|
15264
|
-
return (0,
|
|
15331
|
+
return (0, import_node_path2.resolve)(__dirname, "quantum-sdk");
|
|
15265
15332
|
}
|
|
15266
15333
|
function writeQuantumConfig(config2) {
|
|
15267
15334
|
const sdkDir = getSdkDir();
|
|
15268
|
-
const configPath = (0,
|
|
15269
|
-
(0,
|
|
15270
|
-
(0,
|
|
15335
|
+
const configPath = (0, import_node_path2.join)(sdkDir, "quantum.json");
|
|
15336
|
+
(0, import_node_fs2.mkdirSync)(sdkDir, { recursive: true });
|
|
15337
|
+
(0, import_node_fs2.writeFileSync)(configPath, JSON.stringify(config2, null, 2), "utf-8");
|
|
15271
15338
|
log8.info("quantum.json written", { path: configPath });
|
|
15272
15339
|
}
|
|
15273
15340
|
function createQuantumPlug() {
|
|
@@ -15275,7 +15342,7 @@ function createQuantumPlug() {
|
|
|
15275
15342
|
function loadSdk() {
|
|
15276
15343
|
if (sdk) return sdk;
|
|
15277
15344
|
try {
|
|
15278
|
-
const sdkPath = (0,
|
|
15345
|
+
const sdkPath = (0, import_node_path2.resolve)(__dirname, "quantum-sdk", "index.cjs");
|
|
15279
15346
|
sdk = require(sdkPath);
|
|
15280
15347
|
log8.info("Quantum SDK loaded \u2713");
|
|
15281
15348
|
return sdk;
|
|
@@ -15288,8 +15355,8 @@ function createQuantumPlug() {
|
|
|
15288
15355
|
return {
|
|
15289
15356
|
async init() {
|
|
15290
15357
|
const s = loadSdk();
|
|
15291
|
-
const sdkLogDir = (0,
|
|
15292
|
-
(0,
|
|
15358
|
+
const sdkLogDir = (0, import_node_path2.resolve)(__dirname, "quantum-sdk", "log");
|
|
15359
|
+
(0, import_node_fs2.mkdirSync)(sdkLogDir, { recursive: true });
|
|
15293
15360
|
await s.init();
|
|
15294
15361
|
log8.info("Quantum SDK initialized \u2713");
|
|
15295
15362
|
},
|
|
@@ -15693,8 +15760,8 @@ var OAuthClient = class {
|
|
|
15693
15760
|
|
|
15694
15761
|
// src/auth/token-store.ts
|
|
15695
15762
|
var import_promises = require("fs/promises");
|
|
15696
|
-
var
|
|
15697
|
-
var
|
|
15763
|
+
var import_node_fs3 = require("fs");
|
|
15764
|
+
var import_node_path3 = require("path");
|
|
15698
15765
|
var import_node_crypto2 = require("crypto");
|
|
15699
15766
|
var log11 = createLogger("auth/token-store");
|
|
15700
15767
|
var TokenStore = class {
|
|
@@ -15719,7 +15786,7 @@ var TokenStore = class {
|
|
|
15719
15786
|
*/
|
|
15720
15787
|
async ensureDir() {
|
|
15721
15788
|
if (this.dirEnsured) return;
|
|
15722
|
-
if (!(0,
|
|
15789
|
+
if (!(0, import_node_fs3.existsSync)(this.storageDir)) {
|
|
15723
15790
|
await (0, import_promises.mkdir)(this.storageDir, { recursive: true, mode: 448 });
|
|
15724
15791
|
log11.debug("Storage directory created", { dir: this.storageDir });
|
|
15725
15792
|
}
|
|
@@ -15730,7 +15797,7 @@ var TokenStore = class {
|
|
|
15730
15797
|
* @param key - 存储键名 (如 'token', 'credentials')
|
|
15731
15798
|
*/
|
|
15732
15799
|
filePath(key) {
|
|
15733
|
-
return (0,
|
|
15800
|
+
return (0, import_node_path3.join)(this.storageDir, `${key}.enc`);
|
|
15734
15801
|
}
|
|
15735
15802
|
/**
|
|
15736
15803
|
* 保存 Token — 加密写入文件
|
|
@@ -15779,7 +15846,7 @@ var TokenStore = class {
|
|
|
15779
15846
|
*/
|
|
15780
15847
|
async load(key) {
|
|
15781
15848
|
const filePath = this.filePath(key);
|
|
15782
|
-
if (!(0,
|
|
15849
|
+
if (!(0, import_node_fs3.existsSync)(filePath)) {
|
|
15783
15850
|
log11.debug("Token file not found", { key, path: filePath });
|
|
15784
15851
|
return null;
|
|
15785
15852
|
}
|
|
@@ -17638,7 +17705,7 @@ async function startPlugin(accountConfig, internalOverrides) {
|
|
|
17638
17705
|
appId: accountConfig.appId,
|
|
17639
17706
|
appSecret: accountConfig.appSecret
|
|
17640
17707
|
});
|
|
17641
|
-
const tokenStorePath = (0,
|
|
17708
|
+
const tokenStorePath = (0, import_node_path4.join)((0, import_node_os2.homedir)(), TOKEN_STORE_DIR, "tokens", accountConfig.appId);
|
|
17642
17709
|
const tokenStore = new TokenStore(tokenStorePath, cryptoEngine);
|
|
17643
17710
|
const tokenManager = new TokenManager({
|
|
17644
17711
|
oauthClient,
|
|
@@ -17777,6 +17844,11 @@ ${body}` : body || raw.content;
|
|
|
17777
17844
|
text = c?.text ?? raw.content;
|
|
17778
17845
|
break;
|
|
17779
17846
|
}
|
|
17847
|
+
case "reference": {
|
|
17848
|
+
const c = parsed;
|
|
17849
|
+
text = c?.contentText ?? raw.content;
|
|
17850
|
+
break;
|
|
17851
|
+
}
|
|
17780
17852
|
default:
|
|
17781
17853
|
text = raw.content;
|
|
17782
17854
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "liangzimixin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.84",
|
|
4
4
|
"description": "Quantum-encrypted IM channel plugin for OpenClaw",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -24,6 +24,8 @@
|
|
|
24
24
|
"format:check": "prettier --check src/**/*.ts"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
+
"winston": "^3.19.0",
|
|
28
|
+
"winston-daily-rotate-file": "^5.0.0",
|
|
27
29
|
"ws": "^8.19.0"
|
|
28
30
|
},
|
|
29
31
|
"peerDependencies": {
|
|
@@ -7,7 +7,7 @@ REM liangzimixin install script (Windows)
|
|
|
7
7
|
REM Usage: liangzimixin_install.bat <appId> <appSecret> [quantumAccount]
|
|
8
8
|
REM ============================================================
|
|
9
9
|
|
|
10
|
-
set "SCRIPT_VERSION=0.3.
|
|
10
|
+
set "SCRIPT_VERSION=0.3.84"
|
|
11
11
|
set "NPM_PACKAGE=liangzimixin"
|
|
12
12
|
|
|
13
13
|
set "SKIP_SELF_UPDATE=0"
|
|
@@ -6,7 +6,7 @@ set -euo pipefail
|
|
|
6
6
|
# 用法: ./liangzimixin_install.sh <appId> <appSecret> [quantumAccount]
|
|
7
7
|
# ============================================================
|
|
8
8
|
|
|
9
|
-
SCRIPT_VERSION="0.3.
|
|
9
|
+
SCRIPT_VERSION="0.3.84"
|
|
10
10
|
NPM_PACKAGE="liangzimixin"
|
|
11
11
|
|
|
12
12
|
# ── 颜色 ──────────────────────────────────────────────────────
|