liangzimixin 0.3.7 → 0.3.8
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 +27 -8
- package/dist/index.d.cts +1 -0
- package/dist/setup-entry.cjs +23 -8
- 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 作为会话标识
|
|
@@ -18415,6 +18415,18 @@ function createQuantumImDeliverFn(deps) {
|
|
|
18415
18415
|
return { deliver };
|
|
18416
18416
|
}
|
|
18417
18417
|
|
|
18418
|
+
// src/runtime.ts
|
|
18419
|
+
var runtime = null;
|
|
18420
|
+
function setPluginRuntime(next) {
|
|
18421
|
+
runtime = next;
|
|
18422
|
+
}
|
|
18423
|
+
function getPluginRuntime() {
|
|
18424
|
+
if (!runtime) {
|
|
18425
|
+
throw new Error("PluginRuntime not initialized \u2014 ensure register() has been called");
|
|
18426
|
+
}
|
|
18427
|
+
return runtime;
|
|
18428
|
+
}
|
|
18429
|
+
|
|
18418
18430
|
// src/message-handler/handler.ts
|
|
18419
18431
|
var log12 = createLogger("message-handler/handler");
|
|
18420
18432
|
var InboundPipeline = class {
|
|
@@ -18443,28 +18455,34 @@ var InboundPipeline = class {
|
|
|
18443
18455
|
});
|
|
18444
18456
|
return;
|
|
18445
18457
|
}
|
|
18458
|
+
const core = getPluginRuntime();
|
|
18446
18459
|
const resolvedContent = await resolveContent(context, {
|
|
18447
18460
|
tokenManager: this.deps.tokenManager,
|
|
18448
18461
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
18449
|
-
sdkRuntime:
|
|
18462
|
+
sdkRuntime: core,
|
|
18450
18463
|
maxBytes: this.deps.pluginConfig.file.maxFileSizeMb * 1024 * 1024,
|
|
18451
18464
|
allowPrivateNetwork: this.deps.pluginConfig.file.allowPrivateNetwork,
|
|
18452
18465
|
timeoutMs: this.deps.pluginConfig.file.fetchTimeoutMs
|
|
18453
18466
|
});
|
|
18454
18467
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
18455
|
-
const {
|
|
18456
|
-
const ctx =
|
|
18468
|
+
const { sdkConfig } = this.deps;
|
|
18469
|
+
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
18457
18470
|
const { deliver } = createQuantumImDeliverFn({
|
|
18458
18471
|
messagePipe: this.deps.messagePipe,
|
|
18459
18472
|
chatId: msg.chatId,
|
|
18460
18473
|
senderId: msg.senderId,
|
|
18461
18474
|
replyToMessageId: msg.messageId
|
|
18462
18475
|
});
|
|
18463
|
-
const { dispatcher, replyOptions } =
|
|
18476
|
+
const { dispatcher, replyOptions } = core.channel.reply.createReplyDispatcherWithTyping({
|
|
18464
18477
|
deliver
|
|
18465
18478
|
// TODO: 可选 typingCallbacks (打字指示器)
|
|
18466
18479
|
});
|
|
18467
|
-
|
|
18480
|
+
log12.info("inbound:dispatching", {
|
|
18481
|
+
messageId: msg.messageId,
|
|
18482
|
+
chatId: msg.chatId,
|
|
18483
|
+
sessionKey: msg.chatId
|
|
18484
|
+
});
|
|
18485
|
+
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
18468
18486
|
ctx,
|
|
18469
18487
|
cfg: sdkConfig,
|
|
18470
18488
|
dispatcher,
|
|
@@ -18488,6 +18506,7 @@ var InboundPipeline = class {
|
|
|
18488
18506
|
chatId: msg.chatId,
|
|
18489
18507
|
step: "handle",
|
|
18490
18508
|
error: err.message,
|
|
18509
|
+
stack: err.stack,
|
|
18491
18510
|
durationMs
|
|
18492
18511
|
});
|
|
18493
18512
|
}
|
|
@@ -18833,7 +18852,6 @@ var quantumImPlugin = {
|
|
|
18833
18852
|
messagePipe: instance.messagePipe,
|
|
18834
18853
|
tokenManager: instance.tokenManager,
|
|
18835
18854
|
pluginConfig: config2,
|
|
18836
|
-
sdkRuntime: ctx.runtime,
|
|
18837
18855
|
sdkConfig: ctx.cfg,
|
|
18838
18856
|
gateConfig: {
|
|
18839
18857
|
botUserId: config2.credentials.botUserId ?? ""
|
|
@@ -18843,7 +18861,7 @@ var quantumImPlugin = {
|
|
|
18843
18861
|
pipeline.handle(msg);
|
|
18844
18862
|
});
|
|
18845
18863
|
setMessagePipeGetter(() => instance.messagePipe);
|
|
18846
|
-
setSdkRuntimeGetter(() =>
|
|
18864
|
+
setSdkRuntimeGetter(() => getPluginRuntime());
|
|
18847
18865
|
setTokenManagerGetter(() => instance.tokenManager);
|
|
18848
18866
|
log13.info(`liangzimixin[${ctx.accountId}] started \u2713`);
|
|
18849
18867
|
setTimeout(() => {
|
|
@@ -20476,6 +20494,7 @@ var plugin = {
|
|
|
20476
20494
|
name: "\u91CF\u5B50\u5BC6\u4FE1",
|
|
20477
20495
|
description: "Quantum-encrypted IM channel plugin",
|
|
20478
20496
|
register(api) {
|
|
20497
|
+
setPluginRuntime(api.runtime);
|
|
20479
20498
|
api.registerChannel({ plugin: quantumImPlugin });
|
|
20480
20499
|
log25.info("plugin registered \u2713");
|
|
20481
20500
|
}
|
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 作为会话标识
|
|
@@ -20059,28 +20068,34 @@ var InboundPipeline = class {
|
|
|
20059
20068
|
});
|
|
20060
20069
|
return;
|
|
20061
20070
|
}
|
|
20071
|
+
const core = getPluginRuntime();
|
|
20062
20072
|
const resolvedContent = await resolveContent(context, {
|
|
20063
20073
|
tokenManager: this.deps.tokenManager,
|
|
20064
20074
|
fileServerUrl: this.deps.pluginConfig.file.fileServiceBaseUrl,
|
|
20065
|
-
sdkRuntime:
|
|
20075
|
+
sdkRuntime: core,
|
|
20066
20076
|
maxBytes: this.deps.pluginConfig.file.maxFileSizeMb * 1024 * 1024,
|
|
20067
20077
|
allowPrivateNetwork: this.deps.pluginConfig.file.allowPrivateNetwork,
|
|
20068
20078
|
timeoutMs: this.deps.pluginConfig.file.fetchTimeoutMs
|
|
20069
20079
|
});
|
|
20070
20080
|
const payload = buildInboundPayload(msg, resolvedContent, this.deps.pluginConfig);
|
|
20071
|
-
const {
|
|
20072
|
-
const ctx =
|
|
20081
|
+
const { sdkConfig } = this.deps;
|
|
20082
|
+
const ctx = core.channel.reply.finalizeInboundContext(payload);
|
|
20073
20083
|
const { deliver } = createQuantumImDeliverFn({
|
|
20074
20084
|
messagePipe: this.deps.messagePipe,
|
|
20075
20085
|
chatId: msg.chatId,
|
|
20076
20086
|
senderId: msg.senderId,
|
|
20077
20087
|
replyToMessageId: msg.messageId
|
|
20078
20088
|
});
|
|
20079
|
-
const { dispatcher, replyOptions } =
|
|
20089
|
+
const { dispatcher, replyOptions } = core.channel.reply.createReplyDispatcherWithTyping({
|
|
20080
20090
|
deliver
|
|
20081
20091
|
// TODO: 可选 typingCallbacks (打字指示器)
|
|
20082
20092
|
});
|
|
20083
|
-
|
|
20093
|
+
log24.info("inbound:dispatching", {
|
|
20094
|
+
messageId: msg.messageId,
|
|
20095
|
+
chatId: msg.chatId,
|
|
20096
|
+
sessionKey: msg.chatId
|
|
20097
|
+
});
|
|
20098
|
+
const { counts } = await core.channel.reply.dispatchReplyFromConfig({
|
|
20084
20099
|
ctx,
|
|
20085
20100
|
cfg: sdkConfig,
|
|
20086
20101
|
dispatcher,
|
|
@@ -20104,6 +20119,7 @@ var InboundPipeline = class {
|
|
|
20104
20119
|
chatId: msg.chatId,
|
|
20105
20120
|
step: "handle",
|
|
20106
20121
|
error: err.message,
|
|
20122
|
+
stack: err.stack,
|
|
20107
20123
|
durationMs
|
|
20108
20124
|
});
|
|
20109
20125
|
}
|
|
@@ -20394,7 +20410,6 @@ var quantumImPlugin = {
|
|
|
20394
20410
|
messagePipe: instance.messagePipe,
|
|
20395
20411
|
tokenManager: instance.tokenManager,
|
|
20396
20412
|
pluginConfig: config2,
|
|
20397
|
-
sdkRuntime: ctx.runtime,
|
|
20398
20413
|
sdkConfig: ctx.cfg,
|
|
20399
20414
|
gateConfig: {
|
|
20400
20415
|
botUserId: config2.credentials.botUserId ?? ""
|
|
@@ -20404,7 +20419,7 @@ var quantumImPlugin = {
|
|
|
20404
20419
|
pipeline.handle(msg);
|
|
20405
20420
|
});
|
|
20406
20421
|
setMessagePipeGetter(() => instance.messagePipe);
|
|
20407
|
-
setSdkRuntimeGetter(() =>
|
|
20422
|
+
setSdkRuntimeGetter(() => getPluginRuntime());
|
|
20408
20423
|
setTokenManagerGetter(() => instance.tokenManager);
|
|
20409
20424
|
log25.info(`liangzimixin[${ctx.accountId}] started \u2713`);
|
|
20410
20425
|
setTimeout(() => {
|