Skip to content

Commit 6855a25

Browse files
Merge pull request #433 from ai16z/imports
fix: linting and imports ready for npm
2 parents 714a380 + 18c9fad commit 6855a25

19 files changed

+192
-170
lines changed

README_IT.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,4 @@ pnpm install --include=optional sharp
8989

9090
## Cronologia Stelle
9191

92-
[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date)
92+
[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date)

agent/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export async function loadCharacters(
9696
} catch (e) {
9797
console.error(`Error loading character from ${path}: ${e}`);
9898
// don't continue to load if a specified file is not found
99-
process.exit(1)
99+
process.exit(1);
100100
}
101101
}
102102
}

docs/docs/core/agents.md

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ await memoryManager.createMemory({
252252
roomId,
253253
});
254254
```
255+
255256
---
256257

257258
## Further Reading

docs/docs/core/evaluators.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ sidebar_position: 5
1010

1111
## Overview
1212

13-
Evaluators enable agents to:
13+
Evaluators enable agents to:
1414

1515
- Build long-term memory
1616
- Track goal progress

packages/core/src/runtime.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
type Memory,
4343
} from "./types.ts";
4444
import { stringToUuid } from "./uuid.ts";
45-
import { v4 as uuidv4 } from 'uuid';
45+
import { v4 as uuidv4 } from "uuid";
4646

4747
/**
4848
* Represents the runtime environment for an agent, handling message processing,

packages/core/src/test_resources/createRuntime.ts

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import { SqliteDatabaseAdapter, loadVecExtensions } from "@ai16z/adapter-sqlite";
1+
import {
2+
SqliteDatabaseAdapter,
3+
loadVecExtensions,
4+
} from "@ai16z/adapter-sqlite";
25
import { SqlJsDatabaseAdapter } from "@ai16z/adapter-sqljs";
36
import { SupabaseDatabaseAdapter } from "@ai16z/adapter-supabase";
47
import { DatabaseAdapter } from "../database.ts";
58
import { AgentRuntime } from "../runtime.ts";
6-
import {
7-
Action,
8-
Evaluator,
9-
ModelProviderName,
10-
Provider,
11-
} from "../types.ts";
9+
import { Action, Evaluator, ModelProviderName, Provider } from "../types.ts";
1210
import {
1311
SUPABASE_ANON_KEY,
1412
SUPABASE_URL,

packages/core/src/test_resources/testSetup.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import path from "path";
33

44
// Load test environment variables
55
const envPath = path.resolve(__dirname, "../../.env.test");
6-
console.log('Current directory:', __dirname);
7-
console.log('Trying to load env from:', envPath);
6+
console.log("Current directory:", __dirname);
7+
console.log("Trying to load env from:", envPath);
88
const result = dotenv.config({ path: envPath });
99
if (result.error) {
10-
console.error('Error loading .env.test:', result.error);
10+
console.error("Error loading .env.test:", result.error);
1111
}

packages/core/src/tests/env.test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
import { describe, it, expect } from 'vitest';
2-
import fs from 'fs';
3-
import path from 'path';
1+
import { describe, it, expect } from "vitest";
2+
import fs from "fs";
3+
import path from "path";
44

5-
describe('Environment Setup', () => {
6-
it('should verify .env.test file exists', () => {
5+
describe("Environment Setup", () => {
6+
it("should verify .env.test file exists", () => {
77
const possiblePaths = [
8-
path.join(process.cwd(), '.env.test'),
9-
path.join(process.cwd(), 'packages/core/.env.test'),
10-
path.join(__dirname, '../../.env.test'),
11-
path.join(__dirname, '../.env.test'),
12-
path.join(__dirname, '.env.test'),
8+
path.join(process.cwd(), ".env.test"),
9+
path.join(process.cwd(), "packages/core/.env.test"),
10+
path.join(__dirname, "../../.env.test"),
11+
path.join(__dirname, "../.env.test"),
12+
path.join(__dirname, ".env.test"),
1313
];
1414

15-
console.log('Current working directory:', process.cwd());
16-
console.log('__dirname:', __dirname);
17-
18-
const existingPaths = possiblePaths.filter(p => {
15+
console.log("Current working directory:", process.cwd());
16+
console.log("__dirname:", __dirname);
17+
18+
const existingPaths = possiblePaths.filter((p) => {
1919
const exists = fs.existsSync(p);
2020
console.log(`Path ${p} exists: ${exists}`);
2121
return exists;
2222
});
2323

2424
expect(existingPaths.length).toBeGreaterThan(0);
2525
});
26-
});
26+
});

packages/core/src/tests/goals.test.ts

+7-13
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
State,
2020
} from "../types";
2121

22-
import { describe, test, expect, beforeEach, vi } from 'vitest';
22+
import { describe, test, expect, beforeEach, vi } from "vitest";
2323

2424
// Mock the database adapter
2525
export const mockDatabaseAdapter = {
@@ -180,9 +180,7 @@ const sampleGoal: Goal = {
180180

181181
describe("getGoals", () => {
182182
it("retrieves goals successfully", async () => {
183-
(mockDatabaseAdapter.getGoals).mockResolvedValue([
184-
sampleGoal,
185-
]);
183+
mockDatabaseAdapter.getGoals.mockResolvedValue([sampleGoal]);
186184

187185
const result = await getGoals({
188186
runtime: mockRuntime,
@@ -199,7 +197,7 @@ describe("getGoals", () => {
199197
});
200198

201199
it("handles failure to retrieve goals", async () => {
202-
(mockDatabaseAdapter.getGoals).mockRejectedValue(
200+
mockDatabaseAdapter.getGoals.mockRejectedValue(
203201
new Error("Failed to retrieve goals")
204202
);
205203

@@ -225,9 +223,7 @@ describe("formatGoalsAsString", () => {
225223

226224
describe("updateGoal", () => {
227225
it("updates a goal successfully", async () => {
228-
(mockDatabaseAdapter.updateGoal).mockResolvedValue(
229-
undefined
230-
);
226+
mockDatabaseAdapter.updateGoal.mockResolvedValue(undefined);
231227

232228
await expect(
233229
updateGoal({ runtime: mockRuntime, goal: sampleGoal })
@@ -236,7 +232,7 @@ describe("updateGoal", () => {
236232
});
237233

238234
it("handles failure to update a goal", async () => {
239-
(mockDatabaseAdapter.updateGoal).mockRejectedValue(
235+
mockDatabaseAdapter.updateGoal.mockRejectedValue(
240236
new Error("Failed to update goal")
241237
);
242238

@@ -248,9 +244,7 @@ describe("updateGoal", () => {
248244

249245
describe("createGoal", () => {
250246
it("creates a goal successfully", async () => {
251-
(mockDatabaseAdapter.createGoal).mockResolvedValue(
252-
undefined
253-
);
247+
mockDatabaseAdapter.createGoal.mockResolvedValue(undefined);
254248

255249
await expect(
256250
createGoal({ runtime: mockRuntime, goal: sampleGoal })
@@ -259,7 +253,7 @@ describe("createGoal", () => {
259253
});
260254

261255
it("handles failure to create a goal", async () => {
262-
(mockDatabaseAdapter.createGoal).mockRejectedValue(
256+
mockDatabaseAdapter.createGoal.mockRejectedValue(
263257
new Error("Failed to create goal")
264258
);
265259

packages/core/src/tests/messages.test.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
formatTimestamp,
66
} from "../messages.ts";
77
import { IAgentRuntime, Actor, Content, Memory, UUID } from "../types.ts";
8-
import { describe, test, expect, vi, beforeAll } from 'vitest';
8+
import { describe, test, expect, vi, beforeAll } from "vitest";
99

1010
describe("Messages Library", () => {
1111
let runtime: IAgentRuntime;
@@ -42,7 +42,9 @@ describe("Messages Library", () => {
4242
const roomId: UUID = "room1234-1234-1234-1234-123456789abc" as UUID;
4343

4444
// Using vi.mocked() type assertion instead of jest.Mock casting
45-
vi.mocked(runtime.databaseAdapter.getParticipantsForRoom).mockResolvedValue([userId]);
45+
vi.mocked(
46+
runtime.databaseAdapter.getParticipantsForRoom
47+
).mockResolvedValue([userId]);
4648
vi.mocked(runtime.databaseAdapter.getAccountById).mockResolvedValue({
4749
id: userId,
4850
name: "Test User",

packages/core/src/tests/models.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { getModel, getEndpoint } from "../models.ts";
22
import { ModelProviderName, ModelClass } from "../types.ts";
3-
import { describe, test, expect, vi } from 'vitest';
3+
import { describe, test, expect, vi } from "vitest";
44

55
vi.mock("../settings", () => {
66
return {
@@ -12,7 +12,7 @@ vi.mock("../settings", () => {
1212
OPENROUTER_API_KEY: "mock-openrouter-key",
1313
},
1414
loadEnv: vi.fn(),
15-
}
15+
};
1616
});
1717

1818
describe("Model Provider Tests", () => {

packages/core/src/tests/relationships.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
formatRelationships,
66
} from "../relationships";
77
import { IAgentRuntime, type Relationship, type UUID } from "../types";
8-
import { describe, expect, vi } from 'vitest';
8+
import { describe, expect, vi } from "vitest";
99

1010
// Mock runtime and databaseAdapter
1111
const mockDatabaseAdapter = {

packages/core/src/tests/token.test.ts

+25-24
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import { createRuntime } from "../test_resources/createRuntime";
33
import { TokenProvider, WalletProvider } from "@ai16z/plugin-solana";
44
import { Connection, PublicKey } from "@solana/web3.js";
5-
import { describe, test, expect, beforeEach, vi } from 'vitest';
6-
import NodeCache from 'node-cache';
5+
import { describe, test, expect, beforeEach, vi } from "vitest";
6+
import NodeCache from "node-cache";
77

88
describe("TokenProvider Tests", async () => {
99
let tokenProvider: TokenProvider;
@@ -13,14 +13,14 @@ describe("TokenProvider Tests", async () => {
1313
vi.clearAllMocks();
1414

1515
const { runtime } = await createRuntime({
16-
env: process.env,
17-
conversationLength: 10,
16+
env: process.env,
17+
conversationLength: 10,
1818
});
1919

2020
const walletProvider = new WalletProvider(
21-
new Connection(runtime.getSetting("RPC_URL")),
22-
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))
23-
);
21+
new Connection(runtime.getSetting("RPC_URL")),
22+
new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY"))
23+
);
2424
// Create new instance of TokenProvider
2525
tokenProvider = new TokenProvider(
2626
"2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh",
@@ -31,31 +31,30 @@ describe("TokenProvider Tests", async () => {
3131
(tokenProvider as any).cache.flushAll();
3232
(tokenProvider as any).cache.close();
3333
(tokenProvider as any).cache = new NodeCache();
34-
34+
3535
// Mock the getCachedData method instead
36-
vi.spyOn(tokenProvider as any, 'getCachedData').mockReturnValue(null);
36+
vi.spyOn(tokenProvider as any, "getCachedData").mockReturnValue(null);
3737
});
3838

3939
test("should fetch token security data", async () => {
40-
4140
// Mock the response for the fetchTokenSecurity call
4241
const mockFetchResponse = {
43-
success: true,
44-
data: {
45-
ownerBalance: "100",
46-
creatorBalance: "50",
47-
ownerPercentage: 10,
48-
creatorPercentage: 5,
49-
top10HolderBalance: "200",
50-
top10HolderPercent: 20,
51-
},
42+
success: true,
43+
data: {
44+
ownerBalance: "100",
45+
creatorBalance: "50",
46+
ownerPercentage: 10,
47+
creatorPercentage: 5,
48+
top10HolderBalance: "200",
49+
top10HolderPercent: 20,
50+
},
5251
};
53-
52+
5453
// Mock fetchWithRetry function
5554
const fetchSpy = vi
56-
.spyOn(tokenProvider as any, "fetchWithRetry")
57-
.mockResolvedValue(mockFetchResponse);
58-
55+
.spyOn(tokenProvider as any, "fetchWithRetry")
56+
.mockResolvedValue(mockFetchResponse);
57+
5958
// Run the fetchTokenSecurity method
6059
const securityData = await tokenProvider.fetchTokenSecurity();
6160
// Check if the data returned is correct
@@ -70,7 +69,9 @@ describe("TokenProvider Tests", async () => {
7069

7170
// Ensure the mock was called with correct URL
7271
expect(fetchSpy).toHaveBeenCalledWith(
73-
expect.stringContaining("https://public-api.birdeye.so/defi/token_security?address=2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh"),
72+
expect.stringContaining(
73+
"https://public-api.birdeye.so/defi/token_security?address=2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh"
74+
)
7475
);
7576
});
7677
});

0 commit comments

Comments
 (0)