Skip to content

Commit

Permalink
Update api.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
treppers authored Jan 27, 2025
1 parent 4604fe4 commit 32572af
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions packages/client-direct/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,31 @@ export function createApiRouter(
});
});

router.post("/agents/set", async (req, res) => {
// load character from body
const character = req.body;
console.log('character', character);
try {
validateCharacterConfig(character);
} catch (e) {
elizaLogger.error(`Error parsing character: ${e}`);
res.status(400).json({
success: false,
message: e.message,
});
return;
}

// start it up (and register it)
agent = await directClient.startAgent(character);
elizaLogger.log(`${character.name} started`);

res.json({
id: character.id,
character: character,
});
});

router.get("/agents/:agentId/channels", async (req, res) => {
const { agentId } = validateUUIDParams(req.params, res) ?? {
agentId: null,
Expand Down

0 comments on commit 32572af

Please sign in to comment.