Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/happy-forks-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@livekit/agents": patch
---

add termiante to JobRequest
2 changes: 1 addition & 1 deletion agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"dependencies": {
"@livekit/mutex": "^1.1.1",
"@livekit/protocol": "^1.29.1",
"@livekit/protocol": "^1.39.0",
"@livekit/typed-emitter": "^3.0.0",
"commander": "^12.0.0",
"livekit-server-sdk": "^2.9.2",
Expand Down
9 changes: 7 additions & 2 deletions agents/src/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ export class JobProcess {
*/
export class JobRequest {
#job: proto.Job;
#onReject: () => Promise<void>;
#onReject: (terminate?: boolean) => Promise<void>;
#onAccept: (args: JobAcceptArguments) => Promise<void>;

/** @internal */
constructor(
job: proto.Job,
onReject: () => Promise<void>,
onReject: (terminate?: boolean) => Promise<void>,
onAccept: (args: JobAcceptArguments) => Promise<void>,
) {
this.#job = job;
Expand Down Expand Up @@ -300,6 +300,11 @@ export class JobRequest {
await this.#onReject();
}

/** Terminate the job. */
async terminate() {
await this.#onReject(true);
}

/** Accepts the job, launching it on an idle child process. */
async accept(name = '', identity = '', metadata = '', attributes?: { [key: string]: string }) {
if (identity === '') identity = 'agent-' + this.id;
Expand Down
2 changes: 1 addition & 1 deletion agents/src/tokenize/basic/hyphenator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Hyphenator {

const pieces = [''];
for (let i = 0; i < word.length; i++) {
pieces[pieces.length - 1] += word[i];
pieces[pieces.length - 1]! += word[i];
if (points[i + 2]! % 2) {
pieces.push('');
}
Expand Down
3 changes: 2 additions & 1 deletion agents/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ export class Worker {
async #availability(msg: AvailabilityRequest) {
let answered = false;

const onReject = async () => {
const onReject = async (terminate: boolean = false) => {
answered = true;
this.event.emit(
'worker_msg',
Expand All @@ -642,6 +642,7 @@ export class Worker {
value: {
jobId: msg.job!.id,
available: false,
terminate,
},
},
}),
Expand Down
Loading
Loading