Skip to content

Commit

Permalink
Merge pull request #287 from ai16z/starknet-plugin
Browse files Browse the repository at this point in the history
feat: Starknet plugin
  • Loading branch information
lalalune authored Nov 15, 2024
2 parents 4d1e66c + 3d68fa9 commit 8fe9cb5
Show file tree
Hide file tree
Showing 126 changed files with 27,186 additions and 5,082 deletions.
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ TELEGRAM_BOT_TOKEN=

TOGETHER_API_KEY=
SERVER_PORT=3000

# Starknet
STARKNET_ADDRESS=
STARKNET_PRIVATE_KEY=
28 changes: 28 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PR Title Check

on:
pull_request:
types: [opened, edited, synchronize]

jobs:
check-pr-title:
runs-on: ubuntu-latest

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Validate PR title
id: validate
run: |
PR_TITLE=$(jq -r .pull_request.title "$GITHUB_EVENT_PATH")
echo "PR Title: $PR_TITLE"
if [[ ! "$PR_TITLE" =~ ^(feat|fix|docs|style|refactor|test|chore):\ .+ ]]; then
echo "PR title does not match the required pattern."
exit 1
fi
- name: Set status
if: failure()
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "❌ PR title does not match the required pattern. Please use the format: 'type: description' (e.g., 'feat: add new feature')."
4 changes: 2 additions & 2 deletions packages/adapter-postgres/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
type Relationship,
type UUID,
Participant,
} from "@ai16z/eliza/src/types.ts";
import { DatabaseAdapter } from "@ai16z/eliza/src/database.ts";
} from "@ai16z/eliza";
import { DatabaseAdapter } from "@ai16z/eliza";
const { Pool } = pg;

export class PostgresDatabaseAdapter extends DatabaseAdapter {
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-sqljs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export * from "./sqliteTables.ts";
export * from "./types.ts";

import { v4 } from "uuid";
import { DatabaseAdapter } from "@ai16z/eliza/src/database.ts";
import { DatabaseAdapter } from "@ai16z/eliza";
import {
Account,
Actor,
Expand All @@ -12,7 +12,7 @@ import {
type Relationship,
type UUID,
Participant,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";
import { sqliteTables } from "./sqliteTables.ts";
import { Database } from "./types.ts";

Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-supabase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"tsup": "^8.3.5"
},
"scripts": {
"build": "echo 'No build step required'",
"build": "tsup --format esm --dts",
"dev": "tsup --watch"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/adapter-supabase/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {
type UUID,
Participant,
Room,
} from "@ai16z/eliza/src/types.ts";
import { DatabaseAdapter } from "@ai16z/eliza/src/database.ts";
} from "@ai16z/eliza";
import { DatabaseAdapter } from "@ai16z/eliza";
import { v4 as uuid } from "uuid";
export class SupabaseDatabaseAdapter extends DatabaseAdapter {
async getRoom(roomId: UUID): Promise<UUID | null> {
Expand Down
28 changes: 14 additions & 14 deletions packages/agent/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { PostgresDatabaseAdapter } from "@ai16z/adapter-postgres/src/index.ts";
import { SqliteDatabaseAdapter } from "@ai16z/adapter-sqlite/src/index.ts";
import { DirectClientInterface } from "@ai16z/client-direct/src/index.ts";
import { DiscordClientInterface } from "@ai16z/client-discord/src/index.ts";
import { AutoClientInterface } from "@ai16z/client-auto/src/index.ts";
import { TelegramClientInterface } from "@ai16z/client-telegram/src/index.ts";
import { TwitterClientInterface } from "@ai16z/client-twitter/src/index.ts";
import { defaultCharacter } from "@ai16z/eliza/src/defaultCharacter.ts";
import { AgentRuntime } from "@ai16z/eliza/src/runtime.ts";
import settings from "@ai16z/eliza/src/settings.ts";
import { PostgresDatabaseAdapter } from "@ai16z/adapter-postgres";
import { SqliteDatabaseAdapter } from "@ai16z/adapter-sqlite";
import { DirectClientInterface } from "@ai16z/client-direct";
import { DiscordClientInterface } from "@ai16z/client-discord";
import { AutoClientInterface } from "@ai16z/client-auto";
import { TelegramClientInterface } from "@ai16z/client-telegram";
import { TwitterClientInterface } from "@ai16z/client-twitter";
import { defaultCharacter } from "@ai16z/eliza";
import { AgentRuntime } from "@ai16z/eliza";
import { settings } from "@ai16z/eliza";
import {
Character,
IAgentRuntime,
IDatabaseAdapter,
ModelProviderName,
} from "@ai16z/eliza/src/types.ts";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap/src/index.ts";
import { solanaPlugin } from "@ai16z/plugin-solana/src/index.ts";
import { nodePlugin } from "@ai16z/plugin-node/src/index.ts";
} from "@ai16z/eliza";
import { bootstrapPlugin } from "@ai16z/plugin-bootstrap";
import { solanaPlugin } from "@ai16z/plugin-solana";
import { nodePlugin } from "@ai16z/plugin-node";
import Database from "better-sqlite3";
import fs from "fs";
import readline from "readline";
Expand Down
2 changes: 1 addition & 1 deletion packages/client-auto/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, IAgentRuntime } from "@ai16z/eliza/src/types.ts";
import { Client, IAgentRuntime } from "@ai16z/eliza";
import { TrustScoreManager } from "@ai16z/plugin-solana/src/providers/trustScoreProvider.ts";
import { TokenProvider } from "@ai16z/plugin-solana/src/providers/token.ts";
import { WalletProvider } from "@ai16z/plugin-solana/src/providers/wallet.ts";
Expand Down
6 changes: 6 additions & 0 deletions packages/client-auto/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export default defineConfig({
"https",
"http",
"agentkeepalive",
"safe-buffer",
"base-x",
"bs58",
"borsh",
"@solana/buffer-layout",
"ws",
// Add other modules you want to externalize
],
});
20 changes: 10 additions & 10 deletions packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import bodyParser from "body-parser";
import cors from "cors";
import express, { Request as ExpressRequest } from "express";
import multer, { File } from "multer";
import { generateCaption, generateImage } from "@ai16z/eliza/src/generation.ts";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateMessageResponse } from "@ai16z/eliza/src/generation.ts";
import { messageCompletionFooter } from "@ai16z/eliza/src/parsing.ts";
import { AgentRuntime } from "@ai16z/eliza/src/runtime.ts";
import { generateCaption, generateImage } from "@ai16z/eliza";
import { composeContext } from "@ai16z/eliza";
import { generateMessageResponse } from "@ai16z/eliza";
import { messageCompletionFooter } from "@ai16z/eliza";
import { AgentRuntime } from "@ai16z/eliza";
import {
Content,
Memory,
ModelClass,
State,
Client,
IAgentRuntime,
} from "@ai16z/eliza/src/types.ts";
import { stringToUuid } from "@ai16z/eliza/src/uuid.ts";
import settings from "@ai16z/eliza/src/settings.ts";
} from "@ai16z/eliza";
import { stringToUuid } from "@ai16z/eliza";
import { settings } from "@ai16z/eliza";
const upload = multer({ storage: multer.memoryStorage() });

export const messageHandlerTemplate =
Expand Down Expand Up @@ -187,9 +187,9 @@ export class DirectClient {

await runtime.messageManager.createMemory(memory);

const state = (await runtime.composeState(userMessage, {
const state = await runtime.composeState(userMessage, {
agentName: runtime.character.name,
})) as State;
});

const context = composeContext({
state,
Expand Down
1 change: 1 addition & 0 deletions packages/client-direct/tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default defineConfig({
"https",
"http",
"agentkeepalive",
"safe-buffer",
// Add other modules you want to externalize
],
});
10 changes: 5 additions & 5 deletions packages/client-discord/src/actions/chat_with_attachments.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from "fs";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateText, trimTokens } from "@ai16z/eliza/src/generation.ts";
import models from "@ai16z/eliza/src/models.ts";
import { parseJSONObjectFromText } from "@ai16z/eliza/src/parsing.ts";
import { composeContext } from "@ai16z/eliza";
import { generateText, trimTokens } from "@ai16z/eliza";
import { models } from "@ai16z/eliza";
import { parseJSONObjectFromText } from "@ai16z/eliza";
import {
Action,
ActionExample,
Expand All @@ -12,7 +12,7 @@ import {
Memory,
ModelClass,
State,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";
export const summarizationTemplate = `# Summarized so far (we are adding to this)
{{currentSummary}}
Expand Down
9 changes: 4 additions & 5 deletions packages/client-discord/src/actions/download_media.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from "path";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { parseJSONObjectFromText } from "@ai16z/eliza/src/parsing.ts";
import { composeContext } from "@ai16z/eliza";
import { parseJSONObjectFromText } from "@ai16z/eliza";
import {
Action,
ActionExample,
Expand All @@ -13,9 +13,8 @@ import {
Service,
ServiceType,
State,
} from "@ai16z/eliza/src/types.ts";
import { VideoService } from "@ai16z/plugin-node/src/services/video.ts";
import { generateText } from "@ai16z/eliza/src/generation.ts";
} from "@ai16z/eliza";
import { generateText } from "@ai16z/eliza";

export const mediaUrlTemplate = `# Messages we are searching for a media URL
{{recentMessages}}
Expand Down
4 changes: 2 additions & 2 deletions packages/client-discord/src/actions/joinvoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
Guild,
GuildMember,
} from "discord.js";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { composeContext } from "@ai16z/eliza";
import {
Action,
ActionExample,
IAgentRuntime,
Memory,
State,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";

export default {
name: "JOIN_VOICE",
Expand Down
2 changes: 1 addition & 1 deletion packages/client-discord/src/actions/leavevoice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
IAgentRuntime,
Memory,
State,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";

export default {
name: "LEAVE_VOICE",
Expand Down
22 changes: 7 additions & 15 deletions packages/client-discord/src/actions/summarize_conversation.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import fs from "fs";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import {
generateText,
splitChunks,
trimTokens,
} from "@ai16z/eliza/src/generation.ts";
import { getActorDetails } from "@ai16z/eliza/src/messages.ts";
import models from "@ai16z/eliza/src/models.ts";
import { parseJSONObjectFromText } from "@ai16z/eliza/src/parsing.ts";
import { composeContext } from "@ai16z/eliza";
import { generateText, splitChunks, trimTokens } from "@ai16z/eliza";
import { getActorDetails } from "@ai16z/eliza";
import { models } from "@ai16z/eliza";
import { parseJSONObjectFromText } from "@ai16z/eliza";
import {
Action,
ActionExample,
Expand All @@ -18,7 +14,7 @@ import {
Memory,
ModelClass,
State,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";
export const summarizationTemplate = `# Summarized so far (we are adding to this)
{{currentSummary}}
Expand Down Expand Up @@ -256,11 +252,7 @@ const summarizeAction = {
const model = models[runtime.character.settings.model];
const chunkSize = model.settings.maxContextLength - 1000;

const chunks = await splitChunks(
formattedMemories,
chunkSize,
0
);
const chunks = await splitChunks(formattedMemories, chunkSize, 0);

const datestr = new Date().toUTCString().replace(/:/g, "-");

Expand Down
8 changes: 4 additions & 4 deletions packages/client-discord/src/actions/transcribe_media.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from "fs";
import { composeContext } from "@ai16z/eliza/src/context.ts";
import { generateText } from "@ai16z/eliza/src/generation.ts";
import { parseJSONObjectFromText } from "@ai16z/eliza/src/parsing.ts";
import { composeContext } from "@ai16z/eliza";
import { generateText } from "@ai16z/eliza";
import { parseJSONObjectFromText } from "@ai16z/eliza";
import {
Action,
ActionExample,
Expand All @@ -11,7 +11,7 @@ import {
Memory,
ModelClass,
State,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";
export const transcriptionTemplate = `# Transcription of media file
{{mediaTranscript}}
Expand Down
9 changes: 5 additions & 4 deletions packages/client-discord/src/attachments.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateText, trimTokens } from "@ai16z/eliza/src/generation.ts";
import { parseJSONObjectFromText } from "@ai16z/eliza/src/parsing.ts";
import { generateText, trimTokens } from "@ai16z/eliza";
import { parseJSONObjectFromText } from "@ai16z/eliza";
import {
IAgentRuntime,
IImageDescriptionService,
Expand All @@ -10,7 +10,7 @@ import {
ModelClass,
Service,
ServiceType,
} from "@ai16z/eliza/src/types.ts";
} from "@ai16z/eliza";
import { Attachment, Collection } from "discord.js";
import ffmpeg from "fluent-ffmpeg";
import fs from "fs";
Expand Down Expand Up @@ -103,7 +103,8 @@ export class AttachmentManager {
media = await this.processImageAttachment(attachment);
} else if (
attachment.contentType?.startsWith("video/") ||
this.runtime.getService(ServiceType.VIDEO)
this.runtime
.getService(ServiceType.VIDEO)
.getInstance<IVideoService>()
.isVideoUrl(attachment.url)
) {
Expand Down
13 changes: 4 additions & 9 deletions packages/client-discord/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { embeddingZeroVector } from "@ai16z/eliza/src/memory.ts";
import {
Character,
Client as ElizaClient,
IAgentRuntime,
} from "@ai16z/eliza/src/types.ts";
import { stringToUuid } from "@ai16z/eliza/src/uuid.ts";
import { elizaLogger } from "@ai16z/eliza/src/logger.ts";
import { embeddingZeroVector } from "@ai16z/eliza";
import { Character, Client as ElizaClient, IAgentRuntime } from "@ai16z/eliza";
import { stringToUuid } from "@ai16z/eliza";
import { elizaLogger } from "@ai16z/eliza";
import {
Client,
Events,
Expand Down Expand Up @@ -73,7 +69,6 @@ export class DiscordClient extends EventEmitter {
this.runtime.registerAction(transcribe_media);
this.runtime.registerAction(download_media);


this.runtime.providers.push(channelStateProvider);
this.runtime.providers.push(voiceStateProvider);
}
Expand Down
Loading

0 comments on commit 8fe9cb5

Please sign in to comment.