@livekit/agents-plugin-openai 1.9.5 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -52,7 +52,7 @@ class OpenAIPlugin extends import_agents.Plugin {
52
52
  constructor() {
53
53
  super({
54
54
  title: "openai",
55
- version: "1.9.5",
55
+ version: "1.10.0",
56
56
  package: "@livekit/agents-plugin-openai"
57
57
  });
58
58
  }
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ class OpenAIPlugin extends Plugin {
11
11
  constructor() {
12
12
  super({
13
13
  title: "openai",
14
- version: "1.9.5",
14
+ version: "1.10.0",
15
15
  package: "@livekit/agents-plugin-openai"
16
16
  });
17
17
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/realtime/gpt_live_model.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { llm } from '@livekit/agents';\nimport { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';\nimport type OpenAI from 'openai';\nimport { OpenAITool } from '../tools.js';\n\nexport {\n type GPTLiveDelegation,\n type GPTLiveModelOptions,\n GPTLiveSession,\n type GPTLiveVoices,\n type ResponsesDelegationOptions,\n} from '@livekit/agents/llm/openai_realtime/gpt_live_model';\n\n/** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.\n * @public\n */\nexport class GPTLiveModel extends BaseGPTLiveModel {\n /** @internal */\n override _providerToolConfig(tool: llm.ProviderTool): OpenAI.Responses.Tool | undefined {\n return tool instanceof OpenAITool\n ? (tool.toToolConfig() as unknown as OpenAI.Responses.Tool)\n : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAAiD;AAEjD,mBAA2B;AAE3B,IAAAA,yBAMO;AAKA,MAAM,qBAAqB,sBAAAC,aAAiB;AAAA;AAAA,EAExC,oBAAoB,MAA2D;AACtF,WAAO,gBAAgB,0BAClB,KAAK,aAAa,IACnB;AAAA,EACN;AACF;","names":["import_gpt_live_model","BaseGPTLiveModel"]}
1
+ {"version":3,"sources":["../../src/realtime/gpt_live_model.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { llm } from '@livekit/agents';\nimport { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';\nimport type OpenAI from 'openai';\nimport { OpenAITool } from '../tools.js';\n\nexport {\n type DecisionEventEnvelope,\n type DecisionsOptions,\n type DecisionsTrigger,\n type GPTLiveDelegation,\n type GPTLiveModelOptions,\n GPTLiveSession,\n type GPTLiveVoices,\n type ResponsesDelegationOptions,\n} from '@livekit/agents/llm/openai_realtime/gpt_live_model';\n\n/** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.\n * @public\n */\nexport class GPTLiveModel extends BaseGPTLiveModel {\n /** @internal */\n override _providerToolConfig(tool: llm.ProviderTool): OpenAI.Responses.Tool | undefined {\n return tool instanceof OpenAITool\n ? (tool.toToolConfig() as unknown as OpenAI.Responses.Tool)\n : undefined;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,4BAAiD;AAEjD,mBAA2B;AAE3B,IAAAA,yBASO;AAKA,MAAM,qBAAqB,sBAAAC,aAAiB;AAAA;AAAA,EAExC,oBAAoB,MAA2D;AACtF,WAAO,gBAAgB,0BAClB,KAAK,aAAa,IACnB;AAAA,EACN;AACF;","names":["import_gpt_live_model","BaseGPTLiveModel"]}
@@ -1,7 +1,7 @@
1
1
  import type { llm } from '@livekit/agents';
2
2
  import { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
3
3
  import type OpenAI from 'openai';
4
- export { type GPTLiveDelegation, type GPTLiveModelOptions, GPTLiveSession, type GPTLiveVoices, type ResponsesDelegationOptions, } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
4
+ export { type DecisionEventEnvelope, type DecisionsOptions, type DecisionsTrigger, type GPTLiveDelegation, type GPTLiveModelOptions, GPTLiveSession, type GPTLiveVoices, type ResponsesDelegationOptions, } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
5
5
  /** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.
6
6
  * @public
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import type { llm } from '@livekit/agents';
2
2
  import { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
3
3
  import type OpenAI from 'openai';
4
- export { type GPTLiveDelegation, type GPTLiveModelOptions, GPTLiveSession, type GPTLiveVoices, type ResponsesDelegationOptions, } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
4
+ export { type DecisionEventEnvelope, type DecisionsOptions, type DecisionsTrigger, type GPTLiveDelegation, type GPTLiveModelOptions, GPTLiveSession, type GPTLiveVoices, type ResponsesDelegationOptions, } from '@livekit/agents/llm/openai_realtime/gpt_live_model';
5
5
  /** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.
6
6
  * @public
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"file":"gpt_live_model.d.ts","sourceRoot":"","sources":["../../src/realtime/gpt_live_model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtG,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,0BAA0B,GAChC,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,gBAAgB;IACP,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,SAAS;CAKxF"}
1
+ {"version":3,"file":"gpt_live_model.d.ts","sourceRoot":"","sources":["../../src/realtime/gpt_live_model.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AACtG,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAGjC,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,0BAA0B,GAChC,MAAM,oDAAoD,CAAC;AAE5D;;GAEG;AACH,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,gBAAgB;IACP,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,GAAG,SAAS;CAKxF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/realtime/gpt_live_model.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { llm } from '@livekit/agents';\nimport { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';\nimport type OpenAI from 'openai';\nimport { OpenAITool } from '../tools.js';\n\nexport {\n type GPTLiveDelegation,\n type GPTLiveModelOptions,\n GPTLiveSession,\n type GPTLiveVoices,\n type ResponsesDelegationOptions,\n} from '@livekit/agents/llm/openai_realtime/gpt_live_model';\n\n/** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.\n * @public\n */\nexport class GPTLiveModel extends BaseGPTLiveModel {\n /** @internal */\n override _providerToolConfig(tool: llm.ProviderTool): OpenAI.Responses.Tool | undefined {\n return tool instanceof OpenAITool\n ? (tool.toToolConfig() as unknown as OpenAI.Responses.Tool)\n : undefined;\n }\n}\n"],"mappings":"AAIA,SAAS,gBAAgB,wBAAwB;AAEjD,SAAS,kBAAkB;AAE3B;AAAA,EAGE;AAAA,OAGK;AAKA,MAAM,qBAAqB,iBAAiB;AAAA;AAAA,EAExC,oBAAoB,MAA2D;AACtF,WAAO,gBAAgB,aAClB,KAAK,aAAa,IACnB;AAAA,EACN;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/realtime/gpt_live_model.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2026 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { llm } from '@livekit/agents';\nimport { GPTLiveModel as BaseGPTLiveModel } from '@livekit/agents/llm/openai_realtime/gpt_live_model';\nimport type OpenAI from 'openai';\nimport { OpenAITool } from '../tools.js';\n\nexport {\n type DecisionEventEnvelope,\n type DecisionsOptions,\n type DecisionsTrigger,\n type GPTLiveDelegation,\n type GPTLiveModelOptions,\n GPTLiveSession,\n type GPTLiveVoices,\n type ResponsesDelegationOptions,\n} from '@livekit/agents/llm/openai_realtime/gpt_live_model';\n\n/** OpenAI GPT-Live full-duplex voice model, ready to pass to AgentSession.\n * @public\n */\nexport class GPTLiveModel extends BaseGPTLiveModel {\n /** @internal */\n override _providerToolConfig(tool: llm.ProviderTool): OpenAI.Responses.Tool | undefined {\n return tool instanceof OpenAITool\n ? (tool.toToolConfig() as unknown as OpenAI.Responses.Tool)\n : undefined;\n }\n}\n"],"mappings":"AAIA,SAAS,gBAAgB,wBAAwB;AAEjD,SAAS,kBAAkB;AAE3B;AAAA,EAME;AAAA,OAGK;AAKA,MAAM,qBAAqB,iBAAiB;AAAA;AAAA,EAExC,oBAAoB,MAA2D;AACtF,WAAO,gBAAgB,aAClB,KAAK,aAAa,IACnB;AAAA,EACN;AACF;","names":[]}
@@ -408,6 +408,7 @@ const startConfig = (index = 0) => {
408
408
  ]);
409
409
  server.sockets[0].terminate();
410
410
  await import_vitest.vi.waitFor(() => (0, import_vitest.expect)(session.sessionId).toBe("live_1"));
411
+ await waitCount(2, 1);
411
412
  (0, import_vitest.expect)(server.events(1).map((event) => event.type)).toEqual([
412
413
  "session.start",
413
414
  "session.input_audio.mute"
@@ -453,6 +454,152 @@ const startConfig = (index = 0) => {
453
454
  { type: "session.thinking.append", delegation_id: "d1", content: "Still checking." }
454
455
  ]);
455
456
  });
457
+ (0, import_vitest.it)("supports Decisions delegation and manual evaluation", async () => {
458
+ const decisionsOptions = {
459
+ model: "gpt-6-luna",
460
+ questions: [
461
+ {
462
+ type: "choice",
463
+ name: "mood",
464
+ instructions: "Mood?",
465
+ choices: [{ value: "happy" }, { value: "sad" }]
466
+ }
467
+ ]
468
+ };
469
+ const session = create({ delegation: "decisions", decisionsOptions });
470
+ const events = [];
471
+ session.on("decision_event", (event) => events.push(event));
472
+ await ready(session);
473
+ const eventId = session.createDecision();
474
+ await waitCount(2);
475
+ (0, import_vitest.expect)(startConfig().delegation).toEqual({ type: "decisions", decisions: decisionsOptions });
476
+ (0, import_vitest.expect)(server.events()).toContainEqual({ type: "decision.create", event_id: eventId });
477
+ const payload = {
478
+ type: "decision.completed",
479
+ decision: {
480
+ model: "gpt-6-luna",
481
+ answers: [{ name: "mood", value: "happy" }],
482
+ usage: { input_tokens: 10 }
483
+ }
484
+ };
485
+ await server.send(session, {
486
+ type: "decision.event",
487
+ event_id: "result-1",
488
+ event: payload
489
+ });
490
+ (0, import_vitest.expect)(events).toEqual([{ type: "decision.event", event_id: "result-1", event: payload }]);
491
+ await (0, import_vitest.expect)(session._updateTools(tools)).rejects.toThrow("no tool channel");
492
+ });
493
+ (0, import_vitest.it)("rejects manual Decisions evaluation while a connection drains", async () => {
494
+ server.autoClose = false;
495
+ const session = create({
496
+ delegation: "decisions",
497
+ decisionsOptions: { model: "gpt-6-luna" },
498
+ maxSessionDuration: 300
499
+ });
500
+ try {
501
+ await ready(session);
502
+ await import_vitest.vi.waitFor(() => {
503
+ var _a;
504
+ return (0, import_vitest.expect)((_a = server.events().at(-1)) == null ? void 0 : _a.type).toBe("session.close");
505
+ });
506
+ (0, import_vitest.expect)(() => session.createDecision()).toThrow("closing");
507
+ await server.send(session, { type: "session.closed", reason: "expired" });
508
+ await import_vitest.vi.waitFor(() => (0, import_vitest.expect)(session.sessionId).toBe("live_1"));
509
+ const eventId = session.createDecision();
510
+ await import_vitest.vi.waitFor(
511
+ () => (0, import_vitest.expect)(server.events(1)).toContainEqual({ type: "decision.create", event_id: eventId })
512
+ );
513
+ (0, import_vitest.expect)(server.events(1)).toMatchObject([
514
+ { type: "session.start" },
515
+ { type: "decision.create", event_id: eventId }
516
+ ]);
517
+ } finally {
518
+ server.autoClose = true;
519
+ const closing = session.close();
520
+ for (const socket of server.sockets) {
521
+ if (socket.readyState === import_ws.WebSocket.OPEN)
522
+ socket.send(JSON.stringify({ type: "session.closed" }));
523
+ }
524
+ await closing;
525
+ }
526
+ });
527
+ (0, import_vitest.it)("rejects manual Decisions evaluation while the session closes and after closing", async () => {
528
+ const session = create({
529
+ delegation: "decisions",
530
+ decisionsOptions: { model: "gpt-6-luna" }
531
+ });
532
+ await ready(session);
533
+ const closing = session.close();
534
+ (0, import_vitest.expect)(() => session.createDecision()).toThrow("closing");
535
+ await closing;
536
+ (0, import_vitest.expect)(() => session.createDecision()).toThrow("closing");
537
+ (0, import_vitest.expect)(server.events().some((event) => event.type === "decision.create")).toBe(false);
538
+ });
539
+ (0, import_vitest.it)("does not replay manual Decisions evaluation after a failed startup", async () => {
540
+ server.autoStart = false;
541
+ const session = create({
542
+ delegation: "decisions",
543
+ decisionsOptions: { model: "gpt-6-luna" },
544
+ connOptions: { maxRetry: 1, retryIntervalMs: 10, timeoutMs: 1e3 }
545
+ });
546
+ await session._updateSession();
547
+ await waitCount(1);
548
+ session.createDecision();
549
+ server.sockets[0].terminate();
550
+ await waitCount(1, 1);
551
+ const eventId = session.createDecision();
552
+ await server.send(session, { type: "session.started", session: { id: "live_1" } });
553
+ await import_vitest.vi.waitFor(
554
+ () => (0, import_vitest.expect)(server.events(1)).toContainEqual({ type: "decision.create", event_id: eventId })
555
+ );
556
+ (0, import_vitest.expect)(server.events(1)).toMatchObject([
557
+ { type: "session.start" },
558
+ { type: "decision.create", event_id: eventId }
559
+ ]);
560
+ });
561
+ import_vitest.it.each(["client", "responses"])(
562
+ "serializes Decisions triggers but rejects manual evaluation under %s delegation",
563
+ async (delegation) => {
564
+ var _a;
565
+ const triggers = [
566
+ {
567
+ type: "decisions",
568
+ eventType: "session.output_transcript.delta",
569
+ decisions: {
570
+ questions: [
571
+ {
572
+ name: "mood",
573
+ type: "choice",
574
+ instructions: "Mood?",
575
+ choices: [{ value: "happy" }]
576
+ }
577
+ ]
578
+ }
579
+ }
580
+ ];
581
+ const session = create({ delegation, triggers });
582
+ await ready(session);
583
+ (0, import_vitest.expect)(startConfig().triggers).toEqual([
584
+ {
585
+ type: "decisions",
586
+ event_type: "session.output_transcript.delta",
587
+ decisions: triggers[0].decisions
588
+ }
589
+ ]);
590
+ (0, import_vitest.expect)((_a = startConfig().delegation) == null ? void 0 : _a.type).toBe(delegation);
591
+ (0, import_vitest.expect)(() => session.createDecision()).toThrow("Decisions delegation");
592
+ (0, import_vitest.expect)(server.events().some((event) => event.type === "decision.create")).toBe(false);
593
+ }
594
+ );
595
+ (0, import_vitest.it)("requires Decisions configuration to match Decisions delegation", () => {
596
+ (0, import_vitest.expect)(() => new import_gpt_live_model.GPTLiveModel({ apiKey: "sk-test", delegation: "decisions" })).toThrow(
597
+ "decisionsOptions"
598
+ );
599
+ (0, import_vitest.expect)(
600
+ () => new import_gpt_live_model.GPTLiveModel({ apiKey: "sk-test", decisionsOptions: { model: "gpt-6-luna" } })
601
+ ).toThrow("decisionsOptions");
602
+ });
456
603
  (0, import_vitest.it)("drops old delegation answers during drain, startup, and after reconnect", async () => {
457
604
  server.autoClose = false;
458
605
  const session = create({ delegation: "client", maxSessionDuration: 300 });