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(new-plugin): truth social #2537

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
159 changes: 159 additions & 0 deletions packages/client-truth-social/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Truth Social Client

A TypeScript client for interacting with Truth Social's API, built on top of the @ai16z/eliza framework for AI-powered social media interactions.

## System Overview

This client provides automated interaction capabilities with Truth Social, including:

- Posting and responding to content
- Processing mentions and interactions
- Searching and engaging with relevant content
- Managing rate limits and API interactions

### Core Components

1. **API Layer** (`api.ts`)
- Handles direct communication with Truth Social's API
- Manages authentication and rate limiting
- Provides base methods for posts, likes, reposts, etc.

2. **Base Client** (`base.ts`)
- Provides foundational client functionality
- Manages state and caching
- Handles timeline and post fetching

3. **Post Management** (`post.ts`)
- Handles post creation and processing
- Manages periodic posting
- Processes post actions and interactions

4. **Interactions** (`interactions.ts`)
- Manages user interactions and responses
- Handles conversation threading
- Controls engagement limits and timeouts

5. **Search** (`search.ts`)
- Implements search functionality
- Manages topic-based engagement
- Controls post selection and relevance

6. **Environment** (`environment.ts`)
- Manages configuration and settings
- Validates environment variables
- Sets operational parameters

### Supporting Files

- **Types** (`types.ts`): TypeScript interfaces and types
- **Utils** (`utils.ts`): Shared utilities and helper functions
- **Index** (`index.ts`): Main entry point and client initialization

## Requirements

### Dependencies

- Node.js 14+
- TypeScript 4.5+
- @ai16z/eliza framework
wtfsayo marked this conversation as resolved.
Show resolved Hide resolved
- axios
- date-fns
- zod

### Environment Variables

- TRUTHSOCIAL_DRY_RUN: Boolean, if true, the client will not post or interact with Truth Social
- TRUTHSOCIAL_USERNAME: String, the username of the Truth Social account
- TRUTHSOCIAL_PASSWORD: String, the password of the Truth Social account
- MAX_TRUTH_LENGTH: Number, the maximum length of a post
- POST_INTERVAL_MIN: Number, the minimum interval between posts in seconds
- POST_INTERVAL_MAX: Number, the maximum interval between posts in seconds
- ACTION_INTERVAL: Number, the interval between actions in seconds

## Setup

1. Clone the repository
2. Install dependencies: `npm install`
3. Set environment variables
4. Run the client: `npm start`

## Architecture

The system follows a layered architecture:

1. **API Layer** (Bottom)
- Raw API communication
- Rate limiting
- Authentication

2. **Client Layer**
- Base functionality
- State management
- Caching

3. **Feature Layer**
- Post management
- Interactions
- Search
- Content generation

4. **Interface Layer** (Top)
- Client interface
- Runtime management
- Configuration

## File Dependencies

```
index.ts
├── environment.ts
├── base.ts
│ └── api.ts
├── post.ts
│ ├── base.ts
│ └── utils.ts
├── interactions.ts
│ ├── base.ts
│ └── utils.ts
└── search.ts
├── base.ts
└── utils.ts
```

- `api.ts` depends on `types.ts`
- `base.ts` depends on `types.ts`
- `post.ts` depends on `types.ts`
- `interactions.ts` depends on `types.ts`
- `search.ts` depends on `types.ts`
- `environment.ts` depends on `types.ts`
- `utils.ts` depends on `types.ts`
- `index.ts` depends on `types.ts`
- `environment.ts` depends on `types.ts`

## Safety Notes

1. Rate Limiting
- Built-in rate limit management
- Configurable intervals
- Automatic backoff

2. Content Safety
- Content filtering
- Engagement limits
- Conversation depth control

3. Error Handling
- Comprehensive error catching
- Logging
- Graceful degradation

## Usage Warning

This client includes search and interaction capabilities that should be used responsibly.Be aware of:

1. Rate limit implications
2. User privacy considerations
3. Platform terms of service
4. Potential account restrictions

Always test with `TRUTHSOCIAL_DRY_RUN=true` before live deployment.
3 changes: 3 additions & 0 deletions packages/client-truth-social/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import eslintGlobalConfig from "../../eslint.config.mjs";

export default [...eslintGlobalConfig];
24 changes: 24 additions & 0 deletions packages/client-truth-social/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "@ai16z/client-truth",
"version": "0.1.5-alpha.5",
"description": "Truth Social client integration for AI16Z agents",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@ai16z/eliza": "workspace:*",
"glob": "11.0.0",
"zod": "3.23.8"
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

⚠️ Potential issue

Missing @ai16z/eliza package in workspace

The workspace configuration is correct, but the @ai16z/eliza package doesn't exist in the workspace. Either:

  • Add the missing package to the workspace
  • Remove the dependency if it's no longer needed
  • Update the reference if the package name has changed
🔗 Analysis chain

Fix workspace dependency configuration.

The pipeline is failing due to missing @ai16z/eliza workspace dependency. Ensure the workspace is properly configured and the dependency is available.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check workspace configuration
cat pnpm-workspace.yaml || cat package.json | jq '.workspaces'

Length of output: 114


Script:

#!/bin/bash
# Check if @ai16z/eliza package exists
fd --type directory "eliza" packages/

Length of output: 64


Script:

#!/bin/bash
# Search for package.json files containing eliza
fd package.json packages/ --exec grep -l "eliza" {} \;

Length of output: 2025


Script:

#!/bin/bash
# Search for package.json files containing @ai16z/eliza as package name
fd package.json packages/ --exec jq -r 'select(.name == "@ai16z/eliza") | .name' {} \;

Length of output: 91

🧰 Tools
🪛 GitHub Actions: smoke-test

[warning] Unsupported Node.js engine version. Wanted: 23.3.0, Current: 23.6.0


[error] Missing workspace dependency: @ai16z/eliza is listed as a dependency but not present in the workspace


[warning] Local package.json exists but node_modules is missing. Run package installation

"devDependencies": {
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add engines field to specify Node.js version requirements.

Add Node.js version constraints to prevent version mismatches like the current warning (wanted 23.3.0, got 23.6.0).

{
    "name": "@ai16z/client-truth",
+   "engines": {
+     "node": "^23.3.0"
+   },
    ...
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"name": "@ai16z/client-truth",
"version": "0.1.5-alpha.5",
"description": "Truth Social client integration for AI16Z agents",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@ai16z/eliza": "workspace:*",
"glob": "11.0.0",
"zod": "3.23.8"
},
"devDependencies": {
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
}
}
{
"name": "@ai16z/client-truth",
"engines": {
"node": "^23.3.0"
},
"version": "0.1.5-alpha.5",
"description": "Truth Social client integration for AI16Z agents",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"dependencies": {
"@ai16z/eliza": "workspace:*",
"glob": "11.0.0",
"zod": "3.23.8"
},
"devDependencies": {
"tsup": "8.3.5"
},
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint . --fix"
},
"peerDependencies": {
"whatwg-url": "7.1.0"
}
}
🧰 Tools
🪛 GitHub Actions: smoke-test

[warning] Unsupported Node.js engine version. Wanted: 23.3.0, Current: 23.6.0


[error] Missing workspace dependency: @ai16z/eliza is listed as a dependency but not present in the workspace


[warning] Local package.json exists but node_modules is missing. Run package installation

Loading
Loading