liangzimixin 0.3.93 → 0.3.95
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
CHANGED
|
@@ -31618,7 +31618,9 @@ var InboundPipeline = class {
|
|
|
31618
31618
|
async handle(msg) {
|
|
31619
31619
|
const startMs = Date.now();
|
|
31620
31620
|
const semaphore = this.deps.messagePipe.semaphore;
|
|
31621
|
+
const semaphoreStartMs = Date.now();
|
|
31621
31622
|
const acquireResult = await semaphore.acquire();
|
|
31623
|
+
metrics.recordLatency("inbound.semaphore_wait", Date.now() - semaphoreStartMs);
|
|
31622
31624
|
if (acquireResult === "rejected") {
|
|
31623
31625
|
metrics.increment("inbound.semaphore_rejected");
|
|
31624
31626
|
log15.warn("\u{1F6AB} \u6D88\u606F\u88AB\u62D2\u7EDD (Semaphore \u6EA2\u51FA)", {
|
|
@@ -31778,6 +31780,7 @@ var InboundPipeline = class {
|
|
|
31778
31780
|
}).catch((err) => {
|
|
31779
31781
|
log15.warn("\u26A0\uFE0F \u5373\u65F6\u53CD\u9988\u53D1\u9001\u5931\u8D25", { error: err.message });
|
|
31780
31782
|
});
|
|
31783
|
+
const contentResolveStartMs = Date.now();
|
|
31781
31784
|
const resolvedContent = await resolveContent(context, {
|
|
31782
31785
|
tokenManager: this.deps.tokenManager,
|
|
31783
31786
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
@@ -31788,6 +31791,7 @@ var InboundPipeline = class {
|
|
|
31788
31791
|
messagePipe: this.deps.messagePipe,
|
|
31789
31792
|
fileEncryptionMeta: msg.fileEncryptionMeta
|
|
31790
31793
|
});
|
|
31794
|
+
metrics.recordLatency("inbound.content_resolve", Date.now() - contentResolveStartMs);
|
|
31791
31795
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
31792
31796
|
const { sdkConfig } = this.deps;
|
|
31793
31797
|
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
@@ -31815,6 +31819,7 @@ var InboundPipeline = class {
|
|
|
31815
31819
|
chatId: msg.chatId,
|
|
31816
31820
|
\u5185\u5BB9\u9884\u89C8: String(payload.Body ?? "").slice(0, 200)
|
|
31817
31821
|
});
|
|
31822
|
+
const aiStartMs = Date.now();
|
|
31818
31823
|
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
31819
31824
|
ctx,
|
|
31820
31825
|
cfg: sdkConfig,
|
|
@@ -31824,12 +31829,16 @@ var InboundPipeline = class {
|
|
|
31824
31829
|
if (typeof dispatcher.waitForIdle === "function") {
|
|
31825
31830
|
await dispatcher.waitForIdle();
|
|
31826
31831
|
}
|
|
31832
|
+
metrics.recordLatency("inbound.ai_reply", Date.now() - aiStartMs);
|
|
31833
|
+
const aiDurationMs = Date.now() - aiStartMs;
|
|
31827
31834
|
const durationMs = Date.now() - startMs;
|
|
31828
31835
|
log15.info("\u2705 \u6D88\u606F\u5904\u7406\u5B8C\u6210", {
|
|
31829
31836
|
messageId: msg.messageId,
|
|
31830
31837
|
chatId: msg.chatId,
|
|
31831
31838
|
\u56DE\u590D\u6570: counts?.final ?? 0,
|
|
31832
|
-
\u8017\u65F6ms: durationMs
|
|
31839
|
+
\u8017\u65F6ms: durationMs,
|
|
31840
|
+
AI\u56DE\u590Dms: aiDurationMs,
|
|
31841
|
+
\u63D2\u4EF6\u5904\u7406ms: durationMs - aiDurationMs
|
|
31833
31842
|
});
|
|
31834
31843
|
clearInboundEncryptionStatus(msg.chatId, msg.messageId);
|
|
31835
31844
|
} catch (err) {
|
|
@@ -33680,20 +33689,41 @@ var MessagePipe = class _MessagePipe {
|
|
|
33680
33689
|
async _callMessageApiOnce(url2, body, logTag) {
|
|
33681
33690
|
const apiStartMs = Date.now();
|
|
33682
33691
|
const token2 = await this.tokenFn();
|
|
33683
|
-
const
|
|
33692
|
+
const reqHeaders = {
|
|
33693
|
+
"Authorization": `Bearer ${token2}`,
|
|
33694
|
+
"Content-Type": "application/json"
|
|
33695
|
+
};
|
|
33696
|
+
log25.info(`${logTag}:DEBUG:request`, {
|
|
33697
|
+
url: url2,
|
|
33684
33698
|
method: "POST",
|
|
33685
33699
|
headers: {
|
|
33686
|
-
|
|
33700
|
+
Authorization: `Bearer ${token2.slice(0, 20)}...`,
|
|
33687
33701
|
"Content-Type": "application/json"
|
|
33688
33702
|
},
|
|
33703
|
+
tokenLength: token2.length
|
|
33704
|
+
});
|
|
33705
|
+
const resp = await fetch(url2, {
|
|
33706
|
+
method: "POST",
|
|
33707
|
+
headers: reqHeaders,
|
|
33689
33708
|
body: JSON.stringify(body)
|
|
33690
33709
|
});
|
|
33691
33710
|
if (!resp.ok) {
|
|
33711
|
+
let respBody = "";
|
|
33712
|
+
try {
|
|
33713
|
+
respBody = (await resp.clone().text()).slice(0, 500);
|
|
33714
|
+
} catch {
|
|
33715
|
+
}
|
|
33716
|
+
const respHeaders = {};
|
|
33717
|
+
resp.headers.forEach((v, k) => {
|
|
33718
|
+
respHeaders[k] = v;
|
|
33719
|
+
});
|
|
33692
33720
|
log25.error(`${logTag}:http-error`, {
|
|
33693
33721
|
status: resp.status,
|
|
33694
33722
|
statusText: resp.statusText,
|
|
33695
33723
|
url: url2,
|
|
33696
|
-
body
|
|
33724
|
+
body,
|
|
33725
|
+
responseHeaders: respHeaders,
|
|
33726
|
+
responseBody: respBody
|
|
33697
33727
|
});
|
|
33698
33728
|
if (resp.status === 401 && this.invalidateTokenFn) {
|
|
33699
33729
|
log25.warn(`${logTag}:token-expired, invalidating cached token for retry`);
|
package/dist/package.json
CHANGED
package/dist/setup-entry.cjs
CHANGED
|
@@ -32554,20 +32554,41 @@ var MessagePipe = class _MessagePipe {
|
|
|
32554
32554
|
async _callMessageApiOnce(url2, body, logTag) {
|
|
32555
32555
|
const apiStartMs = Date.now();
|
|
32556
32556
|
const token2 = await this.tokenFn();
|
|
32557
|
-
const
|
|
32557
|
+
const reqHeaders = {
|
|
32558
|
+
"Authorization": `Bearer ${token2}`,
|
|
32559
|
+
"Content-Type": "application/json"
|
|
32560
|
+
};
|
|
32561
|
+
log16.info(`${logTag}:DEBUG:request`, {
|
|
32562
|
+
url: url2,
|
|
32558
32563
|
method: "POST",
|
|
32559
32564
|
headers: {
|
|
32560
|
-
|
|
32565
|
+
Authorization: `Bearer ${token2.slice(0, 20)}...`,
|
|
32561
32566
|
"Content-Type": "application/json"
|
|
32562
32567
|
},
|
|
32568
|
+
tokenLength: token2.length
|
|
32569
|
+
});
|
|
32570
|
+
const resp = await fetch(url2, {
|
|
32571
|
+
method: "POST",
|
|
32572
|
+
headers: reqHeaders,
|
|
32563
32573
|
body: JSON.stringify(body)
|
|
32564
32574
|
});
|
|
32565
32575
|
if (!resp.ok) {
|
|
32576
|
+
let respBody = "";
|
|
32577
|
+
try {
|
|
32578
|
+
respBody = (await resp.clone().text()).slice(0, 500);
|
|
32579
|
+
} catch {
|
|
32580
|
+
}
|
|
32581
|
+
const respHeaders = {};
|
|
32582
|
+
resp.headers.forEach((v, k) => {
|
|
32583
|
+
respHeaders[k] = v;
|
|
32584
|
+
});
|
|
32566
32585
|
log16.error(`${logTag}:http-error`, {
|
|
32567
32586
|
status: resp.status,
|
|
32568
32587
|
statusText: resp.statusText,
|
|
32569
32588
|
url: url2,
|
|
32570
|
-
body
|
|
32589
|
+
body,
|
|
32590
|
+
responseHeaders: respHeaders,
|
|
32591
|
+
responseBody: respBody
|
|
32571
32592
|
});
|
|
32572
32593
|
if (resp.status === 401 && this.invalidateTokenFn) {
|
|
32573
32594
|
log16.warn(`${logTag}:token-expired, invalidating cached token for retry`);
|
|
@@ -34060,7 +34081,9 @@ var InboundPipeline = class {
|
|
|
34060
34081
|
async handle(msg) {
|
|
34061
34082
|
const startMs = Date.now();
|
|
34062
34083
|
const semaphore = this.deps.messagePipe.semaphore;
|
|
34084
|
+
const semaphoreStartMs = Date.now();
|
|
34063
34085
|
const acquireResult = await semaphore.acquire();
|
|
34086
|
+
metrics.recordLatency("inbound.semaphore_wait", Date.now() - semaphoreStartMs);
|
|
34064
34087
|
if (acquireResult === "rejected") {
|
|
34065
34088
|
metrics.increment("inbound.semaphore_rejected");
|
|
34066
34089
|
log28.warn("\u{1F6AB} \u6D88\u606F\u88AB\u62D2\u7EDD (Semaphore \u6EA2\u51FA)", {
|
|
@@ -34220,6 +34243,7 @@ var InboundPipeline = class {
|
|
|
34220
34243
|
}).catch((err) => {
|
|
34221
34244
|
log28.warn("\u26A0\uFE0F \u5373\u65F6\u53CD\u9988\u53D1\u9001\u5931\u8D25", { error: err.message });
|
|
34222
34245
|
});
|
|
34246
|
+
const contentResolveStartMs = Date.now();
|
|
34223
34247
|
const resolvedContent = await resolveContent(context, {
|
|
34224
34248
|
tokenManager: this.deps.tokenManager,
|
|
34225
34249
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
@@ -34230,6 +34254,7 @@ var InboundPipeline = class {
|
|
|
34230
34254
|
messagePipe: this.deps.messagePipe,
|
|
34231
34255
|
fileEncryptionMeta: msg.fileEncryptionMeta
|
|
34232
34256
|
});
|
|
34257
|
+
metrics.recordLatency("inbound.content_resolve", Date.now() - contentResolveStartMs);
|
|
34233
34258
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
34234
34259
|
const { sdkConfig } = this.deps;
|
|
34235
34260
|
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
@@ -34257,6 +34282,7 @@ var InboundPipeline = class {
|
|
|
34257
34282
|
chatId: msg.chatId,
|
|
34258
34283
|
\u5185\u5BB9\u9884\u89C8: String(payload.Body ?? "").slice(0, 200)
|
|
34259
34284
|
});
|
|
34285
|
+
const aiStartMs = Date.now();
|
|
34260
34286
|
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
34261
34287
|
ctx,
|
|
34262
34288
|
cfg: sdkConfig,
|
|
@@ -34266,12 +34292,16 @@ var InboundPipeline = class {
|
|
|
34266
34292
|
if (typeof dispatcher.waitForIdle === "function") {
|
|
34267
34293
|
await dispatcher.waitForIdle();
|
|
34268
34294
|
}
|
|
34295
|
+
metrics.recordLatency("inbound.ai_reply", Date.now() - aiStartMs);
|
|
34296
|
+
const aiDurationMs = Date.now() - aiStartMs;
|
|
34269
34297
|
const durationMs = Date.now() - startMs;
|
|
34270
34298
|
log28.info("\u2705 \u6D88\u606F\u5904\u7406\u5B8C\u6210", {
|
|
34271
34299
|
messageId: msg.messageId,
|
|
34272
34300
|
chatId: msg.chatId,
|
|
34273
34301
|
\u56DE\u590D\u6570: counts?.final ?? 0,
|
|
34274
|
-
\u8017\u65F6ms: durationMs
|
|
34302
|
+
\u8017\u65F6ms: durationMs,
|
|
34303
|
+
AI\u56DE\u590Dms: aiDurationMs,
|
|
34304
|
+
\u63D2\u4EF6\u5904\u7406ms: durationMs - aiDurationMs
|
|
34275
34305
|
});
|
|
34276
34306
|
clearInboundEncryptionStatus(msg.chatId, msg.messageId);
|
|
34277
34307
|
} catch (err) {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ REM liangzimixin install script (Windows)
|
|
|
18
18
|
REM Usage: liangzimixin_install.bat <appId> <appSecret> [quantumAccount]
|
|
19
19
|
REM ============================================================
|
|
20
20
|
|
|
21
|
-
set "SCRIPT_VERSION=0.3.
|
|
21
|
+
set "SCRIPT_VERSION=0.3.95"
|
|
22
22
|
set "NPM_PACKAGE=liangzimixin"
|
|
23
23
|
|
|
24
24
|
set "SKIP_SELF_UPDATE=0"
|
|
@@ -34,6 +34,8 @@ for %%a in (%*) do (
|
|
|
34
34
|
set "SKIP_SELF_UPDATE=1"
|
|
35
35
|
) else if "%%a"=="--beta" (
|
|
36
36
|
set "USE_BETA=1"
|
|
37
|
+
) else if "%%a"=="--internal-logged" (
|
|
38
|
+
REM skip internal flag
|
|
37
39
|
) else (
|
|
38
40
|
set /a IDX+=1
|
|
39
41
|
if !IDX!==1 set "APP_ID=%%a"
|
|
@@ -14,7 +14,7 @@ echo -e "\033[0;36m▸\033[0m Deployment log will be saved to $LOG_FILE"
|
|
|
14
14
|
# 用法: ./liangzimixin_install.sh <appId> <appSecret> [quantumAccount]
|
|
15
15
|
# ============================================================
|
|
16
16
|
|
|
17
|
-
SCRIPT_VERSION="0.3.
|
|
17
|
+
SCRIPT_VERSION="0.3.95"
|
|
18
18
|
NPM_PACKAGE="liangzimixin"
|
|
19
19
|
|
|
20
20
|
# ── 颜色 ──────────────────────────────────────────────────────
|