@elizaos/plugin-knowledge 1.2.2 → 1.2.3
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/.vite/manifest.json +1 -1
- package/dist/assets/{index-YT4-1nM5.js → index-C_sAxTPC.js} +38 -38
- package/dist/index.html +1 -1
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Agent Plugin View</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-C_sAxTPC.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-B5VEkqpw.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -4534,22 +4534,27 @@ async function getKnowledgeByIdHandler(req, res, runtime) {
|
|
|
4534
4534
|
async function knowledgePanelHandler(req, res, runtime) {
|
|
4535
4535
|
const agentId = runtime.agentId;
|
|
4536
4536
|
logger9.debug(`[Document Processor] \u{1F310} Serving knowledge panel for agent ${agentId}`);
|
|
4537
|
+
const requestPath = req.originalUrl || req.url || req.path;
|
|
4538
|
+
const pluginBasePath = requestPath.replace(/\/display.*$/, "");
|
|
4539
|
+
logger9.debug(`[Document Processor] \u{1F310} Plugin base path: ${pluginBasePath}`);
|
|
4537
4540
|
try {
|
|
4538
4541
|
const currentDir = path4.dirname(new URL(import.meta.url).pathname);
|
|
4539
4542
|
const frontendPath = path4.join(currentDir, "../dist/index.html");
|
|
4540
4543
|
logger9.debug(`[Document Processor] \u{1F310} Looking for frontend at: ${frontendPath}`);
|
|
4541
4544
|
if (fs4.existsSync(frontendPath)) {
|
|
4542
4545
|
const html = await fs4.promises.readFile(frontendPath, "utf8");
|
|
4543
|
-
|
|
4546
|
+
let injectedHtml = html.replace(
|
|
4544
4547
|
"<head>",
|
|
4545
4548
|
`<head>
|
|
4546
4549
|
<script>
|
|
4547
4550
|
window.ELIZA_CONFIG = {
|
|
4548
4551
|
agentId: '${agentId}',
|
|
4549
|
-
apiBase: '
|
|
4552
|
+
apiBase: '${pluginBasePath}'
|
|
4550
4553
|
};
|
|
4551
4554
|
</script>`
|
|
4552
4555
|
);
|
|
4556
|
+
injectedHtml = injectedHtml.replace(/src="\.\/assets\//g, `src="${pluginBasePath}/assets/`);
|
|
4557
|
+
injectedHtml = injectedHtml.replace(/href="\.\/assets\//g, `href="${pluginBasePath}/assets/`);
|
|
4553
4558
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
4554
4559
|
res.end(injectedHtml);
|
|
4555
4560
|
} else {
|
|
@@ -4585,10 +4590,10 @@ async function knowledgePanelHandler(req, res, runtime) {
|
|
|
4585
4590
|
<script>
|
|
4586
4591
|
window.ELIZA_CONFIG = {
|
|
4587
4592
|
agentId: '${agentId}',
|
|
4588
|
-
apiBase: '
|
|
4593
|
+
apiBase: '${pluginBasePath}'
|
|
4589
4594
|
};
|
|
4590
4595
|
</script>
|
|
4591
|
-
<link rel="stylesheet" href="
|
|
4596
|
+
<link rel="stylesheet" href="${pluginBasePath}/assets/${cssFile}">
|
|
4592
4597
|
<style>
|
|
4593
4598
|
body { font-family: system-ui, -apple-system, sans-serif; margin: 0; padding: 20px; }
|
|
4594
4599
|
.container { max-width: 1200px; margin: 0 auto; }
|
|
@@ -4601,7 +4606,7 @@ async function knowledgePanelHandler(req, res, runtime) {
|
|
|
4601
4606
|
<div class="loading">Loading Knowledge Library...</div>
|
|
4602
4607
|
</div>
|
|
4603
4608
|
</div>
|
|
4604
|
-
<script type="module" src="
|
|
4609
|
+
<script type="module" src="${pluginBasePath}/assets/${jsFile}"></script>
|
|
4605
4610
|
</body>
|
|
4606
4611
|
</html>`;
|
|
4607
4612
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
@@ -4614,21 +4619,25 @@ async function knowledgePanelHandler(req, res, runtime) {
|
|
|
4614
4619
|
}
|
|
4615
4620
|
async function frontendAssetHandler(req, res, runtime) {
|
|
4616
4621
|
try {
|
|
4617
|
-
|
|
4622
|
+
const fullPath = req.originalUrl || req.url || req.path;
|
|
4623
|
+
logger9.debug(`[Document Processor] \u{1F310} Asset request: ${fullPath}`);
|
|
4618
4624
|
const currentDir = path4.dirname(new URL(import.meta.url).pathname);
|
|
4619
|
-
const assetRequestPath = req.path;
|
|
4620
4625
|
const assetsMarker = "/assets/";
|
|
4621
|
-
const assetsStartIndex =
|
|
4626
|
+
const assetsStartIndex = fullPath.lastIndexOf(assetsMarker);
|
|
4622
4627
|
let assetName = null;
|
|
4623
4628
|
if (assetsStartIndex !== -1) {
|
|
4624
|
-
assetName =
|
|
4629
|
+
assetName = fullPath.substring(assetsStartIndex + assetsMarker.length);
|
|
4630
|
+
const queryIndex = assetName.indexOf("?");
|
|
4631
|
+
if (queryIndex !== -1) {
|
|
4632
|
+
assetName = assetName.substring(0, queryIndex);
|
|
4633
|
+
}
|
|
4625
4634
|
}
|
|
4626
4635
|
if (!assetName || assetName.includes("..")) {
|
|
4627
4636
|
return sendError(
|
|
4628
4637
|
res,
|
|
4629
4638
|
400,
|
|
4630
4639
|
"BAD_REQUEST",
|
|
4631
|
-
`Invalid asset name: '${assetName}' from path ${
|
|
4640
|
+
`Invalid asset name: '${assetName}' from path ${fullPath}`
|
|
4632
4641
|
);
|
|
4633
4642
|
}
|
|
4634
4643
|
const assetPath = path4.join(currentDir, "../dist/assets", assetName);
|