Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Stargaze plugin #1861

Merged
merged 5 commits into from
Jan 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -391,5 +391,10 @@ FUEL_WALLET_PRIVATE_KEY=
# Tokenizer Settings
TOKENIZER_MODEL= # Specify the tokenizer model to be used.
TOKENIZER_TYPE= # Options: tiktoken (for OpenAI models) or auto (AutoTokenizer from Hugging Face for non-OpenAI models). Default: tiktoken.

# Stargaze NFT marketplace from Cosmos (You can use https://graphql.mainnet.stargaze-apis.com/graphql)
STARGAZE_ENDPOINT=

# GenLayer
GENLAYER_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 # Private key of the GenLayer account to use for the agent

1 change: 1 addition & 0 deletions agent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-stargaze": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
Expand Down
3 changes: 3 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ import { suiPlugin } from "@elizaos/plugin-sui";
import { TEEMode, teePlugin } from "@elizaos/plugin-tee";
import { tonPlugin } from "@elizaos/plugin-ton";
import { webSearchPlugin } from "@elizaos/plugin-web-search";
import { echoChamberPlugin } from "@elizaos/plugin-echochambers";
import { stargazePlugin } from "@elizaos/plugin-stargaze";
import { zksyncEraPlugin } from "@elizaos/plugin-zksync-era";
import { availPlugin } from "@elizaos/plugin-avail";
import Database from "better-sqlite3";
Expand Down Expand Up @@ -615,6 +617,7 @@ export async function createAgent(
getSecret(character, "ECHOCHAMBERS_API_KEY")
? echoChamberPlugin
: null,
getSecret(character, "STARGAZE_ENDPOINT") ? stargazePlugin : null,
getSecret(character, "GENLAYER_PRIVATE_KEY")
? genLayerPlugin
: null,
Expand Down
147 changes: 147 additions & 0 deletions packages/client-github/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Client-GitHub for Eliza Framework

## Overview

The `client-github` module is a component of the Eliza framework designed to interact with GitHub repositories. It provides functionalities to clone repositories, manage branches, create pull requests, and maintain file-based knowledge for Eliza agents.

This client leverages GitHub's REST API via the `@octokit/rest` library and includes robust error handling and configuration validation.

## Features

- **Repository Management**: Clone, pull, and switch branches
- **File Processing**: Generate agent memories from repository files
- **Pull Request Management**: Create and manage pull requests programmatically
- **Commit Operations**: Stage, commit, and push files with ease
- **Knowledge Base Integration**: Convert repository content into agent memories
- **Branch Management**: Flexible branch switching and creation

## Installation

Install the package as part of the Eliza framework:
bash
pnpm add @elizaos/client-github

## Configuration

The GitHub client requires the following environment variables:

| Variable | Description | Required |
|-------------------|------------------------------------|----------|
| `GITHUB_OWNER` | Owner of the GitHub repository | Yes |
| `GITHUB_REPO` | Repository name | Yes |
| `GITHUB_BRANCH` | Target branch (default: `main`) | Yes |
| `GITHUB_PATH` | Path to focus on within the repo | Yes |
| `GITHUB_API_TOKEN`| GitHub API token for authentication| Yes |

## Usage

### Initialization
typescript:packages/client-github/README.md
import { GitHubClientInterface } from "@elizaos/client-github";
// Initialize the client
const client = await GitHubClientInterface.start(runtime);

### Creating Memories

```typescript
// Convert repository files to agent memories
await client.createMemoriesFromFiles();

typescript
// Convert repository files to agent memories
await client.createMemoriesFromFiles();
```

### Creating Pull Requests

```typescript
await client.createPullRequest(
"Feature: Add new functionality",
"feature/new-feature",
[
{
path: "src/feature.ts",
content: "// New feature implementation"
}
],
"Implements new functionality with tests"
);


typescript
await client.createPullRequest(
"Feature: Add new functionality",
"feature/new-feature",
[
{
path: "src/feature.ts",
content: "// New feature implementation"
}
],
"Implements new functionality with tests"
);
```

### Direct Commits

```typescript
await client.createCommit(
"Update configuration",
[
{
path: "config.json",
content: JSON.stringify(config, null, 2)
}
]
);


```

## API Reference

### GitHubClientInterface

- `start(runtime: IAgentRuntime)`: Initialize the client
- `stop(runtime: IAgentRuntime)`: Clean up resources

### GitHubClient

- `initialize()`: Set up repository and configuration
- `createMemoriesFromFiles()`: Generate agent memories
- `createPullRequest(title: string, branch: string, files: Array<{path: string, content: string}>, description?: string)`: Create PR
- `createCommit(message: string, files: Array<{path: string, content: string}>)`: Direct commit

## Scripts

```bash
# Build the project
pnpm run build

# Development with watch mode
pnpm run dev

# Lint the codebase
pnpm run lint
```

## Dependencies

- `@elizaos/core`: ^0.1.7-alpha.2
- `@octokit/rest`: ^20.1.1
- `@octokit/types`: ^12.6.0
- `glob`: ^10.4.5
- `simple-git`: ^3.27.0

## Development Dependencies

- `@types/glob`: ^8.1.0
- `tsup`: ^8.3.5

## Contribution

Contributions are welcome! Please ensure all code adheres to the framework's standards and passes linting checks.

## License

This project is licensed under the MIT License. See the LICENSE file for details.
37 changes: 37 additions & 0 deletions packages/plugin-stargaze/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Plugin Stargaze

A plugin for fetching NFT data from the Stargaze API.

## Overview

The Plugin Stargaze provides a simple interface to get NFT data from Stargaze collections. It integrates with Stargaze's GraphQL API to fetch the latest NFTs from collections.

## Installation

```bash
pnpm add @elizaos/plugin-stargaze
```

## Configuration

Set up your environment with the required Stargaze API endpoint, currently Stargaze offers https://graphql.mainnet.stargaze-apis.com/graphql publically.

| Variable Name | Description |
| ------------- | ----------- |
| `STARGAZE_ENDPOINT` | Stargaze GraphQL API endpoint |

## Usage

```typescript
import { stargazePlugin } from "@elizaos/plugin-stargaze";

// Initialize the plugin
const plugin = stargazePlugin;

// The plugin provides the GET_LATEST_NFT action which can be used to fetch NFTs
// Example: "Show me the latest NFT from ammelia collection"
```

## License

MIT
18 changes: 18 additions & 0 deletions packages/plugin-stargaze/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "@elizaos/plugin-stargaze",
"version": "0.1.0",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@elizaos/core": "workspace:*",
"axios": "^1.6.7",
"tsup": "^8.3.5",
"zod": "^3.22.4"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"test": "vitest run"
}
}
Loading
Loading