diff --git a/.changeset/tall-apes-hug.md b/.changeset/tall-apes-hug.md new file mode 100644 index 00000000..a8df2b63 --- /dev/null +++ b/.changeset/tall-apes-hug.md @@ -0,0 +1,5 @@ +--- +"@livekit/agents": patch +--- + +refactor(job): show job request attrs on print diff --git a/agents/src/job.ts b/agents/src/job.ts index 3d99cd9c..67144a0e 100644 --- a/agents/src/job.ts +++ b/agents/src/job.ts @@ -255,46 +255,35 @@ export class JobProcess { * requests should fill idle processes and which should be outright rejected. */ export class JobRequest { - #job: proto.Job; #onReject: () => Promise<void>; #onAccept: (args: JobAcceptArguments) => Promise<void>; + /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ + readonly job: proto.Job; + /** @returns The ID of the job, set by the LiveKit server */ + readonly id: string; + /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ + readonly room?: proto.Room; + /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ + readonly publisher?: proto.ParticipantInfo; + /** @returns The agent's name, as set in {@link WorkerOptions} */ + readonly agentName: string; + /** @internal */ constructor( job: proto.Job, onReject: () => Promise<void>, onAccept: (args: JobAcceptArguments) => Promise<void>, ) { - this.#job = job; + this.job = job; + this.id = job.id; + this.room = job.room; + this.publisher = job.participant; + this.agentName = job.agentName; this.#onReject = onReject; this.#onAccept = onAccept; } - /** @returns The ID of the job, set by the LiveKit server */ - get id(): string { - return this.#job.id; - } - - /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ - get job(): proto.Job { - return this.#job; - } - - /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ - get room(): proto.Room | undefined { - return this.#job.room; - } - - /** @see {@link https://www.npmjs.com/package/@livekit/protocol | @livekit/protocol} */ - get publisher(): proto.ParticipantInfo | undefined { - return this.#job.participant; - } - - /** @returns The agent's name, as set in {@link WorkerOptions} */ - get agentName(): string { - return this.#job.agentName; - } - /** Rejects the job. */ async reject() { await this.#onReject();