Skip to content

Commit

Permalink
fix: Improve agent startup logging and account status management
Browse files Browse the repository at this point in the history
  • Loading branch information
tercel committed Feb 14, 2025
1 parent 10bfa13 commit f63dc5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ const startAgents = async () => {
}

elizaLogger.info(
"Run `pnpm start:client` to start the client and visit the outputted URL (http://localhost:5173) to chat with your agents. When running multiple agents, use client with different port `SERVER_PORT=3001 pnpm start:client`"
`Run 'pnpm start:client' to start the client and visit the outputted URL (http://localhost:${serverPort}) to chat with your agents. When running multiple agents, use client with different port 'SERVER_PORT=${serverPort + 1} pnpm start:client'`
);
};

Expand Down
18 changes: 14 additions & 4 deletions packages/client-direct/src/manage-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ export function createManageApiRouter(
const valid = username === settings.JWT_USERNAME && password === md5(settings.JWT_PASSWORD);
if (valid) {
const token = signToken({ username });
res.json({ success: true, token: token });
const verified = await verifyToken(token);
res.json({ success: true, token: token, exp: verified.exp });
} else {
res.status(400).json({ error: "Invalid username or password" });
}
Expand All @@ -101,12 +102,16 @@ export function createManageApiRouter(
}
const result = await directClient.db.paginate('accounts', params);
if(result.total) {
result.list = result.list.map((item: any) => {
for (const item of result.list) {
if (typeof item.details === "string") {
item.details = item.details ? JSON.parse(item.details) : {};
}
return item;
});
const agent = agents.get(item.id);
if(!agent && item.status === AccountStatus.ACTIVE) {
item.status = AccountStatus.PAUSED;
await changeAccountStatus(item.id, AccountStatus.PAUSED);
}
}
}
res.json(result);
} catch (err) {
Expand All @@ -120,6 +125,11 @@ export function createManageApiRouter(
router.get("/account/:accountId", async (req, res) => {
const accountId = req.params.accountId as UUID;
const account = await directClient.db.getAccountById(accountId);
const agent = agents.get(accountId);
if(!agent && account.status === AccountStatus.ACTIVE) {
account.status = AccountStatus.PAUSED;
await changeAccountStatus(accountId, AccountStatus.PAUSED);
}
res.json(account);
});

Expand Down

0 comments on commit f63dc5b

Please sign in to comment.