@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.
Files changed (90) hide show
  1. package/README.md +0 -15
  2. package/dist/index.d.ts +4886 -3
  3. package/dist/index.js +5287 -4
  4. package/package.json +21 -39
  5. package/dist/browser/index.browser.js +0 -1109
  6. package/dist/browser/index.browser.js.map +0 -707
  7. package/dist/browser/index.d.ts +0 -3
  8. package/dist/node/index.d.ts +0 -3
  9. package/dist/node/index.node.js +0 -74530
  10. package/dist/node/index.node.js.map +0 -1027
  11. package/src/__tests__/action-chaining-simple.test.ts +0 -203
  12. package/src/__tests__/actions.test.ts +0 -218
  13. package/src/__tests__/buffer.test.ts +0 -337
  14. package/src/__tests__/character-validation.test.ts +0 -309
  15. package/src/__tests__/database.test.ts +0 -750
  16. package/src/__tests__/entities.test.ts +0 -727
  17. package/src/__tests__/env.test.ts +0 -23
  18. package/src/__tests__/environment.test.ts +0 -285
  19. package/src/__tests__/logger-browser-node.test.ts +0 -716
  20. package/src/__tests__/logger.test.ts +0 -403
  21. package/src/__tests__/messages.test.ts +0 -196
  22. package/src/__tests__/mockCharacter.ts +0 -544
  23. package/src/__tests__/parsing.test.ts +0 -58
  24. package/src/__tests__/prompts.test.ts +0 -159
  25. package/src/__tests__/roles.test.ts +0 -331
  26. package/src/__tests__/runtime-embedding.test.ts +0 -343
  27. package/src/__tests__/runtime.test.ts +0 -978
  28. package/src/__tests__/search.test.ts +0 -15
  29. package/src/__tests__/services-by-type.test.ts +0 -204
  30. package/src/__tests__/services.test.ts +0 -136
  31. package/src/__tests__/settings.test.ts +0 -810
  32. package/src/__tests__/utils.test.ts +0 -1105
  33. package/src/__tests__/uuid.test.ts +0 -94
  34. package/src/actions.ts +0 -122
  35. package/src/database.ts +0 -579
  36. package/src/entities.ts +0 -406
  37. package/src/index.browser.ts +0 -48
  38. package/src/index.node.ts +0 -39
  39. package/src/index.ts +0 -50
  40. package/src/logger.ts +0 -527
  41. package/src/prompts.ts +0 -243
  42. package/src/roles.ts +0 -85
  43. package/src/runtime.ts +0 -2514
  44. package/src/schemas/character.ts +0 -149
  45. package/src/search.ts +0 -1543
  46. package/src/sentry/instrument.browser.ts +0 -65
  47. package/src/sentry/instrument.node.ts +0 -57
  48. package/src/sentry/instrument.ts +0 -82
  49. package/src/services.ts +0 -105
  50. package/src/settings.ts +0 -409
  51. package/src/test_resources/constants.ts +0 -12
  52. package/src/test_resources/testSetup.ts +0 -21
  53. package/src/test_resources/types.ts +0 -22
  54. package/src/types/agent.ts +0 -112
  55. package/src/types/browser.ts +0 -145
  56. package/src/types/components.ts +0 -184
  57. package/src/types/database.ts +0 -348
  58. package/src/types/email.ts +0 -162
  59. package/src/types/environment.ts +0 -129
  60. package/src/types/events.ts +0 -249
  61. package/src/types/index.ts +0 -29
  62. package/src/types/knowledge.ts +0 -65
  63. package/src/types/lp.ts +0 -124
  64. package/src/types/memory.ts +0 -228
  65. package/src/types/message.ts +0 -233
  66. package/src/types/messaging.ts +0 -57
  67. package/src/types/model.ts +0 -359
  68. package/src/types/pdf.ts +0 -77
  69. package/src/types/plugin.ts +0 -78
  70. package/src/types/post.ts +0 -271
  71. package/src/types/primitives.ts +0 -97
  72. package/src/types/runtime.ts +0 -190
  73. package/src/types/service.ts +0 -198
  74. package/src/types/settings.ts +0 -30
  75. package/src/types/state.ts +0 -60
  76. package/src/types/task.ts +0 -72
  77. package/src/types/tee.ts +0 -107
  78. package/src/types/testing.ts +0 -30
  79. package/src/types/token.ts +0 -96
  80. package/src/types/transcription.ts +0 -133
  81. package/src/types/video.ts +0 -108
  82. package/src/types/wallet.ts +0 -56
  83. package/src/types/web-search.ts +0 -146
  84. package/src/utils/__tests__/buffer.test.ts +0 -80
  85. package/src/utils/__tests__/environment.test.ts +0 -58
  86. package/src/utils/__tests__/stringToUuid.test.ts +0 -88
  87. package/src/utils/buffer.ts +0 -312
  88. package/src/utils/environment.ts +0 -316
  89. package/src/utils/server-health.ts +0 -117
  90. package/src/utils.ts +0 -1076
@@ -1,203 +0,0 @@
1
- import { describe, expect, it, beforeEach, mock } from 'bun:test';
2
- import { AgentRuntime } from '../runtime';
3
- import { createActionResult } from '../types/components';
4
- import type { ActionResult } from '../types';
5
-
6
- describe('Action Chaining Fixes', () => {
7
- describe('createActionResult helper', () => {
8
- it('should create ActionResult with default success=true', () => {
9
- const result = createActionResult();
10
- expect(result.success).toBe(true);
11
- expect(result.text).toBeUndefined();
12
- expect(result.error).toBeUndefined();
13
- });
14
-
15
- it('should allow overriding success field', () => {
16
- const result = createActionResult({ success: false, error: 'Test error' });
17
- expect(result.success).toBe(false);
18
- expect(result.error).toBe('Test error');
19
- });
20
-
21
- it('should preserve all provided fields', () => {
22
- const result = createActionResult({
23
- text: 'Test text',
24
- values: { key: 'value' },
25
- data: { foo: 'bar' },
26
- });
27
- expect(result.success).toBe(true);
28
- expect(result.text).toBe('Test text');
29
- expect(result.values).toEqual({ key: 'value' });
30
- expect(result.data).toEqual({ foo: 'bar' });
31
- });
32
- });
33
-
34
- describe('Runtime immutable helpers', () => {
35
- let runtime: any;
36
-
37
- beforeEach(() => {
38
- // Access private methods through prototype
39
- runtime = AgentRuntime.prototype;
40
- });
41
-
42
- it('should update action plan immutably', () => {
43
- const originalPlan = {
44
- currentStep: 1,
45
- totalSteps: 3,
46
- steps: [{ action: 'step1' }, { action: 'step2' }, { action: 'step3' }],
47
- };
48
-
49
- const updatedPlan = runtime.updateActionPlan(originalPlan, { currentStep: 2 });
50
-
51
- // Original should be unchanged
52
- expect(originalPlan.currentStep).toBe(1);
53
-
54
- // Updated should have new value
55
- expect(updatedPlan.currentStep).toBe(2);
56
- expect(updatedPlan.totalSteps).toBe(3);
57
- expect(updatedPlan.steps).toEqual(originalPlan.steps);
58
-
59
- // Should be different objects
60
- expect(updatedPlan).not.toBe(originalPlan);
61
- });
62
-
63
- it('should update action step immutably', () => {
64
- const originalPlan = {
65
- currentStep: 1,
66
- steps: [
67
- { action: 'step1', status: 'pending' },
68
- { action: 'step2', status: 'pending' },
69
- { action: 'step3', status: 'pending' },
70
- ],
71
- };
72
-
73
- const updatedPlan = runtime.updateActionStep(originalPlan, 1, {
74
- status: 'completed',
75
- result: { success: true },
76
- });
77
-
78
- // Original should be unchanged
79
- expect(originalPlan.steps[1].status).toBe('pending');
80
- expect(originalPlan.steps[1].result).toBeUndefined();
81
-
82
- // Updated should have new values
83
- expect(updatedPlan.steps[1].status).toBe('completed');
84
- expect(updatedPlan.steps[1].result).toEqual({ success: true });
85
-
86
- // Other steps should be unchanged
87
- expect(updatedPlan.steps[0]).toEqual(originalPlan.steps[0]);
88
- expect(updatedPlan.steps[2]).toEqual(originalPlan.steps[2]);
89
-
90
- // Should be different objects
91
- expect(updatedPlan).not.toBe(originalPlan);
92
- expect(updatedPlan.steps).not.toBe(originalPlan.steps);
93
- expect(updatedPlan.steps[1]).not.toBe(originalPlan.steps[1]);
94
- });
95
- });
96
-
97
- describe('Working Memory Cleanup', () => {
98
- it('should enforce MAX_WORKING_MEMORY_ENTRIES limit', () => {
99
- // This is more of a documentation test showing the expected behavior
100
- const MAX_WORKING_MEMORY_ENTRIES = 50;
101
- const workingMemory: Record<string, any> = {};
102
-
103
- // Add 60 entries
104
- for (let i = 0; i < 60; i++) {
105
- workingMemory[`action_${i}`] = {
106
- actionName: `Action${i}`,
107
- timestamp: Date.now() + i, // Incrementing timestamps
108
- result: { success: true },
109
- };
110
- }
111
-
112
- // Simulate cleanup
113
- const entries = Object.entries(workingMemory);
114
- expect(entries.length).toBe(60);
115
-
116
- // Sort by timestamp (newest first) with proper type safety
117
- const sorted = entries.sort((a, b) => {
118
- const entryA = a[1] as { timestamp?: number } | null;
119
- const entryB = b[1] as { timestamp?: number } | null;
120
- const timestampA = entryA?.timestamp ?? 0;
121
- const timestampB = entryB?.timestamp ?? 0;
122
- return timestampB - timestampA;
123
- });
124
-
125
- // Keep only the most recent MAX_WORKING_MEMORY_ENTRIES
126
- const cleaned = Object.fromEntries(sorted.slice(0, MAX_WORKING_MEMORY_ENTRIES));
127
-
128
- expect(Object.keys(cleaned).length).toBe(MAX_WORKING_MEMORY_ENTRIES);
129
-
130
- // Verify we kept the newest entries
131
- const cleanedKeys = Object.keys(cleaned);
132
- expect(cleanedKeys).toContain('action_59');
133
- expect(cleanedKeys).toContain('action_50');
134
- expect(cleanedKeys).not.toContain('action_9'); // Old entry should be removed
135
- });
136
- });
137
-
138
- describe('Bounds Checking', () => {
139
- it('should handle updateActionStep with invalid indices', () => {
140
- // Mock logger
141
- const warnCalls: string[] = [];
142
- const mockLogger = {
143
- warn: (msg: string) => {
144
- warnCalls.push(msg);
145
- },
146
- };
147
-
148
- // Helper function that mimics the runtime's updateActionStep
149
- const updateActionStep = <T, S>(
150
- plan: T & { steps: S[] },
151
- index: number,
152
- stepUpdates: Partial<S>,
153
- logger: typeof mockLogger
154
- ): T & { steps: S[] } => {
155
- if (!plan.steps || index < 0 || index >= plan.steps.length) {
156
- logger.warn(
157
- `Invalid step index: ${index} for plan with ${plan.steps?.length || 0} steps`
158
- );
159
- return plan;
160
- }
161
- return {
162
- ...plan,
163
- steps: plan.steps.map((step: S, i: number) =>
164
- i === index ? { ...step, ...stepUpdates } : step
165
- ),
166
- };
167
- };
168
-
169
- // Test data
170
- const plan = {
171
- name: 'test-plan',
172
- steps: [
173
- { status: 'pending', action: 'step1' },
174
- { status: 'pending', action: 'step2' },
175
- { status: 'pending', action: 'step3' },
176
- ],
177
- };
178
-
179
- // Test valid index
180
- const updated1 = updateActionStep(plan, 1, { status: 'completed' }, mockLogger);
181
- expect(updated1.steps[1].status).toBe('completed');
182
- expect(warnCalls.length).toBe(0);
183
-
184
- // Test negative index
185
- const updated2 = updateActionStep(plan, -1, { status: 'failed' }, mockLogger);
186
- expect(updated2).toBe(plan); // Should return original plan
187
- expect(warnCalls[0]).toBe('Invalid step index: -1 for plan with 3 steps');
188
-
189
- // Test index out of bounds
190
- warnCalls.length = 0; // Clear warnings
191
- const updated3 = updateActionStep(plan, 5, { status: 'failed' }, mockLogger);
192
- expect(updated3).toBe(plan); // Should return original plan
193
- expect(warnCalls[0]).toBe('Invalid step index: 5 for plan with 3 steps');
194
-
195
- // Test with null steps
196
- warnCalls.length = 0; // Clear warnings
197
- const planWithNullSteps = { name: 'test', steps: null as any };
198
- const updated4 = updateActionStep(planWithNullSteps, 0, { status: 'completed' }, mockLogger);
199
- expect(updated4).toBe(planWithNullSteps);
200
- expect(warnCalls[0]).toBe('Invalid step index: 0 for plan with 0 steps');
201
- });
202
- });
203
- });
@@ -1,218 +0,0 @@
1
- import { describe, expect, it } from 'bun:test';
2
- import { composeActionExamples, formatActionNames, formatActions } from '../actions';
3
- import type { Action } from '../types';
4
-
5
- describe('Actions', () => {
6
- const mockActions: Action[] = [
7
- {
8
- name: 'greet',
9
- description: 'Greet someone',
10
- examples: [
11
- [
12
- { name: 'name1', content: { text: 'Hello {{name2}}!' } },
13
- {
14
- name: 'name2',
15
- content: { text: 'Hi {{name1}}!', action: 'wave' },
16
- },
17
- ],
18
- [
19
- {
20
- name: 'name1',
21
- content: { text: 'Hey {{name2}}, how are you?' },
22
- },
23
- {
24
- name: 'name2',
25
- content: { text: "I'm good {{name1}}, thanks!" },
26
- },
27
- ],
28
- ],
29
- similes: ['say hi', 'welcome'],
30
- handler: async () => {
31
- throw new Error('Not implemented');
32
- },
33
- validate: async () => {
34
- throw new Error('Not implemented');
35
- },
36
- },
37
- {
38
- name: 'farewell',
39
- description: 'Say goodbye',
40
- examples: [
41
- [
42
- { name: 'name1', content: { text: 'Goodbye {{name2}}!' } },
43
- { name: 'name2', content: { text: 'Bye {{name1}}!' } },
44
- ],
45
- ],
46
- similes: ['say bye', 'leave'],
47
- handler: async () => {
48
- throw new Error('Not implemented');
49
- },
50
- validate: async () => {
51
- throw new Error('Not implemented');
52
- },
53
- },
54
- {
55
- name: 'help',
56
- description: 'Get assistance',
57
- examples: [
58
- [
59
- {
60
- name: 'name1',
61
- content: { text: 'Can you help me {{name2}}?' },
62
- },
63
- {
64
- name: 'name2',
65
- content: {
66
- text: 'Of course {{name1}}, what do you need?',
67
- action: 'assist',
68
- },
69
- },
70
- ],
71
- ],
72
- similes: ['assist', 'support'],
73
- handler: async () => {
74
- throw new Error('Not implemented');
75
- },
76
- validate: async () => {
77
- throw new Error('Not implemented');
78
- },
79
- },
80
- ];
81
-
82
- describe('composeActionExamples', () => {
83
- it('should generate examples with correct format', () => {
84
- const examples = composeActionExamples(mockActions, 1);
85
- const lines = examples.trim().split('\n');
86
- expect(lines.length).toBeGreaterThan(0);
87
- expect(lines[0]).toMatch(/^name\d: .+/);
88
- });
89
-
90
- it('should replace name placeholders with generated names', () => {
91
- const examples = composeActionExamples(mockActions, 1);
92
- expect(examples).not.toContain('{{name1}}');
93
- expect(examples).not.toContain('{{name2}}');
94
- });
95
-
96
- it('should handle empty actions array', () => {
97
- const examples = composeActionExamples([], 5);
98
- expect(examples).toBe('');
99
- });
100
-
101
- it('should handle count larger than available examples', () => {
102
- const examples = composeActionExamples(mockActions, 10);
103
- expect(examples.length).toBeGreaterThan(0);
104
- });
105
-
106
- it('should handle actions without examples', () => {
107
- const actionsWithoutExamples: Action[] = [
108
- {
109
- name: 'test',
110
- description: 'Test action without examples',
111
- examples: [], // Empty examples array
112
- similes: [],
113
- handler: async () => {
114
- throw new Error('Not implemented');
115
- },
116
- validate: async () => {
117
- throw new Error('Not implemented');
118
- },
119
- },
120
- {
121
- name: 'test2',
122
- description: 'Test action with no examples property',
123
- // examples property not defined
124
- similes: [],
125
- handler: async () => {
126
- throw new Error('Not implemented');
127
- },
128
- validate: async () => {
129
- throw new Error('Not implemented');
130
- },
131
- } as Action,
132
- ];
133
-
134
- const examples = composeActionExamples(actionsWithoutExamples, 5);
135
- expect(examples).toBe('');
136
- });
137
-
138
- it('should handle count of zero', () => {
139
- const examples = composeActionExamples(mockActions, 0);
140
- expect(examples).toBe('');
141
- });
142
-
143
- it('should handle negative count', () => {
144
- const examples = composeActionExamples(mockActions, -5);
145
- expect(examples).toBe('');
146
- });
147
- });
148
-
149
- describe('formatActionNames', () => {
150
- it('should format action names correctly', () => {
151
- const formatted = formatActionNames([mockActions[0], mockActions[1]]);
152
- expect(formatted).toMatch(/^(greet|farewell)(, (greet|farewell))?$/);
153
- });
154
-
155
- it('should handle single action', () => {
156
- const formatted = formatActionNames([mockActions[0]]);
157
- expect(formatted).toBe('greet');
158
- });
159
-
160
- it('should handle empty actions array', () => {
161
- const formatted = formatActionNames([]);
162
- expect(formatted).toBe('');
163
- });
164
- });
165
-
166
- describe('formatActions', () => {
167
- it('should format actions with descriptions', () => {
168
- const formatted = formatActions([mockActions[0]]);
169
- expect(formatted).toBe('- **greet**: Greet someone');
170
- });
171
-
172
- it('should include commas and newlines between multiple actions', () => {
173
- const formatted = formatActions([mockActions[0], mockActions[1]]);
174
- const parts = formatted.split('\n');
175
- expect(parts.length).toBe(2);
176
- expect(parts[0]).toMatch(/^- \*\*(greet|farewell)\*\*: /);
177
- expect(parts[1]).toMatch(/^- \*\*(greet|farewell)\*\*: /);
178
- });
179
-
180
- it('should handle empty actions array', () => {
181
- const formatted = formatActions([]);
182
- expect(formatted).toBe('');
183
- });
184
- });
185
-
186
- describe('Action Structure', () => {
187
- it('should validate action structure', () => {
188
- for (const action of mockActions) {
189
- expect(action).toHaveProperty('name');
190
- expect(action).toHaveProperty('description');
191
- expect(action).toHaveProperty('examples');
192
- expect(action).toHaveProperty('similes');
193
- expect(action).toHaveProperty('handler');
194
- expect(action).toHaveProperty('validate');
195
- expect(Array.isArray(action.examples)).toBe(true);
196
- expect(Array.isArray(action.similes)).toBe(true);
197
- }
198
- });
199
-
200
- it('should validate example structure', () => {
201
- for (const action of mockActions) {
202
- for (const example of action.examples ?? []) {
203
- for (const message of example) {
204
- expect(message).toHaveProperty('name');
205
- expect(message).toHaveProperty('content');
206
- expect(message.content).toHaveProperty('text');
207
- }
208
- }
209
- }
210
- });
211
-
212
- it('should have unique action names', () => {
213
- const names = mockActions.map((action) => action.name);
214
- const uniqueNames = new Set(names);
215
- expect(names.length).toBe(uniqueNames.size);
216
- });
217
- });
218
- });