liangzimixin 0.3.7 → 0.3.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/dist/index.cjs +30 -9
- package/dist/index.d.cts +1 -0
- package/dist/setup-entry.cjs +26 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -18362,7 +18362,7 @@ function buildInboundPayload(msg, resolvedContent, config2) {
|
|
|
18362
18362
|
// 命令检测用
|
|
18363
18363
|
CommandBody: text,
|
|
18364
18364
|
// 命令解析用
|
|
18365
|
-
From: msg.senderId,
|
|
18365
|
+
From: channelAddress(msg.senderId),
|
|
18366
18366
|
To: channelAddress(msg.chatId),
|
|
18367
18367
|
SessionKey: msg.chatId,
|
|
18368
18368
|
// 私聊直接用 chatId 作为会话标识
|
|
@@ -18409,12 +18409,25 @@ function createQuantumImDeliverFn(deps) {
|
|
|
18409
18409
|
});
|
|
18410
18410
|
log11.info("outbound:delivered", {
|
|
18411
18411
|
chatId,
|
|
18412
|
-
length: payload.text.length
|
|
18412
|
+
length: payload.text.length,
|
|
18413
|
+
textPreview: payload.text.slice(0, 200)
|
|
18413
18414
|
});
|
|
18414
18415
|
};
|
|
18415
18416
|
return { deliver };
|
|
18416
18417
|
}
|
|
18417
18418
|
|
|
18419
|
+
// src/runtime.ts
|
|
18420
|
+
var runtime = null;
|
|
18421
|
+
function setPluginRuntime(next) {
|
|
18422
|
+
runtime = next;
|
|
18423
|
+
}
|
|
18424
|
+
function getPluginRuntime() {
|
|
18425
|
+
if (!runtime) {
|
|
18426
|
+
throw new Error("PluginRuntime not initialized \u2014 ensure register() has been called");
|
|
18427
|
+
}
|
|
18428
|
+
return runtime;
|
|
18429
|
+
}
|
|
18430
|
+
|
|
18418
18431
|
// src/message-handler/handler.ts
|
|
18419
18432
|
var log12 = createLogger("message-handler/handler");
|
|
18420
18433
|
var InboundPipeline = class {
|
|
@@ -18443,28 +18456,35 @@ var InboundPipeline = class {
|
|
|
18443
18456
|
});
|
|
18444
18457
|
return;
|
|
18445
18458
|
}
|
|
18459
|
+
const core = getPluginRuntime();
|
|
18446
18460
|
const resolvedContent = await resolveContent(context, {
|
|
18447
18461
|
tokenManager: this.deps.tokenManager,
|
|
18448
18462
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
18449
|
-
sdkRuntime:
|
|
18463
|
+
sdkRuntime: core,
|
|
18450
18464
|
maxBytes: this.deps.pluginConfig.file.maxFileSizeMb * 1024 * 1024,
|
|
18451
18465
|
allowPrivateNetwork: this.deps.pluginConfig.file.allowPrivateNetwork,
|
|
18452
18466
|
timeoutMs: this.deps.pluginConfig.file.fetchTimeoutMs
|
|
18453
18467
|
});
|
|
18454
18468
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
18455
|
-
const {
|
|
18456
|
-
const ctx =
|
|
18469
|
+
const { sdkConfig } = this.deps;
|
|
18470
|
+
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
18457
18471
|
const { deliver } = createQuantumImDeliverFn({
|
|
18458
18472
|
messagePipe: this.deps.messagePipe,
|
|
18459
18473
|
chatId: msg.chatId,
|
|
18460
18474
|
senderId: msg.senderId,
|
|
18461
18475
|
replyToMessageId: msg.messageId
|
|
18462
18476
|
});
|
|
18463
|
-
const { dispatcher, replyOptions } =
|
|
18477
|
+
const { dispatcher, replyOptions } = core.channel.reply.createReplyDispatcherWithTyping({
|
|
18464
18478
|
deliver
|
|
18465
18479
|
// TODO: 可选 typingCallbacks (打字指示器)
|
|
18466
18480
|
});
|
|
18467
|
-
|
|
18481
|
+
log12.info("inbound:dispatching", {
|
|
18482
|
+
messageId: msg.messageId,
|
|
18483
|
+
chatId: msg.chatId,
|
|
18484
|
+
sessionKey: msg.chatId,
|
|
18485
|
+
bodyPreview: String(payload.Body ?? "").slice(0, 200)
|
|
18486
|
+
});
|
|
18487
|
+
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
18468
18488
|
ctx,
|
|
18469
18489
|
cfg: sdkConfig,
|
|
18470
18490
|
dispatcher,
|
|
@@ -18488,6 +18508,7 @@ var InboundPipeline = class {
|
|
|
18488
18508
|
chatId: msg.chatId,
|
|
18489
18509
|
step: "handle",
|
|
18490
18510
|
error: err.message,
|
|
18511
|
+
stack: err.stack,
|
|
18491
18512
|
durationMs
|
|
18492
18513
|
});
|
|
18493
18514
|
}
|
|
@@ -18833,7 +18854,6 @@ var quantumImPlugin = {
|
|
|
18833
18854
|
messagePipe: instance.messagePipe,
|
|
18834
18855
|
tokenManager: instance.tokenManager,
|
|
18835
18856
|
pluginConfig: config2,
|
|
18836
|
-
sdkRuntime: ctx.runtime,
|
|
18837
18857
|
sdkConfig: ctx.cfg,
|
|
18838
18858
|
gateConfig: {
|
|
18839
18859
|
botUserId: config2.credentials.botUserId ?? ""
|
|
@@ -18843,7 +18863,7 @@ var quantumImPlugin = {
|
|
|
18843
18863
|
pipeline.handle(msg);
|
|
18844
18864
|
});
|
|
18845
18865
|
setMessagePipeGetter(() => instance.messagePipe);
|
|
18846
|
-
setSdkRuntimeGetter(() =>
|
|
18866
|
+
setSdkRuntimeGetter(() => getPluginRuntime());
|
|
18847
18867
|
setTokenManagerGetter(() => instance.tokenManager);
|
|
18848
18868
|
log13.info(`liangzimixin[${ctx.accountId}] started \u2713`);
|
|
18849
18869
|
setTimeout(() => {
|
|
@@ -20476,6 +20496,7 @@ var plugin = {
|
|
|
20476
20496
|
name: "\u91CF\u5B50\u5BC6\u4FE1",
|
|
20477
20497
|
description: "Quantum-encrypted IM channel plugin",
|
|
20478
20498
|
register(api) {
|
|
20499
|
+
setPluginRuntime(api.runtime);
|
|
20479
20500
|
api.registerChannel({ plugin: quantumImPlugin });
|
|
20480
20501
|
log25.info("plugin registered \u2713");
|
|
20481
20502
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/setup-entry.cjs
CHANGED
|
@@ -19609,6 +19609,15 @@ var PushQueue = class {
|
|
|
19609
19609
|
}
|
|
19610
19610
|
};
|
|
19611
19611
|
|
|
19612
|
+
// src/runtime.ts
|
|
19613
|
+
var runtime = null;
|
|
19614
|
+
function getPluginRuntime() {
|
|
19615
|
+
if (!runtime) {
|
|
19616
|
+
throw new Error("PluginRuntime not initialized \u2014 ensure register() has been called");
|
|
19617
|
+
}
|
|
19618
|
+
return runtime;
|
|
19619
|
+
}
|
|
19620
|
+
|
|
19612
19621
|
// src/config-schema.ts
|
|
19613
19622
|
var QUANTUM_IM_CONFIG_JSON_SCHEMA = {
|
|
19614
19623
|
$schema: "http://json-schema.org/draft-07/schema#",
|
|
@@ -19978,7 +19987,7 @@ function buildInboundPayload(msg, resolvedContent, config2) {
|
|
|
19978
19987
|
// 命令检测用
|
|
19979
19988
|
CommandBody: text,
|
|
19980
19989
|
// 命令解析用
|
|
19981
|
-
From: msg.senderId,
|
|
19990
|
+
From: channelAddress(msg.senderId),
|
|
19982
19991
|
To: channelAddress(msg.chatId),
|
|
19983
19992
|
SessionKey: msg.chatId,
|
|
19984
19993
|
// 私聊直接用 chatId 作为会话标识
|
|
@@ -20025,7 +20034,8 @@ function createQuantumImDeliverFn(deps) {
|
|
|
20025
20034
|
});
|
|
20026
20035
|
log23.info("outbound:delivered", {
|
|
20027
20036
|
chatId,
|
|
20028
|
-
length: payload.text.length
|
|
20037
|
+
length: payload.text.length,
|
|
20038
|
+
textPreview: payload.text.slice(0, 200)
|
|
20029
20039
|
});
|
|
20030
20040
|
};
|
|
20031
20041
|
return { deliver };
|
|
@@ -20059,28 +20069,35 @@ var InboundPipeline = class {
|
|
|
20059
20069
|
});
|
|
20060
20070
|
return;
|
|
20061
20071
|
}
|
|
20072
|
+
const core = getPluginRuntime();
|
|
20062
20073
|
const resolvedContent = await resolveContent(context, {
|
|
20063
20074
|
tokenManager: this.deps.tokenManager,
|
|
20064
20075
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
20065
|
-
sdkRuntime:
|
|
20076
|
+
sdkRuntime: core,
|
|
20066
20077
|
maxBytes: this.deps.pluginConfig.file.maxFileSizeMb * 1024 * 1024,
|
|
20067
20078
|
allowPrivateNetwork: this.deps.pluginConfig.file.allowPrivateNetwork,
|
|
20068
20079
|
timeoutMs: this.deps.pluginConfig.file.fetchTimeoutMs
|
|
20069
20080
|
});
|
|
20070
20081
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
20071
|
-
const {
|
|
20072
|
-
const ctx =
|
|
20082
|
+
const { sdkConfig } = this.deps;
|
|
20083
|
+
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
20073
20084
|
const { deliver } = createQuantumImDeliverFn({
|
|
20074
20085
|
messagePipe: this.deps.messagePipe,
|
|
20075
20086
|
chatId: msg.chatId,
|
|
20076
20087
|
senderId: msg.senderId,
|
|
20077
20088
|
replyToMessageId: msg.messageId
|
|
20078
20089
|
});
|
|
20079
|
-
const { dispatcher, replyOptions } =
|
|
20090
|
+
const { dispatcher, replyOptions } = core.channel.reply.createReplyDispatcherWithTyping({
|
|
20080
20091
|
deliver
|
|
20081
20092
|
// TODO: 可选 typingCallbacks (打字指示器)
|
|
20082
20093
|
});
|
|
20083
|
-
|
|
20094
|
+
log24.info("inbound:dispatching", {
|
|
20095
|
+
messageId: msg.messageId,
|
|
20096
|
+
chatId: msg.chatId,
|
|
20097
|
+
sessionKey: msg.chatId,
|
|
20098
|
+
bodyPreview: String(payload.Body ?? "").slice(0, 200)
|
|
20099
|
+
});
|
|
20100
|
+
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
20084
20101
|
ctx,
|
|
20085
20102
|
cfg: sdkConfig,
|
|
20086
20103
|
dispatcher,
|
|
@@ -20104,6 +20121,7 @@ var InboundPipeline = class {
|
|
|
20104
20121
|
chatId: msg.chatId,
|
|
20105
20122
|
step: "handle",
|
|
20106
20123
|
error: err.message,
|
|
20124
|
+
stack: err.stack,
|
|
20107
20125
|
durationMs
|
|
20108
20126
|
});
|
|
20109
20127
|
}
|
|
@@ -20394,7 +20412,6 @@ var quantumImPlugin = {
|
|
|
20394
20412
|
messagePipe: instance.messagePipe,
|
|
20395
20413
|
tokenManager: instance.tokenManager,
|
|
20396
20414
|
pluginConfig: config2,
|
|
20397
|
-
sdkRuntime: ctx.runtime,
|
|
20398
20415
|
sdkConfig: ctx.cfg,
|
|
20399
20416
|
gateConfig: {
|
|
20400
20417
|
botUserId: config2.credentials.botUserId ?? ""
|
|
@@ -20404,7 +20421,7 @@ var quantumImPlugin = {
|
|
|
20404
20421
|
pipeline.handle(msg);
|
|
20405
20422
|
});
|
|
20406
20423
|
setMessagePipeGetter(() => instance.messagePipe);
|
|
20407
|
-
setSdkRuntimeGetter(() =>
|
|
20424
|
+
setSdkRuntimeGetter(() => getPluginRuntime());
|
|
20408
20425
|
setTokenManagerGetter(() => instance.tokenManager);
|
|
20409
20426
|
log25.info(`liangzimixin[${ctx.accountId}] started \u2713`);
|
|
20410
20427
|
setTimeout(() => {
|