csdn-im 0.1.5 → 0.1.7
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 +80 -21
- package/dist/index.js +79 -20
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4505,28 +4505,59 @@ function findRequireAnchorPackageJson() {
|
|
|
4505
4505
|
`${CSDN_LOG_TAG} loadOpenclawPluginSdk: no package.json found walking up from process.cwd(); cannot createRequire for openclaw fallback`
|
|
4506
4506
|
);
|
|
4507
4507
|
}
|
|
4508
|
+
var OPENCLAW_SEARCH_ROOTS = [
|
|
4509
|
+
process.cwd(),
|
|
4510
|
+
(0, import_node_path.join)(process.cwd(), ".."),
|
|
4511
|
+
(0, import_node_path.join)(process.cwd(), "..", ".."),
|
|
4512
|
+
(0, import_node_path.join)(process.cwd(), "packages", "csdn"),
|
|
4513
|
+
(0, import_node_path.join)(process.cwd(), "..", "packages", "csdn")
|
|
4514
|
+
];
|
|
4515
|
+
async function importOpenclawPluginSdkFromDisk() {
|
|
4516
|
+
const require2 = (0, import_node_module.createRequire)(findRequireAnchorPackageJson());
|
|
4517
|
+
for (const root of OPENCLAW_SEARCH_ROOTS) {
|
|
4518
|
+
try {
|
|
4519
|
+
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4520
|
+
const pkgRoot = (0, import_node_path.join)((0, import_node_path.dirname)(mainEntry), "..");
|
|
4521
|
+
const sdkEntry = (0, import_node_path.join)(pkgRoot, "dist", "plugin-sdk", "index.js");
|
|
4522
|
+
return await import((0, import_node_url.pathToFileURL)(sdkEntry).href);
|
|
4523
|
+
} catch {
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
throw new Error(`${CSDN_LOG_TAG} could not resolve openclaw from disk`);
|
|
4527
|
+
}
|
|
4528
|
+
async function importOpenclawReplyRuntimeFromDisk() {
|
|
4529
|
+
const require2 = (0, import_node_module.createRequire)(findRequireAnchorPackageJson());
|
|
4530
|
+
for (const root of OPENCLAW_SEARCH_ROOTS) {
|
|
4531
|
+
try {
|
|
4532
|
+
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4533
|
+
const pkgRoot = (0, import_node_path.join)((0, import_node_path.dirname)(mainEntry), "..");
|
|
4534
|
+
const entry = (0, import_node_path.join)(pkgRoot, "dist", "plugin-sdk", "reply-runtime.js");
|
|
4535
|
+
return await import((0, import_node_url.pathToFileURL)(entry).href);
|
|
4536
|
+
} catch {
|
|
4537
|
+
}
|
|
4538
|
+
}
|
|
4539
|
+
throw new Error(`${CSDN_LOG_TAG} could not resolve openclaw reply-runtime from disk`);
|
|
4540
|
+
}
|
|
4541
|
+
async function loadOpenclawReplyRuntime() {
|
|
4542
|
+
try {
|
|
4543
|
+
return await import("openclaw/plugin-sdk/reply-runtime");
|
|
4544
|
+
} catch (first) {
|
|
4545
|
+
try {
|
|
4546
|
+
return await importOpenclawReplyRuntimeFromDisk();
|
|
4547
|
+
} catch {
|
|
4548
|
+
throw first;
|
|
4549
|
+
}
|
|
4550
|
+
}
|
|
4551
|
+
}
|
|
4508
4552
|
async function loadOpenclawPluginSdk() {
|
|
4509
4553
|
try {
|
|
4510
4554
|
return await import("openclaw/plugin-sdk");
|
|
4511
4555
|
} catch (first) {
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
(0, import_node_path.join)(process.cwd(), "..", ".."),
|
|
4517
|
-
(0, import_node_path.join)(process.cwd(), "packages", "csdn"),
|
|
4518
|
-
(0, import_node_path.join)(process.cwd(), "..", "packages", "csdn")
|
|
4519
|
-
];
|
|
4520
|
-
for (const root of searchRoots) {
|
|
4521
|
-
try {
|
|
4522
|
-
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4523
|
-
const pkgRoot = (0, import_node_path.join)((0, import_node_path.dirname)(mainEntry), "..");
|
|
4524
|
-
const sdkEntry = (0, import_node_path.join)(pkgRoot, "dist", "plugin-sdk", "index.js");
|
|
4525
|
-
return await import((0, import_node_url.pathToFileURL)(sdkEntry).href);
|
|
4526
|
-
} catch {
|
|
4527
|
-
}
|
|
4556
|
+
try {
|
|
4557
|
+
return await importOpenclawPluginSdkFromDisk();
|
|
4558
|
+
} catch {
|
|
4559
|
+
throw first;
|
|
4528
4560
|
}
|
|
4529
|
-
throw first;
|
|
4530
4561
|
}
|
|
4531
4562
|
}
|
|
4532
4563
|
|
|
@@ -4552,8 +4583,13 @@ var csdnOutbound = {
|
|
|
4552
4583
|
}
|
|
4553
4584
|
};
|
|
4554
4585
|
|
|
4586
|
+
// src/silent-reply.ts
|
|
4587
|
+
function isSilentReplyText(text) {
|
|
4588
|
+
if (!text) return false;
|
|
4589
|
+
return /^\s*NO_REPLY\s*$/.test(text);
|
|
4590
|
+
}
|
|
4591
|
+
|
|
4555
4592
|
// src/reply-dispatcher.ts
|
|
4556
|
-
var import_plugin_sdk = require("openclaw/plugin-sdk");
|
|
4557
4593
|
function createCsdnReplyDispatcher(options) {
|
|
4558
4594
|
let sendChain = Promise.resolve();
|
|
4559
4595
|
let pending = 1;
|
|
@@ -4567,7 +4603,7 @@ function createCsdnReplyDispatcher(options) {
|
|
|
4567
4603
|
const text = payload?.text?.trim();
|
|
4568
4604
|
const media = payload?.mediaUrl || (Array.isArray(payload?.mediaUrls) && payload.mediaUrls.length > 0 ? payload.mediaUrls[0] : void 0);
|
|
4569
4605
|
if (!text && !media) return false;
|
|
4570
|
-
if (text &&
|
|
4606
|
+
if (text && isSilentReplyText(text)) return false;
|
|
4571
4607
|
queuedCounts[kind] += 1;
|
|
4572
4608
|
pending += 1;
|
|
4573
4609
|
sendChain = sendChain.then(async () => {
|
|
@@ -4729,12 +4765,35 @@ async function handleCsdnMessage(params) {
|
|
|
4729
4765
|
return;
|
|
4730
4766
|
}
|
|
4731
4767
|
logDispatchFallbackOnce((m) => logger.info(m));
|
|
4768
|
+
let replyRuntime;
|
|
4769
|
+
try {
|
|
4770
|
+
replyRuntime = await loadOpenclawReplyRuntime();
|
|
4771
|
+
} catch {
|
|
4772
|
+
replyRuntime = void 0;
|
|
4773
|
+
}
|
|
4774
|
+
if (replyRuntime && typeof replyRuntime.dispatchInboundMessage === "function") {
|
|
4775
|
+
try {
|
|
4776
|
+
if (verbose) {
|
|
4777
|
+
logger.info(`dispatching via plugin-sdk/reply-runtime session=${route.sessionKey}`);
|
|
4778
|
+
}
|
|
4779
|
+
await replyRuntime.dispatchInboundMessage({
|
|
4780
|
+
ctx: inboundCtx,
|
|
4781
|
+
cfg: config,
|
|
4782
|
+
dispatcher,
|
|
4783
|
+
replyOptions: {}
|
|
4784
|
+
});
|
|
4785
|
+
return;
|
|
4786
|
+
} catch (err) {
|
|
4787
|
+
logger.error(`plugin-sdk/reply-runtime dispatch failed: ${String(err)}`);
|
|
4788
|
+
throw err;
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4732
4791
|
try {
|
|
4733
4792
|
const sdk = await loadOpenclawPluginSdk();
|
|
4734
4793
|
const withSettled = sdk.dispatchReplyFromConfigWithSettledDispatcher;
|
|
4735
4794
|
const plain = sdk.dispatchReplyFromConfig;
|
|
4736
4795
|
if (verbose) {
|
|
4737
|
-
logger.info(`dispatching via plugin-sdk session=${route.sessionKey}`);
|
|
4796
|
+
logger.info(`dispatching via plugin-sdk (legacy barrel) session=${route.sessionKey}`);
|
|
4738
4797
|
}
|
|
4739
4798
|
if (typeof withSettled === "function") {
|
|
4740
4799
|
await withSettled({
|
|
@@ -4754,7 +4813,7 @@ async function handleCsdnMessage(params) {
|
|
|
4754
4813
|
});
|
|
4755
4814
|
} else {
|
|
4756
4815
|
throw new Error(
|
|
4757
|
-
"openclaw
|
|
4816
|
+
"openclaw: no channel dispatch API (need plugin-sdk/reply-runtime.dispatchInboundMessage or legacy dispatchReplyFromConfig on plugin-sdk barrel)"
|
|
4758
4817
|
);
|
|
4759
4818
|
}
|
|
4760
4819
|
} catch (err) {
|
package/dist/index.js
CHANGED
|
@@ -4474,28 +4474,59 @@ function findRequireAnchorPackageJson() {
|
|
|
4474
4474
|
`${CSDN_LOG_TAG} loadOpenclawPluginSdk: no package.json found walking up from process.cwd(); cannot createRequire for openclaw fallback`
|
|
4475
4475
|
);
|
|
4476
4476
|
}
|
|
4477
|
+
var OPENCLAW_SEARCH_ROOTS = [
|
|
4478
|
+
process.cwd(),
|
|
4479
|
+
join(process.cwd(), ".."),
|
|
4480
|
+
join(process.cwd(), "..", ".."),
|
|
4481
|
+
join(process.cwd(), "packages", "csdn"),
|
|
4482
|
+
join(process.cwd(), "..", "packages", "csdn")
|
|
4483
|
+
];
|
|
4484
|
+
async function importOpenclawPluginSdkFromDisk() {
|
|
4485
|
+
const require2 = createRequire(findRequireAnchorPackageJson());
|
|
4486
|
+
for (const root of OPENCLAW_SEARCH_ROOTS) {
|
|
4487
|
+
try {
|
|
4488
|
+
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4489
|
+
const pkgRoot = join(dirname(mainEntry), "..");
|
|
4490
|
+
const sdkEntry = join(pkgRoot, "dist", "plugin-sdk", "index.js");
|
|
4491
|
+
return await import(pathToFileURL(sdkEntry).href);
|
|
4492
|
+
} catch {
|
|
4493
|
+
}
|
|
4494
|
+
}
|
|
4495
|
+
throw new Error(`${CSDN_LOG_TAG} could not resolve openclaw from disk`);
|
|
4496
|
+
}
|
|
4497
|
+
async function importOpenclawReplyRuntimeFromDisk() {
|
|
4498
|
+
const require2 = createRequire(findRequireAnchorPackageJson());
|
|
4499
|
+
for (const root of OPENCLAW_SEARCH_ROOTS) {
|
|
4500
|
+
try {
|
|
4501
|
+
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4502
|
+
const pkgRoot = join(dirname(mainEntry), "..");
|
|
4503
|
+
const entry = join(pkgRoot, "dist", "plugin-sdk", "reply-runtime.js");
|
|
4504
|
+
return await import(pathToFileURL(entry).href);
|
|
4505
|
+
} catch {
|
|
4506
|
+
}
|
|
4507
|
+
}
|
|
4508
|
+
throw new Error(`${CSDN_LOG_TAG} could not resolve openclaw reply-runtime from disk`);
|
|
4509
|
+
}
|
|
4510
|
+
async function loadOpenclawReplyRuntime() {
|
|
4511
|
+
try {
|
|
4512
|
+
return await import("openclaw/plugin-sdk/reply-runtime");
|
|
4513
|
+
} catch (first) {
|
|
4514
|
+
try {
|
|
4515
|
+
return await importOpenclawReplyRuntimeFromDisk();
|
|
4516
|
+
} catch {
|
|
4517
|
+
throw first;
|
|
4518
|
+
}
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4477
4521
|
async function loadOpenclawPluginSdk() {
|
|
4478
4522
|
try {
|
|
4479
4523
|
return await import("openclaw/plugin-sdk");
|
|
4480
4524
|
} catch (first) {
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
join(process.cwd(), "..", ".."),
|
|
4486
|
-
join(process.cwd(), "packages", "csdn"),
|
|
4487
|
-
join(process.cwd(), "..", "packages", "csdn")
|
|
4488
|
-
];
|
|
4489
|
-
for (const root of searchRoots) {
|
|
4490
|
-
try {
|
|
4491
|
-
const mainEntry = require2.resolve("openclaw", { paths: [root] });
|
|
4492
|
-
const pkgRoot = join(dirname(mainEntry), "..");
|
|
4493
|
-
const sdkEntry = join(pkgRoot, "dist", "plugin-sdk", "index.js");
|
|
4494
|
-
return await import(pathToFileURL(sdkEntry).href);
|
|
4495
|
-
} catch {
|
|
4496
|
-
}
|
|
4525
|
+
try {
|
|
4526
|
+
return await importOpenclawPluginSdkFromDisk();
|
|
4527
|
+
} catch {
|
|
4528
|
+
throw first;
|
|
4497
4529
|
}
|
|
4498
|
-
throw first;
|
|
4499
4530
|
}
|
|
4500
4531
|
}
|
|
4501
4532
|
|
|
@@ -4521,8 +4552,13 @@ var csdnOutbound = {
|
|
|
4521
4552
|
}
|
|
4522
4553
|
};
|
|
4523
4554
|
|
|
4555
|
+
// src/silent-reply.ts
|
|
4556
|
+
function isSilentReplyText(text) {
|
|
4557
|
+
if (!text) return false;
|
|
4558
|
+
return /^\s*NO_REPLY\s*$/.test(text);
|
|
4559
|
+
}
|
|
4560
|
+
|
|
4524
4561
|
// src/reply-dispatcher.ts
|
|
4525
|
-
import { isSilentReplyText } from "openclaw/plugin-sdk";
|
|
4526
4562
|
function createCsdnReplyDispatcher(options) {
|
|
4527
4563
|
let sendChain = Promise.resolve();
|
|
4528
4564
|
let pending = 1;
|
|
@@ -4698,12 +4734,35 @@ async function handleCsdnMessage(params) {
|
|
|
4698
4734
|
return;
|
|
4699
4735
|
}
|
|
4700
4736
|
logDispatchFallbackOnce((m) => logger.info(m));
|
|
4737
|
+
let replyRuntime;
|
|
4738
|
+
try {
|
|
4739
|
+
replyRuntime = await loadOpenclawReplyRuntime();
|
|
4740
|
+
} catch {
|
|
4741
|
+
replyRuntime = void 0;
|
|
4742
|
+
}
|
|
4743
|
+
if (replyRuntime && typeof replyRuntime.dispatchInboundMessage === "function") {
|
|
4744
|
+
try {
|
|
4745
|
+
if (verbose) {
|
|
4746
|
+
logger.info(`dispatching via plugin-sdk/reply-runtime session=${route.sessionKey}`);
|
|
4747
|
+
}
|
|
4748
|
+
await replyRuntime.dispatchInboundMessage({
|
|
4749
|
+
ctx: inboundCtx,
|
|
4750
|
+
cfg: config,
|
|
4751
|
+
dispatcher,
|
|
4752
|
+
replyOptions: {}
|
|
4753
|
+
});
|
|
4754
|
+
return;
|
|
4755
|
+
} catch (err) {
|
|
4756
|
+
logger.error(`plugin-sdk/reply-runtime dispatch failed: ${String(err)}`);
|
|
4757
|
+
throw err;
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4701
4760
|
try {
|
|
4702
4761
|
const sdk = await loadOpenclawPluginSdk();
|
|
4703
4762
|
const withSettled = sdk.dispatchReplyFromConfigWithSettledDispatcher;
|
|
4704
4763
|
const plain = sdk.dispatchReplyFromConfig;
|
|
4705
4764
|
if (verbose) {
|
|
4706
|
-
logger.info(`dispatching via plugin-sdk session=${route.sessionKey}`);
|
|
4765
|
+
logger.info(`dispatching via plugin-sdk (legacy barrel) session=${route.sessionKey}`);
|
|
4707
4766
|
}
|
|
4708
4767
|
if (typeof withSettled === "function") {
|
|
4709
4768
|
await withSettled({
|
|
@@ -4723,7 +4782,7 @@ async function handleCsdnMessage(params) {
|
|
|
4723
4782
|
});
|
|
4724
4783
|
} else {
|
|
4725
4784
|
throw new Error(
|
|
4726
|
-
"openclaw
|
|
4785
|
+
"openclaw: no channel dispatch API (need plugin-sdk/reply-runtime.dispatchInboundMessage or legacy dispatchReplyFromConfig on plugin-sdk barrel)"
|
|
4727
4786
|
);
|
|
4728
4787
|
}
|
|
4729
4788
|
} catch (err) {
|