Skip to content

Commit

Permalink
Merge branch 'develop' into thirdweb
Browse files Browse the repository at this point in the history
  • Loading branch information
iankm authored Dec 24, 2024
2 parents 90480b4 + 64c5feb commit eff0426
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 67 deletions.
2 changes: 1 addition & 1 deletion docs/community/Notes/lore.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Week 1 Recap: elizaos Launch and Early Developments

Hello, I am Shaw. I am a cross-disciplinary programmer and entrepreneur living in San Francisco. I have been working on autonomous agents for several years and I am overjoyed to finally get to show that to all of you.

I started elizaos here on Twitter with some very capable folks, in the open, using the http://daos.fun platform. Our technology is open source, and powering many of the agents you talk to today. We call this type of agent an eliza.
I started elizaos here on Twitter with some very capable folks, in the open, using the http://daos.fun platform. Our technology is open source, and powering many of the agents you talk to today. We call this type of agent an "eliza".

Our token character agent is @degenspartanai who is a recreation of a legendary friend and poster who quit Twitter last cycle. $degenai is his token.

Expand Down
2 changes: 1 addition & 1 deletion docs/community/creator-fund.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Here's when the community learned about who the top holder is:

> "So a ton of people have been asking (justifiably) who the heck I am, why do I have 16% of elizaos supply, and what I’m going to do with it.
>
> It started by @shawmakesmagic tweeting about some agent he built called @degenspartanai, a recreation of a legend on twitter. I put a bunch of my SOL in there because I had been following Shaw and really thought he was building something great. Almost immediately all of that became close to worthless. Degen’s tweets seemed too human-like to be real anyway - so I figured I got scammed.
> It started by @shawmakesmagic tweeting about some agent he built called @degenspartanai, a recreation of a legend on twitter. I put a bunch of my SOL in there because I had been following Shaw and really thought he was building something great. Almost immediately all of that became close to worthless. Degen’s tweets seemed too "human-like" to be real anyway - so I figured I got scammed.
>
> So I DM’ed shaw, not because I was angry, but I was genuinely curious why he might have scammed me. I ended up sending him a google meet, which turned into an hour long conversation about what he was actually building, and me realizing twitter is usually a misrepresentation of the people you think you know. Shaw is just inspiring. Someone who is completely dedicated to accelerating the world for the better, and not optimizing for optics or money - just building.
>
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/advanced/eliza-in-tee.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The TEE Plugin in the Eliza Framework is built on top of the [Dstack SDK](https:

## Core Components

Eliza's TEE implementation consists of two primary providers that handle secure key managementoperations and remote attestations.
Eliza's TEE implementation consists of two primary providers that handle secure key management operations and remote attestations.

These components work together to provide:

Expand Down
6 changes: 3 additions & 3 deletions packages/adapter-sqljs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ declare class Statement {
getSQL(): string;

/**
* Reset a statement, so that it's parameters can be bound to new
* Reset a statement, so that its parameters can be bound to new
* values. It also clears all previous bindings, freeing the memory used
* by bound parameters.
* @see [https://sql.js.org/documentation/Statement.html#["reset"]](https://sql.js.org/documentation/Statement.html#%5B%22reset%22%5D)
Expand All @@ -115,7 +115,7 @@ declare class Statement {
run(values?: BindParams): void;

/**
* Execute the statement, fetching the the next line of result, that can
* Execute the statement, fetching the next line of result, that can
* be retrieved with `Statement.get`.
* @see [https://sql.js.org/documentation/Statement.html#["step"]](https://sql.js.org/documentation/Statement.html#%5B%22step%22%5D)
*/
Expand Down Expand Up @@ -169,7 +169,7 @@ export declare class Database {
getRowsModified(): number;

/**
* Analyze a result code, return null if no error occured, and throw an
* Analyze a result code, return null if no error occurred, and throw an
* error with a descriptive message otherwise
* @see [https://sql.js.org/documentation/Database.html#["handleError"]](https://sql.js.org/documentation/Database.html#%5B%22handleError%22%5D)
*/
Expand Down
25 changes: 21 additions & 4 deletions packages/client-github/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ export class GitHubClient {

// Clone or pull repository
if (!existsSync(this.repoPath)) {
await this.git.clone(
`https://github.com/${this.config.owner}/${this.config.repo}.git`,
this.repoPath
);
await this.cloneRepository();
} else {
const git = simpleGit(this.repoPath);
await git.pull();
Expand All @@ -73,6 +70,26 @@ export class GitHubClient {
}
}

private async cloneRepository() {
const repositoryUrl = `https://github.com/${this.config.owner}/${this.config.repo}.git`;
const maxRetries = 3;
let retries = 0;

while (retries < maxRetries) {
try {
await this.git.clone(repositoryUrl, this.repoPath);
elizaLogger.log(`Successfully cloned repository from ${repositoryUrl}`);
return;
} catch (error) {
elizaLogger.error(`Failed to clone repository from ${repositoryUrl}. Retrying...`);
retries++;
if (retries === maxRetries) {
throw new Error(`Unable to clone repository from ${repositoryUrl} after ${maxRetries} retries.`);
}
}
}
}

async createMemoriesFromFiles() {
console.log("Create memories");
const searchPath = this.config.path
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const parseShouldRespondFromText = (
: null;
};

export const booleanFooter = `Respond with a YES or a NO.`;
export const booleanFooter = `Respond with only a YES or a NO.`;

export const parseBooleanFromText = (text: string) => {
const match = text.match(/^(YES|NO)$/i);
Expand Down
7 changes: 7 additions & 0 deletions packages/plugin-coinbase/src/plugins/advancedTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const tradeCsvFilePath = path.join(baseDir, "advanced_trades.csv");

const tradeProvider: Provider = {
get: async (runtime: IAgentRuntime, _message: Memory) => {
elizaLogger.debug("Starting tradeProvider function");
try {
const client = new RESTClient(
runtime.getSetting("COINBASE_API_KEY") ??
Expand Down Expand Up @@ -103,6 +104,7 @@ const tradeProvider: Provider = {
};

export async function appendTradeToCsv(tradeResult: any) {
elizaLogger.debug("Starting appendTradeToCsv function");
try {
const csvWriter = createArrayCsvWriter({
path: tradeCsvFilePath,
Expand Down Expand Up @@ -139,6 +141,7 @@ async function hasEnoughBalance(
amount: number,
side: string
): Promise<boolean> {
elizaLogger.debug("Starting hasEnoughBalance function");
try {
const response = await client.listAccounts({});
const accounts = JSON.parse(response);
Expand Down Expand Up @@ -216,6 +219,7 @@ export const executeAdvancedTradeAction: Action = {
let client: RESTClient;

// Initialize client
elizaLogger.debug("Starting advanced trade client initialization");
try {
client = new RESTClient(
runtime.getSetting("COINBASE_API_KEY") ??
Expand All @@ -237,6 +241,7 @@ export const executeAdvancedTradeAction: Action = {

// Generate trade details
let tradeDetails;
elizaLogger.debug("Starting trade details generation");
try {
tradeDetails = await generateObject({
runtime,
Expand Down Expand Up @@ -276,6 +281,7 @@ export const executeAdvancedTradeAction: Action = {

// Configure order
let orderConfiguration: OrderConfiguration;
elizaLogger.debug("Starting order configuration");
try {
if (orderType === "MARKET") {
orderConfiguration =
Expand Down Expand Up @@ -323,6 +329,7 @@ export const executeAdvancedTradeAction: Action = {
// Execute trade
let order: CreateOrderResponse;
try {
elizaLogger.debug("Executing the trade");
if (
!(await hasEnoughBalance(
client,
Expand Down
32 changes: 18 additions & 14 deletions packages/plugin-coinbase/src/plugins/commerce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ interface ChargeRequest {
}

export async function createCharge(apiKey: string, params: ChargeRequest) {
elizaLogger.debug("Starting createCharge function");
try {
const response = await fetch(url, {
method: "POST",
Expand All @@ -47,13 +48,14 @@ export async function createCharge(apiKey: string, params: ChargeRequest) {
const data = await response.json();
return data.data;
} catch (error) {
console.error("Error creating charge:", error);
elizaLogger.error("Error creating charge:", error);
throw error;
}
}

// Function to fetch all charges
export async function getAllCharges(apiKey: string) {
elizaLogger.debug("Starting getAllCharges function");
try {
const response = await fetch(url, {
method: "GET",
Expand All @@ -72,13 +74,14 @@ export async function getAllCharges(apiKey: string) {
const data = await response.json();
return data.data;
} catch (error) {
console.error("Error fetching charges:", error);
elizaLogger.error("Error fetching charges:", error);
throw error;
}
}

// Function to fetch details of a specific charge
export async function getChargeDetails(apiKey: string, chargeId: string) {
elizaLogger.debug("Starting getChargeDetails function");
const getUrl = `${url}${chargeId}`;

try {
Expand All @@ -99,7 +102,7 @@ export async function getChargeDetails(apiKey: string, chargeId: string) {
const data = await response.json();
return data;
} catch (error) {
console.error(
elizaLogger.error(
`Error fetching charge details for ID ${chargeId}:`,
error
);
Expand Down Expand Up @@ -140,7 +143,7 @@ export const createCoinbaseChargeAction: Action = {
_options: any,
callback: HandlerCallback
) => {
elizaLogger.log("Composing state for message:", message);
elizaLogger.info("Composing state for message:", message);
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
Expand Down Expand Up @@ -172,10 +175,10 @@ export const createCoinbaseChargeAction: Action = {
return;
}

elizaLogger.log("Charge details received:", chargeDetails);
elizaLogger.info("Charge details received:", chargeDetails);

// Initialize Coinbase Commerce client

elizaLogger.debug("Starting Coinbase Commerce client initialization");
try {
// Create a charge
const chargeResponse = await createCharge(
Expand All @@ -191,7 +194,7 @@ export const createCoinbaseChargeAction: Action = {
}
);

elizaLogger.log(
elizaLogger.info(
"Coinbase Commerce charge created:",
chargeResponse
);
Expand Down Expand Up @@ -333,7 +336,7 @@ export const getAllChargesAction: Action = {
callback: HandlerCallback
) => {
try {
elizaLogger.log("Composing state for message:", message);
elizaLogger.info("Composing state for message:", message);
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
Expand All @@ -343,7 +346,7 @@ export const getAllChargesAction: Action = {
runtime.getSetting("COINBASE_COMMERCE_KEY")
);

elizaLogger.log("Fetched all charges:", charges);
elizaLogger.info("Fetched all charges:", charges);

callback(
{
Expand Down Expand Up @@ -397,7 +400,7 @@ export const getChargeDetailsAction: Action = {
_options: any,
callback: HandlerCallback
) => {
elizaLogger.log("Composing state for message:", message);
elizaLogger.info("Composing state for message:", message);
if (!state) {
state = (await runtime.composeState(message)) as State;
} else {
Expand Down Expand Up @@ -434,7 +437,7 @@ export const getChargeDetailsAction: Action = {
charge.id
);

elizaLogger.log("Fetched charge details:", chargeDetails);
elizaLogger.info("Fetched charge details:", chargeDetails);

callback(
{
Expand Down Expand Up @@ -486,6 +489,7 @@ export const getChargeDetailsAction: Action = {

export const chargeProvider: Provider = {
get: async (runtime: IAgentRuntime, _message: Memory) => {
elizaLogger.debug("Starting chargeProvider.get function");
const charges = await getAllCharges(
runtime.getSetting("COINBASE_COMMERCE_KEY")
);
Expand All @@ -504,16 +508,16 @@ export const chargeProvider: Provider = {
privateKey: coinbasePrivateKey,
});
const { balances, transactions } = await getWalletDetails(runtime);
elizaLogger.log("Current Balances:", balances);
elizaLogger.log("Last Transactions:", transactions);
elizaLogger.info("Current Balances:", balances);
elizaLogger.info("Last Transactions:", transactions);
}
const formattedCharges = charges.map((charge) => ({
id: charge.id,
name: charge.name,
description: charge.description,
pricing: charge.pricing,
}));
elizaLogger.log("Charges:", formattedCharges);
elizaLogger.info("Charges:", formattedCharges);
return { charges: formattedCharges, balances, transactions };
},
};
Expand Down
Loading

0 comments on commit eff0426

Please sign in to comment.