Skip to content

Commit

Permalink
rename userId to entityId everywhere because why tf not
Browse files Browse the repository at this point in the history
  • Loading branch information
lalalune committed Mar 5, 2025
1 parent c5a3041 commit 59475df
Show file tree
Hide file tree
Showing 123 changed files with 1,628 additions and 1,770 deletions.
34 changes: 17 additions & 17 deletions packages/agent/src/server/api/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,12 @@ export function agentRouter(
runtime,
req.body.roomId ?? `default-room-${agentId}`
);
const userId = createUniqueUuid(runtime, req.body.userId ?? "user");
const entityId = createUniqueUuid(runtime, req.body.entityId ?? "Anon");
const worldId = req.body.worldId;

try {
await runtime.ensureConnection({
userId,
entityId,
roomId,
userName: req.body.userName,
name: req.body.name,
Expand All @@ -446,13 +446,13 @@ export function agentRouter(

const existingRelationship =
await runtime.databaseAdapter.getRelationship({
sourceEntityId: userId,
sourceEntityId: entityId,
targetEntityId: runtime.agentId,
});

if (!existingRelationship && userId !== runtime.agentId) {
if (!existingRelationship && entityId !== runtime.agentId) {
await runtime.databaseAdapter.createRelationship({
sourceEntityId: userId,
sourceEntityId: entityId,
targetEntityId: runtime.agentId,
tags: ["message_interaction"],
metadata: {
Expand Down Expand Up @@ -492,7 +492,7 @@ export function agentRouter(

const userMessage = {
content,
userId,
entityId,
roomId,
agentId: runtime.agentId,
};
Expand All @@ -501,7 +501,7 @@ export function agentRouter(
id: createUniqueUuid(runtime, messageId),
...userMessage,
agentId: runtime.agentId,
userId,
entityId,
roomId,
content,
createdAt: Date.now(),
Expand Down Expand Up @@ -539,7 +539,7 @@ export function agentRouter(
const responseMessage: Memory = {
id: createUniqueUuid(runtime, messageId),
...userMessage,
userId: runtime.agentId,
entityId: runtime.agentId,
content: response,
createdAt: Date.now(),
};
Expand Down Expand Up @@ -807,7 +807,7 @@ export function agentRouter(
return;
}

const { text, roomId: rawRoomId, userId: rawUserId } = req.body;
const { text, roomId: rawRoomId, entityId: rawUserId } = req.body;
if (!text) {
res.status(400).json({
success: false,
Expand Down Expand Up @@ -837,11 +837,11 @@ export function agentRouter(
runtime,
rawRoomId ?? `default-room-${agentId}`
);
const userId = createUniqueUuid(runtime, rawUserId ?? "user");
const entityId = createUniqueUuid(runtime, rawUserId ?? "Anon");

logger.debug("[SPEECH CONVERSATION] Ensuring connection");
await runtime.ensureConnection({
userId,
entityId,
roomId,
userName: req.body.userName,
name: req.body.name,
Expand All @@ -859,15 +859,15 @@ export function agentRouter(

const userMessage = {
content,
userId,
entityId,
roomId,
agentId: runtime.agentId,
};

const memory: Memory = {
id: messageId,
agentId: runtime.agentId,
userId,
entityId,
roomId,
content,
createdAt: Date.now(),
Expand Down Expand Up @@ -915,7 +915,7 @@ export function agentRouter(
logger.debug("[SPEECH CONVERSATION] Creating response memory");
const responseMessage = {
...userMessage,
userId: runtime.agentId,
entityId: runtime.agentId,
content: response,
};

Expand Down Expand Up @@ -1168,7 +1168,7 @@ export function agentRouter(
}

try {
const { name, worldId, roomId, userId } = req.body;
const { name, worldId, roomId, entityId } = req.body;
const roomName = name || `Chat ${new Date().toLocaleString()}`;

await runtime.ensureRoomExists({
Expand All @@ -1180,10 +1180,10 @@ export function agentRouter(
});

await runtime.databaseAdapter.addParticipant(runtime.agentId, roomName);
await runtime.ensureParticipantInRoom(userId, roomId);
await runtime.ensureParticipantInRoom(entityId, roomId);
await runtime.databaseAdapter.setParticipantUserState(
roomId,
userId,
entityId,
"FOLLOWED"
);

Expand Down
2 changes: 1 addition & 1 deletion packages/agent/src/server/api/tee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function teeRouter(
const teeLogQuery: TeeLogQuery = {
agentId: query.agentId || '',
roomId: query.roomId || '',
userId: query.userId || '',
entityId: query.entityId || '',
type: query.type || '',
containsContent: query.containsContent || '',
startTimestamp: query.startTimestamp || undefined,
Expand Down
16 changes: 8 additions & 8 deletions packages/agent/src/server/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ const replyAction = {
examples: [
[
{
user: "{{user1}}",
name: "{{name1}}",
content: {
text: "Hello there!",
},
},
{
user: "{{user2}}",
name: "{{name2}}",
content: {
text: "Hi! How can I help you today?",
actions: ["REPLY"],
Expand All @@ -53,13 +53,13 @@ const replyAction = {
],
[
{
user: "{{user1}}",
name: "{{name1}}",
content: {
text: "What's your favorite color?",
},
},
{
user: "{{user2}}",
name: "{{name2}}",
content: {
text: "I really like deep shades of blue. They remind me of the ocean and the night sky.",
actions: ["REPLY"],
Expand All @@ -68,13 +68,13 @@ const replyAction = {
],
[
{
user: "{{user1}}",
name: "{{name1}}",
content: {
text: "Can you explain how neural networks work?",
},
},
{
user: "{{user2}}",
name: "{{name2}}",
content: {
text: "Let me break that down for you in simple terms...",
actions: ["REPLY"],
Expand All @@ -83,13 +83,13 @@ const replyAction = {
],
[
{
user: "{{user1}}",
name: "{{name1}}",
content: {
text: "Could you help me solve this math problem?",
},
},
{
user: "{{user2}}",
name: "{{name2}}",
content: {
text: "Of course! Let's work through it step by step.",
actions: ["REPLY"],
Expand Down
Loading

0 comments on commit 59475df

Please sign in to comment.