@elizaos/core 1.0.1 → 1.0.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.
@@ -1,91 +0,0 @@
1
- import type { Character, IAgentRuntime, OnboardingConfig, Setting, World, WorldSettings } from './types';
2
- /**
3
- * Creates a new Setting object based on provided config settings.
4
- * @param {Omit<Setting, "value">} configSetting - The configuration settings for the new Setting object.
5
- * @returns {Setting} - The newly created Setting object.
6
- */
7
- /**
8
- * Creates a Setting object from a configSetting object by omitting the 'value' property.
9
- *
10
- * @param {Omit<Setting, 'value'>} configSetting - The configSetting object to create the Setting from.
11
- * @returns {Setting} A new Setting object created from the provided configSetting object.
12
- */
13
- export declare function createSettingFromConfig(configSetting: Omit<Setting, 'value'>): Setting;
14
- /**
15
- * Retrieves the salt based on env variable SECRET_SALT
16
- *
17
- * @returns {string} The salt for the agent.
18
- */
19
- export declare function getSalt(): string;
20
- /**
21
- * Common encryption function for string values
22
- * @param {string} value - The string value to encrypt
23
- * @param {string} salt - The salt to use for encryption
24
- * @returns {string} - The encrypted value in 'iv:encrypted' format
25
- */
26
- export declare function encryptStringValue(value: string, salt: string): string;
27
- /**
28
- * Common decryption function for string values
29
- * @param {string} value - The encrypted value in 'iv:encrypted' format
30
- * @param {string} salt - The salt to use for decryption
31
- * @returns {string} - The decrypted string value
32
- */
33
- export declare function decryptStringValue(value: string, salt: string): string;
34
- /**
35
- * Applies salt to the value of a setting
36
- * Only applies to secret settings with string values
37
- */
38
- export declare function saltSettingValue(setting: Setting, salt: string): Setting;
39
- /**
40
- * Removes salt from the value of a setting
41
- * Only applies to secret settings with string values
42
- */
43
- export declare function unsaltSettingValue(setting: Setting, salt: string): Setting;
44
- /**
45
- * Applies salt to all settings in a WorldSettings object
46
- */
47
- export declare function saltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
48
- /**
49
- * Removes salt from all settings in a WorldSettings object
50
- */
51
- export declare function unsaltWorldSettings(worldSettings: WorldSettings, salt: string): WorldSettings;
52
- /**
53
- * Updates settings state in world metadata
54
- */
55
- export declare function updateWorldSettings(runtime: IAgentRuntime, serverId: string, worldSettings: WorldSettings): Promise<boolean>;
56
- /**
57
- * Gets settings state from world metadata
58
- */
59
- export declare function getWorldSettings(runtime: IAgentRuntime, serverId: string): Promise<WorldSettings | null>;
60
- /**
61
- * Initializes settings configuration for a server
62
- */
63
- export declare function initializeOnboarding(runtime: IAgentRuntime, world: World, config: OnboardingConfig): Promise<WorldSettings | null>;
64
- /**
65
- * Encrypts sensitive data in a Character object
66
- * @param {Character} character - The character object to encrypt secrets for
67
- * @returns {Character} - A copy of the character with encrypted secrets
68
- */
69
- export declare function encryptedCharacter(character: Character): Character;
70
- /**
71
- * Decrypts sensitive data in a Character object
72
- * @param {Character} character - The character object with encrypted secrets
73
- * @param {IAgentRuntime} runtime - The runtime information needed for salt generation
74
- * @returns {Character} - A copy of the character with decrypted secrets
75
- */
76
- export declare function decryptedCharacter(character: Character, runtime: IAgentRuntime): Character;
77
- /**
78
- * Helper function to encrypt all string values in an object
79
- * @param {Record<string, any>} obj - Object with values to encrypt
80
- * @param {string} salt - The salt to use for encryption
81
- * @returns {Record<string, any>} - Object with encrypted values
82
- */
83
- export declare function encryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
84
- /**
85
- * Helper function to decrypt all string values in an object
86
- * @param {Record<string, any>} obj - Object with encrypted values
87
- * @param {string} salt - The salt to use for decryption
88
- * @returns {Record<string, any>} - Object with decrypted values
89
- */
90
- export declare function decryptObjectValues(obj: Record<string, any>, salt: string): Record<string, any>;
91
- export { decryptStringValue as decryptSecret };
@@ -1,9 +0,0 @@
1
- import type { UUID } from '@elizaos/core';
2
- export declare const SERVER_URL = "http://localhost:7998";
3
- export declare const SUPABASE_URL = "https://pronvzrzfwsptkojvudd.supabase.co";
4
- export declare const SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InByb252enJ6ZndzcHRrb2p2dWRkIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MDY4NTYwNDcsImV4cCI6MjAyMjQzMjA0N30.I6_-XrqssUb2SWYg5DjsUqSodNS3_RPoET3-aPdqywM";
5
- export declare const TEST_EMAIL = "testuser123@gmail.com";
6
- export declare const TEST_PASSWORD = "testuser123@gmail.com";
7
- export declare const TEST_EMAIL_2 = "testuser234@gmail.com";
8
- export declare const TEST_PASSWORD_2 = "testuser234@gmail.com";
9
- export declare const zeroUuid: UUID;
@@ -1 +0,0 @@
1
- export {};
@@ -1,22 +0,0 @@
1
- /**
2
- * Interface representing a User.
3
- * @typedef {Object} User
4
- * @property {string} id - The user's ID.
5
- * @property {string} [email] - The user's email (optional).
6
- * @property {string} [phone] - The user's phone number (optional).
7
- * @property {string} [role] - The user's role (optional).
8
- */
9
- /**
10
- * Represents a User with optional properties.
11
- * @typedef {Object} User
12
- * @property {string} id - The unique identifier for the user.
13
- * @property {string} [email] - The email address of the user (optional).
14
- * @property {string} [phone] - The phone number of the user (optional).
15
- * @property {string} [role] - The role of the user (optional).
16
- */
17
- export interface User {
18
- id: string;
19
- email?: string;
20
- phone?: string;
21
- role?: string;
22
- }
package/dist/utils.d.ts DELETED
@@ -1,192 +0,0 @@
1
- import { Buffer } from 'buffer';
2
- import type { Entity, IAgentRuntime, Memory, State, TemplateType } from './types';
3
- import { UUID } from './types';
4
- declare const Readable: any;
5
- /**
6
- * Generates a WAV file header based on the provided audio parameters.
7
- * @param {number} audioLength - The length of the audio data in bytes.
8
- * @param {number} sampleRate - The sample rate of the audio.
9
- * @param {number} [channelCount=1] - The number of channels (default is 1).
10
- * @param {number} [bitsPerSample=16] - The number of bits per sample (default is 16).
11
- * @returns {Buffer} The WAV file header as a Buffer object.
12
- */
13
- declare function getWavHeader(audioLength: number, sampleRate: number, channelCount?: number, bitsPerSample?: number): Buffer;
14
- /**
15
- * Prepends a WAV header to a readable stream of audio data.
16
- *
17
- * @param {Readable} readable - The readable stream containing the audio data.
18
- * @param {number} audioLength - The length of the audio data in seconds.
19
- * @param {number} sampleRate - The sample rate of the audio data.
20
- * @param {number} [channelCount=1] - The number of channels in the audio data (default is 1).
21
- * @param {number} [bitsPerSample=16] - The number of bits per sample in the audio data (default is 16).
22
- * @returns {Readable} A new readable stream with the WAV header prepended to the audio data.
23
- */
24
- declare function prependWavHeader(readable: typeof Readable, audioLength: number, sampleRate: number, channelCount?: number, bitsPerSample?: number): typeof Readable;
25
- export { getWavHeader, prependWavHeader };
26
- /**
27
- * Composes a context string by replacing placeholders in a template with corresponding values from the state.
28
- *
29
- * This function takes a template string with placeholders in the format `{{placeholder}}` and a state object.
30
- * It replaces each placeholder with the value from the state object that matches the placeholder's name.
31
- * If a matching key is not found in the state object for a given placeholder, the placeholder is replaced with an empty string.
32
- *
33
- * @param {Object} params - The parameters for composing the context.
34
- * @param {State} params.state - The state object containing values to replace the placeholders in the template.
35
- * @param {TemplateType} params.template - The template string or function containing placeholders to be replaced with state values.
36
- * @returns {string} The composed context string with placeholders replaced by corresponding state values.
37
- *
38
- * @example
39
- * // Given a state object and a template
40
- * const state = { userName: "Alice", userAge: 30 };
41
- * const template = "Hello, {{userName}}! You are {{userAge}} years old";
42
- *
43
- * // Composing the context with simple string replacement will result in:
44
- * // "Hello, Alice! You are 30 years old."
45
- * const contextSimple = composePromptFromState({ state, template });
46
- *
47
- * // Using composePromptFromState with a template function for dynamic template
48
- * const template = ({ state }) => {
49
- * const tone = Math.random() > 0.5 ? "kind" : "rude";
50
- * return `Hello, {{userName}}! You are {{userAge}} years old. Be ${tone}`;
51
- * };
52
- * const contextSimple = composePromptFromState({ state, template });
53
- */
54
- /**
55
- * Function to compose a prompt using a provided template and state.
56
- * It compiles the template (upgrading double braces to triple braces for non-HTML escaping)
57
- * and then populates it with values from the state. Additionally, it processes the
58
- * resulting string with `composeRandomUser` to replace placeholders like `{{nameX}}`.
59
- *
60
- * @param {Object} options - Object containing state and template information.
61
- * @param {State} options.state - The state object containing values to fill the template.
62
- * @param {TemplateType} options.template - The template string or function to be used for composing the prompt.
63
- * @returns {string} The composed prompt output, with state values and random user names populated.
64
- */
65
- export declare const composePrompt: ({ state, template, }: {
66
- state: {
67
- [key: string]: string;
68
- };
69
- template: TemplateType;
70
- }) => string;
71
- /**
72
- * Function to compose a prompt using a provided template and state.
73
- *
74
- * @param {Object} options - Object containing state and template information.
75
- * @param {State} options.state - The state object containing values to fill the template.
76
- * @param {TemplateType} options.template - The template to be used for composing the prompt.
77
- * @returns {string} The composed prompt output.
78
- */
79
- export declare const composePromptFromState: ({ state, template, }: {
80
- state: State;
81
- template: TemplateType;
82
- }) => string;
83
- /**
84
- * Adds a header to a body of text.
85
- *
86
- * This function takes a header string and a body string and returns a new string with the header prepended to the body.
87
- * If the body string is empty, the header is returned as is.
88
- *
89
- * @param {string} header - The header to add to the body.
90
- * @param {string} body - The body to which to add the header.
91
- * @returns {string} The body with the header prepended.
92
- *
93
- * @example
94
- * // Given a header and a body
95
- * const header = "Header";
96
- * const body = "Body";
97
- *
98
- * // Adding the header to the body will result in:
99
- * // "Header\nBody"
100
- * const text = addHeader(header, body);
101
- */
102
- export declare const addHeader: (header: string, body: string) => string;
103
- export declare const formatPosts: ({ messages, entities, conversationHeader, }: {
104
- messages: Memory[];
105
- entities: Entity[];
106
- conversationHeader?: boolean;
107
- }) => string;
108
- /**
109
- * Format messages into a string
110
- * @param {Object} params - The formatting parameters
111
- * @param {Memory[]} params.messages - List of messages to format
112
- * @param {Entity[]} params.entities - List of entities for name resolution
113
- * @returns {string} Formatted message string with timestamps and user information
114
- */
115
- export declare const formatMessages: ({ messages, entities, }: {
116
- messages: Memory[];
117
- entities: Entity[];
118
- }) => string;
119
- export declare const formatTimestamp: (messageDate: number) => string;
120
- /**
121
- * Parses key-value pairs from a simple XML structure within a given text.
122
- * It looks for an XML block (e.g., <response>...</response>) and extracts
123
- * text content from direct child elements (e.g., <key>value</key>).
124
- *
125
- * Note: This uses regex and is suitable for simple, predictable XML structures.
126
- * For complex XML, a proper parsing library is recommended.
127
- *
128
- * @param text - The input text containing the XML structure.
129
- * @returns An object with key-value pairs extracted from the XML, or null if parsing fails.
130
- */
131
- export declare function parseKeyValueXml(text: string): Record<string, any> | null;
132
- /**
133
- * Parses a JSON object from a given text. The function looks for a JSON block wrapped in triple backticks
134
- * with `json` language identifier, and if not found, it searches for an object pattern within the text.
135
- * It then attempts to parse the JSON string into a JavaScript object. If parsing is successful and the result
136
- * is an object (but not an array), it returns the object; otherwise, it tries to parse an array if the result
137
- * is an array, or returns null if parsing is unsuccessful or the result is neither an object nor an array.
138
- *
139
- * @param text - The input text from which to extract and parse the JSON object.
140
- * @returns An object parsed from the JSON string if successful; otherwise, null or the result of parsing an array.
141
- */
142
- export declare function parseJSONObjectFromText(text: string): Record<string, any> | null;
143
- /**
144
- * Normalizes a JSON-like string by correcting formatting issues:
145
- * - Removes extra spaces after '{' and before '}'.
146
- * - Wraps unquoted values in double quotes.
147
- * - Converts single-quoted values to double-quoted.
148
- * - Ensures consistency in key-value formatting.
149
- * - Normalizes mixed adjacent quote pairs.
150
- *
151
- * This is useful for cleaning up improperly formatted JSON strings
152
- * before parsing them into valid JSON.
153
- *
154
- * @param str - The JSON-like string to normalize.
155
- * @returns A properly formatted JSON string.
156
- */
157
- export declare const normalizeJsonString: (str: string) => string;
158
- /**
159
- * Truncate text to fit within the character limit, ensuring it ends at a complete sentence.
160
- */
161
- export declare function truncateToCompleteSentence(text: string, maxLength: number): string;
162
- export declare function splitChunks(content: string, chunkSize?: number, bleed?: number): Promise<string[]>;
163
- /**
164
- * Trims the provided text prompt to a specified token limit using a tokenizer model and type.
165
- */
166
- export declare function trimTokens(prompt: string, maxTokens: number, runtime: IAgentRuntime): Promise<string>;
167
- export declare function safeReplacer(): (key: string, value: any) => any;
168
- /**
169
- * Parses a string to determine its boolean equivalent.
170
- *
171
- * Recognized affirmative values: "YES", "Y", "TRUE", "T", "1", "ON", "ENABLE"
172
- * Recognized negative values: "NO", "N", "FALSE", "F", "0", "OFF", "DISABLE"
173
- *
174
- * @param {string | undefined | null} value - The input text to parse
175
- * @returns {boolean} - Returns `true` for affirmative inputs, `false` for negative or unrecognized inputs
176
- */
177
- export declare function parseBooleanFromText(value: string | undefined | null): boolean;
178
- /**
179
- * Validates a UUID value.
180
- *
181
- * @param {unknown} value - The value to validate.
182
- * @returns {UUID | null} Returns the validated UUID value or null if validation fails.
183
- */
184
- export declare function validateUuid(value: unknown): UUID | null;
185
- /**
186
- * Converts a string or number to a UUID.
187
- *
188
- * @param {string | number} target - The string or number to convert to a UUID.
189
- * @returns {UUID} The UUID generated from the input target.
190
- * @throws {TypeError} Throws an error if the input target is not a string.
191
- */
192
- export declare function stringToUuid(target: string | number): UUID;