Skip to content

Commit 03717bd

Browse files
committed
move tests
1 parent e81c41f commit 03717bd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+236
-183
lines changed

core/.eslintrc.json

-25
This file was deleted.

core/eslint.config.mjs

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import eslint from '@eslint/js';
2+
import tseslint from '@typescript-eslint/eslint-plugin';
3+
import typescript from '@typescript-eslint/parser';
4+
import prettier from 'eslint-config-prettier';
5+
6+
export default [
7+
// JavaScript and TypeScript files
8+
{
9+
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
10+
languageOptions: {
11+
parser: typescript,
12+
parserOptions: {
13+
ecmaVersion: 'latest',
14+
sourceType: 'module',
15+
project: './tsconfig.json' // Make sure your tsconfig includes @types/node
16+
},
17+
globals: {
18+
// Add Node.js globals
19+
NodeJS: 'readonly',
20+
console: 'readonly',
21+
process: 'readonly',
22+
Buffer: 'readonly',
23+
__dirname: 'readonly',
24+
__filename: 'readonly',
25+
module: 'readonly',
26+
require: 'readonly'
27+
}
28+
},
29+
plugins: {
30+
'@typescript-eslint': tseslint
31+
},
32+
rules: {
33+
...eslint.configs.recommended.rules,
34+
...tseslint.configs.recommended.rules,
35+
"prefer-const": "warn",
36+
"no-constant-binary-expression": "error",
37+
38+
// Disable no-undef as TypeScript handles this better
39+
"no-undef": "off",
40+
41+
// Customize TypeScript rules
42+
"@typescript-eslint/no-explicit-any": "warn", // Changed from error to warn
43+
"@typescript-eslint/no-unused-vars": ["error", {
44+
"argsIgnorePattern": "^_",
45+
"varsIgnorePattern": "^_",
46+
"ignoreRestSiblings": true
47+
}]
48+
}
49+
},
50+
// Add prettier as the last config to override other formatting rules
51+
prettier
52+
];

core/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"types": "dist/index.d.ts",
88
"scripts": {
99
"build": "tsc",
10+
"lint": "eslint . --fix",
1011
"start": "node --loader ts-node/esm src/index.ts",
1112
"start:arok": "node --loader ts-node/esm src/index.ts --characters=\"characters/arok.character.json\"",
1213
"start:service:ruby": "pm2 start npm --name=\"ruby\" --restart-delay=3000 --max-restarts=10 -- run start:ruby",
@@ -25,7 +26,7 @@
2526
"stop:service:tate": "pm2 stop tate",
2627
"start:tate": "node --loader ts-node/esm src/index.ts --characters=\"characters/tate.character.json\"",
2728
"watch": "tsc --watch",
28-
"dev": "nodemon",
29+
"dev": "tsc && nodemon",
2930
"build:docs": "cd docs && npm run build",
3031
"postinstall": "npx playwright install-deps && npx playwright install",
3132
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" jest --runInBand --watch -f",
@@ -35,6 +36,7 @@
3536
"author": "",
3637
"license": "MIT",
3738
"devDependencies": {
39+
"@eslint/js": "^9.13.0",
3840
"@rollup/plugin-commonjs": "25.0.8",
3941
"@rollup/plugin-json": "6.1.0",
4042
"@rollup/plugin-node-resolve": "15.3.0",

core/src/actions/ask_claude.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default {
4949
log_to_file(`${state.agentName}_${datestr}_claude_context`, context);
5050

5151
let responseContent;
52-
let callbackData: Content = {
52+
const callbackData: Content = {
5353
text: undefined, // fill in later
5454
action: "CLAUDE_RESPONSE",
5555
source: "Claude",
@@ -62,7 +62,7 @@ export default {
6262
apiKey: runtime.getSetting("ANTHROPIC_API_KEY"),
6363
});
6464

65-
let attachments = [];
65+
const attachments = [];
6666
for (let triesLeft = 3; triesLeft > 0; triesLeft--) {
6767
try {
6868
const response = await anthropic.messages.create({

core/src/actions/continue.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export default {
8484
template: shouldContinueTemplate,
8585
});
8686

87-
let response = await generateTrueOrFalse({
87+
const response = await generateTrueOrFalse({
8888
context: shouldRespondContext,
8989
modelClass: ModelClass.SMALL,
9090
runtime
@@ -110,7 +110,7 @@ export default {
110110

111111
const { userId, roomId } = message;
112112

113-
let response = await generateMessageResponse({
113+
const response = await generateMessageResponse({
114114
runtime,
115115
context,
116116
modelClass: ModelClass.SMALL,

core/src/actions/pumpfun.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export const createAndBuyToken = async ({
9494
);
9595
if (createResults.success) {
9696
console.log("Success:", `https://pump.fun/${mint.publicKey.toBase58()}`);
97-
let ata = getAssociatedTokenAddressSync(
97+
const ata = getAssociatedTokenAddressSync(
9898
mint.publicKey,
9999
deployer.publicKey,
100100
allowOffCurve
@@ -139,7 +139,7 @@ export const buyToken = async ({
139139
);
140140
if (buyResults.success) {
141141
console.log("Success:", `https://pump.fun/${mint.toBase58()}`);
142-
let ata = getAssociatedTokenAddressSync(
142+
const ata = getAssociatedTokenAddressSync(
143143
mint,
144144
buyer.publicKey,
145145
allowOffCurve
@@ -184,7 +184,7 @@ export const sellToken = async ({
184184
);
185185
if (sellResults.success) {
186186
console.log("Success:", `https://pump.fun/${mint.toBase58()}`);
187-
let ata = getAssociatedTokenAddressSync(
187+
const ata = getAssociatedTokenAddressSync(
188188
mint,
189189
seller.publicKey,
190190
allowOffCurve

core/src/clients/direct/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ this.app.post("/:agentId/whisper", upload.single('file'), async (req: CustomRequ
111111
});
112112

113113
this.app.post("/:agentId/message", async (req: express.Request, res: express.Response) => {
114-
let agentId = req.params.agentId;
114+
const agentId = req.params.agentId;
115115
const roomId = stringToUuid(req.body.roomId ?? ("default-room-" + agentId));
116116
const userId = stringToUuid(req.body.userId ?? "user");
117117

@@ -176,7 +176,7 @@ this.app.post("/:agentId/whisper", upload.single('file'), async (req: CustomRequ
176176
template: messageHandlerTemplate,
177177
});
178178

179-
let response = await generateMessageResponse({
179+
const response = await generateMessageResponse({
180180
runtime: runtime,
181181
context,
182182
modelClass: ModelClass.SMALL,

core/src/clients/discord/actions/chat_with_attachments.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const summarizeAction = {
136136
) => {
137137
state = (await runtime.composeState(message)) as State;
138138

139-
let callbackData: Content = {
139+
const callbackData: Content = {
140140
text: "", // fill in later
141141
action: "CHAT_WITH_ATTACHMENTS_RESPONSE",
142142
source: message.content.source,

core/src/clients/discord/actions/joinvoice.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
}
8282

8383
// We normalize data in from voice channels
84-
let discordMessage = (state.discordChannel ||
84+
const discordMessage = (state.discordChannel ||
8585
state.discordMessage) as DiscordMessage;
8686

8787
if (!discordMessage.content) {

core/src/clients/discord/actions/summarize_conversation.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ const getDateRange = async (
106106
const endInteger = endIntegerString ? parseInt(endIntegerString) : 0;
107107

108108
// multiply by multiplier
109-
let startTime =
109+
const startTime =
110110
startInteger *
111111
multipliers[startMultiplier as keyof typeof multipliers];
112112

113113
console.log("startTime", startTime);
114114

115-
let endTime =
115+
const endTime =
116116
endInteger * multipliers[endMultiplier as keyof typeof multipliers];
117117

118118
console.log("endTime", endTime);
@@ -194,7 +194,7 @@ const summarizeAction = {
194194
state = (await runtime.composeState(message)) as State;
195195
const userId = runtime.agentId;
196196

197-
let callbackData: Content = {
197+
const callbackData: Content = {
198198
text: "", // fill in later
199199
action: "SUMMARIZATION_RESPONSE",
200200
source: message.content.source,

core/src/clients/discord/actions/transcribe_media.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ const transcribeMediaAction = {
109109
) => {
110110
state = (await runtime.composeState(message)) as State;
111111

112-
let callbackData: Content = {
112+
const callbackData: Content = {
113113
text: "", // fill in later
114114
action: "TRANSCRIBE_MEDIA_RESPONSE",
115115
source: message.content.source,

core/src/clients/discord/messages.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ export class MessageManager {
252252

253253
console.log("Responding");
254254

255-
let context = composeContext({
255+
const context = composeContext({
256256
state,
257257
template: messageHandlerTemplate,
258258
});
@@ -305,7 +305,7 @@ export class MessageManager {
305305
files,
306306
);
307307
let notFirstMessage = false;
308-
let memories: Memory[] = [];
308+
const memories: Memory[] = [];
309309
for (const m of messages) {
310310
let action = content.action;
311311
// If there's only one message or it's the last message, keep the original action

core/src/clients/discord/voice.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,14 @@ export class VoiceManager extends EventEmitter {
353353

354354
state = await this.runtime.updateRecentMessageState(state);
355355

356-
let shouldIgnore = await this._shouldIgnore(memory);
356+
const shouldIgnore = await this._shouldIgnore(memory);
357357

358358
if (shouldIgnore) {
359359
transcriptionText = ""; // Reset transcription text
360360
return { text: "", action: "IGNORE" };
361361
}
362362

363-
let context = composeContext({
363+
const context = composeContext({
364364
state,
365365
template: voiceHandlerTemplate,
366366
});
@@ -390,7 +390,7 @@ export class VoiceManager extends EventEmitter {
390390
if (responseMemory.content.text?.trim()) {
391391
await this.runtime.messageManager.createMemory(responseMemory);
392392
state = await this.runtime.updateRecentMessageState(state);
393-
let responseStream = await SpeechService.generate(
393+
const responseStream = await SpeechService.generate(
394394
this.runtime,
395395
content.text,
396396
);

core/src/clients/twitter/generate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export class TwitterGenerationClient extends ClientBase {
118118

119119
const slice = newTweetContent.replaceAll(/\\n/g, "\n").trim();
120120

121-
let content = slice
121+
const content = slice
122122
// .slice(0, 280);
123123
// // if its bigger than 280, delete the last line
124124
// if (content.length > 280) {

core/src/clients/twitter/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export async function buildConversationThread(
3232
tweet: Tweet,
3333
client: ClientBase,
3434
): Promise<void> {
35-
let thread: Tweet[] = [];
35+
const thread: Tweet[] = [];
3636
const visited: Set<string> = new Set();
3737

3838
async function processThread(currentTweet: Tweet) {

core/src/core/context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export const composeContext = ({
2828
state: State;
2929
template: string;
3030
}) => {
31-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
31+
3232
// @ts-expect-error match isn't working as expected
3333
const out = template.replace(/{{\w+}}/g, (match) => {
3434
const key = match.replace(/{{|}}/g, "");

core/src/core/messages.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const formatMessages = ({
6767
.reverse()
6868
.filter((message: Memory) => message.userId)
6969
.map((message: Memory) => {
70-
let messageContent = (message.content as Content).text;
70+
const messageContent = (message.content as Content).text;
7171
const messageAction = (message.content as Content).action;
7272
const formattedName =
7373
actors.find((actor: Actor) => actor.id === message.userId)?.name ||

core/src/core/runtime.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ export class AgentRuntime implements IAgentRuntime {
409409

410410
if (!action) {
411411
// each action has a .similes array, lets see if we can find a match
412-
for (let _action of this.actions) {
412+
for (const _action of this.actions) {
413413
const simileAction = _action.similes.find(
414414
(simile) =>
415415
simile.toLowerCase().replace("_", "").includes(normalizedAction) ||
@@ -698,7 +698,7 @@ Text: ${attachment.text}
698698
const formattedCharacterPostExamples = this.character.postExamples
699699
.sort(() => 0.5 - Math.random())
700700
.map((post) => {
701-
let messageString = `${post}`;
701+
const messageString = `${post}`;
702702
return messageString;
703703
})
704704
.slice(0, 50)

core/src/evaluators/fact.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
6464
template,
6565
});
6666

67-
let facts = await generateObjectArray({
67+
const facts = await generateObjectArray({
6868
runtime,
6969
context,
7070
modelClass: ModelClass.SMALL,
@@ -112,9 +112,9 @@ export default {
112112
"EXTRACT_INFORMATION",
113113
],
114114
validate: async (
115-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
115+
116116
runtime: IAgentRuntime,
117-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
117+
118118
message: Memory,
119119
): Promise<boolean> => {
120120
const messageCount = (await runtime.messageManager.countMemories(

core/src/providers/token.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ export class TokenProvider {
474474

475475
try {
476476
while (true) {
477-
let params = {
477+
const params = {
478478
limit: limit,
479479
displayOptions: {},
480480
mint: this.tokenAddress,

core/src/test_resources/testEvaluator.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ async function handler(runtime: IAgentRuntime, message: Memory) {
1313
export const TEST_EVALUATOR = {
1414
name: "TEST_EVALUATOR",
1515
validate: async (
16-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
16+
1717
_runtime: IAgentRuntime,
18-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
18+
1919
_message: Memory,
2020
): Promise<boolean> => {
2121
return await Promise.resolve(true);
@@ -42,9 +42,9 @@ export const TEST_EVALUATOR = {
4242
export const TEST_EVALUATOR_FAIL = {
4343
name: "TEST_EVALUATOR_FAIL",
4444
validate: async (
45-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
45+
4646
_runtime: IAgentRuntime,
47-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
47+
4848
_message: Memory,
4949
): Promise<boolean> => {
5050
return await Promise.resolve(false);

0 commit comments

Comments
 (0)