@elizaos/plugin-knowledge 1.0.0-beta.71 → 1.0.0-beta.73

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.d.ts CHANGED
@@ -1,4 +1,156 @@
1
- import { Plugin } from '@elizaos/core';
1
+ import { UUID, Plugin } from '@elizaos/core';
2
+ import z from 'zod';
3
+
4
+ declare const ModelConfigSchema: z.ZodObject<{
5
+ EMBEDDING_PROVIDER: z.ZodEnum<["openai", "google"]>;
6
+ TEXT_PROVIDER: z.ZodOptional<z.ZodEnum<["openai", "anthropic", "openrouter", "google"]>>;
7
+ OPENAI_API_KEY: z.ZodOptional<z.ZodString>;
8
+ ANTHROPIC_API_KEY: z.ZodOptional<z.ZodString>;
9
+ OPENROUTER_API_KEY: z.ZodOptional<z.ZodString>;
10
+ GOOGLE_API_KEY: z.ZodOptional<z.ZodString>;
11
+ OPENAI_BASE_URL: z.ZodOptional<z.ZodString>;
12
+ ANTHROPIC_BASE_URL: z.ZodOptional<z.ZodString>;
13
+ OPENROUTER_BASE_URL: z.ZodOptional<z.ZodString>;
14
+ GOOGLE_BASE_URL: z.ZodOptional<z.ZodString>;
15
+ TEXT_EMBEDDING_MODEL: z.ZodString;
16
+ TEXT_MODEL: z.ZodOptional<z.ZodString>;
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>;
20
+ CTX_KNOWLEDGE_ENABLED: z.ZodDefault<z.ZodBoolean>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ MAX_INPUT_TOKENS: number;
23
+ MAX_OUTPUT_TOKENS: number;
24
+ CTX_KNOWLEDGE_ENABLED: boolean;
25
+ EMBEDDING_PROVIDER: "openai" | "google";
26
+ TEXT_EMBEDDING_MODEL: string;
27
+ EMBEDDING_DIMENSION: number;
28
+ TEXT_PROVIDER?: "openai" | "google" | "anthropic" | "openrouter" | undefined;
29
+ OPENAI_API_KEY?: string | undefined;
30
+ ANTHROPIC_API_KEY?: string | undefined;
31
+ OPENROUTER_API_KEY?: string | undefined;
32
+ GOOGLE_API_KEY?: string | undefined;
33
+ OPENAI_BASE_URL?: string | undefined;
34
+ ANTHROPIC_BASE_URL?: string | undefined;
35
+ OPENROUTER_BASE_URL?: string | undefined;
36
+ GOOGLE_BASE_URL?: string | undefined;
37
+ TEXT_MODEL?: string | undefined;
38
+ }, {
39
+ MAX_INPUT_TOKENS: string | number;
40
+ EMBEDDING_PROVIDER: "openai" | "google";
41
+ TEXT_EMBEDDING_MODEL: string;
42
+ MAX_OUTPUT_TOKENS?: string | number | undefined;
43
+ CTX_KNOWLEDGE_ENABLED?: boolean | 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
+ EMBEDDING_DIMENSION?: string | number | undefined;
55
+ }>;
56
+ type ModelConfig = z.infer<typeof ModelConfigSchema>;
57
+ /**
58
+ * Interface for provider rate limits
59
+ */
60
+ interface ProviderRateLimits {
61
+ maxConcurrentRequests: number;
62
+ requestsPerMinute: number;
63
+ tokensPerMinute?: number;
64
+ provider: string;
65
+ }
66
+ /**
67
+ * Options for text generation overrides
68
+ */
69
+ interface TextGenerationOptions {
70
+ provider?: 'anthropic' | 'openai' | 'openrouter' | 'google';
71
+ modelName?: string;
72
+ maxTokens?: number;
73
+ /**
74
+ * Document to cache for contextual retrieval.
75
+ * When provided (along with an Anthropic model via OpenRouter), this enables prompt caching.
76
+ * The document is cached with the provider and subsequent requests will reuse the cached document,
77
+ * significantly reducing costs for multiple operations on the same document.
78
+ * Most effective with contextual retrieval for Knowledge applications.
79
+ */
80
+ cacheDocument?: string;
81
+ /**
82
+ * Options for controlling the cache behavior.
83
+ * Currently supports { type: 'ephemeral' } which sets up a temporary cache.
84
+ * Cache expires after approximately 5 minutes with Anthropic models.
85
+ * This can reduce costs by up to 90% for reads after the initial cache write.
86
+ */
87
+ cacheOptions?: {
88
+ type: 'ephemeral';
89
+ };
90
+ /**
91
+ * Whether to automatically detect and enable caching for contextual retrieval.
92
+ * Default is true for OpenRouter+Anthropic models with document-chunk prompts.
93
+ * Set to false to disable automatic caching detection.
94
+ */
95
+ autoCacheContextualRetrieval?: boolean;
96
+ }
97
+ /**
98
+ * Options for adding knowledge to the system
99
+ */
100
+ interface AddKnowledgeOptions {
101
+ worldId: UUID;
102
+ roomId: UUID;
103
+ entityId: UUID;
104
+ /** Client-provided document ID */
105
+ clientDocumentId: UUID;
106
+ /** MIME type of the file */
107
+ contentType: string;
108
+ /** Original filename */
109
+ originalFilename: string;
110
+ /**
111
+ * Content of the document. Should be:
112
+ * - Base64 encoded string for binary files (PDFs, DOCXs, etc)
113
+ * - Plain text for text files
114
+ */
115
+ content: string;
116
+ }
117
+ declare module '@elizaos/core' {
118
+ interface ServiceTypeRegistry {
119
+ KNOWLEDGE: 'knowledge';
120
+ }
121
+ }
122
+ declare const KnowledgeServiceType: {
123
+ KNOWLEDGE: "knowledge";
124
+ };
125
+ interface KnowledgeDocumentMetadata extends Record<string, any> {
126
+ type: string;
127
+ source: string;
128
+ title?: string;
129
+ filename?: string;
130
+ fileExt?: string;
131
+ fileType?: string;
132
+ fileSize?: number;
133
+ url?: string;
134
+ timestamp: number;
135
+ documentId?: string;
136
+ }
137
+ interface KnowledgeConfig {
138
+ CTX_KNOWLEDGE_ENABLED: boolean;
139
+ LOAD_DOCS_ON_STARTUP: boolean;
140
+ MAX_INPUT_TOKENS?: string | number;
141
+ MAX_OUTPUT_TOKENS?: string | number;
142
+ EMBEDDING_PROVIDER?: string;
143
+ TEXT_PROVIDER?: string;
144
+ TEXT_EMBEDDING_MODEL?: string;
145
+ }
146
+ interface LoadResult {
147
+ successful: number;
148
+ failed: number;
149
+ errors?: Array<{
150
+ filename: string;
151
+ error: string;
152
+ }>;
153
+ }
2
154
 
3
155
  /**
4
156
  * Knowledge Plugin - Main Entry Point
@@ -11,4 +163,4 @@ import { Plugin } from '@elizaos/core';
11
163
  */
12
164
  declare const knowledgePlugin: Plugin;
13
165
 
14
- export { knowledgePlugin as default, knowledgePlugin };
166
+ export { type AddKnowledgeOptions, type KnowledgeConfig, type KnowledgeDocumentMetadata, KnowledgeServiceType, type LoadResult, type ModelConfig, ModelConfigSchema, type ProviderRateLimits, type TextGenerationOptions, knowledgePlugin as default, knowledgePlugin };
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Agent Plugin View</title>
8
+ <script type="module" crossorigin src="./assets/index-BQPj32JK.js"></script>
9
+ <link rel="stylesheet" crossorigin href="./assets/index-Cfdtl60S.css">
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ </body>
14
+ </html>