@elizaos/cli 1.2.4 → 1.2.7
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/bun-exec-KJOLGZOL.js +21 -0
- package/dist/{chunk-2XI6N7KN.js → chunk-2ZF5OAMV.js} +322 -69
- package/dist/chunk-3YTIOEFK.js +202 -0
- package/dist/chunk-AQ6OMR2A.js +14 -0
- package/dist/{chunk-JZG5QBNT.js → chunk-E54G6FI7.js} +32 -6
- package/dist/{chunk-PSSTO76B.js → chunk-KKAK7OQA.js} +100 -104
- package/dist/chunk-Y5IA2UZ2.js +154 -0
- package/dist/commands/agent/actions/index.js +4 -3
- package/dist/commands/agent/index.js +4 -3
- package/dist/commands/create/actions/index.d.ts +6 -2
- package/dist/commands/create/actions/index.js +8 -7
- package/dist/commands/create/index.js +6 -6
- package/dist/commands/shared/index.js +1 -1
- package/dist/index.js +323 -258
- package/dist/{plugin-creator-5CER524N.js → plugin-creator-Y2NWASXI.js} +16 -15
- package/dist/{registry-SN5V2VXR.js → registry-K2OCCRXO.js} +4 -3
- package/dist/templates/plugin-quick-starter/README.md +214 -0
- package/dist/templates/plugin-quick-starter/bunfig.toml +10 -0
- package/dist/templates/plugin-quick-starter/package.json +76 -0
- package/dist/templates/plugin-quick-starter/scripts/install-test-deps.js +53 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +209 -0
- package/dist/templates/plugin-quick-starter/src/__tests__/test-utils.ts +162 -0
- package/dist/templates/plugin-quick-starter/src/index.ts +4 -0
- package/dist/templates/plugin-quick-starter/src/plugin.ts +272 -0
- package/dist/templates/plugin-quick-starter/tsconfig.build.json +11 -0
- package/dist/templates/plugin-quick-starter/tsconfig.json +28 -0
- package/dist/templates/plugin-quick-starter/tsup.config.ts +20 -0
- package/dist/templates/plugin-starter/package.json +2 -2
- package/dist/templates/plugin-starter/scripts/install-test-deps.js +7 -3
- package/dist/templates/plugin-starter/src/__tests__/build-order.test.ts +51 -0
- package/dist/templates/plugin-starter/src/__tests__/vite-config-utils.ts +33 -0
- package/dist/templates/plugin-starter/src/plugin.ts +13 -15
- package/dist/templates/plugin-starter/tsup.config.ts +1 -1
- package/dist/templates/plugin-starter/vite.config.ts +1 -1
- package/dist/templates/project-starter/package.json +4 -4
- package/dist/templates/project-starter/scripts/install-test-deps.js +7 -3
- package/dist/templates/project-starter/src/__tests__/build-order.test.ts +59 -0
- package/dist/templates/project-starter/src/__tests__/character-plugin-ordering.test.ts +11 -110
- package/dist/templates/project-starter/src/__tests__/vite-config-utils.ts +33 -0
- package/dist/templates/project-starter/src/character.ts +14 -17
- package/dist/templates/project-starter/tsup.config.ts +1 -1
- package/dist/templates/project-tee-starter/package.json +3 -3
- package/dist/templates/project-tee-starter/src/character.ts +3 -0
- package/dist/{utils-DTW3XU6O.js → utils-QSRUVLAT.js} +4 -3
- package/package.json +6 -6
- package/templates/plugin-quick-starter/README.md +214 -0
- package/templates/plugin-quick-starter/bunfig.toml +10 -0
- package/templates/plugin-quick-starter/package.json +76 -0
- package/templates/plugin-quick-starter/scripts/install-test-deps.js +53 -0
- package/templates/plugin-quick-starter/src/__tests__/plugin.test.ts +209 -0
- package/templates/plugin-quick-starter/src/__tests__/test-utils.ts +162 -0
- package/templates/plugin-quick-starter/src/index.ts +4 -0
- package/templates/plugin-quick-starter/src/plugin.ts +272 -0
- package/templates/plugin-quick-starter/tsconfig.build.json +11 -0
- package/templates/plugin-quick-starter/tsconfig.json +28 -0
- package/templates/plugin-quick-starter/tsup.config.ts +20 -0
- package/templates/plugin-starter/package.json +2 -2
- package/templates/plugin-starter/scripts/install-test-deps.js +7 -3
- package/templates/plugin-starter/src/__tests__/build-order.test.ts +51 -0
- package/templates/plugin-starter/src/__tests__/vite-config-utils.ts +33 -0
- package/templates/plugin-starter/src/plugin.ts +13 -15
- package/templates/plugin-starter/tsup.config.ts +1 -1
- package/templates/plugin-starter/vite.config.ts +1 -1
- package/templates/project-starter/package.json +4 -4
- package/templates/project-starter/scripts/install-test-deps.js +7 -3
- package/templates/project-starter/src/__tests__/build-order.test.ts +59 -0
- package/templates/project-starter/src/__tests__/character-plugin-ordering.test.ts +11 -110
- package/templates/project-starter/src/__tests__/vite-config-utils.ts +33 -0
- package/templates/project-starter/src/character.ts +14 -17
- package/templates/project-starter/tsup.config.ts +1 -1
- package/templates/project-tee-starter/package.json +3 -3
- package/templates/project-tee-starter/src/character.ts +3 -0
- package/dist/chunk-5DYKNYEY.js +0 -2262
- package/dist/chunk-XB5JBFO6.js +0 -41
- package/dist/chunk-ZWDXDKSA.js +0 -281
- package/dist/setup-UQOWDHFN.js +0 -20
- package/dist/templates/plugin-starter/dist/index.js +0 -391
- package/dist/templates/plugin-starter/dist/index.js.map +0 -1
- package/templates/plugin-starter/dist/.vite/manifest.json +0 -11
- package/templates/plugin-starter/dist/index.d.ts +0 -14
- package/templates/plugin-starter/dist/index.js +0 -391
- package/templates/plugin-starter/dist/index.js.map +0 -1
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { mock, spyOn } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
Content,
|
|
4
|
+
IAgentRuntime,
|
|
5
|
+
Memory,
|
|
6
|
+
ModelType,
|
|
7
|
+
Service,
|
|
8
|
+
State,
|
|
9
|
+
UUID,
|
|
10
|
+
logger,
|
|
11
|
+
} from '@elizaos/core';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Creates a mock runtime for testing
|
|
15
|
+
*
|
|
16
|
+
* @param overrides - Optional overrides for the default mock methods and properties
|
|
17
|
+
* @returns A mock runtime for testing
|
|
18
|
+
*/
|
|
19
|
+
export function createMockRuntime(overrides: Partial<MockRuntime> = {}): MockRuntime {
|
|
20
|
+
// Create base mock runtime with defaults
|
|
21
|
+
const mockRuntime: MockRuntime = {
|
|
22
|
+
// Core properties
|
|
23
|
+
agentId: 'test-agent-id' as UUID,
|
|
24
|
+
character: {
|
|
25
|
+
name: 'Test Character',
|
|
26
|
+
bio: 'This is a test character for testing',
|
|
27
|
+
},
|
|
28
|
+
services: new Map(),
|
|
29
|
+
|
|
30
|
+
// Core methods
|
|
31
|
+
getService: mock().mockReturnValue(null),
|
|
32
|
+
registerService: mock(),
|
|
33
|
+
getSetting: mock().mockReturnValue(null),
|
|
34
|
+
|
|
35
|
+
// Model methods
|
|
36
|
+
useModel: mock().mockImplementation((modelType, params) => {
|
|
37
|
+
if (modelType === ModelType.TEXT_SMALL) {
|
|
38
|
+
return Promise.resolve('Never gonna give you up, never gonna let you down');
|
|
39
|
+
} else if (modelType === ModelType.TEXT_LARGE) {
|
|
40
|
+
return Promise.resolve('Never gonna make you cry, never gonna say goodbye');
|
|
41
|
+
} else if (modelType === ModelType.OBJECT_LARGE) {
|
|
42
|
+
return Promise.resolve({
|
|
43
|
+
thought: 'I should respond in a friendly way',
|
|
44
|
+
message: 'Hello there! How can I help you today?',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return Promise.resolve('Default response');
|
|
48
|
+
}),
|
|
49
|
+
|
|
50
|
+
// Additional methods used in tests
|
|
51
|
+
init: mock().mockResolvedValue(undefined),
|
|
52
|
+
...overrides,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// Merge with overrides
|
|
56
|
+
return mockRuntime;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Creates a mock Memory object for testing
|
|
61
|
+
*
|
|
62
|
+
* @param overrides - Optional overrides for the default memory properties
|
|
63
|
+
* @returns A mock memory object
|
|
64
|
+
*/
|
|
65
|
+
export function createMockMemory(overrides: Partial<Memory> = {}): Partial<Memory> {
|
|
66
|
+
return {
|
|
67
|
+
id: 'test-message-id' as UUID,
|
|
68
|
+
roomId: 'test-room-id' as UUID,
|
|
69
|
+
entityId: 'test-entity-id' as UUID,
|
|
70
|
+
agentId: 'test-agent-id' as UUID,
|
|
71
|
+
content: {
|
|
72
|
+
text: 'Test message',
|
|
73
|
+
source: 'test',
|
|
74
|
+
} as Content,
|
|
75
|
+
createdAt: Date.now(),
|
|
76
|
+
...overrides,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Creates a mock State object for testing
|
|
82
|
+
*
|
|
83
|
+
* @param overrides - Optional overrides for the default state properties
|
|
84
|
+
* @returns A mock state object
|
|
85
|
+
*/
|
|
86
|
+
export function createMockState(overrides: Partial<State> = {}): Partial<State> {
|
|
87
|
+
return {
|
|
88
|
+
...overrides,
|
|
89
|
+
values: {
|
|
90
|
+
recentMessages: 'User: Test message',
|
|
91
|
+
...overrides.values,
|
|
92
|
+
},
|
|
93
|
+
data: {
|
|
94
|
+
...overrides.data,
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Creates a standardized setup for testing with consistent mock objects
|
|
101
|
+
*
|
|
102
|
+
* @param overrides - Optional overrides for default mock implementations
|
|
103
|
+
* @returns An object containing mockRuntime, mockMessage, mockState, and callbackFn
|
|
104
|
+
*/
|
|
105
|
+
export function setupTest(
|
|
106
|
+
overrides: {
|
|
107
|
+
runtimeOverrides?: Partial<MockRuntime>;
|
|
108
|
+
messageOverrides?: Partial<Memory>;
|
|
109
|
+
stateOverrides?: Partial<State>;
|
|
110
|
+
} = {}
|
|
111
|
+
) {
|
|
112
|
+
// Create mock callback function
|
|
113
|
+
const callbackFn = mock();
|
|
114
|
+
|
|
115
|
+
// Create a message
|
|
116
|
+
const mockMessage = createMockMemory(overrides.messageOverrides);
|
|
117
|
+
|
|
118
|
+
// Create a state object
|
|
119
|
+
const mockState = createMockState(overrides.stateOverrides);
|
|
120
|
+
|
|
121
|
+
// Create a mock runtime
|
|
122
|
+
const mockRuntime = createMockRuntime({
|
|
123
|
+
...overrides.runtimeOverrides,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
mockRuntime,
|
|
128
|
+
mockMessage,
|
|
129
|
+
mockState,
|
|
130
|
+
callbackFn,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Type definition for the mock runtime
|
|
136
|
+
*/
|
|
137
|
+
export interface MockRuntime {
|
|
138
|
+
agentId: UUID;
|
|
139
|
+
character: {
|
|
140
|
+
name: string;
|
|
141
|
+
bio: string;
|
|
142
|
+
[key: string]: any;
|
|
143
|
+
};
|
|
144
|
+
services: Map<string, Service>;
|
|
145
|
+
getService: ReturnType<typeof mock>;
|
|
146
|
+
registerService: ReturnType<typeof mock>;
|
|
147
|
+
getSetting: ReturnType<typeof mock>;
|
|
148
|
+
useModel: ReturnType<typeof mock>;
|
|
149
|
+
init: ReturnType<typeof mock>;
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Add spy on logger for common usage in tests
|
|
154
|
+
export function setupLoggerSpies() {
|
|
155
|
+
spyOn(logger, 'info').mockImplementation(() => {});
|
|
156
|
+
spyOn(logger, 'error').mockImplementation(() => {});
|
|
157
|
+
spyOn(logger, 'warn').mockImplementation(() => {});
|
|
158
|
+
spyOn(logger, 'debug').mockImplementation(() => {});
|
|
159
|
+
|
|
160
|
+
// allow tests to restore originals
|
|
161
|
+
return () => mock.restore();
|
|
162
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import type { Plugin } from '@elizaos/core';
|
|
2
|
+
import {
|
|
3
|
+
type Action,
|
|
4
|
+
type ActionResult,
|
|
5
|
+
type Content,
|
|
6
|
+
type GenerateTextParams,
|
|
7
|
+
type HandlerCallback,
|
|
8
|
+
type IAgentRuntime,
|
|
9
|
+
type Memory,
|
|
10
|
+
ModelType,
|
|
11
|
+
type Provider,
|
|
12
|
+
type ProviderResult,
|
|
13
|
+
Service,
|
|
14
|
+
type State,
|
|
15
|
+
logger,
|
|
16
|
+
type MessagePayload,
|
|
17
|
+
type WorldPayload,
|
|
18
|
+
EventType,
|
|
19
|
+
} from '@elizaos/core';
|
|
20
|
+
import { z } from 'zod';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Defines the configuration schema for a plugin, including the validation rules for the plugin name.
|
|
24
|
+
*
|
|
25
|
+
* @type {import('zod').ZodObject<{ EXAMPLE_PLUGIN_VARIABLE: import('zod').ZodString }>}
|
|
26
|
+
*/
|
|
27
|
+
const configSchema = z.object({
|
|
28
|
+
EXAMPLE_PLUGIN_VARIABLE: z
|
|
29
|
+
.string()
|
|
30
|
+
.min(1, 'Example plugin variable is not provided')
|
|
31
|
+
.optional()
|
|
32
|
+
.transform((val) => {
|
|
33
|
+
if (!val) {
|
|
34
|
+
logger.warn('Example plugin variable is not provided (this is expected)');
|
|
35
|
+
}
|
|
36
|
+
return val;
|
|
37
|
+
}),
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Example HelloWorld action
|
|
42
|
+
* This demonstrates the simplest possible action structure
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* Action representing a hello world message.
|
|
46
|
+
* @typedef {Object} Action
|
|
47
|
+
* @property {string} name - The name of the action.
|
|
48
|
+
* @property {string[]} similes - An array of related actions.
|
|
49
|
+
* @property {string} description - A brief description of the action.
|
|
50
|
+
* @property {Function} validate - Asynchronous function to validate the action.
|
|
51
|
+
* @property {Function} handler - Asynchronous function to handle the action and generate a response.
|
|
52
|
+
* @property {Object[]} examples - An array of example inputs and expected outputs for the action.
|
|
53
|
+
*/
|
|
54
|
+
const helloWorldAction: Action = {
|
|
55
|
+
name: 'HELLO_WORLD',
|
|
56
|
+
similes: ['GREET', 'SAY_HELLO'],
|
|
57
|
+
description: 'Responds with a simple hello world message',
|
|
58
|
+
|
|
59
|
+
validate: async (
|
|
60
|
+
_runtime: IAgentRuntime,
|
|
61
|
+
_message: Memory,
|
|
62
|
+
_state: State | undefined
|
|
63
|
+
): Promise<boolean> => {
|
|
64
|
+
// Always valid
|
|
65
|
+
return true;
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
handler: async (
|
|
69
|
+
_runtime: IAgentRuntime,
|
|
70
|
+
message: Memory,
|
|
71
|
+
_state: State | undefined,
|
|
72
|
+
_options: Record<string, unknown> = {},
|
|
73
|
+
callback?: HandlerCallback,
|
|
74
|
+
_responses?: Memory[]
|
|
75
|
+
): Promise<ActionResult> => {
|
|
76
|
+
try {
|
|
77
|
+
logger.info('Handling HELLO_WORLD action');
|
|
78
|
+
|
|
79
|
+
// Simple response content for callback
|
|
80
|
+
const responseContent: Content = {
|
|
81
|
+
text: 'hello world!',
|
|
82
|
+
actions: ['HELLO_WORLD'],
|
|
83
|
+
source: message.content.source,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Call back with the hello world message if callback is provided
|
|
87
|
+
if (callback) {
|
|
88
|
+
await callback(responseContent);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Return ActionResult
|
|
92
|
+
return {
|
|
93
|
+
text: 'hello world!',
|
|
94
|
+
success: true,
|
|
95
|
+
data: {
|
|
96
|
+
actions: ['HELLO_WORLD'],
|
|
97
|
+
source: message.content.source,
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
} catch (error) {
|
|
101
|
+
logger.error('Error in HELLO_WORLD action:', error);
|
|
102
|
+
return {
|
|
103
|
+
success: false,
|
|
104
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
examples: [
|
|
110
|
+
[
|
|
111
|
+
{
|
|
112
|
+
name: '{{name1}}',
|
|
113
|
+
content: {
|
|
114
|
+
text: 'Can you say hello?',
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: '{{name2}}',
|
|
119
|
+
content: {
|
|
120
|
+
text: 'hello world!',
|
|
121
|
+
actions: ['HELLO_WORLD'],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Example Hello World Provider
|
|
130
|
+
* This demonstrates the simplest possible provider implementation
|
|
131
|
+
*/
|
|
132
|
+
const helloWorldProvider: Provider = {
|
|
133
|
+
name: 'HELLO_WORLD_PROVIDER',
|
|
134
|
+
description: 'A simple example provider',
|
|
135
|
+
|
|
136
|
+
get: async (
|
|
137
|
+
_runtime: IAgentRuntime,
|
|
138
|
+
_message: Memory,
|
|
139
|
+
_state: State | undefined
|
|
140
|
+
): Promise<ProviderResult> => {
|
|
141
|
+
return {
|
|
142
|
+
text: 'I am a provider',
|
|
143
|
+
values: {},
|
|
144
|
+
data: {},
|
|
145
|
+
};
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export class StarterService extends Service {
|
|
150
|
+
static override serviceType = 'starter';
|
|
151
|
+
|
|
152
|
+
override capabilityDescription =
|
|
153
|
+
'This is a starter service which is attached to the agent through the starter plugin.';
|
|
154
|
+
|
|
155
|
+
constructor(runtime: IAgentRuntime) {
|
|
156
|
+
super(runtime);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static override async start(runtime: IAgentRuntime): Promise<Service> {
|
|
160
|
+
logger.info('Starting starter service');
|
|
161
|
+
const service = new StarterService(runtime);
|
|
162
|
+
return service;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static override async stop(runtime: IAgentRuntime): Promise<void> {
|
|
166
|
+
logger.info('Stopping starter service');
|
|
167
|
+
const service = runtime.getService(StarterService.serviceType);
|
|
168
|
+
if (!service) {
|
|
169
|
+
throw new Error('Starter service not found');
|
|
170
|
+
}
|
|
171
|
+
if ('stop' in service && typeof service.stop === 'function') {
|
|
172
|
+
await service.stop();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
override async stop(): Promise<void> {
|
|
177
|
+
logger.info('Starter service stopped');
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export const starterPlugin: Plugin = {
|
|
182
|
+
name: 'plugin-quick-starter',
|
|
183
|
+
description: 'Quick backend-only plugin template for elizaOS',
|
|
184
|
+
config: {
|
|
185
|
+
EXAMPLE_PLUGIN_VARIABLE: process.env.EXAMPLE_PLUGIN_VARIABLE,
|
|
186
|
+
},
|
|
187
|
+
async init(config: Record<string, string>) {
|
|
188
|
+
logger.info('Initializing plugin-quick-starter');
|
|
189
|
+
try {
|
|
190
|
+
const validatedConfig = await configSchema.parseAsync(config);
|
|
191
|
+
|
|
192
|
+
// Set all environment variables at once
|
|
193
|
+
for (const [key, value] of Object.entries(validatedConfig)) {
|
|
194
|
+
if (value) process.env[key] = value;
|
|
195
|
+
}
|
|
196
|
+
} catch (error) {
|
|
197
|
+
if (error instanceof z.ZodError) {
|
|
198
|
+
throw new Error(
|
|
199
|
+
`Invalid plugin configuration: ${error.errors.map((e) => e.message).join(', ')}`
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
models: {
|
|
206
|
+
[ModelType.TEXT_SMALL]: async (
|
|
207
|
+
_runtime,
|
|
208
|
+
{ prompt, stopSequences = [] }: GenerateTextParams
|
|
209
|
+
) => {
|
|
210
|
+
return 'Never gonna give you up, never gonna let you down, never gonna run around and desert you...';
|
|
211
|
+
},
|
|
212
|
+
[ModelType.TEXT_LARGE]: async (
|
|
213
|
+
_runtime,
|
|
214
|
+
{
|
|
215
|
+
prompt,
|
|
216
|
+
stopSequences = [],
|
|
217
|
+
maxTokens = 8192,
|
|
218
|
+
temperature = 0.7,
|
|
219
|
+
frequencyPenalty = 0.7,
|
|
220
|
+
presencePenalty = 0.7,
|
|
221
|
+
}: GenerateTextParams
|
|
222
|
+
) => {
|
|
223
|
+
return 'Never gonna make you cry, never gonna say goodbye, never gonna tell a lie and hurt you...';
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
routes: [
|
|
227
|
+
{
|
|
228
|
+
name: 'api-status',
|
|
229
|
+
path: '/api/status',
|
|
230
|
+
type: 'GET',
|
|
231
|
+
handler: async (_req: any, res: any) => {
|
|
232
|
+
res.json({
|
|
233
|
+
status: 'ok',
|
|
234
|
+
plugin: 'quick-starter',
|
|
235
|
+
timestamp: new Date().toISOString(),
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
],
|
|
240
|
+
events: {
|
|
241
|
+
[EventType.MESSAGE_RECEIVED]: [
|
|
242
|
+
async (params: MessagePayload) => {
|
|
243
|
+
logger.debug('MESSAGE_RECEIVED event received');
|
|
244
|
+
logger.debug('Message:', params.message);
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
[EventType.VOICE_MESSAGE_RECEIVED]: [
|
|
248
|
+
async (params: MessagePayload) => {
|
|
249
|
+
logger.debug('VOICE_MESSAGE_RECEIVED event received');
|
|
250
|
+
logger.debug('Message:', params.message);
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
[EventType.WORLD_CONNECTED]: [
|
|
254
|
+
async (params: WorldPayload) => {
|
|
255
|
+
logger.debug('WORLD_CONNECTED event received');
|
|
256
|
+
logger.debug('World:', params.world);
|
|
257
|
+
},
|
|
258
|
+
],
|
|
259
|
+
[EventType.WORLD_JOINED]: [
|
|
260
|
+
async (params: WorldPayload) => {
|
|
261
|
+
logger.debug('WORLD_JOINED event received');
|
|
262
|
+
logger.debug('World:', params.world);
|
|
263
|
+
},
|
|
264
|
+
],
|
|
265
|
+
},
|
|
266
|
+
services: [StarterService],
|
|
267
|
+
actions: [helloWorldAction],
|
|
268
|
+
providers: [helloWorldProvider],
|
|
269
|
+
// dependencies: ['@elizaos/plugin-knowledge'], <--- plugin dependecies go here (if requires another plugin)
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
export default starterPlugin;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"lib": ["ESNext", "dom"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"module": "Preserve",
|
|
7
|
+
"moduleResolution": "Bundler",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": false,
|
|
12
|
+
"allowImportingTsExtensions": true,
|
|
13
|
+
"emitDeclarationOnly": true,
|
|
14
|
+
"declaration": true,
|
|
15
|
+
"resolveJsonModule": true,
|
|
16
|
+
"noImplicitAny": true,
|
|
17
|
+
"allowJs": true,
|
|
18
|
+
"checkJs": false,
|
|
19
|
+
"noEmitOnError": false,
|
|
20
|
+
"moduleDetection": "force",
|
|
21
|
+
"allowArbitraryExtensions": true,
|
|
22
|
+
"jsx": "react",
|
|
23
|
+
"isolatedModules": false,
|
|
24
|
+
"noEmit": true
|
|
25
|
+
},
|
|
26
|
+
"include": ["src/**/*.ts"],
|
|
27
|
+
"exclude": ["src/__tests__/**/*", "e2e/**/*", "**/*.test.ts", "**/*.spec.ts"]
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
entry: ['src/index.ts'],
|
|
5
|
+
outDir: 'dist',
|
|
6
|
+
tsconfig: './tsconfig.build.json', // Use build-specific tsconfig
|
|
7
|
+
sourcemap: true,
|
|
8
|
+
clean: false,
|
|
9
|
+
format: ['esm'], // Ensure you're targeting CommonJS
|
|
10
|
+
dts: true, // require DTS so we get d.ts in the dist folder on npm
|
|
11
|
+
external: [
|
|
12
|
+
'dotenv', // Externalize dotenv to prevent bundling
|
|
13
|
+
'fs', // Externalize fs to use Node.js built-in module
|
|
14
|
+
'path', // Externalize other built-ins if necessary
|
|
15
|
+
'https',
|
|
16
|
+
'http',
|
|
17
|
+
'@elizaos/core',
|
|
18
|
+
'zod',
|
|
19
|
+
],
|
|
20
|
+
});
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"tsup.config.ts"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elizaos/core": "1.2.
|
|
43
|
+
"@elizaos/core": "1.2.7",
|
|
44
44
|
"@tanstack/react-query": "^5.80.7",
|
|
45
45
|
"clsx": "^2.1.1",
|
|
46
46
|
"tailwind-merge": "^3.3.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"zod": "3.24.2"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@elizaos/cli": "1.
|
|
52
|
+
"@elizaos/cli": "1.2.7",
|
|
53
53
|
"@tailwindcss/vite": "^4.1.10",
|
|
54
54
|
"@vitejs/plugin-react-swc": "^3.10.2",
|
|
55
55
|
"dotenv": "16.4.5",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { existsSync, readFileSync } from 'fs';
|
|
4
|
-
import { execSync } from 'child_process';
|
|
5
4
|
import { join } from 'path';
|
|
6
5
|
|
|
7
6
|
const testDependencies = {
|
|
@@ -36,10 +35,15 @@ function installTestDependencies() {
|
|
|
36
35
|
|
|
37
36
|
console.log('Installing test dependencies...');
|
|
38
37
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const proc = Bun.spawnSync(['bun', 'add', '-d', ...missingDeps], {
|
|
39
|
+
stdout: 'inherit',
|
|
40
|
+
stderr: 'inherit',
|
|
41
41
|
cwd: process.cwd(),
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
if (proc.exitCode !== 0) {
|
|
45
|
+
throw new Error('bun add command failed');
|
|
46
|
+
}
|
|
43
47
|
console.log('✓ Test dependencies installed successfully');
|
|
44
48
|
} catch (error) {
|
|
45
49
|
console.error('Failed to install test dependencies:', error.message);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { describe, expect, it, beforeAll, afterAll } from 'bun:test';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { $ } from 'bun';
|
|
5
|
+
import { getViteOutDir } from './vite-config-utils';
|
|
6
|
+
|
|
7
|
+
describe('Build Order Integration Test', () => {
|
|
8
|
+
const rootDir = path.resolve(__dirname, '../..');
|
|
9
|
+
const distDir = path.join(rootDir, 'dist');
|
|
10
|
+
let viteBuildDir: string;
|
|
11
|
+
const tsupBuildMarker = path.join(distDir, 'index.js'); // TSup creates this
|
|
12
|
+
|
|
13
|
+
beforeAll(async () => {
|
|
14
|
+
// Get the actual vite build directory from config
|
|
15
|
+
const viteOutDirRelative = await getViteOutDir(rootDir);
|
|
16
|
+
viteBuildDir = path.join(rootDir, viteOutDirRelative);
|
|
17
|
+
|
|
18
|
+
// Clean dist directory before test
|
|
19
|
+
if (fs.existsSync(distDir)) {
|
|
20
|
+
await fs.promises.rm(distDir, { recursive: true, force: true });
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterAll(async () => {
|
|
25
|
+
// Clean up after test
|
|
26
|
+
if (fs.existsSync(distDir)) {
|
|
27
|
+
await fs.promises.rm(distDir, { recursive: true, force: true });
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should ensure vite build outputs persist after tsup build', async () => {
|
|
32
|
+
// Run the full build process
|
|
33
|
+
await $`cd ${rootDir} && bun run build`;
|
|
34
|
+
|
|
35
|
+
const distFiles = fs.readdirSync(distDir);
|
|
36
|
+
|
|
37
|
+
// Should have vite outputs (HTML files)
|
|
38
|
+
expect(distFiles.some((file) => file.endsWith('.html'))).toBe(true);
|
|
39
|
+
|
|
40
|
+
// Should have vite manifest (if configured)
|
|
41
|
+
const viteBuildMarker = path.join(viteBuildDir, '.vite', 'manifest.json');
|
|
42
|
+
expect(fs.existsSync(viteBuildMarker)).toBe(true);
|
|
43
|
+
|
|
44
|
+
// Should have vite assets directory
|
|
45
|
+
expect(distFiles.includes('assets')).toBe(true);
|
|
46
|
+
|
|
47
|
+
// Should have tsup outputs (JS and d.ts files)
|
|
48
|
+
expect(distFiles.some((file) => file === 'index.js')).toBe(true);
|
|
49
|
+
expect(distFiles.some((file) => file === 'index.d.ts')).toBe(true);
|
|
50
|
+
}, 30000); // 30 second timeout for build process
|
|
51
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extracts the Vite build.outDir from vite.config.ts
|
|
6
|
+
* Handles both relative and absolute paths, accounting for Vite's root directory
|
|
7
|
+
*/
|
|
8
|
+
export async function getViteOutDir(packageRoot: string): Promise<string> {
|
|
9
|
+
const viteConfigPath = path.join(packageRoot, 'vite.config.ts');
|
|
10
|
+
|
|
11
|
+
if (!fs.existsSync(viteConfigPath)) {
|
|
12
|
+
throw new Error(`vite.config.ts not found at ${viteConfigPath}`);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Import the vite config dynamically
|
|
16
|
+
const configModule = await import(viteConfigPath);
|
|
17
|
+
const config =
|
|
18
|
+
typeof configModule.default === 'function'
|
|
19
|
+
? configModule.default({ command: 'build', mode: 'production' })
|
|
20
|
+
: configModule.default;
|
|
21
|
+
|
|
22
|
+
let outDir = config.build?.outDir || 'dist';
|
|
23
|
+
const viteRoot = config.root || '.';
|
|
24
|
+
|
|
25
|
+
// If outDir is relative, resolve it relative to the vite root
|
|
26
|
+
if (!path.isAbsolute(outDir)) {
|
|
27
|
+
const viteRootAbsolute = path.resolve(packageRoot, viteRoot);
|
|
28
|
+
outDir = path.resolve(viteRootAbsolute, outDir);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Ensure the path is relative to packageRoot for consistency
|
|
32
|
+
return path.relative(packageRoot, outDir);
|
|
33
|
+
}
|
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Service,
|
|
14
|
-
type State,
|
|
15
|
-
logger,
|
|
1
|
+
import type {
|
|
2
|
+
Action,
|
|
3
|
+
ActionResult,
|
|
4
|
+
Content,
|
|
5
|
+
GenerateTextParams,
|
|
6
|
+
HandlerCallback,
|
|
7
|
+
IAgentRuntime,
|
|
8
|
+
Memory,
|
|
9
|
+
Plugin,
|
|
10
|
+
Provider,
|
|
11
|
+
ProviderResult,
|
|
12
|
+
State,
|
|
16
13
|
} from '@elizaos/core';
|
|
14
|
+
import { ModelType, Service, logger } from '@elizaos/core';
|
|
17
15
|
import { z } from 'zod';
|
|
18
16
|
import { StarterPluginTestSuite } from './tests';
|
|
19
17
|
|
|
@@ -5,7 +5,7 @@ export default defineConfig({
|
|
|
5
5
|
outDir: 'dist',
|
|
6
6
|
tsconfig: './tsconfig.build.json', // Use build-specific tsconfig
|
|
7
7
|
sourcemap: true,
|
|
8
|
-
clean:
|
|
8
|
+
clean: false,
|
|
9
9
|
format: ['esm'], // Ensure you're targeting CommonJS
|
|
10
10
|
dts: true, // require DTS so we get d.ts in the dist folder on npm
|
|
11
11
|
external: [
|