@livekit/agents 1.0.39 → 1.0.41

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 (154) hide show
  1. package/dist/cli.cjs +20 -18
  2. package/dist/cli.cjs.map +1 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +20 -18
  5. package/dist/cli.js.map +1 -1
  6. package/dist/http_server.cjs +9 -6
  7. package/dist/http_server.cjs.map +1 -1
  8. package/dist/http_server.d.cts +5 -1
  9. package/dist/http_server.d.ts +5 -1
  10. package/dist/http_server.d.ts.map +1 -1
  11. package/dist/http_server.js +9 -6
  12. package/dist/http_server.js.map +1 -1
  13. package/dist/index.cjs +5 -0
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.d.cts +1 -0
  16. package/dist/index.d.ts +1 -0
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +3 -0
  19. package/dist/index.js.map +1 -1
  20. package/dist/inference/stt.cjs +2 -1
  21. package/dist/inference/stt.cjs.map +1 -1
  22. package/dist/inference/stt.d.ts.map +1 -1
  23. package/dist/inference/stt.js +2 -1
  24. package/dist/inference/stt.js.map +1 -1
  25. package/dist/ipc/supervised_proc.cjs +4 -0
  26. package/dist/ipc/supervised_proc.cjs.map +1 -1
  27. package/dist/ipc/supervised_proc.d.cts +1 -0
  28. package/dist/ipc/supervised_proc.d.ts +1 -0
  29. package/dist/ipc/supervised_proc.d.ts.map +1 -1
  30. package/dist/ipc/supervised_proc.js +4 -0
  31. package/dist/ipc/supervised_proc.js.map +1 -1
  32. package/dist/llm/realtime.cjs.map +1 -1
  33. package/dist/llm/realtime.d.cts +5 -1
  34. package/dist/llm/realtime.d.ts +5 -1
  35. package/dist/llm/realtime.d.ts.map +1 -1
  36. package/dist/llm/realtime.js.map +1 -1
  37. package/dist/tokenize/basic/sentence.cjs +3 -3
  38. package/dist/tokenize/basic/sentence.cjs.map +1 -1
  39. package/dist/tokenize/basic/sentence.js +3 -3
  40. package/dist/tokenize/basic/sentence.js.map +1 -1
  41. package/dist/tokenize/tokenizer.test.cjs +3 -1
  42. package/dist/tokenize/tokenizer.test.cjs.map +1 -1
  43. package/dist/tokenize/tokenizer.test.js +3 -1
  44. package/dist/tokenize/tokenizer.test.js.map +1 -1
  45. package/dist/tts/stream_adapter.cjs +15 -1
  46. package/dist/tts/stream_adapter.cjs.map +1 -1
  47. package/dist/tts/stream_adapter.d.ts.map +1 -1
  48. package/dist/tts/stream_adapter.js +15 -1
  49. package/dist/tts/stream_adapter.js.map +1 -1
  50. package/dist/tts/tts.cjs.map +1 -1
  51. package/dist/tts/tts.d.cts +9 -1
  52. package/dist/tts/tts.d.ts +9 -1
  53. package/dist/tts/tts.d.ts.map +1 -1
  54. package/dist/tts/tts.js.map +1 -1
  55. package/dist/types.cjs +3 -0
  56. package/dist/types.cjs.map +1 -1
  57. package/dist/types.d.cts +4 -0
  58. package/dist/types.d.ts +4 -0
  59. package/dist/types.d.ts.map +1 -1
  60. package/dist/types.js +2 -0
  61. package/dist/types.js.map +1 -1
  62. package/dist/voice/agent.cjs +11 -1
  63. package/dist/voice/agent.cjs.map +1 -1
  64. package/dist/voice/agent.d.cts +7 -3
  65. package/dist/voice/agent.d.ts +7 -3
  66. package/dist/voice/agent.d.ts.map +1 -1
  67. package/dist/voice/agent.js +11 -1
  68. package/dist/voice/agent.js.map +1 -1
  69. package/dist/voice/agent_activity.cjs +30 -14
  70. package/dist/voice/agent_activity.cjs.map +1 -1
  71. package/dist/voice/agent_activity.d.cts +1 -0
  72. package/dist/voice/agent_activity.d.ts +1 -0
  73. package/dist/voice/agent_activity.d.ts.map +1 -1
  74. package/dist/voice/agent_activity.js +30 -14
  75. package/dist/voice/agent_activity.js.map +1 -1
  76. package/dist/voice/agent_session.cjs +5 -1
  77. package/dist/voice/agent_session.cjs.map +1 -1
  78. package/dist/voice/agent_session.d.cts +2 -0
  79. package/dist/voice/agent_session.d.ts +2 -0
  80. package/dist/voice/agent_session.d.ts.map +1 -1
  81. package/dist/voice/agent_session.js +5 -1
  82. package/dist/voice/agent_session.js.map +1 -1
  83. package/dist/voice/background_audio.cjs +2 -1
  84. package/dist/voice/background_audio.cjs.map +1 -1
  85. package/dist/voice/background_audio.d.cts +4 -2
  86. package/dist/voice/background_audio.d.ts +4 -2
  87. package/dist/voice/background_audio.d.ts.map +1 -1
  88. package/dist/voice/background_audio.js +2 -1
  89. package/dist/voice/background_audio.js.map +1 -1
  90. package/dist/voice/generation.cjs +58 -5
  91. package/dist/voice/generation.cjs.map +1 -1
  92. package/dist/voice/generation.d.cts +17 -3
  93. package/dist/voice/generation.d.ts +17 -3
  94. package/dist/voice/generation.d.ts.map +1 -1
  95. package/dist/voice/generation.js +63 -6
  96. package/dist/voice/generation.js.map +1 -1
  97. package/dist/voice/index.cjs.map +1 -1
  98. package/dist/voice/index.d.cts +1 -1
  99. package/dist/voice/index.d.ts +1 -1
  100. package/dist/voice/index.d.ts.map +1 -1
  101. package/dist/voice/index.js.map +1 -1
  102. package/dist/voice/io.cjs +22 -2
  103. package/dist/voice/io.cjs.map +1 -1
  104. package/dist/voice/io.d.cts +21 -5
  105. package/dist/voice/io.d.ts +21 -5
  106. package/dist/voice/io.d.ts.map +1 -1
  107. package/dist/voice/io.js +18 -1
  108. package/dist/voice/io.js.map +1 -1
  109. package/dist/voice/room_io/_output.cjs +3 -2
  110. package/dist/voice/room_io/_output.cjs.map +1 -1
  111. package/dist/voice/room_io/_output.d.cts +3 -3
  112. package/dist/voice/room_io/_output.d.ts +3 -3
  113. package/dist/voice/room_io/_output.d.ts.map +1 -1
  114. package/dist/voice/room_io/_output.js +4 -3
  115. package/dist/voice/room_io/_output.js.map +1 -1
  116. package/dist/voice/transcription/synchronizer.cjs +137 -13
  117. package/dist/voice/transcription/synchronizer.cjs.map +1 -1
  118. package/dist/voice/transcription/synchronizer.d.cts +34 -4
  119. package/dist/voice/transcription/synchronizer.d.ts +34 -4
  120. package/dist/voice/transcription/synchronizer.d.ts.map +1 -1
  121. package/dist/voice/transcription/synchronizer.js +141 -14
  122. package/dist/voice/transcription/synchronizer.js.map +1 -1
  123. package/dist/voice/transcription/synchronizer.test.cjs +151 -0
  124. package/dist/voice/transcription/synchronizer.test.cjs.map +1 -0
  125. package/dist/voice/transcription/synchronizer.test.js +150 -0
  126. package/dist/voice/transcription/synchronizer.test.js.map +1 -0
  127. package/dist/worker.cjs +12 -2
  128. package/dist/worker.cjs.map +1 -1
  129. package/dist/worker.d.ts.map +1 -1
  130. package/dist/worker.js +12 -2
  131. package/dist/worker.js.map +1 -1
  132. package/package.json +1 -1
  133. package/src/cli.ts +20 -18
  134. package/src/http_server.ts +18 -6
  135. package/src/index.ts +1 -0
  136. package/src/inference/stt.ts +9 -8
  137. package/src/ipc/supervised_proc.ts +4 -0
  138. package/src/llm/realtime.ts +5 -1
  139. package/src/tokenize/basic/sentence.ts +3 -3
  140. package/src/tokenize/tokenizer.test.ts +4 -0
  141. package/src/tts/stream_adapter.ts +23 -1
  142. package/src/tts/tts.ts +10 -1
  143. package/src/types.ts +5 -0
  144. package/src/voice/agent.ts +19 -4
  145. package/src/voice/agent_activity.ts +38 -13
  146. package/src/voice/agent_session.ts +6 -0
  147. package/src/voice/background_audio.ts +6 -3
  148. package/src/voice/generation.ts +115 -10
  149. package/src/voice/index.ts +1 -1
  150. package/src/voice/io.ts +40 -5
  151. package/src/voice/room_io/_output.ts +6 -5
  152. package/src/voice/transcription/synchronizer.test.ts +206 -0
  153. package/src/voice/transcription/synchronizer.ts +202 -17
  154. package/src/worker.ts +24 -2
package/dist/cli.cjs CHANGED
@@ -108,13 +108,14 @@ const runApp = (opts) => {
108
108
  });
109
109
  program.command("dev").description("Start the worker in development mode").addOption(
110
110
  new import_commander.Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
111
- ).action(() => {
112
- const options = program.optsWithGlobals();
113
- opts.wsURL = options.url || opts.wsURL;
114
- opts.apiKey = options.apiKey || opts.apiKey;
115
- opts.apiSecret = options.apiSecret || opts.apiSecret;
116
- opts.logLevel = options.logLevel || opts.logLevel;
117
- opts.workerToken = options.workerToken || opts.workerToken;
111
+ ).action((...[, command]) => {
112
+ const globalOptions = program.optsWithGlobals();
113
+ const commandOptions = command.opts();
114
+ opts.wsURL = globalOptions.url || opts.wsURL;
115
+ opts.apiKey = globalOptions.apiKey || opts.apiKey;
116
+ opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;
117
+ opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;
118
+ opts.workerToken = globalOptions.workerToken || opts.workerToken;
118
119
  runServer({
119
120
  opts,
120
121
  production: false,
@@ -124,25 +125,26 @@ const runApp = (opts) => {
124
125
  program.command("connect").description("Connect to a specific room").requiredOption("--room <string>", "Room name to connect to").option("--participant-identity <string>", "Identity of user to listen to").addOption(
125
126
  new import_commander.Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
126
127
  ).action((...[, command]) => {
127
- const options = command.optsWithGlobals();
128
- opts.wsURL = options.url || opts.wsURL;
129
- opts.apiKey = options.apiKey || opts.apiKey;
130
- opts.apiSecret = options.apiSecret || opts.apiSecret;
131
- opts.logLevel = options.logLevel || opts.logLevel;
132
- opts.workerToken = options.workerToken || opts.workerToken;
128
+ const globalOptions = program.optsWithGlobals();
129
+ const commandOptions = command.opts();
130
+ opts.wsURL = globalOptions.url || opts.wsURL;
131
+ opts.apiKey = globalOptions.apiKey || opts.apiKey;
132
+ opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;
133
+ opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;
134
+ opts.workerToken = globalOptions.workerToken || opts.workerToken;
133
135
  runServer({
134
136
  opts,
135
137
  production: false,
136
138
  watch: false,
137
- room: options.room,
138
- participantIdentity: options.participantIdentity
139
+ room: commandOptions.room,
140
+ participantIdentity: commandOptions.participantIdentity
139
141
  });
140
142
  });
141
143
  program.command("download-files").description("Download plugin dependency files").addOption(
142
144
  new import_commander.Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
143
- ).action(() => {
144
- const options = program.optsWithGlobals();
145
- (0, import_log.initializeLogger)({ pretty: true, level: options.logLevel });
145
+ ).action((...[, command]) => {
146
+ const commandOptions = command.opts();
147
+ (0, import_log.initializeLogger)({ pretty: true, level: commandOptions.logLevel });
146
148
  const logger = (0, import_log.log)();
147
149
  const downloadFiles = async () => {
148
150
  for (const plugin of import_plugin.Plugin.registeredPlugins) {
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts","../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.43.7_@types+node@22.15.30__postcss@8.5.6_tsx@4.21.0_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Command, Option } from 'commander';\nimport type { EventEmitter } from 'node:events';\nimport { initializeLogger, log } from './log.js';\nimport { Plugin } from './plugin.js';\nimport { version } from './version.js';\nimport { AgentServer, ServerOptions } from './worker.js';\n\ntype CliArgs = {\n opts: ServerOptions;\n production: boolean;\n watch: boolean;\n event?: EventEmitter;\n room?: string;\n participantIdentity?: string;\n};\n\nconst runServer = async (args: CliArgs) => {\n initializeLogger({ pretty: !args.production, level: args.opts.logLevel });\n const logger = log();\n\n // though `production` is defined in ServerOptions, it will always be overridden by CLI.\n const { production: _, ...opts } = args.opts; // eslint-disable-line @typescript-eslint/no-unused-vars\n const server = new AgentServer(new ServerOptions({ production: args.production, ...opts }));\n\n if (args.room) {\n server.event.once('worker_registered', () => {\n logger.info(`connecting to room ${args.room}`);\n server.simulateJob(args.room!, args.participantIdentity);\n });\n }\n\n process.once('SIGINT', async () => {\n logger.debug('SIGINT received in CLI');\n // allow C-c C-c for force interrupt\n process.once('SIGINT', () => {\n console.log('Force exit (Ctrl+C pressed twice)');\n process.exit(130); // SIGINT exit code\n });\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGINT.');\n process.exit(130); // SIGINT exit code\n });\n\n process.once('SIGTERM', async () => {\n logger.debug('SIGTERM received in CLI.');\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGTERM.');\n process.exit(143); // SIGTERM exit code\n });\n\n try {\n await server.run();\n } catch {\n logger.fatal('closing worker due to error.');\n process.exit(1);\n }\n};\n\n/**\n * Exposes a CLI for creating a new worker, in development or production mode.\n *\n * @param opts - Options to launch the worker with\n * @example\n * ```\n * if (process.argv[1] === fileURLToPath(import.meta.url)) {\n * cli.runApp(new ServerOptions({ agent: import.meta.filename }));\n * }\n * ```\n */\nexport const runApp = (opts: ServerOptions) => {\n const program = new Command()\n .name('agents')\n .description('LiveKit Agents CLI')\n .version(version)\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('info')\n .env('LOG_LEVEL'),\n )\n .addOption(\n new Option('--url <string>', 'LiveKit server or Cloud project websocket URL').env(\n 'LIVEKIT_URL',\n ),\n )\n .addOption(\n new Option('--api-key <string>', \"LiveKit server or Cloud project's API key\").env(\n 'LIVEKIT_API_KEY',\n ),\n )\n .addOption(\n new Option('--api-secret <string>', \"LiveKit server or Cloud project's API secret\").env(\n 'LIVEKIT_API_SECRET',\n ),\n )\n .addOption(\n new Option('--worker-token <string>', 'Internal use only')\n .env('LIVEKIT_WORKER_TOKEN')\n .hideHelp(),\n )\n .action(() => {\n if (\n // do not run CLI if origin file is agents/ipc/job_main.js\n process.argv[1] !== new URL('ipc/job_main.js', import.meta.url).pathname &&\n process.argv.length < 3\n ) {\n program.help();\n }\n });\n\n program\n .command('start')\n .description('Start the worker in production mode')\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: true,\n watch: false,\n });\n });\n\n program\n .command('dev')\n .description('Start the worker in development mode')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n });\n });\n\n program\n .command('connect')\n .description('Connect to a specific room')\n .requiredOption('--room <string>', 'Room name to connect to')\n .option('--participant-identity <string>', 'Identity of user to listen to')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const options = command.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n room: options.room,\n participantIdentity: options.participantIdentity,\n });\n });\n\n program\n .command('download-files')\n .description('Download plugin dependency files')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action(() => {\n const options = program.optsWithGlobals();\n initializeLogger({ pretty: true, level: options.logLevel });\n const logger = log();\n\n const downloadFiles = async () => {\n for (const plugin of Plugin.registeredPlugins) {\n logger.info(`Downloading files for ${plugin.title}`);\n try {\n await plugin.downloadFiles();\n logger.info(`Finished downloading files for ${plugin.title}`);\n } catch (error) {\n logger.error(`Failed to download files for ${plugin.title}: ${error}`);\n }\n }\n };\n\n downloadFiles()\n .catch((error) => {\n logger.fatal(`Error during file downloads: ${error}`);\n process.exit(1);\n })\n .finally(() => {\n process.exit(0);\n });\n });\n\n program.parse();\n};\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;ADR9D,uBAAgC;AAEhC,iBAAsC;AACtC,oBAAuB;AACvB,qBAAwB;AACxB,oBAA2C;AAW3C,MAAM,YAAY,OAAO,SAAkB;AACzC,mCAAiB,EAAE,QAAQ,CAAC,KAAK,YAAY,OAAO,KAAK,KAAK,SAAS,CAAC;AACxE,QAAM,aAAS,gBAAI;AAGnB,QAAM,EAAE,YAAY,GAAG,GAAG,KAAK,IAAI,KAAK;AACxC,QAAM,SAAS,IAAI,0BAAY,IAAI,4BAAc,EAAE,YAAY,KAAK,YAAY,GAAG,KAAK,CAAC,CAAC;AAE1F,MAAI,KAAK,MAAM;AACb,WAAO,MAAM,KAAK,qBAAqB,MAAM;AAC3C,aAAO,KAAK,sBAAsB,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AO;AACd,iBAAO,MAAM,gCAAgC,OAAO,KAAK,KAAK,KAAK,EAAE;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAEA,kBAAc,EACX,MAAM,CAAC,UAAU;AAChB,aAAO,MAAM,gCAAgC,KAAK,EAAE;AACpD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC,EACA,QAAQ,MAAM;AACb,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACL,CAAC;AAEH,UAAQ,MAAM;AAChB;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts","../../node_modules/.pnpm/tsup@8.4.0_@microsoft+api-extractor@7.43.7_@types+node@22.15.30__postcss@8.5.6_tsx@4.21.0_typescript@5.4.5/node_modules/tsup/assets/cjs_shims.js"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Command, Option } from 'commander';\nimport type { EventEmitter } from 'node:events';\nimport { initializeLogger, log } from './log.js';\nimport { Plugin } from './plugin.js';\nimport { version } from './version.js';\nimport { AgentServer, ServerOptions } from './worker.js';\n\ntype CliArgs = {\n opts: ServerOptions;\n production: boolean;\n watch: boolean;\n event?: EventEmitter;\n room?: string;\n participantIdentity?: string;\n};\n\nconst runServer = async (args: CliArgs) => {\n initializeLogger({ pretty: !args.production, level: args.opts.logLevel });\n const logger = log();\n\n // though `production` is defined in ServerOptions, it will always be overridden by CLI.\n const { production: _, ...opts } = args.opts; // eslint-disable-line @typescript-eslint/no-unused-vars\n const server = new AgentServer(new ServerOptions({ production: args.production, ...opts }));\n\n if (args.room) {\n server.event.once('worker_registered', () => {\n logger.info(`connecting to room ${args.room}`);\n server.simulateJob(args.room!, args.participantIdentity);\n });\n }\n\n process.once('SIGINT', async () => {\n logger.debug('SIGINT received in CLI');\n // allow C-c C-c for force interrupt\n process.once('SIGINT', () => {\n console.log('Force exit (Ctrl+C pressed twice)');\n process.exit(130); // SIGINT exit code\n });\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGINT.');\n process.exit(130); // SIGINT exit code\n });\n\n process.once('SIGTERM', async () => {\n logger.debug('SIGTERM received in CLI.');\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGTERM.');\n process.exit(143); // SIGTERM exit code\n });\n\n try {\n await server.run();\n } catch {\n logger.fatal('closing worker due to error.');\n process.exit(1);\n }\n};\n\n/**\n * Exposes a CLI for creating a new worker, in development or production mode.\n *\n * @param opts - Options to launch the worker with\n * @example\n * ```\n * if (process.argv[1] === fileURLToPath(import.meta.url)) {\n * cli.runApp(new ServerOptions({ agent: import.meta.filename }));\n * }\n * ```\n */\nexport const runApp = (opts: ServerOptions) => {\n const program = new Command()\n .name('agents')\n .description('LiveKit Agents CLI')\n .version(version)\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('info')\n .env('LOG_LEVEL'),\n )\n .addOption(\n new Option('--url <string>', 'LiveKit server or Cloud project websocket URL').env(\n 'LIVEKIT_URL',\n ),\n )\n .addOption(\n new Option('--api-key <string>', \"LiveKit server or Cloud project's API key\").env(\n 'LIVEKIT_API_KEY',\n ),\n )\n .addOption(\n new Option('--api-secret <string>', \"LiveKit server or Cloud project's API secret\").env(\n 'LIVEKIT_API_SECRET',\n ),\n )\n .addOption(\n new Option('--worker-token <string>', 'Internal use only')\n .env('LIVEKIT_WORKER_TOKEN')\n .hideHelp(),\n )\n .action(() => {\n if (\n // do not run CLI if origin file is agents/ipc/job_main.js\n process.argv[1] !== new URL('ipc/job_main.js', import.meta.url).pathname &&\n process.argv.length < 3\n ) {\n program.help();\n }\n });\n\n program\n .command('start')\n .description('Start the worker in production mode')\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: true,\n watch: false,\n });\n });\n\n program\n .command('dev')\n .description('Start the worker in development mode')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const globalOptions = program.optsWithGlobals();\n const commandOptions = command.opts();\n opts.wsURL = globalOptions.url || opts.wsURL;\n opts.apiKey = globalOptions.apiKey || opts.apiKey;\n opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;\n opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;\n opts.workerToken = globalOptions.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n });\n });\n\n program\n .command('connect')\n .description('Connect to a specific room')\n .requiredOption('--room <string>', 'Room name to connect to')\n .option('--participant-identity <string>', 'Identity of user to listen to')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const globalOptions = program.optsWithGlobals();\n const commandOptions = command.opts();\n opts.wsURL = globalOptions.url || opts.wsURL;\n opts.apiKey = globalOptions.apiKey || opts.apiKey;\n opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;\n opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;\n opts.workerToken = globalOptions.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n room: commandOptions.room,\n participantIdentity: commandOptions.participantIdentity,\n });\n });\n\n program\n .command('download-files')\n .description('Download plugin dependency files')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const commandOptions = command.opts();\n initializeLogger({ pretty: true, level: commandOptions.logLevel });\n const logger = log();\n\n const downloadFiles = async () => {\n for (const plugin of Plugin.registeredPlugins) {\n logger.info(`Downloading files for ${plugin.title}`);\n try {\n await plugin.downloadFiles();\n logger.info(`Finished downloading files for ${plugin.title}`);\n } catch (error) {\n logger.error(`Failed to download files for ${plugin.title}: ${error}`);\n }\n }\n };\n\n downloadFiles()\n .catch((error) => {\n logger.fatal(`Error during file downloads: ${error}`);\n process.exit(1);\n })\n .finally(() => {\n process.exit(0);\n });\n });\n\n program.parse();\n};\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () =>\n typeof document === 'undefined'\n ? new URL(`file:${__filename}`).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,OAClD,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEpC,IAAM,gBAAgC,iCAAiB;ADR9D,uBAAgC;AAEhC,iBAAsC;AACtC,oBAAuB;AACvB,qBAAwB;AACxB,oBAA2C;AAW3C,MAAM,YAAY,OAAO,SAAkB;AACzC,mCAAiB,EAAE,QAAQ,CAAC,KAAK,YAAY,OAAO,KAAK,KAAK,SAAS,CAAC;AACxE,QAAM,aAAS,gBAAI;AAGnB,QAAM,EAAE,YAAY,GAAG,GAAG,KAAK,IAAI,KAAK;AACxC,QAAM,SAAS,IAAI,0BAAY,IAAI,4BAAc,EAAE,YAAY,KAAK,YAAY,GAAG,KAAK,CAAC,CAAC;AAE1F,MAAI,KAAK,MAAM;AACb,WAAO,MAAM,KAAK,qBAAqB,MAA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AO,mBAAmB;AAC7C,eAAO,KAAK,yBAAyB,OAAO,KAAK,EAAE;AACnD,YAAI;AACF,gBAAM,OAAO,cAAc;AAC3B,iBAAO,KAAK,kCAAkC,OAAO,KAAK,EAAE;AAAA,QAC9D,SAAS,OAAO;AACd,iBAAO,MAAM,gCAAgC,OAAO,KAAK,KAAK,KAAK,EAAE;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAEA,kBAAc,EACX,MAAM,CAAC,UAAU;AAChB,aAAO,MAAM,gCAAgC,KAAK,EAAE;AACpD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC,EACA,QAAQ,MAAM;AACb,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACL,CAAC;AAEH,UAAQ,MAAM;AAChB;","names":[]}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AA2DzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,SAAU,aAAa,SAiJzC,CAAC"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAQA,OAAO,EAAe,aAAa,EAAE,MAAM,aAAa,CAAC;AA2DzD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,MAAM,SAAU,aAAa,SAmJzC,CAAC"}
package/dist/cli.js CHANGED
@@ -83,13 +83,14 @@ const runApp = (opts) => {
83
83
  });
84
84
  program.command("dev").description("Start the worker in development mode").addOption(
85
85
  new Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
86
- ).action(() => {
87
- const options = program.optsWithGlobals();
88
- opts.wsURL = options.url || opts.wsURL;
89
- opts.apiKey = options.apiKey || opts.apiKey;
90
- opts.apiSecret = options.apiSecret || opts.apiSecret;
91
- opts.logLevel = options.logLevel || opts.logLevel;
92
- opts.workerToken = options.workerToken || opts.workerToken;
86
+ ).action((...[, command]) => {
87
+ const globalOptions = program.optsWithGlobals();
88
+ const commandOptions = command.opts();
89
+ opts.wsURL = globalOptions.url || opts.wsURL;
90
+ opts.apiKey = globalOptions.apiKey || opts.apiKey;
91
+ opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;
92
+ opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;
93
+ opts.workerToken = globalOptions.workerToken || opts.workerToken;
93
94
  runServer({
94
95
  opts,
95
96
  production: false,
@@ -99,25 +100,26 @@ const runApp = (opts) => {
99
100
  program.command("connect").description("Connect to a specific room").requiredOption("--room <string>", "Room name to connect to").option("--participant-identity <string>", "Identity of user to listen to").addOption(
100
101
  new Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
101
102
  ).action((...[, command]) => {
102
- const options = command.optsWithGlobals();
103
- opts.wsURL = options.url || opts.wsURL;
104
- opts.apiKey = options.apiKey || opts.apiKey;
105
- opts.apiSecret = options.apiSecret || opts.apiSecret;
106
- opts.logLevel = options.logLevel || opts.logLevel;
107
- opts.workerToken = options.workerToken || opts.workerToken;
103
+ const globalOptions = program.optsWithGlobals();
104
+ const commandOptions = command.opts();
105
+ opts.wsURL = globalOptions.url || opts.wsURL;
106
+ opts.apiKey = globalOptions.apiKey || opts.apiKey;
107
+ opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;
108
+ opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;
109
+ opts.workerToken = globalOptions.workerToken || opts.workerToken;
108
110
  runServer({
109
111
  opts,
110
112
  production: false,
111
113
  watch: false,
112
- room: options.room,
113
- participantIdentity: options.participantIdentity
114
+ room: commandOptions.room,
115
+ participantIdentity: commandOptions.participantIdentity
114
116
  });
115
117
  });
116
118
  program.command("download-files").description("Download plugin dependency files").addOption(
117
119
  new Option("--log-level <level>", "Set the logging level").choices(["trace", "debug", "info", "warn", "error", "fatal"]).default("debug").env("LOG_LEVEL")
118
- ).action(() => {
119
- const options = program.optsWithGlobals();
120
- initializeLogger({ pretty: true, level: options.logLevel });
120
+ ).action((...[, command]) => {
121
+ const commandOptions = command.opts();
122
+ initializeLogger({ pretty: true, level: commandOptions.logLevel });
121
123
  const logger = log();
122
124
  const downloadFiles = async () => {
123
125
  for (const plugin of Plugin.registeredPlugins) {
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Command, Option } from 'commander';\nimport type { EventEmitter } from 'node:events';\nimport { initializeLogger, log } from './log.js';\nimport { Plugin } from './plugin.js';\nimport { version } from './version.js';\nimport { AgentServer, ServerOptions } from './worker.js';\n\ntype CliArgs = {\n opts: ServerOptions;\n production: boolean;\n watch: boolean;\n event?: EventEmitter;\n room?: string;\n participantIdentity?: string;\n};\n\nconst runServer = async (args: CliArgs) => {\n initializeLogger({ pretty: !args.production, level: args.opts.logLevel });\n const logger = log();\n\n // though `production` is defined in ServerOptions, it will always be overridden by CLI.\n const { production: _, ...opts } = args.opts; // eslint-disable-line @typescript-eslint/no-unused-vars\n const server = new AgentServer(new ServerOptions({ production: args.production, ...opts }));\n\n if (args.room) {\n server.event.once('worker_registered', () => {\n logger.info(`connecting to room ${args.room}`);\n server.simulateJob(args.room!, args.participantIdentity);\n });\n }\n\n process.once('SIGINT', async () => {\n logger.debug('SIGINT received in CLI');\n // allow C-c C-c for force interrupt\n process.once('SIGINT', () => {\n console.log('Force exit (Ctrl+C pressed twice)');\n process.exit(130); // SIGINT exit code\n });\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGINT.');\n process.exit(130); // SIGINT exit code\n });\n\n process.once('SIGTERM', async () => {\n logger.debug('SIGTERM received in CLI.');\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGTERM.');\n process.exit(143); // SIGTERM exit code\n });\n\n try {\n await server.run();\n } catch {\n logger.fatal('closing worker due to error.');\n process.exit(1);\n }\n};\n\n/**\n * Exposes a CLI for creating a new worker, in development or production mode.\n *\n * @param opts - Options to launch the worker with\n * @example\n * ```\n * if (process.argv[1] === fileURLToPath(import.meta.url)) {\n * cli.runApp(new ServerOptions({ agent: import.meta.filename }));\n * }\n * ```\n */\nexport const runApp = (opts: ServerOptions) => {\n const program = new Command()\n .name('agents')\n .description('LiveKit Agents CLI')\n .version(version)\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('info')\n .env('LOG_LEVEL'),\n )\n .addOption(\n new Option('--url <string>', 'LiveKit server or Cloud project websocket URL').env(\n 'LIVEKIT_URL',\n ),\n )\n .addOption(\n new Option('--api-key <string>', \"LiveKit server or Cloud project's API key\").env(\n 'LIVEKIT_API_KEY',\n ),\n )\n .addOption(\n new Option('--api-secret <string>', \"LiveKit server or Cloud project's API secret\").env(\n 'LIVEKIT_API_SECRET',\n ),\n )\n .addOption(\n new Option('--worker-token <string>', 'Internal use only')\n .env('LIVEKIT_WORKER_TOKEN')\n .hideHelp(),\n )\n .action(() => {\n if (\n // do not run CLI if origin file is agents/ipc/job_main.js\n process.argv[1] !== new URL('ipc/job_main.js', import.meta.url).pathname &&\n process.argv.length < 3\n ) {\n program.help();\n }\n });\n\n program\n .command('start')\n .description('Start the worker in production mode')\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: true,\n watch: false,\n });\n });\n\n program\n .command('dev')\n .description('Start the worker in development mode')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n });\n });\n\n program\n .command('connect')\n .description('Connect to a specific room')\n .requiredOption('--room <string>', 'Room name to connect to')\n .option('--participant-identity <string>', 'Identity of user to listen to')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const options = command.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n room: options.room,\n participantIdentity: options.participantIdentity,\n });\n });\n\n program\n .command('download-files')\n .description('Download plugin dependency files')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action(() => {\n const options = program.optsWithGlobals();\n initializeLogger({ pretty: true, level: options.logLevel });\n const logger = log();\n\n const downloadFiles = async () => {\n for (const plugin of Plugin.registeredPlugins) {\n logger.info(`Downloading files for ${plugin.title}`);\n try {\n await plugin.downloadFiles();\n logger.info(`Finished downloading files for ${plugin.title}`);\n } catch (error) {\n logger.error(`Failed to download files for ${plugin.title}: ${error}`);\n }\n }\n };\n\n downloadFiles()\n .catch((error) => {\n logger.fatal(`Error during file downloads: ${error}`);\n process.exit(1);\n })\n .fin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xB,YAAY,kCAAkC,EAC9C;AAAA,IACC,IAAI,OAAO,uBAAuB,uBAAuB,EACtD,QAAQ,CAAC,SAAS,SAAS,QAAQ,QAAQ,SAAS,OAAO,CAAC,EAC5D,QAAQ,OAAO,EACf,IAAI,WAAW;AAAA,EACpB,EACC,OAAO,MAAM;AACZ,UAAM,UAAU,QAAQ,gBAAgB;AACxC,qBAAiB,EAAE,QAAQ,MAAM,OAAO,QAAQ,SAAS,CAAC;AAC1D,UAAM,SAAS,IAAI;AAEnB,UAAM,gBAAgB,YAAY;AAChC,iBAAW,UAAU,OAAO,mBAAmB;AAC7C,eAAO,KAAK,yBAAyB,OAAO,KAAK,EAAE;AACnD,YAAI;AACF,gBAAM,OAAO,cAAc;AAC3B,iBAAO,KAAK,kCAAkC,OAAO,KAAK,EAAE;AAAA,QAC9D,SAAS,OAAO;AACd,iBAAO,MAAM,gCAAgC,OAAO,KAAK,KAAK,KAAK,EAAE;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAEA,kBAAc,EACX,MAAM,CAAC,UAAU;AAChB,aAAO,MAAM,gCAAgC,KAAK,EAAE;AACpD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC,EACA,QAAQ,MAAM;AACb,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACL,CAAC;AAEH,UAAQ,MAAM;AAChB;","names":[]}
1
+ {"version":3,"sources":["../src/cli.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { Command, Option } from 'commander';\nimport type { EventEmitter } from 'node:events';\nimport { initializeLogger, log } from './log.js';\nimport { Plugin } from './plugin.js';\nimport { version } from './version.js';\nimport { AgentServer, ServerOptions } from './worker.js';\n\ntype CliArgs = {\n opts: ServerOptions;\n production: boolean;\n watch: boolean;\n event?: EventEmitter;\n room?: string;\n participantIdentity?: string;\n};\n\nconst runServer = async (args: CliArgs) => {\n initializeLogger({ pretty: !args.production, level: args.opts.logLevel });\n const logger = log();\n\n // though `production` is defined in ServerOptions, it will always be overridden by CLI.\n const { production: _, ...opts } = args.opts; // eslint-disable-line @typescript-eslint/no-unused-vars\n const server = new AgentServer(new ServerOptions({ production: args.production, ...opts }));\n\n if (args.room) {\n server.event.once('worker_registered', () => {\n logger.info(`connecting to room ${args.room}`);\n server.simulateJob(args.room!, args.participantIdentity);\n });\n }\n\n process.once('SIGINT', async () => {\n logger.debug('SIGINT received in CLI');\n // allow C-c C-c for force interrupt\n process.once('SIGINT', () => {\n console.log('Force exit (Ctrl+C pressed twice)');\n process.exit(130); // SIGINT exit code\n });\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGINT.');\n process.exit(130); // SIGINT exit code\n });\n\n process.once('SIGTERM', async () => {\n logger.debug('SIGTERM received in CLI.');\n if (args.production) {\n await server.drain();\n }\n await server.close();\n logger.debug('worker closed due to SIGTERM.');\n process.exit(143); // SIGTERM exit code\n });\n\n try {\n await server.run();\n } catch {\n logger.fatal('closing worker due to error.');\n process.exit(1);\n }\n};\n\n/**\n * Exposes a CLI for creating a new worker, in development or production mode.\n *\n * @param opts - Options to launch the worker with\n * @example\n * ```\n * if (process.argv[1] === fileURLToPath(import.meta.url)) {\n * cli.runApp(new ServerOptions({ agent: import.meta.filename }));\n * }\n * ```\n */\nexport const runApp = (opts: ServerOptions) => {\n const program = new Command()\n .name('agents')\n .description('LiveKit Agents CLI')\n .version(version)\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('info')\n .env('LOG_LEVEL'),\n )\n .addOption(\n new Option('--url <string>', 'LiveKit server or Cloud project websocket URL').env(\n 'LIVEKIT_URL',\n ),\n )\n .addOption(\n new Option('--api-key <string>', \"LiveKit server or Cloud project's API key\").env(\n 'LIVEKIT_API_KEY',\n ),\n )\n .addOption(\n new Option('--api-secret <string>', \"LiveKit server or Cloud project's API secret\").env(\n 'LIVEKIT_API_SECRET',\n ),\n )\n .addOption(\n new Option('--worker-token <string>', 'Internal use only')\n .env('LIVEKIT_WORKER_TOKEN')\n .hideHelp(),\n )\n .action(() => {\n if (\n // do not run CLI if origin file is agents/ipc/job_main.js\n process.argv[1] !== new URL('ipc/job_main.js', import.meta.url).pathname &&\n process.argv.length < 3\n ) {\n program.help();\n }\n });\n\n program\n .command('start')\n .description('Start the worker in production mode')\n .action(() => {\n const options = program.optsWithGlobals();\n opts.wsURL = options.url || opts.wsURL;\n opts.apiKey = options.apiKey || opts.apiKey;\n opts.apiSecret = options.apiSecret || opts.apiSecret;\n opts.logLevel = options.logLevel || opts.logLevel;\n opts.workerToken = options.workerToken || opts.workerToken;\n runServer({\n opts,\n production: true,\n watch: false,\n });\n });\n\n program\n .command('dev')\n .description('Start the worker in development mode')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const globalOptions = program.optsWithGlobals();\n const commandOptions = command.opts();\n opts.wsURL = globalOptions.url || opts.wsURL;\n opts.apiKey = globalOptions.apiKey || opts.apiKey;\n opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;\n opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;\n opts.workerToken = globalOptions.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n });\n });\n\n program\n .command('connect')\n .description('Connect to a specific room')\n .requiredOption('--room <string>', 'Room name to connect to')\n .option('--participant-identity <string>', 'Identity of user to listen to')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const globalOptions = program.optsWithGlobals();\n const commandOptions = command.opts();\n opts.wsURL = globalOptions.url || opts.wsURL;\n opts.apiKey = globalOptions.apiKey || opts.apiKey;\n opts.apiSecret = globalOptions.apiSecret || opts.apiSecret;\n opts.logLevel = commandOptions.logLevel || globalOptions.logLevel || opts.logLevel;\n opts.workerToken = globalOptions.workerToken || opts.workerToken;\n runServer({\n opts,\n production: false,\n watch: false,\n room: commandOptions.room,\n participantIdentity: commandOptions.participantIdentity,\n });\n });\n\n program\n .command('download-files')\n .description('Download plugin dependency files')\n .addOption(\n new Option('--log-level <level>', 'Set the logging level')\n .choices(['trace', 'debug', 'info', 'warn', 'error', 'fatal'])\n .default('debug')\n .env('LOG_LEVEL'),\n )\n .action((...[, command]) => {\n const commandOptions = command.opts();\n initializeLogger({ pretty: true, level: commandOptions.logLevel });\n const logger = log();\n\n const downloadFiles = async () => {\n for (const plugin of Plugin.registeredPlugins) {\n logger.info(`Downloading files for ${plugin.title}`);\n try {\n await plugin.downloadFiles();\n logger.info(`Finished downloading files for ${plugin.title}`);\n } catch (error) {\n logger.error(`Failed to download files for ${plugin.title}: ${error}`);\n }\n }\n };\n\n downloadFiles()\n .catch((error) => {\n logger.fatal(`Error during file downloads: ${error}`);\n process.exit(1);\n })\n .finally(() => {\n process.exit(0);\n });\n });\n\n program.parse();\n};\n"],"mappings":"AAGA,SAAS,SAAS,cAAc;AAEhC,SAAS,kBAAkB,WAAW;AACtC,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,aAAa,qBAAqB;AAW3C,MAAM,YAAY,OAAO,SAAkB;AACzC,mBAAiB,EAAE,QAAQ,CAAC,KAAK,YAAY,OAAO,KAAK,KAAK,SAAS,CAAC;AACxE,QAAM,SAAS,IAAI;AAGnB,QAAM,EAAE,YAAY,GAAG,GAAG,KAAK,IAAI,KAAK;AACxC,QAAM,SAAS,IAAI,YAAY,IAAI,cAAc,EAAE,YAAY,KAAK,YAAY,GAAG,KAAK,CAAC,CAAC;AAE1F,MAAI,KAAK,MAAM;AACb,WAAO,MAAM,KAAK,qBAAqB,MAAM;AAC3C,aAAO,KAAK,sBAAsB,KAAK,IAAI,EAAE;AAC7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D,YAAI;AACF,gBAAM,OAAO,cAAc;AAC3B,iBAAO,KAAK,kCAAkC,OAAO,KAAK,EAAE;AAAA,QAC9D,SAAS,OAAO;AACd,iBAAO,MAAM,gCAAgC,OAAO,KAAK,KAAK,KAAK,EAAE;AAAA,QACvE;AAAA,MACF;AAAA,IACF;AAEA,kBAAc,EACX,MAAM,CAAC,UAAU;AAChB,aAAO,MAAM,gCAAgC,KAAK,EAAE;AACpD,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC,EACA,QAAQ,MAAM;AACb,cAAQ,KAAK,CAAC;AAAA,IAChB,CAAC;AAAA,EACL,CAAC;AAEH,UAAQ,MAAM;AAChB;","names":[]}
@@ -23,21 +23,24 @@ __export(http_server_exports, {
23
23
  module.exports = __toCommonJS(http_server_exports);
24
24
  var import_node_http = require("node:http");
25
25
  var import_log = require("./log.cjs");
26
- const healthCheck = async (res) => {
27
- res.writeHead(200);
28
- res.end("OK");
29
- };
30
26
  class HTTPServer {
31
27
  host;
32
28
  port;
33
29
  app;
34
30
  #logger = (0, import_log.log)();
35
- constructor(host, port, workerListener) {
31
+ constructor(host, port, healthCheckListener, workerListener) {
36
32
  this.host = host;
37
33
  this.port = port;
38
34
  this.app = (0, import_node_http.createServer)((req, res) => {
39
35
  if (req.url === "/") {
40
- healthCheck(res);
36
+ const result = healthCheckListener();
37
+ if (result.healthy) {
38
+ res.writeHead(200);
39
+ res.end(result.message);
40
+ } else {
41
+ res.writeHead(503);
42
+ res.end(result.message);
43
+ }
41
44
  } else if (req.url === "/worker") {
42
45
  res.writeHead(200, { "Content-Type": "application/json" });
43
46
  res.end(JSON.stringify(workerListener()));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/http_server.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type IncomingMessage, type Server, type ServerResponse, createServer } from 'node:http';\nimport { log } from './log.js';\n\nconst healthCheck = async (res: ServerResponse) => {\n res.writeHead(200);\n res.end('OK');\n};\n\ninterface WorkerResponse {\n agent_name: string;\n worker_type: string;\n active_jobs: number;\n sdk_version: string;\n project_type: string;\n}\n\nexport class HTTPServer {\n host: string;\n port: number;\n app: Server;\n #logger = log();\n\n constructor(host: string, port: number, workerListener: () => WorkerResponse) {\n this.host = host;\n this.port = port;\n\n this.app = createServer((req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/') {\n healthCheck(res);\n } else if (req.url === '/worker') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(workerListener()));\n } else {\n res.writeHead(404);\n res.end('not found');\n }\n });\n }\n\n async run(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.listen(this.port, this.host, (err?: Error) => {\n if (err) reject(err);\n const address = this.app.address();\n if (typeof address! !== 'string') {\n this.#logger.info(`Server is listening on port ${address!.port}`);\n }\n resolve();\n });\n });\n }\n\n async close(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.close((err?: Error) => {\n if (err) reject(err);\n resolve();\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqF;AACrF,iBAAoB;AAEpB,MAAM,cAAc,OAAO,QAAwB;AACjD,MAAI,UAAU,GAAG;AACjB,MAAI,IAAI,IAAI;AACd;AAUO,MAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAU,gBAAI;AAAA,EAEd,YAAY,MAAc,MAAc,gBAAsC;AAC5E,SAAK,OAAO;AACZ,SAAK,OAAO;AAEZ,SAAK,UAAM,+BAAa,CAAC,KAAsB,QAAwB;AACrE,UAAI,IAAI,QAAQ,KAAK;AACnB,oBAAY,GAAG;AAAA,MACjB,WAAW,IAAI,QAAQ,WAAW;AAChC,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,eAAe,CAAC,CAAC;AAAA,MAC1C,OAAO;AACL,YAAI,UAAU,GAAG;AACjB,YAAI,IAAI,WAAW;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAqB;AACzB,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,OAAO,KAAK,MAAM,KAAK,MAAM,CAAC,QAAgB;AACrD,YAAI,IAAK,QAAO,GAAG;AACnB,cAAM,UAAU,KAAK,IAAI,QAAQ;AACjC,YAAI,OAAO,YAAa,UAAU;AAChC,eAAK,QAAQ,KAAK,+BAA+B,QAAS,IAAI,EAAE;AAAA,QAClE;AACA,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,QAAuB;AAC3B,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,MAAM,CAAC,QAAgB;AAC9B,YAAI,IAAK,QAAO,GAAG;AACnB,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/http_server.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type IncomingMessage, type Server, type ServerResponse, createServer } from 'node:http';\nimport { log } from './log.js';\n\nexport interface HealthCheckResult {\n healthy: boolean;\n message: string;\n}\n\ninterface WorkerResponse {\n agent_name: string;\n worker_type: string;\n active_jobs: number;\n sdk_version: string;\n project_type: string;\n}\n\nexport class HTTPServer {\n host: string;\n port: number;\n app: Server;\n #logger = log();\n\n constructor(\n host: string,\n port: number,\n healthCheckListener: () => HealthCheckResult,\n workerListener: () => WorkerResponse,\n ) {\n this.host = host;\n this.port = port;\n\n this.app = createServer((req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/') {\n const result = healthCheckListener();\n if (result.healthy) {\n res.writeHead(200);\n res.end(result.message);\n } else {\n res.writeHead(503);\n res.end(result.message);\n }\n } else if (req.url === '/worker') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(workerListener()));\n } else {\n res.writeHead(404);\n res.end('not found');\n }\n });\n }\n\n async run(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.listen(this.port, this.host, (err?: Error) => {\n if (err) reject(err);\n const address = this.app.address();\n if (typeof address! !== 'string') {\n this.#logger.info(`Server is listening on port ${address!.port}`);\n }\n resolve();\n });\n });\n }\n\n async close(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.close((err?: Error) => {\n if (err) reject(err);\n resolve();\n });\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,uBAAqF;AACrF,iBAAoB;AAeb,MAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,cAAU,gBAAI;AAAA,EAEd,YACE,MACA,MACA,qBACA,gBACA;AACA,SAAK,OAAO;AACZ,SAAK,OAAO;AAEZ,SAAK,UAAM,+BAAa,CAAC,KAAsB,QAAwB;AACrE,UAAI,IAAI,QAAQ,KAAK;AACnB,cAAM,SAAS,oBAAoB;AACnC,YAAI,OAAO,SAAS;AAClB,cAAI,UAAU,GAAG;AACjB,cAAI,IAAI,OAAO,OAAO;AAAA,QACxB,OAAO;AACL,cAAI,UAAU,GAAG;AACjB,cAAI,IAAI,OAAO,OAAO;AAAA,QACxB;AAAA,MACF,WAAW,IAAI,QAAQ,WAAW;AAChC,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,eAAe,CAAC,CAAC;AAAA,MAC1C,OAAO;AACL,YAAI,UAAU,GAAG;AACjB,YAAI,IAAI,WAAW;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAqB;AACzB,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,OAAO,KAAK,MAAM,KAAK,MAAM,CAAC,QAAgB;AACrD,YAAI,IAAK,QAAO,GAAG;AACnB,cAAM,UAAU,KAAK,IAAI,QAAQ;AACjC,YAAI,OAAO,YAAa,UAAU;AAChC,eAAK,QAAQ,KAAK,+BAA+B,QAAS,IAAI,EAAE;AAAA,QAClE;AACA,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,QAAuB;AAC3B,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,MAAM,CAAC,QAAgB;AAC9B,YAAI,IAAK,QAAO,GAAG;AACnB,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1,5 +1,9 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { type Server } from 'node:http';
3
+ export interface HealthCheckResult {
4
+ healthy: boolean;
5
+ message: string;
6
+ }
3
7
  interface WorkerResponse {
4
8
  agent_name: string;
5
9
  worker_type: string;
@@ -12,7 +16,7 @@ export declare class HTTPServer {
12
16
  host: string;
13
17
  port: number;
14
18
  app: Server;
15
- constructor(host: string, port: number, workerListener: () => WorkerResponse);
19
+ constructor(host: string, port: number, healthCheckListener: () => HealthCheckResult, workerListener: () => WorkerResponse);
16
20
  run(): Promise<void>;
17
21
  close(): Promise<void>;
18
22
  }
@@ -1,5 +1,9 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { type Server } from 'node:http';
3
+ export interface HealthCheckResult {
4
+ healthy: boolean;
5
+ message: string;
6
+ }
3
7
  interface WorkerResponse {
4
8
  agent_name: string;
5
9
  worker_type: string;
@@ -12,7 +16,7 @@ export declare class HTTPServer {
12
16
  host: string;
13
17
  port: number;
14
18
  app: Server;
15
- constructor(host: string, port: number, workerListener: () => WorkerResponse);
19
+ constructor(host: string, port: number, healthCheckListener: () => HealthCheckResult, workerListener: () => WorkerResponse);
16
20
  run(): Promise<void>;
17
21
  close(): Promise<void>;
18
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http_server.d.ts","sourceRoot":"","sources":["../src/http_server.ts"],"names":[],"mappings":";AAGA,OAAO,EAAwB,KAAK,MAAM,EAAqC,MAAM,WAAW,CAAC;AAQjG,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,UAAU;;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;gBAGA,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,cAAc;IAiBtE,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAapB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B"}
1
+ {"version":3,"file":"http_server.d.ts","sourceRoot":"","sources":["../src/http_server.ts"],"names":[],"mappings":";AAGA,OAAO,EAAwB,KAAK,MAAM,EAAqC,MAAM,WAAW,CAAC;AAGjG,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,cAAc;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,UAAU;;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;gBAIV,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,mBAAmB,EAAE,MAAM,iBAAiB,EAC5C,cAAc,EAAE,MAAM,cAAc;IAyBhC,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IAapB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ7B"}
@@ -1,20 +1,23 @@
1
1
  import { createServer } from "node:http";
2
2
  import { log } from "./log.js";
3
- const healthCheck = async (res) => {
4
- res.writeHead(200);
5
- res.end("OK");
6
- };
7
3
  class HTTPServer {
8
4
  host;
9
5
  port;
10
6
  app;
11
7
  #logger = log();
12
- constructor(host, port, workerListener) {
8
+ constructor(host, port, healthCheckListener, workerListener) {
13
9
  this.host = host;
14
10
  this.port = port;
15
11
  this.app = createServer((req, res) => {
16
12
  if (req.url === "/") {
17
- healthCheck(res);
13
+ const result = healthCheckListener();
14
+ if (result.healthy) {
15
+ res.writeHead(200);
16
+ res.end(result.message);
17
+ } else {
18
+ res.writeHead(503);
19
+ res.end(result.message);
20
+ }
18
21
  } else if (req.url === "/worker") {
19
22
  res.writeHead(200, { "Content-Type": "application/json" });
20
23
  res.end(JSON.stringify(workerListener()));
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/http_server.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type IncomingMessage, type Server, type ServerResponse, createServer } from 'node:http';\nimport { log } from './log.js';\n\nconst healthCheck = async (res: ServerResponse) => {\n res.writeHead(200);\n res.end('OK');\n};\n\ninterface WorkerResponse {\n agent_name: string;\n worker_type: string;\n active_jobs: number;\n sdk_version: string;\n project_type: string;\n}\n\nexport class HTTPServer {\n host: string;\n port: number;\n app: Server;\n #logger = log();\n\n constructor(host: string, port: number, workerListener: () => WorkerResponse) {\n this.host = host;\n this.port = port;\n\n this.app = createServer((req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/') {\n healthCheck(res);\n } else if (req.url === '/worker') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(workerListener()));\n } else {\n res.writeHead(404);\n res.end('not found');\n }\n });\n }\n\n async run(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.listen(this.port, this.host, (err?: Error) => {\n if (err) reject(err);\n const address = this.app.address();\n if (typeof address! !== 'string') {\n this.#logger.info(`Server is listening on port ${address!.port}`);\n }\n resolve();\n });\n });\n }\n\n async close(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.close((err?: Error) => {\n if (err) reject(err);\n resolve();\n });\n });\n }\n}\n"],"mappings":"AAGA,SAAiE,oBAAoB;AACrF,SAAS,WAAW;AAEpB,MAAM,cAAc,OAAO,QAAwB;AACjD,MAAI,UAAU,GAAG;AACjB,MAAI,IAAI,IAAI;AACd;AAUO,MAAM,WAAW;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,IAAI;AAAA,EAEd,YAAY,MAAc,MAAc,gBAAsC;AAC5E,SAAK,OAAO;AACZ,SAAK,OAAO;AAEZ,SAAK,MAAM,aAAa,CAAC,KAAsB,QAAwB;AACrE,UAAI,IAAI,QAAQ,KAAK;AACnB,oBAAY,GAAG;AAAA,MACjB,WAAW,IAAI,QAAQ,WAAW;AAChC,YAAI,UAAU,KAAK,EAAE,gBAAgB,mBAAmB,CAAC;AACzD,YAAI,IAAI,KAAK,UAAU,eAAe,CAAC,CAAC;AAAA,MAC1C,OAAO;AACL,YAAI,UAAU,GAAG;AACjB,YAAI,IAAI,WAAW;AAAA,MACrB;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,MAAqB;AACzB,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,OAAO,KAAK,MAAM,KAAK,MAAM,CAAC,QAAgB;AACrD,YAAI,IAAK,QAAO,GAAG;AACnB,cAAM,UAAU,KAAK,IAAI,QAAQ;AACjC,YAAI,OAAO,YAAa,UAAU;AAChC,eAAK,QAAQ,KAAK,+BAA+B,QAAS,IAAI,EAAE;AAAA,QAClE;AACA,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEA,MAAM,QAAuB;AAC3B,WAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,WAAK,IAAI,MAAM,CAAC,QAAgB;AAC9B,YAAI,IAAK,QAAO,GAAG;AACnB,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/http_server.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type IncomingMessage, type Server, type ServerResponse, createServer } from 'node:http';\nimport { log } from './log.js';\n\nexport interface HealthCheckResult {\n healthy: boolean;\n message: string;\n}\n\ninterface WorkerResponse {\n agent_name: string;\n worker_type: string;\n active_jobs: number;\n sdk_version: string;\n project_type: string;\n}\n\nexport class HTTPServer {\n host: string;\n port: number;\n app: Server;\n #logger = log();\n\n constructor(\n host: string,\n port: number,\n healthCheckListener: () => HealthCheckResult,\n workerListener: () => WorkerResponse,\n ) {\n this.host = host;\n this.port = port;\n\n this.app = createServer((req: IncomingMessage, res: ServerResponse) => {\n if (req.url === '/') {\n const result = healthCheckListener();\n if (result.healthy) {\n res.writeHead(200);\n res.end(result.message);\n } else {\n res.writeHead(503);\n res.end(result.message);\n }\n } else if (req.url === '/worker') {\n res.writeHead(200, { 'Content-Type': 'application/json' });\n res.end(JSON.stringify(workerListener()));\n } else {\n res.writeHead(404);\n res.end('not found');\n }\n });\n }\n\n async run(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.listen(this.port, this.host, (err?: Error) => {\n if (err) reject(err);\n const address = this.app.address();\n if (typeof address! !== 'string') {\n this.#logger.info(`Server is listening on port ${address!.port}`);\n }\n resolve();\n });\n });\n }\n\n async close(): Promise<void> {\n return new Promise((resolve, reject) => {\n this.app.close((err?: Error) => {\n if (err) reject(err);\n resolve();\n });\n });\n }\n}\n"],"mappings":"AAGA,SAAiE,oBAAoB;AACrF,SAAS,WAAW;AAeb,MAAM,WAAW;AAAA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__toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
32
  cli: () => cli,
33
+ createTimedString: () => import_io.createTimedString,
33
34
  inference: () => inference,
34
35
  ipc: () => ipc,
36
+ isTimedString: () => import_io.isTimedString,
35
37
  llm: () => llm,
36
38
  metrics: () => metrics,
37
39
  stream: () => stream,
@@ -66,12 +68,15 @@ __reExport(index_exports, require("./types.cjs"), module.exports);
66
68
  __reExport(index_exports, require("./utils.cjs"), module.exports);
67
69
  __reExport(index_exports, require("./vad.cjs"), module.exports);
68
70
  __reExport(index_exports, require("./version.cjs"), module.exports);
71
+ var import_io = require("./voice/io.cjs");
69
72
  __reExport(index_exports, require("./worker.cjs"), module.exports);
70
73
  // Annotate the CommonJS export names for ESM import in node:
71
74
  0 && (module.exports = {
72
75
  cli,
76
+ createTimedString,
73
77
  inference,
74
78
  ipc,
79
+ isTimedString,
75
80
  llm,
76
81
  metrics,
77
82
  stream,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LiveKit Agents is a framework for building realtime programmable participants that run on\n * servers.\n *\n * @see {@link https://docs.livekit.io/agents/overview | LiveKit Agents documentation}\n * @packageDocumentation\n */\nimport * as cli from './cli.js';\nimport * as inference from './inference/index.js';\nimport * as ipc from './ipc/index.js';\nimport * as llm from './llm/index.js';\nimport * as metrics from './metrics/index.js';\nimport * as stream from './stream/index.js';\nimport * as stt from './stt/index.js';\nimport * as telemetry from './telemetry/index.js';\nimport * as tokenize from './tokenize/index.js';\nimport * as tts from './tts/index.js';\nimport * as voice from './voice/index.js';\n\nexport * from './_exceptions.js';\nexport * from './audio.js';\nexport * from './connection_pool.js';\nexport * from './generator.js';\nexport * from './inference_runner.js';\nexport * from './job.js';\nexport * from './log.js';\nexport * from './plugin.js';\nexport * from './transcription.js';\nexport * from './types.js';\nexport * from './utils.js';\nexport * from './vad.js';\nexport * from './version.js';\nexport * from './worker.js';\n\nexport { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,UAAqB;AACrB,gBAA2B;AAC3B,UAAqB;AACrB,UAAqB;AACrB,cAAyB;AACzB,aAAwB;AACxB,UAAqB;AACrB,gBAA2B;AAC3B,eAA0B;AAC1B,UAAqB;AACrB,YAAuB;AAEvB,0BAAc,6BAvBd;AAwBA,0BAAc,uBAxBd;AAyBA,0BAAc,iCAzBd;AA0BA,0BAAc,2BA1Bd;AA2BA,0BAAc,kCA3Bd;AA4BA,0BAAc,qBA5Bd;AA6BA,0BAAc,qBA7Bd;AA8BA,0BAAc,wBA9Bd;AA+BA,0BAAc,+BA/Bd;AAgCA,0BAAc,uBAhCd;AAiCA,0BAAc,uBAjCd;AAkCA,0BAAc,qBAlCd;AAmCA,0BAAc,yBAnCd;AAoCA,0BAAc,wBApCd;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LiveKit Agents is a framework for building realtime programmable participants that run on\n * servers.\n *\n * @see {@link https://docs.livekit.io/agents/overview | LiveKit Agents documentation}\n * @packageDocumentation\n */\nimport * as cli from './cli.js';\nimport * as inference from './inference/index.js';\nimport * as ipc from './ipc/index.js';\nimport * as llm from './llm/index.js';\nimport * as metrics from './metrics/index.js';\nimport * as stream from './stream/index.js';\nimport * as stt from './stt/index.js';\nimport * as telemetry from './telemetry/index.js';\nimport * as tokenize from './tokenize/index.js';\nimport * as tts from './tts/index.js';\nimport * as voice from './voice/index.js';\n\nexport * from './_exceptions.js';\nexport * from './audio.js';\nexport * from './connection_pool.js';\nexport * from './generator.js';\nexport * from './inference_runner.js';\nexport * from './job.js';\nexport * from './log.js';\nexport * from './plugin.js';\nexport * from './transcription.js';\nexport * from './types.js';\nexport * from './utils.js';\nexport * from './vad.js';\nexport * from './version.js';\nexport { createTimedString, isTimedString, type TimedString } from './voice/io.js';\nexport * from './worker.js';\n\nexport { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,UAAqB;AACrB,gBAA2B;AAC3B,UAAqB;AACrB,UAAqB;AACrB,cAAyB;AACzB,aAAwB;AACxB,UAAqB;AACrB,gBAA2B;AAC3B,eAA0B;AAC1B,UAAqB;AACrB,YAAuB;AAEvB,0BAAc,6BAvBd;AAwBA,0BAAc,uBAxBd;AAyBA,0BAAc,iCAzBd;AA0BA,0BAAc,2BA1Bd;AA2BA,0BAAc,kCA3Bd;AA4BA,0BAAc,qBA5Bd;AA6BA,0BAAc,qBA7Bd;AA8BA,0BAAc,wBA9Bd;AA+BA,0BAAc,+BA/Bd;AAgCA,0BAAc,uBAhCd;AAiCA,0BAAc,uBAjCd;AAkCA,0BAAc,qBAlCd;AAmCA,0BAAc,yBAnCd;AAoCA,gBAAmE;AACnE,0BAAc,wBArCd;","names":[]}
package/dist/index.d.cts CHANGED
@@ -29,6 +29,7 @@ export * from './types.js';
29
29
  export * from './utils.js';
30
30
  export * from './vad.js';
31
31
  export * from './version.js';
32
+ export { createTimedString, isTimedString, type TimedString } from './voice/io.js';
32
33
  export * from './worker.js';
33
34
  export { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };
34
35
  //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -29,6 +29,7 @@ export * from './types.js';
29
29
  export * from './utils.js';
30
30
  export * from './vad.js';
31
31
  export * from './version.js';
32
+ export { createTimedString, isTimedString, type TimedString } from './voice/io.js';
32
33
  export * from './worker.js';
33
34
  export { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };
34
35
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAA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package/dist/index.js CHANGED
@@ -22,11 +22,14 @@ export * from "./types.js";
22
22
  export * from "./utils.js";
23
23
  export * from "./vad.js";
24
24
  export * from "./version.js";
25
+ import { createTimedString, isTimedString } from "./voice/io.js";
25
26
  export * from "./worker.js";
26
27
  export {
27
28
  cli,
29
+ createTimedString,
28
30
  inference,
29
31
  ipc,
32
+ isTimedString,
30
33
  llm,
31
34
  metrics,
32
35
  stream,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LiveKit Agents is a framework for building realtime programmable participants that run on\n * servers.\n *\n * @see {@link https://docs.livekit.io/agents/overview | LiveKit Agents documentation}\n * @packageDocumentation\n */\nimport * as cli from './cli.js';\nimport * as inference from './inference/index.js';\nimport * as ipc from './ipc/index.js';\nimport * as llm from './llm/index.js';\nimport * as metrics from './metrics/index.js';\nimport * as stream from './stream/index.js';\nimport * as stt from './stt/index.js';\nimport * as telemetry from './telemetry/index.js';\nimport * as tokenize from './tokenize/index.js';\nimport * as tts from './tts/index.js';\nimport * as voice from './voice/index.js';\n\nexport * from './_exceptions.js';\nexport * from './audio.js';\nexport * from './connection_pool.js';\nexport * from './generator.js';\nexport * from './inference_runner.js';\nexport * from './job.js';\nexport * from './log.js';\nexport * from './plugin.js';\nexport * from './transcription.js';\nexport * from './types.js';\nexport * from './utils.js';\nexport * from './vad.js';\nexport * from './version.js';\nexport * from './worker.js';\n\nexport { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };\n"],"mappings":"AAWA,YAAY,SAAS;AACrB,YAAY,eAAe;AAC3B,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,SAAS;AACrB,YAAY,eAAe;AAC3B,YAAY,cAAc;AAC1B,YAAY,SAAS;AACrB,YAAY,WAAW;AAEvB,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * LiveKit Agents is a framework for building realtime programmable participants that run on\n * servers.\n *\n * @see {@link https://docs.livekit.io/agents/overview | LiveKit Agents documentation}\n * @packageDocumentation\n */\nimport * as cli from './cli.js';\nimport * as inference from './inference/index.js';\nimport * as ipc from './ipc/index.js';\nimport * as llm from './llm/index.js';\nimport * as metrics from './metrics/index.js';\nimport * as stream from './stream/index.js';\nimport * as stt from './stt/index.js';\nimport * as telemetry from './telemetry/index.js';\nimport * as tokenize from './tokenize/index.js';\nimport * as tts from './tts/index.js';\nimport * as voice from './voice/index.js';\n\nexport * from './_exceptions.js';\nexport * from './audio.js';\nexport * from './connection_pool.js';\nexport * from './generator.js';\nexport * from './inference_runner.js';\nexport * from './job.js';\nexport * from './log.js';\nexport * from './plugin.js';\nexport * from './transcription.js';\nexport * from './types.js';\nexport * from './utils.js';\nexport * from './vad.js';\nexport * from './version.js';\nexport { createTimedString, isTimedString, type TimedString } from './voice/io.js';\nexport * from './worker.js';\n\nexport { cli, inference, ipc, llm, metrics, stream, stt, telemetry, tokenize, tts, voice };\n"],"mappings":"AAWA,YAAY,SAAS;AACrB,YAAY,eAAe;AAC3B,YAAY,SAAS;AACrB,YAAY,SAAS;AACrB,YAAY,aAAa;AACzB,YAAY,YAAY;AACxB,YAAY,SAAS;AACrB,YAAY,eAAe;AAC3B,YAAY,cAAc;AAC1B,YAAY,SAAS;AACrB,YAAY,WAAW;AAEvB,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,mBAAmB,qBAAuC;AACnE,cAAc;","names":[]}
@@ -30,6 +30,7 @@ var import_stream_channel = require("../stream/stream_channel.cjs");
30
30
  var import_stt = require("../stt/index.cjs");
31
31
  var import_types = require("../types.cjs");
32
32
  var import_utils = require("../utils.cjs");
33
+ var import_io = require("../voice/io.cjs");
33
34
  var import_api_protos = require("./api_protos.cjs");
34
35
  var import_utils2 = require("./utils.cjs");
35
36
  const DEFAULT_ENCODING = "pcm_s16le";
@@ -328,7 +329,7 @@ class SpeechStream extends import_stt.SpeechStream {
328
329
  confidence: data.confidence,
329
330
  text,
330
331
  words: data.words.map(
331
- (word) => ({
332
+ (word) => (0, import_io.createTimedString)({
332
333
  text: word.word,
333
334
  startTime: word.start + this.startTimeOffset,
334
335
  endTime: word.end + this.startTimeOffset,