@elizaos/core 1.5.4 → 1.5.5
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 +0 -15
- package/dist/index.d.ts +4886 -3
- package/dist/index.js +5287 -4
- package/package.json +21 -39
- package/dist/browser/index.browser.js +0 -1109
- package/dist/browser/index.browser.js.map +0 -707
- package/dist/browser/index.d.ts +0 -3
- package/dist/node/index.d.ts +0 -3
- package/dist/node/index.node.js +0 -74530
- package/dist/node/index.node.js.map +0 -1027
- package/src/__tests__/action-chaining-simple.test.ts +0 -203
- package/src/__tests__/actions.test.ts +0 -218
- package/src/__tests__/buffer.test.ts +0 -337
- package/src/__tests__/character-validation.test.ts +0 -309
- package/src/__tests__/database.test.ts +0 -750
- package/src/__tests__/entities.test.ts +0 -727
- package/src/__tests__/env.test.ts +0 -23
- package/src/__tests__/environment.test.ts +0 -285
- package/src/__tests__/logger-browser-node.test.ts +0 -716
- package/src/__tests__/logger.test.ts +0 -403
- package/src/__tests__/messages.test.ts +0 -196
- package/src/__tests__/mockCharacter.ts +0 -544
- package/src/__tests__/parsing.test.ts +0 -58
- package/src/__tests__/prompts.test.ts +0 -159
- package/src/__tests__/roles.test.ts +0 -331
- package/src/__tests__/runtime-embedding.test.ts +0 -343
- package/src/__tests__/runtime.test.ts +0 -978
- package/src/__tests__/search.test.ts +0 -15
- package/src/__tests__/services-by-type.test.ts +0 -204
- package/src/__tests__/services.test.ts +0 -136
- package/src/__tests__/settings.test.ts +0 -810
- package/src/__tests__/utils.test.ts +0 -1105
- package/src/__tests__/uuid.test.ts +0 -94
- package/src/actions.ts +0 -122
- package/src/database.ts +0 -579
- package/src/entities.ts +0 -406
- package/src/index.browser.ts +0 -48
- package/src/index.node.ts +0 -39
- package/src/index.ts +0 -50
- package/src/logger.ts +0 -527
- package/src/prompts.ts +0 -243
- package/src/roles.ts +0 -85
- package/src/runtime.ts +0 -2514
- package/src/schemas/character.ts +0 -149
- package/src/search.ts +0 -1543
- package/src/sentry/instrument.browser.ts +0 -65
- package/src/sentry/instrument.node.ts +0 -57
- package/src/sentry/instrument.ts +0 -82
- package/src/services.ts +0 -105
- package/src/settings.ts +0 -409
- package/src/test_resources/constants.ts +0 -12
- package/src/test_resources/testSetup.ts +0 -21
- package/src/test_resources/types.ts +0 -22
- package/src/types/agent.ts +0 -112
- package/src/types/browser.ts +0 -145
- package/src/types/components.ts +0 -184
- package/src/types/database.ts +0 -348
- package/src/types/email.ts +0 -162
- package/src/types/environment.ts +0 -129
- package/src/types/events.ts +0 -249
- package/src/types/index.ts +0 -29
- package/src/types/knowledge.ts +0 -65
- package/src/types/lp.ts +0 -124
- package/src/types/memory.ts +0 -228
- package/src/types/message.ts +0 -233
- package/src/types/messaging.ts +0 -57
- package/src/types/model.ts +0 -359
- package/src/types/pdf.ts +0 -77
- package/src/types/plugin.ts +0 -78
- package/src/types/post.ts +0 -271
- package/src/types/primitives.ts +0 -97
- package/src/types/runtime.ts +0 -190
- package/src/types/service.ts +0 -198
- package/src/types/settings.ts +0 -30
- package/src/types/state.ts +0 -60
- package/src/types/task.ts +0 -72
- package/src/types/tee.ts +0 -107
- package/src/types/testing.ts +0 -30
- package/src/types/token.ts +0 -96
- package/src/types/transcription.ts +0 -133
- package/src/types/video.ts +0 -108
- package/src/types/wallet.ts +0 -56
- package/src/types/web-search.ts +0 -146
- package/src/utils/__tests__/buffer.test.ts +0 -80
- package/src/utils/__tests__/environment.test.ts +0 -58
- package/src/utils/__tests__/stringToUuid.test.ts +0 -88
- package/src/utils/buffer.ts +0 -312
- package/src/utils/environment.ts +0 -316
- package/src/utils/server-health.ts +0 -117
- package/src/utils.ts +0 -1076
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it } from 'bun:test';
|
|
2
|
-
import type { UUID } from '../types';
|
|
3
|
-
import { stringToUuid } from '../utils';
|
|
4
|
-
|
|
5
|
-
describe('UUID Module', () => {
|
|
6
|
-
// Helper function to generate test strings
|
|
7
|
-
const generateTestString = (): string => Math.random().toString(36).substring(7);
|
|
8
|
-
|
|
9
|
-
// Test data setup
|
|
10
|
-
let testString: string;
|
|
11
|
-
let testNumber: number;
|
|
12
|
-
|
|
13
|
-
beforeEach(() => {
|
|
14
|
-
testString = generateTestString();
|
|
15
|
-
testNumber = Math.floor(Math.random() * 1000);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
describe('stringToUuid', () => {
|
|
19
|
-
it('should generate a valid UUID matching the standard format', () => {
|
|
20
|
-
const result = stringToUuid(testString) as UUID;
|
|
21
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('should generate consistent UUIDs for identical inputs', () => {
|
|
25
|
-
const input = testString;
|
|
26
|
-
const uuid1 = stringToUuid(input) as UUID;
|
|
27
|
-
const uuid2 = stringToUuid(input) as UUID;
|
|
28
|
-
expect(uuid1).toBe(uuid2);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should generate unique UUIDs for different inputs', () => {
|
|
32
|
-
const input1 = testString;
|
|
33
|
-
const input2 = generateTestString();
|
|
34
|
-
const uuid1 = stringToUuid(input1) as UUID;
|
|
35
|
-
const uuid2 = stringToUuid(input2) as UUID;
|
|
36
|
-
expect(uuid1).not.toBe(uuid2);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('input handling', () => {
|
|
40
|
-
it('should convert number inputs to strings correctly', () => {
|
|
41
|
-
const numberUuid = stringToUuid(testNumber) as UUID;
|
|
42
|
-
const stringUuid = stringToUuid(testNumber.toString()) as UUID;
|
|
43
|
-
expect(numberUuid).toBe(stringUuid);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('should throw TypeError for invalid input types', () => {
|
|
47
|
-
expect(() => stringToUuid(undefined as any)).toThrow(TypeError);
|
|
48
|
-
expect(() => stringToUuid(null as any)).toThrow(TypeError);
|
|
49
|
-
expect(() => stringToUuid({} as any)).toThrow(TypeError);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('should handle empty string input', () => {
|
|
53
|
-
const result = stringToUuid('') as UUID;
|
|
54
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('should handle Unicode characters and emojis consistently', () => {
|
|
58
|
-
const unicodeInput = 'Hello 世界! 🌍';
|
|
59
|
-
const result1 = stringToUuid(unicodeInput) as UUID;
|
|
60
|
-
const result2 = stringToUuid(unicodeInput) as UUID;
|
|
61
|
-
expect(result1).toBe(result2);
|
|
62
|
-
expect(result1).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('UUID version and variant bits', () => {
|
|
67
|
-
it('should set correct version bits (version 5)', () => {
|
|
68
|
-
const uuid = stringToUuid(testString) as UUID;
|
|
69
|
-
const versionChar = uuid.split('-')[2][0];
|
|
70
|
-
expect(versionChar).toBe('0');
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('should set correct variant bits (RFC4122)', () => {
|
|
74
|
-
const uuid = stringToUuid(testString) as UUID;
|
|
75
|
-
const variantByte = Number.parseInt(uuid.split('-')[3].slice(0, 2), 16);
|
|
76
|
-
expect(variantByte >= 0x80 && variantByte <= 0xbf).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('encoding handling', () => {
|
|
81
|
-
it('should handle URL-unsafe characters', () => {
|
|
82
|
-
const urlUnsafeInput = 'test?query=value¶m=123';
|
|
83
|
-
const result = stringToUuid(urlUnsafeInput) as UUID;
|
|
84
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('should handle very long inputs', () => {
|
|
88
|
-
const longInput = 'a'.repeat(1000);
|
|
89
|
-
const result = stringToUuid(longInput) as UUID;
|
|
90
|
-
expect(result).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i);
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
package/src/actions.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { names, uniqueNamesGenerator } from 'unique-names-generator';
|
|
2
|
-
import type { Action, ActionExample } from './types';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Composes a set of example conversations based on provided actions and a specified count.
|
|
6
|
-
* It randomly selects examples from the provided actions and formats them with generated names.
|
|
7
|
-
*
|
|
8
|
-
* @param actionsData - An array of `Action` objects from which to draw examples.
|
|
9
|
-
* @param count - The number of examples to generate.
|
|
10
|
-
* @returns A string containing formatted examples of conversations.
|
|
11
|
-
*/
|
|
12
|
-
export const composeActionExamples = (actionsData: Action[], count: number): string => {
|
|
13
|
-
// Handle edge cases
|
|
14
|
-
if (!actionsData.length || count <= 0) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Filter out actions without examples
|
|
19
|
-
const actionsWithExamples = actionsData.filter(
|
|
20
|
-
(action) => action.examples && Array.isArray(action.examples) && action.examples.length > 0
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
// If no actions have examples, return empty string
|
|
24
|
-
if (!actionsWithExamples.length) {
|
|
25
|
-
return '';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Create a working copy of the examples
|
|
29
|
-
const examplesCopy: ActionExample[][][] = actionsWithExamples.map((action) => [
|
|
30
|
-
...(action.examples || []),
|
|
31
|
-
]);
|
|
32
|
-
|
|
33
|
-
const selectedExamples: ActionExample[][] = [];
|
|
34
|
-
|
|
35
|
-
// Keep track of actions that still have examples
|
|
36
|
-
let availableActionIndices = examplesCopy
|
|
37
|
-
.map((examples, index) => (examples.length > 0 ? index : -1))
|
|
38
|
-
.filter((index) => index !== -1);
|
|
39
|
-
|
|
40
|
-
// Select examples until we reach the count or run out of examples
|
|
41
|
-
while (selectedExamples.length < count && availableActionIndices.length > 0) {
|
|
42
|
-
// Randomly select an action
|
|
43
|
-
const randomIndex = Math.floor(Math.random() * availableActionIndices.length);
|
|
44
|
-
const actionIndex = availableActionIndices[randomIndex];
|
|
45
|
-
const examples = examplesCopy[actionIndex];
|
|
46
|
-
|
|
47
|
-
// Select a random example from this action
|
|
48
|
-
const exampleIndex = Math.floor(Math.random() * examples.length);
|
|
49
|
-
selectedExamples.push(examples.splice(exampleIndex, 1)[0]);
|
|
50
|
-
|
|
51
|
-
// Remove action if it has no more examples
|
|
52
|
-
if (examples.length === 0) {
|
|
53
|
-
availableActionIndices.splice(randomIndex, 1);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Format the selected examples
|
|
58
|
-
return formatSelectedExamples(selectedExamples);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Formats selected example conversations with random names.
|
|
63
|
-
*/
|
|
64
|
-
const formatSelectedExamples = (examples: ActionExample[][]): string => {
|
|
65
|
-
const MAX_NAME_PLACEHOLDERS = 5;
|
|
66
|
-
|
|
67
|
-
return examples
|
|
68
|
-
.map((example) => {
|
|
69
|
-
// Generate random names for this example
|
|
70
|
-
const randomNames = Array.from({ length: MAX_NAME_PLACEHOLDERS }, () =>
|
|
71
|
-
uniqueNamesGenerator({ dictionaries: [names] })
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
// Format the conversation
|
|
75
|
-
const conversation = example
|
|
76
|
-
.map((message) => {
|
|
77
|
-
// Build the base message - only include the text, no action info
|
|
78
|
-
let messageText = `${message.name}: ${message.content.text}`;
|
|
79
|
-
|
|
80
|
-
// Replace name placeholders
|
|
81
|
-
for (let i = 0; i < randomNames.length; i++) {
|
|
82
|
-
messageText = messageText.replaceAll(`{{name${i + 1}}}`, randomNames[i]);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return messageText;
|
|
86
|
-
})
|
|
87
|
-
.join('\n');
|
|
88
|
-
|
|
89
|
-
return `\n${conversation}`;
|
|
90
|
-
})
|
|
91
|
-
.join('\n');
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Formats the names of the provided actions into a comma-separated string.
|
|
96
|
-
* @param actions - An array of `Action` objects from which to extract names.
|
|
97
|
-
* @returns A comma-separated string of action names.
|
|
98
|
-
*/
|
|
99
|
-
export function formatActionNames(actions: Action[]): string {
|
|
100
|
-
if (!actions?.length) return '';
|
|
101
|
-
|
|
102
|
-
// Create a shuffled copy instead of mutating the original array
|
|
103
|
-
return [...actions]
|
|
104
|
-
.sort(() => Math.random() - 0.5)
|
|
105
|
-
.map((action) => action.name)
|
|
106
|
-
.join(', ');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Formats the provided actions into a detailed string listing each action's name and description.
|
|
111
|
-
* @param actions - An array of `Action` objects to format.
|
|
112
|
-
* @returns A detailed string of actions, including names and descriptions.
|
|
113
|
-
*/
|
|
114
|
-
export function formatActions(actions: Action[]): string {
|
|
115
|
-
if (!actions?.length) return '';
|
|
116
|
-
|
|
117
|
-
// Create a shuffled copy without mutating the original
|
|
118
|
-
return [...actions]
|
|
119
|
-
.sort(() => Math.random() - 0.5)
|
|
120
|
-
.map((action) => `- **${action.name}**: ${action.description || 'No description available'}`)
|
|
121
|
-
.join('\n');
|
|
122
|
-
}
|