@elizaos/plugin-knowledge 1.2.0 → 1.2.1
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/README.md +1 -1
- package/dist/.vite/manifest.json +1 -1
- package/dist/assets/{index-DlOvU00u.js → index-YT4-1nM5.js} +38 -38
- package/dist/index.d.ts +42 -14
- package/dist/index.html +1 -1
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -2,16 +2,8 @@ import { UUID, Plugin } from '@elizaos/core';
|
|
|
2
2
|
import z from 'zod';
|
|
3
3
|
|
|
4
4
|
declare const ModelConfigSchema: z.ZodObject<{
|
|
5
|
-
EMBEDDING_PROVIDER: z.ZodOptional<z.ZodEnum<
|
|
6
|
-
|
|
7
|
-
google: "google";
|
|
8
|
-
}>>;
|
|
9
|
-
TEXT_PROVIDER: z.ZodOptional<z.ZodEnum<{
|
|
10
|
-
openai: "openai";
|
|
11
|
-
google: "google";
|
|
12
|
-
anthropic: "anthropic";
|
|
13
|
-
openrouter: "openrouter";
|
|
14
|
-
}>>;
|
|
5
|
+
EMBEDDING_PROVIDER: z.ZodOptional<z.ZodEnum<["openai", "google"]>>;
|
|
6
|
+
TEXT_PROVIDER: z.ZodOptional<z.ZodEnum<["openai", "anthropic", "openrouter", "google"]>>;
|
|
15
7
|
OPENAI_API_KEY: z.ZodOptional<z.ZodString>;
|
|
16
8
|
ANTHROPIC_API_KEY: z.ZodOptional<z.ZodString>;
|
|
17
9
|
OPENROUTER_API_KEY: z.ZodOptional<z.ZodString>;
|
|
@@ -22,12 +14,48 @@ declare const ModelConfigSchema: z.ZodObject<{
|
|
|
22
14
|
GOOGLE_BASE_URL: z.ZodOptional<z.ZodString>;
|
|
23
15
|
TEXT_EMBEDDING_MODEL: z.ZodString;
|
|
24
16
|
TEXT_MODEL: z.ZodOptional<z.ZodString>;
|
|
25
|
-
MAX_INPUT_TOKENS: z.
|
|
26
|
-
MAX_OUTPUT_TOKENS: z.
|
|
27
|
-
EMBEDDING_DIMENSION: z.
|
|
17
|
+
MAX_INPUT_TOKENS: z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodNumber]>, number, string | number>;
|
|
18
|
+
MAX_OUTPUT_TOKENS: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
19
|
+
EMBEDDING_DIMENSION: z.ZodEffects<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>, number, string | number | undefined>;
|
|
28
20
|
LOAD_DOCS_ON_STARTUP: z.ZodDefault<z.ZodBoolean>;
|
|
29
21
|
CTX_KNOWLEDGE_ENABLED: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
-
}, z.
|
|
22
|
+
}, "strip", z.ZodTypeAny, {
|
|
23
|
+
TEXT_EMBEDDING_MODEL: string;
|
|
24
|
+
MAX_INPUT_TOKENS: number;
|
|
25
|
+
MAX_OUTPUT_TOKENS: number;
|
|
26
|
+
EMBEDDING_DIMENSION: number;
|
|
27
|
+
LOAD_DOCS_ON_STARTUP: boolean;
|
|
28
|
+
CTX_KNOWLEDGE_ENABLED: boolean;
|
|
29
|
+
EMBEDDING_PROVIDER?: "openai" | "google" | undefined;
|
|
30
|
+
TEXT_PROVIDER?: "openai" | "google" | "anthropic" | "openrouter" | undefined;
|
|
31
|
+
OPENAI_API_KEY?: string | undefined;
|
|
32
|
+
ANTHROPIC_API_KEY?: string | undefined;
|
|
33
|
+
OPENROUTER_API_KEY?: string | undefined;
|
|
34
|
+
GOOGLE_API_KEY?: string | undefined;
|
|
35
|
+
OPENAI_BASE_URL?: string | undefined;
|
|
36
|
+
ANTHROPIC_BASE_URL?: string | undefined;
|
|
37
|
+
OPENROUTER_BASE_URL?: string | undefined;
|
|
38
|
+
GOOGLE_BASE_URL?: string | undefined;
|
|
39
|
+
TEXT_MODEL?: string | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
TEXT_EMBEDDING_MODEL: string;
|
|
42
|
+
MAX_INPUT_TOKENS: string | number;
|
|
43
|
+
EMBEDDING_PROVIDER?: "openai" | "google" | undefined;
|
|
44
|
+
TEXT_PROVIDER?: "openai" | "google" | "anthropic" | "openrouter" | undefined;
|
|
45
|
+
OPENAI_API_KEY?: string | undefined;
|
|
46
|
+
ANTHROPIC_API_KEY?: string | undefined;
|
|
47
|
+
OPENROUTER_API_KEY?: string | undefined;
|
|
48
|
+
GOOGLE_API_KEY?: string | undefined;
|
|
49
|
+
OPENAI_BASE_URL?: string | undefined;
|
|
50
|
+
ANTHROPIC_BASE_URL?: string | undefined;
|
|
51
|
+
OPENROUTER_BASE_URL?: string | undefined;
|
|
52
|
+
GOOGLE_BASE_URL?: string | undefined;
|
|
53
|
+
TEXT_MODEL?: string | undefined;
|
|
54
|
+
MAX_OUTPUT_TOKENS?: string | number | undefined;
|
|
55
|
+
EMBEDDING_DIMENSION?: string | number | undefined;
|
|
56
|
+
LOAD_DOCS_ON_STARTUP?: boolean | undefined;
|
|
57
|
+
CTX_KNOWLEDGE_ENABLED?: boolean | undefined;
|
|
58
|
+
}>;
|
|
31
59
|
type ModelConfig = z.infer<typeof ModelConfigSchema>;
|
|
32
60
|
/**
|
|
33
61
|
* Interface for provider rate limits
|
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-YT4-1nM5.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-B5VEkqpw.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/index.js
CHANGED
|
@@ -2053,27 +2053,25 @@ function logKnowledgeGenerationSummary({
|
|
|
2053
2053
|
import { logger as logger5 } from "@elizaos/core";
|
|
2054
2054
|
import * as fs from "fs";
|
|
2055
2055
|
import * as path from "path";
|
|
2056
|
-
function getKnowledgePath() {
|
|
2057
|
-
const
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2056
|
+
function getKnowledgePath(runtimePath) {
|
|
2057
|
+
const knowledgePath = runtimePath || process.env.KNOWLEDGE_PATH || path.join(process.cwd(), "docs");
|
|
2058
|
+
const resolvedPath = path.resolve(knowledgePath);
|
|
2059
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
2060
|
+
logger5.warn(`Knowledge path does not exist: ${resolvedPath}`);
|
|
2061
|
+
if (runtimePath) {
|
|
2062
|
+
logger5.warn("Please create the directory or update KNOWLEDGE_PATH in agent settings");
|
|
2063
|
+
} else if (process.env.KNOWLEDGE_PATH) {
|
|
2062
2064
|
logger5.warn("Please create the directory or update KNOWLEDGE_PATH environment variable");
|
|
2065
|
+
} else {
|
|
2066
|
+
logger5.info("To use the knowledge plugin, either:");
|
|
2067
|
+
logger5.info('1. Create a "docs" folder in your project root');
|
|
2068
|
+
logger5.info("2. Set KNOWLEDGE_PATH in agent settings or environment variable");
|
|
2063
2069
|
}
|
|
2064
|
-
return resolvedPath;
|
|
2065
|
-
}
|
|
2066
|
-
const defaultPath = path.join(process.cwd(), "docs");
|
|
2067
|
-
if (!fs.existsSync(defaultPath)) {
|
|
2068
|
-
logger5.info(`Default docs folder does not exist at: ${defaultPath}`);
|
|
2069
|
-
logger5.info("To use the knowledge plugin, either:");
|
|
2070
|
-
logger5.info('1. Create a "docs" folder in your project root');
|
|
2071
|
-
logger5.info("2. Set KNOWLEDGE_PATH environment variable to your documents folder");
|
|
2072
2070
|
}
|
|
2073
|
-
return
|
|
2071
|
+
return resolvedPath;
|
|
2074
2072
|
}
|
|
2075
|
-
async function loadDocsFromPath(service, agentId, worldId) {
|
|
2076
|
-
const docsPath = getKnowledgePath();
|
|
2073
|
+
async function loadDocsFromPath(service, agentId, worldId, knowledgePath) {
|
|
2074
|
+
const docsPath = getKnowledgePath(knowledgePath);
|
|
2077
2075
|
if (!fs.existsSync(docsPath)) {
|
|
2078
2076
|
logger5.warn(`Knowledge path does not exist: ${docsPath}`);
|
|
2079
2077
|
return { total: 0, successful: 0, failed: 0 };
|
|
@@ -2282,7 +2280,14 @@ var KnowledgeService = class _KnowledgeService extends Service {
|
|
|
2282
2280
|
);
|
|
2283
2281
|
try {
|
|
2284
2282
|
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
2285
|
-
const
|
|
2283
|
+
const knowledgePath = this.runtime.getSetting("KNOWLEDGE_PATH");
|
|
2284
|
+
const result = await loadDocsFromPath(
|
|
2285
|
+
this,
|
|
2286
|
+
this.runtime.agentId,
|
|
2287
|
+
void 0,
|
|
2288
|
+
// worldId
|
|
2289
|
+
knowledgePath
|
|
2290
|
+
);
|
|
2286
2291
|
if (result.successful > 0) {
|
|
2287
2292
|
logger6.info(
|
|
2288
2293
|
`KnowledgeService: Loaded ${result.successful} documents from docs folder on startup for agent ${this.runtime.agentId}`
|