@livekit/agents 0.4.6 → 0.5.1

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 (214) hide show
  1. package/README.md +17 -0
  2. package/dist/audio.cjs +77 -0
  3. package/dist/audio.cjs.map +1 -0
  4. package/dist/audio.js +48 -37
  5. package/dist/audio.js.map +1 -1
  6. package/dist/cli.cjs +131 -0
  7. package/dist/cli.cjs.map +1 -0
  8. package/dist/cli.js +96 -122
  9. package/dist/cli.js.map +1 -1
  10. package/dist/generator.cjs +36 -0
  11. package/dist/generator.cjs.map +1 -0
  12. package/dist/generator.js +8 -22
  13. package/dist/generator.js.map +1 -1
  14. package/dist/http_server.cjs +72 -0
  15. package/dist/http_server.cjs.map +1 -0
  16. package/dist/http_server.d.ts +1 -1
  17. package/dist/http_server.js +44 -47
  18. package/dist/http_server.js.map +1 -1
  19. package/dist/index.cjs +78 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.js +26 -28
  22. package/dist/index.js.map +1 -1
  23. package/dist/ipc/job_executor.cjs +33 -0
  24. package/dist/ipc/job_executor.cjs.map +1 -0
  25. package/dist/ipc/job_executor.js +7 -4
  26. package/dist/ipc/job_executor.js.map +1 -1
  27. package/dist/ipc/job_main.cjs +147 -0
  28. package/dist/ipc/job_main.cjs.map +1 -0
  29. package/dist/ipc/job_main.d.ts +1 -1
  30. package/dist/ipc/job_main.js +103 -103
  31. package/dist/ipc/job_main.js.map +1 -1
  32. package/dist/ipc/message.cjs +17 -0
  33. package/dist/ipc/message.cjs.map +1 -0
  34. package/dist/ipc/message.js +0 -1
  35. package/dist/ipc/message.js.map +1 -1
  36. package/dist/ipc/proc_job_executor.cjs +174 -0
  37. package/dist/ipc/proc_job_executor.cjs.map +1 -0
  38. package/dist/ipc/proc_job_executor.js +130 -126
  39. package/dist/ipc/proc_job_executor.js.map +1 -1
  40. package/dist/ipc/proc_pool.cjs +126 -0
  41. package/dist/ipc/proc_pool.cjs.map +1 -0
  42. package/dist/ipc/proc_pool.js +93 -96
  43. package/dist/ipc/proc_pool.js.map +1 -1
  44. package/dist/job.cjs +230 -0
  45. package/dist/job.cjs.map +1 -0
  46. package/dist/job.d.ts +6 -1
  47. package/dist/job.d.ts.map +1 -1
  48. package/dist/job.js +195 -198
  49. package/dist/job.js.map +1 -1
  50. package/dist/llm/chat_context.cjs +131 -0
  51. package/dist/llm/chat_context.cjs.map +1 -0
  52. package/dist/llm/chat_context.js +98 -86
  53. package/dist/llm/chat_context.js.map +1 -1
  54. package/dist/llm/function_context.cjs +103 -0
  55. package/dist/llm/function_context.cjs.map +1 -0
  56. package/dist/llm/function_context.js +72 -81
  57. package/dist/llm/function_context.js.map +1 -1
  58. package/dist/llm/function_context.test.cjs +218 -0
  59. package/dist/llm/function_context.test.cjs.map +1 -0
  60. package/dist/llm/function_context.test.js +209 -210
  61. package/dist/llm/function_context.test.js.map +1 -1
  62. package/dist/llm/index.cjs +43 -0
  63. package/dist/llm/index.cjs.map +1 -0
  64. package/dist/llm/index.js +22 -6
  65. package/dist/llm/index.js.map +1 -1
  66. package/dist/llm/llm.cjs +76 -0
  67. package/dist/llm/llm.cjs.map +1 -0
  68. package/dist/llm/llm.js +48 -42
  69. package/dist/llm/llm.js.map +1 -1
  70. package/dist/log.cjs +57 -0
  71. package/dist/log.cjs.map +1 -0
  72. package/dist/log.js +27 -26
  73. package/dist/log.js.map +1 -1
  74. package/dist/multimodal/agent_playout.cjs +228 -0
  75. package/dist/multimodal/agent_playout.cjs.map +1 -0
  76. package/dist/multimodal/agent_playout.d.ts +1 -1
  77. package/dist/multimodal/agent_playout.js +193 -180
  78. package/dist/multimodal/agent_playout.js.map +1 -1
  79. package/dist/multimodal/index.cjs +25 -0
  80. package/dist/multimodal/index.cjs.map +1 -0
  81. package/dist/multimodal/index.js +2 -5
  82. package/dist/multimodal/index.js.map +1 -1
  83. package/dist/multimodal/multimodal_agent.cjs +404 -0
  84. package/dist/multimodal/multimodal_agent.cjs.map +1 -0
  85. package/dist/multimodal/multimodal_agent.d.ts +1 -1
  86. package/dist/multimodal/multimodal_agent.js +351 -330
  87. package/dist/multimodal/multimodal_agent.js.map +1 -1
  88. package/dist/pipeline/agent_output.cjs +172 -0
  89. package/dist/pipeline/agent_output.cjs.map +1 -0
  90. package/dist/pipeline/agent_output.js +136 -138
  91. package/dist/pipeline/agent_output.js.map +1 -1
  92. package/dist/pipeline/agent_playout.cjs +169 -0
  93. package/dist/pipeline/agent_playout.cjs.map +1 -0
  94. package/dist/pipeline/agent_playout.js +126 -136
  95. package/dist/pipeline/agent_playout.js.map +1 -1
  96. package/dist/pipeline/human_input.cjs +158 -0
  97. package/dist/pipeline/human_input.cjs.map +1 -0
  98. package/dist/pipeline/human_input.js +124 -125
  99. package/dist/pipeline/human_input.js.map +1 -1
  100. package/dist/pipeline/index.cjs +31 -0
  101. package/dist/pipeline/index.cjs.map +1 -0
  102. package/dist/pipeline/index.js +8 -4
  103. package/dist/pipeline/index.js.map +1 -1
  104. package/dist/pipeline/pipeline_agent.cjs +642 -0
  105. package/dist/pipeline/pipeline_agent.cjs.map +1 -0
  106. package/dist/pipeline/pipeline_agent.js +595 -651
  107. package/dist/pipeline/pipeline_agent.js.map +1 -1
  108. package/dist/pipeline/speech_handle.cjs +128 -0
  109. package/dist/pipeline/speech_handle.cjs.map +1 -0
  110. package/dist/pipeline/speech_handle.js +102 -100
  111. package/dist/pipeline/speech_handle.js.map +1 -1
  112. package/dist/plugin.cjs +46 -0
  113. package/dist/plugin.cjs.map +1 -0
  114. package/dist/plugin.js +20 -20
  115. package/dist/plugin.js.map +1 -1
  116. package/dist/stt/index.cjs +38 -0
  117. package/dist/stt/index.cjs.map +1 -0
  118. package/dist/stt/index.js +13 -5
  119. package/dist/stt/index.js.map +1 -1
  120. package/dist/stt/stream_adapter.cjs +87 -0
  121. package/dist/stt/stream_adapter.cjs.map +1 -0
  122. package/dist/stt/stream_adapter.js +58 -55
  123. package/dist/stt/stream_adapter.js.map +1 -1
  124. package/dist/stt/stt.cjs +98 -0
  125. package/dist/stt/stt.cjs.map +1 -0
  126. package/dist/stt/stt.js +63 -98
  127. package/dist/stt/stt.js.map +1 -1
  128. package/dist/tokenize/basic/basic.cjs +98 -0
  129. package/dist/tokenize/basic/basic.cjs.map +1 -0
  130. package/dist/tokenize/basic/basic.d.ts +1 -1
  131. package/dist/tokenize/basic/basic.d.ts.map +1 -1
  132. package/dist/tokenize/basic/basic.js +56 -45
  133. package/dist/tokenize/basic/basic.js.map +1 -1
  134. package/dist/tokenize/basic/hyphenator.cjs +425 -0
  135. package/dist/tokenize/basic/hyphenator.cjs.map +1 -0
  136. package/dist/tokenize/basic/hyphenator.js +66 -82
  137. package/dist/tokenize/basic/hyphenator.js.map +1 -1
  138. package/dist/tokenize/basic/index.cjs +35 -0
  139. package/dist/tokenize/basic/index.cjs.map +1 -0
  140. package/dist/tokenize/basic/index.js +7 -4
  141. package/dist/tokenize/basic/index.js.map +1 -1
  142. package/dist/tokenize/basic/paragraph.cjs +57 -0
  143. package/dist/tokenize/basic/paragraph.cjs.map +1 -0
  144. package/dist/tokenize/basic/paragraph.js +30 -35
  145. package/dist/tokenize/basic/paragraph.js.map +1 -1
  146. package/dist/tokenize/basic/sentence.cjs +89 -0
  147. package/dist/tokenize/basic/sentence.cjs.map +1 -0
  148. package/dist/tokenize/basic/sentence.d.ts.map +1 -1
  149. package/dist/tokenize/basic/sentence.js +62 -57
  150. package/dist/tokenize/basic/sentence.js.map +1 -1
  151. package/dist/tokenize/basic/word.cjs +44 -0
  152. package/dist/tokenize/basic/word.cjs.map +1 -0
  153. package/dist/tokenize/basic/word.js +17 -20
  154. package/dist/tokenize/basic/word.js.map +1 -1
  155. package/dist/tokenize/index.cjs +55 -0
  156. package/dist/tokenize/index.cjs.map +1 -0
  157. package/dist/tokenize/index.js +18 -7
  158. package/dist/tokenize/index.js.map +1 -1
  159. package/dist/tokenize/token_stream.cjs +164 -0
  160. package/dist/tokenize/token_stream.cjs.map +1 -0
  161. package/dist/tokenize/token_stream.js +133 -139
  162. package/dist/tokenize/token_stream.js.map +1 -1
  163. package/dist/tokenize/tokenizer.cjs +184 -0
  164. package/dist/tokenize/tokenizer.cjs.map +1 -0
  165. package/dist/tokenize/tokenizer.js +138 -99
  166. package/dist/tokenize/tokenizer.js.map +1 -1
  167. package/dist/tokenize/tokenizer.test.cjs +220 -0
  168. package/dist/tokenize/tokenizer.test.cjs.map +1 -0
  169. package/dist/tokenize/tokenizer.test.d.ts +2 -0
  170. package/dist/tokenize/tokenizer.test.d.ts.map +1 -0
  171. package/dist/tokenize/tokenizer.test.js +219 -0
  172. package/dist/tokenize/tokenizer.test.js.map +1 -0
  173. package/dist/transcription.cjs +131 -0
  174. package/dist/transcription.cjs.map +1 -0
  175. package/dist/transcription.js +99 -96
  176. package/dist/transcription.js.map +1 -1
  177. package/dist/tts/index.cjs +38 -0
  178. package/dist/tts/index.cjs.map +1 -0
  179. package/dist/tts/index.js +13 -5
  180. package/dist/tts/index.js.map +1 -1
  181. package/dist/tts/stream_adapter.cjs +78 -0
  182. package/dist/tts/stream_adapter.cjs.map +1 -0
  183. package/dist/tts/stream_adapter.js +50 -47
  184. package/dist/tts/stream_adapter.js.map +1 -1
  185. package/dist/tts/tts.cjs +127 -0
  186. package/dist/tts/tts.cjs.map +1 -0
  187. package/dist/tts/tts.js +90 -120
  188. package/dist/tts/tts.js.map +1 -1
  189. package/dist/utils.cjs +284 -0
  190. package/dist/utils.cjs.map +1 -0
  191. package/dist/utils.js +242 -247
  192. package/dist/utils.js.map +1 -1
  193. package/dist/vad.cjs +92 -0
  194. package/dist/vad.cjs.map +1 -0
  195. package/dist/vad.js +57 -52
  196. package/dist/vad.js.map +1 -1
  197. package/dist/version.cjs +29 -0
  198. package/dist/version.cjs.map +1 -0
  199. package/dist/version.js +4 -4
  200. package/dist/version.js.map +1 -1
  201. package/dist/worker.cjs +577 -0
  202. package/dist/worker.cjs.map +1 -0
  203. package/dist/worker.d.ts +1 -1
  204. package/dist/worker.d.ts.map +1 -1
  205. package/dist/worker.js +512 -484
  206. package/dist/worker.js.map +1 -1
  207. package/package.json +18 -8
  208. package/src/ipc/job_main.ts +66 -64
  209. package/src/job.ts +3 -2
  210. package/src/pipeline/pipeline_agent.ts +23 -23
  211. package/src/tokenize/basic/basic.ts +1 -1
  212. package/src/tokenize/basic/sentence.ts +14 -8
  213. package/src/tokenize/tokenizer.test.ts +255 -0
  214. package/src/worker.ts +1 -0
@@ -1 +1 @@
1
- {"version":3,"file":"function_context.test.js","sourceRoot":"","sources":["../../src/llm/function_context.test.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;gBACtB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,eAAe,CAAC;gBAC1C,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC;aACzC,CAAC,CAAC;YAEH,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC;YAEjC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,IAAI,EAAE;wBACJ,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,eAAe;qBAC7B;oBACD,GAAG,EAAE;wBACH,IAAI,EAAE,QAAQ;wBACd,WAAW,EAA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CAAC,MAAM,EAAE,WAAW,CAAC;6BAChC;yBACF;qBACF;oBACD,QAAQ,EAAE,CAAC,OAAO,CAAC;iBACpB,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/llm/function_context.test.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { describe, expect, it } from 'vitest';\nimport { z } from 'zod';\nimport type { CallableFunction } from './function_context.js';\nimport { oaiParams } from './function_context.js';\n\ndescribe('function_context', () => {\n describe('oaiParams', () => {\n it('should handle basic object schema', () => {\n const schema = z.object({\n name: z.string().describe('The user name'),\n age: z.number().describe('The user age'),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The user name',\n },\n age: {\n type: 'number',\n description: 'The user age',\n },\n },\n required: ['name', 'age'],\n });\n });\n\n it('should handle enum fields', () => {\n const schema = z.object({\n color: z.enum(['red', 'blue', 'green']).describe('Choose a color'),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n color: {\n type: 'string',\n description: 'Choose a color',\n enum: ['red', 'blue', 'green'],\n },\n },\n required: ['color'],\n });\n });\n\n it('should handle array fields', () => {\n const schema = z.object({\n tags: z.array(z.string()).describe('List of tags'),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n tags: {\n type: 'array',\n description: 'List of tags',\n items: {\n type: 'string',\n },\n },\n },\n required: ['tags'],\n });\n });\n\n it('should handle array of enums', () => {\n const schema = z.object({\n colors: z.array(z.enum(['red', 'blue', 'green'])).describe('List of colors'),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n colors: {\n type: 'array',\n description: 'List of colors',\n items: {\n type: 'string',\n enum: ['red', 'blue', 'green'],\n },\n },\n },\n required: ['colors'],\n });\n });\n\n it('should handle optional fields', () => {\n const schema = z.object({\n name: z.string().describe('The user name'),\n age: z.number().optional().describe('The user age'),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'The user name',\n },\n age: {\n type: 'number',\n description: 'The user age',\n },\n },\n required: ['name'], // age should not be required\n });\n });\n\n it('should handle fields without descriptions', () => {\n const schema = z.object({\n name: z.string(),\n age: z.number(),\n });\n\n const result = oaiParams(schema);\n\n expect(result).toEqual({\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: undefined,\n },\n age: {\n type: 'number',\n description: undefined,\n },\n },\n required: ['name', 'age'],\n });\n });\n });\n\n describe('CallableFunction type', () => {\n it('should properly type a callable function', async () => {\n const schema = z.object({\n name: z.string().describe('The user name'),\n age: z.number().describe('The user age'),\n });\n\n const testFunction: CallableFunction<typeof schema, string> = {\n description: 'Test function',\n parameters: schema,\n execute: async (args: z.infer<typeof schema>) => {\n // TypeScript should recognize args.name and args.age\n return `${args.name} is ${args.age} years old`;\n },\n };\n\n const result = await testFunction.execute({ name: 'John', age: 30 });\n expect(result).toBe('John is 30 years old');\n });\n\n it('should handle async execution', async () => {\n const schema = z.object({\n delay: z.number().describe('Delay in milliseconds'),\n });\n\n const testFunction: CallableFunction<typeof schema, number> = {\n description: 'Async test function',\n parameters: schema,\n execute: async (args: z.infer<typeof schema>) => {\n await new Promise((resolve) => setTimeout(resolve, args.delay));\n return args.delay;\n },\n };\n\n const start = Date.now();\n const result = await testFunction.execute({ delay: 100 });\n const duration = Date.now() - start;\n\n expect(result).toBe(100);\n expect(duration).toBeGreaterThanOrEqual(95); // Allow for small timing variations\n });\n\n describe('nested array support', () => {\n it('should handle nested array fields', () => {\n const schema = z.object({\n items: z.array(\n z.object({\n name: z.string().describe('the item name'),\n modifiers: z\n .array(\n z.object({\n modifier_name: z.string(),\n modifier_value: z.string(),\n }),\n )\n .describe('list of the modifiers applied on this item, such as size'),\n }),\n ),\n });\n const result = oaiParams(schema);\n expect(result).toEqual({\n type: 'object',\n properties: {\n items: {\n type: 'array',\n description: undefined,\n items: {\n type: 'object',\n properties: {\n name: {\n type: 'string',\n description: 'the item name',\n },\n modifiers: {\n type: 'array',\n description: 'list of the modifiers applied on this item, such as size',\n items: {\n type: 'object',\n properties: {\n modifier_name: {\n type: 'string',\n },\n modifier_value: {\n type: 'string',\n },\n },\n required: ['modifier_name', 'modifier_value'],\n },\n },\n },\n required: ['name', 'modifiers'],\n },\n },\n },\n required: ['items'],\n });\n });\n });\n });\n});\n"],"mappings":"AAGA,SAAS,UAAU,QAAQ,UAAU;AACrC,SAAS,SAAS;AAElB,SAAS,iBAAiB;AAE1B,SAAS,oBAAoB,MAAM;AACjC,WAAS,aAAa,MAAM;AAC1B,OAAG,qCAAqC,MAAM;AAC5C,YAAM,SAAS,EAAE,OAAO;AAAA,QACtB,MAAM,EAAE,OAAO,EAAE,SAAS,eAAe;AAAA,QACzC,KAAK,EAAE,OAAO,EAAE,SAAS,cAAc;AAAA,MACzC,CAAC;AAED,YAAM,SAAS,UAAU,MAAM;AAE/B,aAAO,MAAM,EAAE,QAAQ;AAAA,QACrB,MAAM;AAAA,QACN,YAAY;AAAA,UACV,MAAM;AAAA,YACJ,MAAM;AAAA,YACN,aAAa;AAAA,UACf;AAAA,UACA,KAAK;AAAA,YACH,MAAM;AAAA,YACN,aAAa;AAAA,UACf;AAAA,QACF;AAAA,QACA,UAAU,CAAC,QAAQ,KAAK;AAAA,MAC1B,CAAC;AAAA,IACH,CAAC;AAED,OAAG,6BAA6B,MAAM;AACpC,YAAM,SAAS,EAAE,OAAO;AAAA,QACtB,OAAO,EAAE,KAAK,CAAC,OAAO,QAAQ,OAAO,CAAC,EAAE,SAAS,gBAAgB;AAAA,MACnE,CAAC;AAED,YAAM,SAAS,UAAU,MAAM;AAE/B,aAAO,MAAM,EAAE,QAAQ;AAAA,QACrB,M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oBACJ,MAAM;AAAA,oBACN,aAAa;AAAA,kBACf;AAAA,kBACA,WAAW;AAAA,oBACT,MAAM;AAAA,oBACN,aAAa;AAAA,oBACb,OAAO;AAAA,sBACL,MAAM;AAAA,sBACN,YAAY;AAAA,wBACV,eAAe;AAAA,0BACb,MAAM;AAAA,wBACR;AAAA,wBACA,gBAAgB;AAAA,0BACd,MAAM;AAAA,wBACR;AAAA,sBACF;AAAA,sBACA,UAAU,CAAC,iBAAiB,gBAAgB;AAAA,oBAC9C;AAAA,kBACF;AAAA,gBACF;AAAA,gBACA,UAAU,CAAC,QAAQ,WAAW;AAAA,cAChC;AAAA,YACF;AAAA,UACF;AAAA,UACA,UAAU,CAAC,OAAO;AAAA,QACpB,CAAC;AAAA,MACH,CAAC;AAAA,IACH,CAAC;AAAA,EACH,CAAC;AACH,CAAC;","names":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var llm_exports = {};
20
+ __export(llm_exports, {
21
+ ChatContext: () => import_chat_context.ChatContext,
22
+ ChatMessage: () => import_chat_context.ChatMessage,
23
+ ChatRole: () => import_chat_context.ChatRole,
24
+ LLM: () => import_llm.LLM,
25
+ LLMStream: () => import_llm.LLMStream,
26
+ oaiBuildFunctionInfo: () => import_function_context.oaiBuildFunctionInfo,
27
+ oaiParams: () => import_function_context.oaiParams
28
+ });
29
+ module.exports = __toCommonJS(llm_exports);
30
+ var import_function_context = require("./function_context.cjs");
31
+ var import_chat_context = require("./chat_context.cjs");
32
+ var import_llm = require("./llm.cjs");
33
+ // Annotate the CommonJS export names for ESM import in node:
34
+ 0 && (module.exports = {
35
+ ChatContext,
36
+ ChatMessage,
37
+ ChatRole,
38
+ LLM,
39
+ LLMStream,
40
+ oaiBuildFunctionInfo,
41
+ oaiParams
42
+ });
43
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n type CallableFunction,\n type FunctionCallInfo,\n type CallableFunctionResult,\n type FunctionContext,\n type inferParameters,\n oaiParams,\n oaiBuildFunctionInfo,\n} from './function_context.js';\n\nexport {\n type ChatImage,\n type ChatAudio,\n type ChatContent,\n ChatRole,\n ChatMessage,\n ChatContext,\n} from './chat_context.js';\n\nexport {\n type ChoiceDelta,\n type CompletionUsage,\n type Choice,\n type ChatChunk,\n LLM,\n LLMStream,\n} from './llm.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,8BAQO;AAEP,0BAOO;AAEP,iBAOO;","names":[]}
package/dist/llm/index.js CHANGED
@@ -1,7 +1,23 @@
1
- // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
- //
3
- // SPDX-License-Identifier: Apache-2.0
4
- export { oaiParams, oaiBuildFunctionInfo, } from './function_context.js';
5
- export { ChatRole, ChatMessage, ChatContext, } from './chat_context.js';
6
- export { LLM, LLMStream, } from './llm.js';
1
+ import {
2
+ oaiParams,
3
+ oaiBuildFunctionInfo
4
+ } from "./function_context.js";
5
+ import {
6
+ ChatRole,
7
+ ChatMessage,
8
+ ChatContext
9
+ } from "./chat_context.js";
10
+ import {
11
+ LLM,
12
+ LLMStream
13
+ } from "./llm.js";
14
+ export {
15
+ ChatContext,
16
+ ChatMessage,
17
+ ChatRole,
18
+ LLM,
19
+ LLMStream,
20
+ oaiBuildFunctionInfo,
21
+ oaiParams
22
+ };
7
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/llm/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAML,SAAS,EACT,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAIL,QAAQ,EACR,WAAW,EACX,WAAW,GACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAKL,GAAG,EACH,SAAS,GACV,MAAM,UAAU,CAAC"}
1
+ {"version":3,"sources":["../../src/llm/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nexport {\n type CallableFunction,\n type FunctionCallInfo,\n type CallableFunctionResult,\n type FunctionContext,\n type inferParameters,\n oaiParams,\n oaiBuildFunctionInfo,\n} from './function_context.js';\n\nexport {\n type ChatImage,\n type ChatAudio,\n type ChatContent,\n ChatRole,\n ChatMessage,\n ChatContext,\n} from './chat_context.js';\n\nexport {\n type ChoiceDelta,\n type CompletionUsage,\n type Choice,\n type ChatChunk,\n LLM,\n LLMStream,\n} from './llm.js';\n"],"mappings":"AAGA;AAAA,EAME;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAIE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EAKE;AAAA,EACA;AAAA,OACK;","names":[]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var llm_exports = {};
20
+ __export(llm_exports, {
21
+ LLM: () => LLM,
22
+ LLMStream: () => LLMStream
23
+ });
24
+ module.exports = __toCommonJS(llm_exports);
25
+ var import_utils = require("../utils.cjs");
26
+ class LLM {
27
+ }
28
+ class LLMStream {
29
+ queue = new import_utils.AsyncIterableQueue();
30
+ closed = false;
31
+ _functionCalls = [];
32
+ #chatCtx;
33
+ #fncCtx;
34
+ constructor(chatCtx, fncCtx) {
35
+ this.#chatCtx = chatCtx;
36
+ this.#fncCtx = fncCtx;
37
+ }
38
+ /** List of called functions from this stream. */
39
+ get functionCalls() {
40
+ return this._functionCalls;
41
+ }
42
+ /** The function context of this stream. */
43
+ get fncCtx() {
44
+ return this.#fncCtx;
45
+ }
46
+ /** The initial chat context of this stream. */
47
+ get chatCtx() {
48
+ return this.#chatCtx;
49
+ }
50
+ /** Execute all deferred functions of this stream concurrently. */
51
+ executeFunctions() {
52
+ this._functionCalls.forEach(
53
+ (f) => f.task = f.func.execute(f.params).then(
54
+ (result) => ({ name: f.name, toolCallId: f.toolCallId, result }),
55
+ (error) => ({ name: f.name, toolCallId: f.toolCallId, error })
56
+ )
57
+ );
58
+ return this._functionCalls;
59
+ }
60
+ next() {
61
+ return this.queue.next();
62
+ }
63
+ close() {
64
+ this.queue.close();
65
+ this.closed = true;
66
+ }
67
+ [Symbol.asyncIterator]() {
68
+ return this;
69
+ }
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ LLM,
74
+ LLMStream
75
+ });
76
+ //# sourceMappingURL=llm.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/llm/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { AsyncIterableQueue } from '../utils.js';\nimport type { ChatContext, ChatRole } from './chat_context.js';\nimport type { FunctionCallInfo, FunctionContext } from './function_context.js';\n\nexport interface ChoiceDelta {\n role: ChatRole;\n content?: string;\n toolCalls?: FunctionCallInfo[];\n}\n\nexport interface CompletionUsage {\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n}\n\nexport interface Choice {\n delta: ChoiceDelta;\n index: number;\n}\n\nexport interface ChatChunk {\n requestId: string;\n choices: Choice[];\n usage?: CompletionUsage;\n}\n\nexport abstract class LLM {\n /**\n * Returns a {@link LLMStream} that can be used to push text and receive LLM responses.\n */\n abstract chat({\n chatCtx,\n fncCtx,\n temperature,\n n,\n parallelToolCalls,\n }: {\n chatCtx: ChatContext;\n fncCtx?: FunctionContext;\n temperature?: number;\n n?: number;\n parallelToolCalls?: boolean;\n }): LLMStream;\n}\n\nexport abstract class LLMStream implements AsyncIterableIterator<ChatChunk> {\n protected queue = new AsyncIterableQueue<ChatChunk>();\n protected closed = false;\n protected _functionCalls: FunctionCallInfo[] = [];\n\n #chatCtx: ChatContext;\n #fncCtx?: FunctionContext;\n\n constructor(chatCtx: ChatContext, fncCtx?: FunctionContext) {\n this.#chatCtx = chatCtx;\n this.#fncCtx = fncCtx;\n }\n\n /** List of called functions from this stream. */\n get functionCalls(): FunctionCallInfo[] {\n return this._functionCalls;\n }\n\n /** The function context of this stream. */\n get fncCtx(): FunctionContext | undefined {\n return this.#fncCtx;\n }\n\n /** The initial chat context of this stream. */\n get chatCtx(): ChatContext {\n return this.#chatCtx;\n }\n\n /** Execute all deferred functions of this stream concurrently. */\n executeFunctions(): FunctionCallInfo[] {\n this._functionCalls.forEach(\n (f) =>\n (f.task = f.func.execute(f.params).then(\n (result) => ({ name: f.name, toolCallId: f.toolCallId, result }),\n (error) => ({ name: f.name, toolCallId: f.toolCallId, error }),\n )),\n );\n return this._functionCalls;\n }\n\n next(): Promise<IteratorResult<ChatChunk>> {\n return this.queue.next();\n }\n\n close() {\n this.queue.close();\n this.closed = true;\n }\n\n [Symbol.asyncIterator](): LLMStream {\n return this;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,mBAAmC;AA2B5B,MAAe,IAAI;AAiB1B;AAEO,MAAe,UAAsD;AAAA,EAChE,QAAQ,IAAI,gCAA8B;AAAA,EAC1C,SAAS;AAAA,EACT,iBAAqC,CAAC;AAAA,EAEhD;AAAA,EACA;AAAA,EAEA,YAAY,SAAsB,QAA0B;AAC1D,SAAK,WAAW;AAChB,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA,EAGA,IAAI,gBAAoC;AACtC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,SAAsC;AACxC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,UAAuB;AACzB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,mBAAuC;AACrC,SAAK,eAAe;AAAA,MAClB,CAAC,MACE,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE;AAAA,QACjC,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE,YAAY,OAAO;AAAA,QAC9D,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE,YAAY,MAAM;AAAA,MAC9D;AAAA,IACJ;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,OAA2C;AACzC,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEA,QAAQ;AACN,SAAK,MAAM,MAAM;AACjB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAe;AAClC,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/llm/llm.js CHANGED
@@ -1,45 +1,51 @@
1
- // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
- //
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { AsyncIterableQueue } from '../utils.js';
5
- export class LLM {
1
+ import { AsyncIterableQueue } from "../utils.js";
2
+ class LLM {
6
3
  }
7
- export class LLMStream {
8
- queue = new AsyncIterableQueue();
9
- closed = false;
10
- _functionCalls = [];
11
- #chatCtx;
12
- #fncCtx;
13
- constructor(chatCtx, fncCtx) {
14
- this.#chatCtx = chatCtx;
15
- this.#fncCtx = fncCtx;
16
- }
17
- /** List of called functions from this stream. */
18
- get functionCalls() {
19
- return this._functionCalls;
20
- }
21
- /** The function context of this stream. */
22
- get fncCtx() {
23
- return this.#fncCtx;
24
- }
25
- /** The initial chat context of this stream. */
26
- get chatCtx() {
27
- return this.#chatCtx;
28
- }
29
- /** Execute all deferred functions of this stream concurrently. */
30
- executeFunctions() {
31
- this._functionCalls.forEach((f) => (f.task = f.func.execute(f.params).then((result) => ({ name: f.name, toolCallId: f.toolCallId, result }), (error) => ({ name: f.name, toolCallId: f.toolCallId, error }))));
32
- return this._functionCalls;
33
- }
34
- next() {
35
- return this.queue.next();
36
- }
37
- close() {
38
- this.queue.close();
39
- this.closed = true;
40
- }
41
- [Symbol.asyncIterator]() {
42
- return this;
43
- }
4
+ class LLMStream {
5
+ queue = new AsyncIterableQueue();
6
+ closed = false;
7
+ _functionCalls = [];
8
+ #chatCtx;
9
+ #fncCtx;
10
+ constructor(chatCtx, fncCtx) {
11
+ this.#chatCtx = chatCtx;
12
+ this.#fncCtx = fncCtx;
13
+ }
14
+ /** List of called functions from this stream. */
15
+ get functionCalls() {
16
+ return this._functionCalls;
17
+ }
18
+ /** The function context of this stream. */
19
+ get fncCtx() {
20
+ return this.#fncCtx;
21
+ }
22
+ /** The initial chat context of this stream. */
23
+ get chatCtx() {
24
+ return this.#chatCtx;
25
+ }
26
+ /** Execute all deferred functions of this stream concurrently. */
27
+ executeFunctions() {
28
+ this._functionCalls.forEach(
29
+ (f) => f.task = f.func.execute(f.params).then(
30
+ (result) => ({ name: f.name, toolCallId: f.toolCallId, result }),
31
+ (error) => ({ name: f.name, toolCallId: f.toolCallId, error })
32
+ )
33
+ );
34
+ return this._functionCalls;
35
+ }
36
+ next() {
37
+ return this.queue.next();
38
+ }
39
+ close() {
40
+ this.queue.close();
41
+ this.closed = true;
42
+ }
43
+ [Symbol.asyncIterator]() {
44
+ return this;
45
+ }
44
46
  }
47
+ export {
48
+ LLM,
49
+ LLMStream
50
+ };
45
51
  //# sourceMappingURL=llm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/llm/llm.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AA2BjD,MAAM,OAAgB,GAAG;CAiBxB;AAED,MAAM,OAAgB,SAAS;IACnB,KAAK,GAAG,IAAI,kBAAkB,EAAa,CAAC;IAC5C,MAAM,GAAG,KAAK,CAAC;IACf,cAAc,GAAuB,EAAE,CAAC;IAElD,QAAQ,CAAc;IACtB,OAAO,CAAmB;IAE1B,YAAY,OAAoB,EAAE,MAAwB;QACxD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED,iDAAiD;IACjD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,2CAA2C;IAC3C,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,+CAA+C;IAC/C,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,kEAAkE;IAClE,gBAAgB;QACd,IAAI,CAAC,cAAc,CAAC,OAAO,CACzB,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CACrC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,MAAM,EAAE,CAAC,EAChE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,KAAK,EAAE,CAAC,CAC/D,CAAC,CACL,CAAC;QACF,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAED,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
1
+ {"version":3,"sources":["../../src/llm/llm.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { AsyncIterableQueue } from '../utils.js';\nimport type { ChatContext, ChatRole } from './chat_context.js';\nimport type { FunctionCallInfo, FunctionContext } from './function_context.js';\n\nexport interface ChoiceDelta {\n role: ChatRole;\n content?: string;\n toolCalls?: FunctionCallInfo[];\n}\n\nexport interface CompletionUsage {\n completionTokens: number;\n promptTokens: number;\n totalTokens: number;\n}\n\nexport interface Choice {\n delta: ChoiceDelta;\n index: number;\n}\n\nexport interface ChatChunk {\n requestId: string;\n choices: Choice[];\n usage?: CompletionUsage;\n}\n\nexport abstract class LLM {\n /**\n * Returns a {@link LLMStream} that can be used to push text and receive LLM responses.\n */\n abstract chat({\n chatCtx,\n fncCtx,\n temperature,\n n,\n parallelToolCalls,\n }: {\n chatCtx: ChatContext;\n fncCtx?: FunctionContext;\n temperature?: number;\n n?: number;\n parallelToolCalls?: boolean;\n }): LLMStream;\n}\n\nexport abstract class LLMStream implements AsyncIterableIterator<ChatChunk> {\n protected queue = new AsyncIterableQueue<ChatChunk>();\n protected closed = false;\n protected _functionCalls: FunctionCallInfo[] = [];\n\n #chatCtx: ChatContext;\n #fncCtx?: FunctionContext;\n\n constructor(chatCtx: ChatContext, fncCtx?: FunctionContext) {\n this.#chatCtx = chatCtx;\n this.#fncCtx = fncCtx;\n }\n\n /** List of called functions from this stream. */\n get functionCalls(): FunctionCallInfo[] {\n return this._functionCalls;\n }\n\n /** The function context of this stream. */\n get fncCtx(): FunctionContext | undefined {\n return this.#fncCtx;\n }\n\n /** The initial chat context of this stream. */\n get chatCtx(): ChatContext {\n return this.#chatCtx;\n }\n\n /** Execute all deferred functions of this stream concurrently. */\n executeFunctions(): FunctionCallInfo[] {\n this._functionCalls.forEach(\n (f) =>\n (f.task = f.func.execute(f.params).then(\n (result) => ({ name: f.name, toolCallId: f.toolCallId, result }),\n (error) => ({ name: f.name, toolCallId: f.toolCallId, error }),\n )),\n );\n return this._functionCalls;\n }\n\n next(): Promise<IteratorResult<ChatChunk>> {\n return this.queue.next();\n }\n\n close() {\n this.queue.close();\n this.closed = true;\n }\n\n [Symbol.asyncIterator](): LLMStream {\n return this;\n }\n}\n"],"mappings":"AAGA,SAAS,0BAA0B;AA2B5B,MAAe,IAAI;AAiB1B;AAEO,MAAe,UAAsD;AAAA,EAChE,QAAQ,IAAI,mBAA8B;AAAA,EAC1C,SAAS;AAAA,EACT,iBAAqC,CAAC;AAAA,EAEhD;AAAA,EACA;AAAA,EAEA,YAAY,SAAsB,QAA0B;AAC1D,SAAK,WAAW;AAChB,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA,EAGA,IAAI,gBAAoC;AACtC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,SAAsC;AACxC,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,UAAuB;AACzB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA,EAGA,mBAAuC;AACrC,SAAK,eAAe;AAAA,MAClB,CAAC,MACE,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE;AAAA,QACjC,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE,YAAY,OAAO;AAAA,QAC9D,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE,YAAY,MAAM;AAAA,MAC9D;AAAA,IACJ;AACA,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,OAA2C;AACzC,WAAO,KAAK,MAAM,KAAK;AAAA,EACzB;AAAA,EAEA,QAAQ;AACN,SAAK,MAAM,MAAM;AACjB,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAe;AAClC,WAAO;AAAA,EACT;AACF;","names":[]}
package/dist/log.cjs ADDED
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var log_exports = {};
20
+ __export(log_exports, {
21
+ initializeLogger: () => initializeLogger,
22
+ log: () => log,
23
+ loggerOptions: () => loggerOptions
24
+ });
25
+ module.exports = __toCommonJS(log_exports);
26
+ var import_pino = require("pino");
27
+ let loggerOptions;
28
+ let logger = void 0;
29
+ const log = () => {
30
+ if (!logger) {
31
+ throw new TypeError("logger not initialized. did you forget to run initializeLogger()?");
32
+ }
33
+ return logger;
34
+ };
35
+ const initializeLogger = ({ pretty, level }) => {
36
+ loggerOptions = { pretty, level };
37
+ logger = (0, import_pino.pino)(
38
+ pretty ? {
39
+ transport: {
40
+ target: "pino-pretty",
41
+ options: {
42
+ colorize: true
43
+ }
44
+ }
45
+ } : {}
46
+ );
47
+ if (level) {
48
+ logger.level = level;
49
+ }
50
+ };
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ initializeLogger,
54
+ log,
55
+ loggerOptions
56
+ });
57
+ //# sourceMappingURL=log.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { Logger } from 'pino';\nimport { pino } from 'pino';\n\n/** @internal */\nexport type LoggerOptions = {\n pretty: boolean;\n level?: string;\n};\n\n/** @internal */\nexport let loggerOptions: LoggerOptions;\n\n/** @internal */\nlet logger: Logger | undefined = undefined;\n\n/** @internal */\nexport const log = () => {\n if (!logger) {\n throw new TypeError('logger not initialized. did you forget to run initializeLogger()?');\n }\n return logger;\n};\n\n/** @internal */\nexport const initializeLogger = ({ pretty, level }: LoggerOptions) => {\n loggerOptions = { pretty, level };\n logger = pino(\n pretty\n ? {\n transport: {\n target: 'pino-pretty',\n options: {\n colorize: true,\n },\n },\n }\n : {},\n );\n if (level) {\n logger.level = level;\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,kBAAqB;AASd,IAAI;AAGX,IAAI,SAA6B;AAG1B,MAAM,MAAM,MAAM;AACvB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,UAAU,mEAAmE;AAAA,EACzF;AACA,SAAO;AACT;AAGO,MAAM,mBAAmB,CAAC,EAAE,QAAQ,MAAM,MAAqB;AACpE,kBAAgB,EAAE,QAAQ,MAAM;AAChC,eAAS;AAAA,IACP,SACI;AAAA,MACE,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF,IACA,CAAC;AAAA,EACP;AACA,MAAI,OAAO;AACT,WAAO,QAAQ;AAAA,EACjB;AACF;","names":[]}
package/dist/log.js CHANGED
@@ -1,30 +1,31 @@
1
- import { pino } from 'pino';
2
- /** @internal */
3
- export let loggerOptions;
4
- /** @internal */
5
- let logger = undefined;
6
- /** @internal */
7
- export const log = () => {
8
- if (!logger) {
9
- throw new TypeError('logger not initialized. did you forget to run initializeLogger()?');
10
- }
11
- return logger;
1
+ import { pino } from "pino";
2
+ let loggerOptions;
3
+ let logger = void 0;
4
+ const log = () => {
5
+ if (!logger) {
6
+ throw new TypeError("logger not initialized. did you forget to run initializeLogger()?");
7
+ }
8
+ return logger;
12
9
  };
13
- /** @internal */
14
- export const initializeLogger = ({ pretty, level }) => {
15
- loggerOptions = { pretty, level };
16
- logger = pino(pretty
17
- ? {
18
- transport: {
19
- target: 'pino-pretty',
20
- options: {
21
- colorize: true,
22
- },
23
- },
10
+ const initializeLogger = ({ pretty, level }) => {
11
+ loggerOptions = { pretty, level };
12
+ logger = pino(
13
+ pretty ? {
14
+ transport: {
15
+ target: "pino-pretty",
16
+ options: {
17
+ colorize: true
24
18
  }
25
- : {});
26
- if (level) {
27
- logger.level = level;
28
- }
19
+ }
20
+ } : {}
21
+ );
22
+ if (level) {
23
+ logger.level = level;
24
+ }
25
+ };
26
+ export {
27
+ initializeLogger,
28
+ log,
29
+ loggerOptions
29
30
  };
30
31
  //# sourceMappingURL=log.js.map
package/dist/log.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"log.js","sourceRoot":"","sources":["../src/log.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAQ5B,gBAAgB;AAChB,MAAM,CAAC,IAAI,aAA4B,CAAC;AAExC,gBAAgB;AAChB,IAAI,MAAM,GAAuB,SAAS,CAAC;AAE3C,gBAAgB;AAChB,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,EAAE;IACtB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,SAAS,CAAC,mEAAmE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,gBAAgB;AAChB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,EAAE,MAAM,EAAE,KAAK,EAAiB,EAAE,EAAE;IACnE,aAAa,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAClC,MAAM,GAAG,IAAI,CACX,MAAM;QACJ,CAAC,CAAC;YACE,SAAS,EAAE;gBACT,MAAM,EAAE,aAAa;gBACrB,OAAO,EAAE;oBACP,QAAQ,EAAE,IAAI;iBACf;aACF;SACF;QACH,CAAC,CAAC,EAAE,CACP,CAAC;IACF,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;AACH,CAAC,CAAC"}
1
+ {"version":3,"sources":["../src/log.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { Logger } from 'pino';\nimport { pino } from 'pino';\n\n/** @internal */\nexport type LoggerOptions = {\n pretty: boolean;\n level?: string;\n};\n\n/** @internal */\nexport let loggerOptions: LoggerOptions;\n\n/** @internal */\nlet logger: Logger | undefined = undefined;\n\n/** @internal */\nexport const log = () => {\n if (!logger) {\n throw new TypeError('logger not initialized. did you forget to run initializeLogger()?');\n }\n return logger;\n};\n\n/** @internal */\nexport const initializeLogger = ({ pretty, level }: LoggerOptions) => {\n loggerOptions = { pretty, level };\n logger = pino(\n pretty\n ? {\n transport: {\n target: 'pino-pretty',\n options: {\n colorize: true,\n },\n },\n }\n : {},\n );\n if (level) {\n logger.level = level;\n }\n};\n"],"mappings":"AAIA,SAAS,YAAY;AASd,IAAI;AAGX,IAAI,SAA6B;AAG1B,MAAM,MAAM,MAAM;AACvB,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,UAAU,mEAAmE;AAAA,EACzF;AACA,SAAO;AACT;AAGO,MAAM,mBAAmB,CAAC,EAAE,QAAQ,MAAM,MAAqB;AACpE,kBAAgB,EAAE,QAAQ,MAAM;AAChC,WAAS;AAAA,IACP,SACI;AAAA,MACE,WAAW;AAAA,QACT,QAAQ;AAAA,QACR,SAAS;AAAA,UACP,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF,IACA,CAAC;AAAA,EACP;AACA,MAAI,OAAO;AACT,WAAO,QAAQ;AAAA,EACjB;AACF;","names":[]}