Skip to content

Commit

Permalink
update references to import.meta.filename
Browse files Browse the repository at this point in the history
  • Loading branch information
nbsp authored Jun 30, 2024
1 parent 2514709 commit d0de693
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/thirty-rules-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/agents": minor
---

cli: add runHeadless function
3 changes: 2 additions & 1 deletion agents/src/ipc/job_main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { type JobAssignment, ServerMessage } from '@livekit/protocol';
import { Room } from '@livekit/rtc-node';
import { type ChildProcess, fork } from 'child_process';
import { EventEmitter, once } from 'events';
import { fileURLToPath } from 'url';
import { JobContext } from '../job_context.js';
import { log } from '../log.js';
import { IPC_MESSAGE, type JobMainArgs, type Message, type Ping } from './protocol.js';

export const runJob = (args: JobMainArgs): ChildProcess => {
return fork(import.meta.filename, [args.raw, args.entry, args.fallbackURL]);
return fork(fileURLToPath(import.meta.url), [args.raw, args.entry, args.fallbackURL]);
};

if (process.send) {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { fileURLToPath } from 'url';

const requestFunc = async (req: JobRequest) => {
console.log('received request', req);
await req.accept(import.meta.filename);
await req.accept(fileURLToPath(import.meta.url));
};

if (process.argv[1] === fileURLToPath(import.meta.url)) {
Expand Down
2 changes: 1 addition & 1 deletion examples/src/tts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { AudioSource, LocalAudioTrack, TrackPublishOptions, TrackSource } from '
import { fileURLToPath } from 'url';

const requestFunc = async (req: JobRequest) => {
await req.accept(import.meta.filename);
await req.accept(fileURLToPath(import.meta.url));
};

if (process.argv[1] === fileURLToPath(import.meta.url)) {
Expand Down

0 comments on commit d0de693

Please sign in to comment.