Skip to content

Commit 8618d66

Browse files
Merge branch 'main' into ollama-fix
2 parents 95d1dd3 + b08f3f7 commit 8618d66

File tree

115 files changed

+6568
-780
lines changed

Some content is hidden

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

115 files changed

+6568
-780
lines changed

.env.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,5 @@ STARKNET_ADDRESS=
9191
STARKNET_PRIVATE_KEY=
9292
STARKNET_RPC_URL=
9393

94-
94+
# Coinbase Commerce
95+
COINBASE_COMMERCE_KEY=

.github/workflows/ci.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
- name: Run Prettier
2626
run: pnpm run prettier --check .
2727

28+
- name: Run Linter
29+
run: pnpm run lint
30+
2831
- name: Create test env file
2932
run: |
3033
echo "TEST_DATABASE_CLIENT=sqlite" > packages/core/.env.test

.husky/pre-commit

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pnpm run prettier-check
2+
pnpm run lint

agent/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@ai16z/plugin-node": "workspace:*",
2626
"@ai16z/plugin-solana": "workspace:*",
2727
"@ai16z/plugin-starknet": "workspace:*",
28+
"@ai16z/plugin-coinbase": "workspace:*",
2829
"readline": "^1.3.0",
2930
"ws": "^8.18.0",
3031
"yargs": "17.7.2"

agent/src/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
2626
import { solanaPlugin } from "@ai16z/plugin-solana";
2727
import { nodePlugin } from "@ai16z/plugin-node";
28+
import { coinbaseCommercePlugin } from "@ai16z/plugin-coinbase";
2829
import Database from "better-sqlite3";
2930
import fs from "fs";
3031
import readline from "readline";
@@ -249,6 +250,10 @@ export function createAgent(
249250
bootstrapPlugin,
250251
nodePlugin,
251252
character.settings.secrets?.WALLET_PUBLIC_KEY ? solanaPlugin : null,
253+
character.settings.secrets?.COINBASE_COMMERCE_KEY ||
254+
process.env.COINBASE_COMMERCE_KEY
255+
? coinbaseCommercePlugin
256+
: null,
252257
].filter(Boolean),
253258
providers: [],
254259
actions: [],

client/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"devDependencies": {
2626
"@eslint/js": "^9.13.0",
2727
"@types/node": "22.8.4",
28-
"@types/react": "^18.3.12",
29-
"@types/react-dom": "^18.3.1",
28+
"@types/react": "18.3.12",
29+
"@types/react-dom": "18.3.1",
3030
"@vitejs/plugin-react": "^4.3.3",
3131
"autoprefixer": "^10.4.20",
3232
"eslint": "^9.13.0",

docs/docs/packages/plugins.md

+105
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,111 @@ const character = {
106106
};
107107
```
108108

109+
Here is the updated README with the Coinbase Commerce plugin information added:
110+
111+
---
112+
113+
# 🧩 Plugins
114+
115+
## Overview
116+
117+
Eliza's plugin system provides a modular way to extend the core functionality with additional features, actions, evaluators, and providers. Plugins are self-contained modules that can be easily added or removed to customize your agent's capabilities.
118+
119+
## Core Plugin Concepts
120+
121+
### Plugin Structure
122+
123+
Each plugin in Eliza must implement the `Plugin` interface with the following properties:
124+
125+
```typescript
126+
interface Plugin {
127+
name: string; // Unique identifier for the plugin
128+
description: string; // Brief description of plugin functionality
129+
actions?: Action[]; // Custom actions provided by the plugin
130+
evaluators?: Evaluator[]; // Custom evaluators for behavior assessment
131+
providers?: Provider[]; // Context providers for message generation
132+
services?: Service[]; // Additional services (optional)
133+
}
134+
```
135+
136+
### Available Plugins
137+
138+
#### 1. Bootstrap Plugin (`@eliza/plugin-bootstrap`)
139+
140+
The bootstrap plugin provides essential baseline functionality:
141+
142+
**Actions:**
143+
144+
- `continue` - Continue the current conversation flow
145+
- `followRoom` - Follow a room for updates
146+
- `unfollowRoom` - Unfollow a room
147+
- `ignore` - Ignore specific messages
148+
- `muteRoom` - Mute notifications from a room
149+
- `unmuteRoom` - Unmute notifications from a room
150+
151+
**Evaluators:**
152+
153+
- `fact` - Evaluate factual accuracy
154+
- `goal` - Assess goal completion
155+
156+
**Providers:**
157+
158+
- `boredom` - Manages engagement levels
159+
- `time` - Provides temporal context
160+
- `facts` - Supplies factual information
161+
162+
#### 2. Image Generation Plugin (`@eliza/plugin-image-generation`)
163+
164+
Enables AI image generation capabilities:
165+
166+
**Actions:**
167+
168+
- `GENERATE_IMAGE` - Create images based on text descriptions
169+
- Supports multiple image generation services (Anthropic, Together)
170+
- Auto-generates captions for created images
171+
172+
#### 3. Node Plugin (`@eliza/plugin-node`)
173+
174+
Provides core Node.js-based services:
175+
176+
**Services:**
177+
178+
- `BrowserService` - Web browsing capabilities
179+
- `ImageDescriptionService` - Image analysis
180+
- `LlamaService` - LLM integration
181+
- `PdfService` - PDF processing
182+
- `SpeechService` - Text-to-speech
183+
- `TranscriptionService` - Speech-to-text
184+
- `VideoService` - Video processing
185+
186+
#### 4. Solana Plugin (`@eliza/plugin-solana`)
187+
188+
Integrates Solana blockchain functionality:
189+
190+
**Evaluators:**
191+
192+
- `trustEvaluator` - Assess transaction trust scores
193+
194+
**Providers:**
195+
196+
- `walletProvider` - Wallet management
197+
- `trustScoreProvider` - Transaction trust metrics
198+
199+
#### 5. Coinbase Commerce Plugin (`@eliza/plugin-coinbase-commerce`)
200+
201+
Integrates Coinbase Commerce for payment and transaction management:
202+
203+
**Actions:**
204+
205+
- `CREATE_CHARGE` - Create a payment charge using Coinbase Commerce
206+
- `GET_ALL_CHARGES` - Fetch all payment charges
207+
- `GET_CHARGE_DETAILS` - Retrieve details for a specific charge
208+
209+
**Description:**
210+
This plugin enables Eliza to interact with the Coinbase Commerce API to create and manage payment charges, providing seamless integration with cryptocurrency-based payment systems.
211+
212+
---
213+
109214
### Writing Custom Plugins
110215

111216
Create a new plugin by implementing the Plugin interface:

docs/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"clsx": "2.1.0",
2626
"docusaurus-lunr-search": "^3.5.0",
2727
"prism-react-renderer": "2.3.1",
28-
"react": "18.2.0",
29-
"react-dom": "18.2.0",
28+
"react": "18.3.1",
29+
"react-dom": "18.3.1",
3030
"react-router-dom": "6.22.1"
3131
},
3232
"devDependencies": {

eslint.global.mjs

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
import vitest from "eslint-plugin-vitest"; // Add Vitest plugin
6+
7+
export default [
8+
// JavaScript and TypeScript files
9+
{
10+
files: ["src/**/*.js", "src/**/*.cjs", "src/**/*.mjs", "src/**/*.ts"],
11+
languageOptions: {
12+
parser: typescript,
13+
parserOptions: {
14+
ecmaVersion: "latest",
15+
sourceType: "module",
16+
project: "./tsconfig.json", // Make sure your tsconfig includes @types/node
17+
},
18+
globals: {
19+
// Add Node.js globals
20+
NodeJS: "readonly",
21+
console: "readonly",
22+
process: "readonly",
23+
Buffer: "readonly",
24+
__dirname: "readonly",
25+
__filename: "readonly",
26+
module: "readonly",
27+
require: "readonly",
28+
},
29+
},
30+
plugins: {
31+
"@typescript-eslint": tseslint,
32+
},
33+
rules: {
34+
...eslint.configs.recommended.rules,
35+
...tseslint.configs.recommended.rules,
36+
"prefer-const": "warn",
37+
"no-constant-binary-expression": "error",
38+
39+
// Disable no-undef as TypeScript handles this better
40+
"no-undef": "off",
41+
"@typescript-eslint/no-unsafe-function-type": "off",
42+
// Customize TypeScript rules
43+
"@typescript-eslint/no-explicit-any": "off",
44+
"@typescript-eslint/no-unused-vars": [
45+
"error",
46+
{
47+
argsIgnorePattern: "^_",
48+
varsIgnorePattern: "^_",
49+
ignoreRestSiblings: true,
50+
},
51+
],
52+
},
53+
},
54+
// Vitest configuration
55+
{
56+
files: [
57+
"src/**/*.test.js",
58+
"src/**/*.test.ts",
59+
"src/**/*.spec.js",
60+
"src/**/*.spec.ts",
61+
],
62+
plugins: {
63+
vitest, // Register Vitest plugin
64+
},
65+
rules: {
66+
...vitest.configs.recommended.rules,
67+
},
68+
},
69+
// Add prettier as the last config to override other formatting rules
70+
prettier,
71+
];

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"start": "pnpm --filter \"@ai16z/agent\" start --isRoot",
1111
"start:client": "pnpm --dir client start --isRoot",
1212
"dev": "bash ./scripts/dev.sh",
13-
"lint": "pnpm --dir packages/core lint && pnpm --dir packages/agent lint",
13+
"lint": "bash ./scripts/lint.sh",
1414
"prettier-check": "npx prettier --check .",
1515
"prettier": "npx prettier --write .",
1616
"release": "pnpm build && pnpm prettier && npx lerna publish --no-private --force-publish",
@@ -47,7 +47,8 @@
4747
"dependencies": {
4848
"ollama-ai-provider": "^0.16.1",
4949
"optional": "^0.1.4",
50-
"sharp": "^0.33.5"
50+
"sharp": "^0.33.5",
51+
"tslog": "^4.9.3"
5152
},
5253
"packageManager": "pnpm@9.12.3+sha512.cce0f9de9c5a7c95bef944169cc5dfe8741abfb145078c0d508b868056848a87c81e626246cb60967cbd7fd29a6c062ef73ff840d96b3c86c40ac92cf4a813ee"
5354
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/adapter-postgres/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,15 @@
1010
"pg": "^8.13.1"
1111
},
1212
"devDependencies": {
13+
"eslint": "9.13.0",
14+
"eslint-config-prettier": "9.1.0",
15+
"eslint-plugin-prettier": "5.2.1",
16+
"eslint-plugin-vitest": "0.5.4",
1317
"tsup": "^8.3.5"
1418
},
1519
"scripts": {
1620
"build": "tsup --format esm --dts",
17-
"dev": "tsup --format esm --dts --watch"
21+
"dev": "tsup --format esm --dts --watch",
22+
"lint": "eslint . --fix"
1823
}
1924
}

packages/adapter-postgres/src/index.ts

+25-2
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,38 @@ export class PostgresDatabaseAdapter
729729
async addParticipant(userId: UUID, roomId: UUID): Promise<boolean> {
730730
const client = await this.pool.connect();
731731
try {
732+
// Check if the participant already exists
733+
const existingParticipant = await client.query(
734+
`SELECT * FROM participants WHERE "userId" = $1 AND "roomId" = $2`,
735+
[userId, roomId]
736+
);
737+
738+
if (existingParticipant.rows.length > 0) {
739+
console.log(
740+
`Participant with userId ${userId} already exists in room ${roomId}.`
741+
);
742+
return; // Exit early if the participant already exists
743+
}
744+
745+
// Proceed to add the participant if they do not exist
732746
await client.query(
733747
`INSERT INTO participants (id, "userId", "roomId")
734748
VALUES ($1, $2, $3)`,
735749
[v4(), userId, roomId]
736750
);
737751
return true;
738752
} catch (error) {
739-
console.log("Error adding participant", error);
740-
return false;
753+
// This is to prevent duplicate participant error in case of a race condition
754+
// Handle unique constraint violation error (code 23505)
755+
if (error.code === "23505") {
756+
console.warn(
757+
`Participant with userId ${userId} already exists in room ${roomId}.`
758+
); // Optionally, you can log this or handle it differently
759+
} else {
760+
// Handle other errors
761+
console.error("Error adding participant:", error);
762+
return false;
763+
}
741764
} finally {
742765
client.release();
743766
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/adapter-sqlite/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
"sqlite-vec": "0.1.4-alpha.2"
1212
},
1313
"devDependencies": {
14+
"eslint": "9.13.0",
15+
"eslint-config-prettier": "9.1.0",
16+
"eslint-plugin-prettier": "5.2.1",
17+
"eslint-plugin-vitest": "0.5.4",
1418
"tsup": "^8.3.5"
1519
},
1620
"scripts": {
1721
"build": "tsup --format esm --dts",
18-
"dev": "tsup --format esm --dts --watch"
22+
"dev": "tsup --format esm --dts --watch",
23+
"lint": "eslint . --fix"
1924
},
2025
"peerDependencies": {
2126
"whatwg-url": "7.1.0"

packages/adapter-sqlite/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export class SqliteDatabaseAdapter
153153
}
154154
const placeholders = params.roomIds.map(() => "?").join(", ");
155155
let sql = `SELECT * FROM memories WHERE type = ? AND roomId IN (${placeholders})`;
156-
let queryParams = [params.tableName, ...params.roomIds];
156+
const queryParams = [params.tableName, ...params.roomIds];
157157

158158
if (params.agentId) {
159159
sql += ` AND agentId = ?`;
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintGlobalConfig from "../../eslint.global.mjs";
2+
3+
export default [...eslintGlobalConfig];

packages/adapter-sqljs/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
"uuid": "11.0.2"
1212
},
1313
"devDependencies": {
14+
"eslint": "9.13.0",
15+
"eslint-config-prettier": "9.1.0",
16+
"eslint-plugin-prettier": "5.2.1",
17+
"eslint-plugin-vitest": "0.5.4",
1418
"tsup": "^8.3.5"
1519
},
1620
"scripts": {
1721
"build": "tsup --format esm --dts",
18-
"dev": "tsup --watch"
22+
"dev": "tsup --watch",
23+
"lint": "eslint . --fix"
1924
},
2025
"peerDependencies": {
2126
"whatwg-url": "7.1.0"

0 commit comments

Comments
 (0)