From 0f8a13310df24b40482857c430923f02f9af36b0 Mon Sep 17 00:00:00 2001 From: Timothee Legros Date: Mon, 6 Jan 2025 18:45:32 +0100 Subject: [PATCH] fix should generate response --- packages/client-common/src/index.ts | 10 ++++++---- packages/client-common/src/messages.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/client-common/src/index.ts b/packages/client-common/src/index.ts index 236c82d887..d5cbda76a1 100644 --- a/packages/client-common/src/index.ts +++ b/packages/client-common/src/index.ts @@ -46,12 +46,13 @@ export class CommonClient { // TODO: fetch user once Common Api Client is published with the new route // const user = await this.commonApiClient.User.getUser(); - const user = { id: 161416, profile: { name: "Eliza Dev 1" } }; + const user = { id: parseInt(process.env.COMMON_USER_ID), profile: { name: "Eliza Dev 1" } }; this.commonUserId = user.id; this.messageManager = new MessageManager( this.commonApiClient, this.runtime, - this.commonUserId + this.commonUserId, + user.profile.name, ); const webhookPath = `/eliza/${user.id}`; @@ -108,12 +109,13 @@ export class CommonClient { // TODO: verify Webhook signature using config.COMMON_WEBHOOK_SIGNING_KEY // Validate body - const { success, data: body } = AgentMentionedSchema.safeParse( + const { success, data: body, error } = AgentMentionedSchema.safeParse( req.body ); if (success === false) { return res.status(400).send({ - error: "Invalid request body", + error: `Invalid request body`, + schemaErrors: error }); } diff --git a/packages/client-common/src/messages.ts b/packages/client-common/src/messages.ts index 9fe5314b28..3bad2cbf35 100644 --- a/packages/client-common/src/messages.ts +++ b/packages/client-common/src/messages.ts @@ -22,16 +22,20 @@ import {CreateCommentResponse} from "@commonxyz/api-client/api"; export class MessageManager { private readonly runtime: IAgentRuntime; private readonly commonApiClient: CommonApiClient; + // TODO: combine into a single Common user with type from common-client GetUser private readonly commonUserId: number; + private readonly commonProfileName: string; constructor( commonApiClient: CommonApiClient, runtime: IAgentRuntime, - commonUserId: number + commonUserId: number, + commonProfileName: string, ) { this.runtime = runtime; this.commonApiClient = commonApiClient; this.commonUserId = commonUserId; + this.commonProfileName = commonProfileName; } private async _shouldRespond( @@ -155,7 +159,7 @@ export class MessageManager { const state = await this.runtime.composeState(memory, { commonClient: this.commonApiClient, commonMessage: message, - agentName: this.runtime.character.name, + agentName: this.commonProfileName, }); if (!(await this._shouldRespond(message, state))) {