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: added new adapter - zktls - reclaim #1558

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -356,3 +356,11 @@ CRONOSZKEVM_PRIVATE_KEY=

# Fuel Ecosystem (FuelVM)
FUEL_WALLET_PRIVATE_KEY=

# Reclaim Protocol
RECLAIM_APP_ID= # Reclaim App ID
RECLAIM_APP_SECRET= # Reclaim App Secret

# Verifiable Inference Configuration
VERIFIABLE_INFERENCE_ENABLED=false # Set to true to enable verifiable inference
VERIFIABLE_INFERENCE_PROVIDER=reclaim # Options: reclaim, opacity
143 changes: 72 additions & 71 deletions agent/package.json
Original file line number Diff line number Diff line change
@@ -1,73 +1,74 @@
{
"name": "@elizaos/agent",
"version": "0.1.7-alpha.2",
"main": "src/index.ts",
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm src/index.ts",
"dev": "node --loader ts-node/esm src/index.ts",
"check-types": "tsc --noEmit",
"test": "jest"
},
"nodemonConfig": {
"watch": [
"src",
"../core/dist"
],
"ext": "ts,json",
"exec": "node --enable-source-maps --loader ts-node/esm src/index.ts"
},
"dependencies": {
"@elizaos/adapter-postgres": "workspace:*",
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-gitbook": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"@elizaos/plugin-twitter": "workspace:*",
"@elizaos/plugin-cronoszkevm": "workspace:*",
"@elizaos/plugin-3d-generation": "workspace:*",
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
"name": "@elizaos/agent",
"version": "0.1.7-alpha.2",
"main": "src/index.ts",
"type": "module",
"scripts": {
"start": "node --loader ts-node/esm src/index.ts",
"dev": "node --loader ts-node/esm src/index.ts",
"check-types": "tsc --noEmit",
"test": "jest"
},
"nodemonConfig": {
"watch": [
"src",
"../core/dist"
],
"ext": "ts,json",
"exec": "node --enable-source-maps --loader ts-node/esm src/index.ts"
},
"dependencies": {
"@elizaos/adapter-postgres": "workspace:*",
"@elizaos/adapter-reclaim": "workspace:*",
"@elizaos/adapter-redis": "workspace:*",
"@elizaos/adapter-sqlite": "workspace:*",
"@elizaos/client-auto": "workspace:*",
"@elizaos/client-direct": "workspace:*",
"@elizaos/client-discord": "workspace:*",
"@elizaos/client-farcaster": "workspace:*",
"@elizaos/client-lens": "workspace:*",
"@elizaos/client-telegram": "workspace:*",
"@elizaos/client-twitter": "workspace:*",
"@elizaos/client-slack": "workspace:*",
"@elizaos/core": "workspace:*",
"@elizaos/plugin-0g": "workspace:*",
"@elizaos/plugin-abstract": "workspace:*",
"@elizaos/plugin-aptos": "workspace:*",
"@elizaos/plugin-bootstrap": "workspace:*",
"@elizaos/plugin-intiface": "workspace:*",
"@elizaos/plugin-coinbase": "workspace:*",
"@elizaos/plugin-conflux": "workspace:*",
"@elizaos/plugin-evm": "workspace:*",
"@elizaos/plugin-flow": "workspace:*",
"@elizaos/plugin-gitbook": "workspace:*",
"@elizaos/plugin-story": "workspace:*",
"@elizaos/plugin-goat": "workspace:*",
"@elizaos/plugin-icp": "workspace:*",
"@elizaos/plugin-image-generation": "workspace:*",
"@elizaos/plugin-nft-generation": "workspace:*",
"@elizaos/plugin-node": "workspace:*",
"@elizaos/plugin-solana": "workspace:*",
"@elizaos/plugin-starknet": "workspace:*",
"@elizaos/plugin-ton": "workspace:*",
"@elizaos/plugin-sui": "workspace:*",
"@elizaos/plugin-tee": "workspace:*",
"@elizaos/plugin-multiversx": "workspace:*",
"@elizaos/plugin-near": "workspace:*",
"@elizaos/plugin-zksync-era": "workspace:*",
"@elizaos/plugin-twitter": "workspace:*",
"@elizaos/plugin-cronoszkevm": "workspace:*",
"@elizaos/plugin-3d-generation": "workspace:*",
"@elizaos/plugin-fuel": "workspace:*",
"@elizaos/plugin-avalanche": "workspace:*",
"readline": "1.3.0",
"ws": "8.18.0",
"yargs": "17.7.2"
},
"devDependencies": {
"@types/jest": "^29.5.14",
"jest": "^29.7.0",
"ts-jest": "^29.2.5",
"ts-node": "10.9.2",
"tsup": "8.3.5"
}
}
18 changes: 18 additions & 0 deletions agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { LensAgentClient } from "@elizaos/client-lens";
import { SlackClientInterface } from "@elizaos/client-slack";
import { TelegramClientInterface } from "@elizaos/client-telegram";
import { TwitterClientInterface } from "@elizaos/client-twitter";
import { ReclaimAdapter } from "@elizaos/adapter-reclaim";
import {
AgentRuntime,
CacheManager,
Expand Down Expand Up @@ -512,6 +513,22 @@ export async function createAgent(
);
}

// Initialize Reclaim adapter if environment variables are present
let verifiableInferenceAdapter;
if (
process.env.RECLAIM_APP_ID &&
process.env.RECLAIM_APP_SECRET &&
process.env.VERIFIABLE_INFERENCE_ENABLED === "true"
) {
verifiableInferenceAdapter = new ReclaimAdapter({
appId: process.env.RECLAIM_APP_ID,
appSecret: process.env.RECLAIM_APP_SECRET,
modelProvider: character.modelProvider,
token,
});
elizaLogger.log("Verifiable inference adapter initialized");
}

return new AgentRuntime({
databaseAdapter: db,
token,
Expand Down Expand Up @@ -607,6 +624,7 @@ export async function createAgent(
managers: [],
cacheManager: cache,
fetch: logFetch,
verifiableInferenceAdapter,
});
}

Expand Down
101 changes: 101 additions & 0 deletions packages/adapter-reclaim/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# @elizaos/adapter-reclaim

This adapter integrates Reclaim Protocol into ElizaOS, enabling verifiable inference results from various AI model providers. It implements the `IVerifiableInferenceAdapter` interface, making it compatible with other verifiable inference solutions.

## Installation

```bash
pnpm add @elizaos/adapter-reclaim
```

## Configuration

Add the following environment variables to your `.env` file:

```env
RECLAIM_APP_ID=your_app_id
RECLAIM_APP_SECRET=your_app_secret
```

## Usage

```typescript
import { ReclaimAdapter } from "@elizaos/adapter-reclaim";
import { VerifiableInferenceOptions } from "@elizaos/core";

// Initialize the adapter
const reclaimAdapter = new ReclaimAdapter(runtime, {
appId: process.env.RECLAIM_APP_ID,
appSecret: process.env.RECLAIM_APP_SECRET,
});

// Generate text with verifiable results
const options: VerifiableInferenceOptions = {
// Optional: Override the default endpoint
endpoint: "https://custom-api.example.com",
// Optional: Add custom headers
headers: {
"X-Custom-Header": "value",
},
// Optional: Provider-specific options
providerOptions: {
temperature: 0.7,
},
};

const result = await reclaimAdapter.generateText(
"What is Node.js?",
"gpt-4",
options
);

console.log("Response:", result.text);
console.log("Proof:", result.proof);

// Verify the proof
const isValid = await reclaimAdapter.verifyProof(result);
console.log("Proof is valid:", isValid);
```

## Features

- Implements `IVerifiableInferenceAdapter` interface for standardized verifiable inference
- Zero-knowledge proofs for AI model responses
- Support for multiple AI model providers:
- OpenAI
- Anthropic
- Google
- More coming soon
- Customizable options for each request
- Built-in proof verification

## Response Format

The adapter returns a `VerifiableInferenceResult` object containing:

```typescript
{
text: string; // The generated text response
proof: unknown; // The proof data
provider: string; // The provider name (e.g., "reclaim")
timestamp: number; // Generation timestamp
metadata?: { // Optional metadata
modelProvider: string;
modelClass: string;
endpoint: string;
}
}
```

## How it Works

The Reclaim adapter wraps AI model API calls with zero-knowledge proofs using the `@reclaimprotocol/zk-fetch` library. This allows you to:

1. Make verifiable API calls to AI model providers
2. Generate proofs of the responses
3. Verify the authenticity of the responses
4. Ensure the responses haven't been tampered with

## License

MIT
23 changes: 23 additions & 0 deletions packages/adapter-reclaim/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "@elizaos/adapter-reclaim",
"version": "0.1.7-alpha.2",
"description": "Reclaim Protocol adapter for ElizaOS",
"main": "dist/index.js",
"type": "module",
"types": "dist/index.d.ts",
"scripts": {
"build": "tsup src/index.ts --format esm --dts",
"lint": "eslint --fix --cache .",
"watch": "tsc --watch",
"dev": "tsup src/index.ts --format esm --dts --watch"
},
"dependencies": {
"@elizaos/core": "workspace:*",
"@reclaimprotocol/zk-fetch": "^0.3.0",
"@reclaimprotocol/js-sdk": "^2.1.3",
"dotenv": "^16.4.5"
},
"devDependencies": {
"tsup": "^8.3.5"
}
}
Loading
Loading