diff --git a/package.json b/package.json index a9140b4..4ad4651 100644 --- a/package.json +++ b/package.json @@ -24,21 +24,21 @@ "devDependencies": { "@eslint/js": "^9.39.2", "@trivago/prettier-plugin-sort-imports": "^5.2.2", - "@types/node": "^22.19.7", + "@types/node": "^22.19.11", "eslint": "^9.39.2", "globals": "^16.5.0", "jiti": "^2.6.1", "typescript": "^5.9.3", - "typescript-eslint": "^8.54.0", + "typescript-eslint": "^8.55.0", "vite": "^7.3.1", "vitest": "^4.0.18" }, "dependencies": { - "@livekit/agents": "^1.0.40", - "@livekit/agents-plugin-livekit": "^1.0.40", - "@livekit/agents-plugin-silero": "^1.0.40", + "@livekit/agents": "^1.0.43", + "@livekit/agents-plugin-livekit": "^1.0.43", + "@livekit/agents-plugin-silero": "^1.0.43", "@livekit/noise-cancellation-node": "^0.1.9", - "dotenv": "^17.2.3", + "dotenv": "^17.2.4", "zod": "^3.25.76" } } diff --git a/src/agent.test.ts b/src/agent.test.ts index 94b2ff1..c9a0fe6 100644 --- a/src/agent.test.ts +++ b/src/agent.test.ts @@ -1,7 +1,7 @@ import { inference, initializeLogger, voice } from '@livekit/agents'; import dotenv from 'dotenv'; import { afterEach, beforeEach, describe, it } from 'vitest'; -import { Assistant } from './agent.js'; +import { Agent } from './agent'; dotenv.config({ path: '.env.local' }); @@ -15,7 +15,7 @@ describe('agent evaluation', () => { beforeEach(async () => { llmInstance = new inference.LLM({ model: 'openai/gpt-5.1' }); session = new voice.AgentSession({ llm: llmInstance }); - await session.start({ agent: new Assistant() }); + await session.start({ agent: new Agent() }); }); afterEach(async () => { diff --git a/src/agent.ts b/src/agent.ts index 7c1e095..04d4022 100644 --- a/src/agent.ts +++ b/src/agent.ts @@ -1,7 +1,7 @@ import { voice } from '@livekit/agents'; // Define a custom voice AI assistant by extending the base Agent class -export class Assistant extends voice.Agent { +export class Agent extends voice.Agent { constructor() { super({ instructions: `You are a helpful voice AI assistant. The user is interacting with you via voice, even if you perceive the conversation as text. diff --git a/src/main.ts b/src/main.ts index 70263ca..bffc964 100644 --- a/src/main.ts +++ b/src/main.ts @@ -13,7 +13,7 @@ import * as silero from '@livekit/agents-plugin-silero'; import { BackgroundVoiceCancellation } from '@livekit/noise-cancellation-node'; import dotenv from 'dotenv'; import { fileURLToPath } from 'node:url'; -import { Assistant } from './agent.js'; +import { Agent } from './agent'; // Load environment variables from a local file. // Make sure to set LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET @@ -84,7 +84,7 @@ export default defineAgent({ // Start the session, which initializes the voice pipeline and warms up the models await session.start({ - agent: new Assistant(), + agent: new Agent(), room: ctx.room, inputOptions: { // LiveKit Cloud enhanced noise cancellation @@ -105,4 +105,9 @@ export default defineAgent({ }); // Run the agent server -cli.runApp(new ServerOptions({ agent: fileURLToPath(import.meta.url) })); +cli.runApp( + new ServerOptions({ + agent: fileURLToPath(import.meta.url), + agentName: 'my-agent', + }), +); diff --git a/taskfile.yaml b/taskfile.yaml index 832a97a..6be15a1 100644 --- a/taskfile.yaml +++ b/taskfile.yaml @@ -5,7 +5,7 @@ vars: INDENT: 4 REL_PATH: "{{ relPath .USER_WORKING_DIR .ROOT_DIR }}" VENV_DIR: ".venv" - NODE_MAIN: '{{ joinPath "./src" "agent.ts" }}' + NODE_MAIN: '{{ joinPath "./src" "main.ts" }}' tasks: post_create: @@ -31,8 +31,8 @@ tasks: - test -z "$LIVEKIT_AGENT_NAME" cmds: - | - old="WorkerOptions(" - new="WorkerOptions(agent_name=\"{{ .LIVEKIT_AGENT_NAME }}\", " + old="agentName: 'my-agent'" + new="agentName: '{{ .LIVEKIT_AGENT_NAME }}'" file="{{ .NODE_MAIN }}" tmp="$(mktemp)" while IFS= read -r line; do