@livekit/agents-plugin-openai 0.0.0-next-20260624041820

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.
Files changed (179) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +18 -0
  3. package/dist/index.cjs +74 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +9 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +30 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/llm.cjs +382 -0
  11. package/dist/llm.cjs.map +1 -0
  12. package/dist/llm.d.cts +230 -0
  13. package/dist/llm.d.ts +230 -0
  14. package/dist/llm.d.ts.map +1 -0
  15. package/dist/llm.js +357 -0
  16. package/dist/llm.js.map +1 -0
  17. package/dist/llm.test.cjs +36 -0
  18. package/dist/llm.test.cjs.map +1 -0
  19. package/dist/llm.test.d.cts +2 -0
  20. package/dist/llm.test.d.ts +2 -0
  21. package/dist/llm.test.d.ts.map +1 -0
  22. package/dist/llm.test.js +35 -0
  23. package/dist/llm.test.js.map +1 -0
  24. package/dist/models.cjs +50 -0
  25. package/dist/models.cjs.map +1 -0
  26. package/dist/models.d.cts +26 -0
  27. package/dist/models.d.ts +26 -0
  28. package/dist/models.d.ts.map +1 -0
  29. package/dist/models.js +25 -0
  30. package/dist/models.js.map +1 -0
  31. package/dist/realtime/api_proto.cjs +41 -0
  32. package/dist/realtime/api_proto.cjs.map +1 -0
  33. package/dist/realtime/api_proto.d.cts +501 -0
  34. package/dist/realtime/api_proto.d.ts +501 -0
  35. package/dist/realtime/api_proto.d.ts.map +1 -0
  36. package/dist/realtime/api_proto.js +13 -0
  37. package/dist/realtime/api_proto.js.map +1 -0
  38. package/dist/realtime/index.cjs +25 -0
  39. package/dist/realtime/index.cjs.map +1 -0
  40. package/dist/realtime/index.d.cts +3 -0
  41. package/dist/realtime/index.d.ts +3 -0
  42. package/dist/realtime/index.d.ts.map +1 -0
  43. package/dist/realtime/index.js +3 -0
  44. package/dist/realtime/index.js.map +1 -0
  45. package/dist/realtime/realtime_model.cjs +1658 -0
  46. package/dist/realtime/realtime_model.cjs.map +1 -0
  47. package/dist/realtime/realtime_model.d.cts +202 -0
  48. package/dist/realtime/realtime_model.d.ts +202 -0
  49. package/dist/realtime/realtime_model.d.ts.map +1 -0
  50. package/dist/realtime/realtime_model.js +1637 -0
  51. package/dist/realtime/realtime_model.js.map +1 -0
  52. package/dist/realtime/realtime_model.test.cjs +596 -0
  53. package/dist/realtime/realtime_model.test.cjs.map +1 -0
  54. package/dist/realtime/realtime_model.test.d.cts +2 -0
  55. package/dist/realtime/realtime_model.test.d.ts +2 -0
  56. package/dist/realtime/realtime_model.test.d.ts.map +1 -0
  57. package/dist/realtime/realtime_model.test.js +600 -0
  58. package/dist/realtime/realtime_model.test.js.map +1 -0
  59. package/dist/responses/index.cjs +23 -0
  60. package/dist/responses/index.cjs.map +1 -0
  61. package/dist/responses/index.d.cts +2 -0
  62. package/dist/responses/index.d.ts +2 -0
  63. package/dist/responses/index.d.ts.map +1 -0
  64. package/dist/responses/index.js +2 -0
  65. package/dist/responses/index.js.map +1 -0
  66. package/dist/responses/llm.cjs +353 -0
  67. package/dist/responses/llm.cjs.map +1 -0
  68. package/dist/responses/llm.d.cts +52 -0
  69. package/dist/responses/llm.d.ts +52 -0
  70. package/dist/responses/llm.d.ts.map +1 -0
  71. package/dist/responses/llm.js +327 -0
  72. package/dist/responses/llm.js.map +1 -0
  73. package/dist/responses/llm.test.cjs +37 -0
  74. package/dist/responses/llm.test.cjs.map +1 -0
  75. package/dist/responses/llm.test.d.cts +2 -0
  76. package/dist/responses/llm.test.d.ts +2 -0
  77. package/dist/responses/llm.test.d.ts.map +1 -0
  78. package/dist/responses/llm.test.js +36 -0
  79. package/dist/responses/llm.test.js.map +1 -0
  80. package/dist/stt.cjs +627 -0
  81. package/dist/stt.cjs.map +1 -0
  82. package/dist/stt.d.cts +105 -0
  83. package/dist/stt.d.ts +105 -0
  84. package/dist/stt.d.ts.map +1 -0
  85. package/dist/stt.js +605 -0
  86. package/dist/stt.js.map +1 -0
  87. package/dist/stt.test.cjs +132 -0
  88. package/dist/stt.test.cjs.map +1 -0
  89. package/dist/stt.test.d.cts +2 -0
  90. package/dist/stt.test.d.ts +2 -0
  91. package/dist/stt.test.d.ts.map +1 -0
  92. package/dist/stt.test.js +131 -0
  93. package/dist/stt.test.js.map +1 -0
  94. package/dist/tool_utils.cjs +53 -0
  95. package/dist/tool_utils.cjs.map +1 -0
  96. package/dist/tool_utils.d.cts +4 -0
  97. package/dist/tool_utils.d.ts +4 -0
  98. package/dist/tool_utils.d.ts.map +1 -0
  99. package/dist/tool_utils.js +29 -0
  100. package/dist/tool_utils.js.map +1 -0
  101. package/dist/tool_utils.test.cjs +77 -0
  102. package/dist/tool_utils.test.cjs.map +1 -0
  103. package/dist/tool_utils.test.d.cts +2 -0
  104. package/dist/tool_utils.test.d.ts +2 -0
  105. package/dist/tool_utils.test.d.ts.map +1 -0
  106. package/dist/tool_utils.test.js +76 -0
  107. package/dist/tool_utils.test.js.map +1 -0
  108. package/dist/tools.cjs +117 -0
  109. package/dist/tools.cjs.map +1 -0
  110. package/dist/tools.d.cts +88 -0
  111. package/dist/tools.d.ts +88 -0
  112. package/dist/tools.d.ts.map +1 -0
  113. package/dist/tools.js +90 -0
  114. package/dist/tools.js.map +1 -0
  115. package/dist/tts.cjs +141 -0
  116. package/dist/tts.cjs.map +1 -0
  117. package/dist/tts.d.cts +42 -0
  118. package/dist/tts.d.ts +42 -0
  119. package/dist/tts.d.ts.map +1 -0
  120. package/dist/tts.js +116 -0
  121. package/dist/tts.js.map +1 -0
  122. package/dist/tts.test.cjs +17 -0
  123. package/dist/tts.test.cjs.map +1 -0
  124. package/dist/tts.test.d.cts +2 -0
  125. package/dist/tts.test.d.ts +2 -0
  126. package/dist/tts.test.d.ts.map +1 -0
  127. package/dist/tts.test.js +16 -0
  128. package/dist/tts.test.js.map +1 -0
  129. package/dist/ws/index.cjs +29 -0
  130. package/dist/ws/index.cjs.map +1 -0
  131. package/dist/ws/index.d.cts +3 -0
  132. package/dist/ws/index.d.ts +3 -0
  133. package/dist/ws/index.d.ts.map +1 -0
  134. package/dist/ws/index.js +5 -0
  135. package/dist/ws/index.js.map +1 -0
  136. package/dist/ws/llm.cjs +523 -0
  137. package/dist/ws/llm.cjs.map +1 -0
  138. package/dist/ws/llm.d.cts +96 -0
  139. package/dist/ws/llm.d.ts +96 -0
  140. package/dist/ws/llm.d.ts.map +1 -0
  141. package/dist/ws/llm.js +505 -0
  142. package/dist/ws/llm.js.map +1 -0
  143. package/dist/ws/llm.test.cjs +69 -0
  144. package/dist/ws/llm.test.cjs.map +1 -0
  145. package/dist/ws/llm.test.d.cts +2 -0
  146. package/dist/ws/llm.test.d.ts +2 -0
  147. package/dist/ws/llm.test.d.ts.map +1 -0
  148. package/dist/ws/llm.test.js +68 -0
  149. package/dist/ws/llm.test.js.map +1 -0
  150. package/dist/ws/types.cjs +129 -0
  151. package/dist/ws/types.cjs.map +1 -0
  152. package/dist/ws/types.d.cts +172 -0
  153. package/dist/ws/types.d.ts +172 -0
  154. package/dist/ws/types.d.ts.map +1 -0
  155. package/dist/ws/types.js +96 -0
  156. package/dist/ws/types.js.map +1 -0
  157. package/package.json +56 -0
  158. package/src/index.ts +25 -0
  159. package/src/llm.test.ts +38 -0
  160. package/src/llm.ts +553 -0
  161. package/src/models.ts +235 -0
  162. package/src/realtime/api_proto.ts +714 -0
  163. package/src/realtime/index.ts +5 -0
  164. package/src/realtime/realtime_model.test.ts +793 -0
  165. package/src/realtime/realtime_model.ts +2116 -0
  166. package/src/responses/index.ts +4 -0
  167. package/src/responses/llm.test.ts +39 -0
  168. package/src/responses/llm.ts +452 -0
  169. package/src/stt.test.ts +167 -0
  170. package/src/stt.ts +793 -0
  171. package/src/tool_utils.test.ts +84 -0
  172. package/src/tool_utils.ts +46 -0
  173. package/src/tools.ts +166 -0
  174. package/src/tts.test.ts +19 -0
  175. package/src/tts.ts +158 -0
  176. package/src/ws/index.ts +17 -0
  177. package/src/ws/llm.test.ts +83 -0
  178. package/src/ws/llm.ts +710 -0
  179. package/src/ws/types.ts +132 -0
@@ -0,0 +1,172 @@
1
+ import { z } from 'zod';
2
+ export declare const wsResponseCreateEventSchema: z.ZodObject<{
3
+ type: z.ZodLiteral<"response.create">;
4
+ model: z.ZodString;
5
+ input: z.ZodArray<z.ZodUnknown>;
6
+ tools: z.ZodOptional<z.ZodArray<z.ZodUnknown>>;
7
+ previous_response_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ store: z.ZodOptional<z.ZodBoolean>;
9
+ temperature: z.ZodOptional<z.ZodNumber>;
10
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
11
+ }, z.core.$loose>;
12
+ export type WsResponseCreateEvent = z.infer<typeof wsResponseCreateEventSchema>;
13
+ export declare const wsResponseCreatedEventSchema: z.ZodObject<{
14
+ type: z.ZodLiteral<"response.created">;
15
+ response: z.ZodObject<{
16
+ id: z.ZodString;
17
+ }, z.core.$loose>;
18
+ }, z.core.$strip>;
19
+ export declare const wsFunctionCallItemSchema: z.ZodObject<{
20
+ type: z.ZodLiteral<"function_call">;
21
+ call_id: z.ZodString;
22
+ name: z.ZodString;
23
+ arguments: z.ZodString;
24
+ }, z.core.$strip>;
25
+ export declare const wsOutputItemSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
26
+ type: z.ZodLiteral<"function_call">;
27
+ call_id: z.ZodString;
28
+ name: z.ZodString;
29
+ arguments: z.ZodString;
30
+ }, z.core.$strip>, z.ZodObject<{
31
+ type: z.ZodLiteral<"message">;
32
+ phase: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$loose>, z.ZodObject<{
34
+ type: z.ZodLiteral<"reasoning">;
35
+ }, z.core.$loose>, z.ZodObject<{
36
+ type: z.ZodLiteral<"file">;
37
+ }, z.core.$loose>, z.ZodObject<{
38
+ type: z.ZodLiteral<"computer_call">;
39
+ }, z.core.$loose>, z.ZodObject<{
40
+ type: z.ZodLiteral<"web_search_call">;
41
+ }, z.core.$loose>], "type">;
42
+ export declare const wsOutputItemDoneEventSchema: z.ZodObject<{
43
+ type: z.ZodLiteral<"response.output_item.done">;
44
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
45
+ type: z.ZodLiteral<"function_call">;
46
+ call_id: z.ZodString;
47
+ name: z.ZodString;
48
+ arguments: z.ZodString;
49
+ }, z.core.$strip>, z.ZodObject<{
50
+ type: z.ZodLiteral<"message">;
51
+ phase: z.ZodOptional<z.ZodString>;
52
+ }, z.core.$loose>, z.ZodObject<{
53
+ type: z.ZodLiteral<"reasoning">;
54
+ }, z.core.$loose>, z.ZodObject<{
55
+ type: z.ZodLiteral<"file">;
56
+ }, z.core.$loose>, z.ZodObject<{
57
+ type: z.ZodLiteral<"computer_call">;
58
+ }, z.core.$loose>, z.ZodObject<{
59
+ type: z.ZodLiteral<"web_search_call">;
60
+ }, z.core.$loose>], "type">;
61
+ }, z.core.$strip>;
62
+ export declare const wsOutputTextDeltaEventSchema: z.ZodObject<{
63
+ type: z.ZodLiteral<"response.output_text.delta">;
64
+ delta: z.ZodString;
65
+ }, z.core.$strip>;
66
+ export declare const wsResponseCompletedEventSchema: z.ZodObject<{
67
+ type: z.ZodLiteral<"response.completed">;
68
+ response: z.ZodObject<{
69
+ id: z.ZodString;
70
+ service_tier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
71
+ usage: z.ZodOptional<z.ZodObject<{
72
+ output_tokens: z.ZodNumber;
73
+ input_tokens: z.ZodNumber;
74
+ total_tokens: z.ZodNumber;
75
+ input_tokens_details: z.ZodObject<{
76
+ cached_tokens: z.ZodNumber;
77
+ }, z.core.$loose>;
78
+ }, z.core.$strip>>;
79
+ }, z.core.$loose>;
80
+ }, z.core.$strip>;
81
+ export declare const wsResponseFailedEventSchema: z.ZodObject<{
82
+ type: z.ZodLiteral<"response.failed">;
83
+ response: z.ZodObject<{
84
+ id: z.ZodOptional<z.ZodString>;
85
+ error: z.ZodOptional<z.ZodObject<{
86
+ code: z.ZodOptional<z.ZodString>;
87
+ message: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>>;
89
+ }, z.core.$loose>;
90
+ }, z.core.$strip>;
91
+ export declare const wsErrorEventSchema: z.ZodObject<{
92
+ type: z.ZodLiteral<"error">;
93
+ status: z.ZodOptional<z.ZodNumber>;
94
+ error: z.ZodOptional<z.ZodObject<{
95
+ type: z.ZodOptional<z.ZodString>;
96
+ code: z.ZodOptional<z.ZodString>;
97
+ message: z.ZodOptional<z.ZodString>;
98
+ param: z.ZodOptional<z.ZodString>;
99
+ }, z.core.$strip>>;
100
+ message: z.ZodOptional<z.ZodString>;
101
+ }, z.core.$strip>;
102
+ export declare const wsServerEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
103
+ type: z.ZodLiteral<"response.created">;
104
+ response: z.ZodObject<{
105
+ id: z.ZodString;
106
+ }, z.core.$loose>;
107
+ }, z.core.$strip>, z.ZodObject<{
108
+ type: z.ZodLiteral<"response.output_item.done">;
109
+ item: z.ZodDiscriminatedUnion<[z.ZodObject<{
110
+ type: z.ZodLiteral<"function_call">;
111
+ call_id: z.ZodString;
112
+ name: z.ZodString;
113
+ arguments: z.ZodString;
114
+ }, z.core.$strip>, z.ZodObject<{
115
+ type: z.ZodLiteral<"message">;
116
+ phase: z.ZodOptional<z.ZodString>;
117
+ }, z.core.$loose>, z.ZodObject<{
118
+ type: z.ZodLiteral<"reasoning">;
119
+ }, z.core.$loose>, z.ZodObject<{
120
+ type: z.ZodLiteral<"file">;
121
+ }, z.core.$loose>, z.ZodObject<{
122
+ type: z.ZodLiteral<"computer_call">;
123
+ }, z.core.$loose>, z.ZodObject<{
124
+ type: z.ZodLiteral<"web_search_call">;
125
+ }, z.core.$loose>], "type">;
126
+ }, z.core.$strip>, z.ZodObject<{
127
+ type: z.ZodLiteral<"response.output_text.delta">;
128
+ delta: z.ZodString;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ type: z.ZodLiteral<"response.completed">;
131
+ response: z.ZodObject<{
132
+ id: z.ZodString;
133
+ service_tier: z.ZodOptional<z.ZodNullable<z.ZodString>>;
134
+ usage: z.ZodOptional<z.ZodObject<{
135
+ output_tokens: z.ZodNumber;
136
+ input_tokens: z.ZodNumber;
137
+ total_tokens: z.ZodNumber;
138
+ input_tokens_details: z.ZodObject<{
139
+ cached_tokens: z.ZodNumber;
140
+ }, z.core.$loose>;
141
+ }, z.core.$strip>>;
142
+ }, z.core.$loose>;
143
+ }, z.core.$strip>, z.ZodObject<{
144
+ type: z.ZodLiteral<"response.failed">;
145
+ response: z.ZodObject<{
146
+ id: z.ZodOptional<z.ZodString>;
147
+ error: z.ZodOptional<z.ZodObject<{
148
+ code: z.ZodOptional<z.ZodString>;
149
+ message: z.ZodOptional<z.ZodString>;
150
+ }, z.core.$strip>>;
151
+ }, z.core.$loose>;
152
+ }, z.core.$strip>, z.ZodObject<{
153
+ type: z.ZodLiteral<"error">;
154
+ status: z.ZodOptional<z.ZodNumber>;
155
+ error: z.ZodOptional<z.ZodObject<{
156
+ type: z.ZodOptional<z.ZodString>;
157
+ code: z.ZodOptional<z.ZodString>;
158
+ message: z.ZodOptional<z.ZodString>;
159
+ param: z.ZodOptional<z.ZodString>;
160
+ }, z.core.$strip>>;
161
+ message: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>], "type">;
163
+ export type WsResponseCreatedEvent = z.infer<typeof wsResponseCreatedEventSchema>;
164
+ export type WsFunctionCallItem = z.infer<typeof wsFunctionCallItemSchema>;
165
+ export type WsOutputItem = z.infer<typeof wsOutputItemSchema>;
166
+ export type WsOutputItemDoneEvent = z.infer<typeof wsOutputItemDoneEventSchema>;
167
+ export type WsOutputTextDeltaEvent = z.infer<typeof wsOutputTextDeltaEventSchema>;
168
+ export type WsResponseCompletedEvent = z.infer<typeof wsResponseCompletedEventSchema>;
169
+ export type WsResponseFailedEvent = z.infer<typeof wsResponseFailedEventSchema>;
170
+ export type WsErrorEvent = z.infer<typeof wsErrorEventSchema>;
171
+ export type WsServerEvent = z.infer<typeof wsServerEventSchema>;
172
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ws/types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,2BAA2B;;;;;;;;;iBAWxB,CAAC;AAEjB,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAMhF,eAAO,MAAM,4BAA4B;;;;;iBAOvC,CAAC;AAEH,eAAO,MAAM,wBAAwB;;;;;iBAKnC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;2BAO7B,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,4BAA4B;;;iBAGvC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;iBAoBzC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;iBAatC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;iBAY7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;2BAO9B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAClF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,8BAA8B,CAAC,CAAC;AACtF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAChF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { z } from "zod";
2
+ const wsResponseCreateEventSchema = z.object({
3
+ type: z.literal("response.create"),
4
+ model: z.string(),
5
+ input: z.array(z.unknown()),
6
+ tools: z.array(z.unknown()).optional(),
7
+ previous_response_id: z.string().nullable().optional(),
8
+ store: z.boolean().optional(),
9
+ temperature: z.number().optional(),
10
+ metadata: z.record(z.string(), z.string()).optional()
11
+ }).passthrough();
12
+ const wsResponseCreatedEventSchema = z.object({
13
+ type: z.literal("response.created"),
14
+ response: z.object({
15
+ id: z.string()
16
+ }).passthrough()
17
+ });
18
+ const wsFunctionCallItemSchema = z.object({
19
+ type: z.literal("function_call"),
20
+ call_id: z.string(),
21
+ name: z.string(),
22
+ arguments: z.string()
23
+ });
24
+ const wsOutputItemSchema = z.discriminatedUnion("type", [
25
+ wsFunctionCallItemSchema,
26
+ z.object({ type: z.literal("message"), phase: z.string().optional() }).passthrough(),
27
+ z.object({ type: z.literal("reasoning") }).passthrough(),
28
+ z.object({ type: z.literal("file") }).passthrough(),
29
+ z.object({ type: z.literal("computer_call") }).passthrough(),
30
+ z.object({ type: z.literal("web_search_call") }).passthrough()
31
+ ]);
32
+ const wsOutputItemDoneEventSchema = z.object({
33
+ type: z.literal("response.output_item.done"),
34
+ item: wsOutputItemSchema
35
+ });
36
+ const wsOutputTextDeltaEventSchema = z.object({
37
+ type: z.literal("response.output_text.delta"),
38
+ delta: z.string()
39
+ });
40
+ const wsResponseCompletedEventSchema = z.object({
41
+ type: z.literal("response.completed"),
42
+ response: z.object({
43
+ id: z.string(),
44
+ service_tier: z.string().nullable().optional(),
45
+ usage: z.object({
46
+ output_tokens: z.number(),
47
+ input_tokens: z.number(),
48
+ total_tokens: z.number(),
49
+ input_tokens_details: z.object({
50
+ cached_tokens: z.number()
51
+ }).passthrough()
52
+ }).optional()
53
+ }).passthrough()
54
+ });
55
+ const wsResponseFailedEventSchema = z.object({
56
+ type: z.literal("response.failed"),
57
+ response: z.object({
58
+ id: z.string().optional(),
59
+ error: z.object({
60
+ code: z.string().optional(),
61
+ message: z.string().optional()
62
+ }).optional()
63
+ }).passthrough()
64
+ });
65
+ const wsErrorEventSchema = z.object({
66
+ type: z.literal("error"),
67
+ status: z.number().optional(),
68
+ error: z.object({
69
+ type: z.string().optional(),
70
+ code: z.string().optional(),
71
+ message: z.string().optional(),
72
+ param: z.string().optional()
73
+ }).optional(),
74
+ message: z.string().optional()
75
+ });
76
+ const wsServerEventSchema = z.discriminatedUnion("type", [
77
+ wsResponseCreatedEventSchema,
78
+ wsOutputItemDoneEventSchema,
79
+ wsOutputTextDeltaEventSchema,
80
+ wsResponseCompletedEventSchema,
81
+ wsResponseFailedEventSchema,
82
+ wsErrorEventSchema
83
+ ]);
84
+ export {
85
+ wsErrorEventSchema,
86
+ wsFunctionCallItemSchema,
87
+ wsOutputItemDoneEventSchema,
88
+ wsOutputItemSchema,
89
+ wsOutputTextDeltaEventSchema,
90
+ wsResponseCompletedEventSchema,
91
+ wsResponseCreateEventSchema,
92
+ wsResponseCreatedEventSchema,
93
+ wsResponseFailedEventSchema,
94
+ wsServerEventSchema
95
+ };
96
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/ws/types.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { z } from 'zod';\n\n// ============================================================================\n// Client → Server events\n// ============================================================================\n\nexport const wsResponseCreateEventSchema = z\n .object({\n type: z.literal('response.create'),\n model: z.string(),\n input: z.array(z.unknown()),\n tools: z.array(z.unknown()).optional(),\n previous_response_id: z.string().nullable().optional(),\n store: z.boolean().optional(),\n temperature: z.number().optional(),\n metadata: z.record(z.string(), z.string()).optional(),\n })\n .passthrough();\n\nexport type WsResponseCreateEvent = z.infer<typeof wsResponseCreateEventSchema>;\n\n// ============================================================================\n// Server → Client events\n// ============================================================================\n\nexport const wsResponseCreatedEventSchema = z.object({\n type: z.literal('response.created'),\n response: z\n .object({\n id: z.string(),\n })\n .passthrough(),\n});\n\nexport const wsFunctionCallItemSchema = z.object({\n type: z.literal('function_call'),\n call_id: z.string(),\n name: z.string(),\n arguments: z.string(),\n});\n\nexport const wsOutputItemSchema = z.discriminatedUnion('type', [\n wsFunctionCallItemSchema,\n z.object({ type: z.literal('message'), phase: z.string().optional() }).passthrough(),\n z.object({ type: z.literal('reasoning') }).passthrough(),\n z.object({ type: z.literal('file') }).passthrough(),\n z.object({ type: z.literal('computer_call') }).passthrough(),\n z.object({ type: z.literal('web_search_call') }).passthrough(),\n]);\n\nexport const wsOutputItemDoneEventSchema = z.object({\n type: z.literal('response.output_item.done'),\n item: wsOutputItemSchema,\n});\n\nexport const wsOutputTextDeltaEventSchema = z.object({\n type: z.literal('response.output_text.delta'),\n delta: z.string(),\n});\n\nexport const wsResponseCompletedEventSchema = z.object({\n type: z.literal('response.completed'),\n response: z\n .object({\n id: z.string(),\n service_tier: z.string().nullable().optional(),\n usage: z\n .object({\n output_tokens: z.number(),\n input_tokens: z.number(),\n total_tokens: z.number(),\n input_tokens_details: z\n .object({\n cached_tokens: z.number(),\n })\n .passthrough(),\n })\n .optional(),\n })\n .passthrough(),\n});\n\nexport const wsResponseFailedEventSchema = z.object({\n type: z.literal('response.failed'),\n response: z\n .object({\n id: z.string().optional(),\n error: z\n .object({\n code: z.string().optional(),\n message: z.string().optional(),\n })\n .optional(),\n })\n .passthrough(),\n});\n\nexport const wsErrorEventSchema = z.object({\n type: z.literal('error'),\n status: z.number().optional(),\n error: z\n .object({\n type: z.string().optional(),\n code: z.string().optional(),\n message: z.string().optional(),\n param: z.string().optional(),\n })\n .optional(),\n message: z.string().optional(),\n});\n\nexport const wsServerEventSchema = z.discriminatedUnion('type', [\n wsResponseCreatedEventSchema,\n wsOutputItemDoneEventSchema,\n wsOutputTextDeltaEventSchema,\n wsResponseCompletedEventSchema,\n wsResponseFailedEventSchema,\n wsErrorEventSchema,\n]);\n\nexport type WsResponseCreatedEvent = z.infer<typeof wsResponseCreatedEventSchema>;\nexport type WsFunctionCallItem = z.infer<typeof wsFunctionCallItemSchema>;\nexport type WsOutputItem = z.infer<typeof wsOutputItemSchema>;\nexport type WsOutputItemDoneEvent = z.infer<typeof wsOutputItemDoneEventSchema>;\nexport type WsOutputTextDeltaEvent = z.infer<typeof wsOutputTextDeltaEventSchema>;\nexport type WsResponseCompletedEvent = z.infer<typeof wsResponseCompletedEventSchema>;\nexport type WsResponseFailedEvent = z.infer<typeof wsResponseFailedEventSchema>;\nexport type WsErrorEvent = z.infer<typeof wsErrorEventSchema>;\nexport type WsServerEvent = z.infer<typeof wsServerEventSchema>;\n"],"mappings":"AAGA,SAAS,SAAS;AAMX,MAAM,8BAA8B,EACxC,OAAO;AAAA,EACN,MAAM,EAAE,QAAQ,iBAAiB;AAAA,EACjC,OAAO,EAAE,OAAO;AAAA,EAChB,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC;AAAA,EAC1B,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,SAAS;AAAA,EACrC,sBAAsB,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;AAAA,EACrD,OAAO,EAAE,QAAQ,EAAE,SAAS;AAAA,EAC5B,aAAa,EAAE,OA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,EACA;AAAA,EACA;AACF,CAAC;","names":[]}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@livekit/agents-plugin-openai",
3
+ "version": "0.0.0-next-20260624041820",
4
+ "description": "OpenAI plugin for LiveKit Node Agents",
5
+ "main": "dist/index.js",
6
+ "require": "dist/index.cjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/index.d.cts",
15
+ "default": "./dist/index.cjs"
16
+ }
17
+ },
18
+ "author": "LiveKit",
19
+ "type": "module",
20
+ "repository": "git@github.com:livekit/agents-js.git",
21
+ "license": "Apache-2.0",
22
+ "files": [
23
+ "dist",
24
+ "src",
25
+ "README.md"
26
+ ],
27
+ "devDependencies": {
28
+ "@livekit/rtc-node": "^0.13.29",
29
+ "@microsoft/api-extractor": "^7.35.0",
30
+ "@types/ws": "^8.5.10",
31
+ "tsup": "^8.3.5",
32
+ "typescript": "^5.0.0",
33
+ "@livekit/agents-plugin-silero": "0.0.0-next-20260624041820",
34
+ "@livekit/agents-plugins-test": "0.0.0-next-20260624041820",
35
+ "@livekit/agents": "0.0.0-next-20260624041820"
36
+ },
37
+ "dependencies": {
38
+ "@livekit/mutex": "^1.1.1",
39
+ "openai": "^6.8.1",
40
+ "ws": "^8.18.0"
41
+ },
42
+ "peerDependencies": {
43
+ "@livekit/rtc-node": "^0.13.29",
44
+ "zod": "^3.25.76 || ^4.1.8",
45
+ "@livekit/agents": "0.0.0-next-20260624041820"
46
+ },
47
+ "scripts": {
48
+ "build": "tsup --onSuccess \"pnpm build:types\"",
49
+ "build:types": "tsc --declaration --emitDeclarationOnly && node ../../scripts/copyDeclarationOutput.js",
50
+ "clean": "rm -rf dist",
51
+ "clean:build": "pnpm clean && pnpm build",
52
+ "lint": "eslint -f unix \"src/**/*.{ts,js}\"",
53
+ "api:check": "api-extractor run --typescript-compiler-folder ../../node_modules/typescript",
54
+ "api:update": "api-extractor run --local --typescript-compiler-folder ../../node_modules/typescript --verbose"
55
+ }
56
+ }
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ // SPDX-FileCopyrightText: 2025 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { Plugin } from '@livekit/agents';
5
+
6
+ export { LLM, LLMStream, type LLMOptions } from './llm.js';
7
+ export * from './models.js';
8
+ export * from './tools.js';
9
+ export * as realtime from './realtime/index.js';
10
+ export * as responses from './responses/index.js';
11
+ export { STT, type STTOptions } from './stt.js';
12
+ export { ChunkedStream, TTS, type TTSOptions } from './tts.js';
13
+ export * as ws from './ws/index.js';
14
+
15
+ class OpenAIPlugin extends Plugin {
16
+ constructor() {
17
+ super({
18
+ title: 'openai',
19
+ version: __PACKAGE_VERSION__,
20
+ package: __PACKAGE_NAME__,
21
+ });
22
+ }
23
+ }
24
+
25
+ Plugin.registerPlugin(new OpenAIPlugin());
@@ -0,0 +1,38 @@
1
+ // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
+ //
3
+ // SPDX-License-Identifier: Apache-2.0
4
+ import { llm, llmStrict } from '@livekit/agents-plugins-test';
5
+ import { describe, it } from 'vitest';
6
+ import { LLM } from './llm.js';
7
+
8
+ const hasOpenAIApiKey = Boolean(process.env.OPENAI_API_KEY);
9
+
10
+ if (hasOpenAIApiKey) {
11
+ describe('OpenAI', async () => {
12
+ await llm(
13
+ new LLM({
14
+ temperature: 0,
15
+ }),
16
+ false,
17
+ );
18
+ });
19
+ } else {
20
+ describe('OpenAI', () => {
21
+ it.skip('requires OPENAI_API_KEY', () => {});
22
+ });
23
+ }
24
+
25
+ if (hasOpenAIApiKey) {
26
+ describe('OpenAI strict tool schema', async () => {
27
+ await llmStrict(
28
+ new LLM({
29
+ temperature: 0,
30
+ strictToolSchema: true,
31
+ }),
32
+ );
33
+ });
34
+ } else {
35
+ describe('OpenAI strict tool schema', () => {
36
+ it.skip('requires OPENAI_API_KEY', () => {});
37
+ });
38
+ }